Fix error in Windows build.
continuous-integration/drone/push Build is passing
Details
continuous-integration/drone/push Build is passing
Details
This commit is contained in:
parent
67d317e22b
commit
b8b692d4d6
|
@ -1,32 +1,29 @@
|
||||||
#include "scripthandle.h"
|
#include "scripthandle.h"
|
||||||
#include <new>
|
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
|
#include <new>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
BEGIN_AS_NAMESPACE
|
BEGIN_AS_NAMESPACE
|
||||||
|
|
||||||
static void Construct(CScriptHandle *self) { new(self) CScriptHandle(); }
|
static void Construct(CScriptHandle* self) { new (self) CScriptHandle(); }
|
||||||
static void Construct(CScriptHandle *self, const CScriptHandle &o) { new(self) CScriptHandle(o); }
|
static void Construct(CScriptHandle* self, const CScriptHandle& o) { new (self) CScriptHandle(o); }
|
||||||
// This one is not static because it needs to be friend with the CScriptHandle class
|
// This one is not static because it needs to be friend with the CScriptHandle class
|
||||||
void Construct(CScriptHandle *self, void *ref, int typeId) { new(self) CScriptHandle(ref, typeId); }
|
void Construct(CScriptHandle* self, void* ref, int typeId) { new (self) CScriptHandle(ref, typeId); }
|
||||||
static void Destruct(CScriptHandle *self) { self->~CScriptHandle(); }
|
static void Destruct(CScriptHandle* self) { self->~CScriptHandle(); }
|
||||||
|
|
||||||
CScriptHandle::CScriptHandle()
|
CScriptHandle::CScriptHandle() {
|
||||||
{
|
|
||||||
m_ref = 0;
|
m_ref = 0;
|
||||||
m_type = 0;
|
m_type = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
CScriptHandle::CScriptHandle(const CScriptHandle &other)
|
CScriptHandle::CScriptHandle(const CScriptHandle& other) {
|
||||||
{
|
|
||||||
m_ref = other.m_ref;
|
m_ref = other.m_ref;
|
||||||
m_type = other.m_type;
|
m_type = other.m_type;
|
||||||
|
|
||||||
AddRefHandle();
|
AddRefHandle();
|
||||||
}
|
}
|
||||||
|
|
||||||
CScriptHandle::CScriptHandle(void *ref, asITypeInfo *type)
|
CScriptHandle::CScriptHandle(void* ref, asITypeInfo* type) {
|
||||||
{
|
|
||||||
m_ref = ref;
|
m_ref = ref;
|
||||||
m_type = type;
|
m_type = type;
|
||||||
|
|
||||||
|
@ -35,24 +32,18 @@ CScriptHandle::CScriptHandle(void *ref, asITypeInfo *type)
|
||||||
|
|
||||||
// This constructor shouldn't be called from the application
|
// This constructor shouldn't be called from the application
|
||||||
// directly as it requires an active script context
|
// directly as it requires an active script context
|
||||||
CScriptHandle::CScriptHandle(void *ref, int typeId)
|
CScriptHandle::CScriptHandle(void* ref, int typeId) {
|
||||||
{
|
|
||||||
m_ref = 0;
|
m_ref = 0;
|
||||||
m_type = 0;
|
m_type = 0;
|
||||||
|
|
||||||
Assign(ref, typeId);
|
Assign(ref, typeId);
|
||||||
}
|
}
|
||||||
|
|
||||||
CScriptHandle::~CScriptHandle()
|
CScriptHandle::~CScriptHandle() { ReleaseHandle(); }
|
||||||
{
|
|
||||||
ReleaseHandle();
|
|
||||||
}
|
|
||||||
|
|
||||||
void CScriptHandle::ReleaseHandle()
|
void CScriptHandle::ReleaseHandle() {
|
||||||
{
|
if (m_ref && m_type) {
|
||||||
if( m_ref && m_type )
|
asIScriptEngine* engine = m_type->GetEngine();
|
||||||
{
|
|
||||||
asIScriptEngine *engine = m_type->GetEngine();
|
|
||||||
engine->ReleaseScriptObject(m_ref, m_type);
|
engine->ReleaseScriptObject(m_ref, m_type);
|
||||||
|
|
||||||
engine->Release();
|
engine->Release();
|
||||||
|
@ -62,11 +53,9 @@ void CScriptHandle::ReleaseHandle()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void CScriptHandle::AddRefHandle()
|
void CScriptHandle::AddRefHandle() {
|
||||||
{
|
if (m_ref && m_type) {
|
||||||
if( m_ref && m_type )
|
asIScriptEngine* engine = m_type->GetEngine();
|
||||||
{
|
|
||||||
asIScriptEngine *engine = m_type->GetEngine();
|
|
||||||
engine->AddRefScriptObject(m_ref, m_type);
|
engine->AddRefScriptObject(m_ref, m_type);
|
||||||
|
|
||||||
// Hold on to the engine so it isn't destroyed while
|
// Hold on to the engine so it isn't destroyed while
|
||||||
|
@ -75,16 +64,15 @@ void CScriptHandle::AddRefHandle()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
CScriptHandle &CScriptHandle::operator =(const CScriptHandle &other)
|
CScriptHandle& CScriptHandle::operator=(const CScriptHandle& other) {
|
||||||
{
|
|
||||||
Set(other.m_ref, other.m_type);
|
Set(other.m_ref, other.m_type);
|
||||||
|
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
void CScriptHandle::Set(void *ref, asITypeInfo *type)
|
void CScriptHandle::Set(void* ref, asITypeInfo* type) {
|
||||||
{
|
if (m_ref == ref)
|
||||||
if( m_ref == ref ) return;
|
return;
|
||||||
|
|
||||||
ReleaseHandle();
|
ReleaseHandle();
|
||||||
|
|
||||||
|
@ -94,51 +82,41 @@ void CScriptHandle::Set(void *ref, asITypeInfo *type)
|
||||||
AddRefHandle();
|
AddRefHandle();
|
||||||
}
|
}
|
||||||
|
|
||||||
void *CScriptHandle::GetRef()
|
void* CScriptHandle::GetRef() { return m_ref; }
|
||||||
{
|
|
||||||
return m_ref;
|
|
||||||
}
|
|
||||||
|
|
||||||
asITypeInfo *CScriptHandle::GetType() const
|
asITypeInfo* CScriptHandle::GetType() const { return m_type; }
|
||||||
{
|
|
||||||
return m_type;
|
|
||||||
}
|
|
||||||
|
|
||||||
int CScriptHandle::GetTypeId() const
|
int CScriptHandle::GetTypeId() const {
|
||||||
{
|
if (m_type == 0)
|
||||||
if( m_type == 0 ) return 0;
|
return 0;
|
||||||
|
|
||||||
return m_type->GetTypeId() | asTYPEID_OBJHANDLE;
|
return m_type->GetTypeId() | asTYPEID_OBJHANDLE;
|
||||||
}
|
}
|
||||||
|
|
||||||
// This method shouldn't be called from the application
|
// This method shouldn't be called from the application
|
||||||
// directly as it requires an active script context
|
// directly as it requires an active script context
|
||||||
CScriptHandle &CScriptHandle::Assign(void *ref, int typeId)
|
CScriptHandle& CScriptHandle::Assign(void* ref, int typeId) {
|
||||||
{
|
|
||||||
// When receiving a null handle we just clear our memory
|
// When receiving a null handle we just clear our memory
|
||||||
if( typeId == 0 )
|
if (typeId == 0) {
|
||||||
{
|
|
||||||
Set(0, 0);
|
Set(0, 0);
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Dereference received handles to get the object
|
// Dereference received handles to get the object
|
||||||
if( typeId & asTYPEID_OBJHANDLE )
|
if (typeId & asTYPEID_OBJHANDLE) {
|
||||||
{
|
|
||||||
// Store the actual reference
|
// Store the actual reference
|
||||||
ref = *(void**)ref;
|
ref = *(void**)ref;
|
||||||
typeId &= ~asTYPEID_OBJHANDLE;
|
typeId &= ~asTYPEID_OBJHANDLE;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get the object type
|
// Get the object type
|
||||||
asIScriptContext *ctx = asGetActiveContext();
|
asIScriptContext* ctx = asGetActiveContext();
|
||||||
asIScriptEngine *engine = ctx->GetEngine();
|
asIScriptEngine* engine = ctx->GetEngine();
|
||||||
asITypeInfo *type = engine->GetTypeInfoById(typeId);
|
asITypeInfo* type = engine->GetTypeInfoById(typeId);
|
||||||
|
|
||||||
// If the argument is another CScriptHandle, we should copy the content instead
|
// If the argument is another CScriptHandle, we should copy the content instead
|
||||||
if( type && strcmp(type->GetName(), "ref") == 0 )
|
if (type && strcmp(type->GetName(), "ref") == 0) {
|
||||||
{
|
CScriptHandle* r = (CScriptHandle*)ref;
|
||||||
CScriptHandle *r = (CScriptHandle*)ref;
|
|
||||||
ref = r->m_ref;
|
ref = r->m_ref;
|
||||||
type = r->m_type;
|
type = r->m_type;
|
||||||
}
|
}
|
||||||
|
@ -148,10 +126,8 @@ CScriptHandle &CScriptHandle::Assign(void *ref, int typeId)
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CScriptHandle::operator==(const CScriptHandle &o) const
|
bool CScriptHandle::operator==(const CScriptHandle& o) const {
|
||||||
{
|
if (m_ref == o.m_ref && m_type == o.m_type)
|
||||||
if( m_ref == o.m_ref &&
|
|
||||||
m_type == o.m_type )
|
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
// TODO: If type is not the same, we should attempt to do a dynamic cast,
|
// TODO: If type is not the same, we should attempt to do a dynamic cast,
|
||||||
|
@ -160,20 +136,15 @@ bool CScriptHandle::operator==(const CScriptHandle &o) const
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CScriptHandle::operator!=(const CScriptHandle &o) const
|
bool CScriptHandle::operator!=(const CScriptHandle& o) const { return !(*this == o); }
|
||||||
{
|
|
||||||
return !(*this == o);
|
|
||||||
}
|
|
||||||
|
|
||||||
bool CScriptHandle::Equals(void *ref, int typeId) const
|
bool CScriptHandle::Equals(void* ref, int typeId) const {
|
||||||
{
|
|
||||||
// Null handles are received as reference to a null handle
|
// Null handles are received as reference to a null handle
|
||||||
if( typeId == 0 )
|
if (typeId == 0)
|
||||||
ref = 0;
|
ref = 0;
|
||||||
|
|
||||||
// Dereference handles to get the object
|
// Dereference handles to get the object
|
||||||
if( typeId & asTYPEID_OBJHANDLE )
|
if (typeId & asTYPEID_OBJHANDLE) {
|
||||||
{
|
|
||||||
// Compare the actual reference
|
// Compare the actual reference
|
||||||
ref = *(void**)ref;
|
ref = *(void**)ref;
|
||||||
typeId &= ~asTYPEID_OBJHANDLE;
|
typeId &= ~asTYPEID_OBJHANDLE;
|
||||||
|
@ -182,28 +153,27 @@ bool CScriptHandle::Equals(void *ref, int typeId) const
|
||||||
// TODO: If typeId is not the same, we should attempt to do a dynamic cast,
|
// TODO: If typeId is not the same, we should attempt to do a dynamic cast,
|
||||||
// which may change the pointer for application registered classes
|
// which may change the pointer for application registered classes
|
||||||
|
|
||||||
if( ref == m_ref ) return true;
|
if (ref == m_ref)
|
||||||
|
return true;
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// AngelScript: used as '@obj = cast<obj>(ref);'
|
// AngelScript: used as '@obj = cast<obj>(ref);'
|
||||||
void CScriptHandle::Cast(void **outRef, int typeId)
|
void CScriptHandle::Cast(void** outRef, int typeId) {
|
||||||
{
|
|
||||||
// If we hold a null handle, then just return null
|
// If we hold a null handle, then just return null
|
||||||
if( m_type == 0 )
|
if (m_type == 0) {
|
||||||
{
|
|
||||||
*outRef = 0;
|
*outRef = 0;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// It is expected that the outRef is always a handle
|
// It is expected that the outRef is always a handle
|
||||||
assert( typeId & asTYPEID_OBJHANDLE );
|
assert(typeId & asTYPEID_OBJHANDLE);
|
||||||
|
|
||||||
// Compare the type id of the actual object
|
// Compare the type id of the actual object
|
||||||
typeId &= ~asTYPEID_OBJHANDLE;
|
typeId &= ~asTYPEID_OBJHANDLE;
|
||||||
asIScriptEngine *engine = m_type->GetEngine();
|
asIScriptEngine* engine = m_type->GetEngine();
|
||||||
asITypeInfo *type = engine->GetTypeInfoById(typeId);
|
asITypeInfo* type = engine->GetTypeInfoById(typeId);
|
||||||
|
|
||||||
*outRef = 0;
|
*outRef = 0;
|
||||||
|
|
||||||
|
@ -211,150 +181,187 @@ void CScriptHandle::Cast(void **outRef, int typeId)
|
||||||
engine->RefCastObject(m_ref, m_type, type, outRef);
|
engine->RefCastObject(m_ref, m_type, type, outRef);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CScriptHandle::EnumReferences(asIScriptEngine *inEngine)
|
void CScriptHandle::EnumReferences(asIScriptEngine* inEngine) {
|
||||||
{
|
|
||||||
// If we're holding a reference, we'll notify the garbage collector of it
|
// If we're holding a reference, we'll notify the garbage collector of it
|
||||||
if (m_ref)
|
if (m_ref)
|
||||||
inEngine->GCEnumCallback(m_ref);
|
inEngine->GCEnumCallback(m_ref);
|
||||||
|
|
||||||
// The object type itself is also garbage collected
|
// The object type itself is also garbage collected
|
||||||
if( m_type)
|
if (m_type)
|
||||||
inEngine->GCEnumCallback(m_type);
|
inEngine->GCEnumCallback(m_type);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CScriptHandle::ReleaseReferences(asIScriptEngine *inEngine)
|
void CScriptHandle::ReleaseReferences(asIScriptEngine* inEngine) {
|
||||||
{
|
|
||||||
// Simply clear the content to release the references
|
// Simply clear the content to release the references
|
||||||
Set(0, 0);
|
Set(0, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
void RegisterScriptHandle_Native(asIScriptEngine *engine)
|
void RegisterScriptHandle_Native(asIScriptEngine* engine) {
|
||||||
{
|
[[maybe_unused]] int r;
|
||||||
int r;
|
|
||||||
|
|
||||||
#if AS_CAN_USE_CPP11
|
#if AS_CAN_USE_CPP11
|
||||||
// With C++11 it is possible to use asGetTypeTraits to automatically determine the flags that represent the C++ class
|
// With C++11 it is possible to use asGetTypeTraits to automatically determine the flags that represent the C++
|
||||||
r = engine->RegisterObjectType("ref", sizeof(CScriptHandle), asOBJ_VALUE | asOBJ_ASHANDLE | asOBJ_GC | asGetTypeTraits<CScriptHandle>()); assert( r >= 0 );
|
// class
|
||||||
|
r = engine->RegisterObjectType("ref", sizeof(CScriptHandle),
|
||||||
|
asOBJ_VALUE | asOBJ_ASHANDLE | asOBJ_GC | asGetTypeTraits<CScriptHandle>());
|
||||||
|
assert(r >= 0);
|
||||||
#else
|
#else
|
||||||
r = engine->RegisterObjectType("ref", sizeof(CScriptHandle), asOBJ_VALUE | asOBJ_ASHANDLE | asOBJ_GC | asOBJ_APP_CLASS_CDAK); assert( r >= 0 );
|
r = engine->RegisterObjectType("ref", sizeof(CScriptHandle),
|
||||||
|
asOBJ_VALUE | asOBJ_ASHANDLE | asOBJ_GC | asOBJ_APP_CLASS_CDAK);
|
||||||
|
assert(r >= 0);
|
||||||
#endif
|
#endif
|
||||||
r = engine->RegisterObjectBehaviour("ref", asBEHAVE_CONSTRUCT, "void f()", asFUNCTIONPR(Construct, (CScriptHandle *), void), asCALL_CDECL_OBJFIRST); assert( r >= 0 );
|
r = engine->RegisterObjectBehaviour("ref", asBEHAVE_CONSTRUCT, "void f()",
|
||||||
r = engine->RegisterObjectBehaviour("ref", asBEHAVE_CONSTRUCT, "void f(const ref &in)", asFUNCTIONPR(Construct, (CScriptHandle *, const CScriptHandle &), void), asCALL_CDECL_OBJFIRST); assert( r >= 0 );
|
asFUNCTIONPR(Construct, (CScriptHandle*), void), asCALL_CDECL_OBJFIRST);
|
||||||
r = engine->RegisterObjectBehaviour("ref", asBEHAVE_CONSTRUCT, "void f(const ?&in)", asFUNCTIONPR(Construct, (CScriptHandle *, void *, int), void), asCALL_CDECL_OBJFIRST); assert( r >= 0 );
|
assert(r >= 0);
|
||||||
r = engine->RegisterObjectBehaviour("ref", asBEHAVE_DESTRUCT, "void f()", asFUNCTIONPR(Destruct, (CScriptHandle *), void), asCALL_CDECL_OBJFIRST); assert( r >= 0 );
|
r = engine->RegisterObjectBehaviour("ref", asBEHAVE_CONSTRUCT, "void f(const ref &in)",
|
||||||
r = engine->RegisterObjectBehaviour("ref", asBEHAVE_ENUMREFS, "void f(int&in)", asMETHOD(CScriptHandle,EnumReferences), asCALL_THISCALL); assert(r >= 0);
|
asFUNCTIONPR(Construct, (CScriptHandle*, const CScriptHandle&), void),
|
||||||
r = engine->RegisterObjectBehaviour("ref", asBEHAVE_RELEASEREFS, "void f(int&in)", asMETHOD(CScriptHandle, ReleaseReferences), asCALL_THISCALL); assert(r >= 0);
|
asCALL_CDECL_OBJFIRST);
|
||||||
r = engine->RegisterObjectMethod("ref", "void opCast(?&out)", asMETHODPR(CScriptHandle, Cast, (void **, int), void), asCALL_THISCALL); assert( r >= 0 );
|
assert(r >= 0);
|
||||||
r = engine->RegisterObjectMethod("ref", "ref &opHndlAssign(const ref &in)", asMETHOD(CScriptHandle, operator=), asCALL_THISCALL); assert( r >= 0 );
|
r = engine->RegisterObjectBehaviour("ref", asBEHAVE_CONSTRUCT, "void f(const ?&in)",
|
||||||
r = engine->RegisterObjectMethod("ref", "ref &opHndlAssign(const ?&in)", asMETHOD(CScriptHandle, Assign), asCALL_THISCALL); assert( r >= 0 );
|
asFUNCTIONPR(Construct, (CScriptHandle*, void*, int), void),
|
||||||
r = engine->RegisterObjectMethod("ref", "bool opEquals(const ref &in) const", asMETHODPR(CScriptHandle, operator==, (const CScriptHandle &) const, bool), asCALL_THISCALL); assert( r >= 0 );
|
asCALL_CDECL_OBJFIRST);
|
||||||
r = engine->RegisterObjectMethod("ref", "bool opEquals(const ?&in) const", asMETHODPR(CScriptHandle, Equals, (void*, int) const, bool), asCALL_THISCALL); assert( r >= 0 );
|
assert(r >= 0);
|
||||||
|
r = engine->RegisterObjectBehaviour("ref", asBEHAVE_DESTRUCT, "void f()",
|
||||||
|
asFUNCTIONPR(Destruct, (CScriptHandle*), void), asCALL_CDECL_OBJFIRST);
|
||||||
|
assert(r >= 0);
|
||||||
|
r = engine->RegisterObjectBehaviour("ref", asBEHAVE_ENUMREFS, "void f(int&in)",
|
||||||
|
asMETHOD(CScriptHandle, EnumReferences), asCALL_THISCALL);
|
||||||
|
assert(r >= 0);
|
||||||
|
r = engine->RegisterObjectBehaviour("ref", asBEHAVE_RELEASEREFS, "void f(int&in)",
|
||||||
|
asMETHOD(CScriptHandle, ReleaseReferences), asCALL_THISCALL);
|
||||||
|
assert(r >= 0);
|
||||||
|
r = engine->RegisterObjectMethod("ref", "void opCast(?&out)", asMETHODPR(CScriptHandle, Cast, (void**, int), void),
|
||||||
|
asCALL_THISCALL);
|
||||||
|
assert(r >= 0);
|
||||||
|
r = engine->RegisterObjectMethod("ref", "ref &opHndlAssign(const ref &in)", asMETHOD(CScriptHandle, operator=),
|
||||||
|
asCALL_THISCALL);
|
||||||
|
assert(r >= 0);
|
||||||
|
r = engine->RegisterObjectMethod("ref", "ref &opHndlAssign(const ?&in)", asMETHOD(CScriptHandle, Assign),
|
||||||
|
asCALL_THISCALL);
|
||||||
|
assert(r >= 0);
|
||||||
|
r = engine->RegisterObjectMethod("ref", "bool opEquals(const ref &in) const",
|
||||||
|
asMETHODPR(CScriptHandle, operator==,(const CScriptHandle&) const, bool),
|
||||||
|
asCALL_THISCALL);
|
||||||
|
assert(r >= 0);
|
||||||
|
r = engine->RegisterObjectMethod("ref", "bool opEquals(const ?&in) const",
|
||||||
|
asMETHODPR(CScriptHandle, Equals, (void*, int)const, bool), asCALL_THISCALL);
|
||||||
|
assert(r >= 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CScriptHandle_Construct_Generic(asIScriptGeneric *gen)
|
void CScriptHandle_Construct_Generic(asIScriptGeneric* gen) {
|
||||||
{
|
CScriptHandle* self = reinterpret_cast<CScriptHandle*>(gen->GetObject());
|
||||||
CScriptHandle *self = reinterpret_cast<CScriptHandle*>(gen->GetObject());
|
new (self) CScriptHandle();
|
||||||
new(self) CScriptHandle();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void CScriptHandle_ConstructCopy_Generic(asIScriptGeneric *gen)
|
void CScriptHandle_ConstructCopy_Generic(asIScriptGeneric* gen) {
|
||||||
{
|
CScriptHandle* other = reinterpret_cast<CScriptHandle*>(gen->GetArgAddress(0));
|
||||||
CScriptHandle *other = reinterpret_cast<CScriptHandle*>(gen->GetArgAddress(0));
|
CScriptHandle* self = reinterpret_cast<CScriptHandle*>(gen->GetObject());
|
||||||
CScriptHandle *self = reinterpret_cast<CScriptHandle*>(gen->GetObject());
|
new (self) CScriptHandle(*other);
|
||||||
new(self) CScriptHandle(*other);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void CScriptHandle_ConstructVar_Generic(asIScriptGeneric *gen)
|
void CScriptHandle_ConstructVar_Generic(asIScriptGeneric* gen) {
|
||||||
{
|
void* ref = gen->GetArgAddress(0);
|
||||||
void *ref = gen->GetArgAddress(0);
|
|
||||||
int typeId = gen->GetArgTypeId(0);
|
int typeId = gen->GetArgTypeId(0);
|
||||||
CScriptHandle *self = reinterpret_cast<CScriptHandle*>(gen->GetObject());
|
CScriptHandle* self = reinterpret_cast<CScriptHandle*>(gen->GetObject());
|
||||||
Construct(self, ref, typeId);
|
Construct(self, ref, typeId);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CScriptHandle_Destruct_Generic(asIScriptGeneric *gen)
|
void CScriptHandle_Destruct_Generic(asIScriptGeneric* gen) {
|
||||||
{
|
CScriptHandle* self = reinterpret_cast<CScriptHandle*>(gen->GetObject());
|
||||||
CScriptHandle *self = reinterpret_cast<CScriptHandle*>(gen->GetObject());
|
|
||||||
self->~CScriptHandle();
|
self->~CScriptHandle();
|
||||||
}
|
}
|
||||||
|
|
||||||
void CScriptHandle_Cast_Generic(asIScriptGeneric *gen)
|
void CScriptHandle_Cast_Generic(asIScriptGeneric* gen) {
|
||||||
{
|
void** ref = reinterpret_cast<void**>(gen->GetArgAddress(0));
|
||||||
void **ref = reinterpret_cast<void**>(gen->GetArgAddress(0));
|
|
||||||
int typeId = gen->GetArgTypeId(0);
|
int typeId = gen->GetArgTypeId(0);
|
||||||
CScriptHandle *self = reinterpret_cast<CScriptHandle*>(gen->GetObject());
|
CScriptHandle* self = reinterpret_cast<CScriptHandle*>(gen->GetObject());
|
||||||
self->Cast(ref, typeId);
|
self->Cast(ref, typeId);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CScriptHandle_Assign_Generic(asIScriptGeneric *gen)
|
void CScriptHandle_Assign_Generic(asIScriptGeneric* gen) {
|
||||||
{
|
CScriptHandle* other = reinterpret_cast<CScriptHandle*>(gen->GetArgAddress(0));
|
||||||
CScriptHandle *other = reinterpret_cast<CScriptHandle*>(gen->GetArgAddress(0));
|
CScriptHandle* self = reinterpret_cast<CScriptHandle*>(gen->GetObject());
|
||||||
CScriptHandle *self = reinterpret_cast<CScriptHandle*>(gen->GetObject());
|
|
||||||
*self = *other;
|
*self = *other;
|
||||||
gen->SetReturnAddress(self);
|
gen->SetReturnAddress(self);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CScriptHandle_AssignVar_Generic(asIScriptGeneric *gen)
|
void CScriptHandle_AssignVar_Generic(asIScriptGeneric* gen) {
|
||||||
{
|
void* ref = gen->GetArgAddress(0);
|
||||||
void *ref = gen->GetArgAddress(0);
|
|
||||||
int typeId = gen->GetArgTypeId(0);
|
int typeId = gen->GetArgTypeId(0);
|
||||||
CScriptHandle *self = reinterpret_cast<CScriptHandle*>(gen->GetObject());
|
CScriptHandle* self = reinterpret_cast<CScriptHandle*>(gen->GetObject());
|
||||||
self->Assign(ref, typeId);
|
self->Assign(ref, typeId);
|
||||||
gen->SetReturnAddress(self);
|
gen->SetReturnAddress(self);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CScriptHandle_Equals_Generic(asIScriptGeneric *gen)
|
void CScriptHandle_Equals_Generic(asIScriptGeneric* gen) {
|
||||||
{
|
CScriptHandle* other = reinterpret_cast<CScriptHandle*>(gen->GetArgAddress(0));
|
||||||
CScriptHandle *other = reinterpret_cast<CScriptHandle*>(gen->GetArgAddress(0));
|
CScriptHandle* self = reinterpret_cast<CScriptHandle*>(gen->GetObject());
|
||||||
CScriptHandle *self = reinterpret_cast<CScriptHandle*>(gen->GetObject());
|
|
||||||
gen->SetReturnByte(*self == *other);
|
gen->SetReturnByte(*self == *other);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CScriptHandle_EqualsVar_Generic(asIScriptGeneric *gen)
|
void CScriptHandle_EqualsVar_Generic(asIScriptGeneric* gen) {
|
||||||
{
|
void* ref = gen->GetArgAddress(0);
|
||||||
void *ref = gen->GetArgAddress(0);
|
|
||||||
int typeId = gen->GetArgTypeId(0);
|
int typeId = gen->GetArgTypeId(0);
|
||||||
CScriptHandle *self = reinterpret_cast<CScriptHandle*>(gen->GetObject());
|
CScriptHandle* self = reinterpret_cast<CScriptHandle*>(gen->GetObject());
|
||||||
gen->SetReturnByte(self->Equals(ref, typeId));
|
gen->SetReturnByte(self->Equals(ref, typeId));
|
||||||
}
|
}
|
||||||
|
|
||||||
void CScriptHandle_EnumReferences_Generic(asIScriptGeneric *gen)
|
void CScriptHandle_EnumReferences_Generic(asIScriptGeneric* gen) {
|
||||||
{
|
CScriptHandle* self = reinterpret_cast<CScriptHandle*>(gen->GetObject());
|
||||||
CScriptHandle *self = reinterpret_cast<CScriptHandle*>(gen->GetObject());
|
|
||||||
self->EnumReferences(gen->GetEngine());
|
self->EnumReferences(gen->GetEngine());
|
||||||
}
|
}
|
||||||
|
|
||||||
void CScriptHandle_ReleaseReferences_Generic(asIScriptGeneric *gen)
|
void CScriptHandle_ReleaseReferences_Generic(asIScriptGeneric* gen) {
|
||||||
{
|
CScriptHandle* self = reinterpret_cast<CScriptHandle*>(gen->GetObject());
|
||||||
CScriptHandle *self = reinterpret_cast<CScriptHandle*>(gen->GetObject());
|
|
||||||
self->ReleaseReferences(gen->GetEngine());
|
self->ReleaseReferences(gen->GetEngine());
|
||||||
}
|
}
|
||||||
|
|
||||||
void RegisterScriptHandle_Generic(asIScriptEngine *engine)
|
void RegisterScriptHandle_Generic(asIScriptEngine* engine) {
|
||||||
{
|
[[maybe_unused]] int r;
|
||||||
int r;
|
|
||||||
|
|
||||||
r = engine->RegisterObjectType("ref", sizeof(CScriptHandle), asOBJ_VALUE | asOBJ_ASHANDLE | asOBJ_GC | asOBJ_APP_CLASS_CDAK); assert( r >= 0 );
|
r = engine->RegisterObjectType("ref", sizeof(CScriptHandle),
|
||||||
r = engine->RegisterObjectBehaviour("ref", asBEHAVE_CONSTRUCT, "void f()", asFUNCTION(CScriptHandle_Construct_Generic), asCALL_GENERIC); assert( r >= 0 );
|
asOBJ_VALUE | asOBJ_ASHANDLE | asOBJ_GC | asOBJ_APP_CLASS_CDAK);
|
||||||
r = engine->RegisterObjectBehaviour("ref", asBEHAVE_CONSTRUCT, "void f(const ref &in)", asFUNCTION(CScriptHandle_ConstructCopy_Generic), asCALL_GENERIC); assert( r >= 0 );
|
assert(r >= 0);
|
||||||
r = engine->RegisterObjectBehaviour("ref", asBEHAVE_CONSTRUCT, "void f(const ?&in)", asFUNCTION(CScriptHandle_ConstructVar_Generic), asCALL_GENERIC); assert( r >= 0 );
|
r = engine->RegisterObjectBehaviour("ref", asBEHAVE_CONSTRUCT, "void f()",
|
||||||
r = engine->RegisterObjectBehaviour("ref", asBEHAVE_DESTRUCT, "void f()", asFUNCTION(CScriptHandle_Destruct_Generic), asCALL_GENERIC); assert( r >= 0 );
|
asFUNCTION(CScriptHandle_Construct_Generic), asCALL_GENERIC);
|
||||||
r = engine->RegisterObjectBehaviour("ref", asBEHAVE_ENUMREFS, "void f(int&in)", asFUNCTION(CScriptHandle_EnumReferences_Generic), asCALL_GENERIC); assert(r >= 0);
|
assert(r >= 0);
|
||||||
r = engine->RegisterObjectBehaviour("ref", asBEHAVE_RELEASEREFS, "void f(int&in)", asFUNCTION(CScriptHandle_ReleaseReferences_Generic), asCALL_GENERIC); assert(r >= 0);
|
r = engine->RegisterObjectBehaviour("ref", asBEHAVE_CONSTRUCT, "void f(const ref &in)",
|
||||||
r = engine->RegisterObjectMethod("ref", "void opCast(?&out)", asFUNCTION(CScriptHandle_Cast_Generic), asCALL_GENERIC); assert( r >= 0 );
|
asFUNCTION(CScriptHandle_ConstructCopy_Generic), asCALL_GENERIC);
|
||||||
r = engine->RegisterObjectMethod("ref", "ref &opHndlAssign(const ref &in)", asFUNCTION(CScriptHandle_Assign_Generic), asCALL_GENERIC); assert( r >= 0 );
|
assert(r >= 0);
|
||||||
r = engine->RegisterObjectMethod("ref", "ref &opHndlAssign(const ?&in)", asFUNCTION(CScriptHandle_AssignVar_Generic), asCALL_GENERIC); assert( r >= 0 );
|
r = engine->RegisterObjectBehaviour("ref", asBEHAVE_CONSTRUCT, "void f(const ?&in)",
|
||||||
r = engine->RegisterObjectMethod("ref", "bool opEquals(const ref &in) const", asFUNCTION(CScriptHandle_Equals_Generic), asCALL_GENERIC); assert( r >= 0 );
|
asFUNCTION(CScriptHandle_ConstructVar_Generic), asCALL_GENERIC);
|
||||||
r = engine->RegisterObjectMethod("ref", "bool opEquals(const ?&in) const", asFUNCTION(CScriptHandle_EqualsVar_Generic), asCALL_GENERIC); assert( r >= 0 );
|
assert(r >= 0);
|
||||||
|
r = engine->RegisterObjectBehaviour("ref", asBEHAVE_DESTRUCT, "void f()",
|
||||||
|
asFUNCTION(CScriptHandle_Destruct_Generic), asCALL_GENERIC);
|
||||||
|
assert(r >= 0);
|
||||||
|
r = engine->RegisterObjectBehaviour("ref", asBEHAVE_ENUMREFS, "void f(int&in)",
|
||||||
|
asFUNCTION(CScriptHandle_EnumReferences_Generic), asCALL_GENERIC);
|
||||||
|
assert(r >= 0);
|
||||||
|
r = engine->RegisterObjectBehaviour("ref", asBEHAVE_RELEASEREFS, "void f(int&in)",
|
||||||
|
asFUNCTION(CScriptHandle_ReleaseReferences_Generic), asCALL_GENERIC);
|
||||||
|
assert(r >= 0);
|
||||||
|
r = engine->RegisterObjectMethod("ref", "void opCast(?&out)", asFUNCTION(CScriptHandle_Cast_Generic),
|
||||||
|
asCALL_GENERIC);
|
||||||
|
assert(r >= 0);
|
||||||
|
r = engine->RegisterObjectMethod("ref", "ref &opHndlAssign(const ref &in)",
|
||||||
|
asFUNCTION(CScriptHandle_Assign_Generic), asCALL_GENERIC);
|
||||||
|
assert(r >= 0);
|
||||||
|
r = engine->RegisterObjectMethod("ref", "ref &opHndlAssign(const ?&in)",
|
||||||
|
asFUNCTION(CScriptHandle_AssignVar_Generic), asCALL_GENERIC);
|
||||||
|
assert(r >= 0);
|
||||||
|
r = engine->RegisterObjectMethod("ref", "bool opEquals(const ref &in) const",
|
||||||
|
asFUNCTION(CScriptHandle_Equals_Generic), asCALL_GENERIC);
|
||||||
|
assert(r >= 0);
|
||||||
|
r = engine->RegisterObjectMethod("ref", "bool opEquals(const ?&in) const",
|
||||||
|
asFUNCTION(CScriptHandle_EqualsVar_Generic), asCALL_GENERIC);
|
||||||
|
assert(r >= 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
void RegisterScriptHandle(asIScriptEngine *engine)
|
void RegisterScriptHandle(asIScriptEngine* engine) {
|
||||||
{
|
if (strstr(asGetLibraryOptions(), "AS_MAX_PORTABILITY"))
|
||||||
if( strstr(asGetLibraryOptions(), "AS_MAX_PORTABILITY") )
|
|
||||||
RegisterScriptHandle_Generic(engine);
|
RegisterScriptHandle_Generic(engine);
|
||||||
else
|
else
|
||||||
RegisterScriptHandle_Native(engine);
|
RegisterScriptHandle_Native(engine);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
END_AS_NAMESPACE
|
END_AS_NAMESPACE
|
||||||
|
|
Loading…
Reference in New Issue