Getting an error with IMPLEMENT_GLOBAL_CALLBACK
by Nathan Bowhay - ESAL · in Torque 3D Professional · 10/09/2010 (6:23 pm) · 14 replies
I am getting the following errors:
Here is the code
I had to change the names a bit because the code is propitiatory, but other than that everything is the same. Note: tested with these names and still happens.
Why am I getting these errors? I don't see anything wrong? Also when I try and call it, there is an inline error (squiggly red) saying more than one instance of overloaded function... As if the macro is making more than one. If anyone has any idea what is going on let me know. I wasn't quite sure how to do this as this isn't documented yet, but based on examples it looks correct. Also I defined another one that works fine.
Error 1 error C2825: '_EngineTypeTraits<T>::Type': must be a class or namespace when followed by '::' enginetypes.h 105 Error 2 error C2039: 'SuperType' : is not a member of '`global namespace'' enginetypes.h 105 Error 3 error C2146: syntax error : missing ';' before identifier 'SuperType' enginetypes.h 105 Error 4 error C2602: '_EngineTypeTraits<T>::SuperType' is not a member of a base class of '_EngineTypeTraits<T>' enginetypes.h 105 Error 5 error C2868: '_EngineTypeTraits<T>::SuperType' : illegal syntax for using-declaration; expected qualified-name enginetypes.h 105
Here is the code
IMPLEMENT_GLOBAL_CALLBACK( myFoo, void, (const char* type, S32 destID, S32 origID, S32 id, U32 time, U32 count, S32 objectID, S32 objectType, const char* pos, const char* vel, const char* qOrientation, const char* qRate), (type, destID, origID, id, time, count, objectID, objectType, pos, vel, qOrientation, qRate),"Test call");
I had to change the names a bit because the code is propitiatory, but other than that everything is the same. Note: tested with these names and still happens.
Why am I getting these errors? I don't see anything wrong? Also when I try and call it, there is an inline error (squiggly red) saying more than one instance of overloaded function... As if the macro is making more than one. If anyone has any idea what is going on let me know. I wasn't quite sure how to do this as this isn't documented yet, but based on examples it looks correct. Also I defined another one that works fine.
#2
10/10/2010 (4:26 am)
That should be 12. Cause it gave me an error when I had more. I will remove 2 just to check if that fixes it though, but I think it is 12 from what I count.
#3
You're right. The linebreak made me count 13.
Looks like basic counting is beyond my math skills :)
10/10/2010 (4:31 am)
You're right. The linebreak made me count 13.
Looks like basic counting is beyond my math skills :)
#4
10/11/2010 (6:45 pm)
So is this a bug in Torque? Should I submit this as a bug? Any other ideas?
#5
The reason for the error is simply that in the internals, the template specializations only go up to a 11 arguments and not 12.
To rectify this, add the following template specialiations in their respective places.
... splitting this to comply with word count restriction ...
10/12/2010 (10:04 am)
Sorry for the delay. Looked into this now.The reason for the error is simply that in the internals, the template specializations only go up to a 11 arguments and not 12.
To rectify this, add the following template specialiations in their respective places.
... splitting this to comply with word count restriction ...
#6
engineTypeInfo.h
10/12/2010 (10:04 am)
engineTypeInfo.h
template< typename R, typename A, typename B, typename C, typename D, typename E, typename F, typename G, typename H, typename I, typename J, typename K, typename L >
struct _EngineArgumentTypeTable< R( A, B, C, D, E, F, G, H, I, J, K, L ) > : public EngineArgumentTypeTable
{
static const U32 NUM_ARGUMENTS = 12;
static const bool VARIADIC = false;
static const EngineTypeInfo* const RETURN;
static const EngineTypeInfo* const ARGS[ 12 ];
_EngineArgumentTypeTable()
: EngineArgumentTypeTable( TYPE< typename EngineTypeTraits< R >::Type >(), NUM_ARGUMENTS, ARGS ) {}
};
template< typename R, typename A, typename B, typename C, typename D, typename E, typename F, typename G, typename H, typename I, typename J, typename K, typename L >
const EngineTypeInfo* const _EngineArgumentTypeTable< R( A, B, C, D, E, F, G, H, I, J, K, L ) >::RETURN = TYPE< typename EngineTypeTraits< R >::Type >();
template< typename R, typename A, typename B, typename C, typename D, typename E, typename F, typename G, typename H, typename I, typename J, typename K, typename L >
const EngineTypeInfo* const _EngineArgumentTypeTable< R( A, B, C, D, E, F, G, H, I, J, K, L ) >::ARGS[ 12 ] =
{
TYPE< typename EngineTypeTraits< A >::Type >(),
TYPE< typename EngineTypeTraits< B >::Type >(),
TYPE< typename EngineTypeTraits< C >::Type >(),
TYPE< typename EngineTypeTraits< D >::Type >(),
TYPE< typename EngineTypeTraits< E >::Type >(),
TYPE< typename EngineTypeTraits< F >::Type >(),
TYPE< typename EngineTypeTraits< G >::Type >(),
TYPE< typename EngineTypeTraits< H >::Type >(),
TYPE< typename EngineTypeTraits< I >::Type >(),
TYPE< typename EngineTypeTraits< J >::Type >(),
TYPE< typename EngineTypeTraits< K >::Type >(),
TYPE< typename EngineTypeTraits< L >::Type >()
};
template< typename R, typename A, typename B, typename C, typename D, typename E, typename F, typename G, typename H, typename I, typename J, typename K, typename L >
struct _EngineArgumentTypeTable< R( A, B, C, D, E, F, G, H, I, J, K, L, ... ) > : public _EngineArgumentTypeTable< R( A, B, C, D, E, F, G, H, I, J, K, L ) >
{
static const bool VARIADIC = true;
_EngineArgumentTypeTable() {}
};
#7
engineFunctions.h
10/12/2010 (10:05 am)
engineFunctions.h
template< typename A, typename B, typename C, typename D, typename E, typename F, typename G, typename H, typename I, typename J, typename K, typename L >
struct _EngineFunctionDefaultArguments< void( A, B, C, D, E, F, G, H, I, J, K, L ) > : public EngineFunctionDefaultArguments
{
typename EngineTypeTraits< A >::DefaultArgumentValueStoreType a;
typename EngineTypeTraits< B >::DefaultArgumentValueStoreType b;
typename EngineTypeTraits< C >::DefaultArgumentValueStoreType c;
typename EngineTypeTraits< D >::DefaultArgumentValueStoreType d;
typename EngineTypeTraits< E >::DefaultArgumentValueStoreType e;
typename EngineTypeTraits< F >::DefaultArgumentValueStoreType f;
typename EngineTypeTraits< G >::DefaultArgumentValueStoreType g;
typename EngineTypeTraits< H >::DefaultArgumentValueStoreType h;
typename EngineTypeTraits< I >::DefaultArgumentValueStoreType i;
typename EngineTypeTraits< J >::DefaultArgumentValueStoreType j;
typename EngineTypeTraits< K >::DefaultArgumentValueStoreType k;
typename EngineTypeTraits< L >::DefaultArgumentValueStoreType l;
_EngineFunctionDefaultArguments()
{ mNumDefaultArgs = 0; }
_EngineFunctionDefaultArguments( L l )
: l( l )
{ mNumDefaultArgs = 1; }
_EngineFunctionDefaultArguments( K k, L l )
: k( k ),
l( l )
{ mNumDefaultArgs = 2; }
_EngineFunctionDefaultArguments( J j, K k, L l )
: j( j ),
k( k ),
l( l )
{ mNumDefaultArgs = 3; }
_EngineFunctionDefaultArguments( I I, J j, K k, L l )
: i( i ),
j( j ),
k( k ),
l( l )
{ mNumDefaultArgs = 4; }
_EngineFunctionDefaultArguments( H h, I I, J j, K k, L l )
: h( h ),
i( i ),
j( j ),
k( k ),
l( l )
{ mNumDefaultArgs = 5; }
_EngineFunctionDefaultArguments( G g, H h, I I, J j, K k, L l )
: g( g ),
h( h ),
i( i ),
j( j ),
k( k ),
l( l )
{ mNumDefaultArgs = 6; }
_EngineFunctionDefaultArguments( F f, G g, H h, I I, J j, K k, L l )
: f( f ),
g( g ),
h( h ),
i( i ),
j( j ),
k( k ),
l( l )
{ mNumDefaultArgs = 7; }
_EngineFunctionDefaultArguments( E e, F f, G g, H h, I I, J j, K k, L l )
: e( e ),
f( f ),
g( g ),
h( h ),
i( i ),
j( j ),
k( k ),
l( l )
{ mNumDefaultArgs = 8; }
_EngineFunctionDefaultArguments( D d, E e, F f, G g, H h, I I, J j, K k, L l )
: d( d ),
e( e ),
f( f ),
g( g ),
h( h ),
i( i ),
j( j ),
k( k ),
l( l )
{ mNumDefaultArgs = 9; }
_EngineFunctionDefaultArguments( C c, D d, E e, F f, G g, H h, I I, J j, K k, L l )
: c( c ),
d( d ),
e( e ),
f( f ),
g( g ),
h( h ),
i( i ),
j( j ),
k( k ),
l( l )
{ mNumDefaultArgs = 10; }
_EngineFunctionDefaultArguments( B b, C c, D d, E e, F f, G g, H h, I I, J j, K k, L l )
: b( b ),
c( c ),
d( d ),
e( e ),
f( f ),
g( g ),
h( h ),
i( i ),
j( j ),
k( k ),
l( l )
{ mNumDefaultArgs = 11; }
_EngineFunctionDefaultArguments( A a, B b, C c, D d, E e, F f, G g, H h, I I, J j, K k, L l )
: a( a ),
b( b ),
c( c ),
d( d ),
e( e ),
f( f ),
g( g ),
h( h ),
i( i ),
j( j ),
k( k ),
l( l )
{ mNumDefaultArgs = 12; }
};
#8
engineTypes.h
10/12/2010 (10:05 am)
engineTypes.h
template< typename R, typename A, typename B, typename C, typename D, typename E, typename F, typename G, typename H, typename I, typename J, typename K, typename L >
struct _EngineTypeTraits< R( A, B, C, D, E, F, G, H, I, J, K, L ) > : public _EngineFunctionTypeTraits< T( R )( T( A ), T( B ), T( C ), T( D ), T( E ), T( F ), T( G ), T( H ), T( I ), T( J ), T( J ), T( L ) ) > {};
template< typename R, typename A, typename B, typename C, typename D, typename E, typename F, typename G, typename H, typename I, typename J, typename K, typename L >
struct _EngineTypeTraits< R( A, B, C, D, E, F, G, H, I, J, K, L, ... ) > : public _EngineFunctionTypeTraits< T( R )( T( A ), T( B ), T( C ), T( D ), T( E ), T( F ), T( G ), T( H ), T( I ), T( J ), T( K ), T( L ), ... ) > {};
#9
As always thanks for the help Rene!
10/13/2010 (6:50 pm)
Cool nice to know 11 and not 12 was the limit and thanks for the info on how to add another. It worked great!As always thanks for the help Rene!
#10
I have a 12 argument callback with several of the arguments using Poin3D or Poin4D's:
Then in script I have:
What is happening is I look at the value passed to destID and it is "1999" and origID is "100" and then in script %destID is "0 0 0" and %origID is "599720954895". I then noticed %ecefVel is "0 0 0" and %qOrientation is "0 -0 -0.02190900035202503 0.9997599720954895" which has the same values in them or at least part of the value in the case of %origID. This will of course change if the orientation or velocity is bigger or smaller.
I made all the changes above (engineTypeInfo.h, engineApi.h, engineFunctions.h, engineTypes.h) and my other changes I will post my in the next couple comments since it is too long.
11/11/2010 (6:01 pm)
Not sure what post would be the best thread would be to post this in, but I am getting odd behavior due to several things that I posted about and changed.I have a 12 argument callback with several of the arguments using Poin3D or Poin4D's:
IMPLEMENT_GLOBAL_CALLBACK( myFoo, void, (const char* type, S32 destID, S32 origID, S32 id, U32 time, U32 count, S32 objectID, S32 objectType, Point3D ecefPos, Point3D ecefVel, Point4D qOrientation, Point4D qRate), (type, destID, origID, id, time, count, objectID, objectType, pos, vel, qOrientation, qRate),"Test call");
Then in script I have:
function myFoo(%type, %destID, %origID, %id, %time, %count, %objectID, %objectType, %ecefPos, %ecefVel, %qOrientation, %qRate)
What is happening is I look at the value passed to destID and it is "1999" and origID is "100" and then in script %destID is "0 0 0" and %origID is "599720954895". I then noticed %ecefVel is "0 0 0" and %qOrientation is "0 -0 -0.02190900035202503 0.9997599720954895" which has the same values in them or at least part of the value in the case of %origID. This will of course change if the orientation or velocity is bigger or smaller.
I made all the changes above (engineTypeInfo.h, engineApi.h, engineFunctions.h, engineTypes.h) and my other changes I will post my in the next couple comments since it is too long.
#11
mathTypes.h diff from T3D 1.1 beta 3:
11/11/2010 (6:03 pm)
Here is my code for opening Poin3D and Poin4D to the callbacks:mathTypes.h diff from T3D 1.1 beta 3:
19d18 < class Point2D; 21d19 < class Point3D; 23d20 < class Point4D; 26d22 < class RectD; 28d23 < class MatrixD; 30d24 < class Box3D; 33d26 < class AngAxisD; 42d34 < DECLARE_STRUCT( Point2D ); 44d35 < DECLARE_STRUCT( Point3D ); 46d36 < DECLARE_STRUCT( Point4D ); 49d38 < DECLARE_STRUCT( RectD ); 51d39 < DECLARE_STRUCT( MatrixD ); 53d40 < DECLARE_STRUCT( AngAxisD ); 56d42 < DECLARE_STRUCT( Box3D ); 63d48 < DefineConsoleType( TypePoint2D, Point2D ) 65d49 < DefineConsoleType( TypePoint3D, Point3D ) 67d50 < DefineConsoleType( TypePoint4D, Point4D ) 70d52 < DefineConsoleType( TypeRectD, RectD ) 72d53 < DefineConsoleType( TypeMatrixD, MatrixD ) 76d56 < DefineConsoleType( TypeAngAxisD, AngAxisD ) 79d58 < DefineConsoleType( TypeBox3D, Box3D )
#12
11/11/2010 (6:13 pm)
mathTypes.cpp diff:42,49d41 < IMPLEMENT_STRUCT( Point2D, < Point2D, MathTypes, < "" ) < < FIELD( x, x, 1, "X coordinate." ) < FIELD( y, y, 1, "Y coordinate." ) < < END_IMPLEMENT_STRUCT; 59,67d50 < IMPLEMENT_STRUCT( Point3D, < Point3D, MathTypes, < "" ) < < FIELD( x, x, 1, "X coordinate." ) < FIELD( y, y, 1, "Y coordinate." ) < FIELD( z, z, 1, "Z coordinate." ) < < END_IMPLEMENT_STRUCT; 70,79d52 < "" ) < < FIELD( x, x, 1, "X coordinate." ) < FIELD( y, y, 1, "Y coordinate." ) < FIELD( z, z, 1, "Z coordinate." ) < FIELD( w, w, 1, "W coordinate." ) < < END_IMPLEMENT_STRUCT; < IMPLEMENT_STRUCT( Point4D, < Point4D, MathTypes, 96,99d68 < IMPLEMENT_STRUCT( RectD, < RectD, MathTypes, < "" ) < END_IMPLEMENT_STRUCT; 104,107d72 < IMPLEMENT_STRUCT( MatrixD, < MatrixD, MathTypes, < "" ) < END_IMPLEMENT_STRUCT; 110,113d74 < "" ) < END_IMPLEMENT_STRUCT; < IMPLEMENT_STRUCT( AngAxisD, < AngAxisD, MathTypes, 122,125d82 < "" ) < END_IMPLEMENT_STRUCT; < IMPLEMENT_STRUCT( Box3D, < Box3D, MathTypes,
#13
11/11/2010 (6:15 pm)
continued (removed end of it since I am only using 2 types):183,206d139
< // TypePoint2D
< //-----------------------------------------------------------------------------
< ConsoleType( Point2D, TypePoint2D, Point2D )
< ImplementConsoleTypeCasters( TypePoint2D, Point2D )
<
< ConsoleGetType( TypePoint2D )
< {
< Point2D *pt = (Point2D *) dptr;
< char* returnBuffer = Con::getReturnBuffer(256);
< dSprintf(returnBuffer, 256, "%.16g %.16g", pt->x, pt->y);
< return returnBuffer;
< }
<
< ConsoleSetType( TypePoint2D )
< {
< if(argc == 1)
< dSscanf(argv[0], "%lg %lg", &((Point2D *) dptr)->x, &((Point2D *) dptr)->y);
< else if(argc == 2)
< *((Point2D *) dptr) = Point2D(dAtod(argv[0]), dAtod(argv[1]));
< else
< Con::printf("Point2D must be set as { x, y } or "x y"");
< }
<
< //-----------------------------------------------------------------------------
231,254d163
< // TypePoint3D
< //-----------------------------------------------------------------------------
< ConsoleType( Point3D, TypePoint3D, Point3D )
< ImplementConsoleTypeCasters(TypePoint3D, Point3D)
<
< ConsoleGetType( TypePoint3D )
< {
< Point3D *pt = (Point3D *) dptr;
< char* returnBuffer = Con::getReturnBuffer(512);
< dSprintf(returnBuffer, 512, "%.16g %.16g %.16g", pt->x, pt->y, pt->z);
< return returnBuffer;
< }
<
< ConsoleSetType( TypePoint3D )
< {
< if(argc == 1)
< dSscanf(argv[0], "%lg %lg %lg", &((Point3D *) dptr)->x, &((Point3D *) dptr)->y, &((Point3D *) dptr)->z);
< else if(argc == 3)
< *((Point3D *) dptr) = Point3D(dAtod(argv[0]), dAtod(argv[1]), dAtod(argv[2]));
< else
< Con::printf("Point3D must be set as { x, y, z } or "x y z"");
< }
<
< //-----------------------------------------------------------------------------
276,299d184
< }
<
< //-----------------------------------------------------------------------------
< // TypePoint4D
< //-----------------------------------------------------------------------------
< ConsoleType( Point4D, TypePoint4D, Point4D )
< ImplementConsoleTypeCasters( TypePoint4D, Point4D )
<
< ConsoleGetType( TypePoint4D )
< {
< Point4D *pt = (Point4D *) dptr;
< char* returnBuffer = Con::getReturnBuffer(512);
< dSprintf(returnBuffer, 512, "%.16g %.16g %.16g %.16g", pt->x, pt->y, pt->z, pt->w);
< return returnBuffer;
< }
<
< ConsoleSetType( TypePoint4D )
< {
< if(argc == 1)
< dSscanf(argv[0], "%lg %lg %lg %lg", &((Point4D *) dptr)->x, &((Point4D *) dptr)->y, &((Point4D *) dptr)->z, &((Point4D *) dptr)->w);
< else if(argc == 4)
< *((Point4D *) dptr) = Point4D(dAtod(argv[0]), dAtod(argv[1]), dAtod(argv[2]), dAtod(argv[3]));
< else
< Con::printf("Point4D must be set as { x, y, z, w } or "x y z w"");
#14
11/11/2010 (6:19 pm)
I am thinking it has more to do with using the new types in the callback an less about the 12 arguments just because I tried it with less arguments (removed the 1 problem variable) and it still happens only with different variables.
Associate Rene Damm
You're callback hsa 13 arguments whereas the max supported in the templates currently is 12. That's probably leading to the problem here. Simply copy the last "call" method of _EngineConsoleCallbackHelper and add another argument.