Manta Interactive Ray Tracer Development Mailing List

Text archives Help


[Manta] Re: Transaction Callbacks and function calling conventions


Chronological Thread 
  • From: Abe Stephens < >
  • To:
  • Subject: [Manta] Re: Transaction Callbacks and function calling conventions
  • Date: Mon, 15 Dec 2008 13:45:44 -0700


On Dec 15, 2008, at 12:53 PM, Bo Huang wrote:

I create a transaction as follows:

this->rtrt->addTransaction( (TransactionBase*) Callback::create( &UpdateRotationCB, this->rtrt ) );
with the call back function:


TransactionBase has a few more members than a raw Callback (see Transaction.h), so you should use the helper methods to create a TransactionBase instead of an explicit cast:

rtrt->addTransaction( "rotation", Callback::create( &::UpdateRotationCB, rtrt ) );

There are several helper methods, usually the following is used:

void addTransaction(const char* name, CallbackBase_0Data* callback, int flag = TransactionBase::DEFAULT );

The "name" was once useful for debugging, any arbitrary string is fine. The flag specifies different types of behaviors, for example setting flag=TransactionBase::CONTINUE causes the engine to stop processing the transaction queue and continue rendering the next frame, the remaining transactions are executed before the subsequent frame. Setting the flag=TransactionBase::PURGE causes the engine to remove all of the remaining transactions from the queue without processing them. The default behavior is to empty the transaction queue by processing each callback in it before rendering the frame.

template<class T, class Op>
void addTransaction(const char* name, TValue<T>& value, Op op, int flag = TransactionBase::DEFAULT );

This templated add method allows the transaction to return a value. I'm not sure where this is used (even though I'm svn blame'ed for it). It looks like the apply method of class is missing a delete call.

void addUpdateTransaction(const char* name, CallbackBase_0Data* callback, Object* object, int flag = TransactionBase::DEFAULT );

I'm not sure where an UpdateTransaction is useful, perhaps Solomon can elaborate.



void UpdateRotationCB(RTRT* rtrt );

I get the following error at transaction->apply() in void RTRT::postTransactions(bool& changed)

"Run-Time Check Failure #0 - The value of ESP was not properly saved across a function call. This is usually a result of calling a function declared with one calling convention with a function pointer declared with a different calling convention."

I suspected perhaps I should add __stdcall to the call back function like so:

void __stdcall UpdateRotationCB(RTRT* rtrt );

and add __stdcall to all places where

void (__stdcall *pmf)(Arg1);

exist, such as in Callback::create(), and class Callback_Static_0Data_1Arg.

None helps.



Assuming removal of the explicit cast doesn't fix the issue, does the problem occur for non-static transactions? i.e. make UpdateRotationCB a method of "this" and add the transaction as:

rtrt->addTransaction( "rotation", Callback::create( this, &MyClass::UpdateRotationCB, rtrt ) );

Abe







Archive powered by MHonArc 2.6.16.

Top of page