Skip to content

Commit

Permalink
avm2: Add back log_warn
Browse files Browse the repository at this point in the history
  • Loading branch information
Lord-McSweeney authored and adrian17 committed Oct 13, 2023
1 parent acecaab commit 93aa3a4
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 0 deletions.
25 changes: 25 additions & 0 deletions core/src/avm2/globals/__ruffle__.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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<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)
}
3 changes: 3 additions & 0 deletions core/src/avm2/globals/__ruffle__/stubs.as
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

0 comments on commit 93aa3a4

Please sign in to comment.