Exemple #1
0
Scene Scene::load(const std::string &filename, const json11::Json &settings) {
    std::ifstream is(filename);
    std::stringstream ss;
    ss << is.rdbuf();

    std::string err;
    Json jsonRoot = Json::parse(ss.str(), err);
    if (jsonRoot.is_null()) {
        throw Exception("Failed to load scene from '%s' (error: %s)", filename, err);
    }

    _resolver = filesystem::resolver();
    _resolver.prepend(filesystem::path(filename).parent_path());

    Scene scene;

    // Patch settings
    auto settingsValues = jsonRoot["settings"].object_items();
    for (auto kv : settings.object_items()) {
        settingsValues[kv.first] = kv.second;
    }
    scene.settings = Properties(json11::Json(settingsValues));

    // Parse scene objects
    Json jsonScene = jsonRoot["scene"];
    if (jsonScene.is_object()) {
        auto jsonCamera = jsonScene["camera"];
        if (jsonCamera.is_object()) {
            Properties props(jsonCamera);
            scene.camera = Camera(jsonCamera);
        }
        auto jsonWorld = jsonScene["world"];
        if (jsonWorld.is_object()) {
            Properties props(jsonWorld);
            scene.world = World(jsonWorld);
        }
        for (auto jsonBox : jsonScene["boxes"].array_items()) {
            scene.boxes.emplace_back(Box(Properties(jsonBox)));
        }
        for (auto jsonSphere : jsonScene["spheres"].array_items()) {
            scene.spheres.emplace_back(Sphere(Properties(jsonSphere)));
        }
        for (auto jsonMesh : jsonScene["meshes"].array_items()) {
            scene.meshes.emplace_back(Mesh(Properties(jsonMesh)));
        }
        for (auto jsonCameraKeyframe : jsonScene["cameraKeyframes"].array_items()) {
            scene.cameraKeyframes.emplace_back(Camera(Properties(jsonCameraKeyframe)));
        }
        // Set default camera
        if (!jsonCamera.is_object()) {
            Vector3f center = scene.world.bounds.center();
            scene.camera.position += center;
            scene.camera.target += center;
        }
    }

    return scene;
}
xbox_live_result<multiplayer_role_type>
multiplayer_role_type::_Deserialize(
    _In_ const web::json::value& json
    )
{
    if (json.is_null()) return xbox_live_result<multiplayer_role_type>();
 
    multiplayer_role_type returnResult;
    std::error_code errc = xbox_live_error_code::no_error;

    returnResult.m_ownerManaged = utils::extract_json_bool(json, _T("ownerManaged"), errc, false);
    returnResult.m_mutableRoleSettings = _Convert_string_vector_to_mutable_role_settings(
        utils::extract_json_vector<string_t>(utils::json_string_extractor, json, _T("mutableRoleSettings"), errc, false)
        );

    auto rolesJson = utils::extract_json_field(json, _T("roles"), errc, false);
    if (!rolesJson.is_null() && rolesJson.is_object())
    {
        web::json::object rolesObj = rolesJson.as_object();
        for (const auto& role : rolesObj)
        {
            auto roleInfoResult = multiplayer_role_info::_Deserialize(role.second);
            if (roleInfoResult.err())
            {
                errc = roleInfoResult.err();
            }
            returnResult.m_roles[role.first] = roleInfoResult.payload();
        }
    }

    return xbox_live_result<multiplayer_role_type>(returnResult, errc);

}
Exemple #3
0
NODE *lkindof(NODE *args) {
    NODE *argcopy = args;
    NODE *val = UNBOUND;

    if (is_list(car(args))) {
        if (cdr(args) != NIL) {
            err_logo(TOO_MUCH, NIL); /* too many inputs */
        }
        args = car(args);
    }
    /* now args is always a list of objects */
    /* make sure they're all really objects */

    for (argcopy = args; (argcopy != NIL && NOT_THROWING); 
			 argcopy = cdr(argcopy)) {
        while (!is_object(car(argcopy)) && NOT_THROWING) {
            setcar(argcopy, err_logo(BAD_DATA, car(argcopy)));
        }
    }

    if (NOT_THROWING) {
        val = newobj();
        setparents(val, args);
    }

    return val;
}
static std::string
format_verbose_info(mtx::id::verbose_info_t const &info) {
  auto formatted = std::vector<std::string>{};
  auto sub_fmt   = boost::format("%1%.%2%.%3%");

  for (auto const &pair : info) {
    if (pair.second.is_array()) {
      auto idx = 0u;

      for (auto it = pair.second.begin(), end = pair.second.end(); it != end; ++it) {
        if (it->is_object()) {
          for (auto sub_it = it->begin(), sub_end = it->end(); sub_it != sub_end; ++sub_it)
            formatted.emplace_back(format_key_and_json_value((sub_fmt % pair.first % idx % sub_it.key()).str(), sub_it.value()));

          ++idx;

        } else
          formatted.emplace_back(format_key_and_json_value(pair.first, *it));
      }

    } else
      formatted.emplace_back(format_key_and_json_value(pair.first, pair.second));
  }

  brng::sort(formatted);

  return boost::join(formatted, " ");
}
CL_CSSLayoutObject CL_CSSLayoutNode::to_object() const
{
	if (is_object())
		return CL_CSSLayoutObject(impl);
	else
		return CL_CSSLayoutObject();
}
Exemple #6
0
NODE *loneof(NODE *args) {
    NODE *val = UNBOUND, *argcopy;

    if (!is_list(car(args))) {
        setcar(args, cons(car(args), NIL));
    }
    /* now the first arg is always a list of objects */

    /* make sure they're really objects */
    argcopy = car(args);
    while (argcopy != NIL && NOT_THROWING) {
        while (!is_object(car(argcopy)) && NOT_THROWING) {
            setcar(argcopy, err_logo(BAD_DATA, car(argcopy)));
        }
        argcopy = cdr(argcopy);
    }

    if (NOT_THROWING) {
        val = newobj();
        setparents(val, car(args));

        /* apply [[InitList] [Exist Output Self]] cdr(args) */
	return make_cont(withobject_continuation,
			 cons(val,
			      make_cont(begin_apply,
					cons(askexist,
					     cons(cons(cdr(args), NIL),
						  NIL)))));
    }

    return val;
}
Exemple #7
0
/* Changes to Object the object in which subsequent top level instruction will
 * be run until the next time TalkTo is run
 * @params - Object
 */
