|
3 | 3 | use crate::avm1::activation::Activation; |
4 | 4 | use crate::avm1::clamp::Clamp; |
5 | 5 | use crate::avm1::error::Error; |
6 | | -use crate::avm1::function::FunctionObject; |
7 | | -use crate::avm1::property_decl::{define_properties_on, Declaration}; |
| 6 | +use crate::avm1::property_decl::{DeclContext, Declaration, SystemClass}; |
8 | 7 | use crate::avm1::{Attribute, NativeObject, Object, Value}; |
9 | 8 | use crate::ecma_conversions::f64_to_wrapping_i32; |
10 | 9 | use crate::string::{AvmString, StringContext}; |
@@ -62,6 +61,22 @@ const OBJECT_DECLS: &[Declaration] = declare_properties! { |
62 | 61 | "NUMERIC" => int(SortOptions::NUMERIC.bits()); |
63 | 62 | }; |
64 | 63 |
|
| 64 | +pub fn create_class<'gc>( |
| 65 | + context: &mut DeclContext<'_, 'gc>, |
| 66 | + super_proto: Object<'gc>, |
| 67 | +) -> SystemClass<'gc> { |
| 68 | + let proto = ArrayBuilder::new_with_proto(context.strings, super_proto).with([]); |
| 69 | + let class = context.native_class_with_proto(constructor, Some(array), proto); |
| 70 | + context.define_properties_on(proto, PROTO_DECLS); |
| 71 | + |
| 72 | + // TODO: These were added in Flash Player 7, but are available even to SWFv6 and lower |
| 73 | + // when run in Flash Player 7. Make these conditional if we add a parameter to control |
| 74 | + // target Flash Player version. |
| 75 | + context.define_properties_on(class.constr, OBJECT_DECLS); |
| 76 | + |
| 77 | + class |
| 78 | +} |
| 79 | + |
65 | 80 | /// Intermediate builder for constructing `ArrayObject`, |
66 | 81 | /// used to work around borrow-checker issues. |
67 | 82 | pub struct ArrayBuilder<'gc> { |
@@ -121,23 +136,8 @@ impl<'gc> ArrayBuilder<'gc> { |
121 | 136 | } |
122 | 137 | } |
123 | 138 |
|
124 | | -pub fn create_array_object<'gc>( |
125 | | - context: &mut StringContext<'gc>, |
126 | | - array_proto: Object<'gc>, |
127 | | - fn_proto: Object<'gc>, |
128 | | -) -> Object<'gc> { |
129 | | - let array = |
130 | | - FunctionObject::constructor(context, constructor, Some(array), fn_proto, array_proto); |
131 | | - |
132 | | - // TODO: These were added in Flash Player 7, but are available even to SWFv6 and lower |
133 | | - // when run in Flash Player 7. Make these conditional if we add a parameter to control |
134 | | - // target Flash Player version. |
135 | | - define_properties_on(OBJECT_DECLS, context, array, fn_proto); |
136 | | - array |
137 | | -} |
138 | | - |
139 | 139 | /// Implements `Array` constructor |
140 | | -pub fn constructor<'gc>( |
| 140 | +fn constructor<'gc>( |
141 | 141 | activation: &mut Activation<'_, 'gc>, |
142 | 142 | this: Object<'gc>, |
143 | 143 | args: &[Value<'gc>], |
@@ -792,13 +792,3 @@ fn qsort<'gc>( |
792 | 792 |
|
793 | 793 | Ok(()) |
794 | 794 | } |
795 | | - |
796 | | -pub fn create_proto<'gc>( |
797 | | - context: &mut StringContext<'gc>, |
798 | | - proto: Object<'gc>, |
799 | | - fn_proto: Object<'gc>, |
800 | | -) -> Object<'gc> { |
801 | | - let array = ArrayBuilder::new_with_proto(context, proto).with([]); |
802 | | - define_properties_on(PROTO_DECLS, context, array, fn_proto); |
803 | | - array |
804 | | -} |
0 commit comments