Skip to content

Commit

Permalink
Mass replace VTABLE with function calls
Browse files Browse the repository at this point in the history
  • Loading branch information
bacek committed Mar 3, 2012
1 parent 2d2251b commit 4a9efbc
Show file tree
Hide file tree
Showing 6 changed files with 25 additions and 25 deletions.
14 changes: 7 additions & 7 deletions src/dynext.c
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ set_cstring_prop(PARROT_INTERP, ARGMOD(PMC *lib_pmc), ARGIN(const char *what),
PMC * const prop = Parrot_pmc_new(interp, enum_class_String);

VTABLE_set_string_native(interp, prop, name);
VTABLE_setprop(interp, lib_pmc, key, prop);
Parrot_pmc_setprop(interp, lib_pmc, key, prop);
}


Expand Down Expand Up @@ -571,12 +571,12 @@ Parrot_dyn_clone_lib_into(ARGMOD(Interp *d), ARGMOD(Interp *s), ARGIN(PMC *lib_p
STRING * const ops = CONST_STRING(s, "Ops");

STRING * const wo_ext = clone_string_into(d, s,
VTABLE_getprop(s, lib_pmc, filename));
Parrot_pmc_getprop(s, lib_pmc, filename));
STRING * const lib_name = clone_string_into(d, s,
VTABLE_getprop(s, lib_pmc, libname));
Parrot_pmc_getprop(s, lib_pmc, libname));
void * const handle = VTABLE_get_pointer(s, lib_pmc);
STRING * const type =
VTABLE_get_string(s, VTABLE_getprop(s, lib_pmc, type_str));
VTABLE_get_string(s, Parrot_pmc_getprop(s, lib_pmc, type_str));

