reflection.bmx 122 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277
  1. Strict
  2. Rem
  3. bbdoc: BASIC/Reflection
  4. End Rem
  5. Module BRL.Reflection
  6. ModuleInfo "Version: 1.10"
  7. ModuleInfo "Author: Mark Sibly"
  8. ModuleInfo "License: zlib/libpng"
  9. ModuleInfo "Copyright: Blitz Research Ltd"
  10. ModuleInfo "Modserver: BRL"
  11. ModuleInfo "History: 1.10"
  12. ModuleInfo "History: Added LongInt and ULongInt primitives."
  13. ModuleInfo "History: 1.09"
  14. ModuleInfo "History: Threading support."
  15. ModuleInfo "History: 1.08"
  16. ModuleInfo "History: Improved metadata retrieval."
  17. ModuleInfo "History: 1.07"
  18. ModuleInfo "History: Primitive field set/get now avoids passing values through String."
  19. ModuleInfo "History: 1.06"
  20. ModuleInfo "History: Cache lower case member names and use map lookup instead of list."
  21. ModuleInfo "History: 1.05"
  22. ModuleInfo "History: Added size_t, UInt and ULong primitives."
  23. ModuleInfo "History: 1.04"
  24. ModuleInfo "History: Added support for interfaces."
  25. ModuleInfo "History: 1.03"
  26. ModuleInfo "History: Added grable enhancements."
  27. ModuleInfo "History: Added support for globals."
  28. ModuleInfo "History: 1.02 Release"
  29. ModuleInfo "History: Added Brucey's size fix to GetArrayElement()/SetArrayElement()."
  30. ModuleInfo "History: 1.01 Release"
  31. ModuleInfo "History: Fixed NewArray using temp type name"
  32. Import BRL.LinkedList
  33. Import BRL.Map
  34. Import BRL.Threads
  35. Import BRL.StringBuilder
  36. Import "reflection.c"
  37. Private
  38. Extern
  39. Function bbObjectNew:Object( class:Byte Ptr )="BBObject * bbObjectNew(BBClass *)!"
  40. ?Not ptr64
  41. Function bbObjectRegisteredTypes:Int Ptr( count Var )="BBClass** bbObjectRegisteredTypes(int *)!"
  42. Function bbObjectRegisteredInterfaces:Int Ptr( count Var )="BBInterface** bbObjectRegisteredInterfaces(int *)!"
  43. ?ptr64
  44. Function bbObjectRegisteredTypes:Long Ptr( count Var )="BBClass** bbObjectRegisteredTypes(int *)!"
  45. Function bbObjectRegisteredInterfaces:Long Ptr( count Var )="BBInterface** bbObjectRegisteredInterfaces(int *)!"
  46. ?
  47. Function bbArrayNew1D:Object( typeTag:Byte Ptr,length )="BBArray* bbArrayNew1D(const char *,int )!"
  48. Function bbArraySlice:Object( typeTag:Byte Ptr, _array:Object, _start:Int, _end:Int)="BBArray* bbArraySlice(const char *, BBArray*, int, int)!"
  49. Function bbRefArrayClass:Byte Ptr()
  50. Function bbRefStringClass:Byte Ptr()
  51. Function bbRefObjectClass:Byte Ptr()
  52. Function bbRefArrayLength( _array:Object, dim:Int = 0 )
  53. Function bbRefArrayTypeTag:String( _array:Object )
  54. Function bbRefArrayDimensions:Int( _array:Object )
  55. Function bbRefArrayCreate:Object( typeTag:Byte Ptr,dims:Int[] )
  56. Function bbRefFieldPtr:Byte Ptr( obj:Object,index )
  57. Function bbRefMethodPtr:Byte Ptr( obj:Object,index )
  58. Function bbRefArrayElementPtr:Byte Ptr( sz,_array:Object,index )
  59. Function bbRefGetObject:Object( p:Byte Ptr )
  60. Function bbRefPushObject( p:Byte Ptr,obj:Object )
  61. Function bbRefInitObject( p:Byte Ptr,obj:Object )
  62. Function bbRefAssignObject( p:Byte Ptr,obj:Object )
  63. Function bbRefGetObjectClass:Byte Ptr( obj:Object )
  64. Function bbRefGetSuperClass:Byte Ptr( class:Byte Ptr )
  65. Function bbStringFromRef:String( ref:Byte Ptr )
  66. Function bbRefArrayNull:Object()
  67. Function bbInterfaceName:Byte Ptr(ifc:Byte Ptr)
  68. Function bbInterfaceClass:Byte Ptr(ifc:Byte Ptr)
  69. Function bbObjectImplementsInterfaces:Int(class:Byte Ptr)
  70. Function bbObjectImplementedCount:Int(class:Byte Ptr)
  71. Function bbObjectImplementedInterface:Byte Ptr(class:Byte Ptr, index:Int)
  72. Function bbRefClassSuper:Byte Ptr(clas:Byte Ptr)
  73. Function bbRefClassDebugScope:Byte Ptr(clas:Byte Ptr)
  74. Function bbRefClassDebugDecl:Byte Ptr(clas:Byte Ptr)
  75. Function bbRefClassDebugScopeName:Byte Ptr(class:Byte Ptr)
  76. Function bbDebugDeclKind:Int(decl:Byte Ptr)
  77. Function bbDebugDeclName:Byte Ptr(decl:Byte Ptr)
  78. Function bbDebugDeclType:Byte Ptr(decl:Byte Ptr)
  79. Function bbDebugDeclConstValue:String(decl:Byte Ptr)
  80. Function bbDebugDeclFieldOffset:Int(decl:Byte Ptr)
  81. Function bbDebugDeclVarAddress:Byte Ptr(decl:Byte Ptr)
  82. Function bbDebugDeclNext:Byte Ptr(decl:Byte Ptr)
  83. End Extern
  84. Global _guard:TMutex = TMutex.Create()
  85. Function _Get:Object( p:Byte Ptr,typeId:TTypeId )
  86. Select typeId
  87. Case ByteTypeId
  88. Return String.FromInt( (Byte Ptr p)[0] )
  89. Case ShortTypeId
  90. Return String.FromInt( (Short Ptr p)[0] )
  91. Case IntTypeId
  92. Return String.FromInt( (Int Ptr p)[0] )
  93. Case UIntTypeId
  94. Return String.FromUInt( (UInt Ptr p)[0] )
  95. Case LongTypeId
  96. Return String.FromLong( (Long Ptr p)[0] )
  97. Case ULongTypeId
  98. Return String.FromULong( (ULong Ptr p)[0] )
  99. Case SizetTypeId
  100. Return String.FromSizet( (Size_T Ptr p)[0] )
  101. Case FloatTypeId
  102. Return String.FromFloat( (Float Ptr p)[0] )
  103. Case DoubleTypeId
  104. Return String.FromDouble( (Double Ptr p)[0] )
  105. Case LongIntTypeId
  106. Return String.FromLongInt( (LongInt Ptr p)[0] )
  107. Case ULongIntTypeId
  108. Return String.FromULongInt( (ULongInt Ptr p)[0] )
  109. Default
  110. If typeid.ExtendsType(PointerTypeId) Or typeid.ExtendsType(FunctionTypeId) Then
  111. ?Not ptr64
  112. Return String.FromInt( (Int Ptr p)[0] )
  113. ?ptr64
  114. Return String.FromLong( (Long Ptr p)[0] )
  115. ?
  116. EndIf
  117. Return bbRefGetObject( p )
  118. End Select
  119. End Function
  120. Function _Push:Byte Ptr( sp:Byte Ptr,typeId:TTypeId,value:Object )
  121. Select typeId
  122. Case ByteTypeId,ShortTypeId,IntTypeId
  123. (Int Ptr sp)[0]=value.ToString().ToInt()
  124. Return sp+4
  125. Case UIntTypeId
  126. (UInt Ptr sp)[0]=value.ToString().ToUInt()
  127. Return sp+4
  128. Case LongTypeId
  129. (Long Ptr sp)[0]=value.ToString().ToLong()
  130. Return sp+8
  131. Case ULongTypeId
  132. (ULong Ptr sp)[0]=value.ToString().ToULong()
  133. Return sp+8
  134. Case SizetTypeId
  135. (Size_T Ptr sp)[0]=value.ToString().ToSizet()
  136. ?Not ptr64
  137. Return sp+4
  138. ?ptr64
  139. Return sp+8
  140. ?
  141. Case FloatTypeId
  142. (Float Ptr sp)[0]=value.ToString().ToFloat()
  143. Return sp+4
  144. Case DoubleTypeId
  145. (Double Ptr sp)[0]=value.ToString().ToDouble()
  146. Return sp+8
  147. Case LongIntTypeId
  148. (LongInt Ptr sp)[0]=value.ToString().ToLongInt()
  149. ?Not ptr64
  150. Return sp+4
  151. ?ptr64 and not win32
  152. Return sp+8
  153. ?ptr64 and win32
  154. Return sp+4
  155. ?
  156. Case ULongIntTypeId
  157. (ULongInt Ptr sp)[0]=value.ToString().ToULongInt()
  158. ?Not ptr64
  159. Return sp+4
  160. ?ptr64 and not win32
  161. Return sp+8
  162. ?ptr64 and win32
  163. Return sp+4
  164. ?
  165. Case StringTypeId
  166. If Not value value=""
  167. bbRefPushObject sp,value
  168. Return sp+4
  169. Default
  170. If value
  171. If typeid.ExtendsType(PointerTypeId) Or typeid.ExtendsType(FunctionTypeId) Then
  172. ?Not ptr64
  173. (Int Ptr sp)[0]=value.ToString().ToInt()
  174. Return sp+4
  175. ?ptr64
  176. (Long Ptr sp)[0]=value.ToString().ToLong()
  177. Return sp+8
  178. ?
  179. EndIf
  180. Local c:Byte Ptr=typeId._class
  181. Local t:Byte Ptr=bbRefGetObjectClass( value )
  182. While t And t<>c
  183. t=bbRefGetSuperClass( t )
  184. Wend
  185. If Not t Throw "ERROR"
  186. EndIf
  187. bbRefPushObject sp,value
  188. Return sp+4
  189. End Select
  190. End Function
  191. Function _Assign( p:Byte Ptr,typeId:TTypeId,value:Object )
  192. Select typeId
  193. Case ByteTypeId
  194. (Byte Ptr p)[0]=value.ToString().ToInt()
  195. Case ShortTypeId
  196. (Short Ptr p)[0]=value.ToString().ToInt()
  197. Case IntTypeId
  198. (Int Ptr p)[0]=value.ToString().ToInt()
  199. Case UIntTypeId
  200. (UInt Ptr p)[0]=value.ToString().ToUInt()
  201. Case LongTypeId
  202. (Long Ptr p)[0]=value.ToString().ToLong()
  203. Case ULongTypeId
  204. (ULong Ptr p)[0]=value.ToString().ToULong()
  205. Case SizetTypeId
  206. (Size_T Ptr p)[0]=value.ToString().ToSizet()
  207. Case FloatTypeId
  208. (Float Ptr p)[0]=value.ToString().ToFloat()
  209. Case DoubleTypeId
  210. (Double Ptr p)[0]=value.ToString().ToDouble()
  211. Case LongIntTypeId
  212. (LongInt Ptr p)[0]=value.ToString().ToLongInt()
  213. Case ULongIntTypeId
  214. (ULongInt Ptr p)[0]=value.ToString().ToULongInt()
  215. Case StringTypeId
  216. If Not value value=""
  217. bbRefAssignObject p,value
  218. Default
  219. If value
  220. If typeid.ExtendsType(PointerTypeId) Or typeid.ExtendsType(FunctionTypeId) Then
  221. ?Not ptr64
  222. (Int Ptr p)[0]=value.ToString().ToInt()
  223. ?ptr64
  224. (Long Ptr p)[0]=value.ToString().ToLong()
  225. ?
  226. Return
  227. EndIf
  228. Local c:Byte Ptr=typeId._class
  229. Local t:Byte Ptr=bbRefGetObjectClass( value )
  230. While t And t<>c
  231. t=bbRefGetSuperClass( t )
  232. Wend
  233. If Not t Throw "ERROR"
  234. Else
  235. If typeId.Name().Endswith("]") Then
  236. value = bbRefArrayNull()
  237. EndIf
  238. EndIf
  239. bbRefAssignObject p,value
  240. End Select
  241. End Function
  242. Function _CallFunction:Object( p:Byte Ptr,typeId:TTypeId,args:Object[],argTypes:TTypeId[] )
  243. Local q:Byte Ptr[10]
  244. If args Then
  245. For Local i=0 Until args.length
  246. _Push( Varptr q[i],argTypes[i],args[i] )
  247. Next
  248. End If
  249. Select typeId
  250. Case ByteTypeId,ShortTypeId,IntTypeId
  251. Select argTypes.length
  252. Case 0
  253. Local f:Int()=p
  254. Return String.FromInt( f() )
  255. Case 1
  256. Local f:Int(p0:Byte Ptr)=p
  257. Return String.FromInt( f(q[0]) )
  258. Case 2
  259. Local f:Int(p0:Byte Ptr, p1:Byte Ptr)=p
  260. Return String.FromInt( f(q[0], q[1]) )
  261. Case 3
  262. Local f:Int(p0:Byte Ptr, p1:Byte Ptr, p2:Byte Ptr)=p
  263. Return String.FromInt( f(q[0], q[1], q[2]) )
  264. Case 4
  265. Local f:Int(p0:Byte Ptr, p1:Byte Ptr, p2:Byte Ptr, p3:Byte Ptr)=p
  266. Return String.FromInt( f(q[0], q[1], q[2], q[3]) )
  267. Case 5
  268. Local f:Int(p0:Byte Ptr, p1:Byte Ptr, p2:Byte Ptr, p3:Byte Ptr, p4:Byte Ptr)=p
  269. Return String.FromInt( f(q[0], q[1], q[2], q[3], q[4]) )
  270. Case 6
  271. Local f:Int(p0:Byte Ptr, p1:Byte Ptr, p2:Byte Ptr, p3:Byte Ptr, p4:Byte Ptr, p5:Byte Ptr)=p
  272. Return String.FromInt( f(q[0], q[1], q[2], q[3], q[4], q[5]) )
  273. Case 7
  274. Local f:Int(p0:Byte Ptr, p1:Byte Ptr, p2:Byte Ptr, p3:Byte Ptr, p4:Byte Ptr, p5:Byte Ptr, p6:Byte Ptr)=p
  275. Return String.FromInt( f(q[0], q[1], q[2], q[3], q[4], q[5], q[6]) )
  276. Case 8
  277. Local f:Int(p0:Byte Ptr, p1:Byte Ptr, p2:Byte Ptr, p3:Byte Ptr, p4:Byte Ptr, p5:Byte Ptr, p6:Byte Ptr, p7:Byte Ptr)=p
  278. Return String.FromInt( f(q[0], q[1], q[2], q[3], q[4], q[5], q[6], q[7]) )
  279. Default
  280. Local f:Int(p0:Byte Ptr,p1:Byte Ptr,p2:Byte Ptr,p3:Byte Ptr,p4:Byte Ptr,p5:Byte Ptr,p6:Byte Ptr,p7:Byte Ptr)=p
  281. Return String.FromInt( f( q[0],q[1],q[2],q[3],q[4],q[5],q[6],q[7] ) )
  282. End Select
  283. ?Not ptr64
  284. Case UIntTypeId,SizetTypeId
  285. ?ptr64
  286. Case UIntTypeId
  287. ?
  288. Select argTypes.length
  289. Case 0
  290. Local f:UInt()=p
  291. Return String.FromUInt( f() )
  292. Case 1
  293. Local f:UInt(p0:Byte Ptr)=p
  294. Return String.FromUInt( f(q[0]) )
  295. Case 2
  296. Local f:UInt(p0:Byte Ptr, p1:Byte Ptr)=p
  297. Return String.FromUInt( f(q[0], q[1]) )
  298. Case 3
  299. Local f:UInt(p0:Byte Ptr, p1:Byte Ptr, p2:Byte Ptr)=p
  300. Return String.FromUInt( f(q[0], q[1], q[2]) )
  301. Case 4
  302. Local f:UInt(p0:Byte Ptr, p1:Byte Ptr, p2:Byte Ptr, p3:Byte Ptr)=p
  303. Return String.FromUInt( f(q[0], q[1], q[2], q[3]) )
  304. Case 5
  305. Local f:UInt(p0:Byte Ptr, p1:Byte Ptr, p2:Byte Ptr, p3:Byte Ptr, p4:Byte Ptr)=p
  306. Return String.FromUInt( f(q[0], q[1], q[2], q[3], q[4]) )
  307. Case 6
  308. Local f:UInt(p0:Byte Ptr, p1:Byte Ptr, p2:Byte Ptr, p3:Byte Ptr, p4:Byte Ptr, p5:Byte Ptr)=p
  309. Return String.FromUInt( f(q[0], q[1], q[2], q[3], q[4], q[5]) )
  310. Case 7
  311. Local f:UInt(p0:Byte Ptr, p1:Byte Ptr, p2:Byte Ptr, p3:Byte Ptr, p4:Byte Ptr, p5:Byte Ptr, p6:Byte Ptr)=p
  312. Return String.FromUInt( f(q[0], q[1], q[2], q[3], q[4], q[5], q[6]) )
  313. Case 8
  314. Local f:UInt(p0:Byte Ptr, p1:Byte Ptr, p2:Byte Ptr, p3:Byte Ptr, p4:Byte Ptr, p5:Byte Ptr, p6:Byte Ptr, p7:Byte Ptr)=p
  315. Return String.FromUInt( f(q[0], q[1], q[2], q[3], q[4], q[5], q[6], q[7]) )
  316. Default
  317. Local f:UInt(p0:Byte Ptr,p1:Byte Ptr,p2:Byte Ptr,p3:Byte Ptr,p4:Byte Ptr,p5:Byte Ptr,p6:Byte Ptr,p7:Byte Ptr)=p
  318. Return String.FromUInt( f( q[0],q[1],q[2],q[3],q[4],q[5],q[6],q[7] ) )
  319. End Select
  320. Case LongTypeId
  321. Select argTypes.length
  322. Case 0
  323. Local f:Long()=p
  324. Return String.Fromlong( f() )
  325. Case 1
  326. Local f:Long(p0:Byte Ptr)=p
  327. Return String.Fromlong( f(q[0]) )
  328. Case 2
  329. Local f:Long(p0:Byte Ptr, p1:Byte Ptr)=p
  330. Return String.Fromlong( f(q[0], q[1]) )
  331. Case 3
  332. Local f:Long(p0:Byte Ptr, p1:Byte Ptr, p2:Byte Ptr)=p
  333. Return String.Fromlong( f(q[0], q[1], q[2]) )
  334. Case 4
  335. Local f:Long(p0:Byte Ptr, p1:Byte Ptr, p2:Byte Ptr, p3:Byte Ptr)=p
  336. Return String.Fromlong( f(q[0], q[1], q[2], q[3]) )
  337. Case 5
  338. Local f:Long(p0:Byte Ptr, p1:Byte Ptr, p2:Byte Ptr, p3:Byte Ptr, p4:Byte Ptr)=p
  339. Return String.Fromlong( f(q[0], q[1], q[2], q[3], q[4]) )
  340. Case 6
  341. Local f:Long(p0:Byte Ptr, p1:Byte Ptr, p2:Byte Ptr, p3:Byte Ptr, p4:Byte Ptr, p5:Byte Ptr)=p
  342. Return String.Fromlong( f(q[0], q[1], q[2], q[3], q[4], q[5]) )
  343. Case 7
  344. Local f:Long(p0:Byte Ptr, p1:Byte Ptr, p2:Byte Ptr, p3:Byte Ptr, p4:Byte Ptr, p5:Byte Ptr, p6:Byte Ptr)=p
  345. Return String.Fromlong( f(q[0], q[1], q[2], q[3], q[4], q[5], q[6]) )
  346. Case 8
  347. Local f:Long(p0:Byte Ptr, p1:Byte Ptr, p2:Byte Ptr, p3:Byte Ptr, p4:Byte Ptr, p5:Byte Ptr, p6:Byte Ptr, p7:Byte Ptr)=p
  348. Return String.Fromlong( f(q[0], q[1], q[2], q[3], q[4], q[5], q[6], q[7]) )
  349. Default
  350. Local f:Long(p0:Byte Ptr,p1:Byte Ptr,p2:Byte Ptr,p3:Byte Ptr,p4:Byte Ptr,p5:Byte Ptr,p6:Byte Ptr,p7:Byte Ptr)=p
  351. Return String.Fromlong( f( q[0],q[1],q[2],q[3],q[4],q[5],q[6],q[7] ) )
  352. End Select
  353. ?Not ptr64
  354. Case ULongTypeId
  355. ?ptr64
  356. Case ULongTypeId,SizetTypeId
  357. ?
  358. Select argTypes.length
  359. Case 0
  360. Local f:ULong()=p
  361. Return String.FromULong( f() )
  362. Case 1
  363. Local f:ULong(p0:Byte Ptr)=p
  364. Return String.FromULong( f(q[0]) )
  365. Case 2
  366. Local f:ULong(p0:Byte Ptr, p1:Byte Ptr)=p
  367. Return String.FromULong( f(q[0], q[1]) )
  368. Case 3
  369. Local f:ULong(p0:Byte Ptr, p1:Byte Ptr, p2:Byte Ptr)=p
  370. Return String.FromULong( f(q[0], q[1], q[2]) )
  371. Case 4
  372. Local f:ULong(p0:Byte Ptr, p1:Byte Ptr, p2:Byte Ptr, p3:Byte Ptr)=p
  373. Return String.FromULong( f(q[0], q[1], q[2], q[3]) )
  374. Case 5
  375. Local f:ULong(p0:Byte Ptr, p1:Byte Ptr, p2:Byte Ptr, p3:Byte Ptr, p4:Byte Ptr)=p
  376. Return String.FromULong( f(q[0], q[1], q[2], q[3], q[4]) )
  377. Case 6
  378. Local f:ULong(p0:Byte Ptr, p1:Byte Ptr, p2:Byte Ptr, p3:Byte Ptr, p4:Byte Ptr, p5:Byte Ptr)=p
  379. Return String.FromULong( f(q[0], q[1], q[2], q[3], q[4], q[5]) )
  380. Case 7
  381. Local f:ULong(p0:Byte Ptr, p1:Byte Ptr, p2:Byte Ptr, p3:Byte Ptr, p4:Byte Ptr, p5:Byte Ptr, p6:Byte Ptr)=p
  382. Return String.FromULong( f(q[0], q[1], q[2], q[3], q[4], q[5], q[6]) )
  383. Case 8
  384. Local f:ULong(p0:Byte Ptr, p1:Byte Ptr, p2:Byte Ptr, p3:Byte Ptr, p4:Byte Ptr, p5:Byte Ptr, p6:Byte Ptr, p7:Byte Ptr)=p
  385. Return String.FromULong( f(q[0], q[1], q[2], q[3], q[4], q[5], q[6], q[7]) )
  386. Default
  387. Local f:ULong(p0:Byte Ptr,p1:Byte Ptr,p2:Byte Ptr,p3:Byte Ptr,p4:Byte Ptr,p5:Byte Ptr,p6:Byte Ptr,p7:Byte Ptr)=p
  388. Return String.FromULong( f( q[0],q[1],q[2],q[3],q[4],q[5],q[6],q[7] ) )
  389. End Select
  390. Case FloatTypeId
  391. Select argTypes.length
  392. Case 0
  393. Local f:Float()=p
  394. Return String.FromFloat( f() )
  395. Case 1
  396. Local f:Float(p0:Byte Ptr)=p
  397. Return String.FromFloat( f(q[0]) )
  398. Case 2
  399. Local f:Float(p0:Byte Ptr, p1:Byte Ptr)=p
  400. Return String.FromFloat( f(q[0], q[1]) )
  401. Case 3
  402. Local f:Float(p0:Byte Ptr, p1:Byte Ptr, p2:Byte Ptr)=p
  403. Return String.FromFloat( f(q[0], q[1], q[2]) )
  404. Case 4
  405. Local f:Float(p0:Byte Ptr, p1:Byte Ptr, p2:Byte Ptr, p3:Byte Ptr)=p
  406. Return String.FromFloat( f(q[0], q[1], q[2], q[3]) )
  407. Case 5
  408. Local f:Float(p0:Byte Ptr, p1:Byte Ptr, p2:Byte Ptr, p3:Byte Ptr, p4:Byte Ptr)=p
  409. Return String.FromFloat( f(q[0], q[1], q[2], q[3], q[4]) )
  410. Case 6
  411. Local f:Float(p0:Byte Ptr, p1:Byte Ptr, p2:Byte Ptr, p3:Byte Ptr, p4:Byte Ptr, p5:Byte Ptr)=p
  412. Return String.FromFloat( f(q[0], q[1], q[2], q[3], q[4], q[5]) )
  413. Case 7
  414. Local f:Float(p0:Byte Ptr, p1:Byte Ptr, p2:Byte Ptr, p3:Byte Ptr, p4:Byte Ptr, p5:Byte Ptr, p6:Byte Ptr)=p
  415. Return String.FromFloat( f(q[0], q[1], q[2], q[3], q[4], q[5], q[6]) )
  416. Case 8
  417. Local f:Float(p0:Byte Ptr, p1:Byte Ptr, p2:Byte Ptr, p3:Byte Ptr, p4:Byte Ptr, p5:Byte Ptr, p6:Byte Ptr, p7:Byte Ptr)=p
  418. Return String.FromFloat( f(q[0], q[1], q[2], q[3], q[4], q[5], q[6], q[7]) )
  419. Default
  420. Local f:Float(p0:Byte Ptr,p1:Byte Ptr,p2:Byte Ptr,p3:Byte Ptr,p4:Byte Ptr,p5:Byte Ptr,p6:Byte Ptr,p7:Byte Ptr)=p
  421. Return String.FromFloat( f( q[0],q[1],q[2],q[3],q[4],q[5],q[6],q[7] ) )
  422. End Select
  423. Case DoubleTypeId
  424. Select argTypes.length
  425. Case 0
  426. Local f:Double()=p
  427. Return String.FromDouble( f() )
  428. Case 1
  429. Local f:Double(p0:Byte Ptr)=p
  430. Return String.FromDouble( f(q[0]) )
  431. Case 2
  432. Local f:Double(p0:Byte Ptr, p1:Byte Ptr)=p
  433. Return String.FromDouble( f(q[0], q[1]) )
  434. Case 3
  435. Local f:Double(p0:Byte Ptr, p1:Byte Ptr, p2:Byte Ptr)=p
  436. Return String.FromDouble( f(q[0], q[1], q[2]) )
  437. Case 4
  438. Local f:Double(p0:Byte Ptr, p1:Byte Ptr, p2:Byte Ptr, p3:Byte Ptr)=p
  439. Return String.FromDouble( f(q[0], q[1], q[2], q[3]) )
  440. Case 5
  441. Local f:Double(p0:Byte Ptr, p1:Byte Ptr, p2:Byte Ptr, p3:Byte Ptr, p4:Byte Ptr)=p
  442. Return String.FromDouble( f(q[0], q[1], q[2], q[3], q[4]) )
  443. Case 6
  444. Local f:Double(p0:Byte Ptr, p1:Byte Ptr, p2:Byte Ptr, p3:Byte Ptr, p4:Byte Ptr, p5:Byte Ptr)=p
  445. Return String.FromDouble( f(q[0], q[1], q[2], q[3], q[4], q[5]) )
  446. Case 7
  447. Local f:Double(p0:Byte Ptr, p1:Byte Ptr, p2:Byte Ptr, p3:Byte Ptr, p4:Byte Ptr, p5:Byte Ptr, p6:Byte Ptr)=p
  448. Return String.FromDouble( f(q[0], q[1], q[2], q[3], q[4], q[5], q[6]) )
  449. Case 8
  450. Local f:Double(p0:Byte Ptr, p1:Byte Ptr, p2:Byte Ptr, p3:Byte Ptr, p4:Byte Ptr, p5:Byte Ptr, p6:Byte Ptr, p7:Byte Ptr)=p
  451. Return String.FromDouble( f(q[0], q[1], q[2], q[3], q[4], q[5], q[6], q[7]) )
  452. Default
  453. Local f:Double(p0:Byte Ptr,p1:Byte Ptr,p2:Byte Ptr,p3:Byte Ptr,p4:Byte Ptr,p5:Byte Ptr,p6:Byte Ptr,p7:Byte Ptr)=p
  454. Return String.FromDouble( f( q[0],q[1],q[2],q[3],q[4],q[5],q[6],q[7] ) )
  455. End Select
  456. Case VoidTypeId
  457. Select argTypes.length
  458. Case 0
  459. Local f()=p
  460. f()
  461. Case 1
  462. Local f(p0:Byte Ptr)=p
  463. f(q[0])
  464. Case 2
  465. Local f(p0:Byte Ptr, p1:Byte Ptr)=p
  466. f(q[0], q[1])
  467. Case 3
  468. Local f(p0:Byte Ptr, p1:Byte Ptr, p2:Byte Ptr)=p
  469. f(q[0], q[1], q[2])
  470. Case 4
  471. Local f(p0:Byte Ptr, p1:Byte Ptr, p2:Byte Ptr, p3:Byte Ptr)=p
  472. f(q[0], q[1], q[2], q[3])
  473. Case 5
  474. Local f(p0:Byte Ptr, p1:Byte Ptr, p2:Byte Ptr, p3:Byte Ptr, p4:Byte Ptr)=p
  475. f(q[0], q[1], q[2], q[3], q[4])
  476. Case 6
  477. Local f(p0:Byte Ptr, p1:Byte Ptr, p2:Byte Ptr, p3:Byte Ptr, p4:Byte Ptr, p5:Byte Ptr)=p
  478. f(q[0], q[1], q[2], q[3], q[4], q[5])
  479. Case 7
  480. Local f(p0:Byte Ptr, p1:Byte Ptr, p2:Byte Ptr, p3:Byte Ptr, p4:Byte Ptr, p5:Byte Ptr, p6:Byte Ptr)=p
  481. f(q[0], q[1], q[2], q[3], q[4], q[5], q[6])
  482. Case 8
  483. Local f(p0:Byte Ptr, p1:Byte Ptr, p2:Byte Ptr, p3:Byte Ptr, p4:Byte Ptr, p5:Byte Ptr, p6:Byte Ptr, p7:Byte Ptr)=p
  484. f(q[0], q[1], q[2], q[3], q[4], q[5], q[6], q[7])
  485. Default
  486. Local f(p0:Byte Ptr,p1:Byte Ptr,p2:Byte Ptr,p3:Byte Ptr,p4:Byte Ptr,p5:Byte Ptr,p6:Byte Ptr,p7:Byte Ptr)=p
  487. f( q[0],q[1],q[2],q[3],q[4],q[5],q[6],q[7] )
  488. End Select
  489. Case LongIntTypeId
  490. Select argTypes.length
  491. Case 0
  492. Local f:LongInt()=p
  493. Return String.FromLongInt( f() )
  494. Case 1
  495. Local f:LongInt(p0:Byte Ptr)=p
  496. Return String.FromLongInt( f(q[0]) )
  497. Case 2
  498. Local f:LongInt(p0:Byte Ptr, p1:Byte Ptr)=p
  499. Return String.FromLongInt( f(q[0], q[1]) )
  500. Case 3
  501. Local f:LongInt(p0:Byte Ptr, p1:Byte Ptr, p2:Byte Ptr)=p
  502. Return String.FromLongInt( f(q[0], q[1], q[2]) )
  503. Case 4
  504. Local f:LongInt(p0:Byte Ptr, p1:Byte Ptr, p2:Byte Ptr, p3:Byte Ptr)=p
  505. Return String.FromLongInt( f(q[0], q[1], q[2], q[3]) )
  506. Case 5
  507. Local f:LongInt(p0:Byte Ptr, p1:Byte Ptr, p2:Byte Ptr, p3:Byte Ptr, p4:Byte Ptr)=p
  508. Return String.FromLongInt( f(q[0], q[1], q[2], q[3], q[4]) )
  509. Case 6
  510. Local f:LongInt(p0:Byte Ptr, p1:Byte Ptr, p2:Byte Ptr, p3:Byte Ptr, p4:Byte Ptr, p5:Byte Ptr)=p
  511. Return String.FromLongInt( f(q[0], q[1], q[2], q[3], q[4], q[5]) )
  512. Case 7
  513. Local f:LongInt(p0:Byte Ptr, p1:Byte Ptr, p2:Byte Ptr, p3:Byte Ptr, p4:Byte Ptr, p5:Byte Ptr, p6:Byte Ptr)=p
  514. Return String.FromLongInt( f(q[0], q[1], q[2], q[3], q[4], q[5], q[6]) )
  515. Case 8
  516. Local f:LongInt(p0:Byte Ptr, p1:Byte Ptr, p2:Byte Ptr, p3:Byte Ptr, p4:Byte Ptr, p5:Byte Ptr, p6:Byte Ptr, p7:Byte Ptr)=p
  517. Return String.FromLongInt( f(q[0], q[1], q[2], q[3], q[4], q[5], q[6], q[7]) )
  518. Default
  519. Local f:LongInt(p0:Byte Ptr,p1:Byte Ptr,p2:Byte Ptr,p3:Byte Ptr,p4:Byte Ptr,p5:Byte Ptr,p6:Byte Ptr,p7:Byte Ptr)=p
  520. Return String.FromLongInt( f( q[0],q[1],q[2],q[3],q[4],q[5],q[6],q[7] ) )
  521. End Select
  522. Case ULongIntTypeId
  523. Select argTypes.length
  524. Case 0
  525. Local f:ULongInt()=p
  526. Return String.FromULongInt( f() )
  527. Case 1
  528. Local f:ULongInt(p0:Byte Ptr)=p
  529. Return String.FromULongInt( f(q[0]) )
  530. Case 2
  531. Local f:ULongInt(p0:Byte Ptr, p1:Byte Ptr)=p
  532. Return String.FromULongInt( f(q[0], q[1]) )
  533. Case 3
  534. Local f:ULongInt(p0:Byte Ptr, p1:Byte Ptr, p2:Byte Ptr)=p
  535. Return String.FromULongInt( f(q[0], q[1], q[2]) )
  536. Case 4
  537. Local f:ULongInt(p0:Byte Ptr, p1:Byte Ptr, p2:Byte Ptr, p3:Byte Ptr)=p
  538. Return String.FromULongInt( f(q[0], q[1], q[2], q[3]) )
  539. Case 5
  540. Local f:ULongInt(p0:Byte Ptr, p1:Byte Ptr, p2:Byte Ptr, p3:Byte Ptr, p4:Byte Ptr)=p
  541. Return String.FromULongInt( f(q[0], q[1], q[2], q[3], q[4]) )
  542. Case 6
  543. Local f:ULongInt(p0:Byte Ptr, p1:Byte Ptr, p2:Byte Ptr, p3:Byte Ptr, p4:Byte Ptr, p5:Byte Ptr)=p
  544. Return String.FromULongInt( f(q[0], q[1], q[2], q[3], q[4], q[5]) )
  545. Case 7
  546. Local f:ULongInt(p0:Byte Ptr, p1:Byte Ptr, p2:Byte Ptr, p3:Byte Ptr, p4:Byte Ptr, p5:Byte Ptr, p6:Byte Ptr)=p
  547. Return String.FromULongInt( f(q[0], q[1], q[2], q[3], q[4], q[5], q[6]) )
  548. Case 8
  549. Local f:ULongInt(p0:Byte Ptr, p1:Byte Ptr, p2:Byte Ptr, p3:Byte Ptr, p4:Byte Ptr, p5:Byte Ptr, p6:Byte Ptr, p7:Byte Ptr)=p
  550. Return String.FromULongInt( f(q[0], q[1], q[2], q[3], q[4], q[5], q[6], q[7]) )
  551. Default
  552. Local f:ULongInt(p0:Byte Ptr,p1:Byte Ptr,p2:Byte Ptr,p3:Byte Ptr,p4:Byte Ptr,p5:Byte Ptr,p6:Byte Ptr,p7:Byte Ptr)=p
  553. Return String.FromULongInt( f( q[0],q[1],q[2],q[3],q[4],q[5],q[6],q[7] ) )
  554. End Select
  555. Default
  556. If typeid.ExtendsType(PointerTypeId) Or typeid.ExtendsType(FunctionTypeId) Then
  557. ?Not ptr64
  558. Select argTypes.length
  559. Case 0
  560. Local f:Byte Ptr()=p
  561. Return String.FromInt(Int f())
  562. Case 1
  563. Local f:Byte Ptr(p0:Byte Ptr)=p
  564. Return String.FromInt(Int f(q[0]))
  565. Case 2
  566. Local f:Byte Ptr(p0:Byte Ptr, p1:Byte Ptr)=p
  567. Return String.FromInt(Int f(q[0], q[1]))
  568. Case 3
  569. Local f:Byte Ptr(p0:Byte Ptr, p1:Byte Ptr, p2:Byte Ptr)=p
  570. Return String.FromInt(Int f(q[0], q[1], q[2]))
  571. Case 4
  572. Local f:Byte Ptr(p0:Byte Ptr, p1:Byte Ptr, p2:Byte Ptr, p3:Byte Ptr)=p
  573. Return String.FromInt(Int f(q[0], q[1], q[2], q[3]))
  574. Case 5
  575. Local f:Byte Ptr(p0:Byte Ptr, p1:Byte Ptr, p2:Byte Ptr, p3:Byte Ptr, p4:Byte Ptr)=p
  576. Return String.FromInt(Int f(q[0], q[1], q[2], q[3], q[4]))
  577. Case 6
  578. Local f:Byte Ptr(p0:Byte Ptr, p1:Byte Ptr, p2:Byte Ptr, p3:Byte Ptr, p4:Byte Ptr, p5:Byte Ptr)=p
  579. Return String.FromInt(Int f(q[0], q[1], q[2], q[3], q[4], q[5]))
  580. Case 7
  581. Local f:Byte Ptr(p0:Byte Ptr, p1:Byte Ptr, p2:Byte Ptr, p3:Byte Ptr, p4:Byte Ptr, p5:Byte Ptr, p6:Byte Ptr)=p
  582. Return String.FromInt(Int f(q[0], q[1], q[2], q[3], q[4], q[5], q[6]))
  583. Case 8
  584. Local f:Byte Ptr(p0:Byte Ptr, p1:Byte Ptr, p2:Byte Ptr, p3:Byte Ptr, p4:Byte Ptr, p5:Byte Ptr, p6:Byte Ptr, p7:Byte Ptr)=p
  585. Return String.FromInt(Int f(q[0], q[1], q[2], q[3], q[4], q[5], q[6], q[7]))
  586. Default
  587. Local f:Byte Ptr(p0:Byte Ptr,p1:Byte Ptr,p2:Byte Ptr,p3:Byte Ptr,p4:Byte Ptr,p5:Byte Ptr,p6:Byte Ptr,p7:Byte Ptr)=p
  588. Return String.FromInt(Int f( q[0],q[1],q[2],q[3],q[4],q[5],q[6],q[7] ))
  589. End Select
  590. ?ptr64
  591. Select argTypes.length
  592. Case 0
  593. Local f:Byte Ptr()=p
  594. Return String.Fromlong(Long f())
  595. Case 1
  596. Local f:Byte Ptr(p0:Byte Ptr)=p
  597. Return String.Fromlong(Long f(q[0]))
  598. Case 2
  599. Local f:Byte Ptr(p0:Byte Ptr, p1:Byte Ptr)=p
  600. Return String.Fromlong(Long f(q[0], q[1]))
  601. Case 3
  602. Local f:Byte Ptr(p0:Byte Ptr, p1:Byte Ptr, p2:Byte Ptr)=p
  603. Return String.Fromlong(Long f(q[0], q[1], q[2]))
  604. Case 4
  605. Local f:Byte Ptr(p0:Byte Ptr, p1:Byte Ptr, p2:Byte Ptr, p3:Byte Ptr)=p
  606. Return String.Fromlong(Long f(q[0], q[1], q[2], q[3]))
  607. Case 5
  608. Local f:Byte Ptr(p0:Byte Ptr, p1:Byte Ptr, p2:Byte Ptr, p3:Byte Ptr, p4:Byte Ptr)=p
  609. Return String.Fromlong(Long f(q[0], q[1], q[2], q[3], q[4]))
  610. Case 6
  611. Local f:Byte Ptr(p0:Byte Ptr, p1:Byte Ptr, p2:Byte Ptr, p3:Byte Ptr, p4:Byte Ptr, p5:Byte Ptr)=p
  612. Return String.Fromlong(Long f(q[0], q[1], q[2], q[3], q[4], q[5]))
  613. Case 7
  614. Local f:Byte Ptr(p0:Byte Ptr, p1:Byte Ptr, p2:Byte Ptr, p3:Byte Ptr, p4:Byte Ptr, p5:Byte Ptr, p6:Byte Ptr)=p
  615. Return String.Fromlong(Long f(q[0], q[1], q[2], q[3], q[4], q[5], q[6]))
  616. Case 8
  617. Local f:Byte Ptr(p0:Byte Ptr, p1:Byte Ptr, p2:Byte Ptr, p3:Byte Ptr, p4:Byte Ptr, p5:Byte Ptr, p6:Byte Ptr, p7:Byte Ptr)=p
  618. Return String.Fromlong(Long f(q[0], q[1], q[2], q[3], q[4], q[5], q[6], q[7]))
  619. Default
  620. Local f:Byte Ptr(p0:Byte Ptr,p1:Byte Ptr,p2:Byte Ptr,p3:Byte Ptr,p4:Byte Ptr,p5:Byte Ptr,p6:Byte Ptr,p7:Byte Ptr)=p
  621. Return String.Fromlong(Long f( q[0],q[1],q[2],q[3],q[4],q[5],q[6],q[7] ))
  622. End Select
  623. ?
  624. Else
  625. Select argTypes.length
  626. Case 0
  627. Local f:Object()=p
  628. Return f()
  629. Case 1
  630. Local f:Object(p0:Byte Ptr)=p
  631. Return f(q[0])
  632. Case 2
  633. Local f:Object(p0:Byte Ptr, p1:Byte Ptr)=p
  634. Return f(q[0], q[1])
  635. Case 3
  636. Local f:Object(p0:Byte Ptr, p1:Byte Ptr, p2:Byte Ptr)=p
  637. Return f(q[0], q[1], q[2])
  638. Case 4
  639. Local f:Object(p0:Byte Ptr, p1:Byte Ptr, p2:Byte Ptr, p3:Byte Ptr)=p
  640. Return f(q[0], q[1], q[2], q[3])
  641. Case 5
  642. Local f:Object(p0:Byte Ptr, p1:Byte Ptr, p2:Byte Ptr, p3:Byte Ptr, p4:Byte Ptr)=p
  643. Return f(q[0], q[1], q[2], q[3], q[4])
  644. Case 6
  645. Local f:Object(p0:Byte Ptr, p1:Byte Ptr, p2:Byte Ptr, p3:Byte Ptr, p4:Byte Ptr, p5:Byte Ptr)=p
  646. Return f(q[0], q[1], q[2], q[3], q[4], q[5])
  647. Case 7
  648. Local f:Object(p0:Byte Ptr, p1:Byte Ptr, p2:Byte Ptr, p3:Byte Ptr, p4:Byte Ptr, p5:Byte Ptr, p6:Byte Ptr)=p
  649. Return f(q[0], q[1], q[2], q[3], q[4], q[5], q[6])
  650. Case 8
  651. Local f:Object(p0:Byte Ptr, p1:Byte Ptr, p2:Byte Ptr, p3:Byte Ptr, p4:Byte Ptr, p5:Byte Ptr, p6:Byte Ptr, p7:Byte Ptr)=p
  652. Return f(q[0], q[1], q[2], q[3], q[4], q[5], q[6], q[7])
  653. Default
  654. Local f:Object(p0:Byte Ptr,p1:Byte Ptr,p2:Byte Ptr,p3:Byte Ptr,p4:Byte Ptr,p5:Byte Ptr,p6:Byte Ptr,p7:Byte Ptr)=p
  655. Return f( q[0],q[1],q[2],q[3],q[4],q[5],q[6],q[7] )
  656. End Select
  657. End If
  658. End Select
  659. End Function
  660. Function _CallMethod:Object( p:Byte Ptr,typeId:TTypeId,obj:Object,args:Object[],argTypes:TTypeId[] )
  661. Local q:Byte Ptr[10]',sp:Byte Ptr=q
  662. 'bbRefPushObject sp,obj
  663. 'sp:+4
  664. 'If typeId=LongTypeId sp:+8
  665. If args Then
  666. For Local i=0 Until args.length
  667. 'If Int Ptr(sp)>=Int Ptr(q)+8 Throw "ERROR"
  668. _Push( Varptr q[i],argTypes[i],args[i] )
  669. Next
  670. End If
  671. 'If Int Ptr(sp)>Int Ptr(q)+8 Throw "ERROR"
  672. Local retType:TTypeId = typeId._retType
  673. Select retType
  674. Case ByteTypeId,ShortTypeId,IntTypeId
  675. Select argTypes.length
  676. Case 0
  677. Local f:Int(m:Object)=p
  678. Return String.FromInt( f(obj) )
  679. Case 1
  680. Local f:Int(m:Object, p0:Byte Ptr)=p
  681. Return String.FromInt( f(obj, q[0]) )
  682. Case 2
  683. Local f:Int(m:Object, p0:Byte Ptr, p1:Byte Ptr)=p
  684. Return String.FromInt( f(obj, q[0], q[1]) )
  685. Case 3
  686. Local f:Int(m:Object, p0:Byte Ptr, p1:Byte Ptr, p2:Byte Ptr)=p
  687. Return String.FromInt( f(obj, q[0], q[1], q[2]) )
  688. Case 4
  689. Local f:Int(m:Object, p0:Byte Ptr, p1:Byte Ptr, p2:Byte Ptr, p3:Byte Ptr)=p
  690. Return String.FromInt( f(obj, q[0], q[1], q[2], q[3]) )
  691. Case 5
  692. Local f:Int(m:Object, p0:Byte Ptr, p1:Byte Ptr, p2:Byte Ptr, p3:Byte Ptr, p4:Byte Ptr)=p
  693. Return String.FromInt( f(obj, q[0], q[1], q[2], q[3], q[4]) )
  694. Case 6
  695. Local f:Int(m:Object, p0:Byte Ptr, p1:Byte Ptr, p2:Byte Ptr, p3:Byte Ptr, p4:Byte Ptr, p5:Byte Ptr)=p
  696. Return String.FromInt( f(obj, q[0], q[1], q[2], q[3], q[4], q[5]) )
  697. Case 7
  698. Local f:Int(m:Object, p0:Byte Ptr, p1:Byte Ptr, p2:Byte Ptr, p3:Byte Ptr, p4:Byte Ptr, p5:Byte Ptr, p6:Byte Ptr)=p
  699. Return String.FromInt( f(obj, q[0], q[1], q[2], q[3], q[4], q[5], q[6]) )
  700. Case 8
  701. Local f:Int(m:Object, p0:Byte Ptr, p1:Byte Ptr, p2:Byte Ptr, p3:Byte Ptr, p4:Byte Ptr, p5:Byte Ptr, p6:Byte Ptr, p7:Byte Ptr)=p
  702. Return String.FromInt( f(obj, q[0], q[1], q[2], q[3], q[4], q[5], q[6], q[7]) )
  703. Default
  704. Local f:Int(p0:Byte Ptr,p1:Byte Ptr,p2:Byte Ptr,p3:Byte Ptr,p4:Byte Ptr,p5:Byte Ptr,p6:Byte Ptr,p7:Byte Ptr)=p
  705. Return String.FromInt( f( q[0],q[1],q[2],q[3],q[4],q[5],q[6],q[7] ) )
  706. End Select
  707. ?Not ptr64
  708. Case UIntTypeId,SizetTypeId
  709. ?ptr64
  710. Case UIntTypeId
  711. ?
  712. Select argTypes.length
  713. Case 0
  714. Local f:UInt(m:Object)=p
  715. Return String.FromUInt( f(obj) )
  716. Case 1
  717. Local f:UInt(m:Object, p0:Byte Ptr)=p
  718. Return String.FromUInt( f(obj, q[0]) )
  719. Case 2
  720. Local f:UInt(m:Object, p0:Byte Ptr, p1:Byte Ptr)=p
  721. Return String.FromUInt( f(obj, q[0], q[1]) )
  722. Case 3
  723. Local f:UInt(m:Object, p0:Byte Ptr, p1:Byte Ptr, p2:Byte Ptr)=p
  724. Return String.FromUInt( f(obj, q[0], q[1], q[2]) )
  725. Case 4
  726. Local f:UInt(m:Object, p0:Byte Ptr, p1:Byte Ptr, p2:Byte Ptr, p3:Byte Ptr)=p
  727. Return String.FromUInt( f(obj, q[0], q[1], q[2], q[3]) )
  728. Case 5
  729. Local f:UInt(m:Object, p0:Byte Ptr, p1:Byte Ptr, p2:Byte Ptr, p3:Byte Ptr, p4:Byte Ptr)=p
  730. Return String.FromUInt( f(obj, q[0], q[1], q[2], q[3], q[4]) )
  731. Case 6
  732. Local f:UInt(m:Object, p0:Byte Ptr, p1:Byte Ptr, p2:Byte Ptr, p3:Byte Ptr, p4:Byte Ptr, p5:Byte Ptr)=p
  733. Return String.FromUInt( f(obj, q[0], q[1], q[2], q[3], q[4], q[5]) )
  734. Case 7
  735. Local f:UInt(m:Object, p0:Byte Ptr, p1:Byte Ptr, p2:Byte Ptr, p3:Byte Ptr, p4:Byte Ptr, p5:Byte Ptr, p6:Byte Ptr)=p
  736. Return String.FromUInt( f(obj, q[0], q[1], q[2], q[3], q[4], q[5], q[6]) )
  737. Case 8
  738. Local f:UInt(m:Object, p0:Byte Ptr, p1:Byte Ptr, p2:Byte Ptr, p3:Byte Ptr, p4:Byte Ptr, p5:Byte Ptr, p6:Byte Ptr, p7:Byte Ptr)=p
  739. Return String.FromUInt( f(obj, q[0], q[1], q[2], q[3], q[4], q[5], q[6], q[7]) )
  740. Default
  741. Local f:UInt(p0:Byte Ptr,p1:Byte Ptr,p2:Byte Ptr,p3:Byte Ptr,p4:Byte Ptr,p5:Byte Ptr,p6:Byte Ptr,p7:Byte Ptr)=p
  742. Return String.FromUInt( f( q[0],q[1],q[2],q[3],q[4],q[5],q[6],q[7] ) )
  743. End Select
  744. Case LongTypeId
  745. Select argTypes.length
  746. Case 0
  747. Local f:Long(m:Object)=p
  748. Return String.Fromlong( f(obj) )
  749. Case 1
  750. Local f:Long(m:Object, p0:Byte Ptr)=p
  751. Return String.Fromlong( f(obj, q[0]) )
  752. Case 2
  753. Local f:Long(m:Object, p0:Byte Ptr, p1:Byte Ptr)=p
  754. Return String.Fromlong( f(obj, q[0], q[1]) )
  755. Case 3
  756. Local f:Long(m:Object, p0:Byte Ptr, p1:Byte Ptr, p2:Byte Ptr)=p
  757. Return String.Fromlong( f(obj, q[0], q[1], q[2]) )
  758. Case 4
  759. Local f:Long(m:Object, p0:Byte Ptr, p1:Byte Ptr, p2:Byte Ptr, p3:Byte Ptr)=p
  760. Return String.Fromlong( f(obj, q[0], q[1], q[2], q[3]) )
  761. Case 5
  762. Local f:Long(m:Object, p0:Byte Ptr, p1:Byte Ptr, p2:Byte Ptr, p3:Byte Ptr, p4:Byte Ptr)=p
  763. Return String.Fromlong( f(obj, q[0], q[1], q[2], q[3], q[4]) )
  764. Case 6
  765. Local f:Long(m:Object, p0:Byte Ptr, p1:Byte Ptr, p2:Byte Ptr, p3:Byte Ptr, p4:Byte Ptr, p5:Byte Ptr)=p
  766. Return String.Fromlong( f(obj, q[0], q[1], q[2], q[3], q[4], q[5]) )
  767. Case 7
  768. Local f:Long(m:Object, p0:Byte Ptr, p1:Byte Ptr, p2:Byte Ptr, p3:Byte Ptr, p4:Byte Ptr, p5:Byte Ptr, p6:Byte Ptr)=p
  769. Return String.Fromlong( f(obj, q[0], q[1], q[2], q[3], q[4], q[5], q[6]) )
  770. Case 8
  771. Local f:Long(m:Object, p0:Byte Ptr, p1:Byte Ptr, p2:Byte Ptr, p3:Byte Ptr, p4:Byte Ptr, p5:Byte Ptr, p6:Byte Ptr, p7:Byte Ptr)=p
  772. Return String.Fromlong( f(obj, q[0], q[1], q[2], q[3], q[4], q[5], q[6], q[7]) )
  773. Default
  774. Local f:Long(p0:Byte Ptr,p1:Byte Ptr,p2:Byte Ptr,p3:Byte Ptr,p4:Byte Ptr,p5:Byte Ptr,p6:Byte Ptr,p7:Byte Ptr)=p
  775. Return String.Fromlong( f( q[0],q[1],q[2],q[3],q[4],q[5],q[6],q[7] ) )
  776. End Select
  777. ?Not ptr64
  778. Case ULongTypeId
  779. ?ptr64
  780. Case ULongTypeId,SizetTypeId
  781. ?
  782. Select argTypes.length
  783. Case 0
  784. Local f:ULong(m:Object)=p
  785. Return String.FromULong( f(obj) )
  786. Case 1
  787. Local f:ULong(m:Object, p0:Byte Ptr)=p
  788. Return String.FromULong( f(obj, q[0]) )
  789. Case 2
  790. Local f:ULong(m:Object, p0:Byte Ptr, p1:Byte Ptr)=p
  791. Return String.FromULong( f(obj, q[0], q[1]) )
  792. Case 3
  793. Local f:ULong(m:Object, p0:Byte Ptr, p1:Byte Ptr, p2:Byte Ptr)=p
  794. Return String.FromULong( f(obj, q[0], q[1], q[2]) )
  795. Case 4
  796. Local f:ULong(m:Object, p0:Byte Ptr, p1:Byte Ptr, p2:Byte Ptr, p3:Byte Ptr)=p
  797. Return String.FromULong( f(obj, q[0], q[1], q[2], q[3]) )
  798. Case 5
  799. Local f:ULong(m:Object, p0:Byte Ptr, p1:Byte Ptr, p2:Byte Ptr, p3:Byte Ptr, p4:Byte Ptr)=p
  800. Return String.FromULong( f(obj, q[0], q[1], q[2], q[3], q[4]) )
  801. Case 6
  802. Local f:ULong(m:Object, p0:Byte Ptr, p1:Byte Ptr, p2:Byte Ptr, p3:Byte Ptr, p4:Byte Ptr, p5:Byte Ptr)=p
  803. Return String.FromULong( f(obj, q[0], q[1], q[2], q[3], q[4], q[5]) )
  804. Case 7
  805. Local f:ULong(m:Object, p0:Byte Ptr, p1:Byte Ptr, p2:Byte Ptr, p3:Byte Ptr, p4:Byte Ptr, p5:Byte Ptr, p6:Byte Ptr)=p
  806. Return String.FromULong( f(obj, q[0], q[1], q[2], q[3], q[4], q[5], q[6]) )
  807. Case 8
  808. Local f:ULong(m:Object, p0:Byte Ptr, p1:Byte Ptr, p2:Byte Ptr, p3:Byte Ptr, p4:Byte Ptr, p5:Byte Ptr, p6:Byte Ptr, p7:Byte Ptr)=p
  809. Return String.FromULong( f(obj, q[0], q[1], q[2], q[3], q[4], q[5], q[6], q[7]) )
  810. Default
  811. Local f:ULong(p0:Byte Ptr,p1:Byte Ptr,p2:Byte Ptr,p3:Byte Ptr,p4:Byte Ptr,p5:Byte Ptr,p6:Byte Ptr,p7:Byte Ptr)=p
  812. Return String.FromULong( f( q[0],q[1],q[2],q[3],q[4],q[5],q[6],q[7] ) )
  813. End Select
  814. Case FloatTypeId
  815. Select argTypes.length
  816. Case 0
  817. Local f:Float(m:Object)=p
  818. Return String.FromFloat( f(obj) )
  819. Case 1
  820. Local f:Float(m:Object, p0:Byte Ptr)=p
  821. Return String.FromFloat( f(obj, q[0]) )
  822. Case 2
  823. Local f:Float(m:Object, p0:Byte Ptr, p1:Byte Ptr)=p
  824. Return String.FromFloat( f(obj, q[0], q[1]) )
  825. Case 3
  826. Local f:Float(m:Object, p0:Byte Ptr, p1:Byte Ptr, p2:Byte Ptr)=p
  827. Return String.FromFloat( f(obj, q[0], q[1], q[2]) )
  828. Case 4
  829. Local f:Float(m:Object, p0:Byte Ptr, p1:Byte Ptr, p2:Byte Ptr, p3:Byte Ptr)=p
  830. Return String.FromFloat( f(obj, q[0], q[1], q[2], q[3]) )
  831. Case 5
  832. Local f:Float(m:Object, p0:Byte Ptr, p1:Byte Ptr, p2:Byte Ptr, p3:Byte Ptr, p4:Byte Ptr)=p
  833. Return String.FromFloat( f(obj, q[0], q[1], q[2], q[3], q[4]) )
  834. Case 6
  835. Local f:Float(m:Object, p0:Byte Ptr, p1:Byte Ptr, p2:Byte Ptr, p3:Byte Ptr, p4:Byte Ptr, p5:Byte Ptr)=p
  836. Return String.FromFloat( f(obj, q[0], q[1], q[2], q[3], q[4], q[5]) )
  837. Case 7
  838. Local f:Float(m:Object, p0:Byte Ptr, p1:Byte Ptr, p2:Byte Ptr, p3:Byte Ptr, p4:Byte Ptr, p5:Byte Ptr, p6:Byte Ptr)=p
  839. Return String.FromFloat( f(obj, q[0], q[1], q[2], q[3], q[4], q[5], q[6]) )
  840. Case 8
  841. Local f:Float(m:Object, p0:Byte Ptr, p1:Byte Ptr, p2:Byte Ptr, p3:Byte Ptr, p4:Byte Ptr, p5:Byte Ptr, p6:Byte Ptr, p7:Byte Ptr)=p
  842. Return String.FromFloat( f(obj, q[0], q[1], q[2], q[3], q[4], q[5], q[6], q[7]) )
  843. Default
  844. Local f:Float(p0:Byte Ptr,p1:Byte Ptr,p2:Byte Ptr,p3:Byte Ptr,p4:Byte Ptr,p5:Byte Ptr,p6:Byte Ptr,p7:Byte Ptr)=p
  845. Return String.FromFloat( f( q[0],q[1],q[2],q[3],q[4],q[5],q[6],q[7] ) )
  846. End Select
  847. Case DoubleTypeId
  848. Select argTypes.length
  849. Case 0
  850. Local f:Double(m:Object)=p
  851. Return String.FromDouble( f(obj) )
  852. Case 1
  853. Local f:Double(m:Object, p0:Byte Ptr)=p
  854. Return String.FromDouble( f(obj, q[0]) )
  855. Case 2
  856. Local f:Double(m:Object, p0:Byte Ptr, p1:Byte Ptr)=p
  857. Return String.FromDouble( f(obj, q[0], q[1]) )
  858. Case 3
  859. Local f:Double(m:Object, p0:Byte Ptr, p1:Byte Ptr, p2:Byte Ptr)=p
  860. Return String.FromDouble( f(obj, q[0], q[1], q[2]) )
  861. Case 4
  862. Local f:Double(m:Object, p0:Byte Ptr, p1:Byte Ptr, p2:Byte Ptr, p3:Byte Ptr)=p
  863. Return String.FromDouble( f(obj, q[0], q[1], q[2], q[3]) )
  864. Case 5
  865. Local f:Double(m:Object, p0:Byte Ptr, p1:Byte Ptr, p2:Byte Ptr, p3:Byte Ptr, p4:Byte Ptr)=p
  866. Return String.FromDouble( f(obj, q[0], q[1], q[2], q[3], q[4]) )
  867. Case 6
  868. Local f:Double(m:Object, p0:Byte Ptr, p1:Byte Ptr, p2:Byte Ptr, p3:Byte Ptr, p4:Byte Ptr, p5:Byte Ptr)=p
  869. Return String.FromDouble( f(obj, q[0], q[1], q[2], q[3], q[4], q[5]) )
  870. Case 7
  871. Local f:Double(m:Object, p0:Byte Ptr, p1:Byte Ptr, p2:Byte Ptr, p3:Byte Ptr, p4:Byte Ptr, p5:Byte Ptr, p6:Byte Ptr)=p
  872. Return String.FromDouble( f(obj, q[0], q[1], q[2], q[3], q[4], q[5], q[6]) )
  873. Case 8
  874. Local f:Double(m:Object, p0:Byte Ptr, p1:Byte Ptr, p2:Byte Ptr, p3:Byte Ptr, p4:Byte Ptr, p5:Byte Ptr, p6:Byte Ptr, p7:Byte Ptr)=p
  875. Return String.FromDouble( f(obj, q[0], q[1], q[2], q[3], q[4], q[5], q[6], q[7]) )
  876. Default
  877. Local f:Double(p0:Byte Ptr,p1:Byte Ptr,p2:Byte Ptr,p3:Byte Ptr,p4:Byte Ptr,p5:Byte Ptr,p6:Byte Ptr,p7:Byte Ptr)=p
  878. Return String.FromDouble( f( q[0],q[1],q[2],q[3],q[4],q[5],q[6],q[7] ) )
  879. End Select
  880. Case LongIntTypeId
  881. Select argTypes.length
  882. Case 0
  883. Local f:LongInt(m:Object)=p
  884. Return String.FromLongInt( f(obj) )
  885. Case 1
  886. Local f:LongInt(m:Object, p0:Byte Ptr)=p
  887. Return String.FromLongInt( f(obj, q[0]) )
  888. Case 2
  889. Local f:LongInt(m:Object, p0:Byte Ptr, p1:Byte Ptr)=p
  890. Return String.FromLongInt( f(obj, q[0], q[1]) )
  891. Case 3
  892. Local f:LongInt(m:Object, p0:Byte Ptr, p1:Byte Ptr, p2:Byte Ptr)=p
  893. Return String.FromLongInt( f(obj, q[0], q[1], q[2]) )
  894. Case 4
  895. Local f:LongInt(m:Object, p0:Byte Ptr, p1:Byte Ptr, p2:Byte Ptr, p3:Byte Ptr)=p
  896. Return String.FromLongInt( f(obj, q[0], q[1], q[2], q[3]) )
  897. Case 5
  898. Local f:LongInt(m:Object, p0:Byte Ptr, p1:Byte Ptr, p2:Byte Ptr, p3:Byte Ptr, p4:Byte Ptr)=p
  899. Return String.FromLongInt( f(obj, q[0], q[1], q[2], q[3], q[4]) )
  900. Case 6
  901. Local f:LongInt(m:Object, p0:Byte Ptr, p1:Byte Ptr, p2:Byte Ptr, p3:Byte Ptr, p4:Byte Ptr, p5:Byte Ptr)=p
  902. Return String.FromLongInt( f(obj, q[0], q[1], q[2], q[3], q[4], q[5]) )
  903. Case 7
  904. Local f:LongInt(m:Object, p0:Byte Ptr, p1:Byte Ptr, p2:Byte Ptr, p3:Byte Ptr, p4:Byte Ptr, p5:Byte Ptr, p6:Byte Ptr)=p
  905. Return String.FromLongInt( f(obj, q[0], q[1], q[2], q[3], q[4], q[5], q[6]) )
  906. Case 8
  907. Local f:LongInt(m:Object, p0:Byte Ptr, p1:Byte Ptr, p2:Byte Ptr, p3:Byte Ptr, p4:Byte Ptr, p5:Byte Ptr, p6:Byte Ptr, p7:Byte Ptr)=p
  908. Return String.FromLongInt( f(obj, q[0], q[1], q[2], q[3], q[4], q[5], q[6], q[7]) )
  909. Default
  910. Local f:LongInt(p0:Byte Ptr,p1:Byte Ptr,p2:Byte Ptr,p3:Byte Ptr,p4:Byte Ptr,p5:Byte Ptr,p6:Byte Ptr,p7:Byte Ptr)=p
  911. Return String.FromLongInt( f( q[0],q[1],q[2],q[3],q[4],q[5],q[6],q[7] ) )
  912. End Select
  913. Case ULongIntTypeId
  914. Select argTypes.length
  915. Case 0
  916. Local f:ULongInt(m:Object)=p
  917. Return String.FromULongInt( f(obj) )
  918. Case 1
  919. Local f:ULongInt(m:Object, p0:Byte Ptr)=p
  920. Return String.FromULongInt( f(obj, q[0]) )
  921. Case 2
  922. Local f:ULongInt(m:Object, p0:Byte Ptr, p1:Byte Ptr)=p
  923. Return String.FromULongInt( f(obj, q[0], q[1]) )
  924. Case 3
  925. Local f:ULongInt(m:Object, p0:Byte Ptr, p1:Byte Ptr, p2:Byte Ptr)=p
  926. Return String.FromULongInt( f(obj, q[0], q[1], q[2]) )
  927. Case 4
  928. Local f:ULongInt(m:Object, p0:Byte Ptr, p1:Byte Ptr, p2:Byte Ptr, p3:Byte Ptr)=p
  929. Return String.FromULongInt( f(obj, q[0], q[1], q[2], q[3]) )
  930. Case 5
  931. Local f:ULongInt(m:Object, p0:Byte Ptr, p1:Byte Ptr, p2:Byte Ptr, p3:Byte Ptr, p4:Byte Ptr)=p
  932. Return String.FromULongInt( f(obj, q[0], q[1], q[2], q[3], q[4]) )
  933. Case 6
  934. Local f:ULongInt(m:Object, p0:Byte Ptr, p1:Byte Ptr, p2:Byte Ptr, p3:Byte Ptr, p4:Byte Ptr, p5:Byte Ptr)=p
  935. Return String.FromULongInt( f(obj, q[0], q[1], q[2], q[3], q[4], q[5]) )
  936. Case 7
  937. Local f:ULongInt(m:Object, p0:Byte Ptr, p1:Byte Ptr, p2:Byte Ptr, p3:Byte Ptr, p4:Byte Ptr, p5:Byte Ptr, p6:Byte Ptr)=p
  938. Return String.FromULongInt( f(obj, q[0], q[1], q[2], q[3], q[4], q[5], q[6]) )
  939. Case 8
  940. Local f:ULongInt(m:Object, p0:Byte Ptr, p1:Byte Ptr, p2:Byte Ptr, p3:Byte Ptr, p4:Byte Ptr, p5:Byte Ptr, p6:Byte Ptr, p7:Byte Ptr)=p
  941. Return String.FromULongInt( f(obj, q[0], q[1], q[2], q[3], q[4], q[5], q[6], q[7]) )
  942. Default
  943. Local f:ULongInt(p0:Byte Ptr,p1:Byte Ptr,p2:Byte Ptr,p3:Byte Ptr,p4:Byte Ptr,p5:Byte Ptr,p6:Byte Ptr,p7:Byte Ptr)=p
  944. Return String.FromULongInt( f( q[0],q[1],q[2],q[3],q[4],q[5],q[6],q[7] ) )
  945. End Select
  946. Case VoidTypeId
  947. Select argTypes.length
  948. Case 0
  949. Local f(m:Object)=p
  950. f(obj)
  951. Case 1
  952. Local f(m:Object, p0:Byte Ptr)=p
  953. f(obj, q[0])
  954. Case 2
  955. Local f(m:Object, p0:Byte Ptr, p1:Byte Ptr)=p
  956. f(obj, q[0], q[1])
  957. Case 3
  958. Local f(m:Object, p0:Byte Ptr, p1:Byte Ptr, p2:Byte Ptr)=p
  959. f(obj, q[0], q[1], q[2])
  960. Case 4
  961. Local f(m:Object, p0:Byte Ptr, p1:Byte Ptr, p2:Byte Ptr, p3:Byte Ptr)=p
  962. f(obj, q[0], q[1], q[2], q[3])
  963. Case 5
  964. Local f(m:Object, p0:Byte Ptr, p1:Byte Ptr, p2:Byte Ptr, p3:Byte Ptr, p4:Byte Ptr)=p
  965. f(obj, q[0], q[1], q[2], q[3], q[4])
  966. Case 6
  967. Local f(m:Object, p0:Byte Ptr, p1:Byte Ptr, p2:Byte Ptr, p3:Byte Ptr, p4:Byte Ptr, p5:Byte Ptr)=p
  968. f(obj, q[0], q[1], q[2], q[3], q[4], q[5])
  969. Case 7
  970. Local f(m:Object, p0:Byte Ptr, p1:Byte Ptr, p2:Byte Ptr, p3:Byte Ptr, p4:Byte Ptr, p5:Byte Ptr, p6:Byte Ptr)=p
  971. f(obj, q[0], q[1], q[2], q[3], q[4], q[5], q[6])
  972. Case 8
  973. Local f(m:Object, p0:Byte Ptr, p1:Byte Ptr, p2:Byte Ptr, p3:Byte Ptr, p4:Byte Ptr, p5:Byte Ptr, p6:Byte Ptr, p7:Byte Ptr)=p
  974. f(obj, q[0], q[1], q[2], q[3], q[4], q[5], q[6], q[7])
  975. Default
  976. Local f(p0:Byte Ptr,p1:Byte Ptr,p2:Byte Ptr,p3:Byte Ptr,p4:Byte Ptr,p5:Byte Ptr,p6:Byte Ptr,p7:Byte Ptr)=p
  977. f( q[0],q[1],q[2],q[3],q[4],q[5],q[6],q[7] )
  978. End Select
  979. Default
  980. If retType.ExtendsType(PointerTypeId) Or retType.ExtendsType(FunctionTypeId) Then
  981. ?Not ptr64
  982. Select argTypes.length
  983. Case 0
  984. Local f:Byte Ptr(m:Object)=p
  985. Return String.FromInt(Int f(obj))
  986. Case 1
  987. Local f:Byte Ptr(m:Object, p0:Byte Ptr)=p
  988. Return String.FromInt(Int f(obj, q[0]))
  989. Case 2
  990. Local f:Byte Ptr(m:Object, p0:Byte Ptr, p1:Byte Ptr)=p
  991. Return String.FromInt(Int f(obj, q[0], q[1]))
  992. Case 3
  993. Local f:Byte Ptr(m:Object, p0:Byte Ptr, p1:Byte Ptr, p2:Byte Ptr)=p
  994. Return String.FromInt(Int f(obj, q[0], q[1], q[2]))
  995. Case 4
  996. Local f:Byte Ptr(m:Object, p0:Byte Ptr, p1:Byte Ptr, p2:Byte Ptr, p3:Byte Ptr)=p
  997. Return String.FromInt(Int f(obj, q[0], q[1], q[2], q[3]))
  998. Case 5
  999. Local f:Byte Ptr(m:Object, p0:Byte Ptr, p1:Byte Ptr, p2:Byte Ptr, p3:Byte Ptr, p4:Byte Ptr)=p
  1000. Return String.FromInt(Int f(obj, q[0], q[1], q[2], q[3], q[4]))
  1001. Case 6
  1002. Local f:Byte Ptr(m:Object, p0:Byte Ptr, p1:Byte Ptr, p2:Byte Ptr, p3:Byte Ptr, p4:Byte Ptr, p5:Byte Ptr)=p
  1003. Return String.FromInt(Int f(obj, q[0], q[1], q[2], q[3], q[4], q[5]))
  1004. Case 7
  1005. Local f:Byte Ptr(m:Object, p0:Byte Ptr, p1:Byte Ptr, p2:Byte Ptr, p3:Byte Ptr, p4:Byte Ptr, p5:Byte Ptr, p6:Byte Ptr)=p
  1006. Return String.FromInt(Int f(obj, q[0], q[1], q[2], q[3], q[4], q[5], q[6]))
  1007. Case 8
  1008. Local f:Byte Ptr(m:Object, p0:Byte Ptr, p1:Byte Ptr, p2:Byte Ptr, p3:Byte Ptr, p4:Byte Ptr, p5:Byte Ptr, p6:Byte Ptr, p7:Byte Ptr)=p
  1009. Return String.FromInt(Int f(obj, q[0], q[1], q[2], q[3], q[4], q[5], q[6], q[7]))
  1010. Default
  1011. Local f:Byte Ptr(p0:Byte Ptr,p1:Byte Ptr,p2:Byte Ptr,p3:Byte Ptr,p4:Byte Ptr,p5:Byte Ptr,p6:Byte Ptr,p7:Byte Ptr)=p
  1012. Return String.FromInt(Int f( q[0],q[1],q[2],q[3],q[4],q[5],q[6],q[7] ))
  1013. End Select
  1014. ?ptr64
  1015. Select argTypes.length
  1016. Case 0
  1017. Local f:Byte Ptr(m:Object)=p
  1018. Return String.FromLong(Long f(obj))
  1019. Case 1
  1020. Local f:Byte Ptr(m:Object, p0:Byte Ptr)=p
  1021. Return String.FromLong(Long f(obj, q[0]))
  1022. Case 2
  1023. Local f:Byte Ptr(m:Object, p0:Byte Ptr, p1:Byte Ptr)=p
  1024. Return String.FromLong(Long f(obj, q[0], q[1]))
  1025. Case 3
  1026. Local f:Byte Ptr(m:Object, p0:Byte Ptr, p1:Byte Ptr, p2:Byte Ptr)=p
  1027. Return String.FromLong(Long f(obj, q[0], q[1], q[2]))
  1028. Case 4
  1029. Local f:Byte Ptr(m:Object, p0:Byte Ptr, p1:Byte Ptr, p2:Byte Ptr, p3:Byte Ptr)=p
  1030. Return String.FromLong(Long f(obj, q[0], q[1], q[2], q[3]))
  1031. Case 5
  1032. Local f:Byte Ptr(m:Object, p0:Byte Ptr, p1:Byte Ptr, p2:Byte Ptr, p3:Byte Ptr, p4:Byte Ptr)=p
  1033. Return String.FromLong(Long f(obj, q[0], q[1], q[2], q[3], q[4]))
  1034. Case 6
  1035. Local f:Byte Ptr(m:Object, p0:Byte Ptr, p1:Byte Ptr, p2:Byte Ptr, p3:Byte Ptr, p4:Byte Ptr, p5:Byte Ptr)=p
  1036. Return String.FromLong(Long f(obj, q[0], q[1], q[2], q[3], q[4], q[5]))
  1037. Case 7
  1038. Local f:Byte Ptr(m:Object, p0:Byte Ptr, p1:Byte Ptr, p2:Byte Ptr, p3:Byte Ptr, p4:Byte Ptr, p5:Byte Ptr, p6:Byte Ptr)=p
  1039. Return String.FromLong(Long f(obj, q[0], q[1], q[2], q[3], q[4], q[5], q[6]))
  1040. Case 8
  1041. Local f:Byte Ptr(m:Object, p0:Byte Ptr, p1:Byte Ptr, p2:Byte Ptr, p3:Byte Ptr, p4:Byte Ptr, p5:Byte Ptr, p6:Byte Ptr, p7:Byte Ptr)=p
  1042. Return String.FromLong(Long f(obj, q[0], q[1], q[2], q[3], q[4], q[5], q[6], q[7]))
  1043. Default
  1044. Local f:Byte Ptr(p0:Byte Ptr,p1:Byte Ptr,p2:Byte Ptr,p3:Byte Ptr,p4:Byte Ptr,p5:Byte Ptr,p6:Byte Ptr,p7:Byte Ptr)=p
  1045. Return String.FromLong(Long f( q[0],q[1],q[2],q[3],q[4],q[5],q[6],q[7] ))
  1046. End Select
  1047. ?
  1048. Else
  1049. Select argTypes.length
  1050. Case 0
  1051. Local f:Object(m:Object)=p
  1052. Return f(obj)
  1053. Case 1
  1054. Local f:Object(m:Object, p0:Byte Ptr)=p
  1055. Return f(obj, q[0])
  1056. Case 2
  1057. Local f:Object(m:Object, p0:Byte Ptr, p1:Byte Ptr)=p
  1058. Return f(obj, q[0], q[1])
  1059. Case 3
  1060. Local f:Object(m:Object, p0:Byte Ptr, p1:Byte Ptr, p2:Byte Ptr)=p
  1061. Return f(obj, q[0], q[1], q[2])
  1062. Case 4
  1063. Local f:Object(m:Object, p0:Byte Ptr, p1:Byte Ptr, p2:Byte Ptr, p3:Byte Ptr)=p
  1064. Return f(obj, q[0], q[1], q[2], q[3])
  1065. Case 5
  1066. Local f:Object(m:Object, p0:Byte Ptr, p1:Byte Ptr, p2:Byte Ptr, p3:Byte Ptr, p4:Byte Ptr)=p
  1067. Return f(obj, q[0], q[1], q[2], q[3], q[4])
  1068. Case 6
  1069. Local f:Object(m:Object, p0:Byte Ptr, p1:Byte Ptr, p2:Byte Ptr, p3:Byte Ptr, p4:Byte Ptr, p5:Byte Ptr)=p
  1070. Return f(obj, q[0], q[1], q[2], q[3], q[4], q[5])
  1071. Case 7
  1072. Local f:Object(m:Object, p0:Byte Ptr, p1:Byte Ptr, p2:Byte Ptr, p3:Byte Ptr, p4:Byte Ptr, p5:Byte Ptr, p6:Byte Ptr)=p
  1073. Return f(obj, q[0], q[1], q[2], q[3], q[4], q[5], q[6])
  1074. Case 8
  1075. Local f:Object(m:Object, p0:Byte Ptr, p1:Byte Ptr, p2:Byte Ptr, p3:Byte Ptr, p4:Byte Ptr, p5:Byte Ptr, p6:Byte Ptr, p7:Byte Ptr)=p
  1076. Return f(obj, q[0], q[1], q[2], q[3], q[4], q[5], q[6], q[7])
  1077. Default
  1078. Local f:Object(p0:Byte Ptr,p1:Byte Ptr,p2:Byte Ptr,p3:Byte Ptr,p4:Byte Ptr,p5:Byte Ptr,p6:Byte Ptr,p7:Byte Ptr)=p
  1079. Return f( q[0],q[1],q[2],q[3],q[4],q[5],q[6],q[7] )
  1080. End Select
  1081. End If
  1082. End Select
  1083. End Function
  1084. Function TypeTagForId:String( id:TTypeId )
  1085. If id.ExtendsType( ArrayTypeId )
  1086. Return "[]"+TypeTagForId( id.ElementType() )
  1087. EndIf
  1088. If id.ExtendsType( PointerTypeId )
  1089. Return "*"+TypeTagForId(id._elementType)
  1090. EndIf
  1091. If id.ExtendsType( FunctionTypeId )
  1092. Local s:String
  1093. For Local t:TTypeId = EachIn id._argTypes
  1094. If s Then s :+ ","
  1095. s :+ TypeTagForId(t)
  1096. Next
  1097. s = "(" + s + ")"
  1098. If id._retType Then s :+ TypeTagForId(id._retType)
  1099. Return s
  1100. EndIf
  1101. Select id
  1102. Case ByteTypeId Return "b"
  1103. Case ShortTypeId Return "s"
  1104. Case IntTypeId Return "i"
  1105. Case UIntTypeId Return "u"
  1106. Case LongTypeId Return "l"
  1107. Case ULongTypeId Return "y"
  1108. Case SizetTypeId Return "t"
  1109. Case FloatTypeId Return "f"
  1110. Case DoubleTypeId Return "d"
  1111. Case LongIntTypeId Return "v"
  1112. Case ULongIntTypeId Return "e"
  1113. Case StringTypeId Return "$"
  1114. Case PointerTypeId Return "*"
  1115. Case FunctionTypeId Return "("
  1116. End Select
  1117. If id.ExtendsType( ObjectTypeId )
  1118. Return ":"+id.Name()
  1119. EndIf
  1120. Throw "ERROR"
  1121. End Function
  1122. Public
  1123. Function TypeIdForTag:TTypeId( ty:String )
  1124. If ty.StartsWith( "[" )
  1125. Local dims:Int = ty.split(",").length
  1126. ty=ty[ty.Find("]")+1..]
  1127. Local id:TTypeId = TypeIdForTag( ty )
  1128. If id Then
  1129. id=id.ArrayType(dims)
  1130. End If
  1131. Return id
  1132. EndIf
  1133. If ty.StartsWith( ":" )
  1134. ty=ty[1..]
  1135. Local i=ty.FindLast( "." )
  1136. If i<>-1 ty=ty[i+1..]
  1137. Return TTypeId.ForName( ty )
  1138. EndIf
  1139. If ty.StartsWith( "*" ) Then
  1140. ty = ty[1..]
  1141. Local id:TTypeId = TypeIdForTag( ty )
  1142. If id Then
  1143. id = id.PointerType()
  1144. EndIf
  1145. Return id
  1146. EndIf
  1147. If ty.StartsWith( "(" ) Then
  1148. Local t:String[]
  1149. Local idx:Int = ty.FindLast(")")
  1150. If idx > 0 Then
  1151. t = [ ty[1..idx], ty[idx+1..] ]
  1152. Else
  1153. t = [ ty[1..], "" ]
  1154. EndIf
  1155. Local retType:TTypeId=TypeIdForTag( t[1] ), argTypes:TTypeId[]
  1156. If t[0].length>0 Then
  1157. Local i:Int,b:Int,q:String=t[0], args:TList=New TList
  1158. While i < q.length
  1159. Select q[i]
  1160. Case Asc( "," )
  1161. args.AddLast q[b..i]
  1162. i:+1
  1163. b=i
  1164. Case Asc( "[" )
  1165. i:+1
  1166. While i<q.length And q[i]=Asc(",")
  1167. i:+1
  1168. Wend
  1169. Case Asc( "(" )
  1170. Local level:Int = 1
  1171. i:+1
  1172. While i < q.Length
  1173. If q[i] = Asc(",") Then
  1174. If level = 0 Then
  1175. Exit
  1176. End If
  1177. ElseIf q[i] = Asc(")") Then
  1178. level :- 1
  1179. ElseIf q[i] = Asc("(") Then
  1180. level :+ 1
  1181. EndIf
  1182. i:+1
  1183. Wend
  1184. Default
  1185. i:+1
  1186. End Select
  1187. Wend
  1188. If b < q.Length Then args.AddLast q[b..]
  1189. argTypes=New TTypeId[args.Count()]
  1190. i=0
  1191. For Local s:String = EachIn args
  1192. argTypes[i]=TypeIdForTag( s )
  1193. If Not argTypes[i] Then argTypes[i] = ObjectTypeId
  1194. i:+1
  1195. Next
  1196. EndIf
  1197. If Not retType Then retType = ObjectTypeId
  1198. Return retType.FunctionType(argTypes)
  1199. EndIf
  1200. Select ty
  1201. Case "b" Return ByteTypeId
  1202. Case "s" Return ShortTypeId
  1203. Case "i" Return IntTypeId
  1204. Case "u" Return UIntTypeId
  1205. Case "l" Return LongTypeId
  1206. Case "y" Return ULongTypeId
  1207. Case "t" Return SizetTypeId
  1208. Case "f" Return FloatTypeId
  1209. Case "d" Return DoubleTypeId
  1210. Case "v" Return LongIntTypeId
  1211. Case "e" Return ULongIntTypeId
  1212. Case "$" Return StringTypeId
  1213. Case "*" Return PointerTypeId
  1214. Case "(" Return FunctionTypeId
  1215. Case "" Return VoidTypeId
  1216. End Select
  1217. End Function
  1218. Private
  1219. Function ExtractMetaMap:TStringMap( meta:String )
  1220. If Not meta Then
  1221. Return Null
  1222. End If
  1223. Local map:TStringMap = New TStringMap
  1224. Local key:String
  1225. Local value:String
  1226. Local i=0
  1227. While i < meta.length
  1228. Local e:Int = meta.Find( "=",i )
  1229. If e = -1 Throw "Malformed meta data"
  1230. Local key:String = meta[i..e]
  1231. Local value:String
  1232. i = e + 1
  1233. If i < meta.length And meta[i]=Asc("~q")
  1234. i:+1
  1235. Local e:Int = meta.Find( "~q",i )
  1236. If e = -1 Throw "Malformed meta data"
  1237. value = meta[i..e]
  1238. i = e + 1
  1239. Else
  1240. Local e:Int = meta.Find( " ",i )
  1241. If e = -1 e = meta.length
  1242. value = meta[i..e]
  1243. i = e
  1244. EndIf
  1245. map.Insert(key, value)
  1246. If i < meta.length And meta[i] = Asc(" ") i:+1
  1247. Wend
  1248. Return map
  1249. End Function
  1250. Public
  1251. Rem
  1252. bbdoc: Primitive byte type
  1253. End Rem
  1254. Global ByteTypeId:TTypeId=New TTypeId.Init( "Byte",1 )
  1255. Rem
  1256. bbdoc: Primitive short type
  1257. End Rem
  1258. Global ShortTypeId:TTypeId=New TTypeId.Init( "Short",2 )
  1259. Rem
  1260. bbdoc: Primitive int type
  1261. End Rem
  1262. Global IntTypeId:TTypeId=New TTypeId.Init( "Int",4 )
  1263. Rem
  1264. bbdoc: Primitive unsigned int type
  1265. End Rem
  1266. Global UIntTypeId:TTypeId=New TTypeId.Init( "UInt",4 )
  1267. Rem
  1268. bbdoc: Primitive long type
  1269. End Rem
  1270. Global LongTypeId:TTypeId=New TTypeId.Init( "Long",8 )
  1271. Rem
  1272. bbdoc: Primitive unsigned long type
  1273. End Rem
  1274. Global ULongTypeId:TTypeId=New TTypeId.Init( "ULong",8 )
  1275. Rem
  1276. bbdoc: Primitive size_t type
  1277. End Rem
  1278. ?Not ptr64
  1279. Global SizetTypeId:TTypeId=New TTypeId.Init( "size_t",4 )
  1280. ?ptr64
  1281. Global SizetTypeId:TTypeId=New TTypeId.Init( "size_t",8 )
  1282. ?
  1283. Rem
  1284. bbdoc: Primitive longint type
  1285. End Rem
  1286. ?Not ptr64
  1287. Global LongIntTypeId:TTypeId=New TTypeId.Init( "LongInt",4 )
  1288. ?ptr64 and not win32
  1289. Global LongIntTypeId:TTypeId=New TTypeId.Init( "LongInt",8 )
  1290. ?ptr64 and win32
  1291. Global LongIntTypeId:TTypeId=New TTypeId.Init( "LongInt",4 )
  1292. ?
  1293. Rem
  1294. bbdoc: Primitive ulongint type
  1295. End Rem
  1296. ?Not ptr64
  1297. Global ULongIntTypeId:TTypeId=New TTypeId.Init( "ULongInt",4 )
  1298. ?ptr64 and not win32
  1299. Global ULongIntTypeId:TTypeId=New TTypeId.Init( "ULongInt",8 )
  1300. ?ptr64 and win32
  1301. Global ULongIntTypeId:TTypeId=New TTypeId.Init( "ULongInt",4 )
  1302. ?
  1303. Rem
  1304. bbdoc: Primitive float type
  1305. End Rem
  1306. Global FloatTypeId:TTypeId=New TTypeId.Init( "Float",4 )
  1307. Rem
  1308. bbdoc: Primitive double type
  1309. End Rem
  1310. Global DoubleTypeId:TTypeId=New TTypeId.Init( "Double",8 )
  1311. Rem
  1312. bbdoc: Primitive object type
  1313. End Rem
  1314. ?Not ptr64
  1315. Global ObjectTypeId:TTypeId=New TTypeId.Init( "Object",4,bbRefObjectClass() )
  1316. ?ptr64
  1317. Global ObjectTypeId:TTypeId=New TTypeId.Init( "Object",8,bbRefObjectClass() )
  1318. ?
  1319. Rem
  1320. bbdoc: Primitive string type
  1321. End Rem
  1322. ?Not ptr64
  1323. Global StringTypeId:TTypeId=New TTypeId.Init( "String",4,bbRefStringClass(),ObjectTypeId )
  1324. ?ptr64
  1325. Global StringTypeId:TTypeId=New TTypeId.Init( "String",8,bbRefStringClass(),ObjectTypeId )
  1326. ?
  1327. Rem
  1328. bbdoc: Primitive array type
  1329. End Rem
  1330. ?Not ptr64
  1331. Global ArrayTypeId:TTypeId=New TTypeId.Init( "Null[]",4,bbRefArrayClass(),ObjectTypeId )
  1332. ?ptr64
  1333. Global ArrayTypeId:TTypeId=New TTypeId.Init( "Null[]",8,bbRefArrayClass(),ObjectTypeId )
  1334. ?
  1335. ' Void Type
  1336. ' Only used For Function/Method Return types
  1337. Global VoidTypeId:TTypeId=New TTypeId.Init( "Void",0 )
  1338. Rem
  1339. bbdoc: Primitive pointer type
  1340. End Rem
  1341. ?Not ptr64
  1342. Global PointerTypeId:TTypeId=New TTypeId.Init( "Ptr",4 )
  1343. ?ptr64
  1344. Global PointerTypeId:TTypeId=New TTypeId.Init( "Ptr",8 )
  1345. ?
  1346. Rem
  1347. bbdoc: Primitive function type
  1348. End Rem
  1349. ?Not ptr64
  1350. Global FunctionTypeId:TTypeId=New TTypeId.Init( "Null()",4 )
  1351. ?ptr64
  1352. Global FunctionTypeId:TTypeId=New TTypeId.Init( "Null()",8 )
  1353. ?
  1354. Rem
  1355. bbdoc: Type member - Field Or Method.
  1356. End Rem
  1357. Type TMember
  1358. Rem
  1359. bbdoc: Get member name
  1360. End Rem
  1361. Method Name:String()
  1362. Return _name
  1363. End Method
  1364. Method NameLower:String()
  1365. If Not _nameLower Then
  1366. _nameLower = _name.ToLower()
  1367. End If
  1368. Return _nameLower
  1369. End Method
  1370. Rem
  1371. bbdoc: Get member type
  1372. End Rem
  1373. Method TypeId:TTypeId()
  1374. Return _typeId
  1375. End Method
  1376. Rem
  1377. bbdoc: Get member meta data
  1378. End Rem
  1379. Method MetaData:String( key:String="" )
  1380. If Not _metaMap Or Not key Return _meta
  1381. Return String(_metaMap.ValueForKey(key))
  1382. End Method
  1383. Rem
  1384. bbdoc: Returns #True if @key is in the metadata.
  1385. End Rem
  1386. Method HasMetaData:Int( key:String )
  1387. If Not _metaMap Or Not key Return False
  1388. Return _metaMap.Contains(key)
  1389. End Method
  1390. Method InitMeta(meta:String)
  1391. _meta = meta
  1392. _metaMap = ExtractMetaMap(meta)
  1393. End Method
  1394. Field _name:String,_typeId:TTypeId,_meta:String
  1395. Field _nameLower:String
  1396. Field _metaMap:TStringMap
  1397. End Type
  1398. Rem
  1399. bbdoc: Type constant
  1400. EndRem
  1401. Type TConstant Extends TMember
  1402. Method Init:TConstant( name:String, typeId:TTypeId, meta:String, str:String)
  1403. _name = name
  1404. _typeId = typeId
  1405. InitMeta(meta)
  1406. _string = str
  1407. Return Self
  1408. EndMethod
  1409. Rem
  1410. bbdoc: Get constant value
  1411. EndRem
  1412. Method GetString:String()
  1413. Return _string
  1414. EndMethod
  1415. Rem
  1416. bbdoc: Get constant value as @Int
  1417. EndRem
  1418. Method GetInt:Int()
  1419. Return GetString().ToInt()
  1420. EndMethod
  1421. Rem
  1422. bbdoc: Get constant value as @Float
  1423. EndRem
  1424. Method GetFloat:Float()
  1425. Return GetString().ToFloat()
  1426. EndMethod
  1427. Rem
  1428. bbdoc: Get constant value as @Long
  1429. EndRem
  1430. Method GetLong:Long()
  1431. Return GetString().ToLong()
  1432. EndMethod
  1433. Rem
  1434. bbdoc: Get constant value as @size_t
  1435. EndRem
  1436. Method GetSizet:Size_T()
  1437. Return GetString().ToSizet()
  1438. EndMethod
  1439. Rem
  1440. bbdoc: Get constant value as @LongInt
  1441. EndRem
  1442. Method GetLongInt:LongInt()
  1443. Return GetString().ToLongInt()
  1444. EndMethod
  1445. Rem
  1446. bbdoc: Get constant value as @ULongInt
  1447. EndRem
  1448. Method GetULongInt:ULongInt()
  1449. Return GetString().ToULongInt()
  1450. EndMethod
  1451. Rem
  1452. bbdoc: Get constant value as @Double
  1453. EndRem
  1454. Method GetDouble:Double()
  1455. Return GetString().ToDouble()
  1456. EndMethod
  1457. Rem
  1458. bbdoc: Get constant value as @{Byte Ptr}
  1459. EndRem
  1460. Method GetPointer:Byte Ptr()
  1461. ?Not ptr64
  1462. Return Byte Ptr GetString().ToInt()
  1463. ?ptr64
  1464. Return Byte Ptr GetString().ToLong()
  1465. ?
  1466. EndMethod
  1467. Field _string:String
  1468. EndType
  1469. Rem
  1470. bbdoc: Type field
  1471. End Rem
  1472. Type TField Extends TMember
  1473. Method Init:TField( name:String,typeId:TTypeId,meta:String,index )
  1474. _name=name
  1475. _typeId=typeId
  1476. InitMeta(meta)
  1477. _index=index
  1478. Return Self
  1479. End Method
  1480. Rem
  1481. bbdoc: Get field value
  1482. End Rem
  1483. Method Get:Object( obj:Object )
  1484. Return _Get( bbRefFieldPtr( obj,_index ),_typeId )
  1485. End Method
  1486. Rem
  1487. bbdoc: Get #Byte field value
  1488. End Rem
  1489. Method GetByte:Byte( obj:Object )
  1490. Local p:Byte Ptr = bbRefFieldPtr( obj,_index )
  1491. Select _typeId
  1492. Case ByteTypeId
  1493. Return (Byte Ptr p)[0]
  1494. Case ShortTypeId
  1495. Return (Short Ptr p)[0]
  1496. Case IntTypeId
  1497. Return (Int Ptr p)[0]
  1498. Case UIntTypeId
  1499. Return (UInt Ptr p)[0]
  1500. Case LongTypeId
  1501. Return (Long Ptr p)[0]
  1502. Case ULongTypeId
  1503. Return (ULong Ptr p)[0]
  1504. Case SizetTypeId
  1505. Return (Size_T Ptr p)[0]
  1506. Case FloatTypeId
  1507. Return (Float Ptr p)[0]
  1508. Case DoubleTypeId
  1509. Return (Double Ptr p)[0]
  1510. Case LongIntTypeId
  1511. Return (LongInt Ptr p)[0]
  1512. Case ULongIntTypeId
  1513. Return (ULongInt Ptr p)[0]
  1514. End Select
  1515. End Method
  1516. Rem
  1517. bbdoc: Get #Short field value
  1518. End Rem
  1519. Method GetShort:Short( obj:Object )
  1520. Local p:Byte Ptr = bbRefFieldPtr( obj,_index )
  1521. Select _typeId
  1522. Case ByteTypeId
  1523. Return (Byte Ptr p)[0]
  1524. Case ShortTypeId
  1525. Return (Short Ptr p)[0]
  1526. Case IntTypeId
  1527. Return (Int Ptr p)[0]
  1528. Case UIntTypeId
  1529. Return (UInt Ptr p)[0]
  1530. Case LongTypeId
  1531. Return (Long Ptr p)[0]
  1532. Case ULongTypeId
  1533. Return (ULong Ptr p)[0]
  1534. Case SizetTypeId
  1535. Return (Size_T Ptr p)[0]
  1536. Case FloatTypeId
  1537. Return (Float Ptr p)[0]
  1538. Case DoubleTypeId
  1539. Return (Double Ptr p)[0]
  1540. Case LongIntTypeId
  1541. Return (LongInt Ptr p)[0]
  1542. Case ULongIntTypeId
  1543. Return (ULongInt Ptr p)[0]
  1544. End Select
  1545. End Method
  1546. Rem
  1547. bbdoc: Get #Int field value
  1548. End Rem
  1549. Method GetInt:Int( obj:Object )
  1550. Local p:Byte Ptr = bbRefFieldPtr( obj,_index )
  1551. Select _typeId
  1552. Case ByteTypeId
  1553. Return (Byte Ptr p)[0]
  1554. Case ShortTypeId
  1555. Return (Short Ptr p)[0]
  1556. Case IntTypeId
  1557. Return (Int Ptr p)[0]
  1558. Case UIntTypeId
  1559. Return (UInt Ptr p)[0]
  1560. Case LongTypeId
  1561. Return (Long Ptr p)[0]
  1562. Case ULongTypeId
  1563. Return (ULong Ptr p)[0]
  1564. Case SizetTypeId
  1565. Return (Size_T Ptr p)[0]
  1566. Case FloatTypeId
  1567. Return (Float Ptr p)[0]
  1568. Case DoubleTypeId
  1569. Return (Double Ptr p)[0]
  1570. Case LongIntTypeId
  1571. Return (LongInt Ptr p)[0]
  1572. Case ULongIntTypeId
  1573. Return (ULongInt Ptr p)[0]
  1574. End Select
  1575. End Method
  1576. Rem
  1577. bbdoc: Get #UInt field value
  1578. End Rem
  1579. Method GetUInt:UInt( obj:Object )
  1580. Local p:Byte Ptr = bbRefFieldPtr( obj,_index )
  1581. Select _typeId
  1582. Case ByteTypeId
  1583. Return (Byte Ptr p)[0]
  1584. Case ShortTypeId
  1585. Return (Short Ptr p)[0]
  1586. Case IntTypeId
  1587. Return (Int Ptr p)[0]
  1588. Case UIntTypeId
  1589. Return (UInt Ptr p)[0]
  1590. Case LongTypeId
  1591. Return (Long Ptr p)[0]
  1592. Case ULongTypeId
  1593. Return (ULong Ptr p)[0]
  1594. Case SizetTypeId
  1595. Return (Size_T Ptr p)[0]
  1596. Case FloatTypeId
  1597. Return (Float Ptr p)[0]
  1598. Case DoubleTypeId
  1599. Return (Double Ptr p)[0]
  1600. Case LongIntTypeId
  1601. Return (LongInt Ptr p)[0]
  1602. Case ULongIntTypeId
  1603. Return (ULongInt Ptr p)[0]
  1604. End Select
  1605. End Method
  1606. Rem
  1607. bbdoc: Get long field value
  1608. End Rem
  1609. Method GetLong:Long( obj:Object )
  1610. Local p:Byte Ptr = bbRefFieldPtr( obj,_index )
  1611. Select _typeId
  1612. Case ByteTypeId
  1613. Return (Byte Ptr p)[0]
  1614. Case ShortTypeId
  1615. Return (Short Ptr p)[0]
  1616. Case IntTypeId
  1617. Return (Int Ptr p)[0]
  1618. Case UIntTypeId
  1619. Return (UInt Ptr p)[0]
  1620. Case LongTypeId
  1621. Return (Long Ptr p)[0]
  1622. Case ULongTypeId
  1623. Return (ULong Ptr p)[0]
  1624. Case SizetTypeId
  1625. Return (Size_T Ptr p)[0]
  1626. Case FloatTypeId
  1627. Return (Float Ptr p)[0]
  1628. Case DoubleTypeId
  1629. Return (Double Ptr p)[0]
  1630. Case LongIntTypeId
  1631. Return (LongInt Ptr p)[0]
  1632. Case ULongIntTypeId
  1633. Return (ULongInt Ptr p)[0]
  1634. End Select
  1635. End Method
  1636. Rem
  1637. bbdoc: Get #ULong field value
  1638. End Rem
  1639. Method GetULong:ULong( obj:Object )
  1640. Local p:Byte Ptr = bbRefFieldPtr( obj,_index )
  1641. Select _typeId
  1642. Case ByteTypeId
  1643. Return (Byte Ptr p)[0]
  1644. Case ShortTypeId
  1645. Return (Short Ptr p)[0]
  1646. Case IntTypeId
  1647. Return (Int Ptr p)[0]
  1648. Case UIntTypeId
  1649. Return (UInt Ptr p)[0]
  1650. Case LongTypeId
  1651. Return (Long Ptr p)[0]
  1652. Case ULongTypeId
  1653. Return (ULong Ptr p)[0]
  1654. Case SizetTypeId
  1655. Return (Size_T Ptr p)[0]
  1656. Case FloatTypeId
  1657. Return (Float Ptr p)[0]
  1658. Case DoubleTypeId
  1659. Return (Double Ptr p)[0]
  1660. Case LongIntTypeId
  1661. Return (LongInt Ptr p)[0]
  1662. Case ULongIntTypeId
  1663. Return (ULongInt Ptr p)[0]
  1664. End Select
  1665. End Method
  1666. Rem
  1667. bbdoc: Get #Size_T field value
  1668. End Rem
  1669. Method GetSizet:Size_T( obj:Object )
  1670. Local p:Byte Ptr = bbRefFieldPtr( obj,_index )
  1671. Select _typeId
  1672. Case ByteTypeId
  1673. Return (Byte Ptr p)[0]
  1674. Case ShortTypeId
  1675. Return (Short Ptr p)[0]
  1676. Case IntTypeId
  1677. Return (Int Ptr p)[0]
  1678. Case UIntTypeId
  1679. Return (UInt Ptr p)[0]
  1680. Case LongTypeId
  1681. Return (Long Ptr p)[0]
  1682. Case ULongTypeId
  1683. Return (ULong Ptr p)[0]
  1684. Case SizetTypeId
  1685. Return (Size_T Ptr p)[0]
  1686. Case FloatTypeId
  1687. Return (Float Ptr p)[0]
  1688. Case DoubleTypeId
  1689. Return (Double Ptr p)[0]
  1690. Case LongIntTypeId
  1691. Return (LongInt Ptr p)[0]
  1692. Case ULongIntTypeId
  1693. Return (ULongInt Ptr p)[0]
  1694. End Select
  1695. End Method
  1696. Rem
  1697. bbdoc: Get #Float field value
  1698. End Rem
  1699. Method GetFloat:Float( obj:Object )
  1700. Local p:Byte Ptr = bbRefFieldPtr( obj,_index )
  1701. Select _typeId
  1702. Case ByteTypeId
  1703. Return (Byte Ptr p)[0]
  1704. Case ShortTypeId
  1705. Return (Short Ptr p)[0]
  1706. Case IntTypeId
  1707. Return (Int Ptr p)[0]
  1708. Case UIntTypeId
  1709. Return (UInt Ptr p)[0]
  1710. Case LongTypeId
  1711. Return (Long Ptr p)[0]
  1712. Case ULongTypeId
  1713. Return (ULong Ptr p)[0]
  1714. Case SizetTypeId
  1715. Return (Size_T Ptr p)[0]
  1716. Case FloatTypeId
  1717. Return (Float Ptr p)[0]
  1718. Case DoubleTypeId
  1719. Return (Double Ptr p)[0]
  1720. Case LongIntTypeId
  1721. Return (LongInt Ptr p)[0]
  1722. Case ULongIntTypeId
  1723. Return (ULongInt Ptr p)[0]
  1724. End Select
  1725. End Method
  1726. Rem
  1727. bbdoc: Get #Double field value
  1728. End Rem
  1729. Method GetDouble:Double( obj:Object )
  1730. Local p:Byte Ptr = bbRefFieldPtr( obj,_index )
  1731. Select _typeId
  1732. Case ByteTypeId
  1733. Return (Byte Ptr p)[0]
  1734. Case ShortTypeId
  1735. Return (Short Ptr p)[0]
  1736. Case IntTypeId
  1737. Return (Int Ptr p)[0]
  1738. Case UIntTypeId
  1739. Return (UInt Ptr p)[0]
  1740. Case LongTypeId
  1741. Return (Long Ptr p)[0]
  1742. Case ULongTypeId
  1743. Return (ULong Ptr p)[0]
  1744. Case SizetTypeId
  1745. Return (Size_T Ptr p)[0]
  1746. Case FloatTypeId
  1747. Return (Float Ptr p)[0]
  1748. Case DoubleTypeId
  1749. Return (Double Ptr p)[0]
  1750. Case LongIntTypeId
  1751. Return (LongInt Ptr p)[0]
  1752. Case ULongIntTypeId
  1753. Return (ULongInt Ptr p)[0]
  1754. End Select
  1755. End Method
  1756. Rem
  1757. bbdoc: Get #LongInt field value
  1758. End Rem
  1759. Method GetLongInt:LongInt( obj:Object )
  1760. Local p:Byte Ptr = bbRefFieldPtr( obj,_index )
  1761. Select _typeId
  1762. Case ByteTypeId
  1763. Return (Byte Ptr p)[0]
  1764. Case ShortTypeId
  1765. Return (Short Ptr p)[0]
  1766. Case IntTypeId
  1767. Return (Int Ptr p)[0]
  1768. Case UIntTypeId
  1769. Return (UInt Ptr p)[0]
  1770. Case LongTypeId
  1771. Return (Long Ptr p)[0]
  1772. Case ULongTypeId
  1773. Return (ULong Ptr p)[0]
  1774. Case SizetTypeId
  1775. Return (Size_T Ptr p)[0]
  1776. Case FloatTypeId
  1777. Return (Float Ptr p)[0]
  1778. Case DoubleTypeId
  1779. Return (Double Ptr p)[0]
  1780. Case LongIntTypeId
  1781. Return (LongInt Ptr p)[0]
  1782. Case ULongIntTypeId
  1783. Return (ULongInt Ptr p)[0]
  1784. End Select
  1785. End Method
  1786. Rem
  1787. bbdoc: Get #ULongInt field value
  1788. End Rem
  1789. Method GetULongInt:ULongInt( obj:Object )
  1790. Local p:Byte Ptr = bbRefFieldPtr( obj,_index )
  1791. Select _typeId
  1792. Case ByteTypeId
  1793. Return (Byte Ptr p)[0]
  1794. Case ShortTypeId
  1795. Return (Short Ptr p)[0]
  1796. Case IntTypeId
  1797. Return (Int Ptr p)[0]
  1798. Case UIntTypeId
  1799. Return (UInt Ptr p)[0]
  1800. Case LongTypeId
  1801. Return (Long Ptr p)[0]
  1802. Case ULongTypeId
  1803. Return (ULong Ptr p)[0]
  1804. Case SizetTypeId
  1805. Return (Size_T Ptr p)[0]
  1806. Case FloatTypeId
  1807. Return (Float Ptr p)[0]
  1808. Case DoubleTypeId
  1809. Return (Double Ptr p)[0]
  1810. Case LongIntTypeId
  1811. Return (LongInt Ptr p)[0]
  1812. Case ULongIntTypeId
  1813. Return (ULongInt Ptr p)[0]
  1814. End Select
  1815. End Method
  1816. Rem
  1817. bbdoc: Get #String field value
  1818. End Rem
  1819. Method GetString:String( obj:Object )
  1820. Return String( Get( obj ) )
  1821. End Method
  1822. Rem
  1823. bbdoc: Set field value
  1824. End Rem
  1825. Method Set( obj:Object,value:Object )
  1826. _Assign bbRefFieldPtr( obj,_index ),_typeId,value
  1827. End Method
  1828. Rem
  1829. bbdoc: Set #Byte field value
  1830. End Rem
  1831. Method Set( obj:Object,value:Byte )
  1832. SetByte(obj, value)
  1833. End Method
  1834. Rem
  1835. bbdoc: Set #Short field value
  1836. End Rem
  1837. Method Set( obj:Object,value:Short )
  1838. SetShort(obj, value)
  1839. End Method
  1840. Rem
  1841. bbdoc: Set #Int field value
  1842. End Rem
  1843. Method Set( obj:Object,value:Int )
  1844. SetInt(obj, value)
  1845. End Method
  1846. Rem
  1847. bbdoc: Set #UInt field value
  1848. End Rem
  1849. Method Set( obj:Object,value:UInt )
  1850. SetUInt(obj, value)
  1851. End Method
  1852. Rem
  1853. bbdoc: Set #Long field value
  1854. End Rem
  1855. Method Set( obj:Object,value:Long )
  1856. SetLong(obj, value)
  1857. End Method
  1858. Rem
  1859. bbdoc: Set #ULong field value
  1860. End Rem
  1861. Method Set( obj:Object,value:ULong )
  1862. SetULong(obj, value)
  1863. End Method
  1864. Rem
  1865. bbdoc: Set #Size_T field value
  1866. End Rem
  1867. Method Set( obj:Object,value:Size_T )
  1868. SetSizet(obj, value)
  1869. End Method
  1870. Rem
  1871. bbdoc: Set #Float field value
  1872. End Rem
  1873. Method Set( obj:Object,value:Float )
  1874. SetFloat(obj, value)
  1875. End Method
  1876. Rem
  1877. bbdoc: Set #Double field value
  1878. End Rem
  1879. Method Set( obj:Object,value:Double )
  1880. SetDouble(obj, value)
  1881. End Method
  1882. Rem
  1883. bbdoc: Set #LongInt field value
  1884. End Rem
  1885. Method Set( obj:Object,value:LongInt )
  1886. SetLongInt(obj, value)
  1887. End Method
  1888. Rem
  1889. bbdoc: Set #ULongInt field value
  1890. End Rem
  1891. Method Set( obj:Object,value:ULongInt )
  1892. SetULongInt(obj, value)
  1893. End Method
  1894. Rem
  1895. bbdoc: Set #Object field value
  1896. End Rem
  1897. Method SetObject( obj:Object,value:Object )
  1898. _Assign bbRefFieldPtr( obj,_index ),_typeId,value
  1899. End Method
  1900. Rem
  1901. bbdoc: Set #Byte field value
  1902. End Rem
  1903. Method SetByte( obj:Object,value:Byte )
  1904. Local p:Byte Ptr = bbRefFieldPtr( obj,_index )
  1905. Select _typeId
  1906. Case ByteTypeId
  1907. (Byte Ptr p)[0]=value
  1908. Case ShortTypeId
  1909. (Short Ptr p)[0]=Short(value)
  1910. Case IntTypeId
  1911. (Int Ptr p)[0]=Int(value)
  1912. Case UIntTypeId
  1913. (UInt Ptr p)[0]=UInt(value)
  1914. Case LongTypeId
  1915. (Long Ptr p)[0]=Long(value)
  1916. Case ULongTypeId
  1917. (ULong Ptr p)[0]=ULong(value)
  1918. Case SizetTypeId
  1919. (Size_T Ptr p)[0]=Size_T(value)
  1920. Case FloatTypeId
  1921. (Float Ptr p)[0]=Float(value)
  1922. Case DoubleTypeId
  1923. (Double Ptr p)[0]=Double(value)
  1924. Case LongIntTypeId
  1925. (LongInt Ptr p)[0]=LongInt(value)
  1926. Case ULongIntTypeId
  1927. (ULongInt Ptr p)[0]=ULongInt(value)
  1928. Case StringTypeId
  1929. bbRefAssignObject p,String.FromInt( value )
  1930. End Select
  1931. End Method
  1932. Rem
  1933. bbdoc: Set #Short field value
  1934. End Rem
  1935. Method SetShort( obj:Object,value:Short )
  1936. Local p:Byte Ptr = bbRefFieldPtr( obj,_index )
  1937. Select _typeId
  1938. Case ByteTypeId
  1939. (Byte Ptr p)[0]=Byte(value)
  1940. Case ShortTypeId
  1941. (Short Ptr p)[0]=value
  1942. Case IntTypeId
  1943. (Int Ptr p)[0]=Int(value)
  1944. Case UIntTypeId
  1945. (UInt Ptr p)[0]=UInt(value)
  1946. Case LongTypeId
  1947. (Long Ptr p)[0]=Long(value)
  1948. Case ULongTypeId
  1949. (ULong Ptr p)[0]=ULong(value)
  1950. Case SizetTypeId
  1951. (Size_T Ptr p)[0]=Size_T(value)
  1952. Case FloatTypeId
  1953. (Float Ptr p)[0]=Float(value)
  1954. Case DoubleTypeId
  1955. (Double Ptr p)[0]=Double(value)
  1956. Case LongIntTypeId
  1957. (LongInt Ptr p)[0]=LongInt(value)
  1958. Case ULongIntTypeId
  1959. (ULongInt Ptr p)[0]=ULongInt(value)
  1960. Case StringTypeId
  1961. bbRefAssignObject p,String.FromInt( value )
  1962. End Select
  1963. End Method
  1964. Rem
  1965. bbdoc: Set #Int field value
  1966. End Rem
  1967. Method SetInt( obj:Object,value:Int )
  1968. Local p:Byte Ptr = bbRefFieldPtr( obj,_index )
  1969. Select _typeId
  1970. Case ByteTypeId
  1971. (Byte Ptr p)[0]=Byte(value)
  1972. Case ShortTypeId
  1973. (Short Ptr p)[0]=Short(value)
  1974. Case IntTypeId
  1975. (Int Ptr p)[0]=value
  1976. Case UIntTypeId
  1977. (UInt Ptr p)[0]=UInt(value)
  1978. Case LongTypeId
  1979. (Long Ptr p)[0]=Long(value)
  1980. Case ULongTypeId
  1981. (ULong Ptr p)[0]=ULong(value)
  1982. Case SizetTypeId
  1983. (Size_T Ptr p)[0]=Size_T(value)
  1984. Case FloatTypeId
  1985. (Float Ptr p)[0]=Float(value)
  1986. Case DoubleTypeId
  1987. (Double Ptr p)[0]=Double(value)
  1988. Case LongIntTypeId
  1989. (LongInt Ptr p)[0]=LongInt(value)
  1990. Case ULongIntTypeId
  1991. (ULongInt Ptr p)[0]=ULongInt(value)
  1992. Case StringTypeId
  1993. bbRefAssignObject p,String.FromInt( value )
  1994. End Select
  1995. End Method
  1996. Rem
  1997. bbdoc: Set #UInt field value
  1998. End Rem
  1999. Method SetUInt( obj:Object,value:UInt )
  2000. Local p:Byte Ptr = bbRefFieldPtr( obj,_index )
  2001. Select _typeId
  2002. Case ByteTypeId
  2003. (Byte Ptr p)[0]=Byte(value)
  2004. Case ShortTypeId
  2005. (Short Ptr p)[0]=Short(value)
  2006. Case IntTypeId
  2007. (Int Ptr p)[0]=Int(value)
  2008. Case UIntTypeId
  2009. (UInt Ptr p)[0]=value
  2010. Case LongTypeId
  2011. (Long Ptr p)[0]=Long(value)
  2012. Case ULongTypeId
  2013. (ULong Ptr p)[0]=ULong(value)
  2014. Case SizetTypeId
  2015. (Size_T Ptr p)[0]=Size_T(value)
  2016. Case FloatTypeId
  2017. (Float Ptr p)[0]=Float(value)
  2018. Case DoubleTypeId
  2019. (Double Ptr p)[0]=Double(value)
  2020. Case LongIntTypeId
  2021. (LongInt Ptr p)[0]=LongInt(value)
  2022. Case ULongIntTypeId
  2023. (ULongInt Ptr p)[0]=ULongInt(value)
  2024. Case StringTypeId
  2025. bbRefAssignObject p,String.FromUInt( value )
  2026. End Select
  2027. End Method
  2028. Rem
  2029. bbdoc: Set #Long field value
  2030. End Rem
  2031. Method SetLong( obj:Object,value:Long )
  2032. Local p:Byte Ptr = bbRefFieldPtr( obj,_index )
  2033. Select _typeId
  2034. Case ByteTypeId
  2035. (Byte Ptr p)[0]=Byte(value)
  2036. Case ShortTypeId
  2037. (Short Ptr p)[0]=Short(value)
  2038. Case IntTypeId
  2039. (Int Ptr p)[0]=Int(value)
  2040. Case UIntTypeId
  2041. (UInt Ptr p)[0]=UInt(value)
  2042. Case LongTypeId
  2043. (Long Ptr p)[0]=value
  2044. Case ULongTypeId
  2045. (ULong Ptr p)[0]=ULong(value)
  2046. Case SizetTypeId
  2047. (Size_T Ptr p)[0]=Size_T(value)
  2048. Case FloatTypeId
  2049. (Float Ptr p)[0]=Float(value)
  2050. Case DoubleTypeId
  2051. (Double Ptr p)[0]=Double(value)
  2052. Case LongIntTypeId
  2053. (LongInt Ptr p)[0]=LongInt(value)
  2054. Case ULongIntTypeId
  2055. (ULongInt Ptr p)[0]=ULongInt(value)
  2056. Case StringTypeId
  2057. bbRefAssignObject p,String.FromLong( value )
  2058. End Select
  2059. End Method
  2060. Rem
  2061. bbdoc: Set #ULong field value
  2062. End Rem
  2063. Method SetULong( obj:Object,value:ULong )
  2064. Local p:Byte Ptr = bbRefFieldPtr( obj,_index )
  2065. Select _typeId
  2066. Case ByteTypeId
  2067. (Byte Ptr p)[0]=Byte(value)
  2068. Case ShortTypeId
  2069. (Short Ptr p)[0]=Short(value)
  2070. Case IntTypeId
  2071. (Int Ptr p)[0]=Int(value)
  2072. Case UIntTypeId
  2073. (UInt Ptr p)[0]=UInt(value)
  2074. Case LongTypeId
  2075. (Long Ptr p)[0]=Long(value)
  2076. Case ULongTypeId
  2077. (ULong Ptr p)[0]=value
  2078. Case SizetTypeId
  2079. (Size_T Ptr p)[0]=Size_T(value)
  2080. Case FloatTypeId
  2081. (Float Ptr p)[0]=Float(value)
  2082. Case DoubleTypeId
  2083. (Double Ptr p)[0]=Double(value)
  2084. Case LongIntTypeId
  2085. (LongInt Ptr p)[0]=LongInt(value)
  2086. Case ULongIntTypeId
  2087. (ULongInt Ptr p)[0]=ULongInt(value)
  2088. Case StringTypeId
  2089. bbRefAssignObject p,String.FromULong( value )
  2090. End Select
  2091. End Method
  2092. Rem
  2093. bbdoc: Set #Size_T field value
  2094. End Rem
  2095. Method SetSizet( obj:Object,value:Size_T )
  2096. Local p:Byte Ptr = bbRefFieldPtr( obj,_index )
  2097. Select _typeId
  2098. Case ByteTypeId
  2099. (Byte Ptr p)[0]=Byte(value)
  2100. Case ShortTypeId
  2101. (Short Ptr p)[0]=Short(value)
  2102. Case IntTypeId
  2103. (Int Ptr p)[0]=Int(value)
  2104. Case UIntTypeId
  2105. (UInt Ptr p)[0]=UInt(value)
  2106. Case LongTypeId
  2107. (Long Ptr p)[0]=Long(value)
  2108. Case ULongTypeId
  2109. (ULong Ptr p)[0]=ULong(value)
  2110. Case SizetTypeId
  2111. (Size_T Ptr p)[0]=value
  2112. Case FloatTypeId
  2113. (Float Ptr p)[0]=Float(value)
  2114. Case DoubleTypeId
  2115. (Double Ptr p)[0]=Double(value)
  2116. Case LongIntTypeId
  2117. (LongInt Ptr p)[0]=LongInt(value)
  2118. Case ULongIntTypeId
  2119. (ULongInt Ptr p)[0]=ULongInt(value)
  2120. Case StringTypeId
  2121. bbRefAssignObject p,String.FromSizet( value )
  2122. End Select
  2123. End Method
  2124. Rem
  2125. bbdoc: Set #Float field value
  2126. End Rem
  2127. Method SetFloat( obj:Object,value:Float )
  2128. Local p:Byte Ptr = bbRefFieldPtr( obj,_index )
  2129. Select _typeId
  2130. Case ByteTypeId
  2131. (Byte Ptr p)[0]=Byte(value)
  2132. Case ShortTypeId
  2133. (Short Ptr p)[0]=Short(value)
  2134. Case IntTypeId
  2135. (Int Ptr p)[0]=Int(value)
  2136. Case UIntTypeId
  2137. (UInt Ptr p)[0]=UInt(value)
  2138. Case LongTypeId
  2139. (Long Ptr p)[0]=Long(value)
  2140. Case ULongTypeId
  2141. (ULong Ptr p)[0]=ULong(value)
  2142. Case SizetTypeId
  2143. (Size_T Ptr p)[0]=Size_T(value)
  2144. Case FloatTypeId
  2145. (Float Ptr p)[0]=value
  2146. Case DoubleTypeId
  2147. (Double Ptr p)[0]=Double(value)
  2148. Case LongIntTypeId
  2149. (LongInt Ptr p)[0]=LongInt(value)
  2150. Case ULongIntTypeId
  2151. (ULongInt Ptr p)[0]=ULongInt(value)
  2152. Case StringTypeId
  2153. bbRefAssignObject p,String.FromFloat( value )
  2154. End Select
  2155. End Method
  2156. Rem
  2157. bbdoc: Set #Double field value
  2158. End Rem
  2159. Method SetDouble( obj:Object,value:Double )
  2160. Local p:Byte Ptr = bbRefFieldPtr( obj,_index )
  2161. Select _typeId
  2162. Case ByteTypeId
  2163. (Byte Ptr p)[0]=Byte(value)
  2164. Case ShortTypeId
  2165. (Short Ptr p)[0]=Short(value)
  2166. Case IntTypeId
  2167. (Int Ptr p)[0]=Int(value)
  2168. Case UIntTypeId
  2169. (UInt Ptr p)[0]=UInt(value)
  2170. Case LongTypeId
  2171. (Long Ptr p)[0]=Long(value)
  2172. Case ULongTypeId
  2173. (ULong Ptr p)[0]=ULong(value)
  2174. Case SizetTypeId
  2175. (Size_T Ptr p)[0]=Size_T(value)
  2176. Case FloatTypeId
  2177. (Float Ptr p)[0]=Float(value)
  2178. Case DoubleTypeId
  2179. (Double Ptr p)[0]=value
  2180. Case LongIntTypeId
  2181. (LongInt Ptr p)[0]=LongInt(value)
  2182. Case ULongIntTypeId
  2183. (ULongInt Ptr p)[0]=ULongInt(value)
  2184. Case StringTypeId
  2185. bbRefAssignObject p,String.FromDouble( value )
  2186. End Select
  2187. End Method
  2188. Rem
  2189. bbdoc: Set #LongInt field value
  2190. End Rem
  2191. Method SetLongInt( obj:Object,value:LongInt )
  2192. Local p:Byte Ptr = bbRefFieldPtr( obj,_index )
  2193. Select _typeId
  2194. Case ByteTypeId
  2195. (Byte Ptr p)[0]=Byte(value)
  2196. Case ShortTypeId
  2197. (Short Ptr p)[0]=Short(value)
  2198. Case IntTypeId
  2199. (Int Ptr p)[0]=Int(value)
  2200. Case UIntTypeId
  2201. (UInt Ptr p)[0]=UInt(value)
  2202. Case LongTypeId
  2203. (Long Ptr p)[0]=Long(value)
  2204. Case ULongTypeId
  2205. (ULong Ptr p)[0]=ULong(value)
  2206. Case SizetTypeId
  2207. (Size_T Ptr p)[0]=Size_T(value)
  2208. Case FloatTypeId
  2209. (Float Ptr p)[0]=Float(value)
  2210. Case DoubleTypeId
  2211. (Double Ptr p)[0]=Double(value)
  2212. Case LongIntTypeId
  2213. (LongInt Ptr p)[0]=value
  2214. Case ULongIntTypeId
  2215. (ULongInt Ptr p)[0]=ULongInt(value)
  2216. Case StringTypeId
  2217. bbRefAssignObject p,String.FromLongInt( value )
  2218. End Select
  2219. End Method
  2220. Rem
  2221. bbdoc: Set #ULongInt field value
  2222. End Rem
  2223. Method SetULongInt( obj:Object,value:ULongInt )
  2224. Local p:Byte Ptr = bbRefFieldPtr( obj,_index )
  2225. Select _typeId
  2226. Case ByteTypeId
  2227. (Byte Ptr p)[0]=Byte(value)
  2228. Case ShortTypeId
  2229. (Short Ptr p)[0]=Short(value)
  2230. Case IntTypeId
  2231. (Int Ptr p)[0]=Int(value)
  2232. Case UIntTypeId
  2233. (UInt Ptr p)[0]=UInt(value)
  2234. Case LongTypeId
  2235. (Long Ptr p)[0]=Long(value)
  2236. Case ULongTypeId
  2237. (ULong Ptr p)[0]=ULong(value)
  2238. Case SizetTypeId
  2239. (Size_T Ptr p)[0]=Size_T(value)
  2240. Case FloatTypeId
  2241. (Float Ptr p)[0]=Float(value)
  2242. Case DoubleTypeId
  2243. (Double Ptr p)[0]=Double(value)
  2244. Case LongIntTypeId
  2245. (LongInt Ptr p)[0]=LongInt(value)
  2246. Case ULongIntTypeId
  2247. (ULongInt Ptr p)[0]=value
  2248. Case StringTypeId
  2249. bbRefAssignObject p,String.FromULongInt( value )
  2250. End Select
  2251. End Method
  2252. Rem
  2253. bbdoc: Set #String field value
  2254. End Rem
  2255. Method SetString( obj:Object,value:String )
  2256. Set obj,value
  2257. End Method
  2258. Field _index
  2259. End Type
  2260. Rem
  2261. bbdoc: Type global
  2262. End Rem
  2263. Type TGlobal Extends TMember
  2264. Method Init:TGlobal( name:String,typeId:TTypeId,meta:String,ref:Byte Ptr )
  2265. _name=name
  2266. _typeId=typeId
  2267. InitMeta(meta)
  2268. _ref=ref
  2269. Return Self
  2270. End Method
  2271. Rem
  2272. bbdoc: Get global value
  2273. End Rem
  2274. Method Get:Object()
  2275. Return _Get( _ref,_typeId )
  2276. End Method
  2277. Rem
  2278. bbdoc: Get int global value
  2279. End Rem
  2280. Method GetInt:Int( )
  2281. Return GetString().ToInt()
  2282. End Method
  2283. Rem
  2284. bbdoc: Get long global value
  2285. End Rem
  2286. Method GetLong:Long()
  2287. Return GetString().ToLong()
  2288. End Method
  2289. Rem
  2290. bbdoc: Get size_t global value
  2291. End Rem
  2292. Method GetSizet:Size_T()
  2293. Return GetString().ToSizet()
  2294. End Method
  2295. Rem
  2296. bbdoc: Get ulong global value
  2297. End Rem
  2298. Method GetULong:ULong()
  2299. Return GetString().ToULong()
  2300. End Method
  2301. Rem
  2302. bbdoc: Get longint global value
  2303. End Rem
  2304. Method GetLongInt:LongInt()
  2305. Return GetString().ToLongInt()
  2306. End Method
  2307. Rem
  2308. bbdoc: Get ulongint global value
  2309. End Rem
  2310. Method GetULongInt:ULongInt()
  2311. Return GetString().ToULongInt()
  2312. End Method
  2313. Rem
  2314. bbdoc: Get float global value
  2315. End Rem
  2316. Method GetFloat:Float()
  2317. Return GetString().ToFloat()
  2318. End Method
  2319. Rem
  2320. bbdoc: Get double global value
  2321. End Rem
  2322. Method GetDouble:Double()
  2323. Return GetString().ToDouble()
  2324. End Method
  2325. Rem
  2326. bbdoc: Get string global value
  2327. End Rem
  2328. Method GetString:String()
  2329. Return String( Get() )
  2330. End Method
  2331. Rem
  2332. bbdoc: Set global value
  2333. End Rem
  2334. Method Set(value:Object )
  2335. _Assign _ref,_typeId,value
  2336. End Method
  2337. Rem
  2338. bbdoc: Set int global value
  2339. End Rem
  2340. Method SetInt(value:Int )
  2341. SetString String.FromInt( value )
  2342. End Method
  2343. Rem
  2344. bbdoc: Set uint global value
  2345. End Rem
  2346. Method SetUInt(value:UInt )
  2347. SetString String.FromUInt( value )
  2348. End Method
  2349. Rem
  2350. bbdoc: Set long global value
  2351. End Rem
  2352. Method SetLong(value:Long )
  2353. SetString String.FromLong( value )
  2354. End Method
  2355. Rem
  2356. bbdoc: Set ulong global value
  2357. End Rem
  2358. Method SetULong(value:ULong )
  2359. SetString String.FromULong( value )
  2360. End Method
  2361. Rem
  2362. bbdoc: Set longint global value
  2363. End Rem
  2364. Method SetLongInt(value:LongInt )
  2365. SetString String.FromLongInt( value )
  2366. End Method
  2367. Rem
  2368. bbdoc: Set ulongint global value
  2369. End Rem
  2370. Method SetULongInt(value:ULongInt )
  2371. SetString String.FromULongInt( value )
  2372. End Method
  2373. Rem
  2374. bbdoc: Set size_t global value
  2375. End Rem
  2376. Method SetSizet(value:Size_T )
  2377. SetString String.FromSizet( value )
  2378. End Method
  2379. Rem
  2380. bbdoc: Set float global value
  2381. End Rem
  2382. Method SetFloat(value:Float )
  2383. SetString String.FromFloat( value )
  2384. End Method
  2385. Rem
  2386. bbdoc: Set double global value
  2387. End Rem
  2388. Method SetDouble(value:Double )
  2389. SetString String.FromDouble( value )
  2390. End Method
  2391. Rem
  2392. bbdoc: Set string global value
  2393. End Rem
  2394. Method SetString(value:String )
  2395. Set value
  2396. End Method
  2397. Field _ref:Byte Ptr
  2398. End Type
  2399. Rem
  2400. bbdoc: Type function
  2401. endrem
  2402. Type TFunction Extends TMember
  2403. Method Init:TFunction(name:String, typeId:TTypeId, meta:String, selfTypeId:TTypeId, ref:Byte Ptr, argTypes:TTypeId[])
  2404. _name=name
  2405. _typeId=typeId
  2406. InitMeta(meta)
  2407. _selfTypeId=selfTypeId
  2408. _ref=ref
  2409. _argTypes=argTypes
  2410. Return Self
  2411. End Method
  2412. Rem
  2413. bbdoc: Get function arg types
  2414. End Rem
  2415. Method ArgTypes:TTypeId[]()
  2416. Return _argTypes
  2417. End Method
  2418. Rem
  2419. bbdoc: Get function return type
  2420. End Rem
  2421. Method ReturnType:TTypeId()
  2422. Return _typeId
  2423. End Method
  2424. Rem
  2425. bbdoc: Get function pointer.
  2426. endrem
  2427. Method FunctionPtr:Byte Ptr()
  2428. Return _ref
  2429. End Method
  2430. Rem
  2431. bbdoc: Invoke type function
  2432. endrem
  2433. Method Invoke:Object(args:Object[] = Null)
  2434. Return _CallFunction( _ref, _typeId, args, _argTypes)
  2435. End Method
  2436. Field _selfTypeId:TTypeId
  2437. Field _ref:Byte Ptr
  2438. Field _argTypes:TTypeId[]
  2439. EndType
  2440. Rem
  2441. bbdoc: Type method
  2442. End Rem
  2443. Type TMethod Extends TMember
  2444. Method Init:TMethod( name:String,typeId:TTypeId,meta:String,selfTypeId:TTypeId,ref:Byte Ptr,argTypes:TTypeId[] )
  2445. _name=name
  2446. _typeId=typeId
  2447. InitMeta(meta)
  2448. _selfTypeId=selfTypeId
  2449. _ref=ref
  2450. _argTypes=argTypes
  2451. Return Self
  2452. End Method
  2453. Rem
  2454. bbdoc: Get method arg types
  2455. End Rem
  2456. Method ArgTypes:TTypeId[]()
  2457. Return _argTypes
  2458. End Method
  2459. Method ReturnType:TTypeId()
  2460. Return _typeId._retType
  2461. End Method
  2462. Rem
  2463. bbdoc: Invoke method
  2464. End Rem
  2465. Method Invoke:Object( obj:Object,args:Object[] = Null)
  2466. Return _CallMethod( _ref,_typeId,obj,args,_argTypes )
  2467. End Method
  2468. Field _selfTypeId:TTypeId
  2469. Field _ref:Byte Ptr
  2470. Field _argTypes:TTypeId[]
  2471. End Type
  2472. Rem
  2473. bbdoc: Type id
  2474. End Rem
  2475. Type TTypeId
  2476. Rem
  2477. bbdoc: Get name of type
  2478. End Rem
  2479. Method Name:String()
  2480. Return _name
  2481. End Method
  2482. Rem
  2483. bbdoc: Get type meta data
  2484. End Rem
  2485. Method MetaData:String( key:String="" )
  2486. If Not _metaMap Or Not key Return _meta
  2487. Return String(_metaMap.ValueForKey(key))
  2488. End Method
  2489. Rem
  2490. bbdoc: Returns #True if @key is in the metadata.
  2491. End Rem
  2492. Method HasMetaData:Int( key:String )
  2493. If Not _metaMap Or Not key Return False
  2494. Return _metaMap.Contains(key)
  2495. End Method
  2496. Rem
  2497. bbdoc: Get super type
  2498. End Rem
  2499. Method SuperType:TTypeId()
  2500. Return _super
  2501. End Method
  2502. Rem
  2503. bbdoc: Get array type
  2504. End Rem
  2505. Method ArrayType:TTypeId(dims:Int = 1)
  2506. Try
  2507. _guard.Lock()
  2508. If dims >= _arrayType.length Then
  2509. _arrayType = _arrayType[..dims + 1]
  2510. End If
  2511. Local at:TTypeId = _arrayType[dims]
  2512. If Not at
  2513. Local dim:String
  2514. If dims > 1 Then
  2515. For Local i:Int = 1 Until dims
  2516. dim :+ ","
  2517. Next
  2518. End If
  2519. ?Not ptr64
  2520. at = New TTypeId.Init( _name+"[" + dim + "]",4,bbRefArrayClass() )
  2521. ?ptr64
  2522. at = New TTypeId.Init( _name+"[" + dim + "]",8,bbRefArrayClass() )
  2523. ?
  2524. at._elementType=Self
  2525. If _super
  2526. at._super=_super.ArrayType()
  2527. Else
  2528. at._super=ArrayTypeId
  2529. EndIf
  2530. _arrayType[dims] = at
  2531. EndIf
  2532. Return at
  2533. Finally
  2534. _guard.Unlock()
  2535. End Try
  2536. End Method
  2537. Rem
  2538. bbdoc: Get element type
  2539. End Rem
  2540. Method ElementType:TTypeId()
  2541. Return _elementType
  2542. End Method
  2543. Rem
  2544. bbdoc: Get pointer type
  2545. End Rem
  2546. Method PointerType:TTypeId()
  2547. Try
  2548. _guard.Lock()
  2549. Local pt:TTypeId = _pointerType
  2550. If Not pt Then
  2551. ?Not ptr64
  2552. pt = New TTypeId.Init( _name + " Ptr", 4)
  2553. ?ptr64
  2554. pt = New TTypeId.Init( _name + " Ptr", 8)
  2555. ?
  2556. pt._elementType = Self
  2557. If _super Then
  2558. pt._super = _super.PointerType()
  2559. Else
  2560. pt._super = PointerTypeId
  2561. EndIf
  2562. _pointertype = pt
  2563. EndIf
  2564. Return pt
  2565. Finally
  2566. _guard.Unlock()
  2567. End Try
  2568. End Method
  2569. Rem
  2570. bbdoc: Get function pointer type
  2571. End Rem
  2572. Method FunctionType:TTypeId( args:TTypeId[]=Null)
  2573. Local s:String
  2574. If args.length > 2 Then
  2575. Local sb:TStringBuilder = New TStringBuilder()
  2576. For Local t:TTypeId = EachIn args
  2577. If sb.Length() sb.Append(",")
  2578. sb.Append(t.Name())
  2579. Next
  2580. Else
  2581. For Local t:TTypeId = EachIn args
  2582. If s Then s :+ ","
  2583. s :+ t.Name()
  2584. Next
  2585. End If
  2586. If Not _functionType Then
  2587. _functionType = New TStringMap
  2588. End If
  2589. Local ft:TTypeId = TTypeId(_functionType.ValueForKey(s))
  2590. If Not ft Then
  2591. ?Not ptr64
  2592. ft = New TTypeId.Init( _name + "(" + s + ")", 4)
  2593. ?ptr64
  2594. ft = New TTypeId.Init( _name + "(" + s + ")", 8)
  2595. ?
  2596. ft._retType = Self
  2597. ft._argTypes = args
  2598. If _super Then
  2599. ft._super = _super.FunctionType()
  2600. Else
  2601. ft._super = FunctionTypeId
  2602. EndIf
  2603. _functionType.Insert(s, ft)
  2604. EndIf
  2605. Return ft
  2606. End Method
  2607. Rem
  2608. bbdoc: Get function return type
  2609. End Rem
  2610. Method ReturnType:TTypeId()
  2611. If Not _retType Then Throw "TypeID is not a function type"
  2612. Return _retType
  2613. End Method
  2614. Rem
  2615. bbdoc: Get function argument types
  2616. End Rem
  2617. Method ArgTypes:TTypeId[]()
  2618. If Not _retType Then Throw "TypeID is not a function type"
  2619. Return _argTypes
  2620. End Method
  2621. Rem
  2622. bbdoc: Determine if type extends a type
  2623. End Rem
  2624. Method ExtendsType( typeId:TTypeId )
  2625. If Self=typeId Return True
  2626. If _super Return _super.ExtendsType( typeId )
  2627. End Method
  2628. Rem
  2629. bbdoc: Get list of derived types
  2630. End Rem
  2631. Method DerivedTypes:TList()
  2632. If Not _derived _derived=New TList
  2633. Return _derived
  2634. End Method
  2635. Rem
  2636. bbdoc: Create a new object
  2637. End Rem
  2638. Method NewObject:Object()
  2639. If Not _class Throw "Unable to create new object"
  2640. If _interface Throw "Unable to create object from interface"
  2641. Return bbObjectNew( _class )
  2642. End Method
  2643. Rem
  2644. bbdoc: Returns True if this TypeId is an interface.
  2645. End Rem
  2646. Method IsInterface:Int()
  2647. Return _interface <> Null
  2648. End Method
  2649. Rem
  2650. bbdoc: Get list of constants
  2651. about: Only returns constants declared in this type, not in super types.
  2652. End Rem
  2653. Method Constants:TStringMap()
  2654. Return _consts
  2655. End Method
  2656. Rem
  2657. bbdoc: Get list of fields
  2658. about: Only returns fields declared in this type, not in super types.
  2659. End Rem
  2660. Method Fields:TStringMap()
  2661. Return _fields
  2662. End Method
  2663. Rem
  2664. bbdoc: Get list of globals
  2665. about: Only returns globals declared in this type, not in super types.
  2666. End Rem
  2667. Method Globals:TStringMap()
  2668. Return _globals
  2669. End Method
  2670. Rem
  2671. bbdoc: Get list of functions
  2672. about: Only returns functions declared in this type, not in super types.
  2673. EndRem
  2674. Method Functions:TStringMap()
  2675. Return _functions
  2676. End Method
  2677. Rem
  2678. bbdoc: Get list of methods
  2679. about: Only returns methods declared in this type, not in super types.
  2680. End Rem
  2681. Method Methods:TStringMap()
  2682. Return _methods
  2683. End Method
  2684. Rem
  2685. bbdoc: Get list of implemented interfaces.
  2686. End Rem
  2687. Method Interfaces:TList()
  2688. Return _interfaces
  2689. End Method
  2690. Rem
  2691. bbdoc: Find a constant by name
  2692. about: Searchs type hierarchy for constant called @name.
  2693. End Rem
  2694. Method FindConstant:TConstant( name:String )
  2695. name=name.ToLower()
  2696. Local t:TConstant = TConstant(_consts.ValueForKey(name))
  2697. If t Return t
  2698. ' For Local t:TConstant=EachIn _consts
  2699. ' If t.NameLower()=name Return t
  2700. ' Next
  2701. If _super Return _super.FindConstant( name )
  2702. End Method
  2703. Rem
  2704. bbdoc: Find a field by name
  2705. about: Searchs type hierarchy for field called @name.
  2706. End Rem
  2707. Method FindField:TField( name:String )
  2708. name=name.ToLower()
  2709. Local t:TField = TField(_fields.ValueForKey(name))
  2710. If t Then Return t
  2711. If _super Return _super.FindField( name )
  2712. End Method
  2713. Rem
  2714. bbdoc: Find a global by name
  2715. about: Searchs type hierarchy for global called @name.
  2716. End Rem
  2717. Method FindGlobal:TGlobal( name:String )
  2718. name=name.ToLower()
  2719. Local t:TGlobal = TGlobal(_globals.ValueForKey(name))
  2720. If t Then Return t
  2721. If _super Return _super.FindGlobal( name )
  2722. End Method
  2723. Rem
  2724. bbdoc: Find a function by name
  2725. about: Searches type heirarchy for function called @name
  2726. endrem
  2727. Method FindFunction:TFunction(name:String)
  2728. name = name.ToLower()
  2729. Local t:TFunction = TFunction(_functions.ValueForKey(name))
  2730. If t Then Return t
  2731. If _super Return _super.FindFunction(name)
  2732. End Method
  2733. Rem
  2734. bbdoc: Find a method by name
  2735. about: Searchs type hierarchy for method called @name.
  2736. End Rem
  2737. Method FindMethod:TMethod( name:String )
  2738. name=name.ToLower()
  2739. Local t:TMethod = TMethod(_methods.ValueForKey(name))
  2740. If t Then Return t
  2741. If _super Return _super.FindMethod( name )
  2742. End Method
  2743. Rem
  2744. bbdoc: Enumerate all constants
  2745. about: Returns a list of all constants in type hierarchy
  2746. End Rem
  2747. Method EnumConstants:TList( list:TList=Null )
  2748. If Not list list=New TList
  2749. If _super _super.EnumConstants list
  2750. For Local t:TConstant=EachIn _constsList '.Values()
  2751. list.AddLast t
  2752. Next
  2753. Return list
  2754. End Method
  2755. Rem
  2756. bbdoc: Enumerate all fields
  2757. about: Returns a list of all fields in type hierarchy
  2758. End Rem
  2759. Method EnumFields:TList( list:TList=Null )
  2760. If Not list list=New TList
  2761. If _super _super.EnumFields list
  2762. For Local t:TField=EachIn _fieldsList '.Values()
  2763. list.AddLast t
  2764. Next
  2765. Return list
  2766. End Method
  2767. Rem
  2768. bbdoc: Enumerate all globals
  2769. about: Returns a list of all globals in type hierarchy
  2770. End Rem
  2771. Method EnumGlobals:TList( list:TList=Null )
  2772. If Not list list=New TList
  2773. If _super _super.EnumGlobals list
  2774. For Local t:TGlobal=EachIn _globalsList '.Values()
  2775. list.AddLast t
  2776. Next
  2777. Return list
  2778. End Method
  2779. Rem
  2780. bbdoc: Enumerate all functions
  2781. about: Returns a list of all functions in type hierarchy
  2782. End Rem
  2783. Method EnumFunctions:TList( list:TList=Null )
  2784. Function compareFunction:Int( a:Object, b:Object)
  2785. If TFunction(a) And TFunction(b) Then
  2786. Return TFunction(a).Name().Compare(TFunction(b).Name())
  2787. End If
  2788. EndFunction
  2789. If Not list list=New TList
  2790. If _super And _super <> Self Then _super.EnumFunctions list
  2791. For Local t:TFunction=EachIn _functionsList '.Values()
  2792. list.AddLast t
  2793. Next
  2794. ' remove overridden functions
  2795. list.Sort( True, compareFunction)
  2796. Local prev:TFunction
  2797. For Local t:TFunction = EachIn list
  2798. If prev Then
  2799. If (t.Name().Compare(prev.Name())) = 0 Then list.Remove(prev)
  2800. EndIf
  2801. prev = t
  2802. Next
  2803. Return list
  2804. End Method
  2805. Rem
  2806. bbdoc: Enumerate all methods
  2807. about: Returns a list of all methods in type hierarchy - TO DO: handle overrides!
  2808. End Rem
  2809. Method EnumMethods:TList( list:TList=Null )
  2810. If Not list list=New TList
  2811. If _super _super.EnumMethods list
  2812. For Local t:TMethod=EachIn _methodsList '.Values()
  2813. list.AddLast t
  2814. Next
  2815. Return list
  2816. End Method
  2817. Rem
  2818. bbdoc: Create a new array
  2819. End Rem
  2820. Method NewArray:Object( length, dims:Int[] = Null )
  2821. If Not _elementType Throw "TypeID is not an array type"
  2822. Local tag:Byte Ptr=_elementType._typeTag
  2823. If Not tag
  2824. tag=TypeTagForId( _elementType ).ToCString()
  2825. _elementType._typeTag=tag
  2826. EndIf
  2827. If Not dims Then
  2828. Return bbArrayNew1D( tag,length )
  2829. Else
  2830. Return bbRefArrayCreate( tag, dims )
  2831. End If
  2832. End Method
  2833. Rem
  2834. bbdoc: Get array length
  2835. End Rem
  2836. Method ArrayLength( _array:Object, dim:Int = 0 )
  2837. If Not _elementType Throw "TypeID is not an array type"
  2838. Return bbRefArrayLength( _array, dim )
  2839. End Method
  2840. Method NullArray:Object()
  2841. Return bbRefArrayNull()
  2842. End Method
  2843. Rem
  2844. bbdoc: Get the number of dimensions
  2845. End Rem
  2846. Method ArrayDimensions:Int( _array:Object )
  2847. If Not _elementType Throw "TypeID is not an array type"
  2848. Return bbRefArrayDimensions( _array )
  2849. End Method
  2850. Method ArraySlice:Object( _array:Object, _start:Int, _end:Int )
  2851. If Not _elementType Throw "TypeID is not an array type"
  2852. Local tag:Byte Ptr=_elementType._typeTag
  2853. If Not tag
  2854. tag=TypeTagForId( _elementType ).ToCString()
  2855. _elementType._typeTag=tag
  2856. EndIf
  2857. _array = bbArraySlice(tag, _array, _start, _end)
  2858. Return _array
  2859. End Method
  2860. Rem
  2861. bbdoc: Gets an array element
  2862. End Rem
  2863. Method GetArrayElement:Object( _array:Object,index )
  2864. If Not _elementType Throw "TypeID is not an array type"
  2865. Local p:Byte Ptr=bbRefArrayElementPtr( _elementType._size,_array,index )
  2866. Return _Get( p,_elementType )
  2867. End Method
  2868. Rem
  2869. bbdoc: Gets an array element as a #String
  2870. End Rem
  2871. Method GetStringArrayElement:String( _array:Object,index )
  2872. If Not _elementType Throw "TypeID is not an array type"
  2873. Local p:Byte Ptr=bbRefArrayElementPtr( _elementType._size,_array,index )
  2874. Return String(_Get( p,_elementType ))
  2875. End Method
  2876. Rem
  2877. bbdoc: Gets an array element as a #Byte
  2878. End Rem
  2879. Method GetByteArrayElement:Byte( _array:Object,index )
  2880. If Not _elementType Throw "TypeID is not an array type"
  2881. Local p:Byte Ptr=bbRefArrayElementPtr( _elementType._size,_array,index )
  2882. Select _elementType
  2883. Case ByteTypeId
  2884. Return (Byte Ptr p)[0]
  2885. Case ShortTypeId
  2886. Return (Short Ptr p)[0]
  2887. Case IntTypeId
  2888. Return (Int Ptr p)[0]
  2889. Case UIntTypeId
  2890. Return (UInt Ptr p)[0]
  2891. Case LongTypeId
  2892. Return (Long Ptr p)[0]
  2893. Case ULongTypeId
  2894. Return (ULong Ptr p)[0]
  2895. Case SizetTypeId
  2896. Return (Size_T Ptr p)[0]
  2897. Case FloatTypeId
  2898. Return (Float Ptr p)[0]
  2899. Case DoubleTypeId
  2900. Return (Double Ptr p)[0]
  2901. Case LongIntTypeId
  2902. Return (LongInt Ptr p)[0]
  2903. Case ULongIntTypeId
  2904. Return (ULongInt Ptr p)[0]
  2905. End Select
  2906. End Method
  2907. Rem
  2908. bbdoc: Gets an array element as a #Short
  2909. End Rem
  2910. Method GetShortArrayElement:Short( _array:Object,index )
  2911. If Not _elementType Throw "TypeID is not an array type"
  2912. Local p:Byte Ptr=bbRefArrayElementPtr( _elementType._size,_array,index )
  2913. Select _elementType
  2914. Case ByteTypeId
  2915. Return (Byte Ptr p)[0]
  2916. Case ShortTypeId
  2917. Return (Short Ptr p)[0]
  2918. Case IntTypeId
  2919. Return (Int Ptr p)[0]
  2920. Case UIntTypeId
  2921. Return (UInt Ptr p)[0]
  2922. Case LongTypeId
  2923. Return (Long Ptr p)[0]
  2924. Case ULongTypeId
  2925. Return (ULong Ptr p)[0]
  2926. Case SizetTypeId
  2927. Return (Size_T Ptr p)[0]
  2928. Case FloatTypeId
  2929. Return (Float Ptr p)[0]
  2930. Case DoubleTypeId
  2931. Return (Double Ptr p)[0]
  2932. Case LongIntTypeId
  2933. Return (LongInt Ptr p)[0]
  2934. Case ULongIntTypeId
  2935. Return (ULongInt Ptr p)[0]
  2936. End Select
  2937. End Method
  2938. Rem
  2939. bbdoc: Gets an array element as an #Int
  2940. End Rem
  2941. Method GetIntArrayElement:Int( _array:Object,index )
  2942. If Not _elementType Throw "TypeID is not an array type"
  2943. Local p:Byte Ptr=bbRefArrayElementPtr( _elementType._size,_array,index )
  2944. Select _elementType
  2945. Case ByteTypeId
  2946. Return (Byte Ptr p)[0]
  2947. Case ShortTypeId
  2948. Return (Short Ptr p)[0]
  2949. Case IntTypeId
  2950. Return (Int Ptr p)[0]
  2951. Case UIntTypeId
  2952. Return (UInt Ptr p)[0]
  2953. Case LongTypeId
  2954. Return (Long Ptr p)[0]
  2955. Case ULongTypeId
  2956. Return (ULong Ptr p)[0]
  2957. Case SizetTypeId
  2958. Return (Size_T Ptr p)[0]
  2959. Case FloatTypeId
  2960. Return (Float Ptr p)[0]
  2961. Case DoubleTypeId
  2962. Return (Double Ptr p)[0]
  2963. Case LongIntTypeId
  2964. Return (LongInt Ptr p)[0]
  2965. Case ULongIntTypeId
  2966. Return (ULongInt Ptr p)[0]
  2967. End Select
  2968. End Method
  2969. Rem
  2970. bbdoc: Gets an array element as a #UInt
  2971. End Rem
  2972. Method GetUIntArrayElement:UInt( _array:Object,index )
  2973. If Not _elementType Throw "TypeID is not an array type"
  2974. Local p:Byte Ptr=bbRefArrayElementPtr( _elementType._size,_array,index )
  2975. Select _elementType
  2976. Case ByteTypeId
  2977. Return (Byte Ptr p)[0]
  2978. Case ShortTypeId
  2979. Return (Short Ptr p)[0]
  2980. Case IntTypeId
  2981. Return (Int Ptr p)[0]
  2982. Case UIntTypeId
  2983. Return (UInt Ptr p)[0]
  2984. Case LongTypeId
  2985. Return (Long Ptr p)[0]
  2986. Case ULongTypeId
  2987. Return (ULong Ptr p)[0]
  2988. Case SizetTypeId
  2989. Return (Size_T Ptr p)[0]
  2990. Case FloatTypeId
  2991. Return (Float Ptr p)[0]
  2992. Case DoubleTypeId
  2993. Return (Double Ptr p)[0]
  2994. Case LongIntTypeId
  2995. Return (LongInt Ptr p)[0]
  2996. Case ULongIntTypeId
  2997. Return (ULongInt Ptr p)[0]
  2998. End Select
  2999. End Method
  3000. Rem
  3001. bbdoc: Gets an array element as a #Long
  3002. End Rem
  3003. Method GetLongArrayElement:Long( _array:Object,index )
  3004. If Not _elementType Throw "TypeID is not an array type"
  3005. Local p:Byte Ptr=bbRefArrayElementPtr( _elementType._size,_array,index )
  3006. Select _elementType
  3007. Case ByteTypeId
  3008. Return (Byte Ptr p)[0]
  3009. Case ShortTypeId
  3010. Return (Short Ptr p)[0]
  3011. Case IntTypeId
  3012. Return (Int Ptr p)[0]
  3013. Case UIntTypeId
  3014. Return (UInt Ptr p)[0]
  3015. Case LongTypeId
  3016. Return (Long Ptr p)[0]
  3017. Case ULongTypeId
  3018. Return (ULong Ptr p)[0]
  3019. Case SizetTypeId
  3020. Return (Size_T Ptr p)[0]
  3021. Case FloatTypeId
  3022. Return (Float Ptr p)[0]
  3023. Case DoubleTypeId
  3024. Return (Double Ptr p)[0]
  3025. Case LongIntTypeId
  3026. Return (LongInt Ptr p)[0]
  3027. Case ULongIntTypeId
  3028. Return (ULongInt Ptr p)[0]
  3029. End Select
  3030. End Method
  3031. Rem
  3032. bbdoc: Gets an array element as a #ULong
  3033. End Rem
  3034. Method GetULongArrayElement:ULong( _array:Object,index )
  3035. If Not _elementType Throw "TypeID is not an array type"
  3036. Local p:Byte Ptr=bbRefArrayElementPtr( _elementType._size,_array,index )
  3037. Select _elementType
  3038. Case ByteTypeId
  3039. Return (Byte Ptr p)[0]
  3040. Case ShortTypeId
  3041. Return (Short Ptr p)[0]
  3042. Case IntTypeId
  3043. Return (Int Ptr p)[0]
  3044. Case UIntTypeId
  3045. Return (UInt Ptr p)[0]
  3046. Case LongTypeId
  3047. Return (Long Ptr p)[0]
  3048. Case ULongTypeId
  3049. Return (ULong Ptr p)[0]
  3050. Case SizetTypeId
  3051. Return (Size_T Ptr p)[0]
  3052. Case FloatTypeId
  3053. Return (Float Ptr p)[0]
  3054. Case DoubleTypeId
  3055. Return (Double Ptr p)[0]
  3056. Case LongIntTypeId
  3057. Return (LongInt Ptr p)[0]
  3058. Case ULongIntTypeId
  3059. Return (ULongInt Ptr p)[0]
  3060. End Select
  3061. End Method
  3062. Rem
  3063. bbdoc: Gets an array element as a #Size_T
  3064. End Rem
  3065. Method GetSizeTArrayElement:Size_T( _array:Object,index )
  3066. If Not _elementType Throw "TypeID is not an array type"
  3067. Local p:Byte Ptr=bbRefArrayElementPtr( _elementType._size,_array,index )
  3068. Select _elementType
  3069. Case ByteTypeId
  3070. Return (Byte Ptr p)[0]
  3071. Case ShortTypeId
  3072. Return (Short Ptr p)[0]
  3073. Case IntTypeId
  3074. Return (Int Ptr p)[0]
  3075. Case UIntTypeId
  3076. Return (UInt Ptr p)[0]
  3077. Case LongTypeId
  3078. Return (Long Ptr p)[0]
  3079. Case ULongTypeId
  3080. Return (ULong Ptr p)[0]
  3081. Case SizetTypeId
  3082. Return (Size_T Ptr p)[0]
  3083. Case FloatTypeId
  3084. Return (Float Ptr p)[0]
  3085. Case DoubleTypeId
  3086. Return (Double Ptr p)[0]
  3087. Case LongIntTypeId
  3088. Return (LongInt Ptr p)[0]
  3089. Case ULongIntTypeId
  3090. Return (ULongInt Ptr p)[0]
  3091. End Select
  3092. End Method
  3093. Rem
  3094. bbdoc: Gets an array element as a #Float
  3095. End Rem
  3096. Method GetFloatArrayElement:Float( _array:Object,index )
  3097. If Not _elementType Throw "TypeID is not an array type"
  3098. Local p:Byte Ptr=bbRefArrayElementPtr( _elementType._size,_array,index )
  3099. Select _elementType
  3100. Case ByteTypeId
  3101. Return (Byte Ptr p)[0]
  3102. Case ShortTypeId
  3103. Return (Short Ptr p)[0]
  3104. Case IntTypeId
  3105. Return (Int Ptr p)[0]
  3106. Case UIntTypeId
  3107. Return (UInt Ptr p)[0]
  3108. Case LongTypeId
  3109. Return (Long Ptr p)[0]
  3110. Case ULongTypeId
  3111. Return (ULong Ptr p)[0]
  3112. Case SizetTypeId
  3113. Return (Size_T Ptr p)[0]
  3114. Case FloatTypeId
  3115. Return (Float Ptr p)[0]
  3116. Case DoubleTypeId
  3117. Return (Double Ptr p)[0]
  3118. Case LongIntTypeId
  3119. Return (LongInt Ptr p)[0]
  3120. Case ULongIntTypeId
  3121. Return (ULongInt Ptr p)[0]
  3122. End Select
  3123. End Method
  3124. Rem
  3125. bbdoc: Gets an array element as a #Double
  3126. End Rem
  3127. Method GetDoubleArrayElement:Double( _array:Object,index )
  3128. If Not _elementType Throw "TypeID is not an array type"
  3129. Local p:Byte Ptr=bbRefArrayElementPtr( _elementType._size,_array,index )
  3130. Select _elementType
  3131. Case ByteTypeId
  3132. Return (Byte Ptr p)[0]
  3133. Case ShortTypeId
  3134. Return (Short Ptr p)[0]
  3135. Case IntTypeId
  3136. Return (Int Ptr p)[0]
  3137. Case UIntTypeId
  3138. Return (UInt Ptr p)[0]
  3139. Case LongTypeId
  3140. Return (Long Ptr p)[0]
  3141. Case ULongTypeId
  3142. Return (ULong Ptr p)[0]
  3143. Case SizetTypeId
  3144. Return (Size_T Ptr p)[0]
  3145. Case FloatTypeId
  3146. Return (Float Ptr p)[0]
  3147. Case DoubleTypeId
  3148. Return (Double Ptr p)[0]
  3149. Case LongIntTypeId
  3150. Return (LongInt Ptr p)[0]
  3151. Case ULongIntTypeId
  3152. Return (ULongInt Ptr p)[0]
  3153. End Select
  3154. End Method
  3155. Rem
  3156. bbdoc: Gets an array element as a #LongInt
  3157. End Rem
  3158. Method GetLongIntArrayElement:LongInt( _array:Object,index )
  3159. If Not _elementType Throw "TypeID is not an array type"
  3160. Local p:Byte Ptr=bbRefArrayElementPtr( _elementType._size,_array,index )
  3161. Select _elementType
  3162. Case ByteTypeId
  3163. Return (Byte Ptr p)[0]
  3164. Case ShortTypeId
  3165. Return (Short Ptr p)[0]
  3166. Case IntTypeId
  3167. Return (Int Ptr p)[0]
  3168. Case UIntTypeId
  3169. Return (UInt Ptr p)[0]
  3170. Case LongTypeId
  3171. Return (Long Ptr p)[0]
  3172. Case ULongTypeId
  3173. Return (ULong Ptr p)[0]
  3174. Case SizetTypeId
  3175. Return (Size_T Ptr p)[0]
  3176. Case FloatTypeId
  3177. Return (Float Ptr p)[0]
  3178. Case DoubleTypeId
  3179. Return (Double Ptr p)[0]
  3180. Case LongIntTypeId
  3181. Return (LongInt Ptr p)[0]
  3182. Case ULongIntTypeId
  3183. Return (ULongInt Ptr p)[0]
  3184. End Select
  3185. End Method
  3186. Rem
  3187. bbdoc: Gets an array element as a #ULongInt
  3188. End Rem
  3189. Method GetULongIntArrayElement:ULongInt( _array:Object,index )
  3190. If Not _elementType Throw "TypeID is not an array type"
  3191. Local p:Byte Ptr=bbRefArrayElementPtr( _elementType._size,_array,index )
  3192. Select _elementType
  3193. Case ByteTypeId
  3194. Return (Byte Ptr p)[0]
  3195. Case ShortTypeId
  3196. Return (Short Ptr p)[0]
  3197. Case IntTypeId
  3198. Return (Int Ptr p)[0]
  3199. Case UIntTypeId
  3200. Return (UInt Ptr p)[0]
  3201. Case LongTypeId
  3202. Return (Long Ptr p)[0]
  3203. Case ULongTypeId
  3204. Return (ULong Ptr p)[0]
  3205. Case SizetTypeId
  3206. Return (Size_T Ptr p)[0]
  3207. Case FloatTypeId
  3208. Return (Float Ptr p)[0]
  3209. Case DoubleTypeId
  3210. Return (Double Ptr p)[0]
  3211. Case LongIntTypeId
  3212. Return (LongInt Ptr p)[0]
  3213. Case ULongIntTypeId
  3214. Return (ULongInt Ptr p)[0]
  3215. End Select
  3216. End Method
  3217. Rem
  3218. bbdoc: Sets an array element
  3219. End Rem
  3220. Method SetArrayElement( _array:Object,index,value:Object )
  3221. If Not _elementType Throw "TypeID is not an array type"
  3222. Local p:Byte Ptr=bbRefArrayElementPtr( _elementType._size,_array,index )
  3223. _Assign p,_elementType,value
  3224. End Method
  3225. Rem
  3226. bbdoc: Sets an array element as a #Byte
  3227. End Rem
  3228. Method SetArrayElement( _array:Object,index,value:Byte )
  3229. SetByteArrayElement(_array, index, value)
  3230. End Method
  3231. Rem
  3232. bbdoc: Sets an array element as a #Short
  3233. End Rem
  3234. Method SetArrayElement( _array:Object,index,value:Short )
  3235. SetShortArrayElement(_array, index, value)
  3236. End Method
  3237. Rem
  3238. bbdoc: Sets an array element as an #Int
  3239. End Rem
  3240. Method SetArrayElement( _array:Object,index,value:Int )
  3241. SetIntArrayElement(_array, index, value)
  3242. End Method
  3243. Rem
  3244. bbdoc: Sets an array element as a #UInt
  3245. End Rem
  3246. Method SetArrayElement( _array:Object,index,value:UInt )
  3247. SetUIntArrayElement(_array, index, value)
  3248. End Method
  3249. Rem
  3250. bbdoc: Sets an array element as a #Long
  3251. End Rem
  3252. Method SetArrayElement( _array:Object,index,value:Long )
  3253. SetLongArrayElement(_array, index, value)
  3254. End Method
  3255. Rem
  3256. bbdoc: Sets an array element as a #ULong
  3257. End Rem
  3258. Method SetArrayElement( _array:Object,index,value:ULong )
  3259. SetULongArrayElement(_array, index, value)
  3260. End Method
  3261. Rem
  3262. bbdoc: Sets an array element as a #Size_T
  3263. End Rem
  3264. Method SetArrayElement( _array:Object,index,value:Size_T )
  3265. SetSizeTArrayElement(_array, index, value)
  3266. End Method
  3267. Rem
  3268. bbdoc: Sets an array element as a #Float
  3269. End Rem
  3270. Method SetArrayElement( _array:Object,index,value:Float )
  3271. SetFloatArrayElement(_array, index, value)
  3272. End Method
  3273. Rem
  3274. bbdoc: Sets an array element as a #Double
  3275. End Rem
  3276. Method SetArrayElement( _array:Object,index,value:Double )
  3277. SetDoubleArrayElement(_array, index, value)
  3278. End Method
  3279. Rem
  3280. bbdoc: Sets an array element as a #LongInt
  3281. End Rem
  3282. Method SetArrayElement( _array:Object,index,value:LongInt )
  3283. SetLongIntArrayElement(_array, index, value)
  3284. End Method
  3285. Rem
  3286. bbdoc: Sets an array element as a #ULongInt
  3287. End Rem
  3288. Method SetArrayElement( _array:Object,index,value:ULongInt )
  3289. SetULongIntArrayElement(_array, index, value)
  3290. End Method
  3291. Rem
  3292. bbdoc: Sets an array element as a #Byte
  3293. End Rem
  3294. Method SetByteArrayElement( _array:Object,index,value:Byte )
  3295. If Not _elementType Throw "TypeID is not an array type"
  3296. Local p:Byte Ptr=bbRefArrayElementPtr( _elementType._size,_array,index )
  3297. Select _elementType
  3298. Case ByteTypeId
  3299. (Byte Ptr p)[0]=value
  3300. Case ShortTypeId
  3301. (Short Ptr p)[0]=Short(value)
  3302. Case IntTypeId
  3303. (Int Ptr p)[0]=Int(value)
  3304. Case UIntTypeId
  3305. (UInt Ptr p)[0]=UInt(value)
  3306. Case LongTypeId
  3307. (Long Ptr p)[0]=Long(value)
  3308. Case ULongTypeId
  3309. (ULong Ptr p)[0]=ULong(value)
  3310. Case SizetTypeId
  3311. (Size_T Ptr p)[0]=Size_T(value)
  3312. Case FloatTypeId
  3313. (Float Ptr p)[0]=Float(value)
  3314. Case DoubleTypeId
  3315. (Double Ptr p)[0]=Double(value)
  3316. Case LongIntTypeId
  3317. (LongInt Ptr p)[0]=LongInt(value)
  3318. Case ULongIntTypeId
  3319. (ULongInt Ptr p)[0]=ULongInt(value)
  3320. Case StringTypeId
  3321. bbRefAssignObject p,String.FromInt(value)
  3322. End Select
  3323. End Method
  3324. Rem
  3325. bbdoc: Sets an array element as a #Short
  3326. End Rem
  3327. Method SetShortArrayElement( _array:Object,index,value:Short )
  3328. If Not _elementType Throw "TypeID is not an array type"
  3329. Local p:Byte Ptr=bbRefArrayElementPtr( _elementType._size,_array,index )
  3330. Select _elementType
  3331. Case ByteTypeId
  3332. (Byte Ptr p)[0]=Byte(value)
  3333. Case ShortTypeId
  3334. (Short Ptr p)[0]=value
  3335. Case IntTypeId
  3336. (Int Ptr p)[0]=Int(value)
  3337. Case UIntTypeId
  3338. (UInt Ptr p)[0]=UInt(value)
  3339. Case LongTypeId
  3340. (Long Ptr p)[0]=Long(value)
  3341. Case ULongTypeId
  3342. (ULong Ptr p)[0]=ULong(value)
  3343. Case SizetTypeId
  3344. (Size_T Ptr p)[0]=Size_T(value)
  3345. Case FloatTypeId
  3346. (Float Ptr p)[0]=Float(value)
  3347. Case DoubleTypeId
  3348. (Double Ptr p)[0]=Double(value)
  3349. Case LongIntTypeId
  3350. (LongInt Ptr p)[0]=LongInt(value)
  3351. Case ULongIntTypeId
  3352. (ULongInt Ptr p)[0]=ULongInt(value)
  3353. Case StringTypeId
  3354. bbRefAssignObject p,String.FromInt(value)
  3355. End Select
  3356. End Method
  3357. Rem
  3358. bbdoc: Sets an array element as a #Int
  3359. End Rem
  3360. Method SetIntArrayElement( _array:Object,index,value:Int )
  3361. If Not _elementType Throw "TypeID is not an array type"
  3362. Local p:Byte Ptr=bbRefArrayElementPtr( _elementType._size,_array,index )
  3363. Select _elementType
  3364. Case ByteTypeId
  3365. (Byte Ptr p)[0]=Byte(value)
  3366. Case ShortTypeId
  3367. (Short Ptr p)[0]=Short(value)
  3368. Case IntTypeId
  3369. (Int Ptr p)[0]=value
  3370. Case UIntTypeId
  3371. (UInt Ptr p)[0]=UInt(value)
  3372. Case LongTypeId
  3373. (Long Ptr p)[0]=Long(value)
  3374. Case ULongTypeId
  3375. (ULong Ptr p)[0]=ULong(value)
  3376. Case SizetTypeId
  3377. (Size_T Ptr p)[0]=Size_T(value)
  3378. Case FloatTypeId
  3379. (Float Ptr p)[0]=Float(value)
  3380. Case DoubleTypeId
  3381. (Double Ptr p)[0]=Double(value)
  3382. Case LongIntTypeId
  3383. (LongInt Ptr p)[0]=LongInt(value)
  3384. Case ULongIntTypeId
  3385. (ULongInt Ptr p)[0]=ULongInt(value)
  3386. Case StringTypeId
  3387. bbRefAssignObject p,String.FromInt(value)
  3388. End Select
  3389. End Method
  3390. Rem
  3391. bbdoc: Sets an array element as a #UInt
  3392. End Rem
  3393. Method SetUIntArrayElement( _array:Object,index,value:UInt )
  3394. If Not _elementType Throw "TypeID is not an array type"
  3395. Local p:Byte Ptr=bbRefArrayElementPtr( _elementType._size,_array,index )
  3396. Select _elementType
  3397. Case ByteTypeId
  3398. (Byte Ptr p)[0]=Byte(value)
  3399. Case ShortTypeId
  3400. (Short Ptr p)[0]=Short(value)
  3401. Case IntTypeId
  3402. (Int Ptr p)[0]=Int(value)
  3403. Case UIntTypeId
  3404. (UInt Ptr p)[0]=value
  3405. Case LongTypeId
  3406. (Long Ptr p)[0]=Long(value)
  3407. Case ULongTypeId
  3408. (ULong Ptr p)[0]=ULong(value)
  3409. Case SizetTypeId
  3410. (Size_T Ptr p)[0]=Size_T(value)
  3411. Case FloatTypeId
  3412. (Float Ptr p)[0]=Float(value)
  3413. Case DoubleTypeId
  3414. (Double Ptr p)[0]=Double(value)
  3415. Case LongIntTypeId
  3416. (LongInt Ptr p)[0]=LongInt(value)
  3417. Case ULongIntTypeId
  3418. (ULongInt Ptr p)[0]=ULongInt(value)
  3419. Case StringTypeId
  3420. bbRefAssignObject p,String.FromUInt(value)
  3421. End Select
  3422. End Method
  3423. Rem
  3424. bbdoc: Sets an array element as a #Long
  3425. End Rem
  3426. Method SetLongArrayElement( _array:Object,index,value:Long )
  3427. If Not _elementType Throw "TypeID is not an array type"
  3428. Local p:Byte Ptr=bbRefArrayElementPtr( _elementType._size,_array,index )
  3429. Select _elementType
  3430. Case ByteTypeId
  3431. (Byte Ptr p)[0]=Byte(value)
  3432. Case ShortTypeId
  3433. (Short Ptr p)[0]=Short(value)
  3434. Case IntTypeId
  3435. (Int Ptr p)[0]=Int(value)
  3436. Case UIntTypeId
  3437. (UInt Ptr p)[0]=UInt(value)
  3438. Case LongTypeId
  3439. (Long Ptr p)[0]=value
  3440. Case ULongTypeId
  3441. (ULong Ptr p)[0]=ULong(value)
  3442. Case SizetTypeId
  3443. (Size_T Ptr p)[0]=Size_T(value)
  3444. Case FloatTypeId
  3445. (Float Ptr p)[0]=Float(value)
  3446. Case DoubleTypeId
  3447. (Double Ptr p)[0]=Double(value)
  3448. Case LongIntTypeId
  3449. (LongInt Ptr p)[0]=LongInt(value)
  3450. Case ULongIntTypeId
  3451. (ULongInt Ptr p)[0]=ULongInt(value)
  3452. Case StringTypeId
  3453. bbRefAssignObject p,String.FromLong(value)
  3454. End Select
  3455. End Method
  3456. Rem
  3457. bbdoc: Sets an array element as a #ULong
  3458. End Rem
  3459. Method SetULongArrayElement( _array:Object,index,value:ULong )
  3460. If Not _elementType Throw "TypeID is not an array type"
  3461. Local p:Byte Ptr=bbRefArrayElementPtr( _elementType._size,_array,index )
  3462. Select _elementType
  3463. Case ByteTypeId
  3464. (Byte Ptr p)[0]=Byte(value)
  3465. Case ShortTypeId
  3466. (Short Ptr p)[0]=Short(value)
  3467. Case IntTypeId
  3468. (Int Ptr p)[0]=Int(value)
  3469. Case UIntTypeId
  3470. (UInt Ptr p)[0]=UInt(value)
  3471. Case LongTypeId
  3472. (Long Ptr p)[0]=Long(value)
  3473. Case ULongTypeId
  3474. (ULong Ptr p)[0]=value
  3475. Case SizetTypeId
  3476. (Size_T Ptr p)[0]=Size_T(value)
  3477. Case FloatTypeId
  3478. (Float Ptr p)[0]=Float(value)
  3479. Case DoubleTypeId
  3480. (Double Ptr p)[0]=Double(value)
  3481. Case LongIntTypeId
  3482. (LongInt Ptr p)[0]=LongInt(value)
  3483. Case ULongIntTypeId
  3484. (ULongInt Ptr p)[0]=ULongInt(value)
  3485. Case StringTypeId
  3486. bbRefAssignObject p,String.FromULong(value)
  3487. End Select
  3488. End Method
  3489. Rem
  3490. bbdoc: Sets an array element as a #Size_T
  3491. End Rem
  3492. Method SetSizeTArrayElement( _array:Object,index,value:Size_T )
  3493. If Not _elementType Throw "TypeID is not an array type"
  3494. Local p:Byte Ptr=bbRefArrayElementPtr( _elementType._size,_array,index )
  3495. Select _elementType
  3496. Case ByteTypeId
  3497. (Byte Ptr p)[0]=Byte(value)
  3498. Case ShortTypeId
  3499. (Short Ptr p)[0]=Short(value)
  3500. Case IntTypeId
  3501. (Int Ptr p)[0]=Int(value)
  3502. Case UIntTypeId
  3503. (UInt Ptr p)[0]=UInt(value)
  3504. Case LongTypeId
  3505. (Long Ptr p)[0]=Long(value)
  3506. Case ULongTypeId
  3507. (ULong Ptr p)[0]=ULong(value)
  3508. Case SizetTypeId
  3509. (Size_T Ptr p)[0]=value
  3510. Case FloatTypeId
  3511. (Float Ptr p)[0]=Float(value)
  3512. Case DoubleTypeId
  3513. (Double Ptr p)[0]=Double(value)
  3514. Case LongIntTypeId
  3515. (LongInt Ptr p)[0]=LongInt(value)
  3516. Case ULongIntTypeId
  3517. (ULongInt Ptr p)[0]=ULongInt(value)
  3518. Case StringTypeId
  3519. bbRefAssignObject p,String.FromSizeT(value)
  3520. End Select
  3521. End Method
  3522. Rem
  3523. bbdoc: Sets an array element as a #Float
  3524. End Rem
  3525. Method SetFloatArrayElement( _array:Object,index,value:Float )
  3526. If Not _elementType Throw "TypeID is not an array type"
  3527. Local p:Byte Ptr=bbRefArrayElementPtr( _elementType._size,_array,index )
  3528. Select _elementType
  3529. Case ByteTypeId
  3530. (Byte Ptr p)[0]=Byte(value)
  3531. Case ShortTypeId
  3532. (Short Ptr p)[0]=Short(value)
  3533. Case IntTypeId
  3534. (Int Ptr p)[0]=Int(value)
  3535. Case UIntTypeId
  3536. (UInt Ptr p)[0]=UInt(value)
  3537. Case LongTypeId
  3538. (Long Ptr p)[0]=Long(value)
  3539. Case ULongTypeId
  3540. (ULong Ptr p)[0]=ULong(value)
  3541. Case SizetTypeId
  3542. (Size_T Ptr p)[0]=Size_T(value)
  3543. Case FloatTypeId
  3544. (Float Ptr p)[0]=value
  3545. Case DoubleTypeId
  3546. (Double Ptr p)[0]=Double(value)
  3547. Case LongIntTypeId
  3548. (LongInt Ptr p)[0]=LongInt(value)
  3549. Case ULongIntTypeId
  3550. (ULongInt Ptr p)[0]=ULongInt(value)
  3551. Case StringTypeId
  3552. bbRefAssignObject p,String.FromFloat(value)
  3553. End Select
  3554. End Method
  3555. Rem
  3556. bbdoc: Sets an array element as a #Double
  3557. End Rem
  3558. Method SetDoubleArrayElement( _array:Object,index,value:Double )
  3559. If Not _elementType Throw "TypeID is not an array type"
  3560. Local p:Byte Ptr=bbRefArrayElementPtr( _elementType._size,_array,index )
  3561. Select _elementType
  3562. Case ByteTypeId
  3563. (Byte Ptr p)[0]=Byte(value)
  3564. Case ShortTypeId
  3565. (Short Ptr p)[0]=Short(value)
  3566. Case IntTypeId
  3567. (Int Ptr p)[0]=Int(value)
  3568. Case UIntTypeId
  3569. (UInt Ptr p)[0]=UInt(value)
  3570. Case LongTypeId
  3571. (Long Ptr p)[0]=Long(value)
  3572. Case ULongTypeId
  3573. (ULong Ptr p)[0]=ULong(value)
  3574. Case SizetTypeId
  3575. (Size_T Ptr p)[0]=Size_T(value)
  3576. Case FloatTypeId
  3577. (Float Ptr p)[0]=Float(value)
  3578. Case DoubleTypeId
  3579. (Double Ptr p)[0]=value
  3580. Case LongIntTypeId
  3581. (LongInt Ptr p)[0]=LongInt(value)
  3582. Case ULongIntTypeId
  3583. (ULongInt Ptr p)[0]=ULongInt(value)
  3584. Case StringTypeId
  3585. bbRefAssignObject p,String.FromDouble(value)
  3586. End Select
  3587. End Method
  3588. Rem
  3589. bbdoc: Sets an array element as a #LongInt
  3590. End Rem
  3591. Method SetLongIntArrayElement( _array:Object,index,value:LongInt )
  3592. If Not _elementType Throw "TypeID is not an array type"
  3593. Local p:Byte Ptr=bbRefArrayElementPtr( _elementType._size,_array,index )
  3594. Select _elementType
  3595. Case ByteTypeId
  3596. (Byte Ptr p)[0]=Byte(value)
  3597. Case ShortTypeId
  3598. (Short Ptr p)[0]=Short(value)
  3599. Case IntTypeId
  3600. (Int Ptr p)[0]=Int(value)
  3601. Case UIntTypeId
  3602. (UInt Ptr p)[0]=UInt(value)
  3603. Case LongTypeId
  3604. (Long Ptr p)[0]=Long(value)
  3605. Case ULongTypeId
  3606. (ULong Ptr p)[0]=ULong(value)
  3607. Case SizetTypeId
  3608. (Size_T Ptr p)[0]=Size_T(value)
  3609. Case FloatTypeId
  3610. (Float Ptr p)[0]=Float(value)
  3611. Case DoubleTypeId
  3612. (Double Ptr p)[0]=Double(value)
  3613. Case LongIntTypeId
  3614. (LongInt Ptr p)[0]=value
  3615. Case ULongIntTypeId
  3616. (ULongInt Ptr p)[0]=ULongInt(value)
  3617. Case StringTypeId
  3618. bbRefAssignObject p,String.FromDouble(value)
  3619. End Select
  3620. End Method
  3621. Rem
  3622. bbdoc: Sets an array element as a #ULongInt
  3623. End Rem
  3624. Method SetULongIntArrayElement( _array:Object,index,value:ULongInt )
  3625. If Not _elementType Throw "TypeID is not an array type"
  3626. Local p:Byte Ptr=bbRefArrayElementPtr( _elementType._size,_array,index )
  3627. Select _elementType
  3628. Case ByteTypeId
  3629. (Byte Ptr p)[0]=Byte(value)
  3630. Case ShortTypeId
  3631. (Short Ptr p)[0]=Short(value)
  3632. Case IntTypeId
  3633. (Int Ptr p)[0]=Int(value)
  3634. Case UIntTypeId
  3635. (UInt Ptr p)[0]=UInt(value)
  3636. Case LongTypeId
  3637. (Long Ptr p)[0]=Long(value)
  3638. Case ULongTypeId
  3639. (ULong Ptr p)[0]=ULong(value)
  3640. Case SizetTypeId
  3641. (Size_T Ptr p)[0]=Size_T(value)
  3642. Case FloatTypeId
  3643. (Float Ptr p)[0]=Float(value)
  3644. Case DoubleTypeId
  3645. (Double Ptr p)[0]=Double(value)
  3646. Case LongIntTypeId
  3647. (LongInt Ptr p)[0]=LongInt(value)
  3648. Case ULongIntTypeId
  3649. (ULongInt Ptr p)[0]=value
  3650. Case StringTypeId
  3651. bbRefAssignObject p,String.FromDouble(value)
  3652. End Select
  3653. End Method
  3654. Rem
  3655. bbdoc: Sets an array element
  3656. End Rem
  3657. Method SetStringArrayElement( _array:Object,index,value:String )
  3658. If Not _elementType Throw "TypeID is not an array type"
  3659. Local p:Byte Ptr=bbRefArrayElementPtr( _elementType._size,_array,index )
  3660. _Assign p,_elementType,value
  3661. End Method
  3662. Rem
  3663. bbdoc: Get Type by name
  3664. End Rem
  3665. Function ForName:TTypeId( name:String )
  3666. Try
  3667. _guard.Lock()
  3668. _Update
  3669. If name.EndsWith( "]" )
  3670. ' TODO
  3671. name=name[..name.length-2]
  3672. Local nameType:TTypeID = TTypeId( _nameMap.ValueForKey( name.ToLower() ) )
  3673. If Not nameType Then Return Null
  3674. Return nameType.ArrayType()
  3675. ' pointers
  3676. ElseIf name.EndsWith( "Ptr" )
  3677. name=name[..name.length-4].Trim()
  3678. If Not name Then Return Null
  3679. Local baseType:TTypeId = ForName( name )
  3680. If baseType Then
  3681. ' check for valid pointer base types
  3682. Select baseType
  3683. Case ByteTypeId, ShortTypeId, IntTypeId, LongTypeId, FloatTypeId, DoubleTypeId
  3684. Return baseType.PointerType()
  3685. Default
  3686. If baseType.ExtendsType(PointerTypeId) Then Return baseType.PointerType()
  3687. EndSelect
  3688. EndIf
  3689. Return Null
  3690. ' function pointers
  3691. ElseIf name.EndsWith( ")" )
  3692. ' check if its in the table already
  3693. Local t:TTypeId = TTypeId( _nameMap.ValueForKey( name.ToLower() ) )
  3694. If t Then Return t
  3695. Local i:Int = name.Find("(")
  3696. Local ret:TTypeId = ForName( name[..i].Trim())
  3697. Local typs:TTypeId[]
  3698. If ret Then
  3699. Local params:String = name[i+1..name.Length-1].Trim()
  3700. If params Then
  3701. Local args:String[] = params.Split(",")
  3702. If args.Length >= 1 And args[0] Then
  3703. typs = New TTypeId[args.Length]
  3704. For Local i:Int = 0 Until args.Length
  3705. typs[i] = ForName(args[i].Trim())
  3706. If Not typs[i] Then typs[i] = ObjectTypeId
  3707. Next
  3708. EndIf
  3709. EndIf
  3710. 'ret._functionType = Null
  3711. Return ret.FunctionType(typs)
  3712. EndIf
  3713. Else
  3714. Return TTypeId( _nameMap.ValueForKey( name.ToLower() ) )
  3715. EndIf
  3716. Finally
  3717. _guard.Unlock()
  3718. End Try
  3719. End Function
  3720. Rem
  3721. bbdoc: Get Type by object
  3722. End Rem
  3723. Function ForObject:TTypeId( obj:Object )
  3724. Try
  3725. _guard.Lock()
  3726. _Update
  3727. Local class:Byte Ptr=bbRefGetObjectClass( obj )
  3728. If class=ArrayTypeId._class
  3729. If Not bbRefArrayLength( obj ) Return ArrayTypeId
  3730. Return TypeIdForTag( bbRefArrayTypeTag( obj ) ).ArrayType()
  3731. Else
  3732. Return TTypeId( _classMap.ValueForKey( class ) )
  3733. EndIf
  3734. Finally
  3735. _guard.Unlock()
  3736. End Try
  3737. End Function
  3738. Rem
  3739. bbdoc: Get list of all types
  3740. End Rem
  3741. Function EnumTypes:TList()
  3742. Try
  3743. _guard.Lock()
  3744. _Update
  3745. Local list:TList=New TList
  3746. For Local t:TTypeId=EachIn _nameMap.Values()
  3747. list.AddLast t
  3748. Next
  3749. Return list
  3750. Finally
  3751. _guard.Unlock()
  3752. End Try
  3753. End Function
  3754. Rem
  3755. bbdoc: Gets a list of all interfaces
  3756. End Rem
  3757. Function EnumInterfaces:TList()
  3758. _Update
  3759. Local list:TList=New TList
  3760. For Local t:TTypeId=EachIn _interfaceMap.Values()
  3761. list.AddLast t
  3762. Next
  3763. Return list
  3764. End Function
  3765. '***** PRIVATE *****
  3766. Method Init:TTypeId( name:String,size,class:Byte Ptr=Null,supor:TTypeId=Null )
  3767. _name=name
  3768. _size=size
  3769. _class=class
  3770. _super=supor
  3771. _consts=New TStringMap
  3772. _fields=New TStringMap
  3773. _globals=New TStringMap
  3774. _functions=New TStringMap
  3775. _methods=New TStringMap
  3776. _constsList=New TList
  3777. _fieldsList=New TList
  3778. _globalsList=New TList
  3779. _functionsList=New TList
  3780. _methodsList=New TList
  3781. _nameMap.Insert _name.ToLower(),Self
  3782. If class _classMap.Insert class,Self
  3783. Return Self
  3784. End Method
  3785. Method InitMeta(meta:String)
  3786. _meta = meta
  3787. _metaMap = ExtractMetaMap(meta)
  3788. End Method
  3789. Method SetClass:TTypeId( class:Byte Ptr )
  3790. Local name:String=String.FromCString( bbRefClassDebugScopeName(class) )
  3791. Local meta:String
  3792. Local i=name.Find( "{" )
  3793. If i<>-1
  3794. meta=name[i+1..name.length-1]
  3795. name=name[..i]
  3796. EndIf
  3797. _name=name
  3798. InitMeta(meta)
  3799. _class=class
  3800. _nameMap.Insert _name.ToLower(),Self
  3801. _classMap.Insert class,Self
  3802. Return Self
  3803. End Method
  3804. Method SetInterface:TTypeId( ifc:Byte Ptr )
  3805. Local name:String = String.FromCString(bbInterfaceName(ifc))
  3806. Local meta:String
  3807. Local i=name.Find( "{" )
  3808. If i<>-1
  3809. meta=name[i+1..name.length-1]
  3810. name=name[..i]
  3811. EndIf
  3812. _name=name
  3813. InitMeta(meta)
  3814. _interface=ifc
  3815. _class=bbInterfaceClass(ifc)
  3816. _nameMap.Insert _name.ToLower(),Self
  3817. _interfaceMap.Insert ifc,Self
  3818. Return Self
  3819. End Method
  3820. Function _Update()
  3821. Local count:Int
  3822. ?Not ptr64
  3823. Local p:Int Ptr Ptr=bbObjectRegisteredTypes( count )
  3824. ?ptr64
  3825. Local p:Long Ptr Ptr=bbObjectRegisteredTypes( count )
  3826. ?
  3827. If count=_count Return
  3828. Local list:TList=New TList
  3829. For Local i=_count Until count
  3830. Local ty:TTypeId=New TTypeId.SetClass( p[i] )
  3831. list.AddLast ty
  3832. Next
  3833. _count=count
  3834. _UpdateInterfaces()
  3835. For Local t:TTypeId=EachIn list
  3836. t._Resolve
  3837. Next
  3838. End Function
  3839. Function _UpdateInterfaces()
  3840. Local count:Int
  3841. ?Not ptr64
  3842. Local p:Int Ptr Ptr=bbObjectRegisteredInterfaces( count )
  3843. ?ptr64
  3844. Local p:Long Ptr Ptr=bbObjectRegisteredInterfaces( count )
  3845. ?
  3846. If count=_icount Return
  3847. Local list:TList=New TList
  3848. For Local i=_icount Until count
  3849. Local ty:TTypeId=New TTypeId.SetInterface( p[i] )
  3850. list.AddLast ty
  3851. Next
  3852. _icount=count
  3853. For Local t:TTypeId=EachIn list
  3854. t._Resolve
  3855. Next
  3856. End Function
  3857. Method _Resolve()
  3858. If _fields Or Not _class Return
  3859. _consts=New TStringMap
  3860. _fields=New TStringMap
  3861. _globals=New TStringMap
  3862. _functions=New TStringMap
  3863. _methods=New TStringMap
  3864. _constsList=New TList
  3865. _fieldsList=New TList
  3866. _globalsList=New TList
  3867. _functionsList=New TList
  3868. _methodsList=New TList
  3869. _interfaces=New TList
  3870. If Not _interface Then
  3871. _super=TTypeId( _classMap.ValueForKey(bbRefClassSuper(_class)))
  3872. End If
  3873. If Not _super _super=ObjectTypeId
  3874. If Not _super._derived _super._derived=New TList
  3875. _super._derived.AddLast Self
  3876. Local p:Byte Ptr = bbRefClassDebugDecl(_class)
  3877. While bbDebugDeclKind(p)
  3878. Local id:String=String.FromCString( bbDebugDeclName(p) )
  3879. Local ty:String=String.FromCString( bbDebugDeclType(p) )
  3880. Local meta:String
  3881. Local i=ty.Find( "{" )
  3882. If i<>-1
  3883. meta=ty[i+1..ty.length-1]
  3884. ty=ty[..i]
  3885. EndIf
  3886. Select bbDebugDeclKind(p)
  3887. Case 1 'const
  3888. Local tt:TTypeId = TypeIdFortag(ty)
  3889. If tt Then
  3890. Local t:TConstant = New TConstant.Init( id, tt, meta, bbDebugDeclConstValue(p))
  3891. _constsList.AddLast(t)
  3892. _consts.Insert(t.NameLower(), t)
  3893. EndIf
  3894. Case 3 'field
  3895. Local typeId:TTypeId=TypeIdForTag( ty )
  3896. If typeId Then
  3897. Local t:TField = New TField.Init( id,typeId,meta,bbDebugDeclFieldOffset(p) )
  3898. _fieldsList.AddLast(t)
  3899. _fields.Insert(t.NameLower(), t)
  3900. End If
  3901. Case 4 'global
  3902. Local typeId:TTypeId=TypeIdForTag( ty )
  3903. If typeId Then
  3904. Local t:TGlobal = New TGlobal.Init( id,typeId,meta, bbDebugDeclVarAddress(p) )
  3905. _globalsList.AddLast(t)
  3906. _globals.Insert(t.NameLower(), t)
  3907. End If
  3908. Case 6, 7 'method/function
  3909. Local t:String[]=ty.Split( ")" )
  3910. Local retType:TTypeId=TypeIdForTag( t[1] )
  3911. If retType
  3912. Local argTypes:TTypeId[]
  3913. If t[0].length>1
  3914. Local i,b,q:String=t[0][1..],args:TList=New TList
  3915. While i<q.length
  3916. Select q[i]
  3917. Case Asc( "," )
  3918. args.AddLast q[b..i]
  3919. i:+1
  3920. b=i
  3921. Case Asc( "[" )
  3922. i:+1
  3923. While i<q.length And q[i]=Asc(",")
  3924. i:+1
  3925. Wend
  3926. Default
  3927. i:+1
  3928. End Select
  3929. Wend
  3930. If b<q.length args.AddLast q[b..q.length]
  3931. argTypes=New TTypeId[args.Count()]
  3932. i=0
  3933. For Local arg:String=EachIn args
  3934. argTypes[i]=TypeIdForTag( arg )
  3935. If Not argTypes[i] retType=Null
  3936. i:+1
  3937. Next
  3938. EndIf
  3939. If retType
  3940. If bbDebugDeclKind(p) = 6 Then ' method
  3941. Local t:TMethod = New TMethod.Init(id, TypeIdForTag(ty), meta, Self, bbDebugDeclVarAddress(p), argTypes)
  3942. _methodsList.AddLast(t)
  3943. _methods.Insert(t.NameLower(), t)
  3944. Else ' function
  3945. Local t:TFunction = New TFunction.Init(id, TypeIdForTag(ty), meta, Self, bbDebugDeclVarAddress(p), argTypes)
  3946. _functionsList.AddLast(t)
  3947. _functions.Insert(t.NameLower(), t)
  3948. End If
  3949. EndIf
  3950. EndIf
  3951. End Select
  3952. p = bbDebugDeclNext(p)
  3953. Wend
  3954. ' implemented interfaces ?
  3955. Local impInt:Int = bbObjectImplementsInterfaces(_class)
  3956. If impInt Then
  3957. Local imps:Int = bbObjectImplementedCount(_class)
  3958. If imps > 0 Then
  3959. For Local i:Int = 0 Until imps
  3960. _interfaces.AddLast(_interfaceMap.ValueForKey(bbObjectImplementedInterface(_class, i)))
  3961. Next
  3962. End If
  3963. End If
  3964. End Method
  3965. Field _name:String
  3966. Field _meta:String
  3967. Field _metaMap:TStringMap
  3968. Field _class:Byte Ptr
  3969. Field _interface:Byte Ptr
  3970. ' default object size
  3971. ?Not ptr64
  3972. Field _size=4
  3973. ?ptr64
  3974. Field _size=8
  3975. ?
  3976. Field _consts:TStringMap
  3977. Field _fields:TStringMap
  3978. Field _globals:TStringMap
  3979. Field _functions:TStringMap
  3980. Field _methods:TStringMap
  3981. Field _constsList:TList
  3982. Field _fieldsList:TList
  3983. Field _globalsList:TList
  3984. Field _functionsList:TList
  3985. Field _methodsList:TList
  3986. Field _interfaces:TList
  3987. Field _super:TTypeId
  3988. Field _derived:TList
  3989. Field _arrayType:TTypeId[]
  3990. Field _elementType:TTypeId
  3991. Field _typeTag:Byte Ptr
  3992. Field _pointerType:TTypeId
  3993. Field _functionType:TStringMap
  3994. Field _argTypes:TTypeId[]
  3995. Field _retType:TTypeId
  3996. Global _count,_nameMap:TMap=New TMap,_classMap:TPtrMap=New TPtrMap
  3997. Global _icount:Int, _interfaceMap:TPtrMap=New TPtrMap
  3998. End Type