Several built-in functions are not `public`, but instead live in the `AS3` namespace. This moves those functions there.

In practice not many movies will care about this, because the `AS3` namespace is open by default. You could opt-out of that, and I suppose that was there for using existing ES3 code in AS3 projects. ES4 would have had a similar ES4 namespace, which "JavaScript 2.0" code would need to opt into. Of course, ES4/JS2 never happened, so we just have this weird historical quirk here.
This commit is contained in:
David Wendt 2020-03-08 20:22:26 -04:00
parent 37cdcb3bce
commit 8b36751fbb
3 changed files with 8 additions and 4 deletions

View File

@ -53,7 +53,7 @@ pub fn create_proto<'gc>(gc_context: MutationContext<'gc, '_>, proto: Object<'gc
function_proto.install_method( function_proto.install_method(
gc_context, gc_context,
QName::new(Namespace::public_namespace(), "call"), QName::new(Namespace::as3_namespace(), "call"),
0, 0,
FunctionObject::from_builtin(gc_context, call, function_proto), FunctionObject::from_builtin(gc_context, call, function_proto),
); );

View File

@ -167,19 +167,19 @@ pub fn fill_proto<'gc>(
); );
object_proto.install_method( object_proto.install_method(
gc_context, gc_context,
QName::new(Namespace::public_namespace(), "hasOwnProperty"), QName::new(Namespace::as3_namespace(), "hasOwnProperty"),
0, 0,
FunctionObject::from_builtin(gc_context, has_own_property, fn_proto), FunctionObject::from_builtin(gc_context, has_own_property, fn_proto),
); );
object_proto.install_method( object_proto.install_method(
gc_context, gc_context,
QName::new(Namespace::public_namespace(), "isPrototypeOf"), QName::new(Namespace::as3_namespace(), "isPrototypeOf"),
0, 0,
FunctionObject::from_builtin(gc_context, is_prototype_of, fn_proto), FunctionObject::from_builtin(gc_context, is_prototype_of, fn_proto),
); );
object_proto.install_method( object_proto.install_method(
gc_context, gc_context,
QName::new(Namespace::public_namespace(), "propertyIsEnumerable"), QName::new(Namespace::as3_namespace(), "propertyIsEnumerable"),
0, 0,
FunctionObject::from_builtin(gc_context, property_is_enumerable, fn_proto), FunctionObject::from_builtin(gc_context, property_is_enumerable, fn_proto),
); );

View File

@ -59,6 +59,10 @@ impl Namespace {
Namespace::Package("".to_string()) Namespace::Package("".to_string())
} }
pub fn as3_namespace() -> Self {
Namespace::Namespace("http://adobe.com/AS3/2006/builtin".to_string())
}
pub fn package(package_name: &str) -> Self { pub fn package(package_name: &str) -> Self {
Namespace::Package(package_name.to_string()) Namespace::Package(package_name.to_string())
} }