static void test_read__return_EOF(ScmObj port) { SCM_REFSTK_INIT_REG(&port); for (int i = 0; i < TEST_FILE_NR_S_EXPR; i++) scm_read(port); TEST_ASSERT_TRUE(scm_eof_object_p(scm_read(port))); }
static void test_read__specify_closed_port__return_ERROR(ScmObj port) { SCM_REFSTK_INIT_REG(&port); scm_close_port(port); TEST_ASSERT_SCM_NULL(scm_read(port)); }
ScmObj ut_read_cstr(const char *str) { ScmObj port = SCM_OBJ_INIT; port = scm_open_input_string_cstr(str, SCM_ENC_NAME_SRC); return scm_read(port); }
bool scm_read_zips(scm *s, uint8_t **zv, uint64_t oo, uint64_t lo, uint16_t sc, uint64_t *o, uint32_t *l) { // Read the strip offset and length arrays. if (!scm_read(s, o, sc * sizeof (uint64_t), (long long) oo)) return false; if (!scm_read(s, l, sc * sizeof (uint32_t), (long long) lo)) return false; // Read each strip. for (int i = 0; i < sc; i++) if (!scm_read(s, zv[i], (size_t) l[i], (long long) o[i])) return false; return true; }
// // These write/read scheme objects to scheme strings: // static SCM string_to_object (SCM str) { SCM port = scm_open_input_string (str); SCM obj = scm_read (port); scm_close_port (port); return obj; }
bool scm_read_ifd(scm *s, ifd *d, long long o) { assert(s); assert(d); if (o && scm_read(s, d, sizeof (ifd), o)) { if (is_ifd(d)) { return true; } else apperr("%s is not an SCM TIFF", s->name); } return false; }
bool scm_read_header(scm *s, header *h) { assert(s); assert(h); if (scm_read(s, h, sizeof (header), 0)) { if (is_header(h)) { return true; } else apperr("%s is not an SCM TIFF", s->name); } return false; }
static void test_read(ScmObj port) { ScmObj actual = SCM_OBJ_INIT, expected = SCM_OBJ_INIT, sym = SCM_OBJ_INIT; const char *str[] = { "world", "hello", NULL }; SCM_REFSTK_INIT_REG(&port, &actual, &expected, &sym); expected = SCM_NIL_OBJ; for (const char **p = str; *p != NULL; p++) { sym = scm_make_symbol_from_cstr(*p, SCM_ENC_SRC); expected = scm_cons(sym, expected); } actual = scm_read(port); TEST_ASSERT_SCM_EQUAL(expected, actual); }
void GameSession::init() { loops = 0; deltas = 0.0; start_time = CL_System::get_time (); frames = 0; collision_mgr = new CollisionManager(); buildingtypemanager = new BuildingTypeManager(); // Load helper functions // FIXME: These functions need a better place scm_c_primitive_load(path_manager.complete("feuerkraft.scm").c_str()); scm_c_primitive_load(path_manager.complete("input.scm").c_str()); // Deserialize the game world { std::cout << "<<<<<<<<<<<<< Parsing map <<<<<<<<<<<<<" << std::endl; SCM fdes = scm_open_file (scm_makfrom0str(filename.c_str()), scm_makfrom0str("r")); SCM lst = scm_read (fdes); scm_close (fdes); // unstable Testing stuff //OutputWorldBuilder builder; //SexprWorldReader(lst, &builder).run(); // Now we create the real world world = new GameWorld(lst); std::cout << ">>>>>>>>>>>>> Parsing map >>>>>>>>>>>>>" << std::endl; } // End: Test of parsing code // The all mighty soldier that the player controlls Soldier* soldier = new Soldier(AList()); soldier->set_position(FloatVector2d (500, 1100)); { Soldier* soldier = new Soldier(AList()); soldier->set_position(FloatVector2d (1400, 1500)); SoldierAI* ai = new SoldierAI(soldier); world->add(soldier); AIManager::instance()->add(ai); } { Soldier* soldier = new Soldier(AList()); soldier->set_position(FloatVector2d (1300, 1600)); SoldierAI* ai = new SoldierAI(soldier); world->add(soldier); AIManager::instance()->add(ai); } world->add(new RobotTank(660, 1245, 0, 100.0f)); world->add(new Helicopter(AList() .set_float("x-pos", 600) .set_float("y-pos", 1245) .set_int("type", 0))); world->add(new Helicopter(AList() .set_float("x-pos", 600) .set_float("y-pos", 1445) .set_int("type", 1))); world->add(new Helicopter(AList() .set_float("x-pos", 660) .set_float("y-pos", 1645) .set_int("type", 2))); world->add(new Tank(FloatVector2d (650, 1245), 5, "feuerkraft/tank", "feuerkraft/turret", "feuerkraft/fire2")); world->add(new Tank(FloatVector2d (750, 1245), 5, "feuerkraft/tank", "feuerkraft/turret", "feuerkraft/fire2")); world->add(new Tank(FloatVector2d (850, 1245), 5, "feuerkraft/tank", "feuerkraft/turret", "feuerkraft/fire2")); { Tank* tank = new Tank(FloatVector2d (450, 1245), 5, "feuerkraft/tank", "feuerkraft/turret", "feuerkraft/fire2"); world->add(tank); AIManager::instance()->add(new VehicleRoboAI(tank)); } { Tank* tank = new Tank(FloatVector2d (0, 1245), 5, "feuerkraft/tank2", "feuerkraft/turret", "feuerkraft/fire2"); world->add(tank); AIManager::instance()->add(new VehicleRoboAI(tank)); } { Tank* tank = new Tank(FloatVector2d (-100, 1245), 5, "feuerkraft/tank", "feuerkraft/turret2", "feuerkraft/fire2"); world->add(tank); AIManager::instance()->add(new VehicleRoboAI(tank)); } { Tank* tank = new Tank(FloatVector2d (560, 1245), 5, "feuerkraft/tank2", "feuerkraft/turret2", "feuerkraft/fire2"); world->add(tank); VehiclePathAI* ai = new VehiclePathAI(tank); ai->drive_to(FloatVector2d(200, 200)); ai->drive_to(FloatVector2d(500, 200)); ai->drive_to(FloatVector2d(500, 500)); ai->drive_to(FloatVector2d(1500, 500)); ai->drive_to(FloatVector2d(1500, 300)); AIManager::instance()->add(ai); } world->add(new Background (resources->get_sprite("feuerkraft/sand"), -10.0f)); world->add(soldier); player = new Player(soldier); view = new View(0, 0, CL_Display::get_width(), CL_Display::get_height(), new PlayerViewUpdater(player)); DisplayManager::init(); }