Sirikata
Namespaces | Defines | Functions
liboh/plugins/js/JSObjects/JSObjectsUtils.hpp File Reference
#include <v8.h>
#include <sirikata/core/util/Platform.hpp>
#include "../JSObjectStructs/JSPositionListener.hpp"
Include dependency graph for JSObjectsUtils.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 V8_EXCEPTION_STRING(stringErrMsg)   return v8::ThrowException(v8::Exception::Error(v8::String::New(stringErrMsg.c_str(),stringErrMsg.length())));
#define V8_EXCEPTION_CSTR(cstrErrMsg)   return v8::ThrowException(v8::Exception::Error(v8::String::New(cstrErrMsg)));
#define INLINE_TIME_CONV_ERROR(toConvert, whereError, whichArg, whereWriteTo)
#define INLINE_DOUBLE_CONV_ERROR(toConvert, whereError, whichArg, whereWriteTo)
#define INLINE_INTEGER_CONV_ERROR(toConvert, whereError, whichArg, whereWriteTo)
#define INLINE_SPACEID_CONV_ERROR(toConvert, whereError, whichArg, whereWriteTo)
#define INLINE_OBJID_CONV_ERROR(toConvert, whereError, whichArg, whereWriteTo)
#define INLINE_SA_CONV_ERROR(toConvert, whereError, whichArg, whereWriteTo)
#define INLINE_DECODE_UINT_32(toConvert, whereWriteTo)
#define INLINE_DECODE_UINT_32_ERROR(toConvert, whereError, whichArg, whereWriteTo)
#define INLINE_STR_CONV_ERROR(toConvert, whereError, whichArg, whereWriteTo)
#define INLINE_STR_CONV(toConvert, whereWriteTo, defaultArg)

Functions

JSPositionListener * Sirikata::JS::decodeJSPosListener (v8::Handle< v8::Value > toDecode, String &errorMessage)
bool Sirikata::JS::decodeString (v8::Handle< v8::Value > toDecode, String &decodedValue, String &errorMessage)
bool Sirikata::JS::decodeBool (v8::Handle< v8::Value > toDecode, bool &decodedValue, String &errorMessage)
bool Sirikata::JS::decodeSporef (v8::Handle< v8::Value > toDecode, SpaceObjectReference &sporef, String &errorMessage)
bool Sirikata::JS::decodeSpaceID (v8::Handle< v8::Value > toDecode, SpaceID &space, String &errorMessage)
bool Sirikata::JS::decodeObjectReference (v8::Handle< v8::Value > toDecode, ObjectReference &oref, String &errorMessage)
bool Sirikata::JS::decodeUint64FromString (v8::Handle< v8::Value > toDecode, uint64 &decodedInt, String &errorMessage)
bool Sirikata::JS::decodeTimedMotionVector (v8::Handle< v8::Value >toDecodePos, v8::Handle< v8::Value >toDecodeVel, v8::Handle< v8::Value >toDecodeTimeAsString, TimedMotionVector3f &toDecodeTo, String &errorMessage)
bool Sirikata::JS::decodeTimedMotionQuat (v8::Handle< v8::Value > orientationQuat, v8::Handle< v8::Value > orientationVelQuat, v8::Handle< v8::Value > toDecodeTimeAsString, TimedMotionQuaternion &toDecodeTo, String &errorMessage)
bool Sirikata::JS::decodeBoundingSphere3f (v8::Handle< v8::Value > toDecodeCenterVec, v8::Handle< v8::Value > toDecodeRadius, BoundingSphere3f &toDecodeTo, String &errMsg)
bool Sirikata::JS::decodeInt64 (v8::Handle< v8::Value > toDecode, int64 &toDecodeTo, String &errMsg)
bool Sirikata::JS::decodeUint32 (v8::Handle< v8::Value > toDecode, uint32 &toDecodeTo, String &errMsg)
bool Sirikata::JS::decodeSolidAngle (v8::Handle< v8::Value > toDecode, SolidAngle &toDecodeTo, String &errMsg)
bool Sirikata::JS::decodeDouble (v8::Handle< v8::Value > toDecode, double &toDecodeTo, String &errMsg)
bool Sirikata::JS::decodeTimeFromString (v8::Handle< v8::Value > toDecode, Time &toDecodeTo, String &errorMessage)
void Sirikata::JS::debug_checkCurrentContextX (v8::Handle< v8::Context > ctx, String additionalMessage)
void Sirikata::JS::printAllPropertyNames (v8::Handle< v8::Object > objToPrint)
String Sirikata::JS::uint16StrToStr (v8::Handle< v8::String > toDeserialize)
v8::Handle< v8::Value > Sirikata::JS::strToUint16Str (const String &toSerialize)

