home *** CD-ROM | disk | FTP | other *** search
/ C!T ROM 2 / ctrom_ii_b.zip / ctrom_ii_b / PROGRAM / CLIPPER / OBJECT / OBJECTS.CH < prev    next >
Text File  |  1992-12-04  |  3KB  |  57 lines

  1. // (c) Antonio Linares, 1992 - Spain
  2.  
  3. // I give this version to Public Domain. Feel free to use it.
  4. // You can create new classes, you can use the debugger and you have
  5. // multiple inheritance. It is very fast and usefull.
  6.  
  7. // Some prgs are included as examples. I would like to get your feedback
  8. // and instructions to join it to NanForum Lib. I will give all the source
  9. // code.
  10.  
  11. // CompuServe Id: 100114, 1776. I would like to get your messages!
  12.  
  13. // Objects.ch
  14.  
  15. //----------------------------------------------------------------------------//
  16.  
  17. #xcommand DEFAULT <uVar1> = <uDefaultValue1>                                   ;
  18.                [, <uVarN> = <uDefaultValueN> ] =>                              ;
  19.                   <uVar1> = If( <uVar1> == nil, <uDefaultValue1>, <uVar1> )   ;;
  20.                 [ <uVarN> = If( <uVarN> == nil, <uDefaultValueN>, <uVarN> );]
  21.  
  22. #xcommand CLASS <cClassName> [ FROM <cSuperNam1>] [ ,<cSuperNamN> ] =>         ;
  23.           function <cClassName>()                                             ;;
  24.              static nClassHandle, abParents                                   ;;
  25.                 if nClassHandle == nil                                        ;;
  26.                    ClsNew( <"cClassName"> ,                                    ;
  27.                    abParents := { [ { || <cSuperNam1>() } ]                    ;
  28.                                   [,{ || <cSuperNamN>() } ] } )               ;;
  29.                    [#define PARENT <"cSuperNam1">]
  30.  
  31. #xcommand DATA <cVar1> [,<cVarN>] =>                                           ;
  32.             ClsAddData( <"cVar1">, 0 )                                         ;
  33.          [; ClsAddData( <"cVarN">, 0 ) ]
  34.  
  35. #xcommand METHOD <cMethodName>( [<uParms,...>] ) =>                            ;
  36.             ClsAddMethod( Upper( <"cMethodName"> ),                            ;
  37.             { | Self [, <uParms> ] | <cMethodName>( Self [, <uParms> ] ) } )
  38.  
  39. #xcommand METHOD <cMethodName>( [<parms,...>] ) VIRTUAL => ;
  40.             ClsAddMethod( Upper( <"cMethodName"> ), { || nil } )
  41.  
  42. #xcommand ENDCLASS =>                                                          ;
  43.                 nClassHandle = nClsMake()                                     ;;
  44.              end                                                              ;;
  45.           return __ClassIns( nClassHandle )
  46.  
  47. #xtranslate :: => Self:
  48.  
  49. #xtranslate METHOD <cClassName>::<cMethodName>( [<uParms,...>] ) =>            ;
  50.             static function <cMethodName>( Self[, <uParms>] )
  51.  
  52. #xtranslate ::Parent:<method>([<uParms,...>])  =>                              ;
  53.             Eval( bClsMethod( Upper( PARENT ), Upper( <"method"> ) ),          ;
  54.             Self [,<uParms>] )
  55.  
  56. //----------------------------------------------------------------------------//
  57.