mirror of
https://github.com/twiglet/cs2j.git
synced 2025-01-18 13:15:17 +01:00
Support casts
This commit is contained in:
parent
ce5f462672
commit
50cff4d439
@ -22,6 +22,27 @@ namespace cs2jTest.Various.Features
|
|||||||
set { _testWOProperty = value;}
|
set { _testWOProperty = value;}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static explicit operator Various(int i)
|
||||||
|
{
|
||||||
|
return new Various();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static implicit operator Various(string i)
|
||||||
|
{
|
||||||
|
return new Various();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static explicit operator bool(Various v)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static implicit operator string(Various v)
|
||||||
|
{
|
||||||
|
return "Various";
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -513,9 +513,22 @@ namespace RusticiSoftware.Translator.CLR
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: fix cast java
|
public override string[] mkImports() {
|
||||||
|
if (From == null || To == null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
return new string[] {"CS2JNet." + From.Substring(0, From.LastIndexOf('.'))};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public override string mkJava() {
|
public override string mkJava() {
|
||||||
return "/* FIXME Cast " + From + " to " + To + "*/";
|
if (From == null || To == null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
return From.Substring(From.LastIndexOf('.') + 1) + ".__cast_" + To.Replace('.','_') + "(${expr})";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#region Equality
|
#region Equality
|
||||||
@ -1356,7 +1369,6 @@ namespace RusticiSoftware.Translator.CLR
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Cast here? or in InterfaceRepT?
|
|
||||||
private List<CastRepTemplate> _casts = null;
|
private List<CastRepTemplate> _casts = null;
|
||||||
[XmlArrayItem("Cast")]
|
[XmlArrayItem("Cast")]
|
||||||
public List<CastRepTemplate> Casts {
|
public List<CastRepTemplate> Casts {
|
||||||
|
@ -157,6 +157,16 @@ namespace cs2j.Template.Utils
|
|||||||
fieldRep.Type = TypeHelper.buildTypeName(f.FieldType);
|
fieldRep.Type = TypeHelper.buildTypeName(f.FieldType);
|
||||||
klass.Fields.Add(fieldRep);
|
klass.Fields.Add(fieldRep);
|
||||||
}
|
}
|
||||||
|
// Grab Casts
|
||||||
|
foreach (MethodInfo m in t.GetMethods(BindingFlags.DeclaredOnly | BindingFlags.Public | BindingFlags.Static )) {
|
||||||
|
if (m.IsSpecialName && (m.Name == "op_Explicit" || m.Name == "op_Implicit")) {
|
||||||
|
CastRepTemplate cast = new CastRepTemplate();
|
||||||
|
cast.To = TypeHelper.buildTypeName(m.ReturnType);
|
||||||
|
cast.From = TypeHelper.buildTypeName(m.GetParameters()[0].ParameterType);
|
||||||
|
klass.Casts.Add(cast);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user