From: cascade Date: Fri, 30 May 2008 17:40:27 +0000 (+0000) Subject: OCC19770 FIP #24.4 Implementation of returning pointer to OCC Handle for performance... X-Git-Url: http://git.dev.opencascade.org/gitweb/?a=commitdiff_plain;h=eb54e6aaa61439048bd7f6845f439998f421e41b;p=occt-wok.git OCC19770 FIP #24.4 Implementation of returning pointer to OCC Handle for performance reasons. --- diff --git a/src/MS/MS.cxx b/src/MS/MS.cxx index 2e0de0b..c36b839 100755 --- a/src/MS/MS.cxx +++ b/src/MS/MS.cxx @@ -252,20 +252,24 @@ Handle(MS_StdClass) MS::BuildStdClass(const Handle(MS_Class)& aClass, return aNewClass; } +//======================================================================= +//function : BuildStdMethod +//purpose : +//======================================================================= Handle(MS_MemberMet) MS::BuildStdMethod(const Handle(MS_MemberMet)& aMethod, const Handle(MS_Class)& aClass, const Handle(TColStd_HSequenceOfHAsciiString)& aSeqGen, const Handle(TColStd_HSequenceOfHAsciiString)& aSeqType) { Handle(MS_MemberMet) aNewMethod; - + // if (!aMethod.IsNull() && !aClass.IsNull()) { - Standard_Integer i; + Standard_Integer i, aNbParams, aNbRaises; Handle(MS_InstMet) aNewInst; Handle(MS_Construc) aNewCons; Handle(MS_ClassMet) aNewCmet; - MS_InstMet *anInst = 0l; - + MS_InstMet *anInst = NULL;//0l; + // if (aMethod->IsKind(STANDARD_TYPE(MS_InstMet))) { anInst = (MS_InstMet *)aMethod.operator->(); aNewInst = new MS_InstMet(aMethod->Name(),aClass->FullName()); @@ -281,20 +285,20 @@ Handle(MS_MemberMet) MS::BuildStdMethod(const Handle(MS_MemberMet)& aMethod, aNewCmet = new MS_ClassMet(aMethod->Name(),aClass->FullName()); aNewMethod = aNewCmet; } - + // // Parameters // Handle(MS_HArray1OfParam) aSeqParam = aMethod->Params(); Handle(MS_HSequenceOfParam) tmpParamSeq = new MS_HSequenceOfParam; if(!aSeqParam.IsNull()) { - for (i = 1; i <= aSeqParam->Length(); i++) { + aNbParams=aSeqParam->Length(); + for (i = 1; i <= aNbParams; ++i) { tmpParamSeq->Append(MS::BuildStdParam(aSeqParam->Value(i),aNewMethod,aSeqGen,aSeqType)); - //aNewMethod->Param(MS::BuildStdParam(aSeqParam->Value(i),aNewMethod,aSeqGen,aSeqType)); } aNewMethod->Params(tmpParamSeq); } - // Some attributes // + // Some attributes aNewMethod->Private(aMethod->Private()); aNewMethod->Inline(aMethod->IsInline()); aNewMethod->ConstReturn(aMethod->IsConstReturn()); @@ -304,22 +308,25 @@ Handle(MS_MemberMet) MS::BuildStdMethod(const Handle(MS_MemberMet)& aMethod, aNewMethod->Protected(aMethod->IsProtected()); aNewMethod->FunctionCall(aMethod->IsFunctionCall()); aNewMethod->SetAliasType(aMethod->IsOperator()); - + //modified by NIZNHY-PKV Mon May 5 09:09:37 2008f + aNewMethod->PtrReturn(aMethod->IsPtrReturn()); + //modified by NIZNHY-PKV Mon May 5 09:09:40 2008t + // if (!aMethod->Returns().IsNull()) { aNewMethod->Returns(MS::BuildStdParam(aMethod->Returns(),aNewMethod,aSeqGen,aSeqType)); } - + // aNewMethod->CreateFullName(); aNewMethod->MetaSchema(aClass->GetMetaSchema()); aClass->GetMetaSchema()->AddMethod(aNewMethod); - - // Raises // + // Raises Handle(TColStd_HSequenceOfHAsciiString) aRaiseSeq = aMethod->GetRaisesName(); Handle(MS_Method) aSimpleMet = aNewMethod; - + // if(!aRaiseSeq.IsNull()) { - for (i = 1; i <= aRaiseSeq->Length(); i++) { + aNbRaises=aRaiseSeq->Length(); + for (i = 1; i <= aNbRaises; ++i) { aSimpleMet->Raises(aRaiseSeq->Value(i)); } } @@ -328,10 +335,10 @@ Handle(MS_MemberMet) MS::BuildStdMethod(const Handle(MS_MemberMet)& aMethod, cerr << "Error : MS::BuildStdMethod - aMethod or aClass are NULL" << endl; Standard_NullObject::Raise(); } - + // return aNewMethod; } - +// // WARNING (to do) : LikeParam is not copied // Handle(MS_Param) MS::BuildStdParam(const Handle(MS_Param)& aParam, diff --git a/src/MS/MS_Method.cdl b/src/MS/MS_Method.cdl index 2d01f44..25158fa 100755 --- a/src/MS/MS_Method.cdl +++ b/src/MS/MS_Method.cdl @@ -79,9 +79,15 @@ is IsSameSignature(me; aMetName : HAsciiString from TCollection) returns Boolean; - -fields + +--modified by NIZNHY-PKV Sun May 4 16:18:07 2008f + PtrReturn(me : mutable; + aRef : Boolean from Standard); + IsPtrReturn(me) + returns Boolean from Standard; +--modified by NIZNHY-PKV Sun May 4 16:18:13 2008t +fields myParam : HArray1OfParam from MS; -- list of parameters myAttribute : Integer; myReturns : Param from MS; -- return parameter diff --git a/src/MS/MS_Method.cxx b/src/MS/MS_Method.cxx index 70e28be..5d1ea4e 100755 --- a/src/MS/MS_Method.cxx +++ b/src/MS/MS_Method.cxx @@ -1,6 +1,7 @@ #include #include #include + #include #define MET_DESTROY 0x01 @@ -11,11 +12,24 @@ #define MET_OPERATOR 0x20 #define MET_FUNCCALL 0x40 #define MET_COMMENT 0x05 - -MS_Method::MS_Method(const Handle(TCollection_HAsciiString)& aName) : MS_Common(aName),myAttribute(0),myRaises(new TColStd_HSequenceOfHAsciiString),myComment(new TCollection_HAsciiString("")) +#define MET_PTR 0x80 + +//======================================================================= +//function : MS_Method +//purpose : +//======================================================================= +MS_Method::MS_Method(const Handle(TCollection_HAsciiString)& aName) +: + MS_Common(aName), + myAttribute(0), + myRaises(new TColStd_HSequenceOfHAsciiString), + myComment(new TCollection_HAsciiString("")) { } - +//======================================================================= +//function : CreateFullName +//purpose : +//======================================================================= void MS_Method::CreateFullName() { Standard_Integer i; @@ -61,7 +75,10 @@ void MS_Method::CreateFullName() FullName(myIdName); } - +//======================================================================= +//function : Params +//purpose : +//======================================================================= void MS_Method::Params(const Handle(MS_HSequenceOfParam)& params) { if(!params.IsNull()) { @@ -72,11 +89,19 @@ void MS_Method::Params(const Handle(MS_HSequenceOfParam)& params) //myParam->Append(aParam); } +//======================================================================= +//function : Params +//purpose : +//======================================================================= Handle(MS_HArray1OfParam) MS_Method::Params() const { return myParam; } +//======================================================================= +//function : Private +//purpose : +//======================================================================= void MS_Method::Private(const Standard_Boolean aPrivate) { if (aPrivate) { @@ -86,7 +111,10 @@ void MS_Method::Private(const Standard_Boolean aPrivate) myAttribute &= (myAttribute ^ MET_PRIVATE); } } - +//======================================================================= +//function : Private +//purpose : +//======================================================================= Standard_Boolean MS_Method::Private() const { if (myAttribute & MET_PRIVATE) { @@ -96,28 +124,47 @@ Standard_Boolean MS_Method::Private() const return Standard_False; } } - +//======================================================================= +//function : Returns +//purpose : +//======================================================================= void MS_Method::Returns(const Handle(MS_Param)& aParam) { myReturns = aParam; } +//======================================================================= +//function : Returns +//purpose : +//======================================================================= Handle(MS_Param) MS_Method::Returns() const { return myReturns; } +//======================================================================= +//function : Raises +//purpose : +//======================================================================= void MS_Method::Raises(const Handle(TCollection_HAsciiString)& aRaise) { if(myRaises.IsNull()) myRaises = new TColStd_HSequenceOfHAsciiString; myRaises->Append(aRaise); } +//======================================================================= +//function : GetRaisesName +//purpose : +//======================================================================= Handle(TColStd_HSequenceOfHAsciiString) MS_Method::GetRaisesName() const { return myRaises; } +//======================================================================= +//function : Inline +//purpose : +//======================================================================= void MS_Method::Inline(const Standard_Boolean anInline) { if (anInline) { @@ -127,7 +174,10 @@ void MS_Method::Inline(const Standard_Boolean anInline) myAttribute &= (MET_INLINE ^ myAttribute); } } - +//======================================================================= +//function : IsInline +//purpose : +//======================================================================= Standard_Boolean MS_Method::IsInline() const { if (myAttribute & MET_INLINE) { @@ -137,7 +187,10 @@ Standard_Boolean MS_Method::IsInline() const return Standard_False; } } - +//======================================================================= +//function : ConstReturn +//purpose : +//======================================================================= void MS_Method::ConstReturn(const Standard_Boolean aConst) { if (aConst) { @@ -147,7 +200,10 @@ void MS_Method::ConstReturn(const Standard_Boolean aConst) myAttribute &= (MET_CONST ^ myAttribute); } } - +//======================================================================= +//function : IsConstReturn +//purpose : +//======================================================================= Standard_Boolean MS_Method::IsConstReturn() const { if (myAttribute & MET_CONST) { @@ -157,17 +213,26 @@ Standard_Boolean MS_Method::IsConstReturn() const return Standard_False; } } - +//======================================================================= +//function : Alias +//purpose : +//======================================================================= void MS_Method::Alias(const Handle(TCollection_HAsciiString)& anAlias) { myAlias = anAlias; } - +//======================================================================= +//function : IsAlias +//purpose : +//======================================================================= Handle(TCollection_HAsciiString) MS_Method::IsAlias() const { return myAlias; } - +//======================================================================= +//function : RefReturn +//purpose : +//======================================================================= void MS_Method::RefReturn(const Standard_Boolean aRef) { if (aRef) { @@ -177,7 +242,10 @@ void MS_Method::RefReturn(const Standard_Boolean aRef) myAttribute &= (MET_REF ^ myAttribute); } } - +//======================================================================= +//function : IsRefReturn +//purpose : +//======================================================================= Standard_Boolean MS_Method::IsRefReturn() const { if (myAttribute & MET_REF) { @@ -188,6 +256,10 @@ Standard_Boolean MS_Method::IsRefReturn() const } } +//======================================================================= +//function : Destructor +//purpose : +//======================================================================= void MS_Method::Destructor(const Standard_Boolean aDestructor) { if (aDestructor) { @@ -197,7 +269,10 @@ void MS_Method::Destructor(const Standard_Boolean aDestructor) myAttribute &= (MET_DESTROY ^ myAttribute); } } - +//======================================================================= +//function : IsDestructor +//purpose : +//======================================================================= Standard_Boolean MS_Method::IsDestructor() const { if (myAttribute & MET_DESTROY) { @@ -207,7 +282,10 @@ Standard_Boolean MS_Method::IsDestructor() const return Standard_False; } } - +//======================================================================= +//function : FunctionCall +//purpose : +//======================================================================= void MS_Method::FunctionCall(const Standard_Boolean aFunctionCall) { if (aFunctionCall) { @@ -217,7 +295,10 @@ void MS_Method::FunctionCall(const Standard_Boolean aFunctionCall) myAttribute &= (MET_FUNCCALL ^ myAttribute); } } - +//======================================================================= +//function : IsFunctionCall +//purpose : +//======================================================================= Standard_Boolean MS_Method::IsFunctionCall() const { if (myAttribute & MET_FUNCCALL) { @@ -227,8 +308,12 @@ Standard_Boolean MS_Method::IsFunctionCall() const return Standard_False; } } - -Standard_Boolean MS_Method::IsSameSignature(const Handle(TCollection_HAsciiString)& aMetName2) const +//======================================================================= +//function : IsSameSignature +//purpose : +//======================================================================= +Standard_Boolean MS_Method::IsSameSignature + (const Handle(TCollection_HAsciiString)& aMetName2) const { Handle(TCollection_HAsciiString) aMetName1; Standard_Boolean result = Standard_False; @@ -243,28 +328,24 @@ Standard_Boolean MS_Method::IsSameSignature(const Handle(TCollection_HAsciiStrin Standard_PCharacter fin1 = strchr(aname1, '='); Standard_PCharacter fin2 = strchr(aname2, '='); - if(fin1) *fin1 = '\0'; - if(fin2) *fin2 = '\0'; - - //cout << "aname1 : " << aname1 << endl; - //cout << "aname2 : " << aname2 << endl; - + if(fin1) { + *fin1 = '\0'; + } + if(fin2) { + *fin2 = '\0'; + } + // result = !strcmp(aname1, aname2); - - //cout << "result : " << result << endl; - - if(fin1) *fin1 = '='; - if(fin2) *fin2 = '='; - -// Handle(TCollection_HAsciiString) aname1 = aMetName1->Token(":",2), -// aname2 = aMetName2->Token(":",2); - -// aname1 = aname1->Token("="); -// aname2 = aname2->Token("="); -// result = aname1->IsSameString(aname2); - + // + if(fin1) { + *fin1 = '='; + } + if(fin2) { + *fin2 = '='; + } + // if (result) { - Handle(MS_Method) m1,m2; + Handle(MS_Method) m1,m2; Handle(MS_HArray1OfParam) p1,p2; m1 = this; @@ -316,7 +397,10 @@ Standard_Boolean MS_Method::IsSameSignature(const Handle(TCollection_HAsciiStrin return result; } - +//======================================================================= +//function : SetAliasType +//purpose : +//======================================================================= void MS_Method::SetAliasType(const Standard_Boolean aType) { if (aType) { @@ -326,19 +410,26 @@ void MS_Method::SetAliasType(const Standard_Boolean aType) myAttribute &= (MET_OPERATOR ^ myAttribute); } } - +//======================================================================= +//function : Comment +//purpose : +//======================================================================= Handle(TCollection_HAsciiString) MS_Method::Comment() const { - //const Handle(TCollection_HAsciiString)& startComment = new TCollection_HAsciiString("///"); - //if (myComment->IsSameString(startComment)) myComment->Clear(); return myComment; } - +//======================================================================= +//function : SetComment +//purpose : +//======================================================================= void MS_Method::SetComment(const Handle(TCollection_HAsciiString)& aComment) { myComment->AssignCat(aComment); } - +//======================================================================= +//function : IsOperator +//purpose : +//======================================================================= Standard_Boolean MS_Method::IsOperator() const { if (myAttribute & MET_OPERATOR) { @@ -348,10 +439,40 @@ Standard_Boolean MS_Method::IsOperator() const return Standard_False; } } - +//======================================================================= +//function : IsQuotedAlias +//purpose : +//======================================================================= Standard_Boolean MS_Method::IsQuotedAlias() const { return (!myAlias.IsNull() && !IsOperator()); } - +//modified by NIZNHY-PKV Sun May 4 16:20:03 2008f +//======================================================================= +//function : PtrReturn +//purpose : +//======================================================================= +void MS_Method::PtrReturn(const Standard_Boolean aFlag) +{ + if (aFlag) { + myAttribute |= MET_PTR; + } + else { + myAttribute &= (MET_PTR ^ myAttribute); + } +} +//======================================================================= +//function : IsPtrReturn +//purpose : +//======================================================================= +Standard_Boolean MS_Method::IsPtrReturn() const +{ + if (myAttribute & MET_PTR) { + return Standard_True; + } + else { + return Standard_False; + } +} +//modified by NIZNHY-PKV Sun May 4 16:20:04 2008t