gtk-webkit-ruby 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +33 -0
- data/Rakefile +58 -0
- data/ext/webkit/extconf.rb +74 -0
- data/ext/webkit/javascript.h +271 -0
- data/ext/webkit/webkit.c +630 -0
- data/ext/webkit/webkit.cr +160 -0
- data/ext/webkit/webkit.rd +89 -0
- metadata +102 -0
data/README.md
ADDED
@@ -0,0 +1,33 @@
|
|
1
|
+
Gtk Webkit Ruby
|
2
|
+
===============
|
3
|
+
|
4
|
+
Requires
|
5
|
+
--------
|
6
|
+
* rubber-generate >= 0.0.12
|
7
|
+
* ruby-gnome2 (including development files)
|
8
|
+
* webkit (including development files)
|
9
|
+
|
10
|
+
Description
|
11
|
+
-----------
|
12
|
+
|
13
|
+
Gtk Webkit bindings for ruby. Partial coverage sufficient to embed a webview in a ruby-gnome2 application.
|
14
|
+
|
15
|
+
Also initial/experimental support for allowing ruby code to be called by javascript & executing javascript from ruby.
|
16
|
+
|
17
|
+
e.g
|
18
|
+
|
19
|
+
require 'gtk2'
|
20
|
+
require 'webkit'
|
21
|
+
require 'digest/md5'
|
22
|
+
|
23
|
+
v = WebKit::WebView.new
|
24
|
+
v.main_frame.setup_ruby
|
25
|
+
|
26
|
+
v.main_frame.add_js_api('md5') do |what|
|
27
|
+
Digest::MD5.hexdigest(what)
|
28
|
+
end
|
29
|
+
|
30
|
+
puts v.main_frame.exec_js("ruby_eval('RUBY_DESCRIPTION')")
|
31
|
+
puts v.main_frame.exec_js("md5('foo')")
|
32
|
+
puts Digest::MD5.hexdigest('foo')
|
33
|
+
|
data/Rakefile
ADDED
@@ -0,0 +1,58 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
gem 'rake-compiler'
|
3
|
+
require 'rake/extensiontask'
|
4
|
+
BASE_DIR = Dir.pwd
|
5
|
+
require 'rubygems/package_task'
|
6
|
+
require 'rake/testtask'
|
7
|
+
|
8
|
+
exts = []
|
9
|
+
|
10
|
+
namespace :prepare do
|
11
|
+
FileList["ext/*/*.cr"].each do |cr|
|
12
|
+
dir = File.dirname(cr)
|
13
|
+
name = File.basename(dir)
|
14
|
+
desc "Generate source for #{name}"
|
15
|
+
task(name.intern) do
|
16
|
+
sh 'rubber-generate', '--build-dir', dir, cr
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
spec = Gem::Specification.new do |s|
|
22
|
+
s.name = "gtk-webkit-ruby"
|
23
|
+
s.author = "Geoff Youngs"
|
24
|
+
s.email = "git@intersect-uk.co.uk"
|
25
|
+
s.version = "0.0.3"
|
26
|
+
s.homepage = "http://github.com/geoffyoungs/gtk-webkit-ruby"
|
27
|
+
s.summary = "Webkit bindings using rubber-generate"
|
28
|
+
s.add_dependency("rubber-generate", ">= 0.0.12")
|
29
|
+
s.platform = Gem::Platform::RUBY
|
30
|
+
s.extensions = FileList["ext/*/extconf.rb"]
|
31
|
+
s.files = FileList['ext/*/*.{c,h,cr,rd}'] + ['Rakefile', 'README.md']
|
32
|
+
s.description = <<-EOF
|
33
|
+
Gtk Webkit bindings for ruby. Partial coverage sufficient to embed a webview in a Ruby-GNOME2 application.
|
34
|
+
|
35
|
+
Also initial/experimental support for allowing ruby code to be called by javascript & executing javascript
|
36
|
+
from ruby.
|
37
|
+
|
38
|
+
e.g
|
39
|
+
require 'gtk2'
|
40
|
+
require 'webkit'
|
41
|
+
|
42
|
+
v = WebKit::WebView.new
|
43
|
+
v.main_frame.setup_ruby
|
44
|
+
puts v.main_frame.exec_js("ruby_eval('RUBY_DESCRIPTION')")
|
45
|
+
puts v.main_frame.exec_js("document.root.innerHTML")
|
46
|
+
EOF
|
47
|
+
end
|
48
|
+
Gem::PackageTask.new(spec) do |pkg|
|
49
|
+
pkg.need_tar = true
|
50
|
+
end
|
51
|
+
Rake::ExtensionTask.new("webkit", spec)
|
52
|
+
|
53
|
+
Rake::TestTask.new do |t|
|
54
|
+
t.test_files = FileList['test/*_test.rb']
|
55
|
+
end
|
56
|
+
|
57
|
+
task :default, :compile
|
58
|
+
|
@@ -0,0 +1,74 @@
|
|
1
|
+
require 'mkmf'
|
2
|
+
require 'mkmf-gnome2'
|
3
|
+
PKGConfig.have_package("gtk+-2.0") or exit(-1)
|
4
|
+
PKGConfig.have_package("webkit-1.0") or exit(-1)
|
5
|
+
have_header("webkit/webkit.h") or exit(-1)
|
6
|
+
have_header("JavaScriptCore/JavaScript.h") or exit(-1)
|
7
|
+
|
8
|
+
STDOUT.print("checking for new allocation framework... ") # for ruby-1.7
|
9
|
+
if Object.respond_to? :allocate
|
10
|
+
STDOUT.print "yes
|
11
|
+
"
|
12
|
+
$defs << "-DHAVE_OBJECT_ALLOCATE"
|
13
|
+
else
|
14
|
+
STDOUT.print "no
|
15
|
+
"
|
16
|
+
end
|
17
|
+
|
18
|
+
top = File.expand_path(File.dirname(__FILE__) + '/..') # XXX
|
19
|
+
$CFLAGS += " " + ['glib/src'].map{|d|
|
20
|
+
"-I" + File.join(top, d)
|
21
|
+
}.join(" ")
|
22
|
+
|
23
|
+
have_func("rb_define_alloc_func") # for ruby-1.8
|
24
|
+
|
25
|
+
#set_output_lib('libruby-webkit.a')
|
26
|
+
if /cygwin|mingw/ =~ RUBY_PLATFORM
|
27
|
+
top = "../.."
|
28
|
+
[
|
29
|
+
["glib/src", "ruby-glib2"],
|
30
|
+
].each{|d,l|
|
31
|
+
$LDFLAGS << sprintf(" -L%s/%s", top, d)
|
32
|
+
$libs << sprintf(" -l%s", l)
|
33
|
+
}
|
34
|
+
end
|
35
|
+
begin
|
36
|
+
srcdir = File.expand_path(File.dirname($0))
|
37
|
+
|
38
|
+
begin
|
39
|
+
|
40
|
+
obj_ext = "."+$OBJEXT
|
41
|
+
|
42
|
+
$libs = $libs.split(/ /).uniq.join(' ')
|
43
|
+
$source_files = Dir.glob(sprintf("%s/*.c", srcdir)).map{|fname|
|
44
|
+
fname[0, srcdir.length+1] = ''
|
45
|
+
fname
|
46
|
+
}
|
47
|
+
$objs = $source_files.collect do |item|
|
48
|
+
item.gsub(/.c$/, obj_ext)
|
49
|
+
end
|
50
|
+
|
51
|
+
#
|
52
|
+
# create Makefile
|
53
|
+
#
|
54
|
+
$defs << "-DRUBY_WEBKIT_COMPILATION"
|
55
|
+
# $CFLAGS << $defs.join(' ')
|
56
|
+
create_makefile("webkit", srcdir)
|
57
|
+
raise Interrupt if not FileTest.exist? "Makefile"
|
58
|
+
|
59
|
+
File.open("Makefile", "a") do |mfile|
|
60
|
+
$source_files.each do |e|
|
61
|
+
mfile.print sprintf("%s: %s
|
62
|
+
", e.gsub(/.c$/, obj_ext), e)
|
63
|
+
end
|
64
|
+
end
|
65
|
+
ensure
|
66
|
+
#Dir.chdir ".."
|
67
|
+
end
|
68
|
+
|
69
|
+
#create_top_makefile()
|
70
|
+
rescue Interrupt
|
71
|
+
print " [error] " + $!.to_s + "
|
72
|
+
"
|
73
|
+
end
|
74
|
+
|
@@ -0,0 +1,271 @@
|
|
1
|
+
#include <alloca.h>
|
2
|
+
|
3
|
+
#define STRINGIZE(s) #s
|
4
|
+
|
5
|
+
#define JS_fn(f) _JS_fn(ctx, STRINGIZE(f), f)
|
6
|
+
|
7
|
+
JSObjectRef _JS_fn(JSContextRef ctx, const char *name, JSObjectCallAsFunctionCallback f)
|
8
|
+
{
|
9
|
+
JSStringRef nameStr = JSStringCreateWithUTF8CString(name);
|
10
|
+
JSObjectRef value = JSObjectMakeFunctionWithCallback(ctx, nameStr, f);
|
11
|
+
JSStringRelease(nameStr);
|
12
|
+
return value;
|
13
|
+
}
|
14
|
+
|
15
|
+
static inline bool
|
16
|
+
js_obj_set_value(JSContextRef ctx, JSObjectRef object, char *name, JSObjectRef value)
|
17
|
+
{
|
18
|
+
JSValueRef *_exception = NULL;
|
19
|
+
JSStringRef nameStr = JSStringCreateWithUTF8CString(name);
|
20
|
+
|
21
|
+
JSObjectSetProperty(ctx, object, nameStr, value, kJSPropertyAttributeNone, _exception);
|
22
|
+
|
23
|
+
JSStringRelease(nameStr);
|
24
|
+
|
25
|
+
if (*_exception) { return false; }
|
26
|
+
|
27
|
+
return true;
|
28
|
+
}
|
29
|
+
|
30
|
+
static JSValueRef
|
31
|
+
convert_string_to_jsval(JSContextRef ctx, char *str) {
|
32
|
+
JSStringRef js_s_ref;
|
33
|
+
JSValueRef js_val_ref;
|
34
|
+
|
35
|
+
js_s_ref = JSStringCreateWithUTF8CString(str);
|
36
|
+
js_val_ref = JSValueMakeString(ctx, js_s_ref);
|
37
|
+
JSStringRelease(js_s_ref);
|
38
|
+
|
39
|
+
return js_val_ref;
|
40
|
+
}
|
41
|
+
|
42
|
+
static char *
|
43
|
+
convert_javascript_to_utf8_string(JSContextRef ctx, JSValueRef val, size_t* out_len)
|
44
|
+
{
|
45
|
+
JSStringRef str = JSValueToStringCopy(ctx, val, NULL);
|
46
|
+
size_t max = 0, len;
|
47
|
+
char *buf;
|
48
|
+
|
49
|
+
max = JSStringGetMaximumUTF8CStringSize(str);
|
50
|
+
buf = malloc(max);
|
51
|
+
len = JSStringGetUTF8CString(str, buf, max);
|
52
|
+
|
53
|
+
if (out_len) {
|
54
|
+
*out_len = len;
|
55
|
+
}
|
56
|
+
|
57
|
+
JSStringRelease(str);
|
58
|
+
|
59
|
+
return buf;
|
60
|
+
}
|
61
|
+
|
62
|
+
static inline VALUE
|
63
|
+
convert_javascript_string_to_ruby(JSContextRef ctx, JSValueRef val)
|
64
|
+
{
|
65
|
+
VALUE output = Qnil;
|
66
|
+
JSStringRef str;
|
67
|
+
size_t len = 0, max = 0;
|
68
|
+
char *buf;
|
69
|
+
|
70
|
+
str = JSValueToStringCopy(ctx, val, NULL);
|
71
|
+
max = JSStringGetMaximumUTF8CStringSize(str);
|
72
|
+
buf = malloc(max);
|
73
|
+
len = JSStringGetUTF8CString(str, buf, max);
|
74
|
+
|
75
|
+
output = rb_str_new(buf, len-1); // Ignore terminator
|
76
|
+
|
77
|
+
free(buf);
|
78
|
+
JSStringRelease(str);
|
79
|
+
|
80
|
+
return output;
|
81
|
+
}
|
82
|
+
|
83
|
+
static VALUE
|
84
|
+
convert_javascript_to_ruby(JSContextRef ctx, JSValueRef val)
|
85
|
+
{
|
86
|
+
VALUE output = Qnil;
|
87
|
+
JSValueRef *_exception = NULL;
|
88
|
+
|
89
|
+
switch (JSValueGetType(ctx, val)) {
|
90
|
+
case kJSTypeUndefined:
|
91
|
+
case kJSTypeNull:
|
92
|
+
output = Qnil;
|
93
|
+
break;
|
94
|
+
case kJSTypeBoolean:
|
95
|
+
output = JSValueToBoolean(ctx, val) ? Qtrue : Qfalse;
|
96
|
+
break;
|
97
|
+
case kJSTypeNumber:
|
98
|
+
output = rb_float_new(JSValueToNumber(ctx, val, _exception));
|
99
|
+
break;
|
100
|
+
case kJSTypeString:
|
101
|
+
output = convert_javascript_string_to_ruby(ctx, val);
|
102
|
+
break;
|
103
|
+
case kJSTypeObject:
|
104
|
+
output = convert_javascript_string_to_ruby(ctx, val);
|
105
|
+
break;
|
106
|
+
}
|
107
|
+
|
108
|
+
return output;
|
109
|
+
}
|
110
|
+
|
111
|
+
|
112
|
+
static JSValueRef
|
113
|
+
convert_ruby_to_javascript(JSContextRef ctx, VALUE value)
|
114
|
+
{
|
115
|
+
JSStringRef str;
|
116
|
+
JSValueRef jsval;
|
117
|
+
|
118
|
+
switch (TYPE(value)) {
|
119
|
+
case T_FIXNUM:
|
120
|
+
return JSValueMakeNumber(ctx, (double) FIX2LONG(value));
|
121
|
+
case T_FLOAT:
|
122
|
+
return JSValueMakeNumber(ctx, (double) NUM2DBL(value));
|
123
|
+
case T_BIGNUM:
|
124
|
+
return JSValueMakeNumber(ctx, (double) rb_big2long(value));
|
125
|
+
case T_TRUE:
|
126
|
+
case T_FALSE:
|
127
|
+
return JSValueMakeBoolean(ctx, RTEST(value));
|
128
|
+
case T_UNDEF:
|
129
|
+
return JSValueMakeUndefined(ctx);
|
130
|
+
case T_NIL:
|
131
|
+
return JSValueMakeNull(ctx);
|
132
|
+
default:
|
133
|
+
if (TYPE(value) != T_STRING) {
|
134
|
+
value = rb_funcall(value, rb_intern("to_s"), 0);
|
135
|
+
}
|
136
|
+
str = JSStringCreateWithUTF8CString(RSTRING_PTR(value));
|
137
|
+
jsval = JSValueMakeString(ctx, str);
|
138
|
+
JSStringRelease(str);
|
139
|
+
return jsval;
|
140
|
+
}
|
141
|
+
}
|
142
|
+
|
143
|
+
static JSValueRef
|
144
|
+
js_call_ruby_eval (JSContextRef ctx, JSObjectRef function, JSObjectRef thisObject,
|
145
|
+
size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
|
146
|
+
{
|
147
|
+
JSValueRef value = NULL;
|
148
|
+
|
149
|
+
if (argumentCount == 1) {
|
150
|
+
char *script;
|
151
|
+
VALUE val;
|
152
|
+
|
153
|
+
script = convert_javascript_to_utf8_string(ctx, arguments[0], NULL);
|
154
|
+
val = rb_eval_string(script);
|
155
|
+
|
156
|
+
value = convert_ruby_to_javascript(ctx, val);
|
157
|
+
|
158
|
+
free(script);
|
159
|
+
} else {
|
160
|
+
*exception = convert_string_to_jsval(ctx, "Wrong number of arguments");
|
161
|
+
}
|
162
|
+
|
163
|
+
return value;
|
164
|
+
}
|
165
|
+
|
166
|
+
static GHashTable *ruby_fns = NULL;
|
167
|
+
|
168
|
+
static JSValueRef
|
169
|
+
js_ruby_fn(JSContextRef ctx, JSObjectRef function, JSObjectRef thisObject,
|
170
|
+
size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
|
171
|
+
{
|
172
|
+
size_t i;
|
173
|
+
VALUE *args = ALLOC_N(VALUE, argumentCount);
|
174
|
+
VALUE ruby_fn = (VALUE) JSObjectGetPrivate(function);
|
175
|
+
JSValueRef retval;
|
176
|
+
|
177
|
+
if ((!ruby_fn) && ruby_fns) {
|
178
|
+
ruby_fn = (VALUE)g_hash_table_lookup(ruby_fns, (gpointer)function);
|
179
|
+
}
|
180
|
+
|
181
|
+
//printf("Hmm. Found: %p\n", function);
|
182
|
+
|
183
|
+
for (i = 0; i < argumentCount; i++) {
|
184
|
+
args[i] = convert_javascript_to_ruby(ctx, arguments[i]);
|
185
|
+
}
|
186
|
+
|
187
|
+
retval = convert_ruby_to_javascript(ctx,
|
188
|
+
rb_funcall2(ruby_fn, rb_intern("call"), argumentCount, args));
|
189
|
+
|
190
|
+
xfree(args);
|
191
|
+
|
192
|
+
return retval;
|
193
|
+
}
|
194
|
+
|
195
|
+
/**
|
196
|
+
* Javascript functions called directly from binding
|
197
|
+
**/
|
198
|
+
static void *
|
199
|
+
javascript_add_ruby_fn(JSGlobalContextRef ctx, char *name, VALUE ruby_fn)
|
200
|
+
{
|
201
|
+
JSObjectRef fn = NULL;
|
202
|
+
|
203
|
+
if (!ruby_fns) {
|
204
|
+
ruby_fns = g_hash_table_new(NULL, NULL);
|
205
|
+
}
|
206
|
+
|
207
|
+
JSObjectRef global = JSContextGetGlobalObject(ctx);
|
208
|
+
|
209
|
+
fn = JS_fn(js_ruby_fn);
|
210
|
+
|
211
|
+
if (!JSObjectSetPrivate(fn, (void*)ruby_fn)) {
|
212
|
+
gpointer old_value = g_hash_table_lookup(ruby_fns, (gpointer)fn);
|
213
|
+
if (old_value != NULL)
|
214
|
+
RUBYFUNC_DEL((VALUE)old_value);
|
215
|
+
RUBYFUNC_ADD(ruby_fn);
|
216
|
+
g_hash_table_insert(ruby_fns, (gpointer)fn, (gpointer)ruby_fn);
|
217
|
+
}
|
218
|
+
|
219
|
+
js_obj_set_value(ctx, global, name, fn); // Check failure?
|
220
|
+
|
221
|
+
return NULL;
|
222
|
+
}
|
223
|
+
|
224
|
+
static void *
|
225
|
+
javascript_add_ruby_eval(JSGlobalContextRef ctx)
|
226
|
+
{
|
227
|
+
JSObjectRef global = JSContextGetGlobalObject(ctx);
|
228
|
+
|
229
|
+
js_obj_set_value(ctx, global, "ruby_eval", JS_fn(js_call_ruby_eval));
|
230
|
+
|
231
|
+
return NULL;
|
232
|
+
}
|
233
|
+
|
234
|
+
static VALUE
|
235
|
+
javascript_exec(JSGlobalContextRef ctx, char *script)
|
236
|
+
{
|
237
|
+
VALUE output = Qnil;
|
238
|
+
|
239
|
+
JSStringRef js_script = JSStringCreateWithUTF8CString(script);
|
240
|
+
JSStringRef url = JSStringCreateWithUTF8CString("x-ruby://string");
|
241
|
+
|
242
|
+
JSValueRef err = JSValueMakeUndefined(ctx);
|
243
|
+
JSValueRef retval = NULL;
|
244
|
+
|
245
|
+
|
246
|
+
retval = JSEvaluateScript(ctx, js_script, NULL, url, 0, &err);
|
247
|
+
|
248
|
+
JSStringRelease(url);
|
249
|
+
JSStringRelease(js_script);
|
250
|
+
|
251
|
+
/* Convert output to ruby */
|
252
|
+
if (retval) {
|
253
|
+
output = convert_javascript_to_ruby(ctx, retval);
|
254
|
+
} else {
|
255
|
+
JSStringRef str = JSValueToStringCopy(ctx, err, NULL);
|
256
|
+
size_t len = 0, max = 0;
|
257
|
+
char *buf;
|
258
|
+
|
259
|
+
max = JSStringGetMaximumUTF8CStringSize(str);
|
260
|
+
buf = alloca(max);
|
261
|
+
len = JSStringGetUTF8CString(str, buf, max);
|
262
|
+
|
263
|
+
JSStringRelease(str);
|
264
|
+
rb_raise(cJavascriptError, buf);
|
265
|
+
//free(buf); // Will this ever be called?
|
266
|
+
}
|
267
|
+
|
268
|
+
return output;
|
269
|
+
}
|
270
|
+
|
271
|
+
|
data/ext/webkit/webkit.c
ADDED
@@ -0,0 +1,630 @@
|
|
1
|
+
/* Includes */
|
2
|
+
#include <ruby.h>
|
3
|
+
#include <stdlib.h>
|
4
|
+
#include <stdio.h>
|
5
|
+
#include <string.h>
|
6
|
+
#include "webkit/webkit.h"
|
7
|
+
#include "JavaScriptCore/JavaScript.h"
|
8
|
+
|
9
|
+
/* Setup types */
|
10
|
+
/* Try not to clash with other definitions of bool... */
|
11
|
+
typedef int rubber_bool;
|
12
|
+
#define bool rubber_bool
|
13
|
+
|
14
|
+
/* Prototypes */
|
15
|
+
#include "rbglib.h"
|
16
|
+
|
17
|
+
#include "rbgtk.h"
|
18
|
+
|
19
|
+
#if defined(G_PLATFORM_WIN32) && !defined(RUBY_GTK2_STATIC_COMPILATION)
|
20
|
+
# ifdef RUBY_GTK2_COMPILATION
|
21
|
+
# define RUBY_GTK2_VAR __declspec(dllexport)
|
22
|
+
# else
|
23
|
+
# define RUBY_GTK2_VAR extern __declspec(dllimport)
|
24
|
+
# endif
|
25
|
+
#else
|
26
|
+
# define RUBY_GTK2_VAR extern
|
27
|
+
#endif
|
28
|
+
|
29
|
+
RUBY_GTK2_VAR VALUE mGtk;
|
30
|
+
RUBY_GTK2_VAR VALUE mGdk;
|
31
|
+
|
32
|
+
#define RBGTK_INITIALIZE(obj,gtkobj) (rbgtk_initialize_gtkobject(obj, GTK_OBJECT(gtkobj)))
|
33
|
+
static VALUE mWebKit;
|
34
|
+
static VALUE
|
35
|
+
WebKit_CLASS_set_web_database_path(VALUE self, VALUE __v_path);
|
36
|
+
static VALUE
|
37
|
+
WebKit_CLASS_remove_all_web_databases(VALUE self);
|
38
|
+
static VALUE
|
39
|
+
WebKit_CLASS_set_default_web_database_quota(VALUE self, VALUE __v_quota);
|
40
|
+
static VALUE cJavascriptError;
|
41
|
+
static VALUE cWebSettings;
|
42
|
+
static VALUE
|
43
|
+
WebSettings_initialize(VALUE self);
|
44
|
+
static VALUE cWebFrame;
|
45
|
+
static VALUE
|
46
|
+
WebFrame_exec_js(VALUE self, VALUE __v_js);
|
47
|
+
static VALUE
|
48
|
+
WebFrame_add_ruby_eval(VALUE self);
|
49
|
+
static VALUE
|
50
|
+
WebFrame_add_js_api(VALUE self, VALUE __v_name);
|
51
|
+
static VALUE
|
52
|
+
WebFrame_load_string(VALUE self, VALUE __v_content, VALUE __v_mime_type, VALUE __v_encoding, VALUE __v_base_uri);
|
53
|
+
static VALUE cWebView;
|
54
|
+
static VALUE
|
55
|
+
WebView_initialize(VALUE self);
|
56
|
+
static VALUE
|
57
|
+
WebView_open(VALUE self, VALUE __v_uri);
|
58
|
+
static VALUE
|
59
|
+
WebView_execute_script(VALUE self, VALUE __v_script);
|
60
|
+
static VALUE
|
61
|
+
WebView_set_settings(VALUE self, VALUE __v_settings);
|
62
|
+
static VALUE
|
63
|
+
WebView_load_string(VALUE self, VALUE __v_content, VALUE __v_mime_type, VALUE __v_encoding, VALUE __v_base_uri);
|
64
|
+
static VALUE
|
65
|
+
WebView_load_uri(VALUE self, VALUE __v_uri);
|
66
|
+
static VALUE
|
67
|
+
WebView_main_frame(VALUE self);
|
68
|
+
static VALUE
|
69
|
+
WebView_focused_frame(VALUE self);
|
70
|
+
static VALUE
|
71
|
+
WebView_progress(VALUE self);
|
72
|
+
static VALUE
|
73
|
+
WebView_title(VALUE self);
|
74
|
+
static VALUE
|
75
|
+
WebView_uri(VALUE self);
|
76
|
+
static VALUE
|
77
|
+
WebView_reload(VALUE self);
|
78
|
+
static VALUE
|
79
|
+
WebView_reload_bypass_cache(VALUE self);
|
80
|
+
static VALUE
|
81
|
+
WebView_set_custom_encoding(VALUE self, VALUE __v_encoding);
|
82
|
+
static VALUE
|
83
|
+
WebView_stop_loading(VALUE self);
|
84
|
+
static VALUE cWebResource;
|
85
|
+
static VALUE
|
86
|
+
WebResource_encoding(VALUE self);
|
87
|
+
static VALUE
|
88
|
+
WebResource_frame_name(VALUE self);
|
89
|
+
static VALUE
|
90
|
+
WebResource_mime_type(VALUE self);
|
91
|
+
static VALUE
|
92
|
+
WebResource_uri(VALUE self);
|
93
|
+
static VALUE
|
94
|
+
WebResource_data(VALUE self);
|
95
|
+
static VALUE
|
96
|
+
WebResource_data_equals(VALUE self, VALUE data);
|
97
|
+
static VALUE cWebNetworkRequest;
|
98
|
+
static VALUE
|
99
|
+
WebNetworkRequest_uri(VALUE self);
|
100
|
+
static VALUE
|
101
|
+
WebNetworkRequest_uri_equals(VALUE self, VALUE __v_uri);
|
102
|
+
static VALUE cWebNetworkResponse;
|
103
|
+
static VALUE
|
104
|
+
WebNetworkResponse_uri(VALUE self);
|
105
|
+
static VALUE
|
106
|
+
WebNetworkResponse_uri_equals(VALUE self, VALUE __v_uri);
|
107
|
+
static VALUE _gcpool_RubyFunc = Qnil;
|
108
|
+
static void __gcpool_RubyFunc_add(VALUE val);
|
109
|
+
static void __gcpool_RubyFunc_del(VALUE val);
|
110
|
+
#define RUBYFUNC_ADD(val) __gcpool_RubyFunc_add(val)
|
111
|
+
#define RUBYFUNC_DEL(val) __gcpool_RubyFunc_del(val)
|
112
|
+
|
113
|
+
/* Inline C code */
|
114
|
+
|
115
|
+
#include <intern.h>
|
116
|
+
|
117
|
+
#include "javascript.h"
|
118
|
+
|
119
|
+
static inline VALUE strOrNil(const char *str) {
|
120
|
+
if (str) {
|
121
|
+
return rb_str_new2(str);
|
122
|
+
} else {
|
123
|
+
return Qnil;
|
124
|
+
}
|
125
|
+
}
|
126
|
+
|
127
|
+
|
128
|
+
/* Code */
|
129
|
+
static VALUE
|
130
|
+
WebKit_CLASS_set_web_database_path(VALUE self, VALUE __v_path)
|
131
|
+
{
|
132
|
+
char * path; char * __orig_path;
|
133
|
+
__orig_path = path = ( NIL_P(__v_path) ? NULL : StringValuePtr(__v_path) );
|
134
|
+
|
135
|
+
#line 31 "/home/geoff/Projects/gtk-webkit-ruby/ext/webkit/webkit.cr"
|
136
|
+
webkit_set_web_database_directory_path(path);
|
137
|
+
|
138
|
+
return self;
|
139
|
+
}
|
140
|
+
|
141
|
+
static VALUE
|
142
|
+
WebKit_CLASS_remove_all_web_databases(VALUE self)
|
143
|
+
{
|
144
|
+
|
145
|
+
#line 34 "/home/geoff/Projects/gtk-webkit-ruby/ext/webkit/webkit.cr"
|
146
|
+
webkit_remove_all_web_databases();
|
147
|
+
|
148
|
+
return Qnil;
|
149
|
+
}
|
150
|
+
|
151
|
+
static VALUE
|
152
|
+
WebKit_CLASS_set_default_web_database_quota(VALUE self, VALUE __v_quota)
|
153
|
+
{
|
154
|
+
guint64 quota; guint64 __orig_quota;
|
155
|
+
__orig_quota = quota = rb_num2ull(__v_quota);
|
156
|
+
|
157
|
+
#line 37 "/home/geoff/Projects/gtk-webkit-ruby/ext/webkit/webkit.cr"
|
158
|
+
webkit_set_default_web_database_quota(quota);
|
159
|
+
|
160
|
+
return self;
|
161
|
+
}
|
162
|
+
|
163
|
+
static VALUE
|
164
|
+
WebSettings_initialize(VALUE self)
|
165
|
+
{
|
166
|
+
|
167
|
+
#line 43 "/home/geoff/Projects/gtk-webkit-ruby/ext/webkit/webkit.cr"
|
168
|
+
G_INITIALIZE(self, webkit_web_settings_new());
|
169
|
+
|
170
|
+
return Qnil;
|
171
|
+
}
|
172
|
+
|
173
|
+
static VALUE
|
174
|
+
WebFrame_exec_js(VALUE self, VALUE __v_js)
|
175
|
+
{
|
176
|
+
VALUE __p_retval = Qnil;
|
177
|
+
char * js; char * __orig_js;
|
178
|
+
WebKitWebFrame *_self = ((WebKitWebFrame*)RVAL2GOBJ(self));
|
179
|
+
__orig_js = js = ( NIL_P(__v_js) ? NULL : StringValuePtr(__v_js) );
|
180
|
+
|
181
|
+
#line 50 "/home/geoff/Projects/gtk-webkit-ruby/ext/webkit/webkit.cr"
|
182
|
+
do { __p_retval = javascript_exec(webkit_web_frame_get_global_context(_self), js); goto out; } while(0);
|
183
|
+
out:
|
184
|
+
return __p_retval;
|
185
|
+
}
|
186
|
+
|
187
|
+
static VALUE
|
188
|
+
WebFrame_add_ruby_eval(VALUE self)
|
189
|
+
{
|
190
|
+
WebKitWebFrame *_self = ((WebKitWebFrame*)RVAL2GOBJ(self));
|
191
|
+
|
192
|
+
#line 53 "/home/geoff/Projects/gtk-webkit-ruby/ext/webkit/webkit.cr"
|
193
|
+
javascript_add_ruby_eval(webkit_web_frame_get_global_context(_self));
|
194
|
+
|
195
|
+
return Qnil;
|
196
|
+
}
|
197
|
+
|
198
|
+
static VALUE
|
199
|
+
WebFrame_add_js_api(VALUE self, VALUE __v_name)
|
200
|
+
{
|
201
|
+
char * name; char * __orig_name;
|
202
|
+
WebKitWebFrame *_self = ((WebKitWebFrame*)RVAL2GOBJ(self));
|
203
|
+
__orig_name = name = ( NIL_P(__v_name) ? NULL : StringValuePtr(__v_name) );
|
204
|
+
VALUE block = rb_block_proc();
|
205
|
+
|
206
|
+
#line 56 "/home/geoff/Projects/gtk-webkit-ruby/ext/webkit/webkit.cr"
|
207
|
+
javascript_add_ruby_fn(webkit_web_frame_get_global_context(_self), name, block);
|
208
|
+
|
209
|
+
return Qnil;
|
210
|
+
}
|
211
|
+
|
212
|
+
static VALUE
|
213
|
+
WebFrame_load_string(VALUE self, VALUE __v_content, VALUE __v_mime_type, VALUE __v_encoding, VALUE __v_base_uri)
|
214
|
+
{
|
215
|
+
char * content; char * __orig_content;
|
216
|
+
char * mime_type; char * __orig_mime_type;
|
217
|
+
char * encoding; char * __orig_encoding;
|
218
|
+
char * base_uri; char * __orig_base_uri;
|
219
|
+
WebKitWebFrame *_self = ((WebKitWebFrame*)RVAL2GOBJ(self));
|
220
|
+
__orig_content = content = ( NIL_P(__v_content) ? NULL : StringValuePtr(__v_content) );
|
221
|
+
__orig_mime_type = mime_type = ( NIL_P(__v_mime_type) ? NULL : StringValuePtr(__v_mime_type) );
|
222
|
+
__orig_encoding = encoding = ( NIL_P(__v_encoding) ? NULL : StringValuePtr(__v_encoding) );
|
223
|
+
__orig_base_uri = base_uri = ( NIL_P(__v_base_uri) ? NULL : StringValuePtr(__v_base_uri) );
|
224
|
+
|
225
|
+
#line 59 "/home/geoff/Projects/gtk-webkit-ruby/ext/webkit/webkit.cr"
|
226
|
+
webkit_web_frame_load_string(_self, content, mime_type, encoding, base_uri);
|
227
|
+
|
228
|
+
return Qnil;
|
229
|
+
}
|
230
|
+
|
231
|
+
static VALUE
|
232
|
+
WebView_initialize(VALUE self)
|
233
|
+
{
|
234
|
+
|
235
|
+
#line 65 "/home/geoff/Projects/gtk-webkit-ruby/ext/webkit/webkit.cr"
|
236
|
+
RBGTK_INITIALIZE(self, webkit_web_view_new());
|
237
|
+
|
238
|
+
return Qnil;
|
239
|
+
}
|
240
|
+
|
241
|
+
static VALUE
|
242
|
+
WebView_open(VALUE self, VALUE __v_uri)
|
243
|
+
{
|
244
|
+
char * uri; char * __orig_uri;
|
245
|
+
WebKitWebView *_self = ((WebKitWebView*)RVAL2GOBJ(self));
|
246
|
+
__orig_uri = uri = ( NIL_P(__v_uri) ? NULL : StringValuePtr(__v_uri) );
|
247
|
+
|
248
|
+
#line 68 "/home/geoff/Projects/gtk-webkit-ruby/ext/webkit/webkit.cr"
|
249
|
+
webkit_web_view_open(_self, uri);
|
250
|
+
|
251
|
+
return Qnil;
|
252
|
+
}
|
253
|
+
|
254
|
+
static VALUE
|
255
|
+
WebView_execute_script(VALUE self, VALUE __v_script)
|
256
|
+
{
|
257
|
+
char * script; char * __orig_script;
|
258
|
+
WebKitWebView *_self = ((WebKitWebView*)RVAL2GOBJ(self));
|
259
|
+
__orig_script = script = ( NIL_P(__v_script) ? NULL : StringValuePtr(__v_script) );
|
260
|
+
|
261
|
+
#line 71 "/home/geoff/Projects/gtk-webkit-ruby/ext/webkit/webkit.cr"
|
262
|
+
webkit_web_view_execute_script(_self, script);
|
263
|
+
|
264
|
+
return Qnil;
|
265
|
+
}
|
266
|
+
|
267
|
+
static VALUE
|
268
|
+
WebView_set_settings(VALUE self, VALUE __v_settings)
|
269
|
+
{
|
270
|
+
WebKitWebSettings * settings; WebKitWebSettings * __orig_settings;
|
271
|
+
WebKitWebView *_self = ((WebKitWebView*)RVAL2GOBJ(self));
|
272
|
+
__orig_settings = settings = RVAL2GOBJ(__v_settings);
|
273
|
+
|
274
|
+
#line 74 "/home/geoff/Projects/gtk-webkit-ruby/ext/webkit/webkit.cr"
|
275
|
+
webkit_web_view_set_settings(_self, settings);
|
276
|
+
|
277
|
+
return self;
|
278
|
+
}
|
279
|
+
|
280
|
+
static VALUE
|
281
|
+
WebView_load_string(VALUE self, VALUE __v_content, VALUE __v_mime_type, VALUE __v_encoding, VALUE __v_base_uri)
|
282
|
+
{
|
283
|
+
char * content; char * __orig_content;
|
284
|
+
char * mime_type; char * __orig_mime_type;
|
285
|
+
char * encoding; char * __orig_encoding;
|
286
|
+
char * base_uri; char * __orig_base_uri;
|
287
|
+
WebKitWebView *_self = ((WebKitWebView*)RVAL2GOBJ(self));
|
288
|
+
__orig_content = content = ( NIL_P(__v_content) ? NULL : StringValuePtr(__v_content) );
|
289
|
+
__orig_mime_type = mime_type = ( NIL_P(__v_mime_type) ? NULL : StringValuePtr(__v_mime_type) );
|
290
|
+
__orig_encoding = encoding = ( NIL_P(__v_encoding) ? NULL : StringValuePtr(__v_encoding) );
|
291
|
+
__orig_base_uri = base_uri = ( NIL_P(__v_base_uri) ? NULL : StringValuePtr(__v_base_uri) );
|
292
|
+
|
293
|
+
#line 77 "/home/geoff/Projects/gtk-webkit-ruby/ext/webkit/webkit.cr"
|
294
|
+
webkit_web_view_load_string(_self, content, mime_type, encoding, base_uri);
|
295
|
+
|
296
|
+
return Qnil;
|
297
|
+
}
|
298
|
+
|
299
|
+
static VALUE
|
300
|
+
WebView_load_uri(VALUE self, VALUE __v_uri)
|
301
|
+
{
|
302
|
+
char * uri; char * __orig_uri;
|
303
|
+
WebKitWebView *_self = ((WebKitWebView*)RVAL2GOBJ(self));
|
304
|
+
__orig_uri = uri = ( NIL_P(__v_uri) ? NULL : StringValuePtr(__v_uri) );
|
305
|
+
|
306
|
+
#line 80 "/home/geoff/Projects/gtk-webkit-ruby/ext/webkit/webkit.cr"
|
307
|
+
webkit_web_view_load_uri(_self, uri);
|
308
|
+
|
309
|
+
return Qnil;
|
310
|
+
}
|
311
|
+
|
312
|
+
static VALUE
|
313
|
+
WebView_main_frame(VALUE self)
|
314
|
+
{
|
315
|
+
VALUE __p_retval = Qnil;
|
316
|
+
WebKitWebView *_self = ((WebKitWebView*)RVAL2GOBJ(self));
|
317
|
+
|
318
|
+
#line 83 "/home/geoff/Projects/gtk-webkit-ruby/ext/webkit/webkit.cr"
|
319
|
+
do { __p_retval = GOBJ2RVAL(webkit_web_view_get_main_frame(_self)); goto out; } while(0);
|
320
|
+
out:
|
321
|
+
return __p_retval;
|
322
|
+
}
|
323
|
+
|
324
|
+
static VALUE
|
325
|
+
WebView_focused_frame(VALUE self)
|
326
|
+
{
|
327
|
+
VALUE __p_retval = Qnil;
|
328
|
+
WebKitWebView *_self = ((WebKitWebView*)RVAL2GOBJ(self));
|
329
|
+
|
330
|
+
#line 86 "/home/geoff/Projects/gtk-webkit-ruby/ext/webkit/webkit.cr"
|
331
|
+
do { __p_retval = GOBJ2RVAL(webkit_web_view_get_focused_frame(_self)); goto out; } while(0);
|
332
|
+
out:
|
333
|
+
return __p_retval;
|
334
|
+
}
|
335
|
+
|
336
|
+
static VALUE
|
337
|
+
WebView_progress(VALUE self)
|
338
|
+
{
|
339
|
+
VALUE __p_retval = Qnil;
|
340
|
+
WebKitWebView *_self = ((WebKitWebView*)RVAL2GOBJ(self));
|
341
|
+
|
342
|
+
#line 89 "/home/geoff/Projects/gtk-webkit-ruby/ext/webkit/webkit.cr"
|
343
|
+
do { __p_retval = rb_float_new(webkit_web_view_get_progress(_self)); goto out; } while(0);
|
344
|
+
out:
|
345
|
+
return __p_retval;
|
346
|
+
}
|
347
|
+
|
348
|
+
static VALUE
|
349
|
+
WebView_title(VALUE self)
|
350
|
+
{
|
351
|
+
VALUE __p_retval = Qnil;
|
352
|
+
WebKitWebView *_self = ((WebKitWebView*)RVAL2GOBJ(self));
|
353
|
+
|
354
|
+
#line 92 "/home/geoff/Projects/gtk-webkit-ruby/ext/webkit/webkit.cr"
|
355
|
+
do { __p_retval = rb_str_new2(webkit_web_view_get_title(_self)); goto out; } while(0);
|
356
|
+
out:
|
357
|
+
return __p_retval;
|
358
|
+
}
|
359
|
+
|
360
|
+
static VALUE
|
361
|
+
WebView_uri(VALUE self)
|
362
|
+
{
|
363
|
+
VALUE __p_retval = Qnil;
|
364
|
+
WebKitWebView *_self = ((WebKitWebView*)RVAL2GOBJ(self));
|
365
|
+
|
366
|
+
#line 95 "/home/geoff/Projects/gtk-webkit-ruby/ext/webkit/webkit.cr"
|
367
|
+
do { __p_retval = rb_str_new2(webkit_web_view_get_uri(_self)); goto out; } while(0);
|
368
|
+
out:
|
369
|
+
return __p_retval;
|
370
|
+
}
|
371
|
+
|
372
|
+
static VALUE
|
373
|
+
WebView_reload(VALUE self)
|
374
|
+
{
|
375
|
+
WebKitWebView *_self = ((WebKitWebView*)RVAL2GOBJ(self));
|
376
|
+
|
377
|
+
#line 98 "/home/geoff/Projects/gtk-webkit-ruby/ext/webkit/webkit.cr"
|
378
|
+
webkit_web_view_reload(_self);
|
379
|
+
|
380
|
+
return Qnil;
|
381
|
+
}
|
382
|
+
|
383
|
+
static VALUE
|
384
|
+
WebView_reload_bypass_cache(VALUE self)
|
385
|
+
{
|
386
|
+
WebKitWebView *_self = ((WebKitWebView*)RVAL2GOBJ(self));
|
387
|
+
|
388
|
+
#line 101 "/home/geoff/Projects/gtk-webkit-ruby/ext/webkit/webkit.cr"
|
389
|
+
webkit_web_view_reload_bypass_cache(_self);
|
390
|
+
|
391
|
+
return Qnil;
|
392
|
+
}
|
393
|
+
|
394
|
+
static VALUE
|
395
|
+
WebView_set_custom_encoding(VALUE self, VALUE __v_encoding)
|
396
|
+
{
|
397
|
+
char * encoding; char * __orig_encoding;
|
398
|
+
WebKitWebView *_self = ((WebKitWebView*)RVAL2GOBJ(self));
|
399
|
+
__orig_encoding = encoding = ( NIL_P(__v_encoding) ? NULL : StringValuePtr(__v_encoding) );
|
400
|
+
|
401
|
+
#line 104 "/home/geoff/Projects/gtk-webkit-ruby/ext/webkit/webkit.cr"
|
402
|
+
webkit_web_view_set_custom_encoding(_self, encoding);
|
403
|
+
|
404
|
+
return self;
|
405
|
+
}
|
406
|
+
|
407
|
+
static VALUE
|
408
|
+
WebView_stop_loading(VALUE self)
|
409
|
+
{
|
410
|
+
WebKitWebView *_self = ((WebKitWebView*)RVAL2GOBJ(self));
|
411
|
+
|
412
|
+
#line 107 "/home/geoff/Projects/gtk-webkit-ruby/ext/webkit/webkit.cr"
|
413
|
+
webkit_web_view_stop_loading(_self);
|
414
|
+
|
415
|
+
return Qnil;
|
416
|
+
}
|
417
|
+
|
418
|
+
static VALUE
|
419
|
+
WebResource_encoding(VALUE self)
|
420
|
+
{
|
421
|
+
VALUE __p_retval = Qnil;
|
422
|
+
WebKitWebResource *_self = ((WebKitWebResource*)RVAL2GOBJ(self));
|
423
|
+
|
424
|
+
#line 114 "/home/geoff/Projects/gtk-webkit-ruby/ext/webkit/webkit.cr"
|
425
|
+
do { __p_retval = strOrNil(webkit_web_resource_get_encoding(_self)); goto out; } while(0);
|
426
|
+
out:
|
427
|
+
return __p_retval;
|
428
|
+
}
|
429
|
+
|
430
|
+
static VALUE
|
431
|
+
WebResource_frame_name(VALUE self)
|
432
|
+
{
|
433
|
+
VALUE __p_retval = Qnil;
|
434
|
+
WebKitWebResource *_self = ((WebKitWebResource*)RVAL2GOBJ(self));
|
435
|
+
|
436
|
+
#line 117 "/home/geoff/Projects/gtk-webkit-ruby/ext/webkit/webkit.cr"
|
437
|
+
do { __p_retval = strOrNil(webkit_web_resource_get_frame_name(_self)); goto out; } while(0);
|
438
|
+
out:
|
439
|
+
return __p_retval;
|
440
|
+
}
|
441
|
+
|
442
|
+
static VALUE
|
443
|
+
WebResource_mime_type(VALUE self)
|
444
|
+
{
|
445
|
+
VALUE __p_retval = Qnil;
|
446
|
+
WebKitWebResource *_self = ((WebKitWebResource*)RVAL2GOBJ(self));
|
447
|
+
|
448
|
+
#line 120 "/home/geoff/Projects/gtk-webkit-ruby/ext/webkit/webkit.cr"
|
449
|
+
do { __p_retval = strOrNil(webkit_web_resource_get_mime_type(_self)); goto out; } while(0);
|
450
|
+
out:
|
451
|
+
return __p_retval;
|
452
|
+
}
|
453
|
+
|
454
|
+
static VALUE
|
455
|
+
WebResource_uri(VALUE self)
|
456
|
+
{
|
457
|
+
VALUE __p_retval = Qnil;
|
458
|
+
WebKitWebResource *_self = ((WebKitWebResource*)RVAL2GOBJ(self));
|
459
|
+
|
460
|
+
#line 123 "/home/geoff/Projects/gtk-webkit-ruby/ext/webkit/webkit.cr"
|
461
|
+
do { __p_retval = strOrNil(webkit_web_resource_get_mime_type(_self)); goto out; } while(0);
|
462
|
+
out:
|
463
|
+
return __p_retval;
|
464
|
+
}
|
465
|
+
|
466
|
+
static VALUE
|
467
|
+
WebResource_data(VALUE self)
|
468
|
+
{
|
469
|
+
VALUE __p_retval = Qnil;
|
470
|
+
WebKitWebResource *_self = ((WebKitWebResource*)RVAL2GOBJ(self));
|
471
|
+
|
472
|
+
#line 126 "/home/geoff/Projects/gtk-webkit-ruby/ext/webkit/webkit.cr"
|
473
|
+
|
474
|
+
do {
|
475
|
+
GString * data =
|
476
|
+
webkit_web_resource_get_data(_self);
|
477
|
+
do { __p_retval = rb_str_new(data->str, data->len); goto out; } while(0);
|
478
|
+
|
479
|
+
} while(0);
|
480
|
+
|
481
|
+
out:
|
482
|
+
return __p_retval;
|
483
|
+
}
|
484
|
+
|
485
|
+
static VALUE
|
486
|
+
WebResource_data_equals(VALUE self, VALUE data)
|
487
|
+
{
|
488
|
+
VALUE __p_retval = data;
|
489
|
+
WebKitWebResource *_self = ((WebKitWebResource*)RVAL2GOBJ(self));
|
490
|
+
Check_Type(data, T_STRING);
|
491
|
+
|
492
|
+
#line 130 "/home/geoff/Projects/gtk-webkit-ruby/ext/webkit/webkit.cr"
|
493
|
+
|
494
|
+
do {
|
495
|
+
GString * odata =
|
496
|
+
webkit_web_resource_get_data(_self);
|
497
|
+
g_free(odata->str);
|
498
|
+
odata->str = g_malloc(RSTRING_LEN(data)+1);
|
499
|
+
odata->len = odata->allocated_len = RSTRING_LEN(data);
|
500
|
+
memcpy(RSTRING_PTR(data), odata->str, RSTRING_LEN(data));
|
501
|
+
do { __p_retval = data; goto out; } while(0);
|
502
|
+
|
503
|
+
} while(0);
|
504
|
+
|
505
|
+
out:
|
506
|
+
return __p_retval;
|
507
|
+
}
|
508
|
+
|
509
|
+
static VALUE
|
510
|
+
WebNetworkRequest_uri(VALUE self)
|
511
|
+
{
|
512
|
+
VALUE __p_retval = Qnil;
|
513
|
+
WebKitNetworkRequest *_self = ((WebKitNetworkRequest*)RVAL2GOBJ(self));
|
514
|
+
|
515
|
+
#line 142 "/home/geoff/Projects/gtk-webkit-ruby/ext/webkit/webkit.cr"
|
516
|
+
do { __p_retval = rb_str_new2(webkit_network_request_get_uri(_self)); goto out; } while(0);
|
517
|
+
out:
|
518
|
+
return __p_retval;
|
519
|
+
}
|
520
|
+
|
521
|
+
static VALUE
|
522
|
+
WebNetworkRequest_uri_equals(VALUE self, VALUE __v_uri)
|
523
|
+
{
|
524
|
+
char * uri; char * __orig_uri;
|
525
|
+
WebKitNetworkRequest *_self = ((WebKitNetworkRequest*)RVAL2GOBJ(self));
|
526
|
+
__orig_uri = uri = ( NIL_P(__v_uri) ? NULL : StringValuePtr(__v_uri) );
|
527
|
+
|
528
|
+
#line 145 "/home/geoff/Projects/gtk-webkit-ruby/ext/webkit/webkit.cr"
|
529
|
+
webkit_network_request_set_uri(_self, uri);
|
530
|
+
|
531
|
+
return __v_uri;
|
532
|
+
}
|
533
|
+
|
534
|
+
static VALUE
|
535
|
+
WebNetworkResponse_uri(VALUE self)
|
536
|
+
{
|
537
|
+
VALUE __p_retval = Qnil;
|
538
|
+
WebKitNetworkResponse *_self = ((WebKitNetworkResponse*)RVAL2GOBJ(self));
|
539
|
+
|
540
|
+
#line 152 "/home/geoff/Projects/gtk-webkit-ruby/ext/webkit/webkit.cr"
|
541
|
+
do { __p_retval = rb_str_new2(webkit_network_response_get_uri(_self)); goto out; } while(0);
|
542
|
+
out:
|
543
|
+
return __p_retval;
|
544
|
+
}
|
545
|
+
|
546
|
+
static VALUE
|
547
|
+
WebNetworkResponse_uri_equals(VALUE self, VALUE __v_uri)
|
548
|
+
{
|
549
|
+
char * uri; char * __orig_uri;
|
550
|
+
WebKitNetworkResponse *_self = ((WebKitNetworkResponse*)RVAL2GOBJ(self));
|
551
|
+
__orig_uri = uri = ( NIL_P(__v_uri) ? NULL : StringValuePtr(__v_uri) );
|
552
|
+
|
553
|
+
#line 155 "/home/geoff/Projects/gtk-webkit-ruby/ext/webkit/webkit.cr"
|
554
|
+
webkit_network_response_set_uri(_self, uri);
|
555
|
+
|
556
|
+
return __v_uri;
|
557
|
+
}
|
558
|
+
|
559
|
+
static void __gcpool_RubyFunc_add(VALUE val)
|
560
|
+
{
|
561
|
+
if (_gcpool_RubyFunc == Qnil)
|
562
|
+
{
|
563
|
+
_gcpool_RubyFunc = rb_ary_new3(1, val);
|
564
|
+
}
|
565
|
+
else
|
566
|
+
{
|
567
|
+
rb_ary_push(_gcpool_RubyFunc, val);
|
568
|
+
}
|
569
|
+
}
|
570
|
+
|
571
|
+
static void __gcpool_RubyFunc_del(VALUE val)
|
572
|
+
{
|
573
|
+
if (_gcpool_RubyFunc == Qnil)
|
574
|
+
{
|
575
|
+
rb_warn("Trying to remove object from empty GC queue RubyFunc");
|
576
|
+
return;
|
577
|
+
}
|
578
|
+
rb_ary_delete(_gcpool_RubyFunc, val);
|
579
|
+
// If nothing is referenced, don't keep an empty array in the pool...
|
580
|
+
if (RARRAY(_gcpool_RubyFunc)->len == 0)
|
581
|
+
_gcpool_RubyFunc = Qnil;
|
582
|
+
}
|
583
|
+
|
584
|
+
/* Init */
|
585
|
+
void
|
586
|
+
Init_webkit(void)
|
587
|
+
{
|
588
|
+
mWebKit = rb_define_module("WebKit");
|
589
|
+
rb_define_singleton_method(mWebKit, "set_web_database_path", WebKit_CLASS_set_web_database_path, 1);
|
590
|
+
rb_define_singleton_method(mWebKit, "remove_all_web_databases", WebKit_CLASS_remove_all_web_databases, 0);
|
591
|
+
rb_define_singleton_method(mWebKit, "set_default_web_database_quota", WebKit_CLASS_set_default_web_database_quota, 1);
|
592
|
+
cJavascriptError = rb_define_class_under(mWebKit, "JavascriptError", rb_eStandardError);
|
593
|
+
cWebSettings = G_DEF_CLASS(WEBKIT_TYPE_WEB_SETTINGS, "WebSettings", mWebKit);
|
594
|
+
rb_define_method(cWebSettings, "initialize", WebSettings_initialize, 0);
|
595
|
+
cWebFrame = G_DEF_CLASS(WEBKIT_TYPE_WEB_FRAME, "WebFrame", mWebKit);
|
596
|
+
rb_define_method(cWebFrame, "exec_js", WebFrame_exec_js, 1);
|
597
|
+
rb_define_method(cWebFrame, "add_ruby_eval", WebFrame_add_ruby_eval, 0);
|
598
|
+
rb_define_method(cWebFrame, "add_js_api", WebFrame_add_js_api, 1);
|
599
|
+
rb_define_method(cWebFrame, "load_string", WebFrame_load_string, 4);
|
600
|
+
cWebView = G_DEF_CLASS(WEBKIT_TYPE_WEB_VIEW, "WebView", mWebKit);
|
601
|
+
rb_define_method(cWebView, "initialize", WebView_initialize, 0);
|
602
|
+
rb_define_method(cWebView, "open", WebView_open, 1);
|
603
|
+
rb_define_method(cWebView, "execute_script", WebView_execute_script, 1);
|
604
|
+
rb_define_method(cWebView, "set_settings", WebView_set_settings, 1);
|
605
|
+
rb_define_method(cWebView, "load_string", WebView_load_string, 4);
|
606
|
+
rb_define_method(cWebView, "load_uri", WebView_load_uri, 1);
|
607
|
+
rb_define_method(cWebView, "main_frame", WebView_main_frame, 0);
|
608
|
+
rb_define_method(cWebView, "focused_frame", WebView_focused_frame, 0);
|
609
|
+
rb_define_method(cWebView, "progress", WebView_progress, 0);
|
610
|
+
rb_define_method(cWebView, "title", WebView_title, 0);
|
611
|
+
rb_define_method(cWebView, "uri", WebView_uri, 0);
|
612
|
+
rb_define_method(cWebView, "reload", WebView_reload, 0);
|
613
|
+
rb_define_method(cWebView, "reload_bypass_cache", WebView_reload_bypass_cache, 0);
|
614
|
+
rb_define_method(cWebView, "set_custom_encoding", WebView_set_custom_encoding, 1);
|
615
|
+
rb_define_method(cWebView, "stop_loading", WebView_stop_loading, 0);
|
616
|
+
cWebResource = G_DEF_CLASS(WEBKIT_TYPE_WEB_RESOURCE, "WebResource", mWebKit);
|
617
|
+
rb_define_method(cWebResource, "encoding", WebResource_encoding, 0);
|
618
|
+
rb_define_method(cWebResource, "frame_name", WebResource_frame_name, 0);
|
619
|
+
rb_define_method(cWebResource, "mime_type", WebResource_mime_type, 0);
|
620
|
+
rb_define_method(cWebResource, "uri", WebResource_uri, 0);
|
621
|
+
rb_define_method(cWebResource, "data", WebResource_data, 0);
|
622
|
+
rb_define_method(cWebResource, "data=", WebResource_data_equals, 1);
|
623
|
+
cWebNetworkRequest = G_DEF_CLASS(WEBKIT_TYPE_NETWORK_REQUEST, "WebNetworkRequest", mWebKit);
|
624
|
+
rb_define_method(cWebNetworkRequest, "uri", WebNetworkRequest_uri, 0);
|
625
|
+
rb_define_method(cWebNetworkRequest, "uri=", WebNetworkRequest_uri_equals, 1);
|
626
|
+
cWebNetworkResponse = G_DEF_CLASS(WEBKIT_TYPE_NETWORK_RESPONSE, "WebNetworkResponse", mWebKit);
|
627
|
+
rb_define_method(cWebNetworkResponse, "uri", WebNetworkResponse_uri, 0);
|
628
|
+
rb_define_method(cWebNetworkResponse, "uri=", WebNetworkResponse_uri_equals, 1);
|
629
|
+
rb_gc_register_address(&_gcpool_RubyFunc);
|
630
|
+
}
|