• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C++ NPVARIANT_IS_STRING函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C++中NPVARIANT_IS_STRING函数的典型用法代码示例。如果您正苦于以下问题:C++ NPVARIANT_IS_STRING函数的具体用法?C++ NPVARIANT_IS_STRING怎么用?C++ NPVARIANT_IS_STRING使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



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

示例1: g_assert

void
ShockerScriptableControlObject::CaptureMultipleImages (const NPVariant *args, uint32_t arg_count, NPVariant *result)
{
	const char *path;
	
	g_assert (arg_count == 9);
	g_assert (NPVARIANT_IS_STRING (args [0]));
	g_assert (NPVARIANT_IS_STRING (args [1]));
	g_assert (NPVARIANT_IS_NUMBER (args [2]));
	g_assert (NPVARIANT_IS_NUMBER (args [3]));
	g_assert (NPVARIANT_IS_NUMBER (args [4]));
	g_assert (NPVARIANT_IS_NUMBER (args [5]));
	g_assert (NPVARIANT_IS_NUMBER (args [6]));
	g_assert (NPVARIANT_IS_NUMBER (args [7]));
	g_assert (NPVARIANT_IS_NUMBER (args [8]));

	path = STR_FROM_VARIANT (args [1]);
	if (path == NULL || path [0] == 0)
		path = GetTestPath ();

	LOG_PLUGIN ("[%i shocker] ShockerScriptableControlObject::CaptureMultipleImages (base_dir: '%s', file_name: '%s', x: %i, y: %i, width: %i, height: %i, count: %i, interval: %i, initial_delay: %i)\n", getpid (), 
		STR_FROM_VARIANT (args [0]), STR_FROM_VARIANT (args [1]),  NUMBER_TO_INT32 (args [2]), NUMBER_TO_INT32 (args [3]),
		NUMBER_TO_INT32 (args [4]), NUMBER_TO_INT32 (args [5]),NUMBER_TO_INT32 (args [6]), NUMBER_TO_INT32 (args [7]),
		NUMBER_TO_INT32 (args [8]));

	GetImageCaptureProvider ()->CaptureMultipleImages (path, NUMBER_TO_INT32 (args [2]), NUMBER_TO_INT32 (args [3]),
			NUMBER_TO_INT32 (args [4]), NUMBER_TO_INT32 (args [5]),NUMBER_TO_INT32 (args [6]), NUMBER_TO_INT32 (args [7]),
			NUMBER_TO_INT32 (args [8]));

	BOOLEAN_TO_NPVARIANT (true, *result);
}
开发者ID:499940913,项目名称:moon,代码行数:31,代码来源:shocker.cpp


示例2: onLoad

bool JsAgent::onLoad(const NPVariant* args, unsigned argCount) {
	Debug::println("JsAgent::onLoad");

	if(argCount != 4) {
		Debug::println("JsAgent::onLoad> argCount != 4");
		return false;
	}

	if( !NPVARIANT_IS_OBJECT(args[0]) ||
		!NPVARIANT_IS_STRING(args[1]) ||
		!NPVARIANT_IS_INT32(args[2]) ||
		!NPVARIANT_IS_STRING(args[3]) ) {
		Debug::println("JsAgent::onLoad> arg types wrong");
		return false;
	}

	NPObject* pObject = NPVARIANT_TO_OBJECT(args[0]);
	m_helper = NPN_RetainObject(pObject);

	NPObject* pDebug = NPN_CreateObject(getNPP(), GetNPClass<JsDebug>());
	NPN_RetainObject(pDebug);
	Variant var;
	var.set(pDebug);

	if(!NPN_SetProperty(getNPP(), m_window, methods.debug, var.ptr())) {
		Debug::println("JsAgent::onLoad> set property failed");
		return false;
	}

	NPString npstr = NPVARIANT_TO_STRING(args[1]);
	std::string host(npstr.UTF8Characters, npstr.UTF8Length);

	int port = NPVARIANT_TO_INT32(args[2]);

	npstr = NPVARIANT_TO_STRING(args[3]);
	std::string typeName(npstr.UTF8Characters, npstr.UTF8Length);

	if(!m_channel->connect(host.c_str(), port)) {
		Debug::println("JsAgent::onLoad> could not connect");
		return false;
	}

	LoadMessage msg;
	msg.typeName = typeName;

	ArchiveWriter<Channel> ar(*m_channel);
	if(!Message::send(msg, ar)) {
		Debug::println("JsAgent::onLoad> send failed");
		return false;
	}

	JsValue ret;
	return dispatchAndReturn(ret);
}
开发者ID:JimmyJune,项目名称:DotWeb,代码行数:54,代码来源:JsAgent.cpp


示例3: VOID_TO_NPVARIANT

	CString CPlugin::GetNavigateParam(const NPUTF8* name) const
	{
		CString strParam;

		NPVariant vParam;
		VOID_TO_NPVARIANT(vParam);

		try
		{
			NPObject* pContainer = GetContainer();

			if (!NPN_Invoke(m_pNPInstance, pContainer, GetIdentifier(name), NULL, 0, &vParam))
			{
				throw(CString(_T("Cannot invoke window.Container.getXXX()")));
			}
			if (!NPVARIANT_IS_STRING(vParam)) 
			{
				throw(CString(_T("Invalid return value.")));
			}
			strParam = NPStringToCString(vParam.value.stringValue);
		}
		catch (const CString& strMessage)
		{
			UNUSED(strMessage);
			TRACE(_T("[CPlugin::GetNavigateHeaders Exception] %s\n"), strMessage);
		}

		if (!NPVARIANT_IS_VOID(vParam))	NPN_ReleaseVariantValue(&vParam);

		return strParam;
	}
开发者ID:cha63501,项目名称:Fire-IE,代码行数:31,代码来源:plugin.cpp


示例4: Echo

bool nsScriptableObjectOverwolfSample::Echo(
  NPIdentifier name, 
  const NPVariant *args, 
  uint32_t argCount, 
  NPVariant *result) {

  if (argCount < 2 ||
    !NPVARIANT_IS_STRING(args[0]) ||
    !NPVARIANT_IS_OBJECT(args[1])) {
      NPN_SetException(this, "invalid params passed to function");
      return true;
  }

  // add ref count to callback object so it won't delete
  NPN_RetainObject(NPVARIANT_TO_OBJECT(args[1]));

  // convert into std::string
  std::string message;
  message.append(
    NPVARIANT_TO_STRING(args[0]).UTF8Characters,
    NPVARIANT_TO_STRING(args[0]).UTF8Length);

  // post to separate thread so that we are responsive
  return thread_->PostTask(
    std::bind(
      &nsScriptableObjectOverwolfSample::EchoTask, 
      this, 
      message, 
      NPVARIANT_TO_OBJECT(args[1])));
}
开发者ID:Capibara-,项目名称:overwolf-sample-plugin,代码行数:30,代码来源:nsScriptableObjectOverwolfSample.cpp


示例5: stringVariantToIdentifier

NPIdentifier stringVariantToIdentifier(NPVariant variant) {
  assert(NPVARIANT_IS_STRING(variant));
  NPUTF8* utf8String = createCStringFromNPVariant(&variant);
  NPIdentifier identifier = NPN_GetStringIdentifier(utf8String);
  free(utf8String);
  return identifier;
}
开发者ID:jasonLaster,项目名称:gecko-dev,代码行数:7,代码来源:nptest_utils.cpp


示例6: NPN_GetStringIdentifier

