예제 #1
0
CapNegotiationState::CapNegotiationState(const InitParams &init_params)
  : MessageSequenceWithOptionalSetHandler(init_params) {
  AddSequencedHandler(make_ptr(new M3Handler(init_params)));
  AddSequencedHandler(make_ptr(new M4Handler(init_params)));
  AddSequencedHandler(make_ptr(new M5Handler(init_params)));

  AddOptionalHandler(make_ptr(new M3Handler(init_params)));
  AddOptionalHandler(make_ptr(new M4Handler(init_params)));
}
예제 #2
0
파일: parser.c 프로젝트: eldesh/gopts
parse_result parse_write_file (char const * str) {
	FILE * fp=fopen(str, "w");
	if (fp)
		return make_parse_result(make_ptr(fp), last_char(str));
	else
		return make_parse_result(NULL, str);
}
예제 #3
0
파일: test05p.c 프로젝트: 8l/csolve
void main(){
  int **t;
  int *t1;
  int t2;

  t = make_ptr();
  t1 = *t; 	// test minimization
  set_ptr(t, 10);
  
  validptr(t);	//should succeed

  return; 
}
예제 #4
0
static void ffi_open_fn(VMState *state, CallInfo *info) {
  VM_ASSERT(info->args_len == 1, "wrong arity: expected 1, got %i", info->args_len);
  Object *root = state->root;
  Object *string_base = state->shared->vcache.string_base;
  Object *array_base = state->shared->vcache.array_base;
  Object *ffi = AS_OBJ(OBJECT_LOOKUP(root, ffi));
  Object *handle_base = AS_OBJ(OBJECT_LOOKUP(ffi, handle));

  StringObject *sarg = (StringObject*) obj_instance_of(OBJ_OR_NULL(load_arg(state->frame, INFO_ARGS_PTR(info)[0])), string_base);
  VM_ASSERT(sarg, "argument to ffi.open must be string!");

  Object *libmap = AS_OBJ(OBJECT_LOOKUP(ffi, library_map));

  char *file = sarg->value;

  bool file_found = false;
  FastKey file_key = prepare_key(file, strlen(file));
  Value mapping = object_lookup_p(libmap, &file_key, &file_found);
  const char **file_list_ptr = NULL;
  int file_list_len = 0;
  if (file_found) {
    ArrayObject *aobj = (ArrayObject*) obj_instance_of(OBJ_OR_NULL(mapping), array_base);
    StringObject *sobj = (StringObject*) obj_instance_of(OBJ_OR_NULL(mapping), string_base);
    if (aobj) {
      file_list_len = aobj->length;
      file_list_ptr = malloc(sizeof(char*) * file_list_len);
      for (int i = 0; i < file_list_len; i++) {
        StringObject *file = (StringObject*) obj_instance_of(OBJ_OR_NULL(aobj->ptr[i]), string_base);
        VM_ASSERT(file, "library_map sub-entries must be string");
        file_list_ptr[i] = my_asprintf("%s", file->value); // outside gc, make copy
      }
    } else if (sobj) {
      file_list_len = 1;
      file_list_ptr = malloc(sizeof(char*) * 1);
      file_list_ptr[0] = my_asprintf("%s", sobj->value);
    } else VM_ASSERT(false, "library_map entries must be string or array");
  } else {
    file_list_len = 1;
    file_list_ptr = malloc(sizeof(char*) * 1);
    file_list_ptr[0] = file;
  }

  void *dlptr = my_dlopen(file_list_len, file_list_ptr);

  Object *handle_obj = AS_OBJ(make_object(state, handle_base, false));
  handle_obj->flags |= OBJ_FROZEN;
  OBJECT_SET(state, handle_obj, pointer, make_ptr(state, dlptr));
  vm_return(state, info, OBJ2VAL(handle_obj));
}
 BasicHashtableEntry* next() const {
   return make_ptr(_next);
 }
