diff options
author | IOhannes m zmölnig <zmoelnig@umlautQ.umlaeute.mur.at> | 2016-01-25 11:25:59 +0100 |
---|---|---|
committer | IOhannes m zmölnig <zmoelnig@umlautQ.umlaeute.mur.at> | 2016-01-25 11:25:59 +0100 |
commit | 110d59c341b8c50c04f30d90e85e9b8f6f329a0e (patch) | |
tree | 174afbe2ded41ae03923b93a0c4e6975e3163ad5 /snd-axis.c | |
parent | e5328e59987b90c4e98959510b810510e384650d (diff) |
Imported Upstream version 16.1
Diffstat (limited to 'snd-axis.c')
-rw-r--r-- | snd-axis.c | 557 |
1 files changed, 275 insertions, 282 deletions
@@ -1,6 +1,6 @@ #include "snd.h" -bool x_axis_style_p(int n) +bool is_x_axis_style(int n) { switch (n) { @@ -13,7 +13,7 @@ bool x_axis_style_p(int n) } -bool show_axes_p(int n) +bool shows_axes(int n) { switch (n) { @@ -58,7 +58,7 @@ static tick_descriptor *describe_ticks(tick_descriptor *gd_td, double lo, double tick_descriptor *td; int ten, hib, lob, offset = 0; double flog10, plog10; - double frac, ften, hilo_diff, eten, flt_ten, flt_ften; + double frac, ften, hilo_diff, eten, flt_ten; double inside, mfdiv, mten, mften; int mticks, mdiv; @@ -99,6 +99,7 @@ static tick_descriptor *describe_ticks(tick_descriptor *gd_td, double lo, double } else { + double flt_ften; /* try next lower power of ten */ ften = eten * .1; flt_ften = (hi / ften); @@ -111,16 +112,19 @@ static tick_descriptor *describe_ticks(tick_descriptor *gd_td, double lo, double } inside = (td->mhi - td->mlo) / hilo_diff; mticks = (int)floor(inside * max_ticks); + if (mticks <= 1) mdiv = 1; - if (mticks < 3) mdiv = mticks; + else if (mticks < 3) mdiv = mticks; else if (mticks == 3) mdiv = 2; else if (mticks < 6) mdiv = mticks; else if (mticks < 10) mdiv = 5; else mdiv = (int)(10 * floor(mticks / 10)); + mfdiv = (td->mhi - td->mlo) / mdiv; flog10 = floor(log10(mfdiv)); plog10 = pow(10, flog10); td->tens = (int)fabs(flog10); + mten = grid_scale * (double)(floor(4.0 * (.00001 + (mfdiv / plog10)))) / 4.0; if (mten < 1.0) mten = 1.0; if ((mten == 1.0) || (mten == 2.0) || (mten == 2.5) || (mten == 5.0)) ften = mten; @@ -128,6 +132,7 @@ static tick_descriptor *describe_ticks(tick_descriptor *gd_td, double lo, double else if (mten < 2.5) ften = 2.5; else if (mten < 5.0) ften = 5.0; else ften = 10.0; + td->tenstep = ften; mften = ften * plog10; td->step = mften; @@ -345,15 +350,18 @@ static int tick_grf_x(double val, axis_info *ap, x_axis_style_t style, int srate default: res = (int)(ap->x_base + val * ap->x_scale); break; + case X_AXIS_IN_BEATS: case X_AXIS_IN_MEASURES: if (ap->cp) res = (int)(ap->x_base + val * ap->x_scale * 60.0 / ap->cp->beats_per_minute); else res = (int)(ap->x_base + val * ap->x_scale); break; + case X_AXIS_IN_SAMPLES: res = (int)(ap->x_axis_x0 + (val - ap->x0 * srate) * ap->x_scale / srate); break; + case X_AXIS_AS_PERCENTAGE: res = (int)(ap->x_axis_x0 + (val - ap->x0 / ap->xmax) * ap->x_scale * ap->xmax); break; @@ -378,9 +386,9 @@ static int label_base, number_base; static void activate_gl_fonts(void) { #if USE_MOTIF - XFontStruct *label, *number; if (!gl_fonts_activated) { + XFontStruct *label, *number; label = (XFontStruct *)(AXIS_LABEL_FONT(ss)); number = (XFontStruct *)(AXIS_NUMBERS_FONT(ss)); label_base = glGenLists(128); @@ -394,8 +402,6 @@ static void activate_gl_fonts(void) { label_base = glGenLists(128); number_base = glGenLists(128); - gdk_gl_font_use_pango_font(AXIS_LABEL_FONT(ss), 32, 96, label_base + 32); - gdk_gl_font_use_pango_font(AXIS_NUMBERS_FONT(ss), 32, 96, number_base + 32); gl_fonts_activated = true; } #endif @@ -405,9 +411,9 @@ static void activate_gl_fonts(void) void reload_label_font(void) { #if USE_MOTIF - XFontStruct *label; if (gl_fonts_activated) { + XFontStruct *label; glDeleteLists(label_base, 128); label_base = glGenLists(128); label = (XFontStruct *)(AXIS_LABEL_FONT(ss)); @@ -418,7 +424,7 @@ void reload_label_font(void) { glDeleteLists(label_base, 128); label_base = glGenLists(128); - gdk_gl_font_use_pango_font(AXIS_LABEL_FONT(ss), 32, 96, label_base + 32); + /* gdk_gl_font_use_pango_font(AXIS_LABEL_FONT(ss), 32, 96, label_base + 32); */ } #endif } @@ -427,9 +433,9 @@ void reload_label_font(void) void reload_number_font(void) { #if USE_MOTIF - XFontStruct *number; if (gl_fonts_activated) { + XFontStruct *number; glDeleteLists(number_base, 128); number_base = glGenLists(128); number = (XFontStruct *)(AXIS_NUMBERS_FONT(ss)); @@ -440,7 +446,7 @@ void reload_number_font(void) { glDeleteLists(number_base, 128); number_base = glGenLists(128); - gdk_gl_font_use_pango_font(AXIS_NUMBERS_FONT(ss), 32, 96, number_base + 32); + /* gdk_gl_font_use_pango_font(AXIS_NUMBERS_FONT(ss), 32, 96, number_base + 32); */ } #endif } @@ -622,7 +628,7 @@ void make_axes_1(axis_info *ap, x_axis_style_t x_style, int srate, show_axes_t a height = ap->height; ap->graph_active = ((width > 4) || (height > 10)); include_grid = ((ap->cp) && (with_grid)); - + if ((axes == SHOW_NO_AXES) || (width < 40) || (height < 40) || (ap->xmax == 0.0)) { /* leave it set up for bare graph */ @@ -722,7 +728,6 @@ void make_axes_1(axis_info *ap, x_axis_style_t x_style, int srate, show_axes_t a curx = left_border_width; cury = height - bottom_border_width; - use_tiny_font = ((width < 250) || (height < 140)); x_number_height = number_height((use_tiny_font) ? TINY_FONT(ss) : AXIS_NUMBERS_FONT(ss)); @@ -751,27 +756,21 @@ void make_axes_1(axis_info *ap, x_axis_style_t x_style, int srate, show_axes_t a { if (include_y_ticks) { - double y_range; /* figure out how long the longest tick label will be and make room for it */ /* values go from ap->y0 to ap->y1 */ /* basic tick spacing is tick_spacing pixels */ + num_ticks = cury / y_tick_spacing; /* ticks start and stop at 10-based locations (i.e. sloppy axis bounds) */ /* so, given the current min..max, find the pretty min..max for ticks */ - y_range = ap->y1 - ap->y0; - if (y_range <= 0.0) + + if (ap->y1 <= ap->y0) { if (ap->y0 != 0.0) - { - ap->y1 = ap->y0 * 1.25; - y_range = ap->y0 * .25; - } - else - { - ap->y1 = 1.0; - y_range = 1.0; - } + ap->y1 = ap->y0 * 1.25; + else ap->y1 = 1.0; } + tdy = describe_ticks(ap->y_ticks, ap->y0, ap->y1, num_ticks, grid_scale); ap->y_ticks = tdy; if (include_y_tick_labels) @@ -814,27 +813,19 @@ void make_axes_1(axis_info *ap, x_axis_style_t x_style, int srate, show_axes_t a if (include_y_tick_labels) curx += number_width("10000", use_tiny_font); curx += major_tick_length; + ap->y_axis_y1 = include_y_ticks ? top_border_width : 0; } ap->x_axis_x1 = width - right_border_width; ap->x_axis_x0 = curx; - { - double x_range; - x_range = ap->x1 - ap->x0; - if (x_range <= 0) - { - if (ap->x0 != 0.0) - { - ap->x1 = ap->x0 * 1.25; - x_range = ap->x0 * .25; - } - else - { - ap->x1 = .1; - x_range = .1; - } - } - } + + if (ap->x1 <= ap->x0) + { + if (ap->x0 != 0.0) + ap->x1 = ap->x0 * 1.25; + else ap->x1 = .1; + } + if ((x_axis_linear) && (include_x_ticks)) { num_ticks = (ap->x_axis_x1 - curx) / x_tick_spacing; @@ -845,9 +836,11 @@ void make_axes_1(axis_info *ap, x_axis_style_t x_style, int srate, show_axes_t a default: tdx = describe_ticks(ap->x_ticks, ap->x0, ap->x1, num_ticks, grid_scale); break; + case X_AXIS_IN_SAMPLES: tdx = describe_ticks(ap->x_ticks, ap->x0 * srate, ap->x1 * srate, num_ticks, grid_scale); break; + case X_AXIS_IN_BEATS: case X_AXIS_IN_MEASURES: if (ap->cp) /* cp==null probably can't happen -- ap->cp is null (only?) if we're called from the envelope editor */ @@ -1008,7 +1001,11 @@ void make_axes_1(axis_info *ap, x_axis_style_t x_style, int srate, show_axes_t a if ((ap->y_axis_y0 - ap->y_axis_y1) > (y_label_width + 20)) draw_rotated_axis_label(ap->cp, ax, ap->ylabel, (tdy) ? +#if USE_GTK + (ap->y_axis_x0 - tdy->maj_tick_len - tdy->min_label_width - inner_border_width - 10) : +#else (ap->y_axis_x0 - tdy->maj_tick_len - tdy->min_label_width - inner_border_width) : +#endif (ap->y_axis_x0 - inner_border_width - 30), /* tdy might be null if not y_axis_linear (sonogram + log-freq + y axis label) */ (int)((ap->y_axis_y0 + ap->y_axis_y1 - y_label_width) * 0.5) - 8); @@ -1349,10 +1346,12 @@ void make_axes_1(axis_info *ap, x_axis_style_t x_style, int srate, show_axes_t a label = "100"; freq = 100.0; break; + case 1: label = "1000"; freq = 1000.0; break; + case 2: label = "10000"; freq = 10000.0; @@ -1411,10 +1410,12 @@ void make_axes_1(axis_info *ap, x_axis_style_t x_style, int srate, show_axes_t a label = "100"; freq = 100.0; break; + case 1: label = "1000"; freq = 1000.0; break; + case 2: label = "10000"; freq = 10000.0; @@ -1493,7 +1494,7 @@ static axis_info *get_ap(chan_info *cp, axis_info_t ap_id, const char *caller) { #define AXIS_INFO_ID_OK(Id) (Id <= (int)LISP_AXIS_INFO) - if ((cp) && (AXIS_INFO_ID_OK(ap_id))) + if (AXIS_INFO_ID_OK(ap_id)) switch (ap_id) { case TIME_AXIS_INFO: return(cp->axis); break; @@ -1501,120 +1502,117 @@ static axis_info *get_ap(chan_info *cp, axis_info_t ap_id, const char *caller) case LISP_AXIS_INFO: if (cp->lisp_info) return(lisp_info_axis(cp)); break; } - XEN_ERROR(XEN_ERROR_TYPE("no-such-axis"), - XEN_LIST_6(((!(cp->squelch_update)) || (!(AXIS_INFO_ID_OK(ap_id)))) ? - C_TO_XEN_STRING("~A: no such axis: ~A of sound ~A (~A), chan: ~A (axis should be " S_time_graph ", " S_lisp_graph ", or " S_transform_graph ")") : - C_TO_XEN_STRING("~A: no such axis: ~A of sound ~A (~A), chan: ~A does not exist, probably because output is squelched"), - C_TO_XEN_STRING(caller), - C_TO_XEN_INT((int)(ap_id)), - C_INT_TO_XEN_SOUND(cp->sound->index), - C_TO_XEN_STRING(cp->sound->short_filename), - C_TO_XEN_INT(cp->chan))); + Xen_error(Xen_make_error_type("no-such-axis"), + Xen_list_6(((!(cp->squelch_update)) || (!(AXIS_INFO_ID_OK(ap_id)))) ? + C_string_to_Xen_string("~A: no such axis: ~A of sound ~A (~A), chan: ~A (axis should be " S_time_graph ", " S_lisp_graph ", or " S_transform_graph ")") : + C_string_to_Xen_string("~A: no such axis: ~A of sound ~A (~A), chan: ~A does not exist, probably because output is squelched"), + C_string_to_Xen_string(caller), + C_int_to_Xen_integer((int)(ap_id)), + C_int_to_Xen_sound(cp->sound->index), + C_string_to_Xen_string(cp->sound->short_filename), + C_int_to_Xen_integer(cp->chan))); return(NULL); } -#define TO_C_AXIS_INFO(Snd, Chn, Ap, Caller) \ - get_ap(get_cp(Snd, Chn, Caller), \ - (axis_info_t)XEN_TO_C_INT_OR_ELSE(Ap, (int)TIME_AXIS_INFO), \ - Caller) +#define TO_C_AXIS_INFO(Snd, Chn, Ap, Caller) get_ap(get_cp(Snd, Chn, Caller), (Xen_is_integer(Ap)) ? (axis_info_t)Xen_integer_to_C_int(Ap) : TIME_AXIS_INFO, Caller) -static XEN g_x_to_position(XEN val, XEN snd, XEN chn, XEN ap) +static Xen g_x_to_position(Xen val, Xen snd, Xen chn, Xen ap) { #define H_x_to_position "(" S_x_to_position " val :optional snd chn (ax " S_time_graph ")): x pixel loc of val" - XEN_ASSERT_TYPE(XEN_NUMBER_P(val), val, XEN_ARG_1, S_x_to_position, "a number"); - ASSERT_CHANNEL(S_x_to_position, snd, chn, 2); - XEN_ASSERT_TYPE(XEN_INTEGER_IF_BOUND_P(ap), ap, XEN_ARG_4, S_x_to_position, S_time_graph ", " S_transform_graph ", or " S_lisp_graph); - return(C_TO_XEN_INT(grf_x(XEN_TO_C_DOUBLE(val), + Xen_check_type(Xen_is_number(val), val, 1, S_x_to_position, "a number"); + Snd_assert_channel(S_x_to_position, snd, chn, 2); + Xen_check_type(Xen_is_integer_or_unbound(ap), ap, 4, S_x_to_position, S_time_graph ", " S_transform_graph ", or " S_lisp_graph); + return(C_int_to_Xen_integer(grf_x(Xen_real_to_C_double(val), TO_C_AXIS_INFO(snd, chn, ap, S_x_to_position)))); } -static XEN g_y_to_position(XEN val, XEN snd, XEN chn, XEN ap) +static Xen g_y_to_position(Xen val, Xen snd, Xen chn, Xen ap) { #define H_y_to_position "(" S_y_to_position " val :optional snd chn (ax " S_time_graph ")): y pixel loc of val" - XEN_ASSERT_TYPE(XEN_NUMBER_P(val), val, XEN_ARG_1, S_y_to_position, "a number"); - ASSERT_CHANNEL(S_y_to_position, snd, chn, 2); - XEN_ASSERT_TYPE(XEN_INTEGER_IF_BOUND_P(ap), ap, XEN_ARG_4, S_y_to_position, S_time_graph ", " S_transform_graph ", or " S_lisp_graph); - return(C_TO_XEN_INT(grf_y(XEN_TO_C_DOUBLE(val), + Xen_check_type(Xen_is_number(val), val, 1, S_y_to_position, "a number"); + Snd_assert_channel(S_y_to_position, snd, chn, 2); + Xen_check_type(Xen_is_integer_or_unbound(ap), ap, 4, S_y_to_position, S_time_graph ", " S_transform_graph ", or " S_lisp_graph); + return(C_int_to_Xen_integer(grf_y(Xen_real_to_C_double(val), TO_C_AXIS_INFO(snd, chn, ap, S_y_to_position)))); } -static XEN g_position_to_x(XEN val, XEN snd, XEN chn, XEN ap) +static Xen g_position_to_x(Xen val, Xen snd, Xen chn, Xen ap) { #define H_position_to_x "(" S_position_to_x " val :optional snd chn (ax " S_time_graph ")): x axis value corresponding to pixel val" - XEN_ASSERT_TYPE(XEN_INTEGER_P(val), val, XEN_ARG_1, S_position_to_x, "an integer"); - ASSERT_CHANNEL(S_position_to_x, snd, chn, 2); - XEN_ASSERT_TYPE(XEN_INTEGER_IF_BOUND_P(ap), ap, XEN_ARG_4, S_position_to_x, S_time_graph ", " S_transform_graph ", or " S_lisp_graph); - return(C_TO_XEN_DOUBLE(ungrf_x(TO_C_AXIS_INFO(snd, chn, ap, S_position_to_x), - XEN_TO_C_INT(val)))); + Xen_check_type(Xen_is_integer(val), val, 1, S_position_to_x, "an integer"); + Snd_assert_channel(S_position_to_x, snd, chn, 2); + Xen_check_type(Xen_is_integer_or_unbound(ap), ap, 4, S_position_to_x, S_time_graph ", " S_transform_graph ", or " S_lisp_graph); + return(C_double_to_Xen_real(ungrf_x(TO_C_AXIS_INFO(snd, chn, ap, S_position_to_x), + Xen_integer_to_C_int(val)))); } -static XEN g_position_to_y(XEN val, XEN snd, XEN chn, XEN ap) +static Xen g_position_to_y(Xen val, Xen snd, Xen chn, Xen ap) { #define H_position_to_y "(" S_position_to_y " val :optional snd chn (ax " S_time_graph ")): y axis value corresponding to pixel val" - XEN_ASSERT_TYPE(XEN_INTEGER_P(val), val, XEN_ARG_1, S_position_to_y, "an integer"); - ASSERT_CHANNEL(S_position_to_y, snd, chn, 2); - XEN_ASSERT_TYPE(XEN_INTEGER_IF_BOUND_P(ap), ap, XEN_ARG_4, S_position_to_y, S_time_graph ", " S_transform_graph ", or " S_lisp_graph); - return(C_TO_XEN_DOUBLE(ungrf_y(TO_C_AXIS_INFO(snd, chn, ap, S_position_to_y), - XEN_TO_C_INT(val)))); + Xen_check_type(Xen_is_integer(val), val, 1, S_position_to_y, "an integer"); + Snd_assert_channel(S_position_to_y, snd, chn, 2); + Xen_check_type(Xen_is_integer_or_unbound(ap), ap, 4, S_position_to_y, S_time_graph ", " S_transform_graph ", or " S_lisp_graph); + return(C_double_to_Xen_real(ungrf_y(TO_C_AXIS_INFO(snd, chn, ap, S_position_to_y), + Xen_integer_to_C_int(val)))); } -static XEN g_axis_info(XEN snd, XEN chn, XEN ap_id) +static Xen g_axis_info(Xen snd, Xen chn, Xen ap_id) { #define H_axis_info "(" S_axis_info " :optional snd chn (ax " S_time_graph ")): info about axis: (list losamp hisamp \ x0 y0 x1 y1 xmin ymin xmax ymax pix_x0 pix_y0 pix_x1 pix_y1 y_offset xscale yscale xlabel ylabel new-peaks)" axis_info *ap; - ASSERT_CHANNEL(S_axis_info, snd, chn, 1); - XEN_ASSERT_TYPE(XEN_INTEGER_IF_BOUND_P(ap_id), ap_id, XEN_ARG_3, S_axis_info, S_time_graph ", " S_transform_graph ", or " S_lisp_graph); + Snd_assert_channel(S_axis_info, snd, chn, 1); + Xen_check_type(Xen_is_integer_or_unbound(ap_id), ap_id, 3, S_axis_info, S_time_graph ", " S_transform_graph ", or " S_lisp_graph); ap = TO_C_AXIS_INFO(snd, chn, ap_id, S_axis_info); - if (ap == NULL) return(XEN_EMPTY_LIST); - return(XEN_CONS(C_TO_XEN_INT64_T(ap->losamp), - XEN_CONS(C_TO_XEN_INT64_T(ap->hisamp), - XEN_CONS(C_TO_XEN_DOUBLE(ap->x0), - XEN_CONS(C_TO_XEN_DOUBLE(ap->y0), - XEN_CONS(C_TO_XEN_DOUBLE(ap->x1), - XEN_CONS(C_TO_XEN_DOUBLE(ap->y1), - XEN_CONS(C_TO_XEN_DOUBLE(ap->xmin), - XEN_CONS(C_TO_XEN_DOUBLE(ap->ymin), - XEN_CONS(C_TO_XEN_DOUBLE(ap->xmax), - XEN_CONS(C_TO_XEN_DOUBLE(ap->ymax), - XEN_CONS(C_TO_XEN_INT(ap->x_axis_x0), - XEN_CONS(C_TO_XEN_INT(ap->y_axis_y0), - XEN_CONS(C_TO_XEN_INT(ap->x_axis_x1), - XEN_CONS(C_TO_XEN_INT(ap->y_axis_y1), - XEN_CONS(C_TO_XEN_INT(ap->y_offset), - XEN_CONS(C_TO_XEN_DOUBLE(ap->x_scale), - XEN_CONS(C_TO_XEN_DOUBLE(ap->y_scale), - XEN_CONS((ap->xlabel) ? C_TO_XEN_STRING(ap->xlabel) : XEN_FALSE, - XEN_CONS((ap->ylabel) ? C_TO_XEN_STRING(ap->ylabel) : XEN_FALSE, - XEN_CONS((ap->cp) ? C_TO_XEN_BOOLEAN(ap->cp->new_peaks) : XEN_FALSE, - XEN_EMPTY_LIST))))))))))))))))))))); + if (ap == NULL) return(Xen_empty_list); + return(Xen_cons(C_llong_to_Xen_llong(ap->losamp), + Xen_cons(C_llong_to_Xen_llong(ap->hisamp), + Xen_cons(C_double_to_Xen_real(ap->x0), + Xen_cons(C_double_to_Xen_real(ap->y0), + Xen_cons(C_double_to_Xen_real(ap->x1), + Xen_cons(C_double_to_Xen_real(ap->y1), + Xen_cons(C_double_to_Xen_real(ap->xmin), + Xen_cons(C_double_to_Xen_real(ap->ymin), + Xen_cons(C_double_to_Xen_real(ap->xmax), + Xen_cons(C_double_to_Xen_real(ap->ymax), + Xen_cons(C_int_to_Xen_integer(ap->x_axis_x0), + Xen_cons(C_int_to_Xen_integer(ap->y_axis_y0), + Xen_cons(C_int_to_Xen_integer(ap->x_axis_x1), + Xen_cons(C_int_to_Xen_integer(ap->y_axis_y1), + Xen_cons(C_int_to_Xen_integer(ap->y_offset), + Xen_cons(C_double_to_Xen_real(ap->x_scale), + Xen_cons(C_double_to_Xen_real(ap->y_scale), + Xen_cons((ap->xlabel) ? C_string_to_Xen_string(ap->xlabel) : Xen_false, + Xen_cons((ap->ylabel) ? C_string_to_Xen_string(ap->ylabel) : Xen_false, + Xen_cons((ap->cp) ? C_bool_to_Xen_boolean(ap->cp->new_peaks) : Xen_false, + Xen_empty_list))))))))))))))))))))); } #if USE_MOTIF - #define XEN_UNWRAP_SND_GC(Value) XEN_UNWRAP_C_POINTER(XEN_CADR(Value)) - #define XEN_SND_GC_P(Value) (XEN_LIST_P(Value) && (XEN_LIST_LENGTH(Value) >= 2) && \ - (XEN_SYMBOL_P(XEN_CAR(Value))) && \ - (strcmp("GC", XEN_SYMBOL_TO_C_STRING(XEN_CAR(Value))) == 0)) + #define Xen_unwrap_snd_gc(Value) Xen_unwrap_C_pointer(Xen_cadr(Value)) + #define Xen_is_GC(Value) (Xen_is_list(Value) && (Xen_list_length(Value) >= 2) && \ + (Xen_is_symbol(Xen_car(Value))) && \ + (strcmp("GC", Xen_symbol_to_C_string(Xen_car(Value))) == 0)) #else #if USE_GTK - #define XEN_UNWRAP_SND_GC(Value) (gc_t *)(XEN_UNWRAP_C_POINTER(XEN_CADR(Value))) - #define XEN_SND_GC_P(Value) (XEN_LIST_P(Value) && (XEN_LIST_LENGTH(Value) >= 2) && \ - (XEN_SYMBOL_P(XEN_CAR(Value))) && \ - (strcmp("gc_t_", XEN_SYMBOL_TO_C_STRING(XEN_CAR(Value))) == 0)) + #define Xen_unwrap_snd_gc(Value) (gc_t *)(Xen_unwrap_C_pointer(Xen_cadr(Value))) + #define Xen_is_GC(Value) (Xen_is_list(Value) && (Xen_list_length(Value) >= 2) && \ + (Xen_is_symbol(Xen_car(Value))) && \ + (strcmp("gc_t_", Xen_symbol_to_C_string(Xen_car(Value))) == 0)) #else - #define XEN_UNWRAP_SND_GC(Value) 0 - #define XEN_SND_GC_P(Value) 0 + #define Xen_unwrap_snd_gc(Value) 0 + #define Xen_is_GC(Value) 0 #endif #endif -static XEN g_draw_axes(XEN args) +static Xen g_draw_axes(Xen args) { #define H_draw_axes "(" S_draw_axes " wid gc label (x0 0.0) (x1 1.0) (y0 -1.0) (y1 1.0) (style " S_x_axis_in_seconds ") (axes " S_show_all_axes ")): \ draws axes in the widget 'wid', using the graphics context 'gc', with the x-axis label 'label' \ @@ -1631,7 +1629,7 @@ Returns actual (pixel) axis bounds -- a list (x0 y0 x1 y1)." gc_t *gc; #endif - XEN val, xwid, xgc, xx0, xx1, xy0, xy1, xstyle, xaxes, label_ref; + Xen val, xwid, xgc, label_ref; double x0 = 0.0, x1 = 1.0; mus_float_t y0 = -1.0, y1 = 1.0; x_axis_style_t x_style = X_AXIS_IN_SECONDS; @@ -1640,69 +1638,75 @@ Returns actual (pixel) axis bounds -- a list (x0 y0 x1 y1)." axis_info *ap; int len; - len = XEN_LIST_LENGTH(args); + len = Xen_list_length(args); #if (!USE_GTK) - XEN_ASSERT_TYPE((len >= 3) && (len < 10), args, XEN_ONLY_ARG, S_draw_axes, "3 required and 6 optional args"); + Xen_check_type((len >= 3) && (len < 10), args, 1, S_draw_axes, "3 required and 6 optional args"); #else - XEN_ASSERT_TYPE((len >= 3) && (len < 11), args, XEN_ONLY_ARG, S_draw_axes, "3 required and 7 optional args"); + Xen_check_type((len >= 3) && (len < 11), args, 1, S_draw_axes, "3 required and 7 optional args"); #endif - xwid = XEN_LIST_REF(args, 0); - XEN_ASSERT_TYPE(XEN_WIDGET_P(xwid), xwid, XEN_ARG_1, S_draw_axes, "widget"); - xgc = XEN_LIST_REF(args, 1); - XEN_ASSERT_TYPE(XEN_SND_GC_P(xgc), xgc, XEN_ARG_2, S_draw_axes, "snd-gc"); + xwid = Xen_list_ref(args, 0); + Xen_check_type(Xen_is_widget(xwid), xwid, 1, S_draw_axes, "widget"); + xgc = Xen_list_ref(args, 1); + Xen_check_type(Xen_is_GC(xgc), xgc, 2, S_draw_axes, "snd-gc"); #if USE_MOTIF - w = (Widget)(XEN_UNWRAP_WIDGET(xwid)); - gc = (GC)(XEN_UNWRAP_SND_GC(xgc)); + w = (Widget)(Xen_unwrap_widget(xwid)); + gc = (GC)(Xen_unwrap_snd_gc(xgc)); #endif #if USE_GTK - w = (GtkWidget *)(XEN_UNWRAP_WIDGET(xwid)); - gc = (gc_t *)(XEN_UNWRAP_SND_GC(xgc)); + w = (GtkWidget *)(Xen_unwrap_widget(xwid)); + gc = (gc_t *)(Xen_unwrap_snd_gc(xgc)); #endif - label_ref = XEN_LIST_REF(args, 2); - XEN_ASSERT_TYPE(XEN_STRING_P(label_ref) || XEN_FALSE_P(label_ref), label_ref, XEN_ARG_3, S_draw_axes, "a string"); + label_ref = Xen_list_ref(args, 2); + Xen_check_type(Xen_is_string(label_ref) || Xen_is_false(label_ref), label_ref, 3, S_draw_axes, "a string"); if (len > 3) { - xx0 = XEN_LIST_REF(args, 3); - XEN_ASSERT_TYPE(XEN_NUMBER_P(xx0), xx0, XEN_ARG_4, S_draw_axes, "a number"); - x0 = XEN_TO_C_DOUBLE(xx0); + Xen xx0; + xx0 = Xen_list_ref(args, 3); + Xen_check_type(Xen_is_number(xx0), xx0, 4, S_draw_axes, "a number"); + x0 = Xen_real_to_C_double(xx0); if (len > 4) { - xx1 = XEN_LIST_REF(args, 4); - XEN_ASSERT_TYPE(XEN_NUMBER_P(xx1), xx1, XEN_ARG_5, S_draw_axes, "a number"); - x1 = XEN_TO_C_DOUBLE(xx1); + Xen xx1; + xx1 = Xen_list_ref(args, 4); + Xen_check_type(Xen_is_number(xx1), xx1, 5, S_draw_axes, "a number"); + x1 = Xen_real_to_C_double(xx1); if (len > 5) { - xy0 = XEN_LIST_REF(args, 5); - XEN_ASSERT_TYPE(XEN_NUMBER_P(xy0), xy0, XEN_ARG_6, S_draw_axes, "a number"); - y0 = XEN_TO_C_DOUBLE(xy0); + Xen xy0; + xy0 = Xen_list_ref(args, 5); + Xen_check_type(Xen_is_number(xy0), xy0, 6, S_draw_axes, "a number"); + y0 = Xen_real_to_C_double(xy0); if (len > 6) { - xy1 = XEN_LIST_REF(args, 6); - XEN_ASSERT_TYPE(XEN_NUMBER_P(xy1), xy1, XEN_ARG_7, S_draw_axes, "a number"); - y1 = XEN_TO_C_DOUBLE(xy1); + Xen xy1; + xy1 = Xen_list_ref(args, 6); + Xen_check_type(Xen_is_number(xy1), xy1, 7, S_draw_axes, "a number"); + y1 = Xen_real_to_C_double(xy1); if (len > 7) { + Xen xstyle; int tmp; - xstyle = XEN_LIST_REF(args, 7); - XEN_ASSERT_TYPE(XEN_INTEGER_P(xstyle), xstyle, XEN_ARG_8, S_draw_axes, "axis style"); - tmp = XEN_TO_C_INT(xstyle); - if (!(x_axis_style_p(tmp))) - XEN_OUT_OF_RANGE_ERROR(S_draw_axes, 7, xstyle, "axis style"); + xstyle = Xen_list_ref(args, 7); + Xen_check_type(Xen_is_integer(xstyle), xstyle, 8, S_draw_axes, "axis style"); + tmp = Xen_integer_to_C_int(xstyle); + if (!(is_x_axis_style(tmp))) + Xen_out_of_range_error(S_draw_axes, 7, xstyle, "axis style"); x_style = (x_axis_style_t)tmp; if (len > 8) { - xaxes = XEN_LIST_REF(args, 8); - XEN_ASSERT_TYPE(XEN_INTEGER_P(xaxes), xaxes, XEN_ARG_9, S_draw_axes, S_show_axes " choice"); - tmp = XEN_TO_C_INT(xaxes); - if (!(show_axes_p(tmp))) - XEN_OUT_OF_RANGE_ERROR(S_draw_axes, 8, xaxes, S_show_axes " choice"); - axes = (show_axes_t)XEN_TO_C_INT(xaxes); + Xen xaxes; + xaxes = Xen_list_ref(args, 8); + Xen_check_type(Xen_is_integer(xaxes), xaxes, 9, S_draw_axes, S_show_axes " choice"); + tmp = Xen_integer_to_C_int(xaxes); + if (!(shows_axes(tmp))) + Xen_out_of_range_error(S_draw_axes, 8, xaxes, S_show_axes " choice"); + axes = (show_axes_t)Xen_integer_to_C_int(xaxes); #if USE_GTK if (len > 9) - ss->cr = (cairo_t *)XEN_UNWRAP_C_POINTER(XEN_CADR(XEN_LIST_REF(args, 9))); + ss->cr = (cairo_t *)Xen_unwrap_C_pointer(Xen_cadr(Xen_list_ref(args, 9))); #endif }}}}}} @@ -1719,8 +1723,8 @@ Returns actual (pixel) axis bounds -- a list (x0 y0 x1 y1)." ax->wn = WIDGET_TO_WINDOW(w); ax->w = w; if (!ss->cr) - XEN_ERROR(XEN_ERROR_TYPE("no-cairo-t"), - XEN_LIST_1(C_TO_XEN_STRING(S_draw_axes ": in Gtk, the trailing cairo_t argument is not optional"))); + Xen_error(Xen_make_error_type("no-cairo-t"), + Xen_list_1(C_string_to_Xen_string(S_draw_axes ": in Gtk, the trailing cairo_t argument is not optional"))); #endif ap->xmin = x0; @@ -1729,8 +1733,8 @@ Returns actual (pixel) axis bounds -- a list (x0 y0 x1 y1)." ap->ymax = y1; ap->y_ambit = y1 - y0; ap->x_ambit = x1 - x0; - if (XEN_STRING_P(label_ref)) - ap->xlabel = mus_strdup(XEN_TO_C_STRING(label_ref)); + if (Xen_is_string(label_ref)) + ap->xlabel = mus_strdup(Xen_string_to_C_string(label_ref)); ap->x0 = x0; ap->x1 = x1; ap->y0 = y0; @@ -1745,128 +1749,137 @@ Returns actual (pixel) axis bounds -- a list (x0 y0 x1 y1)." make_axes_1(ap, x_style, 1, axes, NOT_PRINTING, WITH_X_AXIS, NO_GRID, WITH_LINEAR_AXES, grid_density(ss)); - val = XEN_CONS(C_TO_XEN_INT(ap->x_axis_x0), - XEN_CONS(C_TO_XEN_INT(ap->y_axis_y0), - XEN_CONS(C_TO_XEN_INT(ap->x_axis_x1), - XEN_CONS(C_TO_XEN_INT(ap->y_axis_y1), - XEN_EMPTY_LIST)))); + val = Xen_cons(C_int_to_Xen_integer(ap->x_axis_x0), + Xen_cons(C_int_to_Xen_integer(ap->y_axis_y0), + Xen_cons(C_int_to_Xen_integer(ap->x_axis_x1), + Xen_cons(C_int_to_Xen_integer(ap->y_axis_y1), + Xen_empty_list)))); free_axis_info(ap); return(val); } -static XEN g_x_axis_label(XEN snd, XEN chn, XEN ax) +static Xen g_x_axis_label(Xen snd, Xen chn, Xen ax) { #define H_x_axis_label "(" S_x_axis_label " :optional snd chn (ax " S_time_graph ")): current x axis label" axis_info *ap; - ASSERT_CHANNEL(S_x_axis_label, snd, chn, 1); - XEN_ASSERT_TYPE(XEN_INTEGER_IF_BOUND_P(ax), ax, XEN_ARG_3, S_x_axis_label, S_time_graph ", " S_transform_graph ", or " S_lisp_graph); + + Snd_assert_channel(S_x_axis_label, snd, chn, 1); + Xen_check_type(Xen_is_integer_or_unbound(ax), ax, 3, S_x_axis_label, S_time_graph ", " S_transform_graph ", or " S_lisp_graph); ap = TO_C_AXIS_INFO(snd, chn, ax, S_x_axis_label); - return(C_TO_XEN_STRING(ap->xlabel)); + + return(C_string_to_Xen_string(ap->xlabel)); } -static XEN g_set_x_axis_label(XEN label, XEN snd, XEN chn, XEN ax) + +static Xen g_set_x_axis_label(Xen label, Xen snd, Xen chn, Xen ax) { axis_info *ap; - ASSERT_CHANNEL(S_setB S_x_axis_label, snd, chn, 2); - XEN_ASSERT_TYPE(XEN_STRING_P(label) || XEN_FALSE_P(label), label, XEN_ARG_1, S_setB S_x_axis_label, "a string"); - XEN_ASSERT_TYPE(XEN_INTEGER_IF_BOUND_P(ax), ax, XEN_ARG_4, S_setB S_x_axis_label, S_time_graph ", " S_transform_graph ", or " S_lisp_graph); + + Snd_assert_channel(S_set S_x_axis_label, snd, chn, 2); + Xen_check_type(Xen_is_string(label) || Xen_is_false(label), label, 1, S_set S_x_axis_label, "a string"); + Xen_check_type(Xen_is_integer_or_unbound(ax), ax, 4, S_set S_x_axis_label, S_time_graph ", " S_transform_graph ", or " S_lisp_graph); + ap = TO_C_AXIS_INFO(snd, chn, ax, S_x_axis_label); if (ap->xlabel) free(ap->xlabel); if (ap->default_xlabel) free(ap->default_xlabel); - if (XEN_FALSE_P(label)) + + if (Xen_is_false(label)) { ap->xlabel = NULL; ap->default_xlabel = NULL; } else { - ap->xlabel = mus_strdup(XEN_TO_C_STRING(label)); - if ((XEN_INTEGER_P(ax)) && (XEN_TO_C_INT(ax) == (int)TRANSFORM_AXIS_INFO)) + ap->xlabel = mus_strdup(Xen_string_to_C_string(label)); + if ((Xen_is_integer(ax)) && (Xen_integer_to_C_int(ax) == (int)TRANSFORM_AXIS_INFO)) set_fft_info_xlabel(ap->cp, ap->xlabel); ap->default_xlabel = mus_strdup(ap->xlabel); } + update_graph(ap->cp); return(label); } -WITH_FOUR_SETTER_ARGS(g_set_x_axis_label_reversed, g_set_x_axis_label) +with_four_setter_args(g_set_x_axis_label_reversed, g_set_x_axis_label) -static XEN g_y_axis_label(XEN snd, XEN chn, XEN ax) +static Xen g_y_axis_label(Xen snd, Xen chn, Xen ax) { #define H_y_axis_label "(" S_y_axis_label " :optional snd chn (ax " S_time_graph ")): current y axis label" axis_info *ap; - ASSERT_CHANNEL(S_y_axis_label, snd, chn, 1); - XEN_ASSERT_TYPE(XEN_INTEGER_IF_BOUND_P(ax), ax, XEN_ARG_3, S_y_axis_label, S_time_graph ", " S_transform_graph ", or " S_lisp_graph); + + Snd_assert_channel(S_y_axis_label, snd, chn, 1); + Xen_check_type(Xen_is_integer_or_unbound(ax), ax, 3, S_y_axis_label, S_time_graph ", " S_transform_graph ", or " S_lisp_graph); ap = TO_C_AXIS_INFO(snd, chn, ax, S_y_axis_label); - return(C_TO_XEN_STRING(ap->ylabel)); + + return(C_string_to_Xen_string(ap->ylabel)); } -static XEN g_set_y_axis_label(XEN label, XEN snd, XEN chn, XEN ax) +static Xen g_set_y_axis_label(Xen label, Xen snd, Xen chn, Xen ax) { axis_info *ap; - ASSERT_CHANNEL(S_setB S_y_axis_label, snd, chn, 2); - XEN_ASSERT_TYPE(XEN_STRING_P(label) || XEN_FALSE_P(label), label, XEN_ARG_1, S_setB S_y_axis_label, "a string"); + Snd_assert_channel(S_set S_y_axis_label, snd, chn, 2); + Xen_check_type(Xen_is_string(label) || Xen_is_false(label), label, 1, S_set S_y_axis_label, "a string"); - XEN_ASSERT_TYPE(XEN_INTEGER_IF_BOUND_P(ax), ax, XEN_ARG_4, S_setB S_y_axis_label, S_time_graph ", " S_transform_graph ", or " S_lisp_graph); + Xen_check_type(Xen_is_integer_or_unbound(ax), ax, 4, S_set S_y_axis_label, S_time_graph ", " S_transform_graph ", or " S_lisp_graph); ap = TO_C_AXIS_INFO(snd, chn, ax, S_y_axis_label); if (ap->ylabel) free(ap->ylabel); - if (XEN_FALSE_P(label)) + if (Xen_is_false(label)) ap->ylabel = NULL; - else ap->ylabel = mus_strdup(XEN_TO_C_STRING(label)); + else ap->ylabel = mus_strdup(Xen_string_to_C_string(label)); update_graph(ap->cp); return(label); } -WITH_FOUR_SETTER_ARGS(g_set_y_axis_label_reversed, g_set_y_axis_label) +with_four_setter_args(g_set_y_axis_label_reversed, g_set_y_axis_label) -static XEN g_x_bounds(XEN snd, XEN chn, XEN ax) +static Xen g_x_bounds(Xen snd, Xen chn, Xen ax) { #define H_x_bounds "(" S_x_bounds " :optional snd chn axis): a list (x0 x1) giving the current x axis bounds of snd channel chn" axis_info *ap; - ASSERT_CHANNEL(S_x_bounds, snd, chn, 1); - XEN_ASSERT_TYPE(XEN_INTEGER_IF_BOUND_P(ax), ax, XEN_ARG_4, S_x_bounds, S_time_graph ", " S_transform_graph ", or " S_lisp_graph); + Snd_assert_channel(S_x_bounds, snd, chn, 1); + Xen_check_type(Xen_is_integer_or_unbound(ax), ax, 4, S_x_bounds, S_time_graph ", " S_transform_graph ", or " S_lisp_graph); ap = TO_C_AXIS_INFO(snd, chn, ax, S_x_bounds); - return(XEN_LIST_2(C_TO_XEN_DOUBLE(ap->x0), - C_TO_XEN_DOUBLE(ap->x1))); + return(Xen_list_2(C_double_to_Xen_real(ap->x0), + C_double_to_Xen_real(ap->x1))); /* wavogram settings depend on context -- no easy way to map back to user's notion of bounds */ } -static XEN g_set_x_bounds(XEN bounds, XEN snd, XEN chn, XEN ax) +static Xen g_set_x_bounds(Xen bounds, Xen snd, Xen chn, Xen ax) { chan_info *cp; axis_info *ap; mus_float_t x0 = 0.0, x1 = 0.0; - ASSERT_CHANNEL(S_setB S_x_bounds, snd, chn, 2); - XEN_ASSERT_TYPE(XEN_NUMBER_P(bounds) || (XEN_LIST_P(bounds) && (XEN_LIST_LENGTH(bounds) == 2)), bounds, XEN_ARG_1, S_setB S_x_bounds, "a list: (x0 x1) or a number"); - XEN_ASSERT_TYPE(XEN_INTEGER_IF_BOUND_P(ax), ax, XEN_ARG_4, S_setB S_x_bounds, S_time_graph ", " S_transform_graph ", or " S_lisp_graph); - ap = TO_C_AXIS_INFO(snd, chn, ax, S_setB S_x_bounds); + Snd_assert_channel(S_set S_x_bounds, snd, chn, 2); + Xen_check_type(Xen_is_number(bounds) || (Xen_is_list(bounds) && (Xen_list_length(bounds) == 2)), bounds, 1, S_set S_x_bounds, "a list: (x0 x1) or a number"); + Xen_check_type(Xen_is_integer_or_unbound(ax), ax, 4, S_set S_x_bounds, S_time_graph ", " S_transform_graph ", or " S_lisp_graph); + ap = TO_C_AXIS_INFO(snd, chn, ax, S_set S_x_bounds); - cp = get_cp(snd, chn, S_setB S_x_bounds); - if (!cp) return(XEN_FALSE); + cp = get_cp(snd, chn, S_set S_x_bounds); + if (!cp) return(Xen_false); - if (XEN_NUMBER_P(bounds)) + if (Xen_is_number(bounds)) { x0 = 0.0; - x1 = XEN_TO_C_DOUBLE(bounds); + x1 = Xen_real_to_C_double(bounds); } else { - x0 = XEN_TO_C_DOUBLE(XEN_CAR(bounds)); - x1 = XEN_TO_C_DOUBLE(XEN_CADR(bounds)); + x0 = Xen_real_to_C_double(Xen_car(bounds)); + x1 = Xen_real_to_C_double(Xen_cadr(bounds)); if (x1 < x0) - XEN_OUT_OF_RANGE_ERROR(S_setB S_x_bounds, 1, bounds, "~A: x1 < x0?"); + Xen_out_of_range_error(S_set S_x_bounds, 1, bounds, "x1 < x0?"); } if (ap == cp->axis) @@ -1878,7 +1891,7 @@ static XEN g_set_x_bounds(XEN bounds, XEN snd, XEN chn, XEN ax) sp = cp->sound; if (sp->nchans > 1) { - if ((XEN_NOT_BOUND_P(chn)) && (cp->sound->channel_style == CHANNELS_COMBINED)) + if ((!Xen_is_bound(chn)) && (cp->sound->channel_style == CHANNELS_COMBINED)) { int i; for (i = 0; i < sp->nchans; i++) @@ -1897,58 +1910,59 @@ static XEN g_set_x_bounds(XEN bounds, XEN snd, XEN chn, XEN ax) return(bounds); } -WITH_FOUR_SETTER_ARGS(g_set_x_bounds_reversed, g_set_x_bounds) +with_four_setter_args(g_set_x_bounds_reversed, g_set_x_bounds) -static XEN g_y_bounds(XEN snd, XEN chn, XEN ax) +static Xen g_y_bounds(Xen snd, Xen chn, Xen ax) { #define H_y_bounds "(" S_y_bounds " :optional snd chn axis): a list (y0 y1) giving the current y axis bounds of snd channel chn" axis_info *ap; - ASSERT_CHANNEL(S_y_bounds, snd, chn, 1); - XEN_ASSERT_TYPE(XEN_INTEGER_IF_BOUND_P(ax), ax, XEN_ARG_4, S_y_bounds, S_time_graph ", " S_transform_graph ", or " S_lisp_graph); - ap = TO_C_AXIS_INFO(snd, chn, ax, S_x_bounds); + Snd_assert_channel(S_y_bounds, snd, chn, 1); + Xen_check_type(Xen_is_integer_or_unbound(ax), ax, 4, S_y_bounds, S_time_graph ", " S_transform_graph ", or " S_lisp_graph); + ap = TO_C_AXIS_INFO(snd, chn, ax, S_y_bounds); - return(XEN_LIST_2(C_TO_XEN_DOUBLE(ap->y0), - C_TO_XEN_DOUBLE(ap->y1))); + return(Xen_list_2(C_double_to_Xen_real(ap->y0), + C_double_to_Xen_real(ap->y1))); } -static XEN g_set_y_bounds(XEN bounds, XEN snd, XEN chn, XEN ax) +static Xen g_set_y_bounds(Xen bounds, Xen snd, Xen chn, Xen ax) { chan_info *cp; axis_info *ap; mus_float_t low = 0.0, hi = 0.0; - int len = 0; - XEN y0 = XEN_UNDEFINED, y1 = XEN_UNDEFINED; + Xen y0 = Xen_undefined, y1 = Xen_undefined; - ASSERT_CHANNEL(S_setB S_y_bounds, snd, chn, 2); - XEN_ASSERT_TYPE(XEN_NUMBER_P(bounds) || XEN_LIST_P_WITH_LENGTH(bounds, len), bounds, XEN_ARG_1, S_setB S_y_bounds, "a list or a number"); - XEN_ASSERT_TYPE(XEN_INTEGER_IF_BOUND_P(ax), ax, XEN_ARG_4, S_setB S_y_bounds, S_time_graph ", " S_transform_graph ", or " S_lisp_graph); - ap = TO_C_AXIS_INFO(snd, chn, ax, S_setB S_y_bounds); + Snd_assert_channel(S_set S_y_bounds, snd, chn, 2); + Xen_check_type((Xen_is_number(bounds)) || (Xen_is_list(bounds)), bounds, 1, S_set S_y_bounds, "a list or a number"); + Xen_check_type(Xen_is_integer_or_unbound(ax), ax, 4, S_set S_y_bounds, S_time_graph ", " S_transform_graph ", or " S_lisp_graph); + ap = TO_C_AXIS_INFO(snd, chn, ax, S_set S_y_bounds); - cp = get_cp(snd, chn, S_setB S_y_bounds); - if (!cp) return(XEN_FALSE); + cp = get_cp(snd, chn, S_set S_y_bounds); + if (!cp) return(Xen_false); - if (XEN_NUMBER_P(bounds)) + if (Xen_is_number(bounds)) { - hi = XEN_TO_C_DOUBLE(bounds); + hi = Xen_real_to_C_double(bounds); low = -hi; } else { + int len; + len = Xen_list_length(bounds); if (len > 0) { - y0 = XEN_CAR(bounds); + y0 = Xen_car(bounds); if (len > 1) - y1 = XEN_CADR(bounds); + y1 = Xen_cadr(bounds); } - if (XEN_NUMBER_P(y0)) + if (Xen_is_number(y0)) { - low = XEN_TO_C_DOUBLE(y0); - if (XEN_NUMBER_P(y1)) - hi = XEN_TO_C_DOUBLE(y1); + low = Xen_real_to_C_double(y0); + if (Xen_is_number(y1)) + hi = Xen_real_to_C_double(y1); else { if (low < 0.0) @@ -1985,81 +1999,60 @@ static XEN g_set_y_bounds(XEN bounds, XEN snd, XEN chn, XEN ax) if (ap == cp->axis) { resize_sy_and_zy(cp); - apply_y_axis_change(ap, cp); + apply_y_axis_change(cp); } } return(bounds); } -WITH_FOUR_SETTER_ARGS(g_set_y_bounds_reversed, g_set_y_bounds) +with_four_setter_args(g_set_y_bounds_reversed, g_set_y_bounds) -#ifdef XEN_ARGIFY_1 - -XEN_ARGIFY_4(g_x_to_position_w, g_x_to_position) -XEN_ARGIFY_4(g_y_to_position_w, g_y_to_position) -XEN_ARGIFY_4(g_position_to_x_w, g_position_to_x) -XEN_ARGIFY_4(g_position_to_y_w, g_position_to_y) -XEN_ARGIFY_3(g_axis_info_w, g_axis_info) +Xen_wrap_4_optional_args(g_x_to_position_w, g_x_to_position) +Xen_wrap_4_optional_args(g_y_to_position_w, g_y_to_position) +Xen_wrap_4_optional_args(g_position_to_x_w, g_position_to_x) +Xen_wrap_4_optional_args(g_position_to_y_w, g_position_to_y) +Xen_wrap_3_optional_args(g_axis_info_w, g_axis_info) #if (!USE_NO_GUI) -XEN_VARGIFY(g_draw_axes_w, g_draw_axes) +Xen_wrap_any_args(g_draw_axes_w, g_draw_axes) #endif -XEN_ARGIFY_3(g_x_axis_label_w, g_x_axis_label) -XEN_ARGIFY_4(g_set_x_axis_label_w, g_set_x_axis_label) -XEN_ARGIFY_3(g_y_axis_label_w, g_y_axis_label) -XEN_ARGIFY_4(g_set_y_axis_label_w, g_set_y_axis_label) -XEN_ARGIFY_3(g_x_bounds_w, g_x_bounds) -XEN_ARGIFY_4(g_set_x_bounds_w, g_set_x_bounds) -XEN_ARGIFY_3(g_y_bounds_w, g_y_bounds) -XEN_ARGIFY_4(g_set_y_bounds_w, g_set_y_bounds) - +Xen_wrap_3_optional_args(g_x_axis_label_w, g_x_axis_label) +Xen_wrap_3_optional_args(g_y_axis_label_w, g_y_axis_label) +Xen_wrap_3_optional_args(g_x_bounds_w, g_x_bounds) +Xen_wrap_3_optional_args(g_y_bounds_w, g_y_bounds) +#if HAVE_SCHEME +#define g_set_x_axis_label_w g_set_x_axis_label_reversed +#define g_set_y_axis_label_w g_set_y_axis_label_reversed +#define g_set_x_bounds_w g_set_x_bounds_reversed +#define g_set_y_bounds_w g_set_y_bounds_reversed #else - -#define g_x_to_position_w g_x_to_position -#define g_y_to_position_w g_y_to_position -#define g_position_to_x_w g_position_to_x -#define g_position_to_y_w g_position_to_y -#define g_axis_info_w g_axis_info -#define g_draw_axes_w g_draw_axes -#define g_x_axis_label_w g_x_axis_label -#define g_set_x_axis_label_w g_set_x_axis_label -#define g_y_axis_label_w g_y_axis_label -#define g_set_y_axis_label_w g_set_y_axis_label -#define g_x_bounds_w g_x_bounds -#define g_set_x_bounds_w g_set_x_bounds -#define g_y_bounds_w g_y_bounds -#define g_set_y_bounds_w g_set_y_bounds - +Xen_wrap_4_optional_args(g_set_x_axis_label_w, g_set_x_axis_label) +Xen_wrap_4_optional_args(g_set_y_axis_label_w, g_set_y_axis_label) +Xen_wrap_4_optional_args(g_set_x_bounds_w, g_set_x_bounds) +Xen_wrap_4_optional_args(g_set_y_bounds_w, g_set_y_bounds) #endif void g_init_axis(void) { - XEN_DEFINE_PROCEDURE(S_x_to_position, g_x_to_position_w, 1, 3, 0, H_x_to_position); - XEN_DEFINE_PROCEDURE(S_y_to_position, g_y_to_position_w, 1, 3, 0, H_y_to_position); - XEN_DEFINE_PROCEDURE(S_position_to_x, g_position_to_x_w, 1, 3, 0, H_position_to_x); - XEN_DEFINE_PROCEDURE(S_position_to_y, g_position_to_y_w, 1, 3, 0, H_position_to_y); - XEN_DEFINE_PROCEDURE(S_axis_info, g_axis_info_w, 0, 3, 0, H_axis_info); - XEN_DEFINE_PROCEDURE(S_draw_axes, g_draw_axes_w, 0, 0, 1, H_draw_axes); - - XEN_DEFINE_PROCEDURE_WITH_REVERSED_SETTER(S_x_axis_label, g_x_axis_label_w, H_x_axis_label, - S_setB S_x_axis_label, g_set_x_axis_label_w, g_set_x_axis_label_reversed, 0, 3, 1, 3); + Xen_define_safe_procedure(S_x_to_position, g_x_to_position_w, 1, 3, 0, H_x_to_position); + Xen_define_safe_procedure(S_y_to_position, g_y_to_position_w, 1, 3, 0, H_y_to_position); + Xen_define_safe_procedure(S_position_to_x, g_position_to_x_w, 1, 3, 0, H_position_to_x); + Xen_define_safe_procedure(S_position_to_y, g_position_to_y_w, 1, 3, 0, H_position_to_y); + Xen_define_safe_procedure(S_axis_info, g_axis_info_w, 0, 3, 0, H_axis_info); + Xen_define_safe_procedure(S_draw_axes, g_draw_axes_w, 0, 0, 1, H_draw_axes); - XEN_DEFINE_PROCEDURE_WITH_REVERSED_SETTER(S_y_axis_label, g_y_axis_label_w, H_y_axis_label, - S_setB S_y_axis_label, g_set_y_axis_label_w, g_set_y_axis_label_reversed, 0, 3, 1, 3); - - XEN_DEFINE_PROCEDURE_WITH_REVERSED_SETTER(S_x_bounds, g_x_bounds_w, H_x_bounds, - S_setB S_x_bounds, g_set_x_bounds_w, g_set_x_bounds_reversed, 0, 3, 1, 3); - - XEN_DEFINE_PROCEDURE_WITH_REVERSED_SETTER(S_y_bounds, g_y_bounds_w, H_y_bounds, - S_setB S_y_bounds, g_set_y_bounds_w, g_set_y_bounds_reversed, 0, 3, 1, 3); - - XEN_DEFINE_CONSTANT(S_time_graph, TIME_AXIS_INFO, "time domain graph axis info"); - XEN_DEFINE_CONSTANT(S_transform_graph, TRANSFORM_AXIS_INFO, "frequency domain graph axis info"); - XEN_DEFINE_CONSTANT(S_lisp_graph, LISP_AXIS_INFO, "lisp graph axis info"); + Xen_define_dilambda(S_x_axis_label, g_x_axis_label_w, H_x_axis_label, S_set S_x_axis_label, g_set_x_axis_label_w, 0, 3, 1, 3); + Xen_define_dilambda(S_y_axis_label, g_y_axis_label_w, H_y_axis_label, S_set S_y_axis_label, g_set_y_axis_label_w, 0, 3, 1, 3); + Xen_define_dilambda(S_x_bounds, g_x_bounds_w, H_x_bounds, S_set S_x_bounds, g_set_x_bounds_w, 0, 3, 1, 3); + Xen_define_dilambda(S_y_bounds, g_y_bounds_w, H_y_bounds, S_set S_y_bounds, g_set_y_bounds_w, 0, 3, 1, 3); + + Xen_define_constant(S_time_graph, TIME_AXIS_INFO, "time domain graph axis info"); + Xen_define_constant(S_transform_graph, TRANSFORM_AXIS_INFO, "frequency domain graph axis info"); + Xen_define_constant(S_lisp_graph, LISP_AXIS_INFO, "lisp graph axis info"); } #endif |