[geary/wip/728002-webkit2: 33/46] Enable accessing javascriptcore objects from web extensions.
- From: Michael Gratton <mjog src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [geary/wip/728002-webkit2: 33/46] Enable accessing javascriptcore objects from web extensions.
- Date: Thu, 1 Dec 2016 23:41:41 +0000 (UTC)
commit 823c571959789e9d3a71e7769cb48d4ed6a953f8
Author: Michael James Gratton <mike vee net>
Date: Fri Nov 25 16:19:47 2016 +1100
Enable accessing javascriptcore objects from web extensions.
* src/CMakeLists.txt: Also generate a custom Also generate a custom
webkit2gtk-web-extension-4.0 VAPI that re-includes javascriptcore
objects, so they can be access from the web extension.
* bindings/metadata/WebKit2WebExtension-4.0-custom.vala,
bindings/metadata/WebKit2WebExtension-4.0.metadata: Include in-tree
metadata for web extension VAPI, update to all access to JS obejcts.
* bindings/vapi/javascriptcore-4.0.vapi: Add a bunch of useful additional
objects and method.
.../metadata/WebKit2WebExtension-4.0-custom.vala | 5 ++
bindings/metadata/WebKit2WebExtension-4.0.metadata | 9 +++
bindings/vapi/javascriptcore-4.0.vapi | 53 +++++++++++++++++++-
src/CMakeLists.txt | 19 +++++++-
4 files changed, 84 insertions(+), 2 deletions(-)
---
diff --git a/bindings/metadata/WebKit2WebExtension-4.0-custom.vala
b/bindings/metadata/WebKit2WebExtension-4.0-custom.vala
new file mode 100644
index 0000000..a994a77
--- /dev/null
+++ b/bindings/metadata/WebKit2WebExtension-4.0-custom.vala
@@ -0,0 +1,5 @@
+namespace WebKit {
+ namespace DOM {
+ public delegate void EventTargetFunc (WebKit.DOM.EventTarget target, WebKit.DOM.Event event);
+ }
+}
diff --git a/bindings/metadata/WebKit2WebExtension-4.0.metadata
b/bindings/metadata/WebKit2WebExtension-4.0.metadata
new file mode 100644
index 0000000..c496dba
--- /dev/null
+++ b/bindings/metadata/WebKit2WebExtension-4.0.metadata
@@ -0,0 +1,9 @@
+DOM* parent="WebKit.DOM" name="DOM(.+)"
+
+DOMEventTarget.add_event_listener skip
+_ContextMenu skip
+_ContextMenuItem skip
+
+Frame.get_javascript_* nullable=false unowned=true
+
+DOMEventTarget.add_event_listener_with_closure.handler type="owned WebKit.DOM.EventTargetFunc"
diff --git a/bindings/vapi/javascriptcore-4.0.vapi b/bindings/vapi/javascriptcore-4.0.vapi
index fd64630..027d781 100644
--- a/bindings/vapi/javascriptcore-4.0.vapi
+++ b/bindings/vapi/javascriptcore-4.0.vapi
@@ -5,18 +5,69 @@ namespace JS {
[CCode (cname = "JSGlobalContextRef")]
[SimpleType]
- public struct GlobalContext {
+ public struct GlobalContext : Context {
+
+ [CCode (cname = "JSValueIsBoolean")]
+ public bool is_boolean(JS.Value value);
[CCode (cname = "JSValueIsNumber")]
public bool is_number(JS.Value value);
+ [CCode (cname = "JSValueToBoolean")]
+ public bool to_boolean(JS.Value value);
+
[CCode (cname = "JSValueToNumber")]
public double to_number(JS.Value value, out JS.Value exception);
+ [CCode (cname = "JSGlobalContextRelease")]
+ public bool release();
+ }
+
+ [CCode (cname = "JSContextRef")]
+ [SimpleType]
+ public struct Context {
+
+ [CCode (cname = "JSEvaluateScript")]
+ public Value evaluate_script(String script,
+ Object? thisObject,
+ String? sourceURL,
+ int startingLineNumber,
+ out Value? exception);
+
+ [CCode (cname = "JSObjectMakeFunction")]
+ public Object make_function(String? name,
+ [CCode (array_length_pos=1.5)]
+ String[]? parameterNames,
+ String body,
+ String? sourceURL,
+ int startingLineNumber,
+ out Value? exception);
+
+ [CCode (cname = "JSObjectCallAsFunction")]
+ public Value call_as_function(Object object,
+ Object? thisObject,
+ [CCode (array_length_pos=2.5)]
+ Value[]? arguments,
+ out Value? exception);
+
+ }
+
+ [CCode (cname = "JSObjectRef")]
+ [SimpleType]
+ public struct Object {
}
[CCode (cname = "JSValueRef")]
[SimpleType]
public struct Value {
}
+
+ [CCode (cname = "JSStringRef", ref_function = "JSStringRetain", unref_function = "JSStringRelease")]
+ [SimpleType]
+ public struct String {
+
+ [CCode (cname = "JSStringCreateWithUTF8CString")]
+ public String.create_with_utf8_cstring(string str);
+
+ }
}
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index eecee92..ae68c2c 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -530,8 +530,9 @@ set(CLIENT_PACKAGES
gcr-3 enchant ${EXTRA_CLIENT_PACKAGES}
)
+# webkit2gtk-web-extension-4.0 is included as custom VAPI below
set(WEB_PROCESS_PACKAGES
- gtk+-3.0 gee-0.8 webkit2gtk-web-extension-4.0
+ gtk+-3.0 gee-0.8 javascriptcore-4.0 libsoup-2.4
)
set(CONSOLE_PACKAGES
@@ -634,6 +635,21 @@ add_custom_command(
vapigen --library=webkit2gtk-4.0 --pkg gtk+-3.0 --pkg libsoup-2.4 --pkg javascriptcore-4.0
--vapidir=${CMAKE_SOURCE_DIR}/bindings/vapi --metadatadir=${CMAKE_SOURCE_DIR}/bindings/metadata
--directory=${CMAKE_BINARY_DIR}/src `${PKG_CONFIG_EXECUTABLE} --variable=girdir
gobject-introspection-1.0`/WebKit2-4.0.gir
)
+# WebKit2GTK Web Extension VAPI generation
+#################################################
+add_custom_command(
+ OUTPUT
+ ${CMAKE_BINARY_DIR}/src/webkit2gtk-web-extension-4.0.vapi
+ DEPENDS
+ ${CMAKE_SOURCE_DIR}/bindings/metadata/WebKit2WebExtension-4.0.metadata
+ ${CMAKE_SOURCE_DIR}/bindings/metadata/WebKit2WebExtension-4.0-custom.vala
+ ${CMAKE_SOURCE_DIR}/bindings/vapi/javascriptcore-4.0.vapi
+ WORKING_DIRECTORY
+ ${CMAKE_SOURCE_DIR}/bindings/metadata
+ COMMAND
+ vapigen --library=webkit2gtk-web-extension-4.0 --pkg gtk+-3.0 --pkg libsoup-2.4 --pkg
javascriptcore-4.0 --vapidir=${CMAKE_SOURCE_DIR}/bindings/vapi
--metadatadir=${CMAKE_SOURCE_DIR}/bindings/metadata --directory=${CMAKE_BINARY_DIR}/src
`${PKG_CONFIG_EXECUTABLE} --variable=girdir gobject-introspection-1.0`/WebKit2WebExtension-4.0.gir
WebKit2WebExtension-4.0-custom.vala
+)
+
# Geary client app
#################################################
set_property(SOURCE ${RESOURCES_C} PROPERTY GENERATED TRUE)
@@ -678,6 +694,7 @@ PACKAGES
${ENGINE_PACKAGES} ## XXX REMOVE ME
CUSTOM_VAPIS
"${CMAKE_BINARY_DIR}/src/geary-static.vapi"
+ "${CMAKE_BINARY_DIR}/src/webkit2gtk-web-extension-4.0.vapi"
OPTIONS
${VALAC_OPTIONS}
)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]