avm2: Add back log_warn
This commit is contained in:
parent
acecaabd0e
commit
93aa3a493b
|
@ -2,6 +2,7 @@ use crate::avm2::activation::Activation;
|
||||||
use crate::avm2::error::Error;
|
use crate::avm2::error::Error;
|
||||||
use crate::avm2::object::Object;
|
use crate::avm2::object::Object;
|
||||||
use crate::avm2::value::Value;
|
use crate::avm2::value::Value;
|
||||||
|
use crate::string::WStr;
|
||||||
use crate::stub::Stub;
|
use crate::stub::Stub;
|
||||||
use std::borrow::Cow;
|
use std::borrow::Cow;
|
||||||
|
|
||||||
|
@ -120,3 +121,27 @@ pub fn stub_constructor<'gc>(
|
||||||
|
|
||||||
Ok(Value::Undefined)
|
Ok(Value::Undefined)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn log_warn<'gc>(
|
||||||
|
activation: &mut Activation<'_, 'gc>,
|
||||||
|
_this: Object<'gc>,
|
||||||
|
args: &[Value<'gc>],
|
||||||
|
) -> Result<Value<'gc>, 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::<Result<Vec<_>, _>>()?;
|
||||||
|
let msg = crate::string::join(&strings, &WStr::from_units(b" "));
|
||||||
|
tracing::warn!("{}", &msg.to_utf8_lossy());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Ok(Value::Undefined)
|
||||||
|
}
|
||||||
|
|
|
@ -6,4 +6,7 @@ package __ruffle__ {
|
||||||
public native function stub_setter(... rest):void;
|
public native function stub_setter(... rest):void;
|
||||||
|
|
||||||
public native function stub_constructor(... rest):void;
|
public native function stub_constructor(... rest):void;
|
||||||
|
|
||||||
|
|
||||||
|
public native function log_warn(... rest):void;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue