Example #1
0
/**
 * Set a camera parameter
 */
int CaptureCommand::capture_setParameter(Value& name, Value& value) {
  LOG_ERROR((name.isNull()), "name not specified");
  LOG_ERROR((value.isNull()), "value not specified");
  LOG_ERROR((mCamera.get() == NULL), "camera not initialized");

  CameraParameters params = mCamera->getParameters();
  params.set(name.asCString(), value.asCString());
  status_t err = mCamera->setParameters(params.flatten());
  if (err != ::OK) {
    ALOGW("Error %d: Failed to set '%s' to '%s'", err,
      name.asCString(), value.asCString());
  }
  return 0;
}
    // Method for sending message from CPP to the targeted platform
    void sendMessageWithParams(std::string methodName, Value methodParams) {
        if (0 == strcmp(methodName.c_str(), "")) {
            return;
        }

        json_t *toBeSentJson = json_object();
        json_object_set_new(toBeSentJson, __CALLED_METHOD__, json_string(methodName.c_str()));

        if (!methodParams.isNull()) {
            json_t *paramsJson = NDKHelper::getJsonFromValue(methodParams);

            json_object_set_new(toBeSentJson, __CALLED_METHOD_PARAMS__, paramsJson);
        }

#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID)
        JniMethodInfo t;

        if (JniHelper::getStaticMethodInfo(t,
                                           CLASS_NAME,
                                           "ReceiveCppMessage",
                                           "(Ljava/lang/String;)V")) {
            char *jsonStrLocal = json_dumps(toBeSentJson, JSON_COMPACT | JSON_ENSURE_ASCII);
            std::string jsonStr(jsonStrLocal);
            free(jsonStrLocal);

            jstring stringArg1 = t.env->NewStringUTF(jsonStr.c_str());
            t.env->CallStaticVoidMethod(t.classID, t.methodID, stringArg1);
            t.env->DeleteLocalRef(stringArg1);
            t.env->DeleteLocalRef(t.classID);
        }
#endif

#if (CC_TARGET_PLATFORM == CC_PLATFORM_IOS)
        json_t *jsonMessageName = json_string(methodName.c_str());

        if (!methodParams.isNull()) {
            json_t *jsonParams = NDKHelper::getJsonFromValue(methodParams);

            IOSNDKHelperImpl::receiveCPPMessage(jsonMessageName, jsonParams);

            json_decref(jsonParams);
        } else {
            IOSNDKHelperImpl::receiveCPPMessage(jsonMessageName, NULL);
        }

        json_decref(jsonMessageName);
#endif

        json_decref(toBeSentJson);
    }
