Leviathan  0.8.0.0
Leviathan game engine
BindHelpers.h File Reference
#include "Logger.h"
#include "angelscript.h"
#include <map>
#include <string>

Go to the source code of this file.

Namespaces

 Leviathan
 The access mask controls which registered functions and classes a script sees.
 

Macros

#define ANGELSCRIPT_REGISTERFAIL
 
#define ANGELSCRIPT_ASSUMED_SIZE_T
 Put this anywhere it is assumed that angelscript type uint64 is the same as size_t. More...
 
#define ANGELSCRIPT_REGISTER_REF_TYPE(RegisterName, ClassName)
 
#define ANGELSCRIPT_REGISTER_ENUM_VALUE(enum, x)
 
#define ANGELSCRIPT_REGISTER_ENUM_VALUE_WITH_NAME(enum, valuename, x)
 
#define ANGLESCRIPT_BASE_CLASS_CASTS(base, base_as, derived, derived_as)
 
#define ANGLESCRIPT_BASE_CLASS_CASTS_NO_REF(base, base_as, derived, derived_as)
 
#define ANGLESCRIPT_BASE_CLASS_CASTS_NO_REF_STRING(base, base_as, derived, derived_as)
 

Functions

template<class From , class To >
To * Leviathan::DoReferenceCastDynamic (From *ptr)
 
template<class From , class To >
To * Leviathan::DoReferenceCastStatic (From *ptr)
 
template<class From , class To >
To * Leviathan::DoReferenceCastDynamicNoRef (From *ptr)
 
template<class From , class To >
To * Leviathan::DoReferenceCastStaticNoRef (From *ptr)
 

Macro Definition Documentation

◆ ANGELSCRIPT_ASSUMED_SIZE_T

#define ANGELSCRIPT_ASSUMED_SIZE_T
Value:
static_assert(sizeof(size_t) == sizeof(uint64_t), \
"Script register for size_t assumes it is " \
"equivalent to uint64_t in angelscript");

Put this anywhere it is assumed that angelscript type uint64 is the same as size_t.

Definition at line 21 of file BindHelpers.h.

◆ ANGELSCRIPT_REGISTER_ENUM_VALUE

#define ANGELSCRIPT_REGISTER_ENUM_VALUE (   enum,
 
)
Value:
{ \
if(engine->RegisterEnumValue(#enum, #x, static_cast<int>(enum ::x)) < 0) { \
ANGELSCRIPT_REGISTERFAIL; \
} \
}

Definition at line 107 of file BindHelpers.h.

◆ ANGELSCRIPT_REGISTER_ENUM_VALUE_WITH_NAME

#define ANGELSCRIPT_REGISTER_ENUM_VALUE_WITH_NAME (   enum,
  valuename,
 
)
Value:
{ \
if(engine->RegisterEnumValue(enum, valuename, static_cast<int>(x)) < 0) { \
ANGELSCRIPT_REGISTERFAIL; \
} \
}

Definition at line 114 of file BindHelpers.h.

◆ ANGELSCRIPT_REGISTER_REF_TYPE

#define ANGELSCRIPT_REGISTER_REF_TYPE (   RegisterName,
  ClassName 
)
Value:
if(engine->RegisterObjectType(RegisterName, 0, asOBJ_REF) < 0) { \
ANGELSCRIPT_REGISTERFAIL; \
} \
\
if(engine->RegisterObjectBehaviour(RegisterName, asBEHAVE_ADDREF, "void f()", \
asMETHOD(ClassName, AddRef), asCALL_THISCALL) < 0) { \
ANGELSCRIPT_REGISTERFAIL; \
} \
\
if(engine->RegisterObjectBehaviour(RegisterName, asBEHAVE_RELEASE, "void f()", \
asMETHOD(ClassName, Release), asCALL_THISCALL) < 0) { \
ANGELSCRIPT_REGISTERFAIL; \
}

Definition at line 92 of file BindHelpers.h.

◆ ANGELSCRIPT_REGISTERFAIL

#define ANGELSCRIPT_REGISTERFAIL
Value:
Leviathan::Logger::Get()->Error("AngelScript: Binding failed: " \
"file " __FILE__ " on line " + \
std::to_string(__LINE__)); \
return false;
static DLLEXPORT Logger * Get()
Definition: Logger.cpp:106
DLLEXPORT void Error(const std::string &data) override
Definition: Logger.cpp:177

Definition at line 12 of file BindHelpers.h.

◆ ANGLESCRIPT_BASE_CLASS_CASTS

