diff --git a/core/src/avm2/globals/__ruffle__.rs b/core/src/avm2/globals/__ruffle__.rs index e0af42f76712..3c9190e19c8d 100644 --- a/core/src/avm2/globals/__ruffle__.rs +++ b/core/src/avm2/globals/__ruffle__.rs @@ -2,6 +2,7 @@ use crate::avm2::activation::Activation; use crate::avm2::error::Error; use crate::avm2::object::Object; use crate::avm2::value::Value; +use crate::string::WStr; use crate::stub::Stub; use std::borrow::Cow; @@ -120,3 +121,27 @@ pub fn stub_constructor<'gc>( Ok(Value::Undefined) } + +pub fn log_warn<'gc>( + activation: &mut Activation<'_, 'gc>, + _this: Object<'gc>, + args: &[Value<'gc>], +) -> Result, Error<'gc>> { + match args { + [] => tracing::warn!("(__ruffle__.log_warn called with no arg)"), + [arg] => { + let msg = arg.coerce_to_string(activation)?; + tracing::warn!("{}", &msg.to_utf8_lossy()); + } + args => { + let strings = args + .iter() + .map(|a| a.coerce_to_string(activation)) + .collect::, _>>()?; + let msg = crate::string::join(&strings, &WStr::from_units(b" ")); + tracing::warn!("{}", &msg.to_utf8_lossy()); + } + } + + Ok(Value::Undefined) +} diff --git a/core/src/avm2/globals/__ruffle__/stubs.as b/core/src/avm2/globals/__ruffle__/stubs.as index 92ee6f39ba3d..2b9d078baf95 100644 --- a/core/src/avm2/globals/__ruffle__/stubs.as +++ b/core/src/avm2/globals/__ruffle__/stubs.as @@ -6,4 +6,7 @@ package __ruffle__ { public native function stub_setter(... rest):void; public native function stub_constructor(... rest):void; + + + public native function log_warn(... rest):void; }