I'm using the Hello world C++-extension example and playing around with it, trying to get a grip of things..
Thank you very much for putting that, up by the way
This is probably a very basic noob question. But can we compare Ruby objects for equality when they are in C/C++ ? Before converting them to structs or whatever..
Or maybe do other tests.
(GC-issue, and altering Ruby VALUES set aside for a moment)
I was under the impression C dident have a clue what VALUES where..
Actually I'm testing Sketchup Point3d objects, so I presume it's not entirely correct to say they are real Ruby objects.
I made a simple test case that seams to give me the correct answer:
It's just added to the Hello world example..
//C++
VALUE test_2_objects(VALUE self, VALUE obj1, VALUE obj2) {
if ( obj1 == obj2 )
return Qtrue;
else
return Qfalse;
}
Then a simple call to C
def self.test2objs()
pt1 = Geom;;Point3d.new(0,1,3)
pt2 = Geom;;Point3d.new(66,10.55,3)
r1 = EC_CEXT;;test_2_objects(pt1, pt1)
puts "2 Equal points. Are equal ? #{r1}"
r2 = EC_CEXT;;test_2_objects(pt1, pt2)
puts "2 Not equal points. Are equal ? #{r2}"
end
Which then puts:
2 Equal points. Are equal ? true
2 Not equal points. Are equal ? false
Can't be that simple ? Really ?
Ive seen conversion from Points to struct. But I was thinking of avoiding that step unless needed to compare x,y,z values or altering the values.
Testing for ex a vector3d against Point3d does not give an error BTW..