Blender interface tweaks; submodule updates

This commit is contained in:
Jack Andersen 2015-08-08 13:33:55 -10:00
parent 99765b60ff
commit 2f3145974c
10 changed files with 19 additions and 211 deletions

View File

@ -25,11 +25,10 @@ namespace Retro
extern HECL::Database::DataSpecEntry SpecEntMP3;
}
/* An overzealous optimizing compiler/linker may not init the specs if
* there's no in-code reference.. this is a simple hack to solve that */
extern "C" void HECLDataSpecs()
/* Please Call Me! */
void HECLRegisterDataSpecs()
{
HECL::Printf(_S("%s\n"), Retro::SpecEntMP1.m_name);
HECL::Printf(_S("%s\n"), Retro::SpecEntMP2.m_name);
HECL::Printf(_S("%s\n"), Retro::SpecEntMP3.m_name);
HECL::Database::DATA_SPEC_REGISTRY.push_back(&Retro::SpecEntMP1);
HECL::Database::DATA_SPEC_REGISTRY.push_back(&Retro::SpecEntMP2);
HECL::Database::DATA_SPEC_REGISTRY.push_back(&Retro::SpecEntMP3);
}

View File

@ -229,8 +229,9 @@ BlenderConnection::BlenderConnection(bool silenceBlender)
if (silenceBlender)
{
close(STDOUT_FILENO);
close(STDERR_FILENO);
int devNull = open("/dev/null", O_WRONLY);
dup2(devNull, STDOUT_FILENO);
dup2(devNull, STDERR_FILENO);
}
char errbuf[256];

View File

@ -19,18 +19,13 @@ add_executable(hecl main.cpp
list(APPEND DATA_SPEC_LIBS
RetroDataSpec
DNACommon
DNAMP1
DNAMP2
DNAMP3)
if(NOT WIN32)
set(WHOLE_START "-Wl,-whole-archive")
set(WHOLE_END "-Wl,-no-whole-archive")
endif()
DNAMP3
DNACommon)
target_link_libraries(hecl
${WHOLE_START} HECLDatabaseInit ${DATA_SPEC_LIBS} ${WHOLE_END}
HECLDatabase HECLBlender HECLCommon AthenaCore AngelScript NOD
LogVisor yaml png squish blowfish z lzo2
${DATA_SPEC_LIBS}
HECLDatabase HECLBlender HECLCommon AthenaCore NOD
LogVisor AthenaLibYaml png squish blowfish z lzo2 pthread
)

View File

@ -107,6 +107,9 @@ int main(int argc, const char** argv)
return 0;
}
/* Prepare DataSpecs */
HECLRegisterDataSpecs();
/* Assemble common tool pass info */
ToolPassInfo info;
info.pname = argv[0];

2
hecl/extern/Athena vendored

@ -1 +1 @@
Subproject commit 9ed090b12629ddb8a431b871340276da61e88442
Subproject commit 9f0cb1327bad28ca727f1181baeba99cc1f3b7d9

@ -1 +1 @@
Subproject commit e0bf3a702401fa832e042a4eeabb399fdd354419
Subproject commit 2d18e95a91e17d1352d2779c71d01da4155a164e

View File