예제 #6
0
void Resources::readItems() {
	ods::Book book{ ":/input.ods" };
	if (book.error()) {
		qDebug() << "Failed to open ods book with input data";
		return;
	}

	//
	//	read options
	//
	{
		auto options = book.sheet("Options");
		if (!options) {
			qDebug() << "Options not found";
		}
		else {
			auto rows = options->rows();
			if (!rows) {
				qDebug() << "No rows for options";
			}
			else {
				int id_col = -1;
				int name_col = -1;
				int value_col = -1;
				for (int i = 0, max_i = rows->size(); i < max_i; ++i) {
					auto row = (*rows)[i];
					if (i == 0) {
						auto& cells = row->cells();
						for (int j = 0, max_j = cells.size(); j < max_j; ++j) {
							auto cell = cells[j];

							auto& v = cell->value();
							if (v.IsString()) {
								auto s = v.AsString();
								if (s) {
									if (*s == "id")
										id_col = j;
									else if (*s == "name")
										name_col = j;
									else if (*s == "value")
										value_col = j;
									else
										qDebug() << "Unexpected option attribute" << *s;
								}
							}
						}
					}
					else {
						auto ok = row->cell(id_col)->value().Ok();
						if (ok) {
							auto id = (int)(*row->cell(id_col)->value().AsDouble());
							auto name = *row->cell(name_col)->value().AsString();
							qDebug() << "Read option" << name;
							if (name == "global_field_width")
								Options::set(OptionType::GlobalFieldWidth, (int)(*row->cell(value_col)->value().AsDouble()));
							else if (name == "global_field_height")
								Options::set(OptionType::GlobalFieldHeight, (int)(*row->cell(value_col)->value().AsDouble()));
							else if (name == "local_field_width")
								Options::set(OptionType::LocalFieldWidth, (int)(*row->cell(value_col)->value().AsDouble()));
							else if (name == "local_field_height")
								Options::set(OptionType::LocalFieldHeight, (int)(*row->cell(value_col)->value().AsDouble()));
							else if (name == "cell_size")
								Options::set(OptionType::CellSize, (int)(*row->cell(value_col)->value().AsDouble()));
							else
								qDebug() << "Unexpected option" << name;
						}
					}
				}
			}
		}
	}

	//	
	//	Read clothes
	//
	{
		auto clothes = book.sheet("Clothes");
		if (!clothes) {
			qDebug() << "Clothes not found";
		}
		else {
			auto rows = clothes->rows();
			if (!rows) {
				qDebug() << "No rows for clothes";
			}
			else {
				int id_col = -1;
				int name_col = -1;
				int description_col = -1;
				int icon_col = -1;
				int weight_col = -1;
				int technology_col = -1;
				int wind_protection_col = -1;
				int water_resistance_col = -1;
				int radiation_resistance_col = -1;
				int heat_absorption_col = -1;
				int target_col = -1;

				for (int i = 0, max_i = rows->size(); i < max_i; ++i) {
					auto row = (*rows)[i];
					if (i == 0) {
						auto& cells = row->cells();
						for (int j = 0, max_j = cells.size(); j < max_j; ++j) {
							auto cell = cells[j];

							auto& v = cell->value();
							if (v.IsString()) {
								auto s = v.AsString();
								if (s) {
									if (*s == "id")
										id_col = j;
									else if (*s == "name")
										name_col = j;
									else if (*s == "description")
										description_col = j;
									else if (*s == "icon")
										icon_col = j;
									else if (*s == "weight")
										weight_col = j;
									else if (*s == "technology")
										technology_col = j;
									else if (*s == "wind_protection")
										wind_protection_col = j;
									else if (*s == "water_resistance")
										water_resistance_col = j;
									else if (*s == "radiation_resistance")
										radiation_resistance_col = j;
									else if (*s == "heat_absorption")
										heat_absorption_col = j;
									else if (*s == "target")
										target_col = j;
									else
										qDebug() << "Unexpected clothes attribute" << *s;
								}
							}
						}
					}
					else {
						if (row->cell(id_col)->value().Ok()) {
							auto v = row->cell(id_col)->value().AsDouble();
							auto id = (int)(*v);
							auto name = *row->cell(name_col)->value().AsString();
							auto description = *row->cell(description_col)->value().AsString();
							auto icon = *row->cell(icon_col)->value().AsString();
							auto weight = *row->cell(weight_col)->value().AsDouble();
							auto technology = (int)(*row->cell(technology_col)->value().AsDouble());
							auto wind_protection = *row->cell(wind_protection_col)->value().AsDouble();
							auto water_resistance = *row->cell(water_resistance_col)->value().AsDouble();
							auto radiation_resistance = *row->cell(radiation_resistance_col)->value().AsDouble();
							auto heat_absorption = *row->cell(heat_absorption_col)->value().AsDouble();
							auto target = fromString(*row->cell(target_col)->value().AsString());

							ClothesClassPtr c = make_ptr(new ClothesClass{});
							c->setName(name);
							c->setDescription(description);
							c->setIcon(icon);
							c->setWeight(weight);
							c->setTechnologyLevel(technology);
							c->setWindProtection(wind_protection);
							c->setWaterResistance(water_resistance);
							c->setRadiationResistance(radiation_resistance);
							c->setHeatRadiationAbsorption(heat_absorption);
							c->setTargetBodyPart(target);
							m_clothes_cache.push_back(c.get());
							m_items.push_back(cast<ItemClass>(c));
						}
					}
				}
			}
		}
	}

	//	
	//	Read surface types
	//
	{
		auto surface_types = book.sheet("SurfaceTypes");
		if (!surface_types) {
			qDebug() << "Surface types not found";
		}
		else {
			auto rows = surface_types->rows();
			if (!rows) {
				qDebug() << "No rows for surface types";
			}
			else {
				int id_col = -1;
				int name_col = -1;
				int icon_col = -1;
				int move_penalty_col = -1;
				int solid_col = -1;

				for (int i = 0, max_i = rows->size(); i < max_i; ++i) {
					auto row = (*rows)[i];
					if (i == 0) {
						auto& cells = row->cells();
						for (int j = 0, max_j = cells.size(); j < max_j; ++j) {
							auto cell = cells[j];

							auto& v = cell->value();
							if (v.IsString()) {
								auto s = v.AsString();
								if (s) {
									if (*s == "id")
										id_col = j;
									else if (*s == "name")
										name_col = j;
									else if (*s == "icon")
										icon_col = j;
									else if (*s == "move_penalty")
										move_penalty_col = j;
									else if (*s == "solid")
										solid_col = j;
									else
										qDebug() << "Unexpected surface type attribute" << *s;
								}
							}
						}
					}
					else {
						if (row->cell(id_col)->value().Ok()) {
							auto id = (int)(*row->cell(id_col)->value().AsDouble());
							auto name = *row->cell(name_col)->value().AsString();
							auto icon = *row->cell(icon_col)->value().AsString();
							auto move_penalty = *row->cell(move_penalty_col)->value().AsDouble();
							auto solid = (int)(*row->cell(solid_col)->value().AsDouble());

							SurfaceTypeClassPtr c = make_ptr(new SurfaceTypeClass{});
							c->setName(name);
							c->setIcon(icon);
							c->setMovePenalty(move_penalty);
							c->setIsLand(solid != 0);
							m_surfaces_cache.push_back(c.get());
							m_surface_types.push_back(std::move(c));
						}
					}
				}
			}
		}
	}
	//	
	//	Read ammo
	//
	{
		auto ammo = book.sheet("Ammo");
		if (!ammo) {
			qDebug() << "Ammo not found";
		}
		else {
			auto rows = ammo->rows();
			if (!rows) {
				qDebug() << "No rows for ammo";
			}
			else {
				int id_col = -1;
				int name_col = -1;
				int description_col = -1;
				int icon_col = -1;
				int weight_col = -1;
				int technology_col = -1;
				int cartridge_col = -1;
				int caliber_col = -1;
				int manufacture_col = -1;
				int speed_col = -1;
				int energy_col = -1;

				for (int i = 0, max_i = rows->size(); i < max_i; ++i) {
					auto row = (*rows)[i];
					if (i == 0) {
						auto& cells = row->cells();
						for (int j = 0, max_j = cells.size(); j < max_j; ++j) {
							auto cell = cells[j];

							auto& v = cell->value();
							if (v.IsString()) {
								auto s = v.AsString();
								if (s) {
									if (*s == "id")
										id_col = j;
									else if (*s == "name")
										name_col = j;
									else if (*s == "description")
										description_col = j;
									else if (*s == "icon")
										icon_col = j;
									else if (*s == "weight")
										weight_col = j;
									else if (*s == "technology")
										technology_col = j;
									else if (*s == "cartridge")
										cartridge_col = j;
									else if (*s == "caliber")
										caliber_col = j;
									else if (*s == "manufacture")
										manufacture_col = j;
									else if (*s == "speed")
										speed_col = j;
									else if (*s == "energy")
										energy_col = j;
									else
										qDebug() << "Unexpected ammo attribute" << *s;
								}
							}
						}
					}
					else {
						if (row->cell(id_col)->value().Ok()) {
							auto v = row->cell(id_col)->value().AsDouble();
							auto id = (int)(*v);
							auto name = *row->cell(name_col)->value().AsString();
							auto description = *row->cell(description_col)->value().AsString();
							auto icon = *row->cell(icon_col)->value().AsString();
							auto weight = *row->cell(weight_col)->value().AsDouble();
							auto technology = (int)(*row->cell(technology_col)->value().AsDouble());
							auto cartridge = *row->cell(cartridge_col)->value().AsString();
							auto caliber = *row->cell(caliber_col)->value().AsDouble();
							auto manufacture = *row->cell(manufacture_col)->value().AsString();
							auto speed = *row->cell(speed_col)->value().AsDouble();
							auto energy = *row->cell(energy_col)->value().AsDouble();

							AmmoClassPtr c = make_ptr(new AmmoClass{});
							c->setName(name);
							c->setDescription(description);
							c->setIcon(icon);
							c->setWeight(weight);
							c->setTechnologyLevel(technology);
							c->setCartridge(cartridge);
							c->setCaliber(caliber);
							c->setManufacture(manufacture);
							c->setSpeed(speed);
							c->setEnergy(energy);
							m_ammo_cache.push_back(c.get());
							m_items.push_back(cast<ItemClass>(c));
						}
					}
				}
			}
		}
	}

	//	
	//	Read weapon
	//
	{
		auto weapon = book.sheet("Weapon");
		if (!weapon) {
			qDebug() << "Weapon not found";
		}
		else {
			auto rows = weapon->rows();
			if (!rows) {
				qDebug() << "No rows for weapons";
			}
			else {
				int id_col = -1;
				int name_col = -1;
				int description_col = -1;
				int icon_col = -1;
				int weight_col = -1;
				int technology_col = -1;
				int length_col = -1;
				int barrel_length_col = -1;
				int width_col = -1;
				int height_col = -1;
				int cartridge_col = -1;
				int range_col = -1;
				int rounds_col = -1;

				for (int i = 0, max_i = rows->size(); i < max_i; ++i) {
					auto row = (*rows)[i];
					if (i == 0) {
						auto& cells = row->cells();
						for (int j = 0, max_j = cells.size(); j < max_j; ++j) {
							auto cell = cells[j];

							auto& v = cell->value();
							if (v.IsString()) {
								auto s = v.AsString();
								if (s) {
									if (*s == "id")
										id_col = j;
									else if (*s == "name")
										name_col = j;
									else if (*s == "description")
										description_col = j;
									else if (*s == "icon")
										icon_col = j;
									else if (*s == "weight")
										weight_col = j;
									else if (*s == "technology")
										technology_col = j;
									else if (*s == "length")
										length_col = j;
									else if (*s == "barrel_length")
										barrel_length_col = j;
									else if (*s == "width")
										width_col = j;
									else if (*s == "height")
										height_col = j;
									else if (*s == "cartridge")
										cartridge_col = j;
									else if (*s == "range")
										range_col = j;
									else if (*s == "rounds")
										rounds_col = j;
									else
										qDebug() << "Unexpected weapon attribute" << *s;
								}
							}
						}
					}
					else {
						if (row->cell(id_col)->value().Ok()) {
							auto v = row->cell(id_col)->value().AsDouble();
							auto id = (int)(*v);
							auto name = *row->cell(name_col)->value().AsString();
							auto description = *row->cell(description_col)->value().AsString();
							auto icon = *row->cell(icon_col)->value().AsString();
							auto weight = *row->cell(weight_col)->value().AsDouble();
							auto technology = (int)(*row->cell(technology_col)->value().AsDouble());
							auto cartridge = *row->cell(cartridge_col)->value().AsString();
							auto width = *row->cell(width_col)->value().AsDouble();
							auto barrel_length = *row->cell(barrel_length_col)->value().AsDouble();
							auto length = *row->cell(length_col)->value().AsDouble();
							auto height = *row->cell(height_col)->value().AsDouble();
							auto range = *row->cell(range_col)->value().AsDouble();
							auto rounds = *row->cell(rounds_col)->value().AsDouble();

							WeaponClassPtr c = make_ptr(new WeaponClass{});
							c->setName(name);
							c->setDescription(description);
							c->setIcon(icon);
							c->setWeight(weight);
							c->setTechnologyLevel(technology);
							c->setCartridge(cartridge);
							c->setLength(length);
							c->setBarrelLength(barrel_length);
							c->setWidth(width);
							c->setHeight(height);
							c->setRange(range);
							m_weapon_cache.push_back(c.get());
							m_items.push_back(cast<ItemClass>(c));
						}
					}
				}
			}
		}

		//	
		//	Read weapon clips
		//
		{
			auto clip = book.sheet("Clip");
			if (!clip) {
				qDebug() << "Clip not found";
			}
			else {
				auto rows = clip->rows();
				if (!rows) {
					qDebug() << "No rows for clips";
				}
				else {
					int id_col = -1;
					int name_col = -1;
					int description_col = -1;
					int icon_col = -1;
					int weight_col = -1;
					int technology_col = -1;
					int length_col = -1;
					int weapon_col = -1;
					int rounds_col = -1;

					for (int i = 0, max_i = rows->size(); i < max_i; ++i) {
						auto row = (*rows)[i];
						if (i == 0) {
							auto& cells = row->cells();
							for (int j = 0, max_j = cells.size(); j < max_j; ++j) {
								auto cell = cells[j];

								auto& v = cell->value();
								if (v.IsString()) {
									auto s = v.AsString();
									if (s) {
										if (*s == "id")
											id_col = j;
										else if (*s == "name")
											name_col = j;
										else if (*s == "description")
											description_col = j;
										else if (*s == "icon")
											icon_col = j;
										else if (*s == "weight")
											weight_col = j;
										else if (*s == "technology")
											technology_col = j;
										else if (*s == "length")
											length_col = j;
										else if (*s == "weapon")
											weapon_col = j;
										else if (*s == "rounds")
											rounds_col = j;
										else
											qDebug() << "Unexpected clip attribute" << *s;
									}
								}
							}
						}
						else {
							if (row->cell(id_col)->value().Ok()) {
								auto v = row->cell(id_col)->value().AsDouble();
								auto id = (int)(*v);
								auto name = *row->cell(name_col)->value().AsString();
								auto description = *row->cell(description_col)->value().AsString();
								auto icon = *row->cell(icon_col)->value().AsString();
								auto weight = *row->cell(weight_col)->value().AsDouble();
								auto technology = (int)(*row->cell(technology_col)->value().AsDouble());
								auto weapon = *row->cell(weapon_col)->value().AsString();
								auto rounds = *row->cell(rounds_col)->value().AsDouble();

								WeaponClipClassPtr c = make_ptr(new WeaponClipClass{});
								c->setName(name);
								c->setDescription(description);
								c->setIcon(icon);
								c->setWeight(weight);
								c->setTechnologyLevel(technology);
								c->setWeapon(weapon);
								c->setRounds(rounds);
								m_weapon_clip_cache.push_back(c.get());
								m_items.push_back(cast<ItemClass>(c));
							}
						}
					}
				}
			}
		}
		
		//	
		//	Read roads
		//
		{
			auto road = book.sheet("Roads");
			if (!road) {
				qDebug() << "Roads not found";
			}
			else {
				auto rows = road->rows();
				if (!rows) {
					qDebug() << "No rows for roads";
				}
				else {					
					int id_col = -1;
					int name_col = -1;
					int description_col = -1;
					int category_col = -1;
					int surface_col = -1;
					int lanes_count_col = -1;
					int lane_width_col = -1;
					int roadway_width_col = -1;
					int roadside_width_col = -1;
					int fortified_roadside_width_col = -1;
					int fortified_separation_width_col = -1;
					int separation_width_col = -1;
					int subgrade_width_col = -1;
					int speed_col = -1;
					int crossroad_speed_col = -1;
					int mountain_speed_col = -1;
					int estimated_traffic_col = -1;

					for (int i = 0, max_i = rows->size(); i < max_i; ++i) {
						auto row = (*rows)[i];
						if (i == 0) {
							auto& cells = row->cells();
							for (int j = 0, max_j = cells.size(); j < max_j; ++j) {
								auto cell = cells[j];

								auto& v = cell->value();
								if (v.IsString()) {
									auto s = v.AsString();
									if (s) {
										if (*s == "id")
											id_col = j;
										else if (*s == "name")
											name_col = j;
										else if (*s == "description")
											description_col = j;												
										else if (*s == "surface")
											surface_col = j;
										else if (*s == "category")
											category_col = j;
										else if (*s == "lanes_count")
											lanes_count_col = j;
										else if (*s == "lane_width")
											lane_width_col = j;
										else if (*s == "roadway_width")
											roadway_width_col = j;
										else if (*s == "roadside_width")
											roadside_width_col = j;
										else if (*s == "fortified_roadside_width")
											fortified_roadside_width_col = j;
										else if (*s == "fortified_separation_width")
											fortified_separation_width_col = j;
										else if (*s == "separation_width")
											separation_width_col = j;
										else if (*s == "subgrade_width")
											subgrade_width_col = j;
										else if (*s == "speed")
											speed_col = j;
										else if (*s == "crossroad_speed")
											crossroad_speed_col = j;
										else if (*s == "mountain_speed")
											mountain_speed_col = j;
										else if (*s == "estimated_traffic")
											estimated_traffic_col = j;
										else
											qDebug() << "Unexpected clip attribute" << *s;
									}
								}
							}
						}
						else {
							if (row->cell(id_col)->value().Ok()) {
								auto v = row->cell(id_col)->value().AsDouble();
								auto id = (int)(*v);
								auto name = *row->cell(name_col)->value().AsString();
								auto description = *row->cell(description_col)->value().AsString();
								auto surface = *row->cell(surface_col)->value().AsString();
								auto category = *row->cell(category_col)->value().AsString();
								auto lanes_count = *row->cell(lanes_count_col)->value().AsDouble();
								auto lane_width = *row->cell(lane_width_col)->value().AsDouble();
								auto roadway_width = *row->cell(roadway_width_col)->value().AsDouble();
								auto roadside_width = *row->cell(roadside_width_col)->value().AsDouble();
								auto fortified_roadside_width = *row->cell(fortified_roadside_width_col)->value().AsDouble();
								auto fortified_separation_width = *row->cell(fortified_separation_width_col)->value().AsDouble();
								auto separation_width = *row->cell(separation_width_col)->value().AsDouble();
								auto subgrade_width = *row->cell(subgrade_width_col)->value().AsDouble();
								auto speed = *row->cell(speed_col)->value().AsDouble();
								auto crossroad_speed = *row->cell(crossroad_speed_col)->value().AsDouble();
								auto mountain_speed = *row->cell(mountain_speed_col)->value().AsDouble();
								auto estimated_traffic = *row->cell(estimated_traffic_col)->value().AsDouble();

								RoadClassPtr c = make_ptr(new RoadClass{});
								c->setName(name);
								c->setDescription(description);
								c->setSurfacePath(surface);
								c->setCategory(category);
								c->setLanesCount(lanes_count);
								c->setLaneWidth(lane_width);
								c->setRoadwayWidth(roadway_width);
								c->setRoadsideWidth(roadside_width);
								c->setFortifiedRoadsideWidth(fortified_roadside_width);
								c->setFortifiedSeparationWidth(fortified_separation_width);
								c->setSeparationWidth(separation_width);
								c->setSubgradeWidth(subgrade_width);
								c->setSpeed(speed);
								c->setCrossroadSpeed(crossroad_speed);
								c->setMountainSpeed(mountain_speed);
								c->setEstimatedTraffic(estimated_traffic);
								m_roads_cache.push_back(c.get());
								m_roads.push_back(std::move(c));
							}
						}
					}
				}
			}
		}
	}
}
예제 #7
0
파일: VIP.C 프로젝트: Breton/Animator-Pro
void *load_exe(char *filename, Exe_head *eh)
{
long retval;
char *alligned_buf;
char *alloc_buf = NULL;
long (*rfunc)();
unsigned long code_offset;
unsigned long init_size;
unsigned long bss_size;
unsigned long total_size;
void *v;
unsigned long fixup_offset;
UWORD fixup[2];
UWORD *segpt;
UWORD code_seg;
int f;
unsigned i;
int ok = 0;

if ((f = jopen(filename, JREADONLY)) == 0)
	{
	cant_find(filename);
	return(NULL);
	}
if (!verify_exe_head(f, eh))
	goto OUT;
code_offset = eh->head_size;
code_offset *= 16;	/* make it a paragraph */
init_size = eh->blocks;
init_size *= 512;
init_size += eh->mod512;
if (eh->mod512 != 0)
	init_size -= 512;
init_size -= code_offset;
bss_size = eh->min_data;
bss_size *= 16;
total_size = init_size + bss_size;
if ((alloc_buf = begmem((unsigned)total_size+16)) == NULL)
	goto OUT;
code_seg = ptr_seg(alloc_buf) + 1;
alligned_buf = make_ptr(0, code_seg);
zero_structure(alligned_buf, (unsigned)total_size);
jseek(f, code_offset, JSEEK_START);
if (jread(f, alligned_buf, init_size) < init_size)
	{
	truncated(filename);
	goto OUT;
	}
v = alligned_buf;
eh->entry_point = v;
if (eh->reloc_count > 0)
	{
	fixup_offset = eh->reloc_list;
	jseek(f, fixup_offset, JSEEK_START);
	for (i=0; i<eh->reloc_count; i++)
		{
		if (jread(f, fixup, sizeof(fixup)) != sizeof(fixup))
			{
			truncated(filename);
			goto OUT;
			}
		segpt = make_ptr(fixup[0], code_seg + fixup[1]);
		segpt[0] += code_seg;
		}
	}
ok = 1;
OUT:
if (!ok)
	{
	gentle_freemem(alloc_buf);
	alloc_buf = NULL;
	}
jclose(f);
return(alloc_buf);
}
예제 #8
0
void call_branch_block(jit_function_t func, block_t *block) {
	jit_value_t args[] = {make_ptr(block)};
	jit_insn_call_native(func, 0, (void *) branch_block, sig_1_ptr, args, 1, 0);
}
예제 #9
0
void MainWindow::createCharacter() {
	auto c = make_ptr(new Character{ world()->globalField(), nullptr });
	c->setHumanControl(true);
	c->setPos(65 * 6250 + 6240, 64 * 6250 + 100);
	world()->addCharacter(std::move(c));
}
예제 #10
0
파일: parser.c 프로젝트: eldesh/gopts
parse_result success_parser(char const * str) {
	return make_parse_result(make_ptr(string_dup(str)), last_char(str));
}
예제 #11
0
파일: main.cpp 프로젝트: WhiZTiM/coliru
constexpr auto make_pptr(_args && ...args)
{
  return std::make_shared<ptr>(make_ptr(std::forward<_args>(args)...));
}
예제 #12
0
FontHandle Renderer::create_font(const std::string &family, long size, std::uint8_t flags)
{
	fonts.push_back(std::make_unique<Font>(make_ptr(), device, family.c_str(), size, flags));
	return FontHandle{ fonts.size() - 1 };
}