Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

fix NCI related DOD problem

git-svn-id: https://svn.parrot.org/parrot/trunk@5994 d31e2699-5ff4-0310-a27c-f18f2fbe73fe
  • Loading branch information...
commit 380c0ba52f638f588a5a2722e5e58eb517c56a11 1 parent f3294ab
Leopold Toetsch authored
View
2  classes/compiler.pmc
@@ -56,7 +56,7 @@ C<Eval> PMC with a new PackFile attached.
/* return value PMC is in P5 */
code_seg = REG_PMC(5);
REG_PMC(5) = p5;
-
+
eval_pf = (struct PackFile *) PMC_data(code_seg);
/* morph the Byte_cointer *pointer in code_seg to an invokable sub */
code_seg->vtable = Parrot_base_vtables[enum_class_Eval];
View
14 classes/nci.pmc
@@ -43,18 +43,18 @@ Initializes the NCI with a C<NULL> function pointer.
/*
-=item C<void set_string_keyed(PMC *func, STRING *value)>
+=item C<void set_pointer_keyed_str(STRING *key, void *func)>
-Sets the specified function pointer and signature (C<*value>).
+Sets the specified function pointer and signature (C<*key>).
=cut
*/
- void set_string_keyed (PMC* func, STRING* value) {
- /* key = func_ptr, value = signature */
- PMC_struct_val(SELF) = (DPOINTER *)func;
- PMC_data(SELF) = build_call_func(INTERP, SELF, value);
+ void set_pointer_keyed_str(STRING *key, void *func) {
+ /* key = signature */
+ PMC_struct_val(SELF) = func;
+ PMC_data(SELF) = build_call_func(INTERP, SELF, key);
}
/*
@@ -122,7 +122,7 @@ Calls the associated C function, returning C<*next>.
func(INTERP, SELF);
return next;
}
-
+
/*
=item C<INTVAL get_integer()>
View
50 classes/unmanagedstruct.pmc
@@ -314,37 +314,37 @@ ret_pmc(Parrot_Interp interpreter, PMC* pmc, char *p, int type, INTVAL idx)
ptr = VTABLE_get_pmc_keyed_int(interpreter, init, idx*3);
if (ptr->pmc_ext && PMC_metadata(ptr)) {
PMC *sig = VTABLE_getprop(interpreter, ptr,
- string_from_cstring(interpreter, "_signature", 0));
+ string_from_cstring(interpreter, "_signature", 0));
if (VTABLE_defined(interpreter, sig)) {
STRING *sig_str = VTABLE_get_string(interpreter, sig);
ret = pmc_new(interpreter, enum_class_NCI);
- VTABLE_set_string_keyed(interpreter, ret,
- *(PMC**)p, sig_str);
+ VTABLE_set_pointer_keyed_str(interpreter, ret, sig_str,
+ *(PMC**)p);
}
}
return ret;
- case enum_type_struct_ptr:
-
- /* check the metadata for an initializer */
- init = PMC_pmc_val( pmc );
- ptr = VTABLE_get_pmc_keyed_int( interpreter, init, idx * 3 );
-
- /* grab the struct from the metadata */
- if (ptr->pmc_ext && PMC_metadata( ptr ))
- {
- ret = VTABLE_getprop( interpreter, ptr,
- string_from_cstring(interpreter, "_struct", 0 ));
- }
- else
- {
- internal_exception( 1,
- "no initializer available for nested struct\n" );
- }
-
- /* assign the pointer */
- PMC_data( ret ) = *(void**)p;
-
- return ret;
+ case enum_type_struct_ptr:
+
+ /* check the metadata for an initializer */
+ init = PMC_pmc_val(pmc);
+ ptr = VTABLE_get_pmc_keyed_int(interpreter, init, idx * 3);
+
+ /* grab the struct from the metadata */
+ if (ptr->pmc_ext && PMC_metadata(ptr))
+ {
+ ret = VTABLE_getprop(interpreter, ptr,
+ const_string(interpreter, "_struct"));
+ }
+ else
+ {
+ internal_exception(1,
+ "no initializer available for nested struct\n");
+ }
+
+ /* assign the pointer */
+ PMC_data(ret) = *(void**)p;
+
+ return ret;
default:
internal_exception(1, "returning unhandled pmc type in struct");
}
View
2  ops/core.ops
@@ -1120,7 +1120,7 @@ op dlfunc (out PMC, in PMC, in STR, in STR) {
}
else {
$1 = nci = pmc_new(interpreter, enum_class_NCI);
- nci->vtable->set_string_keyed(interpreter, nci, (PMC*)F2DPTR(p), $4);
+ nci->vtable->set_pointer_keyed_str(interpreter, nci, $4, F2DPTR(p));
}
string_cstring_free(name);
goto NEXT();
View
9 src/inter_misc.c
@@ -66,9 +66,10 @@ enter_nci_method(Parrot_Interp interpreter, int type,
method_table = table[type];
method = pmc_new(interpreter, enum_class_NCI);
- VTABLE_set_string_keyed(interpreter, method, func,
+ VTABLE_set_pointer_keyed_str(interpreter, method,
string_make(interpreter, proto, strlen(proto),
- "iso-8859-1", PObj_constant_FLAG|PObj_external_FLAG));
+ "iso-8859-1", PObj_constant_FLAG|PObj_external_FLAG),
+ func);
VTABLE_set_pmc_keyed_str(interpreter, method_table,
string_make(interpreter, name,
strlen(name), "iso-8859-1",
@@ -103,8 +104,8 @@ Parrot_compreg(Parrot_Interp interpreter, STRING *type, PMC *func)
nci = pmc_new(interpreter, enum_class_Compiler);
VTABLE_set_pmc_keyed_str(interpreter, hash, type, nci);
/* build native call interface fir the C sub in "func" */
- VTABLE_set_string_keyed(interpreter, nci, func,
- string_from_cstring(interpreter, "pIt", 0));
+ VTABLE_set_pointer_keyed_str(interpreter, nci,
+ const_string(interpreter, "pIt"), func);
}
View
30 t/pmc/nci.t
@@ -17,7 +17,7 @@ i386 and the F<libnci.so> library is found.
=cut
-use Parrot::Test tests => 34;
+use Parrot::Test tests => 33;
use Parrot::Config;
SKIP: {
@@ -655,34 +655,6 @@ CODE
77
OUTPUT
-output_is(<<'CODE', <<'OUTPUT', "nci_p_i - func_ptr*");
- loadlib P1, "libnci"
- dlfunc P0, P1, "nci_pi", "pi"
- # this test function returns a struct { int (*f)(char *) }
- set I5, 5
- invoke
- new P2, .PerlArray
-.include "datatypes.pasm"
- push P2, .DATATYPE_FUNC_PTR
- push P2, 0
- push P2, 0
- assign P5, P2
- # P1 isnt a real PMC, its only suited for passing on to
- # the NCI PMC as a Key
- set P1, P5[0]
- # if no signatur was given, do it manually
- # s. below for another method
- new P0, .NCI
- set P0[P1], "it"
- set S5, "hello call_back"
- invoke
- print I5
- print "\n"
- end
-CODE
-hello call_back
-4711
-OUTPUT
output_is(<<'CODE', <<'OUTPUT', "nci_p_i - func_ptr* with signature");
loadlib P1, "libnci"
Please sign in to comment.
Something went wrong with that request. Please try again.