-->
enum METHODS, PROPERTIES
sequence all_methods = {}
function method_visitor(object key, object /*data*/, /*user_data*/)
all_methods = append(all_methods,key)
return 1
end function
function get_all_methods(object o)
all_methods = {}
traverse_dict(method_visitor,0,o[METHODS])
return all_methods
end function
function exists()
return "exists"
end function
--class X: Xmethods emulates a vtable
constant Xmethods = new_dict({{"exists",exists}})
--class X: destructor
procedure destructor(object o)
destroy_dict(o[PROPERTIES])
end procedure
--class X: create new instances
function newX(object x,y)
integer Xproperties = new_dict({{"x",x},{"y",y}})
object res = delete_routine({Xmethods,Xproperties},destructor)
return res
end function
object x = newX(2,"string")
?get_all_methods(x)