Implemented initial support for class properties.
This commit is contained in:
Родитель
3b115f4629
Коммит
45376532dc
|
@ -151,8 +151,8 @@ namespace MonoManagedToNative.Generators
|
||||||
|
|
||||||
foreach (var property in type.DeclaredProperties)
|
foreach (var property in type.DeclaredProperties)
|
||||||
{
|
{
|
||||||
//var decl = VisitProperty(property);
|
var decl = VisitProperty(property, @class);
|
||||||
//@class.Declarations.Add(decl);
|
@class.Declarations.Add(decl);
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach (var decl in @class.Declarations)
|
foreach (var decl in @class.Declarations)
|
||||||
|
@ -510,9 +510,21 @@ namespace MonoManagedToNative.Generators
|
||||||
throw new NotImplementedException();
|
throw new NotImplementedException();
|
||||||
}
|
}
|
||||||
|
|
||||||
public Property VisitProperty(PropertyInfo @property)
|
public Property VisitProperty(PropertyInfo propertyInfo, Class @class)
|
||||||
{
|
{
|
||||||
throw new NotImplementedException();
|
var property = new Property()
|
||||||
|
{
|
||||||
|
Name = UnmangleTypeName(propertyInfo.Name),
|
||||||
|
QualifiedType = VisitType(propertyInfo.PropertyType),
|
||||||
|
};
|
||||||
|
|
||||||
|
if (propertyInfo.GetMethod != null)
|
||||||
|
property.GetMethod = VisitMethod(propertyInfo.GetMethod, @class);
|
||||||
|
|
||||||
|
if (propertyInfo.SetMethod != null)
|
||||||
|
property.SetMethod = VisitMethod(propertyInfo.SetMethod, @class);
|
||||||
|
|
||||||
|
return property;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -236,7 +236,7 @@ namespace MonoManagedToNative.Generators
|
||||||
|
|
||||||
public virtual bool VisitProperty(Property property)
|
public virtual bool VisitProperty(Property property)
|
||||||
{
|
{
|
||||||
throw new NotImplementedException();
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public virtual bool VisitTemplateParameterDecl(TypeTemplateParameter templateParameter)
|
public virtual bool VisitTemplateParameterDecl(TypeTemplateParameter templateParameter)
|
||||||
|
|
|
@ -46,6 +46,15 @@ TEST_CASE("BuiltinTypes", "[BuiltinTypes]") {
|
||||||
REQUIRE(strcmp(RefStr->str, "Mono") == 0);
|
REQUIRE(strcmp(RefStr->str, "Mono") == 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TEST_CASE("ClassTypes", "[ClassTypes]") {
|
||||||
|
ClassProperties* prop = ClassProperties_new();
|
||||||
|
REQUIRE(ClassProperties_get_Int(prop) == 0);
|
||||||
|
ClassProperties_set_Int(prop, 10);
|
||||||
|
REQUIRE(ClassProperties_get_Int(prop) == 10);
|
||||||
|
|
||||||
|
REQUIRE(ClassProperties_get_ReadOnlyInt(prop) == 0);
|
||||||
|
}
|
||||||
|
|
||||||
TEST_CASE("StaticTypes", "[StaticTypes]") {
|
TEST_CASE("StaticTypes", "[StaticTypes]") {
|
||||||
REQUIRE(NonStaticClass_StaticMethod() == 0);
|
REQUIRE(NonStaticClass_StaticMethod() == 0);
|
||||||
REQUIRE(StaticClass_StaticMethod() == 0);
|
REQUIRE(StaticClass_StaticMethod() == 0);
|
||||||
|
|
|
@ -83,6 +83,12 @@ public static class EnumTypes
|
||||||
|
|
||||||
#region Classes
|
#region Classes
|
||||||
|
|
||||||
|
public class ClassProperties
|
||||||
|
{
|
||||||
|
public int Int { get; set; }
|
||||||
|
public int ReadOnlyInt { get; }
|
||||||
|
}
|
||||||
|
|
||||||
public class NonStaticClass
|
public class NonStaticClass
|
||||||
{
|
{
|
||||||
public static int StaticMethod() { return 0; }
|
public static int StaticMethod() { return 0; }
|
||||||
|
|
Загрузка…
Ссылка в новой задаче