folly::Optional<Object> JSINativeModules::createModule(
    Runtime& rt,
    const std::string& name) {
  bool hasLogger(ReactMarker::logTaggedMarker);
  if (hasLogger) {
    ReactMarker::logTaggedMarker(
        ReactMarker::NATIVE_MODULE_SETUP_START, name.c_str());
  }

  if (!m_genNativeModuleJS) {
    m_genNativeModuleJS =
        rt.global().getPropertyAsFunction(rt, "__fbGenNativeModule");
  }

  auto result = m_moduleRegistry->getConfig(name);
  if (!result.hasValue()) {
    return nullptr;
  }

  Value moduleInfo = m_genNativeModuleJS->call(
      rt,
      valueFromDynamic(rt, result->config),
      static_cast<double>(result->index));
  CHECK(!moduleInfo.isNull()) << "Module returned from genNativeModule is null";

  folly::Optional<Object> module(
      moduleInfo.asObject(rt).getPropertyAsObject(rt, "module"));

  if (hasLogger) {
    ReactMarker::logTaggedMarker(
        ReactMarker::NATIVE_MODULE_SETUP_STOP, name.c_str());
  }

  return module;
}
/*@return the highest layer could build, otherwise NONE
*/
int MapModel::canBuildOnTilePosition(Point pos){
	Point TileLoc = tileCoordForPosition(pos);

	//@debug modify label.
	{
		char buffer[30];
		sprintf(buffer, "row:%.0f, col:%.0f", TileLoc.x, TileLoc.y);
		//getlblTilePos()->setString(buffer);
	}

	//@var later need to Resoucre Manager
	PFComponent *target = nullptr;
	if (_status == HUD_ID::DEFENSE) target = Building::build(selID);
	if (_status == HUD_ID::ATTACK) target = Troop::addTroop(selID);
	CCASSERT(target != nullptr, "target != nullptr");
	for (int lr = SZ(_pfLayers) - 1; lr >= 0; lr--){
		Point buildingLoc = mapCoordForPosition(pos, lr);

		//@procedure check for no tiles on the tile.
		bool noTileOnDirectly = true;
		if (lr < SZ(_pfLayers) - 1){
			for (int tr = 0; tr < target->getOccupy().X; tr++) for (int tc = 0; tc < target->getOccupy().Y; tc++){
				for (int offset = 0; offset <= 1; offset++){
					Point checkTileLoc = Point(TileLoc.x + tr, TileLoc.y - tc * 2 + offset);
					if (isTileInsideLayer(checkTileLoc, lr)){
						int tileGid = _pfLayers.at(lr + 1)->getTileGIDAt(checkTileLoc);
						if (tileGid != EMPTY_TILE) noTileOnDirectly = false;
					}
				}
			}
		}
		if (!noTileOnDirectly) continue;

		int couldTileCnt = 0;
		for (int tr = 0; tr < target->getOccupy().X; tr++) for (int tc = 0; tc < target->getOccupy().Y; tc++){
			for (int offset = 1; offset <= 2; offset++){
				Point checkTileLoc = Point(TileLoc.x + tr, TileLoc.y - tc * 2 + offset);
				if (isTileInsideLayer(checkTileLoc, lr)){
					int tileGid = _pfLayers.at(lr)->getTileGIDAt(checkTileLoc);

					Value props = _tileMap->getPropertiesForGID(tileGid);
					if (!props.isNull()){
						ValueMap map = props.asValueMap();
						int type_int = 0;
						if (map.size() == 0)
							type_int = 0;
						else
							type_int = map.at("buildable").asInt();
						if (1 == type_int){
							couldTileCnt++;
							break;
						}
					}
				}
			}
		}
		if (couldTileCnt == target->getOccupy().X*target->getOccupy().Y) return lr + 1;
	}
	return -1;
}
folly::Optional<Object> JSCNativeModules::createModule(const std::string& name, JSContextRef context) {
  ReactMarker::logTaggedMarker(ReactMarker::NATIVE_MODULE_SETUP_START, name.c_str());

  if (!m_genNativeModuleJS) {
    auto global = Object::getGlobalObject(context);
    m_genNativeModuleJS = global.getProperty("__fbGenNativeModule").asObject();
    m_genNativeModuleJS->makeProtected();
  }

  auto result = m_moduleRegistry->getConfig(name);
  if (!result.hasValue()) {
    return nullptr;
  }

  Value moduleInfo = m_genNativeModuleJS->callAsFunction({
    Value::fromDynamic(context, result->config),
    Value::makeNumber(context, result->index)
  });
  CHECK(!moduleInfo.isNull()) << "Module returned from genNativeModule is null";

  folly::Optional<Object> module(moduleInfo.asObject().getProperty("module").asObject());

  ReactMarker::logTaggedMarker(ReactMarker::NATIVE_MODULE_SETUP_STOP, name.c_str());

  return module;
}
Example #6
0
boost::shared_ptr< Array> execute(std::vector< boost::shared_ptr< Array> >& inputArrays,boost::shared_ptr< Query> query)
{
  boost::shared_ptr<Array> inputArray = inputArrays[0];
  const ArrayDesc &arrayDesc = inputArray->getArrayDesc();
  DimensionDesc xDim= arrayDesc.getDimensions()[2];
  DimensionDesc yDim= arrayDesc.getDimensions()[1];
  DimensionDesc zDim= arrayDesc.getDimensions()[0];
  AttributeID aid = 0; // default attribute pix
  TypeId attType = TID_INT32;
  int32_t threshold = 1000; // default threashold
  Value value = ((boost::shared_ptr<OperatorParamPhysicalExpression>&)_parameters[1])->getExpression()->evaluate();
  if (!value.isNull())
  {
    threshold = value.getInt32();
  }
  Attributes attributes = arrayDesc.getAttributes();

  aid = ((boost::shared_ptr<OperatorParamReference>&)_parameters[0])->getObjectNo();
  attType = attributes[aid].getType();

  boost::shared_ptr<ConstArrayIterator> aItr = inputArray->getConstIterator(aid);
    
  boost::shared_ptr<MemArray> outputArray = boost::shared_ptr<MemArray>(new MemArray(_schema,query));
  ImageProvider provider(aItr, outputArray, aid);
  Cook cook(provider, threshold);
  while(!aItr->end())
  {
    cook.cookRawImage();
    LOG4CXX_DEBUG(logger, "Cooking image: " << aItr->getPosition()[0]);
    ++(*aItr);
  }
  provider.onFinalize();
  return outputArray;
}
Example #7
0
static JSAtom *
ToAtomSlow(ExclusiveContext *cx, typename MaybeRooted<Value, allowGC>::HandleType arg)
{
    JS_ASSERT(!arg.isString());

    Value v = arg;
    if (!v.isPrimitive()) {
        if (!cx->shouldBeJSContext() || !allowGC)
            return NULL;
        RootedValue v2(cx, v);
        if (!ToPrimitive(cx->asJSContext(), JSTYPE_STRING, &v2))
            return NULL;
        v = v2;
    }

    if (v.isString())
        return AtomizeString<allowGC>(cx, v.toString());
    if (v.isInt32())
        return Int32ToAtom<allowGC>(cx, v.toInt32());
    if (v.isDouble())
        return NumberToAtom<allowGC>(cx, v.toDouble());
    if (v.isBoolean())
        return v.toBoolean() ? cx->names().true_ : cx->names().false_;
    if (v.isNull())
        return cx->names().null;
    return cx->names().undefined;
}
Example #8
0
JSON_STATUS CVideoLibrary::GetTVShowDetails(const CStdString &method, ITransportLayer *transport, IClient *client, const Value &parameterObject, Value &result)
{
  if (!(parameterObject.isObject() || parameterObject.isNull() || parameterObject.isMember("tvshowid")))
    return InvalidParams;

  int id = parameterObject.get("tvshowid", -1).asInt();
  if (id < 0)
    return InvalidParams;

  CVideoDatabase videodatabase;
  if (!videodatabase.Open())
    return InternalError;

  CVideoInfoTag infos;
  videodatabase.GetTvShowInfo("", infos, id);
  if (infos.m_iDbId <= 0)
  {
    videodatabase.Close();
    return InvalidParams;
  }

  Json::Value validFields = Value(arrayValue);
  MakeFieldsList(parameterObject, validFields);
  HandleFileItem("tvshowid", true, "tvshowdetails", CFileItemPtr(new CFileItem(infos)), parameterObject, validFields, result);

  videodatabase.Close();
  return OK;
}
Example #9
0
string MyUtility::getUTF8Char(const string key)
{
	auto sharedFileUtils = FileUtils::getInstance();

	std::string fullPathForFilename = sharedFileUtils->fullPathForFilename("utf8_char.plist");

	bool isExist = false;
	isExist = sharedFileUtils->isFileExist(fullPathForFilename);
	if (!isExist) {
		log("utf8_char.plist doesn't exist.");
		return "";
	}

	ValueMap map = sharedFileUtils->getValueMapFromFile(fullPathForFilename);
	Value value =  map[key];

	//log("%s - %s",key.c_str(), value.asString().c_str());

	if (value.isNull()) {
		log("%s doesn't exist.",key.c_str());
		return "";
	}
	return value.asString();

}
Example #10
0
Number Number::dynamicCast(const Value &v)
{
  if (v.isNull() || v.type() != NumberType)
    return Number((NumberImp*)0);

  return Number(static_cast<NumberImp*>(v.imp()));
}
Value Reference::getValue(ExecState *exec) const 
{
  if (baseIsValue) {
    return base;
  }

  Value o = getBase(exec);

  if (o.isNull() || o.type() == NullType) {
    UString m = I18N_NOOP("Can't find variable: ") + getPropertyName(exec).ustring();
    Object err = Error::create(exec, ReferenceError, m.ascii());
    exec->setException(err);
    return err;
  }

  if (o.type() != ObjectType) {
    UString m = I18N_NOOP("Base is not an object");
    Object err = Error::create(exec, ReferenceError, m.ascii());
    exec->setException(err);
    return err;
  }

  if (propertyNameIsNumber)
    return static_cast<ObjectImp*>(o.imp())->get(exec,propertyNameAsNumber);
  return static_cast<ObjectImp*>(o.imp())->get(exec,prop);
}
Example #12
0
Boolean Boolean::dynamicCast(const Value &v)
{
  if (v.isNull() || v.type() != BooleanType)
    return static_cast<BooleanImp*>(0);

  return static_cast<BooleanImp*>(v.imp());
}
Example #13
0
String String::dynamicCast(const Value &v)
{
  if (v.isNull() || v.type() != StringType)
    return String(0);

  return String(static_cast<StringImp*>(v.imp()));
}
Example #14
0
Null Null::dynamicCast(const Value &v)
{
  if (v.isNull() || v.type() != NullType)
    return Null(0);

  return Null();
}
Example #15
0
Undefined Undefined::dynamicCast(const Value &v)
{
  if (v.isNull() || v.type() != UndefinedType)
    return Undefined(0);

  return Undefined();
}
bool _NPN_HasMethod(NPP npp, NPObject *o, NPIdentifier methodName)
{
    if (o->_class == NPScriptObjectClass) {
        JavaScriptObject *obj = (JavaScriptObject *)o; 
        
	if (!_isSafeScript(obj))
	    return false;

        PrivateIdentifier *i = (PrivateIdentifier *)methodName;
        if (!i->isString)
            return false;
            
        // Lookup the function object.
        ExecState *exec = obj->executionContext->interpreter()->globalExec();
        Interpreter::lock();
        Value func = obj->imp->get (exec, identiferFromNPIdentifier(i->value.string));
        Interpreter::unlock();

        if (func.isNull() || func.type() == UndefinedType) {
            return false;
        }
        
        return true;
    }
    
    else if (o->_class->hasMethod) {
        return o->_class->hasMethod (o, methodName);
    }
    
    return false;
}
Example #17
0
 std::pair<size_t, bool> StreamWriter<StreamType>::append_value(const Value& v)
 {
     std::pair<size_t, bool> k(0, false);
     if(v.isNull())
         k = append_null();
     else if(v.isBool())
         k = append_bool(v);
     else if(v.isChar())
         k = append_char(v);
     else if(v.isSignedInteger())
         k = append_signedInt(v);
     else if(v.isUnsignedInteger())
         k = append_unsignedInt(v);
     else if(v.isFloat())
         k = append_float(v);
     else if(v.isString())
         k = append_string(v);
     //else if(v.isBinary())
     //    k = append_binary(v); //currently not supported
     else if(v.isArray())
         k = append_array(v);
     else if(v.isObject())
         k = append_object(v);
     return k;
 }
