2 Copyright (C) 2005-2008, The Perl Foundation.
7 pmc/luafunction.pmc - Lua Function
11 C<LuaFunction> extends C<Parrot Sub> and C<LuaAny> to provide a class
12 with the behaviour of the Lua C<Function> type.
13 C<LuaFunction> is used by standard libraries
16 See also: F<languages/lua/pmc/luaclosure.pmc>
18 =head2 Overloaded Methods
26 #include "lua_private.h"
44 Marks the function as live.
51 if (PMC_metadata(SELF))
52 pobject_lives(INTERP, (PObj *)PMC_metadata(SELF));
57 =item C<STRING* name()>
59 Return the string "function".
65 return const_string(INTERP, "function");
77 PMC_metadata(ret) = PMC_metadata(SELF);
78 PObj_custom_mark_SET(ret);
84 =item C<STRING* get_string()>
89 STRING* get_string() {
90 return Parrot_sprintf_c(INTERP, "function: %08X", SELF);
95 =item C<void set_pmc(PMC *value)>
100 void set_pmc(PMC *value) {
101 PMC_struct_val(SELF) = PMC_struct_val(value);
102 PMC_metadata(SELF) = PMC_metadata(value);
107 =item C<INTVAL is_equal(PMC *value)>
112 INTVAL is_equal(PMC *value) {
114 return (PMC_sub(SELF))->start_offs == (PMC_sub(value))->start_offs
115 && (PMC_sub(SELF))->seg == (PMC_sub(value))->seg;
126 =head2 Specific Methods
130 =item C<PMC *getfenv()>
135 METHOD PMC* getfenv() {
136 PMC *retval = PMC_metadata(SELF);
139 retval = pmc_new(INTERP, dynpmc_LuaNil);
146 =item C<PMC* rawequal(PMC *value)>
151 METHOD PMC* rawequal(PMC *value) {
152 PMC *retval = pmc_new(INTERP, dynpmc_LuaBoolean);
154 if (PMC_type(SELF) == PMC_type(value)
155 && (PMC_sub(SELF))->start_offs == (PMC_sub(value))->start_offs
156 && (PMC_sub(SELF))->seg == (PMC_sub(value))->seg)
157 VTABLE_set_integer_native(INTERP, retval, 1);
159 VTABLE_set_integer_native(INTERP, retval, 0);
166 =item C<void setfenv(PMC *env)>
171 METHOD void setfenv(PMC *env) {
172 PMC_metadata(SELF) = env;
191 * c-file-style: "parrot"
193 * vim: expandtab shiftwidth=4: