mirror of
https://github.com/rubyjs/therubyracer
synced 2023-03-27 23:21:42 -04:00
ditto
This commit is contained in:
parent
2652edbe3c
commit
5f1ce0f692
3 changed files with 94 additions and 0 deletions
9
v8_data.cpp
Normal file
9
v8_data.cpp
Normal file
|
@ -0,0 +1,9 @@
|
|||
#include "v8_data.h"
|
||||
|
||||
V8HandleDest::V8HandleDest() {
|
||||
|
||||
}
|
||||
|
||||
V8HandleDest::~V8HandleDest() {
|
||||
|
||||
}
|
58
v8_standalone.cpp
Normal file
58
v8_standalone.cpp
Normal file
|
@ -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!<br/>");
|
||||
}
|
||||
break;
|
||||
case T_CLASS:
|
||||
printf("class[%s]<br/>", 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!<br/>");
|
||||
} else {
|
||||
printf("Does *NOT* respond to call<br/>");
|
||||
}
|
||||
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;
|
||||
}
|
27
v8_standalone.h
Normal file
27
v8_standalone.h
Normal file
|
@ -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
|
Loading…
Add table
Reference in a new issue