-
-
Notifications
You must be signed in to change notification settings - Fork 828
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
avm2: Port Boolean class to Actionscript
This requires some minor changes to support it
- Loading branch information
Lord-McSweeney
authored and
Lord-McSweeney
committed
Dec 17, 2024
1 parent
21c3bed
commit 5f941ae
Showing
9 changed files
with
209 additions
and
174 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,51 @@ | ||
// This is a stub - the actual class is defined in `boolean.rs` | ||
package { | ||
public class Boolean { | ||
} | ||
[Ruffle(CustomConstructor)] | ||
[Ruffle(CallHandler)] | ||
public final class Boolean { | ||
public function Boolean(value:* = void 0) { | ||
// The Boolean constructor is implemented natively: | ||
// this AS-defined method does nothing | ||
} | ||
|
||
prototype.toString = function():String { | ||
if (this === Boolean.prototype) { | ||
return "false"; | ||
} | ||
|
||
if (!(this is Boolean)) { | ||
throw new TypeError("Error #1004: Method Boolean.prototype.toString was invoked on an incompatible object.", 1004); | ||
} | ||
|
||
return this.AS3::toString(); | ||
}; | ||
|
||
prototype.valueOf = function():* { | ||
if (this === Boolean.prototype) { | ||
return false; | ||
} | ||
|
||
if (!(this is Boolean)) { | ||
throw new TypeError("Error #1004: Method Boolean.prototype.valueOf was invoked on an incompatible object.", 1004); | ||
} | ||
|
||
return this; | ||
}; | ||
|
||
prototype.setPropertyIsEnumerable("toString", false); | ||
prototype.setPropertyIsEnumerable("valueOf", false); | ||
|
||
AS3 function toString():String { | ||
if (this) { | ||
return "true"; | ||
} else { | ||
return "false"; | ||
} | ||
} | ||
|
||
AS3 function valueOf():Boolean { | ||
return this; | ||
} | ||
|
||
public static const length:int = 1; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.