mirror of
https://github.com/TorqueGameEngines/Torque3D.git
synced 2026-02-13 03:33:48 +00:00
Update the CInterface
This commit is contained in:
parent
13eb392c98
commit
ae1f5a3c89
10 changed files with 576 additions and 985 deletions
|
|
@ -20,154 +20,59 @@
|
|||
// IN THE SOFTWARE.
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
#include "platform/platform.h"
|
||||
#include "console/compiler.h"
|
||||
#include "console/consoleInternal.h"
|
||||
#include "console/simSet.h"
|
||||
#include "console/engineAPI.h"
|
||||
|
||||
extern "C" {
|
||||
|
||||
// SimObject C interface
|
||||
const char *SimObject_GetName(SimObject *so)
|
||||
namespace Con
|
||||
{
|
||||
DefineNewEngineFunction(AddConsumer, void, (ConsumerCallback cb), , "")
|
||||
{
|
||||
return so->getName();
|
||||
addConsumer(cb);
|
||||
}
|
||||
|
||||
U32 SimObject_GetId(SimObject *so)
|
||||
DefineNewEngineFunction(RemoveConsumer, void, (ConsumerCallback cb), , "")
|
||||
{
|
||||
return so->getId();
|
||||
removeConsumer(cb);
|
||||
}
|
||||
|
||||
const char *SimObject_GetClassName(SimObject *so)
|
||||
DefineNewEngineFunction(GetConsoleString, String, (String name),, "")
|
||||
{
|
||||
return so->getClassName();
|
||||
return getVariable(StringTable->insert(name));
|
||||
}
|
||||
|
||||
void *SimObject_GetFieldList(SimObject *so, S32 &outNumFields)
|
||||
DefineNewEngineFunction(SetConsoleString, void, (String name, String value),, "")
|
||||
{
|
||||
const AbstractClassRep::FieldList &fl = so->getFieldList();
|
||||
outNumFields = fl.size();
|
||||
return fl.address();
|
||||
setVariable(StringTable->insert(name), StringTable->insert(value));
|
||||
}
|
||||
|
||||
bool SimObject_IsLocked(SimObject *so)
|
||||
DefineNewEngineFunction(GetConsoleInt, S32, (String name),, "")
|
||||
{
|
||||
return so->isLocked();
|
||||
return getIntVariable(StringTable->insert(name));
|
||||
}
|
||||
|
||||
void SimObject_SetDataField(SimObject *so, const char *fieldName, const char *arr, const char *val)
|
||||
DefineNewEngineFunction(SetConsoleInt, void, (String name, S32 value),, "")
|
||||
{
|
||||
so->setDataField(StringTable->insert(fieldName), arr, val);
|
||||
setIntVariable(StringTable->insert(name), value);
|
||||
}
|
||||
|
||||
const char *SimObject_GetDataField(SimObject *so, const char *fieldName, const char *arr)
|
||||
DefineNewEngineFunction(GetConsoleFloat, F32, (String name),, "")
|
||||
{
|
||||
return so->getDataField(StringTable->insert(fieldName), arr);
|
||||
return getFloatVariable(StringTable->insert(name));
|
||||
}
|
||||
|
||||
void SimObject_InspectPreApply(SimObject *so)
|
||||
DefineNewEngineFunction(SetConsoleFloat, void, (String name, F32 value),, "")
|
||||
{
|
||||
so->inspectPreApply();
|
||||
setFloatVariable(StringTable->insert(name), value);
|
||||
}
|
||||
|
||||
void SimObject_InspectPostApply(SimObject *so)
|
||||
DefineNewEngineFunction(GetConsoleBool, bool, (String name),, "")
|
||||
{
|
||||
so->inspectPostApply();
|
||||
return getBoolVariable(StringTable->insert(name));
|
||||
}
|
||||
|
||||
// Con C interface
|
||||
void Con_AddConsumer(ConsumerCallback cb)
|
||||
DefineNewEngineFunction(SetConsoleBool, void, (String name, bool value),, "")
|
||||
{
|
||||
Con::addConsumer(cb);
|
||||
setBoolVariable(StringTable->insert(name), value);
|
||||
}
|
||||
|
||||
void Con_RemoveConsumer(ConsumerCallback cb)
|
||||
{
|
||||
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();
|
||||
}
|
||||
|
||||
void ConsoleBaseType_SetData(ConsoleBaseType *cbt, void *dptr, S32 argc, const char **argv, const EnumTable *tbl, BitSet32 flag)
|
||||
{
|
||||
return cbt->setData(dptr, argc, argv, tbl, flag);
|
||||
}
|
||||
|
||||
const char *ConsoleBaseType_GetData(ConsoleBaseType *cbt, void *dptr, const EnumTable *tbl, BitSet32 flag)
|
||||
{
|
||||
return cbt->getData(dptr, tbl, flag);
|
||||
}
|
||||
|
||||
// Abstract Class Rep
|
||||
AbstractClassRep *AbstractClassRep_GetCommonParent(AbstractClassRep *acr, AbstractClassRep *otheracr)
|
||||
{
|
||||
return acr->getCommonParent(otheracr);
|
||||
}
|
||||
|
||||
AbstractClassRep *AbstractClassRep_FindClassRep(const char* in_pClassName)
|
||||
{
|
||||
return AbstractClassRep::findClassRep(in_pClassName);
|
||||
}
|
||||
|
||||
U32 AbstractClassRep_GetFieldStructSize()
|
||||
{
|
||||
return sizeof(AbstractClassRep::Field);
|
||||
}
|
||||
|
||||
// Sim C interface
|
||||
SimObject *Sim_FindObjectByString(const char *param)
|
||||
{
|
||||
return Sim::findObject(param);
|
||||
}
|
||||
|
||||
SimObject *Sim_FindObjectById(S32 param)
|
||||
{
|
||||
return Sim::findObject(param);
|
||||
}
|
||||
|
||||
// Sim Set
|
||||
SimObject **SimSet_Begin(SimObject *simObject)
|
||||
{
|
||||
return dynamic_cast<SimSet *>(simObject)->begin();
|
||||
}
|
||||
|
||||
SimObject **SimSet_End(SimObject *simObject)
|
||||
{
|
||||
return dynamic_cast<SimSet *>(simObject)->end();
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue