static int add_user_handler(ABObj obj, ABObj module, ISTRING handler, AB_WHEN when) { int retval = 0; ABObj project = NULL; ABObj action = NULL; if (handler == NULL) { return 0; } project = obj_get_project(module); /* * With "callbacks," the to field is irrelevant. The target is generally * whatever widget calls the callback, so we set the "to" field to NULL, * so that this action may be used by multiple widgets. I.e., if the * function type, name and to fields match, an action will be shared. */ action = obj_create(AB_TYPE_ACTION, NULL); obj_set_func_type(action, AB_FUNC_USER_DEF); obj_set_func_name(action, istr_string(handler)); obj_set_arg_type(action, AB_ARG_VOID_PTR); action->info.action.to = NULL; obj_set_from(action, obj); obj_set_when(action, when); install_action(obj, module, action); return 0; }
static int write_map_window( GenCodeInfo genCodeInfo, ABObj window, BOOL show ) { File codeFile = genCodeInfo->code_file; ABObj project = obj_get_project(window); ABObj proj_root_window = abmfP_get_root_window(project); ABObjRec showActionRec; ABObj showAction = &showActionRec; ABObj winParent = NULL; char winParentName[1024]; obj_construct(showAction, AB_TYPE_ACTION, NULL); *winParentName = 0; obj_set_from(showAction, NULL); obj_set_to(showAction, window); obj_set_func_type(showAction, AB_FUNC_BUILTIN); obj_set_func_builtin(showAction, AB_STDACT_SHOW); winParent = obj_get_win_parent(window); if (winParent == NULL) { sprintf(winParentName, "%s()", abmfP_lib_get_toplevel_widget->name); } else { strcpy(winParentName, abmfP_get_c_name(genCodeInfo, winParent)); } abio_printf(codeFile, "%s(%s, %s);\n", abmfP_get_init_proc_name(window), abmfP_get_c_struct_ptr_name(genCodeInfo, window), winParentName); if (show) abmfP_write_builtin_action(genCodeInfo, showAction, FALSE); obj_destruct(showAction); return 0; }
/* * Get the source object. */ static int get_from(FILE * inFile, ABObj obj, ABObj module, ABObj action) { int return_value = 0; int rc = 0; /* r turn code */ ISTRING interface_name = NULL; ISTRING parent_name = NULL; ISTRING name = NULL; ISTRING item_name = NULL; ABObj from = NULL; if ( (abio_gil_get_full_name(inFile, &interface_name, &parent_name, &name, &item_name) < 0) || (name == NULL) ) { abil_print_load_err(ERR_WANT_FULL_NAME); return_value = -1; goto abort; } from = find_or_create_target(obj, module, interface_name, parent_name, name, item_name); if (from == NULL) { rc = abil_print_load_err(ERR_UNKNOWN_OBJECT); goto abort; } obj_set_from(action, from); abort: istr_destroy(parent_name); istr_destroy(name); istr_destroy(item_name); return return_value; }