// XXX FIXME See comment at the other parseOptions variant.
void LibvlcPlaylistNPObject::parseOptions(NPObject *obj, int *i_options,
                                          char*** ppsz_options)
{
    /* WARNING: Safari does not implement NPN_HasProperty/NPN_HasMethod */

    NPVariant value;

    /* we are expecting to have a Javascript Array object */
    NPIdentifier propId = NPN_GetStringIdentifier("length");
    if( NPN_GetProperty(_instance, obj, propId, &value) )
    {
        int count = numberValue(value);
        NPN_ReleaseVariantValue(&value);

        if( count )
        {
            long capacity = 16;
            char **options = (char **)malloc(capacity*sizeof(char *));
            if( options )
            {
                int nOptions = 0;

                while( nOptions < count )
                {
                    propId = NPN_GetIntIdentifier(nOptions);
                    if( ! NPN_GetProperty(_instance, obj, propId, &value) )
                        /* return what we got so far */
                        break;

                    if( ! NPVARIANT_IS_STRING(value) )
                    {
                        /* return what we got so far */
                        NPN_ReleaseVariantValue(&value);
                        break;
                    }

                    if( nOptions == capacity )
                    {
                        capacity += 16;
                        char **moreOptions = (char **)realloc(options, capacity*sizeof(char*));
                        if( ! moreOptions )
                        {
                            /* failed to allocate more memory */
                            NPN_ReleaseVariantValue(&value);
                            /* return what we got so far */
                            *i_options = nOptions;
                            *ppsz_options = options;
                            break;
                        }
                        options = moreOptions;
                    }

                    options[nOptions++] = stringValue(value);
                }
                *i_options = nOptions;
                *ppsz_options = options;
            }
        }
    }
}
开发者ID:Kafay,项目名称:vlc,代码行数:61,代码来源:npolibvlc.cpp


示例7: pluginSetProperty

bool pluginSetProperty (NPObject *npobj, NPIdentifier name, const NPVariant *value)
{
	PluginObject *obj = (PluginObject *)npobj;
    if (name == pluginPropertyIdentifiers[ID_PORT_PROPERTY]) {
		if(NPVARIANT_IS_STRING(*value)) {
			if(obj->port.UTF8Length > 0) {
				free((void *)(obj->port.UTF8Characters));
				obj->port.UTF8Length = 0;
			}
			NPUTF8 *s = (NPUTF8 *)malloc((value->value.stringValue.UTF8Length)+1);
			memcpy(s, value->value.stringValue.UTF8Characters, value->value.stringValue.UTF8Length);
			s[value->value.stringValue.UTF8Length] = '\0';
			obj->port.UTF8Characters = s;
			obj->port.UTF8Length = value->value.stringValue.UTF8Length;

			// when user sets port, connect to it
			if(obj->socket >= 0) {
				mcpClose(obj->socket);
				obj->socket = -1;
			}
			if(obj->port.UTF8Length > 0) {
				obj->socket = mcpOpen((char *)(obj->port.UTF8Characters));
			}
			return true;
		}
    }
	return false;	
}
开发者ID:DimondTheCat,项目名称:xray,代码行数:28,代码来源:PluginObject.c


示例8: CopyNPVariant

static bool CopyNPVariant(NPVariant *dst, const NPVariant *src)
{
	dst->type = src->type;
	if (NPVARIANT_IS_STRING(*src)) {

		NPUTF8 *str = (NPUTF8 *)NPNFuncs.memalloc((src->value.stringValue.UTF8Length + 1) * sizeof(NPUTF8));
		if (NULL == str) {

			return false;
		}
		dst->value.stringValue.UTF8Length = src->value.stringValue.UTF8Length;

		memcpy(str, src->value.stringValue.UTF8Characters, src->value.stringValue.UTF8Length);
		str[dst->value.stringValue.UTF8Length] = 0;

		dst->value.stringValue.UTF8Characters = str;
	}
	else if (NPVARIANT_IS_OBJECT(*src)) {

		NPNFuncs.retainobject(NPVARIANT_TO_OBJECT(*src));
		dst->value.objectValue = src->value.objectValue;
	}
	else {

		dst->value = src->value;
	}

	return true;
}
开发者ID:airm008,项目名称:ff-activex-host,代码行数:29,代码来源:GenericNPObject.cpp


示例9: get_string_property

static inline gchar *
get_string_property (NPP         instance,
                     NPObject   *obj,
                     const char *name)
{
  NPVariant result = { NPVariantType_Void };
  NPString result_str;
  gchar *result_copy;

  result_copy = NULL;

  if (!funcs.getproperty (instance, obj,
                          funcs.getstringidentifier (name),
                          &result))
    goto out;

  if (!NPVARIANT_IS_STRING (result))
    goto out;

  result_str = NPVARIANT_TO_STRING (result);
  result_copy = g_strndup (result_str.UTF8Characters, result_str.UTF8Length);

 out:
  funcs.releasevariantvalue (&result);
  return result_copy;
}
开发者ID:PeterDaveHello,项目名称:deepin-gnome-shell,代码行数:26,代码来源:browser-plugin.c


