mirror of
https://github.com/VCMP-SqMod/SqMod.git
synced 2025-10-15 15:37:20 +02:00
Implement the pure typename meta-methods in SQLite module types using the standard method.
This commit is contained in:
@@ -9,6 +9,9 @@
|
|||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
namespace SqMod {
|
namespace SqMod {
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
SQMODE_DECL_TYPENAME(Typename, _SC("SqLiteColumn"))
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
static inline bool IsDigitsOnly(CSStr str)
|
static inline bool IsDigitsOnly(CSStr str)
|
||||||
{
|
{
|
||||||
@@ -20,14 +23,6 @@ static inline bool IsDigitsOnly(CSStr str)
|
|||||||
return *str == '\0';
|
return *str == '\0';
|
||||||
}
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
|
||||||
SQInteger Column::Typename(HSQUIRRELVM vm)
|
|
||||||
{
|
|
||||||
static const SQChar name[] = _SC("SqSQLiteColumn");
|
|
||||||
sq_pushstring(vm, name, sizeof(name));
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
#if defined(_DEBUG) || defined(SQMOD_EXCEPTLOC)
|
#if defined(_DEBUG) || defined(SQMOD_EXCEPTLOC)
|
||||||
void Column::Validate(CCStr file, Int32 line) const
|
void Column::Validate(CCStr file, Int32 line) const
|
||||||
@@ -513,12 +508,12 @@ Object Column::GetBlob() const
|
|||||||
void Register_Column(Table & sqlns)
|
void Register_Column(Table & sqlns)
|
||||||
{
|
{
|
||||||
sqlns.Bind(_SC("Column"),
|
sqlns.Bind(_SC("Column"),
|
||||||
Class< Column >(sqlns.GetVM(), _SC("SqSQLiteColumn"))
|
Class< Column >(sqlns.GetVM(), Typename::Str)
|
||||||
// Constructors
|
// Constructors
|
||||||
.Ctor()
|
.Ctor()
|
||||||
.Ctor< const Column & >()
|
.Ctor< const Column & >()
|
||||||
// Meta-methods
|
// Meta-methods
|
||||||
.SquirrelFunc(_SC("_typename"), &Column::Typename)
|
.SquirrelFunc(_SC("_typename"), &Typename::Fn)
|
||||||
.Func(_SC("_tostring"), &Column::ToString)
|
.Func(_SC("_tostring"), &Column::ToString)
|
||||||
// Properties
|
// Properties
|
||||||
.Prop(_SC("IsValid"), &Column::IsValid)
|
.Prop(_SC("IsValid"), &Column::IsValid)
|
||||||
|
@@ -218,11 +218,6 @@ public:
|
|||||||
return val ? val : _SC("");
|
return val ? val : _SC("");
|
||||||
}
|
}
|
||||||
|
|
||||||
/* --------------------------------------------------------------------------------------------
|
|
||||||
* Used by the script engine to retrieve the name from instances of this type.
|
|
||||||
*/
|
|
||||||
static SQInteger Typename(HSQUIRRELVM vm);
|
|
||||||
|
|
||||||
/* --------------------------------------------------------------------------------------------
|
/* --------------------------------------------------------------------------------------------
|
||||||
* See whether the column is valid.
|
* See whether the column is valid.
|
||||||
*/
|
*/
|
||||||
|
@@ -6,12 +6,7 @@
|
|||||||
namespace SqMod {
|
namespace SqMod {
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
SQInteger Connection::Typename(HSQUIRRELVM vm)
|
SQMODE_DECL_TYPENAME(Typename, _SC("SqLiteConnection"))
|
||||||
{
|
|
||||||
static const SQChar name[] = _SC("SqSQLiteConnection");
|
|
||||||
sq_pushstring(vm, name, sizeof(name));
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
void Connection::TraceOutput(void * /*ptr*/, CCStr sql)
|
void Connection::TraceOutput(void * /*ptr*/, CCStr sql)
|
||||||
@@ -348,14 +343,14 @@ Int32 Connection::Flush(SQInteger num, Object & env, Function & func)
|
|||||||
void Register_Connection(Table & sqlns)
|
void Register_Connection(Table & sqlns)
|
||||||
{
|
{
|
||||||
sqlns.Bind(_SC("Connection"),
|
sqlns.Bind(_SC("Connection"),
|
||||||
Class< Connection >(sqlns.GetVM(), _SC("SqSQLiteConnection"))
|
Class< Connection >(sqlns.GetVM(), Typename::Str)
|
||||||
// Constructors
|
// Constructors
|
||||||
.Ctor()
|
.Ctor()
|
||||||
.Ctor< const StackStrF & >()
|
.Ctor< const StackStrF & >()
|
||||||
.Ctor< const StackStrF &, Int32 >()
|
.Ctor< const StackStrF &, Int32 >()
|
||||||
.Ctor< const StackStrF &, Int32, const StackStrF & >()
|
.Ctor< const StackStrF &, Int32, const StackStrF & >()
|
||||||
// Meta-methods
|
// Meta-methods
|
||||||
.SquirrelFunc(_SC("_typename"), &Connection::Typename)
|
.SquirrelFunc(_SC("_typename"), &Typename::Fn)
|
||||||
.Func(_SC("_tostring"), &Connection::ToString)
|
.Func(_SC("_tostring"), &Connection::ToString)
|
||||||
// Properties
|
// Properties
|
||||||
.Prop(_SC("IsValid"), &Connection::IsValid)
|
.Prop(_SC("IsValid"), &Connection::IsValid)
|
||||||
|
@@ -172,11 +172,6 @@ public:
|
|||||||
return m_Handle ? m_Handle->mName : NullString();
|
return m_Handle ? m_Handle->mName : NullString();
|
||||||
}
|
}
|
||||||
|
|
||||||
/* --------------------------------------------------------------------------------------------
|
|
||||||
* Used by the script engine to retrieve the name from instances of this type.
|
|
||||||
*/
|
|
||||||
static SQInteger Typename(HSQUIRRELVM vm);
|
|
||||||
|
|
||||||
/* --------------------------------------------------------------------------------------------
|
/* --------------------------------------------------------------------------------------------
|
||||||
* Retrieve the associated connection handle.
|
* Retrieve the associated connection handle.
|
||||||
*/
|
*/
|
||||||
|
@@ -14,6 +14,9 @@ namespace SqMod {
|
|||||||
// Error message when failed to bind value to parameter index.
|
// Error message when failed to bind value to parameter index.
|
||||||
#define SQMOD_BINDFAILED "Unable to bind (%s) parameter (%d) because [%s]"
|
#define SQMOD_BINDFAILED "Unable to bind (%s) parameter (%d) because [%s]"
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
SQMODE_DECL_TYPENAME(Typename, _SC("SqLiteParameter"))
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
static inline bool IsDigitsOnly(CSStr str)
|
static inline bool IsDigitsOnly(CSStr str)
|
||||||
{
|
{
|
||||||
@@ -25,14 +28,6 @@ static inline bool IsDigitsOnly(CSStr str)
|
|||||||
return *str == '\0';
|
return *str == '\0';
|
||||||
}
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
|
||||||
SQInteger Parameter::Typename(HSQUIRRELVM vm)
|
|
||||||
{
|
|
||||||
static const SQChar name[] = _SC("SqSQLiteParameter");
|
|
||||||
sq_pushstring(vm, name, sizeof(name));
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
#if defined(_DEBUG) || defined(SQMOD_EXCEPTLOC)
|
#if defined(_DEBUG) || defined(SQMOD_EXCEPTLOC)
|
||||||
void Parameter::Validate(CCStr file, Int32 line) const
|
void Parameter::Validate(CCStr file, Int32 line) const
|
||||||
@@ -734,12 +729,12 @@ void Parameter::SetNull()
|
|||||||
void Register_Parameter(Table & sqlns)
|
void Register_Parameter(Table & sqlns)
|
||||||
{
|
{
|
||||||
sqlns.Bind(_SC("Parameter"),
|
sqlns.Bind(_SC("Parameter"),
|
||||||
Class< Parameter >(sqlns.GetVM(), _SC("SqSQLiteParameter"))
|
Class< Parameter >(sqlns.GetVM(), Typename::Str)
|
||||||
// Constructors
|
// Constructors
|
||||||
.Ctor()
|
.Ctor()
|
||||||
.Ctor< const Parameter & >()
|
.Ctor< const Parameter & >()
|
||||||
// Meta-methods
|
// Meta-methods
|
||||||
.SquirrelFunc(_SC("_typename"), &Parameter::Typename)
|
.SquirrelFunc(_SC("_typename"), &Typename::Fn)
|
||||||
.Func(_SC("_tostring"), &Parameter::ToString)
|
.Func(_SC("_tostring"), &Parameter::ToString)
|
||||||
// Properties
|
// Properties
|
||||||
.Prop(_SC("IsValid"), &Parameter::IsValid)
|
.Prop(_SC("IsValid"), &Parameter::IsValid)
|
||||||
|
@@ -212,11 +212,6 @@ public:
|
|||||||
return val ? val : _SC("");
|
return val ? val : _SC("");
|
||||||
}
|
}
|
||||||
|
|
||||||
/* --------------------------------------------------------------------------------------------
|
|
||||||
* Used by the script engine to retrieve the name from instances of this type.
|
|
||||||
*/
|
|
||||||
static SQInteger Typename(HSQUIRRELVM vm);
|
|
||||||
|
|
||||||
/* --------------------------------------------------------------------------------------------
|
/* --------------------------------------------------------------------------------------------
|
||||||
* See whether this statement is valid.
|
* See whether this statement is valid.
|
||||||
*/
|
*/
|
||||||
|
@@ -10,12 +10,7 @@
|
|||||||
namespace SqMod {
|
namespace SqMod {
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
SQInteger Statement::Typename(HSQUIRRELVM vm)
|
SQMODE_DECL_TYPENAME(Typename, _SC("SqLiteStatement"))
|
||||||
{
|
|
||||||
static const SQChar name[] = _SC("SqSQLiteStatement");
|
|
||||||
sq_pushstring(vm, name, sizeof(name));
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
#if defined(_DEBUG) || defined(SQMOD_EXCEPTLOC)
|
#if defined(_DEBUG) || defined(SQMOD_EXCEPTLOC)
|
||||||
@@ -426,13 +421,13 @@ Table Statement::GetTable(Int32 min, Int32 max) const
|
|||||||
void Register_Statement(Table & sqlns)
|
void Register_Statement(Table & sqlns)
|
||||||
{
|
{
|
||||||
sqlns.Bind(_SC("Statement"),
|
sqlns.Bind(_SC("Statement"),
|
||||||
Class< Statement >(sqlns.GetVM(), _SC("SqSQLiteStatement"))
|
Class< Statement >(sqlns.GetVM(), Typename::Str)
|
||||||
// Constructors
|
// Constructors
|
||||||
.Ctor()
|
.Ctor()
|
||||||
.Ctor< const Statement & >()
|
.Ctor< const Statement & >()
|
||||||
.FmtCtor< const Connection & >()
|
.FmtCtor< const Connection & >()
|
||||||
// Meta-methods
|
// Meta-methods
|
||||||
.SquirrelFunc(_SC("_typename"), &Statement::Typename)
|
.SquirrelFunc(_SC("_typename"), &Typename::Fn)
|
||||||
.Func(_SC("_tostring"), &Statement::ToString)
|
.Func(_SC("_tostring"), &Statement::ToString)
|
||||||
// Properties
|
// Properties
|
||||||
.Prop(_SC("IsValid"), &Statement::IsValid)
|
.Prop(_SC("IsValid"), &Statement::IsValid)
|
||||||
|
@@ -178,11 +178,6 @@ public:
|
|||||||
return m_Handle ? m_Handle->mQuery : NullString();
|
return m_Handle ? m_Handle->mQuery : NullString();
|
||||||
}
|
}
|
||||||
|
|
||||||
/* --------------------------------------------------------------------------------------------
|
|
||||||
* Used by the script engine to retrieve the name from instances of this type.
|
|
||||||
*/
|
|
||||||
static SQInteger Typename(HSQUIRRELVM vm);
|
|
||||||
|
|
||||||
/* --------------------------------------------------------------------------------------------
|
/* --------------------------------------------------------------------------------------------
|
||||||
* Retrieve the associated statement handle.
|
* Retrieve the associated statement handle.
|
||||||
*/
|
*/
|
||||||
|
@@ -6,12 +6,7 @@
|
|||||||
namespace SqMod {
|
namespace SqMod {
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
SQInteger Transaction::Typename(HSQUIRRELVM vm)
|
SQMODE_DECL_TYPENAME(Typename, _SC("SqLiteTransaction"))
|
||||||
{
|
|
||||||
static const SQChar name[] = _SC("SqSQLiteTransaction");
|
|
||||||
sq_pushstring(vm, name, sizeof(name));
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
Transaction::Transaction(const Connection & db)
|
Transaction::Transaction(const Connection & db)
|
||||||
@@ -88,11 +83,11 @@ bool Transaction::Commit()
|
|||||||
void Register_Transaction(Table & sqlns)
|
void Register_Transaction(Table & sqlns)
|
||||||
{
|
{
|
||||||
sqlns.Bind(_SC("Transaction"),
|
sqlns.Bind(_SC("Transaction"),
|
||||||
Class< Transaction, NoCopy< Transaction > >(sqlns.GetVM(), _SC("SqSQLiteTransaction"))
|
Class< Transaction, NoCopy< Transaction > >(sqlns.GetVM(), Typename::Str)
|
||||||
// Constructors
|
// Constructors
|
||||||
.Ctor< const Connection & >()
|
.Ctor< const Connection & >()
|
||||||
// Meta-methods
|
// Meta-methods
|
||||||
.SquirrelFunc(_SC("_typename"), &Transaction::Typename)
|
.SquirrelFunc(_SC("_typename"), &Typename::Fn)
|
||||||
.Func(_SC("_tostring"), &Transaction::ToString)
|
.Func(_SC("_tostring"), &Transaction::ToString)
|
||||||
// Properties
|
// Properties
|
||||||
.Prop(_SC("IsValid"), &Transaction::IsValid)
|
.Prop(_SC("IsValid"), &Transaction::IsValid)
|
||||||
|
@@ -57,11 +57,6 @@ public:
|
|||||||
return m_Handle ? m_Handle->mName : NullString();
|
return m_Handle ? m_Handle->mName : NullString();
|
||||||
}
|
}
|
||||||
|
|
||||||
/* --------------------------------------------------------------------------------------------
|
|
||||||
* Used by the script engine to retrieve the name from instances of this type.
|
|
||||||
*/
|
|
||||||
static SQInteger Typename(HSQUIRRELVM vm);
|
|
||||||
|
|
||||||
/* --------------------------------------------------------------------------------------------
|
/* --------------------------------------------------------------------------------------------
|
||||||
* Retrieve the associated statement handle.
|
* Retrieve the associated statement handle.
|
||||||
*/
|
*/
|
||||||
|
Reference in New Issue
Block a user