NODE *ltalkto(NODE *args) {
    while (!is_object(car(args)) && NOT_THROWING)
	setcar(args, err_logo(BAD_DATA, car(args)));

    if (NOT_THROWING)
	current_object = car(args);

    return UNBOUND;
}
Exemple #8
0
 inline Integer* to_integer(ObjP p)
 {
     if (is_object(p))
         return to_object(p)->cast_integer();
     else
         if (is_fixnum(p))
             return new Integer(fixnum_to_int(p));
     throw new Exception("bad_integer", p);
 }
Exemple #9
0
inline std::optional<nlohmann::json::const_iterator> find_object(const nlohmann::json& json,
                                                                 const std::string& key) {
  auto it = json.find(key);
  if (it != std::end(json)) {
    if (it->is_object()) {
      return it;
    }
  }
  return std::nullopt;
}
bool
JSON::add(const prog_char key[], int32_t value)
{
  if (!is_object())
    return false;

  if (!obj_separator())
    return false;

  return append("\"") && append_progstr(key) && append("\":") && append(value);
}
bool
JSON::add(const prog_char key[], const char *value)
{
  if (!is_object())
    return false;

  if (!obj_separator())
    return false;

  return (append("\"") && append_progstr(key) && append("\":\"")
          && append(value) && append("\""));
}
Exemple #12
0
 inline int int_value(ObjP p)
 {
     if (is_object(p))
     {
         Integer* integer = to_object(p)->cast_integer();
         return integer->int_value();
     }
     else
         if (is_fixnum(p))
             return fixnum_to_int(p);
     throw new Exception("bad_integer", p);
 }
Exemple #13
0
/* Runs RunList, with Object as the current object for the duration of the
 * Ask. After RunList finishes, the current object reverts to what it was
 * before the Ask.
 * @params - Object RunList
 */
NODE *lask(NODE *args) {
    while (!is_object(car(args)) && NOT_THROWING)
        setcar(args, err_logo(BAD_DATA, car(args)));

    if (NOT_THROWING) {
	return make_cont(withobject_continuation,
			 cons(car(args),
			      make_cont(begin_seq, cadr(args))));
    }

    return UNBOUND;
}
Exemple #14
0
 void update(oga::proto::config::object & dest, oga::proto::config::object const & src) {
     typedef oga::proto::config::object::const_iterator iter_t;
     for(iter_t iter = src.begin(), end = src.end(); iter != end; ++iter) {
         if(is_object(iter->second)) {
             if(dest.count(iter->first) == 0) {
                 dest[iter->first] = oga::proto::config::object();
             }
             update(dest[iter->first].get_object(), iter->second.get_object());
         } else {
             dest[iter->first] = iter->second;
         }
     }
 }
bool VerificationType::is_reference_assignable_from(
    const VerificationType& from, ClassVerifier* context,
    bool from_field_is_protected, TRAPS) const {
  instanceKlassHandle klass = context->current_class();
  if (from.is_null()) {
    // null is assignable to any reference
    return true;
  } else if (is_null()) {
    return false;
  } else if (name() == from.name()) {
    return true;
  } else if (is_object()) {
    // We need check the class hierarchy to check assignability
    if (name() == vmSymbols::java_lang_Object()) {
      // any object or array is assignable to java.lang.Object
      return true;
    }
    Klass* obj = SystemDictionary::resolve_or_fail(
        name(), Handle(THREAD, klass->class_loader()),
        Handle(THREAD, klass->protection_domain()), true, CHECK_false);
    if (TraceClassResolution) {
      Verifier::trace_class_resolution(obj, klass());
    }

    KlassHandle this_class(THREAD, obj);

    if (this_class->is_interface() && (!from_field_is_protected ||
        from.name() != vmSymbols::java_lang_Object())) {
      // If we are not trying to access a protected field or method in
      // java.lang.Object then we treat interfaces as java.lang.Object,
      // including java.lang.Cloneable and java.io.Serializable.
      return true;
    } else if (from.is_object()) {
      Klass* from_class = SystemDictionary::resolve_or_fail(
          from.name(), Handle(THREAD, klass->class_loader()),
          Handle(THREAD, klass->protection_domain()), true, CHECK_false);
      if (TraceClassResolution) {
        Verifier::trace_class_resolution(from_class, klass());
      }
      return InstanceKlass::cast(from_class)->is_subclass_of(this_class());
    }
  } else if (is_array() && from.is_array()) {
    VerificationType comp_this = get_component(context, CHECK_false);
    VerificationType comp_from = from.get_component(context, CHECK_false);
    if (!comp_this.is_bogus() && !comp_from.is_bogus()) {
      return comp_this.is_component_assignable_from(comp_from, context,
                                          from_field_is_protected, CHECK_false);
    }
  }
  return false;
}
Exemple #16
0
void process_sound_events(EngineState *s) { /* Get all sound events, apply their changes to the heap */
	int result;
	SongHandle handle;
	int cue;

	if (s->_version >= SCI_VERSION_01)
		return;
	/* SCI01 and later explicitly poll for everything */

	while ((result = s->_sound.sfx_poll(&handle, &cue))) {
		reg_t obj = DEFROBNICATE_HANDLE(handle);
		if (!is_object(s, obj)) {
			warning("Non-object %04x:%04x received sound signal (%d/%d)", PRINT_REG(obj), result, cue);
			return;
		}

		switch (result) {

		case SI_LOOP:
			debugC(2, kDebugLevelSound, "[process-sound] Song %04x:%04x looped (to %d)\n",
			          PRINT_REG(obj), cue);
			/*			PUT_SEL32V(obj, loops, GET_SEL32V(obj, loop) - 1);*/
			PUT_SEL32V(obj, signal, -1);
			break;

		case SI_RELATIVE_CUE:
			debugC(2, kDebugLevelSound, "[process-sound] Song %04x:%04x received relative cue %d\n",
			          PRINT_REG(obj), cue);
			PUT_SEL32V(obj, signal, cue + 0x7f);
			break;

		case SI_ABSOLUTE_CUE:
			debugC(2, kDebugLevelSound, "[process-sound] Song %04x:%04x received absolute cue %d\n",
			          PRINT_REG(obj), cue);
			PUT_SEL32V(obj, signal, cue);
			break;

		case SI_FINISHED:
			debugC(2, kDebugLevelSound, "[process-sound] Song %04x:%04x finished\n",
			          PRINT_REG(obj));
			PUT_SEL32V(obj, signal, -1);
			PUT_SEL32V(obj, state, _K_SOUND_STATUS_STOPPED);
			break;

		default:
			warning("Unexpected result from sfx_poll: %d", result);
			break;
		}
	}
}
Exemple #17
0
/*
 * Assume that we have root object. 
 */ 
