code cleanup

This commit is contained in:
ekibun
2020-08-18 08:28:07 +08:00
parent 9af3616965
commit d8bd5d7995
8 changed files with 9 additions and 210 deletions

2
.gitignore vendored
View File

@@ -5,3 +5,5 @@
.pub/
build/
.idea/
.vscode/settings.json

View File

@@ -1,19 +0,0 @@
<component name="libraryTable">
<library name="Dart SDK">
<CLASSES>
<root url="file://D:\flutter/bin/cache/dart-sdk/lib/async" />
<root url="file://D:\flutter/bin/cache/dart-sdk/lib/collection" />
<root url="file://D:\flutter/bin/cache/dart-sdk/lib/convert" />
<root url="file://D:\flutter/bin/cache/dart-sdk/lib/core" />
<root url="file://D:\flutter/bin/cache/dart-sdk/lib/developer" />
<root url="file://D:\flutter/bin/cache/dart-sdk/lib/html" />
<root url="file://D:\flutter/bin/cache/dart-sdk/lib/io" />
<root url="file://D:\flutter/bin/cache/dart-sdk/lib/isolate" />
<root url="file://D:\flutter/bin/cache/dart-sdk/lib/math" />
<root url="file://D:\flutter/bin/cache/dart-sdk/lib/mirrors" />
<root url="file://D:\flutter/bin/cache/dart-sdk/lib/typed_data" />
</CLASSES>
<JAVADOC />
<SOURCES />
</library>
</component>

10
.idea/modules.xml generated
View File

@@ -1,10 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectModuleManager">
<modules>
<module fileurl="file://$PROJECT_DIR$/flutter_qjs.iml" filepath="$PROJECT_DIR$/flutter_qjs.iml" />
<module fileurl="file://$PROJECT_DIR$/android/flutter_qjs_android.iml" filepath="$PROJECT_DIR$/android/flutter_qjs_android.iml" />
<module fileurl="file://$PROJECT_DIR$/example/android/flutter_qjs_example_android.iml" filepath="$PROJECT_DIR$/example/android/flutter_qjs_example_android.iml" />
</modules>
</component>
</project>

View File

@@ -1,6 +0,0 @@
<component name="ProjectRunConfigurationManager">
<configuration default="false" name="example/lib/main.dart" type="FlutterRunConfigurationType" factoryName="Flutter">
<option name="filePath" value="$PROJECT_DIR$/example/lib/main.dart" />
<method />
</configuration>
</component>

45
.idea/workspace.xml generated
View File

@@ -1,45 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="FileEditorManager">
<leaf>
<file leaf-file-name="flutter_qjs.dart" pinned="false" current-in-tab="true">
<entry file="file://$PROJECT_DIR$/lib/flutter_qjs.dart">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="0">
<caret line="0" column="0" lean-forward="false" selection-start-line="0" selection-start-column="0" selection-end-line="0" selection-end-column="0" />
</state>
</provider>
</entry>
</file>
<file leaf-file-name="main.dart" pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/example/lib/main.dart">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="0">
<caret line="0" column="0" lean-forward="false" selection-start-line="0" selection-start-column="0" selection-end-line="0" selection-end-column="0" />
</state>
</provider>
</entry>
</file>
</leaf>
</component>
<component name="ToolWindowManager">
<editor active="true" />
<layout>
<window_info id="Project" active="true" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="true" show_stripe_button="true" weight="0.25" sideWeight="0.5" order="0" side_tool="false" content_ui="combo" />
</layout>
</component>
<component name="ProjectView">
<navigator currentView="ProjectPane" proportions="" version="1">
</navigator>
<panes>
<pane id="ProjectPane">
<option name="show-excluded-files" value="false" />
</pane>
</panes>
</component>
<component name="PropertiesComponent">
<property name="last_opened_file_path" value="$PROJECT_DIR$" />
<property name="dart.analysis.tool.window.force.activate" value="true" />
<property name="show.migrate.to.gradle.popup" value="false" />
</component>
</project>

107
.vscode/settings.json vendored
View File

@@ -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"
}

Binary file not shown.

View File

@@ -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));