Example #18
0
/**
 * This function is run when a capture command is received from the client
 */
int CaptureCommand::runCommand(SocketClient *c, int argc, char ** argv) {
  ALOGD("Received command %s", argv[0]);

  // Parse JSON command
  Value cmdJson;
  bool result = mJsonReader.parse(argv[0], cmdJson, false);
  LOG_ERROR((result != true), "Failed to parse command: %s",
      mJsonReader.getFormattedErrorMessages().c_str());

  // Get command name
  Value cmdNameVal = cmdJson["cmdName"];
  LOG_ERROR((cmdNameVal.isNull()), "cmdName not available");

  string cmdName = cmdNameVal.asString();
  if (cmdName == "init") {
    capture_init(cmdJson["cmdData"]);
  } else if (cmdName == "update") {
    capture_update(cmdJson["cmdData"]);
  } else if (cmdName == "stop") {
    capture_cleanup();
  } else if (cmdName == "setParameter") {
    capture_setParameter(cmdJson["name"], cmdJson["value"]);
  } else if (cmdName == "getParameterInt") {
    capture_getParameterInt(cmdJson["name"]);
  } else if (cmdName == "getParameterStr") {
    capture_getParameterStr(cmdJson["name"]);
  } else {
    LOG_ERROR(true, "Invalid command %s", cmdName.c_str());
  }

  return 0;
}
bool _NPN_Invoke (NPP npp, NPObject *o, NPIdentifier methodName, const NPVariant *args, uint32_t argCount, NPVariant *result)
{
    if (o->_class == NPScriptObjectClass) {
        JavaScriptObject *obj = (JavaScriptObject *)o; 
        
	if (!_isSafeScript(obj))
	    return false;
	    
        PrivateIdentifier *i = (PrivateIdentifier *)methodName;
        if (!i->isString)
            return false;
            
	// Special case the "eval" method.
	if (methodName == _NPN_GetStringIdentifier("eval")) {
	    if (argCount != 1)
		return false;
	    if (args[0].type != NPVariantType_String)
		return false;
	    
	    return _NPN_Evaluate (npp, o, (NPString *)&args[0].value.stringValue, result);
	}
	else {
	    // Lookup the function object.
	    ExecState *exec = obj->executionContext->interpreter()->globalExec();
	    Interpreter::lock();
	    Value func = obj->imp->get (exec, identiferFromNPIdentifier(i->value.string));
	    Interpreter::unlock();

	    if (func.isNull()) {
		NPN_InitializeVariantAsNull(result);
		return false;
	    }
	    else if ( func.type() == UndefinedType) {
		NPN_InitializeVariantAsUndefined(result);
		return false;
	    }
	    else {
		// Call the function object.
		ObjectImp *funcImp = static_cast<ObjectImp*>(func.imp());
		Object thisObj = Object(const_cast<ObjectImp*>(obj->imp));
		List argList = listFromVariantArgs(exec, args, argCount);
		Interpreter::lock();
		Value resultV = funcImp->call (exec, thisObj, argList);
		Interpreter::unlock();

		// Convert and return the result of the function call.
		convertValueToNPVariant(exec, resultV, result);
		return true;
	    }
	}
    }
    else {
        if (o->_class->invoke) {
            return o->_class->invoke (o, methodName, args, argCount, result);
        }
    }
    
    return true;
}
bool _NPN_GetProperty (NPP npp, NPObject *o, NPIdentifier propertyName, NPVariant *variant)
{
    if (o->_class == NPScriptObjectClass) {
        JavaScriptObject *obj = (JavaScriptObject *)o; 

	if (!_isSafeScript(obj))
	    return false;

        ExecState *exec = obj->executionContext->interpreter()->globalExec();

        PrivateIdentifier *i = (PrivateIdentifier *)propertyName;
        if (i->isString) {
            if (!obj->imp->hasProperty (exec, identiferFromNPIdentifier(i->value.string))) {
                NPN_InitializeVariantAsNull(variant);
                return false;
            }
        }
        else {
            if (!obj->imp->hasProperty (exec, i->value.number)) {
                NPN_InitializeVariantAsNull(variant);
                return false;
            }
        }
        
        Interpreter::lock();
        Value result;
        if (i->isString) {
            result = obj->imp->get (exec, identiferFromNPIdentifier(i->value.string));
        }
        else {
            result = obj->imp->get (exec, i->value.number);
        }
        Interpreter::unlock();

        if (result.isNull()) {
            NPN_InitializeVariantAsNull(variant);
            return false;
        }
        else if (result.type() == UndefinedType) {
            NPN_InitializeVariantAsUndefined(variant);
            return false;
        }
        else {
            convertValueToNPVariant(exec, result, variant);
        }

        return true;
    }
    else if (o->_class->hasProperty && o->_class->getProperty) {
        if (o->_class->hasProperty (o, propertyName)) {
            return o->_class->getProperty (o, propertyName, variant);
        }
        else {
            return false;
        }
    }
    return false;
}
Example #21
0
TEST(GTestValue, TestIsNull) {
    Value v = Object::null();
    ASSERT_TRUE(v.isNull());

    v = String::null();
    ASSERT_TRUE(v.isNull());

    v = String::create();
    ASSERT_FALSE(v.isNull());

    v = ArrayList::null();
    ASSERT_TRUE(v.isNull());

    v = ArrayList::create();
    ASSERT_FALSE(v.isNull());

    v = 0;
    ASSERT_FALSE(v.isNull());

    // same as 'v = 0'
    // v = NULL;
    // ASSERT_FALSE(v.isNull());

    v = 5;
    ASSERT_FALSE(v.isNull());
}
Example #22
0
// helper method for "yarpdev" body
static void toDox(PolyDriver& dd, FILE *os) {
    fprintf(os,"===============================================================\n");
    fprintf(os,"== Options checked by device:\n== \n");

    Bottle order = dd.getOptions();
    for (size_t i=0; i<order.size(); i++) {
        std::string name = order.get(i).toString();
        if (name=="wrapped"||(name.find(".wrapped")!=std::string::npos)) {
            continue;
        }
        std::string desc = dd.getComment(name.c_str());
        Value def = dd.getDefaultValue(name.c_str());
        Value actual = dd.getValue(name.c_str());
        std::string out = "";
        out += name;
        if (!actual.isNull()) {
            if (actual.toString()!="") {
                out += "=";
                if (actual.toString().length()<40) {
                    out += actual.toString().c_str();
                } else {
                    out += "(value too long)";
                }
            }
        }
        if (!def.isNull()) {
            if (def.toString()!="") {
                out += " [";
                if (def.toString().length()<40) {
                    out += def.toString().c_str();
                } else {
                    out += "(value too long)";
                }
                out += "]";
            }
        }
        if (desc!="") {
            out += "\n    ";
            out += desc.c_str();
        }
        fprintf(os,"%s\n", out.c_str());
    }
    fprintf(os,"==\n");
    fprintf(os,"===============================================================\n");
}
Example #23
0
static bool
Str(JSContext* cx, const Value& v, StringifyContext* scx)
{
    /* Step 11 must be handled by the caller. */
    MOZ_ASSERT(!IsFilteredValue(v));

    JS_CHECK_RECURSION(cx, return false);

    /*
     * This method implements the Str algorithm in ES5 15.12.3, but:
     *
     *   * We move property retrieval (step 1) into callers to stream the
     *     stringification process and avoid constantly copying strings.
     *   * We move the preprocessing in steps 2-4 into a helper function to
     *     allow both JO and JA to use this method.  While JA could use it
     *     without this move, JO must omit any |undefined|-valued property per
     *     so it can't stream out a value using the Str method exactly as
     *     defined by ES5.
     *   * We move step 11 into callers, again to ease streaming.
     */

    /* Step 8. */
    if (v.isString())
        return Quote(cx, scx->sb, v.toString());

    /* Step 5. */
    if (v.isNull())
        return scx->sb.append("null");

    /* Steps 6-7. */
    if (v.isBoolean())
        return v.toBoolean() ? scx->sb.append("true") : scx->sb.append("false");

    /* Step 9. */
    if (v.isNumber()) {
        if (v.isDouble()) {
            if (!IsFinite(v.toDouble()))
                return scx->sb.append("null");
        }

        return NumberValueToStringBuffer(cx, v, scx->sb);
    }

    /* Step 10. */
    MOZ_ASSERT(v.isObject());
    RootedObject obj(cx, &v.toObject());

    scx->depth++;
    bool ok;
    if (IsArray(obj, cx))
        ok = JA(cx, obj, scx);
    else
        ok = JO(cx, obj, scx);
    scx->depth--;

    return ok;
}
Example #24
0
static string int64_or_null(Value const& v)
{
    if (v.isNull()) {
        return "null";
    } else {
        stringstream ss;
        ss << v.getInt64();
        return ss.str();
    }
}
Example #25
0
ModuleEnvironmentObject*
ModuleObject::environment() const
{
    Value value = getReservedSlot(EnvironmentSlot);
    MOZ_ASSERT(!value.isNull());

    if (value.isUndefined())
        return nullptr;

    return &value.toObject().as<ModuleEnvironmentObject>();
}
Example #26
0
XPCTraceableVariant::~XPCTraceableVariant()
{
    Value val = GetJSValPreserveColor();

    MOZ_ASSERT(val.isGCThing(), "Must be traceable or unlinked");

    mData.Cleanup();

    if (!val.isNull())
        RemoveFromRootSet();
}
Example #27
0
/**
 * Update run-time configurable parameters
 */
