home *** CD-ROM | disk | FTP | other *** search
/ DP Tool Club 16 / CD_ASCQ_16_0994.iso / news / 4611 / fw16d.ins / INCLUDE / OBJECTS.CH < prev    next >
Text File  |  1994-05-09  |  8KB  |  223 lines

  1. /*
  2. ╔═══════════════════════════════════════════════════════════════╗
  3. ║    Objects.ch                                                 ║
  4. ║                                                               ║
  5. ║ Clipper 5.x header file for Objects.lib  V 3.0                ║
  6. ║ Fecha: Abril 1994                                             ║
  7. ║                                                               ║
  8. ║ (c) 1993-4 Francisco Pulpón y Antonio Linares                 ║
  9. ╚═══════════════════════════════════════════════════════════════╝
  10.  
  11.     ¡ Dios libre al Sr. Usuario de cambiar una sola linea de
  12.     este fichero sin haber hecho antes una copia de seguridad !
  13.  
  14.     ¡ Please, don't touch even a single line of the following <g> !
  15. */
  16.  
  17. #ifndef _OBJECTS_CH
  18. #define _OBJECTS_CH
  19.  
  20. #define _FuncType_
  21.  
  22. #xcommand DEFAULT <Desc> [, <DescN> ]      => ;
  23.                   __DFT__( <Desc> ) [ ; __DFT__( <DescN> ) ]
  24.  
  25. #xtranslate __DFT__( <Var> := <Dft> ) => ;
  26.                      <Var> := BYDEFAULT <Var>, <Dft>
  27.  
  28. #xtranslate __DFT__( <Var> = <Dft> )  => ;
  29.             __DFT__( <Var> := <Dft> )
  30.  
  31. // Una preciosa idea de Carlos Ruiz
  32. #xtranslate BYNAME <V> [, <VN> ]     => ::<V> := <V> [; ::<VN> := <VN> ]
  33. #xtranslate BYNAME <V> DEFAULT <Val> => ::<V> := BYDEFAULT <V>, <Val>
  34. #xtranslate BYDEFAULT <V>, <Val>     => if( <V> == NIL, <Val>, <V> )
  35.  
  36.  
  37. // Class Declaration
  38. // =======================
  39.  
  40. // El "Ambito" (Scope) por defecto inicial es PUBLIC. Lo pone _NewClass().
  41.  
  42. #xcommand CLASS <ClsNam>   ;
  43.             [ <from: INHERIT FROM, INHERIT, FROM, OF> <SupCls> ] ;
  44.     => ;
  45.           function _AsFunc_( <ClsNam> )  ;;
  46.              static nClassH                ;;
  47.              local Self [ := _AsFunc_( <SupCls> ) ] ;;
  48.              if nClassH == nil          ;;
  49.                 nClassH = _NewClass( _AsStr_( <ClsNam> ), Self ) ;
  50.                 [ ; #define _sUPcLS_ _AsName_( <SupCls> ) ]
  51.  
  52. #xtranslate CREATE CLASS <*ClsHead*> =>  CLASS <ClsHead>
  53.  
  54.  
  55. // Declaraciones de Variables de Instancia y de Clase.
  56. // ===================================================
  57.  
  58. #xcommand _GEN_DATA_ <vt>, <Vrs,...> [ AS <Typ,...> ] ;
  59.          [ <scp: PUBLIC, EXPORT, READONLY, PROTECTED, LOCAL, HIDDEN> ] =>  ;
  60.          _AddMethod( _AsStrLst_( <Vrs> ), [ _AsUppLst_( <Typ> ) ], ;
  61.                     __SCOPE__ [ <scp> ], <vt> )
  62.  
  63. // Declaraciones de Variables de Instancia
  64.  
  65. #xcommand VAR     <*VLst*>   => _GEN_DATA_  1, <VLst>
  66. #xcommand INSTVAR <*VLst*>   => VAR <VLst>
  67. #xcommand DATA    <*VLst*>   => VAR <VLst>
  68.  
  69. // Declaraciones de Variables de Clase.
  70.  
  71. #xcommand CLASSVAR  <*VLst*>   => _GEN_DATA_ 2, <VLst>
  72. #xcommand CLASSDATA <*VLst*>   => CLASSVAR <VLst>
  73.  
  74.  
  75. // Declaraciones de Metodos.
  76. // =========================
  77.  
  78. #xcommand __METHOD__ <Met> [, <MetN> ] [ <scp: PUBLIC, EXPORT, LOCAL, HIDDEN> ] [ <CONSTRUCTOR> ] => ;
  79.    _AddMethod(\{_MetTrans_(<Met>) [,_MetTrans_(<MetN>)]\}, __SCOPE__ [ <scp> ], <.CONSTRUCTOR.>, 0 )
  80.  
  81. #xcommand _GEN_METHOD_ <Met> [,<MetN> ] [<*x*>] =>  ;
  82.           __METHOD__  <Met> [,<MetN> ]  [<x>]
  83.  
  84. #xcommand _GEN_METHOD_ <Met> VIRTUAL [<*x*>] => __METHOD__ <Met>:_VIRTUAL_ [<x>]
  85.  
  86. #xcommand _GEN_METHOD_ <Met> SETGET [<*x*>]  => __METHOD__ <Met>:_SETGET_ [<x>]
  87.  
  88. #xcommand _GEN_METHOD_ <Met> METHOD <udf> [, <MetN> METHOD <udfN> ] [<*x*>] => ;
  89.           __METHOD__ <Met> = <udf> [ , <MetN> = <udfN> ] [<x>]
  90.  
  91. #xcommand _GEN_METHOD_ <Met> <code: EXTERN, CFUNC, CMETHOD> <udf> [<*x*>] => ;
  92.           EXTERNAL _AsName_( <udf> ) ;;
  93.           _AddMethod(\{ _AsStr_(<Met>), _AsStr_( <udf> ) \}, __SCOPE__, .f., 0 )
  94.  
  95. #xcommand _GEN_METHOD_ <Met> <o: BLOCK, INLINE> <code,...> [ <scp: PUBLIC, EXPORT, LOCAL, HIDDEN> ] => ;
  96.           _AddMethod( _BlkTrans_( <Met> <o> <code> ), __SCOPE__ [<scp>], 3 )
  97.  
  98. #xcommand MESSAGE <*cMDesc*>   => _GEN_METHOD_ <cMDesc>
  99.  
  100.  
  101. // PreAmbitos
  102. #xcommand  __ST__  <st: METHOD, MESSAGE, VAR, INSTVAR, DATA, CLASSVAR, CLASSDATA > <*x*> ;
  103.                   => <st> <x>
  104. #xcommand EXPORT  <*x*> => __ST__ <x> PUBLIC
  105. #xcommand HIDE    <*x*> => __ST__ <x> HIDDEN
  106. #xcommand PROTECT <*x*> => __ST__ <x> PROTECTED
  107.  
  108.  
  109. // Declaraciones de Scoping por defecto.
  110. // =======================================
  111. #xcommand EXPORT:     =>   _DftScope( 0 )
  112. #xcommand PUBLIC:     =>   EXPORT:
  113. #xcommand PROTECTED:  =>   _DftScope( 1 )
  114. #xcommand READONLY:   =>   PROTECTED:
  115. #xcommand LOCAL:      =>   _DftScope( 2 )
  116. #xcommand HIDDEN:     =>   LOCAL:
  117.  
  118.  
  119. // Traductores de descripciones de métodos.
  120.  
  121. #xtranslate _MetTrans_( <Met> ) => ;
  122.             _AsStr_( <Met> ), \{|| _AsName_( <Met> )() \}
  123.  
  124. #xtranslate _MetTrans_( <Met> = <udf> ) => ;
  125.             _AsStr_( <Met> ), \{|| _AsName_( <udf> )() \}
  126.  
  127. #xtranslate _MetTrans_( <Met>:_VIRTUAL_ ) => ;
  128.             _AsStr_( <Met> ), "_VIRTUAL_"
  129.  
  130. #xtranslate _MetTrans_( <Met>:_SETGET_ ) => ;
  131.             _AsStr_( <Met> ), \{|| _AsName_( <Met> )() \}, ;
  132.             "_" + _AsStr_( <Met> ), \{|| _AsName_( <Met> )() \}
  133.  
  134. #xtranslate _BlkTrans_( <Met> INLINE <code,...> ) => ;
  135.             #<Met>, \{ | Self | <code> \}
  136.  
  137. #xtranslate _BlkTrans_( <Met>( [<prm,...>] ) INLINE <code,...> ) => ;
  138.             #<Met>, \{ | Self [, <prm> ] | <code> \}
  139.  
  140. #xtranslate _BlkTrans_( <Met> BLOCK <code,...> ) => ;
  141.             _AsStr_( <Met> ), <code>
  142.  
  143. // Traductores Genéricos de <Func>[ ( [ <parms,..> ] ) ]
  144.  
  145. #xtranslate _AsFunc_( <itm> ) => <itm>()
  146. #xtranslate _AsFunc_( <itm>( [<prm,...>] ) ) =>  <itm>( [<prm>] )
  147.  
  148. #xtranslate _AsName_( <itm> ) => <itm>
  149. #xtranslate _AsName_( <itm>( [<prm,...>] ) ) =>  <itm>
  150.  
  151. #xtranslate _AsStr_( <itm> ) => #<itm>
  152. #xtranslate _AsStr_( <itm>( [<prm,...>] ) ) =>  #<itm>
  153. #xtranslate _AsUpp_( <itm> ) => upper( _AsStr_( <itm> ) )
  154.  
  155. #xtranslate _AsStrLst_( <Typ> [, <TypN> ] ) => ;
  156.             \{ _AsStr_( <Typ> ) [, _AsStr_( <TypN> ) ] \}
  157. #xtranslate _AsUppLst_( <Typ> [, <TypN> ] ) => ;
  158.             \{ _AsUpp_( <Typ> ) [, _AsUpp_( <TypN> ) ] \}
  159.  
  160. #xtranslate __SCOPE__                                => NIL
  161. #xtranslate __SCOPE__ <scp: PUBLIC, EXPORT>          => 0
  162. #xtranslate __SCOPE__ <scp: READONLY, PROTECTED>     => 1
  163. #xtranslate __SCOPE__ <scp: LOCAL, HIDDEN>           => 2
  164.  
  165. #xtranslate :VIRTUAL => :_VIRTUAL_
  166. #xtranslate :SETGET  => :_SETGET_
  167.  
  168.  
  169. #xcommand ENDCLASS  =>                                ;
  170.                        end                           ;;
  171.                        return __ClassIns( nClassH )  ;;
  172.                        #include "obendcls.ch"
  173.  
  174. #xcommand END CLASS  => ENDCLASS
  175.  
  176. // Declaraciones para el código ( función ó procedimiento ) de los métodos.
  177. // ==========================================================================
  178.  
  179. #xcommand _METHOD_ <Tp: FUNCTION, PROCEDURE> <Met> [ CLASS <ClassN> ] =>;
  180.                   _FuncType_ <Tp> <Met>  ;;
  181.                   local Self := QSelf()
  182.  
  183. #translate METHOD <Tp: FUNCTION, PROCEDURE> <*Met*> => ;
  184.                  _METHOD_ <Tp> <Met>
  185.  
  186. #translate METHOD <ClassN>::<*Met*>        => ;
  187.                  _METHOD_ FUNCTION <Met>
  188.  
  189. #translate METHOD <ClassN>.<*Met*>         => ;
  190.                  _METHOD_ FUNCTION <Met>
  191.  
  192. //   Sixtaxis Parent / Super
  193. //   =======================
  194.  
  195. #xtranslate :Parent( <SupCls> ):<*M*> => :<SupCls>:<M>
  196.  
  197. #xtranslate :Parent:<*M*>             => :_sUPcLS_:<M>
  198.  
  199. #xtranslate Super:<*M*>               => Self:_sUPcLS_:<M>
  200.  
  201. #xtranslate :Super  => :Parent
  202.  
  203. //   Self
  204. //  ======
  205. #xtranslate ::      =>    Self:
  206.  
  207. #else
  208.  
  209.  
  210. #ifdef _sUPcLS_
  211. #undef _sUPcLS_
  212. #endif
  213.  
  214. #endif  // _OBJECTS_CH
  215.  
  216. //---------------------------
  217.  
  218.   // Redefine el comando METHOD para la declaraciónes de métodos
  219.   // en el bloque de clase.
  220.   // Fue redefinido por el último "endclass" para declarar código de métodos.
  221.  
  222. #xcommand METHOD <*MDesc*> =>  _GEN_METHOD_ <MDesc>
  223.