From a9a72313354745e9e571f9edc84ea642f9072ddd Mon Sep 17 00:00:00 2001 From: Jean-Francois Lefebvre Date: Thu, 13 Jul 2000 21:31:38 +0000 Subject: [PATCH] 2000-07-13 23:24 UTC+0200 JfL & RaC --- harbour/ChangeLog | 16 +++++++--- harbour/source/rtl/tclass.prg | 10 ++++++- harbour/source/rtl/tobject.prg | 55 ++++++++++++++++++++++++++++++---- 3 files changed, 71 insertions(+), 10 deletions(-) diff --git a/harbour/ChangeLog b/harbour/ChangeLog index 508d8d02e7..0094356ca2 100644 --- a/harbour/ChangeLog +++ b/harbour/ChangeLog @@ -1,3 +1,11 @@ +2000-07-13 23:24 UTC+0200 JfL & RaC + * source/rtl/tClass.prg + * Prepared for InitClass (Not working ) + * source/rtl/tObject.prg + * Now Default :New and :Init method 'a la Class(y)' + * New(x,y,z) automatically call Init(x,y,z) + { Very simple implementation limited to 20 params, will be changed asap } + 2000-07-13 07:45 UTC+0800 Ron Pinkas * source/compiler/harbour.slx * Corrected premature release of MACROTEXT @@ -308,10 +316,10 @@ the proposed new Harbour Lexer. It is about half the size of the Flex Lexer and Harbour.exe is about 60K smaller. This might help with 16bit mode and or memory limited situations. It belive it offers few benefits over Flex: Simplicity, Readability, and Consitency of the rules. - More elegant look ahead/parsing capabilities. - Does not require a 3rd party tool (the Tokens & Rules table, is inserted into the Lexer by means of an #include directive. - it doesn't need to be "compiled" like the Flex.exe produces harbourl.c from harbour.l. - It is much smaller than the Flex generated Lexer. + More elegant look ahead/parsing capabilities. + Does not require a 3rd party tool (the Tokens & Rules table, is inserted into the Lexer by means of an #include directive. + it doesn't need to be "compiled" like the Flex.exe produces harbourl.c from harbour.l. + It is much smaller than the Flex generated Lexer. Please note it is not yet optimized for speed, I would love to get your input/suggestion (Ryszard, Victor, Paul, ...). In the process of resaerching the Lex phase I found many "problems" and tried to address them all. It now compiles the full build including keywords.prg (3 compiler (yacc) errors), our previous lexer didn't fully parse keywords.prg diff --git a/harbour/source/rtl/tclass.prg b/harbour/source/rtl/tclass.prg index a91f404839..8399bc1ff6 100644 --- a/harbour/source/rtl/tclass.prg +++ b/harbour/source/rtl/tclass.prg @@ -44,7 +44,7 @@ * Use of __cls_param function to allow multiple superclass declaration * Suppress of SetType and SetInit not more nedded * Delegation and forwarding - * Reworking of hashing as dicRealloc + * Preparing the InitClass class method (not working !! ) * * Copyright 1999 Eddie Runia * Support for inheritance @@ -79,6 +79,7 @@ FUNCTION TClass() __clsAddMsg( s_hClass, "AddVirtual" , @AddVirtual() , HB_OO_MSG_METHOD ) __clsAddMsg( s_hClass, "Instance" , @Instance() , HB_OO_MSG_METHOD ) __clsAddMsg( s_hClass, "SetOnError" , @SetOnError() , HB_OO_MSG_METHOD ) + __clsAddMsg( s_hClass, "InitClass" , @InitClass() , HB_OO_MSG_METHOD ) __clsAddMsg( s_hClass, "cSuper" , {| Self | iif( ::acSuper == NIL .OR. Len( ::acSuper ) == 0, NIL, ::acSuper[ 1 ] ) }, HB_OO_MSG_INLINE ) __clsAddMsg( s_hClass, "_cSuper" , {| Self, xVal | iif( ::acSuper == NIL .OR. Len( ::acSuper ) == 0, ( ::acSuper := { xVal } ), ::acSuper[ 1 ] := xVal ), xVal }, HB_OO_MSG_INLINE ) __clsAddMsg( s_hClass, "hClass" , 1, HB_OO_MSG_DATA ) @@ -361,3 +362,10 @@ STATIC PROCEDURE SetOnError( nFuncPtr ) RETURN +//----------------------------------------------------------------------------// + +STATIC FUNCTION InitClass() + + LOCAL Self := QSelf() + + RETURN Self diff --git a/harbour/source/rtl/tobject.prg b/harbour/source/rtl/tobject.prg index f241365002..1af22b7470 100644 --- a/harbour/source/rtl/tobject.prg +++ b/harbour/source/rtl/tobject.prg @@ -33,7 +33,21 @@ * */ -/* WARNING: Can not use the preprocessor */ +/* + * The following parts are Copyright of the individual authors. + * www - http://www.harbour-project.org + * + * Copyright 2000 J. Lefebvre & RA. Cuylen + * Now supporting of New and Init method as Class(y) use it + * So oMyObj:new(Var1, Var2) will call oMyObj:Init(Var1, Var2) + * Currently limited to 20 params + * + * See doc/license.txt for licensing terms. + * + */ + +/* WARNING: Can not use the preprocessor */ +/* otherwise it will auto inherit from itself */ #include "common.ch" #include "hboo.ch" @@ -43,18 +57,24 @@ FUNCTION TObject() LOCAL nScope := 1 IF s_oClass == NIL + s_oClass := TClass():New( "TObject", {} ) s_oClass:AddInline( "CLASSNAME" , {| Self | __OBJGETCLSNAME( Self ) }, nScope ) s_oClass:AddInline( "CLASSH" , {| Self | __CLASSH( Self ) }, nScope ) s_oClass:AddInline( "CLASSSEL" , {| Self | __CLASSSEL( Self:CLASSH() ) }, nScope ) + s_oClass:AddMethod( "NEW" , @TObject_New() , nScope ) + s_oClass:AddMethod( "INIT", @TObject_Init(), nScope ) + + /* For later use */ + /*s_oClass:AddInline( "CLASS" , {|| s_oClass }, nScope )*/ + /*s_oClass:AddInline( "EVAL" , {| Self | __EVAL( Self ) }, nScope ) */ /*s_oClass:AddInline( "ISDERIVEDFROM" , {| Self, xPar1 | __ObjDerivedFrom( Self, xPar1 ) }, nScope ) */ /* Those one exist within Class(y), so we will probably try to implement it */ - /*s_oClass:AddInline( "INIT" , {| Self | Self }, nScope ) */ /*s_oClass:AddInline( "MSGNOTFOUND" , {| Self | }, nScope ) */ /*s_oClass:AddInline( "ISKINDOF" , {| Self | }, nScope ) */ @@ -66,26 +86,51 @@ FUNCTION TObject() /*s_oClass:AddInline( "isScalar" , {| Self | }, nScope ) */ /*s_oClass:AddInline( "copy" , {| Self | }, nScope ) */ /*s_oClass:AddInline( "deepCopy" , {| Self | }, nScope ) */ + /*s_oClass:AddInline( "deferred" , {| Self | }, nScope ) */ + /*s_oClass:AddInline( "exec" , {| Self | }, nScope ) */ /*s_oClass:AddInline( "error , {| Self | }, nScope ) */ /*s_oClass:AddInline( "hash" , {| Self | }, nScope ) */ /*s_oClass:AddInline( "null" , {| Self | }, nScope ) */ /*s_oClass:AddInline( "size" , {| Self | Len( Self ) }, nScope ) */ + + /* Those three are already treated within Classes.c */ /*s_oClass:AddInline( "protectErr" , {| Self | }, nScope ) */ /*s_oClass:AddInline( "hiddenErr" , {| Self | }, nScope ) */ - /*s_oClass:AddInline( "msgNotFound" , {| Self | }, nScope ) */ /*s_oClass:AddInline( "readOnlyErr" , {| Self | }, nScope ) */ + + /* No idea when those two could occur !!? */ /*s_oClass:AddInline( "wrongClass" , {| Self | }, nScope ) */ /*s_oClass:AddInline( "badMethod" , {| Self | }, nScope ) */ - /* this one exist within VO and is Auto Called when object ran out of scope */ - + /* this one exist within VO and seem to be Auto Called when object ran out of scope */ /*s_oClass:AddInline( "Axit" , {| Self | }, nScope ) */ s_oClass:Create() + /* For later use */ + /*s_oClass:InitClass()*/ + ENDIF RETURN s_oClass:Instance() + +/* Currently limited to 20 param */ +/* Will be re-written in C later to avoid this */ + +static function TObject_New(xPar0, xPar1, xPar2, xPar3, xPar4, xPar5, xPar6, xPar7, xPar8, xPar9, ; + xPar10,xPar11,xPar12,xPar13,xPar14,xPar15,xPar16,xPar17,xPar18,xPar19 ) +local Self := QSelf() + +return Self:Init(xPar0, xPar1, xPar2, xPar3, xPar4, xPar5, xPar6, xPar7, xPar8, xPar9, ; + xPar10,xPar11,xPar12,xPar13,xPar14,xPar15,xPar16,xPar17,xPar18,xPar19 ) + + +static function TObject_Init() +local Self := QSelf() + +return Self + +