Skip to content

Commit

Permalink
Continuing Parrot/C++ cleanups (Steve Peters, RT #42746).
Browse files Browse the repository at this point in the history
git-svn-id: https://svn.parrot.org/parrot/trunk@18339 d31e2699-5ff4-0310-a27c-f18f2fbe73fe
  • Loading branch information
chromatic committed Apr 26, 2007
1 parent 368e650 commit e063e49
Show file tree
Hide file tree
Showing 44 changed files with 221 additions and 224 deletions.
6 changes: 3 additions & 3 deletions include/parrot/events.h
Expand Up @@ -57,7 +57,7 @@ typedef struct parrot_io_event {


typedef struct _call_back_info { typedef struct _call_back_info {
PMC* cbi; /* callback info */ PMC* cbi; /* callback info */
void* external_data; char* external_data;
} _call_back_info; } _call_back_info;


typedef struct parrot_event { typedef struct parrot_event {
Expand Down Expand Up @@ -94,8 +94,8 @@ PARROT_API void Parrot_new_suspend_for_gc_event(Parrot_Interp);
PARROT_API void disable_event_checking(Parrot_Interp); PARROT_API void disable_event_checking(Parrot_Interp);
PARROT_API void enable_event_checking(Parrot_Interp); PARROT_API void enable_event_checking(Parrot_Interp);


PARROT_API void Parrot_new_cb_event(Parrot_Interp, PMC* cbi, void*ext); PARROT_API void Parrot_new_cb_event(Parrot_Interp, PMC* cbi, char *ext);
PARROT_API void Parrot_run_callback(Parrot_Interp, PMC* cbi, void*ext); PARROT_API void Parrot_run_callback(Parrot_Interp, PMC* cbi, char *ext);


PARROT_API void Parrot_kill_event_loop(void); PARROT_API void Parrot_kill_event_loop(void);
PARROT_API void* Parrot_sleep_on_event(Parrot_Interp, FLOATVAL t, void* next); PARROT_API void* Parrot_sleep_on_event(Parrot_Interp, FLOATVAL t, void* next);
Expand Down
6 changes: 3 additions & 3 deletions include/parrot/interpreter.h
Expand Up @@ -472,7 +472,7 @@ PARROT_API STRING*interpinfo_s(Interp *interp, INTVAL what);
void runops(Interp *, size_t offset); void runops(Interp *, size_t offset);
void runops_int(Interp *, size_t offset); void runops_int(Interp *, size_t offset);
PARROT_API parrot_context_t* Parrot_runops_fromc(Interp *, PMC *sub); PARROT_API parrot_context_t* Parrot_runops_fromc(Interp *, PMC *sub);
PARROT_API void* Parrot_runops_fromc_args(Interp *, PMC *sub, const char *sig, ...); PARROT_API PMC* Parrot_runops_fromc_args(Interp *, PMC *sub, const char *sig, ...);
PARROT_API void* Parrot_runops_fromc_args_event(Interp *, PMC *sub, const char *sig, ...); PARROT_API void* Parrot_runops_fromc_args_event(Interp *, PMC *sub, const char *sig, ...);
PARROT_API INTVAL Parrot_runops_fromc_args_reti(Interp *, PMC *, const char *, ...); PARROT_API INTVAL Parrot_runops_fromc_args_reti(Interp *, PMC *, const char *, ...);
PARROT_API FLOATVAL Parrot_runops_fromc_args_retf(Interp *, PMC *, const char *, ...); PARROT_API FLOATVAL Parrot_runops_fromc_args_retf(Interp *, PMC *, const char *, ...);
Expand All @@ -497,8 +497,8 @@ PARROT_API INTVAL Parrot_run_meth_fromc_arglist_reti(Interp *, PMC *sub,
PARROT_API FLOATVAL Parrot_run_meth_fromc_arglist_retf(Interp *, PMC *sub, PARROT_API FLOATVAL Parrot_run_meth_fromc_arglist_retf(Interp *, PMC *sub,
PMC* obj, STRING *meth, const char *signature, va_list); PMC* obj, STRING *meth, const char *signature, va_list);


PARROT_API void Parrot_callback_C(void *external_data, PMC *callback_info); PARROT_API void Parrot_callback_C(char *external_data, PMC *callback_info);
PARROT_API void Parrot_callback_D(PMC *callback_info, void *external_data); PARROT_API void Parrot_callback_D(PMC *callback_info, char *external_data);
PARROT_API PMC* Parrot_make_cb(Interp *interp, PMC* sub, PMC* user_data, PARROT_API PMC* Parrot_make_cb(Interp *interp, PMC* sub, PMC* user_data,
STRING* cb_signature); STRING* cb_signature);


Expand Down
2 changes: 1 addition & 1 deletion include/parrot/io.h
Expand Up @@ -170,7 +170,7 @@ PARROT_API extern PMC *PIO_fdopen(Interp *, ParrotIOLayer *, PIOHANDLE, const ch
PARROT_API extern INTVAL PIO_close(Interp *, PMC *); PARROT_API extern INTVAL PIO_close(Interp *, PMC *);
PARROT_API extern void PIO_flush(Interp *, PMC *); PARROT_API extern void PIO_flush(Interp *, PMC *);
PARROT_API extern STRING *PIO_reads(Interp *, PMC *, size_t); PARROT_API extern STRING *PIO_reads(Interp *, PMC *, size_t);
PARROT_API extern INTVAL PIO_read(Interp *, PMC *, void *, size_t); PARROT_API extern INTVAL PIO_read(Interp *, PMC *, char *, size_t);
PARROT_API extern INTVAL PIO_write(Interp *, PMC *, const void *, size_t); PARROT_API extern INTVAL PIO_write(Interp *, PMC *, const void *, size_t);
PARROT_API extern INTVAL PIO_setbuf(Interp *, PMC *, size_t); PARROT_API extern INTVAL PIO_setbuf(Interp *, PMC *, size_t);
PARROT_API extern INTVAL PIO_setlinebuf(Interp *, PMC *); PARROT_API extern INTVAL PIO_setlinebuf(Interp *, PMC *);
Expand Down
2 changes: 1 addition & 1 deletion include/parrot/packfile.h
Expand Up @@ -178,7 +178,7 @@ typedef struct PackFile_ConstTable {
typedef struct PackFile_ByteCode { typedef struct PackFile_ByteCode {
PackFile_Segment base; PackFile_Segment base;
Prederef prederef; /* The predereferenced code and info */ Prederef prederef; /* The predereferenced code and info */
void *jit_info; /* JITs data */ struct Parrot_jit_info_t *jit_info; /* JITs data */
Parrot_PIC_store *pic_store; /* PIC storage */ Parrot_PIC_store *pic_store; /* PIC storage */
PackFile_Segment *pic_index; /* segment of indices into store */ PackFile_Segment *pic_index; /* segment of indices into store */
struct PackFile_Debug *debugs; struct PackFile_Debug *debugs;
Expand Down
6 changes: 2 additions & 4 deletions include/parrot/pobj.h
Expand Up @@ -81,10 +81,8 @@ struct parrot_string_t {
char *strstart; char *strstart;
UINTVAL strlen; UINTVAL strlen;
/* parrot_string_representation_t representation;*/ /* parrot_string_representation_t representation;*/
void *encoding; /* These should be of type ENCODING * and CHARSET * struct _encoding *encoding;
* respectively, but I'm not sure how to get them struct _charset *charset;
* to do that without a whole lotta work right now */
void *charset;
UINTVAL hashval; /* cached hash value computation; not yet used */ UINTVAL hashval; /* cached hash value computation; not yet used */
}; };


Expand Down
8 changes: 4 additions & 4 deletions include/parrot/string_funcs.h
Expand Up @@ -58,9 +58,9 @@ PARROT_API STRING *string_from_num(Interp *, FLOATVAL f);
PARROT_API STRING *string_grow(Interp *, STRING *s, INTVAL addlen); PARROT_API STRING *string_grow(Interp *, STRING *s, INTVAL addlen);
PARROT_API const char* string_primary_encoding_for_representation(Interp *, PARROT_API const char* string_primary_encoding_for_representation(Interp *,
parrot_string_representation_t representation); parrot_string_representation_t representation);
PARROT_API STRING *string_make(Interp *interp, const void *buffer, PARROT_API STRING *string_make(Interp *interp, const char *buffer,
UINTVAL len, const char *charset_name, UINTVAL flags); UINTVAL len, const char *charset_name, UINTVAL flags);
PARROT_API STRING *string_make_direct(Interp *interp, const void *buffer, PARROT_API STRING *string_make_direct(Interp *interp, const char *buffer,
UINTVAL len, ENCODING *encoding, CHARSET *charset, UINTVAL flags); UINTVAL len, ENCODING *encoding, CHARSET *charset, UINTVAL flags);
PARROT_API STRING * string_make_empty(Interp *interp, PARROT_API STRING * string_make_empty(Interp *interp,
parrot_string_representation_t representation, parrot_string_representation_t representation,
Expand All @@ -78,8 +78,8 @@ PARROT_API void *string_pointer_to_index(Interp *, const STRING *s, UINTVAL idx)
PARROT_API INTVAL string_index(Interp *, const STRING *, UINTVAL idx); PARROT_API INTVAL string_index(Interp *, const STRING *, UINTVAL idx);
PARROT_API INTVAL string_str_index(Interp *interp, const STRING *s, PARROT_API INTVAL string_str_index(Interp *interp, const STRING *s,
const STRING *s2, INTVAL start); const STRING *s2, INTVAL start);
PARROT_API STRING *string_from_cstring(Interp *, const void *, UINTVAL); PARROT_API STRING *string_from_cstring(Interp *, const char *, UINTVAL);
PARROT_API STRING *string_from_const_cstring(Interp *, const void *, UINTVAL); PARROT_API STRING *string_from_const_cstring(Interp *, const char *, UINTVAL);
PARROT_API STRING *const_string(Interp *, const char *buffer) PARROT_API STRING *const_string(Interp *, const char *buffer)
__attribute__nonnull__(2); __attribute__nonnull__(2);
PARROT_API char *string_to_cstring(Interp *, STRING *); PARROT_API char *string_to_cstring(Interp *, STRING *);
Expand Down
2 changes: 1 addition & 1 deletion include/parrot/sub.h
Expand Up @@ -200,7 +200,7 @@ struct Parrot_Context_info {
STRING* nsname; STRING* nsname;
STRING* fullname; STRING* fullname;
int pc; int pc;
const char *file; char *file;
int line; int line;
opcode_t *address; opcode_t *address;
}; };
Expand Down
2 changes: 1 addition & 1 deletion lib/Parrot/Pmc2c/PCCMETHOD.pm
Expand Up @@ -480,7 +480,7 @@ sub rewrite_pccinvoke {


my $n_regs_used = find_max_regs( [ $result_n_regs_used, $args_n_regs_used ] ); my $n_regs_used = find_max_regs( [ $result_n_regs_used, $args_n_regs_used ] );


$method_name = "string_from_const_cstring(interp, $method_name, 0)" $method_name = "string_from_const_cstring(interp, (const char *) $method_name, 0)"
if isquoted($method_name); if isquoted($method_name);


my $file = '"' . __FILE__ . '"'; my $file = '"' . __FILE__ . '"';
Expand Down
14 changes: 7 additions & 7 deletions src/debug.c
Expand Up @@ -1545,7 +1545,7 @@ PDB_disassemble_op(Interp *interp, char* dest, int space,
dest[size++] = '?'; dest[size++] = '?';
break; break;
} }
k = PMC_data(k); k = (PMC *)PMC_data(k);
if (k) dest[size++] = ';'; if (k) dest[size++] = ';';
} }
dest[size++] = ']'; dest[size++] = ']';
Expand Down Expand Up @@ -1624,7 +1624,7 @@ PDB_disassemble(Interp *interp, const char *command)
if (space < default_size) { if (space < default_size) {
alloced += default_size; alloced += default_size;
space += default_size; space += default_size;
pfile->source = mem_sys_realloc(pfile->source, alloced); pfile->source = (char *)mem_sys_realloc(pfile->source, alloced);
} }


size = PDB_disassemble_op(interp, pfile->source + pfile->size, size = PDB_disassemble_op(interp, pfile->source + pfile->size,
Expand Down Expand Up @@ -1810,7 +1810,7 @@ PDB_load_source(Interp *interp, const char *command)
while ((c = fgetc(file)) != EOF) { while ((c = fgetc(file)) != EOF) {
/* Grow it */ /* Grow it */
if (++size == 1024) { if (++size == 1024) {
pfile->source = mem_sys_realloc(pfile->source, pfile->source = (char *)mem_sys_realloc(pfile->source,
(size_t)pfile->size + 1024); (size_t)pfile->size + 1024);
size = 0; size = 0;
} }
Expand Down Expand Up @@ -2053,12 +2053,12 @@ PDB_extend_const_table(Interp *interp)
k = ++interp->code->const_table->const_count; k = ++interp->code->const_table->const_count;
if (interp->code->const_table->constants) { if (interp->code->const_table->constants) {
interp->code->const_table->constants = interp->code->const_table->constants =
mem_sys_realloc(interp->code->const_table->constants, (PackFile_Constant **)mem_sys_realloc(interp->code->const_table->constants,
k * sizeof (PackFile_Constant *)); k * sizeof (PackFile_Constant *));
} }
else { else {
interp->code->const_table->constants = interp->code->const_table->constants =
mem_sys_allocate(k * sizeof (PackFile_Constant *)); (PackFile_Constant **)mem_sys_allocate(k * sizeof (PackFile_Constant *));
} }


/* Allocate a new constant */ /* Allocate a new constant */
Expand Down Expand Up @@ -2491,7 +2491,7 @@ GDB_B(Interp *interp, char *s) {


if (!gdb_bps) { if (!gdb_bps) {
nr = 0; nr = 0;
newbreak = mem_sys_allocate(sizeof (PDB_breakpoint_t)); newbreak = mem_allocate_typed(PDB_breakpoint_t);
newbreak->prev = NULL; newbreak->prev = NULL;
newbreak->next = NULL; newbreak->next = NULL;
gdb_bps = newbreak; gdb_bps = newbreak;
Expand All @@ -2505,7 +2505,7 @@ GDB_B(Interp *interp, char *s) {
break; break;
} }
++nr; ++nr;
newbreak = mem_sys_allocate(sizeof (PDB_breakpoint_t)); newbreak = mem_allocate_typed(PDB_breakpoint_t);
newbreak->prev = bp; newbreak->prev = bp;
newbreak->next = NULL; newbreak->next = NULL;
bp->next = newbreak; bp->next = newbreak;
Expand Down
32 changes: 16 additions & 16 deletions src/events.c
Expand Up @@ -335,7 +335,7 @@ Create queue entry and insert event into task queue.
void void
Parrot_schedule_event(Parrot_Interp interp, parrot_event* ev) Parrot_schedule_event(Parrot_Interp interp, parrot_event* ev)
{ {
QUEUE_ENTRY* entry = mem_sys_allocate(sizeof (QUEUE_ENTRY)); QUEUE_ENTRY* entry = mem_allocate_typed(QUEUE_ENTRY);
entry->next = NULL; entry->next = NULL;
ev->interp = interp; ev->interp = interp;
entry->data = ev; entry->data = ev;
Expand Down Expand Up @@ -364,10 +364,10 @@ Parrot_schedule_event(Parrot_Interp interp, parrot_event* ev)
static void static void
schedule_signal_event(int signum) schedule_signal_event(int signum)
{ {
parrot_event* ev = mem_sys_allocate(sizeof (parrot_event)); parrot_event* ev = mem_allocate_typed(parrot_event);
QUEUE_ENTRY *entry; QUEUE_ENTRY *entry;


entry = mem_sys_allocate(sizeof (QUEUE_ENTRY)); entry = mem_allocate_typed(QUEUE_ENTRY);
entry->next = NULL; entry->next = NULL;
entry->type = QUEUE_ENTRY_TYPE_EVENT; entry->type = QUEUE_ENTRY_TYPE_EVENT;
ev->type = EVENT_TYPE_SIGNAL; ev->type = EVENT_TYPE_SIGNAL;
Expand Down Expand Up @@ -396,7 +396,7 @@ void
Parrot_new_timer_event(Parrot_Interp interp, PMC* timer, FLOATVAL diff, Parrot_new_timer_event(Parrot_Interp interp, PMC* timer, FLOATVAL diff,
FLOATVAL interval, int repeat, PMC* sub, parrot_event_type_enum typ) FLOATVAL interval, int repeat, PMC* sub, parrot_event_type_enum typ)
{ {
parrot_event* ev = mem_sys_allocate(sizeof (parrot_event)); parrot_event* ev = mem_allocate_typed(parrot_event);
FLOATVAL now = Parrot_floatval_time(); FLOATVAL now = Parrot_floatval_time();
ev->type = typ; ev->type = typ;
ev->u.timer_event.timer = timer; ev->u.timer_event.timer = timer;
Expand All @@ -421,10 +421,10 @@ Prepare and schedule a callback event.
*/ */


void void
Parrot_new_cb_event(Parrot_Interp interp, PMC* cbi, void* ext) Parrot_new_cb_event(Parrot_Interp interp, PMC* cbi, char* ext)
{ {
parrot_event* ev = mem_sys_allocate(sizeof (parrot_event)); parrot_event* ev = mem_allocate_typed(parrot_event);
QUEUE_ENTRY* entry = mem_sys_allocate(sizeof (QUEUE_ENTRY)); QUEUE_ENTRY* entry = mem_allocate_typed(QUEUE_ENTRY);
entry->next = NULL; entry->next = NULL;
entry->data = ev; entry->data = ev;
ev->interp = interp; ev->interp = interp;
Expand Down Expand Up @@ -480,7 +480,7 @@ event arrives.
void void
Parrot_new_terminate_event(Parrot_Interp interp) Parrot_new_terminate_event(Parrot_Interp interp)
{ {
parrot_event* ev = mem_sys_allocate(sizeof (parrot_event)); parrot_event* ev = mem_allocate_typed(parrot_event);
ev->type = EVENT_TYPE_TERMINATE; ev->type = EVENT_TYPE_TERMINATE;
Parrot_schedule_event(interp, ev); Parrot_schedule_event(interp, ev);
} }
Expand All @@ -499,9 +499,9 @@ variable for GC to finish when the event arrives.
void void
Parrot_new_suspend_for_gc_event(Parrot_Interp interp) { Parrot_new_suspend_for_gc_event(Parrot_Interp interp) {
QUEUE_ENTRY *qe; QUEUE_ENTRY *qe;
parrot_event* ev = mem_sys_allocate(sizeof (parrot_event)); parrot_event* ev = mem_allocate_typed(parrot_event);
ev->type = EVENT_TYPE_SUSPEND_FOR_GC; ev->type = EVENT_TYPE_SUSPEND_FOR_GC;
qe = mem_sys_allocate(sizeof (QUEUE_ENTRY)); qe = mem_allocate_typed(QUEUE_ENTRY);
qe->next = NULL; qe->next = NULL;
qe->data = ev; qe->data = ev;
qe->type = QUEUE_ENTRY_TYPE_EVENT; qe->type = QUEUE_ENTRY_TYPE_EVENT;
Expand All @@ -524,7 +524,7 @@ Schedule event-loop terminate event. This shuts down the event thread.
void void
Parrot_kill_event_loop(void) Parrot_kill_event_loop(void)
{ {
parrot_event* ev = mem_sys_allocate(sizeof (parrot_event)); parrot_event* ev = mem_allocate_typed(parrot_event);
ev->type = EVENT_TYPE_EVENT_TERMINATE; ev->type = EVENT_TYPE_EVENT_TERMINATE;
Parrot_schedule_event(NULL, ev); Parrot_schedule_event(NULL, ev);
} }
Expand Down Expand Up @@ -667,12 +667,12 @@ static void
store_io_event(pending_io_events *ios, parrot_event *ev) store_io_event(pending_io_events *ios, parrot_event *ev)
{ {
if (!ios->alloced) { if (!ios->alloced) {
ios->events = mem_sys_allocate(16 * sizeof (ev)); ios->events = (parrot_event **)mem_sys_allocate(16 * sizeof (ev));
ios->alloced = 16; ios->alloced = 16;
} }
else if (ios->n == ios->alloced - 1) { else if (ios->n == ios->alloced - 1) {
ios->alloced <<= 1; ios->alloced <<= 1;
ios->events = mem_sys_realloc(ios->events, (ios->alloced * sizeof (ev))); ios->events = (parrot_event **)mem_sys_realloc(ios->events, (ios->alloced * sizeof (ev)));
} }
ios->events[ios->n++] = ev; ios->events[ios->n++] = ev;
} }
Expand Down Expand Up @@ -847,7 +847,7 @@ Parrot_event_add_io_event(Interp* interp,
parrot_event *event; parrot_event *event;
io_thread_msg buf; io_thread_msg buf;


event = mem_sys_allocate(sizeof (parrot_event)); event = mem_allocate_typed(parrot_event);
event->type = EVENT_TYPE_IO; event->type = EVENT_TYPE_IO;
event->interp = interp; event->interp = interp;
/* /*
Expand Down Expand Up @@ -891,10 +891,10 @@ dup_entry(QUEUE_ENTRY* entry)
parrot_event *event; parrot_event *event;
QUEUE_ENTRY *new_entry; QUEUE_ENTRY *new_entry;


new_entry = mem_sys_allocate(sizeof (QUEUE_ENTRY)); new_entry = mem_allocate_typed(QUEUE_ENTRY);
new_entry->next = NULL; new_entry->next = NULL;
new_entry->type = entry->type; new_entry->type = entry->type;
event = new_entry->data = mem_sys_allocate(sizeof (parrot_event)); event = new_entry->data = mem_allocate_typed(parrot_event);
mem_sys_memcopy(event, entry->data, sizeof (parrot_event)); mem_sys_memcopy(event, entry->data, sizeof (parrot_event));
return new_entry; return new_entry;
} }
Expand Down
4 changes: 2 additions & 2 deletions src/global.c
Expand Up @@ -228,7 +228,7 @@ Parrot_get_global(Interp *interp, PMC *ns, STRING *globalname)
if (PMC_IS_NULL(ns)) if (PMC_IS_NULL(ns))
return PMCNULL; return PMCNULL;


return VTABLE_get_pointer_keyed_str(interp, ns, globalname); return (PMC *)VTABLE_get_pointer_keyed_str(interp, ns, globalname);
} }


void void
Expand Down Expand Up @@ -293,7 +293,7 @@ Parrot_find_global_n(Interp *interp, PMC *ns, STRING *globalname)
* distinguishes 'get_pmc_keyed' from 'get_pointer_keyed'; * distinguishes 'get_pmc_keyed' from 'get_pointer_keyed';
* the former is for NS and the latter is for non-NS. * the former is for NS and the latter is for non-NS.
*/ */
res = VTABLE_get_pointer_keyed_str(interp, ns, globalname); res = (PMC *)VTABLE_get_pointer_keyed_str(interp, ns, globalname);
} }


return PMC_IS_NULL(res) ? NULL : res; return PMC_IS_NULL(res) ? NULL : res;
Expand Down
2 changes: 1 addition & 1 deletion src/global_setup.c
Expand Up @@ -76,7 +76,7 @@ parrot_set_config_hash_interpreter(Interp* interp)
{ {
STRING *config_string = STRING *config_string =
string_make_direct(interp, string_make_direct(interp,
parrot_config_stored, parrot_config_size_stored, (const char *)parrot_config_stored, parrot_config_size_stored,
PARROT_DEFAULT_ENCODING, PARROT_DEFAULT_CHARSET, PARROT_DEFAULT_ENCODING, PARROT_DEFAULT_CHARSET,
PObj_external_FLAG|PObj_constant_FLAG); PObj_external_FLAG|PObj_constant_FLAG);


Expand Down

0 comments on commit e063e49

Please sign in to comment.