diff --git a/.gitignore b/.gitignore index e9dc58d..3df4733 100644 --- a/.gitignore +++ b/.gitignore @@ -5,3 +5,5 @@ .pub/ build/ +.idea/ +.vscode/settings.json diff --git a/.idea/libraries/Dart_SDK.xml b/.idea/libraries/Dart_SDK.xml deleted file mode 100644 index 70af93c..0000000 --- a/.idea/libraries/Dart_SDK.xml +++ /dev/null @@ -1,19 +0,0 @@ - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/.idea/modules.xml b/.idea/modules.xml deleted file mode 100644 index 4f16f99..0000000 --- a/.idea/modules.xml +++ /dev/null @@ -1,10 +0,0 @@ - - - - - - - - - - diff --git a/.idea/runConfigurations/example_lib_main_dart.xml b/.idea/runConfigurations/example_lib_main_dart.xml deleted file mode 100644 index 5fd9159..0000000 --- a/.idea/runConfigurations/example_lib_main_dart.xml +++ /dev/null @@ -1,6 +0,0 @@ - - - - \ No newline at end of file diff --git a/.idea/workspace.xml b/.idea/workspace.xml deleted file mode 100644 index e513d54..0000000 --- a/.idea/workspace.xml +++ /dev/null @@ -1,45 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/.vscode/settings.json b/.vscode/settings.json deleted file mode 100644 index bb163bf..0000000 --- a/.vscode/settings.json +++ /dev/null @@ -1,107 +0,0 @@ -{ - "files.associations": { - "algorithm": "cpp", - "atomic": "cpp", - "cctype": "cpp", - "chrono": "cpp", - "cmath": "cpp", - "concepts": "cpp", - "condition_variable": "cpp", - "cstddef": "cpp", - "cstdint": "cpp", - "cstdio": "cpp", - "cstdlib": "cpp", - "cstring": "cpp", - "cwchar": "cpp", - "deque": "cpp", - "exception": "cpp", - "resumable": "cpp", - "functional": "cpp", - "future": "cpp", - "initializer_list": "cpp", - "ios": "cpp", - "iosfwd": "cpp", - "iostream": "cpp", - "istream": "cpp", - "iterator": "cpp", - "limits": "cpp", - "list": "cpp", - "map": "cpp", - "memory": "cpp", - "mutex": "cpp", - "new": "cpp", - "ostream": "cpp", - "queue": "cpp", - "ratio": "cpp", - "set": "cpp", - "sstream": "cpp", - "stdexcept": "cpp", - "streambuf": "cpp", - "string": "cpp", - "system_error": "cpp", - "thread": "cpp", - "tuple": "cpp", - "type_traits": "cpp", - "typeinfo": "cpp", - "unordered_map": "cpp", - "utility": "cpp", - "vector": "cpp", - "xfacet": "cpp", - "xhash": "cpp", - "xiosbase": "cpp", - "xlocale": "cpp", - "xlocinfo": "cpp", - "xlocnum": "cpp", - "xmemory": "cpp", - "xstddef": "cpp", - "xstring": "cpp", - "xtr1common": "cpp", - "xtree": "cpp", - "xutility": "cpp", - "array": "cpp", - "bit": "cpp", - "bitset": "cpp", - "clocale": "cpp", - "cstdarg": "cpp", - "ctime": "cpp", - "cwctype": "cpp", - "fstream": "cpp", - "locale": "cpp", - "optional": "cpp", - "variant": "cpp", - "xlocbuf": "cpp", - "xlocmes": "cpp", - "xlocmon": "cpp", - "xloctime": "cpp", - "cerrno": "cpp", - "__bit_reference": "cpp", - "__config": "cpp", - "__debug": "cpp", - "__errc": "cpp", - "__functional_base": "cpp", - "__hash_table": "cpp", - "__locale": "cpp", - "__mutex_base": "cpp", - "__node_handle": "cpp", - "__nullptr": "cpp", - "__split_buffer": "cpp", - "__string": "cpp", - "__threading_support": "cpp", - "__tree": "cpp", - "__tuple": "cpp", - "complex": "cpp", - "iomanip": "cpp", - "string_view": "cpp", - "strstream": "cpp", - "*.tcc": "cpp", - "memory_resource": "cpp", - "numeric": "cpp", - "cfenv": "cpp", - "cinttypes": "cpp", - "typeindex": "cpp", - "__functional_03": "cpp", - "compare": "cpp", - "any": "cpp" - }, - "java.configuration.updateBuildConfiguration": "interactive" -} \ No newline at end of file diff --git a/cxx/libquickjs.so b/cxx/libquickjs.so deleted file mode 100755 index fb8ae9c..0000000 Binary files a/cxx/libquickjs.so and /dev/null differ diff --git a/linux/flutter_qjs_plugin.cc b/linux/flutter_qjs_plugin.cc index 6c6f5d3..7dc0422 100644 --- a/linux/flutter_qjs_plugin.cc +++ b/linux/flutter_qjs_plugin.cc @@ -3,7 +3,7 @@ * @Author: ekibun * @Date: 2020-08-17 21:37:11 * @LastEditors: ekibun - * @LastEditTime: 2020-08-18 00:57:10 + * @LastEditTime: 2020-08-18 08:23:56 */ #include "include/flutter_qjs/flutter_qjs_plugin.h" @@ -51,27 +51,11 @@ static void flutter_qjs_plugin_handle_method_call( else if (strcmp(method, "evaluate") == 0) { FlValue *args = fl_method_call_get_args(method_call); - qjs::Engine *engine = nullptr; - std::string script, name; - for (int i = 0; i < 3; ++i) - { - FlValue *key = fl_value_get_map_key(args, i); - const gchar *keychar = fl_value_to_string(key); - if (strcmp(keychar, "engine") == 0) - { - engine = (qjs::Engine *)fl_value_get_int(fl_value_get_map_value(args, i)); - } - if (strcmp(keychar, "script") == 0) - { - script = fl_value_get_string(fl_value_get_map_value(args, i)); - } - if (strcmp(keychar, "name") == 0) - { - name = fl_value_get_string(fl_value_get_map_value(args, i)); - } - } - auto pmethod_call = g_object_ref(method_call); + qjs::Engine *engine = (qjs::Engine *)fl_value_get_int(fl_value_lookup_string(args, "engine")); + std::string script(fl_value_get_string(fl_value_lookup_string(args, "script"))); + std::string name(fl_value_get_string(fl_value_lookup_string(args, "name"))); g_warning("engine %ld; script: %s; name: %s", (int64_t)engine, script.c_str(), name.c_str()); + auto pmethod_call = (FlMethodCall *)g_object_ref(method_call); engine->commit(qjs::EngineTask{ [script, name](qjs::Context &ctx) { return ctx.eval(script, name.c_str(), JS_EVAL_TYPE_GLOBAL); @@ -79,11 +63,11 @@ static void flutter_qjs_plugin_handle_method_call( [pmethod_call](qjs::Value resolve) { g_warning("%s", fl_value_to_string(qjs::jsToDart(resolve))); g_autoptr(FlMethodResponse) response = FL_METHOD_RESPONSE(fl_method_success_response_new(qjs::jsToDart(resolve))); - fl_method_call_respond((FlMethodCall *)pmethod_call, response, nullptr); + fl_method_call_respond(pmethod_call, response, nullptr); g_object_unref(pmethod_call); }, [pmethod_call](qjs::Value reject) { - fl_method_call_respond_error((FlMethodCall *)pmethod_call, "FlutterJSException", qjs::getStackTrack(reject).c_str(), nullptr, nullptr); + fl_method_call_respond_error(pmethod_call, "FlutterJSException", qjs::getStackTrack(reject).c_str(), nullptr, nullptr); g_object_unref(pmethod_call); }}); // g_autoptr(FlMethodResponse) response = FL_METHOD_RESPONSE(fl_method_success_response_new(args));