本文整理汇总了C++中CppVariant类的典型用法代码示例。如果您正苦于以下问题:C++ CppVariant类的具体用法?C++ CppVariant怎么用?C++ CppVariant使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了CppVariant类的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: VOID_TO_NPVARIANT
bool CppBoundClass::invoke(NPIdentifier ident,
const NPVariant* arguments,
size_t argumentCount,
NPVariant* result) {
MethodList::const_iterator end = m_methods.end();
MethodList::const_iterator method = m_methods.find(ident);
Callback* callback;
if (method == end) {
if (!m_fallbackCallback.get()) {
VOID_TO_NPVARIANT(*result);
return false;
}
callback = m_fallbackCallback.get();
} else
callback = (*method).second;
// Build a CppArgumentList argument vector from the NPVariants coming in.
CppArgumentList cppArguments(argumentCount);
for (size_t i = 0; i < argumentCount; i++)
cppArguments[i].set(arguments[i]);
CppVariant cppResult;
callback->run(cppArguments, &cppResult);
cppResult.copyToNPVariant(result);
return true;
}
开发者ID:IllusionRom-deprecated,项目名称:android_platform_external_chromium_org_third_party_WebKit,代码行数:27,代码来源:CppBoundClass.cpp
示例2: cppVariantToWebString
WebString LayoutTestController::cppVariantToWebString(const CppVariant& value)
{
if (!value.isString()) {
logErrorToConsole("Invalid value for preference. Expected string value.");
return WebString();
}
return WebString::fromUTF8(value.toString());
}
示例3: cppVariantToWebString
WebString TestRunner::cppVariantToWebString(const CppVariant& value)
{
if (!value.isString()) {
printErrorMessage("Invalid value for preference. Expected string value.");
return WebString();
}
return WebString::fromUTF8(value.toString());
}
示例4: setProperty
bool CppBoundClass::setProperty(NPIdentifier ident, const NPVariant* value)
{
PropertyList::iterator callback = m_properties.find(ident);
if (callback == m_properties.end())
return false;
CppVariant cppValue;
cppValue.set(*value);
return (*callback).second->setValue(cppValue);
}
开发者ID:IllusionRom-deprecated,项目名称:android_platform_external_chromium_org_third_party_WebKit,代码行数:10,代码来源:CppBoundClass.cpp
示例5: notificationReceived
void AccessibilityUIElement::notificationReceived(const char* notificationName)
{
size_t callbackCount = m_notificationCallbacks.size();
for (size_t i = 0; i < callbackCount; i++) {
CppVariant notificationNameArgument;
notificationNameArgument.set(notificationName);
CppVariant invokeResult;
m_notificationCallbacks[i].invokeDefault(¬ificationNameArgument, 1, invokeResult);
}
}
示例6: logErrorToConsole
int32_t LayoutTestController::cppVariantToInt32(const CppVariant& value)
{
if (value.isInt32())
return value.toInt32();
if (value.isString()) {
int number;
if (StringToInt(value.toString(), &number))
return number;
}
logErrorToConsole("Invalid value for preference. Expected integer value.");
return 0;
}
示例7: strtol
int32_t TestRunner::cppVariantToInt32(const CppVariant& value)
{
if (value.isNumber())
return value.toInt32();
if (value.isString()) {
string stringSource = value.toString();
const char* source = stringSource.data();
char* end;
long number = strtol(source, &end, 10);
if (end == source + stringSource.length() && number >= numeric_limits<int32_t>::min() && number <= numeric_limits<int32_t>::max())
return static_cast<int32_t>(number);
}
printErrorMessage("Invalid value for preference. Expected integer value.");
return 0;
}
示例8: invokeDefault
bool CppVariant::invokeDefault(const CppVariant* arguments, uint32_t argumentCount,
CppVariant& result) const
{
WEBKIT_ASSERT(isObject());
NPObject* npObject = value.objectValue;
NPVariant r;
bool status = WebBindings::invokeDefault(0, npObject, arguments, argumentCount, &r);
result.set(r);
return status;
}
示例9: invoke
bool CppVariant::invoke(const string& method, const CppVariant* arguments,
uint32_t argumentCount, CppVariant& result) const
{
WEBKIT_ASSERT(isObject());
NPIdentifier methodName = WebBindings::getStringIdentifier(method.c_str());
NPObject* npObject = value.objectValue;
if (!WebBindings::hasMethod(0, npObject, methodName))
return false;
NPVariant r;
bool status = WebBindings::invoke(0, npObject, methodName, arguments, argumentCount, &r);
result.set(r);
return status;
}
示例10: cppVariantToBool
// Need these conversions because the format of the value for booleans
// may vary - for example, on mac "1" and "0" are used for boolean.
bool TestRunner::cppVariantToBool(const CppVariant& value)
{
if (value.isBool())
return value.toBoolean();
if (value.isNumber())
return value.toInt32();
if (value.isString()) {
string valueString = value.toString();
if (valueString == "true" || valueString == "1")
return true;
if (valueString == "false" || valueString == "0")
return false;
}
printErrorMessage("Invalid value. Expected boolean value.");
return false;
}
示例11: cppVariantToBool
// Need these conversions because the format of the value for booleans
// may vary - for example, on mac "1" and "0" are used for boolean.
bool LayoutTestController::cppVariantToBool(const CppVariant& value)
{
if (value.isBool())
return value.toBoolean();
if (value.isInt32())
return value.toInt32();
if (value.isString()) {
string valueString = value.toString();
if (valueString == "true" || valueString == "1")
return true;
if (valueString == "false" || valueString == "0")
return false;
}
logErrorToConsole("Invalid value. Expected boolean value.");
return false;
}
示例12: CppVariant
void ClientObject::setProperty(const std::string& name, const Awesomium::JSValue& value)
{
std::map<std::string, CppVariant*>::iterator i = clientProperties.find(name);
if(i == clientProperties.end())
{
CppVariant* newValue = new CppVariant();
if(value.isString())
newValue->Set(value.toString());
else if(value.isInteger())
newValue->Set(value.toInteger());
else if(value.isDouble())
newValue->Set(value.toDouble());
else if(value.isBoolean())
newValue->Set(value.toBoolean());
else
newValue->SetNull();
clientProperties[name] = newValue;
BindProperty(name, newValue);
}
else
{
if(value.isString())
i->second->Set(value.toString());
else if(value.isInteger())
i->second->Set(value.toInteger());
else if(value.isDouble())
i->second->Set(value.toDouble());
else if(value.isBoolean())
i->second->Set(value.toBoolean());
else
i->second->SetNull();
}
}