/* * $Id$ */ ********************************************************************** // Ezek az a priori osztlyok. Amikor objektumhoz nylunk, akkor // ezek automatikusan feltltdnek. static Object static Behavior static Meta static MetaClass ********************************************************************** #include "error.ch" #include "objgen.ch" #include "object.och" #include "behavior.och" #include "meta.och" #include "metaclas.och" #define _OBJECT_PRG_ #define setCMethods(pOsztaly) ciOBJECT(pOsztaly) #define setCams(ta,tm) amOBJECT(ta,tm) #define _NO_BEHAVIOR_ #define _NO_CLOBJECT_ #include "object.och" #undef _OBJECT_PRG_ #undef setCMethods #undef setCams #undef _NO_CLOBJECT_ #undef _NO_BEHAVIOR_ #undef CTHIS #define _BEHAVIOR_PRG_ #define setCMethods(pOsztaly) ciBEHAVIOR(pOsztaly) #define setCams(ta,tm) amBEHAVIOR(ta,tm) #define _NO_META_ #define _NO_CLBEHAVIOR_ #include "behavior.och" #undef _BEHAVIOR_PRG_ #undef setCMethods #undef setCams #undef _NO_CLBEHAVIOR_ #undef _NO_META_ #undef CTHIS #define _META_PRG_ #define setCMethods(pOsztaly) ciMETA(pOsztaly) #define setCams(ta,tm) amMETA(ta,tm) #define _NO_METACLAS_ #define _NO_CLMETA_ #include "meta.och" #undef _META_PRG_ #undef setCMethods #undef setCams #undef _NO_CLMETA_ #undef _NO_METACLAS_ #undef CTHIS #include "metaclas.och" // Ktelezen ugyanaz. // #define ciMETACLAS(pOsztaly) ciMETA(pOsztaly) ********************************************************************** * * * Az OBJECT osztly * * * ********************************************************************** ********************************************************************** function clOBJECT() if (Object==nil) primitiveAllAPClassCreate() endif return Object ********************************************************************** // function clOBJECTCLASS() // Az Object osztly meta osztlyt adja. // Ez mr megvan, a Behavior az. // return clBEHAVIOR() ********************************************************************** static function ob_oinit(this) // Ez egy virtulis mvelet, az implementcija res. return this ********************************************************************** static function ob_getclass(this) return eval(this[1][1]) ********************************************************************** static function ob_isClass(this) return .f. ********************************************************************** static function ob_getAttrib(this,attribId) if (valtype(attribId)=="C") attribId:=BEHAVIOR.(OBJECT.this:getClass()):attribIdx(attribId) if (attribId==nil) errAttrib("getAttrib",{BEHAVIOR.(OBJECT.this:getClass()):name,attribId}) endif endif return this[attribId] ********************************************************************** static function ob_setAttrib(this,attribId,value) if (valtype(attribId)=="C") attribId:=BEHAVIOR.(OBJECT.this:getClass()):attribIdx(attribId) if (attribId==nil) errAttrib("getAttrib",{BEHAVIOR.(OBJECT.this:getClass()):name,attribId}) endif endif return this[attribId]:=value ********************************************************************** ********************************************************************** * * * A BEHAVIOR osztly * * * ********************************************************************** ********************************************************************** function clBEHAVIOR() // Az osztly elszedse. (class) if (Behavior==nil) primitiveAllAPClassCreate() endif return Behavior ********************************************************************** // function clBEHAVIORCLASS() // A Behavior osztly meta osztlyt adja. // Ez mr megvan, a Meta az. // return clMETA() ********************************************************************** static function be_onew(this) // Kszt egy objektumot, s inicializlja. // Az objektum a 'this' osztlyba fog tartozni. local obj obj:=BEHAVIOR.this:ocreate() OBJECT.obj:oinit() return obj ********************************************************************** static function be_ocreate(this) // Kszt egy objektumot, de nem inicializlja. // Az objektum a 'this' osztlyba fog tartozni. local obj obj:=primitiveCreateObj(this) return obj ********************************************************************** static function be_rawoinit(this,parent,name,nAttribs,nMethods,amBlock,methodsBlock) // Inicializlja a 'this' osztlyt. local w ob_oinit(this) primitiveInitClass(this,parent,name,nAttribs,nMethods,amBlock,methodsBlock) if (parent!=nil) if (BEHAVIOR.this:classId==nil) BEHAVIOR.this:parentClassIds:=BEHAVIOR.parent:parentClassIds else if (nil!=(w:=BEHAVIOR.parent:parentClassIds)) BEHAVIOR.this:parentClassIds:=w:=aclone(w) else BEHAVIOR.this:parentClassIds:=w:={} endif if (len(w)=1 .and.; valtype(obj[1])=='A' .and.; len(obj[1])>=3 .and.; valtype(obj[1][3])=='A' .and.; obj[1][3]==ob_getObjId() ********************************************************************** function getNextClassId() // Ezt kell hvnia annak az osztlynak, aki id-t akar. static id:=0 return ++id ********************************************************************** static function be_needClassId(this) return .f. ********************************************************************** static function be_isInheritFrom(this,parentClass) local w if (parentClass==nil) return .t. // Spec eset, vlaszthatnnk a .f.-t is. endif if (nil!=(w:=BEHAVIOR.parentClass:classId)) return BEHAVIOR.this:parentClassIds!=nil .and.; len(BEHAVIOR.this:parentClassIds)>=w .and.; BEHAVIOR.this:parentClassIds[w]==w endif // Fel a fn. // alert("Mszunk: "+; // "this: "+BEHAVIOR.this:name+";"+; // "parentClass: "+BEHAVIOR.parentClass:name) w:=this while(w!=nil) if (w==parentClass) return .t. endif w:=BEHAVIOR.w:parent end while return .f. **********************************************************************