Pyrogenesis HEAD
Pyrogenesis, a RTS Engine
ScriptConversions.cpp File Reference
#include "precompiled.h"
#include "ScriptConversions.h"
#include "ScriptExceptions.h"
#include "ScriptExtraHeaders.h"
#include "graphics/Entity.h"
#include "lib/file/vfs/vfs_path.h"
#include "maths/Vector2D.h"
#include "ps/CLogger.h"
#include "ps/CStr.h"
#include <string>
Include dependency graph for ScriptConversions.cpp:

Macros

#define FAIL(msg)   STMT(ScriptException::Raise(rq, msg); ScriptException::CatchPending(rq); return false)
 
#define FAIL_IF_NOT(c, v)
 
#define TOJSVAL_CHAR(N)
 

Functions

template<>
bool Script::FromJSVal< std::wstring > (const ScriptRequest &rq, JS::HandleValue v, std::wstring &out)
 
template<>
bool Script::FromJSVal< std::string > (const ScriptRequest &rq, JS::HandleValue v, std::string &out)
 
template<>
void Script::ToJSVal< std::wstring > (const ScriptRequest &rq, JS::MutableHandleValue ret, const std::wstring &val)
 
template<>
void Script::ToJSVal< std::string > (const ScriptRequest &rq, JS::MutableHandleValue ret, const std::string &val)
 
template<>
void Script::ToJSVal< std::vector< IComponent * > > (const ScriptRequest &rq, JS::MutableHandleValue ret, const std::vector< IComponent * > &val)
 
template<>
bool Script::FromJSVal< std::vector< Entity > > (const ScriptRequest &rq, JS::HandleValue v, std::vector< Entity > &out)
 

Macro Definition Documentation

◆ FAIL

#define FAIL (   msg)    STMT(ScriptException::Raise(rq, msg); ScriptException::CatchPending(rq); return false)

◆ FAIL_IF_NOT

#define FAIL_IF_NOT (   c,
 
)
Value:
STMT(if (!(c)) { \
ScriptException::Raise(rq, "Script value conversion check failed: %s (got type %s)", #c, JS::InformalValueTypeName(v)); \
return false; \
})
#define STMT(STMT_code__)
package code into a single statement.
Definition: code_generation.h:41
void Raise(const ScriptRequest &rq, const char *format,...)
Raise a JS exception from C++ code.
Definition: ScriptExceptions.cpp:95
bool CatchPending(const ScriptRequest &rq)
Log and then clear the current pending exception.
Definition: ScriptExceptions.cpp:33

◆ TOJSVAL_CHAR

#define TOJSVAL_CHAR (   N)
Value:
template<> void Script::ToJSVal<wchar_t[N]>(const ScriptRequest& rq, JS::MutableHandleValue ret, const wchar_t (&val)[N]) \
{ \
ToJSVal(rq, ret, static_cast<const wchar_t*>(val)); \
} \
template<> void Script::ToJSVal<char[N]>(const ScriptRequest& rq, JS::MutableHandleValue ret, const char (&val)[N]) \
{ \
ToJSVal(rq, ret, static_cast<const char*>(val)); \
}
Spidermonkey maintains some 'local' state via the JSContext* object.
Definition: ScriptRequest.h:60

Function Documentation

◆ Script::FromJSVal< std::string >()

template<>
bool Script::FromJSVal< std::string > ( const ScriptRequest rq,
JS::HandleValue  v,
std::string &  out 
)

◆ Script::FromJSVal< std::vector< Entity > >()

template<>
bool Script::FromJSVal< std::vector< Entity > > ( const ScriptRequest rq,
JS::HandleValue  v,
std::vector< Entity > &  out 
)

◆ Script::FromJSVal< std::wstring >()

template<>
bool Script::FromJSVal< std::wstring > ( const ScriptRequest rq,
JS::HandleValue  v,
std::wstring &  out 
)

◆ Script::ToJSVal< std::string >()

template<>
void Script::ToJSVal< std::string > ( const ScriptRequest rq,
JS::MutableHandleValue  ret,
const std::string &  val 
)

◆ Script::ToJSVal< std::vector< IComponent * > >()

template<>
void Script::ToJSVal< std::vector< IComponent * > > ( const ScriptRequest rq,
JS::MutableHandleValue  ret,
const std::vector< IComponent * > &  val 
)

◆ Script::ToJSVal< std::wstring >()

template<>
void Script::ToJSVal< std::wstring > ( const ScriptRequest rq,
JS::MutableHandleValue  ret,
const std::wstring &  val 
)