本文整理汇总了C++中as_value类的典型用法代码示例。如果您正苦于以下问题:C++ as_value类的具体用法?C++ as_value怎么用?C++ as_value使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了as_value类的19个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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;
}
开发者ID:aopui,项目名称:gnash,代码行数:29,代码来源:Class.cpp
示例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 );
}
开发者ID:JamesLinus,项目名称:nui3,代码行数:16,代码来源:as_point.cpp
示例3: send
void as_xmlsock::send(const as_value& val) const
{
if (m_ns)
{
m_ns->write_string(val.to_tu_string(), XML_TIMEOUT);
}
}
开发者ID:cpascal,项目名称:CCSWF,代码行数:7,代码来源:as_xmlsocket.cpp
示例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 );
}
}
开发者ID:Badcreature,项目名称:sagcg,代码行数:27,代码来源:gameswf_environment.cpp
示例5: test_bool
void
test_bool(as_value boolval)
{
if (boolval.is_bool()) {
runtest.pass("as_value(bool)");
} else {
runtest.fail("as_value(bool)");
}
}
开发者ID:BrandRegard,项目名称:gnash,代码行数:9,代码来源:AsValueTest.cpp
示例6: test_int
void
test_int(as_value val)
{
if (val.is_number()) {
runtest.pass("as_value(int)");
} else {
runtest.fail("as_value(int)");
}
}
开发者ID:BrandRegard,项目名称:gnash,代码行数:9,代码来源:AsValueTest.cpp
示例7: test_string
void
test_string(as_value val)
{
if (val.is_string()) {
runtest.pass("as_value(string)");
} else {
runtest.fail("as_value(string)");
}
}
开发者ID:BrandRegard,项目名称:gnash,代码行数:9,代码来源:AsValueTest.cpp
示例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() ) );
}
开发者ID:Badcreature,项目名称:sagcg,代码行数:39,代码来源:gameswf_environment.cpp
示例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;
}
}
开发者ID:Heartbroken,项目名称:bikini,代码行数:38,代码来源:gameswf_value.cpp
示例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);
}
}
开发者ID:Cucurbitace,项目名称:attract,代码行数:50,代码来源:gameswf_value.cpp
示例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;
}
开发者ID:xuxiandi,项目名称:LiquidFL,代码行数:16,代码来源:as_loadvars.cpp
示例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 );
}
开发者ID:Cucurbitace,项目名称:attract,代码行数:38,代码来源:as_transform.cpp
示例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);
}
开发者ID:ChenliTemple,项目名称:gameswf,代码行数:6,代码来源:gameswf_object.cpp
示例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;
}
开发者ID:Badcreature,项目名称:sagcg,代码行数:6,代码来源:gameswf_environment.cpp
示例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 );
}
开发者ID:xuxiandi,项目名称:LiquidFL,代码行数:76,代码来源:as_color_transform.cpp
示例16: if
/// Convert an AS object to an XML string.
std::string
ExternalInterface::_toXML(const as_value &val)
{
// GNASH_REPORT_FUNCTION;
std::stringstream ss;
if (val.is_string()) {
ss << "<string>" << val.to_string() << "</string>";
} else if (val.is_number()) {
ss << "<number>" << val.to_string() << "</number>";
} else if (val.is_undefined()) {
ss << "<void/>";
} else if (val.is_null()) {
ss << "<null/>";
// Exception isn't listed in any docs, but we'll use it for
// marshallExceptions.
} else if (val.is_exception()) {
ss << "<exception>" << val.to_string()<< "</exception>";
} else if (val.is_bool()) {
ss << (val.to_bool(8) ? "<true/>" : "<false/>");
// Function also isn't listed, but it's the only other type
// supported by as_value, so leaving it out doesn't seem right.
} else if (val.is_function()) {
ss << "<function>" << val.to_string() << "</function>";
} else if (val.is_object()) {
as_object *obj = val.get_object();
ss << _objectToXML(obj);
} else {
log_error(_("Can't convert unknown type %d"), val.to_string());
}
return ss.str();
}
开发者ID:liujunhongz,项目名称:gnash,代码行数:35,代码来源:ExternalInterface.cpp
示例17: operator
void operator()(const as_value& val) {
_v.push_back(val.to_number());
}
开发者ID:o1iver,项目名称:Code-Backup,代码行数:3,代码来源:TextFormat_as.cpp
示例18: as_value
//ECMA-262 11.8.5
as_value as_value::abstract_relational_comparison( const as_value & first, const as_value & second )
{
return as_value( first.to_number() < second.to_number() );
// todo
}
开发者ID:Cucurbitace,项目名称:attract,代码行数:6,代码来源:gameswf_value.cpp
示例19: abstract_equality_comparison
bool as_value::abstract_equality_comparison( const as_value & first, const as_value & second )
{
if (first.type_of() == second.type_of())
{
if( first.is_undefined() ) return true;
if( first.is_null() ) return true;
if( first.is_number() )
{
double first_number = first.to_number();
double second_number = second.to_number();
if( first_number == get_nan() || second_number == get_nan() )
{
return false;
}
return first_number == second_number;
}
else if( first.is_string() )
{
return first.to_tu_string() == second.to_tu_string();
}
else if( first.is_bool() )
{
return first.to_bool() == second.to_bool();
}
//13.Return true if x and y refer to the same object or if they refer to objects joined to each other (see
//13.1.2). Otherwise, return false.
// TODO: treat joined object
return first.to_object() == second.to_object();
}
else
{
if( first.is_null() && second.is_undefined() ) return true;
if( second.is_null() && first.is_undefined() ) return true;
if( ( first.is_number() && second.is_string() )
|| (second.is_number() && first.is_string() ) )
{
return first.to_number() == second.to_number();
}
if( first.is_bool() || second.is_bool() ) return first.to_number() == second.to_number();
// TODO:20.If Type(x) is either String or Number and Type(y) is Object,
//return the result of the comparison x == ToPrimitive(y).
//21.If Type(x) is Object and Type(y) is either String or Number,
//return the result of the comparison ToPrimitive(x) == y.
return false;
}
}
开发者ID:Cucurbitace,项目名称:attract,代码行数:55,代码来源:gameswf_value.cpp
注:本文中的as_value类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论