void aggregator_controllers() { map <string, string> item; item["path"] = "admin/aggregator"; item["title"] = "Feed aggregator"; item["callback"] = _MAP( aggregator_admin_overview ); item["access arguments"] = "administer news feeds"; item["parent tab"] = "admin/aggregator"; poke( controllers, item ); item["path"] = "admin/aggregator"; item["title"] = "List"; item["weight"] = "1"; item["callback"] = _MAP( aggregator_admin_overview ); item["type"] = str( MENU_LOCAL_TASK ); item["access arguments"] = "administer news feeds"; item["parent tab"] = "admin/aggregator"; poke( controllers, item ); item["path"] = "admin/aggregator/add/feed"; item["title"] = "Add feed"; item["weight"] = "3"; item["callback"] = _MAP_FORM( aggregator_add_feed ); item["type"] = str( MENU_LOCAL_TASK ); item["access arguments"] = "administer news feeds"; item["parent tab"] = "admin/aggregator"; poke( controllers, item ); item["path"] = "admin/aggregator/update/feed/%"; item["title"] = "Update items"; item["callback"] = _MAP( aggregator_admin_refresh_feed ); item["type"] = str( ~MENU_VISIBLE_IN_TREE ); item["access arguments"] = "administer news feeds"; poke( controllers, item ); item["path"] = "admin/aggregator/remove/feed/%"; item["title"] = "Remove items"; item["callback"] = _MAP( aggregator_admin_remove_feed ); item["type"] = str( ~MENU_VISIBLE_IN_TREE ); item["access arguments"] = "administer news feeds"; poke( controllers, item ); item["path"] = "admin/aggregator/edit/feed/%"; item["title"] = "Edit feed"; item["callback"] = _MAP_FORM( aggregator_edit_feed ); item["type"] = str( ~MENU_VISIBLE_IN_TREE ); item["access arguments"] = "administer news feeds"; poke( controllers, item ); item["path"] = "aggregator/sources/%"; item["callback"] = _MAP( aggregator_page_source ); item["type"] = str( ~MENU_VISIBLE_IN_TREE ); item["access arguments"] = "access news feeds"; poke( controllers, item ); }
static E8_DECLARE_SUB(__e8_map_count) { _MAP(m); e8_var_long(result, m->size); E8_RETURN_OK; }
void example_controllers() { map <string, string> item; item["path"] = "testpage"; item["title"] = "My Model Example"; item["callback"] = _MAP( example_testpage ); item["type"] = str( MENU_LOCAL_TASK ); poke( controllers, item ); }
static void __e8_map_destroy(e8_object obj) { _MAP(m); int i = m->size; while (i--) { e8_gc_free_object(m->data[i]); } free(m->data); free(m); }
void profile_controllers() { map <string, string> item; item["path"] = "admin/profile"; item["title"] = "Profiles"; item["callback"] = _MAP( profile_admin ); item["access callback"] = _MAP_ACCESS( user_access ); item["access arguments"] = "administer users"; item["parent tab"] = "admin/profile"; poke( controllers, item ); item["path"] = "admin/profile/add"; item["title"] = "Add Field"; item["type"] = str( MENU_CALLBACK ); item["callback"] = _MAP_FORM( profile_edit ); item["access callback"] = _MAP_ACCESS( user_access ); item["access arguments"] = "administer users"; poke( controllers, item ); item["path"] = "admin/profile/edit/%"; item["title"] = "Edit Field"; item["type"] = str( MENU_CALLBACK ); item["callback"] = _MAP_FORM( profile_edit ); item["access callback"] = _MAP_ACCESS( user_access ); item["access arguments"] = "administer users"; poke( controllers, item ); item["path"] = "admin/profile/delete/%"; item["title"] = "Edit Field"; item["type"] = str( MENU_CALLBACK ); item["callback"] = _MAP( profile_delete ); item["access callback"] = _MAP_ACCESS( user_access ); item["access arguments"] = "administer users"; poke( controllers, item ); }
static E8_DECLARE_SUB(__e8_map_clear) { _MAP(m); e8_var_object(result, m); /* Return This; */ while (m->size--) e8_gc_free_object(m->data[m->size]); m->size = 0; /* TODO: realloc (?) */ E8_RETURN_OK; }
static E8_DECLARE_SUB(__e8_map_get) { _MAP(m); E8_ARGUMENT(key); int i = __e8_map_index(m, &key); if (i == -1) e8_var_undefined(result); else e8_var_assign(result, &m->data[i]->value); e8_var_destroy(&key); E8_RETURN_OK; }
/******************************************************************************* * Touchmap functions: Not sure how exactly these functions are used, comments * needed!!! ******************************************************************************/ unsigned int touchscreen_map(struct ts_mappings *map, int x, int y) { int i; for(i=0; i < map->amount; i++) { #define _MAP(x) (map->mappings[x]) if(x > _MAP(i).tl_x && x < (_MAP(i).tl_x+_MAP(i).width) && y > _MAP(i).tl_y && y < (_MAP(i).tl_y+_MAP(i).height)) return i; } return -1; }
static E8_DECLARE_SUB(__e8_map_delete) { _MAP(m); E8_ARGUMENT(key); int i = __e8_map_index(m, &key); if (i != -1) { e8_gc_free_object(m->data[i]); --m->size; while (i < m->size) m->data[i] = m->data[i + 1]; } e8_var_destroy(&key); E8_RETURN_OK; }
static E8_DECLARE_SUB(__e8_map_property) { _MAP(m); if (!m->structure) E8_THROW(E8_RT_METHOD_NOT_FOUND); E8_ARGUMENT(v_name); e8_string *s_name; e8_var_cast_string(&v_name, &s_name); e8_var_destroy(&v_name); e8_uchar *lname = e8_utf_strdup(s_name->s); e8_utf_lower_case(lname); e8_var_string(&v_name, lname); e8_string_destroy(s_name); e8_utf_free(lname); int i; i = __e8_map_index(m, &v_name); if (i == -1) { e8_var_bool(result, false); } else { e8_var_bool(result, true); if (argc > 1) { if (argv->can_set) argv->set(argv, &m->data[i]->value); else E8_THROW(E8_RT_VALUE_CANNOT_BE_WRITTEN); } } e8_var_destroy(&v_name); E8_RETURN_OK; }
E8_METHOD_LIST_END static E8_DECLARE_GET_METHOD(__e8_map_get_method) { e8_simple_get_method(name, methods, fn); if (*fn) E8_RETURN_OK; _MAP(m); e8_var key; e8_uchar *lname = e8_utf_strdup(name); e8_utf_lower_case(lname); e8_var_string(&key, lname); e8_utf_free(lname); int i = __e8_map_index(m, &key); if (i == -1) E8_RETURN_OK; e8_var *V = &m->data[i]->value; if (V->type != varObject) E8_RETURN_OK; e8_vtable *vmt = e8_get_vtable(V->obj); if (vmt != &action_command_vmt) E8_RETURN_OK; e8_action_command *c = (e8_action_command *)V->obj; return c->vmt->get_method(c->obj, c->method, fn, user_data); }
static E8_DECLARE_SUB(__e8_map_insert) { _MAP(m); e8_runtime_error *__err; if (m->fixed) E8_THROW(E8_RT_VALUE_CANNOT_BE_WRITTEN); /* TODO: Понятное исключение */ e8_var_object(result, m); /* Return This; */ while (argc) { E8_ARGUMENT(v_key); E8_ARGUMENT(v_value); argc -= 2; E8_VAR(v_skey); /* Уточнённый ключ поиска */ if (m->structure) { e8_string *s_key; e8_var_cast_string(&v_key, &s_key); e8_uchar *lname = e8_utf_strdup(s_key->s); e8_utf_lower_case(lname); s_key = e8_string_init(lname); e8_utf_free(lname); /* TODO: Проверить на правильный идентиификатор */ e8_var_string(&v_skey, s_key->s); e8_string_destroy(s_key); } else e8_var_assign(&v_skey, &v_key); int i; i = __e8_map_index(m, &v_skey); if (i == -1) { i = m->size; if (( __err = e8_collection_add_size(m, 1) )) return __err; e8_keyvalue *it = e8_keyvalue_new(m->fixed); e8_gc_use_object(it); e8_var_assign(&it->key, &v_key); e8_var_assign(&it->s_key, &v_skey); e8_var_assign(&it->value, &v_value); m->data[i] = it; } else { e8_var_assign(&m->data[i]->value, &v_value); } e8_var_destroy(&v_skey); e8_var_destroy(&v_key); e8_var_destroy(&v_value); } E8_RETURN_OK; }
static E8_DECLARE_GET_BY_INDEX(__e8_map_by_index) { _MAP(m); E8_VAR(v_s_index); if (m->structure) { e8_string *s_index; e8_var_cast_string(index, &s_index); e8_uchar *lname = e8_utf_strdup(s_index->s); e8_utf_lower_case(lname); e8_string_destroy(s_index); e8_var_string(&v_s_index, lname); e8_utf_free(lname); } else e8_var_assign(&v_s_index, index); e8_runtime_error *__err; int i = __e8_map_index(m, &v_s_index); if (i == -1) { if (m->structure) { e8_string *s_index; e8_var_cast_string(index, &s_index); e8_uchar *u_index = e8_utf_strdup(s_index->s); e8_string_destroy(s_index); E8_THROW_DETAIL(E8_RT_PROPERTY_NOT_FOUND, u_index); } /* Соответствие */ i = m->size; if (( __err = e8_collection_add_size(m, 1) )) return __err; e8_keyvalue *it = e8_keyvalue_new(m->fixed); e8_gc_use_object(it); e8_var_assign(&it->key, &v_s_index); e8_var_assign(&it->s_key, &v_s_index); e8_var_undefined(&it->value); m->data[i] = it; } e8_create_variant_property(property, &m->data[i]->value); property->can_set = !m->fixed; e8_var_destroy(&v_s_index); E8_RETURN_OK; }