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.
This commit is contained in:
Michael James Gratton 2016-11-25 16:19:47 +11:00
parent 3a3b5d0bff
commit 8d13bf1922
4 changed files with 84 additions and 2 deletions

View file

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