summaryrefslogtreecommitdiffstats
path: root/idlc/inc
diff options
context:
space:
mode:
Diffstat (limited to 'idlc/inc')
-rw-r--r--idlc/inc/astattribute.hxx107
-rw-r--r--idlc/inc/astbasetype.hxx50
-rw-r--r--idlc/inc/astconstant.hxx50
-rw-r--r--idlc/inc/astconstants.hxx35
-rw-r--r--idlc/inc/astdeclaration.hxx136
-rw-r--r--idlc/inc/astenum.hxx45
-rw-r--r--idlc/inc/astexception.hxx35
-rw-r--r--idlc/inc/astexpression.hxx139
-rw-r--r--idlc/inc/astinterface.hxx129
-rw-r--r--idlc/inc/astinterfacemember.hxx45
-rw-r--r--idlc/inc/astmember.hxx48
-rw-r--r--idlc/inc/astmodule.hxx44
-rw-r--r--idlc/inc/astneeds.hxx41
-rw-r--r--idlc/inc/astobserves.hxx41
-rw-r--r--idlc/inc/astoperation.hxx54
-rw-r--r--idlc/inc/astparameter.hxx46
-rw-r--r--idlc/inc/astscope.hxx73
-rw-r--r--idlc/inc/astsequence.hxx49
-rw-r--r--idlc/inc/astservice.hxx61
-rw-r--r--idlc/inc/astservicemember.hxx45
-rw-r--r--idlc/inc/aststack.hxx46
-rw-r--r--idlc/inc/aststruct.hxx62
-rw-r--r--idlc/inc/aststructinstance.hxx49
-rw-r--r--idlc/inc/asttype.hxx37
-rw-r--r--idlc/inc/asttypedef.hxx44
-rw-r--r--idlc/inc/errorhandler.hxx118
-rw-r--r--idlc/inc/fehelper.hxx70
-rw-r--r--idlc/inc/idlc.hxx164
-rw-r--r--idlc/inc/idlctypes.hxx189
-rw-r--r--idlc/inc/inheritedinterface.hxx56
-rw-r--r--idlc/inc/options.hxx76
31 files changed, 2184 insertions, 0 deletions
diff --git a/idlc/inc/astattribute.hxx b/idlc/inc/astattribute.hxx
new file mode 100644
index 000000000..b9a799f92
--- /dev/null
+++ b/idlc/inc/astattribute.hxx
@@ -0,0 +1,107 @@
+/* -*- 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_IDLC_INC_ASTATTRIBUTE_HXX
+#define INCLUDED_IDLC_INC_ASTATTRIBUTE_HXX
+
+#include "astdeclaration.hxx"
+#include "astscope.hxx"
+
+#include <registry/types.hxx>
+#include <rtl/ustring.hxx>
+
+namespace typereg { class Writer; }
+
+class AstAttribute final : public AstDeclaration, public AstScope {
+public:
+ AstAttribute(
+ sal_uInt32 flags, AstType const * type, OString const & name,
+ AstScope * scope):
+ AstDeclaration(NT_attribute, name, scope),
+ AstScope(NT_attribute), m_flags(flags), m_pType(type)
+ {}
+
+ AstAttribute(NodeType nodeType, sal_uInt32 flags, AstType const * pType, const OString& name, AstScope* pScope)
+ : AstDeclaration(nodeType, name, pScope), AstScope(nodeType)
+ , m_flags(flags)
+ , m_pType(pType)
+ {}
+
+ void setExceptions(
+ OUString const * getDoc, DeclList const * getExc,
+ OUString const * setDoc, DeclList const * setExc)
+ {
+ if (getDoc != nullptr) {
+ m_getDocumentation = *getDoc;
+ }
+ if (getExc != nullptr) {
+ m_getExceptions = *getExc;
+ }
+ if (setDoc != nullptr) {
+ m_setDocumentation = *setDoc;
+ }
+ if (setExc != nullptr) {
+ m_setExceptions = *setExc;
+ }
+ }
+
+ DeclList::size_type getGetExceptionCount() const
+ { return m_getExceptions.size(); }
+
+ DeclList::size_type getSetExceptionCount() const
+ { return m_setExceptions.size(); }
+
+ bool isReadonly() const
+ { return ((m_flags & AF_READONLY) == AF_READONLY); }
+ bool isOptional() const
+ { return ((m_flags & AF_OPTIONAL) == AF_OPTIONAL); }
+ bool isBound() const
+ { return ((m_flags & AF_BOUND) == AF_BOUND); }
+ bool isMayBeVoid() const
+ { return ((m_flags & AF_MAYBEVOID) == AF_MAYBEVOID); }
+ bool isConstrained() const
+ { return ((m_flags & AF_CONSTRAINED) == AF_CONSTRAINED); }
+ bool isTransient() const
+ { return ((m_flags & AF_TRANSIENT) == AF_TRANSIENT); }
+ bool isMayBeAmbiguous() const
+ { return ((m_flags & AF_MAYBEAMBIGUOUS) == AF_MAYBEAMBIGUOUS); }
+ bool isMayBeDefault() const
+ { return ((m_flags & AF_MAYBEDEFAULT) == AF_MAYBEDEFAULT); }
+ bool isRemoveable() const
+ { return ((m_flags & AF_REMOVABLE) == AF_REMOVABLE); }
+
+ void dumpBlob(
+ typereg::Writer & rBlob, sal_uInt16 index, sal_uInt16 * methodIndex) const;
+
+private:
+ void dumpExceptions(
+ typereg::Writer & writer, OUString const & documentation,
+ DeclList const & exceptions, RTMethodMode flags,
+ sal_uInt16 * methodIndex) const;
+
+ const sal_uInt32 m_flags;
+ AstType const * m_pType;
+ OUString m_getDocumentation;
+ DeclList m_getExceptions;
+ OUString m_setDocumentation;
+ DeclList m_setExceptions;
+};
+
+#endif // INCLUDED_IDLC_INC_ASTATTRIBUTE_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/idlc/inc/astbasetype.hxx b/idlc/inc/astbasetype.hxx
new file mode 100644
index 000000000..0b488c800
--- /dev/null
+++ b/idlc/inc/astbasetype.hxx
@@ -0,0 +1,50 @@
+/* -*- 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 .
+ */
+#pragma once
+
+#include "asttype.hxx"
+#include "astexpression.hxx"
+
+
+class AstBaseType final : public AstType
+{
+public:
+ AstBaseType(const ExprType type, const OString& name, AstScope* pScope)
+ : AstType(NT_predefined, name, pScope)
+ , m_exprType(type)
+ {}
+
+ virtual bool isUnsigned() const override {
+ switch (m_exprType) {
+ case ET_ushort:
+ case ET_ulong:
+ case ET_uhyper:
+ return true;
+ default:
+ return false;
+ }
+ }
+
+ ExprType getExprType() const
+ { return m_exprType; }
+private:
+ const ExprType m_exprType;
+};
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/idlc/inc/astconstant.hxx b/idlc/inc/astconstant.hxx
new file mode 100644
index 000000000..fb8b417f4
--- /dev/null
+++ b/idlc/inc/astconstant.hxx
@@ -0,0 +1,50 @@
+/* -*- 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_IDLC_INC_ASTCONSTANT_HXX
+#define INCLUDED_IDLC_INC_ASTCONSTANT_HXX
+
+#include "astdeclaration.hxx"
+#include "astexpression.hxx"
+
+namespace typereg { class Writer; }
+
+class AstConstant final : public AstDeclaration
+{
+public:
+ AstConstant(const ExprType type, const NodeType nodeType,
+ AstExpression* pExpr, const OString& name, AstScope* pScope);
+ AstConstant(const ExprType type, AstExpression* pExpr,
+ const OString& name, AstScope* pScope);
+ virtual ~AstConstant() override;
+
+ AstExpression* getConstValue()
+ { return m_pConstValue; }
+ ExprType getConstValueType() const
+ { return m_constValueType; }
+
+ bool dumpBlob(
+ typereg::Writer & rBlob, sal_uInt16 index, bool published);
+private:
+ AstExpression* m_pConstValue;
+ const ExprType m_constValueType;
+};
+
+#endif // INCLUDED_IDLC_INC_ASTCONSTANT_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/idlc/inc/astconstants.hxx b/idlc/inc/astconstants.hxx
new file mode 100644
index 000000000..6add23a45
--- /dev/null
+++ b/idlc/inc/astconstants.hxx
@@ -0,0 +1,35 @@
+/* -*- 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_IDLC_INC_ASTCONSTANTS_HXX
+#define INCLUDED_IDLC_INC_ASTCONSTANTS_HXX
+
+#include "astmodule.hxx"
+
+class AstConstants final : public AstModule
+{
+public:
+ AstConstants(const OString& name, AstScope* pScope)
+ : AstModule(NT_constants, name, pScope)
+ {
+ }
+};
+
+#endif // INCLUDED_IDLC_INC_ASTCONSTANTS_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/idlc/inc/astdeclaration.hxx b/idlc/inc/astdeclaration.hxx
new file mode 100644
index 000000000..0707dbc57
--- /dev/null
+++ b/idlc/inc/astdeclaration.hxx
@@ -0,0 +1,136 @@
+/* -*- 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_IDLC_INC_ASTDECLARATION_HXX
+#define INCLUDED_IDLC_INC_ASTDECLARATION_HXX
+
+#include "idlc.hxx"
+#include <registry/registry.hxx>
+
+class AstScope;
+
+// Enum defining the different kinds of Ast nodes
+enum NodeType
+{
+ NT_service, // Denotes a service
+ NT_interface_member, // Denotes an interface which is exported from object
+ NT_service_member, // Denotes a service which is exported from object
+ NT_observes, // Denotes an observed interface
+ NT_needs, // Denotes a needed service
+ NT_module, // Denotes a module
+ NT_root, // Denotes the root of AST
+ NT_interface, // Denotes an interface
+ NT_constants, // Denotes a constant group
+ NT_const, // Denotes a constant
+ NT_exception, // Denotes an exception
+ NT_attribute, // Denotes an attribute
+ NT_property, // Denotes a property
+ NT_operation, // Denotes an operation
+ NT_parameter, // Denotes an op. parameter
+ NT_struct, // Denotes either a plain struct type, or a
+ // polymorphic struct type template
+ NT_type_parameter, // Denotes a type parameter of a polymorphic struct
+ // type template
+ NT_instantiated_struct, // Denotes an instantiated polymorphic struct type
+ NT_member, // Denotes a member in structure, exception
+ NT_enum, // Denotes an enumeration
+ NT_enum_val, // Denotes an enum. value
+ NT_sequence, // Denotes an IDL sequence
+ NT_typedef, // Denotes a typedef
+ NT_predefined, // Denotes a predefined type
+ NT_singleton // Denotes a singleton
+};
+
+class AstDeclaration
+{
+public:
+ // Constructors
+ AstDeclaration(NodeType type, const OString& name, AstScope* pScope);
+ virtual ~AstDeclaration();
+
+ AstDeclaration(AstDeclaration const &) = default;
+ AstDeclaration(AstDeclaration &&) = default;
+ AstDeclaration & operator =(AstDeclaration const &) = default;
+ AstDeclaration & operator =(AstDeclaration &&) = default;
+
+ // Data access
+ const OString& getLocalName() const
+ { return m_localName; }
+ const OString& getScopedName() const
+ { return m_scopedName; }
+ const OString& getFullName() const
+ { return m_fullName; }
+ virtual const char* getRelativName() const
+ { return m_fullName.getStr()+1; }
+ AstScope* getScope()
+ { return m_pScope; }
+ const AstScope* getScope() const
+ { return m_pScope; }
+ NodeType getNodeType() const
+ { return m_nodeType; }
+ bool isInMainfile() const
+ { return m_bInMainFile; }
+ void setInMainfile(bool bInMainfile)
+ { m_bInMainFile = bInMainfile; }
+ bool isImported() const
+ { return m_bImported; }
+ void setImported(bool bImported)
+ { m_bImported = bImported; }
+ sal_Int32 getLineNumber() const
+ { return m_lineNumber; }
+ void setLineNumber(sal_Int32 lineNumber)
+ { m_lineNumber = lineNumber; }
+ const OString& getFileName() const
+ { return m_fileName; }
+ void setFileName(const OString& rFileName)
+ { m_fileName = rFileName; }
+ const OUString& getDocumentation() const
+ { return m_documentation; }
+ void setDocumentation(const OUString& rDocumentation)
+ { m_documentation = rDocumentation; }
+
+ virtual bool isType() const;
+
+ bool hasAncestor(AstDeclaration* pDecl);
+
+ void setPublished() { m_bPublished = true; }
+ bool isPublished() const { return m_bPublished; }
+
+ virtual bool dump(RegistryKey& rKey);
+
+ bool isPredefined() const { return m_bPredefined; }
+ void setPredefined(bool bPredefined);
+
+protected:
+ OString m_localName;
+ OString m_scopedName; // full qualified name
+ OString m_fullName; // full qualified name with '/' as separator
+ AstScope* m_pScope;
+ NodeType m_nodeType;
+ bool m_bImported; // imported ?
+ bool m_bInMainFile; // defined in main file
+ bool m_bPublished;
+ bool m_bPredefined;
+ sal_Int32 m_lineNumber; // line number defined in
+ OString m_fileName; // fileName defined in
+ OUString m_documentation; // fileName defined in
+};
+
+#endif // INCLUDED_IDLC_INC_ASTDECLARATION_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/idlc/inc/astenum.hxx b/idlc/inc/astenum.hxx
new file mode 100644
index 000000000..dc89d430a
--- /dev/null
+++ b/idlc/inc/astenum.hxx
@@ -0,0 +1,45 @@
+/* -*- 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_IDLC_INC_ASTENUM_HXX
+#define INCLUDED_IDLC_INC_ASTENUM_HXX
+
+#include "asttype.hxx"
+#include "astscope.hxx"
+#include "astconstant.hxx"
+
+class AstEnum final : public AstType, public AstScope
+{
+public:
+ AstEnum(const OString& name, AstScope* pScope);
+
+ virtual ~AstEnum() override;
+
+ sal_Int32 getEnumValueCount() { return m_enumValueCount++; }
+
+ AstConstant* checkValue(AstExpression* pExpr);
+
+ virtual bool dump(RegistryKey& rKey) override;
+
+private:
+ sal_Int32 m_enumValueCount;
+};
+
+#endif // INCLUDED_IDLC_INC_ASTENUM_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/idlc/inc/astexception.hxx b/idlc/inc/astexception.hxx
new file mode 100644
index 000000000..6c2d549bc
--- /dev/null
+++ b/idlc/inc/astexception.hxx
@@ -0,0 +1,35 @@
+/* -*- 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_IDLC_INC_ASTEXCEPTION_HXX
+#define INCLUDED_IDLC_INC_ASTEXCEPTION_HXX
+
+#include "aststruct.hxx"
+
+class AstException final : public AstStruct
+{
+public:
+ AstException(const OString& name, AstException const* pBaseType, AstScope* pScope)
+ : AstStruct(NT_exception, name, pBaseType, pScope)
+ {
+ }
+};
+
+#endif // INCLUDED_IDLC_INC_ASTEXCEPTION_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/idlc/inc/astexpression.hxx b/idlc/inc/astexpression.hxx
new file mode 100644
index 000000000..05d20baa5
--- /dev/null
+++ b/idlc/inc/astexpression.hxx
@@ -0,0 +1,139 @@
+/* -*- 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_IDLC_INC_ASTEXPRESSION_HXX
+#define INCLUDED_IDLC_INC_ASTEXPRESSION_HXX
+
+#include <sal/config.h>
+
+#include <memory>
+
+#include "idlc.hxx"
+#include <optional>
+
+// Enum to define all the different operators to combine expressions
+enum class ExprComb
+{
+ Add, // '+'
+ Minus, // '-'
+ Mul, // '*'
+ Div, // '/'
+ Mod, // '%'
+ Or, // '|'
+ Xor, // '^'
+ And, // '&'
+ Left, // '<<'
+ Right, // '>>'
+ UPlus, // unary '+'
+ UMinus, // unary '-'
+ NONE, // No operator (missing)
+ Symbol // a symbol (function or constant name)
+};
+
+// Enum to define expression type
+enum ExprType
+{
+ ET_short, // Expression value is short
+ ET_ushort, // Expression value is unsigned short
+ ET_long, // Expression value is long
+ ET_ulong, // Expression value is unsigned long
+ ET_hyper, // Expression value is hyper (64 bit)
+ ET_uhyper, // Expression value is unsigned hyper
+ ET_float, // Expression value is 32-bit float
+ ET_double, // Expression value is 64-bit float
+ ET_char, // Expression value is char
+ ET_byte, // Expression value is byte
+ ET_boolean, // Expression value is boolean
+ ET_string, // Expression value is char *
+ ET_any, // Expression value is any of above
+ ET_void, // Expression value is void (absent)
+ ET_type, // Expression value is type
+ ET_none // Expression value is missing
+};
+
+// Structure to describe value of constant expression and its type
+struct AstExprValue
+{
+ union
+ {
+ sal_uInt8 byval; // Contains byte expression value
+ sal_Int16 sval; // Contains short expression value
+ sal_uInt16 usval; // Contains unsigned short expr value
+ sal_Int32 lval; // Contains long expression value
+ sal_uInt32 ulval; // Contains unsigned long expr value
+ sal_Int64 hval; // Contains hyper expression value
+ sal_uInt64 uhval; // Contains unsigned hyper expr value
+ bool bval; // Contains boolean expression value
+ float fval; // Contains 32-bit float expr value
+ double dval; // Contains 64-bit float expr value
+ } u;
+ ExprType et;
+};
+
+const char* exprTypeToString(ExprType t);
+
+class AstExpression final
+{
+public:
+ // Constructor(s)
+ AstExpression(ExprComb c, AstExpression *pExpr1, AstExpression *pExpr2);
+
+ AstExpression(sal_Int32 l);
+ AstExpression(sal_Int32 l, ExprType et);
+ AstExpression(sal_Int64 h);
+ AstExpression(sal_uInt64 uh);
+ AstExpression(double d);
+ AstExpression(OString* scopedName);
+
+ ~AstExpression();
+
+ // Data Accessors
+ AstExprValue* getExprValue()
+ { return m_exprValue.get(); }
+
+ // Evaluation and value coercion
+ bool coerce(ExprType type);
+
+ // Evaluate then store value inside this AstExpression
+ void evaluate();
+
+ // Compare LONG AstExpression values
+ bool compareLong(AstExpression *pExpr);
+
+ OString toString();
+private:
+ // Evaluate different sets of operators
+ std::unique_ptr<AstExprValue> eval_bin_op();
+ std::unique_ptr<AstExprValue> eval_bit_op();
+ std::unique_ptr<AstExprValue> eval_un_op();
+ std::unique_ptr<AstExprValue> eval_symbol();
+
+ ExprComb m_combOperator;
+ std::unique_ptr<AstExpression>
+ m_subExpr1;
+ std::unique_ptr<AstExpression>
+ m_subExpr2;
+ std::unique_ptr<AstExprValue>
+ m_exprValue;
+ std::optional<OString>
+ m_xSymbolicName;
+};
+
+#endif // INCLUDED_IDLC_INC_ASTEXPRESSION_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/idlc/inc/astinterface.hxx b/idlc/inc/astinterface.hxx
new file mode 100644
index 000000000..03c5f22f5
--- /dev/null
+++ b/idlc/inc/astinterface.hxx
@@ -0,0 +1,129 @@
+/* -*- 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_IDLC_INC_ASTINTERFACE_HXX
+#define INCLUDED_IDLC_INC_ASTINTERFACE_HXX
+
+#include "asttype.hxx"
+#include "astscope.hxx"
+#include "inheritedinterface.hxx"
+
+#include <map>
+#include <vector>
+
+class AstInterface : public AstType
+ , public AstScope
+{
+public:
+ typedef std::vector< InheritedInterface > InheritedInterfaces;
+
+ struct DoubleMemberDeclaration {
+ AstDeclaration const * first;
+ AstDeclaration const * second;
+ };
+
+ typedef std::vector< DoubleMemberDeclaration > DoubleMemberDeclarations;
+
+ struct DoubleDeclarations {
+ std::vector< AstInterface const * > interfaces;
+ DoubleMemberDeclarations members;
+ };
+
+ AstInterface(
+ const OString& name, AstInterface const * pInherits,
+ AstScope* pScope);
+ virtual ~AstInterface() override;
+
+ AstInterface(AstInterface const &) = default;
+ AstInterface(AstInterface &&) = default;
+ AstInterface & operator =(AstInterface const &) = default;
+ AstInterface & operator =(AstInterface &&) = default;
+
+ InheritedInterfaces const & getAllInheritedInterfaces() const
+ { return m_inheritedInterfaces; }
+
+ bool hasMandatoryInheritedInterfaces() const
+ { return m_mandatoryInterfaces > 0; }
+
+ void setDefined() { m_bIsDefined = true; }
+ bool isDefined() const
+ { return m_bIsDefined; }
+
+ bool usesSingleInheritance() const { return m_bSingleInheritance; }
+
+ DoubleDeclarations checkInheritedInterfaceClashes(
+ AstInterface const * ifc, bool optional) const;
+
+ void addInheritedInterface(
+ AstType const * ifc, bool optional,
+ OUString const & documentation);
+
+ DoubleMemberDeclarations checkMemberClashes(
+ AstDeclaration const * member) const;
+
+ void addMember(AstDeclaration /*TODO: const*/ * member);
+
+ void forwardDefined(AstInterface const & def);
+
+ virtual bool dump(RegistryKey& rKey) override;
+
+private:
+ enum InterfaceKind {
+ INTERFACE_INDIRECT_OPTIONAL, INTERFACE_DIRECT_OPTIONAL,
+ INTERFACE_INDIRECT_MANDATORY, INTERFACE_DIRECT_MANDATORY };
+
+ struct VisibleMember {
+ explicit VisibleMember(AstDeclaration const * theMandatory = nullptr):
+ mandatory(theMandatory) {}
+
+ typedef std::map< OString, AstDeclaration const * > Optionals;
+
+ AstDeclaration const * mandatory;
+ Optionals optionals;
+ };
+
+ typedef std::map< OString, InterfaceKind > VisibleInterfaces;
+ typedef std::map< OString, VisibleMember > VisibleMembers;
+
+ void checkInheritedInterfaceClashes(
+ DoubleDeclarations & doubleDeclarations,
+ std::set< OString > & seenInterfaces, AstInterface const * ifc,
+ bool direct, bool optional, bool mainOptional) const;
+
+ void checkMemberClashes(
+ DoubleMemberDeclarations & doubleMembers, AstDeclaration const * member,
+ bool checkOptional) const;
+
+ void addVisibleInterface(
+ AstInterface const * ifc, bool direct, bool optional);
+
+ void addOptionalVisibleMembers(AstInterface const * ifc);
+
+ bool increment(sal_uInt16 * counter, char const * sort) const;
+
+ InheritedInterfaces m_inheritedInterfaces;
+ InheritedInterfaces::size_type m_mandatoryInterfaces;
+ bool m_bIsDefined;
+ bool m_bSingleInheritance;
+ VisibleInterfaces m_visibleInterfaces;
+ VisibleMembers m_visibleMembers;
+};
+
+#endif // INCLUDED_IDLC_INC_ASTINTERFACE_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/idlc/inc/astinterfacemember.hxx b/idlc/inc/astinterfacemember.hxx
new file mode 100644
index 000000000..0e290e187
--- /dev/null
+++ b/idlc/inc/astinterfacemember.hxx
@@ -0,0 +1,45 @@
+/* -*- 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_IDLC_INC_ASTINTERFACEMEMBER_HXX
+#define INCLUDED_IDLC_INC_ASTINTERFACEMEMBER_HXX
+
+#include "astinterface.hxx"
+
+class AstInterfaceMember final : public AstDeclaration
+{
+public:
+ AstInterfaceMember(const sal_uInt32 flags, AstInterface* pRealInterface,
+ const OString& name, AstScope* pScope)
+ : AstDeclaration(NT_interface_member, name, pScope)
+ , m_flags(flags)
+ , m_pRealInterface(pRealInterface)
+ {}
+
+ AstInterface* getRealInterface()
+ { return m_pRealInterface; }
+ bool isOptional() const
+ { return ((m_flags & AF_OPTIONAL) == AF_OPTIONAL); }
+private:
+ const sal_uInt32 m_flags;
+ AstInterface* m_pRealInterface;
+};
+
+#endif // INCLUDED_IDLC_INC_ASTINTERFACEMEMBER_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/idlc/inc/astmember.hxx b/idlc/inc/astmember.hxx
new file mode 100644
index 000000000..43597d125
--- /dev/null
+++ b/idlc/inc/astmember.hxx
@@ -0,0 +1,48 @@
+/* -*- 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_IDLC_INC_ASTMEMBER_HXX
+#define INCLUDED_IDLC_INC_ASTMEMBER_HXX
+
+#include "astdeclaration.hxx"
+
+class AstScope;
+class AstType;
+
+class AstMember: public AstDeclaration {
+public:
+ AstMember(
+ AstType const * pType, OString const & name, AstScope * pScope):
+ AstDeclaration(NT_member, name, pScope), m_pType(pType) {}
+
+ AstType const * getType() const { return m_pType; }
+
+protected:
+ AstMember(
+ NodeType type, AstType const * pType, OString const & name,
+ AstScope * pScope):
+ AstDeclaration(type, name, pScope), m_pType(pType) {}
+
+private:
+ AstType const * m_pType;
+};
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/idlc/inc/astmodule.hxx b/idlc/inc/astmodule.hxx
new file mode 100644
index 000000000..6178cfbb6
--- /dev/null
+++ b/idlc/inc/astmodule.hxx
@@ -0,0 +1,44 @@
+/* -*- 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_IDLC_INC_ASTMODULE_HXX
+#define INCLUDED_IDLC_INC_ASTMODULE_HXX
+
+#include "astdeclaration.hxx"
+#include "astscope.hxx"
+
+class AstModule : public AstDeclaration, public AstScope
+{
+public:
+ AstModule(const OString& name, AstScope* pScope)
+ : AstDeclaration(NT_module, name, pScope)
+ , AstScope(NT_module)
+ {
+ }
+ AstModule(NodeType type, const OString& name, AstScope* pScope)
+ : AstDeclaration(type, name, pScope)
+ , AstScope(type)
+ {
+ }
+
+ virtual bool dump(RegistryKey& rKey) override;
+};
+
+#endif // INCLUDED_IDLC_INC_ASTMODULE_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/idlc/inc/astneeds.hxx b/idlc/inc/astneeds.hxx
new file mode 100644
index 000000000..13d2dbbef
--- /dev/null
+++ b/idlc/inc/astneeds.hxx
@@ -0,0 +1,41 @@
+/* -*- 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_IDLC_INC_ASTNEEDS_HXX
+#define INCLUDED_IDLC_INC_ASTNEEDS_HXX
+
+#include "astservice.hxx"
+
+class AstNeeds final : public AstDeclaration
+{
+public:
+ AstNeeds(AstService* pRealService, const OString& name, AstScope* pScope)
+ : AstDeclaration(NT_needs, name, pScope)
+ , m_pRealService(pRealService)
+ {
+ }
+
+ AstService* getRealService() { return m_pRealService; }
+
+private:
+ AstService* m_pRealService;
+};
+
+#endif // INCLUDED_IDLC_INC_ASTNEEDS_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/idlc/inc/astobserves.hxx b/idlc/inc/astobserves.hxx
new file mode 100644
index 000000000..11bb5a677
--- /dev/null
+++ b/idlc/inc/astobserves.hxx
@@ -0,0 +1,41 @@
+/* -*- 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_IDLC_INC_ASTOBSERVES_HXX
+#define INCLUDED_IDLC_INC_ASTOBSERVES_HXX
+
+#include "astinterface.hxx"
+
+class AstObserves final : public AstDeclaration
+{
+public:
+ AstObserves(AstInterface* pRealInterface, const OString& name, AstScope* pScope)
+ : AstDeclaration(NT_observes, name, pScope)
+ , m_pRealInterface(pRealInterface)
+ {
+ }
+
+ AstInterface* getRealInterface() { return m_pRealInterface; }
+
+private:
+ AstInterface* m_pRealInterface;
+};
+
+#endif // INCLUDED_IDLC_INC_ASTOBSERVES_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/idlc/inc/astoperation.hxx b/idlc/inc/astoperation.hxx
new file mode 100644
index 000000000..e3e0335c9
--- /dev/null
+++ b/idlc/inc/astoperation.hxx
@@ -0,0 +1,54 @@
+/* -*- 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_IDLC_INC_ASTOPERATION_HXX
+#define INCLUDED_IDLC_INC_ASTOPERATION_HXX
+
+#include "astdeclaration.hxx"
+#include "astscope.hxx"
+
+namespace typereg { class Writer; }
+
+class AstType;
+
+class AstOperation final : public AstDeclaration
+ , public AstScope
+{
+public:
+ AstOperation(AstType const * pReturnType, const OString& name, AstScope* pScope)
+ : AstDeclaration(NT_operation, name, pScope)
+ , AstScope(NT_operation)
+ , m_pReturnType(pReturnType)
+ {}
+
+ bool isVariadic() const;
+
+ bool isConstructor() const { return m_pReturnType == nullptr; }
+
+ void setExceptions(DeclList const * pExceptions);
+
+ void dumpBlob(typereg::Writer & rBlob, sal_uInt16 index);
+
+private:
+ AstType const * m_pReturnType;
+ DeclList m_exceptions;
+};
+
+#endif // INCLUDED_IDLC_INC_ASTOPERATION_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/idlc/inc/astparameter.hxx b/idlc/inc/astparameter.hxx
new file mode 100644
index 000000000..cfee34260
--- /dev/null
+++ b/idlc/inc/astparameter.hxx
@@ -0,0 +1,46 @@
+/* -*- 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_IDLC_INC_ASTPARAMETER_HXX
+#define INCLUDED_IDLC_INC_ASTPARAMETER_HXX
+
+#include "astmember.hxx"
+
+enum Direction { DIR_IN, DIR_OUT, DIR_INOUT };
+
+class AstParameter final : public AstMember {
+public:
+ AstParameter(
+ Direction direction, bool rest, AstType const * type,
+ OString const & name, AstScope * scope):
+ AstMember(NT_parameter, type, name, scope), m_direction(direction),
+ m_rest(rest) {}
+
+ Direction getDirection() const { return m_direction; }
+
+ bool isRest() const { return m_rest; }
+
+private:
+ Direction m_direction;
+ bool m_rest;
+};
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/idlc/inc/astscope.hxx b/idlc/inc/astscope.hxx
new file mode 100644
index 000000000..be7b03828
--- /dev/null
+++ b/idlc/inc/astscope.hxx
@@ -0,0 +1,73 @@
+/* -*- 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_IDLC_INC_ASTSCOPE_HXX
+#define INCLUDED_IDLC_INC_ASTSCOPE_HXX
+
+#include <sal/config.h>
+
+#include <string_view>
+#include "idlc.hxx"
+#include "astdeclaration.hxx"
+#include "astexpression.hxx"
+
+class AstExpression;
+
+class AstScope
+{
+public:
+ AstScope(NodeType nodeType);
+ virtual ~AstScope();
+
+ AstScope(AstScope const&) = default;
+ AstScope(AstScope&&) = default;
+ AstScope& operator=(AstScope const&) = default;
+ AstScope& operator=(AstScope&&) = default;
+
+ NodeType getScopeNodeType() const { return m_nodeType; }
+
+ AstDeclaration* addDeclaration(AstDeclaration* pDecl);
+
+ sal_uInt32 nMembers() const { return static_cast<sal_uInt32>(m_declarations.size()); }
+ DeclList::const_iterator getIteratorBegin() const { return m_declarations.begin(); }
+ DeclList::const_iterator getIteratorEnd() const { return m_declarations.end(); }
+ sal_uInt16 getNodeCount(NodeType nType) const;
+
+ // Name look up mechanism
+ AstDeclaration* lookupByName(const OString& scopedName);
+ // Look up the identifier 'name' specified only in the local scope
+ AstDeclaration* lookupByNameLocal(std::string_view name) const;
+
+ AstDeclaration* lookupInInherited(const OString& scopedName) const;
+
+ // Look up a predefined type by its ExprType
+ AstDeclaration* lookupPrimitiveType(ExprType type);
+
+ AstDeclaration* lookupForAdd(AstDeclaration const* pDecl) const;
+
+protected:
+ AstDeclaration const* getLast() const { return m_declarations.back(); }
+
+private:
+ DeclList m_declarations;
+ NodeType m_nodeType;
+};
+
+#endif // INCLUDED_IDLC_INC_ASTSCOPE_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/idlc/inc/astsequence.hxx b/idlc/inc/astsequence.hxx
new file mode 100644
index 000000000..e8a2850e2
--- /dev/null
+++ b/idlc/inc/astsequence.hxx
@@ -0,0 +1,49 @@
+/* -*- 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_IDLC_INC_ASTSEQUENCE_HXX
+#define INCLUDED_IDLC_INC_ASTSEQUENCE_HXX
+
+#include "asttype.hxx"
+
+class AstSequence final : public AstType
+{
+public:
+ AstSequence(AstType const* pMemberType, AstScope* pScope)
+ : AstType(NT_sequence, OString::Concat("[]") + pMemberType->getScopedName(), pScope)
+ , m_pMemberType(pMemberType)
+ {
+ }
+
+ AstType const* getMemberType() const { return m_pMemberType; }
+
+ virtual bool isUnsigned() const override
+ {
+ return m_pMemberType != nullptr && m_pMemberType->isUnsigned();
+ }
+
+ virtual const char* getRelativName() const override;
+
+private:
+ AstType const* m_pMemberType;
+ mutable std::optional<OString> m_xRelativName;
+};
+
+#endif // INCLUDED_IDLC_INC_ASTSEQUENCE_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/idlc/inc/astservice.hxx b/idlc/inc/astservice.hxx
new file mode 100644
index 000000000..4ad769cd5
--- /dev/null
+++ b/idlc/inc/astservice.hxx
@@ -0,0 +1,61 @@
+/* -*- 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_IDLC_INC_ASTSERVICE_HXX
+#define INCLUDED_IDLC_INC_ASTSERVICE_HXX
+
+#include "astdeclaration.hxx"
+#include "astscope.hxx"
+
+class AstService final : public AstDeclaration
+ , public AstScope
+{
+public:
+ AstService(const OString& name, AstScope* pScope)
+ : AstDeclaration(NT_service, name, pScope)
+ , AstScope(NT_service)
+ , m_singleInterfaceBasedService(false)
+ , m_defaultConstructor(false)
+ {}
+ AstService(const NodeType type, const OString& name, AstScope* pScope)
+ : AstDeclaration(type, name, pScope)
+ , AstScope(type)
+ , m_singleInterfaceBasedService(false)
+ , m_defaultConstructor(false)
+ {}
+
+ virtual bool dump(RegistryKey& rKey) override;
+
+ void setSingleInterfaceBasedService()
+ { m_singleInterfaceBasedService = true; }
+
+ void setDefaultConstructor(bool b) { m_defaultConstructor = b; }
+
+ bool isSingleInterfaceBasedService() const
+ { return m_singleInterfaceBasedService; }
+
+ bool checkLastConstructor() const;
+
+private:
+ bool m_singleInterfaceBasedService;
+ bool m_defaultConstructor;
+};
+
+#endif // INCLUDED_IDLC_INC_ASTSERVICE_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/idlc/inc/astservicemember.hxx b/idlc/inc/astservicemember.hxx
new file mode 100644
index 000000000..380449b25
--- /dev/null
+++ b/idlc/inc/astservicemember.hxx
@@ -0,0 +1,45 @@
+/* -*- 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_IDLC_INC_ASTSERVICEMEMBER_HXX
+#define INCLUDED_IDLC_INC_ASTSERVICEMEMBER_HXX
+
+#include "astservice.hxx"
+
+class AstServiceMember final : public AstDeclaration
+{
+public:
+ AstServiceMember(const sal_uInt32 flags, AstService* pRealService,
+ const OString& name, AstScope* pScope)
+ : AstDeclaration(NT_service_member, name, pScope)
+ , m_flags(flags)
+ , m_pRealService(pRealService)
+ {}
+
+ AstService* getRealService()
+ { return m_pRealService; }
+ bool isOptional() const
+ { return ((m_flags & AF_OPTIONAL) == AF_OPTIONAL); }
+private:
+ const sal_uInt32 m_flags;
+ AstService* m_pRealService;
+};
+
+#endif // INCLUDED_IDLC_INC_ASTSERVICEMEMBER_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/idlc/inc/aststack.hxx b/idlc/inc/aststack.hxx
new file mode 100644
index 000000000..d36bd4e48
--- /dev/null
+++ b/idlc/inc/aststack.hxx
@@ -0,0 +1,46 @@
+/* -*- 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 .
+ */
+
+#pragma once
+
+#include <sal/types.h>
+#include <vector>
+
+class AstScope;
+
+class AstStack final
+{
+public:
+ AstStack();
+ ~AstStack();
+
+ sal_uInt32 depth() const { return m_stack.size(); }
+ AstScope* top();
+ AstScope* bottom();
+ AstScope* nextToTop();
+ AstScope* topNonNull();
+ AstStack* push(AstScope* pScope);
+ void pop();
+ void clear();
+
+private:
+ std::vector<AstScope*> m_stack;
+};
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/idlc/inc/aststruct.hxx b/idlc/inc/aststruct.hxx
new file mode 100644
index 000000000..5e037d1b5
--- /dev/null
+++ b/idlc/inc/aststruct.hxx
@@ -0,0 +1,62 @@
+/* -*- 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_IDLC_INC_ASTSTRUCT_HXX
+#define INCLUDED_IDLC_INC_ASTSTRUCT_HXX
+
+#include <sal/config.h>
+
+#include <string_view>
+
+#include "asttype.hxx"
+#include "astscope.hxx"
+#include "idlctypes.hxx"
+
+class AstStruct;
+
+class AstStruct : public AstType
+ , public AstScope
+{
+public:
+ AstStruct(
+ const OString& name,
+ std::vector< OString > const & typeParameters,
+ AstStruct const* pBaseType, AstScope* pScope);
+
+ AstStruct(const NodeType type,
+ const OString& name,
+ AstStruct const* pBaseType,
+ AstScope* pScope);
+ virtual ~AstStruct() override;
+
+ std::size_t getTypeParameterCount() const
+ { return m_typeParameters.size(); }
+
+ AstDeclaration const * findTypeParameter(std::string_view name) const;
+
+ virtual bool isType() const override;
+
+ virtual bool dump(RegistryKey& rKey) override;
+private:
+ AstStruct const* m_pBaseType;
+ std::vector<std::unique_ptr<AstDeclaration>> m_typeParameters;
+};
+
+#endif // INCLUDED_IDLC_INC_ASTSTRUCT_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/idlc/inc/aststructinstance.hxx b/idlc/inc/aststructinstance.hxx
new file mode 100644
index 000000000..1357aa351
--- /dev/null
+++ b/idlc/inc/aststructinstance.hxx
@@ -0,0 +1,49 @@
+/* -*- 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_IDLC_INC_ASTSTRUCTINSTANCE_HXX
+#define INCLUDED_IDLC_INC_ASTSTRUCTINSTANCE_HXX
+
+#include "asttype.hxx"
+#include "idlctypes.hxx"
+
+class AstScope;
+
+class AstStructInstance final : public AstType {
+public:
+ AstStructInstance(
+ AstType const * typeTemplate, DeclList const * typeArguments,
+ AstScope * scope);
+
+ AstType const * getTypeTemplate() const { return m_typeTemplate; }
+
+ DeclList::const_iterator getTypeArgumentsBegin() const
+ { return m_typeArguments.begin(); }
+
+ DeclList::const_iterator getTypeArgumentsEnd() const
+ { return m_typeArguments.end(); }
+
+private:
+ AstType const * m_typeTemplate;
+ DeclList m_typeArguments;
+};
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/idlc/inc/asttype.hxx b/idlc/inc/asttype.hxx
new file mode 100644
index 000000000..8627429cd
--- /dev/null
+++ b/idlc/inc/asttype.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_IDLC_INC_ASTTYPE_HXX
+#define INCLUDED_IDLC_INC_ASTTYPE_HXX
+
+#include "astdeclaration.hxx"
+
+class AstType : public AstDeclaration
+{
+public:
+ AstType(const NodeType type, const OString& name, AstScope* pScope)
+ : AstDeclaration(type, name, pScope)
+ {
+ }
+
+ virtual bool isUnsigned() const { return false; }
+};
+
+#endif // INCLUDED_IDLC_INC_ASTTYPE_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/idlc/inc/asttypedef.hxx b/idlc/inc/asttypedef.hxx
new file mode 100644
index 000000000..427d63307
--- /dev/null
+++ b/idlc/inc/asttypedef.hxx
@@ -0,0 +1,44 @@
+/* -*- 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_IDLC_INC_ASTTYPEDEF_HXX
+#define INCLUDED_IDLC_INC_ASTTYPEDEF_HXX
+
+#include "asttype.hxx"
+
+class AstTypeDef final : public AstType
+{
+public:
+ AstTypeDef(
+ AstType const * baseType, OString const & name, AstScope * scope):
+ AstType(NT_typedef, name, scope), m_pBaseType(baseType) {}
+
+ AstType const * getBaseType() const
+ { return m_pBaseType; }
+
+ virtual bool isUnsigned() const override
+ { return m_pBaseType != nullptr && m_pBaseType->isUnsigned(); }
+
+ virtual bool dump(RegistryKey& rKey) override;
+private:
+ AstType const * m_pBaseType;
+};
+
+#endif // INCLUDED_IDLC_INC_ASTTYPEDEF_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/idlc/inc/errorhandler.hxx b/idlc/inc/errorhandler.hxx
new file mode 100644
index 000000000..9b49f5df4
--- /dev/null
+++ b/idlc/inc/errorhandler.hxx
@@ -0,0 +1,118 @@
+/* -*- 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_IDLC_INC_ERRORHANDLER_HXX
+#define INCLUDED_IDLC_INC_ERRORHANDLER_HXX
+
+#include "astdeclaration.hxx"
+#include "astexpression.hxx"
+#include "astenum.hxx"
+
+enum class ErrorCode
+{
+ SyntaxError, // Syntax error in IDL input
+ // More details will be gleaned from examining
+ // the parse state
+ RedefScope, // Redefinition inside defining scope
+ CoercionFailure, // Coercion failure
+ ScopeConflict, // Between fwd declare and full declare
+ IllegalAdd, // Illegal add action
+ IllegalRaises, // Error in "raises" clause
+ CantInherit, // Cannot inherit from non-interface
+ IdentNotFound, // Identifier not found
+ CannotInheritFromForward, // Cannot inherit from fwd decl interface
+ ExpectedConstant, // We got something else...
+ Eval, // Error in evaluating expression
+ ForwardDeclLookup, // Tried to lookup in fwd declared intf
+ RecursiveType, // Illegal recursive use of type
+ NotAType, // Not a type
+ InterfaceMemberLookup, // interface is not defined or a fwd declaration not exists
+ ServiceMemberLookup,
+ DefinedAttributeFlag,
+ WrongAttributeKeyword,
+ MissingAttributeKeyword,
+ BadAttributeFlags,
+ ExpectedOptional,
+ MixedInheritance,
+ DoubleInheritance,
+ DoubleMember,
+ ConstructorParameterNotIn,
+ ConstructorRestParameterNotFirst,
+ RestParameterNotLast,
+ RestParameterNotAny,
+ MethodHasRestParameter,
+ ReadOnlyAttributeSetExceptions,
+ UnsignedTypeArgument,
+ WrongNumberOfTypeArguments,
+ InstantiatedStructTypeTypedef,
+ IdenticalTypeParameters,
+ StructTypeTemplateWithBase,
+ PublishedForward,
+ PublishedusesUnpublished,
+ SimilarConstructors
+};
+
+enum class WarningCode
+{
+ WrongNamingConvention // type or identifier doesn't fulfill the UNO naming convention
+};
+
+class ErrorHandler
+{
+public:
+ // Report errors with varying numbers of arguments
+ static void error0(ErrorCode e);
+ static void error1(ErrorCode e, AstDeclaration const * d);
+ static void error2(
+ ErrorCode e, AstDeclaration const * d1, AstDeclaration const * d2);
+ static void error3(ErrorCode e, AstDeclaration const * d1, AstDeclaration const * d2, AstDeclaration const * d3);
+
+ // Warning
+ static void warning0(WarningCode e, const char* warningmsg);
+
+ // Report a syntax error in IDL input
+ static void syntaxError(ParseState state, sal_Int32 lineNumber, const char* errmsg);
+
+ // Report an unsuccessful coercion attempt
+ static void coercionError(AstExpression *pExpr, ExprType et);
+
+ // Report a failed name lookup attempt
+ static void lookupError(const OString& n);
+ // Report a failed name lookup attempt
+ static void lookupError(ErrorCode e, const OString& n, AstDeclaration const * pScope);
+
+
+ // Report a type error
+ static void noTypeError(AstDeclaration const * pDecl);
+
+ static void inheritanceError(NodeType nodeType, const OString* name, AstDeclaration const * pDecl);
+
+ static void flagError(ErrorCode e, sal_uInt32 flag);
+
+ static void forwardLookupError(const AstDeclaration* pForward, const OString& name);
+
+ static void constantExpected(AstDeclaration const * pDecl, const OString& name);
+
+ static void evalError(AstExpression* pExpr);
+
+ static bool checkPublished(AstDeclaration const * decl, bool bOptional=false);
+};
+
+#endif // INCLUDED_IDLC_INC_ERRORHANDLER_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/idlc/inc/fehelper.hxx b/idlc/inc/fehelper.hxx
new file mode 100644
index 000000000..be401defc
--- /dev/null
+++ b/idlc/inc/fehelper.hxx
@@ -0,0 +1,70 @@
+/* -*- 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_IDLC_INC_FEHELPER_HXX
+#define INCLUDED_IDLC_INC_FEHELPER_HXX
+
+#include "asttype.hxx"
+#include "astinterface.hxx"
+
+#include <vector>
+
+class FeDeclarator final
+{
+public:
+ FeDeclarator(const OString& name);
+ ~FeDeclarator();
+ const OString& getName() const
+ { return m_name; }
+ bool checkType(AstDeclaration const * pType) const;
+ static AstType const * compose(AstDeclaration const * pDecl);
+private:
+ OString m_name;
+};
+
+typedef ::std::list< FeDeclarator* > FeDeclList;
+
+class FeInheritanceHeader final
+{
+public:
+ FeInheritanceHeader(
+ NodeType nodeType, OString* pName, OString const * pInherits,
+ std::vector< OString > const * typeParameters);
+
+ NodeType getNodeType() const
+ { return m_nodeType; }
+ OString* getName()
+ { return m_pName.get(); }
+ AstDeclaration* getInherits()
+ { return m_pInherits; }
+
+ std::vector< OString > const & getTypeParameters() const
+ { return m_typeParameters; }
+
+private:
+ void initializeInherits(OString const * pinherits);
+
+ NodeType m_nodeType;
+ std::unique_ptr<OString> m_pName;
+ AstDeclaration* m_pInherits;
+ std::vector< OString > m_typeParameters;
+};
+
+#endif // INCLUDED_IDLC_INC_FEHELPER_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/idlc/inc/idlc.hxx b/idlc/inc/idlc.hxx
new file mode 100644
index 000000000..1be11b145
--- /dev/null
+++ b/idlc/inc/idlc.hxx
@@ -0,0 +1,164 @@
+/* -*- 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 .
+ */
+#pragma once
+
+#include "idlctypes.hxx"
+#include "aststack.hxx"
+#include "options.hxx"
+#include <memory>
+#include <string_view>
+
+#ifdef SAL_UNX
+#define SEPARATOR '/'
+#define PATH_SEPARATOR "/"
+#else
+#define SEPARATOR '\\'
+#define PATH_SEPARATOR "\\"
+#endif
+
+class AstInterface;
+class AstModule;
+class AstType;
+class Options;
+class ErrorHandler;
+
+class Idlc final
+{
+public:
+ Idlc(Options* pOptions);
+ ~Idlc();
+
+ void init();
+
+ bool dumpDeps(std::string_view rDepFile,
+ OString const& rTarget);
+
+ Options* getOptions()
+ { return m_pOptions; }
+ AstStack* scopes()
+ { return m_pScopes.get(); }
+ AstModule* getRoot()
+ { return m_pRoot.get(); }
+ const OString& getFileName() const
+ { return m_fileName; }
+ void setFileName(const OString& fileName)
+ { m_fileName = fileName; addInclude(fileName); }
+ const OString& getMainFileName() const
+ { return m_mainFileName; }
+ void setMainFileName(const OString& mainFileName)
+ { m_mainFileName = mainFileName; }
+ const OString& getRealFileName() const
+ { return m_realFileName; }
+ void setRealFileName(const OString& realFileName)
+ { m_realFileName = realFileName; }
+ const OString& getDocumentation()
+ {
+ m_bIsDocValid = false;
+ return m_documentation;
+ }
+ void setDocumentation(const OString& documentation)
+ {
+ m_documentation = documentation;
+ m_bIsDocValid = true;
+ }
+ OUString processDocumentation();
+ bool isInMainFile() const
+ { return m_bIsInMainfile; }
+ void setInMainfile(bool bInMainfile)
+ { m_bIsInMainfile = bInMainfile; }
+ sal_uInt32 getErrorCount() const
+ { return m_errorCount; }
+ void incErrorCount()
+ { m_errorCount++; }
+ sal_uInt32 getWarningCount() const
+ { return m_warningCount; }
+ void incWarningCount()
+ { m_warningCount++; }
+ sal_uInt32 getLineNumber() const
+ { return m_lineNumber; }
+ sal_uInt32 getOffsetStart() const
+ { return m_offsetStart; }
+ sal_uInt32 getOffsetEnd() const
+ { return m_offsetEnd; }
+ void setOffset( sal_uInt32 start, sal_uInt32 end)
+ { m_offsetStart = start; m_offsetEnd = end; }
+ void setLineNumber(sal_uInt32 lineNumber)
+ { m_lineNumber = lineNumber; }
+ void incLineNumber()
+ { m_lineNumber++; }
+ ParseState getParseState() const
+ { return m_parseState; }
+ void setParseState(ParseState parseState)
+ { m_parseState = parseState; }
+
+ void addInclude(const OString& inc)
+ { m_includes.insert(inc); }
+
+ void setPublished(bool published) { m_published = published; }
+ bool isPublished() const { return m_published; }
+
+ void reset();
+private:
+ Options* m_pOptions;
+ std::unique_ptr<AstStack> m_pScopes;
+ std::unique_ptr<AstModule> m_pRoot;
+ OString m_fileName;
+ OString m_mainFileName;
+ OString m_realFileName;
+ OString m_documentation;
+ bool m_bIsDocValid;
+ bool m_bGenerateDoc;
+ bool m_bIsInMainfile;
+ bool m_published;
+ sal_uInt32 m_errorCount;
+ sal_uInt32 m_warningCount;
+ sal_uInt32 m_lineNumber;
+ sal_uInt32 m_offsetStart;
+ sal_uInt32 m_offsetEnd;
+ ParseState m_parseState;
+ std::set< OString > m_includes;
+};
+
+
+typedef ::std::pair< OString, OString > sPair_t;
+sal_Int32 compileFile(const OString * pathname);
+ // a null pathname means stdin
+sal_Int32 produceFile(const OString& filenameBase,
+ sPair_t const*const pDepFile);
+ // filenameBase is filename without ".idl"
+void removeIfExists(std::string_view pathname);
+
+bool copyFile(const OString* source, const OString& target);
+ // a null source means stdin
+
+bool isFileUrl(std::string_view fileName);
+OString convertToAbsoluteSystemPath(const OString& fileName);
+OString convertToFileUrl(const OString& fileName);
+
+Idlc* idlc();
+Idlc* setIdlc(Options* pOptions);
+
+AstDeclaration const * resolveTypedefs(AstDeclaration const * type);
+
+AstDeclaration const * deconstructAndResolveTypedefs(
+ AstDeclaration const * type, sal_Int32 * rank);
+
+AstInterface const * resolveInterfaceTypedefs(AstType const * type);
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/idlc/inc/idlctypes.hxx b/idlc/inc/idlctypes.hxx
new file mode 100644
index 000000000..a2dadfee1
--- /dev/null
+++ b/idlc/inc/idlctypes.hxx
@@ -0,0 +1,189 @@
+/* -*- 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 .
+ */
+#pragma once
+
+#include <stdio.h>
+
+#include <list>
+#include <set>
+#include <string>
+#include <unordered_map>
+#include <vector>
+
+#include <sal/types.h>
+#include <rtl/ustring.hxx>
+
+
+class AstDeclaration;
+
+typedef std::list< AstDeclaration* > DeclList;
+
+class AstScope;
+AstDeclaration* scopeAsDecl(AstScope* pScope);
+AstScope* declAsScope(AstDeclaration* pDecl);
+
+// flags used for attributes, properties and services
+#define AF_INVALID 0x0000
+#define AF_READONLY 0x0001
+#define AF_OPTIONAL 0x0002
+#define AF_MAYBEVOID 0x0004
+#define AF_BOUND 0x0008
+#define AF_CONSTRAINED 0x0010
+#define AF_TRANSIENT 0x0020
+#define AF_MAYBEAMBIGUOUS 0x0040
+#define AF_MAYBEDEFAULT 0x0080
+#define AF_REMOVABLE 0x0100
+#define AF_ATTRIBUTE 0x0200
+#define AF_PROPERTY 0x0400
+
+enum ParseState
+{
+ PS_NoState,
+ PS_TypeDeclSeen, // Seen complete typedef declaration
+ PS_ConstantDeclSeen, // Seen complete const declaration
+ PS_ExceptionDeclSeen, // Seen complete exception declaration
+ PS_InterfaceDeclSeen, // Seen complete interface declaration
+ PS_ServiceDeclSeen, // Seen complete service declaration
+ PS_SingletonDeclSeen, // Seen complete singleton declaration
+ PS_ModuleDeclSeen, // Seen complete module declaration
+ PS_AttributeDeclSeen, // Seen complete attribute declaration
+ PS_PropertyDeclSeen, // Seen complete property declaration
+ PS_OperationDeclSeen, // Seen complete operation declaration
+ PS_InterfaceInheritanceDeclSeen, // Seen complete interface inheritance decl
+ PS_ConstantsDeclSeen, // Seen complete constants declaration
+
+ PS_ServiceSeen, // Seen a SERVICE keyword
+ PS_ServiceIDSeen, // Seen the service ID
+ PS_ServiceSqSeen, // '{' seen for service
+ PS_ServiceQsSeen, // '}' seen for service
+ PS_ServiceBodySeen, // Seen complete service body
+ PS_ServiceMemberSeen, // Seen a service member
+ PS_ServiceIFHeadSeen, // Seen an interface member header
+ PS_ServiceSHeadSeen, // Seen a service member header
+
+ PS_SingletonSeen, // Seen a SINGLETON keyword
+ PS_SingletonIDSeen, // Seen the singleton ID
+ PS_SingletonSqSeen, // '{' seen for singleton
+ PS_SingletonQsSeen, // '}' seen for singleton
+ PS_SingletonBodySeen, // Seen complete singleton body
+
+ PS_ModuleSeen, // Seen a MODULE keyword
+ PS_ModuleIDSeen, // Seen the module ID
+ PS_ModuleSqSeen, // '{' seen for module
+ PS_ModuleQsSeen, // '}' seen for module
+ PS_ModuleBodySeen, // Seen complete module body
+
+ PS_ConstantsSeen, // Seen a CONSTANTS keyword
+ PS_ConstantsIDSeen, // Seen the constants ID
+ PS_ConstantsSqSeen, // '{' seen for constants
+ PS_ConstantsQsSeen, // '}' seen for constants
+ PS_ConstantsBodySeen, // Seen complete constants body
+
+ PS_InterfaceSeen, // Seen an INTERFACE keyword
+ PS_InterfaceIDSeen, // Seen the interface ID
+ PS_InterfaceHeadSeen, // Seen the interface head
+ PS_InheritSpecSeen, // Seen a complete inheritance spec
+ PS_ForwardDeclSeen, // Forward interface decl seen
+ PS_InterfaceSqSeen, // '{' seen for interface
+ PS_InterfaceQsSeen, // '}' seen for interface
+ PS_InterfaceBodySeen, // Seen an interface body
+ PS_InheritColonSeen, // Seen ':' in inheritance list
+
+ PS_SNListCommaSeen, // Seen ',' in list of scoped names
+ PS_ScopedNameSeen, // Seen a complete scoped name
+ PS_SN_IDSeen, // Seen an identifier as part of a scoped name
+ PS_ScopeDelimSeen, // Seen a scope delim as party of a scoped name
+
+ PS_ConstSeen, // Seen a CONST keyword
+ PS_ConstTypeSeen, // Parsed the type of a constant
+ PS_ConstIDSeen, // Seen the constant ID
+ PS_ConstAssignSeen, // Seen the '='
+ PS_ConstExprSeen, // Seen the constant value expression
+
+ PS_TypedefSeen, // Seen a TYPEDEF keyword
+ PS_TypeSpecSeen, // Seen a complete type specification
+ PS_DeclaratorsSeen, // Seen a complete list of declarators
+
+ PS_StructSeen, // Seen a STRUCT keyword
+ PS_StructHeaderSeen, // Seen struct header
+ PS_StructIDSeen, // Seen the struct ID
+ PS_StructSqSeen, // '{' seen for struct
+ PS_StructQsSeen, // '}' seen for struct
+ PS_StructBodySeen, // Seen complete body of struct decl
+
+ PS_MemberTypeSeen, // Seen type of struct or except member
+ PS_MemberDeclsSeen, // Seen decls of struct or except members
+ PS_MemberDeclsCompleted,// Completed one struct or except member to ';'
+
+ PS_EnumSeen, // Seen an ENUM keyword
+ PS_EnumIDSeen, // Seen the enum ID
+ PS_EnumSqSeen, // Seen '{' for enum
+ PS_EnumQsSeen, // Seen '}' for enum
+ PS_EnumBodySeen, // Seen complete enum body
+ PS_EnumCommaSeen, // Seen ',' in list of enumerators
+
+ PS_SequenceSeen, // Seen a SEQUENCE keyword
+ PS_SequenceSqSeen, // Seen '<' for sequence
+ PS_SequenceQsSeen, // Seen '>' for sequence
+ PS_SequenceTypeSeen, // Seen type decl for sequence
+
+ PS_FlagHeaderSeen, // Seen the attribute|property|interface member head
+ PS_AttrSeen, // Seen ATTRIBUTE keyword
+ PS_AttrTypeSeen, // Seen type decl for attribute
+ PS_AttrCompleted, // Seen complete attribute declaration
+ PS_ReadOnlySeen, // Seen READONLY keyword
+ PS_OptionalSeen, // Seen OPTIONAL keyword
+ PS_MayBeVoidSeen, // Seen MAYBEVOID yword
+ PS_BoundSeen, // Seen BOUND keyword
+ PS_ConstrainedSeen, // Seen CONSTRAINED keyword
+ PS_TransientSeen, // Seen TRANSIENT keyword
+ PS_MayBeAmbiguousSeen, // Seen MAYBEAMBIGUOUS keyword
+ PS_MayBeDefaultSeen, // Seen MAYBEDEFAULT keyword
+ PS_RemoveableSeen, // Seen REMOVABLE keyword
+
+ PS_PropertySeen, // Seen PROPERTY keyword
+ PS_PropertyTypeSeen, // Seen type decl for property
+ PS_PropertyCompleted, // Seen complete property declaration
+
+ PS_ExceptSeen, // Seen EXCEPTION keyword
+ PS_ExceptHeaderSeen, // Seen exception header keyword
+ PS_ExceptIDSeen, // Seen exception identifier
+ PS_ExceptSqSeen, // Seen '{' for exception
+ PS_ExceptQsSeen, // Seen '}' for exception
+ PS_ExceptBodySeen, // Seen complete exception body
+
+ PS_OpTypeSeen, // Seen operation return type
+ PS_OpIDSeen, // Seen operation ID
+ PS_OpParsCompleted, // Completed operation param list
+ PS_OpSqSeen, // Seen '(' for operation
+ PS_OpQsSeen, // Seen ')' for operation
+ PS_OpParCommaSeen, // Seen ',' in list of op params
+ PS_OpParDirSeen, // Seen parameter direction
+ PS_OpParTypeSeen, // Seen parameter type
+ PS_OpParDeclSeen, // Seen parameter declaration
+
+ PS_RaiseSeen, // Seen RAISES keyword
+ PS_RaiseSqSeen, // Seen '(' for RAISES
+ PS_RaiseQsSeen, // Seen ')' for RAISES
+
+ PS_DeclsCommaSeen, // Seen ',' in declarators list
+ PS_DeclsDeclSeen // Seen complete decl in decls list
+};
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/idlc/inc/inheritedinterface.hxx b/idlc/inc/inheritedinterface.hxx
new file mode 100644
index 000000000..16462b4da
--- /dev/null
+++ b/idlc/inc/inheritedinterface.hxx
@@ -0,0 +1,56 @@
+/* -*- 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_IDLC_INC_INHERITEDINTERFACE_HXX
+#define INCLUDED_IDLC_INC_INHERITEDINTERFACE_HXX
+
+#include "idlc.hxx"
+
+#include <rtl/ustring.hxx>
+#include <utility>
+
+class AstInterface;
+class AstType;
+
+class InheritedInterface {
+public:
+ InheritedInterface(
+ AstType const * theInterface, bool theOptional,
+ OUString theDocumentation):
+ interface(theInterface), optional(theOptional),
+ documentation(std::move(theDocumentation)) {}
+
+ AstType const * getInterface() const { return interface; }
+
+ AstInterface const * getResolved() const
+ { return resolveInterfaceTypedefs(interface); }
+
+ bool isOptional() const { return optional; }
+
+ const OUString& getDocumentation() const { return documentation; }
+
+private:
+ AstType const * interface;
+ bool optional;
+ OUString documentation;
+};
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/idlc/inc/options.hxx b/idlc/inc/options.hxx
new file mode 100644
index 000000000..c3a0949b3
--- /dev/null
+++ b/idlc/inc/options.hxx
@@ -0,0 +1,76 @@
+/* -*- 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_IDLC_INC_OPTIONS_HXX
+#define INCLUDED_IDLC_INC_OPTIONS_HXX
+
+#include "idlctypes.hxx"
+#include <utility>
+
+typedef std::unordered_map< OString, OString > OptionMap;
+
+class IllegalArgument
+{
+public:
+ IllegalArgument(OString msg) : m_message(std::move(msg)) {}
+
+ OString m_message;
+};
+
+
+class Options
+{
+public:
+ explicit Options(char const * progname);
+ ~Options();
+
+ static bool checkArgument(std::vector< std::string > & rArgs, char const * arg, size_t len);
+ static bool checkCommandFile(std::vector< std::string > & rArgs, char const * filename);
+
+ /// @throws IllegalArgument
+ bool initOptions(std::vector< std::string > & rArgs);
+ /// @throws IllegalArgument
+ static bool badOption(char const * reason, std::string const & rArg);
+ bool setOption(char const * option, std::string const & rArg);
+
+ OString prepareHelp() const;
+ OString prepareVersion() const;
+
+ const OString& getProgramName() const { return m_program;}
+ bool isValid(const OString& option) const;
+ /// @throws IllegalArgument
+ const OString& getOption(const OString& option);
+
+ const std::vector< OString >& getInputFiles() const { return m_inputFiles; }
+ bool readStdin() const { return m_stdin; }
+ bool verbose() const { return m_verbose; }
+ bool quiet() const { return m_quiet; }
+
+protected:
+ OString m_program;
+ std::vector< OString > m_inputFiles;
+ bool m_stdin;
+ bool m_verbose;
+ bool m_quiet;
+ OptionMap m_options;
+};
+
+#endif // INCLUDED_IDLC_INC_OPTIONS_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */