本文整理汇总了C++中as_value类的典型用法代码示例。如果您正苦于以下问题:C++ as_value类的具体用法?C++ as_value怎么用?C++ as_value使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了as_value类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: uri
bool
Class::addValue(string_table::key name, Namespace *ns,
std::uint32_t slotId, Class *type, as_value& val, bool isconst,
bool isstatic)
{
Global_as* g = VM::get().getGlobal();
if (val.is_object()) {
val.to_object(*g)->set_member(NSV::INTERNAL_TYPE, type->getName());
}
string_table::key nsname = ns ? ns->getURI() : string_table::key(0);
int flags = PropFlags::dontDelete;
if (isconst)
flags |= PropFlags::readOnly;
if (isstatic)
flags |= PropFlags::staticProp;
const ObjectURI uri(name, nsname);
if (slotId == 0) {
_prototype->init_member(uri, val, flags);
}
else {
_prototype->init_member(uri, val, flags, slotId);
}
return true;
}
示例2: if
//TODO: we should use a switch() instead of string compares.
bool as_point::set_member(const tu_stringi& name, const as_value& val)
{
if( name == "x" )
{
m_point.m_x = val.to_float();
return true;
}
else if( name == "y" )
{
m_point.m_y = val.to_float();
return true;
}
return as_object::set_member( name, val );
}
示例3: send
void as_xmlsock::send(const as_value& val) const
{
if (m_ns)
{
m_ns->write_string(val.to_tu_string(), XML_TIMEOUT);
}
}
示例4:
void as_environment::set_variable (
const tu_string &varname,
const as_value &val,
const array<with_stack_entry>& with_stack )
// Given a path to variable, set its value.
{
IF_VERBOSE_ACTION ( log_msg ( "-------------- %s = %s\n", varname.c_str(), val.to_string() ) ); //xxxxxxxxxx
// Path lookup rigamarole.
character *target = get_target();
tu_string path;
tu_string var;
if ( parse_path ( varname, &path, &var ) )
{
target = cast_to<character> ( find_target ( path.c_str() ) );
if ( target )
{
target->set_member ( var, val );
}
}
else
{
set_variable_raw ( varname, val, with_stack );
}
}
示例5: test_bool
void
test_bool(as_value boolval)
{
if (boolval.is_bool()) {
runtest.pass("as_value(bool)");
} else {
runtest.fail("as_value(bool)");
}
}
示例6: test_int
void
test_int(as_value val)
{
if (val.is_number()) {
runtest.pass("as_value(int)");
} else {
runtest.fail("as_value(int)");
}
}
示例7: test_string
void
test_string(as_value val)
{
if (val.is_string()) {
runtest.pass("as_value(string)");
} else {
runtest.fail("as_value(string)");
}
}
示例8: set_target
void as_environment::set_target ( as_value &target, character *original_target )
{
if ( target.is_string() )
{
tu_string path = target.to_tu_string();
IF_VERBOSE_ACTION ( log_msg ( "-------------- ActionSetTarget2: %s", path.c_str() ) );
if ( path.size() > 0 )
{
character *tar = cast_to<character> ( find_target ( path.c_str() ) );
if ( tar )
{
set_target ( tar );
return;
}
}
else
{
set_target ( original_target );
return;
}
}
else if ( target.is_object() )
{
IF_VERBOSE_ACTION ( log_msg ( "-------------- ActionSetTarget2: %s", target.to_string() ) );
character *tar = cast_to<character> ( find_target ( target ) );
if ( tar )
{
set_target ( tar );
return;
}
}
IF_VERBOSE_ACTION ( log_msg ( "can't set target %s\n", target.to_string() ) );
}
示例9: switch
bool as_value::operator==(const as_value& v) const
// Return true if operands are equal.
{
// types don't match
if (m_type != PROPERTY && v.m_type != PROPERTY && m_type != v.m_type)
{
return false;
}
switch (m_type)
{
case UNDEFINED:
return v.m_type == UNDEFINED;
case STRING:
return m_string == v.to_tu_string();
case NUMBER:
return m_number == v.to_number();
case BOOLEAN:
return m_bool == v.to_bool();
case OBJECT:
return m_object == v.to_object();
case PROPERTY:
{
as_value prop;
get_property(&prop);
return prop == v;
}
default:
assert(0);
return false;
}
}
示例10:
void as_value::operator=(const as_value& v)
{
switch (v.m_type)
{
case UNDEFINED:
set_undefined();
break;
case NUMBER:
set_double(v.m_number);
m_flags = v.m_flags;
break;
case BOOLEAN:
set_bool(v.m_bool);
m_flags = v.m_flags;
break;
case STRING:
set_tu_string(v.m_string);
m_flags = v.m_flags;
break;
case OBJECT:
set_as_object(v.m_object);
m_flags = v.m_flags;
break;
case PROPERTY:
drop_refs();
// is binded property ?
if (v.m_property_target == NULL)
{
m_type = PROPERTY;
m_property = v.m_property;
m_property_target = NULL;
}
else
{
v.get_property(this);
}
m_flags = v.m_flags;
break;
default:
assert(0);
}
}
示例11: set_member
bool as_loadvars::set_member(const lfl_stringi& name, const as_value& val)
{
// todo: check for callbacks
if( name == "onData"
|| name == "onHTTPStatus"
||name == "onLoad"
)
{
return as_object::set_member( name, val );
}
m_values.set( name.to_lfl_string(), val.to_lfl_string() );
return true;
}
示例12: set_member
bool as_transform::set_member(const tu_stringi& name, const as_value& val)
{
as_transform_member member = get_transform_member( name );
switch (member)
{
case colorTransform:
{
m_color_transform = cast_to<as_color_transform>( val.to_object() );
m_movie->set_cxform( m_color_transform->m_color_transform );
return true;
}
case concatenatedColorTransform:
{
//read-only
return true;
}
case matrix:
{
assert( false && "todo" );
return true;
}
case concatenatedMatrix:
{
//read-only
return true;
}
case pixelBounds:
{
assert( false && "todo" );
return true;
}
default:
break;
};
return as_object::set_member( name, val );
}
示例13:
// called from a object constructor only
void as_object::builtin_member(const tu_stringi& name, const as_value& val)
{
val.set_flags(as_value::DONT_ENUM);
m_members.set(name, val);
}
示例14: set_register
void as_environment::set_register ( int reg, const as_value &val )
{
IF_VERBOSE_ACTION ( log_msg ( "-------------- set_register(%d): %s at %p\n",
reg, val.to_string(), val.to_object() ) );
*local_register_ptr ( reg ) = val;
}
示例15: set_member
bool as_color_transform::set_member(const lfl_stringi& name, const as_value& val)
{
as_color_transform_member member = get_color_transform_member( name );
switch( member )
{
case alphaOffset:
{
m_color_transform.m_[ 3 ][ 1 ] = val.to_float();
return true;
}
case blueOffset:
{
m_color_transform.m_[ 2 ][ 1 ] = val.to_float();
return true;
}
case greenOffset:
{
m_color_transform.m_[ 1 ][ 1 ] = val.to_float();
return true;
}
case redOffset:
{
m_color_transform.m_[ 0 ][ 1 ] = val.to_float();
return true;
}
case alphaMultiplier:
{
m_color_transform.m_[ 3 ][ 0 ] = val.to_float();
return true;
}
case blueMultiplier:
{
m_color_transform.m_[ 2 ][ 0 ] = val.to_float();
return true;
}
case greenMultiplier:
{
m_color_transform.m_[ 1 ][ 0 ] = val.to_float();
return true;
}
case redMultiplier:
{
m_color_transform.m_[ 0 ][ 0 ] = val.to_float();
return true;
}
case rgb:
{
int rgb;
rgb = val.to_int();
m_color_transform.m_[ 0 ][ 0 ] = 0.0f;
m_color_transform.m_[ 1 ][ 0 ] = 0.0f;
m_color_transform.m_[ 2 ][ 0 ] = 0.0f;
m_color_transform.m_[ 3 ][ 0 ] = 0.0f;
m_color_transform.m_[ 0 ][ 1 ] = static_cast<float>( ( rgb >> 16 ) & 0xFF );
m_color_transform.m_[ 1 ][ 1 ] = static_cast<float>( ( rgb >> 8 ) & 0xFF );
m_color_transform.m_[ 2 ][ 1 ] = static_cast<float>( rgb & 0xFF );
m_color_transform.m_[ 3 ][ 1 ] = 255.0f;
return true;
}
default:
break;
}
return as_object::set_member( name, val );
}