@ -15,7 +15,6 @@
#include <stdint.h>
#include <assert.h>
#include <angelscript.h>
#include <Athena/IStreamReader.hpp>
#include <LogVisor/LogVisor.hpp>
@ -27,129 +26,6 @@ namespace Database
{
class Project;
extern AngelScript::asIScriptEngine* asENGINE;
void InitASEngine();
template <class ASCLASS>
class ASType
{
static void Constructor(ASCLASS* self)
{
new(self) ASCLASS();
}
static void Destructor(ASCLASS* self)
{
self->~ASCLASS();
}
const char* m_name;
int m_typeid;
public:
ASType(const char* namesp, const char* name) : m_name(name)
{
InitASEngine();
assert(asENGINE->SetDefaultNamespace(namesp) >= 0);
assert((m_typeid = asENGINE->RegisterObjectType(name, sizeof(ASCLASS), AngelScript::asOBJ_VALUE)) >= 0);
assert(asENGINE->RegisterObjectBehaviour(name, AngelScript::asBEHAVE_CONSTRUCT, "void f()",
AngelScript::asFUNCTION(Constructor),
AngelScript::asCALL_CDECL_OBJLAST) >= 0);
assert(asENGINE->RegisterObjectBehaviour(name, AngelScript::asBEHAVE_DESTRUCT, "void f()",
AngelScript::asFUNCTION(Destructor),
AngelScript::asCALL_CDECL_OBJLAST) >= 0);
}
inline const char* getName() const {return m_name;}
inline int getTypeID() const {return m_typeid;}
};
template <class ASELEMCLASS>
class ASListType
{
struct ASListInst
{
std::vector<ASELEMCLASS*> m_items;
ASListInst(void* list)
{
AngelScript::asUINT count = *(AngelScript::asUINT*)list;
ASELEMCLASS* items = (ASELEMCLASS*)((char*)list + 4);
m_items.reserve(count);
for (AngelScript::asUINT i=0 ; i<count ; ++i)
m_items.push_back(&items[i]);
}
};
static void ListConstructor(void* list, ASListInst* self)
{
new(self) ASListInst(list);
}
static void ListDestructor(ASListInst* self)
{
self->~ASListInst();
}
const char* m_name;
const char* m_elemName;
int m_typeid;
public:
ASListType(const char* namesp, const char* name, const char* elemName) : m_name(name), m_elemName(elemName)
{
InitASEngine();
assert(asENGINE->SetDefaultNamespace(namesp) >= 0);
assert((m_typeid = asENGINE->RegisterObjectType(name, sizeof(ASListInst), AngelScript::asOBJ_VALUE)) >= 0);
assert(asENGINE->RegisterObjectBehaviour(name, AngelScript::asBEHAVE_LIST_CONSTRUCT,
("void f(int &in) {repeat " + std::string(elemName) + "}").c_str(),
AngelScript::asFUNCTION(ListConstructor),
AngelScript::asCALL_CDECL_OBJLAST) >= 0);
assert(asENGINE->RegisterObjectBehaviour(name, AngelScript::asBEHAVE_DESTRUCT, "void f()",
AngelScript::asFUNCTION(ListDestructor),
AngelScript::asCALL_CDECL_OBJLAST) >= 0);
}
inline const char* getName() const {return m_name;}
inline const char* getElemName() const {return m_elemName;}
inline int getTypeID() const {return m_typeid;}
inline std::vector<ASELEMCLASS*>& vectorCast(void* addr) const
{return static_cast<ASListInst*>(addr)->m_items;}
inline const std::vector<ASELEMCLASS*>& vectorCast(const void* addr) const
{return static_cast<const ASListInst*>(addr)->m_items;}
};
struct ASStringType : ASType<std::string>
{ASStringType();};
extern ASStringType asSTRINGTYPE;
/**
* @brief AngelScript Module Wrapper designed for HECL usage
*
* Behaves similarly to unique_ptr. Move construction/assignment only
* Implicit conversion is supplied for seamless usage as a module reference
*/
class ASUniqueModule
{
AngelScript::asIScriptModule* m_mod;
ASUniqueModule() {m_mod = nullptr;}
ASUniqueModule(AngelScript::asIScriptModule* mod) : m_mod(mod) {}
public:
~ASUniqueModule() {if (m_mod) m_mod->Discard();}
ASUniqueModule(ASUniqueModule&& other) = default;
ASUniqueModule(const ASUniqueModule& other) = delete;
ASUniqueModule& operator=(ASUniqueModule&& other) = default;
ASUniqueModule& operator=(const ASUniqueModule& other) = delete;
inline operator AngelScript::asIScriptModule&() {return *m_mod;}
inline operator bool() {return m_mod != nullptr;}
static ASUniqueModule CreateFromCode(const char* module, const char* code)
{
AngelScript::asIScriptModule* mod = asENGINE->GetModule(module, AngelScript::asGM_ALWAYS_CREATE);
assert(mod);
assert(mod->AddScriptSection(module, code) >= 0);
if (mod->Build() >= 0)
return ASUniqueModule(mod);
else
return ASUniqueModule();
}
static ASUniqueModule CreateFromPath(const ProjectPath& path)
{
std::string asStr;
std::ifstream(path.getAbsolutePath()) >> asStr;
return CreateFromCode(path.getRelativePathUTF8().c_str(), asStr.c_str());
}
};
extern LogVisor::LogModule LogModule;
/**
@ -287,10 +163,7 @@ struct DataSpecEntry
DataSpecEntry(const SystemChar* name, const SystemChar* desc,
std::function<IDataSpec*(Project& project, DataSpecTool)>&& factory)
: m_name(std::move(name)), m_desc(std::move(desc)), m_factory(std::move(factory))
{
DATA_SPEC_REGISTRY.push_back(this);
}
: m_name(name), m_desc(desc), m_factory(std::move(factory)) {}
};
/**

View File

@ -1,36 +0,0 @@
#include "HECL/Database.hpp"
namespace HECL
{
namespace Database
{
/* Centralized AngelScript engine */
AngelScript::asIScriptEngine* asENGINE = nullptr;
/* AngelScript Logger */
static LogVisor::LogModule Log("AngelScript");
static void MessageCallback(const AngelScript::asSMessageInfo* msg, void*)
{
LogVisor::Level lv = LogVisor::Error;
if (msg->type == AngelScript::asMSGTYPE_WARNING)
lv = LogVisor::Warning;
else if (msg->type == AngelScript::asMSGTYPE_INFORMATION)
lv = LogVisor::Info;
Log.reportSource(lv, msg->section, msg->row, msg->message);
}
static bool InitEntered = false;
void InitASEngine()
{
if (InitEntered)
return;
InitEntered = true;
assert(asENGINE = AngelScript::asCreateScriptEngine(ANGELSCRIPT_VERSION));
assert(asENGINE->SetEngineProperty(AngelScript::asEP_COPY_SCRIPT_SECTIONS, false) >= 0);
assert(asENGINE->SetEngineProperty(AngelScript::asEP_ALLOW_MULTILINE_STRINGS, true) >= 0);
assert(asENGINE->SetMessageCallback(AngelScript::asFUNCTION(MessageCallback), nullptr, AngelScript::asCALL_CDECL) >= 0);
}
}
}

View File

@ -1,24 +0,0 @@
#include "HECL/Database.hpp"
namespace HECL
{
namespace Database
{
static std::string StringFactory(unsigned int byteLength, const char *s)
{
return std::string(s, byteLength);
}
ASStringType asSTRINGTYPE;
ASStringType::ASStringType() : ASType<std::string>("", "string")
{
assert(asENGINE->RegisterStringFactory("string",
AngelScript::asFUNCTION(StringFactory),
AngelScript::asCALL_CDECL) >= 0);
}
}
}

View File

@ -1,6 +1,3 @@
add_library(HECLDatabaseInit
ASInit.cpp)
add_library(HECLDatabase
ASEngine.cpp
Project.cpp)