cvs commit: ponie/perl embedvar.h perl.c perlapi.h perlvars.h
[email protected] (Nicholas Clark) 29 Apr 2005 13:26:29 -0000
| Newsgroups | perl.ponie.changes |
|---|---|
| Message-ID | <[email protected]> |
cvsuser 05/04/29 06:26:29
Modified: perl embedvar.h perl.c perlapi.h perlvars.h
Log:
Add PL_pmc_to_type to hold a reverse lookup table to convert from PMC type
back to perl 5 type
Revision Changes Path
1.11 +2 -0 ponie/perl/embedvar.h
Index: embedvar.h
===================================================================
RCS file: /cvs/public/ponie/perl/embedvar.h,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -r1.10 -r1.11
--- embedvar.h 28 Apr 2005 22:52:11 -0000 1.10
+++ embedvar.h 29 Apr 2005 13:26:29 -0000 1.11
@@ -897,6 +897,7 @@
#define PL_malloc_mutex (PL_Vars.Gmalloc_mutex)
#define PL_op_mutex (PL_Vars.Gop_mutex)
#define PL_patleave (PL_Vars.Gpatleave)
+#define PL_pmc_to_type (PL_Vars.Gpmc_to_type)
#define PL_pmcname (PL_Vars.Gpmcname)
#define PL_pmcname_mutex (PL_Vars.Gpmcname_mutex)
#define PL_sh_path (PL_Vars.Gsh_path)
@@ -916,6 +917,7 @@
#define PL_Gmalloc_mutex PL_malloc_mutex
#define PL_Gop_mutex PL_op_mutex
#define PL_Gpatleave PL_patleave
+#define PL_Gpmc_to_type PL_pmc_to_type
#define PL_Gpmcname PL_pmcname
#define PL_Gpmcname_mutex PL_pmcname_mutex
#define PL_Gsh_path PL_sh_path
1.20 +17 -0 ponie/perl/perl.c
Index: perl.c
===================================================================
RCS file: /cvs/public/ponie/perl/perl.c,v
retrieving revision 1.19
retrieving revision 1.20
diff -u -r1.19 -r1.20
--- perl.c 28 Apr 2005 22:52:11 -0000 1.19
+++ perl.c 29 Apr 2005 13:26:29 -0000 1.20
@@ -253,6 +253,10 @@
{Ponie_PMC_Perl5_MAX, NULL}
};
const Ponie_pmc_init *i = s;
+ Parrot_Int max_type = 0;
+ signed char *temp;
+ int j;
+
while (i->name) {
Parrot_Int type = Parrot_PMC_typenum(PL_Parrot, i->name);
@@ -265,7 +269,20 @@
}
PL_pmcname[i->array_index] = type;
++i;
+ if (type > max_type)
+ max_type = type;
}
+
+ temp = malloc(max_type);
+ memset (temp, -1, max_type);
+
+ /* Build the reverse lookup table. */
+ j = Ponie_PMC_Perl5_MAX;
+ while (j--) {
+ temp[PL_pmcname[j]] = j;
+ }
+
+ PL_pmc_to_type = temp;
}
#ifdef USE_ITHREADS
MUTEX_UNLOCK(&PL_pmcname_mutex);
1.11 +2 -0 ponie/perl/perlapi.h
Index: perlapi.h
===================================================================
RCS file: /cvs/public/ponie/perl/perlapi.h,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -r1.10 -r1.11
--- perlapi.h 28 Apr 2005 22:52:11 -0000 1.10
+++ perlapi.h 29 Apr 2005 13:26:29 -0000 1.11
@@ -939,6 +939,8 @@
#define PL_op_mutex (*Perl_Gop_mutex_ptr(NULL))
#undef PL_patleave
#define PL_patleave (*Perl_Gpatleave_ptr(NULL))
+#undef PL_pmc_to_type
+#define PL_pmc_to_type (*Perl_Gpmc_to_type_ptr(NULL))
#undef PL_pmcname
#define PL_pmcname (*Perl_Gpmcname_ptr(NULL))
#undef PL_pmcname_mutex
1.5 +2 -0 ponie/perl/perlvars.h
Index: perlvars.h
===================================================================
RCS file: /cvs/public/ponie/perl/perlvars.h,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- perlvars.h 4 Apr 2005 17:46:12 -0000 1.4
+++ perlvars.h 29 Apr 2005 13:26:29 -0000 1.5
@@ -71,6 +71,8 @@
/* Cached names for PMC types */
PERLVARI(Gpmcname[Ponie_PMC_Perl5_MAX], Parrot_Int, {0})
+/* A reverse lookup table to convert parrot types back to Perl 5 types. */
+PERLVAR(Gpmc_to_type, const signed char *)
#ifndef PERL_USE_SAFE_PUTENV
PERLVARI(Guse_safe_putenv, int, 1)