示例10: SetProperty

bool ScriptablePluginObject::SetProperty(NPIdentifier name, const NPVariant *value)
{
    if (!m_plugin)
        return false;

    std::string str;
    std::stringstream ss;
    bool boolean = false;
    unsigned short val = -1;

    if (NPVARIANT_IS_STRING(*value))
    {
        str.assign(NPVARIANT_TO_STRING(*value).UTF8Characters,
                   NPVARIANT_TO_STRING(*value).UTF8Length);
    }
    else if (NPVARIANT_IS_BOOLEAN(*value))
    {
        boolean = NPVARIANT_TO_BOOLEAN(*value);
    }
    else if (NPVARIANT_IS_INT32(*value))
    {
        val = NPVARIANT_TO_INT32(*value);
        ss << val;
        ss >> str;
    }
开发者ID:Acidburn0zzz,项目名称:spice-xpi,代码行数:25,代码来源:nsScriptablePeer.cpp


示例11: plugin_object_invoke

static bool
plugin_object_invoke (NPObject        *npobj,
		      NPIdentifier     name,
		      const NPVariant *args,
		      uint32_t         argc,
		      NPVariant       *result)
{
  PluginObject *obj;

  g_return_val_if_fail (plugin_object_has_method (npobj, name), FALSE);

  g_debug ("invoking plugin object method");

  obj = (PluginObject*) npobj;

  VOID_TO_NPVARIANT (*result);

  if (name == list_extensions_id)
    return plugin_list_extensions (obj, result);
  else if (name == get_metadata_id)
    {
      g_return_val_if_fail (argc >= 1, FALSE);
      g_return_val_if_fail (NPVARIANT_IS_STRING(args[0]), FALSE);

      return plugin_get_metadata (obj, NPVARIANT_TO_STRING(args[0]), result);
    }
  else if (name == enable_extension_id)
    {
      g_return_val_if_fail (argc >= 2, FALSE);
      g_return_val_if_fail (NPVARIANT_IS_STRING(args[0]), FALSE);
      g_return_val_if_fail (NPVARIANT_IS_BOOLEAN(args[1]), FALSE);

      return plugin_enable_extension (obj,
				      NPVARIANT_TO_STRING(args[0]),
				      NPVARIANT_TO_BOOLEAN(args[1]));
    }
  else if (name == install_extension_id)
    {
      g_return_val_if_fail (argc >= 1, FALSE);
      g_return_val_if_fail (NPVARIANT_IS_STRING(args[0]), FALSE);

      return plugin_install_extension (obj,
				       NPVARIANT_TO_STRING(args[0]));
    }

  return TRUE;
}
开发者ID:gcampax,项目名称:sweettooth-plugin,代码行数:47,代码来源:sweettooth-plugin.c


示例12: Close

void
StatementObject::GetProcedureColumns(const NPVariant *arg0, const NPVariant *arg1, 
	const NPVariant *arg2, const NPVariant *arg3)
{
  NPString *cat = NULL;
  NPString *sch = NULL; 
  NPString *prc = NULL;
  NPString *col = NULL;

  if (NPVARIANT_IS_STRING(*arg0))
    cat = (NPString*)&NPVARIANT_TO_STRING(*arg0);
  if (NPVARIANT_IS_STRING(*arg1))
    sch = (NPString*)&NPVARIANT_TO_STRING(*arg1);
  if (NPVARIANT_IS_STRING(*arg2))
    prc = (NPString*)&NPVARIANT_TO_STRING(*arg2);
  if (NPVARIANT_IS_STRING(*arg3))
    col = (NPString*)&NPVARIANT_TO_STRING(*arg3);

  if (!m_hstmt) {
    NPN_SetException(this, "Statement isn't initialized");
    return;
  }

  NPError rc = Close();
  if (rc != NPERR_NO_ERROR)
    return;

  SQLRETURN code = SQLProcedureColumnsW(m_hstmt, 
  	(cat?nsWString(cat).Data():NULL), (cat?SQL_NTS:0),
  	(sch?nsWString(sch).Data():NULL), (sch?SQL_NTS:0),
  	(prc?nsWString(prc).Data():NULL), (prc?SQL_NTS:0),
  	(col?nsWString(col).Data():NULL), (col?SQL_NTS:0));
  if (!SQL_SUCCEEDED(code) && code != SQL_NO_DATA) {
    StoreError(SQL_HANDLE_STMT, m_hstmt);  
    return;
  } 
    
  SQLSMALLINT cols;
  if (SQL_SUCCEEDED(SQLNumResultCols(m_hstmt, &cols)))
    m_columnCount = cols;

  SQLLEN rcnt;
  if (SQL_SUCCEEDED(SQLRowCount(m_hstmt, &rcnt)))
    m_rowCount = rcnt;
}
开发者ID:openlink,项目名称:WebDB_ODBC,代码行数:45,代码来源:Statement.cpp


示例13: variantToIdentifier

NPIdentifier variantToIdentifier(NPVariant variant) {
  if (NPVARIANT_IS_STRING(variant))
    return stringVariantToIdentifier(variant);
  else if (NPVARIANT_IS_INT32(variant))
    return int32VariantToIdentifier(variant);
  else if (NPVARIANT_IS_DOUBLE(variant))
    return doubleVariantToIdentifier(variant);
  return 0;
}
开发者ID:jasonLaster,项目名称:gecko-dev,代码行数:9,代码来源:nptest_utils.cpp


示例14: InvokeJavascript_TwoArgs

bool InvokeJavascript_TwoArgs(NPObject *npobj, const char *methodName, const NPVariant &arg1, const NPVariant &arg2, NPVariant *&result) {
  bool success = false;
  if (!strcmp(methodName, "saveTextFile") && NPVARIANT_IS_STRING(arg1) && NPVARIANT_IS_STRING(arg2)) {
    const char *filename = stringFromNpVariant(arg1);
    const char *contents = stringFromNpVariant(arg2);
    success = saveText(filename, contents, arg2.value.stringValue.UTF8Length);
    delete[] contents;
    delete[] filename;
  } else if (!strcmp(methodName, "saveBinaryFile") && NPVARIANT_IS_STRING(arg1) && NPVARIANT_IS_OBJECT(arg2)) {
    const char *filename = stringFromNpVariant(arg1);
    size_t length;
    const char *bytes = byteArrayFromNpVariant(arg2, GetInstance(npobj), length);
    success = saveBinaryFile(filename, bytes, length);
    delete[] bytes;
    delete[] filename;
  }
  return success;
}
开发者ID:captn3m0,项目名称:npapi-file-io,代码行数:18,代码来源:npapi-file-io.cpp


示例15: getInterfaceName

std::string getInterfaceName(NPP npp, NPObject* object)
{
    std::string className;
    NPVariant result;
    bool asConstructor = true;  // true if object can be a constructor

    VOID_TO_NPVARIANT(result);
    NPN_Invoke(npp, object, NPN_GetStringIdentifier("toString"), 0, 0, &result);
    for (;;)
    {
        if (NPVARIANT_IS_STRING(result))
        {
            className = std::string(NPVARIANT_TO_STRING(result).utf8characters,
                                    NPVARIANT_TO_STRING(result).utf8length);
        }
        NPN_ReleaseVariantValue(&result);
        if (className.compare(0, 9, "function ") == 0)
        {
            // In Chrome, a [Constructor] object is represented as a 'Function'.
            className = className.substr(9);
            size_t pos = className.find('(');
            if (pos != std::string::npos)
            {
                className = className.substr(0, pos);
                break;
            }
            return "Function";
        }
        if (className.compare(0, 8, "[object ", 8) == 0 && className[className.length() - 1] == ']')
        {
            className = className.substr(8, className.length() - 9);
            break;
        }
        // This object is likely to have a stringifier. Check the constructor name directly.
        NPVariant constructor;
        VOID_TO_NPVARIANT(constructor);
        if (asConstructor && NPN_GetProperty(npp, object, NPN_GetStringIdentifier("constructor"), &constructor))
        {
            if (NPVARIANT_IS_OBJECT(constructor) &&
                NPN_Invoke(npp, NPVARIANT_TO_OBJECT(constructor), NPN_GetStringIdentifier("toString"), 0, 0, &result))
            {
                NPN_ReleaseVariantValue(&constructor);
                asConstructor = false;
                continue;
            }
            NPN_ReleaseVariantValue(&constructor);
        }
        return "Object";
    }
    // In Firefox, the constructor and an instance object cannot be distinguished by toString().
    // Check if object has a 'prototype' to see if it is a constructor.
    if (asConstructor && NPN_HasProperty(npp, object, NPN_GetStringIdentifier("prototype")))
    {
        className += "_Constructor";
    }
    return className;
}
开发者ID:giobeatle1794,项目名称:es-operating-system,代码行数:57,代码来源:bridge.cpp


示例16: stringValue

char* RuntimeNPObject::stringValue(const NPVariant &v)
{
    char *s = NULL;
    if( NPVARIANT_IS_STRING(v) )
    {
        return stringValue(NPVARIANT_TO_STRING(v));
    }
    return s;
}
开发者ID:FranEstSol,项目名称:vc-axnp-vlc,代码行数:9,代码来源:nporuntime.cpp


示例17: ExecuteListenOnFile

bool PluginMethodListenOnFile::ExecuteListenOnFile(
  const NPVariant *args,
  uint32_t argCount,
  NPVariant *result) {
  std::string filename;
  bool skip_to_end = false;

  try {
    if (argCount < 3 ||
      !NPVARIANT_IS_STRING(args[0]) ||
      !NPVARIANT_IS_BOOLEAN(args[1]) ||
      !NPVARIANT_IS_OBJECT(args[2])) {
      NPN_SetException(
        object_, 
        "invalid or missing params passed to function - expecting 3 params: "
        "filename, skipToEnd, callback(status, data)");
      return false;
    }

    callback_ = NPVARIANT_TO_OBJECT(args[2]);
    skip_to_end = NPVARIANT_TO_BOOLEAN(args[1]);

    // add ref count to callback object so it won't delete
    NPN_RetainObject(callback_);

    filename.append(
      NPVARIANT_TO_STRING(args[0]).UTF8Characters,
      NPVARIANT_TO_STRING(args[0]).UTF8Length);  
  } catch(...) {

  }

  if (nullptr == thread_.get()) {
    thread_.reset(new utils::Thread);
    if (!thread_->Start()) {
      NPN_SetException(
        __super::object_,
        "an unexpected error occurred - couldn't start file listening thread");
      return false;
    }
  }

  std::wstring wide_filename = utils::Encoders::utf8_decode(filename);

  if (!file_stream_.Initialize(wide_filename.c_str(), this, skip_to_end)) {
    NPN_SetException(
      __super::object_,
      "an unexpected error occurred - couldn't open the file for read access");
    return false;
  }

  return thread_->PostTask(
    std::bind(
    &PluginMethodListenOnFile::StartListening,
    this));
}
开发者ID:Ridrog,项目名称:overwolf-simple-io-plugin,代码行数:56,代码来源:plugin_method_listen_on_file.cpp


示例18: InvokeJavascript_OneArg

bool InvokeJavascript_OneArg(NPObject *npobj, const char *methodName, const NPVariant &arg, NPVariant *&result) {
  if (!(NPVARIANT_IS_STRING(arg))) {
    return false;
  }

  bool success = false;

  const char *argStringValue = stringFromNpVariant(arg);

  if (!strcmp(methodName, "fileExists")) {
    //fileExists(filename : string) : bool
    success = SetReturnValue(fileExists(argStringValue), *result);
  } else if (!strcmp(methodName, "isDirectory")) {
    //isDirectory(filename : string) : bool
    success = SetReturnValue(isDirectory(argStringValue), *result);
  } else if (!strcmp(methodName, "createDirectory")) {
    if (!createDirectory(argStringValue)) {
      //TODO: Throw a particular exception
      success = false;
    } else {
      success = true;
    }
  } else if (!strcmp(methodName, "getTextFile")) {
    //getTextFile(filename : string) : string
    char *value = NULL;
    size_t len = 0;
    if (getFile(argStringValue, value, len, false)) {
      success = SetReturnValue(value, len, *result);
      delete[] value;
    }
  } else if (!strcmp(methodName, "getBinaryFile")) {
    //getBinaryFile(filename : string) : array<byte>
    char *value = NULL;
    size_t len = 0;
    if (getFile(argStringValue, value, len, true)) {
      success = SetArrayReturnValue(value, len, GetInstance(npobj), result);
      delete[] value;
    }
  } else if (!strcmp(methodName, "removeFile")) {
    //removeFile(filename : string) : void
    success = removeFile(argStringValue);
  } else if (!strcmp(methodName, "listFiles")) {
    //listFiles(filename : string) : array<object>
    std::vector<FileEntry *> *entries;
    if (listFiles(argStringValue, entries)) {
      success = SetArrayReturnValue(*entries, GetInstance(npobj), result);
      deleteFileEntries(entries);
    } else {
      success = false;
    }
  }

  delete[] argStringValue;
  return success;
}
开发者ID:captn3m0,项目名称:npapi-file-io,代码行数:55,代码来源:npapi-file-io.cpp


示例19: m_strFromVar

void m_strFromVar(char **dst, NPVariant var) {
	if (!dst)
		return;
	if (!((NPVARIANT_IS_STRING(var)) || (NPVARIANT_IS_VOID(var))))
		return;
	if (*dst) {
		NPN_MemFree(*dst);
		*dst = NULL;
	}
	if (NPVARIANT_IS_STRING(var)) {
		NPString src = NPVARIANT_TO_STRING(var);
		int len = src.UTF8Length;
		*dst = (char*) NPN_MemAlloc(len+1);
		memcpy(*dst, src.UTF8Characters, len);
		(*dst)[len] = '\0';
	}
	else {
		*dst = NULL;
	}
}
开发者ID:grharon,项目名称:tpmbrowserplugin,代码行数:20,代码来源:fix.cpp


示例20: ExecuteStopFileListen

bool PluginMethodListenOnFile::ExecuteStopFileListen(
  const NPVariant *args,
  uint32_t argCount,
  NPVariant *result) {

  std::string id;
  try {
    if (argCount < 1 || !NPVARIANT_IS_STRING(args[0])) {
      NPN_SetException(
        object_,
        "invalid or missing params passed to function - expecting 1 params: "
        "id");
      return false;
    }

    id.append(
      NPVARIANT_TO_STRING(args[0]).UTF8Characters,
      NPVARIANT_TO_STRING(args[0]).UTF8Length);
  }
  catch (...) {

  }

  TextFileThreadMap::iterator iter = threads_.find(id);
  if (iter != threads_.end()) {
    if (!iter->second.first->StopListening()) {
      NPN_SetException(
        __super::object_,
        "an unexpected error occurred - couldn't stop existing listener");
      return false;
    }

    if (!iter->second.second->Stop()) {
      NPN_SetException(
        __super::object_,
        "an unexpected error occurred - couldn't stop existing listener thread");
      return false;
    }

	delete iter->second.first;
	delete iter->second.second;

    threads_.erase(id);

    if (nullptr != ids_to_callbacks_[id]) {
      NPN_ReleaseObject(ids_to_callbacks_[id]);
      ids_to_callbacks_[id] = nullptr;
      ids_to_callbacks_.erase(id);
    }
  }

  return true;
}
开发者ID:JonasFortmann,项目名称:simple-io-plugin,代码行数:53,代码来源:plugin_method_listen_on_file.cpp



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ NPVARIANT_TO_STRING函数代码示例发布时间:2022-05-30
下一篇:
C++ NPVARIANT_IS_OBJECT函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap