diff options
Diffstat (limited to 'idlc/inc/idlc')
35 files changed, 2916 insertions, 0 deletions
diff --git a/idlc/inc/idlc/astarray.hxx b/idlc/inc/idlc/astarray.hxx new file mode 100644 index 000000000000..bb711823e869 --- /dev/null +++ b/idlc/inc/idlc/astarray.hxx @@ -0,0 +1,64 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ +#ifndef _IDLC_ASTARRAY_HXX_ +#define _IDLC_ASTARRAY_HXX_ + +#include <idlc/asttype.hxx> +#include <idlc/astscope.hxx> + +class AstArray : public AstType +{ +public: + AstArray(const ::rtl::OString& name, AstType* pType, const ExprList& rDimExpr, AstScope* pScope); + AstArray(AstType* pType, const ExprList& rDimExpr, AstScope* pScope); + + virtual ~AstArray() {} + + AstType* getType() + { return m_pType; } + void setType(AstType* pType) + { + m_pType = pType; + setName(makeName()); + } + ExprList* getDimExpressions() + { return &m_dimExpressions; } + sal_uInt32 getDimension() + { return m_dimension; } + +private: + ::rtl::OString makeName(); + + AstType* m_pType; + sal_uInt32 m_dimension; + ExprList m_dimExpressions; +}; + +#endif // _IDLC_ASTARRAY_HXX_ + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/idlc/inc/idlc/astattribute.hxx b/idlc/inc/idlc/astattribute.hxx new file mode 100644 index 000000000000..9b55069b6609 --- /dev/null +++ b/idlc/inc/idlc/astattribute.hxx @@ -0,0 +1,123 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ +#ifndef _IDLC_ASTATTRIBUTE_HXX_ +#define _IDLC_ASTATTRIBUTE_HXX_ + +#include <idlc/astdeclaration.hxx> +#include "idlc/astscope.hxx" + +#include "registry/types.h" +#include "rtl/ustring.hxx" + +namespace typereg { class Writer; } + +class AstAttribute: public AstDeclaration, public AstScope { +public: + AstAttribute( + sal_uInt32 flags, AstType const * type, rtl::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 ::rtl::OString& name, AstScope* pScope) + : AstDeclaration(nodeType, name, pScope), AstScope(nodeType) + , m_flags(flags) + , m_pType(pType) + {} + virtual ~AstAttribute() {} + + void setExceptions( + rtl::OUString const * getDoc, DeclList const * getExc, + rtl::OUString const * setDoc, DeclList const * setExc) + { + if (getDoc != 0) { + m_getDocumentation = *getDoc; + } + if (getExc != 0) { + m_getExceptions = *getExc; + } + if (setDoc != 0) { + m_setDocumentation = *setDoc; + } + if (setExc != 0) { + m_setExceptions = *setExc; + } + } + + DeclList::size_type getGetExceptionCount() const + { return m_getExceptions.size(); } + + DeclList::size_type getSetExceptionCount() const + { return m_setExceptions.size(); } + + AstType const * getType() const + { return m_pType; } + sal_Bool isReadonly() const + { return ((m_flags & AF_READONLY) == AF_READONLY); } + sal_Bool isOptional() const + { return ((m_flags & AF_OPTIONAL) == AF_OPTIONAL); } + sal_Bool isAttribute() const + { return ((m_flags & AF_ATTRIBUTE) == AF_ATTRIBUTE); } + sal_Bool isProperty() const + { return ((m_flags & AF_PROPERTY) == AF_PROPERTY); } + sal_Bool isBound() const + { return ((m_flags & AF_BOUND) == AF_BOUND); } + sal_Bool isMayBeVoid() const + { return ((m_flags & AF_MAYBEVOID) == AF_MAYBEVOID); } + sal_Bool isConstrained() const + { return ((m_flags & AF_CONSTRAINED) == AF_CONSTRAINED); } + sal_Bool isTransient() const + { return ((m_flags & AF_TRANSIENT) == AF_TRANSIENT); } + sal_Bool isMayBeAmbiguous() const + { return ((m_flags & AF_MAYBEAMBIGUOUS) == AF_MAYBEAMBIGUOUS); } + sal_Bool isMayBeDefault() const + { return ((m_flags & AF_MAYBEDEFAULT) == AF_MAYBEDEFAULT); } + sal_Bool isRemoveable() const + { return ((m_flags & AF_REMOVEABLE) == AF_REMOVEABLE); } + + sal_Bool dumpBlob( + typereg::Writer & rBlob, sal_uInt16 index, sal_uInt16 * methodIndex); + +private: + void dumpExceptions( + typereg::Writer & writer, rtl::OUString const & documentation, + DeclList const & exceptions, RTMethodMode flags, + sal_uInt16 * methodIndex); + + const sal_uInt32 m_flags; + AstType const * m_pType; + rtl::OUString m_getDocumentation; + DeclList m_getExceptions; + rtl::OUString m_setDocumentation; + DeclList m_setExceptions; +}; + +#endif // _IDLC_ASTATTRIBUTE_HXX_ + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/idlc/inc/idlc/astbasetype.hxx b/idlc/inc/idlc/astbasetype.hxx new file mode 100644 index 000000000000..4d0793ef66fb --- /dev/null +++ b/idlc/inc/idlc/astbasetype.hxx @@ -0,0 +1,64 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ +#ifndef _IDLC_ASTBASETYPE_HXX_ +#define _IDLC_ASTBASETYPE_HXX_ + +#include <idlc/asttype.hxx> +#include <idlc/astexpression.hxx> + + +class AstBaseType : public AstType +{ +public: + AstBaseType(const ExprType type, const ::rtl::OString& name, AstScope* pScope) + : AstType(NT_predefined, name, pScope) + , m_exprType(type) + {} + + virtual ~AstBaseType() {} + + virtual bool isUnsigned() const { + 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; +}; + +#endif // _IDLC_ASTBASETYPE_HXX_ + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/idlc/inc/idlc/astconstant.hxx b/idlc/inc/idlc/astconstant.hxx new file mode 100644 index 000000000000..b9c87ad42f03 --- /dev/null +++ b/idlc/inc/idlc/astconstant.hxx @@ -0,0 +1,59 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ +#ifndef _IDLC_ASTCONSTANT_HXX_ +#define _IDLC_ASTCONSTANT_HXX_ + +#include <idlc/astdeclaration.hxx> +#include <idlc/astexpression.hxx> + +namespace typereg { class Writer; } + +class AstConstant : public AstDeclaration +{ +public: + AstConstant(const ExprType type, const NodeType nodeType, + AstExpression* pExpr, const ::rtl::OString& name, AstScope* pScope); + AstConstant(const ExprType type, AstExpression* pExpr, + const ::rtl::OString& name, AstScope* pScope); + virtual ~AstConstant(); + + AstExpression* getConstValue() + { return m_pConstValue; } + ExprType getConstValueType() const + { return m_constValueType; } + + sal_Bool dumpBlob( + typereg::Writer & rBlob, sal_uInt16 index, bool published); +private: + AstExpression* m_pConstValue; + const ExprType m_constValueType; +}; + +#endif // _IDLC_ASTCONSTANT_HXX_ + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/idlc/inc/idlc/astconstants.hxx b/idlc/inc/idlc/astconstants.hxx new file mode 100644 index 000000000000..f132a978b31d --- /dev/null +++ b/idlc/inc/idlc/astconstants.hxx @@ -0,0 +1,44 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ +#ifndef _IDLC_ASTCONSTANTS_HXX_ +#define _IDLC_ASTCONSTANTS_HXX_ + +#include <idlc/astmodule.hxx> + +class AstConstants : public AstModule +{ +public: + AstConstants(const ::rtl::OString& name, AstScope* pScope) + : AstModule(NT_constants, name, pScope) + {} + virtual ~AstConstants() {} +}; + +#endif // _IDLC_ASTCONSTANTS_HXX_ + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/idlc/inc/idlc/astdeclaration.hxx b/idlc/inc/idlc/astdeclaration.hxx new file mode 100644 index 000000000000..f0f6d29b0953 --- /dev/null +++ b/idlc/inc/idlc/astdeclaration.hxx @@ -0,0 +1,150 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ +#ifndef _IDLC_ASTDECLARATION_HXX_ +#define _IDLC_ASTDECLARATION_HXX_ + +#include <idlc/idlc.hxx> +#include <registry/registry.hxx> + +class AstScope; + +// Enum defining the different kinds of Ast nodes +enum NodeType +{ + NT_object, // Denotes an object + NT_service, // Denotes an servcie + NT_interface_member, // Denotes an interface which is exported from object + NT_service_member, // Denotes an service which is exported from object + NT_observes, // Denotes an observed interface + NT_needs, // Denotes an 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 an property + NT_operation, // Denotes an operation + NT_parameter, // Denotes an op. parameter + NT_union, // Denotes a union + NT_union_branch, // Denotes a union branch + 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_array, // Denotes an IDL array + 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 ::rtl::OString& name, AstScope* pScope); + virtual ~AstDeclaration(); + + // Data access + void setName(const ::rtl::OString& name); + const ::rtl::OString& getLocalName() const + { return m_localName; } + const ::rtl::OString& getScopedName() const + { return m_scopedName; } + const ::rtl::OString& getFullName() + { return m_fullName; } + virtual const sal_Char* getRelativName() const + { return m_fullName.getStr()+1; } + AstScope* getScope() + { return m_pScope; } + void setScope(AstScope* pSc) + { m_pScope = pSc; } + NodeType getNodeType() const + { return m_nodeType; } + sal_Bool isInMainfile() const + { return m_bInMainFile; } + void setInMainfile(sal_Bool bInMainfile) + { m_bInMainFile = bInMainfile; } + sal_Bool isImported() const + { return m_bImported; } + void setImported(sal_Bool bImported) + { m_bImported = bImported; } + sal_Int32 getLineNumber() const + { return m_lineNumber; } + void setLineNumber(sal_Int32 lineNumber) + { m_lineNumber = lineNumber; } + const ::rtl::OString& getFileName() const + { return m_fileName; } + void setFileName(const ::rtl::OString& rFileName) + { m_fileName = rFileName; } + const ::rtl::OUString& getDocumentation() const + { return m_documentation; } + void setDocumentation(const ::rtl::OUString& rDocumentation) + { m_documentation = rDocumentation; } + sal_Bool isAdded() + { return m_bIsAdded; } + void markAsAdded() + { m_bIsAdded = sal_True; } + + virtual bool isType() const; + + sal_Bool hasAncestor(AstDeclaration* pDecl); + + void setPublished() { m_bPublished = true; } + bool isPublished() const { return m_bPublished; } + + virtual sal_Bool dump(RegistryKey& rKey); + + bool isPredefined() { return m_bPredefined; } + void setPredefined(bool bPredefined); + +protected: + ::rtl::OString m_localName; + ::rtl::OString m_scopedName; // full qualified name + ::rtl::OString m_fullName; // full qualified name with '/' as seperator + AstScope* m_pScope; + NodeType m_nodeType; + sal_Bool m_bImported; // imported ? + sal_Bool m_bIsAdded; // mark declaration as added in scope + sal_Bool m_bInMainFile; // defined in main file + bool m_bPublished; + bool m_bPredefined; + sal_Int32 m_lineNumber; // line number defined in + ::rtl::OString m_fileName; // fileName defined in + ::rtl::OUString m_documentation; // fileName defined in +}; + +#endif // _IDLC_ASTDECLARATION_HXX_ + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/idlc/inc/idlc/astenum.hxx b/idlc/inc/idlc/astenum.hxx new file mode 100644 index 000000000000..6a3380a22250 --- /dev/null +++ b/idlc/inc/idlc/astenum.hxx @@ -0,0 +1,59 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ +#ifndef _IDLC_ASTENUM_HXX_ +#define _IDLC_ASTENUM_HXX_ + +#include <idlc/asttype.hxx> +#include <idlc/astscope.hxx> +#include <idlc/astconstant.hxx> + +class AstEnum : public AstType + , public AstScope +{ +public: + AstEnum(const ::rtl::OString& name, AstScope* pScope); + + virtual ~AstEnum(); + + void setEnumValueCount(sal_Int32 count) + { m_enumValueCount = count; } + sal_Int32 getEnumValueCount() + { return m_enumValueCount++; } + + AstConstant* checkValue(AstExpression* pExpr); + + virtual sal_Bool dump(RegistryKey& rKey); + + virtual AstDeclaration* addDeclaration(AstDeclaration* pDecl); +private: + sal_Int32 m_enumValueCount; +}; + +#endif // _IDLC_ASTENUM_HXX_ + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/idlc/inc/idlc/astexception.hxx b/idlc/inc/idlc/astexception.hxx new file mode 100644 index 000000000000..2f4c73ac7d07 --- /dev/null +++ b/idlc/inc/idlc/astexception.hxx @@ -0,0 +1,45 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ +#ifndef _IDLC_ASTEXCEPTION_HXX_ +#define _IDLC_ASTEXCEPTION_HXX_ + +#include <idlc/aststruct.hxx> + +class AstException : public AstStruct +{ +public: + AstException(const ::rtl::OString& name, AstException* pBaseType, AstScope* pScope) + : AstStruct(NT_exception, name, pBaseType, pScope) + {} + + virtual ~AstException() {} +}; + +#endif // _IDLC_ASTEXCEPTION_HXX_ + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/idlc/inc/idlc/astexpression.hxx b/idlc/inc/idlc/astexpression.hxx new file mode 100644 index 000000000000..74dfb91b7c8c --- /dev/null +++ b/idlc/inc/idlc/astexpression.hxx @@ -0,0 +1,188 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ +#ifndef _IDLC_ASTEXPRESSION_HXX_ +#define _IDLC_ASTEXPRESSION_HXX_ + +#include <idlc/idlc.hxx> + +// Enum to define all the different operators to combine expressions +enum ExprComb +{ + EC_add, // '+' + EC_minus, // '-' + EC_mul, // '*' + EC_div, // '/' + EC_mod, // '%' + EC_or, // '|' + EC_xor, // '^' + EC_and, // '&' + EC_left, // '<<' + EC_right, // '>>' + EC_u_plus, // unary '+' + EC_u_minus, // unary '-' + EC_bit_neg, // '~' + EC_none, // No operator (missing) + EC_symbol // a symbol (function or constant name) +}; + +// Enum to define the different kinds of evaluation possible +enum EvalKind +{ + EK_const, // Must evaluate to constant + EK_positive_int // Must evaluate to positive integer +}; + +// 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 + sal_Bool bval; // Contains boolean expression value + float fval; // Contains 32-bit float expr value + double dval; // Contains 64-bit float expr value + sal_uInt32 eval; // Contains enumeration value + } u; + ExprType et; +}; + +const sal_Char* SAL_CALL exprTypeToString(ExprType t); + +class AstExpression +{ +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(::rtl::OString* scopedName); + + virtual ~AstExpression(); + + // Data Accessors + AstScope* getScope() + { return m_pScope; } + void setScope(AstScope* pScope) + { m_pScope = pScope; } + sal_Int32 getLine() + { return m_lineNo; } + void setLine(sal_Int32 l) + { m_lineNo = l; } + const ::rtl::OString& getFileName() + { return m_fileName; } + void setFileName(const ::rtl::OString& fileName) + { m_fileName = fileName; } + ExprComb getCombOperator() + { return m_combOperator; } + void setCombOperator(ExprComb new_ec) + { m_combOperator = new_ec; } + AstExprValue* getExprValue() + { return m_exprValue; } + void setExprValue(AstExprValue *pEv) + { m_exprValue = pEv; } + AstExpression* getExpr1() + { return m_subExpr1; } + void setExpr1(AstExpression *pExpr) + { m_subExpr1 = pExpr; } + AstExpression* getExpr2() + { return m_subExpr2; } + void setExpr2(AstExpression *pExpr) + { m_subExpr2 = pExpr; } + ::rtl::OString* getSymbolicName() + { return m_pSymbolicName; } + void setSymbolicName(::rtl::OString* pSymbolicName) + { m_pSymbolicName = pSymbolicName; } + + // Evaluation and value coercion + AstExprValue* coerce(ExprType type, sal_Bool bAssign=sal_True); + + // Evaluate then store value inside this AstExpression + void evaluate(EvalKind ek); + + // Compare to AstExpressions + sal_Bool operator==(AstExpression *pExpr); + sal_Bool compare(AstExpression *pExpr); + + ::rtl::OString toString(); + void dump() {} +private: + // Fill out the lineno, filename and definition scope details + void fillDefinitionDetails(); + // Internal evaluation + AstExprValue* eval_internal(EvalKind ek); + // Evaluate different sets of operators + AstExprValue* eval_bin_op(EvalKind ek); + AstExprValue* eval_bit_op(EvalKind ek); + AstExprValue* eval_un_op(EvalKind ek); + AstExprValue* eval_symbol(EvalKind ek); + + AstScope* m_pScope; // scope defined in + sal_Int32 m_lineNo; // line number defined in + ::rtl::OString m_fileName; // fileName defined in + + ExprComb m_combOperator; + AstExpression* m_subExpr1; + AstExpression* m_subExpr2; + AstExprValue* m_exprValue; + ::rtl::OString* m_pSymbolicName; +}; + +#endif // _IDLC_ASTEXPRESSION_HXX_ + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/idlc/inc/idlc/astinterface.hxx b/idlc/inc/idlc/astinterface.hxx new file mode 100644 index 000000000000..5b4f3ae6fee7 --- /dev/null +++ b/idlc/inc/idlc/astinterface.hxx @@ -0,0 +1,146 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ +#ifndef _IDLC_ASTINTERFACE_HXX_ +#define _IDLC_ASTINTERFACE_HXX_ + +#include <idlc/asttype.hxx> +#include <idlc/astscope.hxx> +#include "idlc/inheritedinterface.hxx" + +#include <map> +#include <vector> + +class AstInterface : public AstType + , public AstScope +{ +public: + typedef std::vector< InheritedInterface > InheritedInterfaces; + + typedef std::vector< AstInterface const * > DoubleInterfaceDeclarations; + + struct DoubleMemberDeclaration { + AstDeclaration const * first; + AstDeclaration const * second; + }; + + typedef std::vector< DoubleMemberDeclaration > DoubleMemberDeclarations; + + struct DoubleDeclarations { + DoubleInterfaceDeclarations interfaces; + DoubleMemberDeclarations members; + }; + + AstInterface( + const ::rtl::OString& name, AstInterface const * pInherits, + AstScope* pScope); + virtual ~AstInterface(); + + InheritedInterfaces const & getAllInheritedInterfaces() const + { return m_inheritedInterfaces; } + + bool hasMandatoryInheritedInterfaces() const + { return m_mandatoryInterfaces > 0; } + + void setForwarded(sal_Bool bForwarded) + { m_bForwarded = bForwarded; } + sal_Bool isForwarded() + { return m_bForwarded; } + void setForwardedInSameFile(sal_Bool bForwarded) + { m_bForwardedInSameFile = bForwarded; } + sal_Bool isForwardedInSameFile() + { return m_bForwardedInSameFile; } + + void setDefined() { m_bIsDefined = true; } + sal_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, + rtl::OUString const & documentation); + + DoubleMemberDeclarations checkMemberClashes( + AstDeclaration const * member) const; + + void addMember(AstDeclaration /*TODO: const*/ * member); + + void forwardDefined(AstInterface const & def); + + virtual sal_Bool dump(RegistryKey& rKey); + +private: + enum InterfaceKind { + INTERFACE_INDIRECT_OPTIONAL, INTERFACE_DIRECT_OPTIONAL, + INTERFACE_INDIRECT_MANDATORY, INTERFACE_DIRECT_MANDATORY }; + + struct VisibleMember { + explicit VisibleMember(AstDeclaration const * theMandatory = 0): + mandatory(theMandatory) {} + + typedef std::map< rtl::OString, AstDeclaration const * > Optionals; + + AstDeclaration const * mandatory; + Optionals optionals; + }; + + typedef std::map< rtl::OString, InterfaceKind > VisibleInterfaces; + typedef std::map< rtl::OString, VisibleMember > VisibleMembers; + + void checkInheritedInterfaceClashes( + DoubleDeclarations & doubleDeclarations, + std::set< rtl::OString > & seenInterfaces, AstInterface const * ifc, + bool optional, bool direct, 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; + sal_Bool m_bIsDefined; + sal_Bool m_bForwarded; + sal_Bool m_bForwardedInSameFile; + bool m_bSingleInheritance; + VisibleInterfaces m_visibleInterfaces; + VisibleMembers m_visibleMembers; +}; + +#endif // _IDLC_ASTINTERFACE_HXX_ + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/idlc/inc/idlc/astinterfacemember.hxx b/idlc/inc/idlc/astinterfacemember.hxx new file mode 100644 index 000000000000..12eb19cf678e --- /dev/null +++ b/idlc/inc/idlc/astinterfacemember.hxx @@ -0,0 +1,55 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ +#ifndef _IDLC_ASTINTERFACEMEMBER_HXX_ +#define _IDLC_ASTINTERFACEMEMBER_HXX_ + +#include <idlc/astinterface.hxx> + +class AstInterfaceMember : public AstDeclaration +{ +public: + AstInterfaceMember(const sal_uInt32 flags, AstInterface* pRealInterface, + const ::rtl::OString& name, AstScope* pScope) + : AstDeclaration(NT_interface_member, name, pScope) + , m_flags(flags) + , m_pRealInterface(pRealInterface) + {} + virtual ~AstInterfaceMember() {} + + AstInterface* getRealInterface() + { return m_pRealInterface; } + sal_Bool isOptional() + { return ((m_flags & AF_OPTIONAL) == AF_OPTIONAL); } +private: + const sal_uInt32 m_flags; + AstInterface* m_pRealInterface; +}; + +#endif // _IDLC_ASTINTERFACEMEMBER_HXX_ + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/idlc/inc/idlc/astmember.hxx b/idlc/inc/idlc/astmember.hxx new file mode 100644 index 000000000000..4100bffd3826 --- /dev/null +++ b/idlc/inc/idlc/astmember.hxx @@ -0,0 +1,60 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef _IDLC_ASTMEMBER_HXX_ +#define _IDLC_ASTMEMBER_HXX_ + +#include "idlc/astdeclaration.hxx" + +namespace rtl { class OString; } +class AstScope; +class AstType; + +class AstMember: public AstDeclaration { +public: + AstMember( + AstType const * pType, rtl::OString const & name, AstScope * pScope): + AstDeclaration(NT_member, name, pScope), m_pType(pType) {} + + virtual ~AstMember() {} + + AstType const * getType() const { return m_pType; } + +protected: + AstMember( + NodeType type, AstType const * pType, rtl::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/idlc/astmodule.hxx b/idlc/inc/idlc/astmodule.hxx new file mode 100644 index 000000000000..54c95c2d1305 --- /dev/null +++ b/idlc/inc/idlc/astmodule.hxx @@ -0,0 +1,53 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ +#ifndef _IDLC_ASTMODULE_HXX_ +#define _IDLC_ASTMODULE_HXX_ + +#include <idlc/astdeclaration.hxx> +#include <idlc/astscope.hxx> + +class AstModule : public AstDeclaration + , public AstScope +{ +public: + AstModule(const ::rtl::OString& name, AstScope* pScope) + : AstDeclaration(NT_module, name, pScope) + , AstScope(NT_module) + {} + AstModule(NodeType type, const ::rtl::OString& name, AstScope* pScope) + : AstDeclaration(type, name, pScope) + , AstScope(type) + {} + virtual ~AstModule() {} + + virtual sal_Bool dump(RegistryKey& rKey); +}; + +#endif // _IDLC_ASTMODULE_HXX_ + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/idlc/inc/idlc/astneeds.hxx b/idlc/inc/idlc/astneeds.hxx new file mode 100644 index 000000000000..c4084dfef5a5 --- /dev/null +++ b/idlc/inc/idlc/astneeds.hxx @@ -0,0 +1,50 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ +#ifndef _IDLC_ASTNEEDS_HXX_ +#define _IDLC_ASTNEEDS_HXX_ + +#include <idlc/astservice.hxx> + +class AstNeeds : public AstDeclaration +{ +public: + AstNeeds(AstService* pRealService, const ::rtl::OString& name, AstScope* pScope) + : AstDeclaration(NT_needs, name, pScope) + , m_pRealService(pRealService) + {} + virtual ~AstNeeds() {} + + AstService* getRealService() + { return m_pRealService; } +private: + AstService* m_pRealService; +}; + +#endif // _IDLC_ASTNEEDS_HXX_ + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/idlc/inc/idlc/astobserves.hxx b/idlc/inc/idlc/astobserves.hxx new file mode 100644 index 000000000000..0faec0b8a949 --- /dev/null +++ b/idlc/inc/idlc/astobserves.hxx @@ -0,0 +1,50 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ +#ifndef _IDLC_ASTOBSERVES_HXX_ +#define _IDLC_ASTOBSERVES_HXX_ + +#include <idlc/astinterface.hxx> + +class AstObserves : public AstDeclaration +{ +public: + AstObserves(AstInterface* pRealInterface, const ::rtl::OString& name, AstScope* pScope) + : AstDeclaration(NT_observes, name, pScope) + , m_pRealInterface(pRealInterface) + {} + virtual ~AstObserves() {} + + AstInterface* getRealInterface() + { return m_pRealInterface; } +private: + AstInterface* m_pRealInterface; +}; + +#endif // _IDLC_ASTOBSERVES_HXX_ + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/idlc/inc/idlc/astoperation.hxx b/idlc/inc/idlc/astoperation.hxx new file mode 100644 index 000000000000..397e1c3396c0 --- /dev/null +++ b/idlc/inc/idlc/astoperation.hxx @@ -0,0 +1,78 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ +#ifndef _IDLC_ASTOPERATION_HXX_ +#define _IDLC_ASTOPERATION_HXX_ + +#include <idlc/astdeclaration.hxx> +#include <idlc/astscope.hxx> + +namespace typereg { class Writer; } + +#define OP_NONE 0x0000 +#define OP_ONEWAY 0x0001 + +class AstType; + +class AstOperation : public AstDeclaration + , public AstScope +{ +public: + AstOperation(sal_uInt32 flags, AstType* pReturnType, const ::rtl::OString& name, AstScope* pScope) + : AstDeclaration(NT_operation, name, pScope) + , AstScope(NT_operation) + , m_flags(flags) + , m_pReturnType(pReturnType) + {} + virtual ~AstOperation() {} + + sal_Bool isOneway() + { return ((m_flags & OP_ONEWAY) == OP_ONEWAY); } + + bool isVariadic() const; + + bool isConstructor() const { return m_pReturnType == 0; } + + void setExceptions(DeclList const * pExceptions); + const DeclList& getExceptions() + { return m_exceptions; } + sal_uInt16 nExceptions() + { return (sal_uInt16)(m_exceptions.size()); } + + sal_Bool dumpBlob(typereg::Writer & rBlob, sal_uInt16 index); + + // scope management + virtual AstDeclaration* addDeclaration(AstDeclaration* pDecl); +private: + sal_uInt32 m_flags; + AstType* m_pReturnType; + DeclList m_exceptions; +}; + +#endif // _IDLC_ASTOPERATION_HXX_ + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/idlc/inc/idlc/astparameter.hxx b/idlc/inc/idlc/astparameter.hxx new file mode 100644 index 000000000000..3d97e72d14b8 --- /dev/null +++ b/idlc/inc/idlc/astparameter.hxx @@ -0,0 +1,57 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef _IDLC_ASTPARAMETER_HXX_ +#define _IDLC_ASTPARAMETER_HXX_ + +#include <idlc/astmember.hxx> + +enum Direction { DIR_IN, DIR_OUT, DIR_INOUT }; + +class AstParameter: public AstMember { +public: + AstParameter( + Direction direction, bool rest, AstType const * type, + rtl::OString const & name, AstScope * scope): + AstMember(NT_parameter, type, name, scope), m_direction(direction), + m_rest(rest) {} + + virtual ~AstParameter() {} + + 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/idlc/astscope.hxx b/idlc/inc/idlc/astscope.hxx new file mode 100644 index 000000000000..e7f6a3962928 --- /dev/null +++ b/idlc/inc/idlc/astscope.hxx @@ -0,0 +1,80 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ +#ifndef _IDLC_ASTSCOPE_HXX_ +#define _IDLC_ASTSCOPE_HXX_ + +#include <idlc/idlc.hxx> + +class AstExpression; +#include <idlc/astdeclaration.hxx> +#include <idlc/astexpression.hxx> + +class AstScope +{ +public: + AstScope(NodeType nodeType); + virtual ~AstScope(); + + NodeType getScopeNodeType() const + { return m_nodeType; } + + virtual AstDeclaration* addDeclaration(AstDeclaration* pDecl); + + sal_uInt32 nMembers() const + { return (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); + + // Name look up mechanism + AstDeclaration* lookupByName(const ::rtl::OString& scopedName); + // Look up the identifier 'name' specified only in the local scope + AstDeclaration* lookupByNameLocal(const ::rtl::OString& name) const; + + AstDeclaration* lookupInForwarded(const ::rtl::OString& scopedName); + AstDeclaration* lookupInInherited(const ::rtl::OString& scopedName) const; + + // Look up a predefined type by its ExprType + AstDeclaration* lookupPrimitiveType(ExprType type); + + AstDeclaration* lookupForAdd(AstDeclaration* pDecl); + +protected: + inline AstDeclaration const * getLast() const + { return m_declarations.back(); } + +private: + DeclList m_declarations; + NodeType m_nodeType; +}; + +#endif // _IDLC_ASTSCOPE_HXX_ + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/idlc/inc/idlc/astsequence.hxx b/idlc/inc/idlc/astsequence.hxx new file mode 100644 index 000000000000..d7e3cec03b9d --- /dev/null +++ b/idlc/inc/idlc/astsequence.hxx @@ -0,0 +1,61 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ +#ifndef _IDLC_ASTSEQUENCE_HXX_ +#define _IDLC_ASTSEQUENCE_HXX_ + +#include <idlc/asttype.hxx> + +class AstSequence : public AstType +{ +public: + AstSequence(AstType* pMemberType, AstScope* pScope) + : AstType(NT_sequence, ::rtl::OString("[]")+pMemberType->getScopedName(), pScope) + , m_pMemberType(pMemberType) + , m_pRelativName(NULL) + {} + virtual ~AstSequence() + { + if ( m_pRelativName ) + delete m_pRelativName; + } + + AstType* getMemberType() const + { return m_pMemberType; } + + virtual bool isUnsigned() const + { return m_pMemberType != 0 && m_pMemberType->isUnsigned(); } + + virtual const sal_Char* getRelativName() const; +private: + AstType* m_pMemberType; + mutable ::rtl::OString* m_pRelativName; +}; + +#endif // _IDLC_ASTSEQUENCE_HXX_ + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/idlc/inc/idlc/astservice.hxx b/idlc/inc/idlc/astservice.hxx new file mode 100644 index 000000000000..862c33ce17c4 --- /dev/null +++ b/idlc/inc/idlc/astservice.hxx @@ -0,0 +1,62 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ +#ifndef _IDLC_ASTSERVICE_HXX_ +#define _IDLC_ASTSERVICE_HXX_ + +#include <idlc/astdeclaration.hxx> +#include <idlc/astscope.hxx> + +class AstService : public AstDeclaration + , public AstScope +{ +public: + AstService(const ::rtl::OString& name, AstScope* pScope) + : AstDeclaration(NT_service, name, pScope) + , AstScope(NT_service) + , m_defaultConstructor(false) + {} + AstService(const NodeType type, const ::rtl::OString& name, AstScope* pScope) + : AstDeclaration(type, name, pScope) + , AstScope(type) + , m_defaultConstructor(false) + {} + virtual ~AstService() {} + + virtual sal_Bool dump(RegistryKey& rKey); + + void setDefaultConstructor(bool b) { m_defaultConstructor = b; } + + bool checkLastConstructor() const; + +private: + bool m_defaultConstructor; +}; + +#endif // _IDLC_ASTSERVICE_HXX_ + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/idlc/inc/idlc/astservicemember.hxx b/idlc/inc/idlc/astservicemember.hxx new file mode 100644 index 000000000000..f8b7932a647f --- /dev/null +++ b/idlc/inc/idlc/astservicemember.hxx @@ -0,0 +1,55 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ +#ifndef _IDLC_ASTSERVICEMEMBER_HXX_ +#define _IDLC_ASTSERVICEMEMBER_HXX_ + +#include <idlc/astservice.hxx> + +class AstServiceMember : public AstDeclaration +{ +public: + AstServiceMember(const sal_uInt32 flags, AstService* pRealService, + const ::rtl::OString& name, AstScope* pScope) + : AstDeclaration(NT_service_member, name, pScope) + , m_flags(flags) + , m_pRealService(pRealService) + {} + virtual ~AstServiceMember() {} + + AstService* getRealService() + { return m_pRealService; } + sal_Bool isOptional() + { return ((m_flags & AF_OPTIONAL) == AF_OPTIONAL); } +private: + const sal_uInt32 m_flags; + AstService* m_pRealService; +}; + +#endif // _IDLC_ASTSERVICEMEMBER_HXX_ + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/idlc/inc/idlc/aststack.hxx b/idlc/inc/idlc/aststack.hxx new file mode 100644 index 000000000000..6604996c9bb2 --- /dev/null +++ b/idlc/inc/idlc/aststack.hxx @@ -0,0 +1,58 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ +#ifndef _IDLC_ASTSTACK_HXX_ +#define _IDLC_ASTSTACK_HXX_ + +#include <sal/types.h> + +class AstScope; + +class AstStack +{ +public: + AstStack(); + virtual ~AstStack(); + + sal_uInt32 depth(); + AstScope* top(); + AstScope* bottom(); + AstScope* nextToTop(); + AstScope* topNonNull(); + AstStack* push(AstScope* pScope); + void pop(); + void clear(); + +private: + AstScope** m_stack; + sal_uInt32 m_size; + sal_uInt32 m_top; +}; + +#endif // _IDLC_ASTSTACK_HXX_ + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/idlc/inc/idlc/aststruct.hxx b/idlc/inc/idlc/aststruct.hxx new file mode 100644 index 000000000000..98cadcc4899c --- /dev/null +++ b/idlc/inc/idlc/aststruct.hxx @@ -0,0 +1,71 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ +#ifndef _IDLC_ASTSTRUCT_HXX_ +#define _IDLC_ASTSTRUCT_HXX_ + +#include <idlc/asttype.hxx> +#include <idlc/astscope.hxx> +#include "idlc/idlctypes.hxx" + +class AstStruct; +typedef ::std::vector< AstStruct* > InheritedTypes; + +class AstStruct : public AstType + , public AstScope +{ +public: + AstStruct( + const ::rtl::OString& name, + std::vector< rtl::OString > const & typeParameters, + AstStruct* pBaseType, AstScope* pScope); + + AstStruct(const NodeType type, + const ::rtl::OString& name, + AstStruct* pBaseType, + AstScope* pScope); + virtual ~AstStruct(); + + AstStruct* getBaseType() + { return m_pBaseType; } + + DeclList::size_type getTypeParameterCount() const + { return m_typeParameters.size(); } + + AstDeclaration const * findTypeParameter(rtl::OString const & name) const; + + virtual bool isType() const; + + virtual sal_Bool dump(RegistryKey& rKey); +private: + AstStruct* m_pBaseType; + DeclList m_typeParameters; +}; + +#endif // _IDLC_ASTSTRUCT_HXX_ + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/idlc/inc/idlc/aststructinstance.hxx b/idlc/inc/idlc/aststructinstance.hxx new file mode 100644 index 000000000000..3428bc2be0b2 --- /dev/null +++ b/idlc/inc/idlc/aststructinstance.hxx @@ -0,0 +1,59 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef INCLUDED_idlc_inc_idlc_aststructinstance_hxx +#define INCLUDED_idlc_inc_idlc_aststructinstance_hxx + +#include "idlc/asttype.hxx" +#include "idlc/idlctypes.hxx" + +class AstDeclaration; +class AstScope; + +class AstStructInstance: 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/idlc/asttype.hxx b/idlc/inc/idlc/asttype.hxx new file mode 100644 index 000000000000..32a18ab671f5 --- /dev/null +++ b/idlc/inc/idlc/asttype.hxx @@ -0,0 +1,47 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ +#ifndef _IDLC_ASTTYPE_HXX_ +#define _IDLC_ASTTYPE_HXX_ + +#include <idlc/astdeclaration.hxx> + +class AstType : public AstDeclaration +{ +public: + AstType(const NodeType type, const ::rtl::OString& name, AstScope* pScope) + : AstDeclaration(type, name, pScope) + {} + + virtual ~AstType() {} + + virtual bool isUnsigned() const { return false; } +}; + +#endif // _IDLC_ASTTYPE_HXX_ + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/idlc/inc/idlc/asttypedef.hxx b/idlc/inc/idlc/asttypedef.hxx new file mode 100644 index 000000000000..2b1839dcadd9 --- /dev/null +++ b/idlc/inc/idlc/asttypedef.hxx @@ -0,0 +1,55 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ +#ifndef _IDLC_ASTTYPEDEF_HXX_ +#define _IDLC_ASTTYPEDEF_HXX_ + +#include <idlc/asttype.hxx> + +class AstTypeDef : public AstType +{ +public: + AstTypeDef( + AstType const * baseType, rtl::OString const & name, AstScope * scope): + AstType(NT_typedef, name, scope), m_pBaseType(baseType) {} + + virtual ~AstTypeDef() {} + + AstType const * getBaseType() const + { return m_pBaseType; } + + virtual bool isUnsigned() const + { return m_pBaseType != 0 && m_pBaseType->isUnsigned(); } + + virtual sal_Bool dump(RegistryKey& rKey); +private: + AstType const * m_pBaseType; +}; + +#endif // _IDLC_ASTTYPEDEF_HXX_ + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/idlc/inc/idlc/astunion.hxx b/idlc/inc/idlc/astunion.hxx new file mode 100644 index 000000000000..4435317bee37 --- /dev/null +++ b/idlc/inc/idlc/astunion.hxx @@ -0,0 +1,70 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ +#ifndef _IDLC_ASTUNION_HXX_ +#define _IDLC_ASTUNION_HXX_ + +#include <idlc/aststruct.hxx> +#include <idlc/astunionbranch.hxx> + +class AstUnion : public AstStruct +{ +public: + AstUnion(const ::rtl::OString& name, AstType* pDiscType, AstScope* pScope); + virtual ~AstUnion(); + + AstType* getDiscrimantType() + { return m_pDiscriminantType; } + ExprType getDiscrimantExprType() + { return m_discExprType; } + + virtual sal_Bool dump(RegistryKey& rKey); + + virtual AstDeclaration* addDeclaration(AstDeclaration* pDecl); +protected: + // Look up a branch by node pointer + AstUnionBranch* lookupBranch(AstUnionBranch* pBranch); + + // Look up the branch with the "default" label + AstUnionBranch* lookupDefault(sal_Bool bReportError = sal_True ); + + // Look up a branch given a branch with a label. This is used to + // check for duplicate labels + AstUnionBranch* lookupLabel(AstUnionBranch* pBranch); + + // Look up a union branch given an enumerator. This is used to + // check for duplicate enum labels + AstUnionBranch* lookupEnum(AstUnionBranch* pBranch); + +private: + AstType* m_pDiscriminantType; + ExprType m_discExprType; +}; + +#endif // _IDLC_ASTUNION_HXX_ + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/idlc/inc/idlc/astunionbranch.hxx b/idlc/inc/idlc/astunionbranch.hxx new file mode 100644 index 000000000000..20df92b90552 --- /dev/null +++ b/idlc/inc/idlc/astunionbranch.hxx @@ -0,0 +1,48 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ +#ifndef _IDLC_ASTUNIONBRANCH_HXX_ +#define _IDLC_ASTUNIONBRANCH_HXX_ + +#include <idlc/astmember.hxx> +#include <idlc/astunionlabel.hxx> + +class AstUnionBranch : public AstMember +{ +public: + AstUnionBranch(AstUnionLabel* pLabel, AstType const * pType, const ::rtl::OString& name, AstScope* pScope); + virtual ~AstUnionBranch(); + + AstUnionLabel* getLabel() + { return m_pLabel; } +private: + AstUnionLabel* m_pLabel; +}; + +#endif // _IDLC_ASTUNIONBRANCH_HXX_ + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/idlc/inc/idlc/astunionlabel.hxx b/idlc/inc/idlc/astunionlabel.hxx new file mode 100644 index 000000000000..d468884d5a01 --- /dev/null +++ b/idlc/inc/idlc/astunionlabel.hxx @@ -0,0 +1,54 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ +#ifndef _IDLC_ASTUNIONLABEL_HXX_ +#define _IDLC_ASTUNIONLABEL_HXX_ + +enum UnionLabel +{ + UL_default, // Label is "default" + UL_label // Regular label +}; + +class AstUnionLabel +{ +public: + AstUnionLabel(UnionLabel labelKind, AstExpression* pExpr); + virtual ~AstUnionLabel(); + + UnionLabel getLabelKind() + { return m_label; } + AstExpression* getLabelValue() + { return m_pLabelValue; } +private: + UnionLabel m_label; + AstExpression* m_pLabelValue; +}; + +#endif // _IDLC_ASTUNIONLABEL_HXX_ + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/idlc/inc/idlc/errorhandler.hxx b/idlc/inc/idlc/errorhandler.hxx new file mode 100644 index 000000000000..44d2a8a5a704 --- /dev/null +++ b/idlc/inc/idlc/errorhandler.hxx @@ -0,0 +1,159 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ +#ifndef _IDLC_ERRORHANDLER_HXX_ +#define _IDLC_ERRORHANDLER_HXX_ + +#include <idlc/astdeclaration.hxx> +#include <idlc/astexpression.hxx> +#include <idlc/astunion.hxx> +#include <idlc/astenum.hxx> + +enum ErrorCode +{ + EIDL_NONE, // No error + EIDL_SYNTAX_ERROR, // Syntax error in IDL input + // More details will be gleaned from examining + // the parse state + EIDL_REDEF, // Redefinition + EIDL_REDEF_SCOPE, // Redefinition inside defining scope + EIDL_DEF_USE, // Definition after use + EIDL_MULTIPLE_BRANCH, // More than one union branch with this label + EIDL_COERCION_FAILURE, // Coercion failure + EIDL_SCOPE_CONFLICT, // Between fwd declare and full declare + EIDL_ONEWAY_CONFLICT, // Between op decl and argument direction + EIDL_DISC_TYPE, // Illegal discriminator type in union + EIDL_LABEL_TYPE, // Mismatch with discriminator type in union + EIDL_ILLEGAL_ADD, // Illegal add action + EIDL_ILLEGAL_USE, // Illegal type used in expression + EIDL_ILLEGAL_RAISES, // Error in "raises" clause + EIDL_CANT_INHERIT, // Cannot inherit from non-interface + EIDL_LOOKUP_ERROR, // Identifier not found + EIDL_INHERIT_FWD_ERROR, // Cannot inherit from fwd decl interface + EIDL_CONSTANT_EXPECTED, // We got something else.. + EIDL_NAME_CASE_ERROR, // Spelling differences found + EIDL_ENUM_VAL_EXPECTED, // Expected an enumerator + EIDL_ENUM_VAL_NOT_FOUND, // Didnt find an enumerator with that name + EIDL_EVAL_ERROR, // Error in evaluating expression + EIDL_AMBIGUOUS, // Ambiguous name definition + EIDL_DECL_NOT_DEFINED, // Forward declared but never defined + EIDL_FWD_DECL_LOOKUP, // Tried to lookup in fwd declared intf + EIDL_RECURSIVE_TYPE, // Illegal recursive use of type + EIDL_NONVOID_ONEWAY, // Non-void return type in oneway operation + EIDL_NOT_A_TYPE, // Not a type + EIDL_TYPE_NOT_VALID, // Type is not valid in this context + EIDL_INTERFACEMEMBER_LOOKUP, // interface is not defined or a fwd declaration not exists + EIDL_SERVICEMEMBER_LOOKUP, + EIDL_TYPE_IDENT_CONFLICT, // type and identifier has equal names + EIDL_ONEWAY_RAISE_CONFLICT, // oneway function raised excpetion conflict + EIDL_WRONGATTRIBUTEFLAG, + EIDL_DEFINED_ATTRIBUTEFLAG, + EIDL_WRONGATTRIBUTEKEYWORD, + EIDL_MISSINGATTRIBUTEKEYWORD, + EIDL_BAD_ATTRIBUTE_FLAGS, + EIDL_OPTIONALEXPECTED, + EIDL_MIXED_INHERITANCE, + EIDL_DOUBLE_INHERITANCE, + EIDL_DOUBLE_MEMBER, + EIDL_CONSTRUCTOR_PARAMETER_NOT_IN, + EIDL_CONSTRUCTOR_REST_PARAMETER_NOT_FIRST, + EIDL_REST_PARAMETER_NOT_LAST, + EIDL_REST_PARAMETER_NOT_ANY, + EIDL_METHOD_HAS_REST_PARAMETER, + EIDL_READONLY_ATTRIBUTE_SET_EXCEPTIONS, + EIDL_UNSIGNED_TYPE_ARGUMENT, + EIDL_WRONG_NUMBER_OF_TYPE_ARGUMENTS, + EIDL_INSTANTIATED_STRUCT_TYPE_TYPEDEF, + EIDL_IDENTICAL_TYPE_PARAMETERS, + EIDL_STRUCT_TYPE_TEMPLATE_WITH_BASE, + EIDL_PUBLISHED_FORWARD, + EIDL_PUBLISHED_USES_UNPUBLISHED, + EIDL_SIMILAR_CONSTRUCTORS +}; + +enum WarningCode +{ + WIDL_EXPID_CONFLICT, // exception id conflict + WIDL_REQID_CONFLICT, // request id conflict + WIDL_INHERIT_IDCONFLICT, // request id conflict inheritance tree + WIDL_TYPE_IDENT_CONFLICT, // type and identifier has equal names + WIDL_WRONG_NAMING_CONV // type or identifier doesn't fulfill the UNO naming convention +}; + +class ErrorHandler +{ +public: + // Report errors with varying numbers of arguments + void error0(ErrorCode e); + void error1(ErrorCode e, AstDeclaration const * d); + void error2( + ErrorCode e, AstDeclaration const * d1, AstDeclaration const * d2); + void error3(ErrorCode e, AstDeclaration* d1, AstDeclaration* d2, AstDeclaration* d3); + + // Warning + void warning0(WarningCode e, const sal_Char* warningmsg); + + // Report a syntax error in IDL input + void syntaxError(ParseState state, sal_Int32 lineNumber, const sal_Char* errmsg); + + // Report an unsuccesful coercion attempt + void coercionError(AstExpression *pExpr, ExprType et); + + // Report a failed name lookup attempt + void lookupError(const ::rtl::OString& n); + // Report a failed name lookup attempt + void lookupError(ErrorCode e, const ::rtl::OString& n, AstDeclaration* pScope); + + + // Report a type error + void noTypeError(AstDeclaration const * pDecl); + + void inheritanceError(NodeType nodeType, const ::rtl::OString* name, AstDeclaration* pDecl); + + void flagError(ErrorCode e, sal_uInt32 flag); + + void forwardLookupError(AstDeclaration* pForward, const ::rtl::OString& name); + + void constantExpected(AstDeclaration* pDecl, const ::rtl::OString& name); + + void evalError(AstExpression* pExpr); + + // Report a situation where an enumerator was expected but we got + // something else instead. This occurs when a union with an enum + // discriminator is being parsed and one of the branch labels is + // not an enumerator in that enum + void enumValExpected(AstUnion* pUnion); + + // Report a failed enumerator lookup in an enum + void enumValLookupFailure(AstUnion* pUnion, AstEnum* pEnum, const ::rtl::OString& name); + + bool checkPublished(AstDeclaration const * decl, bool bOptiional=false); +}; + +#endif // _IDLC_ERRORHANDLER_HXX_ + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/idlc/inc/idlc/fehelper.hxx b/idlc/inc/idlc/fehelper.hxx new file mode 100644 index 000000000000..9c716da3edfd --- /dev/null +++ b/idlc/inc/idlc/fehelper.hxx @@ -0,0 +1,100 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ +#ifndef _IDLC_FEHELPER_HXX_ +#define _IDLC_FEHELPER_HXX_ + +#include <idlc/asttype.hxx> +#include <idlc/astinterface.hxx> + +#include <vector> + +class FeDeclarator +{ +public: + // Enum to denote types of declarators + enum DeclaratorType + { + FD_simple, // Simple declarator + FD_complex // Complex declarator (complex_part field used) + }; + + FeDeclarator(const ::rtl::OString& name, DeclaratorType declType, AstDeclaration* pComplPart); + virtual ~FeDeclarator(); + + AstDeclaration* getComplexPart() + { return m_pComplexPart; } + const ::rtl::OString& getName() + { return m_name; } + DeclaratorType getDeclType() + { return m_declType; } + + sal_Bool checkType(AstDeclaration const * pType); + AstType const * compose(AstDeclaration const * pDecl); +private: + AstDeclaration* m_pComplexPart; + ::rtl::OString m_name; + DeclaratorType m_declType; +}; + +typedef ::std::list< FeDeclarator* > FeDeclList; + +class FeInheritanceHeader +{ +public: + FeInheritanceHeader( + NodeType nodeType, ::rtl::OString* pName, ::rtl::OString* pInherits, + std::vector< rtl::OString > * typeParameters); + + virtual ~FeInheritanceHeader() + { + if ( m_pName ) + delete m_pName; + } + + NodeType getNodeType() + { return m_nodeType; } + ::rtl::OString* getName() + { return m_pName; } + AstDeclaration* getInherits() + { return m_pInherits; } + + std::vector< rtl::OString > const & getTypeParameters() const + { return m_typeParameters; } + +private: + void initializeInherits(::rtl::OString* pinherits); + + NodeType m_nodeType; + ::rtl::OString* m_pName; + AstDeclaration* m_pInherits; + std::vector< rtl::OString > m_typeParameters; +}; + +#endif // _IDLC_FEHELPER_HXX_ + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/idlc/inc/idlc/idlc.hxx b/idlc/inc/idlc/idlc.hxx new file mode 100644 index 000000000000..8262b26fc095 --- /dev/null +++ b/idlc/inc/idlc/idlc.hxx @@ -0,0 +1,178 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ +#ifndef _IDLC_IDLC_HXX_ +#define _IDLC_IDLC_HXX_ + +#include <idlc/idlctypes.hxx> +#include <idlc/aststack.hxx> +#include <idlc/options.hxx> + +#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 +{ +public: + Idlc(Options* pOptions); + virtual ~Idlc(); + + void init(); + + Options* getOptions() + { return m_pOptions; } + AstStack* scopes() + { return m_pScopes; } + AstModule* getRoot() + { return m_pRoot; } + ErrorHandler* error() + { return m_pErrorHandler; } + const ::rtl::OString& getFileName() + { return m_fileName; } + void setFileName(const ::rtl::OString& fileName) + { m_fileName = fileName; } + const ::rtl::OString& getMainFileName() + { return m_mainFileName; } + void setMainFileName(const ::rtl::OString& mainFileName) + { m_mainFileName = mainFileName; } + const ::rtl::OString& getRealFileName() + { return m_realFileName; } + void setRealFileName(const ::rtl::OString& realFileName) + { m_realFileName = realFileName; } + const ::rtl::OString& getDocumentation() + { + m_bIsDocValid = sal_False; + return m_documentation; + } + void setDocumentation(const ::rtl::OString& documentation) + { + m_documentation = documentation; + m_bIsDocValid = sal_True; + } + sal_Bool isDocValid(); + sal_Bool isInMainFile() + { return m_bIsInMainfile; } + void setInMainfile(sal_Bool bInMainfile) + { m_bIsInMainfile = bInMainfile; } + sal_uInt32 getErrorCount() + { return m_errorCount; } + void setErrorCount(sal_uInt32 errorCount) + { m_errorCount = errorCount; } + void incErrorCount() + { m_errorCount++; } + sal_uInt32 getWarningCount() + { return m_warningCount; } + void setWarningCount(sal_uInt32 warningCount) + { m_warningCount = warningCount; } + void incWarningCount() + { m_warningCount++; } + sal_uInt32 getLineNumber() + { return m_lineNumber; } + sal_uInt32 getOffsetStart() + { return m_offsetStart; } + sal_uInt32 getOffsetEnd() + { 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() + { return m_parseState; } + void setParseState(ParseState parseState) + { m_parseState = parseState; } + + void insertInclude(const ::rtl::OString& inc) + { m_includes.insert(inc); } + StringSet* getIncludes() + { return &m_includes; } + + void setPublished(bool published) { m_published = published; } + bool isPublished() const { return m_published; } + + void reset(); +private: + Options* m_pOptions; + AstStack* m_pScopes; + AstModule* m_pRoot; + ErrorHandler* m_pErrorHandler; + ::rtl::OString m_fileName; + ::rtl::OString m_mainFileName; + ::rtl::OString m_realFileName; + ::rtl::OString m_documentation; + sal_Bool m_bIsDocValid; + sal_Bool m_bGenerateDoc; + sal_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; + StringSet m_includes; +}; + +sal_Int32 compileFile(const ::rtl::OString * pathname); + // a null pathname means stdin +sal_Int32 produceFile(const ::rtl::OString& filenameBase); + // filenameBase is filename without ".idl" +void removeIfExists(const ::rtl::OString& pathname); + +::rtl::OString makeTempName(const ::rtl::OString& prefix, const ::rtl::OString& postfix); +sal_Bool copyFile(const ::rtl::OString* source, const ::rtl::OString& target); + // a null source means stdin + +sal_Bool isFileUrl(const ::rtl::OString& fileName); +::rtl::OString convertToAbsoluteSystemPath(const ::rtl::OString& fileName); +::rtl::OString convertToFileUrl(const ::rtl::OString& fileName); + +Idlc* SAL_CALL idlc(); +Idlc* SAL_CALL setIdlc(Options* pOptions); + +AstDeclaration const * resolveTypedefs(AstDeclaration const * type); + +AstDeclaration const * deconstructAndResolveTypedefs( + AstDeclaration const * type, sal_Int32 * rank); + +AstInterface const * resolveInterfaceTypedefs(AstType const * type); + +#endif // _IDLC_IDLC_HXX_ + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/idlc/inc/idlc/idlctypes.hxx b/idlc/inc/idlc/idlctypes.hxx new file mode 100644 index 000000000000..0849dd85fb28 --- /dev/null +++ b/idlc/inc/idlc/idlctypes.hxx @@ -0,0 +1,268 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ +#ifndef _IDLC_IDLCTYPES_HXX_ +#define _IDLC_IDLCTYPES_HXX_ + +#include <stdio.h> + +#include <hash_map> +#include <list> +#include <vector> +#include <set> +#include <sal/types.h> +#include <rtl/ustring.hxx> + +struct EqualString +{ + sal_Bool operator()(const ::rtl::OString& str1, const ::rtl::OString& str2) const + { + return (str1 == str2); + } +}; + +struct HashString +{ + sal_Int32 operator()(const ::rtl::OString& str) const + { + return str.hashCode(); + } +}; + +struct LessString +{ + sal_Bool operator()(const ::rtl::OString& str1, const ::rtl::OString& str2) const + { + return (str1 < str2); + } +}; + +typedef ::std::list< ::rtl::OString > StringList; +typedef ::std::vector< ::rtl::OString > StringVector; +typedef ::std::set< ::rtl::OString, LessString > StringSet; + +class AstExpression; +typedef ::std::list< AstExpression* > ExprList; + +class AstUnionLabel; +typedef ::std::list< AstUnionLabel* > LabelList; + +class AstDeclaration; + +typedef ::std::hash_map< ::rtl::OString, AstDeclaration*, HashString, EqualString > DeclMap; +typedef ::std::list< AstDeclaration* > DeclList; + +class AstScope; +AstDeclaration* SAL_CALL scopeAsDecl(AstScope* pScope); +AstScope* SAL_CALL declAsScope(AstDeclaration* pDecl); + +#ifdef _MSC_VER +#pragma warning( disable : 4541 ) +#endif + +// 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_REMOVEABLE 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 an 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_SingletonMemberSeen, // Seen a singleton member + + 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_UnionSeen, // Seen a UNION keyword + PS_UnionIDSeen, // Seen the union ID + PS_SwitchSeen, // Seen the SWITCH keyword + PS_SwitchOpenParSeen, // Seen the switch open par. + PS_SwitchTypeSeen, // Seen the switch type spec + PS_SwitchCloseParSeen, // Seen the switch close par. + PS_UnionSqSeen, // '{' seen for union + PS_UnionQsSeen, // '}' seen for union + PS_DefaultSeen, // Seen DEFAULT keyword + PS_UnionLabelSeen, // Seen label of union element + PS_LabelColonSeen, // Seen ':' of union branch label + PS_LabelExprSeen, // Seen expression of union branch label + PS_UnionElemSeen, // Seen a union element + PS_UnionElemCompleted, // Completed one union member up to ';' + PS_CaseSeen, // Seen a CASE keyword + PS_UnionElemTypeSeen, // Seen type spec for union element + PS_UnionElemDeclSeen, // Seen declarator for union element + PS_UnionBodySeen, // Seen completed union body + + 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_ArrayIDSeen, // Seen array ID + PS_ArrayTypeSeen, // Seen array type + PS_ArrayCompleted, // Seen completed array declaration + PS_DimSqSeen, // Seen '[' for array dimension + PS_DimQsSeen, // Seen ']' for array dimension + PS_DimExprSeen, // Seen size expression for array dimension + + + 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_MayBeAmbigiousSeen, // Seen MAYBEAMBIGIOUS keyword + PS_MayBeDefaultSeen, // Seen MAYBEDEFAULT keyword + PS_RemoveableSeen, // Seen REMOVEABLE 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_OpHeadSeen, // Seen the operation head + PS_OpTypeSeen, // Seen operation return type + PS_OpIDSeen, // Seen operation ID + PS_OpParsCompleted, // Completed operation param list + PS_OpCompleted, // Completed operation statement + 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_OpOnewaySeen, // Seen ONEWAY keyword + + 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 +}; + +#endif // _IDLC_IDLCTYPES_HXX_ + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/idlc/inc/idlc/inheritedinterface.hxx b/idlc/inc/idlc/inheritedinterface.hxx new file mode 100644 index 000000000000..e983c751acd2 --- /dev/null +++ b/idlc/inc/idlc/inheritedinterface.hxx @@ -0,0 +1,64 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef INCLUDED_idlc_inc_idlc_inheritedinterface_hxx +#define INCLUDED_idlc_inc_idlc_inheritedinterface_hxx + +#include "idlc/idlc.hxx" + +#include "rtl/ustring.hxx" + +class AstInterface; +class AstType; + +class InheritedInterface { +public: + InheritedInterface( + AstType const * theInterface, bool theOptional, + rtl::OUString const & theDocumentation): + interface(theInterface), optional(theOptional), + documentation(theDocumentation) {} + + AstType const * getInterface() const { return interface; } + + AstInterface const * getResolved() const + { return resolveInterfaceTypedefs(interface); } + + bool isOptional() const { return optional; } + + rtl::OUString getDocumentation() const { return documentation; } + +private: + AstType const * interface; + bool optional; + rtl::OUString documentation; +}; + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/idlc/inc/idlc/options.hxx b/idlc/inc/idlc/options.hxx new file mode 100644 index 000000000000..796552aec671 --- /dev/null +++ b/idlc/inc/idlc/options.hxx @@ -0,0 +1,82 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef _IDLC_OPTIONS_HXX_ +#define _IDLC_OPTIONS_HXX_ + +#include <idlc/idlctypes.hxx> + +typedef ::std::hash_map< ::rtl::OString, + ::rtl::OString, + HashString, + EqualString > OptionMap; + +class IllegalArgument +{ +public: + IllegalArgument(const ::rtl::OString& msg) + : m_message(msg) {} + + ::rtl::OString m_message; +}; + + +class Options +{ +public: + Options(); + ~Options(); + + sal_Bool initOptions(int ac, char* av[], sal_Bool bCmdFile=sal_False) + throw( IllegalArgument ); + + ::rtl::OString prepareHelp(); + ::rtl::OString prepareVersion(); + + const ::rtl::OString& getProgramName() const; + sal_Bool isValid(const ::rtl::OString& option); + const ::rtl::OString getOption(const ::rtl::OString& option) + throw( IllegalArgument ); + + const StringVector& getInputFiles() const { return m_inputFiles; } + bool readStdin() const { return m_stdin; } + bool verbose() const { return m_verbose; } + bool quiet() const { return m_quiet; } + +protected: + ::rtl::OString m_program; + StringVector m_inputFiles; + bool m_stdin; + bool m_verbose; + bool m_quiet; + OptionMap m_options; +}; + +#endif // _IDLC_OPTIONS_HXX_ + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |