Created
October 20, 2011 20:50
-
-
Save bamboo/1302345 to your computer and use it in GitHub Desktop.
annoying constructor chaining mapping
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
public abstract class Base | |
{ | |
public Base(string s) {} | |
} | |
public class ChainToBase : Base | |
{ | |
public ChainToBase() : base("foo") {} | |
} | |
public class ChainToOther : Base | |
{ | |
public ChainToOther(string s) : this(s, -1) {} | |
public ChainToOther(string s, int i) : base(s) {} | |
} | |
public static class Client | |
{ | |
public static void Main() | |
{ | |
new ChainToBase(); | |
new ChainToOther("foo"); | |
} | |
} | |
// becomes | |
package { | |
import System.CLIObject; | |
public class Base extends CLIObject { | |
protected function Base_Constructor(msg: String): void { | |
} | |
} | |
public class ChainToBase extends Base { | |
protected function ChainToBase_Constructor(): void { | |
Base_Constructor("foo"); | |
} | |
public static function New(): ChainToBase { | |
var instance: ChainToBase = new ChainToBase(); | |
instance.ChainToBase_Constructor(); | |
return instance; | |
} | |
} | |
public class ChainToOther extends Base { | |
protected function ChainToOther_Constructor_String(s: String): void { | |
ChainToOther_Constructor_String_Int32(s, -1); | |
} | |
protected function ChainToOther_Constructor_String_Int32(s: String, i: int): void { | |
Base_Constructor(s); | |
} | |
public static function New_String(s: String): ChainToOther { | |
var instance: ChainToOther = new ChainToOther(); | |
instance.ChainToOther_Constructor_String(s); | |
return instance; | |
} | |
public static function New_String_Int32(s: String, i: int): ChainToOther { | |
var instance: ChainToOther = new ChainToOther(); | |
instance.ChainToOther_Constructor_String_Int32(s, i); | |
return instance; | |
} | |
} | |
public final class Client extends CLIObject { | |
public static function Main() { | |
ChainToBase.New(); | |
ChainToOther.New_String("foo"); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment