summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNoel Grandin <noel@peralex.com>2016-02-11 09:26:19 +0200
committerNoel Grandin <noel@peralex.com>2016-02-11 10:01:46 +0200
commit401b7468bdaae0626d1179bc1c98c2882cc38d1d (patch)
tree0875651631ff05a82b083c13d43f94bd61517348
parent6b00d851672ecdde1833cf3ce3d90e34480af5e5 (diff)
create a new class SvIdlParser
and start the process of moving the parsing code to one central file Change-Id: If6d8def37ec8c8415c22d39f9d8b7a09ec423873
-rw-r--r--idl/Executable_svidl.mk1
-rw-r--r--idl/inc/database.hxx3
-rw-r--r--idl/inc/parser.hxx37
-rw-r--r--idl/source/prj/command.cxx4
-rw-r--r--idl/source/prj/database.cxx62
-rw-r--r--idl/source/prj/parser.cxx90
6 files changed, 132 insertions, 65 deletions
diff --git a/idl/Executable_svidl.mk b/idl/Executable_svidl.mk
index b2b3ecd960c2..090bdd675517 100644
--- a/idl/Executable_svidl.mk
+++ b/idl/Executable_svidl.mk
@@ -47,6 +47,7 @@ $(eval $(call gb_Executable_add_exception_objects,svidl,\
idl/source/prj/database \
idl/source/prj/globals \
idl/source/prj/svidl \
+ idl/source/prj/parser \
))
# vim: set noet sw=4 ts=4:
diff --git a/idl/inc/database.hxx b/idl/inc/database.hxx
index c435aaf85bda..3b7f15f02534 100644
--- a/idl/inc/database.hxx
+++ b/idl/inc/database.hxx
@@ -102,6 +102,7 @@ public:
{ aError = r; }
const OUString & GetPath() const { return aPath; }
+ void SetPath(const OUString &s) { aPath = s; }
SvRefMemberList<SvMetaObject *>& GetStack() { return aContextStack; }
void Write(const OString& rText);
@@ -135,8 +136,6 @@ class SvIdlWorkingBase : public SvIdlDataBase
public:
explicit SvIdlWorkingBase( const SvCommand& rCmd );
- bool ReadSvIdl( SvTokenStream &, bool bImported, const OUString & rPath );
-
bool WriteSfx( SvStream & );
};
diff --git a/idl/inc/parser.hxx b/idl/inc/parser.hxx
new file mode 100644
index 000000000000..c06287b7a9e4
--- /dev/null
+++ b/idl/inc/parser.hxx
@@ -0,0 +1,37 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#ifndef INCLUDED_IDL_INC_PARSER_HXX
+#define INCLUDED_IDL_INC_PARSER_HXX
+
+#include <rtl/ustring.hxx>
+
+class SvTokenStream;
+class SvIdlDataBase;
+
+class SvIdlParser
+{
+public:
+ bool ReadSvIdl( SvIdlDataBase& rBase, SvTokenStream &, bool bImported, const OUString & rPath );
+
+};
+
+#endif // INCLUDED_IDL_INC_PARSER_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/idl/source/prj/command.cxx b/idl/source/prj/command.cxx
index 4db8ca592d27..2967e054850c 100644
--- a/idl/source/prj/command.cxx
+++ b/idl/source/prj/command.cxx
@@ -29,6 +29,7 @@
#include <command.hxx>
#include <globals.hxx>
#include <database.hxx>
+#include <parser.hxx>
char const * SyntaxStrings[] = {
"basic-type:",
@@ -126,7 +127,8 @@ bool ReadIdl( SvIdlWorkingBase * pDataBase, const SvCommand & rCommand )
if( aStm.GetError() == SVSTREAM_OK )
{
SvTokenStream aTokStm( aStm, aFileName );
- if( !pDataBase->ReadSvIdl( aTokStm, false, rCommand.aPath ) )
+ SvIdlParser aParser;
+ if( !aParser.ReadSvIdl( *pDataBase, aTokStm, false, rCommand.aPath ) )
return false;
}
else
diff --git a/idl/source/prj/database.cxx b/idl/source/prj/database.cxx
index b6539fcd197a..0a153515c65f 100644
--- a/idl/source/prj/database.cxx
+++ b/idl/source/prj/database.cxx
@@ -478,68 +478,6 @@ SvIdlWorkingBase::SvIdlWorkingBase(const SvCommand& rCmd) : SvIdlDataBase(rCmd)
{
}
-bool SvIdlWorkingBase::ReadSvIdl( SvTokenStream & rInStm, bool bImported, const OUString & rPath )
-{
- aPath = rPath; // only valid for this iteration
- bool bOk = true;
- SvToken * pTok = &rInStm.GetToken();
- // only one import at the very beginning
- if( pTok->Is( SvHash_import() ) )
- {
- rInStm.GetToken_Next();
- pTok = rInStm.GetToken_Next();
- if( pTok && pTok->IsString() )
- {
- OUString aFullName;
- if( osl::FileBase::E_None == osl::File::searchFileURL(
- OStringToOUString(pTok->GetString(), RTL_TEXTENCODING_ASCII_US),
- rPath,
- aFullName) )
- {
- osl::FileBase::getSystemPathFromFileURL( aFullName, aFullName );
- this->AddDepFile(aFullName);
- SvFileStream aStm( aFullName, STREAM_STD_READ | StreamMode::NOCREATE );
- SvTokenStream aTokStm( aStm, aFullName );
- bOk = ReadSvIdl( aTokStm, true, rPath );
- }
- else
- bOk = false;
- }
- else
- bOk = false;
- }
-
- sal_uInt32 nBeginPos = 0xFFFFFFFF; // can not happen with Tell
-
- while( bOk && nBeginPos != rInStm.Tell() )
- {
- nBeginPos = rInStm.Tell();
- pTok = &rInStm.GetToken();
- if( pTok->IsEof() )
- return true;
- if( pTok->IsEmpty() )
- bOk = false;
-
- // only one import at the very beginning
- if( pTok->Is( SvHash_module() ) )
- {
- tools::SvRef<SvMetaModule> aModule = new SvMetaModule( bImported );
- if( aModule->ReadSvIdl( *this, rInStm ) )
- GetModuleList().push_back( aModule );
- else
- bOk = false;
- }
- else
- bOk = false;
- }
- if( !bOk || !pTok->IsEof() )
- {
- // error treatment
- WriteError( rInStm );
- return false;
- }
- return true;
-}
bool SvIdlWorkingBase::WriteSfx( SvStream & rOutStm )
{
diff --git a/idl/source/prj/parser.cxx b/idl/source/prj/parser.cxx
new file mode 100644
index 000000000000..4bb0320b0f36
--- /dev/null
+++ b/idl/source/prj/parser.cxx
@@ -0,0 +1,90 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#include <sal/config.h>
+
+#include <parser.hxx>
+#include <database.hxx>
+#include <globals.hxx>
+#include <osl/file.hxx>
+
+bool SvIdlParser::ReadSvIdl( SvIdlDataBase& rBase, SvTokenStream & rInStm, bool bImported, const OUString & rPath )
+{
+ rBase.SetPath(rPath); // only valid for this iteration
+ bool bOk = true;
+ SvToken * pTok = &rInStm.GetToken();
+ // only one import at the very beginning
+ if( pTok->Is( SvHash_import() ) )
+ {
+ rInStm.GetToken_Next();
+ pTok = rInStm.GetToken_Next();
+ if( pTok && pTok->IsString() )
+ {
+ OUString aFullName;
+ if( osl::FileBase::E_None == osl::File::searchFileURL(
+ OStringToOUString(pTok->GetString(), RTL_TEXTENCODING_ASCII_US),
+ rPath,
+ aFullName) )
+ {
+ osl::FileBase::getSystemPathFromFileURL( aFullName, aFullName );
+ rBase.AddDepFile(aFullName);
+ SvFileStream aStm( aFullName, STREAM_STD_READ | StreamMode::NOCREATE );
+ SvTokenStream aTokStm( aStm, aFullName );
+ bOk = ReadSvIdl( rBase, aTokStm, true, rPath );
+ }
+ else
+ bOk = false;
+ }
+ else
+ bOk = false;
+ }
+
+ sal_uInt32 nBeginPos = 0xFFFFFFFF; // can not happen with Tell
+
+ while( bOk && nBeginPos != rInStm.Tell() )
+ {
+ nBeginPos = rInStm.Tell();
+ pTok = &rInStm.GetToken();
+ if( pTok->IsEof() )
+ return true;
+ if( pTok->IsEmpty() )
+ bOk = false;
+
+ // only one import at the very beginning
+ if( pTok->Is( SvHash_module() ) )
+ {
+ tools::SvRef<SvMetaModule> aModule = new SvMetaModule( bImported );
+ if( aModule->ReadSvIdl( rBase, rInStm ) )
+ rBase.GetModuleList().push_back( aModule );
+ else
+ bOk = false;
+ }
+ else
+ bOk = false;
+ }
+ if( !bOk || !pTok->IsEof() )
+ {
+ // error treatment
+ rBase.WriteError( rInStm );
+ return false;
+ }
+ return true;
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */