Commits

Anonymous committed 01a4ca9

mmmm

  • Participants
  • Parent commits 4ebc314

Comments (0)

Files changed (1)

File c++/v8/main.cpp

 // from http://code.google.com/apis/v8/get_started.html
 #include <v8.h>
-
+#include <iostream>
+using namespace std;
 using namespace v8;
 
 Local<Function> create_func(Persistent<Object>& global,
                            const char* code, const char* name){
+  cout << name << endl;
+  cout << code << endl;
   Handle<Script> s = Script::Compile(String::New(code), String::New(name));
   Handle<Value> fun_obj = s->Run();
   return Function::Cast(*(global->Get(String::New(name))));
   //  Handle<String> source = String::New("{ someatom: 23, anotheratom: 3.3 };");
 
   Handle<Value> v0[1];
-  v0[0]= Integer::New(23);
+  {
+    Handle<String> src = String::New("2344");
+    Handle<Script> script = Script::Compile(src);
+    v0[0] = script->Run();
+  }
   //  global->Set("v0", 
   const char* fun = "fun0 = function(i){ return i+1; }";
   const char* fun1 = "fun1 = function(i){ return i-1; }";
   Local<Value> ret1 = create_func(global, fun1, "fun1");
   Persistent<Value> f = Persistent<Value>::New(ret);
 
+  cout << f->IsFunction() << endl;
   Handle<Value> result = ((Function*)(*f))->Call(global, 1, v0);
   String::AsciiValue ascii(result);
   printf("%s\n", *ascii);