#define ANGLESCRIPT_BASE_CLASS_CASTS (   base,
  base_as,
  derived,
  derived_as 
)
Value:
if(engine->RegisterObjectMethod(base_as, derived_as "@ opCast()", \
asFUNCTION((Leviathan::DoReferenceCastDynamic<base, derived>)), \
asCALL_CDECL_OBJFIRST) < 1) { \
ANGELSCRIPT_REGISTERFAIL; \
} \
if(engine->RegisterObjectMethod(derived_as, base_as "@ opImplCast()", \
asFUNCTION((Leviathan::DoReferenceCastStatic<derived, base>)), \
asCALL_CDECL_OBJFIRST) < 1) { \
ANGELSCRIPT_REGISTERFAIL; \
} \
if(engine->RegisterObjectMethod(base_as, "const " derived_as "@ opCast() const", \
asFUNCTION((Leviathan::DoReferenceCastDynamic<base, derived>)), \
asCALL_CDECL_OBJFIRST) < 1) { \
ANGELSCRIPT_REGISTERFAIL; \
} \
if(engine->RegisterObjectMethod(derived_as, "const " base_as "@ opImplCast() const", \
asFUNCTION((Leviathan::DoReferenceCastStatic<derived, base>)), \
asCALL_CDECL_OBJFIRST) < 1) { \
ANGELSCRIPT_REGISTERFAIL; \
}

Definition at line 122 of file BindHelpers.h.

◆ ANGLESCRIPT_BASE_CLASS_CASTS_NO_REF

#define ANGLESCRIPT_BASE_CLASS_CASTS_NO_REF (   base,
  base_as,
  derived,
  derived_as 
)
Value:
if(engine->RegisterObjectMethod(base_as, derived_as "@ opCast()", \
asFUNCTION((Leviathan::DoReferenceCastDynamicNoRef<base, derived>)), \
asCALL_CDECL_OBJFIRST) < 1) { \
ANGELSCRIPT_REGISTERFAIL; \
} \
if(engine->RegisterObjectMethod(derived_as, base_as "@ opImplCast()", \
asFUNCTION((Leviathan::DoReferenceCastStaticNoRef<derived, base>)), \
asCALL_CDECL_OBJFIRST) < 1) { \
ANGELSCRIPT_REGISTERFAIL; \
} \
if(engine->RegisterObjectMethod(base_as, "const " derived_as "@ opCast() const", \
asFUNCTION((Leviathan::DoReferenceCastDynamicNoRef<base, derived>)), \
asCALL_CDECL_OBJFIRST) < 1) { \
ANGELSCRIPT_REGISTERFAIL; \
} \
if(engine->RegisterObjectMethod(derived_as, "const " base_as "@ opImplCast() const", \
asFUNCTION((Leviathan::DoReferenceCastStaticNoRef<derived, base>)), \
asCALL_CDECL_OBJFIRST) < 1) { \
ANGELSCRIPT_REGISTERFAIL; \
}

Definition at line 145 of file BindHelpers.h.

◆ ANGLESCRIPT_BASE_CLASS_CASTS_NO_REF_STRING

#define ANGLESCRIPT_BASE_CLASS_CASTS_NO_REF_STRING (   base,
  base_as,
  derived,
  derived_as 
)
Value:
if(engine->RegisterObjectMethod(base_as.c_str(), (derived_as + "@ opCast()").c_str(), \
asFUNCTION((Leviathan::DoReferenceCastDynamicNoRef<base, derived>)), \
asCALL_CDECL_OBJFIRST) < 1) { \
ANGELSCRIPT_REGISTERFAIL; \
} \
if(engine->RegisterObjectMethod(derived_as.c_str(), (base_as + "@ opImplCast()").c_str(), \
asFUNCTION((Leviathan::DoReferenceCastStaticNoRef<derived, base>)), \
asCALL_CDECL_OBJFIRST) < 1) { \
ANGELSCRIPT_REGISTERFAIL; \
} \
if(engine->RegisterObjectMethod(base_as.c_str(), \
("const " + derived_as + "@ opCast() const").c_str(), \
asFUNCTION((Leviathan::DoReferenceCastDynamicNoRef<base, derived>)), \
asCALL_CDECL_OBJFIRST) < 1) { \
ANGELSCRIPT_REGISTERFAIL; \
} \
if(engine->RegisterObjectMethod(derived_as.c_str(), \
("const " + base_as + "@ opImplCast() const").c_str(), \
asFUNCTION((Leviathan::DoReferenceCastStaticNoRef<derived, base>)), \
asCALL_CDECL_OBJFIRST) < 1) { \
ANGELSCRIPT_REGISTERFAIL; \
}

Definition at line 168 of file BindHelpers.h.