HandleFromObject - HandleToObject ?

BlitzMax Forums/BlitzMax Programming/HandleFromObject - HandleToObject ?

I found something that works, but it probably does the same thing as the official functions (HandleFromObject and HandleToObject)
SuperStrict

Type mytype
	Field word:String
	
	Method Say()
		
		If word <> Null
			Print word
			
		Else
			Print "ERROR: No word set!"
			
		End If
		
	End Method
	
End Type

Local a:mytype = New mytype
	a.word = "hello!"
	
Local b:Byte Ptr = Varptr(a)
	Print Int(Varptr(b)[0])

Local iptr:Int = (Int Ptr Varptr a)[0] + 1 'HandleForObject(a)
	Print iptr

Local obj:mytype = mytype(ObjectForHandle(iptr)) 'mytype(HandleToObject(Int(b)))
If obj = Null Print "iadfgjaweg!"
obj.Say()


Function ObjectForHandle:Object(handle:Int)
  Local obj:Object

	(Int Ptr Varptr obj)[0] = handle - 1
	
	Return obj
	
End Function

Function HandleForObject:Int(obj:Object)
	
	Return (Int Ptr Varptr obj)[0] + 1
	
End Function

( http://www.blitzbasic.com/codearcs/codearcs.php?code=1876 )

You will also notice the code archive has functions for retaining and releasing handles, so no real progress here.. I wonder if you can even have a integer handle without having to 'release it'? - shouldn't have to release jack, considering its just a bloody integer.