static bool process_pipe(int fd, ExtlFn fn, bool *doneseen, bool *eagain) { char buf[BL]; int n; *eagain=FALSE; n=read(fd, buf, BL-1); if(n<0){ if(errno==EAGAIN || errno==EINTR){ *eagain=(errno==EAGAIN); return TRUE; } warn_err_obj(TR("reading a pipe")); return FALSE; }else if(n>0){ buf[n]='\0'; *doneseen=FALSE; return extl_call(fn, "s", "b", &buf, doneseen); } return FALSE; }
static bool resize_handler(WRegion *reg, XEvent *xev) { XKeyEvent *ev=&xev->xkey; WBinding *binding=NULL; WMoveresMode *mode; if(ev->type==KeyRelease) return FALSE; if(reg==NULL) return FALSE; mode=moveres_mode(reg); if(mode==NULL) return FALSE; binding=bindmap_lookup_binding(ioncore_moveres_bindmap, BINDING_KEYPRESS, ev->state, ev->keycode); if(!binding) return FALSE; if(binding!=NULL){ extl_protect(&moveres_safelist); extl_call(binding->func, "oo", NULL, mode, reg); extl_unprotect(&moveres_safelist); } return (moveres_mode(reg)==NULL); }
int test_tostring() { ExtlFn tostringfn; ExtlFn fn; ErrorLog el; char *retstr=NULL; errorlog_begin(&el); if(!extl_loadstring(tostringstr, &tostringfn)) return 1; if(!extl_loadstring("print('testing\\n'); return 'test'", &fn)) return 2; fprintf(stderr, "Calling extl_call...\n"); if(!extl_call(tostringfn, "f", "s", fn, &retstr)) return 3; if (retstr == NULL) return 4; if(strcmp("\"test\"", retstr) != 0){ fprintf(stderr, "Result was '%s' instead of 'test'", retstr); return 5; } return 0; }
bool extl_iter_obj(ExtlFn fn, Obj *obj) { bool ret1, ret2=FALSE; extl_protect(NULL); ret1=extl_call(fn, "o", "b", obj, &ret2); extl_unprotect(NULL); return (ret1 && ret2); }
ExtlTab ioncore_get_layout(const char *layout) { ExtlTab tab=extl_table_none(); if(get_layout_fn_set){ extl_protect(NULL); extl_call(get_layout_fn, "s", "t", layout, &tab); extl_unprotect(NULL); } return tab; }
ExtlTab ioncore_get_winprop(WClientWin *cwin) { ExtlTab tab=extl_table_none(); if(get_winprop_fn_set){ extl_protect(NULL); extl_call(get_winprop_fn, "o", "t", cwin, &tab); extl_unprotect(NULL); } return tab; }
static int try_read_savefile(const char *file, TryCallParam *param) { int ret=try_load(file, param); if(ret!=EXTL_TRYCONFIG_OK) return ret; ret=extl_call(param->fn, NULL, "t", &(param->tab)); extl_unref_fn(param->fn); return (ret ? EXTL_TRYCONFIG_OK : EXTL_TRYCONFIG_CALL_FAILED); }
static void menu_do_finish(WMenu *menu) { ExtlFn handler; ExtlTab tab; bool ok; WMenu *head=menu_head(menu); handler=menu->handler; menu->handler=extl_fn_none(); ok=extl_table_geti_t(menu->tab, menu->selected_entry+1, &tab); if(!region_rqdispose((WRegion*)head)){ if(head->submenu!=NULL) destroy_obj((Obj*)head->submenu); } if(ok) extl_call(handler, "t", NULL, tab); extl_unref_fn(handler); extl_unref_table(tab); }
static bool marshall_extl_alt_o(ExtlFn fn, void *param) { bool ret=FALSE; extl_call(fn, "o", "b", (Obj*)param, &ret); return ret; }
static bool marshall_extl_alt_v(ExtlFn fn, void *UNUSED(param)) { bool ret=FALSE; extl_call(fn, NULL, "b", &ret); return ret; }
static bool marshall_extl_o(ExtlFn fn, void *param) { return extl_call(fn, "o", NULL, (Obj*)param); }
static bool marshall_extl_v(ExtlFn fn, void *UNUSED(param)) { extl_call(fn, NULL, NULL); return TRUE; }
static void show_sub(WMenu *menu, int n) { WFitParams fp; WMenuCreateParams fnp; WMenu *submenu; WWindow *par; par=REGION_PARENT(menu); if(par==NULL) return; fp=menu->last_fp; fnp.pmenu_mode=menu->pmenu_mode; fnp.big_mode=menu->big_mode; fnp.submenu_mode=TRUE; if(menu->pmenu_mode){ fnp.refg.x=REGION_GEOM(menu).x+REGION_GEOM(menu).w; fnp.refg.y=REGION_GEOM(menu).y+get_sub_y_off(menu, n); fnp.refg.w=0; fnp.refg.h=0; }else{ fnp.refg=REGION_GEOM(menu); } fnp.tab=extl_table_none(); { ExtlFn fn; if(extl_table_getis(menu->tab, n+1, "submenu_fn", 'f', &fn)){ extl_protect(NULL); extl_call(fn, NULL, "t", &(fnp.tab)); extl_unprotect(NULL); extl_unref_fn(fn); }else{ extl_table_getis(menu->tab, n+1, "submenu", 't', &(fnp.tab)); } if(fnp.tab==extl_table_none()) return; } fnp.handler=extl_ref_fn(menu->handler); fnp.initial=0; { ExtlFn fn; if(extl_table_getis(menu->tab, n+1, "initial", 'f', &fn)){ extl_protect(NULL); extl_call(fn, NULL, "i", &(fnp.initial)); extl_unprotect(NULL); extl_unref_fn(fn); }else{ extl_table_getis(menu->tab, n+1, "initial", 'i', &(fnp.initial)); } } submenu=create_menu(par, &fp, &fnp); if(submenu==NULL) return; menu->submenu=submenu; region_set_manager((WRegion*)submenu, (WRegion*)menu); region_restack((WRegion*)submenu, MENU_WIN(menu), Above); region_map((WRegion*)submenu); if(!menu->pmenu_mode && region_may_control_focus((WRegion*)menu)) region_do_set_focus((WRegion*)submenu, FALSE); }