RingRacers/libs/ACSVM/include/CAPI/Module.cpp
Sally Coolatta cb8dddbedc ACS basic implementation
- BEHAVIOR lumps successfully load & run from maps. Currently they do not get unloaded between maps, though.
- Print and Timer are the only implemented CallFuncs. All of the base language functions (Delay, etc) are already implemented by the VM though.
- ACS compiler files are included, for use with GDCC. (Picked instead of ACC because it's less ZDoom-centric)
- Additionally, also added the configs for Zone Builder to be able to compile it in editor. Syntax highlighting is very incomplete atm.
2022-10-04 03:23:17 -04:00

70 lines
1.5 KiB
C++

//-----------------------------------------------------------------------------
//
// Copyright (C) 2015 David Hill
//
// See COPYING for license information.
//
//-----------------------------------------------------------------------------
//
// Modules.
//
//-----------------------------------------------------------------------------
#include "Module.h"
#include "Environment.h"
#include "ACSVM/Error.hpp"
extern "C"
{
//----------------------------------------------------------------------------|
// Extern Functions |
//
//
// ACSVM_Module_GetName
//
void ACSVM_Module_GetName(ACSVM_Module const *module_, ACSVM_ModuleName *out)
{
auto module = reinterpret_cast<ACSVM::Module const *>(module_);
out->s = reinterpret_cast<ACSVM_String *>(module->name.s);
out->p = module->name.p;
out->i = module->name.i;
}
//
// ACSVM_Module_ReadBytecode
//
bool ACSVM_Module_ReadBytecode(ACSVM_Module *module_, ACSVM_Byte const *data, size_t size)
{
auto module = reinterpret_cast<ACSVM::Module *>(module_);
try
{
module->readBytecode(data, size);
return true;
}
catch(ACSVM::ReadError const &e)
{
auto env = static_cast<ACSVM_Environment *>(module->env);
if(env->funcs.readError)
env->funcs.readError(env, e.what());
return false;
}
catch(std::bad_alloc const &e)
{
auto env = static_cast<ACSVM_Environment *>(module->env);
if(env->funcs.bad_alloc)
env->funcs.bad_alloc(env, e.what());
return false;
}
}
}
// EOF