1
0
Fork 0
mirror of https://github.com/rubyjs/therubyracer synced 2023-03-27 23:21:42 -04:00
therubyracer/v8_data.h
Bill Robertson be8f4b2594 Tweak extconf to generate test target that
calls ruby spec.
2009-10-15 23:45:53 -04:00

80 lines
1.3 KiB
C++

#ifndef __v8_data_h__
#define __v8_data_h__
#include "v8.h"
#include "stdint.h"
#include <stdio.h>
template<class T, class R> class V8HandleSource {
T dest;
public:
V8HandleSource() {}
~V8HandleSource() {}
R push(v8::Handle<v8::Value>& value, const char* name = 0) {
if(value->IsNull()) {
return dest.pushNull(name);
}
if(value->IsTrue()) {
return dest.pushBool(true, name);
}
if(value->IsFalse()) {
return dest.pushBool(false, name);
}
if(value->IsString()) {
//v8::Local<v8:String::AsciiValue> strValue(value->ToString());
return dest.pushString("", name);
}
if(value->IsInt32()) {
return dest.pushInt(value->Int32Value(), name);
}
if(value->IsNumber()) {
return dest.pushDouble(value->NumberValue(), name);
}
}
};
/*
class V8ScopeDest {
v8::Context::Scope& scope;
public:
V8ScopeDest(v8::Context::Scope& scope);
~V8ScopeDest();
bool pushString(const char* value, const char* name=0) {
// convert and insert
return false;
}
bool pushInt(int64_t value, const char* name=0) {
return pushDouble(value, name);
}
bool pushDouble(double value, const char* name=0) {
// convert and insert
return false;
}
bool pushBool(bool value, const char* name=0) {
// convert and insert
return false;
}
};
*/
#endif