1
0
Fork 0
mirror of https://github.com/rubyjs/therubyracer synced 2023-03-27 23:21:42 -04:00

acutally wrap a v8 context. w00t\!

This commit is contained in:
Charles Lowell 2009-10-08 22:27:41 -05:00
parent 6704426bdd
commit 6d90a69f72
3 changed files with 14 additions and 14 deletions

View file

@ -2,7 +2,7 @@ require 'mkmf'
CONFIG['LDSHARED'] = "g++ -shared"
#dir_config('v8')
#have_library('v8')
dir_config('v8')
have_library('v8')
create_makefile('v8')

6
t.rb
View file

@ -5,5 +5,11 @@ e.print("Hello World")
e.print("Hello World")
e.print("Hello World")
e2 = V8::Context.new
e2.print("You Suck!")
e2.print("You Suck!")
e2.print("You RULE!")

18
v8.cpp
View file

@ -1,23 +1,17 @@
#include "ruby.h"
#include "v8.h"
#include <stdio.h>
#include <string.h>
class foo {
private:
int messageNumber=0;
public:
void print(const char* msg) {
printf("%d %s\n", ++messageNumber, msg);
}
}
typedef struct v8_context {
int a;
v8::Handle<v8::Context> context;
public:
v8_context() : context(v8::Context::New()) {}
} v8_context;
extern "C" {
void Init_v8();
}
VALUE v8_allocate(VALUE clazz);
void v8_mark(v8_context *s);
void v8_free(v8_context *s);
@ -39,7 +33,6 @@ extern "C" {
VALUE v8_allocate(VALUE clazz) {
printf("v8_allocate()\n");
v8_context *s = new v8_context;
memset(s, 0, sizeof(v8_context));
return Data_Wrap_Struct(clazz, v8_mark, v8_free, s);
}
@ -55,6 +48,7 @@ VALUE print(VALUE object, VALUE arg)
{
v8_context* s=0;
Data_Get_Struct(object, struct v8_context, s);
// s->wrapped.print(RSTRING(arg)->ptr);
return Qnil;
}