Define Documentation

#define INLINE_DECODE_UINT_32 (   toConvert,
  whereWriteTo 
)
Value:
uint32 whereWriteTo; \
    { \
        String _errMsg;                                                 \
        if (! decodeUint32(toConvert,whereWriteTo,_errMsg))             \
            JSLOG(error, "error.  cannot decode the uint32 in INLINE_DECODE_UINT_32"); \
    }
Parameters:
toConvertv8::Handle<v8::Value> that we will try to decode as a uint32
whereWriteToshould be the name of the uint32 that we want to decode the uint32 to. Shouldn't already be declared. Gets declared in the following #define.
#define INLINE_DECODE_UINT_32_ERROR (   toConvert,
  whereError,
  whichArg,
  whereWriteTo 
)
Value:
uint32 whereWriteTo; \
    { \
        String _errMsg = "In " #whereError "cannot convert " #whichArg " to uint32";\
        if (! decodeUint32(toConvert,whereWriteTo,_errMsg))             \
            return v8::ThrowException(v8::Exception::Error(v8::String::New(_errMsg.c_str(), _errMsg.length()))); \
    }

Referenced by Sirikata::JS::JSSystem::root_createContext().

#define INLINE_DOUBLE_CONV_ERROR (   toConvert,
  whereError,
  whichArg,
  whereWriteTo 
)
Value:
double whereWriteTo;                                                \
    {                                                                   \
        String _errMsg = "In " #whereError " cannot convert arg " #whichArg " to double"; \
        if (!decodeDouble(toConvert,whereWriteTo,_errMsg))        \
            V8_EXCEPTION_STRING(_errMsg);                               \
    }

Referenced by Sirikata::JS::JSUtilObj::ScriptDiv(), and Sirikata::JS::JSUtilObj::ScriptMult().

#define INLINE_INTEGER_CONV_ERROR (   toConvert,
  whereError,
  whichArg,
  whereWriteTo 
)
Value:
int64 whereWriteTo;                                                \
    {                                                                   \
        String _errMsg = "In " #whereError " cannot convert arg " #whichArg " to integer"; \
        if (!decodeInt64(toConvert,whereWriteTo,_errMsg))        \
            V8_EXCEPTION_STRING(_errMsg);                               \
    }

Referenced by Sirikata::JS::JSUtilObj::ScriptMod().

#define INLINE_OBJID_CONV_ERROR (   toConvert,
  whereError,
  whichArg,
  whereWriteTo 
)
Value:
ObjectReference whereWriteTo;                                       \
    {                                                                   \
        String _errMsg = "In " #whereError "cannot convert arg " #whichArg " to object reference"; \
        if (!decodeObjectReference(toConvert,whereWriteTo,_errMsg))             \
            return v8::ThrowException(v8::Exception::Error(v8::String::New(_errMsg.c_str(), _errMsg.length()))); \
    }

Referenced by Sirikata::JS::JSUtilObj::ScriptSporef().

#define INLINE_SA_CONV_ERROR (   toConvert,
  whereError,
  whichArg,
  whereWriteTo 
)
Value:
SolidAngle whereWriteTo;                                                   \
    {                                                                      \
        String _errMsg = "In " #whereError "cannot convert arg " #whichArg " to solid angle";     \
        if (!decodeSolidAngle(toConvert,whereWriteTo,_errMsg))                 \
            return v8::ThrowException(v8::Exception::Error(v8::String::New(_errMsg.c_str(), _errMsg.length()))); \
    }
