Permalink
Browse files

Merge branch 'GCI_extend_cleanup' of git://github.com/trishume/parrot…

… into extend_cleanup
  • Loading branch information...
2 parents 3e796d7 + 7a4a967 commit ec76d8ccb526ff80dd6036a001ac6aeb93883b85 @Whiteknight Whiteknight committed Nov 26, 2011
Showing with 34 additions and 166 deletions.
  1. +1 −3 docs/embed.pod
  2. +0 −18 include/parrot/extend.h
  3. +9 −0 include/parrot/oo.h
  4. +1 −2 ports/debian/libparrot3.3.0.symbols
  5. +0 −51 src/extend.c
  6. +19 −0 src/oo.c
  7. +1 −81 t/src/embed.t
  8. +3 −11 t/src/extend_vtable.t
View
@@ -1224,7 +1224,7 @@ The list may also be augmented if additional functionality is required.
=item C<Parrot_PMC_new>
-=item C<Parrot_PMC_newclass>
+=item C<Parrot_oo_new_class_pmc>
=item C<Parrot_PMC_null>
@@ -1562,8 +1562,6 @@ The list may also be augmented if additional functionality is required.
=item C<Parrot_str_upcase>
-=item C<Parrot_sub_new_from_c_func>
-
=item C<Parrot_test_debug>
=item C<Parrot_test_flag>
@@ -116,10 +116,6 @@ Parrot_PMC Parrot_PMC_new(PARROT_INTERP, Parrot_Int type)
__attribute__nonnull__(1);
PARROT_EXPORT
-Parrot_PMC Parrot_PMC_newclass(PARROT_INTERP, Parrot_PMC classtype)
- __attribute__nonnull__(1);
-
-PARROT_EXPORT
PARROT_PURE_FUNCTION
PARROT_CAN_RETURN_NULL
Parrot_PMC Parrot_PMC_null(void);
@@ -160,14 +156,6 @@ void Parrot_set_strreg(PARROT_INTERP,
__attribute__nonnull__(1);
PARROT_EXPORT
-Parrot_PMC Parrot_sub_new_from_c_func(PARROT_INTERP,
- ARGIN(void (*func)(void)),
- ARGIN(const char * signature))
- __attribute__nonnull__(1)
- __attribute__nonnull__(2)
- __attribute__nonnull__(3);
-
-PARROT_EXPORT
void Parrot_unregister_pmc(PARROT_INTERP, Parrot_PMC pmc)
__attribute__nonnull__(1);
@@ -211,8 +199,6 @@ int Parrot_vfprintf(PARROT_INTERP,
PARROT_ASSERT_ARG(interp))
#define ASSERT_ARGS_Parrot_PMC_new __attribute__unused__ int _ASSERT_ARGS_CHECK = (\
PARROT_ASSERT_ARG(interp))
-#define ASSERT_ARGS_Parrot_PMC_newclass __attribute__unused__ int _ASSERT_ARGS_CHECK = (\
- PARROT_ASSERT_ARG(interp))
#define ASSERT_ARGS_Parrot_PMC_null __attribute__unused__ int _ASSERT_ARGS_CHECK = (0)
#define ASSERT_ARGS_Parrot_PMC_typenum __attribute__unused__ int _ASSERT_ARGS_CHECK = (\
PARROT_ASSERT_ARG(interp))
@@ -230,10 +216,6 @@ int Parrot_vfprintf(PARROT_INTERP,
PARROT_ASSERT_ARG(interp))
#define ASSERT_ARGS_Parrot_set_strreg __attribute__unused__ int _ASSERT_ARGS_CHECK = (\
PARROT_ASSERT_ARG(interp))
-#define ASSERT_ARGS_Parrot_sub_new_from_c_func __attribute__unused__ int _ASSERT_ARGS_CHECK = (\
- PARROT_ASSERT_ARG(interp) \
- , PARROT_ASSERT_ARG(func) \
- , PARROT_ASSERT_ARG(signature))
#define ASSERT_ARGS_Parrot_unregister_pmc __attribute__unused__ int _ASSERT_ARGS_CHECK = (\
PARROT_ASSERT_ARG(interp))
#define ASSERT_ARGS_Parrot_unregister_string __attribute__unused__ int _ASSERT_ARGS_CHECK = (\
View
@@ -134,6 +134,12 @@ PARROT_WARN_UNUSED_RESULT
PMC * Parrot_oo_get_class_str(PARROT_INTERP, ARGIN_NULLOK(STRING *name))
__attribute__nonnull__(1);
+PARROT_EXPORT
+PARROT_CANNOT_RETURN_NULL
+PMC * Parrot_oo_new_class_pmc(PARROT_INTERP, ARGIN(PMC *classtype))
+ __attribute__nonnull__(1)
+ __attribute__nonnull__(2);
+
void destroy_object_cache(PARROT_INTERP)
__attribute__nonnull__(1);
@@ -212,6 +218,9 @@ INTVAL Parrot_oo_register_type(PARROT_INTERP,
, PARROT_ASSERT_ARG(key))
#define ASSERT_ARGS_Parrot_oo_get_class_str __attribute__unused__ int _ASSERT_ARGS_CHECK = (\
PARROT_ASSERT_ARG(interp))
+#define ASSERT_ARGS_Parrot_oo_new_class_pmc __attribute__unused__ int _ASSERT_ARGS_CHECK = (\
+ PARROT_ASSERT_ARG(interp) \
+ , PARROT_ASSERT_ARG(classtype))
#define ASSERT_ARGS_destroy_object_cache __attribute__unused__ int _ASSERT_ARGS_CHECK = (\
PARROT_ASSERT_ARG(interp))
#define ASSERT_ARGS_init_object_cache __attribute__unused__ int _ASSERT_ARGS_CHECK = (\
@@ -474,7 +474,6 @@ libparrot.so.3.3.0 libparrot3.3.0 #MINVER#
Parrot_PMC_name@Base 3.3.0
Parrot_PMC_neg@Base 3.3.0
Parrot_PMC_new@Base 3.3.0
- Parrot_PMC_newclass@Base 3.3.0
Parrot_PMC_null@Base 3.3.0
Parrot_PMC_pop_float@Base 3.3.0
Parrot_PMC_pop_integer@Base 3.3.0
@@ -1166,6 +1165,7 @@ libparrot.so.3.3.0 libparrot3.3.0 #MINVER#
Parrot_oo_find_vtable_override_for_class@Base 3.3.0
Parrot_oo_get_class@Base 3.3.0
Parrot_oo_get_class_str@Base 3.3.0
+ Parrot_oo_new_class_pmc@Base 3.3.0
Parrot_pa_destroy@Base 3.3.0
Parrot_pa_is_owned@Base 3.3.0
Parrot_pa_new@Base 3.3.0
@@ -1365,7 +1365,6 @@ libparrot.so.3.3.0 libparrot3.3.0 #MINVER#
Parrot_sub_context_get_info@Base 3.3.0
Parrot_sub_full_sub_name@Base 3.3.0
Parrot_sub_new_closure@Base 3.3.0
- Parrot_sub_new_from_c_func@Base 3.3.0
Parrot_switch_to_cs@Base 3.3.0
Parrot_sysmem_amount@Base 3.3.0
Parrot_test_debug@Base 3.3.0
View
@@ -685,57 +685,6 @@ Parrot_unregister_string(PARROT_INTERP, Parrot_String s)
/*
-=item C<Parrot_PMC Parrot_sub_new_from_c_func(PARROT_INTERP, void (*func(void)),
-const char * signature)>
-
-Returns a PMC sub wrapper for a c function.
-
-TODO: Clean this up, move it some place more appropriate
-
-=cut
-
-*/
-
-PARROT_EXPORT
-Parrot_PMC
-Parrot_sub_new_from_c_func(PARROT_INTERP,
- ARGIN(void (*func)(void)), ARGIN(const char * signature))
-{
- ASSERT_ARGS(Parrot_sub_new_from_c_func)
-
- Parrot_String sig;
- Parrot_PMC sub;
-
- sig = Parrot_new_string(interp, signature, strlen(signature),
- (char *) NULL, 0);
-
- sub = Parrot_pmc_new(interp, enum_class_NCI);
- VTABLE_set_pointer_keyed_str(interp, sub, sig, F2DPTR(func));
- return sub;
-}
-
-/*
-
-=item C<Parrot_PMC Parrot_PMC_newclass(PARROT_INTERP, Parrot_PMC classtype)>
-
-Create a class with the type given
-
-TODO: Clean this up, move this to src/oo.c
-
-=cut
-
-*/
-
-PARROT_EXPORT
-Parrot_PMC
-Parrot_PMC_newclass(PARROT_INTERP, Parrot_PMC classtype)
-{
- ASSERT_ARGS(Parrot_PMC_newclass)
- return Parrot_pmc_new_init(interp, enum_class_Class, classtype);
-}
-
-/*
-
=back
=head1 SEE ALSO
View
@@ -442,6 +442,25 @@ Parrot_oo_get_class_str(PARROT_INTERP, ARGIN_NULLOK(STRING *name))
}
}
+/*
+
+=item C<PMC * Parrot_oo_new_class_pmc(PARROT_INTERP, PMC *classtype)>
+
+Create a class with the type given
+
+=cut
+
+*/
+
+PARROT_EXPORT
+PARROT_CANNOT_RETURN_NULL
+PMC *
+Parrot_oo_new_class_pmc(PARROT_INTERP, ARGIN(PMC *classtype))
+{
+ ASSERT_ARGS(Parrot_oo_new_class_pmc)
+ return Parrot_pmc_new_init(interp, enum_class_Class, classtype);
+}
+
/*
View
@@ -13,7 +13,7 @@ my $parrot_config = "parrot_config" . $PConfig{o};
plan skip_all => 'src/parrot_config.o does not exist' unless -e catfile("src", $parrot_config);
-plan tests => 15;
+plan tests => 13;
=head1 NAME
@@ -540,51 +540,6 @@ CODE
42.0 is the answer. What is the question?
OUTPUT
-
-c_output_is($common . linedirective(__LINE__) . <<'CODE', <<'OUTPUT', "External sub", todo => "Must explicitly set a PIR compreg" );
-
-void hello(Parrot_Interp interp);
-
-void hello(Parrot_Interp interp)
-{
- Parrot_printf(interp, "Hello from C\n");
-}
-
-int main(void)
-{
- Parrot_Interp interp;
- Parrot_String compiler;
- Parrot_String errstr;
- Parrot_PMC code;
- Parrot_PMC hellosub, pir_compiler, pasm_compiler, interp_pmc;
-
- /* Create the interpreter */
- interp = new_interp();
-
- imcc_get_pir_compreg_api(interp_pmc, 1, &pir_compiler);
- imcc_get_pir_compreg_api(interp_pmc, 1, &pasm_compiler);
-
- /* Compile pir */
- compiler = createstring(interp, "PIR");
- code = Parrot_compile_string(interp, compiler,
-".sub externcall :main\n"
-" .param pmc ec\n"
-" ec()\n"
-"\n"
-".end\n"
-"\n",
- &errstr
- );
- hellosub = Parrot_sub_new_from_c_func(interp, (void (*)())& hello, "vJ");
- Parrot_ext_call(interp, code, "P->", hellosub);
-
- Parrot_destroy(interp);
- return 0;
-}
-CODE
-Hello from C
-OUTPUT
-
c_output_is($common . linedirective(__LINE__) . <<'CODE', <<'OUTPUT', "Insert external sub in namespace", todo => "Must explicitly set a PIR compreg" );
void hello(Parrot_Interp interp);
@@ -600,7 +555,6 @@ int main(void)
Parrot_String compiler, pir_compiler;
Parrot_String errstr;
Parrot_PMC code;
- Parrot_PMC hellosub;
Parrot_PMC rootns;
Parrot_String parrotname;
Parrot_PMC parrotns;
@@ -628,7 +582,6 @@ int main(void)
rootns = Parrot_get_root_namespace(interp);
parrotname = createstring(interp, "parrot");
parrotns = Parrot_PMC_get_pmc_keyed_str(interp, rootns, parrotname);
- hellosub = Parrot_sub_new_from_c_func(interp, (void (*)())& hello, "vJ");
helloname = createstring(interp, "hello");
Parrot_PMC_set_pmc_keyed_str(interp, parrotns, helloname, hellosub);
@@ -1094,39 +1047,6 @@ OUTPUT
}
-SKIP: {
-skip 'Need extra NCI thunks',1 unless $PConfig{HAS_EXTRA_NCI_THUNKS};
-
-c_output_is($common . linedirective(__LINE__) . <<'CODE', <<'OUTPUT', "Parrot_sub_new_from_c_func");
-
-void test(int x);
-
-void test(int x)
-{
- printf("Hello!\n", x);
-}
-
-int main()
-{
- Parrot_Interp interp;
- Parrot_PMC test_pmc;
- int x,y;
-
- /* Create the interpreter */
- interp = new_interp();
-
- x = 10;
-
- test_pmc = Parrot_sub_new_from_c_func(interp, (void (*)())& test, "i");
- Parrot_ext_call(interp, test_pmc, "I->", x, &y);
-
- Parrot_x_exit(interp, 0);
-}
-CODE
-Hello!
-OUTPUT
-}
-
# Local Variables:
# mode: cperl
# cperl-indent-level: 4
View
@@ -14,7 +14,7 @@ my $parrot_config = "parrot_config" . $PConfig{o};
plan skip_all => 'src/parrot_config.o does not exist' unless -e catfile("src", $parrot_config);
-plan tests => 138;
+plan tests => 137;
=head1 NAME
@@ -97,7 +97,7 @@ void dotest(Parrot_Interp interp, void *unused)
{
Parrot_PMC pmc, pmc2, pmc3, pmc_string, pmc_string2, pmc_string3;
Parrot_PMC pmc_float, pmc_float2;
- Parrot_PMC rpa, rpa2, fpa, hash, hash_iter, continuation, continuation2, nci;
+ Parrot_PMC rpa, rpa2, fpa, hash, hash_iter, continuation, continuation2;
Parrot_PMC key_int, key_str, hashkey, ns, object, klass;
Parrot_Int type, value, integer, integer2;
Parrot_Float number, number2;
@@ -111,7 +111,6 @@ void dotest(Parrot_Interp interp, void *unused)
fpa = Parrot_PMC_new(interp, Parrot_PMC_typenum(interp, "FixedPMCArray"));
hash = Parrot_PMC_new(interp, Parrot_PMC_typenum(interp, "Hash"));
ns = Parrot_PMC_new(interp, Parrot_PMC_typenum(interp, "Namespace"));
- nci = Parrot_sub_new_from_c_func(interp, (void (*)(void))Parrot_PMC_new, "PpI");
pmc = Parrot_PMC_new(interp, type);
pmc2 = Parrot_PMC_new(interp, type);
pmc3 = Parrot_PMC_new(interp, type);
@@ -132,7 +131,7 @@ void dotest(Parrot_Interp interp, void *unused)
string = createstring(interp,"Object");
Parrot_PMC_assign_string_native(interp, pmc_string, string);
- object = Parrot_PMC_newclass(interp, pmc_string);
+ object = Parrot_oo_new_class_pmc(interp, pmc_string);
CODE
@@ -942,13 +941,6 @@ Got non-zero hash value!
Done!
OUTPUT
-extend_vtable_output_like(<<'CODE', qr/Got pointer!/, "Parrot_PMC_get_pointer");
- integer = (Parrot_Int) Parrot_PMC_get_pointer(interp, nci);
- Parrot_printf(interp,"pointer = %d\n", integer);
- if (integer != NULL)
- Parrot_printf(interp,"Got pointer!n");
-CODE
-
extend_vtable_output_is(<<'CODE', <<'OUTPUT', "Parrot_PMC_get_pointer_keyed");
Parrot_PMC_set_integer_native(interp, pmc, 42);

0 comments on commit ec76d8c

Please sign in to comment.