Function property Getter/Setters now take a JSContext parameter.

This was SVN commit r2996.
This commit is contained in:
prefect 2005-10-24 02:32:44 +00:00
parent 52a8793450
commit 7362d746d5
6 changed files with 17 additions and 17 deletions

View File

@ -34,13 +34,13 @@ void CPlayerSlot::ScriptingInit()
AddMethod<bool, &CPlayerSlot::JSI_AssignToSession>("assignToSession", 1);
AddMethod<bool, &CPlayerSlot::JSI_AssignLocal>("assignLocal", 0);
AddMethod<bool, &CPlayerSlot::JSI_AssignOpen>("assignOpen", 0);
AddProperty(L"assignment", (GetFn)&CPlayerSlot::JSI_GetAssignment);
AddProperty(L"assignment", &CPlayerSlot::JSI_GetAssignment);
// AddMethod<bool, &CPlayerSlot::JSI_AssignAI>("assignAI", <num_args>);
CJSObject<CPlayerSlot>::ScriptingInit("PlayerSlot");
}
jsval CPlayerSlot::JSI_GetSession()
jsval CPlayerSlot::JSI_GetSession(JSContext* UNUSED(cx))
{
if (m_pSession)
return OBJECT_TO_JSVAL(m_pSession->GetScript());
@ -48,7 +48,7 @@ jsval CPlayerSlot::JSI_GetSession()
return JSVAL_NULL;
}
jsval CPlayerSlot::JSI_GetAssignment()
jsval CPlayerSlot::JSI_GetAssignment(JSContext* UNUSED(cx))
{
switch (m_Assignment)
{

View File

@ -43,8 +43,8 @@ class CPlayerSlot: public CJSObject<CPlayerSlot>
// TODO This will wait until there actually is AI to set up
// bool JSI_AssignAI(JSContext *cx, uintN argc, jsval *argv);
jsval JSI_GetSession();
jsval JSI_GetAssignment();
jsval JSI_GetSession(JSContext* cx);
jsval JSI_GetAssignment(JSContext* cx);
void CallCallback();
void SetAssignment(EPlayerSlotAssignment, CNetServerSession *pSession, int sessionID);

View File

@ -40,7 +40,7 @@ void CPlayer::ScriptingInit()
// AddClassProperty( L"name", &CPlayer::m_Name );
// AddClassProperty( L"colour", &CPlayer::m_Colour );
AddProperty( L"controlled", (IJSObject::GetFn)&CPlayer::JSI_GetControlledEntities );
AddProperty( L"controlled", &CPlayer::JSI_GetControlledEntities );
CJSObject<CPlayer>::ScriptingInit( "Player" );
}
@ -84,7 +84,7 @@ jsval CPlayer::JSI_ToString( JSContext* cx, uintN UNUSED(argc), jsval* UNUSED(ar
return( STRING_TO_JSVAL( JS_NewUCStringCopyZ( cx, str16.c_str() ) ) );
}
jsval CPlayer::JSI_GetControlledEntities()
jsval CPlayer::JSI_GetControlledEntities(JSContext* UNUSED(cx))
{
std::vector<HEntity>* controlledSet = GetControlledEntities();
jsval vp = OBJECT_TO_JSVAL( EntityCollection::Create( *controlledSet ) );

View File

@ -59,7 +59,7 @@ public:
// JS Interface Functions
jsval JSI_ToString( JSContext* context, uintN argc, jsval* argv );
jsval JSI_GetControlledEntities();
jsval JSI_GetControlledEntities( JSContext* context );
jsval JSI_SetColour(JSContext *context, uintN argc, jsval *argv);
static void ScriptingInit();

View File

@ -90,7 +90,7 @@ public:
// Javascript stuff...
static void ScriptingInit();
jsval JS_GetName() { return( ToJSVal( CStrW( name ) ) ); }
jsval JS_GetName(JSContext*) { return( ToJSVal( CStrW( name ) ) ); }
};
class CProfileManager : public Singleton<CProfileManager>

View File

@ -29,8 +29,8 @@ public:
typedef STL_HASH_MAP<CStrW, IJSProperty*, CStrW_hash_compare> PropertyTable;
// Property getters and setters
typedef jsval (IJSObject::*GetFn)();
typedef void (IJSObject::*SetFn)( jsval value );
typedef jsval (IJSObject::*GetFn)( JSContext* cx );
typedef void (IJSObject::*SetFn)( JSContext* cx, jsval value );
// Return a pointer to a property, if it exists
virtual IJSProperty* HasProperty( CStrW PropertyName ) = 0;
@ -107,14 +107,14 @@ public:
// Must at least be able to read
debug_assert( m_Getter );
}
jsval Get( JSContext* UNUSED(cx), IJSObject* obj )
jsval Get( JSContext* cx, IJSObject* obj )
{
return( (obj->*m_Getter)() );
return( (obj->*m_Getter)(cx) );
}
void Set( JSContext* UNUSED(cx), IJSObject* obj, jsval value )
void Set( JSContext* cx, IJSObject* obj, jsval value )
{
if( m_Setter )
(obj->*m_Setter)( value );
(obj->*m_Setter)( cx, value );
}
};
@ -195,8 +195,8 @@ protected:
public:
// Property getters and setters
typedef jsval (T::*TGetFn)();
typedef void (T::*TSetFn)( jsval value );
typedef jsval (T::*TGetFn)( JSContext* );
typedef void (T::*TSetFn)( JSContext*, jsval value );
static JSClass JSI_class;