From 69a09542797de999e5eb5be5a4786016d2b3bfda Mon Sep 17 00:00:00 2001 From: Antonio Linares Date: Sun, 3 Oct 1999 07:57:19 +0000 Subject: [PATCH] *** empty log message *** --- harbour/include/classes.ch | 26 ++++++++++++++++++++++---- harbour/source/rtl/tclass.prg | 32 +++++++++++++++++++++++++++++++- 2 files changed, 53 insertions(+), 5 deletions(-) diff --git a/harbour/include/classes.ch b/harbour/include/classes.ch index 6fddeb7e4b..197bce0126 100644 --- a/harbour/include/classes.ch +++ b/harbour/include/classes.ch @@ -46,15 +46,33 @@ [ ; #translate Super : => ::: ] ; [ ; extern ] -#xcommand DATA [,] => ; - oClass:AddData( <(DataName1)> ) [; oClass:AddData( <(DataNameN)> ) ] +#xcommand DATA [,] [ AS ] [ INIT ] => ; + [ oClass:SetType( <(type)> ) ; ][ oClass:SetInit( ) ; ] ; + oClass:AddData( <(DataName1)> ) ; + [; oClass:AddData( <(DataNameN)> ) ] ; + [; oClass:SetInit(,) ] [ ; oClass:SetType(,<(type)>) ] + // Note the use of commas ',' on the above two rules to avoid their call + // if there are no AS ... or INIT clauses specified. As we just use + // those methods first parameter, the second one supplied acts as a dummy one -#xcommand CLASSDATA [,] => ; - oClass:AddClassData( <(DataName1)> ) [; oClass:AddClassData( <(DataNameN)> ) ] +#xcommand CLASSDATA [,] [ AS ] [ INIT ] => ; + [ oClass:SetType( <(type)> ) ; ][ oClass:SetInit( ) ; ] ; + oClass:AddClassData( <(DataName1)> ) ; + [; oClass:AddClassData( <(DataNameN)> ) ] ; + [; oClass:SetInit(,) ] [ ; oClass:SetType(,<(type)>) ] + // Note the use of commas ',' on the above two rules to avoid their call + // if there are no AS ... or INIT clauses specified. As we just use + // those methods first parameter, the second one supplied acts as a dummy one #xcommand METHOD ( [] ) [ CONSTRUCTOR ] => ; oClass:AddMethod( <(MethodName)>, CLSMETH _CLASS_NAME_ () ) +#xcommand METHOD ( [] ) BLOCK => ; + oClass:AddInline( <(MethodName)>, ) + +#xcommand METHOD ( [] ) EXTERN ( [] ) => ; + oClass:AddMethod( <(MethodName)>, @() ) + #xcommand METHOD ( [] ) INLINE => ; oClass:AddInline( <(MethodName)>, {|Self [,] | } ) diff --git a/harbour/source/rtl/tclass.prg b/harbour/source/rtl/tclass.prg index ec2015f529..d947d89f2e 100644 --- a/harbour/source/rtl/tclass.prg +++ b/harbour/source/rtl/tclass.prg @@ -57,7 +57,7 @@ function TClass() static hClass := 0 if hClass == 0 - hClass = __clsNew( "TCLASS", 8 ) + hClass = __clsNew( "TCLASS", 10 ) __clsAddMsg( hClass, "New", @New(), MET_METHOD ) __clsAddMsg( hClass, "Create", @Create(), MET_METHOD ) @@ -67,6 +67,8 @@ function TClass() __clsAddMsg( hClass, "AddMethod", @AddMethod(), MET_METHOD ) __clsAddMsg( hClass, "AddVirtual", @AddVirtual(), MET_METHOD ) __clsAddMsg( hClass, "Instance", @Instance(), MET_METHOD ) + __clsAddMsg( hClass, "SetInit", @SetInit(), MET_METHOD ) + __clsAddMsg( hClass, "SetType", @SetType(), MET_METHOD ) __clsAddMsg( hClass, "hClass", 1, MET_DATA ) __clsAddMsg( hClass, "_hClass", 1, MET_DATA ) @@ -84,6 +86,10 @@ function TClass() __clsAddMsg( hClass, "_aVirtuals", 7, MET_DATA ) __clsAddMsg( hClass, "cSuper", 8, MET_DATA ) __clsAddMsg( hClass, "_cSuper", 8, MET_DATA ) + __clsAddMsg( hClass, "uInit", 9, MET_DATA ) + __clsAddMsg( hClass, "_uInit", 9, MET_DATA ) + __clsAddMsg( hClass, "cType", 10, MET_DATA ) + __clsAddMsg( hClass, "_cType", 10, MET_DATA ) endif return __clsInst( hClass ) @@ -181,6 +187,10 @@ static function AddData( cData, xInit ) /* xInit is initializer */ local Self := QSelf() + if ::uInit != nil + xInit = ::uInit + endif + AAdd( ::aDatas, { cData, xInit } ) return nil @@ -226,3 +236,23 @@ static function AddVirtual( cMethod ) return nil //----------------------------------------------------------------------------// + +static function SetInit( uValue ) + + local Self := QSelf() + + ::uInit = uValue + +return nil + +//----------------------------------------------------------------------------// + +static function SetType( cType ) + + local Self := QSelf() + + ::cType = cType + +return nil + +//----------------------------------------------------------------------------//