libsee.pas 41 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084
  1. { $define libseehelper}
  2. {$mode objfpc}
  3. {$h+}
  4. {$IFNDEF FPC_DOTTEDUNITS}
  5. unit libsee;
  6. {$ENDIF FPC_DOTTEDUNITS}
  7. interface
  8. {$IFDEF FPC_DOTTEDUNITS}
  9. uses
  10. System.CTypes;
  11. {$ELSE FPC_DOTTEDUNITS}
  12. uses
  13. ctypes;
  14. {$ENDIF FPC_DOTTEDUNITS}
  15. {
  16. Automatically converted by H2Pas 1.0.0 from libsee.c
  17. The following command line parameters were used:
  18. -D
  19. -l
  20. see
  21. -C
  22. -u
  23. libsee
  24. -T
  25. -o
  26. libsee.pas
  27. -P
  28. libsee.c
  29. }
  30. const
  31. {$ifdef unix}
  32. LibSeeLibraryName='libsee.so';
  33. {$else}
  34. LibSeeLibraryName='libsee.dll';
  35. {$endif}
  36. Type
  37. Tsize_t = csize_t;
  38. tcuchar = AnsiChar;
  39. Tuint16_t = word;
  40. Tuint32_t = cardinal;
  41. Tuint64_t = qword;
  42. Tint16_t = integer;
  43. Tint32_t = longint;
  44. Tint64_t = int64;
  45. TDouble = double;
  46. tcuint = word;
  47. tcint = integer;
  48. PTcchar = PAnsiChar;
  49. PPTcchar = ^PTcchar;
  50. Ptcint = ^tcint;
  51. PTcuint = ^tcuint;
  52. tcchar = AnsiChar;
  53. var
  54. SEE_literal_NaN : array[0..7] of Tcuchar;cvar;external;
  55. Type
  56. PFILE = Pointer;
  57. PTFILE = Pointer;
  58. PPSEE_string = ^PSEE_string;
  59. PSEE_context = ^TSEE_context;
  60. PSEE_enum = ^TSEE_enum;
  61. PSEE_growable = ^TSEE_growable;
  62. PSEE_input = ^TSEE_input;
  63. PSEE_interpreter = ^TSEE_interpreter;
  64. PSEE_module = ^TSEE_module;
  65. PSEE_native = ^TSEE_native;
  66. PSEE_object = ^TSEE_object;
  67. PSEE_objectclass = ^TSEE_objectclass;
  68. PSEE_scope = ^TSEE_scope;
  69. PSEE_string = ^TSEE_string;
  70. PSEE_throw_location = ^TSEE_throw_location;
  71. PSEE_try_context = ^TSEE_try_context;
  72. PSEE_unicode_t = ^TSEE_unicode_t;
  73. PSEE_value = ^TSEE_value;
  74. PTSEE_char_t = ^TSEE_Char_t;
  75. PTSEE_Code = Pointer;
  76. PTSEE_context = ^TSEE_context;
  77. PTSEE_enum = ^TSEE_enum;
  78. PTSEE_growable = ^TSEE_growable;
  79. PTSEE_input = ^TSEE_input;
  80. PTSEE_interpreter = ^TSEE_interpreter;
  81. PTSEE_module = ^TSEE_module;
  82. PTSEE_native = ^TSEE_native;
  83. PTSEE_object = ^TSEE_object;
  84. PTSEE_objectclass = ^TSEE_objectclass;
  85. PTSEE_scope = ^TSEE_scope;
  86. PTSEE_string = ^TSEE_string;
  87. TPSEE_string = PTSEE_string;
  88. PTSEE_throw_location = ^TSEE_throw_location;
  89. PTSEE_try_context = ^TSEE_try_context;
  90. PTSEE_unicode_t = ^TSEE_unicode_t;
  91. PTSEE_value = ^TSEE_value;
  92. PPTSEE_value = ^PSEE_value;
  93. PTSEE_enumclass = ^TSEE_enumclass;
  94. PSEE_system = ^TSEE_System;
  95. // PTSEE_property = ^TSEE_property;
  96. PTSEE_property = Pointer;
  97. TPSEE_object = ^TSEE_object;
  98. PTSEE_inputclass = ^TSEE_inputclass;
  99. PTSEE_traceback = ^TSEE_traceback;
  100. PTSEE_regex_engine = Pointer;
  101. PTSEE_stringclass = ^TSEE_stringclass;
  102. TPSEE_enum = PSEE_Enum;
  103. TPSEE_input = PSEE_INPUT;
  104. PTPSEE_string = ^TSEE_STRING;
  105. TPSEE_interpreter_state = Pointer; //^TSEE_interpreter_state;
  106. {$IFDEF FPC}
  107. {$PACKRECORDS C}
  108. {$ENDIF}
  109. TSEE_uint16_t = Tuint16_t;
  110. TSEE_uint32_t = Tuint32_t;
  111. TSEE_int32_t = Tint32_t;
  112. TSEE_uint64_t = Tuint64_t;
  113. TSEE_int64_t = Tint64_t;
  114. TSEE_number_t = Tdouble;
  115. TSEE_boolean_t = Tcuchar;
  116. TSEE_char_t = TSEE_uint16_t;
  117. TSEE_unicode_t = TSEE_uint32_t;
  118. TSEE_type = (SEE_UNDEFINED,SEE_NULL,SEE_BOOLEAN,SEE_NUMBER,
  119. SEE_STRING,SEE_OBJECT,SEE_REFERENCE,SEE_COMPLETION
  120. );
  121. TSEE_reference = record
  122. base : PTSEE_object;
  123. _property : PTSEE_string;
  124. end;
  125. TSEE_completion = record
  126. value : PTSEE_value;
  127. target : Tcuint;
  128. _type : (SEE_COMPLETION_NORMAL,SEE_COMPLETION_BREAK,
  129. SEE_COMPLETION_CONTINUE,SEE_COMPLETION_RETURN,
  130. SEE_COMPLETION_THROW);
  131. end;
  132. TSEE_value = record
  133. _type : TSEE_type;
  134. u : record
  135. case longint of
  136. 0 : ( number : TSEE_number_t );
  137. 1 : ( boolean : TSEE_boolean_t );
  138. 2 : ( _object : PTSEE_object );
  139. 3 : ( _string : PTSEE_string );
  140. 4 : ( reference : TSEE_reference );
  141. 5 : ( completion : TSEE_completion );
  142. 6 : ( _padding : array[0..3] of pointer );
  143. end;
  144. end;
  145. TSEE_get_fn_t = procedure (i:PTSEE_interpreter; obj:PTSEE_object; prop:PTSEE_string; res:PTSEE_value);cdecl;
  146. TSEE_put_fn_t = procedure (i:PTSEE_interpreter; obj:PTSEE_object; prop:PTSEE_string; res:PTSEE_value; flags:Tcint);cdecl;
  147. TSEE_boolean_fn_t = function (i:PTSEE_interpreter; obj:PTSEE_object; prop:PTSEE_string):Tcint;cdecl;
  148. TSEE_hasinstance_fn_t = function (i:PTSEE_interpreter; obj:PTSEE_object; instance:PTSEE_value):Tcint;cdecl;
  149. TSEE_default_fn_t = procedure (i:PTSEE_interpreter; obj:PTSEE_object; hint:PTSEE_value; res:PTSEE_value);cdecl;
  150. TSEE_call_fn_t = procedure (i:PTSEE_interpreter; obj:PTSEE_object; thisobj:PTSEE_object; argc:Tcint; argv:PPTSEE_value;
  151. res:PTSEE_value);cdecl;
  152. TSEE_enumerator_fn_t = function (i:PTSEE_interpreter; obj:PTSEE_object):PTSEE_enum;cdecl;
  153. TSEE_get_sec_domain_fn_t = function (i:PTSEE_interpreter; obj:PTSEE_object):pointer;cdecl;
  154. (* Const before type ignored *)
  155. TSEE_objectclass = record
  156. _Class : PTcchar;
  157. Get : TSEE_get_fn_t;
  158. Put : TSEE_put_fn_t;
  159. CanPut : TSEE_boolean_fn_t;
  160. HasProperty : TSEE_boolean_fn_t;
  161. Delete : TSEE_boolean_fn_t;
  162. DefaultValue : TSEE_default_fn_t;
  163. enumerator : TSEE_enumerator_fn_t;
  164. Construct : TSEE_call_fn_t;
  165. Call : TSEE_call_fn_t;
  166. HasInstance : TSEE_hasinstance_fn_t;
  167. get_sec_domain : TSEE_get_sec_domain_fn_t;
  168. end;
  169. TSEE_object = record
  170. objectclass : PTSEE_objectclass;
  171. Prototype : PTSEE_object;
  172. host_data : pointer;
  173. end;
  174. TSEE_enumclass = record
  175. unused : pointer;
  176. next : function (i:PTSEE_interpreter; e:PTSEE_enum; flags_return:pTcint):TPSEE_string;cdecl;
  177. end;
  178. TSEE_enum = record
  179. enumclass : PTSEE_enumclass;
  180. end;
  181. TSEE_native = record
  182. _object : TSEE_object;
  183. properties : array[0..256] of PTSEE_property;
  184. lru : PTSEE_property;
  185. end;
  186. TSEE_scope = record
  187. next : PTSEE_scope;
  188. obj : TPSEE_object;
  189. end;
  190. TSEE_inputclass = record
  191. next : function (para1:PTSEE_input):TSEE_unicode_t;cdecl;
  192. close : procedure (para1:PTSEE_input);
  193. end;
  194. TSEE_input = record
  195. inputclass : PTSEE_inputclass;
  196. eof : TSEE_boolean_t;
  197. lookahead : TSEE_unicode_t;
  198. filename : TPSEE_string;
  199. first_lineno : Tcint;
  200. interpreter : PTSEE_interpreter;
  201. end;
  202. TSEE_trace_event = (SEE_TRACE_CALL,SEE_TRACE_RETURN,SEE_TRACE_STATEMENT,
  203. SEE_TRACE_THROW);
  204. TSEE_interpreter = record
  205. host_data : pointer;
  206. compatibility : Tcint;
  207. Global : TPSEE_object;
  208. _Object : TPSEE_object;
  209. Object_prototype : TPSEE_object;
  210. Error : TPSEE_object;
  211. EvalError : TPSEE_object;
  212. RangeError : TPSEE_object;
  213. ReferenceError : TPSEE_object;
  214. SyntaxError : TPSEE_object;
  215. TypeError : TPSEE_object;
  216. URIError : TPSEE_object;
  217. _String : TPSEE_object;
  218. String_prototype : TPSEE_object;
  219. _Function : TPSEE_object;
  220. Function_prototype : TPSEE_object;
  221. _Array : TPSEE_object;
  222. Array_prototype : TPSEE_object;
  223. Number : TPSEE_object;
  224. Number_prototype : TPSEE_object;
  225. Boolean : TPSEE_object;
  226. Boolean_prototype : TPSEE_object;
  227. Math : TPSEE_object;
  228. RegExp : TPSEE_object;
  229. RegExp_prototype : TPSEE_object;
  230. Date : TPSEE_object;
  231. Date_prototype : TPSEE_object;
  232. Global_eval : TPSEE_object;
  233. Global_scope : PTSEE_scope;
  234. try_context : PTSEE_try_context;
  235. try_location : PTSEE_throw_location;
  236. traceback : PTSEE_traceback;
  237. module_private : Ppointer;
  238. intern_tab : pointer;
  239. random_seed : Tcuint;
  240. locale : PTcchar;
  241. recursion_limit : Tcint;
  242. sec_domain : pointer;
  243. trace : procedure (para1:PTSEE_interpreter; para2:PTSEE_throw_location; para3:PTSEE_context; para4:TSEE_trace_event);cdecl;
  244. regex_engine : PTSEE_regex_engine;
  245. end;
  246. TSEE_traceback = record
  247. call_location : PTSEE_throw_location;
  248. callee : TPSEE_object;
  249. call_type : Tcint;
  250. prev : PTSEE_traceback;
  251. end;
  252. TSEE_context = record
  253. interpreter : PTSEE_interpreter;
  254. activation : TPSEE_object;
  255. variable : TPSEE_object;
  256. varattr : Tcint;
  257. thisobj : TPSEE_object;
  258. scope : PTSEE_scope;
  259. end;
  260. TSEE_growable = record
  261. data_ptr : Ppointer;
  262. length_ptr : PTcuint;
  263. element_size : Tsize_t;
  264. allocated : Tsize_t;
  265. flag0 : word;
  266. end;
  267. TSEE_module = record
  268. magic : TSEE_uint32_t;
  269. name : PTcchar;
  270. version : PTcchar;
  271. index : Tcuint;
  272. mod_init : function :Tcint;cdecl;
  273. alloc : procedure (para1:PTSEE_interpreter);cdecl;
  274. init : procedure (para1:PTSEE_interpreter);cdecl;
  275. end;
  276. TSEE_string = record
  277. length : Tcuint;
  278. data : PTSEE_char_t;
  279. stringclass : PTSEE_stringclass;
  280. interpreter : PTSEE_interpreter;
  281. flags : Tcint;
  282. end;
  283. TSEE_stringclass = record
  284. growby : procedure (para1:TPSEE_string; para2:Tcuint);cdecl;
  285. end;
  286. TFinalProc = procedure (para1:PTSEE_interpreter; para2:pointer; para3:pointer); cdecl;
  287. TSEE_system = record
  288. default_locale : PTcchar;
  289. default_recursion_limit : Tcint;
  290. default_trace : procedure (para1:PTSEE_interpreter; para2:PTSEE_throw_location; para3:PTSEE_context; para4:TSEE_trace_event);cdecl;
  291. default_compat_flags : Tcint;
  292. random_seed : function :Tcuint;
  293. abort : procedure (para1:PTSEE_interpreter; para2:PTcchar);
  294. periodic : procedure (para1:PTSEE_interpreter);
  295. malloc : function (para1:PTSEE_interpreter; para2:Tsize_t; para3:PTcchar; para4:Tcint):pointer;
  296. malloc_finalize : function (para1:PTSEE_interpreter; para2:Tsize_t; para3:tfinalproc; para4:pointer; para5:PTcchar; para6:Tcint):pointer;
  297. malloc_string : function (para1:PTSEE_interpreter; para2:Tsize_t; para3:PTcchar; para4:Tcint):pointer;
  298. free : procedure (para1:PTSEE_interpreter; para2:pointer; para3:PTcchar; para4:Tcint);
  299. mem_exhausted : procedure (para1:PTSEE_interpreter);
  300. gcollect : procedure (para1:PTSEE_interpreter);
  301. transit_sec_domain : function (para1:PTSEE_interpreter; para2:pointer):pointer;
  302. code_alloc : function (para1:PTSEE_interpreter): PTSEE_code;
  303. object_construct : procedure (interp:PTSEE_interpreter; self:TPSEE_object; thisobj:TPSEE_object; argc:Tcint; argv:PPTSEE_value;
  304. res:PTSEE_value);
  305. default_regex_engine : PTSEE_regex_engine;
  306. end;
  307. TSEE_throw_location = record
  308. filename : TPSEE_string;
  309. lineno : Tcint;
  310. end;
  311. Tjmp_buf = record
  312. a : array[1..200] of byte;
  313. end;
  314. TSEE_try_context_t = record
  315. interpreter : PTSEE_interpreter;
  316. previous : PTSEE_try_context;
  317. thrown : TSEE_value;
  318. done : Tcint;
  319. env : Tjmp_buf; //
  320. throw_file : PTcchar;
  321. throw_line : Tcint;
  322. saved_traceback : PTSEE_traceback;
  323. traceback : PTSEE_traceback;
  324. end;
  325. TSEE_try_context = TSEE_try_context_t;
  326. const
  327. bm_TSEE_growable_is_string = $1;
  328. bp_TSEE_growable_is_string = 0;
  329. var
  330. _SEE_isnan : function(n:TSEE_number_t):Tcint;cdecl;
  331. _SEE_isfinite : function(n:TSEE_number_t):Tcint;cdecl;
  332. _SEE_copysign : function(x:TSEE_number_t; y:TSEE_number_t):TSEE_number_t;cdecl;
  333. _SEE_ispinf : function(n:TSEE_number_t):Tcint;cdecl;
  334. _SEE_isninf : function(n:TSEE_number_t):Tcint;cdecl;
  335. SEE_ToPrimitive : procedure(i:PTSEE_interpreter; val:PTSEE_value; _type:PTSEE_value; res:PTSEE_value);cdecl;
  336. SEE_ToBoolean : procedure(i:PTSEE_interpreter; val:PTSEE_value; res:PTSEE_value);cdecl;
  337. SEE_ToNumber : procedure(i:PTSEE_interpreter; val:PTSEE_value; res:PTSEE_value);cdecl;
  338. SEE_ToInteger : procedure(i:PTSEE_interpreter; val:PTSEE_value; res:PTSEE_value);cdecl;
  339. SEE_ToString : procedure(i:PTSEE_interpreter; val:PTSEE_value; res:PTSEE_value);cdecl;
  340. SEE_ToObject : procedure(i:PTSEE_interpreter; val:PTSEE_value; res:PTSEE_value);cdecl;
  341. SEE_ToInt32 : function(i:PTSEE_interpreter; val:PTSEE_value):TSEE_int32_t;cdecl;
  342. SEE_ToUint32 : function(i:PTSEE_interpreter; val:PTSEE_value):TSEE_uint32_t;cdecl;
  343. SEE_ToUint16 : function(i:PTSEE_interpreter; val:PTSEE_value):TSEE_uint16_t;cdecl;
  344. SEE_hexstr_lowercase : array[0..15] of Tcchar;cvar;external;
  345. _SEE_intern_assert : function(i:PTSEE_interpreter; s:TPSEE_string):TPSEE_string;cdecl;
  346. SEE_intern_ascii : function(para1:PTSEE_interpreter; para2:PTcchar):TPSEE_string;cdecl;
  347. SEE_function_is_joined : function(a:PTSEE_object; b:PTSEE_object):Tcint;cdecl;
  348. SEE_Object_new : function(para1:PTSEE_interpreter):TPSEE_object;cdecl;
  349. SEE_object_call : procedure(para1:PTSEE_interpreter; para2:TPSEE_object; para3:TPSEE_object; para4:Tcint; para5:PPTSEE_value;
  350. para6:PTSEE_value);cdecl;
  351. SEE_object_construct : procedure(para1:PTSEE_interpreter; para2:TPSEE_object; para3:TPSEE_object; para4:Tcint; para5:PPTSEE_value;
  352. para6:PTSEE_value);cdecl;
  353. SEE_object_instanceof : function(interp:PTSEE_interpreter; val:PTSEE_value; obj:TPSEE_object):Tcint;cdecl;
  354. SEE_native_get : procedure(i:PTSEE_interpreter; obj:TPSEE_object; prop:TPSEE_string; res:PTSEE_value);cdecl;
  355. SEE_native_put : procedure(i:PTSEE_interpreter; obj:TPSEE_object; prop:TPSEE_string; val:PTSEE_value; flags:Tcint);cdecl;
  356. SEE_native_canput : function(i:PTSEE_interpreter; obj:TPSEE_object; prop:TPSEE_string):Tcint;cdecl;
  357. SEE_native_hasproperty : function(i:PTSEE_interpreter; obj:TPSEE_object; prop:TPSEE_string):Tcint;cdecl;
  358. SEE_native_hasownproperty : function(i:PTSEE_interpreter; obj:TPSEE_object; prop:TPSEE_string):Tcint;cdecl;
  359. SEE_native_getownattr : function(i:PTSEE_interpreter; obj:TPSEE_object; prop:TPSEE_string):Tcint;cdecl;
  360. SEE_native_delete : function(i:PTSEE_interpreter; obj:TPSEE_object; prop:TPSEE_string):Tcint;cdecl;
  361. SEE_native_defaultvalue : procedure(i:PTSEE_interpreter; obj:TPSEE_object; hint:PTSEE_value; res:PTSEE_value);cdecl;
  362. SEE_native_enumerator : function(i:PTSEE_interpreter; obj:TPSEE_object):TPSEE_enum;cdecl;
  363. SEE_native_new : function(i:PTSEE_interpreter):TPSEE_object;cdecl;
  364. SEE_native_init : procedure(obj:PTSEE_native; i:PTSEE_interpreter; obj_class:PTSEE_objectclass; prototype:TPSEE_object);cdecl;
  365. SEE_cfunction_make : function(i:PTSEE_interpreter; func:TSEE_call_fn_t; name:TPSEE_string; length:Tcint):TPSEE_object;cdecl;
  366. SEE_parse_args : procedure(i:PTSEE_interpreter; argc:Tcint; argv:PPTSEE_value; fmt:pTcchar);cdecl;varargs;
  367. SEE_call_args : procedure(i:PTSEE_interpreter; func:TPSEE_object; thisobj:TPSEE_object; ret:PTSEE_value; fmt:pTcchar);cdecl;varargs;
  368. SEE_PrintValue : procedure(i:PTSEE_interpreter; v:PTSEE_value; f:PTFILE);cdecl;
  369. SEE_PrintObject : procedure(i:PTSEE_interpreter; o:TPSEE_object; f:PTFILE);cdecl;
  370. SEE_PrintString : procedure(i:PTSEE_interpreter; s:TPSEE_string; f:PTFILE);cdecl;
  371. SEE_PrintTraceback : procedure(i:PTSEE_interpreter; f:PTFILE);cdecl;
  372. SEE_PrintContextTraceback : procedure(i:PTSEE_interpreter; context:PTSEE_try_context; f:PTFILE);cdecl;
  373. SEE_Global_eval : procedure(i:PTSEE_interpreter; input:PTSEE_input; res:PTSEE_value);cdecl;
  374. SEE_eval : procedure(i:PTSEE_interpreter; input:PTSEE_input; thisobj:TPSEE_object; variable:TPSEE_object; scope:PTSEE_scope;
  375. res:PTSEE_value);cdecl;
  376. SEE_Function_new : function(i:PTSEE_interpreter; name:TPSEE_string; param_input:PTSEE_input; body_input:PTSEE_input):TPSEE_object;cdecl;
  377. SEE_error__throw_string : procedure(i:PTSEE_interpreter; errorobj:TPSEE_object; filename:pTcchar; lineno:Tcint; message:TPSEE_string);cdecl;
  378. SEE_error__throw : procedure(i:PTSEE_interpreter; errorobj:TPSEE_object; filename:pTcchar; lineno:Tcint; fmt:pTcchar);cdecl; varargs;
  379. SEE_error__throw_sys : procedure(i:PTSEE_interpreter; errorobj:TPSEE_object; filename:pTcchar; lineno:Tcint; fmt:pTcchar);cdecl; varargs;
  380. SEE_Error_make : function(i:PTSEE_interpreter; name:TPSEE_string):TPSEE_object;cdecl;
  381. SEE_error__throw0 : procedure(i:PTSEE_interpreter; errorobj:TPSEE_object; fmt:pTcchar);cdecl;varargs;
  382. SEE_error__throw_sys0 : procedure(i:PTSEE_interpreter; errorobj:TPSEE_object; fmt:pTcchar);cdecl;varargs;
  383. SEE_input_file : function(i:PTSEE_interpreter; f:PTFILE; filename:pTcchar; encoding:pTcchar):TPSEE_input;cdecl;
  384. SEE_input_string : function(i:PTSEE_interpreter; s:TPSEE_string):TPSEE_input;cdecl;
  385. SEE_input_utf8 : function(i:PTSEE_interpreter; s:pTcchar):TPSEE_input;cdecl;
  386. SEE_input_lookahead : function(i:TPSEE_input; maxlookahead:Tcint):TPSEE_input;cdecl;
  387. SEE_input_lookahead_copy : function(li:TPSEE_input; buf:PTSEE_unicode_t; buflen:Tcint):Tcint;cdecl;
  388. _SEE_intern_init : procedure(i:PTSEE_interpreter);cdecl;
  389. SEE_intern : function(i:PTSEE_interpreter; s:TPSEE_string):TPSEE_string;cdecl;
  390. SEE_intern_and_free : procedure(i:PTSEE_interpreter; s:PTPSEE_string);cdecl;
  391. // SEE_intern_ascii : function(i:PTSEE_interpreter; s:pTcchar):TPSEE_string;cdecl;
  392. SEE_intern_global : function(s:pTcchar):TPSEE_string;cdecl;
  393. SEE_interpreter_init : procedure(i:PTSEE_interpreter);cdecl;
  394. SEE_interpreter_init_compat : procedure(i:PTSEE_interpreter; compat_flags:Tcint);cdecl;
  395. SEE_interpreter_save_state : function(i:PTSEE_interpreter):TPSEE_interpreter_state;cdecl;
  396. SEE_interpreter_restore_state : procedure(i:PTSEE_interpreter; state:TPSEE_interpreter_state);cdecl;
  397. SEE_context_eval : procedure(context:PTSEE_context; expr:TPSEE_string; res:PTSEE_value);cdecl;
  398. Type
  399. Tfinalizefn = procedure( i:PTSEE_interpreter; p:pointer; closure:pointer);cdecl;
  400. Var
  401. SEE_malloc : function(i:PTSEE_interpreter; sz:Tsize_t):pointer;cdecl;
  402. SEE_malloc_string : function(i:PTSEE_interpreter; sz:Tsize_t):pointer;cdecl;
  403. SEE_malloc_finalize : function(i:PTSEE_interpreter; sz:Tsize_t; finalizefn:Tfinalizefn; closure:pointer):pointer;cdecl;
  404. SEE_free : procedure(i:PTSEE_interpreter; memp:Ppointer);cdecl;
  405. SEE_gcollect : procedure(i:PTSEE_interpreter);cdecl;
  406. _SEE_malloc_debug : function(i:PTSEE_interpreter; sz:Tsize_t; _file:pTcchar; line:Tcint):pointer;cdecl;
  407. _SEE_malloc_string_debug : function(i:PTSEE_interpreter; sz:Tsize_t; _file:pTcchar; line:Tcint):pointer;cdecl;
  408. _SEE_malloc_finalize_debug : function(i:PTSEE_interpreter; sz:Tsize_t; finalizefn:Tfinalizefn; closure:pointer; _file:pTcchar; line:Tcint):pointer;cdecl;
  409. _SEE_free_debug : procedure(i:PTSEE_interpreter; memp:Ppointer; _file:pTcchar; line:Tcint);cdecl;
  410. function is_string(var a : TSEE_growable) : boolean;
  411. procedure set_is_string(var a : TSEE_growable; __is_string : boolean);
  412. var
  413. SEE_grow_to : procedure(i:PTSEE_interpreter; grow:PTSEE_growable; new_len:Tcuint);cdecl;
  414. _SEE_grow_to_debug : procedure(i:PTSEE_interpreter; grow:PTSEE_growable; new_len:Tcuint; _file:pTcchar; line:Tcint);cdecl;
  415. SEE_module_add : function(module:PTSEE_module):Tcint;cdecl;
  416. SEE_no_get : procedure(para1:PTSEE_interpreter; para2:TPSEE_object; para3:TPSEE_string; val:PTSEE_value);cdecl;
  417. SEE_no_put : procedure(para1:PTSEE_interpreter; para2:TPSEE_object; para3:TPSEE_string; val:PTSEE_value; para5:Tcint);cdecl;
  418. SEE_no_canput : function(para1:PTSEE_interpreter; para2:TPSEE_object; para3:TPSEE_string):Tcint;cdecl;
  419. SEE_no_hasproperty : function(para1:PTSEE_interpreter; para2:TPSEE_object; para3:TPSEE_string):Tcint;cdecl;
  420. SEE_no_delete : function(para1:PTSEE_interpreter; para2:TPSEE_object; para3:TPSEE_string):Tcint;cdecl;
  421. SEE_no_defaultvalue : procedure(para1:PTSEE_interpreter; para2:TPSEE_object; para3:PTSEE_value; para4:PTSEE_value);cdecl;
  422. SEE_no_enumerator : function(para1:PTSEE_interpreter; para2:TPSEE_object):TPSEE_enum;cdecl;
  423. var
  424. SEE_string_addch : procedure(s:TPSEE_string; ch:Tcint);cdecl;
  425. SEE_string_append : procedure(s:TPSEE_string; sffx:TPSEE_string);cdecl;
  426. SEE_string_append_ascii : procedure(s:TPSEE_string; ascii:pTcchar);cdecl;
  427. SEE_string_append_int : procedure(s:TPSEE_string; i:Tcint);cdecl;
  428. SEE_string_append_unicode : procedure(s:TPSEE_string; uch:TSEE_unicode_t);cdecl;
  429. SEE_string_fputs : function(s:TPSEE_string; _file:PTFILE):Tcint;cdecl;
  430. SEE_string_cmp : function(s1:TPSEE_string; s2:TPSEE_string):Tcint;cdecl;
  431. SEE_string_cmp_ascii : function(s1:TPSEE_string; s2:pTcchar):Tcint;cdecl;
  432. SEE_string_new : function(i:PTSEE_interpreter; space:Tcuint):TPSEE_string;cdecl;
  433. SEE_string_dup : function(i:PTSEE_interpreter; s:TPSEE_string):TPSEE_string;cdecl;
  434. SEE_string_substr : function(i:PTSEE_interpreter; s:TPSEE_string; index:Tcint; length:Tcint):TPSEE_string;cdecl;
  435. SEE_string_concat : function(i:PTSEE_interpreter; s1:TPSEE_string; s2:TPSEE_string):TPSEE_string;cdecl;
  436. SEE_string_sprintf : function(i:PTSEE_interpreter; fmt:pTcchar):TPSEE_string;cdecl; varargs;
  437. SEE_string_literal : function(i:PTSEE_interpreter; s:TPSEE_string):TPSEE_string;cdecl;
  438. SEE_string_fix : function(s:TPSEE_string):TPSEE_string;cdecl;
  439. SEE_string_free : procedure(i:PTSEE_interpreter; sp:PTPSEE_string);cdecl;
  440. SEE_string_toutf8 : procedure(i:PTSEE_interpreter; buf:pTcchar; buflen:Tsize_t; s:TPSEE_string);cdecl;
  441. SEE_string_utf8_size : function(interp:PTSEE_interpreter; s:TPSEE_string):Tsize_t;cdecl;
  442. _SEE_string_dup_fix : function(para1:PTSEE_interpreter; para2:TPSEE_string):TPSEE_string;cdecl;
  443. var
  444. SEE_system : TSEE_system;cvar;external;
  445. SEE_init : procedure;cdecl;
  446. SEE_regex_engine_list : function:PPTcchar;cdecl;
  447. SEE_regex_engine : function(name:pTcchar):PTSEE_regex_engine;cdecl;
  448. var
  449. SEE_throw_abort : procedure(para1:PTSEE_interpreter; para2:PTSEE_value; para3:PTcchar; para4:Tcint);cdecl;
  450. SEE_location_string : function(i:PTSEE_interpreter; loc:PTSEE_throw_location):TPSEE_string;cdecl;
  451. SEE_throw : procedure;cdecl;
  452. SEE_version : function: PTcchar;cdecl;
  453. procedure see_input_close(Inp : PSEE_INPUT);
  454. function SEE_VALUE_GET_TYPE(v : PSEE_value) : TSEE_type;
  455. procedure SEE_VALUE_COPY(dst, src : PSEE_value);
  456. procedure SEE_SET_UNDEFINED(v : PSEE_value);
  457. procedure SEE_SET_NULL(v : PSEE_value);
  458. procedure SEE_SET_BOOLEAN(v : PSEE_value; b : Boolean);
  459. procedure SEE_SET_NUMBER(v : PSEE_value; n : TSEE_number_t);
  460. procedure SEE_SET_STRING(v :PSEE_value; s: PSEE_STRING);
  461. procedure SEE_SET_OBJECT(v :PSEE_value; o: PSEE_OBJECT);
  462. function SEE_isnan (n:TSEE_number_t):Tcint;
  463. function SEE_isfinite (n:TSEE_number_t):Tcint;
  464. function SEE_copysign (x:TSEE_number_t; y:TSEE_number_t):TSEE_number_t;
  465. function SEE_ispinf (n:TSEE_number_t):Tcint;
  466. function SEE_isninf (n:TSEE_number_t):Tcint;
  467. Function SEE_MODULE_PRIVATE(i : PTSEE_interpreter; m : PSEE_module) : Pointer;
  468. procedure SEE_OBJECT_PUT(Interp : PTSEE_interpreter; Obj : PSEE_object; prop:TPSEE_string; val:PTSEE_value; flags:Tcint);
  469. CONST
  470. SEE_ATTR_READONLY = $01;
  471. SEE_ATTR_DONTENUM = $02;
  472. SEE_ATTR_DONTDELETE = $04;
  473. SEE_ATTR_INTERNAL = $08;
  474. SEE_MODULE_MAGIC = $5345456d;
  475. SEE_ATTR_DEFAULT = SEE_ATTR_DONTENUM;
  476. SEE_ATTR_LENGTH = SEE_ATTR_READONLY or SEE_ATTR_DONTDELETE or SEE_ATTR_DONTENUM;
  477. {$ifdef libseehelper}
  478. {$l libsee.so}
  479. {$l libseewrap.o}
  480. function SEE_help_Global_eval (para1 : PSEE_Interpreter; para2: PSEE_input; para3 : PSEE_value) : cint; cdecl; external;
  481. function SEE_help_CAUGHT(para1: TSEE_try_context) : PSEE_value; cdecl; external;
  482. procedure SEE_help_THROW(para1: PSEE_Interpreter; para2: PSEE_value); cdecl; external;
  483. procedure SEE_help_RETHROW(para1: PSEE_Interpreter; para2: PSEE_value); cdecl; external;
  484. procedure SEE_help_DEFAULT_CATCH(para1: PSEE_Interpreter; para2: PSEE_try_context); cdecl; external;
  485. function new_SEE_interpreter : PSEE_Interpreter; cdecl; external;
  486. function new_SEE_value : PSEE_Value; cdecl; external;
  487. function new_SEE_objectclass : PSEE_objectclass; cdecl; external;
  488. function new_SEE_object : PSEE_object; cdecl; external;
  489. function new_SEE_enumclass : PTSEE_enumclass; cdecl; external;
  490. function new_SEE_enum : PSEE_enum; cdecl; external;
  491. function new_SEE_native : PSEE_native; cdecl; external;
  492. function new_SEE_scope : PSEE_scope; cdecl; external;
  493. function new_SEE_inputclass : PTSEE_inputclass; cdecl; external;
  494. function new_SEE_input : PSEE_input; cdecl; external;
  495. function new_SEE_traceback : PTSEE_traceback; cdecl; external;
  496. function new_SEE_context : PSEE_context; cdecl; external;
  497. function new_SEE_stringclass : PTSEE_stringclass; cdecl; external;
  498. function new_SEE_throw_location : PSEE_throw_location; cdecl; external;
  499. function new_SEE_try_context : PSEE_try_context; cdecl; external;
  500. procedure free_SEE_struct(P : pointer); cdecl; external;
  501. {$else}
  502. function new_SEE_interpreter : PSEE_Interpreter;
  503. function new_SEE_value : PSEE_Value;
  504. function new_SEE_objectclass : PSEE_objectclass;
  505. function new_SEE_object : PSEE_object;
  506. function new_SEE_enumclass : PTSEE_enumclass;
  507. function new_SEE_enum : PSEE_enum;
  508. function new_SEE_native : PSEE_native;
  509. function new_SEE_scope : PSEE_scope;
  510. function new_SEE_inputclass : PTSEE_inputclass;
  511. function new_SEE_input : PSEE_input;
  512. function new_SEE_traceback : PTSEE_traceback;
  513. function new_SEE_context : PSEE_context;
  514. function new_SEE_stringclass : PTSEE_stringclass;
  515. function new_SEE_throw_location : PSEE_throw_location;
  516. function new_SEE_try_context : PSEE_try_context;
  517. procedure free_SEE_struct(P : pointer);
  518. {$endif}
  519. procedure Loadlibsee(Const Alib : string);
  520. procedure Freelibsee;
  521. Function LibseeLoaded : Boolean;
  522. implementation
  523. {$IFDEF FPC_DOTTEDUNITS}
  524. uses
  525. System.SysUtils, System.DynLibs;
  526. {$ELSE FPC_DOTTEDUNITS}
  527. uses
  528. SysUtils, dynlibs;
  529. {$ENDIF FPC_DOTTEDUNITS}
  530. {$ifndef libseehelper}
  531. function new_SEE_interpreter : PSEE_Interpreter;
  532. begin
  533. Result:=SEE_malloc(Nil,SizeOf(TSEE_interpreter));
  534. end;
  535. function new_SEE_value : PSEE_Value;
  536. begin
  537. Result:=SEE_malloc(Nil,SizeOf(TSEE_Value));
  538. end;
  539. function new_SEE_objectclass : PSEE_objectclass;
  540. begin
  541. Result:=SEE_malloc(Nil,SizeOf(TSEE_objectclass));
  542. end;
  543. function new_SEE_object : PSEE_object;
  544. begin
  545. Result:=SEE_malloc(Nil,SizeOf(TSEE_object));
  546. end;
  547. function new_SEE_enumclass : PTSEE_enumclass;
  548. begin
  549. Result:=SEE_malloc(Nil,SizeOf(TSEE_enumclass));
  550. end;
  551. function new_SEE_enum : PSEE_enum;
  552. begin
  553. Result:=SEE_malloc(Nil,SizeOf(TSEE_enum));
  554. end;
  555. function new_SEE_native : PSEE_native;
  556. begin
  557. Result:=SEE_malloc(Nil,SizeOf(TSEE_native));
  558. end;
  559. function new_SEE_scope : PSEE_scope;
  560. begin
  561. Result:=SEE_malloc(Nil,SizeOf(TSEE_scope));
  562. end;
  563. function new_SEE_inputclass : PTSEE_inputclass;
  564. begin
  565. Result:=SEE_malloc(Nil,SizeOf(TSEE_inputclass));
  566. end;
  567. function new_SEE_input : PSEE_input;
  568. begin
  569. Result:=SEE_malloc(Nil,SizeOf(TSEE_input));
  570. end;
  571. function new_SEE_traceback : PTSEE_traceback;
  572. begin
  573. Result:=SEE_malloc(Nil,SizeOf(TSEE_traceback));
  574. end;
  575. function new_SEE_context : PSEE_context;
  576. begin
  577. Result:=SEE_malloc(Nil,SizeOf(TSEE_context));
  578. end;
  579. function new_SEE_stringclass : PTSEE_stringclass;
  580. begin
  581. Result:=SEE_malloc(Nil,SizeOf(TSEE_stringclass));
  582. end;
  583. function new_SEE_throw_location : PSEE_throw_location;
  584. begin
  585. Result:=SEE_malloc(Nil,SizeOf(TSEE_throw_location));
  586. end;
  587. function new_SEE_try_context : PSEE_try_context;
  588. begin
  589. Result:=SEE_malloc(Nil,SizeOf(TSEE_try_context));
  590. end;
  591. procedure free_SEE_struct(P : pointer);
  592. begin
  593. SEE_free(Nil,P);
  594. end;
  595. {$endif}
  596. procedure SEE_OBJECT_PUT(Interp : PTSEE_interpreter; Obj : PSEE_object; prop:TPSEE_string; val:PTSEE_value; flags:Tcint);
  597. begin
  598. obj^.objectclass^.Put(Interp,obj,prop,val,flags);
  599. end;
  600. // SEE_native_put : procedure(i:PTSEE_interpreter; obj:TPSEE_object; prop:TPSEE_string; val:PTSEE_value; flags:Tcint);cdecl;
  601. function SEE_VALUE_GET_TYPE(v : PSEE_value) : TSEE_type;
  602. begin
  603. Result:=v^._type;
  604. end;
  605. procedure SEE_VALUE_COPY(dst, src : PSEE_value);
  606. begin
  607. dst^:=src^;
  608. end;
  609. procedure SEE_SET_TYPE(v: PSEE_VALUE; t : TSEE_type);
  610. begin
  611. v^._type:=t;
  612. end;
  613. procedure SEE_SET_UNDEFINED(v : PSEE_value);
  614. begin
  615. SEE_SET_TYPE(v,SEE_UNDEFINED);
  616. end;
  617. procedure SEE_SET_NULL(v : PSEE_value);
  618. begin
  619. SEE_SET_TYPE(V,SEE_NULL);
  620. end;
  621. procedure SEE_SET_BOOLEAN(v : PSEE_value; b : Boolean);
  622. begin
  623. SEE_SET_TYPE(V,SEE_BOOLEAN);
  624. V^.u.boolean:=AnsiChar(ord(B));
  625. end;
  626. procedure SEE_SET_NUMBER(v : PSEE_value; n : TSEE_number_t);
  627. begin
  628. SEE_SET_TYPE(V,SEE_NUMBER);
  629. V^.u.number:=N;
  630. end;
  631. procedure SEE_SET_STRING(v :PSEE_value; s: PSEE_STRING);
  632. begin
  633. SEE_SET_TYPE(V,SEE_STRING);
  634. V^.u._string:=s
  635. end;
  636. procedure SEE_SET_OBJECT(v :PSEE_value; o: PSEE_OBJECT);
  637. begin
  638. SEE_SET_TYPE(V,SEE_OBJECT);
  639. V^.u._object:=o;
  640. end;
  641. function SEE_isnan (n:TSEE_number_t):Tcint;
  642. begin
  643. Result:=_see_isnan(n);
  644. end;
  645. function SEE_isfinite (n:TSEE_number_t):Tcint;
  646. begin
  647. result:=_see_isfinite(n);
  648. end;
  649. function SEE_copysign (x:TSEE_number_t; y:TSEE_number_t):TSEE_number_t;
  650. begin
  651. result:=_see_copysign(x,y);
  652. end;
  653. function SEE_ispinf (n:TSEE_number_t):Tcint;
  654. begin
  655. result:=_see_ispinf(n);
  656. end;
  657. function SEE_isninf (n:TSEE_number_t):Tcint;
  658. begin
  659. result:=_see_isninf(n);
  660. end;
  661. function is_string(var a : TSEE_growable) : Boolean;
  662. begin
  663. is_string:=((a.flag0 and bm_TSEE_growable_is_string) shr bp_TSEE_growable_is_string)<>0;
  664. end;
  665. procedure set_is_string(var a : TSEE_growable; __is_string : Boolean);
  666. begin
  667. a.flag0:=a.flag0 or ((ord(__is_string) shl bp_TSEE_growable_is_string) and bm_TSEE_growable_is_string);
  668. end;
  669. Function SEE_MODULE_PRIVATE(i : PTSEE_interpreter; m : PSEE_module) : Pointer;
  670. begin
  671. Result:=@I^.module_private[Integer(m^.index)];
  672. end;
  673. procedure see_input_close(Inp : PSEE_INPUT);
  674. begin
  675. Inp^.inputclass^.close(inp);
  676. end;
  677. var
  678. hlib : tlibhandle;
  679. procedure Freelibsee;
  680. begin
  681. If HLib<>NilHandle then
  682. FreeLibrary(hlib);
  683. _SEE_isnan:=nil;
  684. _SEE_isfinite:=nil;
  685. _SEE_copysign:=nil;
  686. _SEE_ispinf:=nil;
  687. _SEE_isninf:=nil;
  688. SEE_ToPrimitive:=nil;
  689. SEE_ToBoolean:=nil;
  690. SEE_ToNumber:=nil;
  691. SEE_ToInteger:=nil;
  692. SEE_ToString:=nil;
  693. SEE_ToObject:=nil;
  694. SEE_ToInt32:=nil;
  695. SEE_ToUint32:=nil;
  696. SEE_ToUint16:=nil;
  697. _SEE_intern_assert:=nil;
  698. SEE_intern_ascii:=nil;
  699. SEE_function_is_joined:=nil;
  700. SEE_Object_new:=nil;
  701. SEE_object_call:=nil;
  702. SEE_object_construct:=nil;
  703. SEE_object_instanceof:=nil;
  704. SEE_native_get:=nil;
  705. SEE_native_put:=nil;
  706. SEE_native_canput:=nil;
  707. SEE_native_hasproperty:=nil;
  708. SEE_native_hasownproperty:=nil;
  709. SEE_native_getownattr:=nil;
  710. SEE_native_delete:=nil;
  711. SEE_native_defaultvalue:=nil;
  712. SEE_native_enumerator:=nil;
  713. SEE_native_new:=nil;
  714. SEE_native_init:=nil;
  715. SEE_cfunction_make:=nil;
  716. SEE_parse_args:=nil;
  717. SEE_parse_args:=nil;
  718. SEE_call_args:=nil;
  719. SEE_call_args:=nil;
  720. SEE_PrintValue:=nil;
  721. SEE_PrintObject:=nil;
  722. SEE_PrintString:=nil;
  723. SEE_PrintTraceback:=nil;
  724. SEE_PrintContextTraceback:=nil;
  725. SEE_Global_eval:=nil;
  726. SEE_eval:=nil;
  727. SEE_Function_new:=nil;
  728. SEE_error__throw_string:=nil;
  729. SEE_error__throw:=nil;
  730. SEE_error__throw:=nil;
  731. SEE_error__throw_sys:=nil;
  732. SEE_error__throw_sys:=nil;
  733. SEE_Error_make:=nil;
  734. SEE_error__throw0:=nil;
  735. SEE_error__throw0:=nil;
  736. SEE_error__throw_sys0:=nil;
  737. SEE_error__throw_sys0:=nil;
  738. SEE_input_file:=nil;
  739. SEE_input_string:=nil;
  740. SEE_input_utf8:=nil;
  741. SEE_input_lookahead:=nil;
  742. SEE_input_lookahead_copy:=nil;
  743. _SEE_intern_init:=nil;
  744. SEE_intern:=nil;
  745. SEE_intern_and_free:=nil;
  746. SEE_intern_ascii:=nil;
  747. SEE_intern_global:=nil;
  748. SEE_interpreter_init:=nil;
  749. SEE_interpreter_init_compat:=nil;
  750. SEE_interpreter_save_state:=nil;
  751. SEE_interpreter_restore_state:=nil;
  752. SEE_context_eval:=nil;
  753. SEE_malloc:=nil;
  754. SEE_malloc_string:=nil;
  755. SEE_malloc_finalize:=nil;
  756. SEE_free:=nil;
  757. SEE_gcollect:=nil;
  758. _SEE_malloc_debug:=nil;
  759. _SEE_malloc_string_debug:=nil;
  760. _SEE_malloc_finalize_debug:=nil;
  761. _SEE_free_debug:=nil;
  762. SEE_grow_to:=nil;
  763. _SEE_grow_to_debug:=nil;
  764. SEE_module_add:=nil;
  765. SEE_no_get:=nil;
  766. SEE_no_put:=nil;
  767. SEE_no_canput:=nil;
  768. SEE_no_hasproperty:=nil;
  769. SEE_no_delete:=nil;
  770. SEE_no_defaultvalue:=nil;
  771. SEE_no_enumerator:=nil;
  772. SEE_string_addch:=nil;
  773. SEE_string_append:=nil;
  774. SEE_string_append_ascii:=nil;
  775. SEE_string_append_int:=nil;
  776. SEE_string_append_unicode:=nil;
  777. SEE_string_fputs:=nil;
  778. SEE_string_cmp:=nil;
  779. SEE_string_cmp_ascii:=nil;
  780. SEE_string_new:=nil;
  781. SEE_string_dup:=nil;
  782. SEE_string_substr:=nil;
  783. SEE_string_concat:=nil;
  784. SEE_string_sprintf:=nil;
  785. SEE_string_sprintf:=nil;
  786. SEE_string_literal:=nil;
  787. SEE_string_fix:=nil;
  788. SEE_string_free:=nil;
  789. SEE_string_toutf8:=nil;
  790. SEE_string_utf8_size:=nil;
  791. _SEE_string_dup_fix:=nil;
  792. SEE_init:=nil;
  793. SEE_regex_engine_list:=nil;
  794. SEE_regex_engine:=nil;
  795. SEE_throw_abort:=nil;
  796. SEE_location_string:=nil;
  797. SEE_throw:=nil;
  798. SEE_version:=nil;
  799. end;
  800. Function LibseeLoaded : Boolean;
  801. begin
  802. Result:=hlib<>nilhandle;
  803. end;
  804. procedure Loadlibsee(Const Alib : string);
  805. begin
  806. Freelibsee;
  807. hlib:=LoadLibrary(PAnsiChar(Alib));
  808. if hlib=0 then
  809. raise Exception.Create(format('Could not load library: %s',[Alib]));
  810. pointer(_SEE_isnan):=GetProcAddress(hlib,'_SEE_isnan');
  811. pointer(_SEE_isfinite):=GetProcAddress(hlib,'_SEE_isfinite');
  812. pointer(_SEE_copysign):=GetProcAddress(hlib,'_SEE_copysign');
  813. pointer(_SEE_ispinf):=GetProcAddress(hlib,'_SEE_ispinf');
  814. pointer(_SEE_isninf):=GetProcAddress(hlib,'_SEE_isninf');
  815. pointer(SEE_ToPrimitive):=GetProcAddress(hlib,'SEE_ToPrimitive');
  816. pointer(SEE_ToBoolean):=GetProcAddress(hlib,'SEE_ToBoolean');
  817. pointer(SEE_ToNumber):=GetProcAddress(hlib,'SEE_ToNumber');
  818. pointer(SEE_ToInteger):=GetProcAddress(hlib,'SEE_ToInteger');
  819. pointer(SEE_ToString):=GetProcAddress(hlib,'SEE_ToString');
  820. pointer(SEE_ToObject):=GetProcAddress(hlib,'SEE_ToObject');
  821. pointer(SEE_ToInt32):=GetProcAddress(hlib,'SEE_ToInt32');
  822. pointer(SEE_ToUint32):=GetProcAddress(hlib,'SEE_ToUint32');
  823. pointer(SEE_ToUint16):=GetProcAddress(hlib,'SEE_ToUint16');
  824. pointer(_SEE_intern_assert):=GetProcAddress(hlib,'_SEE_intern_assert');
  825. pointer(SEE_intern_ascii):=GetProcAddress(hlib,'SEE_intern_ascii');
  826. pointer(SEE_function_is_joined):=GetProcAddress(hlib,'SEE_function_is_joined');
  827. pointer(SEE_Object_new):=GetProcAddress(hlib,'SEE_Object_new');
  828. pointer(SEE_object_call):=GetProcAddress(hlib,'SEE_object_call');
  829. pointer(SEE_object_construct):=GetProcAddress(hlib,'SEE_object_construct');
  830. pointer(SEE_object_instanceof):=GetProcAddress(hlib,'SEE_object_instanceof');
  831. pointer(SEE_native_get):=GetProcAddress(hlib,'SEE_native_get');
  832. pointer(SEE_native_put):=GetProcAddress(hlib,'SEE_native_put');
  833. pointer(SEE_native_canput):=GetProcAddress(hlib,'SEE_native_canput');
  834. pointer(SEE_native_hasproperty):=GetProcAddress(hlib,'SEE_native_hasproperty');
  835. pointer(SEE_native_hasownproperty):=GetProcAddress(hlib,'SEE_native_hasownproperty');
  836. pointer(SEE_native_getownattr):=GetProcAddress(hlib,'SEE_native_getownattr');
  837. pointer(SEE_native_delete):=GetProcAddress(hlib,'SEE_native_delete');
  838. pointer(SEE_native_defaultvalue):=GetProcAddress(hlib,'SEE_native_defaultvalue');
  839. pointer(SEE_native_enumerator):=GetProcAddress(hlib,'SEE_native_enumerator');
  840. pointer(SEE_native_new):=GetProcAddress(hlib,'SEE_native_new');
  841. pointer(SEE_native_init):=GetProcAddress(hlib,'SEE_native_init');
  842. pointer(SEE_cfunction_make):=GetProcAddress(hlib,'SEE_cfunction_make');
  843. pointer(SEE_parse_args):=GetProcAddress(hlib,'SEE_parse_args');
  844. pointer(SEE_parse_args):=GetProcAddress(hlib,'SEE_parse_args');
  845. pointer(SEE_call_args):=GetProcAddress(hlib,'SEE_call_args');
  846. pointer(SEE_call_args):=GetProcAddress(hlib,'SEE_call_args');
  847. pointer(SEE_PrintValue):=GetProcAddress(hlib,'SEE_PrintValue');
  848. pointer(SEE_PrintObject):=GetProcAddress(hlib,'SEE_PrintObject');
  849. pointer(SEE_PrintString):=GetProcAddress(hlib,'SEE_PrintString');
  850. pointer(SEE_PrintTraceback):=GetProcAddress(hlib,'SEE_PrintTraceback');
  851. pointer(SEE_PrintContextTraceback):=GetProcAddress(hlib,'SEE_PrintContextTraceback');
  852. pointer(SEE_Global_eval):=GetProcAddress(hlib,'SEE_Global_eval');
  853. pointer(SEE_eval):=GetProcAddress(hlib,'SEE_eval');
  854. pointer(SEE_Function_new):=GetProcAddress(hlib,'SEE_Function_new');
  855. pointer(SEE_error__throw_string):=GetProcAddress(hlib,'SEE_error__throw_string');
  856. pointer(SEE_error__throw):=GetProcAddress(hlib,'SEE_error__throw');
  857. pointer(SEE_error__throw):=GetProcAddress(hlib,'SEE_error__throw');
  858. pointer(SEE_error__throw_sys):=GetProcAddress(hlib,'SEE_error__throw_sys');
  859. pointer(SEE_error__throw_sys):=GetProcAddress(hlib,'SEE_error__throw_sys');
  860. pointer(SEE_Error_make):=GetProcAddress(hlib,'SEE_Error_make');
  861. pointer(SEE_error__throw0):=GetProcAddress(hlib,'SEE_error__throw0');
  862. pointer(SEE_error__throw0):=GetProcAddress(hlib,'SEE_error__throw0');
  863. pointer(SEE_error__throw_sys0):=GetProcAddress(hlib,'SEE_error__throw_sys0');
  864. pointer(SEE_error__throw_sys0):=GetProcAddress(hlib,'SEE_error__throw_sys0');
  865. pointer(SEE_input_file):=GetProcAddress(hlib,'SEE_input_file');
  866. pointer(SEE_input_string):=GetProcAddress(hlib,'SEE_input_string');
  867. pointer(SEE_input_utf8):=GetProcAddress(hlib,'SEE_input_utf8');
  868. pointer(SEE_input_lookahead):=GetProcAddress(hlib,'SEE_input_lookahead');
  869. pointer(SEE_input_lookahead_copy):=GetProcAddress(hlib,'SEE_input_lookahead_copy');
  870. pointer(_SEE_intern_init):=GetProcAddress(hlib,'_SEE_intern_init');
  871. pointer(SEE_intern):=GetProcAddress(hlib,'SEE_intern');
  872. pointer(SEE_intern_and_free):=GetProcAddress(hlib,'SEE_intern_and_free');
  873. pointer(SEE_intern_ascii):=GetProcAddress(hlib,'SEE_intern_ascii');
  874. pointer(SEE_intern_global):=GetProcAddress(hlib,'SEE_intern_global');
  875. pointer(SEE_interpreter_init):=GetProcAddress(hlib,'SEE_interpreter_init');
  876. pointer(SEE_interpreter_init_compat):=GetProcAddress(hlib,'SEE_interpreter_init_compat');
  877. pointer(SEE_interpreter_save_state):=GetProcAddress(hlib,'SEE_interpreter_save_state');
  878. pointer(SEE_interpreter_restore_state):=GetProcAddress(hlib,'SEE_interpreter_restore_state');
  879. pointer(SEE_context_eval):=GetProcAddress(hlib,'SEE_context_eval');
  880. pointer(SEE_malloc):=GetProcAddress(hlib,'SEE_malloc');
  881. pointer(SEE_malloc_string):=GetProcAddress(hlib,'SEE_malloc_string');
  882. pointer(SEE_malloc_finalize):=GetProcAddress(hlib,'SEE_malloc_finalize');
  883. pointer(SEE_free):=GetProcAddress(hlib,'SEE_free');
  884. pointer(SEE_gcollect):=GetProcAddress(hlib,'SEE_gcollect');
  885. pointer(_SEE_malloc_debug):=GetProcAddress(hlib,'_SEE_malloc_debug');
  886. pointer(_SEE_malloc_string_debug):=GetProcAddress(hlib,'_SEE_malloc_string_debug');
  887. pointer(_SEE_malloc_finalize_debug):=GetProcAddress(hlib,'_SEE_malloc_finalize_debug');
  888. pointer(_SEE_free_debug):=GetProcAddress(hlib,'_SEE_free_debug');
  889. pointer(SEE_grow_to):=GetProcAddress(hlib,'SEE_grow_to');
  890. pointer(_SEE_grow_to_debug):=GetProcAddress(hlib,'_SEE_grow_to_debug');
  891. pointer(SEE_module_add):=GetProcAddress(hlib,'SEE_module_add');
  892. pointer(SEE_no_get):=GetProcAddress(hlib,'SEE_no_get');
  893. pointer(SEE_no_put):=GetProcAddress(hlib,'SEE_no_put');
  894. pointer(SEE_no_canput):=GetProcAddress(hlib,'SEE_no_canput');
  895. pointer(SEE_no_hasproperty):=GetProcAddress(hlib,'SEE_no_hasproperty');
  896. pointer(SEE_no_delete):=GetProcAddress(hlib,'SEE_no_delete');
  897. pointer(SEE_no_defaultvalue):=GetProcAddress(hlib,'SEE_no_defaultvalue');
  898. pointer(SEE_no_enumerator):=GetProcAddress(hlib,'SEE_no_enumerator');
  899. pointer(SEE_string_addch):=GetProcAddress(hlib,'SEE_string_addch');
  900. pointer(SEE_string_append):=GetProcAddress(hlib,'SEE_string_append');
  901. pointer(SEE_string_append_ascii):=GetProcAddress(hlib,'SEE_string_append_ascii');
  902. pointer(SEE_string_append_int):=GetProcAddress(hlib,'SEE_string_append_int');
  903. pointer(SEE_string_append_unicode):=GetProcAddress(hlib,'SEE_string_append_unicode');
  904. pointer(SEE_string_fputs):=GetProcAddress(hlib,'SEE_string_fputs');
  905. pointer(SEE_string_cmp):=GetProcAddress(hlib,'SEE_string_cmp');
  906. pointer(SEE_string_cmp_ascii):=GetProcAddress(hlib,'SEE_string_cmp_ascii');
  907. pointer(SEE_string_new):=GetProcAddress(hlib,'SEE_string_new');
  908. pointer(SEE_string_dup):=GetProcAddress(hlib,'SEE_string_dup');
  909. pointer(SEE_string_substr):=GetProcAddress(hlib,'SEE_string_substr');
  910. pointer(SEE_string_concat):=GetProcAddress(hlib,'SEE_string_concat');
  911. pointer(SEE_string_sprintf):=GetProcAddress(hlib,'SEE_string_sprintf');
  912. pointer(SEE_string_sprintf):=GetProcAddress(hlib,'SEE_string_sprintf');
  913. pointer(SEE_string_literal):=GetProcAddress(hlib,'SEE_string_literal');
  914. pointer(SEE_string_fix):=GetProcAddress(hlib,'SEE_string_fix');
  915. pointer(SEE_string_free):=GetProcAddress(hlib,'SEE_string_free');
  916. pointer(SEE_string_toutf8):=GetProcAddress(hlib,'SEE_string_toutf8');
  917. pointer(SEE_string_utf8_size):=GetProcAddress(hlib,'SEE_string_utf8_size');
  918. pointer(_SEE_string_dup_fix):=GetProcAddress(hlib,'_SEE_string_dup_fix');
  919. pointer(SEE_init):=GetProcAddress(hlib,'SEE_init');
  920. pointer(SEE_regex_engine_list):=GetProcAddress(hlib,'SEE_regex_engine_list');
  921. pointer(SEE_regex_engine):=GetProcAddress(hlib,'SEE_regex_engine');
  922. pointer(SEE_throw_abort):=GetProcAddress(hlib,'SEE_throw_abort');
  923. pointer(SEE_location_string):=GetProcAddress(hlib,'SEE_location_string');
  924. pointer(SEE_throw):=GetProcAddress(hlib,'SEE_throw');
  925. pointer(SEE_version):=GetProcAddress(hlib,'SEE_version');
  926. end;
  927. initialization
  928. try
  929. Loadlibsee(LibSeeLibraryName);
  930. except
  931. // Ignore errors.
  932. end;
  933. finalization
  934. Freelibsee;
  935. end.