New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WIP: CInterface Update #2136

Closed
wants to merge 7 commits into
base: development
from
Copy path View file
@@ -59,6 +59,8 @@
#include "util/sampler.h"
#include "platform/threads/threadPool.h"
#include "cinterface/cinterface.h"
// For the TickMs define... fix this for T2D...
#include "T3D/gameBase/processList.h"
@@ -267,6 +269,9 @@ void StandardMainLoop::init()
ThreadPool::GlobalThreadPool::createSingleton();
// Set engineAPI initialized to true
engineAPI::gIsInitialized = true;
// Initialize modules.
EngineModuleManager::initializeSystem();
@@ -440,6 +445,11 @@ bool StandardMainLoop::handleCommandLine( S32 argc, const char **argv )
// directly because the resource system restricts
// access to the "root" directory.
bool foundExternalMain = false;
CInterface::CallMain(&foundExternalMain);
if (foundExternalMain)
return true;
#ifdef TORQUE_ENABLE_VFS
Zip::ZipArchive *vfs = openEmbeddedVFSArchive();
bool useVFS = vfs != NULL;
@@ -20,61 +20,12 @@
// IN THE SOFTWARE.
//-----------------------------------------------------------------------------
#include "platform/platform.h"
#include "console/compiler.h"
#include "c_consoleInterface.h"
#include "console/consoleInternal.h"
#include "console/simSet.h"
extern "C" {
// SimObject C interface
const char *SimObject_GetName(SimObject *so)
{
return so->getName();
}
U32 SimObject_GetId(SimObject *so)
{
return so->getId();
}
const char *SimObject_GetClassName(SimObject *so)
{
return so->getClassName();
}
void *SimObject_GetFieldList(SimObject *so, S32 &outNumFields)
{
const AbstractClassRep::FieldList &fl = so->getFieldList();
outNumFields = fl.size();
return fl.address();
}
bool SimObject_IsLocked(SimObject *so)
{
return so->isLocked();
}
void SimObject_SetDataField(SimObject *so, const char *fieldName, const char *arr, const char *val)
{
so->setDataField(StringTable->insert(fieldName), arr, val);
}
const char *SimObject_GetDataField(SimObject *so, const char *fieldName, const char *arr)
{
return so->getDataField(StringTable->insert(fieldName), arr);
}
void SimObject_InspectPreApply(SimObject *so)
{
so->inspectPreApply();
}
void SimObject_InspectPostApply(SimObject *so)
{
so->inspectPostApply();
}
// Con C interface
void Con_AddConsumer(ConsumerCallback cb)
{
@@ -86,88 +37,46 @@ extern "C" {
Con::removeConsumer(cb);
}
void Con_AddCommand_String(StringCallback cb, const char *nameSpace, const char *funcName, const char* usage, S32 minArgs, S32 maxArgs)
{
if (!nameSpace || !dStrlen(nameSpace))
Con::addCommand(funcName, cb, usage, minArgs + 1, maxArgs + 1);
else
Con::addCommand(nameSpace, funcName, cb, usage, minArgs + 1, maxArgs + 1);
}
// ConsoleBaseType C interface
ConsoleBaseType *ConsoleBaseType_GetTypeById(const S32 typeId)
{
return ConsoleBaseType::getType(typeId);
}
S32 ConsoleBaseType_GetTypeId(ConsoleBaseType *cbt)
{
return cbt->getTypeID();
}
S32 ConsoleBaseType_GetTypeSize(ConsoleBaseType *cbt)
{
return cbt->getTypeSize();
}
const char *ConsoleBaseType_GetTypeName(ConsoleBaseType *cbt)
{
return cbt->getTypeName();
}
const char *ConsoleBaseType_GetInspectorFieldType(ConsoleBaseType *cbt)
{
return cbt->getInspectorFieldType();
}
// StringTable->insert?
void ConsoleBaseType_SetData(ConsoleBaseType *cbt, void *dptr, S32 argc, const char **argv, const EnumTable *tbl, BitSet32 flag)
const char* Con_getConsoleString(const char* name)
{
return cbt->setData(dptr, argc, argv, tbl, flag);
return Con::getVariable(StringTable->insert(name));
}
const char *ConsoleBaseType_GetData(ConsoleBaseType *cbt, void *dptr, const EnumTable *tbl, BitSet32 flag)
void Con_setConsoleString(const char* name, const char* value)
{
return cbt->getData(dptr, tbl, flag);
Con::setVariable(StringTable->insert(name), StringTable->insert(value));
}
// Abstract Class Rep
AbstractClassRep *AbstractClassRep_GetCommonParent(AbstractClassRep *acr, AbstractClassRep *otheracr)
S32 Con_getConsoleInt(const char* name)
{
return acr->getCommonParent(otheracr);
return Con::getIntVariable(StringTable->insert(name));
}
AbstractClassRep *AbstractClassRep_FindClassRep(const char* in_pClassName)
void Con_setConsoleInt(const char* name, S32 value)
{
return AbstractClassRep::findClassRep(in_pClassName);
Con::setIntVariable(StringTable->insert(name), value);
}
U32 AbstractClassRep_GetFieldStructSize()
F32 Con_getConsoleFloat(const char* name)
{
return sizeof(AbstractClassRep::Field);
return Con::getFloatVariable(StringTable->insert(name));
}
// Sim C interface
SimObject *Sim_FindObjectByString(const char *param)
{
return Sim::findObject(param);
}
SimObject *Sim_FindObjectById(S32 param)
void Con_setConsoleFloat(const char* name, F32 value)
{
return Sim::findObject(param);
Con::setFloatVariable(StringTable->insert(name), value);
}
// Sim Set
SimObject **SimSet_Begin(SimObject *simObject)
bool Con_getConsoleBool(const char* name)
{
return dynamic_cast<SimSet *>(simObject)->begin();
return Con::getBoolVariable(StringTable->insert(name));
}
SimObject **SimSet_End(SimObject *simObject)
void Con_setConsoleBool(const char* name, bool value)
{
return dynamic_cast<SimSet *>(simObject)->end();
Con::setBoolVariable(StringTable->insert(name), value);
}
};
}
@@ -0,0 +1,41 @@
//-----------------------------------------------------------------------------
// Copyright (c) 2012 GarageGames, LLC
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to
// deal in the Software without restriction, including without limitation the
// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
// sell copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
// IN THE SOFTWARE.
//-----------------------------------------------------------------------------
#ifndef C_CONSOLEINTERFACE_H
#define C_CONSOLEINTERFACE_H
#include "platform/platformDlibrary.h"
#include "console/consoleInternal.h"
extern "C" {
void Con_AddConsumer(ConsumerCallback cb);
void Con_RemoveConsumer(ConsumerCallback cb);
const char* Con_getConsoleString(const char* name);
void Con_setConsoleString(const char* name, const char* value);
S32 Con_getConsoleInt(const char* name);
void Con_setConsoleInt(const char* name, S32 value);
F32 Con_getConsoleFloat(const char* name);
void Con_setConsoleFloat(const char* name, F32 value);
bool Con_getConsoleBool(const char* name);
void Con_setConsoleBool(const char* name, bool value);
}
#endif // C_CONSOLEINTERFACE_H
Oops, something went wrong.
ProTip! Use n and p to navigate between commits in a pull request.