本文整理汇总了C++中QScriptValue::toUInt16方法的典型用法代码示例。如果您正苦于以下问题:C++ QScriptValue::toUInt16方法的具体用法?C++ QScriptValue::toUInt16怎么用?C++ QScriptValue::toUInt16使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QScriptValue
的用法示例。
在下文中一共展示了QScriptValue::toUInt16方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: marshall_basetype
//.........这里部分代码省略.........
break;
case Smoke::t_short:
switch(m->action()) {
case Marshall::FromQScriptValue:
{
QScriptValue value = *(m->var());
if (value.isNull()) {
m->item().s_short = 0;
} else {
m->item().s_short = (short) value.toInt32();
}
break;
}
case Marshall::ToQScriptValue:
*(m->var()) = QScriptValue(m->engine(), m->item().s_short);
break;
default:
m->unsupported();
break;
}
break;
case Smoke::t_ushort:
switch(m->action()) {
case Marshall::FromQScriptValue:
{
QScriptValue value = *(m->var());
if (value.isNull()) {
m->item().s_ushort = 0;
} else {
m->item().s_ushort = value.toUInt16();
}
break;
}
case Marshall::ToQScriptValue:
*(m->var()) = QScriptValue(m->engine(), m->item().s_ushort);
break;
default:
m->unsupported();
break;
}
break;
case Smoke::t_int:
switch(m->action()) {
case Marshall::FromQScriptValue:
{
QScriptValue value = *(m->var());
if (value.isNull()) {
m->item().s_int = 0;
} else {
m->item().s_int = value.toInt32();
}
break;
}
case Marshall::ToQScriptValue:
*(m->var()) = QScriptValue(m->engine(), m->item().s_int);
break;
default:
m->unsupported();
break;
}
示例2: wscReadyStateFromScriptValue
void wscReadyStateFromScriptValue(const QScriptValue& object, WebSocketClass::ReadyState& readyState) {
readyState = (WebSocketClass::ReadyState)object.toUInt16();
}
示例3: fromScriptValue
void ReflectiveScriptClass::fromScriptValue(
const QScriptValue& value, Node_ptr node)
{
// std::cout << __FUNCTION__ << std::endl;
using namespace gsim::core;
const descriptor_type type =
node->descriptor->get_type();
node->check_for_initialized();
holder& hold = node->holder;
descriptor_base const * descriptor = node->descriptor;
switch(type)
{
case TYPE_STRUCT:
{
if (value.isObject())
{
unsigned int count =
node->descriptor->get_children_count();
// Search by name
for (unsigned int i = 0; i < count; i++)
{
const char *childName = descriptor->get_child_name(i);
QScriptValue childValue = value.property(childName);
if (childValue.isValid())
fromScriptValue(childValue, node->children[i]);
}
}
else
{
std::cerr << "Must be an object!" << std::endl;
}
}
break;
case TYPE_ARRAY:
if (descriptor->get_slice()->get_type() == TYPE_CHAR)
{
const std::string str(value.toString().toStdString());
descriptor->from_string(hold, str);
break;
}
case TYPE_SEQUENCE:
{
unsigned int length = descriptor->get_length(hold);
unsigned int newLength = value.property("length").toUInt32();
if (descriptor->is_variable_length() &&
length != newLength)
{
descriptor->set_length(hold, newLength);
node->reset();
node->check_for_initialized();
}
for (unsigned int i = 0; i < newLength && i < length; i++)
{
fromScriptValue(value.property(i),
node->children[i]);
}
}
break;
case TYPE_BOOL:
hold.to_value< bool >() = value.toBool();
break;
case TYPE_OCTET:
hold.to_value< unsigned char >() = value.toInteger();
break;
case TYPE_CHAR:
hold.to_value< char >() = value.toInteger();
break;
case TYPE_SHORT:
hold.to_value< short >() = value.toInteger();
break;
case TYPE_USHORT:
hold.to_value< unsigned short >() = value.toUInt16();
break;
case TYPE_LONG:
hold.to_value< int32_t >() = value.toInteger();
break;
case TYPE_ULONG:
hold.to_value< uint32_t >() = value.toUInt32();
break;
case TYPE_LONGLONG:
hold.to_value< int64_t >() = value.toInteger();
break;
case TYPE_ULONGLONG:
hold.to_value< uint64_t >() = value.toInteger();
break;
case TYPE_STRING:
//.........这里部分代码省略.........
示例4: qWSCloseCodeFromScriptValue
void qWSCloseCodeFromScriptValue(const QScriptValue &object, QWebSocketProtocol::CloseCode &closeCode) {
closeCode = (QWebSocketProtocol::CloseCode)object.toUInt16();
}