当前位置: 首页>>代码示例>>C++>>正文


C++ MutableHandleValue::setNull方法代码示例

本文整理汇总了C++中js::MutableHandleValue::setNull方法的典型用法代码示例。如果您正苦于以下问题:C++ MutableHandleValue::setNull方法的具体用法?C++ MutableHandleValue::setNull怎么用?C++ MutableHandleValue::setNull使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在js::MutableHandleValue的用法示例。


在下文中一共展示了MutableHandleValue::setNull方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: ErrorInvalidOperation

void
WebGL2Context::GetSamplerParameter(JSContext*, WebGLSampler* sampler, GLenum pname, JS::MutableHandleValue retval)
{
    retval.setNull();

    if (IsContextLost())
        return;

    if (!sampler || sampler->IsDeleted())
        return ErrorInvalidOperation("getSamplerParameter: invalid sampler");

    if (!ValidateSamplerParameterName(pname, "getSamplerParameter"))
        return;

    switch (pname) {
    case LOCAL_GL_TEXTURE_MIN_FILTER:
    case LOCAL_GL_TEXTURE_MAG_FILTER:
    case LOCAL_GL_TEXTURE_WRAP_S:
    case LOCAL_GL_TEXTURE_WRAP_T:
    case LOCAL_GL_TEXTURE_WRAP_R:
    case LOCAL_GL_TEXTURE_COMPARE_MODE:
    case LOCAL_GL_TEXTURE_COMPARE_FUNC:
        retval.set(JS::Int32Value(
                       WebGLContextUnchecked::GetSamplerParameteriv(sampler, pname)));
        return;

    case LOCAL_GL_TEXTURE_MIN_LOD:
    case LOCAL_GL_TEXTURE_MAX_LOD:
        retval.set(JS::Float32Value(
                       WebGLContextUnchecked::GetSamplerParameterfv(sampler, pname)));
        return;
    }
}
开发者ID:subsevenx2001,项目名称:gecko-dev,代码行数:33,代码来源:WebGL2ContextSamplers.cpp

示例2: rq

template<> void ScriptInterface::ToJSVal<IComponent*>(JSContext* cx, JS::MutableHandleValue ret, IComponent* const& val)
{
	JSAutoRequest rq(cx);
	if (val == NULL)
	{
		ret.setNull();
		return;
	}

	// If this is a scripted component, just return the JS object directly
	JS::RootedValue instance(cx, val->GetJSInstance());
	if (!instance.isNull())
	{
		ret.set(instance);
		return;
	}

	// Otherwise we need to construct a wrapper object
	// (TODO: cache wrapper objects?)
	JS::RootedObject obj(cx);
	if (!val->NewJSObject(*ScriptInterface::GetScriptInterfaceAndCBData(cx)->pScriptInterface, &obj))
	{
		// Report as an error, since scripts really shouldn't try to use unscriptable interfaces
		LOGERROR("IComponent does not have a scriptable interface");
		ret.setUndefined();
		return;
	}

	JS_SetPrivate(obj, static_cast<void*>(val));
	ret.setObject(*obj);
}
开发者ID:,项目名称:,代码行数:31,代码来源:

示例3: MakeContextCurrent

void
WebGL2Context::GetActiveUniformBlockParameter(JSContext* cx, const WebGLProgram& program,
                                              GLuint uniformBlockIndex, GLenum pname,
                                              JS::MutableHandleValue out_retval,
                                              ErrorResult& out_error)
{
    out_retval.setNull();
    if (IsContextLost())
        return;

    if (!ValidateObject("getActiveUniformBlockParameter: program", program))
        return;

    MakeContextCurrent();

    switch(pname) {
    case LOCAL_GL_UNIFORM_BLOCK_REFERENCED_BY_VERTEX_SHADER:
    case LOCAL_GL_UNIFORM_BLOCK_REFERENCED_BY_FRAGMENT_SHADER:
    case LOCAL_GL_UNIFORM_BLOCK_BINDING:
    case LOCAL_GL_UNIFORM_BLOCK_DATA_SIZE:
    case LOCAL_GL_UNIFORM_BLOCK_ACTIVE_UNIFORMS:
        out_retval.set(program.GetActiveUniformBlockParam(uniformBlockIndex, pname));
        return;

    case LOCAL_GL_UNIFORM_BLOCK_ACTIVE_UNIFORM_INDICES:
        out_retval.set(program.GetActiveUniformBlockActiveUniforms(cx, uniformBlockIndex,
                                                                   &out_error));
        return;
    }

    ErrorInvalidEnumInfo("getActiveUniformBlockParameter: parameter", pname);
}
开发者ID:alphan102,项目名称:gecko-dev,代码行数:32,代码来源:WebGL2ContextUniforms.cpp

