static SCM scm_all_clients(void) { SCM clients = SCM_EOL; SCM smob; client_t *client = client_list; while (client) { SCM_NEWSMOB(smob, client_tag, client); clients = scm_append(scm_list_2(clients, scm_list_1(smob))); client = client->next; } return clients; }
void weechat_guile_hashtable_map_cb (void *data, struct t_hashtable *hashtable, const char *key, const char *value) { SCM *alist, pair, list; /* make C compiler happy */ (void) hashtable; alist = (SCM *)data; pair = scm_cons (scm_from_locale_string (key), scm_from_locale_string (value)); list = scm_list_1 (pair); *alist = scm_append (scm_list_2 (*alist, list)); }
static void gnc_column_view_edit_remove_cb(GtkButton * button, gpointer user_data) { gnc_column_view_edit * r = user_data; SCM newlist = SCM_EOL; SCM oldlist = r->contents_list; int count; int oldlength; if (scm_is_list(r->contents_list)) { oldlength = scm_ilength(r->contents_list); if (oldlength > r->contents_selected) { for (count = 0; count < r->contents_selected; count++) { newlist = scm_cons(SCM_CAR(oldlist), newlist); oldlist = SCM_CDR(oldlist); } if (count <= oldlength) { newlist = scm_append(scm_listify(scm_reverse(newlist), SCM_CDR(oldlist), SCM_UNDEFINED)); } } if (r->contents_selected > 0 && oldlength == r->contents_selected + 1) { r->contents_selected --; } scm_gc_unprotect_object(r->contents_list); r->contents_list = newlist; scm_gc_protect_object(r->contents_list); gnc_column_view_set_option(r->odb, "__general", "report-list", r->contents_list); gnc_options_dialog_changed (r->optwin); } update_display_lists(r); }
static void gnc_edit_column_view_move_up_cb(GtkButton * button, gpointer user_data) { gnc_column_view_edit * r = user_data; SCM oldlist = r->contents_list; SCM newlist = SCM_EOL; SCM temp; int oldlength; int count; oldlength = scm_ilength(r->contents_list); if ((r->contents_selected > 0) && (oldlength > r->contents_selected)) { for (count = 1; count < r->contents_selected; count++) { newlist = scm_cons(SCM_CAR(oldlist), newlist); oldlist = SCM_CDR(oldlist); } temp = SCM_CAR(oldlist); oldlist = SCM_CDR(oldlist); newlist = scm_cons(temp, scm_cons(SCM_CAR(oldlist), newlist)); newlist = scm_append(scm_listify(scm_reverse(newlist), SCM_CDR(oldlist), SCM_UNDEFINED)); scm_gc_unprotect_object(r->contents_list); r->contents_list = newlist; scm_gc_protect_object(r->contents_list); r->contents_selected = r->contents_selected - 1; gnc_column_view_set_option(r->odb, "__general", "report-list", r->contents_list); gnc_options_dialog_changed (r->optwin); update_display_lists(r); } }
static void gnc_column_view_edit_add_cb(GtkButton * button, gpointer user_data) { gnc_column_view_edit * r = user_data; SCM make_report = scm_c_eval_string("gnc:make-report"); SCM mark_report = scm_c_eval_string("gnc:report-set-needs-save?!"); SCM template_name; SCM new_report; SCM newlist = SCM_EOL; SCM oldlist = r->contents_list; int count; int oldlength, id; if (scm_is_list(r->available_list) && (scm_ilength(r->available_list) > r->available_selected)) { template_name = scm_list_ref(r->available_list, scm_int2num(r->available_selected)); new_report = scm_call_1(make_report, template_name); id = scm_num2int(new_report, SCM_ARG1, G_STRFUNC); scm_call_2(mark_report, gnc_report_find(id), SCM_BOOL_T); oldlength = scm_ilength(r->contents_list); if (oldlength > r->contents_selected) { for (count = 0; count < r->contents_selected; count++) { newlist = scm_cons(SCM_CAR(oldlist), newlist); oldlist = SCM_CDR(oldlist); } newlist = scm_append (scm_listify(scm_reverse(scm_cons(SCM_LIST4(new_report, scm_int2num(1), scm_int2num(1), SCM_BOOL_F), newlist)), oldlist, SCM_UNDEFINED)); } else { newlist = scm_append (scm_listify(oldlist, SCM_LIST1(SCM_LIST4(new_report, scm_int2num(1), scm_int2num(1), SCM_BOOL_F)), SCM_UNDEFINED)); r->contents_selected = oldlength; } scm_gc_unprotect_object(r->contents_list); r->contents_list = newlist; scm_gc_protect_object(r->contents_list); gnc_column_view_set_option(r->odb, "__general", "report-list", r->contents_list); gnc_options_dialog_changed (r->optwin); } update_display_lists(r); }
static void process(scm *s, scm **V, int C, int O) { const size_t S = (size_t) (scm_get_n(s) + 2) * (size_t) (scm_get_n(s) + 2) * (size_t) (scm_get_c(s)); float *p; float *q; // Allocate temporary and accumulator buffers. if ((p = scm_alloc_buffer(s)) && (q = scm_alloc_buffer(s))) { long long b = 0; long long m = 0; long long i = 0; long long o[256]; // Determine the highest page index in the input. for (int f = 0; f < C; ++f) { if (m < scm_get_index(V[f], scm_get_length(V[f]) - 1)) m = scm_get_index(V[f], scm_get_length(V[f]) - 1); o[f] = 0; } // Process each page of an SCM with the desired depth. for (int x = 0; x <= m; ++x) { int c = scm_get_c(s); int g = 0; int k = 0; // Count the SCMs contributing to page x. for (int f = 0; f < C; ++f) if ((i = scm_search(V[f], x)) < 0) o[f] = 0; else { o[f] = scm_get_offset(V[f], i); g = f; k++; } // If there is exactly one contributor, repeat its page. if (k == 1) b = scm_repeat(s, b, V[g], o[g]); // If there is more than one, append their summed pages. else if (k > 1) { memset(p, 0, S * sizeof (float)); for (int f = 0; f < C; ++f) if (o[f] && scm_read_page(V[f], o[f], q)) switch (O) { case 0: for (size_t j = 0; j < S; ++j) p[j] = sum(p[j], q[j]); break; case 1: for (size_t j = 0; j < S; ++j) p[j] = max(p[j], q[j]); break; case 2: for (size_t j = 0; j < S; ++j) p[j] = avg(p[j], q[j]); break; case 3: for (size_t j = 0; j < S; j += c) blend(p + j, q + j, c); break; } b = scm_append(s, b, x, p); } } free(q); free(p); } }