mirror of
https://gitea.wildfiregames.com/0ad/0ad.git
synced 2026-07-23 23:51:49 +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:
@@ -171,6 +171,23 @@ public:
|
||||
}
|
||||
};
|
||||
|
||||
// Special case for void functions
|
||||
template<typename T, bool ReadOnly, void (T::*NativeFunction)( JSContext* cx, uintN argc, jsval* argv )>
|
||||
class CNativeFunction<T, ReadOnly, void, NativeFunction>
|
||||
{
|
||||
public:
|
||||
static JSBool JSFunction( JSContext* cx, JSObject* obj, uintN argc, jsval* argv, jsval* UNUSED(rval) )
|
||||
{
|
||||
T* Native = ToNative<T>( cx, obj );
|
||||
if( !Native )
|
||||
return( JS_TRUE );
|
||||
|
||||
(Native->*NativeFunction)( cx, argc, argv );
|
||||
|
||||
return( JS_TRUE );
|
||||
}
|
||||
};
|
||||
|
||||
template<typename T, bool ReadOnly> class CJSObject : public IJSObject
|
||||
{
|
||||
// This object
|
||||
|
||||
Reference in New Issue
Block a user