From 7e857949a6902ec9fa82bd4f36835d22e776a5cd Mon Sep 17 00:00:00 2001 From: cas Date: Fri, 22 Oct 1999 18:05:40 +0000 Subject: [PATCH] Initial revision --- src/CPPClient/CPPClient.cxx | 1605 +++++++++++++++++++++++++ src/CPPClient/CPPClient.hxx | 155 +++ src/CPPClient/CPPClient_Define.hxx | 86 ++ src/CPPClient/CPPClient_Enum.cxx | 64 + src/CPPClient/CPPClient_General.edl | 100 ++ src/CPPClient/CPPClient_MPV.cxx | 254 ++++ src/CPPClient/CPPClient_Package.cxx | 204 ++++ src/CPPClient/CPPClient_Template.edl | 1122 +++++++++++++++++ src/CPPClient/CPPClient_Transient.cxx | 298 +++++ src/CPPClient/FILES | 10 + 10 files changed, 3898 insertions(+) create mode 100755 src/CPPClient/CPPClient.cxx create mode 100755 src/CPPClient/CPPClient.hxx create mode 100755 src/CPPClient/CPPClient_Define.hxx create mode 100755 src/CPPClient/CPPClient_Enum.cxx create mode 100755 src/CPPClient/CPPClient_General.edl create mode 100755 src/CPPClient/CPPClient_MPV.cxx create mode 100755 src/CPPClient/CPPClient_Package.cxx create mode 100755 src/CPPClient/CPPClient_Template.edl create mode 100755 src/CPPClient/CPPClient_Transient.cxx create mode 100755 src/CPPClient/FILES diff --git a/src/CPPClient/CPPClient.cxx b/src/CPPClient/CPPClient.cxx new file mode 100755 index 0000000..f13609d --- /dev/null +++ b/src/CPPClient/CPPClient.cxx @@ -0,0 +1,1605 @@ +// CLE : Extracteur de stubs C++ pour CAS.CADE +// Matra-Datavision 1995 +// +// 10/1995 +// +#include +#include +#include +#include +#include +#include +#include +#include + +static WOKTools_MapOfHAsciiString MethodMap; + +Handle(MS_HSequenceOfMemberMet) SeqOfMemberMet = new MS_HSequenceOfMemberMet; +Handle(MS_HSequenceOfExternMet) SeqOfExternMet = new MS_HSequenceOfExternMet; + +Handle(TCollection_HAsciiString) CPPClient_InterfaceName; +Handle(TCollection_HAsciiString) CPPClient_ErrorArgument = new TCollection_HAsciiString("%error%"); + +// Standard Extractor API : list the EDL files used by this program +// +Handle(TColStd_HSequenceOfHAsciiString) CPPClient_TemplatesUsed() +{ + Handle(TColStd_HSequenceOfHAsciiString) result = new TColStd_HSequenceOfHAsciiString; + + result->Append(new TCollection_HAsciiString("CPPClient_Template.edl")); + result->Append(new TCollection_HAsciiString("CPPClient_General.edl")); + + return result; +} + +void CPPClient_Init(const Handle(MS_MetaSchema)& aMeta, + const Handle(TCollection_HAsciiString)& aName, + const Handle(MS_HSequenceOfExternMet)& SeqOfEM, + const Handle(MS_HSequenceOfMemberMet)& SeqOfMM) +{ + Standard_Integer i; + Handle(MS_Client) client; + + SeqOfMemberMet = SeqOfMM; + SeqOfExternMet = SeqOfEM; + + MethodMap.Clear(); + + if (aMeta->IsClient(aName)) { + Handle(MS_Method) amet; + Handle(TColStd_HSequenceOfHAsciiString) asyncmet; + + CPPClient_InterfaceName = aName; + client = aMeta->GetClient(aName); + asyncmet = client->Methods(); + + for(i = 1; i <= asyncmet->Length(); i++) { + amet = MS::GetMethodFromFriendName(aMeta,asyncmet->Value(i)); + + if (!amet.IsNull()) { + if (!MethodMap.Contains(amet->FullName())) { + MethodMap.Add(amet->FullName()); + } + } + else { + ErrorMsg << "CPPClient" << "Init : Method " << asyncmet->Value(i) << " not found..." << endm; + Standard_NoSuchObject::Raise(); + } + } + + } + else { + ErrorMsg << "CPPClient" << "Init : Client " << aName << " not found..." << endm; + Standard_NoSuchObject::Raise(); + } +} + +Handle(TCollection_HAsciiString)& CPPClient_TransientRootName() +{ + static Handle(TCollection_HAsciiString) name = new TCollection_HAsciiString("FrontEnd_HExternRef"); + + return name; +} + +Handle(TCollection_HAsciiString)& CPPClient_MemoryRootName() +{ + static Handle(TCollection_HAsciiString) name = new TCollection_HAsciiString("MMgt_TShared"); + + return name; +} + +Handle(TCollection_HAsciiString)& CPPClient_MPVRootName() +{ + static Handle(TCollection_HAsciiString) name = new TCollection_HAsciiString("FrontEnd_ExternRef"); + + return name; +} + +Handle(EDL_API)& CPPClient_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; + + api->ClearVariables(); + + if (!alreadyLoaded) { + alreadyLoaded = Standard_True; + + for(Standard_Integer i = 1; i <= edlsfullpath->Length(); i++) { + api->AddIncludeDirectory(edlsfullpath->Value(i)->ToCString()); + } + + if (api->Execute("CPPClient_Template.edl") != EDL_NORMAL) { + ErrorMsg << "CPPClient" << "unable to load : CPPClient_Template.edl" << endm; + Standard_NoSuchObject::Raise(); + } + if (api->Execute("CPPClient_General.edl") != EDL_NORMAL) { + ErrorMsg << "CPPClient" << "unable to load : CPPClient_General.edl" << endm; + Standard_NoSuchObject::Raise(); + } + } + + // full path of the destination directory + // + api->AddVariable(VFullPath,outdir->ToCString()); + + // templates for methods extraction + // + api->AddVariable(VMethodHeader,"MethodHeader"); + api->AddVariable(VConstructorHeader,"ConstructorHeader"); + api->AddVariable(VInterface,CPPClient_InterfaceName->ToCString()); + + return api; +} + +// write the content of a variable into a file +// +void CPPClient_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"); +} + +// we test the type and dispatch it in the different lists +// +void CPPClient_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) +{ + if (thetype->IsKind(STANDARD_TYPE(MS_Class))) { + Handle(MS_Class) theclass = *((Handle(MS_Class)*)&thetype); + Handle(TCollection_HAsciiString) handlename; + + if (theclass->IsTransient() || theclass->IsPersistent()) { + handlename = new TCollection_HAsciiString("Handle_"); + + handlename->AssignCat(CPPClient_InterfaceName); + handlename->AssignCat("_"); + handlename->AssignCat(thetype->FullName()); + MS::AddOnce(List,handlename); + handlename = new TCollection_HAsciiString(CPPClient_InterfaceName); + handlename->AssignCat("_"); + handlename->AssignCat(thetype->FullName()); + MS::AddOnce(Incp,handlename); + } + else { + handlename = new TCollection_HAsciiString(CPPClient_InterfaceName); + handlename->AssignCat("_"); + handlename->AssignCat(thetype->FullName()); + + if (notusedwithref) { + MS::AddOnce(List,handlename); + } + else { + MS::AddOnce(Incp,handlename); + } + } + } + else if (thetype->IsKind(STANDARD_TYPE(MS_Enum))) { + Handle(TCollection_HAsciiString) name = new TCollection_HAsciiString(CPPClient_InterfaceName); + name->AssignCat("_"); + name->AssignCat(thetype->FullName()); + MS::AddOnce(List,name); + } + else if (thetype->IsKind(STANDARD_TYPE(MS_NatType))) { + MS::AddOnce(List,thetype->FullName()); + } +} + +Standard_Boolean CPPClient_AncestorHaveEmptyConstructor(const Handle(MS_MetaSchema)& aMeta, + const Handle(TCollection_HAsciiString)& aMother) +{ + Standard_Boolean result = Standard_False; + + if (aMeta->IsDefined(aMother)) { + Handle(MS_Type) t = aMeta->GetType(aMother); + + if (t->IsKind(STANDARD_TYPE(MS_Class))) { + Handle(MS_HSequenceOfMemberMet) methods; + Handle(MS_Class) c = *((Handle(MS_Class)*)&t); + Standard_Integer i; + + methods = c->GetMethods(); + + for (i = 1; i <= methods->Length() && !result; i++) { + if (methods->Value(i)->IsKind(STANDARD_TYPE(MS_Construc))) { + if ((methods->Value(i)->Params().IsNull()) && !methods->Value(i)->Private() && !methods->Value(i)->IsProtected()) { + result = Standard_True; + } + } + } + } + } + + return result; +} + +// sort the method used types : +// +// FullList : all the used types +// List : the types that must have a full definition +// Incp : the types that only have to be declared +// +void CPPClient_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; + + if (aMethod->IsKind(STANDARD_TYPE(MS_MemberMet))) { + Handle(MS_MemberMet) aMM = *((Handle(MS_MemberMet)*)&aMethod); + + aName = aMM->Class(); + } + else if (aMethod->IsKind(STANDARD_TYPE(MS_ExternMet))) { + Handle(MS_ExternMet) aMM = *((Handle(MS_ExternMet)*)&aMethod); + + aName = aMM->Package(); + } + + aParam = aMethod->Returns(); + + if (!aParam.IsNull()) { + thetype = aParam->Type(); + parname = aParam->TypeName(); + + if (thetype->IsKind(STANDARD_TYPE(MS_Alias))) { + Handle(MS_Alias) analias = *((Handle(MS_Alias)*)&thetype); + + parname = analias->DeepType(); + + if (aMeta->IsDefined(parname)) { + thetype = aMeta->GetType(parname); + } + else { + ErrorMsg << "CPPClient" << "Type " << parname << " not defined..." << endm; + Standard_NoSuchObject::Raise(); + } + } + + if (!parname->IsSameString(aName)) { + CPPClient_DispatchUsedType(aMeta,thetype,List,Incp,!aMethod->IsRefReturn()); + } + } + + Handle(MS_HArray1OfParam) seqparam = aMethod->Params(); + + if(!seqparam.IsNull()) { + for (i = 1; i <= seqparam->Length(); i++) { + thetype = seqparam->Value(i)->Type(); + parname = seqparam->Value(i)->TypeName(); + + if (thetype->IsKind(STANDARD_TYPE(MS_Alias))) { + Handle(MS_Alias) analias = *((Handle(MS_Alias)*)&thetype); + + parname = analias->DeepType(); + + if (aMeta->IsDefined(parname)) { + thetype = aMeta->GetType(parname); + } + else { + ErrorMsg << "CPPClient" << "Type " << parname << " not defined..." << endm; + Standard_NoSuchObject::Raise(); + } + } + + if (!parname->IsSameString(aName)) { + CPPClient_DispatchUsedType(aMeta,thetype,List,Incp,Standard_False); + } + } + } +} + + +// sort the class used types : +// +// FullList : all the used types +// List : the types that must have a full definition +// Incp : the types that only have to be declared +// +void CPPClient_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(CPPClient_InterfaceName); + aNameType->AssignCat("_"); + aNameType->AssignCat(asciiseq->Value(i)); + MS::AddOnce(List,aNameType); + } + + Handle(MS_HSequenceOfMemberMet) metseq = aClass->GetMethods(); + + for (i = 1; i <= metseq->Length(); i++) { + CPPClient_MethodUsedTypes(aMeta,metseq->Value(i),List,Incp); + } +} + + +// sort the used types : +// +// FullList : all the used types +// List : the types that must have a full definition +// Incp : the types that only have to be declared +// +void CPPClient_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); + + CPPClient_ClassUsedTypes(aMeta,aClass,List,Incp); + } + } +} + +// build a return, parameter or field type in c++ +// return a or a Handle_ +// +Handle(TCollection_HAsciiString) CPPClient_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 (aType->IsKind(STANDARD_TYPE(MS_Alias))) { + Handle(MS_Alias) analias = *((Handle(MS_Alias)*)&aType); + + parname = analias->DeepType(); + + if (aMeta->IsDefined(parname)) { + aType = aMeta->GetType(parname); + } + else { + ErrorMsg << "CPPClient" << "Type " << parname << " not defined..." << endm; + Standard_NoSuchObject::Raise(); + } + } + + rTypeName = new TCollection_HAsciiString(CPPClient_InterfaceName); + rTypeName->AssignCat("_"); + rTypeName->AssignCat(parname); + + if (aType->IsKind(STANDARD_TYPE(MS_Class))) { + Handle(MS_Class) aClass; + + aClass = *((Handle(MS_Class)*)&aType); + + if (aClass->IsPersistent() || aClass->IsTransient()) { + result->AssignCat("Handle_"); + result->AssignCat(rTypeName); + } + else { + result->AssignCat(rTypeName); + } + } + else if (aType->IsKind(STANDARD_TYPE(MS_NatType))) { + if (aType->IsKind(STANDARD_TYPE(MS_Imported)) || aType->IsKind(STANDARD_TYPE(MS_Pointer))) { + result = CPPClient_ErrorArgument; + } + else { + result->AssignCat(parname); + } + } + } + else { + ErrorMsg << "CPPClient" << "Type " << aTypeName << " not defined..." << endm; + Standard_NoSuchObject::Raise(); + } + + return result; +} + +// Build a parameter list for methods +// the output is in C++ +// +Handle(TCollection_HAsciiString) CPPClient_BuildParameterList(const Handle(MS_MetaSchema)& aMeta, + const Handle(MS_HArray1OfParam)& aSeq, + const Standard_Boolean withDefaultValue) +{ + 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(","); + } + + if (!aSeq->Value(i)->IsOut()) { + result->AssignCat("const "); + } + + if (aMeta->IsDefined(aSeq->Value(i)->TypeName())) { + parname = aSeq->Value(i)->TypeName(); + aType = aMeta->GetType(parname); + + if (aType->IsKind(STANDARD_TYPE(MS_Alias))) { + Handle(MS_Alias) analias = *((Handle(MS_Alias)*)&aType); + + parname = analias->DeepType(); + + if (aMeta->IsDefined(parname)) { + aType = aMeta->GetType(parname); + } + else { + ErrorMsg << "CPPClient" << "Type " << parname << " not defined..." << endm; + Standard_NoSuchObject::Raise(); + } + } + + + + if (aType->IsKind(STANDARD_TYPE(MS_Class))) { + aClass = *((Handle(MS_Class)*)&aType); + + if (aClass->IsPersistent() || aClass->IsTransient()) { + result->AssignCat("Handle("); + result->AssignCat(CPPClient_InterfaceName); + result->AssignCat("_"); + result->AssignCat(parname); + result->AssignCat(")& "); + result->AssignCat(aSeq->Value(i)->Name()); + } + else { + result->AssignCat(CPPClient_InterfaceName); + result->AssignCat("_"); + result->AssignCat(parname); + result->AssignCat("& "); + result->AssignCat(aSeq->Value(i)->Name()); + } + } + else if ((aType->IsKind(STANDARD_TYPE(MS_Alias)) || aSeq->Value(i)->IsItem() || aSeq->Value(i)->IsOut()) && !(aType->IsKind(STANDARD_TYPE(MS_Imported)) || aType->IsKind(STANDARD_TYPE(MS_Pointer)))) { + result->AssignCat(parname); + result->AssignCat("& "); + result->AssignCat(aSeq->Value(i)->Name()); + } + // WARNING : error here + // + else if (aType->IsKind(STANDARD_TYPE(MS_Imported)) || aType->IsKind(STANDARD_TYPE(MS_Pointer))) { + result = CPPClient_ErrorArgument; + return result; + } + else if (aType->IsKind(STANDARD_TYPE(MS_PrimType))) { + result->AssignCat(parname); + result->AssignCat(" "); + result->AssignCat(aSeq->Value(i)->Name()); + } + else { + result->AssignCat(parname); + result->AssignCat(" "); + result->AssignCat(aSeq->Value(i)->Name()); + } + } + else { + result->AssignCat(aSeq->Value(i)->TypeName()); + result->AssignCat("& "); + result->AssignCat(aSeq->Value(i)->Name()); + } + + if (aSeq->Value(i)->GetValueType() != MS_NONE && withDefaultValue) { + MS_ParamWithValue* pwv = (MS_ParamWithValue*)aSeq->Value(i).operator->(); + result->AssignCat(" = "); + result->AssignCat(pwv->GetValue()); + } + } + } + return result; +} + + +// build a c++ declaration method (ASYNCHRONOUS) +// the result is in the EDL variable VMethod +// +// template used : +// +// MethodTemplateDef +// ConstructorTemplateDef +// MethodTemplateDec +// ConstructorTemplateDec +// InlineMethodTemplateDec +// +// the EDL variables : +// VMethodHeader : must contains the name of the template used for +// methods construction +// VConstructorHeader : must contains the name of the template used for +// constructors construction +// +// WARNING : if an error was found the result in the variable "%Method" will be "%error%" +// +void CPPClient_BuildAsynchronousMethod(const Handle(MS_MetaSchema)& aMeta, + const Handle(EDL_API)& api, + const Handle(MS_Method)& m, + const Handle(TCollection_HAsciiString)& methodName, + const Standard_Boolean forGetArg, + const Standard_Boolean forDeclaration = Standard_True) +{ + Handle(MS_InstMet) im; + Handle(MS_ClassMet) cm; + Handle(MS_Construc) ct; + Handle(MS_Param) retType; + + Handle(TCollection_HAsciiString) MetTemplate, + theArgList, + ConTemplate; + + Standard_Boolean InlineMethod; + + MetTemplate = api->GetVariableValue(VMethodHeader); + ConTemplate = api->GetVariableValue(VConstructorHeader); + + + // no inline method in c++ client + // + InlineMethod = Standard_False; + api->AddVariable(VIsInline,"no"); + + api->AddVariable(VVirtual,""); + + if (forGetArg) { + Handle(TCollection_HAsciiString) argName = new TCollection_HAsciiString(methodName); + + argName->AssignCat("Arg"); + api->AddVariable(VMethodName,argName->ToCString()); + } + else { + api->AddVariable(VMethodName,methodName->ToCString()); + } + + // it s returning const ? + // + if (m->IsConstReturn()) { + api->AddVariable(VRetSpec,"const"); + } + else { + api->AddVariable(VRetSpec,""); + } + + // no ref return in c++ client + // + api->AddVariable(VAnd,""); + + theArgList = CPPClient_BuildParameterList(aMeta,m->Params(),forDeclaration); + + if (theArgList == CPPClient_ErrorArgument) { + WarningMsg << "CPPClient" << "Bad argument type in method (pointer or imported type) " << m->FullName() << endm; + WarningMsg << "CPPClient" << "Method : " << m->FullName() << " not exported." << endm; + api->AddVariable(VMethod,CPPClient_ErrorArgument->ToCString()); + return; + } + + if (m->IsKind(STANDARD_TYPE(MS_ClassMet)) || m->IsKind(STANDARD_TYPE(MS_ExternMet))) { + if (!theArgList->IsEmpty()) { + theArgList->AssignCat(","); + } + else { + theArgList->AssignCat(" "); + } + api->AddVariable("%Arguments",theArgList->ToCString()); + if (forDeclaration) { + api->Apply("%Arguments","AsyncClientDec"); + } + else { + api->Apply("%Arguments","AsyncClientDef"); + } + api->AddVariable("%Arguments",api->GetVariableValue("%Arguments")->ToCString()); + } + else { + if (!theArgList->IsEmpty()) { + theArgList->AssignCat(",FrontEnd_MID& uid"); + } + else { + theArgList->AssignCat("FrontEnd_MID& uid"); + } + api->AddVariable("%Arguments",theArgList->ToCString()); + } + + // it s returning a type or void ? + // + retType = m->Returns(); + + if (!retType.IsNull() && forGetArg) { + Handle(TCollection_HAsciiString) returnT = CPPClient_BuildType(aMeta,retType->TypeName()); + + if (returnT == CPPClient_ErrorArgument) { + WarningMsg << "CPPClient" << "Return type (pointer or imported type) of " << m->FullName() << " not exportable." << endm; + WarningMsg << "CPPClient" << "Method : " << m->FullName() << " not exported." << endm; + api->AddVariable(VMethod,CPPClient_ErrorArgument->ToCString()); + return; + } + else { + api->AddVariable(VReturn,returnT->ToCString()); + } + } + else { + api->AddVariable(VReturn,"void"); + } + + // now the specials attributes + // + // instance methods + // + if (m->IsKind(STANDARD_TYPE(MS_InstMet))) { + im = *((Handle(MS_InstMet)*)&m); + + api->AddVariable(VIsCreateMethod,"no"); + + if (!im->IsDeferred() || !forDeclaration) { + if (!im->IsStatic() && forDeclaration) { + api->AddVariable(VVirtual,"Standard_EXPORT virtual"); + } + else if (im->IsStatic() && forDeclaration) { + api->AddVariable(VVirtual,"Standard_EXPORT"); + } + + if (im->IsConst()) { + api->AddVariable(VMetSpec,"const"); + } + else { + api->AddVariable(VMetSpec,""); + } + } + // no pure vir classes in stubs + // + else if (forDeclaration) { + api->AddVariable(VVirtual,"Standard_EXPORT virtual"); + + if (im->IsConst()) { + api->AddVariable(VMetSpec,"const"); + } + else { + api->AddVariable(VMetSpec,""); + } + } + + api->Apply(VMethod,MetTemplate->ToCString()); + } + // + // class methods + // + else if (m->IsKind(STANDARD_TYPE(MS_ClassMet))) { + api->AddVariable(VIsCreateMethod,"no"); + api->AddVariable(VMetSpec,""); + if (forDeclaration) { + api->AddVariable(VVirtual,"Standard_EXPORT static"); + } + else { + api->AddVariable(VVirtual,""); + } + + api->Apply(VMethod,MetTemplate->ToCString()); + } + // + // package methods + // + else if (m->IsKind(STANDARD_TYPE(MS_ExternMet))) { + api->AddVariable(VIsCreateMethod,"no"); + api->AddVariable(VMetSpec,""); + if (forDeclaration) { + api->AddVariable(VVirtual,"Standard_EXPORT static"); + } + + api->Apply(VMethod,MetTemplate->ToCString()); + } +} + +// build a c++ declaration method +// the result is in the EDL variable VMethod +// +// template used : +// +// MethodTemplateDef +// ConstructorTemplateDef +// MethodTemplateDec +// ConstructorTemplateDec +// InlineMethodTemplateDec +// +// the EDL variables : +// VMethodHeader : must contains the name of the template used for +// methods construction +// VConstructorHeader : must contains the name of the template used for +// constructors construction +// +// WARNING : if an error was found the result in the variable "%Method" will be "%error%" +// +void CPPClient_BuildMethod(const Handle(MS_MetaSchema)& aMeta, + const Handle(EDL_API)& api, + const Handle(MS_Method)& m, + const Handle(TCollection_HAsciiString)& methodName, + const Standard_Boolean forDeclaration = Standard_True) +{ + Standard_Boolean IsAsynchrone = MethodMap.Contains(m->FullName()); + + // Here we build calls for synchronous methods + // + if (!IsAsynchrone) { + Standard_Boolean InlineMethod; + Handle(MS_InstMet) im; + Handle(MS_ClassMet) cm; + Handle(MS_Construc) ct; + Handle(MS_Param) retType; + Handle(TCollection_HAsciiString) MetTemplate, + theArgList, + ConTemplate; + + MetTemplate = api->GetVariableValue(VMethodHeader); + ConTemplate = api->GetVariableValue(VConstructorHeader); + + // here we process all the common attributes of methods + // + api->AddVariable(VMethodName,methodName->ToCString()); + api->AddVariable(VVirtual,""); + + // no inline method in c++ client + // + InlineMethod = Standard_False; + api->AddVariable(VIsInline,"no"); + + // it s returning const ? + // + if (m->IsConstReturn()) { + api->AddVariable(VRetSpec,"const"); + } + else { + api->AddVariable(VRetSpec,""); + } + + // no ref return in c++ client + // + api->AddVariable(VAnd,""); + + theArgList = CPPClient_BuildParameterList(aMeta,m->Params(),forDeclaration); + + if (theArgList == CPPClient_ErrorArgument) { + WarningMsg << "CPPClient" << "Bad argument type in method (pointer or imported type) " << m->FullName() << endm; + WarningMsg << "CPPClient" << "Method : " << m->FullName() << " not exported." << endm; + api->AddVariable(VMethod,CPPClient_ErrorArgument->ToCString()); + return; + } + + if (m->IsKind(STANDARD_TYPE(MS_Construc)) || m->IsKind(STANDARD_TYPE(MS_ClassMet)) || m->IsKind(STANDARD_TYPE(MS_ExternMet))) { + if (!theArgList->IsEmpty()) { + theArgList->AssignCat(","); + } + else { + theArgList->AssignCat(" "); + } + api->AddVariable("%Arguments",theArgList->ToCString()); + if (forDeclaration) { + api->Apply("%Arguments","ConstructorClientDec"); + } + else { + api->Apply("%Arguments","ConstructorClientDef"); + } + api->AddVariable("%Arguments",api->GetVariableValue("%Arguments")->ToCString()); + } + else { + api->AddVariable("%Arguments",theArgList->ToCString()); + } + + // it s returning a type or void ? + // + retType = m->Returns(); + + if (!retType.IsNull()) { + Handle(TCollection_HAsciiString) returnT = CPPClient_BuildType(aMeta,retType->TypeName()); + + if (returnT == CPPClient_ErrorArgument) { + WarningMsg << "CPPClient" << "Return type (pointer or imported type) of " << m->FullName() << " not exportable." << endm; + WarningMsg << "CPPClient" << "Method : " << m->FullName() << " not exported." << endm; + api->AddVariable(VMethod,CPPClient_ErrorArgument->ToCString()); + return; + } + else { + api->AddVariable(VReturn,returnT->ToCString()); + } + } + else { + api->AddVariable(VReturn,"void"); + } + + // now the specials attributes + // + // instance methods + // + if (m->IsKind(STANDARD_TYPE(MS_InstMet))) { + im = *((Handle(MS_InstMet)*)&m); + + api->AddVariable(VIsCreateMethod,"no"); + + if (!im->IsDeferred() || !forDeclaration) { + if (!im->IsStatic() && forDeclaration) { + api->AddVariable(VVirtual,"Standard_EXPORT virtual"); + } + else if (im->IsStatic() && forDeclaration) { + api->AddVariable(VVirtual,"Standard_EXPORT"); + } + + if (im->IsConst()) { + api->AddVariable(VMetSpec,"const"); + } + else { + api->AddVariable(VMetSpec,""); + } + } + // no pure vir classes in stubs + // + else if (forDeclaration) { + api->AddVariable(VVirtual,"virtual"); + + if (im->IsConst()) { + api->AddVariable(VMetSpec,"const"); + } + else { + api->AddVariable(VMetSpec,""); + } + } + + api->Apply(VMethod,MetTemplate->ToCString()); + } + // + // class methods + // + else if (m->IsKind(STANDARD_TYPE(MS_ClassMet))) { + api->AddVariable(VIsCreateMethod,"no"); + api->AddVariable(VMetSpec,""); + if (forDeclaration) { + api->AddVariable(VVirtual,"Standard_EXPORT static"); + } + else { + api->AddVariable(VVirtual,""); + } + api->Apply(VMethod,MetTemplate->ToCString()); + } + // + // constructors + // + else if (m->IsKind(STANDARD_TYPE(MS_Construc))) { + api->AddVariable(VIsCreateMethod,"yes"); + api->Apply(VMethod,ConTemplate->ToCString()); + } + // + // package methods + // + else if (m->IsKind(STANDARD_TYPE(MS_ExternMet))) { + api->AddVariable(VIsCreateMethod,"no"); + api->AddVariable(VMetSpec,""); + if (forDeclaration) { + api->AddVariable(VVirtual,"Standard_EXPORT static"); + } + + api->Apply(VMethod,MetTemplate->ToCString()); + } + } + // Here we build calls for asynchronous methods + // + else { + Handle(TCollection_HAsciiString) tmp; + + CPPClient_BuildAsynchronousMethod(aMeta,api,m,methodName,Standard_False,forDeclaration); + + if (!api->GetVariableValue("%Method")->IsSameString(CPPClient_ErrorArgument)) { + tmp = api->GetVariableValue(VMethod); + tmp->AssignCat(";"); + CPPClient_BuildAsynchronousMethod(aMeta,api,m,methodName,Standard_True,forDeclaration); + tmp->AssignCat(api->GetVariableValue(VMethod)); + api->AddVariable(VMethod,tmp->ToCString()); + } + } +} + +void CPPClient_ClassTypeMgt(const Handle(MS_MetaSchema)& aMeta, + const Handle(EDL_API)& api, + const Handle(MS_Class)& aClass, + const Standard_CString var) +{ + Handle(TColStd_HSequenceOfHAsciiString) inh = aClass->GetFullInheritsNames(); + Standard_Integer i; + Handle(TCollection_HAsciiString) ichar; + Handle(TCollection_HAsciiString) rTypeName; + Handle(TCollection_HAsciiString) str = new TCollection_HAsciiString; + Handle(TCollection_HAsciiString) str1 = new TCollection_HAsciiString; + + for (i = 1; i <= inh->Length(); i++) { + ichar = new TCollection_HAsciiString(i); + + api->AddVariable(VNb,ichar->ToCString()); + api->Apply(VNb,"TypeMgtAncestorType"); + + str1->AssignCat(api->GetVariableValue(VNb)); + str1->AssignCat(","); + + rTypeName = new TCollection_HAsciiString(CPPClient_InterfaceName); + rTypeName->AssignCat("_"); + rTypeName->AssignCat(inh->Value(i)); + + api->AddVariable(VAncestors,rTypeName->ToCString()); + api->Apply("%TMgtInherits","TypeMgtAncestor"); + str->AssignCat(api->GetVariableValue("%TMgtInherits")); + } + + rTypeName = new TCollection_HAsciiString(CPPClient_InterfaceName); + rTypeName->AssignCat("_"); + rTypeName->AssignCat(aClass->FullName()); + + api->AddVariable("%TMgtInherits",str->ToCString()); + api->AddVariable(VAncestors,str1->ToCString()); + api->AddVariable("%TMgtClass",rTypeName->ToCString()); + + api->Apply(var,"TypeMgt"); +} + +// build the return sentence for a stub c++ method call +// +Handle(TCollection_HAsciiString) CPPClient_BuildAsynchronousReturnCode(const Handle(MS_MetaSchema)& aMeta, + const Handle(EDL_API)& api, + const Handle(MS_Method)& m) +{ + Handle(TCollection_HAsciiString) result = new TCollection_HAsciiString; + Handle(MS_Type) rtype = aMeta->GetType(m->Returns()->TypeName()); + + if (rtype->IsKind(STANDARD_TYPE(MS_Alias))) { + Handle(TCollection_HAsciiString) parname; + Handle(MS_Alias) analias = *((Handle(MS_Alias)*)&rtype); + + parname = analias->DeepType(); + + if (aMeta->IsDefined(parname)) { + rtype = aMeta->GetType(parname); + } + else { + ErrorMsg << "CPPClient" << "Type " << parname << " not defined..." << endm; + Standard_NoSuchObject::Raise(); + } + } + + + if (rtype->IsKind(STANDARD_TYPE(MS_PrimType))) { + api->AddVariable("%PrimName",rtype->Name()->ToCString()); + api->Apply("%Return","AsyncMethodReturnPrim"); + } + else if (rtype->IsKind(STANDARD_TYPE(MS_Enum))) { + api->AddVariable("%PrimName",rtype->FullName()->ToCString()); + api->Apply("%Return","AsyncMethodReturnEnum"); + } + else if (rtype->IsKind(STANDARD_TYPE(MS_StdClass)) && !rtype->IsKind(STANDARD_TYPE(MS_Error))) { + Handle(MS_StdClass) aClass = *((Handle(MS_StdClass)*)&rtype); + Handle(TCollection_HAsciiString) cname = new TCollection_HAsciiString(CPPClient_InterfaceName); + + cname->AssignCat("_"); + cname->AssignCat(aClass->FullName()); + api->AddVariable("%PrimName",cname->ToCString()); + + if (aClass->IsTransient() || aClass->IsPersistent()) { + if (m->IsKind(STANDARD_TYPE(MS_ClassMet)) || m->IsKind(STANDARD_TYPE(MS_ExternMet))) { + api->Apply("%Return","AsyncStaticMethodReturnHandle"); + } + else { + api->Apply("%Return","AsyncMethodReturnHandle"); + } + } + else { + if (m->IsKind(STANDARD_TYPE(MS_ClassMet)) || m->IsKind(STANDARD_TYPE(MS_ExternMet))) { + api->Apply("%Return","AsyncStaticMethodReturnValue"); + } + else { + api->Apply("%Return","AsyncMethodReturnValue"); + } + } + } + + result->AssignCat(api->GetVariableValue("%Return")); + + return result; +} + +// build the return sentence for a stub c++ method call +// +Handle(TCollection_HAsciiString) CPPClient_BuildReturnCode(const Handle(MS_MetaSchema)& aMeta, + const Handle(EDL_API)& api, + const Handle(MS_Method)& m) +{ + Handle(TCollection_HAsciiString) result = new TCollection_HAsciiString; + Handle(MS_Type) rtype = aMeta->GetType(m->Returns()->TypeName()); + + if (rtype->IsKind(STANDARD_TYPE(MS_Alias))) { + Handle(TCollection_HAsciiString) parname; + Handle(MS_Alias) analias = *((Handle(MS_Alias)*)&rtype); + + parname = analias->DeepType(); + + if (aMeta->IsDefined(parname)) { + rtype = aMeta->GetType(parname); + } + else { + ErrorMsg << "CPPClient" << "Type " << parname << " not defined..." << endm; + Standard_NoSuchObject::Raise(); + } + } + + + if (rtype->IsKind(STANDARD_TYPE(MS_PrimType))) { + api->AddVariable("%PrimName",rtype->Name()->ToCString()); + api->Apply("%Return","MethodReturnPrim"); + } + else if (rtype->IsKind(STANDARD_TYPE(MS_Enum))) { + api->AddVariable("%PrimName",rtype->FullName()->ToCString()); + api->Apply("%Return","MethodReturnEnum"); + } + else if (rtype->IsKind(STANDARD_TYPE(MS_StdClass)) && !rtype->IsKind(STANDARD_TYPE(MS_Error))) { + Handle(MS_StdClass) aClass = *((Handle(MS_StdClass)*)&rtype); + Handle(TCollection_HAsciiString) cname = new TCollection_HAsciiString(CPPClient_InterfaceName); + + cname->AssignCat("_"); + cname->AssignCat(aClass->FullName()); + api->AddVariable("%PrimName",cname->ToCString()); + + if (aClass->IsTransient() || aClass->IsPersistent()) { + if (m->IsKind(STANDARD_TYPE(MS_ClassMet)) || m->IsKind(STANDARD_TYPE(MS_ExternMet))) { + api->Apply("%Return","StaticMethodReturnHandle"); + } + else { + api->Apply("%Return","MethodReturnHandle"); + } + } + else { + if (m->IsKind(STANDARD_TYPE(MS_ClassMet)) || m->IsKind(STANDARD_TYPE(MS_ExternMet))) { + api->Apply("%Return","StaticMethodReturnValue"); + } + else { + api->Apply("%Return","MethodReturnValue"); + } + } + } + + result->AssignCat(api->GetVariableValue("%Return")); + + return result; +} + +// build an asynchronous method call for stub c++ +// +void CPPClient_AsynchronousMethodBuilder(const Handle(MS_MetaSchema)& aMeta, + const Handle(EDL_API)& api, + const Handle(TCollection_HAsciiString)& className, + const Handle(MS_Method)& m, + const Handle(TCollection_HAsciiString)& methodName, + const Standard_Boolean mustAddAncestorConstrucCall) +{ + Handle(TCollection_HAsciiString) metname = new TCollection_HAsciiString(CPPClient_InterfaceName); + Handle(TCollection_HAsciiString) metbody = new TCollection_HAsciiString; + Standard_CString headerTemplate; + + metname->AssignCat("_"); + metname->AssignCat(className); + metname->AssignCat("::"); + metname->AssignCat(methodName); + + if (m->IsKind(STANDARD_TYPE(MS_InstMet))) { + headerTemplate = "AsyncInstMethodDec"; + api->AddVariable("%WhatEngine","Engine()"); + api->AddVariable("%MethodName",methodName->ToCString()); + } + else if (m->IsKind(STANDARD_TYPE(MS_ClassMet))) { + headerTemplate = "AsyncClassMethodDec"; + api->AddVariable("%ClassName",className->ToCString()); + api->AddVariable("%WhatEngine","_aCurrent"); + api->AddVariable("%MethodName",methodName->ToCString()); + } + else if (m->IsKind(STANDARD_TYPE(MS_ExternMet))) { + headerTemplate = "AsyncPackMethodDec"; + api->AddVariable("%ClassName",className->ToCString()); + api->AddVariable("%WhatEngine","_aCurrent"); + api->AddVariable("%MethodName",methodName->ToCString()); + } + + api->Apply("%Method",headerTemplate); + + metbody->AssignCat(api->GetVariableValue("%Method")); + + Handle(MS_HArray1OfParam) aSeqP = m->Params(); + Standard_Integer i; + + if(!aSeqP.IsNull()) { + for (i = 1; i <= aSeqP->Length(); i++) { + api->AddVariable("%ArgName",aSeqP->Value(i)->Name()->ToCString()); + Handle(MS_Type) t = aMeta->GetType(aSeqP->Value(i)->TypeName()); + + if (aSeqP->Value(i)->IsOut()) { + if (t->IsKind(STANDARD_TYPE(MS_Enum))) { + Handle(TCollection_HAsciiString) n = new TCollection_HAsciiString("(Standard_Integer&)"); + n->AssignCat(aSeqP->Value(i)->Name()); + api->AddVariable("%ArgName",n->ToCString()); + } + api->Apply("%Method","AsyncMethodArgOut"); + } + else { + if (t->IsKind(STANDARD_TYPE(MS_Enum))) { + Handle(TCollection_HAsciiString) n = new TCollection_HAsciiString("(Standard_Integer)"); + n->AssignCat(aSeqP->Value(i)->Name()); + api->AddVariable("%ArgName",n->ToCString()); + } + api->Apply("%Method","AsyncMethodArg"); + } + + metbody->AssignCat(api->GetVariableValue("%Method")); + } + } + metbody->AssignCat(" _aMethod->ExecuteAsynchrone();\n"); + + CPPClient_BuildAsynchronousMethod(aMeta,api,m,metname,Standard_False,Standard_False); + api->AddVariable(VConstructorHeader,"ConstructorHeader"); + + if (!api->GetVariableValue("%Method")->IsSameString(CPPClient_ErrorArgument)) { + api->AddVariable("%MBody",metbody->ToCString()); + api->Apply("%Method","MethodTemplateDef"); + } + + Handle(TCollection_HAsciiString) metGetArg; + + metGetArg = api->GetVariableValue("%Method"); + + CPPClient_BuildAsynchronousMethod(aMeta,api,m,metname,Standard_True,Standard_False); + + api->AddVariable("%ReturnBody",""); + + if (!api->GetVariableValue("%Method")->IsSameString(CPPClient_ErrorArgument)) { + if (!m->Returns().IsNull()) { + metbody = CPPClient_BuildAsynchronousReturnCode(aMeta,api,m); + api->AddVariable("%ReturnBody",metbody->ToCString()); + } + else { + api->Apply("%ReturnBody","AsyncMethodReturnVoid"); + } + } + + api->Apply("%Method","AsyncGetArg"); + + metGetArg->AssignCat(api->GetVariableValue("%Method")); + + api->AddVariable("%Method",metGetArg->ToCString()); + + api->AddVariable(VConstructorHeader,"ConstructorHeader"); +} + +// build a method call for stub c++ +// +void CPPClient_MethodBuilder(const Handle(MS_MetaSchema)& aMeta, + const Handle(EDL_API)& api, + const Handle(TCollection_HAsciiString)& className, + const Handle(MS_Method)& m, + const Handle(TCollection_HAsciiString)& methodName, + const Standard_Boolean mustAddAncestorConstrucCall) +{ + Standard_Boolean IsAsynchrone = MethodMap.Contains(m->FullName()); + + if (!IsAsynchrone) { + Handle(TCollection_HAsciiString) metname = new TCollection_HAsciiString(CPPClient_InterfaceName); + Handle(TCollection_HAsciiString) metbody = new TCollection_HAsciiString; + Standard_CString headerTemplate; + + metname->AssignCat("_"); + metname->AssignCat(className); + metname->AssignCat("::"); + + if (m->IsKind(STANDARD_TYPE(MS_Construc))) { + metname->AssignCat(CPPClient_InterfaceName); + metname->AssignCat("_"); + metname->AssignCat(className); + } + else { + metname->AssignCat(methodName); + } + + if (m->IsKind(STANDARD_TYPE(MS_InstMet))) { + headerTemplate = "InstMethodDec"; + api->AddVariable("%MethodName",methodName->ToCString()); + } + else if (m->IsKind(STANDARD_TYPE(MS_ClassMet))) { + headerTemplate = "ClassMethodDec"; + api->AddVariable("%ClassName",className->ToCString()); + api->AddVariable("%MethodName",methodName->ToCString()); + } + else if (m->IsKind(STANDARD_TYPE(MS_Construc))) { + headerTemplate = "CreateMethodDec"; + api->AddVariable("%ClassName",className->ToCString()); + api->AddVariable("%MethodName",className->ToCString()); + } + else if (m->IsKind(STANDARD_TYPE(MS_ExternMet))) { + headerTemplate = "PackMethodDec"; + api->AddVariable("%ClassName",className->ToCString()); + api->AddVariable("%MethodName",methodName->ToCString()); + } + + api->Apply("%Method",headerTemplate); + + metbody->AssignCat(api->GetVariableValue("%Method")); + + Handle(MS_HArray1OfParam) aSeqP = m->Params(); + Standard_Integer i; + + if(!aSeqP.IsNull()) { + for (i = 1; i <= aSeqP->Length(); i++) { + api->AddVariable("%ArgName",aSeqP->Value(i)->Name()->ToCString()); + Handle(MS_Type) t = aMeta->GetType(aSeqP->Value(i)->TypeName()); + + if (aSeqP->Value(i)->IsOut()) { + if (t->IsKind(STANDARD_TYPE(MS_Enum))) { + Handle(TCollection_HAsciiString) n = new TCollection_HAsciiString("(Standard_Integer&)"); + n->AssignCat(aSeqP->Value(i)->Name()); + api->AddVariable("%ArgName",n->ToCString()); + } + api->Apply("%Method","MethodArgOut"); + } + else { + if (t->IsKind(STANDARD_TYPE(MS_Enum))) { + Handle(TCollection_HAsciiString) n = new TCollection_HAsciiString("(Standard_Integer)"); + n->AssignCat(aSeqP->Value(i)->Name()); + api->AddVariable("%ArgName",n->ToCString()); + } + api->Apply("%Method","MethodArg"); + } + + metbody->AssignCat(api->GetVariableValue("%Method")); + } + } + metbody->AssignCat(" _aMethod.Execute();\n"); + + if (m->IsKind(STANDARD_TYPE(MS_Construc))) { + Handle(MS_Type) tmpType = aMeta->GetType(className); + Handle(MS_Class) myClass = *((Handle(MS_Class)*)&tmpType); + Standard_Boolean iamHandled = myClass->IsTransient() || myClass->IsPersistent(); + + // for handled classes we must call the superclass constructor + // + if (iamHandled) { + api->Apply("%Return","CreateMethodReturnHandle"); + } + else { + api->Apply("%Return","CreateMethodReturnValue"); + } + + if (mustAddAncestorConstrucCall) { + if (iamHandled || myClass->GetInheritsNames()->Length() == 0) { + api->AddVariable(VConstructorHeader,"ExternalConstructorCallAncestorHeader"); + } + else { + api->AddVariable(VConstructorHeader,"ExternalValueConstructorCallAncestorHeader"); + } + } else { + if (iamHandled || myClass->GetInheritsNames()->Length() == 0) { + api->AddVariable(VConstructorHeader,"ExternalConstructorHeader"); + } + else { + api->AddVariable(VConstructorHeader,"ExternalValueConstructorCallAncestorHeader"); + } + } + + metbody->AssignCat(api->GetVariableValue("%Return")); + } + else if (!m->Returns().IsNull()) { + metbody->AssignCat(CPPClient_BuildReturnCode(aMeta,api,m)); + } + + CPPClient_BuildMethod(aMeta,api,m,metname,Standard_False); + api->AddVariable(VConstructorHeader,"ConstructorHeader"); + + if (!api->GetVariableValue("%Method")->IsSameString(CPPClient_ErrorArgument)) { + api->AddVariable("%MBody",metbody->ToCString()); + api->Apply("%Method","MethodTemplateDef"); + } + } + // ASYNCHRONOUS + // + else { + CPPClient_AsynchronousMethodBuilder(aMeta,api,className,m,methodName,mustAddAncestorConstrucCall); + } +} + +// Standard extractor API : launch the extraction of C++ files +// from the type +// +void CPPClient_TypeExtract(const Handle(MS_MetaSchema)& aMeta, + const Handle(TCollection_HAsciiString)& aName, + const Handle(TColStd_HSequenceOfHAsciiString)& edlsfullpath, + const Handle(TCollection_HAsciiString)& outdir, + const Handle(TColStd_HSequenceOfHAsciiString)& outfile, + const ExtractionType MustBeComplete) +{ + Handle(MS_Type) srcType; + Handle(MS_Package) srcPackage; + + // before begining, we look if the entity has something to extract... + // + if (aMeta->IsDefined(aName)) { + srcType = aMeta->GetType(aName); + } + else if (aMeta->IsPackage(aName)) { + srcPackage = aMeta->GetPackage(aName); + } + else { + ErrorMsg << "CPPClient" << aName->ToCString() << " not defined..." << endm; + Standard_NoSuchObject::Raise(); + } + + // ... and we load the templates + // + Handle(EDL_API) api; + + // Package Extraction + // + if (!srcPackage.IsNull()) { + if (srcPackage->Methods()->Length() > 0) { + Handle(MS_HSequenceOfExternMet) aSeqMet = new MS_HSequenceOfExternMet; + + api = CPPClient_LoadTemplate(edlsfullpath,outdir); + + if (MustBeComplete == CPPClient_SEMICOMPLETE) { + Standard_Integer i; + + for (i = 1; i <= SeqOfExternMet->Length(); i++) { + if (aName->IsSameString(SeqOfExternMet->Value(i)->Package())) { + aSeqMet->Append(SeqOfExternMet->Value(i)); + } + } + } + + CPPClient_Package(aMeta,api,srcPackage,outfile,MustBeComplete,aSeqMet); + } + else { + return; + } + } + else if (aName->IsSameString(MS::GetTransientRootName()) || aName->IsSameString(MS::GetPersistentRootName())) { + Handle(TCollection_HAsciiString) aHandleFile = new TCollection_HAsciiString(outdir); + Standard_CString CXX,HXX; + + if (aName->IsSameString(MS::GetTransientRootName())) { + CXX = "TransientRootClientCXX"; + HXX = "TransientRootClientHXX"; + } + else { + CXX = "PersistentRootClientCXX"; + HXX = "PersistentRootClientHXX"; + } + + aHandleFile->AssignCat("Handle_"); + aHandleFile->AssignCat(CPPClient_InterfaceName); + aHandleFile->AssignCat("_"); + aHandleFile->AssignCat(aName); + aHandleFile->AssignCat(".hxx"); + + outfile->Append(aHandleFile); + + api = CPPClient_LoadTemplate(edlsfullpath,outdir); + + CPPClient_TransientHandle(api,aName,CPPClient_TransientRootName(),aHandleFile); + + aHandleFile = new TCollection_HAsciiString(outdir); + + aHandleFile->AssignCat(CPPClient_InterfaceName); + aHandleFile->AssignCat("_"); + aHandleFile->AssignCat(aName); + aHandleFile->AssignCat("_client.cxx"); + api->Apply("%outClass",CXX); + outfile->Append(aHandleFile); + + // ...now we write the result + // + api->OpenFile("HTFile",aHandleFile->ToCString()); + api->WriteFile("HTFile","%outClass"); + api->CloseFile("HTFile"); + + aHandleFile = new TCollection_HAsciiString(outdir); + + aHandleFile->AssignCat(CPPClient_InterfaceName); + aHandleFile->AssignCat("_"); + aHandleFile->AssignCat(aName); + aHandleFile->AssignCat(".hxx"); + api->Apply("%outClass",HXX); + outfile->Append(aHandleFile); + + // ...now we write the result + // + api->OpenFile("HTFile",aHandleFile->ToCString()); + api->WriteFile("HTFile","%outClass"); + api->CloseFile("HTFile"); + } + else if (aName->IsSameString(CPPClient_MemoryRootName())) { + Handle(TCollection_HAsciiString) aHandleFile = new TCollection_HAsciiString(outdir), + ancestorName; + Standard_CString CXX,HXX; + + CXX = "MemoryRootClientCXX"; + HXX = "MemoryRootClientHXX"; + + aHandleFile->AssignCat("Handle_"); + aHandleFile->AssignCat(CPPClient_InterfaceName); + aHandleFile->AssignCat("_"); + aHandleFile->AssignCat(aName); + aHandleFile->AssignCat(".hxx"); + + outfile->Append(aHandleFile); + + api = CPPClient_LoadTemplate(edlsfullpath,outdir); + + CPPClient_TransientHandle(api,aName,MS::GetTransientRootName(),aHandleFile); + + aHandleFile = new TCollection_HAsciiString(outdir); + + aHandleFile->AssignCat(CPPClient_InterfaceName); + aHandleFile->AssignCat("_"); + aHandleFile->AssignCat(aName); + aHandleFile->AssignCat("_client.cxx"); + api->Apply("%outClass",CXX); + outfile->Append(aHandleFile); + + // ...now we write the result + // + api->OpenFile("HTFile",aHandleFile->ToCString()); + api->WriteFile("HTFile","%outClass"); + api->CloseFile("HTFile"); + + aHandleFile = new TCollection_HAsciiString(outdir); + + aHandleFile->AssignCat(CPPClient_InterfaceName); + aHandleFile->AssignCat("_"); + aHandleFile->AssignCat(aName); + aHandleFile->AssignCat(".hxx"); + api->Apply("%outClass",HXX); + outfile->Append(aHandleFile); + + // ...now we write the result + // + api->OpenFile("HTFile",aHandleFile->ToCString()); + api->WriteFile("HTFile","%outClass"); + api->CloseFile("HTFile"); + } + else if (aName->IsSameString(MS::GetStorableRootName())) { + Handle(TCollection_HAsciiString) aHandleFile = new TCollection_HAsciiString(outdir); + + api = CPPClient_LoadTemplate(edlsfullpath,outdir); + + aHandleFile = new TCollection_HAsciiString(outdir); + + aHandleFile->AssignCat(CPPClient_InterfaceName); + aHandleFile->AssignCat("_"); + aHandleFile->AssignCat(aName); + aHandleFile->AssignCat("_client.cxx"); + api->Apply("%outClass","StorableRootClientCXX"); + outfile->Append(aHandleFile); + + // ...now we write the result + // + api->OpenFile("HTFile",aHandleFile->ToCString()); + api->WriteFile("HTFile","%outClass"); + api->CloseFile("HTFile"); + + aHandleFile = new TCollection_HAsciiString(outdir); + + aHandleFile->AssignCat(CPPClient_InterfaceName); + aHandleFile->AssignCat("_"); + aHandleFile->AssignCat(aName); + aHandleFile->AssignCat(".hxx"); + api->Apply("%outClass","StorableRootClientHXX"); + outfile->Append(aHandleFile); + + // ...now we write the result + // + api->OpenFile("HTFile",aHandleFile->ToCString()); + api->WriteFile("HTFile","%outClass"); + api->CloseFile("HTFile"); + } + // Extraction of Classes + // + else if (srcType->IsKind(STANDARD_TYPE(MS_StdClass)) && !srcType->IsKind(STANDARD_TYPE(MS_GenClass)) && !srcType->IsKind(STANDARD_TYPE(MS_InstClass))) { + Handle(MS_StdClass) aClass = *((Handle(MS_StdClass)*)&srcType); + + if (aClass->IsGeneric()) { + return; + } + + Handle(MS_HSequenceOfMemberMet) aSeqMet = new MS_HSequenceOfMemberMet; + + api = CPPClient_LoadTemplate(edlsfullpath,outdir); + + if (MustBeComplete == CPPClient_SEMICOMPLETE) { + Standard_Integer i; + + for (i = 1; i <= SeqOfMemberMet->Length(); i++) { + if (aName->IsSameString(SeqOfMemberMet->Value(i)->Class())) { + aSeqMet->Append(SeqOfMemberMet->Value(i)); + } + } + } + + // Transient classes + // + if (aClass->IsTransient() || aClass->IsPersistent()) { + Handle(TCollection_HAsciiString) aHandleFile = new TCollection_HAsciiString(outdir); + + aHandleFile->AssignCat("Handle_"); + aHandleFile->AssignCat(CPPClient_InterfaceName); + aHandleFile->AssignCat("_"); + aHandleFile->AssignCat(aName); + aHandleFile->AssignCat(".hxx"); + + outfile->Append(aHandleFile); + + CPPClient_TransientHandle(api,aName,aClass->GetInheritsNames()->Value(1),aHandleFile); + CPPClient_TransientClass(aMeta,api,aClass,outfile,MustBeComplete,aSeqMet); + } + // MPV classes + // + else { + CPPClient_MPVClass(aMeta,api,aClass,outfile,MustBeComplete,aSeqMet); + } + } + else if (srcType->IsKind(STANDARD_TYPE(MS_Enum))) { + api = CPPClient_LoadTemplate(edlsfullpath,outdir); + + Handle(MS_Enum) theEnum = *((Handle(MS_Enum)*)&srcType); + + CPPClient_Enum(aMeta,api,theEnum,outfile); + } +} + +void CPPClient_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)) { + ExtractionType theMode; + + if (strcmp(Mode,"CPPClient_COMPLETE") == 0) {theMode = CPPClient_COMPLETE;} + else if (strcmp(Mode,"CPPClient_INCOMPLETE") == 0) {theMode = CPPClient_INCOMPLETE;} + else if (strcmp(Mode,"CPPClient_SEMICOMPLETE") == 0) {theMode = CPPClient_SEMICOMPLETE;} + else { + ErrorMsg << "CPPClient" << "Unknown extraction mode:" << Mode << endm; + Standard_NoSuchObject::Raise(); + } + + CPPClient_TypeExtract(aMeta,aTypeName,edlsfullpath,outdir,outfile,theMode); + } + else { + ErrorMsg << "CPPClient" << "Type " << aTypeName << " not defined..." << endm; + Standard_NoSuchObject::Raise(); + } +} + diff --git a/src/CPPClient/CPPClient.hxx b/src/CPPClient/CPPClient.hxx new file mode 100755 index 0000000..5f6780d --- /dev/null +++ b/src/CPPClient/CPPClient.hxx @@ -0,0 +1,155 @@ +#ifndef _CPPClient_HeaderFile +#define _CPPClient_HeaderFile +#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 "C" { + + Handle(TColStd_HSequenceOfHAsciiString) Standard_EXPORT CPPClient_TemplatesUsed(); + + void Standard_EXPORT CPPClient_Init(const Handle(MS_MetaSchema)&, + const Handle(TCollection_HAsciiString)&, + const Handle(MS_HSequenceOfExternMet)&, + const Handle(MS_HSequenceOfMemberMet)&); + + void Standard_EXPORT CPPClient_Extract(const Handle(MS_MetaSchema)& ams, + const Handle(TCollection_HAsciiString)& atypename, + const Handle(TColStd_HSequenceOfHAsciiString)& edlsfullpath, + const Handle(TCollection_HAsciiString)& outdir, + const Handle(TColStd_HSequenceOfHAsciiString)& outfile, + const Standard_CString Mode); + } + +enum ExtractionType {CPPClient_COMPLETE,CPPClient_INCOMPLETE,CPPClient_SEMICOMPLETE}; + +Handle(TCollection_HAsciiString) CPPClient_BuildType(const Handle(MS_MetaSchema)&, + const Handle(TCollection_HAsciiString)&); + +void CPPClient_TransientHandle(const Handle(EDL_API)&, + const Handle(TCollection_HAsciiString)&, + const Handle(TCollection_HAsciiString)&, + const Handle(TCollection_HAsciiString)&); + + +void CPPClient_TransientClass(const Handle(MS_MetaSchema)&, + const Handle(EDL_API)&, + const Handle(MS_Class)&, + const Handle(TColStd_HSequenceOfHAsciiString)&, + const ExtractionType, + const Handle(MS_HSequenceOfMemberMet)&); + +void CPPClient_MPVClass(const Handle(MS_MetaSchema)&, + const Handle(EDL_API)&, + const Handle(MS_Class)&, + const Handle(TColStd_HSequenceOfHAsciiString)&, + const ExtractionType, + const Handle(MS_HSequenceOfMemberMet)&); + +void CPPClient_Alias(const Handle(MS_MetaSchema)&, + const Handle(EDL_API)&, + const Handle(MS_Alias)&, + const Handle(TColStd_HSequenceOfHAsciiString)&); + +void CPPClient_Package(const Handle(MS_MetaSchema)&, + const Handle(EDL_API)&, + const Handle(MS_Package)&, + const Handle(TColStd_HSequenceOfHAsciiString)&, + const ExtractionType, + const Handle(MS_HSequenceOfExternMet)&); + +void CPPClient_BuildMethod(const Handle(MS_MetaSchema)& aMeta, + const Handle(EDL_API)& api, + const Handle(MS_Method)& m, + const Handle(TCollection_HAsciiString)& methodName, + const Standard_Boolean forDeclaration); + +void CPPClient_Enum(const Handle(MS_MetaSchema)& aMeta, + const Handle(EDL_API)& api, + const Handle(MS_Enum)& anEnum, + const Handle(TColStd_HSequenceOfHAsciiString)& outfile); + +// EDL variables +// +Standard_CString VClass = "%Class", + VTICIncludes = "%TICIncludes", + VInherits = "%Inherits", + VTICPublicmets = "%TICPublicmets", + VTICPublicfriends = "%TICPublicfriends", + VTICProtectedmets = "%TICProtectedmets", + VTICProtectedfields = "%TICProtectedfields", + VTICPrivatemets = "%TICPrivatemets", + VTICPrivatefriends = "%TICPrivatefriends", + VTICDefines = "%TICDefines", + VTICInlineIncludes = "%TICInlineIncludes", + VTICUndefines = "%TICUndefines", + VTICPrivatefields = "%TICPrivatefields", + VRetSpec = "%RetSpec", + VVirtual = "%Virtual", + VReturn = "%Return", + VAnd = "%And", + VMethodName = "%MethodName", + VArgument = "%Arguments", + VMetSpec = "%MetSpec", + VMethod = "%Method", + VMBody = "%MBody", + VDName = "%DName", + VDValue = "%DValue", + VIsInline = "%IsInline", + VIsCreateMethod = "%IsCreateMethod", + VIClass = "%IClass", + VSuffix = "%Suffix", + VCxxFile = "CxxFile", + VLxxFile = "LxxFile", + VInlineMethod = "%InlineMethod", + VoutClass = "%outClass", + VNb = "%Nb", + VValues = "%Values", + VSupplement = "%Supplement", + VTypeMgt = "%TypeMgt", + VMethods = "%Methods", + VAncestors = "%Ancestors", + VFullPath = "%FullPath", + VMethodHeader = "%MethodHeader", + VConstructorHeader = "%ConstructorHeader", + VTICSuppMethod = "%TICSuppMethod", + VInterface = "%Interface"; + + +#endif diff --git a/src/CPPClient/CPPClient_Define.hxx b/src/CPPClient/CPPClient_Define.hxx new file mode 100755 index 0000000..223b04b --- /dev/null +++ b/src/CPPClient/CPPClient_Define.hxx @@ -0,0 +1,86 @@ +#ifndef _CPPClient_Define_HeaderFile +#define _CPPClient_Define_HeaderFile + +extern Standard_CString VClass, + VTICIncludes, + VInherits, + VTICPublicmets, + VTICPublicfriends, + VTICProtectedmets, + VTICProtectedfields, + VTICPrivatemets, + VTICPrivatefriends, + VTICDefines, + VTICInlineIncludes, + VTICUndefines, + VTICPrivatefields, + VTICSuppMethod, + VRetSpec, + VVirtual, + VReturn, + VAnd, + VMethodName, + VArgument, + VMetSpec, + VMethod, + VMBody, + VDName, + VDValue, + VIsInline, + VIsCreateMethod, + VIClass, + VSuffix, + VCxxFile, + VLxxFile, + VInlineMethod, + VoutClass, + VNb, + VValues, + VSupplement, + VTypeMgt, + VMethods, + VAncestors, + VFullPath, + VMethodHeader, + VConstructorHeader; + +extern Handle(TCollection_HAsciiString) CPPClient_InterfaceName; + +Handle(TCollection_HAsciiString)& CPPClient_TransientRootName(); + +void CPPClient_WriteFile(const Handle(EDL_API)& api, + const Handle(TCollection_HAsciiString)& aFileName, + const Standard_CString var); + +void CPPClient_UsedTypes(const Handle(MS_MetaSchema)& aMeta, + const Handle(MS_Common)& aCommon, + const Handle(TColStd_HSequenceOfHAsciiString)& List, + const Handle(TColStd_HSequenceOfHAsciiString)& Incp); + +Handle(TCollection_HAsciiString) CPPClient_BuildType(const Handle(MS_MetaSchema)& aMeta, + const Handle(TCollection_HAsciiString)& aTypeName); + +class Handle(MS_HSequenceOfParam); +Handle(TCollection_HAsciiString) CPPClient_BuildParameterList(const Handle(MS_MetaSchema)& aMeta, + const Handle(MS_HSequenceOfParam)& aSeq, + const Standard_Boolean withDefaultValue); + +void CPPClient_BuildMethod(const Handle(MS_MetaSchema)& aMeta, + const Handle(EDL_API)& api, + const Handle(MS_Method)& m, + const Handle(TCollection_HAsciiString)& methodName, + const Standard_Boolean forDeclaration = Standard_True); + +void CPPClient_ClassTypeMgt(const Handle(MS_MetaSchema)& aMeta, + const Handle(EDL_API)& api, + const Handle(MS_Class)& aClass, + const Standard_CString var); +void CPPClient_Enum(const Handle(MS_MetaSchema)& aMeta, + const Handle(EDL_API)& api, + const Handle(MS_Enum)& anEnum, + const Handle(TColStd_HSequenceOfHAsciiString)& outfile); + +extern Handle(TCollection_HAsciiString) CPPClient_ErrorArgument; + +enum ExtractionType {CPPClient_COMPLETE,CPPClient_INCOMPLETE,CPPClient_SEMICOMPLETE}; +#endif diff --git a/src/CPPClient/CPPClient_Enum.cxx b/src/CPPClient/CPPClient_Enum.cxx new file mode 100755 index 0000000..0886328 --- /dev/null +++ b/src/CPPClient/CPPClient_Enum.cxx @@ -0,0 +1,64 @@ +// CLE +// +// 10/1996 +// +#include + +#include + +#include +#include +#include +#include +#include + +#include + +// Extraction of a transient class (inst or std) +// +void CPPClient_Enum(const Handle(MS_MetaSchema)& aMeta, + 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(); + + i = 1; + + for (; i < EnumVal->Length(); i++) { + result->AssignCat(EnumVal->Value(i)); + result->AssignCat(",\n"); + } + + if (EnumVal->Length() > 0) { + result->AssignCat(EnumVal->Value(i)); + } + + api->AddVariable("%Values",result->ToCString()); + + api->Apply("%outClass","EnumHXX"); + + aFileName = new TCollection_HAsciiString(api->GetVariableValue("%FullPath")); + aFileName->AssignCat(CPPClient_InterfaceName); + aFileName->AssignCat("_"); + aFileName->AssignCat(anEnum->FullName()); + aFileName->AssignCat(".hxx"); + + CPPClient_WriteFile(api,aFileName,"%outClass"); + outfile->Append(aFileName); +} + + + diff --git a/src/CPPClient/CPPClient_General.edl b/src/CPPClient/CPPClient_General.edl new file mode 100755 index 0000000..13f4a97 --- /dev/null +++ b/src/CPPClient/CPPClient_General.edl @@ -0,0 +1,100 @@ +-- File: CPPExt_Template.edl +-- Author: Kernel (CLE) +-- History: Tue Sep 19 17:25:59 1995 Kernel Creation +-- Copyright: Matra Datavision 1995 +-- Purpose: C++ extractor + +@verboseoff; + + +-- ============== +-- misc templates +-- ============== + +@template Include(%IClass,%Suffix) is +$#ifndef _%IClass_HeaderFile +$#include <%IClass.%Suffix> +$#endif +@end; + +@template IncludeNoSafe(%IClass,%Suffix) is +$#include <%IClass.%Suffix> +@end; + +@template Define(%DName,%DValue) is +$#define %DName %DValue +@end; + +@template Undefine(%DName) is +$#undef %DName +@end; + +@template ShortDec(%IClass) is +$class %IClass; +@end; + +-- ============================================== +-- Methods templates +-- ============================================== + +@template ConstructorHeader(%Class,%Arguments) is +$Standard_EXPORT %Class(%Arguments)\^ +@end; + +@template MethodHeader(%Virtual,%RetSpec,%Return,%And,%MethodName,%Arguments,%MetSpec) is +$%Virtual %RetSpec %Return%And %MethodName(%Arguments) %MetSpec\^ +@end; + +@template ExternalConstructorCallAncestorHeader(%Class,%Arguments,%Inherits) is +$%Class::%Class(%Arguments) : %Inherits(__NullFHandle,__NullEngineAdaptor)\^ +@end; + +@template ExternalValueConstructorCallAncestorHeader(%Class,%Arguments,%Inherits) is +$%Class::%Class(%Arguments) : %Inherits(__NullFHandle)\^ +@end; + +@template ExternalConstructorHeader(%Class,%Arguments,%Inherits) is +$%Class::%Class(%Arguments)\^ +@end; + +@template ExternalMethodHeader(%Virtual,%RetSpec,%Return,%And,%MethodName,%Arguments,%MetSpec) is +$%Virtual %RetSpec %Return%And %Class::%MethodName(%Arguments) %MetSpec\^ +@end; + +@template MethodTemplateDec(%Method) is +$%Method; +@end; + +@template InlineMethodTemplateDec(%Method) is +$inline %Method\^ +@end; + +@template MethodTemplateDef(%Method,%MBody) is +$%Method +${ +$ %MBody +$} +$ +@end; + +@template AsyncGetArg(%Method,%WhatEngine,%ReturnBody) is +$%Method +${ +$ %WhatEngine->WaitAndRelease(uid); +$ uid.Method()->GetArgumentAsynchrone(); +$ %ReturnBody +$} +@end; + +@template EmptyDestructorTemplate(%Class) is +$~%Class(); +@end; + +@template FullEmptyHandleDestructorTemplate(%Class) is +$Handle_%Class::~Handle_%Class() {} +@end; + +@template FullEmptyDestructorTemplate(%Class) is +$%Class::~%Class() {} +@end; + diff --git a/src/CPPClient/CPPClient_MPV.cxx b/src/CPPClient/CPPClient_MPV.cxx new file mode 100755 index 0000000..af49069 --- /dev/null +++ b/src/CPPClient/CPPClient_MPV.cxx @@ -0,0 +1,254 @@ +// 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 + +Handle(TCollection_HAsciiString)& CPPClient_MPVRootName(); + +void CPPClient_MethodBuilder(const Handle(MS_MetaSchema)& aMeta, + const Handle(EDL_API)& api, + const Handle(TCollection_HAsciiString)& className, + const Handle(MS_Method)& m, + const Handle(TCollection_HAsciiString)& methodName,const Standard_Boolean); + +void CPPClient_MethodUsedTypes(const Handle(MS_MetaSchema)& aMeta, + const Handle(MS_Method)& aMethod, + const Handle(TColStd_HSequenceOfHAsciiString)& List, + const Handle(TColStd_HSequenceOfHAsciiString)& Incp); + +Standard_Boolean CPPClient_AncestorHaveEmptyConstructor(const Handle(MS_MetaSchema)&, + const Handle(TCollection_HAsciiString)&); + +// Extraction of .cxx for handled object +// +void CPPClient_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; + + // the name must be __ + // + api->AddVariable("%Class",aClass->FullName()->ToCString()); + api->Apply("%Class","BuildTypeName"); + + for (i = 1; i <= inclist->Length(); i++) { + if (!inclist->Value(i)->IsSameString(aClass->FullName())) { + api->AddVariable("%IClass",inclist->Value(i)->ToCString()); + api->Apply("%Includes","Include"); + publics->AssignCat(api->GetVariableValue("%Includes")); + } + } + + 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(); + + + // the name must be __ + // + api->AddVariable("%Class",aClass->FullName()->ToCString()); + api->Apply("%Class","BuildTypeName"); + + api->AddVariable("%RealClass",aClass->FullName()->ToCString()); + + api->Apply("%outClass","ValueClassClientCXX"); + + // we write the .cxx of this class + // + Handle(TCollection_HAsciiString) aFile = new TCollection_HAsciiString(api->GetVariableValue("%FullPath")); + + aFile->AssignCat(CPPClient_InterfaceName); + aFile->AssignCat("_"); + aFile->AssignCat(aClass->FullName()); + aFile->AssignCat("_client.cxx"); + + CPPClient_WriteFile(api,aFile,"%outClass"); + + outfile->Append(aFile); +} + + +// Extraction of a transient class (inst or std) +// +void CPPClient_MPVClass(const Handle(MS_MetaSchema)& aMeta, + const Handle(EDL_API)& api, + const Handle(MS_Class)& aClass, + const Handle(TColStd_HSequenceOfHAsciiString)& outfile, + const 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; + Standard_Boolean mustCallAncestor = Standard_False; + + // we create the inheritance + // + if (theClass->GetInheritsNames()->Length() == 0) { + api->AddVariable("%Inherits",CPPClient_MPVRootName()->ToCString()); + api->AddVariable("%InheritsTrick",""); + } + else { + mustCallAncestor = !CPPClient_AncestorHaveEmptyConstructor(aMeta,theClass->GetInheritsNames()->Value(1)); + api->AddVariable("%Class",theClass->GetInheritsNames()->Value(1)->ToCString()); + api->Apply("%Inherits","BuildTypeName"); + List->Append(api->GetVariableValue("%Inherits")); + api->AddVariable("%InheritsTrick",": %Inherits(*((FrontEnd_FHandle*)NULL))"); + } + + // the name must be __ + // + api->AddVariable("%Class",theClass->FullName()->ToCString()); + api->Apply("%Class","BuildTypeName"); + + if (MustBeComplete == CPPClient_SEMICOMPLETE) { + methods = theMetSeq; + } + else { + methods = theClass->GetMethods(); + } + + for (i = 1; i <= methods->Length() && (MustBeComplete != CPPClient_INCOMPLETE); i++) { + CPPClient_BuildMethod(aMeta,api,methods->Value(i),methods->Value(i)->Name()); + + if (!api->GetVariableValue("%Method")->IsSameString(CPPClient_ErrorArgument)) { + api->Apply(VMethod,"MethodTemplateDec"); + + if ((theClass->Deferred() && methods->Value(i)->IsKind(STANDARD_TYPE(MS_Construc))) + || methods->Value(i)->IsProtected() + || methods->Value(i)->Private()) { + // nothing + } + else { + CPPClient_MethodUsedTypes(aMeta,methods->Value(i),List,incp); + publics->AssignCat(api->GetVariableValue(VMethod)); + CPPClient_MethodBuilder(aMeta,api,aClass->FullName(),methods->Value(i),methods->Value(i)->Name(),mustCallAncestor); + Supplement->Append(api->GetVariableValue(VMethod)); + } + } + } + + api->AddVariable("%Methods",publics->ToCString()); + + publics->Clear(); + + if (MustBeComplete != CPPClient_INCOMPLETE) { + api->AddVariable(VSuffix,"hxx"); + + for (i = 1; i <= List->Length(); i++) { + if (!List->Value(i)->IsSameString(theClass->FullName())) { + api->AddVariable("%IClass",List->Value(i)->ToCString()); + api->Apply("%Includes","Include"); + publics->AssignCat(api->GetVariableValue("%Includes")); + } + } + + + for (i = 1; i <= incp->Length(); i++) { + if (!incp->Value(i)->IsSameString(theClass->FullName())) { + api->AddVariable("%IClass",incp->Value(i)->ToCString()); + api->Apply("%Includes","ShortDec"); + publics->AssignCat(api->GetVariableValue("%Includes")); + } + } + } + + api->AddVariable("%Includes",publics->ToCString()); + + // we create the inheritance + // + if (theClass->GetInheritsNames()->Length() == 0) { + api->AddVariable("%Inherits",CPPClient_MPVRootName()->ToCString()); + } + else { + api->AddVariable("%Class",theClass->GetInheritsNames()->Value(1)->ToCString()); + api->Apply("%Inherits","BuildTypeName"); + } + + // the name must be __ + // + api->AddVariable("%Class",theClass->FullName()->ToCString()); + api->Apply("%Class","BuildTypeName"); + + api->Apply("%outClass","ValueClassClientHXX"); + + // we write the .hxx of this class + // + Handle(TCollection_HAsciiString) aFile = new TCollection_HAsciiString(api->GetVariableValue("%FullPath")); + + aFile->AssignCat(CPPClient_InterfaceName); + aFile->AssignCat("_"); + aFile->AssignCat(theClass->FullName()); + aFile->AssignCat(".hxx"); + + CPPClient_WriteFile(api,aFile,"%outClass"); + + outfile->Append(aFile); + + if (MustBeComplete != CPPClient_INCOMPLETE) { + CPPClient_MPVDerivated(aMeta,api,aClass,outfile,incp,Supplement); + } + } + else { + ErrorMsg << "CPPClient" << "CPPClient_TransientClass - the class is NULL..." << endm; + Standard_NoSuchObject::Raise(); + } +} + diff --git a/src/CPPClient/CPPClient_Package.cxx b/src/CPPClient/CPPClient_Package.cxx new file mode 100755 index 0000000..52ec8c9 --- /dev/null +++ b/src/CPPClient/CPPClient_Package.cxx @@ -0,0 +1,204 @@ +// 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 + +void CPPClient_MethodUsedTypes(const Handle(MS_MetaSchema)& aMeta, + const Handle(MS_Method)& aMethod, + const Handle(TColStd_HSequenceOfHAsciiString)& List, + const Handle(TColStd_HSequenceOfHAsciiString)& Incp); + +void CPPClient_MethodBuilder(const Handle(MS_MetaSchema)& aMeta, + const Handle(EDL_API)& api, + const Handle(TCollection_HAsciiString)& className, + const Handle(MS_Method)& m, + const Handle(TCollection_HAsciiString)& methodName,const Standard_Boolean); + +void CPPClient_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; + + // the name must be _ + // + api->AddVariable("%Class",aPackage->Name()->ToCString()); + api->Apply("%Class","BuildTypeName"); + + for (i = 1; i <= inclist->Length(); i++) { + if (!inclist->Value(i)->IsSameString(aPackage->Name())) { + api->AddVariable("%IClass",inclist->Value(i)->ToCString()); + api->Apply("%Includes","Include"); + publics->AssignCat(api->GetVariableValue("%Includes")); + } + } + + 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(); + + + // the name must be _ + // + api->AddVariable("%Class",aPackage->Name()->ToCString()); + api->Apply("%Class","BuildTypeName"); + + api->Apply("%outClass","PackageClientCXX"); + + // we write the .cxx of this class + // + Handle(TCollection_HAsciiString) aFile = new TCollection_HAsciiString(api->GetVariableValue("%FullPath")); + + aFile->AssignCat(CPPClient_InterfaceName); + aFile->AssignCat("_"); + aFile->AssignCat(aPackage->Name()); + aFile->AssignCat("_client.cxx"); + + CPPClient_WriteFile(api,aFile,"%outClass"); + + outfile->Append(aFile); + +} + + +// Extraction of a package +// +void CPPClient_Package(const Handle(MS_MetaSchema)& aMeta, + const Handle(EDL_API)& api, + const Handle(MS_Package)& aPackage, + const Handle(TColStd_HSequenceOfHAsciiString)& outfile, + const 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; + + + // the name must be _ + // + api->AddVariable("%Class",aPackage->Name()->ToCString()); + api->Apply("%Class","BuildTypeName"); + + if (mustBeComplete == CPPClient_SEMICOMPLETE) { + methods = theMetSeq; + } + else { + methods = aPackage->Methods(); + } + + // extraction of the methods + // + for (i = 1; i <= methods->Length(); i++) { + CPPClient_BuildMethod(aMeta,api,methods->Value(i),methods->Value(i)->Name()); + + if (!api->GetVariableValue("%Method")->IsSameString(CPPClient_ErrorArgument)) { + api->Apply(VMethod,"MethodTemplateDec"); + + CPPClient_MethodUsedTypes(aMeta,methods->Value(i),List,incp); + publics->AssignCat(api->GetVariableValue(VMethod)); + CPPClient_MethodBuilder(aMeta,api,aPackage->Name(),methods->Value(i),methods->Value(i)->Name(),Standard_False); + Supplement->Append(api->GetVariableValue(VMethod)); + } + } + + api->AddVariable("%Methods",publics->ToCString()); + + publics->Clear(); + + api->AddVariable(VSuffix,"hxx"); + + for (i = 1; i <= List->Length(); i++) { + if (!List->Value(i)->IsSameString(aPackage->Name())) { + api->AddVariable("%IClass",List->Value(i)->ToCString()); + 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()); + api->Apply("%Includes","ShortDec"); + publics->AssignCat(api->GetVariableValue("%Includes")); + } + } + + api->AddVariable("%Includes",publics->ToCString()); + + api->Apply(VoutClass,"PackageClientHXX"); + + // we write the .hxx of this class + // + Handle(TCollection_HAsciiString) aFile = new TCollection_HAsciiString(api->GetVariableValue(VFullPath)); + + aFile->AssignCat(CPPClient_InterfaceName); + aFile->AssignCat("_"); + aFile->AssignCat(aPackage->Name()); + aFile->AssignCat(".hxx"); + + CPPClient_WriteFile(api,aFile,VoutClass); + + outfile->Append(aFile); + + CPPClient_PackageDerivated(aMeta,api,aPackage,outfile,incp,Supplement); + } + else { + ErrorMsg << "CPPClient" << "CPPClient_Package - the package is NULL..." << endm; + Standard_NoSuchObject::Raise(); + } +} + diff --git a/src/CPPClient/CPPClient_Template.edl b/src/CPPClient/CPPClient_Template.edl new file mode 100755 index 0000000..da9d868 --- /dev/null +++ b/src/CPPClient/CPPClient_Template.edl @@ -0,0 +1,1122 @@ +-- File: CPPClient_Template.edl +-- Author: Kernel (CLE) +-- History: Tue Dec 19 08:22:43 1995 Kernel Creation +-- Copyright: Matra Datavision 1995 + +@template HandleClient(%Interface,%Class,%Inherits) is +$// C++ Client +$// Copyright (C) 1991,1995 by +$// +$// MATRA DATAVISION, FRANCE +$// +$// This software is furnished in accordance with the terms and conditions +$// of the contract and with the inclusion of the above copyright notice. +$// This software or any other copy thereof may not be provided or otherwise +$// be made available to any other person. No title to an ownership of the +$// software is hereby transferred. +$// +$// At the termination of the contract, the software and all copies of this +$// software must be deleted. +$ +$// +$#ifndef _Handle_%Class_HeaderFile +$#define _Handle_%Class_HeaderFile +$#ifndef _Standard_Macro_HeaderFile +$#include +$#endif +$#ifndef _Handle_%Inherits_HeaderFile +$#include +$#endif +$ +$class Standard_Transient; +$class Handle_Standard_Type; +$class Handle(%Inherits); +$class %Class; +$Standard_EXPORT Handle_Standard_Type& STANDARD_TYPE(%Class); +$ +$#ifndef _Handle_%Inherits_HeaderFile +$#include +$#endif +$class %Class; +$ +$ +$class Handle(%Class) : public Handle(%Inherits) +${ +$ public: +$ Handle(%Class)() : Handle(%Inherits)() +$ { +$ } +$ +$ Handle(%Class)(const Handle(%Class)& aHandle) : Handle(%Inherits)(aHandle) +$ { +$ } +$ +$ Handle(%Class)(const %Class* anItem) : Handle(%Inherits)((%Inherits *)anItem) +$ { +$ } +$ +$ Handle(%Class)& operator=(const Handle(%Class)& aHandle) +$ { +$ Assign(aHandle.Access()); +$ return *this; +$ } +$ +$ Handle(%Class)& operator=(const %Class* anItem) +$ { +$ Assign((Standard_Transient *)anItem); +$ return *this; +$ } +$ +$ %Class* operator->() +$ { +$ return (%Class *)ControlAccess(); +$ } +$ +$ %Class* operator->() const +$ { +$ return (%Class *)ControlAccess(); +$ } +$ +$ Standard_EXPORT ~Handle(%Class)(); +$ Standard_EXPORT static const Handle(%Class) DownCast(const Handle(Standard_Transient)& AnObject); +$}; +$#endif +@end; + +@template BuildTypeName(%Interface,%Class) is +$%Interface_%Class\^ +@end; + +@template TransientRootClientHXX(%Interface) is +$// C++ Client +$// Copyright (C) 1991,1995 by +$// +$// MATRA DATAVISION, FRANCE +$// +$// This software is furnished in accordance with the terms and conditions +$// of the contract and with the inclusion of the above copyright notice. +$// This software or any other copy thereof may not be provided or otherwise +$// be made available to any other person. No title to an ownership of the +$// software is hereby transferred. +$// +$// At the termination of the contract, the software and all copies of this +$// software must be deleted. +$// +$#ifndef _%Interface_Standard_Transient_HeaderFile +$#define _%Interface_Standard_Transient_HeaderFile +$#include +$ +$#ifndef _FrontEnd_EngineAdaptor_HeaderFile +$#include +$#endif +$#ifndef _FrontEnd_HExternRef_HeaderFile +$#include +$#endif +$extern Handle(FrontEnd_EngineAdaptor) __NullEngineAdaptor; +$extern FrontEnd_FHandle __NullFHandle; +$Standard_EXPORT Handle_Standard_Type& %Interface_Standard_Transient_Type_(); +$ +$class %Interface_Standard_Transient: public FrontEnd_HExternRef { +$ +$public: +$ +$ inline %Interface_Standard_Transient(const FrontEnd_FHandle& _aRef, const Handle(FrontEnd_EngineAdaptor)& _anEng) : FrontEnd_HExternRef(_aRef,_anEng) +$ { +$ } +$ +$ const Handle(Standard_Type)& DynamicType() const +$ { +$ return STANDARD_TYPE(%Interface_Standard_Transient) ; +$ } +$ +$ Standard_Boolean IsKind(const Handle(Standard_Type)& AType) const +$ { +$ return (STANDARD_TYPE(%Interface_Standard_Transient) == AType || FrontEnd_HExternRef::IsKind(AType)); +$ } +$}; +$ +$#endif +@end; + +@template TransientRootClientCXX(%Interface) is +$// C++ Client +$// Copyright (C) 1991,1995 by +$// +$// MATRA DATAVISION, FRANCE +$// +$// This software is furnished in accordance with the terms and conditions +$// of the contract and with the inclusion of the above copyright notice. +$// This software or any other copy thereof may not be provided or otherwise +$// be made available to any other person. No title to an ownership of the +$// software is hereby transferred. +$// +$// At the termination of the contract, the software and all copies of this +$// software must be deleted. +$// +$#ifndef _%Interface_Standard_Transient_HeaderFile +$#include <%Interface_Standard_Transient.hxx> +$#endif +$ +$#ifndef _FrontEnd_EngineAdaptor_HeaderFile +$#include +$#endif +$#ifndef _FrontEnd_ExternRef_HeaderFile +$#include +$#endif +$#ifndef _FrontEnd_HExternRef_HeaderFile +$#include +$#endif +$#ifndef _FrontEnd_FHandle_HeaderFile +$#include +$#endif +$#ifndef _FrontEnd_Method_HeaderFile +$#include +$#endif +$#ifndef _FrontEnd_InstanceMet_HeaderFile +$#include +$#endif +$#ifndef _FrontEnd_ClassMet_HeaderFile +$#include +$#endif +$#ifndef _FrontEnd_CreateMet_HeaderFile +$#include +$#endif +$ +$Handle_Standard_Type& %Interface_Standard_Transient_Type_() +${ +$ static Handle_Standard_Type aTypeT = STANDARD_TYPE(Standard_Transient); +$ static Handle_Standard_Type aTypeTs = STANDARD_TYPE(MMgt_TShared); +$ static Handle_Standard_Type aType1 = STANDARD_TYPE(FrontEnd_HExternRef); +$ static Handle_Standard_Transient _Ancestors[]= {aType1,aTypeTs,aTypeT,NULL}; +$ static Handle_Standard_Type _aType = new Standard_Type("%Interface_Standard_Transient", +$ sizeof(%Interface_Standard_Transient), +$ 1, +$ (Standard_Address)_Ancestors, +$ (Standard_Address)NULL); +$ return _aType; +$} +$ +$const Handle(%Interface_Standard_Transient) Handle(%Interface_Standard_Transient)::DownCast(const Handle(Standard_Transient)& AnObject) +${ +$ Handle(%Interface_Standard_Transient) _anOtherObject; +$ +$ if (!AnObject.IsNull()) +$ if (AnObject->IsKind(STANDARD_TYPE(%Interface_Standard_Transient))) { +$ _anOtherObject = Handle(%Interface_Standard_Transient)((Handle(%Interface_Standard_Transient)&)AnObject); +$ } +$ +$ return _anOtherObject ; +$} +$ +$Handle(%Interface_Standard_Transient)::~Handle(%Interface_Standard_Transient)() +${ +$} +@end; + +@template PersistentRootClientHXX(%Interface) is +$// C++ Client +$// Copyright (C) 1991,1995 by +$// +$// MATRA DATAVISION, FRANCE +$// +$// This software is furnished in accordance with the terms and conditions +$// of the contract and with the inclusion of the above copyright notice. +$// This software or any other copy thereof may not be provided or otherwise +$// be made available to any other person. No title to an ownership of the +$// software is hereby transferred. +$// +$// At the termination of the contract, the software and all copies of this +$// software must be deleted. +$// +$#ifndef _%Interface_Standard_Persistent_HeaderFile +$#define _%Interface_Standard_Persistent_HeaderFile +$#include +$ +$#ifndef _FrontEnd_EngineAdaptor_HeaderFile +$#include +$#endif +$#ifndef _FrontEnd_HExternRef_HeaderFile +$#include +$#endif +$#ifndef _%Interface_Standard_Storable_HeaderFile +$#include <%Interface_Standard_Storable.hxx> +$#endif +$ +$extern Handle(FrontEnd_EngineAdaptor) __NullEngineAdaptor; +$extern FrontEnd_FHandle __NullFHandle; +$Standard_EXPORT Handle_Standard_Type& %Interface_Standard_Persistent_Type_(); +$ +$class %Interface_Standard_Persistent: public FrontEnd_HExternRef{ +$ +$public: +$ +$ inline %Interface_Standard_Persistent(const FrontEnd_FHandle& _aRef, const Handle(FrontEnd_EngineAdaptor)& _anEng) +$ : FrontEnd_HExternRef(_aRef,_anEng) +$ { +$ } +$ +$ const Handle(Standard_Type)& DynamicType() const +$ { +$ return STANDARD_TYPE(%Interface_Standard_Persistent) ; +$ } +$ +$ Standard_Boolean IsKind(const Handle(Standard_Type)& AType) const +$ { +$ return (STANDARD_TYPE(%Interface_Standard_Persistent) == AType || FrontEnd_HExternRef::IsKind(AType)); +$ } +$}; +$ +$#endif +@end; + + +@template PersistentRootClientCXX(%Interface) is +$// C++ Client +$// Copyright (C) 1991,1995 by +$// +$// MATRA DATAVISION, FRANCE +$// +$// This software is furnished in accordance with the terms and conditions +$// of the contract and with the inclusion of the above copyright notice. +$// This software or any other copy thereof may not be provided or otherwise +$// be made available to any other person. No title to an ownership of the +$// software is hereby transferred. +$// +$// At the termination of the contract, the software and all copies of this +$// software must be deleted. +$// +$#ifndef _%Interface_Standard_Persistent_HeaderFile +$#include <%Interface_Standard_Persistent.hxx> +$#endif +$#ifndef _FrontEnd_EngineAdaptor_HeaderFile +$#include +$#endif +$#ifndef _FrontEnd_ExternRef_HeaderFile +$#include +$#endif +$#ifndef _FrontEnd_HExternRef_HeaderFile +$#include +$#endif +$#ifndef _FrontEnd_FHandle_HeaderFile +$#include +$#endif +$#ifndef _FrontEnd_Method_HeaderFile +$#include +$#endif +$#ifndef _FrontEnd_InstanceMet_HeaderFile +$#include +$#endif +$#ifndef _FrontEnd_ClassMet_HeaderFile +$#include +$#endif +$#ifndef _FrontEnd_CreateMet_HeaderFile +$#include +$#endif +$ +$Handle_Standard_Type& %Interface_Standard_Persistent_Type_() +${ +$ static Handle_Standard_Type aType1 = STANDARD_TYPE(%Interface_Standard_Storable); +$ static Handle_Standard_Type aType2 = STANDARD_TYPE(FrontEnd_HExternRef); +$ static Handle_Standard_Type aTypeT = STANDARD_TYPE(Standard_Transient); +$ static Handle_Standard_Type aTypeTs = STANDARD_TYPE(MMgt_TShared); +$ static Handle_Standard_Transient _Ancestors[]= {aType1,aType2,aTypeTs,aTypeT,NULL}; +$ static Handle_Standard_Type _aType = new Standard_Type("%Interface_Standard_Persistent", +$ sizeof(%Interface_Standard_Persistent), +$ 1, +$ (Standard_Address)_Ancestors, +$ (Standard_Address)NULL); +$ +$ return _aType; +$} +$ +$const Handle(%Interface_Standard_Persistent) Handle(%Interface_Standard_Persistent)::DownCast(const Handle(Standard_Transient)& AnObject) +${ +$ Handle(%Interface_Standard_Persistent) _anOtherObject; +$ +$ if (!AnObject.IsNull()) +$ if (AnObject->IsKind(STANDARD_TYPE(%Interface_Standard_Persistent))) { +$ _anOtherObject = Handle(%Interface_Standard_Persistent)((Handle(%Interface_Standard_Persistent)&)AnObject); +$ } +$ +$ return _anOtherObject ; +$} +$ +$Handle(%Interface_Standard_Persistent)::~Handle(%Interface_Standard_Persistent)() +${ +$} +$ +@end; + +@template StorableRootClientHXX(%Interface) is +$// C++ Client +$// Copyright (C) 1991,1995 by +$// +$// MATRA DATAVISION, FRANCE +$// +$// This software is furnished in accordance with the terms and conditions +$// of the contract and with the inclusion of the above copyright notice. +$// This software or any other copy thereof may not be provided or otherwise +$// be made available to any other person. No title to an ownership of the +$// software is hereby transferred. +$// +$// At the termination of the contract, the software and all copies of this +$// software must be deleted. +$// +$#ifndef _FrontEnd_EngineAdaptor_HeaderFile +$#include +$#endif +$#ifndef _FrontEnd_ExternRef_HeaderFile +$#include +$#endif +$#ifndef _Standard_Integer_HeaderFile +$#include +$#endif +$#ifndef _FrontEnd_FHandle_HeaderFile +$#include +$#endif +$#ifndef _%Interface_Standard_Storable_HeaderFile +$#define _%Interface_Standard_Storable_HeaderFile +$Standard_EXPORT Handle_Standard_Type& %Interface_Standard_Storable_Type_(); +$extern Handle(FrontEnd_EngineAdaptor) __NullEngineAdaptor; +$extern FrontEnd_FHandle __NullFHandle; +$ +$class %Interface_Standard_Storable: public FrontEnd_ExternRef +${ +$ +$ public: +$ Standard_EXPORT virtual Standard_Integer HashCode(const Standard_Integer Upper) const ; +$ Standard_EXPORT Standard_Boolean IsEqual(const %Interface_Standard_Storable& Other) const ; +$ Standard_EXPORT Standard_Boolean IsSimilar(const %Interface_Standard_Storable& Other) const ; +$ %Interface_Standard_Storable(const FrontEnd_FHandle& ) {} +$ inline %Interface_Standard_Storable(const FrontEnd_FHandle& _aRef, const Handle(FrontEnd_EngineAdaptor)& _anEng) +$ : FrontEnd_ExternRef(_aRef,_anEng) +$ { +$ } +$}; +$ +$#endif +@end; + +@template StorableRootClientCXX(%Interface) is +$// C++ Client +$// Copyright (C) 1991,1995 by +$// +$// MATRA DATAVISION, FRANCE +$// +$// This software is furnished in accordance with the terms and conditions +$// of the contract and with the inclusion of the above copyright notice. +$// This software or any other copy thereof may not be provided or otherwise +$// be made available to any other person. No title to an ownership of the +$// software is hereby transferred. +$// +$// At the termination of the contract, the software and all copies of this +$// software must be deleted. +$// +$#ifndef _%Interface_Standard_Storable_HeaderFile +$#include <%Interface_Standard_Storable.hxx> +$#endif +$#ifndef _FrontEnd_EngineAdaptor_HeaderFile +$#include +$#endif +$#ifndef _FrontEnd_ExternRef_HeaderFile +$#include +$#endif +$#ifndef _FrontEnd_HExternRef_HeaderFile +$#include +$#endif +$#ifndef _FrontEnd_FHandle_HeaderFile +$#include +$#endif +$#ifndef _FrontEnd_Method_HeaderFile +$#include +$#endif +$#ifndef _FrontEnd_InstanceMet_HeaderFile +$#include +$#endif +$#ifndef _FrontEnd_ClassMet_HeaderFile +$#include +$#endif +$#ifndef _FrontEnd_CreateMet_HeaderFile +$#include +$#endif +$ +$Handle_Standard_Type& %Interface_Standard_Storable_Type_() +${ +$ static Handle_Standard_Type aType2 = STANDARD_TYPE(FrontEnd_HExternRef); +$ static Handle_Standard_Type aTypeT = STANDARD_TYPE(Standard_Transient); +$ static Handle_Standard_Type aTypeTs = STANDARD_TYPE(MMgt_TShared); +$ static Handle_Standard_Transient _Ancestors[]= {aType2,aTypeTs,aTypeT,NULL}; +$ static Handle_Standard_Type _aType = new Standard_Type("%Interface_Standard_Storable", +$ sizeof(%Interface_Standard_Storable), +$ 1, +$ (Standard_Address)_Ancestors, +$ (Standard_Address)NULL); +$ +$ return _aType; +$} +$ +$Standard_Integer %Interface_Standard_Storable::HashCode(const Standard_Integer Upper) const +${ +$ FrontEnd_InstanceMet _aMethod ("HashCode",Reference(),Engine()); +$ _aMethod.Arg(Upper); +$ _aMethod.Execute(); +$ return (_aMethod.ReturnInteger()); +$} +$ +$ +$Standard_Boolean %Interface_Standard_Storable::IsEqual(const %Interface_Standard_Storable& Other) const +${ +$ FrontEnd_InstanceMet _aMethod ("IsEqual",Reference(),Engine()); +$ _aMethod.Arg(Other); +$ _aMethod.Execute(); +$ return (_aMethod.ReturnBoolean()); +$} +$ +$Standard_Boolean %Interface_Standard_Storable::IsSimilar(const %Interface_Standard_Storable& Other) const +${ +$ FrontEnd_InstanceMet _aMethod ("IsSimilar",Reference(),Engine()); +$ _aMethod.Arg(Other); +$ _aMethod.Execute(); +$ return (_aMethod.ReturnBoolean()); +$} +@end; + +@template MemoryRootClientHXX(%Interface) is +$// C++ Client (%Interface_MMgt_TShared) +$// Copyright (C) 1991,1995 by +$// +$// MATRA DATAVISION, FRANCE +$// +$// This software is furnished in accordance with the terms and conditions +$// of the contract and with the inclusion of the above copyright notice. +$// This software or any other copy thereof may not be provided or otherwise +$// be made available to any other person. No title to an ownership of the +$// software is hereby transferred. +$// +$// At the termination of the contract, the software and all copies of this +$// software must be deleted. +$// +$#ifndef _%Interface_MMgt_TShared_HeaderFile +$#define _%Interface_MMgt_TShared_HeaderFile +$#include +$ +$#ifndef _FrontEnd_EngineAdaptor_HeaderFile +$#include +$#endif +$ +$#ifndef _%Interface_Standard_Transient_HeaderFile +$#include <%Interface_Standard_Transient.hxx> +$#endif +$ +$extern Handle(FrontEnd_EngineAdaptor) __NullEngineAdaptor; +$extern FrontEnd_FHandle __NullFHandle; +$class Handle_Standard_Type; +$Standard_EXPORT Handle_Standard_Type& %Interface_MMgt_TShared_Type_(); +$ +$#ifndef _%Interface_Standard_Transient_HeaderFile +$#include <%Interface_Standard_Transient.hxx> +$#endif +$#ifndef _Standard_Address_HeaderFile +$#include +$#endif +$#ifndef _Standard_Integer_HeaderFile +$#include +$#endif +$ +$Standard_EXPORT Handle_Standard_Type& %Interface_MMgt_TShared_Type_(); +$ +$class %Interface_MMgt_TShared: public %Interface_Standard_Transient { +$ +$public: +$ inline %Interface_MMgt_TShared(const FrontEnd_FHandle& _aRef, const Handle(FrontEnd_EngineAdaptor)& _anEng) +$ : %Interface_Standard_Transient(_aRef,_anEng) +$ { +$ } +$ +$ const Handle(Standard_Type)& DynamicType() const +$ { +$ return STANDARD_TYPE(%Interface_MMgt_TShared) ; +$ } +$ +$ Standard_Boolean IsKind(const Handle(Standard_Type)& AType) const +$ { +$ return (STANDARD_TYPE(%Interface_MMgt_TShared) == AType || %Interface_Standard_Transient::IsKind(AType)); +$ } +$}; +$ +$#endif +@end; + +@template MemoryRootClientCXX(%Interface) is +$// Copyright (C) 1991,1995 by +$// +$// MATRA DATAVISION, FRANCE +$// +$// This software is furnished in accordance with the terms and conditions +$// of the contract and with the inclusion of the above copyright notice. +$// This software or any other copy thereof may not be provided or otherwise +$// be made available to any other person. No title to an ownership of the +$// software is hereby transferred. +$// +$// At the termination of the contract, the software and all copies of this +$// software must be deleted. +$ +$#ifndef _%Interface_MMgt_TShared_HeaderFile +$#include <%Interface_MMgt_TShared.hxx> +$#endif +$#ifndef _FrontEnd_EngineAdaptor_HeaderFile +$#include +$#endif +$#ifndef _FrontEnd_ExternRef_HeaderFile +$#include +$#endif +$#ifndef _FrontEnd_HExternRef_HeaderFile +$#include +$#endif +$#ifndef _FrontEnd_FHandle_HeaderFile +$#include +$#endif +$#ifndef _FrontEnd_Method_HeaderFile +$#include +$#endif +$#ifndef _FrontEnd_InstanceMet_HeaderFile +$#include +$#endif +$#ifndef _FrontEnd_ClassMet_HeaderFile +$#include +$#endif +$#ifndef _FrontEnd_CreateMet_HeaderFile +$#include +$#endif +$ +$ +$ +$Handle_Standard_Type& %Interface_MMgt_TShared_Type_() +${ +$ static Handle_Standard_Type aType1 = STANDARD_TYPE(%Interface_Standard_Transient); +$ static Handle_Standard_Type aType2 = STANDARD_TYPE(FrontEnd_HExternRef); +$ if ( aType1.IsNull()) aType1 = STANDARD_TYPE(%Interface_Standard_Transient); +$ +$ +$ static Handle_Standard_Transient _Ancestors[]= {aType1,aType2,NULL}; +$ static Handle_Standard_Type _aType = new Standard_Type("%Interface_MMgt_TShared", +$ sizeof(%Interface_MMgt_TShared), +$ 1, +$ (Standard_Address)_Ancestors, +$ (Standard_Address)NULL); +$ +$ return _aType; +$} +$ +$ +$const Handle(%Interface_MMgt_TShared) Handle(%Interface_MMgt_TShared)::DownCast(const Handle(Standard_Transient)& AnObject) +${ +$ Handle(%Interface_MMgt_TShared) _anOtherObject; +$ +$ if (!AnObject.IsNull()) +$ if (AnObject->IsKind(STANDARD_TYPE(%Interface_MMgt_TShared))) { +$ _anOtherObject = Handle(%Interface_MMgt_TShared)((Handle(%Interface_MMgt_TShared)&)AnObject); +$ } +$ +$ return _anOtherObject; +$} +$ +$Handle(%Interface_MMgt_TShared)::~Handle(%Interface_MMgt_TShared)(){} +@end; + +@template RefClassClientHXX(%Class,%Inherits,%Includes,%Methods) is +$// C++ Client (%Class) +$// Copyright (C) 1991,1995 by +$// +$// MATRA DATAVISION, FRANCE +$// +$// This software is furnished in accordance with the terms and conditions +$// of the contract and with the inclusion of the above copyright notice. +$// This software or any other copy thereof may not be provided or otherwise +$// be made available to any other person. No title to an ownership of the +$// software is hereby transferred. +$// +$// At the termination of the contract, the software and all copies of this +$// software must be deleted. +$// +$#ifndef _%Class_HeaderFile +$#define _%Class_HeaderFile +$#include +$ +$#ifndef _FrontEnd_EngineAdaptor_HeaderFile +$#include +$#endif +$#ifndef _FrontEnd_MID_HeaderFile +$#include +$#endif +$#ifndef _%Inherits_HeaderFile +$#include <%Inherits.hxx> +$#endif +$ +$class Handle_Standard_Type; +$Standard_EXPORT Handle_Standard_Type& %Class_Type_(); +$extern Handle(FrontEnd_EngineAdaptor) __NullEngineAdaptor; +$extern FrontEnd_FHandle __NullFHandle; +$ +$%Includes +$ +$class %Class: public %Inherits { +$ +$public: +$ %Methods +$ +$ inline %Class(const FrontEnd_FHandle& _aRef, const Handle(FrontEnd_EngineAdaptor)& _anEng) +$ : %Inherits(_aRef,_anEng) +$ { +$ } +$ +$ const Handle(Standard_Type)& DynamicType() const +$ { +$ return STANDARD_TYPE(%Class); +$ } +$ +$ Standard_Boolean IsKind(const Handle(Standard_Type)& AType) const +$ { +$ return (STANDARD_TYPE(%Class) == AType || %Inherits::IsKind(AType)); +$ } +$}; +$ +$#endif +@end; + +@template RefClassClientCXX(%Class,%Inherits,%Methods,%Includes,%TypeMgt) is +$// Copyright (C) 1991,1995 by +$// +$// MATRA DATAVISION, FRANCE +$// +$// This software is furnished in accordance with the terms and conditions +$// of the contract and with the inclusion of the above copyright notice. +$// This software or any other copy thereof may not be provided or otherwise +$// be made available to any other person. No title to an ownership of the +$// software is hereby transferred. +$// +$// At the termination of the contract, the software and all copies of this +$// software must be deleted. +$ +$#ifndef _%Class_HeaderFile +$#include <%Class.hxx> +$#endif +$#ifndef _FrontEnd_EngineAdaptor_HeaderFile +$#include +$#endif +$#ifndef _FrontEnd_ExternRef_HeaderFile +$#include +$#endif +$#ifndef _FrontEnd_HExternRef_HeaderFile +$#include +$#endif +$#ifndef _FrontEnd_FHandle_HeaderFile +$#include +$#endif +$#ifndef _FrontEnd_Method_HeaderFile +$#include +$#endif +$#ifndef _FrontEnd_InstanceMet_HeaderFile +$#include +$#endif +$#ifndef _FrontEnd_ClassMet_HeaderFile +$#include +$#endif +$#ifndef _FrontEnd_CreateMet_HeaderFile +$#include +$#endif +$ +$%Includes +$ +$%TypeMgt +$ +$const Handle(%Class) Handle(%Class)::DownCast(const Handle(Standard_Transient)& AnObject) +${ +$ Handle(%Class) _anOtherObject; +$ +$ if (!AnObject.IsNull()) +$ if (AnObject->IsKind(STANDARD_TYPE(%Class))) { +$ _anOtherObject = Handle(%Class)((Handle(%Class)&)AnObject); +$ } +$ +$ return _anOtherObject; +$} +$ +$Handle(%Class)::~Handle(%Class)(){} +$ +$%Methods +@end; + +@template ValueClassClientHXX(%InheritsTrick,%Class,%Inherits,%Includes,%Methods) is +$// C++ Client (%Class) +$// Copyright (C) 1991,1995 by +$// +$// MATRA DATAVISION, FRANCE +$// +$// This software is furnished in accordance with the terms and conditions +$// of the contract and with the inclusion of the above copyright notice. +$// This software or any other copy thereof may not be provided or otherwise +$// be made available to any other person. No title to an ownership of the +$// software is hereby transferred. +$// +$// At the termination of the contract, the software and all copies of this +$// software must be deleted. +$ +$// +$#ifndef _%Class_HeaderFile +$#define _%Class_HeaderFile +$#ifndef _FrontEnd_EngineAdaptor_HeaderFile +$#include +$#endif +$#ifndef _%Inherits_HeaderFile +$#include <%Inherits.hxx> +$#endif +$#ifndef _FrontEnd_MID_HeaderFile +$#include +$#endif +$extern Handle(FrontEnd_EngineAdaptor) __NullEngineAdaptor; +$extern FrontEnd_FHandle __NullFHandle; +$%Includes +$ +$class %Class: public %Inherits { +$ +$public: +$ %Methods +$ +$ inline %Class(const FrontEnd_FHandle&) %InheritsTrick {} +$ inline %Class(const FrontEnd_FHandle& _aRef, const Handle(FrontEnd_EngineAdaptor)& _anEng) +$ : %Inherits(_aRef,_anEng) +$ { +$ } +$}; +$ +$#endif +@end; + +@template ValueClassClientCXX(%Class,%Methods,%Includes) is +$// Copyright (C) 1991,1995 by +$// +$// MATRA DATAVISION, FRANCE +$// +$// This software is furnished in accordance with the terms and conditions +$// of the contract and with the inclusion of the above copyright notice. +$// This software or any other copy thereof may not be provided or otherwise +$// be made available to any other person. No title to an ownership of the +$// software is hereby transferred. +$// +$// At the termination of the contract, the software and all copies of this +$// software must be deleted. +$ +$#ifndef _%Class_HeaderFile +$#include <%Class.hxx> +$#endif +$#ifndef _FrontEnd_EngineAdaptor_HeaderFile +$#include +$#endif +$#ifndef _FrontEnd_ExternRef_HeaderFile +$#include +$#endif +$#ifndef _FrontEnd_HExternRef_HeaderFile +$#include +$#endif +$#ifndef _FrontEnd_FHandle_HeaderFile +$#include +$#endif +$#ifndef _FrontEnd_Method_HeaderFile +$#include +$#endif +$#ifndef _FrontEnd_InstanceMet_HeaderFile +$#include +$#endif +$#ifndef _FrontEnd_ClassMet_HeaderFile +$#include +$#endif +$#ifndef _FrontEnd_CreateMet_HeaderFile +$#include +$#endif +$ +$%Includes +$ +$%Methods +@end; + +@template PackageClientHXX(%Class,%Includes,%Methods) is +$// C++ Client (%Class) +$// Copyright (C) 1991,1995 by +$// +$// MATRA DATAVISION, FRANCE +$// +$// This software is furnished in accordance with the terms and conditions +$// of the contract and with the inclusion of the above copyright notice. +$// This software or any other copy thereof may not be provided or otherwise +$// be made available to any other person. No title to an ownership of the +$// software is hereby transferred. +$// +$// At the termination of the contract, the software and all copies of this +$// software must be deleted. +$// +$#ifndef _%Class_HeaderFile +$#define _%Class_HeaderFile +$#ifndef _FrontEnd_EngineAdaptor_HeaderFile +$#include +$#endif +$#ifndef _FrontEnd_MID_HeaderFile +$#include +$#endif +$extern Handle(FrontEnd_EngineAdaptor) __NullEngineAdaptor; +$%Includes +$ +$class %Class { +$ +$public: +$ %Methods +$}; +$ +$#endif +@end; + +@template PackageClientCXX(%Class,%Methods,%Includes) is +$// Copyright (C) 1991,1995 by +$// +$// MATRA DATAVISION, FRANCE +$// +$// This software is furnished in accordance with the terms and conditions +$// of the contract and with the inclusion of the above copyright notice. +$// This software or any other copy thereof may not be provided or otherwise +$// be made available to any other person. No title to an ownership of the +$// software is hereby transferred. +$// +$// At the termination of the contract, the software and all copies of this +$// software must be deleted. +$ +$#ifndef _%Class_HeaderFile +$#include <%Class.hxx> +$#endif +$#ifndef _FrontEnd_EngineAdaptor_HeaderFile +$#include +$#endif +$#ifndef _FrontEnd_ExternRef_HeaderFile +$#include +$#endif +$#ifndef _FrontEnd_HExternRef_HeaderFile +$#include +$#endif +$#ifndef _FrontEnd_FHandle_HeaderFile +$#include +$#endif +$#ifndef _FrontEnd_Method_HeaderFile +$#include +$#endif +$#ifndef _FrontEnd_PackageMet_HeaderFile +$#include +$#endif +$ +$%Includes +$ +$%Methods +@end; + +@template EnumHXX(%Class,%Values) is +$// C++ Client (%Class) +$// Copyright (C) 1991,1995 by +$// +$// MATRA DATAVISION, FRANCE +$// +$// This software is furnished in accordance with the terms and conditions +$// of the contract and with the inclusion of the above copyright notice. +$// This software or any other copy thereof may not be provided or otherwise +$// be made available to any other person. No title to an ownership of the +$// software is hereby transferred. +$// +$// At the termination of the contract, the software and all copies of this +$// software must be deleted. +$// +$#ifndef _%Class_HeaderFile +$#define _%Class_HeaderFile +$ +$enum %Class { +$ %Values +$}; +$ +$ +$#ifndef _Standard_PrimitiveTypes_HeaderFile +$#include +$#endif +$ +$#endif +@end; + +-- method header + +@template ConstructorClientDec(%Arguments) is +$%Argumentsconst Handle(FrontEnd_EngineAdaptor)& _aCurrent = FrontEnd_EngineAdaptor_Current\^ +@end; + +@template ConstructorClientDef(%Arguments) is +$%Argumentsconst Handle(FrontEnd_EngineAdaptor)& _aCurrent\^ +@end; + +@template AsyncClientDec(%Arguments) is +$%ArgumentsFrontEnd_MID& uid,const Handle(FrontEnd_EngineAdaptor)& _aCurrent = FrontEnd_EngineAdaptor_Current\^ +@end; + +@template AsyncClientDef(%Arguments) is +$%ArgumentsFrontEnd_MID& uid,const Handle(FrontEnd_EngineAdaptor)& _aCurrent\^ +@end; + +@template CreateMethodDec(%MethodName) is +$ FrontEnd_CreateMet _aMethod ("%MethodName",_aCurrent); +@end; + +@template InstMethodDec(%MethodName) is +$ FrontEnd_InstanceMet _aMethod ("%MethodName",Reference(),Engine()); +@end; + +@template ClassMethodDec(%MethodName,%ClassName) is +$ FrontEnd_ClassMet _aMethod ("%MethodName","%ClassName",_aCurrent); +@end; + +@template PackMethodDec(%MethodName,%ClassName) is +$ FrontEnd_PackageMet _aMethod("%MethodName","%ClassName",_aCurrent); +@end; + +@template AsyncInstMethodDec(%MethodName) is +$ FrontEnd_InstanceMet* _aMethod = new FrontEnd_InstanceMet("%MethodName",Reference(),Engine()); +$ FrontEnd_MID ___uid(_aMethod); +$ uid.Assign(___uid); +@end; + +@template AsyncClassMethodDec(%MethodName,%ClassName) is +$ FrontEnd_ClassMet* _aMethod = new FrontEnd_ClassMet("%MethodName","%ClassName",_aCurrent); +$ FrontEnd_MID ___uid(_aMethod); +$ uid.Assign(___uid); +@end; + +@template AsyncPackMethodDec(%MethodName,%ClassName) is +$ FrontEnd_PackageMet* _aMethod = new FrontEnd_PackageMet("%MethodName","%ClassName",_aCurrent); +$ FrontEnd_MID ___uid(_aMethod); +$ uid.Assign(___uid); +@end; + +@template AsyncMethodArg(%ArgName) is +$ _aMethod->Arg(%ArgName); +@end; + +@template AsyncMethodArgOut(%ArgName) is +$ _aMethod->ArgOut(%ArgName); +@end; + +@template MethodArg(%ArgName) is +$ _aMethod.Arg(%ArgName); +@end; + +@template MethodArgOut(%ArgName) is +$ _aMethod.ArgOut(%ArgName); +@end; + +-- return type + +@template CreateMethodReturnHandle() is +$ FrontEnd_HExternRef::Associated(_aMethod.ReturnFHandle(),_aCurrent); +@end; + +@template CreateMethodReturnValue() is +$ FrontEnd_ExternRef::Associated(_aMethod.ReturnFHandle(),_aCurrent); +@end; + +@template MethodReturnPrim(%PrimName) is +$ return (_aMethod.Return%PrimName()); +@end; + +@template MethodReturnEnum(%PrimName) is +$ return ((%PrimName)_aMethod.ReturnInteger()); +@end; + +@template MethodReturnHandle(%PrimName) is +$ Handle(%PrimName) _res = new %PrimName(_aMethod.ReturnFHandle(),Engine()); +$ return _res; +@end; + +@template MethodReturnValue(%PrimName) is +$ return (%PrimName(_aMethod.ReturnFHandle(),Engine())); +@end; + +@template StaticMethodReturnHandle(%PrimName) is +$ Handle(%PrimName) _res = new %PrimName(_aMethod.ReturnFHandle(),_aCurrent); +$ return _res; +@end; + +@template StaticMethodReturnValue(%PrimName) is +$ return (%PrimName(_aMethod.ReturnFHandle(),_aCurrent)); +@end; + +-- return type async +@template AsyncMethodReturnVoid(%PrimName) is +$ delete uid.Method(); +@end; + +@template AsyncMethodReturnPrim(%PrimName) is +$ Standard_%PrimName _res = uid.Method()->Return%PrimName(); +$ delete uid.Method(); +$ return _res; +@end; + +@template AsyncMethodReturnEnum(%PrimName) is +$ Standard_Integer _res = (%PrimName)uid.Method()->ReturnInteger(); +$ delete uid.Method(); +$ return _res; +@end; + +@template AsyncMethodReturnHandle(%PrimName) is +$ Handle(%PrimName) _res = new %PrimName(uid.Method()->ReturnFHandle(),Engine()); +$ delete uid.Method(); +$ return _res; +@end; + +@template AsyncMethodReturnValue(%PrimName) is +$ %PrimName _res = %PrimName(uid.Method()->ReturnFHandle(),Engine()); +$ delete uid.Method(); +$ return _res; +@end; + +@template AsyncStaticMethodReturnHandle(%PrimName) is +$ Handle(%PrimName) _res = new %PrimName(uid.Method()->ReturnFHandle(),_aCurrent); +$ delete uid.Method(); +$ return _res; +@end; + +@template AsyncStaticMethodReturnValue(%PrimName) is +$ %PrimName _res = %PrimName(uid.Method()->ReturnFHandle(),_aCurrent); +$ delete uid.Method(); +$ return _res; +@end; + +-- type management : BEGIN + +@template TypeMgtAncestorType(%Nb) is +$aType%Nb\^ +@end; + +@template TypeMgtAncestor(%Nb,%Ancestors) is +$ static Handle_Standard_Type %Nb = STANDARD_TYPE(%Ancestors); +$ if ( %Nb.IsNull()) %Nb = STANDARD_TYPE(%Ancestors); +@end; + +@template TypeMgt(%TMgtClass,%TMgtInherits,%Ancestors) is +$Handle_Standard_Type& %TMgtClass_Type_() +${ +$ %TMgtInherits +$ static Handle_Standard_Type aTypeT = STANDARD_TYPE(Standard_Transient); +$ static Handle_Standard_Type aTypeTs = STANDARD_TYPE(MMgt_TShared); +$ static Handle_Standard_Type aTypeR = STANDARD_TYPE(FrontEnd_HExternRef); +$ static Handle_Standard_Transient _Ancestors[]= {%Ancestors aTypeR,aTypeTs,aTypeT,NULL}; +$ static Handle_Standard_Type _aType = new Standard_Type("%TMgtClass", +$ sizeof(%TMgtClass), +$ 1, +$ (Standard_Address)_Ancestors, +$ (Standard_Address)NULL); +$ +$ return _aType; +$} +$ +@end; diff --git a/src/CPPClient/CPPClient_Transient.cxx b/src/CPPClient/CPPClient_Transient.cxx new file mode 100755 index 0000000..b6b3888 --- /dev/null +++ b/src/CPPClient/CPPClient_Transient.cxx @@ -0,0 +1,298 @@ +// 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 + +void CPPClient_MethodBuilder(const Handle(MS_MetaSchema)& aMeta, + const Handle(EDL_API)& api, + const Handle(TCollection_HAsciiString)& className, + const Handle(MS_Method)& m, + const Handle(TCollection_HAsciiString)& methodName,const Standard_Boolean); + +void CPPClient_MethodUsedTypes(const Handle(MS_MetaSchema)& aMeta, + const Handle(MS_Method)& aMethod, + const Handle(TColStd_HSequenceOfHAsciiString)& List, + const Handle(TColStd_HSequenceOfHAsciiString)& Incp); + +Standard_Boolean CPPClient_AncestorHaveEmptyConstructor(const Handle(MS_MetaSchema)&, + const Handle(TCollection_HAsciiString)&); + +// Extraction of a transient handle +// +void CPPClient_TransientHandle(const Handle(EDL_API)& api, + const Handle(TCollection_HAsciiString)& aClass, + const Handle(TCollection_HAsciiString)& aMother, + const Handle(TCollection_HAsciiString)& aFileName) +{ + // we create the handle... + // + if (aClass->IsSameString(MS::GetTransientRootName()) || + aClass->IsSameString(MS::GetPersistentRootName())) { + api->AddVariable("%Inherits",CPPClient_TransientRootName()->ToCString()); + } + else { + api->AddVariable(VClass,aMother->ToCString()); + api->Apply("%Inherits","BuildTypeName"); + } + + api->AddVariable(VClass,aClass->ToCString()); + api->Apply("%Class","BuildTypeName"); + api->Apply("%HTHandle","HandleClient"); + + // ...now we write the result + // + api->OpenFile("HTFile",aFileName->ToCString()); + api->WriteFile("HTFile","%HTHandle"); + api->CloseFile("HTFile"); +} + +// Extraction of .cxx for handled object +// +void CPPClient_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 ExtractionType MustBeComplete) +{ + Handle(TCollection_HAsciiString) publics = new TCollection_HAsciiString; + Standard_Integer i; + + // the name must be __ + // + api->AddVariable("%Class",aClass->FullName()->ToCString()); + api->Apply("%Class","BuildTypeName"); + + if (MustBeComplete != CPPClient_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","Include"); + publics->AssignCat(api->GetVariableValue("%Includes")); + } + } + } + + api->AddVariable("%Includes",publics->ToCString()); + publics->Clear(); + + if (MustBeComplete != CPPClient_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()) || + aClass->FullName()->IsSameString(MS::GetPersistentRootName())) { + api->AddVariable("%Inherits",CPPClient_TransientRootName()->ToCString()); + } + else { + api->AddVariable("%Class",aClass->GetInheritsNames()->Value(1)->ToCString()); + api->Apply("%Inherits","BuildTypeName"); + } + + // the name must be __ + // + api->AddVariable("%Class",aClass->FullName()->ToCString()); + api->Apply("%Class","BuildTypeName"); + + api->AddVariable("%RealClass",aClass->FullName()->ToCString()); + + CPPClient_ClassTypeMgt(aMeta,api,aClass,"%TypeMgt"); + + api->Apply("%outClass","RefClassClientCXX"); + + // we write the .cxx of this class + // + Handle(TCollection_HAsciiString) aFile = new TCollection_HAsciiString(api->GetVariableValue("%FullPath")); + + aFile->AssignCat(CPPClient_InterfaceName); + aFile->AssignCat("_"); + aFile->AssignCat(aClass->FullName()); + aFile->AssignCat("_client.cxx"); + + CPPClient_WriteFile(api,aFile,"%outClass"); + + outfile->Append(aFile); +} + + +// Extraction of a transient class (inst or std) +// +void CPPClient_TransientClass(const Handle(MS_MetaSchema)& aMeta, + const Handle(EDL_API)& api, + const Handle(MS_Class)& aClass, + const Handle(TColStd_HSequenceOfHAsciiString)& outfile, + const 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; + Standard_Boolean mustCallAncestor = Standard_False; + + // we create the inheritance + // + if (theClass->FullName()->IsSameString(MS::GetTransientRootName()) || + theClass->FullName()->IsSameString(MS::GetPersistentRootName())) { + api->AddVariable("%Inherits",CPPClient_TransientRootName()->ToCString()); + } + else { + api->AddVariable("%Class",theClass->GetInheritsNames()->Value(1)->ToCString()); + mustCallAncestor = !CPPClient_AncestorHaveEmptyConstructor(aMeta,theClass->GetInheritsNames()->Value(1)); + api->Apply("%Inherits","BuildTypeName"); + } + + List->Append(api->GetVariableValue("%Inherits")); + + // the name must be __ + // + api->AddVariable("%Class",theClass->FullName()->ToCString()); + api->Apply("%Class","BuildTypeName"); + + if (MustBeComplete == CPPClient_SEMICOMPLETE) { + methods = theMetSeq; + } + else { + methods = theClass->GetMethods(); + } + + for (i = 1; i <= methods->Length() && (MustBeComplete != CPPClient_INCOMPLETE); i++) { + CPPClient_BuildMethod(aMeta,api,methods->Value(i),methods->Value(i)->Name()); + + if (!api->GetVariableValue("%Method")->IsSameString(CPPClient_ErrorArgument)) { + api->Apply(VMethod,"MethodTemplateDec"); + + if ((theClass->Deferred() && methods->Value(i)->IsKind(STANDARD_TYPE(MS_Construc))) + || methods->Value(i)->IsProtected() + || methods->Value(i)->Private()) { + // nothing + } + else { + CPPClient_MethodUsedTypes(aMeta,methods->Value(i),List,incp); + publics->AssignCat(api->GetVariableValue(VMethod)); + CPPClient_MethodBuilder(aMeta,api,aClass->FullName(),methods->Value(i),methods->Value(i)->Name(),mustCallAncestor); + Supplement->Append(api->GetVariableValue(VMethod)); + } + } + } + + api->AddVariable("%Methods",publics->ToCString()); + + publics->Clear(); + + if (MustBeComplete != CPPClient_INCOMPLETE) { + api->AddVariable(VSuffix,"hxx"); + + for (i = 1; i <= List->Length(); i++) { + if (!List->Value(i)->IsSameString(theClass->FullName())) { + api->AddVariable("%IClass",List->Value(i)->ToCString()); + api->Apply("%Includes","Include"); + publics->AssignCat(api->GetVariableValue("%Includes")); + } + } + + + for (i = 1; i <= incp->Length(); i++) { + if (!incp->Value(i)->IsSameString(theClass->FullName())) { + api->AddVariable("%IClass",incp->Value(i)->ToCString()); + api->Apply("%Includes","ShortDec"); + publics->AssignCat(api->GetVariableValue("%Includes")); + } + } + } + + api->AddVariable("%Includes",publics->ToCString()); + + // we create the inheritance + // + if (theClass->FullName()->IsSameString(MS::GetTransientRootName()) || + theClass->FullName()->IsSameString(MS::GetPersistentRootName())) { + api->AddVariable("%Inherits",CPPClient_TransientRootName()->ToCString()); + } + else { + api->AddVariable("%Class",theClass->GetInheritsNames()->Value(1)->ToCString()); + api->Apply("%Inherits","BuildTypeName"); + } + + // the name must be __ + // + api->AddVariable("%Class",theClass->FullName()->ToCString()); + api->Apply("%Class","BuildTypeName"); + + api->Apply("%outClass","RefClassClientHXX"); + + // we write the .hxx of this class + // + Handle(TCollection_HAsciiString) aFile = new TCollection_HAsciiString(api->GetVariableValue("%FullPath")); + + aFile->AssignCat(CPPClient_InterfaceName); + aFile->AssignCat("_"); + aFile->AssignCat(theClass->FullName()); + aFile->AssignCat(".hxx"); + + CPPClient_WriteFile(api,aFile,"%outClass"); + + outfile->Append(aFile); + + + CPPClient_TransientDerivated(aMeta,api,aClass,outfile,incp,Supplement,MustBeComplete); + } + else { + ErrorMsg << "CPPClient" << "CPPClient_TransientClass - the class is NULL..." << endm; + Standard_NoSuchObject::Raise(); + } +} + diff --git a/src/CPPClient/FILES b/src/CPPClient/FILES new file mode 100755 index 0000000..317b952 --- /dev/null +++ b/src/CPPClient/FILES @@ -0,0 +1,10 @@ +CPPClient.cxx +CPPClient_Transient.cxx +CPPClient_Package.cxx +CPPClient_Enum.cxx +CPPClient_MPV.cxx +CPPClient_Template.edl +CPPClient_General.edl +CPPClient.hxx +CPPClient_Define.hxx +FILES -- 2.39.5