if (STRING_equal(s, type, ops)) {
/* we can't clone oplibs in the normal way, since they're actually
Expand All @@ -588,9 +588,9 @@ Parrot_dyn_clone_lib_into(ARGMOD(Interp *d), ARGMOD(Interp *s), ARGIN(PMC *lib_p
PMC * const new_lib_pmc = Parrot_pmc_new(d, enum_class_ParrotLibrary);

PMC_data(new_lib_pmc) = handle;
VTABLE_setprop(d, new_lib_pmc, CONST_STRING(s, "_filename"), Parrot_pmc_box_string(d, wo_ext));
VTABLE_setprop(d, new_lib_pmc, CONST_STRING(s, "_lib_name"), Parrot_pmc_box_string(d, lib_name));
VTABLE_setprop(d, new_lib_pmc, CONST_STRING(s, "_type"), Parrot_pmc_box_string(d, ops));
Parrot_pmc_setprop(d, new_lib_pmc, CONST_STRING(s, "_filename"), Parrot_pmc_box_string(d, wo_ext));
Parrot_pmc_setprop(d, new_lib_pmc, CONST_STRING(s, "_lib_name"), Parrot_pmc_box_string(d, lib_name));
Parrot_pmc_setprop(d, new_lib_pmc, CONST_STRING(s, "_type"), Parrot_pmc_box_string(d, ops));

/* fixup d->all_op_libs, if necessary */
if (d->n_libs != s->n_libs) {
Expand Down
2 changes: 1 addition & 1 deletion src/interp/api.c
Original file line number Diff line number Diff line change
Expand Up @@ -621,7 +621,7 @@ Parrot_interp_mark_method_writes(PARROT_INTERP, int type, ARGIN(const char *name
PMC * const pmc_true = Parrot_pmc_new_init_int(interp, enum_class_Integer, 1);
PMC * const method = VTABLE_get_pmc_keyed_str(interp,
interp->vtables[type]->_namespace, str_name);
VTABLE_setprop(interp, method, CONST_STRING(interp, "write"), pmc_true);
Parrot_pmc_setprop(interp, method, CONST_STRING(interp, "write"), pmc_true);
}

/*
Expand Down
16 changes: 8 additions & 8 deletions src/interp/inter_cb.c
Original file line number Diff line number Diff line change
Expand Up @@ -94,9 +94,9 @@ Parrot_make_cb(PARROT_INTERP, ARGMOD(PMC* sub), ARGIN(PMC* user_data),

/* be sure __LINE__ is consistent */
sc = CONST_STRING(interp, "_interpreter");
VTABLE_setprop(interp, user_data, sc, interp_pmc);
Parrot_pmc_setprop(interp, user_data, sc, interp_pmc);
sc = CONST_STRING(interp, "_sub");
VTABLE_setprop(interp, user_data, sc, sub);
Parrot_pmc_setprop(interp, user_data, sc, sub);
/* only ASCII signatures are supported */
if (STRING_length(cb_signature) == 3) {
/* Callback return type ignored */
Expand All @@ -117,7 +117,7 @@ Parrot_make_cb(PARROT_INTERP, ARGMOD(PMC* sub), ARGIN(PMC* user_data),
cb_sig = Parrot_pmc_new(interp, enum_class_String);
VTABLE_set_string_native(interp, cb_sig, cb_signature);
sc = CONST_STRING(interp, "_signature");
VTABLE_setprop(interp, user_data, sc, cb_sig);
Parrot_pmc_setprop(interp, user_data, sc, cb_sig);
/*
* We are going to be passing the user_data PMC to external code, but
* it may go out of scope until the callback is called -- we don't know
Expand Down Expand Up @@ -182,7 +182,7 @@ verify_CD(ARGIN(char *external_data), ARGMOD_NULLOK(PMC *user_data))

/* Fetch original interpreter from prop */
sc = CONST_STRING(interp, "_interpreter");
interp_pmc = VTABLE_getprop(interp, user_data, sc);
interp_pmc = Parrot_pmc_getprop(interp, user_data, sc);
GETATTR_ParrotInterpreter_interp(interp, interp_pmc, interp);
if (!interp)
PANIC(interp, "interpreter not found for callback");
Expand Down Expand Up @@ -230,12 +230,12 @@ callback_CD(PARROT_INTERP, ARGIN(char *external_data), ARGMOD(PMC *user_data))
* 3) check interpreter ...
*/
sc = CONST_STRING(interp, "_interpreter");
passed_interp = VTABLE_getprop(interp, user_data, sc);
passed_interp = Parrot_pmc_getprop(interp, user_data, sc);
if (VTABLE_get_pointer(interp, passed_interp) != interp)
PANIC(interp, "callback gone to wrong interpreter");

sc = CONST_STRING(interp, "_synchronous");
passed_synchronous = VTABLE_getprop(interp, user_data, sc);
passed_synchronous = Parrot_pmc_getprop(interp, user_data, sc);
if (!PMC_IS_NULL(passed_synchronous) &&
VTABLE_get_bool(interp, passed_synchronous))
synchronous = 1;
Expand Down Expand Up @@ -300,9 +300,9 @@ Parrot_run_callback(PARROT_INTERP,
STRING *sc;

sc = CONST_STRING(interp, "_sub");
sub = VTABLE_getprop(interp, user_data, sc);
sub = Parrot_pmc_getprop(interp, user_data, sc);
sc = CONST_STRING(interp, "_signature");
signature = VTABLE_getprop(interp, user_data, sc);
signature = Parrot_pmc_getprop(interp, user_data, sc);
sig_str = VTABLE_get_string(interp, signature);

pasm_sig[0] = 'P';
Expand Down
2 changes: 1 addition & 1 deletion src/pmc/parrotlibrary.pmc
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ Returns the name of the loaded library.

VTABLE STRING *get_string() {
STRING * const key = CONST_STRING(INTERP, "_filename");
PMC * const prop = VTABLE_getprop(INTERP, SELF, key);
PMC * const prop = Parrot_pmc_getprop(INTERP, SELF, key);

return VTABLE_get_string(INTERP, prop);
}
Expand Down
2 changes: 1 addition & 1 deletion src/pmc/undef.pmc
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ appropriate type.
while (VTABLE_get_bool(INTERP, iter)) {
STRING * const key = VTABLE_shift_string(INTERP, iter);
PMC * const value = VTABLE_get_pmc_keyed_str(INTERP, meta, key);
VTABLE_setprop(INTERP, SELF, key, value);
Parrot_pmc_setprop(INTERP, SELF, key, value);
}
}
PMC_data(clone) = NULL;
Expand Down
14 changes: 7 additions & 7 deletions src/pmc/unmanagedstruct.pmc
Original file line number Diff line number Diff line change
Expand Up @@ -310,7 +310,7 @@ char_offset_key(PARROT_INTERP, ARGIN(PMC *pmc), ARGIN(PMC *key), ARGOUT(int *typ
/* the struct PMC is hanging off the initializer element
* as property "_struct" */
PMC * const ptr = VTABLE_get_pmc_keyed_int(interp, init, ix);
init = VTABLE_getprop(interp, ptr, CONST_STRING(interp, "_struct"));
init = Parrot_pmc_getprop(interp, ptr, CONST_STRING(interp, "_struct"));

PARROT_ASSERT(init
&& (init->vtable->base_type == enum_class_UnManagedStruct
Expand Down Expand Up @@ -532,7 +532,7 @@ ret_pmc(PARROT_INTERP, ARGIN(PMC *pmc), ARGIN(char *p), int type, INTVAL idx)
/* now check if initializer has a signature attached */
if (PMC_metadata(ptr)) {
STRING *signature_str = CONST_STRING(interp, "_signature");
PMC * const sig = VTABLE_getprop(interp, ptr, signature_str);
PMC * const sig = Parrot_pmc_getprop(interp, ptr, signature_str);
if (VTABLE_defined(interp, sig)) {
STRING * const sig_str = VTABLE_get_string(interp, sig);
ret = Parrot_pmc_new(interp, enum_class_NCI);
Expand All @@ -547,7 +547,7 @@ ret_pmc(PARROT_INTERP, ARGIN(PMC *pmc), ARGIN(char *p), int type, INTVAL idx)

/* grab the struct from the metadata */
if (PMC_metadata(ptr))
ret = VTABLE_getprop(interp, ptr, CONST_STRING(interp, "_struct"));
ret = Parrot_pmc_getprop(interp, ptr, CONST_STRING(interp, "_struct"));
else {
Parrot_ex_throw_from_c_args(interp, NULL,
EXCEPTION_INVALID_OPERATION,
Expand Down Expand Up @@ -688,7 +688,7 @@ calc_align(PARROT_INTERP, ARGIN(PMC *type_pmc), int type, size_t offs)
if (type == enum_type_struct || type == enum_type_struct_ptr) {
/* a nested structs alignment is the biggest item in it
* so go through that struct and check */
nested = VTABLE_getprop(interp, type_pmc, CONST_STRING(interp, "_struct"));
nested = Parrot_pmc_getprop(interp, type_pmc, CONST_STRING(interp, "_struct"));
nested_init = PARROT_UNMANAGEDSTRUCT(nested)->init;
}
if (type == enum_type_struct) {
Expand Down Expand Up @@ -775,15 +775,15 @@ calc_offsets(PARROT_INTERP, ARGIN(PMC *pmc), ARGIN(PMC *value), size_t toff)
toff = offs;

if (type == enum_type_struct) {
PMC * const nested = VTABLE_getprop(interp, type_pmc, _struct);
PMC * const nested = Parrot_pmc_getprop(interp, type_pmc, _struct);
size = VTABLE_get_integer(interp, nested);
}
else if (type == enum_type_struct_ptr) {
PMC * const nested = VTABLE_getprop(interp, type_pmc, _struct);
PMC * const nested = Parrot_pmc_getprop(interp, type_pmc, _struct);

/* must clone this struct so as not to share its memory */
if (nested->vtable->base_type == enum_class_ManagedStruct)
VTABLE_setprop(interp, type_pmc, _struct,
Parrot_pmc_setprop(interp, type_pmc, _struct,
VTABLE_clone(interp, nested));

size = data_types[type - enum_first_type].size;
Expand Down

0 comments on commit 4a9efbc

Please sign in to comment.