avm1: Replaced all existing stub warnings with new stub system

This commit is contained in:
Nathan Adams 2023-01-31 17:57:45 +01:00
parent 366f8bef43
commit 44981af409
9 changed files with 52 additions and 67 deletions

View File

@ -86,7 +86,7 @@ macro_rules! avm1_stub {
static STUB: $crate::stub::Stub = $crate::stub::Stub::Avm1Method {
class: $class,
method: $method,
specifics: Some(Cow::Borrowed($specifics)),
specifics: Some($specifics),
};
$activation.context.stub_tracker.encounter(&STUB);
};

View File

@ -4,6 +4,7 @@ use crate::avm1::activation::Activation;
use crate::avm1::error::Error;
use crate::avm1::property_decl::{define_properties_on, Declaration};
use crate::avm1::{Object, ScriptObject, Value};
use crate::avm1_stub;
use gc_arena::MutationContext;
const OBJECT_DECLS: &[Declaration] = declare_properties! {
@ -13,29 +14,29 @@ const OBJECT_DECLS: &[Declaration] = declare_properties! {
};
pub fn is_active<'gc>(
_activation: &mut Activation<'_, 'gc>,
activation: &mut Activation<'_, 'gc>,
_this: Object<'gc>,
_args: &[Value<'gc>],
) -> Result<Value<'gc>, Error<'gc>> {
tracing::warn!("Accessibility.isActive: not yet implemented");
avm1_stub!(activation, "Accessibility", "isActive");
Ok(Value::Bool(false))
}
pub fn send_event<'gc>(
_activation: &mut Activation<'_, 'gc>,
activation: &mut Activation<'_, 'gc>,
_this: Object<'gc>,
_args: &[Value<'gc>],
) -> Result<Value<'gc>, Error<'gc>> {
tracing::warn!("Accessibility.sendEvent: not yet implemented");
avm1_stub!(activation, "Accessibility", "sendEvent");
Ok(Value::Undefined)
}
pub fn update_properties<'gc>(
_activation: &mut Activation<'_, 'gc>,
activation: &mut Activation<'_, 'gc>,
_this: Object<'gc>,
_args: &[Value<'gc>],
) -> Result<Value<'gc>, Error<'gc>> {
tracing::warn!("Accessibility.updateProperties: not yet implemented");
avm1_stub!(activation, "Accessibility", "updateProperties");
Ok(Value::Undefined)
}

View File

@ -6,13 +6,13 @@ use crate::avm1::globals::color_transform::ColorTransformObject;
use crate::avm1::object::bitmap_data::BitmapDataObject;
use crate::avm1::property_decl::{define_properties_on, Declaration};
use crate::avm1::{Activation, Error, Object, TObject, Value};
use crate::avm_error;
use crate::bitmap::bitmap_data::IBitmapDrawable;
use crate::bitmap::bitmap_data::{BitmapData, ChannelOptions, Color};
use crate::bitmap::is_size_valid;
use crate::character::Character;
use crate::display_object::TDisplayObject;
use crate::swf::BlendMode;
use crate::{avm1_stub, avm_error};
use gc_arena::{GcCell, MutationContext};
use ruffle_render::transform::Transform;
use std::str::FromStr;
@ -522,7 +522,7 @@ pub fn draw<'gc>(
}
if args.get(4).is_some() {
tracing::warn!("BitmapData.draw with clip rect - not implemented")
avm1_stub!(activation, "BitmapData", "draw", "with clip rect");
}
let smoothing = args
.get(5)
@ -570,22 +570,22 @@ pub fn draw<'gc>(
}
pub fn apply_filter<'gc>(
_activation: &mut Activation<'_, 'gc>,
activation: &mut Activation<'_, 'gc>,
_this: Object<'gc>,
_args: &[Value<'gc>],
) -> Result<Value<'gc>, Error<'gc>> {
tracing::warn!("BitmapData.applyFilter - not yet implemented");
avm1_stub!(activation, "BitmapData", "applyFilter");
Ok((-1).into())
}
pub fn generate_filter_rect<'gc>(
_activation: &mut Activation<'_, 'gc>,
activation: &mut Activation<'_, 'gc>,
this: Object<'gc>,
_args: &[Value<'gc>],
) -> Result<Value<'gc>, Error<'gc>> {
if let Some(bitmap_data) = this.as_bitmap_data_object() {
if !bitmap_data.disposed() {
tracing::warn!("BitmapData.generateFilterRect - not yet implemented");
avm1_stub!(activation, "BitmapData", "generateFilterRect");
return Ok(Value::Undefined);
}
}
@ -743,13 +743,13 @@ pub fn perlin_noise<'gc>(
}
pub fn hit_test<'gc>(
_activation: &mut Activation<'_, 'gc>,
activation: &mut Activation<'_, 'gc>,
this: Object<'gc>,
_args: &[Value<'gc>],
) -> Result<Value<'gc>, Error<'gc>> {
if let Some(bitmap_data) = this.as_bitmap_data_object() {
if !bitmap_data.disposed() {
tracing::warn!("BitmapData.hitTest - not yet implemented");
avm1_stub!(activation, "BitmapData", "hitTest");
return Ok(Value::Undefined);
}
}
@ -1076,13 +1076,13 @@ pub fn palette_map<'gc>(
}
pub fn pixel_dissolve<'gc>(
_activation: &mut Activation<'_, 'gc>,
activation: &mut Activation<'_, 'gc>,
this: Object<'gc>,
_args: &[Value<'gc>],
) -> Result<Value<'gc>, Error<'gc>> {
if let Some(bitmap_data) = this.as_bitmap_data_object() {
if !bitmap_data.disposed() {
tracing::warn!("BitmapData.pixelDissolve - not yet implemented");
avm1_stub!(activation, "BitmapData", "pixelDissolve");
return Ok(Value::Undefined);
}
}

View File

@ -7,7 +7,7 @@ use crate::avm1::function::ExecutionReason;
use crate::avm1::property::Attribute;
use crate::avm1::property_decl::{define_properties_on, Declaration};
use crate::avm1::{Object, ScriptObject, TObject, Value};
use crate::avm_warn;
use crate::avm1_stub;
use crate::backend::navigator::{NavigationMethod, Request};
use crate::string::AvmString;
use gc_arena::MutationContext;
@ -51,7 +51,7 @@ fn add_request_header<'gc>(
_this: Object<'gc>,
_args: &[Value<'gc>],
) -> Result<Value<'gc>, Error<'gc>> {
avm_warn!(activation, "LoadVars.addRequestHeader: Unimplemented");
avm1_stub!(activation, "LoadVars", "addRequestHeader");
Ok(Value::Undefined)
}

View File

@ -6,7 +6,7 @@ use crate::avm1::object::NativeObject;
use crate::avm1::property::Attribute;
use crate::avm1::property_decl::{define_properties_on, Declaration};
use crate::avm1::{Object, ScriptObject, TObject, Value};
use crate::avm_warn;
use crate::avm1_stub;
use crate::display_object::TDisplayObject;
use crate::string::AvmString;
use flash_lso::types::Value as AmfValue;
@ -41,7 +41,7 @@ pub fn delete_all<'gc>(
_this: Object<'gc>,
_args: &[Value<'gc>],
) -> Result<Value<'gc>, Error<'gc>> {
avm_warn!(activation, "SharedObject.deleteAll() not implemented");
avm1_stub!(activation, "SharedObject", "deleteAll");
Ok(Value::Undefined)
}
@ -50,7 +50,7 @@ pub fn get_disk_usage<'gc>(
_this: Object<'gc>,
_args: &[Value<'gc>],
) -> Result<Value<'gc>, Error<'gc>> {
avm_warn!(activation, "SharedObject.getDiskUsage() not implemented");
avm1_stub!(activation, "SharedObject", "getDiskUsage");
Ok(Value::Undefined)
}
@ -388,7 +388,7 @@ pub fn get_remote<'gc>(
_this: Object<'gc>,
_args: &[Value<'gc>],
) -> Result<Value<'gc>, Error<'gc>> {
avm_warn!(activation, "SharedObject.getRemote() not implemented");
avm1_stub!(activation, "SharedObject", "getRemote");
Ok(Value::Undefined)
}
@ -397,7 +397,7 @@ pub fn get_max_size<'gc>(
_this: Object<'gc>,
_args: &[Value<'gc>],
) -> Result<Value<'gc>, Error<'gc>> {
avm_warn!(activation, "SharedObject.getMaxSize() not implemented");
avm1_stub!(activation, "SharedObject", "getMaxSize");
Ok(Value::Undefined)
}
@ -406,7 +406,7 @@ pub fn add_listener<'gc>(
_this: Object<'gc>,
_args: &[Value<'gc>],
) -> Result<Value<'gc>, Error<'gc>> {
avm_warn!(activation, "SharedObject.addListener() not implemented");
avm1_stub!(activation, "SharedObject", "addListener");
Ok(Value::Undefined)
}
@ -415,7 +415,7 @@ pub fn remove_listener<'gc>(
_this: Object<'gc>,
_args: &[Value<'gc>],
) -> Result<Value<'gc>, Error<'gc>> {
avm_warn!(activation, "SharedObject.removeListener() not implemented");
avm1_stub!(activation, "SharedObject", "removeListener");
Ok(Value::Undefined)
}
@ -460,7 +460,7 @@ pub fn close<'gc>(
_this: Object<'gc>,
_args: &[Value<'gc>],
) -> Result<Value<'gc>, Error<'gc>> {
avm_warn!(activation, "SharedObject.close() not implemented");
avm1_stub!(activation, "SharedObject", "close");
Ok(Value::Undefined)
}
@ -469,7 +469,7 @@ pub fn connect<'gc>(
_this: Object<'gc>,
_args: &[Value<'gc>],
) -> Result<Value<'gc>, Error<'gc>> {
avm_warn!(activation, "SharedObject.connect() not implemented");
avm1_stub!(activation, "SharedObject", "connect");
Ok(Value::Undefined)
}
@ -505,7 +505,7 @@ pub fn get_size<'gc>(
_this: Object<'gc>,
_args: &[Value<'gc>],
) -> Result<Value<'gc>, Error<'gc>> {
avm_warn!(activation, "SharedObject.getSize() not implemented");
avm1_stub!(activation, "SharedObject", "getSize");
Ok(Value::Undefined)
}
@ -514,7 +514,7 @@ pub fn send<'gc>(
_this: Object<'gc>,
_args: &[Value<'gc>],
) -> Result<Value<'gc>, Error<'gc>> {
avm_warn!(activation, "SharedObject.send() not implemented");
avm1_stub!(activation, "SharedObject", "send");
Ok(Value::Undefined)
}
@ -523,7 +523,7 @@ pub fn set_fps<'gc>(
_this: Object<'gc>,
_args: &[Value<'gc>],
) -> Result<Value<'gc>, Error<'gc>> {
avm_warn!(activation, "SharedObject.setFps() not implemented");
avm1_stub!(activation, "SharedObject", "setFps");
Ok(Value::Undefined)
}
@ -532,7 +532,7 @@ pub fn on_status<'gc>(
_this: Object<'gc>,
_args: &[Value<'gc>],
) -> Result<Value<'gc>, Error<'gc>> {
avm_warn!(activation, "SharedObject.onStatus() not implemented");
avm1_stub!(activation, "SharedObject", "onStatus");
Ok(Value::Undefined)
}
@ -541,7 +541,7 @@ pub fn on_sync<'gc>(
_this: Object<'gc>,
_args: &[Value<'gc>],
) -> Result<Value<'gc>, Error<'gc>> {
avm_warn!(activation, "SharedObject.onSync() not implemented");
avm1_stub!(activation, "SharedObject", "onSync");
Ok(Value::Undefined)
}

View File

@ -5,10 +5,10 @@ use crate::avm1::activation::Activation;
use crate::avm1::error::Error;
use crate::avm1::property_decl::{define_properties_on, Declaration};
use crate::avm1::{Object, ScriptObject, SoundObject, TObject, Value};
use crate::avm_warn;
use crate::backend::navigator::Request;
use crate::character::Character;
use crate::display_object::{SoundTransform, TDisplayObject};
use crate::{avm1_stub, avm_warn};
use gc_arena::MutationContext;
const PROTO_DECLS: &[Declaration] = declare_properties! {
@ -135,7 +135,7 @@ fn get_bytes_loaded<'gc>(
_args: &[Value<'gc>],
) -> Result<Value<'gc>, Error<'gc>> {
if activation.swf_version() >= 6 {
avm_warn!(activation, "Sound.getBytesLoaded: Unimplemented");
avm1_stub!(activation, "Sound", "getBytesLoaded");
Ok(1.into())
} else {
Ok(Value::Undefined)
@ -148,7 +148,7 @@ fn get_bytes_total<'gc>(
_args: &[Value<'gc>],
) -> Result<Value<'gc>, Error<'gc>> {
if activation.swf_version() >= 6 {
avm_warn!(activation, "Sound.getBytesTotal: Unimplemented");
avm1_stub!(activation, "Sound", "getBytesTotal");
Ok(1.into())
} else {
Ok(Value::Undefined)
@ -227,7 +227,7 @@ fn id3<'gc>(
_args: &[Value<'gc>],
) -> Result<Value<'gc>, Error<'gc>> {
if activation.swf_version() >= 6 {
avm_warn!(activation, "Sound.id3: Unimplemented");
avm1_stub!(activation, "Sound", "id3");
}
Ok(Value::Undefined)
}

View File

@ -5,7 +5,7 @@ use crate::avm1::property::Attribute;
use crate::avm1::property_decl::{define_properties_on, Declaration};
use crate::avm1::runtime::Avm1;
use crate::avm1::{ScriptObject, TObject, Value};
use crate::avm_warn;
use crate::avm1_stub;
use bitflags::bitflags;
use core::fmt;
use gc_arena::MutationContext;
@ -449,13 +449,9 @@ pub fn show_settings<'gc>(
.unwrap_or(&last_panel_pos.into())
.coerce_to_i32(activation)?;
let panel = SettingsPanel::from_u8(panel_pos as u8).unwrap_or(SettingsPanel::Privacy);
let _panel = SettingsPanel::from_u8(panel_pos as u8).unwrap_or(SettingsPanel::Privacy);
avm_warn!(
activation,
"System.showSettings({:?}) not not implemented",
panel
);
avm1_stub!(activation, "System", "showSettings");
Ok(Value::Undefined)
}
@ -512,7 +508,7 @@ pub fn on_status<'gc>(
_this: Object<'gc>,
_args: &[Value<'gc>],
) -> Result<Value<'gc>, Error<'gc>> {
avm_warn!(activation, "System.onStatus() not implemented");
avm1_stub!(activation, "System", "onStatus");
Ok(Value::Undefined)
}

View File

@ -3,7 +3,7 @@ use crate::avm1::error::Error;
use crate::avm1::object::Object;
use crate::avm1::property_decl::{define_properties_on, Declaration};
use crate::avm1::{ScriptObject, Value};
use crate::avm_warn;
use crate::avm1_stub;
use crate::string::AvmString;
use gc_arena::MutationContext;
@ -22,7 +22,7 @@ fn allow_domain<'gc>(
_this: Object<'gc>,
_args: &[Value<'gc>],
) -> Result<Value<'gc>, Error<'gc>> {
avm_warn!(activation, "System.security.allowDomain() not implemented");
avm1_stub!(activation, "System.security", "allowDomain");
Ok(Value::Undefined)
}
@ -31,10 +31,7 @@ fn allow_insecure_domain<'gc>(
_this: Object<'gc>,
_args: &[Value<'gc>],
) -> Result<Value<'gc>, Error<'gc>> {
avm_warn!(
activation,
"System.security.allowInsecureDomain() not implemented"
);
avm1_stub!(activation, "System.security", "allowInsecureDomain");
Ok(Value::Undefined)
}
@ -43,10 +40,7 @@ fn load_policy_file<'gc>(
_this: Object<'gc>,
_args: &[Value<'gc>],
) -> Result<Value<'gc>, Error<'gc>> {
avm_warn!(
activation,
"System.security.loadPolicyFile() not implemented"
);
avm1_stub!(activation, "System.security", "loadPolicyFile");
Ok(Value::Undefined)
}
@ -55,7 +49,7 @@ fn escape_domain<'gc>(
_this: Object<'gc>,
_args: &[Value<'gc>],
) -> Result<Value<'gc>, Error<'gc>> {
avm_warn!(activation, "System.security.escapeDomain() not implemented");
avm1_stub!(activation, "System.security", "escapeDomain");
Ok(Value::Undefined)
}
@ -76,10 +70,7 @@ fn get_choose_local_swf_path<'gc>(
_this: Object<'gc>,
_args: &[Value<'gc>],
) -> Result<Value<'gc>, Error<'gc>> {
avm_warn!(
activation,
"System.security.chooseLocalSwfPath() not implemented"
);
avm1_stub!(activation, "System.security", "chooseLocalSwfPath");
Ok(Value::Undefined)
}
@ -88,10 +79,7 @@ fn policy_file_resolver<'gc>(
_this: Object<'gc>,
_args: &[Value<'gc>],
) -> Result<Value<'gc>, Error<'gc>> {
avm_warn!(
activation,
"System.security.chooseLocalSwfPath() not implemented"
);
avm1_stub!(activation, "System.security", "chooseLocalSwfPath");
Ok(Value::Undefined)
}

View File

@ -3,7 +3,7 @@
use crate::avm1::object::NativeObject;
use crate::avm1::property_decl::{define_properties_on, Declaration};
use crate::avm1::{Activation, ArrayObject, Error, Object, ScriptObject, TObject, Value};
use crate::avm_warn;
use crate::avm1_stub;
use crate::display_object::{AutoSizeMode, EditText, TDisplayObject};
use crate::ecma_conversions::round_to_even;
use crate::html::TextFormat;
@ -414,7 +414,7 @@ fn set_bullet<'gc>(
}
fn display<'gc>(activation: &mut Activation<'_, 'gc>, _text_format: &TextFormat) -> Value<'gc> {
avm_warn!(activation, "TextFormat.display: Unimplemented");
avm1_stub!(activation, "TextFormat", "display");
Value::Null
}
@ -423,7 +423,7 @@ fn set_display<'gc>(
_text_format: &mut TextFormat,
_value: &Value<'gc>,
) -> Result<(), Error<'gc>> {
avm_warn!(activation, "TextFormat.display: Unimplemented");
avm1_stub!(activation, "TextFormat", "display");
Ok(())
}