From e3013b3e717e279cd1a0a150aa920100671afe60 Mon Sep 17 00:00:00 2001 From: Bill Robertson Date: Thu, 8 Oct 2009 22:38:26 -0400 Subject: [PATCH] 1/2 baby step, put an object into the struct. --- v8.cpp | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/v8.cpp b/v8.cpp index b08e617..d578fa3 100644 --- a/v8.cpp +++ b/v8.cpp @@ -2,6 +2,15 @@ #include #include +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_context; @@ -20,7 +29,6 @@ VALUE rb_cV8; extern "C" { void Init_v8() { - printf("Init_v8()\n"); rb_mModule = rb_define_module("V8"); rb_cV8 = rb_define_class_under(rb_mModule, "Context", rb_cObject); rb_define_alloc_func(rb_cV8, v8_allocate); @@ -47,7 +55,6 @@ VALUE print(VALUE object, VALUE arg) { v8_context* s=0; Data_Get_Struct(object, struct v8_context, s); - printf("%d %s\n", (s?s->a++:-1), RSTRING(arg)->ptr); return Qnil; }