Sirikata
Namespaces | Defines | Functions
liboh/plugins/js/JSUtil.hpp File Reference
#include <sirikata/oh/Platform.hpp>
#include <v8.h>
Include dependency graph for JSUtil.hpp:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Namespaces

namespace  Sirikata
 

Note: All the classes provided in this file are thin wrappers around the corresponding classes in ASIO.


namespace  Sirikata::JS

Defines

#define JS_STRING(x)   (v8::String::New( #x ))
#define NumericCheckAndExtract(native, value)
#define StringCheckAndExtract(native, value)
#define ObjectCheckAndCast(result, value)
#define FunctionCheckAndCast(result, value)

Functions

bool Sirikata::JS::StringValidate (const Handle< Value > &val)
std::string Sirikata::JS::StringExtract (const Handle< Value > &val)
bool Sirikata::JS::NumericValidate (const Handle< Value > &val)
double Sirikata::JS::NumericExtract (const Handle< Value > &val)
Handle< Value > Sirikata::JS::CreateJSResult (Handle< Object > &orig, const double &src)
Handle< Value > Sirikata::JS::CreateJSResult (v8::Handle< v8::Context > &ctx, const double &src)
Handle< Value > Sirikata::JS::CreateJSResult (Handle< Object > &orig, const float &src)
Handle< Value > Sirikata::JS::CreateJSResult (v8::Handle< v8::Context > &ctx, const float &src)
v8::Handle< v8::Object > Sirikata::JS::ObjectCast (const v8::Handle< v8::Value > &v)
v8::Handle< v8::Function > Sirikata::JS::FunctionCast (const v8::Handle< v8::Value > &v)
Handle< Value > Sirikata::JS::GetGlobal (v8::Handle< v8::Context > &ctx, const char *obj_name)
String Sirikata::JS::FromV8String (const v8::String::Utf8Value &v8str)

Define Documentation

#define FunctionCheckAndCast (   result,
  value 
)
Value:
if (!value->IsFunction())                                           \
        return v8::ThrowException( v8::Exception::TypeError(v8::String::New("Expected function.")) ); \
    Handle<Function> result = Handle<Function>::Cast(value);
#define JS_STRING (   x)    (v8::String::New( #x ))
#define NumericCheckAndExtract (   native,
  value 
)
Value:
if (!NumericValidate(value))                                        \
        return v8::ThrowException( v8::Exception::TypeError(v8::String::New("Value couldn't be interpreted as numeric.")) ); \
    double native = NumericExtract(value);

Referenced by Sirikata::JS::QuaternionConstructor(), and Sirikata::JS::Vec3Constructor().

#define ObjectCheckAndCast (   result,
  value 
)
Value:
if (!value->IsObject())                                             \
        return v8::ThrowException( v8::Exception::TypeError(v8::String::New("Expected object.")) ); \
    Handle<Object> result = Handle<Object>::Cast(value);

Referenced by Sirikata::JS::QuaternionConstructor().

#define StringCheckAndExtract (   native,
  value 
)
Value:
if (!StringValidate(value))                                         \
        return v8::ThrowException( v8::Exception::TypeError(v8::String::New("Value couldn't be interpreted as string.")) ); \
    std::string native = StringExtract(value);

Referenced by Sirikata::JS::JSSystem::commonRequire(), and Sirikata::JS::JSSystem::evalInGlobal().