? changes ? notes ? psd-pathimport.diff ? scheme-debug.diff ? scheme-gc-fix.diff ? xor-funk.diff Index: plug-ins/script-fu/scheme-wrapper.c =================================================================== RCS file: /cvs/gnome/gimp/plug-ins/script-fu/scheme-wrapper.c,v retrieving revision 1.71 diff -u -p -r1.71 scheme-wrapper.c --- plug-ins/script-fu/scheme-wrapper.c 18 Nov 2006 22:30:23 -0000 1.71 +++ plug-ins/script-fu/scheme-wrapper.c 23 Nov 2006 19:01:04 -0000 @@ -978,7 +978,7 @@ if (count > 0) { fprintf (stderr, " "); for (j = 0; j < count; ++j) - fprintf (stderr, " %u", + fprintf (stderr, " %ld", sc->vptr->ivalue ( sc->vptr->vector_elem (vector, j) )); fprintf (stderr, "\n"); } @@ -1306,40 +1306,45 @@ fprintf (stderr, " value %d is type case GIMP_PDB_SELECTION: case GIMP_PDB_BOUNDARY: case GIMP_PDB_VECTORS: - return_val = sc->vptr->cons (sc, - sc->vptr->mk_integer (sc, - values[i + 1].data.d_int32), - return_val); + return_val = sc->vptr->cons (sc, sc->NIL, return_val); + set_safe_foreign (sc, return_val); + sc->vptr->set_car (return_val, + sc->vptr->mk_integer (sc, + values[i + 1].data.d_int32)); break; case GIMP_PDB_INT16: - return_val = sc->vptr->cons (sc, - sc->vptr->mk_integer (sc, - values[i + 1].data.d_int16), - return_val); + return_val = sc->vptr->cons (sc, sc->NIL, return_val); + set_safe_foreign (sc, return_val); + sc->vptr->set_car (return_val, + sc->vptr->mk_integer (sc, + values[i + 1].data.d_int16)); break; case GIMP_PDB_INT8: - return_val = sc->vptr->cons (sc, - sc->vptr->mk_integer (sc, - values[i + 1].data.d_int8), - return_val); + return_val = sc->vptr->cons (sc, sc->NIL, return_val); + set_safe_foreign (sc, return_val); + sc->vptr->set_car (return_val, + sc->vptr->mk_integer (sc, + values[i + 1].data.d_int8)); break; case GIMP_PDB_FLOAT: - return_val = sc->vptr->cons (sc, - sc->vptr->mk_real (sc, - values[i + 1].data.d_float), - return_val); + return_val = sc->vptr->cons (sc, sc->NIL, return_val); + set_safe_foreign (sc, return_val); + sc->vptr->set_car (return_val, + sc->vptr->mk_real (sc, + values[i + 1].data.d_float)); break; case GIMP_PDB_STRING: string = values[i + 1].data.d_string; if (! string) string = ""; - return_val = sc->vptr->cons (sc, - sc->vptr->mk_string (sc, string), - return_val); + return_val = sc->vptr->cons (sc, sc->NIL, return_val); + set_safe_foreign (sc, return_val); + sc->vptr->set_car (return_val, + sc->vptr->mk_string (sc, string)); break; case GIMP_PDB_INT32ARRAY: @@ -1349,7 +1354,13 @@ fprintf (stderr, " value %d is type { gint32 num_int32s = values[i].data.d_int32; gint32 *array = (gint32 *) values[i + 1].data.d_int32array; - pointer vector = sc->vptr->mk_vector (sc, num_int32s); + pointer vector; + + return_val = sc->vptr->cons (sc, sc->NIL, return_val); + set_safe_foreign (sc, return_val); + vector = sc->vptr->mk_vector (sc, num_int32s); + + sc->vptr->set_car (return_val, vector); for (j = 0; j < num_int32s; j++) { @@ -1357,8 +1368,6 @@ fprintf (stderr, " value %d is type sc->vptr->mk_integer (sc, array[j])); } - - return_val = sc->vptr->cons (sc, vector, return_val); } break; @@ -1369,7 +1378,13 @@ fprintf (stderr, " value %d is type { gint32 num_int16s = values[i].data.d_int32; gint16 *array = (gint16 *) values[i + 1].data.d_int16array; - pointer vector = sc->vptr->mk_vector (sc, num_int16s); + pointer vector; + + return_val = sc->vptr->cons (sc, sc->NIL, return_val); + set_safe_foreign (sc, return_val); + vector = sc->vptr->mk_vector (sc, num_int16s); + + sc->vptr->set_car (return_val, vector); for (j = 0; j < num_int16s; j++) { @@ -1377,7 +1392,6 @@ fprintf (stderr, " value %d is type sc->vptr->mk_integer (sc, array[j])); } - return_val = sc->vptr->cons (sc, vector, return_val); } break; @@ -1388,7 +1402,13 @@ fprintf (stderr, " value %d is type { gint32 num_int8s = values[i].data.d_int32; guint8 *array = (guint8 *) values[i + 1].data.d_int8array; - pointer vector = sc->vptr->mk_vector (sc, num_int8s); + pointer vector; + + return_val = sc->vptr->cons (sc, sc->NIL, return_val); + set_safe_foreign (sc, return_val); + vector = sc->vptr->mk_vector (sc, num_int8s); + + sc->vptr->set_car (return_val, vector); for (j = 0; j < num_int8s; j++) { @@ -1396,8 +1416,6 @@ fprintf (stderr, " value %d is type sc->vptr->mk_integer (sc, array[j])); } - - return_val = sc->vptr->cons (sc, vector, return_val); } break; @@ -1408,7 +1426,13 @@ fprintf (stderr, " value %d is type { gint32 num_floats = values[i].data.d_int32; gdouble *array = (gdouble *) values[i + 1].data.d_floatarray; - pointer vector = sc->vptr->mk_vector (sc, num_floats); + pointer vector; + + return_val = sc->vptr->cons (sc, sc->NIL, return_val); + set_safe_foreign (sc, return_val); + vector = sc->vptr->mk_vector (sc, num_floats); + + sc->vptr->set_car (return_val, vector); for (j = 0; j < num_floats; j++) { @@ -1416,8 +1440,6 @@ fprintf (stderr, " value %d is type sc->vptr->mk_real (sc, array[j])); } - - return_val = sc->vptr->cons (sc, vector, return_val); } break; @@ -1428,7 +1450,13 @@ fprintf (stderr, " value %d is type { gint num_strings = values[i].data.d_int32; gchar **array = (gchar **) values[i + 1].data.d_stringarray; - pointer vector = sc->vptr->mk_vector (sc, num_strings); + pointer vector; + + return_val = sc->vptr->cons (sc, sc->NIL, return_val); + set_safe_foreign (sc, return_val); + vector = sc->vptr->mk_vector (sc, num_strings); + + sc->vptr->set_car (return_val, vector); for (j = 0; j < num_strings; j++) { @@ -1436,8 +1464,6 @@ fprintf (stderr, " value %d is type sc->vptr->mk_string (sc, array[j])); } - - return_val = sc->vptr->cons (sc, vector, return_val); } break; @@ -1447,11 +1473,30 @@ fprintf (stderr, " value %d is type gimp_rgb_get_uchar (&values[i + 1].data.d_color, &r, &g, &b); - intermediate_val = sc->vptr->cons (sc, sc->vptr->mk_integer (sc, r), - sc->vptr->cons (sc, sc->vptr->mk_integer (sc, g), - sc->vptr->cons (sc, sc->vptr->mk_integer (sc, b), - sc->NIL))); - return_val = sc->vptr->cons (sc, intermediate_val, return_val); + return_val = sc->vptr->cons (sc, sc->NIL, return_val); + set_safe_foreign (sc, return_val); + + intermediate_val = sc->vptr->cons (sc, sc->NIL, sc->NIL); + sc->vptr->set_car (return_val, + intermediate_val); + + sc->vptr->set_car (intermediate_val, + sc->vptr->mk_integer (sc, r)); + sc->vptr->set_cdr (intermediate_val, + sc->vptr->cons (sc, sc->NIL, sc->NIL)); + intermediate_val = sc->vptr->pair_cdr (intermediate_val); + + sc->vptr->set_car (intermediate_val, + sc->vptr->mk_integer (sc, g)); + sc->vptr->set_cdr (intermediate_val, + sc->vptr->cons (sc, sc->NIL, sc->NIL)); + intermediate_val = sc->vptr->pair_cdr (intermediate_val); + + sc->vptr->set_car (intermediate_val, + sc->vptr->mk_integer (sc, b)); + sc->vptr->set_cdr (intermediate_val, + sc->NIL); + break; } @@ -1464,40 +1509,72 @@ fprintf (stderr, " value %d is type w = values[i + 1].data.d_region.width; h = values[i + 1].data.d_region.height; - intermediate_val = sc->vptr->cons (sc, - sc->vptr->mk_integer (sc, x), - sc->vptr->cons (sc, sc->vptr->mk_integer (sc, y), - sc->vptr->cons (sc, sc->vptr->mk_integer (sc, w), - sc->vptr->cons (sc, sc->vptr->mk_integer (sc, h), - sc->NIL)))); - return_val = sc->vptr->cons (sc, intermediate_val, return_val); + return_val = sc->vptr->cons (sc, sc->NIL, return_val); + set_safe_foreign (sc, return_val); + intermediate_val = sc->vptr->cons (sc, sc->NIL, sc->NIL); + sc->vptr->set_car (return_val, + intermediate_val); + + sc->vptr->set_car (intermediate_val, + sc->vptr->mk_integer (sc, x)); + sc->vptr->set_cdr (intermediate_val, + sc->vptr->cons (sc, sc->NIL, sc->NIL)); + intermediate_val = sc->vptr->pair_cdr (intermediate_val); + + sc->vptr->set_car (intermediate_val, + sc->vptr->mk_integer (sc, y)); + sc->vptr->set_cdr (intermediate_val, + sc->vptr->cons (sc, sc->NIL, sc->NIL)); + intermediate_val = sc->vptr->pair_cdr (intermediate_val); + + sc->vptr->set_car (intermediate_val, + sc->vptr->mk_integer (sc, w)); + sc->vptr->set_cdr (intermediate_val, + sc->vptr->cons (sc, sc->NIL, sc->NIL)); + intermediate_val = sc->vptr->pair_cdr (intermediate_val); + + sc->vptr->set_car (intermediate_val, + sc->vptr->mk_integer (sc, h)); + sc->vptr->set_cdr (intermediate_val, + sc->NIL); + break; } break; case GIMP_PDB_PARASITE: { - pointer name, flags, data; - if (values[i + 1].data.d_parasite.name == NULL) return_val = my_err ("Error: null parasite", sc->NIL); else { - name = sc->vptr->mk_string (sc, - values[i + 1].data.d_parasite.name); - - flags = sc->vptr->mk_integer (sc, - values[i + 1].data.d_parasite.flags); + return_val = sc->vptr->cons (sc, sc->NIL, return_val); + set_safe_foreign (sc, return_val); + intermediate_val = sc->vptr->cons (sc, sc->NIL, sc->NIL); + sc->vptr->set_car (return_val, + intermediate_val); + + sc->vptr->set_car (intermediate_val, + sc->vptr->mk_string (sc, + values[i + 1].data.d_parasite.name)); + sc->vptr->set_cdr (intermediate_val, + sc->vptr->cons (sc, sc->NIL, sc->NIL)); + intermediate_val = sc->vptr->pair_cdr (intermediate_val); + + sc->vptr->set_car (intermediate_val, + sc->vptr->mk_integer (sc, + values[i + 1].data.d_parasite.flags)); + sc->vptr->set_cdr (intermediate_val, + sc->vptr->cons (sc, sc->NIL, sc->NIL)); + intermediate_val = sc->vptr->pair_cdr (intermediate_val); + + sc->vptr->set_car (intermediate_val, + sc->vptr->mk_counted_string (sc, + values[i + 1].data.d_parasite.data, + values[i + 1].data.d_parasite.size)); + sc->vptr->set_cdr (intermediate_val, + sc->NIL); - data = sc->vptr->mk_counted_string (sc, - values[i + 1].data.d_parasite.data, - values[i + 1].data.d_parasite.size); - - intermediate_val = sc->vptr->cons (sc, name, - sc->vptr->cons (sc, flags, - sc->vptr->cons (sc, data, - sc->NIL))); - return_val = sc->vptr->cons (sc, intermediate_val, return_val); #if DEBUG_MARSHALL fprintf (stderr, " name '%s'\n", values[i+1].data.d_parasite.name); fprintf (stderr, " flags %d", values[i+1].data.d_parasite.flags); Index: plug-ins/script-fu/tinyscheme/scheme-private.h =================================================================== RCS file: /cvs/gnome/gimp/plug-ins/script-fu/tinyscheme/scheme-private.h,v retrieving revision 1.7 diff -u -p -r1.7 scheme-private.h --- plug-ins/script-fu/tinyscheme/scheme-private.h 9 Nov 2006 23:03:54 -0000 1.7 +++ plug-ins/script-fu/tinyscheme/scheme-private.h 23 Nov 2006 19:01:04 -0000 @@ -63,11 +63,12 @@ char *alloc_seg[CELL_NSEGMENT]; pointer cell_seg[CELL_NSEGMENT]; int last_cell_seg; -/* We use 4 registers. */ +/* We use 5 registers. */ pointer args; /* register for arguments of function */ pointer envir; /* stack register for current environment */ pointer code; /* register for current code */ pointer dump; /* stack register for next evaluation */ +pointer safe_foreign; /* register to avoid gc problems */ int interactive_repl; /* are we in an interactive REPL? */ int print_output; /* set to 1 to print results and error messages */ Index: plug-ins/script-fu/tinyscheme/scheme.c =================================================================== RCS file: /cvs/gnome/gimp/plug-ins/script-fu/tinyscheme/scheme.c,v retrieving revision 1.21 diff -u -p -r1.21 scheme.c --- plug-ins/script-fu/tinyscheme/scheme.c 17 Nov 2006 05:43:50 -0000 1.21 +++ plug-ins/script-fu/tinyscheme/scheme.c 23 Nov 2006 19:01:05 -0000 @@ -912,6 +912,15 @@ static pointer mk_number(scheme *sc, num } } +void set_safe_foreign (scheme *sc, pointer data) { + if (sc->safe_foreign == sc->NIL) { + fprintf (stderr, "get_safe_foreign called outside a foreign function\n"); + } else { + car (sc->safe_foreign) = data; + } +} + + /* char_cnt is length of string in chars. */ /* str points to a NUL terminated string. */ /* Only uses fill_char if str is NULL. */ @@ -1248,6 +1257,7 @@ static void gc(scheme *sc, pointer a, po mark(sc->code); dump_stack_mark(sc); mark(sc->value); + mark(sc->safe_foreign); mark(sc->inport); mark(sc->save_inport); mark(sc->outport); @@ -2524,7 +2534,9 @@ static pointer opexe_0(scheme *sc, enum if (is_proc(sc->code)) { s_goto(sc,procnum(sc->code)); /* PROCEDURE */ } else if (is_foreign(sc->code)) { + sc->safe_foreign = cons (sc, sc->NIL, sc->safe_foreign); x=sc->code->_object._ff(sc,sc->args); + sc->safe_foreign = cdr (sc->safe_foreign); s_return(sc,x); } else if (is_closure(sc->code) || is_macro(sc->code) || is_promise(sc->code)) { /* CLOSURE */ @@ -4487,6 +4499,7 @@ int scheme_init_custom_alloc(scheme *sc, sc->code = sc->NIL; sc->tracing=0; sc->bc_flag = 0; + sc->safe_foreign = sc->NIL; /* init sc->NIL */ typeflag(sc->NIL) = (T_ATOM | MARK); Index: plug-ins/script-fu/tinyscheme/scheme.h =================================================================== RCS file: /cvs/gnome/gimp/plug-ins/script-fu/tinyscheme/scheme.h,v retrieving revision 1.5 diff -u -p -r1.5 scheme.h --- plug-ins/script-fu/tinyscheme/scheme.h 9 Nov 2006 23:03:54 -0000 1.5 +++ plug-ins/script-fu/tinyscheme/scheme.h 23 Nov 2006 19:01:05 -0000 @@ -140,6 +140,7 @@ pointer mk_character(scheme *sc, gunicha pointer mk_foreign_func(scheme *sc, foreign_func f); void putstr(scheme *sc, const char *s); +void set_safe_foreign (scheme *sc, pointer data); #if USE_INTERFACE struct scheme_interface {