📄 template.py
字号:
# -*- python -*-# Package : omniidl# template.py Created on: 2000/01/18# Author : David Scott (djs)## Copyright (C) 1999 AT&T Laboratories Cambridge## This file is part of omniidl.## omniidl is free software; you can redistribute it and/or modify it# under the terms of the GNU General Public License as published by# the Free Software Foundation; either version 2 of the License, or# (at your option) any later version.## This program 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# General Public License for more details.## You should have received a copy of the GNU General Public License# along with this program; if not, write to the Free Software# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA# 02111-1307, USA.## Description:# # C++ templates for the .hh file# $Id: template.py,v 1.5.2.27 2005/12/30 17:40:21 dgrisby Exp $# $Log: template.py,v $# Revision 1.5.2.27 2005/12/30 17:40:21 dgrisby# Previously extern inline functions are now just inline or static# inline when inside classes.## Revision 1.5.2.26 2005/12/15 12:01:36 dgrisby# Functions declared extern inline upset the IRIX compiler.## Revision 1.5.2.25 2005/07/21 15:25:09 dgrisby# Silence some gcc 4 warnings / errors.## Revision 1.5.2.24 2004/10/18 02:44:37 dgrisby# New -Wbdll_includes option.## Revision 1.5.2.23 2004/07/29 10:36:34 dgrisby# Bug with unmarshalling unions with multiple case labels.## Revision 1.5.2.22 2004/07/23 14:07:04 dgrisby# Subtly incorrect generated code for arrays.## Revision 1.5.2.21 2004/04/19 09:25:21 dgrisby# Nil object references are bound to the lifetime of the skeleton file# if OMNI_UNLOADABLE_STUBS is defined.## Revision 1.5.2.20 2004/02/11 11:49:57 dgrisby# Generate _out types for simple typedefs.## Revision 1.5.2.19 2001/11/12 13:46:07 dpg1# _unchecked_narrow, improved _narrow.## Revision 1.5.2.18 2001/11/08 16:33:51 dpg1# Local servant POA shortcut policy.## Revision 1.5.2.17 2001/10/29 17:42:41 dpg1# Support forward-declared structs/unions, ORB::create_recursive_tc().## Revision 1.5.2.16 2001/10/18 12:45:28 dpg1# IDL compiler tweaks.## Revision 1.5.2.15 2001/10/17 16:44:05 dpg1# Update DynAny to CORBA 2.5 spec, const Any exception extraction.## Revision 1.5.2.14 2001/09/19 17:29:04 dpg1# Cosmetic changes.## Revision 1.5.2.13 2001/08/17 13:45:56 dpg1# C++ mapping fixes.## Revision 1.5.2.12 2001/08/15 10:26:10 dpg1# New object table behaviour, correct POA semantics.## Revision 1.5.2.11 2001/08/03 17:41:17 sll# System exception minor code overhaul. When a system exeception is raised,# a meaning minor code is provided.## Revision 1.5.2.10 2001/07/31 19:25:11 sll# Array _var should be separated into fixed and variable size ones.## Revision 1.5.2.9 2001/06/18 20:30:51 sll# Only define 1 conversion operator from T_var to T* if the compiler is# gcc. Previously, this is only done for gcc 2.7.2. It seems that gcc 3.0# requires this to be the case. This is the default for all versions of# gcc.## Revision 1.5.2.8 2001/05/29 17:03:50 dpg1# In process identity.## Revision 1.5.2.7 2001/04/19 09:30:12 sll# Big checkin with the brand new internal APIs.# Scoped where appropriate with the omni namespace.## Revision 1.5.2.6 2001/03/13 10:32:09 dpg1# Fixed point support.## Revision 1.5.2.5 2000/11/20 14:43:25 sll# Added support for wchar and wstring.## Revision 1.5.2.4 2000/11/09 12:27:55 dpg1# Huge merge from omni3_develop, plus full long long from omni3_1_develop.## Revision 1.5.2.3 2000/11/03 19:20:41 sll# Replaced old marshal operators with a unified operator for cdrStream.## Revision 1.5.2.2 2000/10/12 15:37:51 sll# Updated from omni3_1_develop.## Revision 1.6.2.2 2000/08/21 11:35:18 djs# Lots of tidying## Revision 1.6.2.1 2000/08/02 10:52:02 dpg1# New omni3_1_develop branch, merged from omni3_develop.## Revision 1.6 2000/07/13 15:26:00 dpg1# Merge from omni3_develop for 3.0 release.## Revision 1.3.2.15 2000/07/26 15:29:11 djs# Missing typedef and forward when generating BOA skeletons## Revision 1.3.2.14 2000/07/24 09:35:20 dpg1# Adding the missing constructor meant that there was no longer a# default constructor.## Revision 1.3.2.13 2000/07/24 10:17:31 djs# Added missing BOA skeleton constructor## Revision 1.3.2.12 2000/07/04 12:57:55 djs# Fixed Any insertion/extraction operators for unions and exceptions## Revision 1.3.2.11 2000/06/26 16:24:00 djs# Better handling of #include'd files (via new commandline options)# Refactoring of configuration state mechanism.## Revision 1.3.2.10 2000/06/19 18:19:50 djs# Implemented union discriminant setting function _d(_value) with checks for# illegal uses (setting to a label corresponding to a non-current member and# setting before initialisation)## Revision 1.3.2.9 2000/06/05 13:03:57 djs# Removed union member name clash (x & pd_x, pd__default, pd__d)# Removed name clash when a sequence is called "pd_seq"# Nested union within union fix# Actually generates BOA non-flattened tie templates## Revision 1.3.2.8 2000/05/31 18:02:58 djs# Better output indenting (and preprocessor directives now correctly output at# the beginning of lines)## Revision 1.3.2.7 2000/05/30 15:59:25 djs# Removed inheritance ambiguity in generated BOA _sk_ and POA_ classes## Revision 1.3.2.6 2000/05/18 15:57:33 djs# Added missing T* data constructor for bounded sequence types## Revision 1.3.2.5 2000/03/20 11:50:20 djs# Removed excess buffering- output templates have code attached which is# lazily evaluated when required.## Revision 1.3.2.4 2000/03/10 12:01:03 djr# Re-fixed omniidl (make exception _NP_duplicate() public).## Revision 1.3.2.3 2000/03/09 15:22:42 djs# Changing the protection status of an exception method, mirroring a change# in omniidl3## Revision 1.3.2.2 2000/03/07 18:07:33 djr# Fixed user-exceptions when can't catch by base class.## Revision 1.3.2.1 2000/03/03 14:29:17 djr# Improvement to BOA skeletons (less generated code).## Revision 1.3 2000/02/01 09:26:45 djs# Tracking fixes in old compiler: powerpc-aix scoped identifier workarounds## Revision 1.2 2000/01/19 11:23:29 djs# Moved most C++ code to template file## Revision 1.1 2000/01/18 18:05:53 djs# Extracted most C++ from header/defs and put in a template file.# General refactoring.#"""C++ templates for the .hh file"""#### File header##header = """\// This file is generated by @program@- @library@. Do not edit.#ifndef __@guard@_hh__#define __@guard@_hh__"""footer = """\#endif"""#### Main file##main = """\#ifndef USE_omniORB_logStream#define USE_omniORB_logStream#endif#ifndef __CORBA_H_EXTERNAL_GUARD__#include <omniORB4/CORBA.h>#endif#ifndef USE_core_stub_in_nt_dll# define USE_core_stub_in_nt_dll_NOT_DEFINED_@guard@#endif#ifndef USE_dyn_stub_in_nt_dll# define USE_dyn_stub_in_nt_dll_NOT_DEFINED_@guard@#endif@sub_include_pre@@cxx_direct_include@@includes@@sub_include_post@#ifdef USE_stub_in_nt_dll#ifndef USE_core_stub_in_nt_dll#define USE_core_stub_in_nt_dll#endif#ifndef USE_dyn_stub_in_nt_dll#define USE_dyn_stub_in_nt_dll#endif#endif#ifdef _core_attr# error "A local CPP macro _core_attr has already been defined."#else# ifdef USE_core_stub_in_nt_dll# define _core_attr _OMNIORB_NTDLL_IMPORT# else# define _core_attr# endif#endif#ifdef _dyn_attr# error "A local CPP macro _dyn_attr has already been defined."#else# ifdef USE_dyn_stub_in_nt_dll# define _dyn_attr _OMNIORB_NTDLL_IMPORT# else# define _dyn_attr# endif#endif@forward_declarations@@string_tcParser_declarations@@defs@@poa@@other_tie@#undef _core_attr#undef _dyn_attr@operators@@marshalling@#ifdef USE_core_stub_in_nt_dll_NOT_DEFINED_@guard@# undef USE_core_stub_in_nt_dll# undef USE_core_stub_in_nt_dll_NOT_DEFINED_@guard@#endif#ifdef USE_dyn_stub_in_nt_dll_NOT_DEFINED_@guard@# undef USE_dyn_stub_in_nt_dll# undef USE_dyn_stub_in_nt_dll_NOT_DEFINED_@guard@#endif#endif // __@guard@_hh__"""sub_include_pre = """\#ifdef INCLUDED_stub_in_nt_dll# ifdef USE_stub_in_nt_dll# error "cannot use both INCLUDED_stub_in_nt_dll and USE_stub_in_nt_dll."# else# define USE_stub_in_nt_dll# endif# define INCLUDED_stub_in_nt_dll_DEFINED_@guard@# undef INCLUDED_stub_in_nt_dll#endif"""sub_include_post = """\#ifdef INCLUDED_stub_in_nt_dll_DEFINED_@guard@# undef USE_stub_in_nt_dll# define INCLUDED_stub_in_nt_dll # undef INCLUDED_stub_in_nt_dll_DEFINED_@guard@#endif"""main_include = """\#ifndef __@guardname@_EXTERNAL_GUARD__#define __@guardname@_EXTERNAL_GUARD__#include @filename@#endif"""#### tcParser_unionHelper forward declaration##tcParser_unionHelper = """\// Declare helper class for union type @fqname@class @private_prefix@_tcParser_unionhelper_@guard_name@;"""#### Modules### name => C++ form of the module identifiermodule_begin = """\_CORBA_MODULE @name@_CORBA_MODULE_BEG"""module_end = """\_CORBA_MODULE_END"""POA_module_begin = """\_CORBA_MODULE @POA_prefix@@name@_CORBA_MODULE_BEG"""POA_module_end = """\_CORBA_MODULE_END"""POA_interface = """\class @POA_name@ : public virtual @impl_scopedID@, @inherits@{public: virtual ~@POA_name@(); inline ::@scopedID@_ptr _this() { return (::@scopedID@_ptr) _do_this(::@scopedID@::_PD_repoId); }};"""#### Interfaces##interface_Helper = """\#ifndef __@guard@__#define __@guard@__class @name@;class _objref_@name@;class _impl_@name@;@class_sk_name@typedef _objref_@name@* @name@_ptr;typedef @name@_ptr @name@Ref;class @name@_Helper {public: typedef @name@_ptr _ptr_type; static _ptr_type _nil(); static _CORBA_Boolean is_nil(_ptr_type); static void release(_ptr_type); static void duplicate(_ptr_type); static void marshalObjRef(_ptr_type, cdrStream&); static _ptr_type unmarshalObjRef(cdrStream&);};typedef _CORBA_ObjRef_Var<_objref_@name@, @name@_Helper> @name@_var;typedef _CORBA_ObjRef_OUT_arg<_objref_@name@,@name@_Helper > @name@_out;#endif"""interface_type = """\class @name@ {public: // Declarations for this interface type. typedef @name@_ptr _ptr_type; typedef @name@_var _var_type; static _ptr_type _duplicate(_ptr_type); static _ptr_type _narrow(CORBA::Object_ptr); static _ptr_type _unchecked_narrow(CORBA::Object_ptr); static _ptr_type _nil(); static inline void _marshalObjRef(_ptr_type, cdrStream&); static inline _ptr_type _unmarshalObjRef(cdrStream& s) { omniObjRef* o = omniObjRef::_unMarshal(_PD_repoId,s); if (o) return (_ptr_type) o->_ptrToObjRef(_PD_repoId); else return _nil(); } static _core_attr const char* _PD_repoId; // Other IDL defined within this scope. @Other_IDL@};"""interface_objref = """\class _objref_@name@ : @inherits@{public: @operations@ inline _objref_@name@() @init_shortcut@ { _PR_setobj(0); } // nil _objref_@name@(omniIOR*, omniIdentity*);protected: virtual ~_objref_@name@(); @shortcut@private: virtual void* _ptrToObjRef(const char*); _objref_@name@(const _objref_@name@&); _objref_@name@& operator = (const _objref_@name@&); // not implemented friend class @name@;};"""interface_shortcut = """\virtual void _enableShortcut(omniServant*, const _CORBA_Boolean*);_impl_@name@* _shortcut;const _CORBA_Boolean* _invalid;\"""interface_pof = """\class _pof_@name@ : public _OMNI_NS(proxyObjectFactory) {public: inline _pof_@name@() : _OMNI_NS(proxyObjectFactory)(@name@::_PD_repoId) {} virtual ~_pof_@name@(); virtual omniObjRef* newObjRef(omniIOR*,omniIdentity*); virtual _CORBA_Boolean is_a(const char*) const;};"""interface_impl = """\class _impl_@name@ : @inherits@{public: virtual ~_impl_@name@();
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -