Skip to content
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

Improve cinterface #2366

Open
wants to merge 25 commits into
base: development
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
ed1052b
AFX: Fix ambiguous "addEffect" naming
lukaspj Aug 2, 2019
391f772
Expand EngineAPI type definitions
lukaspj Aug 3, 2019
ff9e6ad
Rename GuiSpeedometer::mColor to mNeedleColor to avoid clash with parent
lukaspj Aug 3, 2019
ce87bb2
TriggerComponent: Avoid nameclash between fields and callback methods.
lukaspj Aug 3, 2019
d4457ea
PostEffect: Rename isEnabled field to enabled, to fix name clash
lukaspj Aug 3, 2019
62c9f0a
ModuleDefinition: Remove duplicate addProtectedField for ModuleId
lukaspj Aug 3, 2019
59218f7
GuiFilterCtrl: Rename identity function to resetFiltering to avoid clash
lukaspj Aug 3, 2019
42403fb
Update EngineAPI, use fixed_tuple as main underlying data structure
lukaspj Aug 3, 2019
2eb6620
Engine API: Pass structs by reference
lukaspj Aug 3, 2019
14342a5
EngineAPI: Expose strings as UTF8 instead of UTF16
lukaspj Aug 3, 2019
e5a0075
ModuleSystem: Lookup CInterface methods when calling module create func
lukaspj Aug 3, 2019
33acca2
Expose SimPersistID to EngineAPI
lukaspj Aug 3, 2019
96c23b7
Remove superfluous Get/SetField API methods
lukaspj Aug 3, 2019
440da9c
Correct name of EaseF param in struct EngineAPI export
lukaspj Aug 3, 2019
e588bd7
Fix typo in reverbModDepth field name
lukaspj Aug 3, 2019
c13ae22
Avoid nameclash in guiScriptNotifyControl fields
lukaspj Aug 3, 2019
9d0739b
Remove double quotes inside string definition in UndoManagerpushCompound
lukaspj Aug 3, 2019
b21f898
Comment out unused Call Ins for setting SFXSource transform
lukaspj Aug 3, 2019
36a5912
Improve Engine API export, robust Default Value logic and allow _ in arg
lukaspj Aug 3, 2019
c17152c
CInterface integration in CodeInterpreter null ptr fix
lukaspj Aug 4, 2019
017d545
Remove typename from ArgumentToValue specifier
lukaspj Oct 7, 2019
a88c86a
Fix non-mvc compilation in EngineDefaultArguments
lukaspj Oct 7, 2019
0a6beb8
Remove typename from ArgumentToValue specifier in MethodTrampoline
lukaspj Oct 7, 2019
27867d8
Remove object and function namespace from argument list
lukaspj Oct 8, 2019
6a0ec74
Properly mark Parent class of DebugDrawer for Console hierarchy
lukaspj Oct 15, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 11 additions & 11 deletions Engine/source/T3D/components/game/triggerComponent.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,28 +18,28 @@

#include "gfx/sim/debugDraw.h"

IMPLEMENT_CALLBACK( TriggerComponent, onEnterViewCmd, void,
IMPLEMENT_CALLBACK( TriggerComponent, onEnterView, void,
( Entity* cameraEnt, bool firstTimeSeeing ), ( cameraEnt, firstTimeSeeing ),
"@brief Called when an object enters the volume of the Trigger instance using this TriggerData.\n\n"

"@param trigger the Trigger instance whose volume the object entered\n"
"@param obj the object that entered the volume of the Trigger instance\n" );

IMPLEMENT_CALLBACK( TriggerComponent, onExitViewCmd, void,
IMPLEMENT_CALLBACK( TriggerComponent, onExitView, void,
( Entity* cameraEnt ), ( cameraEnt ),
"@brief Called when an object enters the volume of the Trigger instance using this TriggerData.\n\n"

"@param trigger the Trigger instance whose volume the object entered\n"
"@param obj the object that entered the volume of the Trigger instance\n" );

IMPLEMENT_CALLBACK( TriggerComponent, onUpdateInViewCmd, void,
IMPLEMENT_CALLBACK( TriggerComponent, onUpdateInView, void,
( Entity* cameraEnt ), ( cameraEnt ),
"@brief Called when an object enters the volume of the Trigger instance using this TriggerData.\n\n"

"@param trigger the Trigger instance whose volume the object entered\n"
"@param obj the object that entered the volume of the Trigger instance\n" );

IMPLEMENT_CALLBACK( TriggerComponent, onUpdateOutOfViewCmd, void,
IMPLEMENT_CALLBACK( TriggerComponent, onUpdateOutOfView, void,
( Entity* cameraEnt ), ( cameraEnt ),
"@brief Called when an object enters the volume of the Trigger instance using this TriggerData.\n\n"

Expand Down Expand Up @@ -146,8 +146,8 @@ void TriggerComponent::initPersistFields()

addField("visibile", TypeBool, Offset( mVisible, TriggerComponent ), "" );

addField("onEnterViewCmd", TypeCommand, Offset(mEnterCommand, TriggerComponent), "");
addField("onExitViewCmd", TypeCommand, Offset(mOnExitCommand, TriggerComponent), "");
addField("onEnterViewCmd", TypeCommand, Offset(mOnEnterViewCmd, TriggerComponent), "");
addField("onExitViewCmd", TypeCommand, Offset(mOnExitViewCmd, TriggerComponent), "");
addField("onUpdateInViewCmd", TypeCommand, Offset(mOnUpdateInViewCmd, TriggerComponent), "");
}

Expand Down Expand Up @@ -180,10 +180,10 @@ void TriggerComponent::potentialEnterObject(SceneObject *collider)
{
mObjectList.push_back(collider);

if (!mEnterCommand.isEmpty())
if (!mOnEnterViewCmd.isEmpty())
{
String command = String("%obj = ") + collider->getIdString() + ";" +
String("%this = ") + getIdString() + ";" + mEnterCommand;
String("%this = ") + getIdString() + ";" + mOnEnterViewCmd;
Con::evaluate(command.c_str());
}

Expand Down Expand Up @@ -262,10 +262,10 @@ void TriggerComponent::processTick()
{
if(!testObject(mObjectList[i]))
{
if (!mOnExitCommand.isEmpty())
if (!mOnExitViewCmd.isEmpty())
{
String command = String("%obj = ") + mObjectList[i]->getIdString() + ";" +
String("%this = ") + getIdString() + ";" + mOnExitCommand;
String("%this = ") + getIdString() + ";" + mOnExitViewCmd;
Con::evaluate(command.c_str());
}

Expand Down Expand Up @@ -354,4 +354,4 @@ DefineEngineMethod( TriggerComponent, visualizeFrustums, void,
"@return true if successful, false if failed (objB is not valid)" )
{
object->visualizeFrustums(renderTime);
}
}
12 changes: 6 additions & 6 deletions Engine/source/T3D/components/game/triggerComponent.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ class TriggerComponent : public Component

bool mVisible;

String mEnterCommand;
String mOnExitCommand;
String mOnEnterViewCmd;
String mOnExitViewCmd;
String mOnUpdateInViewCmd;

public:
Expand Down Expand Up @@ -65,10 +65,10 @@ class TriggerComponent : public Component

void visualizeFrustums(F32 renderTimeMS);

DECLARE_CALLBACK(void, onEnterViewCmd, (Entity* cameraEnt, bool firstTimeSeeing));
DECLARE_CALLBACK(void, onExitViewCmd, (Entity* cameraEnt));
DECLARE_CALLBACK(void, onUpdateInViewCmd, (Entity* cameraEnt));
DECLARE_CALLBACK(void, onUpdateOutOfViewCmd, (Entity* cameraEnt));
DECLARE_CALLBACK(void, onEnterView, (Entity* cameraEnt, bool firstTimeSeeing));
DECLARE_CALLBACK(void, onExitView, (Entity* cameraEnt));
DECLARE_CALLBACK(void, onUpdateInView, (Entity* cameraEnt));
DECLARE_CALLBACK(void, onUpdateOutOfView, (Entity* cameraEnt));
};

#endif // _EXAMPLEBEHAVIOR_H_
5 changes: 5 additions & 0 deletions Engine/source/T3D/trigger.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -235,6 +235,11 @@ bool Trigger::castRay(const Point3F &start, const Point3F &end, RayInfo* info)
DECLARE_STRUCT( Polyhedron );
IMPLEMENT_STRUCT( Polyhedron, Polyhedron,,
"" )

FIELD(mPointList, pointList, 1, "")
FIELD(mPlaneList, planeList, 1, "")
FIELD(mEdgeList, edgeList, 1, "")

END_IMPLEMENT_STRUCT;
ConsoleType(floatList, TypeTriggerPolyhedron, Polyhedron, "")

Expand Down
8 changes: 4 additions & 4 deletions Engine/source/T3D/vehicles/guiSpeedometer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ class GuiSpeedometerHud : public GuiBitmapCtrl
F32 mMaxAngle; ///< Max pos of needle
F32 mMinAngle; ///< Min pos of needle
Point2F mCenter; ///< Center of needle rotation
LinearColorF mColor; ///< Needle Color
LinearColorF mNeedleColor; ///< Needle Color
F32 mNeedleLength;
F32 mNeedleWidth;
F32 mTailLength;
Expand Down Expand Up @@ -103,7 +103,7 @@ GuiSpeedometerHud::GuiSpeedometerHud()
mNeedleWidth = 3;
mNeedleLength = 10;
mTailLength = 5;
mColor.set(1,0,0,1);
mNeedleColor.set(1,0,0,1);
}

void GuiSpeedometerHud::initPersistFields()
Expand All @@ -122,7 +122,7 @@ void GuiSpeedometerHud::initPersistFields()
"Angle (in radians) of the needle when the Vehicle speed is >= maxSpeed. "
"An angle of 0 points right, 90 points up etc)." );

addField("color", TypeColorF, Offset( mColor, GuiSpeedometerHud ),
addField("color", TypeColorF, Offset( mNeedleColor, GuiSpeedometerHud ),
"Color of the needle" );

addField("center", TypePoint2F, Offset( mCenter, GuiSpeedometerHud ),
Expand Down Expand Up @@ -210,7 +210,7 @@ void GuiSpeedometerHud::onRender(Point2I offset, const RectI &updateRect)
GFX->setTexture(0, NULL);

// Render the needle
PrimBuild::color4f(mColor.red, mColor.green, mColor.blue, mColor.alpha);
PrimBuild::color4f(mNeedleColor.red, mNeedleColor.green, mNeedleColor.blue, mNeedleColor.alpha);
PrimBuild::begin(GFXLineStrip, 5);
for(int k=0; k<5; k++){
rotMatrix.mulP(vertList[k]);
Expand Down
6 changes: 3 additions & 3 deletions Engine/source/afx/afxEffectGroup.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -253,13 +253,13 @@ DefineEngineMethod(afxEffectGroupData, reset, void, (),,
object->reloadReset();
}

DefineEngineMethod(afxEffectGroupData, addEffect, void, (afxEffectBaseData* effect),,
"Adds an effect (wrapper or group) to an effect-group.\n\n"
DefineEngineMethod(afxEffectGroupData, pushEffect, void, (afxEffectBaseData* effect),,
"Pushes an effect (wrapper or group) to an effect-group.\n\n"
"@ingroup AFX")
{
if (!effect)
{
Con::errorf("afxEffectGroupData::addEffect() -- missing afxEffectWrapperData.");
Con::errorf("afxEffectGroupData::pushEffect() -- missing afxEffectWrapperData.");
return;
}

Expand Down
6 changes: 3 additions & 3 deletions Engine/source/afx/afxEffectron.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -216,13 +216,13 @@ DefineEngineMethod(afxEffectronData, reset, void, (),,
object->reloadReset();
}

DefineEngineMethod(afxEffectronData, addEffect, void, (afxEffectBaseData* effect),,
"Adds an effect (wrapper or group) to an effectron's phase.\n\n"
DefineEngineMethod(afxEffectronData, pushEffect, void, (afxEffectBaseData* effect),,
"Pushes an effect (wrapper or group) to an effectron's phase.\n\n"
"@ingroup AFX")
{
if (!effect)
{
Con::errorf("afxEffectronData::addEffect() -- missing afxEffectWrapperData.");
Con::errorf("afxEffectronData::pushEffect() -- missing afxEffectWrapperData.");
return;
}

Expand Down
30 changes: 15 additions & 15 deletions Engine/source/afx/afxMagicSpell.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -460,78 +460,78 @@ DefineEngineMethod(afxMagicSpellData, reset, void, (),,
object->reloadReset();
}

DefineEngineMethod(afxMagicSpellData, addCastingEffect, void, (afxEffectBaseData* effect),,
"Adds an effect (wrapper or group) to a spell's casting phase.\n\n"
DefineEngineMethod(afxMagicSpellData, pushCastingEffect, void, (afxEffectBaseData* effect),,
"Pushes an effect (wrapper or group) to a spell's casting phase.\n\n"
"@ingroup AFX")
{
if (!effect)
{
Con::errorf(ConsoleLogEntry::General,
"afxMagicSpellData::addCastingEffect() -- "
"afxMagicSpellData::pushCastingEffect() -- "
"missing afxEffectWrapperData.");
return;
}

object->mCasting_fx_list.push_back(effect);
}

DefineEngineMethod(afxMagicSpellData, addLaunchEffect, void, (afxEffectBaseData* effect),,
"Adds an effect (wrapper or group) to a spell's launch phase.\n\n"
DefineEngineMethod(afxMagicSpellData, pushLaunchEffect, void, (afxEffectBaseData* effect),,
"Pushes an effect (wrapper or group) to a spell's launch phase.\n\n"
"@ingroup AFX")

{
if (!effect)
{
Con::errorf(ConsoleLogEntry::General,
"afxMagicSpellData::addLaunchEffect() -- "
"afxMagicSpellData::pushLaunchEffect() -- "
"failed to find afxEffectWrapperData.");
return;
}

object->mLaunch_fx_list.push_back(effect);
}

DefineEngineMethod(afxMagicSpellData, addDeliveryEffect, void, (afxEffectBaseData* effect),,
"Adds an effect (wrapper or group) to a spell's delivery phase.\n\n"
DefineEngineMethod(afxMagicSpellData, pushDeliveryEffect, void, (afxEffectBaseData* effect),,
"Pushes an effect (wrapper or group) to a spell's delivery phase.\n\n"
"@ingroup AFX")

{
if (!effect)
{
Con::errorf(ConsoleLogEntry::General,
"afxMagicSpellData::addDeliveryEffect() -- "
"afxMagicSpellData::pushDeliveryEffect() -- "
"missing afxEffectWrapperData.");
return;
}

object->mDelivery_fx_list.push_back(effect);
}

DefineEngineMethod(afxMagicSpellData, addImpactEffect, void, (afxEffectBaseData* effect),,
"Adds an effect (wrapper or group) to a spell's impact phase.\n\n"
DefineEngineMethod(afxMagicSpellData, pushImpactEffect, void, (afxEffectBaseData* effect),,
"Pushes an effect (wrapper or group) to a spell's impact phase.\n\n"
"@ingroup AFX")

{
if (!effect)
{
Con::errorf(ConsoleLogEntry::General,
"afxMagicSpellData::addImpactEffect() -- "
"afxMagicSpellData::pushImpactEffect() -- "
"missing afxEffectWrapperData.");
return;
}

object->mImpact_fx_list.push_back(effect);
}

DefineEngineMethod(afxMagicSpellData, addLingerEffect, void, (afxEffectBaseData* effect),,
"Adds an effect (wrapper or group) to a spell's linger phase.\n\n"
DefineEngineMethod(afxMagicSpellData, pushLingerEffect, void, (afxEffectBaseData* effect),,
"Pushes an effect (wrapper or group) to a spell's linger phase.\n\n"
"@ingroup AFX")

{
if (!effect)
{
Con::errorf(ConsoleLogEntry::General,
"afxMagicSpellData::addLingerEffect() -- "
"afxMagicSpellData::pushLingerEffect() -- "
"missing afxEffectWrapperData.");
return;
}
Expand Down
6 changes: 3 additions & 3 deletions Engine/source/afx/ce/afxPhraseEffect.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -297,12 +297,12 @@ void afxPhraseEffectData::gather_cons_defs(Vector<afxConstraintDef>& defs)

//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//

DefineEngineMethod( afxPhraseEffectData, addEffect, void, ( afxEffectBaseData* effectData ),,
"Add a child effect to a phrase effect datablock. Argument can be an afxEffectWrappperData or an afxEffectGroupData.\n" )
DefineEngineMethod( afxPhraseEffectData, pushEffect, void, ( afxEffectBaseData* effectData ),,
"Push a child effect to a phrase effect datablock. Argument can be an afxEffectWrappperData or an afxEffectGroupData.\n" )
{
if (!effectData)
{
Con::errorf("afxPhraseEffectData::addEffect() -- failed to resolve effect datablock.");
Con::errorf("afxPhraseEffectData::pushEffect() -- failed to resolve effect datablock.");
return;
}

Expand Down
14 changes: 13 additions & 1 deletion Engine/source/cinterface/c_consoleInterface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@

namespace Con
{
/* Consumer Callback is not defined as EngineType yet, until then we have to define these methods directly.
DefineNewEngineFunction(AddConsumer, void, (ConsumerCallback cb), , "")
{
addConsumer(cb);
Expand All @@ -35,6 +36,17 @@ namespace Con
{
removeConsumer(cb);
}
*/

TORQUE_API void fnAddConsumer(ConsumerCallback cb)
{
addConsumer(cb);
}

TORQUE_API void fnRemoveConsumer(ConsumerCallback cb)
{
removeConsumer(cb);
}

DefineNewEngineFunction(GetConsoleString, String, (String name),, "")
{
Expand Down Expand Up @@ -75,4 +87,4 @@ namespace Con
{
setBoolVariable(StringTable->insert(name), value);
}
}
}
12 changes: 1 addition & 11 deletions Engine/source/cinterface/c_simobjectInterface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,16 +28,6 @@ DefineNewEngineMethod(SimObject, RegisterObject, bool, (),,"")
return object->registerObject();
}

DefineNewEngineMethod(SimObject, GetField, String, (String fieldName, String arrayIndex),, "")
{
return object->getDataField(StringTable->insert(fieldName), StringTable->insert(arrayIndex));
}

DefineNewEngineMethod(SimObject, SetField, void, (String fieldName, String arrayIndex, String value),, "")
{
object->setDataField(StringTable->insert(fieldName), StringTable->insert(arrayIndex), StringTable->insert(value));
}

DefineNewEngineMethod(SimObject, CopyFrom, void, (SimObject* parent),, "")
{
if (parent)
Expand Down Expand Up @@ -66,4 +56,4 @@ DefineNewEngineMethod(SimObject, InspectPreApply, void, (), , "")
DefineNewEngineMethod(SimObject, InspectPostApply, void, (), , "")
{
object->inspectPostApply();
}
}
13 changes: 7 additions & 6 deletions Engine/source/console/codeInterpreter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2079,7 +2079,7 @@ OPCodeReturn CodeInterpreter::op_callfunc(U32 &ip)
mNSEntry = Namespace::global()->lookup(fnName);

StringStackWrapper args(mCallArgc, mCallArgv);
cRetRes = CInterface::GetCInterface().CallFunction(fnNamespace, fnName, args.argv, args.argc, &cFunctionRes);
cRetRes = CInterface::CallFunction(fnNamespace, fnName, args.argv + 1, args.argc - 1, &cFunctionRes);
}
else if (callType == FuncCallExprNode::MethodCall)
{
Expand Down Expand Up @@ -2112,7 +2112,7 @@ OPCodeReturn CodeInterpreter::op_callfunc(U32 &ip)
mNSEntry = NULL;

StringStackWrapper args(mCallArgc, mCallArgv);
cRetRes = CInterface::GetCInterface().CallMethod(gEvalState.thisObject, fnName, args.argv, args.argc, &cFunctionRes);
cRetRes = CInterface::CallMethod(gEvalState.thisObject, fnName, args.argv + 2, args.argc - 2, &cFunctionRes);
}
else // it's a ParentCall
{
Expand Down Expand Up @@ -2178,14 +2178,15 @@ OPCodeReturn CodeInterpreter::op_callfunc(U32 &ip)

// ConsoleFunctionType is for any function defined by script.
// Any 'callback' type is an engine function that is exposed to script.
if (mNSEntry->mType == Namespace::Entry::ConsoleFunctionType
|| cFunctionRes)
if (cFunctionRes || mNSEntry->mType == Namespace::Entry::ConsoleFunctionType)
{
ConsoleValue retVal;
ConsoleValueRef ret;
if (cFunctionRes)
{
StringStackConsoleWrapper retVal(1, &cRetRes);
ret = retVal.argv[0];
retVal.init();
ret.value = &retVal;
retVal.setStackStringValue(cRetRes);
}
else if (mNSEntry->mFunctionOffset)
{
Expand Down
Loading