示例4: GetQuery

void WebGLContext::GetQuery(JSContext* cx, GLenum target, GLenum pname,
                            JS::MutableHandleValue retval) {
  const FuncScope funcScope(*this, "getQuery");

  retval.setNull();
  if (IsContextLost()) return;

  switch (pname) {
    case LOCAL_GL_CURRENT_QUERY_EXT: {
      if (IsExtensionEnabled(WebGLExtensionID::EXT_disjoint_timer_query) &&
          target == LOCAL_GL_TIMESTAMP) {
        // Doesn't seem illegal to ask about, but is always null.
        // TIMESTAMP has no slot, so ValidateQuerySlotByTarget would generate
        // INVALID_ENUM.
        return;
      }

      const auto& slot = ValidateQuerySlotByTarget(target);
      if (!slot || !*slot) return;

      const auto& query = *slot;
      if (target != query->Target()) return;

      JS::Rooted<JS::Value> v(cx);
      dom::GetOrCreateDOMReflector(cx, slot->get(), &v);
      retval.set(v);
    }
      return;

    case LOCAL_GL_QUERY_COUNTER_BITS_EXT:
      if (!IsExtensionEnabled(WebGLExtensionID::EXT_disjoint_timer_query))
        break;

      if (target != LOCAL_GL_TIME_ELAPSED_EXT &&
          target != LOCAL_GL_TIMESTAMP_EXT) {
        ErrorInvalidEnumInfo("target", target);
        return;
      }

      {
        GLint bits = 0;
        gl->fGetQueryiv(target, pname, &bits);

        if (!Has64BitTimestamps() && bits > 32) {
          bits = 32;
        }
        retval.set(JS::Int32Value(bits));
      }
      return;

    default:
      break;
  }

  ErrorInvalidEnumInfo("pname", pname);
}
开发者ID:Noctem,项目名称:gecko-dev,代码行数:56,代码来源:WebGL2ContextQueries.cpp

示例5: GetQueryParameter

void WebGLContext::GetQueryParameter(JSContext*, const WebGLQuery& query,
                                     GLenum pname,
                                     JS::MutableHandleValue retval) {
  const FuncScope funcScope(*this, "getQueryParameter");
  retval.setNull();
  if (IsContextLost()) return;

  if (!ValidateObject("query", query)) return;

  query.GetQueryParameter(pname, retval);
}
开发者ID:Noctem,项目名称:gecko-dev,代码行数:11,代码来源:WebGL2ContextQueries.cpp

示例6: CallConstructor

void ScriptInterface::CallConstructor(JS::HandleValue ctor, JS::HandleValueArray argv, JS::MutableHandleValue out)
{
	JSAutoRequest rq(m->m_cx);
	if (!ctor.isObject())
	{
		LOGERROR("CallConstructor: ctor is not an object");
		out.setNull();
		return;
	}

	JS::RootedObject ctorObj(m->m_cx, &ctor.toObject());
	out.setObjectOrNull(JS_New(m->m_cx, ctorObj, argv));
}
开发者ID:Rektosauros,项目名称:0ad,代码行数:13,代码来源:ScriptInterface.cpp

示例7:

void
WebGLContext::GetQueryParameter(JSContext*, const WebGLQuery& query, GLenum pname,
                                JS::MutableHandleValue retval, const char* funcName)
{
    if (!funcName) {
        funcName = "getQueryParameter";
    }

    retval.setNull();
    if (IsContextLost())
        return;

    if (!ValidateObject(funcName, query))
        return;

    query.GetQueryParameter(pname, retval);
}
开发者ID:artines1,项目名称:gecko-dev,代码行数:17,代码来源:WebGL2ContextQueries.cpp

示例8: value

