Pyrogenesis HEAD
Pyrogenesis, a RTS Engine
Conversions.cpp File Reference
#include "precompiled.h"
#include "Conversions.h"
#include "graphics/Entity.h"
#include "lib/path.h"
#include "ps/CStr.h"
#include "scriptinterface/Exceptions.h"
#include "scriptinterface/Request.h"
#include <cstddef>
#include <js/Conversions.h>
#include <js/GCAPI.h>
#include <js/String.h>
#include <jsapi.h>
#include <string>
Include dependency graph for Conversions.cpp:

Namespaces

namespace  Script
 Abstraction around a SpiderMonkey JSContext.
 

Macros

#define FAIL(msg)   STMT(Exception::Raise(rq, msg); Exception::CatchPending(rq); Exception::ReportUncatchable(rq); return false)
 
#define FAIL_IF_NOT(c, v)
 

Functions

template<>
bool Script::FromJSVal< bool > (const Request &rq, JS::HandleValue v, bool &out)
 
template<>
bool Script::FromJSVal< float > (const Request &rq, JS::HandleValue v, float &out)
 
template<>
bool Script::FromJSVal< double > (const Request &rq, JS::HandleValue v, double &out)
 
template<>
bool Script::FromJSVal< std::int32_t > (const Request &rq, JS::HandleValue v, std::int32_t &out)
 
template<>
bool Script::FromJSVal< std::uint32_t > (const Request &rq, JS::HandleValue v, std::uint32_t &out)
 
template<>
bool Script::FromJSVal< std::uint16_t > (const Request &rq, JS::HandleValue v, std::uint16_t &out)
 
template<>
bool Script::FromJSVal< std::uint8_t > (const Request &rq, JS::HandleValue v, std::uint8_t &out)
 
template<>
bool Script::FromJSVal< std::wstring > (const Request &rq, JS::HandleValue v, std::wstring &out)
 
template<>
bool Script::FromJSVal< Path > (const Request &rq, JS::HandleValue v, Path &out)
 
template<>
bool Script::FromJSVal< std::string > (const Request &rq, JS::HandleValue v, std::string &out)
 
template<>
bool Script::FromJSVal< CStr8 > (const Request &rq, JS::HandleValue v, CStr8 &out)
 
template<>
bool Script::FromJSVal< CStrW > (const Request &rq, JS::HandleValue v, CStrW &out)
 
template<>
bool Script::FromJSVal< Entity > (const Request &rq, JS::HandleValue v, Entity &out)
 
template<>
void Script::ToJSVal< bool > (const Request &, JS::MutableHandleValue ret, const bool &val)
 
template<>
void Script::ToJSVal< float > (const Request &, JS::MutableHandleValue ret, const float &val)
 
template<>
void Script::ToJSVal< double > (const Request &, JS::MutableHandleValue ret, const double &val)
 
template<>
void Script::ToJSVal< std::int32_t > (const Request &, JS::MutableHandleValue ret, const std::int32_t &val)
 
template<>
void Script::ToJSVal< std::uint16_t > (const Request &, JS::MutableHandleValue ret, const std::uint16_t &val)
 
template<>
void Script::ToJSVal< std::uint8_t > (const Request &, JS::MutableHandleValue ret, const std::uint8_t &val)
 
template<>
void Script::ToJSVal< std::uint32_t > (const Request &, JS::MutableHandleValue ret, const std::uint32_t &val)
 
template<>
void Script::ToJSVal< std::wstring > (const Request &rq, JS::MutableHandleValue ret, const std::wstring &val)
 
template<>
void Script::ToJSVal< Path > (const Request &rq, JS::MutableHandleValue ret, const Path &val)
 
template<>
void Script::ToJSVal< std::string > (const Request &rq, JS::MutableHandleValue ret, const std::string &val)
 
template<>
void Script::ToJSVal< const wchar_t * > (const Request &rq, JS::MutableHandleValue ret, const wchar_t *const &val)
 
template<>
void Script::ToJSVal< const char * > (const Request &rq, JS::MutableHandleValue ret, const char *const &val)
 
template<>
void Script::ToJSVal< CStrW > (const Request &rq, JS::MutableHandleValue ret, const CStrW &val)
 
template<>
void Script::ToJSVal< CStr8 > (const Request &rq, JS::MutableHandleValue ret, const CStr8 &val)
 
template<>
void Script::ToJSVal< std::vector< IComponent * > > (const Script::Request &rq, JS::MutableHandleValue ret, const std::vector< IComponent * > &val)
 
template<>
bool Script::FromJSVal< std::vector< Entity > > (const Script::Request &rq, JS::HandleValue v, std::vector< Entity > &out)
 

Macro Definition Documentation

◆ FAIL

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

◆ FAIL_IF_NOT

#define FAIL_IF_NOT (   c,
  v 
)
Value:
STMT(if (!(c)) { \
Exception::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 ReportUncatchable(const Request &rq)
Since ESR140, SpiderMonkey asserts in debug builds that a JSNative returning false reported an except...
Definition: Exceptions.cpp:111
void Raise(const Request &rq, const char *format,...)
Raise a JS exception from C++ code.
Definition: Exceptions.cpp:117
bool CatchPending(const Request &rq)
Log and then clear the current pending exception.
Definition: Exceptions.cpp:49

Function Documentation

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

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

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

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