HV *mop_get_all_package_symbols (HV *stash, type_filter_t filter);
-/* Class::MOP::Instance stuff */
+/* Class::MOP Magic stuff */
-/* MI: Meta Instance object of Class::MOP::Method */
+/* MG: MOP Magic object */
/* All the MOP_mg_* macros require MAGIC* mg for the first argument */
-/* All the MOP_mi_* macros require AV* mi for the first argument */
typedef struct {
- SV* (*create_instance)(pTHX_ MAGIC* const mg);
- bool (*has_slot) (pTHX_ MAGIC* const mg, SV* const instance);
- SV* (*get_slot) (pTHX_ MAGIC* const mg, SV* const instance);
- SV* (*set_slot) (pTHX_ MAGIC* const mg, SV* const instance, SV* const value);
- SV* (*delete_slot) (pTHX_ MAGIC* const mg, SV* const instance);
- void (*weaken_slot) (pTHX_ MAGIC* const mg, SV* const instance);
+ SV* (*create_instance)(pTHX_ SV* const mi);
+ 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;
const mop_instance_vtbl* mop_get_default_instance_vtbl(pTHX);
#define MOP_MI_SLOT 0
#define MOP_MI_last 1
-#define MOP_mg_mi(mg) ((AV*)(mg)->mg_obj)
+#define MOP_mg_mi(mg) ((mg)->mg_obj)
#define MOP_mg_vtbl(mg) ((const mop_instance_vtbl*)(mg)->mg_ptr)
#define MOP_mg_flags(mg) ((mg)->mg_private)
+#define MOP_mg_miav(mg) ((AV*)MOP_mg_mi(mg))
+
#ifdef DEBUGGING
#define MOP_mi_access(mi, a) *mop_debug_mi_access(aTHX_ (mi) , (a))
SV** mop_debug_mi_access(pTHX_ AV* const mi, I32 const attr_ix);
#endif
#define MOP_mi_slot(mi) MOP_mi_access((mi), MOP_MI_SLOT)
-#define MOP_mg_slot(mg) MOP_mi_slot(MOP_mg_mi(mg))
-
-#define MOP_mg_create_instance(mg) MOP_mg_vtbl(mg)->create_instance (aTHX_ (mg))
-#define MOP_mg_has_slot(mg, o) MOP_mg_vtbl(mg)->has_slot (aTHX_ (mg), (o))
-#define MOP_mg_get_slot(mg, o) MOP_mg_vtbl(mg)->get_slot (aTHX_ (mg), (o))
-#define MOP_mg_set_slot(mg, o, v) MOP_mg_vtbl(mg)->set_slot (aTHX_ (mg), (o), (v))
-#define MOP_mg_delete_slot(mg, o) MOP_mg_vtbl(mg)->delete_slot (aTHX_ (mg), (o))
-#define MOP_mg_weaken_slot(mg, o) MOP_mg_vtbl(mg)->weaken_slot (aTHX_ (mg), (o))
+
+#define MOP_mg_create_instance(mg) MOP_mg_vtbl(mg)->create_instance (aTHX_ MOP_mg_mi(mg))
+#define MOP_mg_has_slot(mg, o) MOP_mg_vtbl(mg)->has_slot (aTHX_ MOP_mg_mi(mg), (o))
+#define MOP_mg_get_slot(mg, o) MOP_mg_vtbl(mg)->get_slot (aTHX_ MOP_mg_mi(mg), (o))
+#define MOP_mg_set_slot(mg, o, v) MOP_mg_vtbl(mg)->set_slot (aTHX_ MOP_mg_mi(mg), (o), (v))
+#define MOP_mg_delete_slot(mg, o) MOP_mg_vtbl(mg)->delete_slot (aTHX_ MOP_mg_mi(mg), (o))
+#define MOP_mg_weaken_slot(mg, o) MOP_mg_vtbl(mg)->weaken_slot (aTHX_ MOP_mg_mi(mg), (o))
/* Class::MOP::Method::Accessor stuff */
} STMT_END
static SV*
-mop_instance_create_instance(pTHX_ MAGIC* const mg PERL_UNUSED_DECL) {
+mop_instance_create_instance(pTHX_ SV* const mi PERL_UNUSED_DECL) {
return newRV_noinc((SV*)newHV());
}
static bool
-mop_instance_has_slot(pTHX_ MAGIC* const mg, SV* const instance) {
+mop_instance_has_slot(pTHX_ SV* const mi, SV* const instance) {
CHECK_INSTANCE(instance);
- return hv_exists_ent((HV*)SvRV(instance), MOP_mg_slot(mg), 0U);
+ return hv_exists_ent((HV*)SvRV(instance), MOP_mi_slot(mi), 0U);
}
static SV*
-mop_instance_get_slot(pTHX_ MAGIC* const mg, SV* const instance) {
+mop_instance_get_slot(pTHX_ SV* const mi, SV* const instance) {
HE* he;
CHECK_INSTANCE(instance);
- he = hv_fetch_ent((HV*)SvRV(instance), MOP_mg_slot(mg), FALSE, 0U);
+ he = hv_fetch_ent((HV*)SvRV(instance), MOP_mi_slot(mi), FALSE, 0U);
return he ? HeVAL(he) : NULL;
}
static SV*
-mop_instance_set_slot(pTHX_ MAGIC* const mg, SV* const instance, SV* const value) {
+mop_instance_set_slot(pTHX_ SV* const mi, SV* const instance, SV* const value) {
HE* he;
SV* sv;
CHECK_INSTANCE(instance);
- he = hv_fetch_ent((HV*)SvRV(instance), MOP_mg_slot(mg), TRUE, 0U);
+ he = hv_fetch_ent((HV*)SvRV(instance), MOP_mi_slot(mi), TRUE, 0U);
sv = HeVAL(he);
sv_setsv_mg(sv, value);
return sv;
}
static SV*
-mop_instance_delete_slot(pTHX_ MAGIC* const mg, SV* const instance) {
+mop_instance_delete_slot(pTHX_ SV* const mi, SV* const instance) {
CHECK_INSTANCE(instance);
- return hv_delete_ent((HV*)SvRV(instance), MOP_mg_slot(mg), 0, 0U);
+ return hv_delete_ent((HV*)SvRV(instance), MOP_mi_slot(mi), 0, 0U);
}
static void
-mop_instance_weaken_slot(pTHX_ MAGIC* const mg, SV* const instance) {
+mop_instance_weaken_slot(pTHX_ SV* const mi, SV* const instance) {
HE* he;
CHECK_INSTANCE(instance);
- he = hv_fetch_ent((HV*)SvRV(instance), MOP_mg_slot(mg), FALSE, 0U);
+ he = hv_fetch_ent((HV*)SvRV(instance), MOP_mi_slot(mi), FALSE, 0U);
if(he){
sv_rvweaken(HeVAL(he));
}