Pyrogenesis trunk
Macros | Functions
MessageTypeConversions.cpp File Reference
#include "precompiled.h"
#include "ps/CLogger.h"
#include "scriptinterface/ScriptConversions.h"
#include "simulation2/MessageTypes.h"
#include "simulation2/TypeList.h"
Include dependency graph for MessageTypeConversions.cpp:

Macros

#define TOJSVAL_SETUP()
 
#define SET_MSG_PROPERTY(name)
 
#define FROMJSVAL_SETUP()
 
#define GET_MSG_PROPERTY(type, name)
 
#define MESSAGE_1(name, t0, a0)
 
#define MESSAGE(name)   case MT_##name: return CMessage##name::FromJSVal(rq, val);
 
#define INTERFACE(name)
 
#define COMPONENT(name)
 

Functions

CMessageCMessageFromJSVal (int mtid, const ScriptRequest &rq, JS::HandleValue val)
 

Macro Definition Documentation

◆ COMPONENT

#define COMPONENT (   name)

◆ FROMJSVAL_SETUP

#define FROMJSVAL_SETUP ( )
Value:
if (val.isPrimitive()) \
return NULL; \
JS::RootedObject obj(rq.cx, &val.toObject()); \
JS::RootedValue prop(rq.cx);

◆ GET_MSG_PROPERTY

#define GET_MSG_PROPERTY (   type,
  name 
)
Value:
type name; \
{ \
if (! JS_GetProperty(rq.cx, obj, #name, &prop)) \
return NULL; \
if (! Script::FromJSVal(rq, prop, name)) \
return NULL; \
}
bool FromJSVal(const ScriptRequest &rq, const JS::HandleValue val, T &ret)
Convert a JS::Value to a C++ type.

◆ INTERFACE

#define INTERFACE (   name)

◆ MESSAGE

#define MESSAGE (   name)    case MT_##name: return CMessage##name::FromJSVal(rq, val);

◆ MESSAGE_1

#define MESSAGE_1 (   name,
  t0,
  a0 
)
Value:
{ \
TOJSVAL_SETUP(); \
SET_MSG_PROPERTY(a0); \
return JS::ObjectValue(*obj); \
} \
CMessage* CMessage##name::FromJSVal(const ScriptRequest& rq, JS::HandleValue val) \
{ \
FROMJSVAL_SETUP(); \
GET_MSG_PROPERTY(t0, a0); \
return new CMessage##name(a0); \
}
Definition: Message.h:26
Spidermonkey maintains some 'local' state via the JSContext* object.
Definition: ScriptRequest.h:60
void ToJSVal(const ScriptRequest &rq, JS::MutableHandleValue ret, T const &val)
Convert a C++ type to a JS::Value.
Config::Value_type Value
Definition: json_spirit_value.h:182

◆ SET_MSG_PROPERTY

#define SET_MSG_PROPERTY (   name)
Value:
do { \
JS::RootedValue prop(rq.cx);\
Script::ToJSVal(rq, &prop, this->name); \
if (! JS_SetProperty(rq.cx, obj, #name, prop)) \
return JS::UndefinedValue(); \
} while (0);

◆ TOJSVAL_SETUP

#define TOJSVAL_SETUP ( )
Value:
JS::RootedObject obj(rq.cx, JS_NewPlainObject(rq.cx)); \
if (!obj) \
return JS::UndefinedValue();

Function Documentation

◆ CMessageFromJSVal()

CMessage * CMessageFromJSVal ( int  mtid,
const ScriptRequest rq,
JS::HandleValue  val 
)