void * parent(void * Self_v) {
  const struct root_osd * Self = Self_v;
//  const struct object_properties_osd ** Self = Self_v + sizeof(object_osa);
  /*
  if (NULL == Self) {
	ERROR("Attempt to get parent of object at NULL address.");
	THROW(NULL_POINTER_OBJECT);
	// never reach this point return only to remove warning	
	return NULL;
  }
  */
  ASSERT(FALSE == is_object(Self_v), NULL_POINTER_OBJECT, NULL,
		 "Malformed object.");
  return (void *)(Self->properties->parent);
}
Exemple #18
0
const char* json_node::get_type(void) const
{
	if (is_string())
		return "string";
	else if (is_number())
		return "number";
	else if (is_bool())
		return "bool";
	else if (is_null())
		return "null";
	else if (is_object())
		return "object";
	else if (is_array())
		return "array";
	else
		return "unknown";
}
Exemple #19
0
OdinEvent::OdinEvent(const j::json &full_msg)
  : OdinEvent() {

  if (full_msg.is_object()) {
    auto v= full_msg["type"];
    if (v.is_number()) {
      _type = SCAST(MType, JS_INT(v));
    }
    v= full_msg["code"];
    if (v.is_number()) {
      _code = SCAST(EType, JS_INT(v));
    }
    v= full_msg["source"];
    if (v.is_object()) {
      _doco =v;
    }
  }
}
Exemple #20
0
int is_entity_ok (int x, int y)
{
    // On vérifie si aucune autre entité n'est sur la case visée
    if (is_occupied(x, y))
        return 0;

    // On vérifie si le personnage n'essaye pas de sortir de la map
    if (!is_in_map(x, y))
        return 0;

    // On vérifie si le personnage peut marcher si le tile visé
    if (is_bloquant(x, y))
        return 0;

    if (is_object(x, y))
        return 0;

    return 1;
}
Exemple #21
0
bool Config::parse()
{
    std::ifstream ifs(m_path);

    // File exists?
    if (ifs.good())
    {
        const auto jsonDoc = json::parse(ifs);

        if (jsonDoc.is_object() && (jsonDoc.find("ipdvrConfig") != jsonDoc.end()))
        {
            DEBUG_PRINT("Found a valid ipdvrConfig root tag in file: " << m_path << std::endl);
        }
        else
        {
            ERROR_PRINT("Error parsing config file: " << m_path << std::endl);
            return false;
        }

        const auto rootNode = jsonDoc["ipdvrConfig"];
        if (rootNode.find("channels") != rootNode.end())
        {
            m_channelDataList = parseChannels(rootNode["channels"]);
            DEBUG_PRINT("Parsed a channel list with " << m_channelDataList.size() << " entries." << std::endl);
            return true;
        }
        else
        {
            ERROR_PRINT("No channels defined!" << std::endl);
            return false;
        }
    }
    else
    {
        ERROR_PRINT("Could not open configuration file: " << m_path << std::endl);
        return false;
    }
}
Exemple #22
0
bool VerificationType::is_reference_assignable_from(
    const VerificationType& from, ClassVerifier* context,
    bool from_field_is_protected, TRAPS) const {
  instanceKlassHandle klass = context->current_class();
  if (from.is_null()) {
    // null is assignable to any reference
    return true;
  } else if (is_null()) {
    return false;
  } else if (name() == from.name()) {
    return true;
  } else if (is_object()) {
    // We need check the class hierarchy to check assignability
    if (name() == vmSymbols::java_lang_Object()) {
      // any object or array is assignable to java.lang.Object
      return true;
    }

    if (DumpSharedSpaces && SystemDictionaryShared::add_verification_constraint(klass(),
              name(), from.name(), from_field_is_protected, from.is_array(),
              from.is_object())) {
      // If add_verification_constraint() returns true, the resolution/check should be
      // delayed until runtime.
      return true;
    }

    return resolve_and_check_assignability(klass(), name(), from.name(),
          from_field_is_protected, from.is_array(), from.is_object(), THREAD);
  } else if (is_array() && from.is_array()) {
    VerificationType comp_this = get_component(context, CHECK_false);
    VerificationType comp_from = from.get_component(context, CHECK_false);
    if (!comp_this.is_bogus() && !comp_from.is_bogus()) {
      return comp_this.is_component_assignable_from(comp_from, context,
                                          from_field_is_protected, CHECK_false);
    }
  }
  return false;
}
bool
JSON::add(const prog_char key[], const uint8_t *data, size_t data_len)
{
  size_t i;
  char buf[4];

  if (!is_object())
    return false;

  if (!obj_separator())
    return false;

  if (!append("\"") || !append_progstr(key) || !append("\":\""))
    return false;

  for (i = 0; i < data_len; i++)
    {
      snprintf(buf, sizeof(buf), "%02x", data[i]);
      if (!append(buf))
        return false;
    }

  return append("\"");
}
Exemple #24
0
bool f_is_object(CVarRef v) {
  return is_object(v);
}
Exemple #25
0
int is_image( lua_State* L, int index )
{
	return is_object( L, index, uiImageSignature );
}
 value_type parse() {
     value_type result;
     require(is_object(result) || is_array(result), "object or array");
     return result;
 }
Exemple #27
0
 void assign( value v ) { val = v; assert( is_object(v) || is_native_object(v) ); }
bool HHVM_FUNCTION(is_object, const Variant& v) {
  return is_object(v);
}
Exemple #29
0
 inline Code* to_code(ObjP p)
 {
     if (is_object(p))
         return to_object(p)->cast_code();
     throw new Exception("bad_type", p);
 }
Exemple #30
0
	VALUE set_internal(VALUE obj, VALUE member, VALUE val) {
		ASSERT(is_object(obj) && "Cannot set members of immediates!");
		return object_for(obj)->set(obj, member, val).value();
	}