/* All the MOP_mg_* macros require MAGIC* mg for the first argument */
-typedef struct {
- SV* (*create_instance)(pTHX_ HV* const stash);
- SV* (*clone_instance) (pTHX_ SV* const instance);
- bool (*has_slot) (pTHX_ SV* const mi, SV* const instance);
- SV* (*get_slot) (pTHX_ SV* const mi, SV* const instance);
- SV* (*set_slot) (pTHX_ SV* const mi, SV* const instance, SV* const value);
- SV* (*delete_slot) (pTHX_ SV* const mi, SV* const instance);
- void (*weaken_slot) (pTHX_ SV* const mi, SV* const instance);
-} mop_instance_vtbl;
/* Class::MOP::Instance stuff */
-SV* mop_instance_create (pTHX_ HV* const stash);
-SV* mop_instance_clone (pTHX_ SV* const instance);
-bool mop_instance_has_slot (pTHX_ SV* const instance, SV* const slot);
-SV* mop_instance_get_slot (pTHX_ SV* const instance, SV* const slot);
-SV* mop_instance_set_slot (pTHX_ SV* const instance, SV* const slot, SV* const value);
-SV* mop_instance_delete_slot(pTHX_ SV* const instance, SV* const slot);
-void mop_instance_weaken_slot(pTHX_ SV* const instance, SV* const slot);
+/* SV* mi (meta instance) may not be used */
+typedef struct {
+ SV* (*create_instance)(pTHX_ SV* const mi, HV* const stash);
+ SV* (*clone_instance) (pTHX_ SV* const mi, SV* const instance);
+ bool (*has_slot) (pTHX_ SV* const mi, SV* const instance, SV* const slot);
+ SV* (*get_slot) (pTHX_ SV* const mi, SV* const instance, SV* const slot);
+ SV* (*set_slot) (pTHX_ SV* const mi, SV* const instance, SV* const slot, SV* const value);
+ SV* (*delete_slot) (pTHX_ SV* const mi, SV* const instance, SV* const slot);
+ void (*weaken_slot) (pTHX_ SV* const mi, SV* const instance, SV* const slot);
+} mop_instance_vtbl;
+
+SV* mop_instance_create (pTHX_ SV* const mi, HV* const stash);
+SV* mop_instance_clone (pTHX_ SV* const mi, SV* const instance);
+bool mop_instance_has_slot (pTHX_ SV* const mi, SV* const instance, SV* const slot);
+SV* mop_instance_get_slot (pTHX_ SV* const mi, SV* const instance, SV* const slot);
+SV* mop_instance_set_slot (pTHX_ SV* const mi, SV* const instance, SV* const slot, SV* const value);
+SV* mop_instance_delete_slot(pTHX_ SV* const mi, SV* const instance, SV* const slot);
+void mop_instance_weaken_slot(pTHX_ SV* const mi, SV* const instance, SV* const slot);
const mop_instance_vtbl* mop_get_default_instance_vtbl(pTHX);
#define MOP_mg_obj_refcounted_on(mg) (void)((mg)->mg_flags |= MGf_REFCOUNTED);
-#define MOP_mg_create_instance(mg, stash) MOP_mg_vtbl(mg)->create_instance (aTHX_ (stash))
-#define MOP_mg_clone_instance(mg, o) MOP_mg_vtbl(mg)->clone_instance (aTHX_ (o))
-#define MOP_mg_has_slot(mg, o, slot) MOP_mg_vtbl(mg)->has_slot (aTHX_ (o), (slot))
-#define MOP_mg_get_slot(mg, o, slot) MOP_mg_vtbl(mg)->get_slot (aTHX_ (o), (slot))
-#define MOP_mg_set_slot(mg, o, slot, v) MOP_mg_vtbl(mg)->set_slot (aTHX_ (o), (slot), (v))
-#define MOP_mg_delete_slot(mg, o, slot) MOP_mg_vtbl(mg)->delete_slot (aTHX_ (o), (slot))
-#define MOP_mg_weaken_slot(mg, o, slot) MOP_mg_vtbl(mg)->weaken_slot (aTHX_ (o), (slot))
+#define MOP_mg_create_instance(mg, stash) MOP_mg_vtbl(mg)->create_instance (aTHX_ NULL, (stash))
+#define MOP_mg_clone_instance(mg, o) MOP_mg_vtbl(mg)->clone_instance (aTHX_ NULL, (o))
+#define MOP_mg_has_slot(mg, o, slot) MOP_mg_vtbl(mg)->has_slot (aTHX_ NULL, (o), (slot))
+#define MOP_mg_get_slot(mg, o, slot) MOP_mg_vtbl(mg)->get_slot (aTHX_ NULL, (o), (slot))
+#define MOP_mg_set_slot(mg, o, slot, v) MOP_mg_vtbl(mg)->set_slot (aTHX_ NULL, (o), (slot), (v))
+#define MOP_mg_delete_slot(mg, o, slot) MOP_mg_vtbl(mg)->delete_slot (aTHX_ NULL, (o), (slot))
+#define MOP_mg_weaken_slot(mg, o, slot) MOP_mg_vtbl(mg)->weaken_slot (aTHX_ NULL, (o), (slot))
/* Class::MOP::Attribute stuff */
} STMT_END
SV*
-mop_instance_create(pTHX_ HV* const stash) {
+mop_instance_create(pTHX_ SV* const mi PERL_UNUSED_DECL, HV* const stash) {
assert(stash);
return sv_bless( newRV_noinc((SV*)newHV()), stash );
}
SV*
-mop_instance_clone(pTHX_ SV* const instance) {
+mop_instance_clone(pTHX_ SV* const mi PERL_UNUSED_DECL, SV* const instance) {
HV* proto;
assert(instance);
bool
-mop_instance_has_slot(pTHX_ SV* const instance, SV* const slot) {
+mop_instance_has_slot(pTHX_ SV* const mi PERL_UNUSED_DECL, SV* const instance, SV* const slot) {
assert(instance);
assert(slot);
CHECK_INSTANCE(instance);
}
SV*
-mop_instance_get_slot(pTHX_ SV* const instance, SV* const slot) {
+mop_instance_get_slot(pTHX_ SV* const mi PERL_UNUSED_DECL, SV* const instance, SV* const slot) {
HE* he;
assert(instance);
assert(slot);
}
SV*
-mop_instance_set_slot(pTHX_ SV* const instance, SV* const slot, SV* const value) {
+mop_instance_set_slot(pTHX_ SV* const mi PERL_UNUSED_DECL, SV* const instance, SV* const slot, SV* const value) {
HE* he;
SV* sv;
assert(instance);
}
SV*
-mop_instance_delete_slot(pTHX_ SV* const instance, SV* const slot) {
+mop_instance_delete_slot(pTHX_ SV* const mi PERL_UNUSED_DECL, SV* const instance, SV* const slot) {
assert(instance);
assert(slot);
CHECK_INSTANCE(instance);
}
void
-mop_instance_weaken_slot(pTHX_ SV* const instance, SV* const slot) {
+mop_instance_weaken_slot(pTHX_ SV* const mi PERL_UNUSED_DECL, SV* const instance, SV* const slot) {
HE* he;
assert(instance);
assert(slot);
}
}
-static const mop_instance_vtbl mop_default_instance = {
+static const mop_instance_vtbl mop_default_instance_vtbl = {
mop_instance_create,
mop_instance_clone,
mop_instance_has_slot,
const mop_instance_vtbl*
mop_get_default_instance_vtbl(pTHX){
- return &mop_default_instance;
+ return &mop_default_instance_vtbl;
}
MODULE = Class::MOP::Instance PACKAGE = Class::MOP::Instance
/* $self->can("get_slot_value") == \&Class::MOP::Instance::get_slot_value */
code_ref = mop_call1(aTHX_ self, mop_can, method);
if(SvROK(code_ref) && SvRV(code_ref) == (SV*)default_method){
- RETVAL = (void*)&mop_default_instance;
+ RETVAL = (void*)&mop_default_instance_vtbl;
}
else{
RETVAL = NULL;
SV* class_name;
CODE:
class_name = mop_call0_pvs(self, "_class_name");
- RETVAL = mop_instance_create(aTHX_ gv_stashsv(class_name, TRUE));
+ RETVAL = mop_instance_create(aTHX_ NULL, gv_stashsv(class_name, TRUE));
OUTPUT:
RETVAL
clone_instance(SV* self, SV* instance)
CODE:
PERL_UNUSED_VAR(self);
- RETVAL = mop_instance_clone(aTHX_ instance);
+ RETVAL = mop_instance_clone(aTHX_ NULL, instance);
OUTPUT:
RETVAL
is_slot_initialized(SV* self, SV* instance, SV* slot)
CODE:
PERL_UNUSED_VAR(self);
- RETVAL = mop_instance_has_slot(aTHX_ instance, slot);
+ RETVAL = mop_instance_has_slot(aTHX_ NULL, instance, slot);
OUTPUT:
RETVAL
get_slot_value(SV* self, SV* instance, SV* slot)
CODE:
PERL_UNUSED_VAR(self);
- RETVAL = mop_instance_get_slot(aTHX_ instance, slot);
+ RETVAL = mop_instance_get_slot(aTHX_ NULL, instance, slot);
RETVAL = RETVAL ? newSVsv(RETVAL) : &PL_sv_undef;
OUTPUT:
RETVAL
set_slot_value(SV* self, SV* instance, SV* slot, SV* value)
CODE:
PERL_UNUSED_VAR(self);
- RETVAL = mop_instance_set_slot(aTHX_ instance, slot, value);
+ RETVAL = mop_instance_set_slot(aTHX_ NULL, instance, slot, value);
SvREFCNT_inc_simple_void_NN(RETVAL);
OUTPUT:
RETVAL
deinitialize_slot(SV* self, SV* instance, SV* slot)
CODE:
PERL_UNUSED_VAR(self);
- RETVAL = mop_instance_delete_slot(aTHX_ instance, slot);
+ RETVAL = mop_instance_delete_slot(aTHX_ NULL, instance, slot);
if(RETVAL){
SvREFCNT_inc_simple_void_NN(RETVAL);
}
weaken_slot_value(SV* self, SV* instance, SV* slot)
CODE:
PERL_UNUSED_VAR(self);
- mop_instance_weaken_slot(aTHX_ instance, slot);
+ mop_instance_weaken_slot(aTHX_ NULL, instance, slot);