1
0
forked from mirrors/0ad

# housekeeping

add new JSUtil, automatically included via SpiderMonkey.h.
move JS_ASSERT there and rename JSU_ASSERT.
move scriptglue's REQUIRE_PARAMS there and rename to JSU_*
replace if(argc < x) bail() code with those macros.

This was SVN commit r4169.
This commit is contained in:
janwas
2006-07-26 13:10:13 +00:00
parent 2261231ffa
commit 37c87a6579
9 changed files with 189 additions and 233 deletions
+12 -19
View File
@@ -159,28 +159,21 @@ JSBool JSI_Vector3D::construct( JSContext* cx, JSObject* UNUSED(obj), uintN argc
*rval = OBJECT_TO_JSVAL( vector );
return( JS_TRUE );
}
else if( argc == 3 )
JSU_REQUIRE_PARAMS(3);
try
{
try
{
float x = ToPrimitive<float>( argv[0] );
float y = ToPrimitive<float>( argv[1] );
float z = ToPrimitive<float>( argv[2] );
JS_SetPrivate( cx, vector, new Vector3D_Info( x, y, z ) );
*rval = OBJECT_TO_JSVAL( vector );
return( JS_TRUE );
}
catch (PSERROR_Scripting_ConversionFailed)
{
// Invalid input (i.e. can't be coerced into doubles) - fail
JS_ReportError( cx, "Invalid parameters to Vector3D constructor" );
*rval = JSVAL_NULL;
return( JS_FALSE );
}
float x = ToPrimitive<float>( argv[0] );
float y = ToPrimitive<float>( argv[1] );
float z = ToPrimitive<float>( argv[2] );
JS_SetPrivate( cx, vector, new Vector3D_Info( x, y, z ) );
*rval = OBJECT_TO_JSVAL( vector );
return( JS_TRUE );
}
else
catch (PSERROR_Scripting_ConversionFailed)
{
JS_ReportError( cx, "Invalid number of parameters to Vector3D constructor" );
// Invalid input (i.e. can't be coerced into doubles) - fail
JS_ReportError( cx, "Invalid parameters to Vector3D constructor" );
*rval = JSVAL_NULL;
return( JS_FALSE );
}