#include #include #include "bindings.h" #include "list.h" #include "../gmtool_structs.h" #include // lua includes #include #include #include using namespace luabind; region * current_region(void) { map_region * mr = cursor_region(¤t_state->display, ¤t_state->cursor); return mr->r; } static tag * next_tag(int hash, const state * st) { while (hash!=MAXTHASH) { tag * t = st->selected->tags[hash]; if (t!=NULL) return t; ++hash; } return NULL; } class selectedregion { public: static tag * next(tag * node) { if (node->nexthash) { return node->nexthash; } coordinate * c = &node->coord; unsigned int key = ((c->x << 12) ^ c->y); unsigned int hash = key & (MAXTHASH-1); return next_tag(++hash, current_state); } static region * value(tag * node) { return findregion((short)node->coord.x, (short)node->coord.y); } }; static eressea::list selected_regions(void) { return eressea::list(next_tag(0, current_state)); } void bind_gmtool(lua_State * L) { module(L)[ def("selected_regions", &selected_regions, return_stl_iterator), def("current_region", ¤t_region) ]; #ifdef LUABIND_NO_EXCEPTIONS luabind::set_error_callback(error_callback); #endif }