1 module webkit2.JavascriptResult; 2 3 private import gobject.ObjectG; 4 private import javascriptcore.Value; 5 private import webkit2.c.functions; 6 public import webkit2.c.types; 7 8 9 /** */ 10 public class JavascriptResult 11 { 12 /** the main Gtk struct */ 13 protected WebKitJavascriptResult* webKitJavascriptResult; 14 protected bool ownedRef; 15 16 /** Get the main Gtk struct */ 17 public WebKitJavascriptResult* getJavascriptResultStruct(bool transferOwnership = false) 18 { 19 if (transferOwnership) 20 ownedRef = false; 21 return webKitJavascriptResult; 22 } 23 24 /** the main Gtk struct as a void* */ 25 protected void* getStruct() 26 { 27 return cast(void*)webKitJavascriptResult; 28 } 29 30 /** 31 * Sets our main struct and passes it to the parent class. 32 */ 33 public this (WebKitJavascriptResult* webKitJavascriptResult, bool ownedRef = false) 34 { 35 this.webKitJavascriptResult = webKitJavascriptResult; 36 this.ownedRef = ownedRef; 37 } 38 39 ~this () 40 { 41 if ( ownedRef ) 42 webkit_javascript_result_unref(webKitJavascriptResult); 43 } 44 45 46 /** */ 47 public static GType getType() 48 { 49 return webkit_javascript_result_get_type(); 50 } 51 52 /** 53 * Get the global Javascript context that should be used with the 54 * <function>JSValueRef</function> returned by webkit_javascript_result_get_value(). 55 * 56 * Deprecated: Use jsc_value_get_context() instead. 57 * 58 * Returns: the <function>JSGlobalContextRef</function> for the #WebKitJavascriptResult 59 */ 60 public JSGlobalContextRef getGlobalContext() 61 { 62 return webkit_javascript_result_get_global_context(webKitJavascriptResult); 63 } 64 65 /** 66 * Get the #JSCValue of @js_result. 67 * 68 * Returns: the #JSCValue of the #WebKitJavascriptResult 69 * 70 * Since: 2.22 71 */ 72 public Value getJsValue() 73 { 74 auto __p = webkit_javascript_result_get_js_value(webKitJavascriptResult); 75 76 if(__p is null) 77 { 78 return null; 79 } 80 81 return ObjectG.getDObject!(Value)(cast(JSCValue*) __p); 82 } 83 84 /** 85 * Get the value of @js_result. You should use the <function>JSGlobalContextRef</function> 86 * returned by webkit_javascript_result_get_global_context() to use the <function>JSValueRef</function>. 87 * 88 * Deprecated: Use webkit_javascript_result_get_js_value() instead. 89 * 90 * Returns: the <function>JSValueRef</function> of the #WebKitJavascriptResult 91 */ 92 public JSValueRef getValue() 93 { 94 return webkit_javascript_result_get_value(webKitJavascriptResult); 95 } 96 97 alias doref = ref_; 98 /** 99 * Atomically increments the reference count of @js_result by one. This 100 * function is MT-safe and may be called from any thread. 101 * 102 * Returns: The passed in #WebKitJavascriptResult 103 */ 104 public JavascriptResult ref_() 105 { 106 auto __p = webkit_javascript_result_ref(webKitJavascriptResult); 107 108 if(__p is null) 109 { 110 return null; 111 } 112 113 return ObjectG.getDObject!(JavascriptResult)(cast(WebKitJavascriptResult*) __p, true); 114 } 115 116 /** 117 * Atomically decrements the reference count of @js_result by one. If the 118 * reference count drops to 0, all memory allocated by the #WebKitJavascriptResult is 119 * released. This function is MT-safe and may be called from any 120 * thread. 121 */ 122 public void unref() 123 { 124 webkit_javascript_result_unref(webKitJavascriptResult); 125 } 126 }