int CaptureCommand::capture_update(Value& cmdData) {
  ALOGV("%s", __FUNCTION__);

  LOG_ERROR((cmdData.isNull()), "update command data is null");

  if (!cmdData["audioMute"].isNull()) {
    sAudioMute = cmdData["audioMute"].asBool();
    ALOGV("sAudioMute %d", sAudioMute);
  }
  return 0;
}
Example #28
0
bool rs::jsapi::Object::IsObject(const Value& value) {
    auto isObject = value.isObject() && !value.isNull();
    if (isObject) {
        auto obj = value.toObject();
        isObject = obj;
        if (isObject) {
            auto klass = JS_GetClass(obj);
            isObject = klass && klass->name && std::strcmp(klass->name, class_.name) == 0;
        }
    }
    return isObject; 
}
//以下为检测layer上都有什么
//说真的,还不是很明白,反正就是知道回馈它是否是一个prop(传进来的属性值)
bool TollgateMapLayer::isPropAtTileCoordForLayer(const char *prop, const Point &tileCoord, TMXLayer* layer)const
{
	if (!this->isValidTileCoord(tileCoord)){
		return false;
	}
	int gid = layer->getTileGIDAt(tileCoord);
	Value properties = map->getPropertiesForGID(gid);
	if (properties.isNull()){
		return false;
	}
	//prop是一个char,Valuemap是一个string,怎么能找到
	return properties.asValueMap().find(prop) != properties.asValueMap().end();
}
Example #30
0
bool MainScene::isPropAtTileCoordForLayer(const char *prop, const Point &tileCoord, TMXLayer *layer)
{
	if (!this->isValidTileCoord(tileCoord))
	{
		return false;
	}
	int gid = layer->getTileGIDAt(tileCoord);
	Value properties = _tileMap->getPropertiesForGID(gid);
	if (properties.isNull())
	{
		return false;
	}
	return properties.asValueMap().find(prop) != properties.asValueMap().end();
}