📄 template.py
字号:
# -*- python -*-# Package : omniidl# template.py Created on: 2000/01/19# 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 SK.cc file# $Id: template.py,v 1.3.2.31 2005/03/29 15:52:53 dgrisby Exp $# $Log: template.py,v $# Revision 1.3.2.31 2005/03/29 15:52:53 dgrisby# Change on 1st July to void operation call descriptors broke with# compilers that cannot catch by base class.## Revision 1.3.2.30 2004/10/17 21:47:40 dgrisby# Fully qualify scopes in _ptrToObjRef and _ptrToInterface.## Revision 1.3.2.29 2004/07/29 10:45:22 dgrisby# Bug with unmarshalling unions with multiple case labels.## Revision 1.3.2.28 2004/07/23 14:07:04 dgrisby# Subtly incorrect generated code for arrays.## Revision 1.3.2.27 2004/07/01 19:13:32 dgrisby# Suppress compiler warnings on void methods. Thanks Peter Klotz.## Revision 1.3.2.26 2004/04/19 09:25:26 dgrisby# Nil object references are bound to the lifetime of the skeleton file# if OMNI_UNLOADABLE_STUBS is defined.## Revision 1.3.2.25 2003/07/25 16:03:06 dgrisby# Initialise base classes in correct order.## Revision 1.3.2.24 2003/06/19 16:22:21 dgrisby# Updates to facilitate Windows omniNotify port. Work around DLL issues# and a compiler bug.## Revision 1.3.2.23 2002/01/16 11:31:58 dpg1# Race condition in use of registerNilCorbaObject/registerTrackedObject.# (Reported by Teemu Torma).## Revision 1.3.2.22 2001/11/27 14:35:09 dpg1# Context, DII fixes.## Revision 1.3.2.21 2001/11/13 14:14:45 dpg1# Bug when no catch by base class.## Revision 1.3.2.20 2001/11/12 13:46:07 dpg1# _unchecked_narrow, improved _narrow.## Revision 1.3.2.19 2001/11/09 09:56:11 dpg1# Missed a file in yesterday's checkin.## Revision 1.3.2.18 2001/11/07 15:45:53 dpg1# Faster _ptrToInterface/_ptrToObjRef in common cases.## Revision 1.3.2.17 2001/11/06 15:41:37 dpg1# Reimplement Context. Remove CORBA::Status. Tidying up.## Revision 1.3.2.16 2001/10/29 17:42:42 dpg1# Support forward-declared structs/unions, ORB::create_recursive_tc().## Revision 1.3.2.15 2001/10/18 12:45:29 dpg1# IDL compiler tweaks.## Revision 1.3.2.14 2001/10/17 16:44:06 dpg1# Update DynAny to CORBA 2.5 spec, const Any exception extraction.## Revision 1.3.2.13 2001/09/19 17:26:47 dpg1# Full clean-up after orb->destroy().## Revision 1.3.2.12 2001/08/15 10:26:11 dpg1# New object table behaviour, correct POA semantics.## Revision 1.3.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.3.2.10 2001/07/25 13:40:53 dpg1# Suppress compiler warning about unused variable in _dispatch() for# empty interfaces.## Revision 1.3.2.9 2001/06/08 17:12:20 dpg1# Merge all the bug fixes from omni3_develop.## Revision 1.3.2.8 2001/05/31 16:18:12 dpg1# inline string matching functions, re-ordered string matching in# _ptrToInterface/_ptrToObjRef## Revision 1.3.2.7 2001/05/29 17:03:50 dpg1# In process identity.## Revision 1.3.2.6 2001/05/02 14:20:15 sll# Make sure that getStream() is used instead of casting to get a cdrStream# from a IOP_C and IOP_S.## Revision 1.3.2.5 2001/04/19 09:30:11 sll# Big checkin with the brand new internal APIs.# Scoped where appropriate with the omni namespace.## Revision 1.3.2.4 2000/11/09 12:27:56 dpg1# Huge merge from omni3_develop, plus full long long from omni3_1_develop.## Revision 1.3.2.3 2000/11/03 19:23:53 sll# Replace the old set of marshalling operators in the generated code with# a couple of unified operators for cdrStream. Changed template to correspond# to the new callDescriptor structure and the new way to dispatch a call on# the server side.## Revision 1.3.2.2 2000/10/12 15:37:53 sll# Updated from omni3_1_develop.## Revision 1.4.2.2 2000/08/21 11:35:34 djs# Lots of tidying## Revision 1.4.2.1 2000/08/02 10:52:01 dpg1# New omni3_1_develop branch, merged from omni3_develop.## Revision 1.4 2000/07/13 15:25:59 dpg1# Merge from omni3_develop for 3.0 release.## Revision 1.1.2.8 2000/07/24 16:32:19 djs# Fixed typo in previous BOA skeleton bugfix.# Suppressed compiler warning (from gcc -Wall) when encountering a call with# no arguments and no return value.## Revision 1.1.2.7 2000/07/24 10:17:34 djs# Added missing BOA skeleton constructor## Revision 1.1.2.6 2000/06/05 13:04:20 djs# Removed union member name clash (x & pd_x, pd__default, pd__d)# Removed name clash when a sequence is called "pd_seq"## Revision 1.1.2.5 2000/05/31 18:03:40 djs# Better output indenting (and preprocessor directives now correctly output at# the beginning of lines)# Calling an exception "e" resulted in a name clash (and resultant C++# compile failure)## Revision 1.1.2.4 2000/05/05 16:50:53 djs# Existing workaround for MSVC5 scoping problems extended to help with# base class initialisers. Instead of using the fully qualified or unambiguous# name, a flat typedef is generated at global scope and that is used instead.# This was a solution to a previous bug wrt operation dispatch()ing.# This does not affect the OMNI_BASE_CTOR powerpc/aix workaround.## Revision 1.1.2.3 2000/04/26 18:22:57 djs# Rewrote type mapping code (now in types.py)# Rewrote identifier handling code (now in id.py)# Removed superfluous externs in front of function definitions## Revision 1.1.2.2 2000/04/20 15:11:28 djr# Fixed bug when duplicating a nil object reference.## Revision 1.1.2.1 2000/03/20 11:50:28 djs# Removed excess buffering- output templates have code attached which is# lazily evaluated when required.## Revision 1.1 2000/01/19 17:05:16 djs# Modified to use an externally stored C++ output template.#"""C++ templates for the SK.cc file"""#### Includes##boilerplate = """\// This file is generated by @program@- @library@. Do not edit.#include "@basename@@hh@"#include <omniORB4/IOP_S.h>#include <omniORB4/IOP_C.h>#include <omniORB4/callDescriptor.h>#include <omniORB4/callHandle.h>#include <omniORB4/objTracker.h>@include_omniAMICallDescriptor@OMNI_USING_NAMESPACE(omni)static const char* @prefix@_library_version = @library@;"""#### Interface##interface_POA = """\POA_@fqname@::~@POA_prefix@@name@() {}"""interface_Helper = """\@name@_ptr @name@_Helper::_nil() { return ::@name@::_nil();}CORBA::Boolean @name@_Helper::is_nil(::@name@_ptr p) { return CORBA::is_nil(p);\n}void @name@_Helper::release(::@name@_ptr p) { CORBA::release(p);}void @name@_Helper::duplicate(::@name@_ptr p) { if( p && !p->_NP_is_nil() ) omni::duplicateObjRef(p);}void @name@_Helper::marshalObjRef(::@name@_ptr obj, cdrStream& s) { ::@name@::_marshalObjRef(obj, s);}@name@_ptr @name@_Helper::unmarshalObjRef(cdrStream& s) { return ::@name@::_unmarshalObjRef(s);}"""interface_class = """\@name@_ptr@name@::_duplicate(::@name@_ptr obj){ if( obj && !obj->_NP_is_nil() ) omni::duplicateObjRef(obj); return obj;}@name@_ptr@name@::_narrow(CORBA::Object_ptr obj){ if( !obj || obj->_NP_is_nil() || obj->_NP_is_pseudo() ) return _nil(); _ptr_type e = (_ptr_type) obj->_PR_getobj()->_realNarrow(_PD_repoId); return e ? e : _nil();}@name@_ptr@name@::_unchecked_narrow(CORBA::Object_ptr obj){ if( !obj || obj->_NP_is_nil() || obj->_NP_is_pseudo() ) return _nil(); _ptr_type e = (_ptr_type) obj->_PR_getobj()->_uncheckedNarrow(_PD_repoId); return e ? e : _nil();}@name@_ptr@name@::_nil(){#ifdef OMNI_UNLOADABLE_STUBS static @objref_name@ _the_nil_obj; return &_the_nil_obj;#else static @objref_name@* _the_nil_ptr = 0; if( !_the_nil_ptr ) { omni::nilRefLock().lock(); if( !_the_nil_ptr ) { _the_nil_ptr = new @objref_name@; registerNilCorbaObject(_the_nil_ptr); } omni::nilRefLock().unlock(); } return _the_nil_ptr;#endif}const char* @name@::_PD_repoId = "@repoID@";"""interface_objref = """\@fq_objref_name@::~@objref_name@() {}@fq_objref_name@::@objref_name@(omniIOR* ior, omniIdentity* id) : omniObjRef(::@name@::_PD_repoId, ior, id, 1)@comma@ @inherits_str@ @init_shortcut@{ _PR_setobj(this);}void*@fq_objref_name@::_ptrToObjRef(const char* id){ if( id == ::@name@::_PD_repoId ) return (::@name@_ptr) this; @_ptrToObjRef_ptr@ if( id == ::CORBA::Object::_PD_repoId ) return (::CORBA::Object_ptr) this; if( omni::strMatch(id, ::@name@::_PD_repoId) ) return (::@name@_ptr) this; @_ptrToObjRef_str@ if( omni::strMatch(id, ::CORBA::Object::_PD_repoId) ) return (::CORBA::Object_ptr) this; return 0;}"""interface_objref_repoID_ptr = """\if( id == ::@inherits_fqname@::_PD_repoId ) return (::@inherits_fqname@_ptr) this;"""interface_objref_repoID_str = """\if( omni::strMatch(id, ::@inherits_fqname@::_PD_repoId) ) return (::@inherits_fqname@_ptr) this;"""interface_shortcut = """\void@fq_objref_name@::_enableShortcut(omniServant* _svt, const _CORBA_Boolean* _inv){ if (_svt) _shortcut = (_impl_@basename@*)_svt->_ptrToInterface(::@name@::_PD_repoId); else _shortcut = 0; _invalid = _inv; @inherited@}"""interface_shortcut_inh = """\@parent@::_enableShortcut(_svt, _inv);"""interface_callback = """\// Local call call-back function.static void@local_call_descriptor@(omniCallDescriptor* cd, omniServant* svnt){ @get_call_descriptor@ @impl_fqname@* impl = (@impl_fqname@*) svnt->_ptrToInterface(@name@::_PD_repoId);@impl_call@}"""interface_callback_context = """\ CORBA::Context_var ctxt; if (cd->is_upcall()) ctxt = CORBA::Context::_duplicate(tcd->ctxt); else ctxt = CORBA::Context::filterContext(tcd->ctxt, @cname@, @count@);"""interface_callback_invoke = """\ @result@impl->@cxx_operation_name@(@operation_arguments@);"""interface_callback_tryblock = """\#ifdef HAS_Cplusplus_catch_exception_by_base @result@impl->@cxx_operation_name@(@operation_arguments@);#else if (!cd->is_upcall()) @result@impl->@cxx_operation_name@(@operation_arguments@); else { try { @result@impl->@cxx_operation_name@(@operation_arguments@); } @catch@ }#endif"""interface_proxy_class = """\// Proxy call descriptor class. Mangled signature:// @signature@class @call_descriptor@ : public omniCallDescriptor{public: inline @call_descriptor@(@ctor_args@): @base_ctor@ {} @in_arguments_decl@ @out_arguments_decl@ @user_exceptions_decl@ @member_data@};"""interface_context_array = """\static const char*const @context_descriptor@[] = { @contexts@ 0};"""interface_proxy_marshal_arguments = """\void @call_descriptor@::marshalArguments(cdrStream& _n){ @marshal_block@}"""interface_proxy_marshal_context = """\CORBA::Context::marshalContext(ctxt, @name@, @count@, _n);"""interface_proxy_unmarshal_arguments = """\void @call_descriptor@::unmarshalArguments(cdrStream& _n){ @marshal_block@}"""interface_proxy_unmarshal_context = """\ctxt = CORBA::Context::unmarshalContext(_n);"""interface_proxy_marshal_returnedvalues = """\void @call_descriptor@::marshalReturnedValues(cdrStream& _n){ @marshal_block@}"""interface_proxy_unmarshal_returnedvalues = """\void @call_descriptor@::unmarshalReturnedValues(cdrStream& _n){ @marshal_block@}"""interface_proxy_exn = """\const char* const @call_descriptor@::_user_exns[] = { @exception_namelist@};void @call_descriptor@::userException(cdrStream& s, _OMNI_NS(IOP_C)* iop_client, const char* repoId){ @exception_block@ else { if (iop_client) iop_client->RequestCompleted(1); OMNIORB_THROW(UNKNOWN,UNKNOWN_UserException, (CORBA::CompletionStatus)s.completion()); }}"""interface_proxy_exn_handle = """\
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -