Function pointers for methods

BlitzMax Forums/OpenGL Module/Function pointers for methods

Drey(Posted 2006) [#1]
Type Tight

	Method Action()
	
		Print "Action packed!"
	
	End Method

End Type 



Local WhatIsIt() 

ItIs:Tight = New Tight

WhatIsIt = ItIs.Action


WhatIsIt()


WaitKey()

End 



How do i get a function pointer to work for Methods..please tell me there's a way.


Drey(Posted 2006) [#2]
Oops, wrong forum..sorry guys. if you have the answers..feel free to reply :).


N(Posted 2006) [#3]
You can't.


Dreamora(Posted 2006) [#4]
You would need to do it this way:

Type Tight

	function ActionWrap(entity:object)
	        Tight(entity).Action
        end function

        Method Action()
		Print "Action packed!"
	
	End Method

End Type 



Local WhatIsIt(entity:object) 

ItIs:Tight = New Tight

WhatIsIt = Tight.ActionWrap
WhatIsIt(ItIs)


WaitKey()

End 



Drey(Posted 2006) [#5]
yeah, i see. I don't think that'll due though. I'll have to create wraps of all my functions then..or least ones i think i want pointers to work for.

People mention the program will crash if you nullify the object ref and the fnc pointer is called..i don't see what the big deal is..just keep up with it in code or else.


Dreamora(Posted 2006) [#6]
The problem is that it would become far slower to track method pointers for all methods as well not only the ref counter for the object itself. (actually not even this is fully implemented as no root references exist)