1
0
mirror of https://github.com/VCMP-SqMod/SqMod.git synced 2025-01-31 09:57:14 +01:00

Implement the pure typename meta-methods in entity types using the standard method.

This commit is contained in:
Sandu Liviu Catalin 2016-11-15 21:16:24 +02:00
parent 351d44a8e5
commit 411ac5ef28
14 changed files with 40 additions and 110 deletions

View File

@ -6,15 +6,10 @@
namespace SqMod {
// ------------------------------------------------------------------------------------------------
const Int32 CBlip::Max = SQMOD_BLIP_POOL;
SQMODE_DECL_TYPENAME(Typename, _SC("SqBlip"))
// ------------------------------------------------------------------------------------------------
SQInteger CBlip::Typename(HSQUIRRELVM vm)
{
static const SQChar name[] = _SC("SqBlip");
sq_pushstring(vm, name, sizeof(name));
return 1;
}
const Int32 CBlip::Max = SQMOD_BLIP_POOL;
// ------------------------------------------------------------------------------------------------
SQInteger CBlip::SqGetNull(HSQUIRRELVM vm)
@ -311,11 +306,11 @@ static Object & Blip_Create(Int32 index, Int32 world, const Vector3 & pos, Int32
// ================================================================================================
void Register_CBlip(HSQUIRRELVM vm)
{
RootTable(vm).Bind(_SC("SqBlip"),
Class< CBlip, NoConstructor< CBlip > >(vm, _SC("SqBlip"))
RootTable(vm).Bind(Typename::Str,
Class< CBlip, NoConstructor< CBlip > >(vm, Typename::Str)
// Meta-methods
.SquirrelFunc(_SC("_typename"), &Typename::Fn)
.Func(_SC("_cmp"), &CBlip::Cmp)
.SquirrelFunc(_SC("_typename"), &CBlip::Typename)
.Func(_SC("_tostring"), &CBlip::ToString)
// Static Values
.SetStaticValue(_SC("MaxID"), CBlip::Max)

View File

@ -90,11 +90,6 @@ public:
*/
const String & ToString() const;
/* --------------------------------------------------------------------------------------------
* Used by the script engine to retrieve the name from instances of this type.
*/
static SQInteger Typename(HSQUIRRELVM vm);
/* --------------------------------------------------------------------------------------------
* Retrieve the associated null entity instance.
*/

View File

@ -8,6 +8,9 @@
// ------------------------------------------------------------------------------------------------
namespace SqMod {
// ------------------------------------------------------------------------------------------------
SQMODE_DECL_TYPENAME(Typename, _SC("SqCheckpoint"))
// ------------------------------------------------------------------------------------------------
Color4 CCheckpoint::s_Color4;
Vector3 CCheckpoint::s_Vector3;
@ -21,14 +24,6 @@ Int32 CCheckpoint::s_ColorA;
// ------------------------------------------------------------------------------------------------
const Int32 CCheckpoint::Max = SQMOD_CHECKPOINT_POOL;
// ------------------------------------------------------------------------------------------------
SQInteger CCheckpoint::Typename(HSQUIRRELVM vm)
{
static const SQChar name[] = _SC("SqCheckpoint");
sq_pushstring(vm, name, sizeof(name));
return 1;
}
// ------------------------------------------------------------------------------------------------
SQInteger CCheckpoint::SqGetNull(HSQUIRRELVM vm)
{
@ -529,11 +524,11 @@ static Object & Checkpoint_Create(Int32 world, bool sphere, const Vector3 & pos,
// ================================================================================================
void Register_CCheckpoint(HSQUIRRELVM vm)
{
RootTable(vm).Bind(_SC("SqCheckpoint"),
Class< CCheckpoint, NoConstructor< CCheckpoint > >(vm, _SC("SqCheckpoint"))
RootTable(vm).Bind(Typename::Str,
Class< CCheckpoint, NoConstructor< CCheckpoint > >(vm, Typename::Str)
// Meta-methods
.SquirrelFunc(_SC("_typename"), &Typename::Fn)
.Func(_SC("_cmp"), &CCheckpoint::Cmp)
.SquirrelFunc(_SC("_typename"), &CCheckpoint::Typename)
.Func(_SC("_tostring"), &CCheckpoint::ToString)
// Static Values
.SetStaticValue(_SC("MaxID"), CCheckpoint::Max)

View File

@ -111,11 +111,6 @@ public:
*/
const String & ToString() const;
/* --------------------------------------------------------------------------------------------
* Used by the script engine to retrieve the name from instances of this type.
*/
static SQInteger Typename(HSQUIRRELVM vm);
/* --------------------------------------------------------------------------------------------
* Retrieve the associated null entity instance.
*/

View File

@ -6,15 +6,10 @@
namespace SqMod {
// ------------------------------------------------------------------------------------------------
const Int32 CKeybind::Max = SQMOD_KEYBIND_POOL;
SQMODE_DECL_TYPENAME(Typename, _SC("SqKeybind"))
// ------------------------------------------------------------------------------------------------
SQInteger CKeybind::Typename(HSQUIRRELVM vm)
{
static const SQChar name[] = _SC("SqKeybind");
sq_pushstring(vm, name, sizeof(name));
return 1;
}
const Int32 CKeybind::Max = SQMOD_KEYBIND_POOL;
// ------------------------------------------------------------------------------------------------
SQInteger CKeybind::SqGetNull(HSQUIRRELVM vm)
@ -210,11 +205,11 @@ static SQInteger Keybind_UnusedSlot()
// ================================================================================================
void Register_CKeybind(HSQUIRRELVM vm)
{
RootTable(vm).Bind(_SC("SqKeybind"),
Class< CKeybind, NoConstructor< CKeybind > >(vm, _SC("SqKeybind"))
RootTable(vm).Bind(Typename::Str,
Class< CKeybind, NoConstructor< CKeybind > >(vm, Typename::Str)
// Meta-methods
.SquirrelFunc(_SC("_typename"), &Typename::Fn)
.Func(_SC("_cmp"), &CKeybind::Cmp)
.SquirrelFunc(_SC("_typename"), &CKeybind::Typename)
.Func(_SC("_tostring"), &CKeybind::ToString)
// Static Values
.SetStaticValue(_SC("MaxID"), CKeybind::Max)

View File

@ -90,11 +90,6 @@ public:
*/
const String & ToString() const;
/* --------------------------------------------------------------------------------------------
* Used by the script engine to retrieve the name from instances of this type.
*/
static SQInteger Typename(HSQUIRRELVM vm);
/* --------------------------------------------------------------------------------------------
* Retrieve the associated null entity instance.
*/

View File

@ -8,6 +8,9 @@
// ------------------------------------------------------------------------------------------------
namespace SqMod {
// ------------------------------------------------------------------------------------------------
SQMODE_DECL_TYPENAME(Typename, _SC("SqObject"))
// ------------------------------------------------------------------------------------------------
Vector3 CObject::s_Vector3;
Quaternion CObject::s_Quaternion;
@ -15,14 +18,6 @@ Quaternion CObject::s_Quaternion;
// ------------------------------------------------------------------------------------------------
const Int32 CObject::Max = SQMOD_OBJECT_POOL;
// ------------------------------------------------------------------------------------------------
SQInteger CObject::Typename(HSQUIRRELVM vm)
{
static const SQChar name[] = _SC("SqObject");
sq_pushstring(vm, name, sizeof(name));
return 1;
}
// ------------------------------------------------------------------------------------------------
SQInteger CObject::SqGetNull(HSQUIRRELVM vm)
{
@ -889,11 +884,11 @@ static Object & Object_Create(Int32 model, Int32 world, const Vector3 & pos, Int
// ================================================================================================
void Register_CObject(HSQUIRRELVM vm)
{
RootTable(vm).Bind(_SC("SqObject"),
Class< CObject, NoConstructor< CObject > >(vm, _SC("SqObject"))
RootTable(vm).Bind(Typename::Str,
Class< CObject, NoConstructor< CObject > >(vm, Typename::Str)
// Meta-methods
.SquirrelFunc(_SC("_typename"), &Typename::Fn)
.Func(_SC("_cmp"), &CObject::Cmp)
.SquirrelFunc(_SC("_typename"), &CObject::Typename)
.Func(_SC("_tostring"), &CObject::ToString)
// Static Values
.SetStaticValue(_SC("MaxID"), CObject::Max)

View File

@ -127,11 +127,6 @@ public:
*/
const String & ToString() const;
/* --------------------------------------------------------------------------------------------
* Used by the script engine to retrieve the name from instances of this type.
*/
static SQInteger Typename(HSQUIRRELVM vm);
/* --------------------------------------------------------------------------------------------
* Retrieve the associated null entity instance.
*/

View File

@ -7,20 +7,15 @@
// ------------------------------------------------------------------------------------------------
namespace SqMod {
// ------------------------------------------------------------------------------------------------
SQMODE_DECL_TYPENAME(Typename, _SC("SqPickup"))
// ------------------------------------------------------------------------------------------------
Vector3 CPickup::s_Vector3;
// ------------------------------------------------------------------------------------------------
const Int32 CPickup::Max = SQMOD_PICKUP_POOL;
// ------------------------------------------------------------------------------------------------
SQInteger CPickup::Typename(HSQUIRRELVM vm)
{
static const SQChar name[] = _SC("SqPickup");
sq_pushstring(vm, name, sizeof(name));
return 1;
}
// ------------------------------------------------------------------------------------------------
SQInteger CPickup::SqGetNull(HSQUIRRELVM vm)
{
@ -452,11 +447,11 @@ static Object & Pickup_Create(Int32 model, Int32 world, Int32 quantity, const Ve
// ================================================================================================
void Register_CPickup(HSQUIRRELVM vm)
{
RootTable(vm).Bind(_SC("SqPickup"),
Class< CPickup, NoConstructor< CPickup > >(vm, _SC("SqPickup"))
RootTable(vm).Bind(Typename::Str,
Class< CPickup, NoConstructor< CPickup > >(vm, Typename::Str)
// Meta-methods
.SquirrelFunc(_SC("_typename"), &Typename::Fn)
.Func(_SC("_cmp"), &CPickup::Cmp)
.SquirrelFunc(_SC("_typename"), &CPickup::Typename)
.Func(_SC("_tostring"), &CPickup::ToString)
// Static Values
.SetStaticValue(_SC("MaxID"), CPickup::Max)

View File

@ -109,11 +109,6 @@ public:
*/
const String & ToString() const;
/* --------------------------------------------------------------------------------------------
* Used by the script engine to retrieve the name from instances of this type.
*/
static SQInteger Typename(HSQUIRRELVM vm);
/* --------------------------------------------------------------------------------------------
* Retrieve the associated null entity instance.
*/

View File

@ -19,6 +19,9 @@ namespace SqMod {
// ------------------------------------------------------------------------------------------------
extern SQRESULT SqGrabPlayerMessageColor(HSQUIRRELVM vm, Int32 idx, Uint32 & color, Int32 & msgidx);
// ------------------------------------------------------------------------------------------------
SQMODE_DECL_TYPENAME(Typename, _SC("SqPlayer"))
// ------------------------------------------------------------------------------------------------
Color3 CPlayer::s_Color3;
Vector3 CPlayer::s_Vector3;
@ -29,14 +32,6 @@ SQChar CPlayer::s_Buffer[SQMOD_PLAYER_TMP_BUFFER];
// ------------------------------------------------------------------------------------------------
const Int32 CPlayer::Max = SQMOD_PLAYER_POOL;
// ------------------------------------------------------------------------------------------------
SQInteger CPlayer::Typename(HSQUIRRELVM vm)
{
static const SQChar name[] = _SC("SqPlayer");
sq_pushstring(vm, name, sizeof(name));
return 1;
}
// ------------------------------------------------------------------------------------------------
SQInteger CPlayer::SqGetNull(HSQUIRRELVM vm)
{
@ -2366,11 +2361,11 @@ static const Object & Player_FindAuto(Object & by)
// ================================================================================================
void Register_CPlayer(HSQUIRRELVM vm)
{
RootTable(vm).Bind(_SC("SqPlayer"),
Class< CPlayer, NoConstructor< CPlayer > >(vm, _SC("SqPlayer"))
RootTable(vm).Bind(Typename::Str,
Class< CPlayer, NoConstructor< CPlayer > >(vm, Typename::Str)
// Meta-methods
.SquirrelFunc(_SC("_typename"), &Typename::Fn)
.Func(_SC("_cmp"), &CPlayer::Cmp)
.SquirrelFunc(_SC("_typename"), &CPlayer::Typename)
.Func(_SC("_tostring"), &CPlayer::ToString)
// Static Values
.SetStaticValue(_SC("MaxID"), CPlayer::Max)

View File

@ -178,11 +178,6 @@ public:
*/
const String & ToString() const;
/* --------------------------------------------------------------------------------------------
* Used by the script engine to retrieve the name from instances of this type.
*/
static SQInteger Typename(HSQUIRRELVM vm);
/* --------------------------------------------------------------------------------------------
* Retrieve the associated null entity instance.
*/

View File

@ -9,6 +9,9 @@
// ------------------------------------------------------------------------------------------------
namespace SqMod {
// ------------------------------------------------------------------------------------------------
SQMODE_DECL_TYPENAME(Typename, _SC("SqVehicle"))
// ------------------------------------------------------------------------------------------------
Vector2 CVehicle::s_Vector2;
Vector3 CVehicle::s_Vector3;
@ -17,14 +20,6 @@ Quaternion CVehicle::s_Quaternion;
// ------------------------------------------------------------------------------------------------
const Int32 CVehicle::Max = SQMOD_VEHICLE_POOL;
// ------------------------------------------------------------------------------------------------
SQInteger CVehicle::Typename(HSQUIRRELVM vm)
{
static const SQChar name[] = _SC("SqVehicle");
sq_pushstring(vm, name, sizeof(name));
return 1;
}
// ------------------------------------------------------------------------------------------------
SQInteger CVehicle::SqGetNull(HSQUIRRELVM vm)
{
@ -1764,11 +1759,11 @@ static Object & Vehicle_Create(Int32 model, Int32 world, const Vector3 & pos, Fl
// ================================================================================================
void Register_CVehicle(HSQUIRRELVM vm)
{
RootTable(vm).Bind(_SC("SqVehicle"),
Class< CVehicle, NoConstructor< CVehicle > >(vm, _SC("SqVehicle"))
RootTable(vm).Bind(Typename::Str,
Class< CVehicle, NoConstructor< CVehicle > >(vm, Typename::Str)
// Meta-methods
.SquirrelFunc(_SC("_typename"), &Typename::Fn)
.Func(_SC("_cmp"), &CVehicle::Cmp)
.SquirrelFunc(_SC("_typename"), &CVehicle::Typename)
.Func(_SC("_tostring"), &CVehicle::ToString)
// Static Values
.SetStaticValue(_SC("MaxID"), CVehicle::Max)

View File

@ -115,11 +115,6 @@ public:
*/
const String & ToString() const;
/* --------------------------------------------------------------------------------------------
* Used by the script engine to retrieve the name from instances of this type.
*/
static SQInteger Typename(HSQUIRRELVM vm);
/* --------------------------------------------------------------------------------------------
* Retrieve the associated null entity instance.
*/