void
WebGL2Context::GetActiveUniforms(JSContext* cx, const WebGLProgram& program,
                                 const dom::Sequence<GLuint>& uniformIndices,
                                 GLenum pname, JS::MutableHandleValue retval)
{
    const char funcName[] = "getActiveUniforms";
    retval.setNull();
    if (IsContextLost())
        return;

    if (!ValidateUniformEnum(this, pname, funcName))
        return;

    if (!ValidateObject("getActiveUniforms: program", program))
        return;

    const auto& numActiveUniforms = program.LinkInfo()->uniforms.size();
    for (const auto& curIndex : uniformIndices) {
        if (curIndex >= numActiveUniforms) {
            ErrorInvalidValue("%s: Too-large active uniform index queried.", funcName);
            return;
        }
    }

    const auto& count = uniformIndices.Length();

    JS::Rooted<JSObject*> array(cx, JS_NewArrayObject(cx, count));
    UniquePtr<GLint[]> samples(new GLint[count]);
    if (!array || !samples) {
        ErrorOutOfMemory("%s: Failed to allocate buffers.", funcName);
        return;
    }
    retval.setObject(*array);

    MakeContextCurrent();
    gl->fGetActiveUniformsiv(program.mGLName, count, uniformIndices.Elements(), pname,
                             samples.get());

    switch (pname) {
    case LOCAL_GL_UNIFORM_TYPE:
    case LOCAL_GL_UNIFORM_SIZE:
    case LOCAL_GL_UNIFORM_BLOCK_INDEX:
    case LOCAL_GL_UNIFORM_OFFSET:
    case LOCAL_GL_UNIFORM_ARRAY_STRIDE:
    case LOCAL_GL_UNIFORM_MATRIX_STRIDE:
        for (size_t i = 0; i < count; ++i) {
            JS::RootedValue value(cx);
            value = JS::Int32Value(samples[i]);
            if (!JS_DefineElement(cx, array, i, value, JSPROP_ENUMERATE))
                return;
        }
        break;
    case LOCAL_GL_UNIFORM_IS_ROW_MAJOR:
        for (size_t i = 0; i < count; ++i) {
            JS::RootedValue value(cx);
            value = JS::BooleanValue(samples[i]);
            if (!JS_DefineElement(cx, array, i, value, JSPROP_ENUMERATE))
                return;
        }
        break;

    default:
        MOZ_CRASH("Invalid pname");
    }
}
开发者ID:alphan102,项目名称:gecko-dev,代码行数:65,代码来源:WebGL2ContextUniforms.cpp

示例9: if

static void
convertValue(JSContext *             jct,
             JS::MutableHandleValue  theData,
             const yarp::os::Value & inputValue)
{
    ODL_ENTER(); //####
    ODL_P2("jct = ", jct, "inputValue = ", &inputValue); //####
    if (inputValue.isBool())
    {
        theData.setBoolean(inputValue.asBool());
    }
    else if (inputValue.isInt())
    {
        theData.setInt32(inputValue.asInt());
    }
    else if (inputValue.isString())
    {
        YarpString value = inputValue.asString();
        JSString * aString = JS_NewStringCopyZ(jct, value.c_str());

        if (aString)
        {
            theData.setString(aString);
        }
    }
    else if (inputValue.isDouble())
    {
        theData.setDouble(inputValue.asDouble());
    }
    else if (inputValue.isDict())
    {
        yarp::os::Property * value = inputValue.asDict();

        if (value)
        {
            yarp::os::Bottle asList(value->toString());

            convertDictionary(jct, theData, asList);
        }
    }
    else if (inputValue.isList())
    {
        yarp::os::Bottle * value = inputValue.asList();

        if (value)
        {
            yarp::os::Property asDict;

            if (ListIsReallyDictionary(*value, asDict))
            {
                convertDictionary(jct, theData, *value);
            }
            else
            {
                convertList(jct, theData, *value);
            }
        }
    }
    else
    {
        // We don't know what to do with this...
        theData.setNull();
    }
    ODL_EXIT(); //####
} // convertValue
开发者ID:MovementAndMeaning,项目名称:Core_MPlusM,代码行数:65,代码来源:m+mJavaScriptFilterService.cpp


注:本文中的js::MutableHandleValue::setNull方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。