Permalink
Browse files

Added WindowAlert test

git-svn-id: http://hotruby.googlecode.com/svn/trunk@22 4fb8041d-b042-0410-9571-f50be27af959
  • Loading branch information...
1 parent 8be6433 commit d4d7e45794e80527fdc7e2ddd720338ff66b0817 yukoba@accelart.jp committed Jan 15, 2008
View
@@ -646,7 +646,16 @@ HotRuby.prototype = {
// Get native global variable
var v = eval("(" + varName + ")");
if(typeof(v) != "undefined") {
- sf.stack[sf.sp++] = v;
+ if(typeof(v) == "function") {
+ var convArgs = this.rubyObjectAryToNativeAry(args);
+ var ret = v.apply(null, convArgs);
+ sf.stack[sf.sp++] = this.nativeToRubyObject(ret);
+ } else {
+ sf.stack[sf.sp++] = {
+ __className: "NativeObject",
+ __native: v
+ }
+ }
return;
}
} else if(this.env == "flash") {
@@ -693,7 +702,7 @@ HotRuby.prototype = {
if(op != null)
throw "[invokeNativeMethod] Unsupported operator: " + op;
var convArgs = this.rubyObjectAryToNativeAry(args);
- ret = recver.__native[methodName].apply(recver, convArgs);
+ ret = recver.__native[methodName].apply(recver.__native, convArgs);
} else {
// Get native instance variable
if(op == null) {

Some generated files are not rendered by default. Learn more.

Oops, something went wrong.
@@ -0,0 +1,2 @@
+$native.alert "Hello World! - 1"
+$native.window.alert "Hello World! - 2"
@@ -0,0 +1,71 @@
+[
+ "YARVInstructionSequence\/SimpleDataFormat",
+ 1,
+ 1,
+ 1,
+ {
+ "arg_size": 0,
+ "local_size": 1,
+ "stack_max": 2
+ },
+ "<main>",
+ "windowAlert\\windowAlert.rb",
+ "top",
+ [
+
+ ],
+ 0,
+ [
+
+ ],
+ [
+ 1,
+ [
+ "getglobal",
+ "$native"
+ ],
+ [
+ "putstring",
+ "Hello World! - 1"
+ ],
+ [
+ "send",
+ "alert",
+ 1,
+ null,
+ 0,
+ null
+ ],
+ [
+ "pop"
+ ],
+ 2,
+ [
+ "getglobal",
+ "$native"
+ ],
+ [
+ "send",
+ "window",
+ 0,
+ null,
+ 0,
+ null
+ ],
+ [
+ "putstring",
+ "Hello World! - 2"
+ ],
+ [
+ "send",
+ "alert",
+ 1,
+ null,
+ 0,
+ null
+ ],
+ [
+ "leave"
+ ]
+ ]
+]
View
@@ -646,7 +646,16 @@ HotRuby.prototype = {
// Get native global variable
var v = eval("(" + varName + ")");
if(typeof(v) != "undefined") {
- sf.stack[sf.sp++] = v;
+ if(typeof(v) == "function") {
+ var convArgs = this.rubyObjectAryToNativeAry(args);
+ var ret = v.apply(null, convArgs);
+ sf.stack[sf.sp++] = this.nativeToRubyObject(ret);
+ } else {
+ sf.stack[sf.sp++] = {
+ __className: "NativeObject",
+ __native: v
+ }
+ }
return;
}
} else if(this.env == "flash") {
@@ -693,7 +702,7 @@ HotRuby.prototype = {
if(op != null)
throw "[invokeNativeMethod] Unsupported operator: " + op;
var convArgs = this.rubyObjectAryToNativeAry(args);
- ret = recver.__native[methodName].apply(recver, convArgs);
+ ret = recver.__native[methodName].apply(recver.__native, convArgs);
} else {
// Get native instance variable
if(op == null) {

Some generated files are not rendered by default. Learn more.

Oops, something went wrong.
@@ -0,0 +1,9 @@
+<html>
+ <head>
+ <title>WindowAlert - HotRuby</title>
+ <script type="text/javascript" src="../js/HotRuby.js"></script>
+ <script type="text/javascript" src="../js/test/windowAlert.js"></script>
+ </head>
+ <body onload="new HotRuby().run(src);">
+ </body>
+</html>

0 comments on commit d4d7e45

Please sign in to comment.