Reflection/List methods: Difference between revisions

(Upgrade to a full task)
Line 733:
 
=={{header|Phix}}==
===emulated===
Phix is not object orientated, but this sort of thing is fairly easy to emulate.
<lang Phix>enum METHODS, PROPERTIES
Line 779 ⟶ 780:
<pre>
{"exists"}
</pre>
===classes===
Needs 0.8.1+
Note that content from and parameters to get_struct_fields() may change between releases.
<lang Phix>class c
private function foo();
public procedure bar();
end class
 
include builtins\structs.e as structs
sequence f = structs:get_struct_fields(c)
for i=1 to length(f) do
{string name, integer tid, integer flags} = f[i]
if and_bits(flags,SF_RTN) then
if tid!=ST_INTEGER then ?9/0 end if -- (sanity check)
printf(1,"%s:%s\n",{name,structs:get_field_flags(c,name,true)})
end if
end for</lang>
{{out}}
<pre>
foo:SF_PRIVATE+SF_FUNC
bar:SF_PROC
</pre>
 
7,815

edits