From c218c03bb4a72a9a8b3b507875413e53bd8a43b0 Mon Sep 17 00:00:00 2001 From: cas Date: Fri, 9 Jun 2000 14:09:51 +0000 Subject: [PATCH] No comments --- src/CPPJini/CPPJini.cxx | 1696 ++++++++++++++++------------ src/CPPJini/CPPJini_ClientInfo.cdl | 23 +- src/CPPJini/CPPJini_ClientInfo.cxx | 7 +- src/CPPJini/CPPJini_Enum.cxx | 80 +- src/CPPJini/CPPJini_General.edl | 48 +- src/CPPJini/CPPJini_MPV.cxx | 596 ++++++---- src/CPPJini/CPPJini_Package.cxx | 442 +++++--- src/CPPJini/CPPJini_Template.edl | 99 +- src/CPPJini/CPPJini_Transient.cxx | 655 ++++++----- 9 files changed, 2150 insertions(+), 1496 deletions(-) diff --git a/src/CPPJini/CPPJini.cxx b/src/CPPJini/CPPJini.cxx index 456143e..943740a 100755 --- a/src/CPPJini/CPPJini.cxx +++ b/src/CPPJini/CPPJini.cxx @@ -1,41 +1,52 @@ -// CLE : Extracteur de stubs C++ pour CAS.CADE -// Matra-Datavision 1995 -// -// 10/1995 -// +#include +#include +#include +#include + #include #include -#include -#include -#include -#include #include #include #include -#include + +#include +#include +#include +#include + +#include #include -#include -#include -#define CPPJINI_BOOLEAN 1 -#define CPPJINI_CHARACTER 2 -#define CPPJINI_ENUMERATION 3 -#define CPPJINI_EXTCHARACTER 4 -#define CPPJINI_INTEGER 5 -#define CPPJINI_REAL 6 -#define CPPJINI_BYTE 7 -#define CPPJINI_SHORTREAL 8 +#include + +#define CPPJINI_BOOLEAN 1 +#define CPPJINI_CHARACTER 2 +#define CPPJINI_ENUMERATION 3 +#define CPPJINI_EXTCHARACTER 4 +#define CPPJINI_INTEGER 5 +#define CPPJINI_REAL 6 +#define CPPJINI_BYTE 7 +#define CPPJINI_SHORTREAL 8 + +static Handle( MS_MetaSchema ) s_MS; +static CPPJini_ExtractionType s_Type; -Handle(MS_HSequenceOfMemberMet) SeqOfMemberMet = new MS_HSequenceOfMemberMet; -Handle(MS_HSequenceOfExternMet) SeqOfExternMet = new MS_HSequenceOfExternMet; +Handle( MS_HSequenceOfMemberMet ) SeqOfMemberMet = new MS_HSequenceOfMemberMet (); +Handle( MS_HSequenceOfExternMet ) SeqOfExternMet = new MS_HSequenceOfExternMet (); -Handle(TCollection_HAsciiString) CPPJini_InterfaceName; -Handle(TCollection_HAsciiString) CPPJini_ErrorArgument = new TCollection_HAsciiString("%error%"); +Handle( TCollection_HAsciiString ) CPPJini_InterfaceName; +Handle( TCollection_HAsciiString ) CPPJini_ErrorArgument = + new TCollection_HAsciiString ( "%error%" ); Handle( TCollection_HAsciiString ) CPPJini_DotReplace ( char*, char = '_' ); static CPPJini_SequenceOfClientInfo s_CltInfo; static WOKTools_MapOfHAsciiString s_CltMap; +static Standard_Integer s_UseLevel; + +WOKTools_MapOfHAsciiString g_ImportMap; +WOKTools_DataMapOfHAsciiStringOfHAsciiString g_SkipMap; +Handle( CPPJini_ClientInfo ) g_Client; static Standard_Boolean CPPJini_CheckClients ( const Handle( TCollection_HAsciiString )& className, @@ -124,269 +135,404 @@ Standard_Boolean CPPJini_HasSemicomplete ( } // end CPPJini_HasIncomplete -Standard_Boolean CPPJini_Defined ( +Standard_Boolean CPPJini_Defined ( const Handle( TCollection_HAsciiString )& aTypeName, - Handle( TCollection_HAsciiString )& cltName + Handle( TCollection_HAsciiString )& cltName, + Standard_Boolean& fDuplicate, + CPPJini_ExtractionType& aType ) { - Standard_Boolean retVal = Standard_False; - CPPJini_ExtractionType type; - Standard_Integer i; + Standard_Boolean retVal = Standard_False; + CPPJini_ExtractionType type; + Standard_Integer i; + Handle( CPPJini_ClientInfo ) cInfo; + TColStd_SequenceOfInteger sLevels; + TColStd_SequenceOfInteger sModes; + TColStd_SequenceOfInteger sIndices; - for ( i = 1; i <= s_CltInfo.Length (); ++i ) { + fDuplicate = Standard_False; + + for ( i = 1; i <= s_CltInfo.Length (); ++i ) if ( s_CltInfo.Value ( i ) -> Defined ( aTypeName, type ) ) { - cltName = new TCollection_HAsciiString ( s_CltInfo.Value ( i ) -> Name () ); - retVal = Standard_True; - break; + sLevels.Append ( s_CltInfo.Value ( i ) -> Level () ); + sIndices.Append ( i ); + sModes.Append ( ( Standard_Integer )type ); } // end if - } // end for + switch ( sLevels.Length () ) { - return retVal; + case 0: -} // end CPPJini_Defined + break; -Standard_Boolean CPPJini_Defined ( - const Handle( MS_MetaSchema )& ms, - const Handle( TCollection_HAsciiString )& aTypeName, - Handle( TCollection_HAsciiString )& cltName, - Standard_Boolean& fDuplicate, - CPPJini_ExtractionType& aType - ) { + case 1: - Standard_Boolean retVal = Standard_False; - CPPJini_ExtractionType type; - Standard_Integer i; + cltName = new TCollection_HAsciiString ( + s_CltInfo.Value ( sIndices.Value ( 1 ) ) -> Name () + ); + aType = ( CPPJini_ExtractionType )sModes.Value ( 1 ); + retVal = Standard_True; - fDuplicate = Standard_False; + break; - for ( i = 1; i <= s_CltInfo.Length (); ++i ) { + default: { - if ( s_CltInfo.Value ( i ) -> Defined ( aTypeName, type ) ) { + Handle( CPPJini_ClientInfo ) ci; + Standard_Boolean fDefined = Standard_False; - if ( !retVal ) { + if ( s_Type != CPPJini_SEMICOMPLETE ) { - cltName = new TCollection_HAsciiString ( s_CltInfo.Value ( i ) -> Name () ); - aType = type; - retVal = Standard_True; + for ( i = 1; i <= sIndices.Length (); ++i ) - } else { + if ( s_CltInfo.Value ( sIndices.Value ( i ) ) -> Root () ) - Standard_Integer j; - const Handle( TColStd_HSequenceOfHAsciiString ) use = - ms -> GetClient ( s_CltInfo.Value ( i ) -> Name () ) -> Uses (); + if ( !fDefined ) { - for ( j = 1; j <= use -> Length (); ++j ) + ci = s_CltInfo.Value ( sIndices.Value ( i ) ); + s_CltInfo.Remove ( sIndices.Value ( i ) ); + s_CltInfo.Prepend ( ci ); + fDefined = Standard_True; + cltName = new TCollection_HAsciiString ( ci -> Name () ); + aType = ( CPPJini_ExtractionType )sModes.Value ( i ); - if ( use -> Value ( j ) -> IsSameString ( cltName ) ) return retVal; + } else { - fDuplicate = Standard_True; - break; + fDuplicate = Standard_True; + break; - } // end else + } // end else - } // end if + if ( !fDefined ) { - } // end for + Standard_Integer maxVal = INT_MIN; + Standard_Integer index, j; + + for ( i = 1; i <= sLevels.Length (); ++i ) + + if ( sLevels.Value ( i ) > maxVal ) { + + maxVal = sLevels.Value ( i ); + index = sIndices.Value ( i ); + j = i; + fDuplicate = Standard_False; + fDefined = Standard_True; + + } else if ( sLevels.Value ( i ) == maxVal ) { + + fDuplicate = Standard_True; + continue; + + } // end if + + ci = s_CltInfo.Value ( index ); + cltName = new TCollection_HAsciiString ( ci -> Name () ); + aType = ( CPPJini_ExtractionType )sModes.Value ( j ); + s_CltInfo.Remove ( index ); + s_CltInfo.Prepend ( ci ); + + } // end if + + } // end if + + if ( !fDefined ) { + + Standard_Integer minVal = INT_MAX; + Standard_Integer index, j; + + for ( i = 1; i <= sLevels.Length (); ++i ) + + if ( sLevels.Value ( i ) < minVal ) { + + minVal = sLevels.Value ( i ); + index = sIndices.Value ( i ); + j = i; + fDuplicate = Standard_False; + + } else if ( sLevels.Value ( i ) == minVal ) { + + fDuplicate = Standard_True; + continue; + + } // end if + + ci = s_CltInfo.Value ( index ); + cltName = new TCollection_HAsciiString ( ci -> Name () ); + aType = ( CPPJini_ExtractionType )sModes.Value ( j ); + s_CltInfo.Remove ( index ); + s_CltInfo.Prepend ( ci ); + + } // end if + + retVal = Standard_True; + + } // default + + } // end switch; return retVal; } // end CPPJini_Defined -// Standard Extractor API : list the EDL files used by this program -// -Handle(TColStd_HSequenceOfHAsciiString) CPPJini_TemplatesUsed() -{ - Handle(TColStd_HSequenceOfHAsciiString) result = new TColStd_HSequenceOfHAsciiString; +Standard_Boolean CPPJini_Defined ( + const Handle( TCollection_HAsciiString )& aTypeName, + Handle( TCollection_HAsciiString )& cltName + ) { - result->Append(new TCollection_HAsciiString("CPPJini_Template.edl")); - result->Append(new TCollection_HAsciiString("CPPJini_General.edl")); + Standard_Boolean fDup; + CPPJini_ExtractionType xType; - return result; -} + return CPPJini_Defined ( aTypeName, cltName, fDup, xType ); + +} // end CPPJini_Defined + +Handle( TColStd_HSequenceOfHAsciiString ) CPPJini_TemplatesUsed () { + + Handle( TColStd_HSequenceOfHAsciiString ) result = + new TColStd_HSequenceOfHAsciiString (); + + result -> Append ( new TCollection_HAsciiString ( "CPPJini_Template.edl" ) ); + result -> Append ( new TCollection_HAsciiString ( "CPPJini_General.edl" ) ); + + return result; + +} // end CPPJini_TemplatesUsed static void _CPPJini_FillUses ( const Handle( MS_MetaSchema )& ms, const Handle( TColStd_HSequenceOfHAsciiString )& use ) { - Standard_Integer i; + ++s_UseLevel; - for ( i = 1; i <= use -> Length (); ++i ) + Standard_Integer i; - if ( !s_CltMap.Contains ( use -> Value ( i ) ) ) { + for ( i = 1; i <= use -> Length (); ++i ) - Handle( MS_Client ) clt = ms -> GetClient ( use -> Value ( i ) ); + if ( !s_CltMap.Contains ( use -> Value ( i ) ) ) { - s_CltInfo.Prepend ( new CPPJini_ClientInfo ( ms, use -> Value ( i ) ) ); - s_CltMap.Add ( use -> Value ( i ) ); + Handle( MS_Client ) clt = ms -> GetClient ( use -> Value ( i ) ); - _CPPJini_FillUses ( ms, clt -> Uses () ); + s_CltInfo.Prepend ( + new CPPJini_ClientInfo ( + ms, use -> Value ( i ), s_UseLevel + ) + ); + s_CltMap.Add ( use -> Value ( i ) ); - } // end if + _CPPJini_FillUses ( ms, clt -> Uses () ); + + } // end if + + if ( i == 1 && s_CltInfo.Length () ) + + s_CltInfo.Value ( 1 ) -> SetRoot ( Standard_True ); + + --s_UseLevel; } // end _CPPJini_FillUses -void CPPJini_Init(const Handle(MS_MetaSchema)& aMeta, - const Handle(TCollection_HAsciiString)& aName, - const Handle(MS_HSequenceOfExternMet)& SeqOfEM, - const Handle(MS_HSequenceOfMemberMet)& SeqOfMM, - const Handle(TColStd_HSequenceOfHAsciiString)& use - ) { +void CPPJini_Init ( + const Handle( MS_MetaSchema )& aMeta, + const Handle( TCollection_HAsciiString )& aName, + const Handle( MS_HSequenceOfExternMet )& SeqOfEM, + const Handle( MS_HSequenceOfMemberMet )& SeqOfMM, + const Handle( TColStd_HSequenceOfHAsciiString )& use + ) { - Handle( MS_Client ) client; - - SeqOfMemberMet = SeqOfMM; - SeqOfExternMet = SeqOfEM; + SeqOfMemberMet = SeqOfMM; + SeqOfExternMet = SeqOfEM; - if (aMeta->IsClient(aName)) { - CPPJini_InterfaceName = aName; - } - else { - ErrorMsg << "CPPJini" << "Init : Client " << aName << " not found..." << endm; - Standard_NoSuchObject::Raise(); - } + WOKTools_MapOfHAsciiString map; + + for ( Standard_Integer i = 1; i <= SeqOfEM -> Length (); ++i ) + + if ( map.Contains ( SeqOfEM -> Value ( i ) -> FullName () ) ) + + SeqOfEM -> Remove ( i ); + + else + + map.Add ( SeqOfEM -> Value ( i ) -> FullName () ); + + if ( aMeta -> IsClient ( aName ) ) { + + CPPJini_InterfaceName = aName; + + } else { + + ErrorMsg << "CPPJini" << "Init : Client " << aName << " not found..." << endm; + Standard_NoSuchObject :: Raise (); + + } // end else s_CltInfo.Clear (); s_CltMap.Clear (); + s_UseLevel = 0; _CPPJini_FillUses ( aMeta, use ); -} + g_SkipMap.Clear (); -Handle(TCollection_HAsciiString)& CPPJini_TransientRootName() -{ - static Handle(TCollection_HAsciiString) name = new TCollection_HAsciiString("Standard_Transient"); + g_Client = new CPPJini_ClientInfo ( aMeta, aName, 0 ); - return name; -} +} // end CPPJini_Init -Handle(TCollection_HAsciiString)& CPPJini_MemoryRootName() -{ - static Handle(TCollection_HAsciiString) name = new TCollection_HAsciiString("MMgt_TShared"); +Handle( TCollection_HAsciiString )& CPPJini_TransientRootName () { - return name; -} + static Handle( TCollection_HAsciiString ) name = + new TCollection_HAsciiString ( "Standard_Transient" ); -Handle(TCollection_HAsciiString)& CPPJini_MPVRootName() -{ - static Handle(TCollection_HAsciiString) name = new TCollection_HAsciiString("jcas.Object"); + return name; - return name; -} +} // end CPPJini_TransientRootName -Handle(EDL_API)& CPPJini_LoadTemplate(const Handle(TColStd_HSequenceOfHAsciiString)& edlsfullpath, - const Handle(TCollection_HAsciiString)& outdir) -{ - static Handle(EDL_API) api = new EDL_API; - static Standard_Boolean alreadyLoaded = Standard_False; +Handle( TCollection_HAsciiString )& CPPJini_MemoryRootName () { - api->ClearVariables(); + static Handle( TCollection_HAsciiString ) name = + new TCollection_HAsciiString ("MMgt_TShared"); - if (!alreadyLoaded) { - alreadyLoaded = Standard_True; + return name; - for(Standard_Integer i = 1; i <= edlsfullpath->Length(); i++) { - api->AddIncludeDirectory(edlsfullpath->Value(i)->ToCString()); - } +} // end CPPJini_MemoryRootName - if (api->Execute("CPPJini_Template.edl") != EDL_NORMAL) { - ErrorMsg << "CPPJini" << "unable to load : CPPJini_Template.edl" << endm; - Standard_NoSuchObject::Raise(); - } - if (api->Execute("CPPJini_General.edl") != EDL_NORMAL) { - ErrorMsg << "CPPJini" << "unable to load : CPPJini_General.edl" << endm; - Standard_NoSuchObject::Raise(); - } - } +Handle( TCollection_HAsciiString )& CPPJini_MPVRootName () { - // full path of the destination directory - // - api->AddVariable(VJFullPath,outdir->ToCString()); + static Handle( TCollection_HAsciiString ) name = + new TCollection_HAsciiString ( "jcas.Object" ); - // templates for methods extraction - // - api->AddVariable(VJMethodHeader,"MethodHeader"); - api->AddVariable(VJConstructorHeader,"ConstructorHeader"); - api->AddVariable(VJInterface,CPPJini_InterfaceName->ToCString()); + return name; - return api; -} +} // end CPPJini_MPVRootName -// write the content of a variable into a file -// -void CPPJini_WriteFile(const Handle(EDL_API)& api, - const Handle(TCollection_HAsciiString)& aFileName, - const Standard_CString var) -{ - // ...now we write the result - // - api->OpenFile("HTFile",aFileName->ToCString()); - api->WriteFile("HTFile",var); - api->CloseFile("HTFile"); -} +Handle( EDL_API )& CPPJini_LoadTemplate ( + const Handle( TColStd_HSequenceOfHAsciiString )& edlsfullpath, + const Handle( TCollection_HAsciiString )& outdir + ) { -// we test the type and dispatch it in the different lists -// -//void CPPJini_DispatchUsedType(const Handle(MS_MetaSchema)& aMeta, -void CPPJini_DispatchUsedType(const Handle(MS_MetaSchema)& , - const Handle(MS_Type)& thetype, - const Handle(TColStd_HSequenceOfHAsciiString)& List, - const Handle(TColStd_HSequenceOfHAsciiString)& Incp, -// const Standard_Boolean notusedwithref) - const Standard_Boolean ) -{ - MS::AddOnce(List,thetype->FullName()); - MS::AddOnce(Incp,thetype->FullName()); -} + static Handle( EDL_API ) api = new EDL_API (); + static Standard_Boolean alreadyLoaded = Standard_False; + api -> ClearVariables (); -Handle(TCollection_HAsciiString) CPPJini_UnderScoreReplace(const Handle(TCollection_HAsciiString)& name) -{ - char str[5000]; - char* from = name->ToCString(); - int cur=0; - for (int i=0; i < name->Length(); i++) { - if (from[i] == '_') { - str[cur] = '_'; - cur++; - str[cur] = '1'; - cur++; - } - else { - str[cur] = from[i]; - cur++; - } - } - str[cur] = '\0'; - return new TCollection_HAsciiString(str); - -} + if ( !alreadyLoaded ) { + alreadyLoaded = Standard_True; -//Standard_Boolean CPPJini_HaveEmptyConstructor(const Handle(MS_MetaSchema)& aMeta, -Standard_Boolean CPPJini_HaveEmptyConstructor(const Handle(MS_MetaSchema)& , -// const Handle(TCollection_HAsciiString)& aClass, - const Handle(TCollection_HAsciiString)& , - const Handle(MS_HSequenceOfMemberMet)& methods) -{ - if (methods.IsNull()) return Standard_False; + for ( Standard_Integer i = 1; i <= edlsfullpath -> Length(); ++i ) + + api -> AddIncludeDirectory ( + edlsfullpath -> Value ( i ) -> ToCString () + ); + + + if ( api -> Execute ( "CPPJini_Template.edl" ) != EDL_NORMAL ) { + + ErrorMsg << "CPPJini" << "unable to load : CPPJini_Template.edl" << endm; + Standard_NoSuchObject :: Raise (); + + } // end if + + if ( api -> Execute ( "CPPJini_General.edl" ) != EDL_NORMAL ) { + + ErrorMsg << "CPPJini" << "unable to load : CPPJini_General.edl" << endm; + Standard_NoSuchObject :: Raise (); + + } // end if - for (int i = 1; i <= methods->Length(); i++) { - if (methods->Value(i)->IsKind(STANDARD_TYPE(MS_Construc))) { - if ((methods->Value(i)->Params().IsNull()) && !methods->Value(i)->Private() && !methods->Value(i)->IsProtected()) { - return Standard_True; - } - } - } + } // end if + + api -> AddVariable ( VJFullPath, outdir -> ToCString () ); + api -> AddVariable ( VJMethodHeader, "MethodHeader" ); + api -> AddVariable ( VJConstructorHeader,"ConstructorHeader" ); + api -> AddVariable ( + VJInterface, CPPJini_InterfaceName -> ToCString () + ); + + Handle( TCollection_HAsciiString ) libName = new TCollection_HAsciiString ( + CPPJini_InterfaceName -> ToCString () + ); + + libName -> ChangeAll ( '.', '_' ); + + api -> AddVariable ( "%LibName", libName -> ToCString () ); + + return api; + +} // end CPPJini_LoadTemplate + +void CPPJini_WriteFile ( + const Handle( EDL_API )& api, + const Handle( TCollection_HAsciiString )& aFileName, + const Standard_CString var + ) { + + api -> OpenFile ("HTFile", aFileName -> ToCString () ); + api -> WriteFile ("HTFile", var ); + api -> CloseFile ("HTFile" ); + +} // end CPPJini_WriteFile + +void CPPJini_DispatchUsedType ( + const Handle( MS_MetaSchema )& aMeta, + const Handle( MS_Type )& thetype, + const Handle( TColStd_HSequenceOfHAsciiString )& List, + const Handle( TColStd_HSequenceOfHAsciiString )& Incp, + const Standard_Boolean notusedwithref + ) { + + MS :: AddOnce ( List, thetype -> FullName () ); + MS :: AddOnce ( Incp, thetype -> FullName () ); + +} // end CPPJini_DispatchUsedType + +Handle( TCollection_HAsciiString ) CPPJini_UnderScoreReplace ( + const Handle( TCollection_HAsciiString )& name + ) { + + char str[ 5000 ]; + char* from = name -> ToCString (); + int cur = 0; + + for ( int i = 0; i < name -> Length (); ++i ) + + if ( from[ i ] == '_' ) { + + str[ cur++ ] = '_'; + str[ cur++ ] = '1'; + + } else str[ cur++ ] = from[ i ]; + + str[ cur ] = '\0'; + + return new TCollection_HAsciiString ( str ); + +} // end CPPJini_UnderScoreReplace + +Standard_Boolean CPPJini_HaveEmptyConstructor ( + const Handle( MS_MetaSchema )& aMeta, + const Handle( TCollection_HAsciiString )& aClass, + const Handle( MS_HSequenceOfMemberMet )& methods + ) { + + if ( methods.IsNull () ) return Standard_False; - return Standard_False; -} + for ( int i = 1; i <= methods -> Length (); ++i ) + if ( methods -> Value ( i ) -> IsKind ( STANDARD_TYPE( MS_Construc ) ) ) +#if 1 + if ( methods -> Value ( i ) -> Params ().IsNull () && + !methods -> Value ( i ) -> Private () && + !methods -> Value ( i ) -> IsProtected () + ) return Standard_True; +#else + if ( methods -> Value ( i ) -> Params ().IsNull () ) return Standard_True; +#endif + return Standard_False; +} // end CPPJini_HaveEmptyConstructor // sort the method used types : // @@ -394,85 +540,113 @@ Standard_Boolean CPPJini_HaveEmptyConstructor(const Handle(MS_MetaSchema)& , // List : the types that must have a full definition // Incp : the types that only have to be declared // -void CPPJini_MethodUsedTypes(const Handle(MS_MetaSchema)& aMeta, - const Handle(MS_Method)& aMethod, - const Handle(TColStd_HSequenceOfHAsciiString)& List, - const Handle(TColStd_HSequenceOfHAsciiString)& Incp) -{ - Standard_Integer i; - Handle(MS_Param) aParam; - Handle(MS_Type) thetype; - Handle(TCollection_HAsciiString) aName,aNameType,parname; +void CPPJini_MethodUsedTypes ( + const Handle( MS_MetaSchema )& aMeta, + const Handle( MS_Method )& aMethod, + const Handle( TColStd_HSequenceOfHAsciiString )& List, + const Handle( TColStd_HSequenceOfHAsciiString )& Incp + ) { - if (aMethod->IsKind(STANDARD_TYPE(MS_MemberMet))) { - Handle(MS_MemberMet) aMM = *((Handle(MS_MemberMet)*)&aMethod); + Standard_Integer i; + Handle( MS_Param ) aParam; + Handle( MS_Type ) thetype; + Handle( TCollection_HAsciiString ) aName, aNameType, parname; - aName = aMM->Class(); - } - else if (aMethod->IsKind(STANDARD_TYPE(MS_ExternMet))) { - Handle(MS_ExternMet) aMM = *((Handle(MS_ExternMet)*)&aMethod); + if ( aMethod -> IsKind ( STANDARD_TYPE( MS_MemberMet ) ) ) { - aName = aMM->Package(); - } + Handle( MS_MemberMet ) aMM = *( ( Handle( MS_MemberMet )* )&aMethod ); + + aName = aMM -> Class (); + + } else if ( aMethod -> IsKind ( STANDARD_TYPE( MS_ExternMet ) ) ) { - aParam = aMethod->Returns(); + Handle( MS_ExternMet ) aMM = *( ( Handle( MS_ExternMet )* )&aMethod ); - if (!aParam.IsNull()) { - thetype = aParam->Type(); - parname = aParam->TypeName(); + aName = aMM -> Package (); + + } // end if + + aParam = aMethod -> Returns (); + + if ( !aParam.IsNull () ) { - if (thetype->IsKind(STANDARD_TYPE(MS_Alias))) { - Handle(MS_Alias) analias = *((Handle(MS_Alias)*)&thetype); + thetype = aParam -> Type (); + parname = aParam -> TypeName (); + + if ( thetype -> IsKind ( STANDARD_TYPE( MS_Alias ) ) ) { + + Handle( MS_Alias ) analias = *( ( Handle( MS_Alias )* )&thetype ); - parname = analias->DeepType(); + parname = analias -> DeepType (); - if (aMeta->IsDefined(parname)) { - thetype = aMeta->GetType(parname); - } - else { + if ( aMeta -> IsDefined ( parname ) ) + + thetype = aMeta -> GetType ( parname ); + + else { + ErrorMsg << "CPPJini" << "Type " << parname << " not defined..." << endm; - Standard_NoSuchObject::Raise(); - } - } + Standard_NoSuchObject :: Raise (); + + } // end else + + } // end if - if (!parname->IsSameString(aName)) { - CPPJini_DispatchUsedType(aMeta,thetype,List,Incp,!aMethod->IsRefReturn()); - } - } + if ( !parname -> IsSameString ( aName ) ) - Standard_Boolean fEnum = Standard_False; - Handle(MS_HArray1OfParam) seqparam = aMethod->Params(); + CPPJini_DispatchUsedType ( + aMeta, thetype, List, Incp, !aMethod -> IsRefReturn () + ); - if(!seqparam.IsNull()) { - for (i = 1; i <= seqparam->Length(); i++) { - thetype = seqparam->Value(i)->Type(); - - if ( !fEnum && thetype -> IsKind ( STANDARD_TYPE( MS_Enum ) ) ) fEnum = Standard_True; + } // end if - parname = seqparam->Value(i)->TypeName(); + Standard_Boolean fEnum = Standard_False; + Handle(MS_HArray1OfParam) seqparam = aMethod->Params(); - if (thetype->IsKind(STANDARD_TYPE(MS_Alias))) { - Handle(MS_Alias) analias = *((Handle(MS_Alias)*)&thetype); + if ( !seqparam.IsNull () ) { + + for ( i = 1; i <= seqparam -> Length (); ++i ) { + + thetype = seqparam -> Value ( i ) -> Type (); + + if ( !fEnum && thetype -> IsKind ( STANDARD_TYPE( MS_Enum ) ) ) + + fEnum = Standard_True; + + parname = seqparam -> Value ( i ) -> TypeName (); + + if ( thetype -> IsKind ( STANDARD_TYPE( MS_Alias ) ) ) { + + Handle( MS_Alias ) analias = *( ( Handle( MS_Alias )* )&thetype ); - parname = analias->DeepType(); + parname = analias -> DeepType (); - if (aMeta->IsDefined(parname)) { - thetype = aMeta->GetType(parname); - } - else { - ErrorMsg << "CPPJini" << "Type " << parname << " not defined..." << endm; - Standard_NoSuchObject::Raise(); - } - } + if ( aMeta -> IsDefined ( parname ) ) - if (!parname->IsSameString(aName)) { - CPPJini_DispatchUsedType(aMeta,thetype,List,Incp,Standard_False); - } - } - if ( fEnum ) List -> Append ( new TCollection_HAsciiString ( "Standard_Integer" ) ); - } -} + thetype = aMeta -> GetType ( parname ); + + else { + + ErrorMsg << "CPPJini" << "Type " << parname << " not defined..." << endm; + Standard_NoSuchObject :: Raise (); + + } // end else + + } // end if + + if ( !parname -> IsSameString ( aName ) ) + CPPJini_DispatchUsedType ( + aMeta, thetype, List, Incp, Standard_False + ); + + } // end for + + if ( fEnum ) List -> Append ( new TCollection_HAsciiString ( "Standard_Integer" ) ); + + } // end if + +} // end CPPJini_MethodUsedTypes // sort the class used types : // @@ -480,32 +654,37 @@ void CPPJini_MethodUsedTypes(const Handle(MS_MetaSchema)& aMeta, // List : the types that must have a full definition // Incp : the types that only have to be declared // -void CPPJini_ClassUsedTypes(const Handle(MS_MetaSchema)& aMeta, - const Handle(MS_Class)& aClass, - const Handle(TColStd_HSequenceOfHAsciiString)& List, - const Handle(TColStd_HSequenceOfHAsciiString)& Incp) -{ - Standard_Integer i; - Handle(TColStd_HSequenceOfHAsciiString) asciiseq; - Handle(TCollection_HAsciiString) str,aNameType; - - asciiseq = aClass->GetInheritsNames(); - - for (i = 1; i <= asciiseq->Length(); i++) { - aNameType = new TCollection_HAsciiString; - aNameType->AssignCat(CPPJini_InterfaceName); - aNameType->AssignCat("_"); - aNameType->AssignCat(asciiseq->Value(i)); - MS::AddOnce(List,aNameType); - } +void CPPJini_ClassUsedTypes ( + const Handle( MS_MetaSchema )& aMeta, + const Handle( MS_Class )& aClass, + const Handle( TColStd_HSequenceOfHAsciiString )& List, + const Handle( TColStd_HSequenceOfHAsciiString )& Incp + ) { - Handle(MS_HSequenceOfMemberMet) metseq = aClass->GetMethods(); + Standard_Integer i; + Handle( TColStd_HSequenceOfHAsciiString ) asciiseq; + Handle( TCollection_HAsciiString ) str, aNameType; - for (i = 1; i <= metseq->Length(); i++) { - CPPJini_MethodUsedTypes(aMeta,metseq->Value(i),List,Incp); - } -} + asciiseq = aClass -> GetInheritsNames (); + + for ( i = 1; i <= asciiseq -> Length (); ++i ) { + aNameType = new TCollection_HAsciiString (); + aNameType -> AssignCat ( CPPJini_InterfaceName ); + aNameType -> AssignCat ( "_" ); + aNameType -> AssignCat ( asciiseq -> Value ( i ) ); + + MS::AddOnce ( List, aNameType ); + + } // end for + + Handle( MS_HSequenceOfMemberMet ) metseq = aClass -> GetMethods (); + + for ( i = 1; i <= metseq -> Length (); ++i ) + + CPPJini_MethodUsedTypes ( aMeta, metseq -> Value ( i ), List, Incp ); + +} // end CPPJini_ClassUsedTypes // sort the used types : // @@ -513,288 +692,288 @@ void CPPJini_ClassUsedTypes(const Handle(MS_MetaSchema)& aMeta, // List : the types that must have a full definition // Incp : the types that only have to be declared // -void CPPJini_UsedTypes(const Handle(MS_MetaSchema)& aMeta, - const Handle(MS_Common)& aCommon, - const Handle(TColStd_HSequenceOfHAsciiString)& List, - const Handle(TColStd_HSequenceOfHAsciiString)& Incp) -{ - if (aCommon->IsKind(STANDARD_TYPE(MS_Type))) { - if (aCommon->IsKind(STANDARD_TYPE(MS_Class))) { - Handle(MS_Class) aClass = *((Handle(MS_Class)*)&aCommon); +void CPPJini_UsedTypes ( + const Handle( MS_MetaSchema )& aMeta, + const Handle( MS_Common )& aCommon, + const Handle( TColStd_HSequenceOfHAsciiString )& List, + const Handle( TColStd_HSequenceOfHAsciiString )& Incp + ) { + + if ( aCommon -> IsKind ( STANDARD_TYPE( MS_Type ) ) && + aCommon -> IsKind ( STANDARD_TYPE( MS_Class ) ) + ) { + + Handle( MS_Class ) aClass = *( ( Handle( MS_Class )* )&aCommon ); - CPPJini_ClassUsedTypes(aMeta,aClass,List,Incp); - } - } -} + CPPJini_ClassUsedTypes ( aMeta, aClass, List, Incp ); + + } // end if + +} // end CPPJini_UsedTypes // build a return, parameter or field type in c++ // return a or a Handle_ // -Handle(TCollection_HAsciiString) CPPJini_BuildType(const Handle(MS_MetaSchema)& aMeta, - const Handle(TCollection_HAsciiString)& aTypeName) -{ - Handle(TCollection_HAsciiString) result = new TCollection_HAsciiString(); - Handle(TCollection_HAsciiString) rTypeName; - Handle(TCollection_HAsciiString) parname; - Handle(MS_Type) aType; - +Handle( TCollection_HAsciiString ) CPPJini_BuildType ( + const Handle( MS_MetaSchema )& aMeta, + const Handle( TCollection_HAsciiString )& aTypeName + ) { + + Handle( TCollection_HAsciiString ) result = new TCollection_HAsciiString (); + Handle( TCollection_HAsciiString ) rTypeName; + Handle( TCollection_HAsciiString ) parname; + Handle( MS_Type ) aType; - if (aMeta->IsDefined(aTypeName)) { - aType = aMeta->GetType(aTypeName); - parname = aTypeName; + if ( aMeta -> IsDefined ( aTypeName ) ) { - if (aType->IsKind(STANDARD_TYPE(MS_Alias))) { - Handle(MS_Alias) analias = *((Handle(MS_Alias)*)&aType); + aType = aMeta -> GetType ( aTypeName ); + parname = aTypeName; + + if ( aType -> IsKind ( STANDARD_TYPE( MS_Alias ) ) ) { + + Handle( MS_Alias ) analias = *( ( Handle( MS_Alias )* )&aType ); - parname = analias->DeepType(); + parname = analias -> DeepType (); - if (aMeta->IsDefined(parname)) { - aType = aMeta->GetType(parname); - } - else { - ErrorMsg << "CPPJini" << "Type " << parname << " not defined..." << endm; - Standard_NoSuchObject::Raise(); - } - } - + if ( aMeta -> IsDefined ( parname ) ) - if (aType->IsKind(STANDARD_TYPE(MS_Enum))) { - parname = new TCollection_HAsciiString("int"); - } - result->AssignCat(parname); - if (aType->IsKind(STANDARD_TYPE(MS_NatType))) { - if (aType->IsKind(STANDARD_TYPE(MS_Imported)) || aType->IsKind(STANDARD_TYPE(MS_Pointer))) { - result = CPPJini_ErrorArgument; - } - } - if (!strcmp(aType->FullName()->ToCString(),"Standard_Address")) { - result = CPPJini_ErrorArgument; - } + aType = aMeta -> GetType ( parname ); + + else { + + ErrorMsg << "CPPJini" << "Type " << parname << " not defined..." << endm; + Standard_NoSuchObject :: Raise (); + + } // end else + + } // end if - } - else { - ErrorMsg << "CPPJini" << "Type " << aTypeName << " not defined..." << endm; - Standard_NoSuchObject::Raise(); - } + if ( aType -> IsKind ( STANDARD_TYPE( MS_Enum ) ) ) - return result; -} + parname = new TCollection_HAsciiString ( "int" ); + result -> AssignCat ( parname ); -Standard_Boolean CPPJini_IsCasType(const Handle(TCollection_HAsciiString)& typname) -{ - char* typeName = typname->ToCString(); + if ( aType -> IsKind ( STANDARD_TYPE( MS_NatType ) ) ) - if (!strcmp(typeName,"Object")) { - return Standard_True; - } + if ( aType -> IsKind ( STANDARD_TYPE( MS_Imported ) ) || + aType -> IsKind ( STANDARD_TYPE( MS_Pointer ) ) + ) result = CPPJini_ErrorArgument; - if (typeName[0] != 'S') return Standard_False; + if ( !strcmp ( aType -> FullName () -> ToCString (), "Standard_Address" ) ) - if (!strcmp(typeName,"Standard_CString")) { - return Standard_True; - } + result = CPPJini_ErrorArgument; - if (!strcmp(typeName,"Standard_ExtString")) { - return Standard_True; - } + } else { - if (!strcmp(typeName,"Standard_Character")) { - return Standard_True; - } + ErrorMsg << "CPPJini" << "Type " << aTypeName << " not defined..." << endm; + Standard_NoSuchObject :: Raise (); - if (!strcmp(typeName,"Standard_Integer")) { - return Standard_True; - } - - if (!strcmp(typeName,"Standard_Real")) { - return Standard_True; - } - - if (!strcmp(typeName,"Standard_Boolean")) { - return Standard_True; - } - - if (!strcmp(typeName,"Standard_ExtCharacter")) { - return Standard_True; - } - - if (!strcmp(typeName,"Standard_Byte")) { - return Standard_True; - } - - if (!strcmp(typeName,"Standard_ShortReal")) { - return Standard_True; - } + } // end else + + return result; + +} // end CPPJini_BuildType + +Standard_Boolean CPPJini_IsCasType ( const Handle( TCollection_HAsciiString )& typname ) { + + char* typeName = typname -> ToCString (); + + if ( !strcmp ( typeName, "Object" ) ) return Standard_True; + + if ( typeName[ 0 ] != 'S' ) return Standard_False; + + if ( !strcmp ( typeName, "Standard_CString" ) ) return Standard_True; + if ( !strcmp ( typeName, "Standard_ExtString" ) ) return Standard_True; + if ( !strcmp ( typeName, "Standard_Character" ) ) return Standard_True; + if ( !strcmp ( typeName, "Standard_Integer" ) ) return Standard_True; + if ( !strcmp ( typeName, "Standard_Real" ) ) return Standard_True; + if ( !strcmp ( typeName, "Standard_Boolean" ) ) return Standard_True; + if ( !strcmp ( typeName, "Standard_ExtCharacter" ) ) return Standard_True; + if ( !strcmp ( typeName, "Standard_Byte" ) ) return Standard_True; + if ( !strcmp ( typeName, "Standard_ShortReal" ) ) return Standard_True; + if ( !strcmp ( typeName, "Standard_Address" ) ) return Standard_True; + + return Standard_False; + +} // end CPPJini_IsCasType + +Handle( TCollection_HAsciiString ) CPPJini_CheckPrimParam ( + const Handle( TCollection_HAsciiString )& parname, + const Standard_Boolean isout + ) { + + char* typeName = parname -> ToCString (); + + if ( !strcmp ( typeName, "Standard_Address" ) ) return CPPJini_ErrorArgument; + + if ( !strcmp ( typeName, "Standard_ExtString" ) ) + + return !isout ? new TCollection_HAsciiString ( "String" ) + : new TCollection_HAsciiString ( "StringBuffer" ); + + if ( isout ) return parname; - if (!strcmp(typeName,"Standard_Address")) { - return Standard_True; - } + if ( !strcmp ( typeName, "Standard_Integer" ) ) + return new TCollection_HAsciiString ( "int" ); + if ( !strcmp ( typeName, "Standard_Real" ) ) + return new TCollection_HAsciiString ( "double" ); + if ( !strcmp ( typeName, "Standard_Boolean" ) ) + return new TCollection_HAsciiString ( "boolean" ); + if ( !strcmp ( typeName, "Standard_ExtCharacter" ) ) + return new TCollection_HAsciiString ( "char" ); + if ( !strcmp ( typeName, "Standard_Byte" ) ) + return new TCollection_HAsciiString ( "byte" ); + if ( !strcmp ( typeName, "Standard_ShortReal" ) ) + return new TCollection_HAsciiString ( "float" ); - return Standard_False; -} + return parname; - +} // end CPPJini_CheckPrimParam -Handle(TCollection_HAsciiString) CPPJini_CheckPrimParam(const Handle(TCollection_HAsciiString)& parname, - const Standard_Boolean isout) -{ - char* typeName = parname->ToCString(); +Handle( TCollection_HAsciiString ) CPPJini_GetFullJavaType ( + const Handle( TCollection_HAsciiString )& className + ) { + Handle( TCollection_HAsciiString ) theret; - if (!strcmp(typeName,"Standard_Address")) { - return CPPJini_ErrorArgument; - } - if (!strcmp(typeName,"Standard_ExtString")) { - if (!isout) { - return new TCollection_HAsciiString("String"); - } - return new TCollection_HAsciiString("StringBuffer"); - } + if ( CPPJini_IsCasType ( className ) ) - if (isout) { - return parname; - } + theret = new TCollection_HAsciiString ( "jcas." ); + + else { - if (!strcmp(typeName,"Standard_Integer")) { - return new TCollection_HAsciiString("int"); - } - - if (!strcmp(typeName,"Standard_Real")) { - return new TCollection_HAsciiString("double"); - } - - if (!strcmp(typeName,"Standard_Boolean")) { - return new TCollection_HAsciiString("boolean"); - } - - if (!strcmp(typeName,"Standard_ExtCharacter")) { - return new TCollection_HAsciiString("char"); - } - - if (!strcmp(typeName,"Standard_Byte")) { - return new TCollection_HAsciiString("byte"); - } - - if (!strcmp(typeName,"Standard_ShortReal")) { - return new TCollection_HAsciiString("float"); - } - + theret = new TCollection_HAsciiString ( CPPJini_InterfaceName -> ToCString () ); + theret -> AssignCat ( "." ); - return parname; -} + } // end else -Handle(TCollection_HAsciiString) CPPJini_GetFullJavaType(const Handle(TCollection_HAsciiString)& className) -{ - Handle(TCollection_HAsciiString) theret; - if (CPPJini_IsCasType(className)) { - theret = new TCollection_HAsciiString("jcas."); - } - else { - theret = new TCollection_HAsciiString(CPPJini_InterfaceName->ToCString()); - theret->AssignCat("."); - } - theret->AssignCat(className); - return theret; -} + theret -> AssignCat ( className ); + + return theret; +} // end CPPJini_GetFullJavaType // Build a parameter list for methods // the output is in C++ // -Handle(TCollection_HAsciiString) CPPJini_BuildParameterList(const Handle(MS_MetaSchema)& aMeta, - const Handle(MS_HArray1OfParam)& aSeq, - const Standard_Boolean withtype) -{ - Standard_Integer i; - Handle(TCollection_HAsciiString) result = new TCollection_HAsciiString; - Handle(MS_Type) aType; - Handle(MS_Class) aClass; - Handle(TCollection_HAsciiString) parname; - - if(!aSeq.IsNull()) { - for (i = 1; i <= aSeq->Length(); i++) { - if (i > 1) { - result->AssignCat(","); - } +Handle( TCollection_HAsciiString ) CPPJini_BuildParameterList ( + const Handle( MS_MetaSchema )& aMeta, + const Handle( MS_HArray1OfParam )& aSeq, + const Standard_Boolean withtype + ) { - if (aMeta->IsDefined(aSeq->Value(i)->TypeName())) { - if (!withtype) { - result->AssignCat(aSeq->Value(i)->Name()); - } - else { + Standard_Integer i; + Handle( TCollection_HAsciiString ) result = new TCollection_HAsciiString (); + Handle( MS_Type ) aType; + Handle( MS_Class ) aClass; + Handle( TCollection_HAsciiString ) parname; - parname = aSeq->Value(i)->TypeName(); - aType = aMeta->GetType(parname); + if ( !aSeq.IsNull () ) { + + for ( i = 1; i <= aSeq -> Length (); ++i ) { + + if ( i > 1 ) result -> AssignCat ( "," ); + + if ( aMeta -> IsDefined ( aSeq -> Value ( i ) -> TypeName () ) ) { + + if ( !withtype ) + + result -> AssignCat ( aSeq -> Value ( i ) -> Name () ); + + else { + + parname = aSeq -> Value ( i ) -> TypeName (); + aType = aMeta -> GetType ( parname ); - if (aType->IsKind(STANDARD_TYPE(MS_Alias))) { - Handle(MS_Alias) analias = *((Handle(MS_Alias)*)&aType); + if ( aType -> IsKind ( STANDARD_TYPE( MS_Alias ) ) ) { + + Handle( MS_Alias ) analias = *( ( Handle( MS_Alias )* )&aType ); - parname = analias->DeepType(); + parname = analias -> DeepType (); - if (aMeta->IsDefined(parname)) { - aType = aMeta->GetType(parname); - } - else { - ErrorMsg << "CPPJini" << "Type " << parname << " not defined..." << endm; - Standard_NoSuchObject::Raise(); - } - } + if ( aMeta -> IsDefined ( parname ) ) - if (aType->IsKind(STANDARD_TYPE(MS_Imported)) || aType->IsKind(STANDARD_TYPE(MS_Pointer))) { - result = CPPJini_ErrorArgument; - return result; - } - if (aType->IsKind(STANDARD_TYPE(MS_Enum))) { - if (aSeq->Value(i)->IsOut()) { - parname = new TCollection_HAsciiString("Standard_Integer"); - } - else { - parname = new TCollection_HAsciiString("int"); - } - } + aType = aMeta -> GetType ( parname ); - if (aType->IsKind(STANDARD_TYPE(MS_PrimType))) { - parname = CPPJini_CheckPrimParam(parname,aSeq->Value(i)->IsOut()); - if (parname == CPPJini_ErrorArgument) return parname; - } + else { + + ErrorMsg << "CPPJini" << "Type " << parname << " not defined..." << endm; + Standard_NoSuchObject :: Raise (); + + } // end else + + } // end if + + if ( aType -> IsKind ( STANDARD_TYPE( MS_Imported ) ) || + aType -> IsKind ( STANDARD_TYPE( MS_Pointer ) ) + ) { + + result = CPPJini_ErrorArgument; + return result; + + } // end if + + if ( aType -> IsKind( STANDARD_TYPE( MS_Enum ) ) ) + + if ( aSeq -> Value ( i ) -> IsOut () ) + + parname = new TCollection_HAsciiString ( "Standard_Integer" ); + + else + + parname = new TCollection_HAsciiString ( "int" ); + + if ( aType -> IsKind ( STANDARD_TYPE( MS_PrimType ) ) ) { + + parname = CPPJini_CheckPrimParam ( parname, aSeq -> Value ( i ) -> IsOut () ); + + if ( parname == CPPJini_ErrorArgument ) return parname; + + } // end if - result->AssignCat(parname); - result->AssignCat(" "); - result->AssignCat(aSeq->Value(i)->Name()); - } - } - } - } - return result; -} + result -> AssignCat ( parname ); + result -> AssignCat ( " " ); + result -> AssignCat ( aSeq -> Value ( i ) -> Name () ); + } // end else + } // end if -void CPPJini_CheckMethod(const Standard_Integer index, - const Handle(TCollection_HAsciiString)& thename, - CPPJini_DataMapOfAsciiStringInteger& themap, - TColStd_Array1OfInteger& theindexes) -{ + } // end for - TCollection_AsciiString name(thename->ToCString()); + } // end if + return result; - if (themap.IsBound(name)) { - Standard_Integer curnb=0; - Standard_Integer theindex = themap.Find(name); - if (theindexes(theindex) == 0) { - theindexes(theindex) = 1; - } - curnb = theindexes(theindex) + 1; - theindexes(index) = curnb; - themap.UnBind(name); - } - themap.Bind(name,index); -} - +} // end if +void CPPJini_CheckMethod ( + const Standard_Integer index, + const Handle( TCollection_HAsciiString )& thename, + CPPJini_DataMapOfAsciiStringInteger& themap, + TColStd_Array1OfInteger& theindexes + ) { + TCollection_AsciiString name( thename -> ToCString () ); + + if ( themap.IsBound ( name ) ) { + + Standard_Integer curnb = 0; + Standard_Integer theindex = themap.Find ( name ); + + if ( theindexes ( theindex ) == 0 ) theindexes ( theindex ) = 1; + + curnb = theindexes ( theindex ) + 1; + theindexes ( index ) = curnb; + themap.UnBind ( name ); + + } // end if + + themap.Bind ( name, index ); + +} // end CPPJini_CheckMethod + // build a c++ declaration method // the result is in the EDL variable VJMethod // @@ -1044,8 +1223,7 @@ Handle(TCollection_HAsciiString) CPPJini_ConvertToJavaType(const Handle(MS_MetaS void CPPJini_ArgumentBuilder(const Handle(MS_MetaSchema)& aMeta, const Handle(EDL_API)& api, -// const Handle(TCollection_HAsciiString)& className, - const Handle(TCollection_HAsciiString)& , + const Handle(TCollection_HAsciiString)& className, const Handle(MS_Method)& m, Handle(TCollection_HAsciiString)& ArgsInDecl, Handle(TCollection_HAsciiString)& ArgsRetrieve, @@ -1279,164 +1457,221 @@ Standard_Boolean CPPJini_HasMagicConstructor(const Handle(MS_Type)& atyp) return Standard_True; } -Standard_Boolean CPPJini_HasEmptyConstructor(const Handle(MS_Type)& atyp) -{ - Handle(MS_Class) thecl = Handle(MS_Class)::DownCast(atyp); - if (thecl.IsNull()) return Standard_False; - Handle(MS_HSequenceOfMemberMet) methods = thecl->GetMethods(); - for (Standard_Integer i=1; i<= methods->Length(); i++) { - if (methods->Value(i)->IsKind(STANDARD_TYPE(MS_Construc))) { - Handle(MS_HArray1OfParam) parameters = methods->Value(i)->Params(); - if (parameters.IsNull()) { - if (methods->Value(i)->Private()) { - return Standard_False; - } - return Standard_True; - } - } - } - return Standard_False; -} +Standard_Boolean CPPJini_HasEmptyConstructor ( const Handle( MS_Type )& atyp ) { + Handle( MS_Class ) thecl = Handle( MS_Class ) :: DownCast ( atyp ); -void CPPJini_ReturnBuilder(const Handle(MS_MetaSchema)& aMeta, - const Handle(EDL_API)& api, -// const Handle(TCollection_HAsciiString)& className, - const Handle(TCollection_HAsciiString)& , - const Handle(MS_Method)& m, - const Handle(TCollection_HAsciiString)& MethodCall, - Handle(TCollection_HAsciiString)& RetInDecl, - Handle(TCollection_HAsciiString)& RetInCall, - Handle(TCollection_HAsciiString)& RetOut) -{ - if (!m->Returns().IsNull()) { - Handle(MS_Type) rtype = aMeta->GetType(m->Returns()->TypeName()); + if ( thecl.IsNull () ) return Standard_False; + + Handle( MS_HSequenceOfMemberMet ) methods = thecl -> GetMethods (); + + for ( Standard_Integer i = 1; i<= methods -> Length (); ++i ) { + + if ( methods -> Value ( i ) -> IsKind ( STANDARD_TYPE( MS_Construc ) ) ) { + + Handle( MS_HArray1OfParam ) parameters = methods -> Value ( i ) -> Params (); + + if ( parameters.IsNull () ) { + + if ( methods -> Value ( i ) -> Private () ) return Standard_False; + + return Standard_True; + + } // end if + + } // end if + + } // end for + + return Standard_False; + +} // end CPPJini_HasEmptyConstructor + +void CPPJini_ReturnBuilder ( + const Handle( MS_MetaSchema )& aMeta, + const Handle( EDL_API )& api, + const Handle( TCollection_HAsciiString )& className, + const Handle( MS_Method )& m, + const Handle( TCollection_HAsciiString )& MethodCall, + Handle( TCollection_HAsciiString )& RetInDecl, + Handle( TCollection_HAsciiString )& RetInCall, + Handle( TCollection_HAsciiString )& RetOut + ) { + + char* objType = "jobject"; + + if ( !m -> Returns ().IsNull () ) { + + Handle( MS_Type ) rtype = aMeta -> GetType ( + m -> Returns () -> TypeName () + ); + + if ( rtype -> IsKind ( STANDARD_TYPE( MS_Alias ) ) ) { - if (rtype->IsKind(STANDARD_TYPE(MS_Alias))) { - Handle(TCollection_HAsciiString) parname; - Handle(MS_Alias) analias = *((Handle(MS_Alias)*)&rtype); + Handle( TCollection_HAsciiString ) parname; + Handle( MS_Alias ) analias = + *( ( Handle( MS_Alias )* )& rtype ); - parname = analias->DeepType(); + parname = analias -> DeepType (); - if (aMeta->IsDefined(parname)) { - rtype = aMeta->GetType(parname); - } - else { - ErrorMsg << "CPPJini" << "Type " << parname << " not defined..." << endm; - Standard_NoSuchObject::Raise(); - } - } + if ( aMeta -> IsDefined ( parname ) ) + + rtype = aMeta -> GetType ( parname ); + + else { + + ErrorMsg << "CPPJini" << "Type " << parname << " not defined..." << endm; + Standard_NoSuchObject :: Raise (); + + } // end else + + } // end if - int curprimtype = 0; - RetInDecl = CPPJini_ConvertToJavaType(aMeta,rtype->FullName(),Standard_False,curprimtype); + int curprimtype = 0; + + RetInDecl = CPPJini_ConvertToJavaType ( + aMeta, rtype -> FullName (), Standard_False, curprimtype + ); - if (strcmp(RetInDecl->ToCString(),"jobject")) { - // retour type basique + if ( strcmp ( RetInDecl -> ToCString (),"jobject" ) ) { - if (!strcmp(RetInDecl->ToCString(),"jstring")) { - api->AddVariable("%MethodCall",MethodCall->ToCString()); - api->Apply("%Return","ReturnString"); - RetInCall->AssignCat(api->GetVariableValue("%Return")); - RetOut->AssignCat("return thejret;"); - } - else if (!strcmp(RetInDecl->ToCString(),"cstring")) { - RetInDecl = new TCollection_HAsciiString("jobject"); - api->AddVariable("%MethodCall",MethodCall->ToCString()); - api->Apply("%Return","ReturnCString"); - RetInCall->AssignCat(api->GetVariableValue("%Return")); - RetOut->AssignCat("return thejret;"); - } - else { - RetInCall->AssignCat(RetInDecl); - RetInCall->AssignCat(" thejret = "); - RetInCall->AssignCat(MethodCall); - RetInCall->AssignCat(";\n"); - RetOut->AssignCat("return thejret;"); - } - } + if ( !strcmp ( RetInDecl -> ToCString (), "jstring" ) ) { + + api -> AddVariable ( "%MethodCall", MethodCall -> ToCString () ); + api -> Apply("%Return","ReturnString"); + RetInCall -> AssignCat ( api -> GetVariableValue ( "%Return" ) ); + objType = "jstring"; + + } else if ( !strcmp ( RetInDecl -> ToCString (),"cstring" ) ) { + + RetInDecl = new TCollection_HAsciiString("jobject"); + api -> AddVariable ( "%MethodCall", MethodCall -> ToCString () ); + api -> Apply ( "%Return", "ReturnCString" ); + RetInCall -> AssignCat ( api -> GetVariableValue ( "%Return" ) ); + + } else { + + objType = RetInDecl -> ToCString (); + RetInCall -> AssignCat ( " thejret = " ); + RetInCall -> AssignCat ( MethodCall ); + RetInCall -> AssignCat ( ";\n" ); + goto setReturn; + + } // end else + + } else { + + if ( rtype -> IsKind ( STANDARD_TYPE( MS_StdClass ) ) ) { + + Handle( MS_StdClass ) aClass = + *( ( Handle( MS_StdClass )* )& rtype ); + + api -> AddVariable ( + "%ClassName", aClass -> FullName () -> ToCString() + ); + api -> AddVariable ( "%MethodCall", MethodCall -> ToCString () ); + + if ( CPPJini_IsCasType ( rtype -> FullName () ) ) + + api -> AddVariable ( "%FromInterface", "jcas" ); + else { - if (rtype->IsKind(STANDARD_TYPE(MS_StdClass))) { - Handle(MS_StdClass) aClass = *((Handle(MS_StdClass)*)&rtype); - api->AddVariable("%ClassName",aClass->FullName()->ToCString()); - api->AddVariable("%MethodCall",MethodCall->ToCString()); - if (CPPJini_IsCasType(rtype->FullName())) { + Handle( TCollection_HAsciiString ) cltName; + Handle( TCollection_HAsciiString ) iName = + CPPJini_Defined ( aClass -> FullName (), cltName ) ? + cltName : CPPJini_InterfaceName; - api->AddVariable("%FromInterface","jcas"); - } - else { + api -> AddVariable ( + "%FromInterface", + CPPJini_DotReplace ( + iName -> ToCString (), '/' + ) -> ToCString () + ); - Handle( TCollection_HAsciiString ) cltName; - Handle( TCollection_HAsciiString ) iName = CPPJini_Defined ( - aClass -> FullName (), cltName - ) ? cltName : CPPJini_InterfaceName; - api -> AddVariable ( - "%FromInterface", - CPPJini_DotReplace ( - iName -> ToCString (), '/' - ) -> ToCString () - ); - } - if (aClass->IsTransient()) { - api->Apply("%Return","ReturnHandle"); - } - else { - if (m->IsRefReturn()) { - api->Apply("%Return","ReturnValueRef"); - } - else if (CPPJini_HasMagicConstructor(aClass)) { - api->Apply("%Return","ReturnValueMagic"); - } - else if (CPPJini_HasEmptyConstructor(aClass)) { - api->Apply("%Return","ReturnValueEmpty"); - } - else { - api->Apply("%Return","ReturnValueMalloc"); - } - } - RetInCall->AssignCat(api->GetVariableValue("%Return")); - RetOut->AssignCat("return thejret;"); - } - else { - // type primitif non converti en type java - api->AddVariable("%ClassName",rtype->FullName()->ToCString()); - api->AddVariable("%MethodCall",MethodCall->ToCString()); - if (CPPJini_IsCasType(rtype->FullName())) { - api->AddVariable("%FromInterface","jcas"); - } - else { + } // end else + + if ( aClass -> IsTransient () ) + + api -> Apply ( "%Return", "ReturnHandle" ); - Handle( TCollection_HAsciiString ) cltName; - Handle( TCollection_HAsciiString ) iName = CPPJini_Defined ( - rtype -> FullName (), cltName - ) ? cltName : CPPJini_InterfaceName; - api -> AddVariable ( - "%FromInterface", - CPPJini_DotReplace ( - iName -> ToCString (), '/' - ) -> ToCString () - ); - } - if (m->IsRefReturn()) { - api->Apply("%Return","ReturnValueRef"); - } else { - api->Apply("%Return","ReturnValueMalloc"); - } - RetInCall->AssignCat(api->GetVariableValue("%Return")); - RetOut->AssignCat("return thejret;"); - } + if ( m -> IsRefReturn () ) - } - } - else { - // pas de return - RetInDecl->AssignCat("void"); - RetInCall->AssignCat(MethodCall); - RetInCall->AssignCat(";\n"); - } -} + api -> Apply ( "%Return","ReturnValueRef" ); + + else if ( CPPJini_HasMagicConstructor ( aClass ) ) + + api -> Apply ( "%Return", "ReturnValueMagic" ); + + else if ( CPPJini_HasEmptyConstructor ( aClass ) ) + + api -> Apply ( "%Return","ReturnValueEmpty" ); + + else + + api -> Apply ( "%Return","ReturnValueMalloc" ); + + } // end else + + RetInCall -> AssignCat ( api -> GetVariableValue ( "%Return" ) ); + + } else { + + api -> AddVariable ( + "%ClassName", rtype -> FullName () -> ToCString () + ); + api -> AddVariable ( "%MethodCall", MethodCall -> ToCString () ); + + if ( CPPJini_IsCasType ( rtype -> FullName () ) ) + + api -> AddVariable ( "%FromInterface","jcas" ); + + else { + + Handle( TCollection_HAsciiString ) cltName; + Handle( TCollection_HAsciiString ) iName = + CPPJini_Defined ( + rtype -> FullName (), cltName + ) ? cltName : CPPJini_InterfaceName; + + api -> AddVariable ( + "%FromInterface", + CPPJini_DotReplace ( + iName -> ToCString (), '/' + ) -> ToCString () + ); + + } // end else + + if ( m -> IsRefReturn () ) + + api -> Apply ( "%Return", "ReturnValueRef" ); + + else + + api -> Apply ( "%Return", "ReturnValueMalloc" ); + + RetInCall -> AssignCat ( api -> GetVariableValue ( "%Return" ) ); + + } // end else + + } // end else +setReturn: + api -> AddVariable ( "%ObjType", objType ); + api -> Apply ( "%MVar", "ReturnVar" ); + api -> AddVariable ( "%MRet", "return thejret;" ); + + } else { + + RetInDecl -> AssignCat ( "void" ); + RetInCall -> AssignCat ( MethodCall ); + RetInCall -> AssignCat ( ";\n" ); + + } // end else + +} // end CPPJini_ReturnBuilder // build a method call for stub c++ // @@ -1467,6 +1702,12 @@ void CPPJini_MethodBuilder(const Handle(MS_MetaSchema)& aMeta, metname->AssignCat(CPPJini_InterfaceName); metname->AssignCat("_"); Handle(TCollection_HAsciiString) classunder = CPPJini_UnderScoreReplace(className); + + + api -> AddVariable ( "%MVar", "" ); + api -> AddVariable ( "%MRet", "" ); + + if ((nummet != 0) || (m->IsKind(STANDARD_TYPE(MS_Construc)))) { metname->AssignCat(classunder); metname->AssignCat("_"); @@ -1606,15 +1847,11 @@ void CPPJini_MethodBuilder(const Handle(MS_MetaSchema)& aMeta, api->AddVariable("%Method",metstart->ToCString()); api->AddVariable("%MBody",metbody->ToCString()); -char* var1 = "MethodTemplateDefOBJS"; -char* var2 = "MethodTemplateDef"; - - api -> Apply ( "%Method", !strcmp ( api -> GetVariableValue ( "%CPPJiniEXTDBMS" ) -> ToCString (), "OBJS" - ) ? var1 : var2 + ) ? "MethodTemplateDefOBJS" : "MethodTemplateDef" ); } @@ -1783,62 +2020,89 @@ void CPPJini_TypeExtract(const Handle(MS_MetaSchema)& aMeta, } } -void CPPJini_Extract(const Handle(MS_MetaSchema)& aMeta, - const Handle(TCollection_HAsciiString)& aTypeName, - const Handle(TColStd_HSequenceOfHAsciiString)& edlsfullpath, - const Handle(TCollection_HAsciiString)& outdir, - const Handle(TColStd_HSequenceOfHAsciiString)& outfile, - const Standard_CString Mode) -{ - if (aMeta->IsDefined(aTypeName) || aMeta->IsPackage(aTypeName)) { - CPPJini_ExtractionType theMode = CPPJini_COMPLETE; - - if (strcmp(Mode,"CPPJini_COMPLETE") == 0) { - theMode = CPPJini_COMPLETE; - } - else if (strcmp(Mode,"CPPJini_INCOMPLETE") == 0) { - theMode = CPPJini_INCOMPLETE; - } - else if (strcmp(Mode,"CPPJini_SEMICOMPLETE") == 0) { - theMode = CPPJini_SEMICOMPLETE; - } - else { - ErrorMsg << "CPPJini" << "Unknown extraction mode:" << Mode << endm; - Standard_NoSuchObject::Raise(); - } +void CPPJini_Extract ( + const Handle( MS_MetaSchema )& aMeta, + const Handle( TCollection_HAsciiString )& aTypeName, + const Handle( TColStd_HSequenceOfHAsciiString )& edlsfullpath, + const Handle( TCollection_HAsciiString )& outdir, + const Handle( TColStd_HSequenceOfHAsciiString )& outfile, + const Standard_CString Mode + ) { + + if ( aMeta -> IsDefined ( aTypeName ) || + aMeta -> IsPackage ( aTypeName ) + ) { + + CPPJini_ExtractionType theMode = CPPJini_COMPLETE; - Standard_Boolean fDuplicate; - CPPJini_ExtractionType type; - Handle( TCollection_HAsciiString ) cltName; + if ( strcmp ( Mode, "CPPJini_COMPLETE" ) == 0 ) - if ( CPPJini_Defined ( aMeta, aTypeName, cltName, fDuplicate, type ) ) { + theMode = CPPJini_COMPLETE; - if ( theMode == CPPJini_COMPLETE && type == CPPJini_COMPLETE || - theMode == CPPJini_INCOMPLETE || - theMode == CPPJini_SEMICOMPLETE && type == CPPJini_COMPLETE - ) { + else if ( strcmp ( Mode, "CPPJini_INCOMPLETE" ) == 0 ) - InfoMsg << "CPPJini" << "Skipping " << aTypeName - << " (already defined in " << cltName << ")" << endm; + theMode = CPPJini_INCOMPLETE; - if ( fDuplicate ) + else if ( strcmp ( Mode, "CPPJini_SEMICOMPLETE" ) == 0 ) - WarningMsg << "CPPJini" << aTypeName << " defined in more than one client declared in 'uses' statement" - << endm; + theMode = CPPJini_SEMICOMPLETE; - return; + else { - } // end if + ErrorMsg << "CPPJini" << "Unknown extraction mode:" << Mode << endm; + Standard_NoSuchObject :: Raise (); - } // end if + } // end else - CPPJini_TypeExtract(aMeta,aTypeName,edlsfullpath,outdir,outfile,theMode,Mode); - } - else { - ErrorMsg << "CPPJini" << "Type " << aTypeName << " not defined..." << endm; - Standard_NoSuchObject::Raise(); - } -} + s_MS = aMeta; + s_Type = theMode; + + Standard_Boolean fDuplicate; + CPPJini_ExtractionType type; + Handle( TCollection_HAsciiString ) cltName; + + if ( CPPJini_Defined ( + aTypeName, cltName, fDuplicate, type + ) + ) { + + if ( theMode == CPPJini_COMPLETE && type == CPPJini_COMPLETE || + theMode == CPPJini_INCOMPLETE || + theMode == CPPJini_SEMICOMPLETE && type == CPPJini_COMPLETE + ) { + + InfoMsg << "CPPJini" << "Skipping " << aTypeName + << " (already defined in " << cltName << ")" << endm; + + g_SkipMap.Bind ( aTypeName, cltName ); + + if ( fDuplicate ) + + WarningMsg << "CPPJini" + << aTypeName + << " defined in more than one client declared in 'uses' statement" + << endm; + + return; + + } // end if + + } // end if + + g_ImportMap.Clear (); + + CPPJini_TypeExtract ( + aMeta, aTypeName, edlsfullpath, outdir, outfile, theMode, Mode + ); + + } else { + + ErrorMsg << "CPPJini" << "Type " << aTypeName << " not defined..." << endm; + Standard_NoSuchObject :: Raise (); + + } // end else + +} // end CPPJini_Extract Handle( TCollection_HAsciiString ) CPPJini_DotReplace ( char* str, char c ) { diff --git a/src/CPPJini/CPPJini_ClientInfo.cdl b/src/CPPJini/CPPJini_ClientInfo.cdl index bbafe19..d0f5e3a 100755 --- a/src/CPPJini/CPPJini_ClientInfo.cdl +++ b/src/CPPJini/CPPJini_ClientInfo.cdl @@ -16,8 +16,11 @@ private class ClientInfo from CPPJini inherits Transient from Standard is - Create ( aMS : MetaSchema from MS; aName : HAsciiString from TCollection ) - returns mutable ClientInfo from CPPJini; + Create ( + aMS : MetaSchema from MS; + aName : HAsciiString from TCollection; + aLevel : Integer from Standard + ) returns mutable ClientInfo from CPPJini; ---Purpose: constructor HasComplete ( me; aName : HAsciiString from TCollection ) @@ -43,12 +46,28 @@ private class ClientInfo from CPPJini inherits Transient from Standard ---Purpose: returns field ---C++: return const& + Level ( me ) returns Integer from Standard; + ---Purpose: returns level of the client in the 'uses' hierarchy + ---C++: inline + + Root ( me ) returns Boolean from Standard; + ---Purpose: returns a flag indicating whether client is a + -- root in the 'uses' hierarchy + ---C++: inline + + SetRoot ( me : mutable; aRoot : Boolean from Standard ); + ---Purpose: sets client state indicating that the client is a root + -- in the 'uses' hierarchy + ---C++: inline + fields myName : HAsciiString from TCollection; myComplete : MapOfHAsciiString from WOKTools; myIncomplete : MapOfHAsciiString from WOKTools; mySemicomplete : MapOfHAsciiString from WOKTools; + myLevel : Integer from Standard; + myRoot : Boolean from Standard; end ClientInfo; diff --git a/src/CPPJini/CPPJini_ClientInfo.cxx b/src/CPPJini/CPPJini_ClientInfo.cxx index d67b400..b6c7136 100755 --- a/src/CPPJini/CPPJini_ClientInfo.cxx +++ b/src/CPPJini/CPPJini_ClientInfo.cxx @@ -8,7 +8,8 @@ CPPJini_ClientInfo :: CPPJini_ClientInfo ( const Handle( MS_MetaSchema )& aMS, - const Handle( TCollection_HAsciiString )& aName + const Handle( TCollection_HAsciiString )& aName, + const Standard_Integer aLevel ) { Handle( MS_Client ) clt = aMS -> GetClient ( aName ); @@ -30,7 +31,9 @@ CPPJini_ClientInfo :: CPPJini_ClientInfo ( } // end else - myName = new TCollection_HAsciiString ( aName ); + myName = new TCollection_HAsciiString ( aName ); + myLevel = aLevel; + myRoot = Standard_False; } // end CPPJini_ClientInfo :: CPPJini_ClientInfo diff --git a/src/CPPJini/CPPJini_Enum.cxx b/src/CPPJini/CPPJini_Enum.cxx index b7b29d9..ce042ee 100755 --- a/src/CPPJini/CPPJini_Enum.cxx +++ b/src/CPPJini/CPPJini_Enum.cxx @@ -1,60 +1,54 @@ -// CLE -// -// 10/1996 -// -#include - #include -#include +#include #include #include +#include + #include + #include #include -// Extraction of a transient class (inst or std) -// -//void CPPJini_Enum(const Handle(MS_MetaSchema)& aMeta, -void CPPJini_Enum(const Handle(MS_MetaSchema)& , - const Handle(EDL_API)& api, - const Handle(MS_Enum)& anEnum, - const Handle(TColStd_HSequenceOfHAsciiString)& outfile) -{ - if (anEnum.IsNull()) return; - - Handle(TColStd_HSequenceOfHAsciiString) EnumVal = anEnum->Enums(); - Handle(TCollection_HAsciiString) result, - aFileName; - Standard_Integer i; - - result = new TCollection_HAsciiString(EnumVal->Length()); - - // api->AddVariable("%Nb",result->ToCString()); - api->AddVariable("%Class",anEnum->FullName()->ToCString()); - - result->Clear(); +void CPPJini_Enum ( + const Handle( MS_MetaSchema )& aMeta, + const Handle( EDL_API )& api, + const Handle( MS_Enum )& anEnum, + const Handle( TColStd_HSequenceOfHAsciiString )& outfile + ) { - for (i = 1; i <= EnumVal->Length(); i++) { - api->AddVariable("%Value",EnumVal->Value(i)->ToCString()); - Handle(TCollection_HAsciiString) number = new TCollection_HAsciiString(i-1); - api->AddVariable("%Number",number->ToCString()); - api->Apply("%aValue","EnumValueDef"); - result->AssignCat(api->GetVariableValue("%aValue")); - } + if ( anEnum.IsNull () ) return; - api->AddVariable("%Values",result->ToCString()); + Handle( TColStd_HSequenceOfHAsciiString ) EnumVal = anEnum -> Enums (); + Handle( TCollection_HAsciiString ) result, aFileName; + Standard_Integer i; + + result = new TCollection_HAsciiString ( EnumVal -> Length () ); - api->Apply("%outClass","EnumJAVA"); + api -> AddVariable ( "%Class", anEnum -> FullName () -> ToCString () ); - aFileName = new TCollection_HAsciiString(api->GetVariableValue("%FullPath")); - aFileName->AssignCat(anEnum->FullName()); - aFileName->AssignCat(".java"); + result -> Clear (); + + for ( i = 1; i <= EnumVal -> Length (); ++i ) { - CPPJini_WriteFile(api,aFileName,"%outClass"); - outfile->Append(aFileName); -} + api -> AddVariable ( "%Value", EnumVal -> Value ( i ) -> ToCString () ); + Handle( TCollection_HAsciiString ) number = new TCollection_HAsciiString ( i - 1 ); + api -> AddVariable ( "%Number", number -> ToCString () ); + api -> Apply ( "%aValue","EnumValueDef" ); + result -> AssignCat ( api -> GetVariableValue ( "%aValue" ) ); + + } // end for + + api -> AddVariable ( "%Values", result -> ToCString () ); + api -> Apply ( "%outClass", "EnumJAVA" ); + + aFileName = new TCollection_HAsciiString ( api -> GetVariableValue ( "%FullPath" ) ); + aFileName -> AssignCat ( anEnum -> FullName () ); + aFileName -> AssignCat ( ".java" ); + CPPJini_WriteFile ( api, aFileName, "%outClass" ); + outfile -> Append ( aFileName ); +} // end CPPJini_Enum diff --git a/src/CPPJini/CPPJini_General.edl b/src/CPPJini/CPPJini_General.edl index 781fcd9..f27fe4b 100755 --- a/src/CPPJini/CPPJini_General.edl +++ b/src/CPPJini/CPPJini_General.edl @@ -71,9 +71,10 @@ $private %Virtual native %Return %Class_%MethodName_%NbMet(%Arguments); $ @end; -@template MethodTemplateDef(%Method,%MBody) is +@template MethodTemplateDef(%Method,%MBody,%MVar,%MRet) is $%Method ${ +$%MVar $jcas_Locking alock(env); ${ $try { @@ -86,14 +87,16 @@ $ Err << (char) 0; $ jcas_ThrowException(env,Err.rdbuf()->str()); $} $} -$alock.Release(); +$alock.Release(); +$%MRet $} $ @end; -@template MethodTemplateDefOBJS(%Method,%MBody) is +@template MethodTemplateDefOBJS(%Method,%MBody,%MVar,%MRet) is $%Method ${ +$%MVar; $jcas_Locking alock(env); ${ $OS_ESTABLISH_FAULT_HANDLER; @@ -109,6 +112,7 @@ $} $OS_END_FAULT_HANDLER; $} $alock.Release(); +$%MRet; $} $ @end; @@ -127,5 +131,41 @@ $%Class::~%Class() {} @template EnumValueDef(%Class,%Value,%Number) is -$public final static int %Value = %Number; +$public final static short %Value = %Number; +@end; + +@template GetPrevious ( %PrevClassName, %PackName, %ShortClassName, %ShortPackName ) is +$ +$public %PackName.%PrevClassName get%ShortPackName%ShortClassName () { +$ +$ if ( thePrevious == null ) thePrevious = new %PackName.%PrevClassName (); +$ +$ thePrevious.HID = HID; +$ +$ if ( aVirer == 1 ) { +$ +$ thePrevious.aVirer = aVirer; +$ aVirer = 0; +$ +$ } // end if +$ +$ return thePrevious; +$ +$} // end get%PackName%ShortClassName +@end; + +@template SetPrevious ( %Class, %PackName, %PrevClassName ) is +$public %Class ( %PackName.%PrevClassName aPrev ) { +$ +$ thePrevious = aPrev; +$ HID = aPrev.HID; +$ aVirer = 0; +$ +$} // end %Class +@end; + +@template ThePrevious ( %PackName, %PrevClassName ) is +$ +$ private %PackName.%PrevClassName thePrevious = null; +$ @end; diff --git a/src/CPPJini/CPPJini_MPV.cxx b/src/CPPJini/CPPJini_MPV.cxx index 43744ed..58c874d 100755 --- a/src/CPPJini/CPPJini_MPV.cxx +++ b/src/CPPJini/CPPJini_MPV.cxx @@ -1,349 +1,453 @@ -#define CPPJini_CREATE_EMPTY_JAVA_CONSTRUCTOR 0 -// CLE -// -// 10/1995 -// -#include +#define CPPJini_CREATE_EMPTY_JAVA_CONSTRUCTOR 1 #include -#include - +#include +#include +#include +#include +#include #include -#include -#include +#include +#include #include -#include +#include #include - -#include -#include +#include #include #include +#include +#include #include - -#include -#include -#include -#include -#include - -#include -#include +#include #include #include #include -#include +#include +#include + +#include + +#include #include +#include #include -#include +#include +#include #include +#include +#include #include -#include -#include -#include +extern WOKTools_MapOfHAsciiString g_ImportMap; +extern Handle( CPPJini_ClientInfo ) g_Client; extern Standard_Boolean CPPJini_HasComplete ( const Handle( TCollection_HAsciiString )&, Handle( TCollection_HAsciiString )&, Standard_Boolean& ); - extern Standard_Boolean CPPJini_HasIncomplete ( const Handle( TCollection_HAsciiString )&, Handle( TCollection_HAsciiString )&, Standard_Boolean& ); - extern Standard_Boolean CPPJini_HasSemicomplete ( const Handle( TCollection_HAsciiString )&, Handle( TCollection_HAsciiString )&, Standard_Boolean& ); - extern Standard_Boolean CPPJini_Defined ( const Handle( TCollection_HAsciiString )&, Handle( TCollection_HAsciiString )& ); +extern Standard_Boolean CPPJini_Defined ( + const Handle( TCollection_HAsciiString )&, + Handle( TCollection_HAsciiString )&, + Standard_Boolean&, + CPPJini_ExtractionType& + ); +extern void CPPJini_AddImport ( + const Handle( EDL_API )&, + const Handle( TCollection_HAsciiString )&, + const Handle( TCollection_HAsciiString )& + ); +extern void CPPJini_MethodUsedTypes ( + const Handle( MS_MetaSchema )&, + const Handle( MS_Method )&, + const Handle( TColStd_HSequenceOfHAsciiString )&, + const Handle( TColStd_HSequenceOfHAsciiString )& + ); +extern Handle( TCollection_HAsciiString )& CPPJini_MPVRootName (); +extern Handle( TCollection_HAsciiString ) CPPJini_DotReplace ( char*, char = '_' ); -Handle(TCollection_HAsciiString)& CPPJini_MPVRootName(); - -extern Handle( TCollection_HAsciiString ) CPPJini_DotReplace ( char*, char = '_' ); - -void CPPJini_MethodUsedTypes(const Handle(MS_MetaSchema)& aMeta, - const Handle(MS_Method)& aMethod, - const Handle(TColStd_HSequenceOfHAsciiString)& List, - const Handle(TColStd_HSequenceOfHAsciiString)& Incp); - -// Extraction of .cxx for handled object -// -//void CPPJini_MPVDerivated(const Handle(MS_MetaSchema)& aMeta, -void CPPJini_MPVDerivated(const Handle(MS_MetaSchema)& , - const Handle(EDL_API)& api, - const Handle(MS_Class)& aClass, - const Handle(TColStd_HSequenceOfHAsciiString)& outfile, - const Handle(TColStd_HSequenceOfHAsciiString)& inclist, - const Handle(TColStd_HSequenceOfHAsciiString)& supplement) -{ - Handle(TCollection_HAsciiString) publics = new TCollection_HAsciiString; - Standard_Integer i; - - api->AddVariable("%Class",aClass->FullName()->ToCString()); - - for (i = 1; i <= inclist->Length(); i++) { - if (!inclist->Value(i)->IsSameString(aClass->FullName())) { - api->AddVariable("%IClass",inclist->Value(i)->ToCString()); - api->Apply("%Includes","IncludeCPlus"); - publics->AssignCat(api->GetVariableValue("%Includes")); - } - } - - api->AddVariable("%Includes",publics->ToCString()); - publics->Clear(); +void CPPJini_MPVDerivated ( + const Handle( MS_MetaSchema )& aMeta, + const Handle( EDL_API )& api, + const Handle( MS_Class )& aClass, + const Handle( TColStd_HSequenceOfHAsciiString )& outfile, + const Handle( TColStd_HSequenceOfHAsciiString )& inclist, + const Handle( TColStd_HSequenceOfHAsciiString )& supplement + ) { + Handle( TCollection_HAsciiString ) publics = new TCollection_HAsciiString (); + Standard_Integer i; - for (i = 1; i <= supplement->Length(); i++) { - publics->AssignCat(supplement->Value(i)); - } + api -> AddVariable ( "%Class",aClass -> FullName () -> ToCString () ); - api->AddVariable("%Methods",publics->ToCString()); - publics->Clear(); + for ( i = 1; i <= inclist -> Length (); ++i ) + if ( !inclist -> Value ( i ) -> IsSameString ( aClass -> FullName () ) ) { - api->AddVariable("%Class",aClass->FullName()->ToCString()); + api -> AddVariable ( "%IClass", inclist -> Value ( i ) -> ToCString () ); + api -> Apply ( "%Includes", "IncludeCPlus" ); + publics -> AssignCat ( api->GetVariableValue ( "%Includes" ) ); - api->Apply("%outClass","ValueClassClientCXX"); + } // end if - // we write the .cxx of this class - // - Handle(TCollection_HAsciiString) aFile = new TCollection_HAsciiString(api->GetVariableValue("%FullPath")); + api -> AddVariable ( "%Includes", publics -> ToCString () ); + publics -> Clear (); + + for ( i = 1; i <= supplement -> Length(); ++i ) + + publics -> AssignCat ( supplement -> Value ( i ) ); + + api -> AddVariable ( "%Methods", publics -> ToCString () ); + publics -> Clear (); + + api -> AddVariable ( "%Class", aClass -> FullName () -> ToCString () ); + + Handle( TCollection_HAsciiString ) iName = api -> GetVariableValue ( "%Interface" ); + + iName -> ChangeAll ( '.', '_' ); + api -> AddVariable ( "%IncludeInterface", iName -> ToCString () ); + api -> Apply ( "%outClass", "ValueClassClientCXX" ); + + Handle( TCollection_HAsciiString ) aFile = + new TCollection_HAsciiString ( api -> GetVariableValue ( "%FullPath" ) ); - aFile->AssignCat(CPPJini_InterfaceName); - aFile->AssignCat("_"); - aFile->AssignCat(aClass->FullName()); - aFile->AssignCat("_java.cxx"); + aFile -> AssignCat ( CPPJini_InterfaceName ); + aFile -> AssignCat ( "_" ); + aFile -> AssignCat ( aClass -> FullName () ); + aFile -> AssignCat ( "_java.cxx" ); - CPPJini_WriteFile(api,aFile,"%outClass"); + CPPJini_WriteFile ( api, aFile, "%outClass" ); - outfile->Append(aFile); -} - - -// Extraction of a transient class (inst or std) -// -void CPPJini_MPVClass(const Handle(MS_MetaSchema)& aMeta, - const Handle(EDL_API)& api, - const Handle(MS_Class)& aClass, - const Handle(TColStd_HSequenceOfHAsciiString)& outfile, - const CPPJini_ExtractionType MustBeComplete, - const Handle(MS_HSequenceOfMemberMet)& theMetSeq) -{ - Handle(MS_StdClass) theClass = Handle(MS_StdClass)::DownCast(aClass); - Handle(TColStd_HSequenceOfHAsciiString) List = new TColStd_HSequenceOfHAsciiString; - Handle(TColStd_HSequenceOfHAsciiString) incp = new TColStd_HSequenceOfHAsciiString; - - if (!theClass.IsNull()) { - Standard_Integer i; - Handle(MS_HSequenceOfMemberMet) methods; - Handle(TCollection_HAsciiString) publics = new TCollection_HAsciiString; - Handle(TCollection_HAsciiString) SuppMethod = new TCollection_HAsciiString; - Handle(TColStd_HSequenceOfHAsciiString) Supplement = new TColStd_HSequenceOfHAsciiString; - - // we create the inheritance - // - if (theClass->GetInheritsNames()->Length() == 0) { - api->AddVariable("%Inherits",CPPJini_MPVRootName()->ToCString()); - } - else { - List->Append(theClass->GetInheritsNames()->Value(1)); - api->AddVariable("%Inherits",CPPJini_GetFullJavaType(theClass->GetInheritsNames()->Value(1))->ToCString()); + outfile -> Append ( aFile ); + +} // end CPPJini_MPVDerivated + +void CPPJini_MPVClass ( + const Handle( MS_MetaSchema )& aMeta, + const Handle( EDL_API )& api, + const Handle( MS_Class )& aClass, + const Handle( TColStd_HSequenceOfHAsciiString )& outfile, + const CPPJini_ExtractionType MustBeComplete, + const Handle( MS_HSequenceOfMemberMet )& theMetSeq + ) { + + Handle( MS_StdClass ) theClass = Handle( MS_StdClass ) :: DownCast ( aClass ); + Handle( TColStd_HSequenceOfHAsciiString ) List = new TColStd_HSequenceOfHAsciiString (); + Handle( TColStd_HSequenceOfHAsciiString ) incp = new TColStd_HSequenceOfHAsciiString (); + Handle( TCollection_HAsciiString ) jType; + + if ( !theClass.IsNull () ) { + + Standard_Integer i; + Standard_Boolean defConst = Standard_False; + Handle( MS_HSequenceOfMemberMet ) methods; + Handle( TCollection_HAsciiString ) publics = new TCollection_HAsciiString (); + Handle( TCollection_HAsciiString ) members = new TCollection_HAsciiString (); + Handle( TCollection_HAsciiString ) SuppMethod = new TCollection_HAsciiString (); + Handle( TColStd_HSequenceOfHAsciiString ) Supplement = new TColStd_HSequenceOfHAsciiString (); + + if ( theClass -> GetInheritsNames () -> Length () == 0 ) + + api -> AddVariable ( "%Inherits", CPPJini_MPVRootName () -> ToCString () ); + + else { + + jType = CPPJini_GetFullJavaType ( theClass -> GetInheritsNames () -> Value ( 1 ) ); + + List -> Append ( theClass -> GetInheritsNames () -> Value ( 1 ) ); + api -> AddVariable ( "%Inherits", jType -> ToCString () ); - } + } // end else - api->AddVariable("%Class",theClass->FullName()->ToCString()); + api -> AddVariable ( "%Class", theClass -> FullName () -> ToCString () ); - if (MustBeComplete == CPPJini_SEMICOMPLETE) { - methods = theMetSeq; - } - else if (MustBeComplete == CPPJini_COMPLETE) { - methods = theClass->GetMethods(); - } - + if ( MustBeComplete == CPPJini_SEMICOMPLETE ) + + methods = theMetSeq; + + else if ( MustBeComplete == CPPJini_COMPLETE ) + + methods = theClass -> GetMethods (); #if CPPJini_CREATE_EMPTY_JAVA_CONSTRUCTOR - Standard_Boolean mustCreateEmptyConst = !CPPJini_HaveEmptyConstructor(aMeta,theClass->FullName(),methods); + Standard_Boolean mustCreateEmptyConst = + !CPPJini_HaveEmptyConstructor ( aMeta, theClass -> FullName (), methods ); #endif // CPPJini_CREATE_EMPTY_JAVA_CONSTRUCTOR + if ( MustBeComplete != CPPJini_INCOMPLETE ) { - if (MustBeComplete != CPPJini_INCOMPLETE) { - CPPJini_DataMapOfAsciiStringInteger mapnames; + CPPJini_DataMapOfAsciiStringInteger mapnames; - TColStd_Array1OfInteger theindexes(1,methods->Length()); - theindexes.Init(0); + TColStd_Array1OfInteger theindexes ( 1, methods -> Length () ); + theindexes.Init( 0 ); - for (i = 1; i <= methods->Length(); i++) { - CPPJini_CheckMethod(i,methods->Value(i)->Name(),mapnames,theindexes); - } + for ( i = 1; i <= methods -> Length (); ++i ) + + CPPJini_CheckMethod ( i, methods -> Value ( i ) -> Name (), mapnames, theindexes ); - for (i = 1; i <= methods->Length(); i++) { - CPPJini_BuildMethod(aMeta,api,theClass->FullName(),methods->Value(i),methods->Value(i)->Name(),theindexes(i)); - if (!api->GetVariableValue("%Method")->IsSameString(CPPJini_ErrorArgument)) { + for ( i = 1; i <= methods -> Length (); ++i ) { + + CPPJini_BuildMethod ( + aMeta, api, theClass -> FullName (), methods -> Value ( i ), + methods -> Value ( i ) -> Name (), theindexes ( i ) + ); + + if ( !api -> GetVariableValue ( "%Method" ) -> IsSameString ( CPPJini_ErrorArgument ) ) { + + Standard_Boolean cond = theClass -> Deferred () && + methods -> Value ( i ) -> IsKind ( STANDARD_TYPE( MS_Construc ) ); - if ((theClass->Deferred() && methods->Value(i)->IsKind(STANDARD_TYPE(MS_Construc))) - || methods->Value(i)->IsProtected() - || methods->Value(i)->Private()) { - // nothing - } - else { - CPPJini_MethodUsedTypes(aMeta,methods->Value(i),List,incp); - publics->AssignCat(api->GetVariableValue(VJMethod)); - CPPJini_MethodBuilder(aMeta,api,aClass->FullName(),methods->Value(i),methods->Value(i)->Name(),theindexes(i)); - Supplement->Append(api->GetVariableValue(VJMethod)); - } - } - } - } - - api->AddVariable("%Class",theClass->FullName()->ToCString()); + if ( !defConst && cond ) defConst = Standard_True; + + if ( !( cond || methods -> Value ( i ) -> IsProtected () + || methods -> Value ( i ) -> Private () + ) + ) { + + CPPJini_MethodUsedTypes ( aMeta, methods -> Value ( i ), List, incp ); + + members -> AssignCat ( api -> GetVariableValue ( VJMethod ) ); + CPPJini_MethodBuilder ( + aMeta, api, aClass -> FullName (), methods -> Value ( i ), + methods -> Value ( i ) -> Name (), theindexes ( i ) + ); + Supplement -> Append ( api -> GetVariableValue ( VJMethod ) ); + + } // end if + + } // end if + + } // end for + + } // end if + + api -> AddVariable ( "%Class", theClass -> FullName () -> ToCString () ); #if CPPJini_CREATE_EMPTY_JAVA_CONSTRUCTOR - if (mustCreateEmptyConst) { - api->Apply(VJMethod,"EmptyConstructorHeader"); - publics->AssignCat(api->GetVariableValue(VJMethod)); - } + if ( mustCreateEmptyConst || ( defConst && !mustCreateEmptyConst ) ) { + + api -> Apply ( VJMethod, "EmptyConstructorHeader" ); + members -> AssignCat ( api -> GetVariableValue ( VJMethod ) ); + + } // end if #endif // CPPJini_CREATE_EMPTY_JAVA_CONSTRUCTOR - Handle(TCollection_HAsciiString) namefinal = new TCollection_HAsciiString("Java_"); - namefinal->AssignCat(CPPJini_InterfaceName); - namefinal->AssignCat("_"); - namefinal->AssignCat(CPPJini_UnderScoreReplace(theClass->FullName())); - namefinal->AssignCat("_FinalizeValue"); + Handle( TCollection_HAsciiString ) namefinal = new TCollection_HAsciiString ( "Java_" ); + namefinal -> AssignCat ( CPPJini_InterfaceName ); + namefinal -> AssignCat ( "_" ); + namefinal -> AssignCat ( CPPJini_UnderScoreReplace ( theClass -> FullName () ) ); + namefinal -> AssignCat ( "_FinalizeValue" ); + + api -> AddVariable ( + "%MethodName", + CPPJini_DotReplace ( namefinal -> ToCString () ) -> ToCString () + ); + api -> Apply ( VJMethod, "FinalizeForValue" ); + Supplement -> Append ( api -> GetVariableValue ( VJMethod ) ); + + if ( MustBeComplete != CPPJini_INCOMPLETE ) { + + for ( i = 1; i <= List -> Length (); ++i ) { - api -> AddVariable ( - "%MethodName", - CPPJini_DotReplace ( namefinal -> ToCString () ) -> ToCString () - ); + jType = List -> Value ( i ); - api->Apply(VJMethod,"FinalizeForValue"); - Supplement->Append(api->GetVariableValue(VJMethod)); + if ( !jType -> IsSameString ( theClass -> FullName () ) ) { - api->AddVariable("%Methods",publics->ToCString()); + api -> AddVariable ( "%IClass", jType -> ToCString () ); - publics->Clear(); + if ( CPPJini_IsCasType ( jType ) ) - if (MustBeComplete != CPPJini_INCOMPLETE) { - - for (i = 1; i <= List->Length(); i++) { - if (!List->Value(i)->IsSameString(theClass->FullName())) { - api->AddVariable("%IClass",List->Value(i)->ToCString()); - if (CPPJini_IsCasType(List->Value(i))) { - api->Apply("%Includes","IncludeJCas"); - } - else { + api -> Apply ( "%Includes", "IncludeJCas" ); + + else { - Handle( TCollection_HAsciiString ) aClt; - Standard_Boolean fPush = Standard_False; + Handle( TCollection_HAsciiString ) aClt; + Standard_Boolean fPush = Standard_False; - if ( CPPJini_Defined ( List -> Value ( i ), aClt ) ) { + if ( CPPJini_Defined ( jType, aClt ) ) { - fPush = Standard_True; - api -> AddVariable ( "%Interface", aClt -> ToCString () ); + fPush = Standard_True; + api -> AddVariable ( "%Interface", aClt -> ToCString () ); - } // end if + } // end if - api->Apply("%Includes","Include"); + api -> Apply ( "%Includes", "Include" ); - if ( fPush ) + if ( fPush ) - api -> AddVariable ( - "%Interface", CPPJini_InterfaceName -> ToCString () - ); + api -> AddVariable ( "%Interface", CPPJini_InterfaceName -> ToCString () ); - } - publics->AssignCat(api->GetVariableValue("%Includes")); - } - } - + } // end else + + jType = api -> GetVariableValue ( "%Includes" ); + + if ( !g_ImportMap.Contains ( jType ) ) { + + g_ImportMap.Add ( jType ); + publics -> AssignCat ( jType ); + + } // end if + + } // end if + + } // end for - for (i = 1; i <= incp->Length(); i++) { - if (!incp->Value(i)->IsSameString(theClass->FullName())) { - api->AddVariable("%IClass",incp->Value(i)->ToCString()); - if (CPPJini_IsCasType(incp->Value(i))) { - api->Apply("%Includes","ShortDecJCas"); - } - else { - Handle( TCollection_HAsciiString ) aClt; - Standard_Boolean fPush = Standard_False; + for ( i = 1; i <= incp -> Length (); ++i ) { + + if ( !incp -> Value ( i ) -> IsSameString ( theClass -> FullName () ) ) { + + api -> AddVariable ( "%IClass", incp -> Value ( i ) -> ToCString () ); - if ( CPPJini_Defined ( incp -> Value ( i ), aClt ) ) { + if ( CPPJini_IsCasType ( incp -> Value ( i ) ) ) - fPush = Standard_True; - api -> AddVariable ( "%Interface", aClt -> ToCString () ); + api -> Apply ( "%Includes", "ShortDecJCas" ); - } // end if + else { - api->Apply("%Includes","ShortDec"); + Handle( TCollection_HAsciiString ) aClt; + Standard_Boolean fPush = Standard_False; - if ( fPush ) + if ( CPPJini_Defined ( incp -> Value ( i ), aClt ) ) { - api -> AddVariable ( - "%Interface", CPPJini_InterfaceName -> ToCString () - ); + fPush = Standard_True; + api -> AddVariable ( "%Interface", aClt -> ToCString () ); - } - publics->AssignCat(api->GetVariableValue("%Includes")); - } - } - } + } // end if - api->AddVariable("%Includes",publics->ToCString()); + api -> Apply ( "%Includes", "ShortDec" ); - // we create the inheritance - // - Handle( TCollection_HAsciiString ) aClt; - Handle( TCollection_HAsciiString ) name = theClass -> GetInheritsNames () -> Length () ? - theClass -> GetInheritsNames () -> Value ( 1 ) : - theClass -> FullName (); + if ( fPush ) - if ( CPPJini_Defined ( name, aClt ) ) { + api -> AddVariable ( + "%Interface", CPPJini_InterfaceName -> ToCString () + ); - aClt -> AssignCat ( "." ); - aClt -> AssignCat ( name ); - api -> AddVariable ( "%Inherits", aClt -> ToCString () ); + } // end else + + jType = api -> GetVariableValue ( "%Includes" ); + + if ( !g_ImportMap.Contains ( jType ) ) { + + g_ImportMap.Add ( jType ); + publics -> AssignCat ( jType ); + + } // end if + + } // end if + + } // end for + + } // end if + + api -> AddVariable ( "%Includes", publics -> ToCString () ); + + Handle( TCollection_HAsciiString ) aClt; + Handle( TCollection_HAsciiString ) anAncestor; + Standard_Boolean fDup; + CPPJini_ExtractionType thisType, otherType; + + if ( aClass -> GetInheritsNames () -> Length () ) { + + anAncestor = aClass -> GetInheritsNames () -> Value ( 1 ); + + g_Client -> Defined ( anAncestor, thisType ); + + if ( CPPJini_Defined ( anAncestor, aClt, fDup, otherType ) ) { + + if ( thisType == CPPJini_COMPLETE && otherType == CPPJini_COMPLETE || + thisType == CPPJini_INCOMPLETE || + thisType == CPPJini_SEMICOMPLETE && otherType == CPPJini_COMPLETE + ) { // this type has been skipped in this client, use one from other client + + CPPJini_AddImport ( api, aClt, anAncestor ); } else { - if (theClass->GetInheritsNames()->Length() == 0) { - api->AddVariable("%Inherits",CPPJini_MPVRootName()->ToCString()); - } - else { - api->AddVariable("%Inherits",CPPJini_GetFullJavaType(theClass->GetInheritsNames()->Value(1))->ToCString()); - } + CPPJini_AddImport ( api, g_Client -> Name (), anAncestor ); } // end else - api->AddVariable("%Class",theClass->FullName()->ToCString()); + } else { + + api -> AddVariable ( + "%Inherits", + CPPJini_GetFullJavaType ( + theClass -> GetInheritsNames () -> Value ( 1 ) + ) -> ToCString () + ); - api->Apply("%outClass","ValueClassClientJAVA"); + } // end else - // we write the .hxx of this class - // - Handle(TCollection_HAsciiString) aFile = new TCollection_HAsciiString(api->GetVariableValue("%FullPath")); + if ( CPPJini_Defined ( theClass -> FullName (), aClt ) ) { // create additional + // constructors + Handle( TCollection_HAsciiString ) aShortClt = + new TCollection_HAsciiString ( aClt ); - aFile->AssignCat(theClass->FullName()); - aFile->AssignCat(".java"); + aShortClt -> RemoveAll ( '.' ); + api -> AddVariable ( "%ShortPackName", aShortClt -> ToCString () ); + api -> AddVariable ( "%PackName", aClt -> ToCString () ); + api -> AddVariable ( "%PrevClassName", aClass -> FullName () -> ToCString () ); - CPPJini_WriteFile(api,aFile,"%outClass"); + Handle( TCollection_HAsciiString ) shortName = + new TCollection_HAsciiString ( aClass -> FullName () ); - outfile->Append(aFile); + shortName -> RemoveAll ( '_' ); - CPPJini_MPVDerivated(aMeta,api,aClass,outfile,incp,Supplement); - } - else { - ErrorMsg << "CPPJini" << "CPPJini_TransientClass - the class is NULL..." << endm; - Standard_NoSuchObject::Raise(); - } -} + api -> AddVariable ( "%ShortClassName", shortName -> ToCString () ); + + api -> Apply ( "%thePrevious", "ThePrevious" ); + api -> Apply ( "%setPrevious", "SetPrevious" ); + api -> Apply ( "%getPrevious", "GetPrevious" ); + members -> AssignCat ( api -> GetVariableValue ( "%thePrevious" ) ); + members -> AssignCat ( api -> GetVariableValue ( "%setPrevious" ) ); + members -> AssignCat ( api -> GetVariableValue ( "%getPrevious" ) ); + + } // end if + + } else { + + api -> AddVariable ( "%Inherits", CPPJini_MPVRootName () -> ToCString () ); + api -> AddVariable ( "%Imports", CPPJini_MPVRootName () -> ToCString () ); + + } // end else + + api -> AddVariable ( "%Methods", members -> ToCString () ); + api -> AddVariable ( "%Class", theClass -> FullName () -> ToCString () ); + api -> Apply ( "%outClass", "ValueClassClientJAVA" ); + + Handle( TCollection_HAsciiString ) aFile = + new TCollection_HAsciiString ( api -> GetVariableValue ( "%FullPath" ) ); + + aFile -> AssignCat ( theClass -> FullName () ); + aFile -> AssignCat ( ".java" ); + + CPPJini_WriteFile ( api, aFile, "%outClass" ); + + outfile -> Append ( aFile ); + + CPPJini_MPVDerivated ( aMeta, api, aClass, outfile, incp, Supplement ); + + } else { + + ErrorMsg << "CPPJini" << "CPPJini_TransientClass - the class is NULL..." << endm; + Standard_NoSuchObject :: Raise (); + + } // end else +} // end CPPJini_MPVClass diff --git a/src/CPPJini/CPPJini_Package.cxx b/src/CPPJini/CPPJini_Package.cxx index d979cf3..64ce659 100755 --- a/src/CPPJini/CPPJini_Package.cxx +++ b/src/CPPJini/CPPJini_Package.cxx @@ -1,217 +1,303 @@ -// CLE -// -// 10/1995 -// -#include - #include -#include - +#include +#include #include -#include -#include -#include #include -#include - -#include -#include -#include -#include - #include #include +#include +#include #include -#include +#include +#include +#include +#include #include - -#include -#include +#include +#include +#include #include #include #include -#include -#include +#include +#include + +#include #include -#include +#include +#include +#include -#include #include -#include -#include +#include +#include + +#include #include +#include + +extern WOKTools_MapOfHAsciiString g_ImportMap; +extern WOKTools_DataMapOfHAsciiStringOfHAsciiString g_SkipMap; + -void CPPJini_MethodUsedTypes(const Handle(MS_MetaSchema)& aMeta, - const Handle(MS_Method)& aMethod, - const Handle(TColStd_HSequenceOfHAsciiString)& List, - const Handle(TColStd_HSequenceOfHAsciiString)& Incp); - -//void CPPJini_PackageDerivated(const Handle(MS_MetaSchema)& aMeta, -void CPPJini_PackageDerivated(const Handle(MS_MetaSchema)& , - const Handle(EDL_API)& api, - const Handle(MS_Package)& aPackage, - const Handle(TColStd_HSequenceOfHAsciiString)& outfile, - const Handle(TColStd_HSequenceOfHAsciiString)& inclist, - const Handle(TColStd_HSequenceOfHAsciiString)& supplement) -{ - Handle(TCollection_HAsciiString) publics = new TCollection_HAsciiString; - Standard_Integer i; - - // the name must be _ - // - api->AddVariable("%Class",aPackage->Name()->ToCString()); - - for (i = 1; i <= inclist->Length(); i++) { - if (!inclist->Value(i)->IsSameString(aPackage->Name())) { - api->AddVariable("%IClass",inclist->Value(i)->ToCString()); - api->Apply("%Includes","IncludeCPlus"); - publics->AssignCat(api->GetVariableValue("%Includes")); - } - } +extern Standard_Boolean CPPJini_Defined ( + const Handle( TCollection_HAsciiString )&, + Handle( TCollection_HAsciiString )& + ); + +extern void CPPJini_MethodUsedTypes ( + const Handle( MS_MetaSchema )&, + const Handle( MS_Method )&, + const Handle( TColStd_HSequenceOfHAsciiString )&, + const Handle( TColStd_HSequenceOfHAsciiString )& + ); + +void CPPJini_PackageDerivated ( + const Handle( MS_MetaSchema )& aMeta, + const Handle( EDL_API )& api, + const Handle( MS_Package )& aPackage, + const Handle( TColStd_HSequenceOfHAsciiString )& outfile, + const Handle( TColStd_HSequenceOfHAsciiString )& inclist, + const Handle( TColStd_HSequenceOfHAsciiString )& supplement + ) { + + Handle( TCollection_HAsciiString ) publics = new TCollection_HAsciiString (); + Standard_Integer i; + + api -> AddVariable ( "%Class", aPackage -> Name () -> ToCString () ); + + for ( i = 1; i <= inclist -> Length (); ++i ) + + if ( !inclist -> Value ( i ) -> IsSameString ( aPackage -> Name () ) ) { + + api -> AddVariable ( "%IClass", inclist -> Value ( i ) -> ToCString () ); + api -> Apply ( "%Includes", "IncludeCPlus" ); + publics -> AssignCat ( api -> GetVariableValue ( "%Includes" ) ); + + } // end if - api->AddVariable("%Includes",publics->ToCString()); - publics->Clear(); + api -> AddVariable ( "%Includes", publics -> ToCString () ); + publics -> Clear (); - for (i = 1; i <= supplement->Length(); i++) { - publics->AssignCat(supplement->Value(i)); - } + for ( i = 1; i <= supplement -> Length (); ++i ) - api->AddVariable("%Methods",publics->ToCString()); - publics->Clear(); + publics -> AssignCat ( supplement -> Value ( i ) ); + api -> AddVariable ( "%Methods", publics -> ToCString () ); + publics -> Clear (); - api->AddVariable("%Class",aPackage->Name()->ToCString()); + api -> AddVariable ( "%Class",aPackage -> Name () -> ToCString () ); - api->Apply("%outClass","PackageClientCXX"); + Handle( TCollection_HAsciiString ) iName = api -> GetVariableValue ( "%Interface" ); - // we write the .cxx of this class - // - Handle(TCollection_HAsciiString) aFile = new TCollection_HAsciiString(api->GetVariableValue("%FullPath")); + iName -> ChangeAll ( '.', '_' ); + + api -> AddVariable ( "%IncludeInterface", iName -> ToCString () ); + api -> Apply ( "%outClass", "PackageClientCXX" ); + + Handle( TCollection_HAsciiString ) aFile = + new TCollection_HAsciiString ( api -> GetVariableValue ( "%FullPath" ) ); - aFile->AssignCat(CPPJini_InterfaceName); - aFile->AssignCat("_"); - aFile->AssignCat(aPackage->Name()); - aFile->AssignCat("_java.cxx"); + aFile -> AssignCat ( CPPJini_InterfaceName ); + aFile -> AssignCat ( "_" ); + aFile -> AssignCat ( aPackage -> Name () ); + aFile -> AssignCat ( "_java.cxx" ); - CPPJini_WriteFile(api,aFile,"%outClass"); + CPPJini_WriteFile ( api, aFile, "%outClass" ); - outfile->Append(aFile); - -} - - -// Extraction of a package -// -void CPPJini_Package(const Handle(MS_MetaSchema)& aMeta, - const Handle(EDL_API)& api, - const Handle(MS_Package)& aPackage, - const Handle(TColStd_HSequenceOfHAsciiString)& outfile, - const CPPJini_ExtractionType mustBeComplete, - const Handle(MS_HSequenceOfExternMet)& theMetSeq) -{ - if (!aPackage.IsNull()) { - Standard_Integer i; - - Handle(MS_HSequenceOfExternMet) methods; - Handle(TCollection_HAsciiString) publics = new TCollection_HAsciiString; - Handle(TColStd_HSequenceOfHAsciiString) Supplement = new TColStd_HSequenceOfHAsciiString; - Handle(TColStd_HSequenceOfHAsciiString) List = new TColStd_HSequenceOfHAsciiString; - Handle(TColStd_HSequenceOfHAsciiString) incp = new TColStd_HSequenceOfHAsciiString; - + outfile -> Append ( aFile ); - // the name must be _ - // - api->AddVariable("%Class",aPackage->Name()->ToCString()); - - if (mustBeComplete == CPPJini_SEMICOMPLETE) { - methods = theMetSeq; - } - else if (mustBeComplete == CPPJini_COMPLETE) { - methods = aPackage->Methods(); - } - - // extraction of the methods - // - if (mustBeComplete != CPPJini_INCOMPLETE) { - if (methods->Length() > 0) { - CPPJini_DataMapOfAsciiStringInteger mapnames; - - TColStd_Array1OfInteger theindexes(1,methods->Length()); - theindexes.Init(0); - +} // end CPPJini_PackageDerivated + +void CPPJini_Package ( + const Handle( MS_MetaSchema )& aMeta, + const Handle( EDL_API )& api, + const Handle( MS_Package )& aPackage, + const Handle( TColStd_HSequenceOfHAsciiString )& outfile, + const CPPJini_ExtractionType mustBeComplete, + const Handle( MS_HSequenceOfExternMet )& theMetSeq + ) { + + if ( !aPackage.IsNull () ) { + + Standard_Integer i; + Standard_Boolean fPush = Standard_False; + Handle( MS_HSequenceOfExternMet ) methods; + Handle( TCollection_HAsciiString ) publics = new TCollection_HAsciiString (); + Handle( TCollection_HAsciiString ) jType; + Handle( TColStd_HSequenceOfHAsciiString ) Supplement = new TColStd_HSequenceOfHAsciiString (); + Handle( TColStd_HSequenceOfHAsciiString ) List = new TColStd_HSequenceOfHAsciiString (); + Handle( TColStd_HSequenceOfHAsciiString ) incp = new TColStd_HSequenceOfHAsciiString (); + + api -> AddVariable ( "%Class", aPackage -> Name () -> ToCString () ); + + if ( mustBeComplete == CPPJini_SEMICOMPLETE ) + + methods = theMetSeq; + + else if ( mustBeComplete == CPPJini_COMPLETE ) + + methods = aPackage -> Methods (); + + if ( mustBeComplete != CPPJini_INCOMPLETE ) + + if ( methods -> Length () > 0 ) { + + CPPJini_DataMapOfAsciiStringInteger mapnames; + TColStd_Array1OfInteger theindexes ( 1, methods -> Length () ); + + theindexes.Init ( 0 ); - for (i = 1; i <= methods->Length(); i++) { - CPPJini_CheckMethod(i,methods->Value(i)->Name(),mapnames,theindexes); - } + for ( i = 1; i <= methods -> Length (); ++i ) + + CPPJini_CheckMethod ( i, methods -> Value ( i ) -> Name (), mapnames, theindexes ); - for (i = 1; i <= methods->Length(); i++) { - CPPJini_BuildMethod(aMeta,api,aPackage->Name(),methods->Value(i),methods->Value(i)->Name(),theindexes(i)); + for ( i = 1; i <= methods -> Length (); ++i ) { + + if ( methods -> Value ( i ) -> Private () ) continue; - if (!api->GetVariableValue("%Method")->IsSameString(CPPJini_ErrorArgument)) { + CPPJini_BuildMethod ( + aMeta, api, aPackage -> Name (), + methods -> Value ( i ), methods -> Value ( i ) -> Name (), theindexes ( i ) + ); + + if ( !api -> GetVariableValue ( "%Method" ) -> IsSameString ( CPPJini_ErrorArgument ) ) { - CPPJini_MethodUsedTypes(aMeta,methods->Value(i),List,incp); - publics->AssignCat(api->GetVariableValue(VJMethod)); - CPPJini_MethodBuilder(aMeta,api,aPackage->Name(),methods->Value(i),methods->Value(i)->Name(),theindexes(i)); - Supplement->Append(api->GetVariableValue(VJMethod)); - } - } - } - } - - api->AddVariable("%Methods",publics->ToCString()); - - publics->Clear(); - - - for (i = 1; i <= List->Length(); i++) { - if (!List->Value(i)->IsSameString(aPackage->Name())) { - api->AddVariable("%IClass",List->Value(i)->ToCString()); - if (CPPJini_IsCasType(List->Value(i))) { - api->Apply("%Includes","IncludeJCas"); - } - else { - api->Apply("%Includes","Include"); - } - publics->AssignCat(api->GetVariableValue("%Includes")); - } - } - - for (i = 1; i <= incp->Length(); i++) { - if (!incp->Value(i)->IsSameString(aPackage->Name())) { - api->AddVariable("%IClass",incp->Value(i)->ToCString()); - if (CPPJini_IsCasType(incp->Value(i))) { - api->Apply("%Includes","ShortDecJCas"); - } - else { - api->Apply("%Includes","ShortDec"); - } - publics->AssignCat(api->GetVariableValue("%Includes")); - } - } - - api->AddVariable("%Includes",publics->ToCString()); - - api->Apply(VJoutClass,"PackageClientJAVA"); + CPPJini_MethodUsedTypes ( aMeta, methods -> Value ( i ), List, incp ); + publics->AssignCat ( api -> GetVariableValue ( VJMethod ) ); + CPPJini_MethodBuilder ( + aMeta, api, aPackage -> Name (), methods -> Value ( i ), + methods -> Value ( i ) -> Name (), theindexes ( i ) + ); + Supplement -> Append ( api -> GetVariableValue ( VJMethod ) ); + + } // end if + + } // end for + + } // end if + + api -> AddVariable ( "%Methods", publics -> ToCString () ); + + publics -> Clear (); + + for ( i = 1; i <= List -> Length (); ++i ) + + if ( !List -> Value ( i ) -> IsSameString ( aPackage -> Name () ) ) { + + if ( g_SkipMap.IsBound ( List -> Value ( i ) ) ) { + + fPush = Standard_True; + api -> AddVariable ( + "%Interface", g_SkipMap.Find ( List -> Value ( i ) ) -> ToCString () + ); + + } else if ( CPPJini_Defined ( List -> Value ( i ), jType ) ) { + + fPush = Standard_True; + api -> AddVariable ( + "%Interface", jType -> ToCString () + ); + + } // end if + + api -> AddVariable ( "%IClass", List -> Value ( i ) -> ToCString () ); + + if ( CPPJini_IsCasType ( List -> Value ( i ) ) ) + + api -> Apply ( "%Includes", "IncludeJCas" ); + + else api -> Apply ( "%Includes", "Include" ); + + jType = api -> GetVariableValue ( "%Includes" ); + + if ( !g_ImportMap.Contains ( jType ) ) { + + publics -> AssignCat ( jType ); + g_ImportMap.Add ( jType ); + + } // end if + + if ( fPush ) { + + api -> AddVariable ( "%Interface", CPPJini_InterfaceName -> ToCString () ); + fPush = Standard_False; + + } // end if + + } // end if + + fPush = Standard_False; + + for ( i = 1; i <= incp -> Length (); ++i ) + + if ( !incp -> Value ( i ) -> IsSameString ( aPackage -> Name () ) ) { + + if ( g_SkipMap.IsBound ( incp -> Value ( i ) ) ) { + + fPush = Standard_True; + api -> AddVariable ( + "%Interface", g_SkipMap.Find ( incp -> Value ( i ) ) -> ToCString () + ); + + } else if ( CPPJini_Defined ( List -> Value ( i ), jType ) ) { + + fPush = Standard_True; + api -> AddVariable ( + "%Interface", jType -> ToCString () + ); + + } // end if + + api -> AddVariable ( "%IClass", incp -> Value ( i ) -> ToCString () ); + + if ( CPPJini_IsCasType ( incp -> Value ( i ) ) ) + + api -> Apply ( "%Includes", "ShortDecJCas" ); + + else api -> Apply ( "%Includes", "ShortDec" ); + + jType = api -> GetVariableValue ( "%Includes" ); + + if ( !g_ImportMap.Contains ( jType ) ) { + + publics -> AssignCat ( jType ); + g_ImportMap.Add ( jType ); + + } // end if + + if ( fPush ) { + + api -> AddVariable ( "%Interface", CPPJini_InterfaceName -> ToCString () ); + fPush = Standard_False; + + } // end if + + } // end if + + api -> AddVariable ( "%Includes", publics -> ToCString () ); + api -> Apply ( VJoutClass, "PackageClientJAVA" ); - // we write the .hxx of this class - // - Handle(TCollection_HAsciiString) aFile = new TCollection_HAsciiString(api->GetVariableValue(VJFullPath)); + Handle( TCollection_HAsciiString ) aFile = + new TCollection_HAsciiString ( api -> GetVariableValue ( VJFullPath ) ); + + aFile->AssignCat ( aPackage -> Name () ); + aFile->AssignCat ( ".java" ); + + CPPJini_WriteFile ( api, aFile, VJoutClass ); + + outfile -> Append ( aFile ); - aFile->AssignCat(aPackage->Name()); - aFile->AssignCat(".java"); + CPPJini_PackageDerivated ( aMeta, api, aPackage, outfile, incp, Supplement ); - CPPJini_WriteFile(api,aFile,VJoutClass); + } else { - outfile->Append(aFile); + ErrorMsg << "CPPJini" << "CPPJini_Package - the package is NULL..." << endm; + Standard_NoSuchObject :: Raise (); - CPPJini_PackageDerivated(aMeta,api,aPackage,outfile,incp,Supplement); - } - else { - ErrorMsg << "CPPJini" << "CPPJini_Package - the package is NULL..." << endm; - Standard_NoSuchObject::Raise(); - } -} + } // end else +} // end CPPJini_Package diff --git a/src/CPPJini/CPPJini_Template.edl b/src/CPPJini/CPPJini_Template.edl index c236f8d..924141a 100755 --- a/src/CPPJini/CPPJini_Template.edl +++ b/src/CPPJini/CPPJini_Template.edl @@ -1,4 +1,10 @@ -@template TransientRootClientJAVA(%Interface) is +-- File: CPPJini_Template.edl +-- Author: Kernel (CLE) +-- History: Tue Dec 19 08:22:43 1995 Kernel Creation +-- Copyright: Matra Datavision 1995 + + +@template TransientRootClientJAVA(%Interface,%LibName) is $// Java Native Class from Cas.Cade $// Copyright (C) 1991,1999 by $// @@ -22,14 +28,14 @@ $ $public class Standard_Transient extends jcas.Object { $ $ static { -$ System.loadLibrary("%Interface"); +$ System.loadLibrary("%LibName"); $ } $ $ $} @end; -@template StorableRootClientJAVA(%Interface) is +@template StorableRootClientJAVA(%Interface,%LibName) is $// Java Native Class from Cas.Cade $// Copyright (C) 1991,1999 by $// @@ -53,13 +59,13 @@ $ $public class Standard_Storable extends jcas.Object { $ $ static { -$ System.loadLibrary("%Interface"); +$ System.loadLibrary("%LibName"); $ } $ $} @end; -@template MemoryRootClientJAVA(%Interface) is +@template MemoryRootClientJAVA(%Interface,%LibName) is $// Java Native Class from Cas.Cade $// Copyright (C) 1991,1999 by $// @@ -84,13 +90,13 @@ $ $public class MMgt_TShared extends %Interface.Standard_Transient { $ $ static { -$ System.loadLibrary("%Interface"); +$ System.loadLibrary("%LibName"); $ } $ $} @end; -@template TransientClassClientJAVA(%Interface,%Class,%Inherits,%Includes,%Methods) is +@template TransientClassClientJAVA(%Interface,%Class,%Inherits,%Includes,%Methods,%LibName) is $// Java Native Class from Cas.Cade $// Copyright (C) 1991,1999 by $// @@ -110,13 +116,12 @@ $ $package %Interface; $ $import jcas.Object; -$import %Inherits; $%Includes $ $public class %Class extends %Inherits { $ $ static { -$ System.loadLibrary("%Interface"); +$ System.loadLibrary("%LibName"); $ } $ $%Methods @@ -125,7 +130,7 @@ $ $} @end; -@template TransientClassClientCXX(%Interface,%Class,%Methods,%Includes) is +@template TransientClassClientCXX(%Interface,%Class,%Methods,%Includes,%IncludeInterface) is $// Copyright (C) 1991,1995 by $// $// MATRA DATAVISION, FRANCE @@ -139,7 +144,7 @@ $// $// At the termination of the contract, the software and all copies of this $// software must be deleted. $ -$#include <%Interface_%Class.h> +$#include <%IncludeInterface_%Class.h> $#include <%Class.hxx> $#include $#include @@ -153,7 +158,7 @@ $%Methods $} @end; -@template ValueClassClientJAVA(%Interface,%Class,%Inherits,%Includes,%Methods) is +@template ValueClassClientJAVA(%Interface,%Class,%Inherits,%Includes,%Methods,%LibName) is $// Java Native Class from Cas.Cade $// Copyright (C) 1991,1999 by $// @@ -172,28 +177,29 @@ $ $ $package %Interface; $ -$import jcas.Object; -$import %Inherits; $%Includes $ $public class %Class extends %Inherits { $ $ static { -$ System.loadLibrary("%Interface"); +$ System.loadLibrary("%LibName"); $ } $ $%Methods $ -$native static void FinalizeValue(long anHID); +$public native static void FinalizeValue(long anHID); $ $public void finalize() { -$ FinalizeValue(HID); +$ synchronized(myCasLock) { +$ if ( aVirer != 0 ) FinalizeValue(HID); +$ HID = 0; +$ } $} $ $} @end; -@template ValueClassClientCXX(%Interface,%Class,%Methods,%Includes) is +@template ValueClassClientCXX(%Interface,%Class,%Methods,%Includes,%IncludeInterface) is $// Copyright (C) 1991,1995 by $// $// MATRA DATAVISION, FRANCE @@ -207,7 +213,7 @@ $// $// At the termination of the contract, the software and all copies of this $// software must be deleted. $ -$#include <%Interface_%Class.h> +$#include <%IncludeInterface_%Class.h> $#include <%Class.hxx> $#include $#include @@ -221,7 +227,7 @@ $%Methods $} @end; -@template PackageClientJAVA(%Interface,%Class,%Includes,%Methods) is +@template PackageClientJAVA(%Interface,%Class,%Includes,%Methods,%LibName) is $// Java Native Class from Cas.Cade $// Copyright (C) 1991,1999 by $// @@ -245,7 +251,7 @@ $ $public class %Class { $ $ static { -$ System.loadLibrary("%Interface"); +$ System.loadLibrary("%LibName"); $ } $ $%Methods @@ -254,7 +260,7 @@ $ $} @end; -@template PackageClientCXX(%Interface,%Class,%Methods,%Includes) is +@template PackageClientCXX(%Interface,%Class,%Methods,%Includes,%IncludeInterface) is $// Copyright (C) 1991,1995 by $// $// MATRA DATAVISION, FRANCE @@ -269,7 +275,7 @@ $// At the termination of the contract, the software and all copies of this $// software must be deleted. $ $ -$#include <%Interface_%Class.h> +$#include <%IncludeInterface_%Class.h> $#include <%Class.hxx> $#include $#include @@ -346,8 +352,11 @@ $, %TypeName %ArgName\^ -- argument transfert @template TransientGetValue(%ClassName,%ArgName) is -$Handle(%ClassName) the_%ArgName; -$ if ( %ArgName ) the_%ArgName = *((Handle(%ClassName)*) jcas_GetHandle(env,%ArgName)); +$ Handle( %ClassName ) the_%ArgName; +$ void* ptr_%ArgName = jcas_GetHandle(env,%ArgName); +$ +$ if ( ptr_%ArgName != NULL ) the_%ArgName = *( ( Handle( %ClassName )* )ptr_%ArgName ); +$ @end; @template ValueGetValue(%ClassName,%ArgName) is @@ -379,7 +388,7 @@ $Standard_Integer the_%ArgName = jcas_GetInteger(env,%ArgName); @end; @template IntegerGetEnumValue(%ArgName,%EnumName) is -$%EnumName the_%ArgName = (%EnumName)jcas_GetInteger (env,%ArgName ); +$%EnumName the_%ArgName = ( %EnumName )jcas_GetInteger ( env, %ArgName ); @end; @template ExtCharacterGetValue(%ArgName) is @@ -409,12 +418,19 @@ $%ClassName* the_this = (%ClassName*) jcas_GetHandle(env,theobj); -- out argument -@template TransientSetValue(%ClassName,%ArgName) is -$Handle(%ClassName)* theprevious_%ArgName = (Handle(%ClassName)*) jcas_GetHandle(env,%ArgName); -$if (theprevious_%ArgName) delete theprevious_%ArgName; -$Handle(%ClassName)* thenew_%ArgName = new Handle(%ClassName); -$(*thenew_%ArgName) = the_%ArgName; -$jcas_SetHandle(env,%ArgName,thenew_%ArgName); +@template TransientSetValue(%ClassName,%ArgName,%FromInterface) is +$ +$ Handle( %ClassName )* theprevious_%ArgName = +$ ( Handle( %ClassName )* )jcas_GetHandle ( env, %ArgName ); +$ +$ if ( theprevious_%ArgName ) delete theprevious_%ArgName; +$ +$ Handle( %ClassName )* thenew_%ArgName = new Handle( %ClassName ); +$ +$ ( *thenew_%ArgName ) = the_%ArgName; +$ +$ jcas_SetHandle (env, %ArgName, thenew_%ArgName ); +$ @end; @template CStringSetValue(%ArgName) is @@ -486,41 +502,45 @@ $jcas_SetHandle(env,theobj,theret); @template ReturnHandle(%ClassName,%MethodCall,%FromInterface) is $Handle(%ClassName)* theret = new Handle(%ClassName); $*theret = %MethodCall; -$jobject thejret = jcas_CreateObject(env,"%FromInterface/%ClassName",theret); +$thejret = jcas_CreateObject(env,"%FromInterface/%ClassName",theret); @end; @template ReturnValueMagic(%ClassName,%MethodCall,%FromInterface) is $%ClassName* theret = new %ClassName(%MethodCall); -$jobject thejret = jcas_CreateObject(env,"%FromInterface/%ClassName",theret); +$thejret = jcas_CreateObject(env,"%FromInterface/%ClassName",theret); @end; @template ReturnValueRef(%ClassName,%MethodCall,%FromInterface) is $const %ClassName& theret = %MethodCall; -$jobject thejret = jcas_CreateObject(env,"%FromInterface/%ClassName",&theret); +$thejret = jcas_CreateObject(env,"%FromInterface/%ClassName",&theret,0); @end; @template ReturnValueEmpty(%ClassName,%MethodCall,%FromInterface) is $%ClassName* theret = new %ClassName(); $*theret = %MethodCall; -$jobject thejret = jcas_CreateObject(env,"%FromInterface/%ClassName",theret); +$thejret = jcas_CreateObject(env,"%FromInterface/%ClassName",theret); @end; @template ReturnValueMalloc(%ClassName,%MethodCall,%FromInterface) is $%ClassName *theret = ((%ClassName *) malloc(sizeof(%ClassName))); $*theret = %MethodCall; -$jobject thejret = jcas_CreateObject(env,"%FromInterface/%ClassName",theret); +$thejret = jcas_CreateObject(env,"%FromInterface/%ClassName",theret); @end; @template ReturnCString(%MethodCall) is $Standard_CString sret = %MethodCall; $jclass CLSret = env->FindClass("jcas/Standard_CString"); -$jobject thejret = env->AllocObject(CLSret); +$thejret = env->AllocObject(CLSret); $jcas_SetCStringValue(env,thejret,sret); @end; @template ReturnString(%MethodCall) is $Standard_ExtString sret = %MethodCall; -$jstring thejret = jcas_ConvertTojstring(env,sret); +$thejret = jcas_ConvertTojstring(env,sret); +@end; + +@template ReturnVar (%ObjType) is +$%ObjType thejret; @end; -- finalize for MPV types @@ -537,3 +557,4 @@ $} $} $ @end; + diff --git a/src/CPPJini/CPPJini_Transient.cxx b/src/CPPJini/CPPJini_Transient.cxx index 8213da9..b57ab6b 100755 --- a/src/CPPJini/CPPJini_Transient.cxx +++ b/src/CPPJini/CPPJini_Transient.cxx @@ -1,343 +1,466 @@ -#define CPPJini_CREATE_EMPTY_JAVA_CONSTRUCTOR 0 -// CLE -// -// 10/1995 -// -#include +#define CPPJini_CREATE_EMPTY_JAVA_CONSTRUCTOR 1 #include -#include - +#include +#include +#include +#include #include -#include -#include -#include #include -#include - -#include #include +#include +#include #include +#include +#include #include +#include +#include #include - -#include -#include -#include -#include -#include - -#include -#include +#include +#include #include #include #include -#include -#include +#include +#include + +#include #include -#include +#include +#include +#include -#include #include -#include -#include +#include + +#include +#include #include +#include extern Standard_Boolean CPPJini_HasComplete ( const Handle( TCollection_HAsciiString )&, Handle( TCollection_HAsciiString )&, Standard_Boolean& ); - extern Standard_Boolean CPPJini_HasIncomplete ( const Handle( TCollection_HAsciiString )&, Handle( TCollection_HAsciiString )&, Standard_Boolean& ); - extern Standard_Boolean CPPJini_HasSemicomplete ( const Handle( TCollection_HAsciiString )&, Handle( TCollection_HAsciiString )&, Standard_Boolean& ); - extern Standard_Boolean CPPJini_Defined ( const Handle( TCollection_HAsciiString )&, Handle( TCollection_HAsciiString )& ); +extern Standard_Boolean CPPJini_Defined ( + const Handle( TCollection_HAsciiString )&, + Handle( TCollection_HAsciiString )&, + Standard_Boolean&, + CPPJini_ExtractionType& + ); +extern void CPPJini_MethodUsedTypes ( + const Handle( MS_MetaSchema )& aMeta, + const Handle( MS_Method )& aMethod, + const Handle( TColStd_HSequenceOfHAsciiString )& List, + const Handle( TColStd_HSequenceOfHAsciiString )& Incp + ); -void CPPJini_MethodUsedTypes(const Handle(MS_MetaSchema)& aMeta, - const Handle(MS_Method)& aMethod, - const Handle(TColStd_HSequenceOfHAsciiString)& List, - const Handle(TColStd_HSequenceOfHAsciiString)& Incp); - -// Extraction of a transient handle -// - -// Extraction of .cxx for handled object -// -//void CPPJini_TransientDerivated(const Handle(MS_MetaSchema)& aMeta, -void CPPJini_TransientDerivated(const Handle(MS_MetaSchema)& , - const Handle(EDL_API)& api, - const Handle(MS_Class)& aClass, - const Handle(TColStd_HSequenceOfHAsciiString)& outfile, - const Handle(TColStd_HSequenceOfHAsciiString)& inclist, - const Handle(TColStd_HSequenceOfHAsciiString)& supplement, - const CPPJini_ExtractionType MustBeComplete) -{ - Handle(TCollection_HAsciiString) publics = new TCollection_HAsciiString; - Standard_Integer i; +extern WOKTools_MapOfHAsciiString g_ImportMap; +extern Handle( CPPJini_ClientInfo ) g_Client; + +void CPPJini_AddImport ( + const Handle( EDL_API )&, + const Handle( TCollection_HAsciiString )&, + const Handle( TCollection_HAsciiString )& + ); + +void CPPJini_TransientDerivated ( + const Handle( MS_MetaSchema )& aMeta, + const Handle( EDL_API )& api, + const Handle( MS_Class )& aClass, + const Handle( TColStd_HSequenceOfHAsciiString )& outfile, + const Handle( TColStd_HSequenceOfHAsciiString )& inclist, + const Handle( TColStd_HSequenceOfHAsciiString )& supplement, + const CPPJini_ExtractionType MustBeComplete + ) { + + Handle( TCollection_HAsciiString ) publics = new TCollection_HAsciiString (); + Standard_Integer i; - // the name must be __ - // - api->AddVariable("%Class",aClass->FullName()->ToCString()); - - if (MustBeComplete != CPPJini_INCOMPLETE) { - for (i = 1; i <= inclist->Length(); i++) { - if (!inclist->Value(i)->IsSameString(aClass->FullName())) { - api->AddVariable("%IClass",inclist->Value(i)->ToCString()); - api->Apply("%Includes","IncludeCPlus"); - publics->AssignCat(api->GetVariableValue("%Includes")); - } - } - } - - api->AddVariable("%Includes",publics->ToCString()); - publics->Clear(); - - if (MustBeComplete != CPPJini_INCOMPLETE) { - for (i = 1; i <= supplement->Length(); i++) { - publics->AssignCat(supplement->Value(i)); - } - } - - api->AddVariable("%Methods",publics->ToCString()); - publics->Clear(); - - // we create the inheritance - // - if (aClass->FullName()->IsSameString(MS::GetTransientRootName())) { - api->AddVariable("%Inherits",CPPJini_GetFullJavaType(CPPJini_TransientRootName())->ToCString()); - } - else { - - Handle( TCollection_HAsciiString ) aClt; - Handle( TCollection_HAsciiString ) name = aClass -> GetInheritsNames () -> Length () ? - aClass -> GetInheritsNames () -> Value ( 1 ) : - aClass -> FullName (); - - if ( CPPJini_Defined ( name, aClt ) ) { - - aClt -> AssignCat ( "." ); - aClt -> AssignCat ( name ); - api -> AddVariable ( "%Inherits", aClt -> ToCString () ); - - } else + api -> AddVariable ( "%Class", aClass -> FullName () -> ToCString () ); + + if ( MustBeComplete != CPPJini_INCOMPLETE ) { + + for ( i = 1; i <= inclist -> Length (); ++i ) + + if ( !inclist -> Value ( i ) -> IsSameString ( aClass -> FullName () ) ) { + + api -> AddVariable ( "%IClass", inclist -> Value ( i ) -> ToCString () ); + api -> Apply ( "%Includes", "IncludeCPlus" ); + publics -> AssignCat ( api -> GetVariableValue ( "%Includes" ) ); + + } // end if + + } // end if + + api -> AddVariable ( "%Includes", publics -> ToCString () ); + publics -> Clear (); + + if ( MustBeComplete != CPPJini_INCOMPLETE ) + + for ( i = 1; i <= supplement -> Length (); ++i ) + + publics -> AssignCat ( supplement -> Value ( i ) ); + + + api -> AddVariable ( "%Methods", publics -> ToCString () ); + publics -> Clear (); + + if ( aClass -> FullName () -> IsSameString ( MS :: GetTransientRootName () ) ) + + api -> AddVariable ( + "%Inherits", + CPPJini_GetFullJavaType ( CPPJini_TransientRootName () ) -> ToCString () + ); + + else { + + Handle( TCollection_HAsciiString ) aClt; + + if ( CPPJini_Defined ( aClass -> FullName (), aClt ) ) + + CPPJini_AddImport ( api, aClt, aClass -> FullName () ); + + else if ( aClass -> GetInheritsNames () -> Length () && + CPPJini_Defined ( + aClass -> GetInheritsNames () -> Value ( 1 ), aClt + ) + ) + + CPPJini_AddImport ( api, aClt, aClass -> GetInheritsNames () -> Value ( 1 ) ); + + else - api->AddVariable("%Inherits",CPPJini_GetFullJavaType(aClass->GetInheritsNames()->Value(1))->ToCString()); + api -> AddVariable ( + "%Inherits", + CPPJini_GetFullJavaType ( + aClass -> GetInheritsNames () -> Value ( 1 ) + ) -> ToCString () + ); + + } // end else + + api -> AddVariable ( "%Class", aClass -> FullName () -> ToCString () ); + + Handle( TCollection_HAsciiString ) iName = api -> GetVariableValue ( "%Interface" ); - } + iName -> ChangeAll ( '.', '_' ); - api->AddVariable("%Class",aClass->FullName()->ToCString()); + api -> AddVariable ( "%IncludeInterface", iName -> ToCString () ); - api->Apply("%outClass","TransientClassClientCXX"); + api -> Apply ( "%outClass", "TransientClassClientCXX" ); - // we write the .cxx of this class - // - Handle(TCollection_HAsciiString) aFile = new TCollection_HAsciiString(api->GetVariableValue("%FullPath")); + Handle( TCollection_HAsciiString ) aFile = + new TCollection_HAsciiString ( api -> GetVariableValue ( "%FullPath" ) ); - aFile->AssignCat(CPPJini_InterfaceName); - aFile->AssignCat("_"); - aFile->AssignCat(aClass->FullName()); - aFile->AssignCat("_java.cxx"); + aFile -> AssignCat ( CPPJini_InterfaceName ); + aFile -> AssignCat ( "_" ); + aFile -> AssignCat ( aClass -> FullName () ); + aFile -> AssignCat ( "_java.cxx" ); - CPPJini_WriteFile(api,aFile,"%outClass"); + CPPJini_WriteFile ( api, aFile, "%outClass" ); - outfile->Append(aFile); -} - - -// Extraction of a transient class (inst or std) -// -void CPPJini_TransientClass(const Handle(MS_MetaSchema)& aMeta, - const Handle(EDL_API)& api, - const Handle(MS_Class)& aClass, - const Handle(TColStd_HSequenceOfHAsciiString)& outfile, - const CPPJini_ExtractionType MustBeComplete, - const Handle(MS_HSequenceOfMemberMet)& theMetSeq) -{ - Handle(MS_StdClass) theClass = Handle(MS_StdClass)::DownCast(aClass); - - if (!theClass.IsNull()) { - Standard_Integer i; - Handle(MS_HSequenceOfMemberMet) methods; - Handle(TCollection_HAsciiString) publics = new TCollection_HAsciiString; - Handle(TCollection_HAsciiString) SuppMethod = new TCollection_HAsciiString; - Handle(TColStd_HSequenceOfHAsciiString) Supplement = new TColStd_HSequenceOfHAsciiString; - Handle(TColStd_HSequenceOfHAsciiString) List = new TColStd_HSequenceOfHAsciiString; - Handle(TColStd_HSequenceOfHAsciiString) incp = new TColStd_HSequenceOfHAsciiString; - - // we create the inheritance - // - if (theClass->FullName()->IsSameString(MS::GetTransientRootName())) return; - - api->AddVariable("%Class",theClass->FullName()->ToCString()); - - if (MustBeComplete == CPPJini_SEMICOMPLETE) { - methods = theMetSeq; - } - else if (MustBeComplete == CPPJini_COMPLETE){ - methods = theClass->GetMethods(); - } + outfile -> Append ( aFile ); + +} // end CPPJini_TransientDerivated + +void CPPJini_TransientClass ( + const Handle( MS_MetaSchema )& aMeta, + const Handle( EDL_API )& api, + const Handle( MS_Class )& aClass, + const Handle( TColStd_HSequenceOfHAsciiString )& outfile, + const CPPJini_ExtractionType MustBeComplete, + const Handle( MS_HSequenceOfMemberMet )& theMetSeq + ) { + + Handle( MS_StdClass ) theClass = Handle( MS_StdClass ) :: DownCast ( aClass ); + + if ( !theClass.IsNull () ) { + + Standard_Integer i; + Standard_Boolean defConst = Standard_False; + Handle( MS_HSequenceOfMemberMet ) methods; + Handle( TCollection_HAsciiString ) publics = new TCollection_HAsciiString (); + Handle( TCollection_HAsciiString ) members = new TCollection_HAsciiString (); + Handle( TCollection_HAsciiString ) SuppMethod = new TCollection_HAsciiString (); + Handle( TCollection_HAsciiString ) jType; + Handle( TColStd_HSequenceOfHAsciiString ) Supplement = new TColStd_HSequenceOfHAsciiString (); + Handle( TColStd_HSequenceOfHAsciiString ) List = new TColStd_HSequenceOfHAsciiString (); + Handle( TColStd_HSequenceOfHAsciiString ) incp = new TColStd_HSequenceOfHAsciiString (); + + if ( theClass -> FullName () -> IsSameString ( MS :: GetTransientRootName () ) ) return; + + api -> AddVariable ( "%Class", theClass -> FullName () -> ToCString () ); + + if ( MustBeComplete == CPPJini_SEMICOMPLETE ) + + methods = theMetSeq; + + else if ( MustBeComplete == CPPJini_COMPLETE ) + + methods = theClass -> GetMethods (); #if CPPJini_CREATE_EMPTY_JAVA_CONSTRUCTOR - Standard_Boolean mustCreateEmptyConst = !CPPJini_HaveEmptyConstructor(aMeta,theClass->FullName(),methods); -#endif - if (MustBeComplete != CPPJini_INCOMPLETE) { - if (methods->Length() > 0) { - CPPJini_DataMapOfAsciiStringInteger mapnames; - - TColStd_Array1OfInteger theindexes(1,methods->Length()); - theindexes.Init(0); - + Standard_Boolean mustCreateEmptyConst = + !CPPJini_HaveEmptyConstructor ( aMeta, theClass -> FullName (), methods ); +#endif // CPPJini_CREATE_EMPTY_JAVA_CONSTRUCTOR + if ( MustBeComplete != CPPJini_INCOMPLETE ) + + if ( methods -> Length () > 0 ) { + + CPPJini_DataMapOfAsciiStringInteger mapnames; + TColStd_Array1OfInteger theindexes ( 1, methods -> Length () ); + + theindexes.Init ( 0 ); - for (i = 1; i <= methods->Length(); i++) { - CPPJini_CheckMethod(i,methods->Value(i)->Name(),mapnames,theindexes); - } + for ( i = 1; i <= methods -> Length (); ++i ) + + CPPJini_CheckMethod ( i, methods -> Value ( i ) -> Name (), mapnames, theindexes ); - for (i = 1; i <= methods->Length(); i++) { - CPPJini_BuildMethod(aMeta,api,theClass->FullName(),methods->Value(i),methods->Value(i)->Name(),theindexes(i)); - if (!api->GetVariableValue("%Method")->IsSameString(CPPJini_ErrorArgument)) { - - if ((theClass->Deferred() && methods->Value(i)->IsKind(STANDARD_TYPE(MS_Construc))) - || methods->Value(i)->IsProtected() - || methods->Value(i)->Private()) { - // nothing - } - else { - CPPJini_MethodUsedTypes(aMeta,methods->Value(i),List,incp); - publics->AssignCat(api->GetVariableValue(VJMethod)); - CPPJini_MethodBuilder(aMeta,api,aClass->FullName(),methods->Value(i),methods->Value(i)->Name(),theindexes(i)); - Supplement->Append(api->GetVariableValue(VJMethod)); - } - } - } - } - } + for ( i = 1; i <= methods -> Length (); ++i ) { + + CPPJini_BuildMethod ( + aMeta, api, theClass -> FullName (), methods -> Value ( i ), + methods -> Value ( i ) -> Name (), theindexes ( i ) + ); + + if ( !api -> GetVariableValue ( "%Method" ) -> IsSameString ( CPPJini_ErrorArgument ) ) { + + Standard_Boolean cond = theClass -> Deferred () && + methods -> Value ( i ) -> IsKind ( STANDARD_TYPE( MS_Construc ) ); + + if ( !defConst && cond ) defConst = Standard_True; + + if ( !( cond || methods -> Value ( i ) -> IsProtected () + || methods -> Value ( i ) -> Private () + ) + ) { + + CPPJini_MethodUsedTypes ( aMeta, methods -> Value ( i ), List, incp ); + + members -> AssignCat ( api -> GetVariableValue ( VJMethod ) ); + + CPPJini_MethodBuilder ( + aMeta, api, aClass -> FullName (), methods -> Value ( i ), + methods -> Value ( i ) -> Name (), theindexes ( i ) + ); + + Supplement -> Append ( api -> GetVariableValue ( VJMethod ) ); + + } // end if + + } // end if + + } // end for + + } // end if #if CPPJini_CREATE_EMPTY_JAVA_CONSTRUCTOR - if (mustCreateEmptyConst) { - api->Apply(VJMethod,"EmptyConstructorHeader"); - publics->AssignCat(api->GetVariableValue(VJMethod)); - } -#endif - api->AddVariable("%Methods",publics->ToCString()); + if ( mustCreateEmptyConst || ( defConst && !mustCreateEmptyConst ) ) { - publics->Clear(); + api -> Apply ( VJMethod, "EmptyConstructorHeader" ); + members -> AssignCat ( api -> GetVariableValue ( VJMethod ) ); - if (MustBeComplete != CPPJini_INCOMPLETE) { - - for (i = 1; i <= List->Length(); i++) { - if (!List->Value(i)->IsSameString(theClass->FullName())) { - api->AddVariable("%IClass",List->Value(i)->ToCString()); - if (CPPJini_IsCasType(List->Value(i))) { - api->Apply("%Includes","IncludeJCas"); - } - else { - Handle( TCollection_HAsciiString ) aClt; - Standard_Boolean fPush = Standard_False; - - if ( CPPJini_Defined ( List -> Value ( i ), aClt ) ) { - - fPush = Standard_True; - api -> AddVariable ( "%Interface", aClt -> ToCString () ); - - } // end if - - api->Apply("%Includes","Include"); - - if ( fPush ) - - api -> AddVariable ( - "%Interface", CPPJini_InterfaceName -> ToCString () - ); - } - publics->AssignCat(api->GetVariableValue("%Includes")); - } - } + } // end if +#endif // end CPPJini_CREATE_EMPTY_JAVA_CONSTRUCTOR + if ( MustBeComplete != CPPJini_INCOMPLETE ) { + for ( i = 1; i <= List -> Length (); ++i ) + + if ( !List -> Value ( i ) -> IsSameString ( theClass -> FullName () ) ) { + + api -> AddVariable ( "%IClass", List -> Value ( i ) -> ToCString () ); + + if ( CPPJini_IsCasType ( List -> Value ( i ) ) ) + + api -> Apply ( "%Includes", "IncludeJCas" ); + + else { + + Handle( TCollection_HAsciiString ) aClt; + Standard_Boolean fPush = Standard_False; + + if ( CPPJini_Defined ( List -> Value ( i ), aClt ) ) { + + fPush = Standard_True; + api -> AddVariable ( "%Interface", aClt -> ToCString () ); + + } // end if + + api -> Apply ( "%Includes", "Include" ); + + if ( fPush ) api -> AddVariable ( + "%Interface", CPPJini_InterfaceName -> ToCString () + ); + } // end else + + jType = api -> GetVariableValue ( "%Includes" ); + + if ( !g_ImportMap.Contains ( jType ) ) { + + publics -> AssignCat ( jType ); + g_ImportMap.Add ( jType ); + + } // end if + + } // end if - for (i = 1; i <= incp->Length(); i++) { - if (!incp->Value(i)->IsSameString(theClass->FullName())) { - api->AddVariable("%IClass",incp->Value(i)->ToCString()); - if (CPPJini_IsCasType(incp->Value(i))) { - api->Apply("%Includes","ShortDecJCas"); - } - else { - Handle( TCollection_HAsciiString ) aClt; - Standard_Boolean fPush = Standard_False; + for ( i = 1; i <= incp -> Length (); ++i ) + + if ( !incp -> Value ( i ) -> IsSameString ( theClass -> FullName () ) ) { + + api -> AddVariable ( "%IClass", incp -> Value ( i ) -> ToCString () ); + + if ( CPPJini_IsCasType ( incp -> Value ( i ) ) ) + + api -> Apply ( "%Includes", "ShortDecJCas" ); + + else { + + Handle( TCollection_HAsciiString ) aClt; + Standard_Boolean fPush = Standard_False; + + if ( CPPJini_Defined ( incp -> Value ( i ), aClt ) ) { + + fPush = Standard_True; + api -> AddVariable ( "%Interface", aClt -> ToCString () ); + + } // end if + + api -> Apply ( "%Includes", "ShortDec" ); + + if ( fPush ) + + api -> AddVariable ( "%Interface", CPPJini_InterfaceName -> ToCString () ); + + } // end else + + jType = api -> GetVariableValue ( "%Includes" ); + + if ( !g_ImportMap.Contains ( jType ) ) { + + publics -> AssignCat ( jType ); + g_ImportMap.Add ( jType ); + + } // end if + + } // end if + + } // end if + + api -> AddVariable ( "%Includes", publics -> ToCString () ); + + Handle( TCollection_HAsciiString ) aClt; + Handle( TCollection_HAsciiString ) anAncestor = aClass -> GetInheritsNames () -> Value ( 1 ); + Standard_Boolean fDup; + CPPJini_ExtractionType thisType, otherType; + + g_Client -> Defined ( anAncestor, thisType ); + + if ( CPPJini_Defined ( anAncestor, aClt, fDup, otherType ) ) { + + if ( thisType == CPPJini_COMPLETE && otherType == CPPJini_COMPLETE || + thisType == CPPJini_INCOMPLETE || + thisType == CPPJini_SEMICOMPLETE && otherType == CPPJini_COMPLETE + ) { // this type has been skipped in this client, use one from other client + + CPPJini_AddImport ( api, aClt, anAncestor ); + + } else { + + CPPJini_AddImport ( api, g_Client -> Name (), anAncestor ); + + } // end else + + } else { + + api -> AddVariable ( + "%Inherits", + CPPJini_GetFullJavaType ( + theClass -> GetInheritsNames () -> Value ( 1 ) + ) -> ToCString () + ); + + } // end else - if ( CPPJini_Defined ( incp -> Value ( i ), aClt ) ) { + if ( CPPJini_Defined ( theClass -> FullName (), aClt ) ) { // create additional + // constructors + Handle( TCollection_HAsciiString ) aShortClt = + new TCollection_HAsciiString ( aClt ); - fPush = Standard_True; - api -> AddVariable ( "%Interface", aClt -> ToCString () ); + aShortClt -> RemoveAll ( '.' ); + api -> AddVariable ( "%ShortPackName", aShortClt -> ToCString () ); + api -> AddVariable ( "%PackName", aClt -> ToCString () ); + api -> AddVariable ( "%PrevClassName", aClass -> FullName () -> ToCString () ); - } // end if + Handle( TCollection_HAsciiString ) shortName = + new TCollection_HAsciiString ( aClass -> FullName () ); - api->Apply("%Includes","ShortDec"); + shortName -> RemoveAll ( '_' ); - if ( fPush ) + api -> AddVariable ( "%ShortClassName", shortName -> ToCString () ); - api -> AddVariable ( - "%Interface", CPPJini_InterfaceName -> ToCString () - ); - } - publics->AssignCat(api->GetVariableValue("%Includes")); - } - } - } + api -> Apply ( "%thePrevious", "ThePrevious" ); + api -> Apply ( "%setPrevious", "SetPrevious" ); + api -> Apply ( "%getPrevious", "GetPrevious" ); + members -> AssignCat ( api -> GetVariableValue ( "%thePrevious" ) ); + members -> AssignCat ( api -> GetVariableValue ( "%setPrevious" ) ); + members -> AssignCat ( api -> GetVariableValue ( "%getPrevious" ) ); - api->AddVariable("%Includes",publics->ToCString()); + } // end if - // we create the inheritance - // - Handle( TCollection_HAsciiString ) aClt; - Handle( TCollection_HAsciiString ) name = theClass -> GetInheritsNames () -> Length () ? - theClass -> GetInheritsNames () -> Value ( 1 ) : - theClass -> FullName (); + api -> AddVariable ( "%Methods", members -> ToCString () ); + api -> AddVariable ( "%Class", theClass -> FullName () -> ToCString () ); + api -> Apply ( "%outClass", "TransientClassClientJAVA" ); - if ( CPPJini_Defined ( name, aClt ) ) { + Handle( TCollection_HAsciiString ) aFile = + new TCollection_HAsciiString ( api -> GetVariableValue ( "%FullPath" ) ); - aClt -> AssignCat ( "." ); - aClt -> AssignCat ( name ); - api -> AddVariable ( "%Inherits", aClt -> ToCString () ); + aFile -> AssignCat ( theClass -> FullName () ); + aFile -> AssignCat ( ".java" ); - } else + CPPJini_WriteFile ( api, aFile, "%outClass" ); - api->AddVariable("%Inherits",CPPJini_GetFullJavaType(theClass->GetInheritsNames()->Value(1))->ToCString()); + outfile -> Append ( aFile ); - api->AddVariable("%Class",theClass->FullName()->ToCString()); + CPPJini_TransientDerivated ( aMeta, api, aClass, outfile, incp, Supplement, MustBeComplete ); - api->Apply("%outClass","TransientClassClientJAVA"); + } else { - // we write the .java of this class - // - Handle(TCollection_HAsciiString) aFile = new TCollection_HAsciiString(api->GetVariableValue("%FullPath")); + ErrorMsg << "CPPJini" << "CPPJini_TransientClass - the class is NULL..." << endm; + Standard_NoSuchObject :: Raise (); - aFile->AssignCat(theClass->FullName()); - aFile->AssignCat(".java"); + } // end else - CPPJini_WriteFile(api,aFile,"%outClass"); +} // end CPPJini_TransientClass - outfile->Append(aFile); +void CPPJini_AddImport ( + const Handle( EDL_API )& api, + const Handle( TCollection_HAsciiString )& aClt, + const Handle( TCollection_HAsciiString )& name + ) { + Handle( TCollection_HAsciiString ) clt = new TCollection_HAsciiString ( aClt ); - CPPJini_TransientDerivated(aMeta,api,aClass,outfile,incp,Supplement,MustBeComplete); - } - else { - ErrorMsg << "CPPJini" << "CPPJini_TransientClass - the class is NULL..." << endm; - Standard_NoSuchObject::Raise(); - } -} + clt -> AssignCat ( "." ); + clt -> AssignCat ( name ); + api -> AddVariable ( "%Inherits", clt -> ToCString () ); +} // end CPPJini_AddImport -- 2.39.5