@@ -34,6 +34,8 @@ type callSafeAsyncWork struct {
3434 function string
3535 args []interface {}
3636 ret chan callReturnSafeWork
37+ resolve func (unsafe.Pointer , unsafe.Pointer )
38+ reject func (unsafe.Pointer , unsafe.Pointer )
3739}
3840
3941const PtrSizeInBytes = (32 << uintptr (^ uintptr (0 )>> 63 )) >> 3
@@ -97,7 +99,7 @@ func Initialize() error {
9799 }
98100 case callSafeAsyncWork :
99101 {
100- value , err := CallAwaitUnsafe (v .function , v .args ... )
102+ value , err := CallAwaitUnsafe (v .function , v .resolve , v . reject , v . args ... )
101103 v .ret <- callReturnSafeWork {value , err }
102104 }
103105 }
@@ -132,7 +134,7 @@ func LoadFromFileUnsafe(tag string, scripts []string) error {
132134 return nil
133135}
134136
135- func CallAwaitUnsafe (function string , args ... interface {}) (interface {}, error ) {
137+ func CallAwaitUnsafe (function string , ResolveCallback , RejectCallBack func (unsafe. Pointer , unsafe. Pointer ), args ... interface {}) (interface {}, error ) {
136138 cFunction := C .CString (function )
137139 defer C .free (unsafe .Pointer (cFunction ))
138140 cFunc := C .metacall_function (cFunction )
@@ -149,7 +151,9 @@ func CallAwaitUnsafe(function string, args ...interface{}) (interface{}, error)
149151 }
150152 })()
151153
152- ret := C .metacallfv_await (cFunc , (* unsafe .Pointer )(cArgs )) // todo
154+ var Context interface {} // undefined
155+
156+ ret := C .metacallfv_await (cFunc , (* unsafe .Pointer )(cArgs ), * unsafe .Pointer (& ResolveCallback ), * unsafe .Pointer (& RejectCallBack ), & Context )
153157
154158 if ret != nil {
155159 defer C .metacall_value_destroy (ret )
@@ -189,11 +193,13 @@ func CallUnsafe(function string, args ...interface{}) (interface{}, error) {
189193// Call sends work and blocks until it's processed
190194func Call (function string , args ... interface {}) (interface {}, error ) {
191195 ret := make (chan callReturnSafeWork , 1 )
196+
192197 w := callSafeWork {
193198 function : function ,
194199 args : args ,
195200 ret : ret ,
196201 }
202+
197203 wg .Add (1 )
198204 queue <- w
199205
@@ -205,11 +211,25 @@ func Call(function string, args ...interface{}) (interface{}, error) {
205211// Await sends asynchronous work and blocks until it's processed
206212func Await (function string , args ... interface {}) (interface {}, error ) {
207213 ret := make (chan callReturnSafeWork , 1 )
214+
215+ Resolve := func (pointer unsafe.Pointer , pointer2 unsafe.Pointer ) {
216+ // todo
217+
218+ }
219+
220+ Reject := func (pointer unsafe.Pointer , pointer2 unsafe.Pointer ) {
221+ // todo
222+
223+ }
224+
208225 w := callSafeAsyncWork {
209226 function : function ,
210227 args : args ,
211228 ret : ret ,
229+ resolve : Resolve ,
230+ reject : Reject ,
212231 }
232+
213233 wg .Add (1 )
214234 queue <- w
215235
0 commit comments