diff --git a/v8_data.cpp b/v8_data.cpp new file mode 100644 index 0000000..b0a0c3e --- /dev/null +++ b/v8_data.cpp @@ -0,0 +1,9 @@ +#include "v8_data.h" + +V8HandleDest::V8HandleDest() { + +} + +V8HandleDest::~V8HandleDest() { + +} \ No newline at end of file diff --git a/v8_standalone.cpp b/v8_standalone.cpp new file mode 100644 index 0000000..5f68718 --- /dev/null +++ b/v8_standalone.cpp @@ -0,0 +1,58 @@ +#include "v8_standalone.h" + +VALUE ruby_call_symbol; +VALUE ruby_respond_to_ID; + +bool is_callable(VALUE& object) { + return Qtrue == rb_funcall(object, ruby_respond_to_ID, 1, ruby_call_symbol); +} + +/** + * Debugging aid + */ +VALUE v8_what_is_this(VALUE self, VALUE object) { + VALUE boolean; + switch (TYPE(object)) { + case T_NIL: + printf("nil\n"); + break; + case T_OBJECT: + printf("ordinary object\n"); + if (is_callable(object)) { + printf("responds to call!
"); + } + break; + case T_CLASS: + printf("class[%s]
", rb_class2name(object)); + break; + case T_MODULE: printf("module\n"); break; + case T_FLOAT: printf("floating point number\n"); break; + case T_STRING: printf("string\n"); break; + case T_REGEXP: printf("regular expression\n"); break; + case T_ARRAY: printf("array\n"); break; + case T_FIXNUM: printf("Fixnum(31bit integer)\n"); break; + case T_HASH: printf("associative array\n"); break; + case T_STRUCT: printf("(Ruby) structure\n"); break; + case T_BIGNUM: printf("multi precision integer\n"); break; + case T_FILE: printf("IO\n"); break; + case T_TRUE: printf("true\n"); break; + case T_FALSE: printf("false\n"); break; + case T_DATA: + printf("data... inspecting\n"); + if (is_callable(object)) { + printf("Responds to call!
"); + } else { + printf("Does *NOT* respond to call
"); + } + v8_what_is_this(Qnil, RDATA(object)->basic.klass); + break; + case T_SYMBOL: printf("symbol\n"); break; + + default: + printf("I have no idea!!!\n"); + rb_raise(rb_eTypeError, "not valid value"); + break; + } + + return Qnil; +} diff --git a/v8_standalone.h b/v8_standalone.h new file mode 100644 index 0000000..3a3c40f --- /dev/null +++ b/v8_standalone.h @@ -0,0 +1,27 @@ +#ifndef __v8_standalone_h__ +#define __v8_standalone_h__ + +#include "ruby.h" + +/** + * interned symbol for "call" + */ +extern VALUE ruby_call_symbol; + +/** + * id for respond_to? + */ +extern VALUE ruby_respond_to_ID; + +/** + * Determine whether or not a value can respond to "call". + * i.e. is this Proc/Method object? + */ +bool is_callable(VALUE& object); + +/** + * Debugging aid. Println debugging goo for VALUES. + */ +VALUE v8_what_is_this(VALUE self, VALUE object); + +#endif \ No newline at end of file