avm2: Stub more parts of LocalConnection and UrlRequest
This commit is contained in:
parent
c8314da8d3
commit
5e115ed038
|
@ -453,6 +453,13 @@ pub fn load_player_globals<'gc>(
|
|||
avm2_system_class!(array, activation, array::create_class(mc), script);
|
||||
|
||||
function(activation, "", "trace", toplevel::trace, script)?;
|
||||
function(
|
||||
activation,
|
||||
"__ruffle__",
|
||||
"log_warn",
|
||||
toplevel::log_warn,
|
||||
script,
|
||||
)?;
|
||||
function(activation, "", "isFinite", toplevel::is_finite, script)?;
|
||||
function(activation, "", "isNaN", toplevel::is_nan, script)?;
|
||||
function(activation, "", "parseInt", toplevel::parse_int, script)?;
|
||||
|
|
|
@ -0,0 +1,3 @@
|
|||
package __ruffle__ {
|
||||
public native function log_warn(...arguments);
|
||||
}
|
|
@ -262,6 +262,16 @@ pub fn is_url_inaccessible<'gc>(
|
|||
Ok(false.into())
|
||||
}
|
||||
|
||||
/// `parentAllowsChild` getter stub
|
||||
pub fn parent_allows_child<'gc>(
|
||||
_activation: &mut Activation<'_, 'gc, '_>,
|
||||
_this: Option<Object<'gc>>,
|
||||
_args: &[Value<'gc>],
|
||||
) -> Result<Value<'gc>, Error<'gc>> {
|
||||
log::warn!("LoaderInfo.parentAllowsChild is a stub");
|
||||
Ok(false.into())
|
||||
}
|
||||
|
||||
/// `swfVersion` getter
|
||||
pub fn swf_version<'gc>(
|
||||
_activation: &mut Activation<'_, 'gc, '_>,
|
||||
|
@ -529,6 +539,7 @@ pub fn create_class<'gc>(mc: MutationContext<'gc, '_>) -> GcCell<'gc, Class<'gc>
|
|||
("frameRate", Some(frame_rate), None),
|
||||
("height", Some(height), None),
|
||||
("isURLInaccessible", Some(is_url_inaccessible), None),
|
||||
("parentAllowsChild", Some(parent_allows_child), None),
|
||||
("swfVersion", Some(swf_version), None),
|
||||
("url", Some(url), None),
|
||||
("width", Some(width), None),
|
||||
|
|
|
@ -1,9 +1,30 @@
|
|||
package flash.net {
|
||||
import flash.events.EventDispatcher;
|
||||
import __ruffle__.log_warn;
|
||||
|
||||
// NOTE: this entire class is a stub.
|
||||
// Thankfully (hopefully) a lot of code like Mochicrypt doesn't actually require this to... well do anything.
|
||||
public class LocalConnection extends EventDispatcher {
|
||||
|
||||
public var client: Object;
|
||||
|
||||
public function LocalConnection() {
|
||||
this.client = this;
|
||||
}
|
||||
|
||||
public function get domain():String {
|
||||
// FIXME - implement this
|
||||
// FIXME - implement this - this is unrelated to the messaging functionality.
|
||||
return "localhost";
|
||||
}
|
||||
|
||||
public function close(): void {}
|
||||
public function connect(connectionName:String): void {
|
||||
log_warn("LocalConnection.connect is not implemented");
|
||||
}
|
||||
|
||||
public function send(connectionName: String, methodName: String, ... arguments): void {}
|
||||
|
||||
public function allowDomain(... domains): void {}
|
||||
public function allowInsecureDomain(... domains): void {}
|
||||
}
|
||||
}
|
|
@ -1,10 +1,15 @@
|
|||
package flash.net {
|
||||
|
||||
import __ruffle__.log_warn;
|
||||
|
||||
public final class URLRequest {
|
||||
// NOTE - when implementing properties (e.g. `contentType`, `data`, etc.)
|
||||
// be sure to also check for them in `URLLoader`
|
||||
|
||||
// FIXME - this should be a getter/setter for consistency with Flash
|
||||
public var url:String;
|
||||
private var _contentType: String = "application/x-www-form-urlencoded"; // ignored
|
||||
|
||||
public var digest:String;
|
||||
private var _method:String = URLRequestMethod.GET;
|
||||
private var _data:Object;
|
||||
|
@ -28,9 +33,20 @@ package flash.net {
|
|||
|
||||
public function set data(newData:Object):void {
|
||||
if (newData !== null) {
|
||||
throw new Error("URLRequest.data setter is not yet implemented!");
|
||||
log_warn("URLRequest.data setter is not yet implemented");
|
||||
}
|
||||
this._data = newData;
|
||||
}
|
||||
|
||||
public function set contentType(value:String):void {
|
||||
if (value !== this._contentType) {
|
||||
log_warn("URLRequest.contentType setter is not yet implemented");
|
||||
}
|
||||
this._contentType = value;
|
||||
}
|
||||
|
||||
public function get contentType():String {
|
||||
return this._contentType;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -23,3 +23,4 @@ include "String.as"
|
|||
include "int.as"
|
||||
include "uint.as"
|
||||
include "Vector.as"
|
||||
include "__ruffle__/logging.as"
|
|
@ -30,6 +30,30 @@ pub fn trace<'gc>(
|
|||
Ok(Value::Undefined)
|
||||
}
|
||||
|
||||
pub fn log_warn<'gc>(
|
||||
activation: &mut Activation<'_, 'gc, '_>,
|
||||
_this: Option<Object<'gc>>,
|
||||
args: &[Value<'gc>],
|
||||
) -> Result<Value<'gc>, Error<'gc>> {
|
||||
match args {
|
||||
[] => log::warn!("(__ruffle__.log_warn called with no arg)"),
|
||||
[arg] => {
|
||||
let msg = arg.coerce_to_string(activation)?;
|
||||
log::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" "));
|
||||
log::warn!("{}", &msg.to_utf8_lossy());
|
||||
}
|
||||
}
|
||||
|
||||
Ok(Value::Undefined)
|
||||
}
|
||||
|
||||
pub fn is_finite<'gc>(
|
||||
activation: &mut Activation<'_, 'gc, '_>,
|
||||
_this: Option<Object<'gc>>,
|
||||
|
|
Loading…
Reference in New Issue