uox3/source/JSEncapsulate.h
Xoduz 29acded626 Misc JS-related fixes/changes
Fixed an issue where the JS function TriggerEvent() didn't restore the original JSContext and JSObject of the calling script after calling an event in a separate script, causing timers to be associated with the wrong script when both TriggerEvent and StartTimer were used in same script
(In a previous commit) Updated KillTimers JS method to support an optional argument specifying the timerID of the timer to be killed. If no arguments are provided, it will - as previously - kill all timers for the object
2021-05-25 19:48:49 +08:00

51 lines
976 B
C++

#include "Prerequisites.h"
#include "typedefs.h"
enum JSEncapsObjectType
{
JSOT_INT = 0,
JSOT_DOUBLE,
JSOT_BOOL,
JSOT_STRING,
JSOT_OBJECT,
JSOT_NULL,
JSOT_VOID,
JSOT_COUNT
};
class JSEncapsulate
{
public:
JSEncapsulate( JSContext *jsCX, jsval *jsVP );
JSEncapsulate( JSContext *jsCX, JSObject *jsVP );
JSEncapsulate();
void SetContext( JSContext *jsCX, jsval *jsVP );
bool isType( JSEncapsObjectType toCheck );
SI32 toInt( void );
bool toBool( void );
R32 toFloat( void );
std::string toString( void );
void * toObject( void );
std::string ClassName( void );
private:
void InternalReset( void );
void Init( void );
bool beenParsed[JSOT_COUNT+1];
JSEncapsObjectType nativeType;
SI32 intVal;
R32 floatVal;
bool boolVal;
std::string stringVal;
void * objectVal;
JSContext * cx;
jsval * vp;
JSObject * obj;
std::string className;
bool classCached;
void Parse( JSEncapsObjectType typeConvert );
};