本文整理汇总了C++中STRINGZ_TO_NPVARIANT函数的典型用法代码示例。如果您正苦于以下问题:C++ STRINGZ_TO_NPVARIANT函数的具体用法?C++ STRINGZ_TO_NPVARIANT怎么用?C++ STRINGZ_TO_NPVARIANT使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了STRINGZ_TO_NPVARIANT函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: on_shell_signal
static void
on_shell_signal (GDBusProxy *proxy,
gchar *sender_name,
gchar *signal_name,
GVariant *parameters,
gpointer user_data)
{
PluginObject *obj = user_data;
if (strcmp (signal_name, "ExtensionStatusChanged") == 0)
{
gchar *uuid;
gint32 status;
gchar *error;
NPVariant args[3];
NPVariant result;
g_variant_get (parameters, "(sis)", &uuid, &status, &error);
STRINGZ_TO_NPVARIANT (uuid, args[0]);
INT32_TO_NPVARIANT (status, args[1]);
STRINGZ_TO_NPVARIANT (error, args[2]);
funcs.invokeDefault (obj->instance, obj->listener,
args, 3, &result);
funcs.releasevariantvalue (&result);
g_free (uuid);
g_free (error);
}
}
示例2: printf
bool
ScriptablePluginObject::Invoke(NPIdentifier name, const NPVariant *args,
uint32_t argCount, NPVariant *result)
{
if (name == sFoo_id) {
printf ("foo called!\n");
NPVariant docv;
NPN_GetProperty(mNpp, sWindowObj, sDocument_id, &docv);
NPObject *doc = NPVARIANT_TO_OBJECT(docv);
NPVariant strv;
STRINGZ_TO_NPVARIANT("div", strv);
NPVariant divv;
NPN_Invoke(mNpp, doc, sCreateElement_id, &strv, 1, &divv);
STRINGZ_TO_NPVARIANT("I'm created by a plugin!", strv);
NPVariant textv;
NPN_Invoke(mNpp, doc, sCreateTextNode_id, &strv, 1, &textv);
NPVariant v;
NPN_Invoke(mNpp, NPVARIANT_TO_OBJECT(divv), sAppendChild_id, &textv, 1,
&v);
NPN_ReleaseVariantValue(&v);
NPN_ReleaseVariantValue(&textv);
NPVariant bodyv;
NPN_GetProperty(mNpp, doc, sBody_id, &bodyv);
NPN_Invoke(mNpp, NPVARIANT_TO_OBJECT(bodyv), sAppendChild_id, &divv, 1,
&v);
NPN_ReleaseVariantValue(&v);
NPN_ReleaseVariantValue(&divv);
NPN_ReleaseVariantValue(&bodyv);
NPN_ReleaseVariantValue(&docv);
STRINGZ_TO_NPVARIANT(strdup("foo return val"), *result);
return PR_TRUE;
}
return PR_FALSE;
}
示例3: m_pNPInstance
CPlugin::CPlugin(NPP pNPInstance, int16_t argc, char* argn[], char* argv[]):
m_pNPInstance(pNPInstance),
m_pNPStream(NULL),
m_bInitialized(false),
m_pScriptableObject(NULL)
{
#ifdef XP_WIN
m_hWnd = NULL;
#endif
// code from npruntime, get browser version
const char *ua = NPN_UserAgent(m_pNPInstance);
strcpy(m_String, ua);
// Here is an example of passing parameters from plugin to ScriptablePlugin
// initialize id
NPIdentifier code_id = NPN_GetStringIdentifier("code");
NPVariant v1;
VOID_TO_NPVARIANT(v1);
for (int16_t i = 0;i < argc;i++) {
printf("%s = %s\n", argn[i], argv[i]);
if (!strcmp(argn[i],"code")) {
STRINGZ_TO_NPVARIANT(m_strdup(argv[i]),v1);
}
}
NPObject *myobj = this->GetScriptableObject();
NPN_SetProperty(m_pNPInstance, myobj, code_id, &v1);
NPN_ReleaseObject(myobj);
}
示例4: strMessage
bool ScriptablePluginObject::InvokeDefault(const NPVariant *args, uint32_t argCount,
NPVariant *result)
{
CString strMessage(_T("Welcome to use the IEMode Plugin for firefox!"));
STRINGZ_TO_NPVARIANT(CStringToNPStringCharacters(strMessage), *result);
return true;
}
示例5: testGetProperty
static bool testGetProperty(NPObject* npobj, NPIdentifier name, NPVariant* result)
{
if (name == testIdentifiers[ID_PROPERTY_FOO]) {
char* mem = static_cast<char*>(browser->memalloc(4));
strcpy(mem, "foo");
STRINGZ_TO_NPVARIANT(mem, *result);
return true;
}
if (name == testIdentifiers[ID_PROPERTY_OBJECT_POINTER]) {
int32_t objectPointer = static_cast<int32_t>(reinterpret_cast<long long>(npobj));
INT32_TO_NPVARIANT(objectPointer, *result);
return true;
}
if (name == testIdentifiers[ID_PROPERTY_TEST_OBJECT]) {
TestObject* testObject = reinterpret_cast<TestObject*>(npobj);
if (!testObject->testObject)
testObject->testObject = browser->createobject(0, &testClass);
browser->retainobject(testObject->testObject);
OBJECT_TO_NPVARIANT(testObject->testObject, *result);
return true;
}
if (name == testIdentifiers[ID_PROPERTY_REF_COUNT]) {
INT32_TO_NPVARIANT(npobj->referenceCount, *result);
return true;
}
return false;
}
示例6: plugin_get_metadata
static bool
plugin_get_metadata (PluginObject *obj,
NPString uuid,
NPVariant *result)
{
GError *error = NULL;
GVariant *res;
const gchar *json;
gchar *buffer;
res = g_dbus_proxy_call_sync (obj->proxy,
"GetExtensionInfo",
g_variant_new ("(s)", uuid.UTF8Characters),
G_DBUS_CALL_FLAGS_NONE,
-1, /* timeout */
NULL, /* cancellable */
&error);
if (!res)
{
g_warning ("Failed to retrieve extension list: %s", error->message);
g_error_free (error);
return FALSE;
}
g_variant_get(res, "(&s)", &json);
buffer = funcs.memalloc (strlen (json));
strcpy(buffer, json);
STRINGZ_TO_NPVARIANT (buffer, *result);
g_variant_unref (res);
return TRUE;
}
示例7: NPVARIANT_TO_STRING
bool
ScriptablePluginObject::Invoke(NPIdentifier name, const NPVariant *args,
uint32_t argCount, NPVariant *result)
{
if (name == sendCmd_id)
{
if ( argCount < 1 )
{
return false;
}
PString strParam = "";
NPString npStr = NPVARIANT_TO_STRING( args[0] );
for (unsigned int i=0; i<npStr.utf8length; i++)
{
strParam += npStr.utf8characters[ i ];
}
PString strResult = g_NativeLogic.InvokeFunction( strParam );
char* pszName = (char*)NPN_MemAlloc( strResult.GetSize() + 1 );
strcpy( pszName, strResult );
STRINGZ_TO_NPVARIANT(pszName, *result);
return PR_TRUE;
}
return PR_FALSE;
}
示例8: cloud_spy_log
static void
cloud_spy_log (const gchar * log_domain, GLogLevelFlags log_level, const gchar * message, gpointer user_data)
{
NPNetscapeFuncs * browser = cloud_spy_nsfuncs;
NPP instance = static_cast<NPP> (user_data);
NPObject * window = NULL, * console = NULL;
NPVariant variant, result;
NPError error;
(void) log_domain;
(void) log_level;
error = browser->getvalue (instance, NPNVWindowNPObject, &window);
if (error != NPERR_NO_ERROR)
goto beach;
VOID_TO_NPVARIANT (variant);
if (!browser->getproperty (instance, window, browser->getstringidentifier ("console"), &variant))
goto beach;
console = NPVARIANT_TO_OBJECT (variant);
STRINGZ_TO_NPVARIANT (message, variant);
VOID_TO_NPVARIANT (result);
if (!browser->invoke (instance, console, browser->getstringidentifier ("log"), &variant, 1, &result))
goto beach;
browser->releasevariantvalue (&result);
beach:
if (console != NULL)
browser->releaseobject (console);
if (window != NULL)
browser->releaseobject (window);
}
示例9: g_assert
void
ShockerScriptableControlObject::GetTestDefinition (const NPVariant *args, uint32_t arg_count, NPVariant *result)
{
char *test_definition;
bool free_test_definition = false;
char *retval;
bool isJson = false;
g_assert (arg_count <= 1);
LOG_PLUGIN ("[%i shocker] ShockerScriptableControlObject::GetTestDefinition ()\n", getpid ());
test_definition = getenv ("MOONLIGHT_HARNESS_TESTDEFINITION");
if (test_definition == NULL) {
if (arg_count > 0) {
g_assert (NPVARIANT_IS_BOOLEAN (args [0]));
isJson = NPVARIANT_TO_BOOLEAN (args [0]);
}
test_definition = LogProvider::GetInstance ()->GetTestDefinition (isJson);
free_test_definition = true;
}
retval = NPN_strdup (test_definition == NULL ? "" : test_definition);
STRINGZ_TO_NPVARIANT (retval, *result);
if (free_test_definition)
g_free (test_definition);
}
示例10: pluginGetProperty
static bool pluginGetProperty(NPObject *obj, NPIdentifier name, NPVariant *variant)
{
if (name == pluginPropertyIdentifiers[ID_PROPERTY_PROPERTY]) {
char* mem = static_cast<char*>(browser->memalloc(9));
strcpy(mem, "property");
STRINGZ_TO_NPVARIANT(mem, *variant);
return true;
} else if (name == pluginPropertyIdentifiers[ID_PROPERTY_EVENT_LOGGING]) {
BOOLEAN_TO_NPVARIANT(((PluginObject *)obj)->eventLogging, *variant);
return true;
} else if (name == pluginPropertyIdentifiers[ID_PROPERTY_LOG_DESTROY]) {
BOOLEAN_TO_NPVARIANT(((PluginObject *)obj)->logDestroy, *variant);
return true;
} else if (name == pluginPropertyIdentifiers[ID_PROPERTY_HAS_STREAM]) {
BOOLEAN_TO_NPVARIANT(((PluginObject *)obj)->stream != 0, *variant);
return true;
} else if (name == pluginPropertyIdentifiers[ID_PROPERTY_TEST_OBJECT]) {
NPObject *testObject = ((PluginObject *)obj)->testObject;
browser->retainobject(testObject);
OBJECT_TO_NPVARIANT(testObject, *variant);
return true;
} else if (name == pluginPropertyIdentifiers[ID_PROPERTY_TEST_OBJECT_COUNT]) {
INT32_TO_NPVARIANT(getTestObjectCount(), *variant);
return true;
}
return false;
}
示例11: retrieve_highres_icon
static void
retrieve_highres_icon (WebappMonitor *monitor, const gchar *desktop_file)
{
GKeyFile *key_file;
gchar *s;
GError *error = NULL;
/* Get URL to get icon for */
key_file = g_key_file_new ();
if (!g_key_file_load_from_data (key_file, desktop_file, strlen (desktop_file), 0, &error)) {
g_warning ("Could not parse desktop file: %s", error->message);
g_error_free (error);
goto out;
}
if (get_icon_size (key_file) >= 64)
goto out;
s = g_key_file_get_string (key_file, G_KEY_FILE_DESKTOP_GROUP, G_KEY_FILE_DESKTOP_KEY_EXEC, NULL);
if (s != NULL) {
gint n_args, i;
gchar **args, *url = NULL;
g_debug ("Parsing command line %s", s);
if (!g_shell_parse_argv (s, &n_args, &args, &error)) {
g_debug ("Failed parsing command line %s", s);
goto out;
}
for (i = 0; i < n_args && args[i] != NULL; i++) {
g_debug ("Processing argument %s", args[i]);
if (g_str_has_prefix (args[i], "--app=")) {
url = g_strdup (args[i] + 6);
g_debug ("Found URL %s", url);
break;
}
}
if (url != NULL) {
NPVariant url_varg, result;
STRINGZ_TO_NPVARIANT(url, url_varg);
NULL_TO_NPVARIANT(result);
if (!NPN_InvokeDefault (monitor->instance, monitor->icon_loader_callback, &url_varg, 1, &result))
g_debug ("Failed calling JS callback");
g_free (url);
NPN_ReleaseVariantValue (&result);
}
g_strfreev (args);
g_free (s);
}
out:
g_key_file_free (key_file);
}
示例12: systemGetProperty
static bool systemGetProperty(NPObject *obj, NPIdentifier name, NPVariant *variant)
{
if (name == systemPropertyIdentifiers[SYSTEM_PROPERTY_VERSION]) {
STRINGZ_TO_NPVARIANT(strdup(SYSTEM_VERSION), *variant);
return true;
}
return false;
}
示例13: NPN_strdup
void
ShockerScriptableControlObject::GetPlatformVersion (const NPVariant *args, uint32_t arg_count, NPVariant *result)
{
char *retval;
retval = NPN_strdup (LogProvider::GetInstance ()->GetPlatformVersion ());
LOG_PLUGIN ("[%i shocker] ShockerScriptableControlObject::GetPlatformVersion (): %s\n", getpid (), retval);
STRINGZ_TO_NPVARIANT (retval, *result);
}
示例14: VOID_TO_NPVARIANT
bool
ScriptablePluginObject::GetProperty(NPIdentifier name, NPVariant *result)
{
VOID_TO_NPVARIANT(*result);
//kk
/*if (name == sBar_id) {
static int a = 17;
INT32_TO_NPVARIANT(a, *result);
a += 5;
return true;
}*/
char *pProp = NPN_UTF8FromIdentifier(name);
if( !strcmp( "Version", pProp ) )
{
char *p = (char*) NPN_MemAlloc( "Version 1.0" );//allocating Memory for the string with invocation of Browser-API
STRINGZ_TO_NPVARIANT( p, *result);
return true;
}
if( !strcmp( "Name", pProp ) )
{
char *p = (char*) NPN_MemAlloc( m_pszName );//allocating Memory for the string with invocation of Browser-API
STRINGZ_TO_NPVARIANT( p, *result);
return true;
}
if (name == sPluginType_id) {
NPObject *myobj =
NPN_CreateObject(mNpp, GET_NPOBJECT_CLASS(ConstructablePluginObject));
if (!myobj) {
return false;
}
OBJECT_TO_NPVARIANT(myobj, *result);
return true;
}
return true;
}
示例15: mmp_script_element_set_property_string
gboolean
mmp_script_element_set_property_string (NPP npp, NPVariant *element,
const gchar *property_name, const gchar *property_value)
{
NPVariant string;
STRINGZ_TO_NPVARIANT (property_value, string);
return NPN_SetProperty (npp, NPVARIANT_TO_OBJECT (*element),
NPN_GetStringIdentifier (property_name), &string);
}