Permalink
Browse files

Remove Parrot_PMC_typenum (use Parrot_pmc_get_type_str instead) and P…

…arrot_free_cstring (use Parrot_str_free_cstring). This closes #407
  • Loading branch information...
Whiteknight committed May 8, 2012
1 parent cc2f31c commit fc5314165fd9e666d8f6622862480198cdbf523e
Showing with 20 additions and 89 deletions.
  1. +1 −3 docs/embed.pod
  2. +2 −2 docs/pdds/draft/pdd11_extending.pod
  3. +3 −1 examples/embed/cotorra.c
  4. +8 −7 src/dynpmc/README.pod
  5. +0 −20 src/extend.c
  6. +1 −1 src/io/api.c
  7. +5 −55 t/src/extend.t
View
@@ -483,7 +483,7 @@ performing both compiling and linking in one step.
sub = Parrot_ns_find_current_namespace_global(interp, pstr);
/* run foo(), which returns nothing */
- Parrot_ext_call(interp, sub, "->");
+ Parrot_ext_call(interp, sub, "->");
Parrot_destroy(interp);
@@ -714,8 +714,6 @@ The list may also be augmented if additional functionality is required.
=item C<Parrot_free_context>
-=item C<Parrot_free_cstring>
-
=item C<Parrot_freeze>
=item C<Parrot_freeze_at_destruct>
@@ -94,7 +94,7 @@ will not change the original in any way.
This memory will I<not> be reclaimed by garbage collection, nor may it be
returned to the system with C<free>. It must be returned with
-C<Parrot_free_cstring>.
+C<Parrot_str_free_cstring>.
=item C<Parrot_PMC_get_cstring_intkey(interp, pmc, Parrot_Int key)>
@@ -111,7 +111,7 @@ of an integer that will get the length of the string as Parrot knows it.
This memory will I<not> be reclaimed by garbage collection, nor may it be
returned to the system with C<free>. It must be returned with
-C<Parrot_free_cstring>.
+C<Parrot_str_free_cstring>.
=item C<Parrot_PMC_get_cstringn_intkey(interp, pmc, &len, Parrot_Int key)>
View
@@ -234,7 +234,9 @@ int cotorra_main(Parrot_Interp interp, int argc, const char **argv)
if (i < argc) {
int pos;
Parrot_PMC arg = Parrot_pmc_new(interp,
- Parrot_PMC_typenum(interp, "FixedStringArray"));
+ Parrot_pmc_get_type_str(interp,
+ Parrot_str_new(interp, "FixedStringArray", 0)));
+
Parrot_PMC_set_integer_native(interp, arg, argc - i);
for (pos = 0; i < argc; ++i, ++pos) {
Parrot_PMC_set_string_keyed_int(interp, arg, pos, create_string(interp, argv[i]));
View
@@ -18,7 +18,7 @@ There are some differences you have to be aware of when creating dynamic PMCs.
When declaring the dynamic PMC, you must specify the C<dynpmc> flag, as in:
- pmclass TclString extends TclObject dynpmc ... { ... }
+ pmclass TclString extends TclObject dynpmc ... { ... }
Note that regular (non-dynamic) PMCs have a type id
C<enum_class_PMCNAME>, but dynamic PMCs obviously cannot use the same
@@ -28,7 +28,7 @@ determine the PMC type. So, while C<scalar> (a builtin) has the
luxury of knowing at compile time what the class number of its child
C<String> is -- for example:
- if (type == enum_class_String) { ...
+ if (type == enum_class_String) { ...
a dynamic PMC such as C<TclInt> must instead perform a runtime lookup
of its corresponding C<TclString> PMC, resulting in the more complicated:
@@ -39,7 +39,8 @@ of its corresponding C<TclString> PMC, resulting in the more complicated:
void class_init() {
if (pass) {
- dynpmc_TclString = Parrot_PMC_typenum(interp,"TclString");
+ dynpmc_TclString = Parrot_pmc_get_type_str(interp,
+ Parrot_str_new(interp, "TclString", 0));
}
}
}
@@ -61,14 +62,14 @@ Edit C<src/dynpmc/Defines.in> and C<src/dynpmc/Rules.in>, appending your PMC(s)
to the build target. These files are processed by Configure.pl to create the
real makefile fragments.
Next invoke the configure script, then make:
-
- $ perl Configure.pl
- $ make
+
+ $ perl Configure.pl
+ $ make
=item 3
If anything changes inside parrot, be sure to:
- $ make dynpmc-clean
+ $ make dynpmc-clean
=back
View
@@ -111,26 +111,6 @@ Parrot_PMC_typenum(PARROT_INTERP, ARGIN_NULLOK(const char *_class))
/*
-=item C<void Parrot_free_cstring(char *string)>
-
-Deallocate a C string that the interpreter has handed to you.
-
-DEPRECATED. Use Parrot_str_free_cstring instead.
-
-=cut
-
-*/
-
-PARROT_EXPORT
-void
-Parrot_free_cstring(ARGFREE(char *string))
-{
- ASSERT_ARGS(Parrot_free_cstring)
- Parrot_str_free_cstring(string);
-}
-
-/*
-
=item C<void Parrot_ext_call(PARROT_INTERP, Parrot_PMC sub_pmc, const char
*signature, ...)>
View
@@ -163,7 +163,7 @@ Parrot_io_open_handle(PARROT_INTERP, ARGIN(PMC *pmc), ARGIN(STRING *path), ARGIN
ASSERT_ARGS(Parrot_io_open_handle)
PMC *filehandle;
const INTVAL typenum = Parrot_hll_get_ctx_HLL_type(interp,
- Parrot_PMC_typenum(interp, "FileHandle"));
+ enum_class_FileHandle);
if (PMC_IS_NULL(pmc)) {
filehandle = Parrot_pmc_new(interp, typenum);
}
View
@@ -16,7 +16,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 => 20;
+plan tests => 19;
=head1 NAME
@@ -204,7 +204,7 @@ main(int argc, const char *argv[])
/* Interpreter set-up */
if (interp) {
- type = Parrot_PMC_typenum(interp, "Integer");
+ type = Parrot_pmc_get_type_str(interp, Parrot_str_new(interp, "Integer", 0));
testpmc = Parrot_pmc_new(interp, type);
Parrot_PMC_set_integer_native(interp, testpmc, value);
@@ -220,56 +220,6 @@ CODE
101010
OUTPUT
-c_output_is( linedirective(__LINE__) . <<'CODE', <<'OUTPUT', 'Parrot_free_cstring');
-#include <stdio.h>
-#include "parrot/parrot.h"
-#include "parrot/parrot.h"
-#include "parrot/extend.h"
-
-static void fail(const char *msg);
-static Parrot_String createstring(Parrot_Interp interp, const char * value);
-static Parrot_Interp new_interp();
-
-static void fail(const char *msg)
-{
- fprintf(stderr, "failed: %s\n", msg);
- exit(EXIT_FAILURE);
-}
-
-static Parrot_String createstring(Parrot_Interp interp, const char * value)
-{
- return Parrot_str_new(interp, value, strlen(value));
-}
-
-static Parrot_Interp new_interp()
-{
- Parrot_Interp interp = Parrot_interp_new(NULL);
- if (!interp)
- fail("Cannot create parrot interpreter");
- return interp;
-
-}
-
-int main(int argc, const char **argv)
-{
- Parrot_Interp interp;
- Parrot_String err, string;
- Parrot_PMC func_pmc;
- char *str;
-
- interp = new_interp();
-
- string = createstring(interp, "PIR");
- str = Parrot_str_to_cstring(interp, string);
-
- Parrot_free_cstring(str);
-
- Parrot_interp_destroy(interp);
- return 0;
-}
-CODE
-OUTPUT
-
c_output_is( <<'CODE', <<'OUTPUT', 'PMC_set/get_integer_keyed_int' );
#include <stdio.h>
@@ -284,7 +234,7 @@ main(int argc, const char *argv[])
/* Interpreter set-up */
if (interp) {
- Parrot_Int type = Parrot_PMC_typenum(interp, "ResizablePMCArray");
+ Parrot_Int type = Parrot_pmc_get_type_str(interp, Parrot_str_new(interp, "ResizablePMCArray", 0));
Parrot_PMC array = Parrot_pmc_new(interp, type);
Parrot_Int value = 12345;
Parrot_Int key = 10;
@@ -320,7 +270,7 @@ main(int argc, const char *argv[])
/* Interpreter set-up */
if (interp) {
- type = Parrot_PMC_typenum(interp, "Float");
+ type = Parrot_pmc_get_type_str(interp, Parrot_str_new(interp, "Float", 0));
testpmc = Parrot_pmc_new(interp, type);
Parrot_PMC_set_number_native(interp, testpmc, value);
@@ -352,7 +302,7 @@ main(int argc, const char *argv[])
/* Interpreter set-up */
if (interp) {
- type = Parrot_PMC_typenum(interp, "String");
+ type = Parrot_pmc_get_type_str(interp, Parrot_str_new(interp, "String", 0));
testpmc = Parrot_pmc_new(interp, type);
value = Parrot_str_new(interp, "Pumpking", 8/*, "iso-8859-1", 0*/);

0 comments on commit fc53141

Please sign in to comment.