diff --git a/cxx/ffi.h b/cxx/ffi.h index 90d6ca6..d2b59ce 100644 --- a/cxx/ffi.h +++ b/cxx/ffi.h @@ -9,104 +9,103 @@ extern "C" { -typedef void *JSChannel(JSContext *ctx, const char *method, void *argv); + typedef void *JSChannel(JSContext *ctx, const char *method, void *argv); -JSValue *jsThrowInternalError(JSContext *ctx, char *message); + DLLEXPORT JSValue *jsThrowInternalError(JSContext *ctx, char *message); -JSValue *jsEXCEPTION(); + DLLEXPORT JSValue *jsEXCEPTION(); -JSValue *jsUNDEFINED(); + DLLEXPORT JSValue *jsUNDEFINED(); -JSValue *jsNULL(); + DLLEXPORT JSValue *jsNULL(); -JSRuntime *jsNewRuntime(JSChannel channel); + DLLEXPORT JSRuntime *jsNewRuntime(JSChannel channel); -void jsFreeRuntime(JSRuntime *rt); + DLLEXPORT void jsFreeRuntime(JSRuntime *rt); -JSContext *jsNewContext(JSRuntime *rt); + DLLEXPORT JSContext *jsNewContext(JSRuntime *rt); -void jsFreeContext(JSContext *ctx); + DLLEXPORT void jsFreeContext(JSContext *ctx); -JSRuntime *jsGetRuntime(JSContext *ctx); + DLLEXPORT JSRuntime *jsGetRuntime(JSContext *ctx); -JSValue *jsEval(JSContext *ctx, const char *input, size_t input_len, const char *filename, int32_t eval_flags); + DLLEXPORT JSValue *jsEval(JSContext *ctx, const char *input, size_t input_len, const char *filename, int32_t eval_flags); -int32_t jsValueGetTag(JSValue *val); + DLLEXPORT int32_t jsValueGetTag(JSValue *val); -void *jsValueGetPtr(JSValue *val); + DLLEXPORT void *jsValueGetPtr(JSValue *val); -int32_t jsTagIsFloat64(int32_t tag); + DLLEXPORT int32_t jsTagIsFloat64(int32_t tag); -JSValue *jsNewBool(JSContext *ctx, int32_t val); + DLLEXPORT JSValue *jsNewBool(JSContext *ctx, int32_t val); -JSValue *jsNewInt64(JSContext *ctx, int64_t val); + DLLEXPORT JSValue *jsNewInt64(JSContext *ctx, int64_t val); -JSValue *jsNewFloat64(JSContext *ctx, double val); + DLLEXPORT JSValue *jsNewFloat64(JSContext *ctx, double val); -JSValue *jsNewString(JSContext *ctx, const char *str); + DLLEXPORT JSValue *jsNewString(JSContext *ctx, const char *str); -JSValue *jsNewArrayBufferCopy(JSContext *ctx, const uint8_t *buf, size_t len); + DLLEXPORT JSValue *jsNewArrayBufferCopy(JSContext *ctx, const uint8_t *buf, size_t len); -JSValue *jsNewArray(JSContext *ctx); + DLLEXPORT JSValue *jsNewArray(JSContext *ctx); -JSValue *jsNewObject(JSContext *ctx); + DLLEXPORT JSValue *jsNewObject(JSContext *ctx); -void jsFreeValue(JSContext *ctx, JSValue *v); + DLLEXPORT void jsFreeValue(JSContext *ctx, JSValue *v); -void jsFreeValueRT(JSRuntime *rt, JSValue *v); + DLLEXPORT void jsFreeValueRT(JSRuntime *rt, JSValue *v); -JSValue *jsDupValue(JSContext *ctx, JSValueConst *v); + DLLEXPORT JSValue *jsDupValue(JSContext *ctx, JSValueConst *v); -JSValue *jsDupValueRT(JSRuntime *rt, JSValue *v); + DLLEXPORT JSValue *jsDupValueRT(JSRuntime *rt, JSValue *v); -int32_t jsToBool(JSContext *ctx, JSValueConst *val); + DLLEXPORT int32_t jsToBool(JSContext *ctx, JSValueConst *val); -int64_t jsToInt64(JSContext *ctx, JSValueConst *val); + DLLEXPORT int64_t jsToInt64(JSContext *ctx, JSValueConst *val); -double jsToFloat64(JSContext *ctx, JSValueConst *val); + DLLEXPORT double jsToFloat64(JSContext *ctx, JSValueConst *val); -const char *jsToCString(JSContext *ctx, JSValueConst *val); + DLLEXPORT const char *jsToCString(JSContext *ctx, JSValueConst *val); -void jsFreeCString(JSContext *ctx, const char *ptr); + DLLEXPORT void jsFreeCString(JSContext *ctx, const char *ptr); -uint8_t *jsGetArrayBuffer(JSContext *ctx, size_t *psize, JSValueConst *obj); + DLLEXPORT uint8_t *jsGetArrayBuffer(JSContext *ctx, size_t *psize, JSValueConst *obj); -int32_t jsIsFunction(JSContext *ctx, JSValueConst *val); + DLLEXPORT int32_t jsIsFunction(JSContext *ctx, JSValueConst *val); -int32_t jsIsArray(JSContext *ctx, JSValueConst *val); + DLLEXPORT int32_t jsIsArray(JSContext *ctx, JSValueConst *val); -void deleteJSValue(JSValueConst *val); + DLLEXPORT void deleteJSValue(JSValueConst *val); -JSValue *jsGetProperty(JSContext *ctx, JSValueConst *this_obj, + DLLEXPORT JSValue *jsGetProperty(JSContext *ctx, JSValueConst *this_obj, JSAtom prop); -int32_t jsDefinePropertyValue(JSContext *ctx, JSValueConst *this_obj, - JSAtom prop, JSValue *val, int32_t flags); + DLLEXPORT int32_t jsDefinePropertyValue(JSContext *ctx, JSValueConst *this_obj, + JSAtom prop, JSValue *val, int32_t flags); -void jsFreeAtom(JSContext *ctx, JSAtom v); + DLLEXPORT void jsFreeAtom(JSContext *ctx, JSAtom v); -JSAtom jsValueToAtom(JSContext *ctx, JSValueConst *val); + DLLEXPORT JSAtom jsValueToAtom(JSContext *ctx, JSValueConst *val); -JSValue *jsAtomToValue(JSContext *ctx, JSAtom val); + DLLEXPORT JSValue *jsAtomToValue(JSContext *ctx, JSAtom val); -int32_t jsGetOwnPropertyNames(JSContext *ctx, JSPropertyEnum **ptab, - uint32_t *plen, JSValueConst *obj, int32_t flags); + DLLEXPORT int32_t jsGetOwnPropertyNames(JSContext *ctx, JSPropertyEnum **ptab, + uint32_t *plen, JSValueConst *obj, int32_t flags); -JSAtom jsPropertyEnumGetAtom(JSPropertyEnum *ptab, int32_t i); + DLLEXPORT JSAtom jsPropertyEnumGetAtom(JSPropertyEnum *ptab, int32_t i); -uint32_t sizeOfJSValue(); + DLLEXPORT uint32_t sizeOfJSValue(); -void setJSValueList(JSValue *list, uint32_t i, JSValue *val); + DLLEXPORT void setJSValueList(JSValue *list, uint32_t i, JSValue *val); -JSValue *jsCall(JSContext *ctx, JSValueConst *func_obj, JSValueConst *this_obj, + DLLEXPORT JSValue *jsCall(JSContext *ctx, JSValueConst *func_obj, JSValueConst *this_obj, int32_t argc, JSValueConst *argv); -int32_t jsIsException(JSValueConst *val); + DLLEXPORT int32_t jsIsException(JSValueConst *val); -JSValue *jsGetException(JSContext *ctx); + DLLEXPORT JSValue *jsGetException(JSContext *ctx); -int32_t jsExecutePendingJob(JSRuntime *rt); - -JSValue *jsNewPromiseCapability(JSContext *ctx, JSValue *resolving_funcs); + DLLEXPORT int32_t jsExecutePendingJob(JSRuntime *rt); + DLLEXPORT JSValue *jsNewPromiseCapability(JSContext *ctx, JSValue *resolving_funcs); } \ No newline at end of file diff --git a/lib/wrapper.dart b/lib/wrapper.dart index 424d8c7..28142a2 100644 --- a/lib/wrapper.dart +++ b/lib/wrapper.dart @@ -3,14 +3,13 @@ * @Author: ekibun * @Date: 2020-09-19 22:07:47 * @LastEditors: ekibun - * @LastEditTime: 2020-09-22 00:27:54 + * @LastEditTime: 2020-09-24 13:38:08 */ import 'dart:async'; import 'dart:ffi'; import 'dart:typed_data'; import 'package:ffi/ffi.dart'; -import 'package:flutter/cupertino.dart'; import 'ffi.dart';