Skip to content

Commit 6d161a2

Browse files
atsushienojonpryor
authored andcommitted
[generator] Java RawJavaType (return type) should return int, not enum for C#. (#68)
There was inconsistency between jar2xml and class-parse + api-xml-adjuster where the latter failed to retrieve valid return type when it was enumified. (Found during new api-merge support experiment.)
1 parent 5badc2e commit 6d161a2

File tree

2 files changed

+13
-5
lines changed

2 files changed

+13
-5
lines changed

tools/generator/Method.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ public ManagedMethod (GenBase declaringType, MethodDefinition m)
3737
foreach (var p in support.GetParameters (regatt))
3838
Parameters.Add (p);
3939

40-
if (regatt != null && !IsReturnEnumified) {
40+
if (regatt != null) {
4141
var rt = support.GetJniReturnType (regatt);
4242
if (rt != null)
4343
java_return = rt.Type;
@@ -271,7 +271,7 @@ protected Method (GenBase declaringType, IMethodBaseSupport support)
271271

272272
internal void FillReturnType ()
273273
{
274-
retval = new ReturnValue (this, Return, ManagedReturn);
274+
retval = new ReturnValue (this, Return, ManagedReturn, IsReturnEnumified);
275275
}
276276

277277
public bool GenerateDispatchingSetter { get; protected set; }

tools/generator/ReturnValue.cs

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,14 @@ public class ReturnValue {
1212
ISymbol sym;
1313
string java_type;
1414
string managed_type;
15+
string raw_type;
16+
bool is_enumified;
1517

16-
public ReturnValue (Method owner, string java_type, string managed_type)
18+
public ReturnValue (Method owner, string java_type, string managed_type, bool isEnumified)
1719
{
18-
this.java_type = java_type;
20+
this.raw_type = this.java_type = java_type;
1921
this.managed_type = managed_type;
22+
this.is_enumified = isEnumified;
2023
}
2124

2225
public string CallMethodPrefix {
@@ -44,6 +47,7 @@ public string FullName {
4447
public void SetGeneratedEnumType (string enumType)
4548
{
4649
sym = new GeneratedEnumSymbol (enumType);
50+
is_enumified = true;
4751
managed_type = null;
4852
java_type = sym.JavaName;
4953
}
@@ -61,6 +65,10 @@ public bool IsArray {
6165
get { return sym.IsArray; }
6266
}
6367

68+
public bool IsEnumified {
69+
get { return is_enumified; }
70+
}
71+
6472
public bool IsGeneric {
6573
get { return sym is GenericSymbol ? !(sym as GenericSymbol).IsConcrete : !string.IsNullOrEmpty (sym.GetGenericType (null)); }
6674
}
@@ -78,7 +86,7 @@ public string NativeType {
7886
}
7987

8088
public string RawJavaType {
81-
get { return java_type; }
89+
get { return raw_type; }
8290
}
8391

8492
public string FromNative (CodeGenerationOptions opt, string var_name, bool owned)

0 commit comments

Comments
 (0)