From f16eeecae998f943ca49284d409376d6d4126c6d Mon Sep 17 00:00:00 2001 From: kgv Date: Mon, 31 Mar 2014 12:57:44 +0400 Subject: [PATCH] 0024709: Avoid generation of separate header files for Handle classes CPPExt - do not generate and do not include Handle_Class.hxx files when environment variable $CSF_HANDLEHXX is set to 0. --- src/CPPExt/CPPExt.cxx | 204 +++++++++++++++++--------------- src/CPPExt/CPPExt_Define.hxx | 3 + src/CPPExt/CPPExt_Template.edl | 96 ++++++++++++--- src/CPPExt/CPPExt_Transient.cxx | 7 +- src/WOKsite/wok_env.bat | 1 + src/WOKsite/wok_env.sh | 1 + src/WOKsite/wok_tclshrc.tcl | 5 + 7 files changed, 202 insertions(+), 115 deletions(-) diff --git a/src/CPPExt/CPPExt.cxx b/src/CPPExt/CPPExt.cxx index 5b46451..2b3684c 100755 --- a/src/CPPExt/CPPExt.cxx +++ b/src/CPPExt/CPPExt.cxx @@ -9,6 +9,12 @@ #include #include #include +#include + +namespace +{ + static OSD_Environment THE_HANDLEHXX ("CSF_HANDLEHXX"); +} // Standard Extractor API : list the EDL files used by this program // @@ -915,56 +921,60 @@ void CPP_ClassTypeMgt(const Handle(MS_MetaSchema)& , api->Apply(var,"TypeMgt"); } +Standard_Boolean CPP_HaveHandleHeaders() +{ + return THE_HANDLEHXX.Value() != "0"; +} // Standard extractor API : launch the extraction of C++ files // from the type // -void CPP_Extract(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 Standard_CString DBMS) +void CPP_Extract (const Handle(MS_MetaSchema)& theMeta, + const Handle(TCollection_HAsciiString)& theName, + const Handle(TColStd_HSequenceOfHAsciiString)& theEdlsFullPath, + const Handle(TCollection_HAsciiString)& theOutDir, + const Handle(TColStd_HSequenceOfHAsciiString)& theOutFile, + const Standard_CString theDBMS) { - 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); + // look if the entity has something to extract... + Handle(MS_Type) aSrcType; + Handle(MS_Package) aSrcPackage; + if (theMeta->IsDefined (theName)) + { + aSrcType = theMeta->GetType (theName); } - else if (aMeta->IsPackage(aName)) { - srcPackage = aMeta->GetPackage(aName); + else if (theMeta->IsPackage (theName)) + { + aSrcPackage = theMeta->GetPackage (theName); } - else { - ErrorMsg() << "CPPExt" << aName->ToCString() << " not defined..." << endm; + else + { + ErrorMsg() << "CPPExt" << theName->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) { - api = CPP_LoadTemplate(edlsfullpath,outdir,DBMS); - CPP_Package(aMeta,api,srcPackage,outfile); - } - else { + if (!aSrcPackage.IsNull()) + { + if (aSrcPackage->Methods()->Length() < 1) + { return; } + + Handle(EDL_API) anApi = CPP_LoadTemplate (theEdlsFullPath, theOutDir, theDBMS); + CPP_Package (theMeta, anApi, aSrcPackage, theOutFile); + return; } + // 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->Incomplete()) { - ErrorMsg() << "CPPExt" << aName->ToCString() << " not complete..." << endm; + if (aSrcType->IsKind (STANDARD_TYPE(MS_StdClass)) + && !aSrcType->IsKind (STANDARD_TYPE(MS_GenClass)) + && !aSrcType->IsKind (STANDARD_TYPE(MS_InstClass))) + { + Handle(MS_StdClass) aClass = *((Handle(MS_StdClass)*)&aSrcType); + if (aClass->Incomplete()) + { + ErrorMsg() << "CPPExt" << theName->ToCString() << " not complete..." << endm; Standard_NoSuchObject::Raise(); } @@ -974,12 +984,10 @@ void CPP_Extract(const Handle(MS_MetaSchema)& aMeta, return; } - api = CPP_LoadTemplate(edlsfullpath,outdir,DBMS); - - // Transient classes - // + Handle(EDL_API) anApi = CPP_LoadTemplate (theEdlsFullPath, theOutDir, theDBMS); + const Standard_Boolean haveHandleHeaders = CPP_HaveHandleHeaders(); if (aClass->IsTransient() - && !aName->IsSameString (MS::GetTransientRootName())) + && !theName->IsSameString (MS::GetTransientRootName())) { if (aClass->GetInheritsNames()->Length() == 0) { @@ -987,27 +995,27 @@ void CPP_Extract(const Handle(MS_MetaSchema)& aMeta, Standard_NoSuchObject::Raise(); } - Handle(TCollection_HAsciiString) aHandleFile = new TCollection_HAsciiString(outdir); - aHandleFile->AssignCat("Handle_"); - aHandleFile->AssignCat(aName); - aHandleFile->AssignCat(".hxx"); - - outfile->Append(aHandleFile); - CPP_TransientHandle(api,aName,aClass->GetInheritsNames()->Value(1),aHandleFile); + if (haveHandleHeaders) + { + Handle(TCollection_HAsciiString) aHandleFile = new TCollection_HAsciiString (theOutDir); + aHandleFile->AssignCat ("Handle_"); + aHandleFile->AssignCat (theName); + aHandleFile->AssignCat (".hxx"); + theOutFile->Append (aHandleFile); + CPP_TransientHandle (anApi, theName, aClass->GetInheritsNames()->Value (1), aHandleFile); + } - if (aClass->IsKind(STANDARD_TYPE(MS_Error))) + if (aClass->IsKind (STANDARD_TYPE(MS_Error))) { - CPP_ExceptionClass(aMeta,api,aClass,outfile); + CPP_ExceptionClass (theMeta, anApi, aClass, theOutFile); } else { - CPP_TransientClass(aMeta,api,aClass,outfile); + CPP_TransientClass (theMeta, anApi, aClass, theOutFile); } } - // Persistent classes - // else if (aClass->IsPersistent() - && !aName->IsSameString(MS::GetPersistentRootName())) + && !theName->IsSameString (MS::GetPersistentRootName())) { if (aClass->GetInheritsNames()->Length() == 0) { @@ -1015,76 +1023,76 @@ void CPP_Extract(const Handle(MS_MetaSchema)& aMeta, Standard_NoSuchObject::Raise(); } - Handle(TCollection_HAsciiString) aHandleFile = new TCollection_HAsciiString(outdir); - - aHandleFile->AssignCat("Handle_"); - aHandleFile->AssignCat(aName); - aHandleFile->AssignCat(".hxx"); - - outfile->Append(aHandleFile); + Handle(TCollection_HAsciiString) aHandleFile; + if (haveHandleHeaders) + { + aHandleFile = new TCollection_HAsciiString (theOutDir); + aHandleFile->AssignCat ("Handle_"); + aHandleFile->AssignCat (theName); + aHandleFile->AssignCat (".hxx"); + theOutFile->Append (aHandleFile); + } - if (!strcmp(api->GetVariableValue("%CPPEXTDBMS")->ToCString(),"OBJY")) + if (!strcmp (anApi->GetVariableValue ("%CPPEXTDBMS")->ToCString(), "OBJY")) { - CPP_PersistentHandleOBJY(api,aName,aClass->GetInheritsNames()->Value(1),aHandleFile); - CPP_PersistentClassOBJY(aMeta,api,aClass,outfile); + if (haveHandleHeaders) + { + CPP_PersistentHandleOBJY (anApi, theName, aClass->GetInheritsNames()->Value (1), aHandleFile); + } + CPP_PersistentClassOBJY (theMeta, anApi, aClass, theOutFile); } - else if (!strcmp(api->GetVariableValue("%CPPEXTDBMS")->ToCString(),"MEM")) + else if (!strcmp (anApi->GetVariableValue ("%CPPEXTDBMS")->ToCString(), "MEM")) { } - else if (!strcmp(api->GetVariableValue("%CPPEXTDBMS")->ToCString(),"OBJS")) + else if (!strcmp (anApi->GetVariableValue ("%CPPEXTDBMS")->ToCString(), "OBJS")) { - CPP_PersistentHandleOBJS(api,aName,aClass->GetInheritsNames()->Value(1),aHandleFile); - CPP_PersistentClassOBJS(aMeta,api,aClass,outfile); + if (haveHandleHeaders) + { + CPP_PersistentHandleOBJS (anApi, theName, aClass->GetInheritsNames()->Value (1), aHandleFile); + } + CPP_PersistentClassOBJS (theMeta, anApi, aClass, theOutFile); } - else if (!strcmp(api->GetVariableValue("%CPPEXTDBMS")->ToCString(),"OO2")) + else if (!strcmp (anApi->GetVariableValue ("%CPPEXTDBMS")->ToCString(), "OO2")) { } - else if (!strcmp(api->GetVariableValue("%CPPEXTDBMS")->ToCString(),"CSFDB")) + else if (!strcmp (anApi->GetVariableValue ("%CPPEXTDBMS")->ToCString(), "CSFDB")) { - CPP_PersistentHandleCSFDB(api,aName,aClass->GetInheritsNames()->Value(1),aHandleFile); - CPP_PersistentClassCSFDB(aMeta,api,aClass,outfile); + if (haveHandleHeaders) + { + CPP_PersistentHandleCSFDB (anApi, theName, aClass->GetInheritsNames()->Value (1), aHandleFile); + } + CPP_PersistentClassCSFDB (theMeta, anApi, aClass, theOutFile); } } - // Storable classes - // else if (aClass->IsStorable()) { - CPP_StorableClass(aMeta,api,aClass,outfile); - } - // MPV classes - // + CPP_StorableClass (theMeta, anApi, aClass, theOutFile); + } else { - CPP_MPVClass(aMeta,api,aClass,outfile); + CPP_MPVClass (theMeta, anApi, aClass, theOutFile); } } - // Enumerations - // - else if (srcType->IsKind(STANDARD_TYPE(MS_Enum))) + else if (aSrcType->IsKind (STANDARD_TYPE(MS_Enum))) { - Handle(MS_Enum) anEnum = *((Handle(MS_Enum)*)&srcType); - - api = CPP_LoadTemplate(edlsfullpath,outdir,DBMS); - CPP_Enum(aMeta,api,anEnum,outfile); + Handle(MS_Enum) anEnum = *((Handle(MS_Enum)*)&aSrcType); + Handle(EDL_API) anApi = CPP_LoadTemplate (theEdlsFullPath, theOutDir, theDBMS); + CPP_Enum (theMeta, anApi, anEnum, theOutFile); } - // Aliases - // - else if (srcType->IsKind(STANDARD_TYPE(MS_Alias))) + else if (aSrcType->IsKind (STANDARD_TYPE(MS_Alias))) { - Handle(MS_Alias) anAlias = *((Handle(MS_Alias)*)&srcType); - - api = CPP_LoadTemplate(edlsfullpath,outdir,DBMS); - CPP_Alias(aMeta,api,anAlias,outfile); + Handle(MS_Alias) anAlias = *((Handle(MS_Alias)*)&aSrcType); + Handle(EDL_API) anApi = CPP_LoadTemplate (theEdlsFullPath, theOutDir, theDBMS); + CPP_Alias (theMeta, anApi, anAlias, theOutFile); } - else if (srcType->IsKind(STANDARD_TYPE(MS_Pointer))) + else if (aSrcType->IsKind (STANDARD_TYPE(MS_Pointer))) { - Handle(MS_Pointer) aPointer = *((Handle(MS_Pointer)*)&srcType); - - api = CPP_LoadTemplate(edlsfullpath,outdir,DBMS); - CPP_Pointer(aMeta,api,aPointer,outfile); + Handle(MS_Pointer) aPointer = *((Handle(MS_Pointer)*)&aSrcType); + Handle(EDL_API) anApi = CPP_LoadTemplate (theEdlsFullPath, theOutDir, theDBMS); + CPP_Pointer (theMeta, anApi, aPointer, theOutFile); } } - + Handle(TCollection_HAsciiString) CPP_WithoutHandleSuffix (const Handle(TCollection_HAsciiString)& theName) { const Standard_Integer aSuffLen = Standard_Integer(sizeof("Handle_") - 1); diff --git a/src/CPPExt/CPPExt_Define.hxx b/src/CPPExt/CPPExt_Define.hxx index b91c2c8..0646b02 100755 --- a/src/CPPExt/CPPExt_Define.hxx +++ b/src/CPPExt/CPPExt_Define.hxx @@ -103,4 +103,7 @@ void CPP_ClassTypeMgt(const Handle(MS_MetaSchema)& aMeta, //! Auxiliary function to remove Handle_ suffix Handle(TCollection_HAsciiString) CPP_WithoutHandleSuffix (const Handle(TCollection_HAsciiString)& theName); +//! Read $CSF_HANDLEHXX variable +Standard_Boolean CPP_HaveHandleHeaders(); + #endif diff --git a/src/CPPExt/CPPExt_Template.edl b/src/CPPExt/CPPExt_Template.edl index c7c58ec..911b9a3 100755 --- a/src/CPPExt/CPPExt_Template.edl +++ b/src/CPPExt/CPPExt_Template.edl @@ -11,7 +11,7 @@ @template HandleTransient (%HTName,%HTInherits) is $// This file is generated by WOK (CPPExt). $// Please do not edit this file; modify original file instead. -$// The copyright and license terms as defined for the original file apply to +$// The copyright and license terms as defined for the original file apply to $// this header file considered to be the "object code" form of the original source. $ $#ifndef _Handle_%HTName_HeaderFile @@ -35,6 +35,67 @@ $#endif // _Handle_%HTName_HeaderFile -- extraction of a transient class -- =============================== +@template TransientInstClass_HandleHxx (%ClassComment, + %Class, + %TICIncludes, + %Inherits, + %TICPublicmets, + %TICPublicfriends, + %TICProtectedmets, + %TICProtectedfields, + %TICPrivatemets, + %TICPrivatefields, + %TICPrivatefriends, + %TICDefines, + %TICInlineIncludes, + %TICUndefines, + %TICSuppMethod) is +$// This file is generated by WOK (CPPExt). +$// Please do not edit this file; modify original file instead. +$// The copyright and license terms as defined for the original file apply to +$// this header file considered to be the "object code" form of the original source. +$ +$#ifndef _%Class_HeaderFile +$#define _%Class_HeaderFile +$ +$#include +$#include +$#include +$ +$%TICIncludes +$ +$%ClassComment +$class %Class : public %Inherits +${ +$ +$public: +$ +$%TICPublicmets +$%TICPublicfriends +$ +$ DEFINE_STANDARD_RTTI(%Class) +$ +$protected: +$ +$%TICProtectedmets +$%TICProtectedfields +$ +$private: +$ +$%TICPrivatemets +$%TICPrivatefields +$%TICPrivatefriends +$}; +$ +$%TICDefines +$%TICInlineIncludes +$%TICUndefines +$ +$%TICSuppMethod +$ +$#endif // _%Class_HeaderFile +@end; + @template TransientInstClass (%ClassComment, %Class, %TICIncludes, @@ -52,7 +113,7 @@ $#endif // _Handle_%HTName_HeaderFile %TICSuppMethod) is $// This file is generated by WOK (CPPExt). $// Please do not edit this file; modify original file instead. -$// The copyright and license terms as defined for the original file apply to +$// The copyright and license terms as defined for the original file apply to $// this header file considered to be the "object code" form of the original source. $ $#ifndef _%Class_HeaderFile @@ -60,10 +121,13 @@ $#define _%Class_HeaderFile $ $#include $#include -$#include $ $%TICIncludes $ +$class Handle(%Inherits); +$class %Class; +$DEFINE_STANDARD_HANDLE(%Class, %Inherits) +$ $%ClassComment $class %Class : public %Inherits ${ @@ -80,7 +144,7 @@ $ $%TICProtectedmets $%TICProtectedfields $ -$private: +$private: $ $%TICPrivatemets $%TICPrivatefields @@ -99,7 +163,7 @@ $#endif // _%Class_HeaderFile @template TransientIxx (%Class,%Suffix,%Supplement,%TypeMgt,%Methods) is $// This file is generated by WOK (CPPExt). $// Please do not edit this file; modify original file instead. -$// The copyright and license terms as defined for the original file apply to +$// The copyright and license terms as defined for the original file apply to $// this header file considered to be the "object code" form of the original source. $ $#include <%Class.%Suffix> @@ -134,7 +198,7 @@ $%Methods %TICSuppMethod) is $// This file is generated by WOK (CPPExt). $// Please do not edit this file; modify original file instead. -$// The copyright and license terms as defined for the original file apply to +$// The copyright and license terms as defined for the original file apply to $// this header file considered to be the "object code" form of the original source. $ $#ifndef _%Class_HeaderFile @@ -183,7 +247,7 @@ $#endif // _%Class_HeaderFile @template MPVIxx (%Class,%Suffix,%Supplement,%Methods) is $// This file is generated by WOK (CPPExt). $// Please do not edit this file; modify original file instead. -$// The copyright and license terms as defined for the original file apply to +$// The copyright and license terms as defined for the original file apply to $// this header file considered to be the "object code" form of the original source. $ $#include <%Class.%Suffix> @@ -214,7 +278,7 @@ $%Methods %TICSuppMethod) is $// This file is generated by WOK (CPPExt). $// Please do not edit this file; modify original file instead. -$// The copyright and license terms as defined for the original file apply to +$// The copyright and license terms as defined for the original file apply to $// this header file considered to be the "object code" form of the original source. $ $#ifndef _%Class_HeaderFile @@ -244,7 +308,7 @@ $ $%TICProtectedmets $%TICProtectedfields $ -$private: +$private: $ $%TICPrivatemets $%TICPrivatefields @@ -263,7 +327,7 @@ $#endif // _%Class_HeaderFile @template StorableIxx(%Class,%Suffix,%Supplement,%Methods) is $// This file is generated by WOK (CPPExt). $// Please do not edit this file; modify original file instead. -$// The copyright and license terms as defined for the original file apply to +$// The copyright and license terms as defined for the original file apply to $// this header file considered to be the "object code" form of the original source. $ $#include <%Class.%Suffix> @@ -282,7 +346,7 @@ $%Methods @template EnumHXX(%EnumComment,%Class,%Values) is $// This file is generated by WOK (CPPExt). $// Please do not edit this file; modify original file instead. -$// The copyright and license terms as defined for the original file apply to +$// The copyright and license terms as defined for the original file apply to $// this header file considered to be the "object code" form of the original source. $ $#ifndef _%Class_HeaderFile @@ -309,7 +373,7 @@ $ @template AliasHXX(%Class,%Inherits, %HandleTypedef) is $// This file is generated by WOK (CPPExt). $// Please do not edit this file; modify original file instead. -$// The copyright and license terms as defined for the original file apply to +$// The copyright and license terms as defined for the original file apply to $// this header file considered to be the "object code" form of the original source. $ $#ifndef _%Class_HeaderFile @@ -332,7 +396,7 @@ $#endif // _%Class_HeaderFile @template PointerHXX(%Class,%Inherits) is $// This file is generated by WOK (CPPExt). $// Please do not edit this file; modify original file instead. -$// The copyright and license terms as defined for the original file apply to +$// The copyright and license terms as defined for the original file apply to $// this header file considered to be the "object code" form of the original source. $ $#ifndef _%Class_HeaderFile @@ -350,7 +414,7 @@ $#endif // _%Class_HeaderFile @template ExceptionHXX(%Class,%Inherits) is $// This file is generated by WOK (CPPExt). $// Please do not edit this file; modify original file instead. -$// The copyright and license terms as defined for the original file apply to +$// The copyright and license terms as defined for the original file apply to $// this header file considered to be the "object code" form of the original source. $ $#ifndef _%Class_HeaderFile @@ -361,7 +425,9 @@ $#include $#include $#include $#include <%Inherits.hxx> -$#include +$ +$class %Class; +$DEFINE_STANDARD_HANDLE(%Class, %Inherits) $ $#if !defined No_Exception && !defined No_%Class $ #define %Class_Raise_if(CONDITION, MESSAGE) \ diff --git a/src/CPPExt/CPPExt_Transient.cxx b/src/CPPExt/CPPExt_Transient.cxx index c0ff2dd..531617d 100755 --- a/src/CPPExt/CPPExt_Transient.cxx +++ b/src/CPPExt/CPPExt_Transient.cxx @@ -378,7 +378,10 @@ void CPP_TransientClass(const Handle(MS_MetaSchema)& aMeta, continue; } - ///aName = CPP_WithoutHandleSuffix (aName); + if (!CPP_HaveHandleHeaders()) + { + aName = CPP_WithoutHandleSuffix (aName); + } api->AddVariable (VIClass, aName->ToCString()); api->Apply (VTICIncludes, "Include"); publics->AssignCat (api->GetVariableValue (VTICIncludes)); @@ -394,7 +397,7 @@ void CPP_TransientClass(const Handle(MS_MetaSchema)& aMeta, api->AddVariable(VTICIncludes,publics->ToCString()); - api->Apply(VoutClass,"TransientInstClass"); + api->Apply (VoutClass, CPP_HaveHandleHeaders() ? "TransientInstClass_HandleHxx" : "TransientInstClass"); // we write the .hxx of this class // diff --git a/src/WOKsite/wok_env.bat b/src/WOKsite/wok_env.bat index 84beac7..dc8a77f 100644 --- a/src/WOKsite/wok_env.bat +++ b/src/WOKsite/wok_env.bat @@ -20,6 +20,7 @@ set "HAVE_FREEIMAGE=false" set "HAVE_GL2PS=false" set "HAVE_VTK=false" set "VCVARS=" +set "CSF_HANDLEHXX=1" rem ----- Set local settings (M$ Visual Studio compilers etc.) ----- if exist "%~dp0custom.bat" ( diff --git a/src/WOKsite/wok_env.sh b/src/WOKsite/wok_env.sh index 2bb6468..74b0568 100644 --- a/src/WOKsite/wok_env.sh +++ b/src/WOKsite/wok_env.sh @@ -27,6 +27,7 @@ export HAVE_FREEIMAGE="false"; export HAVE_GL2PS="false"; export HAVE_VTK="false"; export PRODUCTS_DEFINES=""; +export CSF_HANDLEHXX="1"; # ----- Set local settings ----- if [ -e "${aScriptPath}/custom.sh" ]; then diff --git a/src/WOKsite/wok_tclshrc.tcl b/src/WOKsite/wok_tclshrc.tcl index 587f794..cc36add 100644 --- a/src/WOKsite/wok_tclshrc.tcl +++ b/src/WOKsite/wok_tclshrc.tcl @@ -146,6 +146,11 @@ if { "$tcl_platform(platform)" == "windows" } { if { "$PRODUCTS_PATH" != "" } { puts " 3rd-parties root: '$::env(PRODUCTS_PATH)'" } +if { [info exists ::env(CSF_HANDLEHXX)] && "$::env(CSF_HANDLEHXX)" == "0" } { + puts " Generate Handle_XXX.hxx files: OFF" +} else { + puts " Generate Handle_XXX.hxx files: ON" +} set anErrs {} if { [wokdep:SearchTclTk anErrs anErrs anErrs anErrs anErrs] == "false" } { -- 2.39.5