#define INLINE_SPACEID_CONV_ERROR (   toConvert,
  whereError,
  whichArg,
  whereWriteTo 
)
Value:
SpaceID whereWriteTo;                                               \
    {                                                                   \
        String _errMsg = "In " #whereError "cannot convert arg " #whichArg " to space id"; \
        if (!decodeSpaceID(toConvert,whereWriteTo,_errMsg))             \
            return v8::ThrowException(v8::Exception::Error(v8::String::New(_errMsg.c_str(), _errMsg.length()))); \
    }

Referenced by Sirikata::JS::JSUtilObj::ScriptSporef().

#define INLINE_STR_CONV (   toConvert,
  whereWriteTo,
  defaultArg 
)
Value:
String whereWriteTo;                                               \
    {                                                                  \
        String _errMsg;                                                \
        if (!decodeString(toConvert,whereWriteTo,_errMsg))             \
        {                                                              \
            JSLOG(error,"error.  cannot decode the string value in INLINE_STR_CONV"); \
            whereWriteTo = defaultArg;                                 \
        }                                                              \
    }
Parameters:
toConvertv8::Handle<v8::Value> that we are trying to read as a string
whereWriteToshould be the name of the string that we want to decode the string to. shouldn't already be declared. Becomes declared in the #define. If string conversion failed, log error, and write default value into string.
defaultArgIf string conversion fails, set whereWriteTo string to this string.

Referenced by Sirikata::JS::getPropertyNames(), Sirikata::JS::JSSerializer::serializeFieldValueInternal(), and Sirikata::JS::JSSerializer::serializeObjectInternal().

#define INLINE_STR_CONV_ERROR (   toConvert,
  whereError,
  whichArg,
  whereWriteTo 
)
Value:
String whereWriteTo;                                                   \
    {                                                                      \
        String _errMsg = "In " #whereError "cannot convert arg " #whichArg " to string";     \
        if (!decodeString(toConvert,whereWriteTo,_errMsg))                 \
            return v8::ThrowException(v8::Exception::Error(v8::String::New(_errMsg.c_str(), _errMsg.length()))); \
    }
Parameters:
toConvertis a v8::Handle<v8::Value> that we are trying to read as a string
whereErrorshould be the name of the function that running this in. Will be part of error message if cannot decode string.
whichArgshould be a number that corresponds to which arg couldn't decode. Will be part of error message if cannot decode string.
whereWriteToshould be the name of the string that we want to decode the string to. shouldn't already be declared. Becomes declared in the #define.

Referenced by Sirikata::JS::JSSystem::emersonCompileString(), Sirikata::JS::JSSystem::pushEvalContextScopeDirectory(), Sirikata::JS::JSSystem::root_createEntity(), Sirikata::JS::JSSystem::root_createEntityNoSpace(), Sirikata::JS::JSSystem::root_http(), Sirikata::JS::JSSystem::root_print(), Sirikata::JS::JSSystem::setRestoreScript(), Sirikata::JS::JSSystem::storageCount(), Sirikata::JS::JSSystem::storageErase(), Sirikata::JS::JSSystem::storageRangeErase(), Sirikata::JS::JSSystem::storageRangeRead(), Sirikata::JS::JSSystem::storageRead(), and Sirikata::JS::JSSystem::storageWrite().

#define INLINE_TIME_CONV_ERROR (   toConvert,
  whereError,
  whichArg,
  whereWriteTo 
)
Value:
Time whereWriteTo;                                                \
    {                                                                   \
        String _errMsg = "In " #whereError " cannot convert arg " #whichArg " to Time"; \
        if (!decodeTimeFromString(toConvert,whereWriteTo,_errMsg))        \
            V8_EXCEPTION_STRING(_errMsg);                               \
    }

Referenced by Sirikata::JS::JSSystem::root_restorePresence().

#define V8_EXCEPTION_CSTR (   cstrErrMsg)    return v8::ThrowException(v8::Exception::Error(v8::String::New(cstrErrMsg)));
#define V8_EXCEPTION_STRING (   stringErrMsg)    return v8::ThrowException(v8::Exception::Error(v8::String::New(stringErrMsg.c_str(),stringErrMsg.length())));