1
0
Fork 0
mirror of https://github.com/rubyjs/therubyracer synced 2023-03-27 23:21:42 -04:00
therubyracer/ext/v8/function.cc
2012-06-12 07:06:25 -05:00

58 lines
No EOL
1.8 KiB
C++

#include "rr.h"
namespace rr {
void Function::Init() {
ClassBuilder("Function", Object::Class).
defineMethod("NewInstance", &NewInstance).
defineMethod("Call", &Call).
defineMethod("SetName", &SetName).
defineMethod("GetName", &GetName).
defineMethod("GetInferredName", &GetInferredName).
defineMethod("GetScriptLineNumber", &GetScriptLineNumber).
defineMethod("GetScriptColumnNumber", &GetScriptColumnNumber).
defineMethod("GetScriptId", &GetScriptId).
defineMethod("GetScriptOrigin", &GetScriptOrigin).
store(&Class);
}
VALUE Function::NewInstance(int argc, VALUE argv[], VALUE self) {
VALUE args;
rb_scan_args(argc,argv,"01", &args);
if (RTEST(args)) {
return Object(Function(self)->NewInstance(RARRAY_LENINT(args), Value::array<Value>(args)));
} else {
return Object(Function(self)->NewInstance());
}
}
VALUE Function::Call(VALUE self, VALUE receiver, VALUE argv) {
return Value(Function(self)->Call(Object(receiver), RARRAY_LENINT(argv), Value::array<Value>(argv)));
}
VALUE Function::SetName(VALUE self, VALUE name) {
Void(Function(self)->SetName(String(name)));
}
VALUE Function::GetName(VALUE self) {
return Value(Function(self)->GetName());
}
VALUE Function::GetInferredName(VALUE self) {
return Value(Function(self)->GetInferredName());
}
VALUE Function::GetScriptLineNumber(VALUE self) {
return INT2FIX(Function(self)->GetScriptLineNumber());
}
VALUE Function::GetScriptColumnNumber(VALUE self) {
return INT2FIX(Function(self)->GetScriptColumnNumber());
}
VALUE Function::GetScriptId(VALUE self) {
return Value(Function(self)->GetScriptId());
}
VALUE Function::GetScriptOrigin(VALUE self) {
return not_implemented("GetScriptOrigin");
}
}