mirror of
https://gitea.wildfiregames.com/0ad/0ad.git
synced 2026-07-24 02:34:04 +00:00
# Fixed some warnings and potentially misleading code
* Removed ToJSVal<jsval> because it's treated as ToJSVal<long> and causes minor confusion and/or compiler errors. Changed script interface functions to return either C++ types or a jsval_t wrapper. * Replaced some C casts with static_cast to avoid significant confusion and to cause compiler errors instead. * Removed some redundant argument-checking code. Simplified some string-generating code. * Fixed some "dereferencing type-punned pointer will break strict-aliasing rules" warnings (from `g++ -O3`). This was SVN commit r5115.
This commit is contained in:
@@ -43,7 +43,7 @@ void CProductionItem::ScriptingInit()
|
||||
AddProperty(L"name", &CProductionItem::m_name, true);
|
||||
AddProperty(L"elapsedTime", &CProductionItem::m_elapsedTime, true);
|
||||
AddProperty(L"totalTime", &CProductionItem::m_totalTime, true);
|
||||
AddProperty(L"progress", (GetFn)&CProductionItem::JSI_GetProgress);
|
||||
AddProperty(L"progress", static_cast<GetFn>(&CProductionItem::JSI_GetProgress));
|
||||
CJSObject<CProductionItem>::ScriptingInit("ProductionItem");
|
||||
}
|
||||
|
||||
@@ -103,12 +103,12 @@ jsval CProductionQueue::JSI_GetLength( JSContext* UNUSED(cx) )
|
||||
return ToJSVal( (int) m_items.size() );
|
||||
}
|
||||
|
||||
jsval CProductionQueue::JSI_Get( JSContext* cx, uintN argc, jsval* argv )
|
||||
jsval_t CProductionQueue::JSI_Get( JSContext* cx, uintN argc, jsval* argv )
|
||||
{
|
||||
debug_assert( argc == 1 );
|
||||
debug_assert( JSVAL_IS_INT(argv[0]) );
|
||||
|
||||
int index = ToPrimitive<int>( argv[0] );
|
||||
int index = ToPrimitive<int>( argv[0] );
|
||||
|
||||
if(index < 0 || index >= (int)m_items.size() )
|
||||
{
|
||||
@@ -124,7 +124,7 @@ bool CProductionQueue::JSI_Cancel( JSContext* cx, uintN argc, jsval* argv )
|
||||
debug_assert( argc == 1 );
|
||||
debug_assert( JSVAL_IS_INT(argv[0]) );
|
||||
|
||||
int index = ToPrimitive<int>( argv[0] );
|
||||
int index = ToPrimitive<int>( argv[0] );
|
||||
|
||||
if(index < 0 || index >= (int)m_items.size() )
|
||||
{
|
||||
@@ -141,8 +141,8 @@ bool CProductionQueue::JSI_Cancel( JSContext* cx, uintN argc, jsval* argv )
|
||||
|
||||
void CProductionQueue::ScriptingInit()
|
||||
{
|
||||
AddProperty(L"length", (GetFn)&CProductionQueue::JSI_GetLength);
|
||||
AddMethod<jsval, &CProductionQueue::JSI_Get>( "get", 1 );
|
||||
AddProperty(L"length", static_cast<GetFn>(&CProductionQueue::JSI_GetLength));
|
||||
AddMethod<jsval_t, &CProductionQueue::JSI_Get>( "get", 1 );
|
||||
AddMethod<bool, &CProductionQueue::JSI_Cancel>( "cancel", 1 );
|
||||
CJSObject<CProductionQueue>::ScriptingInit("ProductionQueue");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user