#pragma once
#include "DeerStudio/EditorEngine/ErrorHandle.h"
#include "DeerStudio/EditorEngine.h"

#define REGISTER_GLOBAL_FUNC(funcdef, func)     \
AS_CHECK(scriptEngine->RegisterGlobalFunction(      \
    funcdef,      \
    asFUNCTION(func), asCALL_CDECL \
))

#define REGISTER_OBJECT_METHOD(clasdef, funcdef, clas, func)     \
AS_CHECK(scriptEngine->RegisterObjectMethod(     \
    clasdef, funcdef,     \
    asMETHOD(clas, func), asCALL_THISCALL \
))

#define REGISTER_EXT_OBJECT_METHOD(clasdef, funcdef, func)     \
AS_CHECK(scriptEngine->RegisterObjectMethod(     \
    clasdef, funcdef,     \
    asFUNCTION(func), asCALL_CDECL_OBJLAST \
))

#define REGISTER_EXT_OBJECT_CONSTRUCTOR(clasdef, funcdef, func)     \
AS_CHECK(scriptEngine->RegisterObjectBehaviour (     \
    clasdef, asBEHAVE_CONSTRUCT, funcdef,     \
    asFUNCTION(func), asCALL_CDECL_OBJLAST \
))
#define REGISTER_EXT_OBJECT_DESTRUCTOR(clasdef, funcdef, func)     \
AS_CHECK(scriptEngine->RegisterObjectBehaviour (     \
    clasdef, asBEHAVE_DESTRUCT, funcdef,     \
    asFUNCTION(func), asCALL_CDECL_OBJLAST \
))