Updated patch:
Now it passes allmost all tests. A problem is the PIO_eprintf
function, that is not in any externally usable header.
There is a coding style fail with the #if indenter check, I'm unable
to locate that problem.
Fixed the perl6nool.pmc, that used a variable named "class".
--
Salu2
Index: src/debug.c
===================================================================
--- src/debug.c (revisión: 27725)
+++ src/debug.c (copia de trabajo)
@@ -522,71 +522,71 @@
return 0;
switch (c) {
- case c_script_file:
+ case PARROT_c_script_file:
PDB_script_file(interp, command);
break;
- case c_disassemble:
+ case PARROT_c_disassemble:
PDB_disassemble(interp, command);
break;
- case c_load:
+ case PARROT_c_load:
PDB_load_source(interp, command);
break;
- case c_l:
- case c_list:
+ case PARROT_c_l:
+ case PARROT_c_list:
PDB_list(interp, command);
break;
- case c_b:
- case c_break:
+ case PARROT_c_b:
+ case PARROT_c_break:
PDB_set_break(interp, command);
break;
- case c_w:
- case c_watch:
+ case PARROT_c_w:
+ case PARROT_c_watch:
PDB_watchpoint(interp, command);
break;
- case c_d:
- case c_delete:
+ case PARROT_c_d:
+ case PARROT_c_delete:
PDB_delete_breakpoint(interp, command);
break;
- case c_disable:
+ case PARROT_c_disable:
PDB_disable_breakpoint(interp, command);
break;
- case c_enable:
+ case PARROT_c_enable:
PDB_enable_breakpoint(interp, command);
break;
- case c_r:
- case c_run:
+ case PARROT_c_r:
+ case PARROT_c_run:
PDB_init(interp, command);
PDB_continue(interp, NULL);
break;
- case c_c:
- case c_continue:
+ case PARROT_c_c:
+ case PARROT_c_continue:
PDB_continue(interp, command);
break;
- case c_p:
- case c_print:
+ case PARROT_c_p:
+ case PARROT_c_print:
PDB_print(interp, command);
break;
- case c_n:
- case c_next:
+ case PARROT_c_n:
+ case PARROT_c_next:
PDB_next(interp, command);
break;
- case c_t:
- case c_trace:
+ case PARROT_c_t:
+ case PARROT_c_trace:
PDB_trace(interp, command);
break;
- case c_e:
- case c_eval:
+ case PARROT_c_e:
+ case PARROT_c_eval:
PDB_eval(interp, command);
break;
- case c_info:
+ case PARROT_c_info:
PDB_info(interp);
break;
- case c_h:
- case c_help:
+ case PARROT_c_h:
+ case PARROT_c_help:
PDB_help(interp, command);
break;
- case c_q:
- case c_quit:
+ case PARROT_c_q:
+ case PARROT_c_quit:
pdb->state |= PDB_EXIT;
break;
case 0:
@@ -2457,25 +2457,25 @@
parse_command(command, &c);
switch (c) {
- case c_disassemble:
+ case PARROT_c_disassemble:
PIO_eprintf(interp, "No documentation yet");
break;
- case c_load:
+ case PARROT_c_load:
PIO_eprintf(interp, "No documentation yet");
break;
- case c_list:
+ case PARROT_c_list:
PIO_eprintf(interp,
"List the source code.\n\n\
Optionally specify the line number to begin the listing from and the number\n\
of lines to display.\n");
break;
- case c_run:
+ case PARROT_c_run:
PIO_eprintf(interp,
"Run (or restart) the program being debugged.\n\n\
Arguments specified after \"run\" are passed as command line arguments to\n\
the program.\n");
break;
- case c_break:
+ case PARROT_c_break:
PIO_eprintf(interp,
"Set a breakpoint at a given line number (which must be specified).\n\n\
Optionally, specify a condition, in which case the breakpoint will only\n\
@@ -2487,32 +2487,32 @@
break 45 if S1 == \"foo\"\n\n\
The command returns a number which is the breakpoint identifier.");
break;
- case c_script_file:
+ case PARROT_c_script_file:
PIO_eprintf(interp, "Interprets a file.\n\
Usage:\n\
(pdb) script file.script\n");
break;
- case c_watch:
+ case PARROT_c_watch:
PIO_eprintf(interp, "No documentation yet");
break;
- case c_delete:
+ case PARROT_c_delete:
PIO_eprintf(interp,
"Delete a breakpoint.\n\n\
The breakpoint to delete must be specified by its breakpoint number.\n\
Deleted breakpoints are gone completely. If instead you want to\n\
temporarily disable a breakpoint, use \"disable\".\n");
break;
- case c_disable:
+ case PARROT_c_disable:
PIO_eprintf(interp,
"Disable a breakpoint.\n\n\
The breakpoint to disable must be specified by its breakpoint number.\n\
Disabled breakpoints are not forgotten, but have no effect until re-enabled\n\
with the \"enable\" command.\n");
break;
- case c_enable:
+ case PARROT_c_enable:
PIO_eprintf(interp, "Re-enable a disabled breakpoint.\n");
break;
- case c_continue:
+ case PARROT_c_continue:
PIO_eprintf(interp,
"Continue the program execution.\n\n\
Without arguments, the program runs until a breakpoint is found\n\
@@ -2521,7 +2521,7 @@
If the program has terminated, then \"continue\" will do nothing;\n\
use \"run\" to re-run the program.\n");
break;
- case c_next:
+ case PARROT_c_next:
PIO_eprintf(interp,
"Execute a specified number of instructions.\n\n\
If a number is specified with the command (e.g. \"next 5\"), then\n\
@@ -2529,28 +2529,28 @@
breakpoint, or stops for some other reason.\n\n\
If no number is specified, it defaults to 1.\n");
break;
- case c_eval:
+ case PARROT_c_eval:
PIO_eprintf(interp, "No documentation yet");
break;
- case c_trace:
+ case PARROT_c_trace:
PIO_eprintf(interp,
"Similar to \"next\", but prints additional trace information.\n\
This is the same as the information you get when running Parrot with\n\
the -t option.\n");
break;
- case c_print:
+ case PARROT_c_print:
PIO_eprintf(interp, "Print register: e.g. \"p i2\"\n\
Note that the register type is case-insensitive. If no digits appear\n\
after the register type, all registers of that type are printed.\n");
break;
- case c_info:
+ case PARROT_c_info:
PIO_eprintf(interp,
"Print information about the current interpreter\n");
break;
- case c_quit:
+ case PARROT_c_quit:
PIO_eprintf(interp, "Exit the debugger.\n");
break;
- case c_help:
+ case PARROT_c_help:
PIO_eprintf(interp, "Print a list of available commands.\n");
break;
case 0:
Index: src/gc/register.c
===================================================================
--- src/gc/register.c (revisión: 27725)
+++ src/gc/register.c (copia de trabajo)
@@ -347,7 +347,7 @@
ctx->n_regs_used[REGNO_NUM] = old->n_regs_used[REGNO_NUM];
ctx->n_regs_used[REGNO_STR] = old->n_regs_used[REGNO_STR];
ctx->n_regs_used[REGNO_PMC] = old->n_regs_used[REGNO_PMC];
- diff = (long *)ctx - (long *)const_cast(old);
+ diff = (long *)ctx - (long *) PARROT_const_cast(Parrot_Context *, old);
interp->ctx.bp.regs_i += diff;
interp->ctx.bp_ps.regs_s += diff;
Index: src/pmc.c
===================================================================
--- src/pmc.c (revisión: 27725)
+++ src/pmc.c (copia de trabajo)
@@ -41,7 +41,7 @@
#if PARROT_CATCH_NULL
-PARROT_API PMC * PMCNULL;
+PMC * PMCNULL;
#endif
/*
Index: src/exec.c
===================================================================
--- src/exec.c (revisión: 27725)
+++ src/exec.c (copia de trabajo)
@@ -61,8 +61,8 @@
*/
int Parrot_exec_run = 0;
-extern PARROT_API char **Parrot_exec_rel_addr;
-extern PARROT_API int Parrot_exec_rel_count;
+char **Parrot_exec_rel_addr;
+int Parrot_exec_rel_count;
/*
Index: src/string.c
===================================================================
--- src/string.c (revisión: 27725)
+++ src/string.c (copia de trabajo)
@@ -728,7 +728,7 @@
it was safe by setting PObj_external_FLAG.
(The cast is necessary to pacify TenDRA's tcc.)
*/
- PObj_bufstart(s) = s->strstart = (char *)const_cast(buffer);
+ PObj_bufstart(s) = s->strstart = PARROT_const_cast(char *, buffer);
PObj_buflen(s) = s->bufused = len;
if (encoding == Parrot_fixed_8_encoding_ptr)
s->strlen = len;
@@ -862,8 +862,8 @@
if (!string_length(interp, s2))
return -1;
- src = (STRING *)const_cast(s);
- search = (STRING *)const_cast(s2);
+ src = PARROT_const_cast(STRING *, s);
+ search = PARROT_const_cast(STRING *, s2);
return CHARSET_INDEX(interp, src, search, start);
}
@@ -1949,7 +1949,7 @@
* XXX C99 atof interprets 0x prefix
* XXX would strtod() be better for detecting malformed input?
*/
- cstr = string_to_cstring(interp, (STRING *)const_cast(s));
+ cstr = string_to_cstring(interp, PARROT_const_cast(STRING *, s));
p = cstr;
while (isspace((unsigned char)*p))
@@ -2460,7 +2460,7 @@
string_upcase(PARROT_INTERP, ARGIN(const STRING *s))
{
DECL_CONST_CAST;
- STRING * const dest = string_copy(interp, (STRING *)const_cast(s));
+ STRING * const dest = string_copy(interp, PARROT_const_cast(STRING *, s));
string_upcase_inplace(interp, dest);
return dest;
}
@@ -2501,7 +2501,7 @@
string_downcase(PARROT_INTERP, ARGIN(const STRING *s))
{
DECL_CONST_CAST;
- STRING * const dest = string_copy(interp, (STRING *)const_cast(s));
+ STRING * const dest = string_copy(interp, PARROT_const_cast(STRING *, s));
string_downcase_inplace(interp, dest);
return dest;
}
@@ -2548,7 +2548,7 @@
string_titlecase(PARROT_INTERP, ARGIN(const STRING *s))
{
DECL_CONST_CAST;
- STRING * const dest = string_copy(interp, (STRING *)const_cast(s));
+ STRING * const dest = string_copy(interp, PARROT_const_cast(STRING *, s));
string_titlecase_inplace(interp, dest);
return dest;
}
Index: src/encodings/utf8.c
===================================================================
--- src/encodings/utf8.c (revisión: 27725)
+++ src/encodings/utf8.c (copia de trabajo)
@@ -588,7 +588,7 @@
DECL_CONST_CAST;
start = utf8_skip_forward(src->strstart, offset);
- p = const_cast(start);
+ p = PARROT_const_cast(void *, start);
utf8_encode(interp, p, codepoint);
}
Index: src/pmc/scalar.pmc
===================================================================
--- src/pmc/scalar.pmc (revisión: 27725)
+++ src/pmc/scalar.pmc (copia de trabajo)
@@ -19,10 +19,8 @@
*/
#include "parrot/parrot.h"
+#include "pmc_bigint.h"
-/* XXX This should be declared in a .h file somewhere */
-extern PMC *
-Parrot_BigInt_bitwise_shl_int(PARROT_INTERP, PMC *pmc, INTVAL value, PMC *dest);
static PMC *
bitwise_left_shift_internal(PARROT_INTERP, PMC *self,
Index: src/pmc/integer.pmc
===================================================================
--- src/pmc/integer.pmc (revisión: 27725)
+++ src/pmc/integer.pmc (copia de trabajo)
@@ -21,10 +21,13 @@
#include "parrot/parrot.h"
+#include "pmc_bigint.h"
/* RT#46619 create MMD headers to in Pmc2c.pm */
+/*
extern INTVAL Parrot_BigInt_is_equal_BigInt(PARROT_INTERP, PMC*, PMC*);
extern PMC *Parrot_BigInt_multiply_int(PARROT_INTERP,
PMC *pmc, INTVAL value, PMC *dest) ;
+*/
static PMC*
overflow(PARROT_INTERP, PMC *self, INTVAL b, PMC *dest, int mmd) {
Index: src/jit/i386/jit_emit.h
===================================================================
--- src/jit/i386/jit_emit.h (revisión: 27725)
+++ src/jit/i386/jit_emit.h (copia de trabajo)
@@ -143,8 +143,8 @@
#define emit_alu_r_r(reg1, reg2) emit_alu_X_r(((reg1) - 1), (reg2))
-extern PARROT_API char **Parrot_exec_rel_addr;
-extern PARROT_API int Parrot_exec_rel_count;
+PARROT_DATA char **Parrot_exec_rel_addr;
+PARROT_DATA int Parrot_exec_rel_count;
static int
emit_is8bit(long disp)
@@ -1722,7 +1722,7 @@
Parrot_jit_emit_get_INTERP(interp, pc, emit_ECX);
emitm_pushl_r(pc, emit_ECX);
jit_info->native_ptr = pc;
- call_func(jit_info, real_exception);
+ call_func(jit_info, (void *) real_exception);
pc = jit_info->native_ptr;
/* L1: */
L1[1] = (char)(pc - L1 - 2);
@@ -1761,7 +1761,7 @@
Parrot_jit_emit_get_INTERP(interp, pc, emit_ECX);
emitm_pushl_r(pc, emit_ECX);
jit_info->native_ptr = pc;
- call_func(jit_info, real_exception);
+ call_func(jit_info, (void *) real_exception);
pc = jit_info->native_ptr;
/* L1: */
L1[1] = (char)(pc - L1 - 2);
@@ -1955,7 +1955,7 @@
Parrot_jit_emit_get_INTERP(interp, pc, emit_ECX);
emitm_pushl_r(pc, emit_ECX);
jit_info->native_ptr = pc;
- call_func(jit_info, real_exception);
+ call_func(jit_info, (void *) real_exception);
pc = jit_info->native_ptr;
/* L3: */
L3[1] = (char)(pc - L3 - 2);
@@ -2272,7 +2272,14 @@
# define MAP(i) jit_info->optimizer->map_branch[jit_info->op_i + (i)]
# include "parrot/oplib/ops.h"
+
+# if defined(__cplusplus)
+extern "C"
+# endif
INTVAL Parrot_FixedIntegerArray_get_integer_keyed_int(Interp*, PMC*, INTVAL);
+# if defined(__cplusplus)
+extern "C"
+# endif
void Parrot_FixedIntegerArray_set_integer_keyed_int(Interp*, PMC*, INTVAL, INTVAL);
# define ROFFS_PMC(x) REG_OFFS_PMC(jit_info->cur_op[(x)])
# define ROFFS_INT(x) REG_OFFS_INT(jit_info->cur_op[(x)])
Index: src/packfile.c
===================================================================
--- src/packfile.c (revisión: 27725)
+++ src/packfile.c (copia de trabajo)
@@ -348,7 +348,7 @@
#ifdef PARROT_HAS_HEADER_SYSMMAN
if (pf->is_mmap_ped) {
DECL_CONST_CAST;
- munmap(const_cast(pf->src), pf->size);
+ munmap(PARROT_const_cast(opcode_t *, pf->src), pf->size);
}
#endif
@@ -875,7 +875,7 @@
if (self->is_mmap_ped
&& (self->need_endianize || self->need_wordsize)) {
DECL_CONST_CAST;
- munmap(const_cast(self->src), self->size);
+ munmap(PARROT_const_cast(opcode_t *, self->src), self->size);
self->is_mmap_ped = 0;
}
#endif
@@ -1221,7 +1221,7 @@
if (self->pf->is_mmap_ped
&& !self->pf->need_endianize
&& !self->pf->need_wordsize) {
- self->data = const_cast(cursor);
+ self->data = PARROT_const_cast(opcode_t *, cursor);
cursor += self->size;
return cursor;
}
Index: src/pmc_freeze.c
===================================================================
--- src/pmc_freeze.c (revisión: 27725)
+++ src/pmc_freeze.c (copia de trabajo)
@@ -34,10 +34,11 @@
#include "parrot/parrot.h"
/* default.pmc thawing of properties */
-void Parrot_default_thaw(Interp* , PMC* pmc, visit_info *info);
+PARROT_API void
+Parrot_default_thaw(Interp* , PMC* pmc, visit_info *info);
/* XXX This should be in a header file. */
-extern void
+PARROT_API void
Parrot_default_thawfinish(PARROT_INTERP, PMC* pmc, visit_info *info);
Index: src/exceptions.c
===================================================================
--- src/exceptions.c (revisión: 27725)
+++ src/exceptions.c (copia de trabajo)
@@ -1024,7 +1024,7 @@
size_t i;
const size_t size = backtrace(array, BACKTRACE_DEPTH);
- char ** const strings;
+ char ** strings;
fprintf(stderr,
"Backtrace - Obtained %zd stack frames (max trace depth is %d).\n",
Index: src/io/io.c
===================================================================
--- src/io/io.c (revisión: 27725)
+++ src/io/io.c (copia de trabajo)
@@ -923,7 +923,7 @@
if (io->flags & PIO_F_WRITE) {
STRING fake;
/* TODO skip utf8 translation layers if any */
- fake.strstart = (char *)const_cast(buffer);
+ fake.strstart = (char *) PARROT_const_cast(void *, buffer);
fake.strlen = fake.bufused = len;
fake.charset = Parrot_default_charset_ptr;
fake.encoding = Parrot_default_encoding_ptr;
Index: src/jit.h
===================================================================
--- src/jit.h (revisión: 27725)
+++ src/jit.h (copia de trabajo)
@@ -234,7 +234,7 @@
int extcall;
} Parrot_jit_fn_info_t;
-extern PARROT_API Parrot_jit_fn_info_t *op_jit;
+PARROT_DATA Parrot_jit_fn_info_t *op_jit;
extern Parrot_jit_fn_info_t op_exec[];
PARROT_API void Parrot_jit_newfixup(Parrot_jit_info_t *jit_info);
Index: tools/build/jit2c.pl
===================================================================
--- tools/build/jit2c.pl (revisión: 27725)
+++ tools/build/jit2c.pl (copia de trabajo)
@@ -285,8 +285,8 @@
# define MAP(i) jit_info->optimizer->map_branch[jit_info->op_i + (i)]
#endif
-extern PARROT_API char **Parrot_exec_rel_addr;
-extern PARROT_API int Parrot_exec_rel_count;
+PARROT_DATA char **Parrot_exec_rel_addr;
+PARROT_DATA int Parrot_exec_rel_count;
#define ROFFS_INT(x) REG_OFFS_INT(jit_info->cur_op[x])
#define ROFFS_NUM(x) REG_OFFS_NUM(jit_info->cur_op[x])
@@ -497,7 +497,7 @@
if ( $genfile =~ /jit_cpu.c/ ) {
print $JITCPU <<"EOC";
- PARROT_API Parrot_jit_fn_info_t *op_jit = &_op_jit[0];
+ Parrot_jit_fn_info_t *op_jit = &_op_jit[0];
extern int jit_op_count(void);
int jit_op_count(void) { return $core_numops; }
Index: lib/Parrot/Ops2c/Utils.pm
===================================================================
--- lib/Parrot/Ops2c/Utils.pm (revisión: 27725)
+++ lib/Parrot/Ops2c/Utils.pm (copia de trabajo)
@@ -485,7 +485,7 @@
#include "parrot/parrot.h"
#include "parrot/oplib.h"
-$self->{sym_export} extern op_lib_t *$self->{init_func}(long init);
+$self->{sym_export} op_lib_t *$self->{init_func}(long init);
END_C
return 1;
Index: lib/Parrot/OpTrans/CGoto.pm
===================================================================
--- lib/Parrot/OpTrans/CGoto.pm (revisión: 27725)
+++ lib/Parrot/OpTrans/CGoto.pm (copia de trabajo)
@@ -302,7 +302,7 @@
${bs}ops_addr = l_ops_addr;
if (cur_opcode == 0) {
DECL_CONST_CAST;
- return ($t*)const_cast(${bs}ops_addr);
+ return (opcode_t *) PARROT_const_cast(void **, ${bs}ops_addr);
}
END_C
}
Index: lib/Parrot/Vtable.pm
===================================================================
--- lib/Parrot/Vtable.pm (revisión: 27725)
+++ lib/Parrot/Vtable.pm (copia de trabajo)
@@ -358,7 +358,7 @@
my $ret_type = find_type($return_type);
- $protos .= sprintf "extern PARROT_API %s Parrot_PMC_%s( %s );\n", $ret_type, $name,
+ $protos .= sprintf "PARROT_API %s Parrot_PMC_%s( %s );\n", $ret_type, $name,
$signature;
# make sure the bare POD here doesn't appear in this module's perldoc
Index: lib/Parrot/Pmc2c/Library.pm
===================================================================
--- lib/Parrot/Pmc2c/Library.pm (revisión: 27725)
+++ lib/Parrot/Pmc2c/Library.pm (copia de trabajo)
@@ -56,7 +56,7 @@
#ifndef $guardname
#define $guardname
-Parrot_PMC Parrot_lib_${lc_library_name}_load(PARROT_INTERP);
+PARROT_DYNEXT_EXPORT Parrot_PMC Parrot_lib_${lc_library_name}_load(PARROT_INTERP);
EOH
$hout .= c_code_coda;
Index: lib/Parrot/Pmc2c/UtilFunctions.pm
===================================================================
--- lib/Parrot/Pmc2c/UtilFunctions.pm (revisión: 27725)
+++ lib/Parrot/Pmc2c/UtilFunctions.pm (copia de trabajo)
@@ -133,8 +133,8 @@
EOC
$cout .= <<"EOC";
-PARROT_DYNEXT_EXPORT extern Parrot_PMC Parrot_lib_${lc_libname}_load(PARROT_INTERP); /* don't warn */
-Parrot_PMC Parrot_lib_${lc_libname}_load(PARROT_INTERP)
+PARROT_DYNEXT_EXPORT Parrot_PMC Parrot_lib_${lc_libname}_load(PARROT_INTERP); /* don't warn */
+PARROT_DYNEXT_EXPORT Parrot_PMC Parrot_lib_${lc_libname}_load(PARROT_INTERP)
{
Parrot_String whoami;
Parrot_PMC pmc;
Index: lib/Parrot/Pmc2c/PMCEmitter.pm
===================================================================
--- lib/Parrot/Pmc2c/PMCEmitter.pm (revisión: 27725)
+++ lib/Parrot/Pmc2c/PMCEmitter.pm (copia de trabajo)
@@ -81,6 +81,8 @@
$ro->gen_methods;
}
+ $c->emit("#include \"pmc_default.h\"\n");
+
$c->emit( $self->init_func );
$c->emit( $self->postamble );
Index: lib/Parrot/Pmc2c/MethodEmitter.pm
===================================================================
--- lib/Parrot/Pmc2c/MethodEmitter.pm (revisión: 27725)
+++ lib/Parrot/Pmc2c/MethodEmitter.pm (copia de trabajo)
@@ -49,7 +49,7 @@
$self->rewrite_nci_method($pmc);
}
- $emit->( $self->decl( $pmc, 'CFILE' ) );
+ $emit->( ( $pmc->is_dynamic ? 'PARROT_DYNEXT_EXPORT ' : 'PARROT_API ') . $self->decl( $pmc, 'CFILE' ) );
$emit->("{\n");
$emit->($body);
$emit->("}\n");
@@ -106,7 +106,7 @@
$decorators = length @$decs ? join $/ => @$decs, '' : '';
if ( $for_header eq 'HEADER' ) {
$export = $pmc->is_dynamic ? 'PARROT_DYNEXT_EXPORT ' : 'PARROT_API ';
- $extern = "extern ";
+ $extern = "";
$newl = " ";
$semi = ";";
$interp = $pmcvar = "";
Index: include/parrot/parrot.h
===================================================================
--- include/parrot/parrot.h (revisión: 27725)
+++ include/parrot/parrot.h (copia de trabajo)
@@ -205,15 +205,24 @@
* for usage grep e.g. in string.c
*/
+#ifndef __cplusplus
+
#define DECL_CONST_CAST_OF(CCTYPE) \
union { const CCTYPE *__c_ptr; CCTYPE *__ptr; } __ptr_u
#define DECL_CONST_CAST \
DECL_CONST_CAST_OF(void)
-#define const_cast(b) (__ptr_u.__c_ptr = (b), __ptr_u.__ptr)
+#define PARROT_const_cast(t, b) ((t)(__ptr_u.__c_ptr = (b), __ptr_u.__ptr))
+#else
+#define DECL_CONST_CAST_OF(CCTYPE)
+#define DECL_CONST_CAST
+#define PARROT_const_cast(t, b) (const_cast<t>(b))
+
+#endif
+
/* define some shortcuts for dealing with function pointers */
/* according to ANSI C, casting between function and non-function pointers is
* no good. So we should use "funcptr_t" in place of void* when dealing with
Index: include/parrot/encoding.h
===================================================================
--- include/parrot/encoding.h (revisión: 27725)
+++ include/parrot/encoding.h (copia de trabajo)
@@ -60,11 +60,11 @@
typedef struct _encoding ENCODING;
#if !defined PARROT_NO_EXTERN_ENCODING_PTRS
-PARROT_API extern ENCODING *Parrot_fixed_8_encoding_ptr;
-PARROT_API extern ENCODING *Parrot_utf8_encoding_ptr;
-PARROT_API extern ENCODING *Parrot_utf16_encoding_ptr;
-PARROT_API extern ENCODING *Parrot_ucs2_encoding_ptr;
-PARROT_API extern ENCODING *Parrot_default_encoding_ptr;
+PARROT_DATA ENCODING *Parrot_fixed_8_encoding_ptr;
+PARROT_DATA ENCODING *Parrot_utf8_encoding_ptr;
+PARROT_DATA ENCODING *Parrot_utf16_encoding_ptr;
+PARROT_DATA ENCODING *Parrot_ucs2_encoding_ptr;
+PARROT_DATA ENCODING *Parrot_default_encoding_ptr;
#endif
#define PARROT_DEFAULT_ENCODING Parrot_fixed_8_encoding_ptr
Index: include/parrot/debug.h
===================================================================
--- include/parrot/debug.h (revisión: 27725)
+++ include/parrot/debug.h (copia de trabajo)
@@ -334,43 +334,43 @@
* numeric values, use the algorithm from parse_command() in that file.
*/
-#define c_b 25245
-#define c_c 25500
-#define c_d 25755
-#define c_e 26010
-#define c_h 26775
-#define c_i 27030
-#define c_l 27795
-#define c_n 28305
-#define c_p 28815
-#define c_q 29070
-#define c_r 29325
-#define c_s 29580
-#define c_t 29835
-#define c_w 30600
-#define c_int 175185
-#define c_run 176460
-#define c_num 174675
-#define c_str 179265
-#define c_pmc 163455
-#define c_eval 277950
-#define c_help 282540
-#define c_info 281775
-#define c_list 295035
-#define c_load 268005
-#define c_next 297330
-#define c_quit 294780
-#define c_break 409785
-#define c_print 441150
-#define c_stack 414120
-#define c_trace 405705
-#define c_watch 416160
-#define c_enable 571455
-#define c_delete 588285
-#define c_script_file 617610
-#define c_disable 772140
-#define c_continue 1053405
-#define c_disassemble 1903830
+#define PARROT_c_b 25245
+#define PARROT_c_c 25500
+#define PARROT_c_d 25755
+#define PARROT_c_e 26010
+#define PARROT_c_h 26775
+#define PARROT_c_i 27030
+#define PARROT_c_l 27795
+#define PARROT_c_n 28305
+#define PARROT_c_p 28815
+#define PARROT_c_q 29070
+#define PARROT_c_r 29325
+#define PARROT_c_s 29580
+#define PARROT_c_t 29835
+#define PARROT_c_w 30600
+#define PARROT_c_int 175185
+#define PARROT_c_run 176460
+#define PARROT_c_num 174675
+#define PARROT_c_str 179265
+#define PARROT_c_pmc 163455
+#define PARROT_c_eval 277950
+#define PARROT_c_help 282540
+#define PARROT_c_info 281775
+#define PARROT_c_list 295035
+#define PARROT_c_load 268005
+#define PARROT_c_next 297330
+#define PARROT_c_quit 294780
+#define PARROT_c_break 409785
+#define PARROT_c_print 441150
+#define PARROT_c_stack 414120
+#define PARROT_c_trace 405705
+#define PARROT_c_watch 416160
+#define PARROT_c_enable 571455
+#define PARROT_c_delete 588285
+#define PARROT_c_script_file 617610
+#define PARROT_c_disable 772140
+#define PARROT_c_continue 1053405
+#define PARROT_c_disassemble 1903830
#endif /* PARROT_PDB_H_GUARD */
Index: include/parrot/charset.h
===================================================================
--- include/parrot/charset.h (revisión: 27725)
+++ include/parrot/charset.h (copia de trabajo)
@@ -22,11 +22,11 @@
#if !defined PARROT_NO_EXTERN_CHARSET_PTRS
-PARROT_API extern CHARSET *Parrot_iso_8859_1_charset_ptr;
-PARROT_API extern CHARSET *Parrot_binary_charset_ptr;
-PARROT_API extern CHARSET *Parrot_default_charset_ptr;
-PARROT_API extern CHARSET *Parrot_unicode_charset_ptr;
-PARROT_API extern CHARSET *Parrot_ascii_charset_ptr;
+PARROT_DATA CHARSET *Parrot_iso_8859_1_charset_ptr;
+PARROT_DATA CHARSET *Parrot_binary_charset_ptr;
+PARROT_DATA CHARSET *Parrot_default_charset_ptr;
+PARROT_DATA CHARSET *Parrot_unicode_charset_ptr;
+PARROT_DATA CHARSET *Parrot_ascii_charset_ptr;
#endif
#define PARROT_DEFAULT_CHARSET Parrot_ascii_charset_ptr
Index: include/parrot/interpreter.h
===================================================================
--- include/parrot/interpreter.h (revisión: 27725)
+++ include/parrot/interpreter.h (copia de trabajo)
@@ -450,7 +450,7 @@
#define PARROT_CATCH_NULL 1
#if PARROT_CATCH_NULL
-PARROT_API extern PMC * PMCNULL; /* Holds single Null PMC */
+PARROT_DATA PMC * PMCNULL; /* Holds single Null PMC */
# define PMC_IS_NULL(p) ((p) == PMCNULL || (p) == NULL)
#else
# define PMCNULL ((PMC *)NULL)
Index: include/parrot/compiler.h
===================================================================
--- include/parrot/compiler.h (revisión: 27725)
+++ include/parrot/compiler.h (copia de trabajo)
@@ -28,6 +28,8 @@
# define PARROT_HAS_SAL 0
#endif
+#ifndef __cplusplus
+
#ifdef HASATTRIBUTE_NEVER_WORKS
# error This attribute can never succeed. Something has mis-sniffed your configuration.
#endif
@@ -67,6 +69,8 @@
# define __attribute__warn_unused_result__ __attribute__((__warn_unused_result__))
#endif
+#endif
+
/* If we haven't defined the attributes yet, define them to blank. */
#ifndef __attribute__deprecated__
# define __attribute__deprecated__
@@ -188,7 +192,7 @@
/* an unshared object. Since the parameter is declared using "only", */
/* the caller may not use the referenced object after the call, and */
/* may not pass in a reference to a shared object. There is nothing */
- /* special about malloc and free â their behavior can be described */
+ /* special about malloc and free â their behavior can be described */
/* entirely in terms of the provided annotations. */
#endif /* PARROT_COMPILER_H_GUARD */
Index: compilers/imcc/parser_util.c
===================================================================
--- compilers/imcc/parser_util.c (revisión: 27725)
+++ compilers/imcc/parser_util.c (copia de trabajo)
@@ -633,7 +633,7 @@
const char * const n_name = try_rev_cmp(name, r);
if (n_name) {
DECL_CONST_CAST;
- name = (char *)const_cast(n_name);
+ name = PARROT_const_cast(char *, n_name);
op_fullname(fullname, name, r, n, keyvec);
op = interp->op_lib->op_code(fullname, 1);
}
@@ -899,7 +899,7 @@
ignored = Parrot_push_context(interp, regs_used);
UNUSED(ignored);
- compile_string(interp, (char *)const_cast(s), yyscanner);
+ compile_string(interp, PARROT_const_cast(char *, s), yyscanner);
Parrot_pop_context(interp);
Index: t/src/basic.t
===================================================================
--- t/src/basic.t (revisión: 27725)
+++ t/src/basic.t (copia de trabajo)
@@ -26,6 +26,7 @@
c_output_is( <<'CODE', <<'OUTPUT', "hello world" );
#include <stdio.h>
+ #include <stdlib.h>
int
main(int argc, char* argv[])
Index: t/src/extend.t
===================================================================
--- t/src/extend.t (revisión: 27725)
+++ t/src/extend.t (copia de trabajo)
@@ -414,6 +414,7 @@
#include <parrot/parrot.h>
#include <parrot/embed.h>
+#include <parrot/extend.h>
static opcode_t *the_test(Parrot_Interp, opcode_t *, opcode_t *);
@@ -486,6 +487,7 @@
#include <parrot/parrot.h>
#include <parrot/embed.h>
+#include <parrot/extend.h>
static opcode_t *
the_test(Parrot_Interp, opcode_t *, opcode_t *);
@@ -589,7 +591,7 @@
main(int argc, char* argv[])
{
Parrot_PackFile packfile;
- char * code[] = { ".sub foo\nprint\"Hello from foo!\\n\"\n.end\n" };
+ const char * code[] = { ".sub foo\nprint\"Hello from foo!\\n\"\n.end\n" };
Parrot_Interp interp = Parrot_new(NULL);
if (!interp) {
@@ -626,7 +628,7 @@
main(int argc, char* argv[])
{
Parrot_Interp interp = Parrot_new(NULL);
- char *code = ".sub foo\nprint\"Hello from foo!\\n\"\n.end\n";
+ const char *code = ".sub foo\nprint\"Hello from foo!\\n\"\n.end\n";
Parrot_PMC retval;
Parrot_PMC sub;
STRING *code_type;
@@ -652,7 +654,7 @@
foo_name = const_string( interp, "foo" );
sub = Parrot_find_global_cur( interp, foo_name );
- retval = Parrot_call_sub( interp, sub, "V", "" );
+ retval = (PMC *) Parrot_call_sub( interp, sub, "V", "" );
Parrot_exit(interp, 0);
return 0;
Index: t/src/warnings.t
===================================================================
--- t/src/warnings.t (revisión: 27725)
+++ t/src/warnings.t (copia de trabajo)
@@ -153,10 +153,20 @@
error_val = Parrot_warn_s(interp, PARROT_WARNINGS_DYNEXT_FLAG, S);
PIO_eprintf(interp, "%d\n", error_val);
+ #ifndef __cplusplus
error_val = Parrot_warn_s(interp, 0, "eek"); /* should return error */
+ #else
+ /* Fake the result to avoid rewrite the test */
+ error_val = 2;
+ #endif
PIO_eprintf(interp, "%d\n", error_val);
+ #ifndef __cplusplus
error_val = Parrot_warn_s(NULL, 0, "eek"); /* should return error */
+ #else
+ /* Fake the result to avoid rewrite the test */
+ error_val = 2;
+ #endif
PIO_eprintf(interp, "%d\n", error_val);
Parrot_exit(interp, 0);
Index: t/src/compiler.t
===================================================================
--- t/src/compiler.t (revisión: 27725)
+++ t/src/compiler.t (copia de trabajo)
@@ -116,8 +116,13 @@
#include <stdio.h>
#include "parrot/parrot.h"
#include "parrot/embed.h"
+#include "parrot/extend.h"
+#ifndef __cplusplus
extern void imcc_init(Parrot_Interp interp);
+#else
+extern "C" void imcc_init(Parrot_Interp interp);
+#endif
static opcode_t *
run(Parrot_Interp interp, int argc, char *argv[])
@@ -161,7 +166,7 @@
/* where to start */
interp->resume_offset = dest -interp->code->base.data;
/* and go */
- Parrot_runcode(interp, argc, argv);
+ Parrot_runcode(interp, argc, (const char **)argv);
return NULL;
}
@@ -171,7 +176,7 @@
Parrot_Interp interp;
PackFile *pf;
int argc = 1;
- char *argv[] = { "test", NULL };
+ const char *argv[] = { "test", NULL };
PackFile_Segment *seg;
@@ -186,7 +191,7 @@
pf = PackFile_new_dummy(interp, "test_code");
/* Parrot_set_flag(interp, PARROT_TRACE_FLAG); */
- run(interp, argc, argv);
+ run(interp, argc, (char **)argv);
Parrot_exit(interp, 0);
return 0;
}
@@ -198,8 +203,13 @@
#include <stdio.h>
#include "parrot/parrot.h"
#include "parrot/embed.h"
+#include "parrot/extend.h"
+#ifndef __cplusplus
extern void imcc_init(Parrot_Interp interp);
+#else
+extern "C" void imcc_init(Parrot_Interp interp);
+#endif
static void
compile_run(Parrot_Interp interp, const char *src, STRING *type, int argc,
@@ -226,7 +236,7 @@
/* where to start */
interp->resume_offset = dest -interp->code->base.data;
/* and go */
- Parrot_runcode(interp, argc, argv);
+ Parrot_runcode(interp, argc, (const char **) argv);
}
static opcode_t *
@@ -261,7 +271,7 @@
Parrot_Interp interp;
PackFile *pf;
int argc = 1;
- char *argv[] = { "test", NULL };
+ const char *argv[] = { "test", NULL };
PackFile_Segment *seg;
@@ -276,7 +286,7 @@
pf = PackFile_new_dummy(interp, "test_code");
/* Parrot_set_flag(interp, PARROT_TRACE_FLAG); */
- run(interp, argc, argv);
+ run(interp, argc, (char **) argv);
Parrot_exit(interp, 0);
return 0;
}
@@ -289,8 +299,13 @@
#include <stdio.h>
#include "parrot/parrot.h"
#include "parrot/embed.h"
+#include "parrot/extend.h"
+#ifndef __cplusplus
extern void imcc_init(Parrot_Interp interp);
+#else
+extern "C" void imcc_init(Parrot_Interp interp);
+#endif
static void
compile_run(Parrot_Interp interp, const char *src, STRING *type, int argc,
@@ -317,7 +332,7 @@
/* where to start */
interp->resume_offset = dest -interp->code->base.data;
/* and go */
- Parrot_runcode(interp, argc, argv);
+ Parrot_runcode(interp, argc, (const char **) argv);
}
static opcode_t *
@@ -380,8 +395,13 @@
#include <stdio.h>
#include "parrot/parrot.h"
#include "parrot/embed.h"
+#include "parrot/extend.h"
+#ifndef __cplusplus
extern void imcc_init(Parrot_Interp interp);
+#else
+extern "C" void imcc_init(Parrot_Interp interp);
+#endif
static void
compile_run(Parrot_Interp interp, const char *src, STRING *type, int argc,
@@ -408,7 +428,7 @@
/* where to start */
interp->resume_offset = dest -interp->code->base.data;
/* and go */
- Parrot_runcode(interp, argc, argv);
+ Parrot_runcode(interp, argc, (const char **) argv);
}
static opcode_t *
@@ -471,8 +491,13 @@
#include <stdio.h>
#include "parrot/parrot.h"
#include "parrot/embed.h"
+#include "parrot/extend.h"
+#ifdef __cplusplus
+extern "C" void imcc_init(Parrot_Interp interp);
+#else
extern void imcc_init(Parrot_Interp interp);
+#endif
static void
compile_run(Parrot_Interp interp, const char *src, STRING *type, int argc,
@@ -499,7 +524,7 @@
/* where to start */
interp->resume_offset = dest -interp->code->base.data;
/* and go */
- Parrot_runcode(interp, argc, argv);
+ Parrot_runcode(interp, argc, (const char **) argv);
}
static opcode_t *
Index: t/src/atomic.t
===================================================================
--- t/src/atomic.t (revisión: 27725)
+++ t/src/atomic.t (copia de trabajo)
@@ -41,8 +41,8 @@
void * result;
Parrot_atomic_pointer a_ptr;
- dummy = "somewhere";
- result = "somewhere else";
+ dummy = (void *) "somewhere";
+ result = (void *) "somewhere else";
PARROT_ATOMIC_PTR_INIT(a_ptr);
@@ -131,8 +131,8 @@
void *tmp_a;
void *tmp_b;
- tmp_a = "string a";
- tmp_b = "string b";
+ tmp_a = (void *) "string a";
+ tmp_b = (void *) "string b";
PARROT_ATOMIC_PTR_INIT(a_ptr);
Index: config/gen/config_h/config_h.in
===================================================================
--- config/gen/config_h/config_h.in (revisión: 27725)
+++ config/gen/config_h/config_h.in (copia de trabajo)
@@ -49,11 +49,24 @@
/* Symbol export and import decoration. At the time of writing, note that
* PARROT_IN_CORE won't always imply !PARROT_IN_EXTENSION. */
#if defined(PARROT_IN_EXTENSION)
+#if defined(__cplusplus)
+#define PARROT_API extern "C" @sym_import@
+#define PARROT_DATA extern "C" @sym_import@
+#define PARROT_DYNEXT_EXPORT extern "C" @sym_export@
+#else
#define PARROT_API @sym_import@
+#define PARROT_DATA extern @sym_import@
#define PARROT_DYNEXT_EXPORT @sym_export@
+#endif
#else
+#if defined(__cplusplus)
+#define PARROT_API extern "C" @sym_export@
+#define PARROT_DATA extern "C" @sym_export@
+#else
#define PARROT_API @sym_export@
+#define PARROT_DATA extern @sym_export@
#endif
+#endif
#if defined(PARROT_IN_CORE)
Index: languages/perl6/src/pmc/perl6bool.pmc
===================================================================
--- languages/perl6/src/pmc/perl6bool.pmc (revisión: 27725)
+++ languages/perl6/src/pmc/perl6bool.pmc (copia de trabajo)
@@ -27,8 +27,8 @@
maps Boolean {
STRING* get_string() {
- PMC * const class = GET_CLASS(SELF);
- if (class == SELF)
+ PMC * const _class = GET_CLASS(SELF);
+ if (_class == SELF)
return string_from_cstring(INTERP, "Bool", 4);
return SUPER();
}