-
Notifications
You must be signed in to change notification settings - Fork 0
/
jx.lisp
120 lines (68 loc) · 3.63 KB
/
jx.lisp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
(in-package :cl-node.jx)
(pushnew (first (directory #p"*/out/Release/"))
cffi:*foreign-library-directories*
:test #'equal)
(cffi:define-foreign-library libjx
(:unix (:or "libjx.so")))
(cffi:defctype size :unsigned-long)
(cffi:defctype bool :char)
(cffi:defcenum jx-type
(:rt-int32 1)
:rt-double
:rt-boolean
:rt-string
:rt-object
:rt-buffer
:rt-undefined
:rt-null
:rt-error
:rt-function)
(cffi:defcstruct (jx-value :class jx-value-type)
(com :pointer)
(persistant bool)
(was-stored bool)
(data :pointer)
(size size)
(type :int))
(cffi:use-foreign-library libjx)
;; JX_Initialize depricated in favor of JX_InitializeOnce
(cffi:defcfun ("JX_Initialize" initialize) :void (home-folder :string) (callback :pointer))
(cffi:defcfun ("JX_InitializeOnce" initialize-once) :void (home-folder :string))
(cffi:defcfun ("JX_InitializeNewEngine" initialize-new-engine) :void)
(cffi:defcfun ("JX_DefineMainFile" define-main-file) :void (data :string))
(cffi:defcfun ("JX_DefineExtension" define-extension) :void (name :string) (callback :pointer))
(cffi:defcfun ("JX_StartEngine" start-engine) :void)
(cffi:defcfun ("JX_LoopOnce" loop-once) :int)
(cffi:defcfun ("JX_Evaluate" evaluate) :boolean (script-code :string) (script-name :string) (result :pointer))
(cffi:defcfun ("JX_Free" free) :void (value :pointer))
(cffi:defcfun ("JX_StopEngine" stop-engine) :void)
(cffi:defcfun ("JX_IsV8" is-v8) :boolean)
(cffi:defcfun ("JX_IsNull" is-null) :boolean (result :pointer))
(cffi:defcfun ("JX_IsUndefined" is-undefined) :boolean (result :pointer))
(cffi:defcfun ("JX_IsNullOrUndefined" is-null-or-undefined):boolean (result :pointer))
(cffi:defcfun ("JX_IsBoolean" is-boolean) :boolean (result :pointer))
(cffi:defcfun ("JX_IsInt32" is-int32) :boolean (result :pointer))
(cffi:defcfun ("JX_IsDouble" is-double) :boolean (result :pointer))
(cffi:defcfun ("JX_IsBuffer" is-buffer) :boolean (result :pointer))
(cffi:defcfun ("JX_IsObject" is-object) :boolean (result :pointer))
(cffi:defcfun ("JX_IsString" is-string) :boolean (result :pointer))
(cffi:defcfun ("JX_IsError" is-error) :boolean (result :pointer))
(cffi:defcfun ("JX_IsFunction" is-function) :boolean (result :pointer))
(cffi:defcfun ("JX_GetBoolean" get-boolean) :boolean (result :pointer))
(cffi:defcfun ("JX_GetInt32" get-int32) :int32 (result :pointer))
(cffi:defcfun ("JX_GetDouble" get-double) :double (result :pointer))
(cffi:defcfun ("JX_GetString" get-string) :string (result :pointer))
(cffi:defcfun ("JX_CallFunction" call-function) :void (fnc :pointer) (params :pointer) (argc :int) (out :pointer))
(cffi:defcfun ("JX_MakePersistent" make-persistent) :boolean (value :pointer))
(cffi:defcfun ("JX_ClearPersistent" clear-persistent) :boolean (value :pointer))
(cffi:defcfun ("JX_New" new) :boolean (value :pointer))
(cffi:defcfun ("JX_SetBoolean" set-boolean) :void (value :pointer) (val :boolean))
(cffi:defcfun ("JX_SetInt32" set-int32) :void (value :pointer) (val :int32))
(cffi:defcfun ("JX_SetDouble" set-double) :void (value :pointer) (val :double))
(cffi:defcfun ("JX_SetString" set-string) :void (value :pointer) (val :string) (len :int))
(cffi:defcfun ("JX_SetNull" set-null) :void (value :pointer))
(cffi:defcfun ("JX_SetUndefined" set-undefined) :void (value :pointer))
(cffi:defcfun ("JX_SetNativeMethod" set-native-method) :void (host :pointer) (name :string) (method :pointer))
(cffi:defcfun ("JX_CreateEmptyObject" create-empty-object) :bool (value :pointer))
(cffi:defcfun ("JX_SetNamedProperty" set-named-property) :void (host :pointer) (name :string) (value :pointer))
(cffi:defcfun ("JX_GetGlobalObject" get-global-object) :void (out :pointer))