Torque 3D 3.8
ClosurePtr Methods

The methods of the ClosurePtr class are listed here.

For const member functions, we only need a const class pointer. Since we know that the member function is const, it's safe to remove the const qualifier from the 'this' pointer with a const_cast. VC6 has problems if we just overload 'bindmemfunc', so we give it a different name. 
At present, GCC doesn't recognize constness of MFPs in templates 
For static functions, the 'static_function_invoker' class in the parent will be called. The parent then needs to call GetStaticFunction() to find out the actual function to invoke. 
ClosurePtr<> - Evil version
For compilers where data pointers are at least as big as code pointers, it is possible to store the function pointer in the this pointer, using another horrible_cast. Invocation isn't any faster, but it saves 4 bytes, and speeds up comparison and assignment. If C++ provided direct language support for delegates, they would produce asm code that was almost identical to this. Note that the Sun C++ and MSVC documentation explicitly state that they support static_cast between void * and function pointers. 
This is GetClosureMemPtr, a member of class ClosurePtr. 
These functions are required for invoking the stored function 
Does the closure contain this static function? 
Copyright (c) 2015. All rights reserved.
What do you think about this topic? Send feedback!