Permalink
Find file
Fetching contributors…
Cannot retrieve contributors at this time
63 lines (45 sloc) 1.32 KB
#ifndef __MOP_METHOD_C__
#define __MOP_METHOD_C__
#include "mop.h"
mop_method *
mop_method_create(char *name, char *package_name, mop_class *c, SV *body)
{
mop_method *method;
Newxz(method, 1, mop_method);
Newxz( method->name, strlen(name) + 1, char );
Copy( name, method->name, strlen(name) + 1, char );
Newxz( method->package_name, strlen(package_name) + 1, char );
Copy( package_name, method->package_name, strlen(package_name) + 1, char );
method->associated_metaclass = c;
method->body = SvREFCNT_inc( body );
}
void
mop_method_destroy(mop_method *method)
{
if (mop_component_state_has_refs((mop_component *) method))
return;
mop_component_state_destroy((mop_component *) method );
if (method->associated_metaclass != NULL)
return;
PerlIO_printf(PerlIO_stderr(), " DESTROY mop_method %p\n", method);
SvREFCNT_dec(method->body);
Safefree(method->package_name);
Safefree(method->name);
Safefree(method);
}
void
mop_method_dump(mop_method *method)
{
PerlIO_printf(PerlIO_stderr(), " -> method %s\n", method->name);
}
void
mop_method_attach_to_class(mop_method *method, mop_class *c)
{
method->associated_metaclass = c;
}
void
mop_method_detach_from_class(mop_method *method)
{
method->associated_metaclass = NULL;
}
#endif __MOP_METHOD_C__