[orbitcpp-list] Any and other Compiler enhancements
Status: Beta
Brought to you by:
philipd
From: John L. <jk...@lu...> - 2000-11-07 23:08:55
|
Attached is output of diff to the orb, orbitcpp_any.hh orbitcpp_any.cc, and diffs on the compiler. The compiler should eek out marshalling for Any with the correct argument passing rules. I have done some minimal testing and it seems to work well. I also have a good start on the generation of any inserter and extractor functions. I have tried my best to follow the basic patterns of the compiler framework. So your comments on the compiler patch file itself are appreciated. in CORBA::Any works except for things with TypeCode_ptr (they are basically implemented, just commented out so the code will compile). One issue in the compiler patch: The IDL compiler needs to keep track of Array and Sequence (and soon Fixed) type definitions to make sure that multiple specs aren't being written for what is effectively the same type. I started a solution to this (making a IDLSequenceList in types.hh that is basically implemented as a set, so it should be very fast). The list is kept in IDLCompilerState. The same exact thing has to be done for array. In addition I am fixing array to defer its spec generation (just like sequence), at this time because without it, the code generated for array typedef nested more than module scope is broken. John Luebs /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */ /* * ORBit-C++: C++ bindings for ORBit. * * Copyright (C) 2000 John K. Luebs * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Library General Public * License as published by the Free Software Foundation; either * version 2 of the License, or (at your option) any later version. * * This library 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 * Library General Public License for more details. * * You should have received a copy of the GNU Library General Public * License along with this library; if not, write to the Free * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * * Author: John K. Luebs <jk...@ma...> * * Description: CORBA Any implementation */ #include <cwchar> #include <orb/orbit.h> #include "orbitcpp_any.hh" /*void CORBA::Any::copy(TypeCode_ptr tc, void* value, Boolean release) { m_target._type = ORBit_TypeCode_dup(reinterpret_cast<CORBA_TypeCode>(tc)); if( release ) m_target._value = ORBit_copy_value(value, _type); else m_target._value = value; m_target._release = release; } */ void CORBA::Any::insert_simple(CORBA_TypeCode tc, void* value, Boolean v_copy) { g_assert( tc->parent.refs == ORBIT_REFCNT_STATIC ); void *new_val; if(v_copy) new_val = ORBit_copy_value(value, tc); else new_val = value; if( m_target._release ) CORBA_free( m_target._value ); m_target._value = new_val; m_target._release = CORBA_TRUE; if( m_target._type != tc ) { ORBit_RootObject_release(m_target._type); m_target._type = tc; } } void CORBA::Any::operator<<=(from_string in) { if( in.bound && (strlen(in.val) > in.bound) ) return; ORBit_RootObject_release(m_target._type); CORBA_TypeCode new_tc = _orbitcpp::TypeCode_allocate(); new_tc->kind = CORBA_tk_string; new_tc->length = in.bound; m_target._type = new_tc; if( m_target._release ) ORBit_free( m_target._value ); if( in.nocopy ) { m_target._value = ORBit_alloc_tcval(m_target._type, 1); *(CORBA_char**)m_target._value = in.val; } else m_target._value = ORBit_copy_value(&in.val, m_target._type); m_target._release = CORBA_TRUE; } void CORBA::Any::operator<<=(from_wstring in) { if( in.bound && (wcslen((wchar_t*)in.val) > in.bound) ) return; ORBit_RootObject_release(m_target._type); CORBA_TypeCode new_tc = _orbitcpp::TypeCode_allocate(); new_tc->kind = CORBA_tk_wstring; new_tc->length = in.bound; m_target._type = new_tc; if( m_target._release ) ORBit_free( m_target._value ); if( in.nocopy ) { m_target._value = ORBit_alloc_tcval(m_target._type, 1); *(CORBA_char**)m_target._value = (CORBA_char*)in.val; } else m_target._value = ORBit_copy_value(&in.val, m_target._type); m_target._release = CORBA_TRUE; } CORBA::Boolean CORBA::Any::operator>>=(to_string out) const { CORBA_TypeCode tmp = _orbitcpp::TypeCode_allocate(); tmp->kind = CORBA_tk_string; tmp->length = out.bound; Boolean ret = extract(tmp, const_cast<char*&>(out.val)); ORBit_RootObject_release(tmp); return ret; } CORBA::Boolean CORBA::Any::operator>>=(to_wstring out) const { CORBA_TypeCode tmp = _orbitcpp::TypeCode_allocate(); tmp->kind = CORBA_tk_wstring; tmp->length = out.bound; Boolean ret = extract(tmp, const_cast<WChar*&>(out.val)); ORBit_RootObject_release(tmp); return ret; } |