#include <TColStd_SequenceOfInteger.hxx>
#include <TColStd_Array1OfInteger.hxx>
+#include <Standard_ProgramError.hxx>
+
#include <limits.h>
#define CPPJINI_BOOLEAN 1
Handle( TCollection_HAsciiString ) CPPJini_DotReplace ( char*, char = '_' );
static CPPJini_SequenceOfClientInfo s_CltInfo;
-static WOKTools_MapOfHAsciiString s_CltMap;
static Standard_Integer s_UseLevel;
+static WOKTools_MapOfHAsciiString s_CltMap;
WOKTools_MapOfHAsciiString g_ImportMap;
WOKTools_DataMapOfHAsciiStringOfHAsciiString g_SkipMap;
++s_UseLevel;
- Standard_Integer i;
+ Standard_Integer i, j;
- for ( i = 1; i <= use -> Length (); ++i )
+ for ( i = 1; i <= use -> Length (); ++i ) {
- if ( !s_CltMap.Contains ( use -> Value ( i ) ) ) {
+ Handle( MS_Client ) clt;
- 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_UseLevel
- )
- );
- s_CltMap.Add ( use -> Value ( i ) );
-
- _CPPJini_FillUses ( ms, clt -> Uses () );
+ ErrorMsg << "_CPPJini_FillUses"
+ << "Cyclic dependency between clients ( check your 'uses' lists )"
+ << endm;
+ Standard_ProgramError :: Raise ();
} // end if
+ for ( j = 1; j <= s_CltInfo.Length (); ++j )
+
+ if ( s_CltInfo.Value ( j ) -> Name () -> IsSameString ( use -> Value ( i ) ) ) {
+
+ s_CltInfo.Value ( j ) -> SetLevel (
+ s_CltInfo.Value ( j ) -> Level () + 1
+ );
+ goto next;
+
+ } // end if
+
+ clt = ms -> GetClient ( use -> Value ( i ) );
+
+ s_CltInfo.Prepend (
+ new CPPJini_ClientInfo (
+ ms, use -> Value ( i ), s_UseLevel
+ )
+ );
+
+ s_CltMap.Add ( use -> Value ( i ) );
+ _CPPJini_FillUses ( ms, clt -> Uses () );
+ s_CltMap.Remove ( use -> Value ( i ) );
+next: continue;
+ } // end for
+
if ( i == 1 && s_CltInfo.Length () )
s_CltInfo.Value ( 1 ) -> SetRoot ( Standard_True );
s_CltMap.Clear ();
s_UseLevel = 0;
- _CPPJini_FillUses ( aMeta, use );
+ s_CltMap.Add ( aName );
+ _CPPJini_FillUses ( aMeta, use );
+ s_CltMap.Remove ( aName );
g_SkipMap.Clear ();
} // end for
- if ( fEnum ) List -> Append ( new TCollection_HAsciiString ( "Standard_Integer" ) );
+ if ( fEnum ) List -> Append ( new TCollection_HAsciiString ( "Standard_Short" ) );
} // end if
if ( aType -> IsKind ( STANDARD_TYPE( MS_Enum ) ) )
- parname = new TCollection_HAsciiString ( "int" );
+ parname = new TCollection_HAsciiString ( "short" );
result -> AssignCat ( parname );
if ( !strcmp ( typeName, "Standard_Byte" ) ) return Standard_True;
if ( !strcmp ( typeName, "Standard_ShortReal" ) ) return Standard_True;
if ( !strcmp ( typeName, "Standard_Address" ) ) return Standard_True;
+ if ( !strcmp ( typeName, "Standard_Short" ) ) return Standard_True;
return Standard_False;
if ( aSeq -> Value ( i ) -> IsOut () )
- parname = new TCollection_HAsciiString ( "Standard_Integer" );
+ parname = new TCollection_HAsciiString ( "Standard_Short" );
else
- parname = new TCollection_HAsciiString ( "int" );
+ parname = new TCollection_HAsciiString ( "short" );
if ( aType -> IsKind ( STANDARD_TYPE( MS_PrimType ) ) ) {
if (aType->IsKind(STANDARD_TYPE(MS_Enum))) {
typeprim = CPPJINI_ENUMERATION;
if (!isout) {
- result->AssignCat("jint");
+ result->AssignCat("jshort");
}
else {
result->AssignCat("jobject");
ArgsInCall->AssignCat("the_");
ArgsInCall->AssignCat(aSeqP->Value(i)->Name());
api -> AddVariable ( "%EnumName", curtype -> FullName () -> ToCString () );
- api->Apply("%Method","IntegerGetEnumValue");
+ api->Apply("%Method","ShortGetEnumValue");
ArgsRetrieve->AssignCat(api->GetVariableValue("%Method"));
- api->Apply("%MetOut","IntegerSetValue");
+ api->Apply("%MetOut","ShortSetValue");
ArgsOut->AssignCat(api->GetVariableValue("%MetOut"));
break;
}
// c'est fini
- char* var1 = "MethodTemplateDefOBJS";
- char* var2 = "MethodTemplateDef";
-
api->AddVariable("%Method",metstart->ToCString());
api->AddVariable("%MBody",metbody->ToCString());
"%Method",
!strcmp (
api -> GetVariableValue ( "%CPPJiniEXTDBMS" ) -> ToCString (), "OBJS"
- ) ? var1 : var2
+ ) ? "MethodTemplateDefOBJS" : "MethodTemplateDef"
);
}
<< " (already defined in " << cltName << ")" << endm;
g_SkipMap.Bind ( aTypeName, cltName );
-
+#if 0
if ( fDuplicate )
WarningMsg << "CPPJini"
<< aTypeName
<< " defined in more than one client declared in 'uses' statement"
<< endm;
-
+#endif
return;
} // end if
-- in the 'uses' hierarchy
---C++: inline
+ SetLevel ( me : mutable; aLevel : Integer from Standard );
+ ---Purpose: sets a level of the client in the 'uses' hierarchy
+ ---C++: inline
+
fields
myName : HAsciiString from TCollection;
myRoot = aRoot;
} // end void CPPJini_ClientInfo :: SetRoot
+
+inline void CPPJini_ClientInfo :: SetLevel ( const Standard_Integer aLevel ) {
+
+ myLevel = aLevel;
+
+} // end void CPPJini_ClientInfo :: SetLevel
} // end else
- if ( CPPJini_Defined ( theClass -> FullName (), aClt ) ) { // create additional
- // constructors
- Handle( TCollection_HAsciiString ) aShortClt =
- new TCollection_HAsciiString ( aClt );
+ } else {
- aShortClt -> RemoveAll ( '.' );
- api -> AddVariable ( "%ShortPackName", aShortClt -> ToCString () );
- api -> AddVariable ( "%PackName", aClt -> ToCString () );
- api -> AddVariable ( "%PrevClassName", aClass -> FullName () -> ToCString () );
+ api -> AddVariable ( "%Inherits", CPPJini_MPVRootName () -> ToCString () );
+ api -> AddVariable ( "%Imports", CPPJini_MPVRootName () -> ToCString () );
- Handle( TCollection_HAsciiString ) shortName =
- new TCollection_HAsciiString ( aClass -> FullName () );
+ } // end else
- shortName -> RemoveAll ( '_' );
+ if ( CPPJini_Defined ( theClass -> FullName (), aClt ) ) { // create additional
+ // constructors
+ Handle( TCollection_HAsciiString ) aShortClt =
+ new TCollection_HAsciiString ( aClt );
- api -> AddVariable ( "%ShortClassName", shortName -> ToCString () );
+ aShortClt -> RemoveAll ( '.' );
+ api -> AddVariable ( "%ShortPackName", aShortClt -> ToCString () );
+ api -> AddVariable ( "%PackName", aClt -> ToCString () );
+ api -> AddVariable ( "%PrevClassName", aClass -> FullName () -> 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" ) );
+ Handle( TCollection_HAsciiString ) shortName =
+ new TCollection_HAsciiString ( aClass -> FullName () );
- } // end if
+ shortName -> RemoveAll ( '_' );
- } else {
+ api -> AddVariable ( "%ShortClassName", shortName -> ToCString () );
- api -> AddVariable ( "%Inherits", CPPJini_MPVRootName () -> ToCString () );
- api -> AddVariable ( "%Imports", CPPJini_MPVRootName () -> 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 else
+ } // end if
api -> AddVariable ( "%Methods", members -> ToCString () );
api -> AddVariable ( "%Class", theClass -> FullName () -> ToCString () );
@template ValueGetValue(%ClassName,%ArgName) is
$%ClassName* the_%ArgName = (%ClassName*) jcas_GetHandle(env,%ArgName);
+$if ( the_%ArgName == NULL ) {
+$
+$ the_%ArgName = new %ClassName ();
+$ jcas_SetHandle ( env, %ArgName, the_%ArgName );
+$
+$} // end if
@end;
@template CStringGetValue(%ArgName) is
-$Standard_CString the_%ArgName = jcas_ConvertToCString(env,%ArgName);
+$TCollection_AsciiString theAscii_%ArgName = jcas_ConvertToCString(env,%ArgName);
+$Standard_CString the_%ArgName = theAscii_%ArgName.ToCString();
@end;
@template StringGetValue(%ArgName) is
-$Standard_ExtString the_%ArgName = jcas_ConvertToExtString(env,%ArgName);
+$TCollection_ExtendedString theExt_%ArgName = jcas_ConvertToExtString(env,%ArgName);
+$Standard_ExtString the_%ArgName = theExt_%ArgName.ToExtString();
@end;
@template BooleanGetValue(%ArgName) is
$Standard_Integer the_%ArgName = jcas_GetInteger(env,%ArgName);
@end;
-@template IntegerGetEnumValue(%ArgName,%EnumName) is
-$%EnumName the_%ArgName = ( %EnumName )jcas_GetInteger ( env, %ArgName );
+@template ShortGetEnumValue(%ArgName,%EnumName) is
+$%EnumName the_%ArgName = ( %EnumName )jcas_GetShort ( env, %ArgName );
@end;
@template ExtCharacterGetValue(%ArgName) is
@end;
@template StringBufferGetValue(%ArgName) is
-$Standard_ExtString the_%ArgName = jcas_ConvertSBToExtString(env,%ArgName);
+$TCollection_ExtendedString theExt_%ArgName = jcas_ConvertSBToExtString(env,%ArgName);
+$Standard_ExtString the_%ArgName = theExt_%ArgName.ToExtString();
@end;
@template ThisTransientGetValue(%ClassName) is
$jcas_SetCharacter(env,%ArgName,the_%ArgName);
@end;
+@template ShortSetValue(%ArgName) is
+$jcas_SetShort(env,%ArgName,the_%ArgName);
+@end;
+
@template IntegerSetValue(%ArgName) is
$jcas_SetInteger(env,%ArgName,the_%ArgName);
@end;