[generator] Remove support for Classic bindings. Partial fix for #6300. (#6643)

Partial fix for https://github.com/xamarin/xamarin-macios/issues/6300.
This commit is contained in:
Rolf Bjarne Kvinge 2019-07-24 09:01:40 -07:00 коммит произвёл GitHub
Родитель 6075a9aa5b
Коммит 6f19d734b7
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
7 изменённых файлов: 100 добавлений и 382 удалений

Просмотреть файл

@ -28,7 +28,6 @@ IOS_TARGETS_DIRS += \
$(IOS_DESTDIR)$(MONOTOUCH_PREFIX)/lib/bgen \ $(IOS_DESTDIR)$(MONOTOUCH_PREFIX)/lib/bgen \
IOS_TARGETS += \ IOS_TARGETS += \
$(IOS_DESTDIR)$(MONOTOUCH_PREFIX)/lib/bgen/monotouch.BindingAttributes.dll \
$(IOS_DESTDIR)$(MONOTOUCH_PREFIX)/lib/bgen/Xamarin.iOS.BindingAttributes.dll \ $(IOS_DESTDIR)$(MONOTOUCH_PREFIX)/lib/bgen/Xamarin.iOS.BindingAttributes.dll \
$(IOS_DESTDIR)$(MONOTOUCH_PREFIX)/lib/bgen/bgen.exe \ $(IOS_DESTDIR)$(MONOTOUCH_PREFIX)/lib/bgen/bgen.exe \
$(IOS_DESTDIR)$(MONOTOUCH_PREFIX)/bin/bgen \ $(IOS_DESTDIR)$(MONOTOUCH_PREFIX)/bin/bgen \
@ -61,10 +60,6 @@ $(IOS_BUILD_DIR)/native/Xamarin.iOS.BindingAttributes.dll: generator-attributes.
$(Q) mkdir -p $(dir $@) $(Q) mkdir -p $(dir $@)
$(Q_GEN) $(SYSTEM_CSC) -nologo -out:$@ -debug generator-attributes.cs -target:library -deterministic $(Q_GEN) $(SYSTEM_CSC) -nologo -out:$@ -debug generator-attributes.cs -target:library -deterministic
$(IOS_BUILD_DIR)/native/monotouch.BindingAttributes.dll: generator-attributes.cs Makefile.generator
$(Q) mkdir -p $(dir $@)
$(Q_GEN) $(SYSTEM_CSC) -nologo -debug -out:$@ -debug generator-attributes.cs -target:library -deterministic
# #
# Xamarin.Watch (bwatch) # Xamarin.Watch (bwatch)
# #
@ -166,7 +161,6 @@ bgen: \
$(MAC_DESTDIR)$(MAC_FRAMEWORK_CURRENT_DIR)/lib/bgen/bgen.exe \ $(MAC_DESTDIR)$(MAC_FRAMEWORK_CURRENT_DIR)/lib/bgen/bgen.exe \
$(MAC_DESTDIR)$(MAC_FRAMEWORK_CURRENT_DIR)/lib/bgen/Xamarin.Mac-full.BindingAttributes.dll \ $(MAC_DESTDIR)$(MAC_FRAMEWORK_CURRENT_DIR)/lib/bgen/Xamarin.Mac-full.BindingAttributes.dll \
$(MAC_DESTDIR)$(MAC_FRAMEWORK_CURRENT_DIR)/lib/bgen/Xamarin.Mac-mobile.BindingAttributes.dll \ $(MAC_DESTDIR)$(MAC_FRAMEWORK_CURRENT_DIR)/lib/bgen/Xamarin.Mac-mobile.BindingAttributes.dll \
$(IOS_DESTDIR)$(MONOTOUCH_PREFIX)/lib/bgen/monotouch.BindingAttributes.dll \
$(IOS_DESTDIR)$(MONOTOUCH_PREFIX)/lib/bgen/Xamarin.iOS.BindingAttributes.dll \ $(IOS_DESTDIR)$(MONOTOUCH_PREFIX)/lib/bgen/Xamarin.iOS.BindingAttributes.dll \
$(IOS_DESTDIR)$(MONOTOUCH_PREFIX)/lib/bgen/Xamarin.TVOS.BindingAttributes.dll \ $(IOS_DESTDIR)$(MONOTOUCH_PREFIX)/lib/bgen/Xamarin.TVOS.BindingAttributes.dll \
$(IOS_DESTDIR)$(MONOTOUCH_PREFIX)/lib/bgen/Xamarin.WatchOS.BindingAttributes.dll \ $(IOS_DESTDIR)$(MONOTOUCH_PREFIX)/lib/bgen/Xamarin.WatchOS.BindingAttributes.dll \

Просмотреть файл

@ -92,12 +92,6 @@ namespace ObjCRuntime
case "nint": case "nint":
case "nuint": case "nuint":
case "nfloat": case "nfloat":
#if BGENERATOR
var isUnified = generator.UnifiedAPI;
#endif
if (!isUnified)
return false;
if (t.Namespace != "System") if (t.Namespace != "System")
return false; return false;
#if BGENERATOR #if BGENERATOR
@ -208,12 +202,6 @@ namespace ObjCRuntime
public static bool X86_64NeedStret (Type returnType, Generator generator) public static bool X86_64NeedStret (Type returnType, Generator generator)
{ {
#if BGENERATOR
var isUnified = generator.UnifiedAPI;
#endif
if (!isUnified)
return false;
Type t = returnType; Type t = returnType;
if (!t.IsValueType || t.IsEnum || IsMagicTypeOrCorlibType (t, generator)) if (!t.IsValueType || t.IsEnum || IsMagicTypeOrCorlibType (t, generator))

Просмотреть файл

@ -1,68 +0,0 @@
#!/bin/bash
sdk=
bmac=
new_style=
refs=
full_profile=
mobile_profile=
mono=/Library/Frameworks/Mono.framework/Versions/Current/bin/mono
BMAC_DIR=`dirname $0`
if [ `basename $BMAC_DIR` == "Commands" ]; then
BMAC_DIR="`dirname $BMAC_DIR`/Versions/Current/bin"
fi
ROOT_DIR=$BMAC_DIR/..
btouch_arguments=()
for arg in "$@"; do
if [[ $sdk == next-arg ]]; then
sdk=$arg
elif [[ $arg =~ ^(/|-{1,2})sdk ]]; then
sdk=${arg#*=}; sdk=${sdk#*:}
if [[ $sdk == $arg ]]; then
sdk=next-arg
fi
elif [[ $arg =~ ^(/|-{1,2})new-style$ ]]; then
new_style=1
mobile_profile=1
continue
elif [[ $arg =~ ^(/|-{1,2})unified-full-profile$ ]]; then
full_profile=1
new_style=1
elif [[ $arg =~ ^(/|-{1,2})unified-mobile-profile$ ]]; then
mobile_profile=1
new_style=1
fi
btouch_arguments+=("${arg}")
done
sdk=$(echo $sdk | tr '[:upper:]' '[:lower:]')
case $sdk in
mobile|xamarin.mac|xammac)
bmac="bmac-mobile.exe -no-mono-path"
mono=/Library/Frameworks/Mono.framework/Commands/mono
export MONO_PATH=$ROOT_DIR/lib/mono/Xamarin.Mac
;;
*)
if [[ -z "$new_style" ]]; then
bmac=bmac-compat.exe
refs="-r:/Library/Frameworks/Mono.framework/Versions/Current/lib/mono/4.5/System.Drawing.dll -baselib:$ROOT_DIR/lib/mono/XamMac.dll --target-framework=XamMac,v1.0"
export MONO_PATH=$ROOT_DIR/lib/mono
else
if [[ "$full_profile" -eq 1 ]]; then
refs="-baselib:$ROOT_DIR/lib/reference/full/Xamarin.Mac.dll --target-framework=Xamarin.Mac,Version=v4.5,Profile=Full"
bmac=bmac-full.exe
export MONO_PATH=$ROOT_DIR/lib/reference/full
elif [[ "$mobile_profile" -eq 1 ]]; then
refs="-baselib:$ROOT_DIR/lib/reference/mobile/Xamarin.Mac.dll --target-framework=Xamarin.Mac,Version=v2.0,Profile=Mobile"
bmac=bmac-mobile.exe
export MONO_PATH=$ROOT_DIR/lib/mono/Xamarin.Mac
fi
fi
;;
esac
$mono $MONO_OPTIONS $ROOT_DIR/lib/bmac/$bmac $refs "${btouch_arguments[@]}"

Просмотреть файл

@ -42,7 +42,6 @@ public class BindingTouch {
TargetFramework? target_framework; TargetFramework? target_framework;
public PlatformName CurrentPlatform; public PlatformName CurrentPlatform;
public bool BindThirdPartyLibrary = true; public bool BindThirdPartyLibrary = true;
public bool Unified;
public bool skipSystemDrawing; public bool skipSystemDrawing;
public string outfile; public string outfile;
@ -89,11 +88,7 @@ public class BindingTouch {
switch (CurrentPlatform) { switch (CurrentPlatform) {
case PlatformName.iOS: case PlatformName.iOS:
if (Unified) { return Path.Combine (GetSDKRoot (), "lib", "bgen", "Xamarin.iOS.BindingAttributes.dll");
return Path.Combine (GetSDKRoot (), "lib", "bgen", "Xamarin.iOS.BindingAttributes.dll");
} else {
return Path.Combine (GetSDKRoot (), "lib", "bgen", "monotouch.BindingAttributes.dll");
}
case PlatformName.WatchOS: case PlatformName.WatchOS:
return Path.Combine (GetSDKRoot (), "lib", "bgen", "Xamarin.WatchOS.BindingAttributes.dll"); return Path.Combine (GetSDKRoot (), "lib", "bgen", "Xamarin.WatchOS.BindingAttributes.dll");
case PlatformName.TvOS: case PlatformName.TvOS:
@ -117,7 +112,7 @@ public class BindingTouch {
{ {
switch (CurrentPlatform) { switch (CurrentPlatform) {
case PlatformName.iOS: case PlatformName.iOS:
yield return Path.Combine (GetSDKRoot (), "lib", "mono", Unified ? "Xamarin.iOS" : "2.1"); yield return Path.Combine (GetSDKRoot (), "lib", "mono", "Xamarin.iOS");
break; break;
case PlatformName.WatchOS: case PlatformName.WatchOS:
yield return Path.Combine (GetSDKRoot (), "lib", "mono", "Xamarin.WatchOS"); yield return Path.Combine (GetSDKRoot (), "lib", "mono", "Xamarin.WatchOS");
@ -195,20 +190,6 @@ public class BindingTouch {
throw ErrorHelper.CreateError (70, "Invalid target framework: {0}. Valid target frameworks are: {1}.", target_framework.Value, string.Join (" ", TargetFramework.ValidFrameworks.Select ((v) => v.ToString ()).ToArray ())); throw ErrorHelper.CreateError (70, "Invalid target framework: {0}. Valid target frameworks are: {1}.", target_framework.Value, string.Join (" ", TargetFramework.ValidFrameworks.Select ((v) => v.ToString ()).ToArray ()));
} }
public string NamespacePlatformPrefix {
get {
switch (CurrentPlatform) {
case PlatformName.MacOSX:
return Unified ? null : "MonoMac";
case PlatformName.iOS:
return Unified ? null : "MonoTouch";
default:
return null;
}
}
}
static int Main2 (string [] args) static int Main2 (string [] args)
{ {
var touch = new BindingTouch (); var touch = new BindingTouch ();
@ -340,18 +321,8 @@ public class BindingTouch {
throw ErrorHelper.CreateError (86, "A target framework (--target-framework) must be specified."); throw ErrorHelper.CreateError (86, "A target framework (--target-framework) must be specified.");
switch (target_framework.Value.Identifier.ToLowerInvariant ()) { switch (target_framework.Value.Identifier.ToLowerInvariant ()) {
case "monotouch":
CurrentPlatform = PlatformName.iOS;
Unified = false;
if (string.IsNullOrEmpty (baselibdll))
baselibdll = Path.Combine (GetSDKRoot (), "lib/mono/2.1/monotouch.dll");
Path.Combine (GetSDKRoot (), "bin/smcs");
references.Add ("Facades/System.Drawing.Common");
ReferenceFixer.FixSDKReferences (GetSDKRoot (), "lib/mono/2.1/", references);
break;
case "xamarin.ios": case "xamarin.ios":
CurrentPlatform = PlatformName.iOS; CurrentPlatform = PlatformName.iOS;
Unified = true;
nostdlib = true; nostdlib = true;
if (string.IsNullOrEmpty (baselibdll)) if (string.IsNullOrEmpty (baselibdll))
baselibdll = Path.Combine (GetSDKRoot (), "lib/mono/Xamarin.iOS/Xamarin.iOS.dll"); baselibdll = Path.Combine (GetSDKRoot (), "lib/mono/Xamarin.iOS/Xamarin.iOS.dll");
@ -360,7 +331,6 @@ public class BindingTouch {
break; break;
case "xamarin.tvos": case "xamarin.tvos":
CurrentPlatform = PlatformName.TvOS; CurrentPlatform = PlatformName.TvOS;
Unified = true;
nostdlib = true; nostdlib = true;
if (string.IsNullOrEmpty (baselibdll)) if (string.IsNullOrEmpty (baselibdll))
baselibdll = Path.Combine (GetSDKRoot (), "lib/mono/Xamarin.TVOS/Xamarin.TVOS.dll"); baselibdll = Path.Combine (GetSDKRoot (), "lib/mono/Xamarin.TVOS/Xamarin.TVOS.dll");
@ -369,24 +339,14 @@ public class BindingTouch {
break; break;
case "xamarin.watchos": case "xamarin.watchos":
CurrentPlatform = PlatformName.WatchOS; CurrentPlatform = PlatformName.WatchOS;
Unified = true;
nostdlib = true; nostdlib = true;
if (string.IsNullOrEmpty (baselibdll)) if (string.IsNullOrEmpty (baselibdll))
baselibdll = Path.Combine (GetSDKRoot (), "lib/mono/Xamarin.WatchOS/Xamarin.WatchOS.dll"); baselibdll = Path.Combine (GetSDKRoot (), "lib/mono/Xamarin.WatchOS/Xamarin.WatchOS.dll");
references.Add ("Facades/System.Drawing.Common"); references.Add ("Facades/System.Drawing.Common");
ReferenceFixer.FixSDKReferences (GetSDKRoot (), "lib/mono/Xamarin.WatchOS", references); ReferenceFixer.FixSDKReferences (GetSDKRoot (), "lib/mono/Xamarin.WatchOS", references);
break; break;
case "xammac":
CurrentPlatform = PlatformName.MacOSX;
Unified = false;
if (string.IsNullOrEmpty (baselibdll))
baselibdll = Path.Combine (GetSDKRoot (), "lib", "mono", "XamMac.dll");
references.Add ("Facades/System.Drawing.Common");
ReferenceFixer.FixSDKReferences ("/Library/Frameworks/Mono.framework/Versions/Current/lib/mono/4.5", references);
break;
case "xamarin.mac": case "xamarin.mac":
CurrentPlatform = PlatformName.MacOSX; CurrentPlatform = PlatformName.MacOSX;
Unified = true;
nostdlib = true; nostdlib = true;
if (string.IsNullOrEmpty (baselibdll)) { if (string.IsNullOrEmpty (baselibdll)) {
if (target_framework == TargetFramework.Xamarin_Mac_2_0_Mobile) if (target_framework == TargetFramework.Xamarin_Mac_2_0_Mobile)
@ -555,7 +515,6 @@ public class BindingTouch {
var nsManager = new NamespaceManager ( var nsManager = new NamespaceManager (
this, this,
NamespacePlatformPrefix,
ns == null ? firstApiDefinitionName : ns, ns == null ? firstApiDefinitionName : ns,
skipSystemDrawing skipSystemDrawing
); );
@ -563,16 +522,9 @@ public class BindingTouch {
var g = new Generator (this, nsManager, public_mode, external, debug, types.ToArray (), strong_dictionaries.ToArray ()){ var g = new Generator (this, nsManager, public_mode, external, debug, types.ToArray (), strong_dictionaries.ToArray ()){
BaseDir = basedir != null ? basedir : tmpdir, BaseDir = basedir != null ? basedir : tmpdir,
ZeroCopyStrings = zero_copy, ZeroCopyStrings = zero_copy,
InlineSelectors = inline_selectors ?? (Unified && CurrentPlatform != PlatformName.MacOSX), InlineSelectors = inline_selectors ?? (CurrentPlatform != PlatformName.MacOSX),
}; };
if (!Unified && !BindThirdPartyLibrary) {
foreach (var mi in baselib.GetType (nsManager.CoreObjCRuntime + ".Messaging").GetMethods ()){
if (mi.Name.IndexOf ("_objc_msgSend", StringComparison.Ordinal) != -1)
g.RegisterMethodName (mi.Name);
}
}
g.Go (); g.Go ();
if (generate_file_list != null){ if (generate_file_list != null){

Просмотреть файл

@ -41,12 +41,7 @@ public class AttributeManager
throw ErrorHelper.CreateError (1061, $"The attribute '{type.FullName}' found on '{Generator.FormatProvider (provider)}' is not a valid binding attribute. Please remove this attribute."); throw ErrorHelper.CreateError (1061, $"The attribute '{type.FullName}' found on '{Generator.FormatProvider (provider)}' is not a valid binding attribute. Please remove this attribute.");
} }
var prefix = BindingTouch.NamespacePlatformPrefix; rv = typeof (TypeManager).Assembly.GetType (type.FullName);
var n = type.FullName;
if (!string.IsNullOrEmpty (prefix) && type.Namespace.StartsWith (prefix, System.StringComparison.Ordinal)) {
n = n.Substring (prefix.Length + 1);
}
rv = typeof (TypeManager).Assembly.GetType (n);
} else { } else {
throw ErrorHelper.CreateError (1054, "Internal error: can't convert type '{0}' (unknown assembly). Please file a bug report (https://github.com/xamarin/xamarin-macios/issues/new) with a test case.", type.AssemblyQualifiedName); throw ErrorHelper.CreateError (1054, "Internal error: can't convert type '{0}' (unknown assembly). Please file a bug report (https://github.com/xamarin/xamarin-macios/issues/new) with a test case.", type.AssemblyQualifiedName);
} }
@ -72,12 +67,7 @@ public class AttributeManager
string fullname; string fullname;
// HACK ?? // HACK ??
if (type.Namespace?.StartsWith ("XamCore.", System.StringComparison.Ordinal) == true) { if (type.Namespace?.StartsWith ("XamCore.", System.StringComparison.Ordinal) == true) {
var prefix = BindingTouch.NamespacePlatformPrefix; fullname = type.FullName.Substring (8);
if (!string.IsNullOrEmpty (prefix)) {
fullname = prefix + "." + type.FullName.Substring (8);
} else {
fullname = type.FullName.Substring (8);
}
} else { } else {
fullname = type.FullName; fullname = type.FullName;
} }

Просмотреть файл

@ -137,18 +137,11 @@ public class TypeManager {
Type Lookup (Assembly assembly, string @namespace, string @typename, bool inexistentOK = false) Type Lookup (Assembly assembly, string @namespace, string @typename, bool inexistentOK = false)
{ {
string fullname; string fullname;
string nsManagerPrefix = null;
if (assembly == platform_assembly || assembly == api_assembly)
nsManagerPrefix = BindingTouch.NamespacePlatformPrefix;
if (!string.IsNullOrEmpty (nsManagerPrefix))
nsManagerPrefix += ".";
if (string.IsNullOrEmpty (@namespace)) { if (string.IsNullOrEmpty (@namespace)) {
fullname = nsManagerPrefix + @typename; fullname = @typename;
} else { } else {
fullname = nsManagerPrefix + @namespace + "." + @typename; fullname = @namespace + "." + @typename;
} }
var rv = assembly.GetType (fullname); var rv = assembly.GetType (fullname);
@ -215,11 +208,9 @@ public class TypeManager {
System_UInt64 = Lookup (corlib_assembly, "System", "UInt64"); System_UInt64 = Lookup (corlib_assembly, "System", "UInt64");
System_Void = Lookup (corlib_assembly, "System", "Void"); System_Void = Lookup (corlib_assembly, "System", "Void");
if (BindingTouch.Unified) { System_nint = Lookup (platform_assembly, "System", "nint");
System_nint = Lookup (platform_assembly, "System", "nint"); System_nuint = Lookup (platform_assembly, "System", "nuint");
System_nuint = Lookup (platform_assembly, "System", "nuint"); System_nfloat = Lookup (platform_assembly, "System", "nfloat");
System_nfloat = Lookup (platform_assembly, "System", "nfloat");
}
/* fundamental */ /* fundamental */
NSObject = Lookup (platform_assembly, "Foundation", "NSObject"); NSObject = Lookup (platform_assembly, "Foundation", "NSObject");
@ -231,11 +222,7 @@ public class TypeManager {
Protocol = Lookup (platform_assembly, "ObjCRuntime", "Protocol"); Protocol = Lookup (platform_assembly, "ObjCRuntime", "Protocol");
Selector = Lookup (platform_assembly, "ObjCRuntime", "Selector"); Selector = Lookup (platform_assembly, "ObjCRuntime", "Selector");
if (BindingTouch.Unified) { Constants = Lookup (platform_assembly, "ObjCRuntime", "Constants");
Constants = Lookup (platform_assembly, "ObjCRuntime", "Constants");
} else {
Constants = Lookup (platform_assembly, "", "Constants");
}
/* Different binding types */ /* Different binding types */
@ -323,10 +310,8 @@ public class TypeManager {
NSDirectionalEdgeInsets = Lookup (platform_assembly, "UIKit", "NSDirectionalEdgeInsets"); NSDirectionalEdgeInsets = Lookup (platform_assembly, "UIKit", "NSDirectionalEdgeInsets");
} }
if (BindingTouch.Unified) { CoreGraphics_CGRect = Lookup (platform_assembly, "CoreGraphics", "CGRect");
CoreGraphics_CGRect = Lookup (platform_assembly, "CoreGraphics", "CGRect"); CoreGraphics_CGPoint = Lookup (platform_assembly, "CoreGraphics", "CGPoint");
CoreGraphics_CGPoint = Lookup (platform_assembly, "CoreGraphics", "CGPoint"); CoreGraphics_CGSize = Lookup (platform_assembly, "CoreGraphics", "CGSize");
CoreGraphics_CGSize = Lookup (platform_assembly, "CoreGraphics", "CGSize");
}
} }
} }

Просмотреть файл

@ -149,24 +149,24 @@ public static class ReflectionExtensions {
public static bool IsInternal (this MemberInfo mi, Generator generator) public static bool IsInternal (this MemberInfo mi, Generator generator)
{ {
return generator.AttributeManager.HasAttribute<InternalAttribute> (mi) return generator.AttributeManager.HasAttribute<InternalAttribute> (mi)
|| (generator.UnifiedAPI && generator.AttributeManager.HasAttribute<UnifiedInternalAttribute> (mi)); || (generator.AttributeManager.HasAttribute<UnifiedInternalAttribute> (mi));
} }
public static bool IsUnifiedInternal (this MemberInfo mi, Generator generator) public static bool IsUnifiedInternal (this MemberInfo mi, Generator generator)
{ {
return (generator.UnifiedAPI && generator.AttributeManager.HasAttribute<UnifiedInternalAttribute> (mi)); return (generator.AttributeManager.HasAttribute<UnifiedInternalAttribute> (mi));
} }
public static bool IsInternal (this PropertyInfo pi, Generator generator) public static bool IsInternal (this PropertyInfo pi, Generator generator)
{ {
return generator.AttributeManager.HasAttribute<InternalAttribute> (pi) return generator.AttributeManager.HasAttribute<InternalAttribute> (pi)
|| (generator.UnifiedAPI && generator.AttributeManager.HasAttribute<UnifiedInternalAttribute> (pi)); || (generator.AttributeManager.HasAttribute<UnifiedInternalAttribute> (pi));
} }
public static bool IsInternal (this Type type, Generator generator) public static bool IsInternal (this Type type, Generator generator)
{ {
return generator.AttributeManager.HasAttribute<InternalAttribute> (type) return generator.AttributeManager.HasAttribute<InternalAttribute> (type)
|| (generator.UnifiedAPI && generator.AttributeManager.HasAttribute<UnifiedInternalAttribute> (type)); || (generator.AttributeManager.HasAttribute<UnifiedInternalAttribute> (type));
} }
public static List <MethodInfo> GatherMethods (this Type type, BindingFlags flags, Generator generator) { public static List <MethodInfo> GatherMethods (this Type type, BindingFlags flags, Generator generator) {
@ -478,7 +478,7 @@ public class MemberInformation
is_abstract = AttributeManager.HasAttribute<AbstractAttribute> (mi) && mi.DeclaringType == type; is_abstract = AttributeManager.HasAttribute<AbstractAttribute> (mi) && mi.DeclaringType == type;
is_protected = AttributeManager.HasAttribute<ProtectedAttribute> (mi); is_protected = AttributeManager.HasAttribute<ProtectedAttribute> (mi);
is_internal = mi.IsInternal (generator); is_internal = mi.IsInternal (generator);
is_unified_internal = (Generator.UnifiedAPI && AttributeManager.HasAttribute<UnifiedInternalAttribute> (mi)); is_unified_internal = AttributeManager.HasAttribute<UnifiedInternalAttribute> (mi);
is_override = AttributeManager.HasAttribute<OverrideAttribute> (mi) || !Generator.MemberBelongsToType (mi.DeclaringType, type); is_override = AttributeManager.HasAttribute<OverrideAttribute> (mi) || !Generator.MemberBelongsToType (mi.DeclaringType, type);
is_new = AttributeManager.HasAttribute<NewAttribute> (mi); is_new = AttributeManager.HasAttribute<NewAttribute> (mi);
is_sealed = AttributeManager.HasAttribute<SealedAttribute> (mi); is_sealed = AttributeManager.HasAttribute<SealedAttribute> (mi);
@ -649,11 +649,8 @@ public class NamespaceManager
{ {
public BindingTouch BindingTouch; public BindingTouch BindingTouch;
PlatformName CurrentPlatform { get { return BindingTouch.CurrentPlatform; } } PlatformName CurrentPlatform { get { return BindingTouch.CurrentPlatform; } }
bool UnifiedAPI { get { return BindingTouch.Unified; } }
Frameworks Frameworks { get { return BindingTouch.Frameworks; } } Frameworks Frameworks { get { return BindingTouch.Frameworks; } }
public string Prefix { get; private set; }
// Where the core messaging lives // Where the core messaging lives
public string CoreObjCRuntime { get; private set; } public string CoreObjCRuntime { get; private set; }
@ -667,10 +664,9 @@ public class NamespaceManager
public ICollection<string> ImplicitNamespaces { get; private set; } public ICollection<string> ImplicitNamespaces { get; private set; }
public ICollection<string> NamespacesThatConflictWithTypes { get; private set; } public ICollection<string> NamespacesThatConflictWithTypes { get; private set; }
public NamespaceManager (BindingTouch binding_touch, string prefix, string customObjCRuntimeNS, bool skipSystemDrawing) public NamespaceManager (BindingTouch binding_touch, string customObjCRuntimeNS, bool skipSystemDrawing)
{ {
BindingTouch = binding_touch; BindingTouch = binding_touch;
Prefix = prefix;
CoreObjCRuntime = Get ("ObjCRuntime"); CoreObjCRuntime = Get ("ObjCRuntime");
ObjCRuntime = String.IsNullOrEmpty (customObjCRuntimeNS) ObjCRuntime = String.IsNullOrEmpty (customObjCRuntimeNS)
@ -728,7 +724,7 @@ public class NamespaceManager
if (Frameworks.HaveAudioUnit) if (Frameworks.HaveAudioUnit)
ImplicitNamespaces.Add (Get ("AudioUnit")); ImplicitNamespaces.Add (Get ("AudioUnit"));
if (Frameworks.HaveContacts && UnifiedAPI) if (Frameworks.HaveContacts)
ImplicitNamespaces.Add (Get ("Contacts")); ImplicitNamespaces.Add (Get ("Contacts"));
if (Frameworks.HaveCoreAnimation) if (Frameworks.HaveCoreAnimation)
ImplicitNamespaces.Add (Get ("CoreAnimation")); ImplicitNamespaces.Add (Get ("CoreAnimation"));
@ -765,16 +761,16 @@ public class NamespaceManager
if (Frameworks.HaveAddressBook) if (Frameworks.HaveAddressBook)
ImplicitNamespaces.Add (Get ("AddressBook")); ImplicitNamespaces.Add (Get ("AddressBook"));
if (Frameworks.HaveModelIO && !(CurrentPlatform == PlatformName.MacOSX && !UnifiedAPI)) if (Frameworks.HaveModelIO)
ImplicitNamespaces.Add (Get ("ModelIO")); ImplicitNamespaces.Add (Get ("ModelIO"));
if (Frameworks.HaveMetal && !(CurrentPlatform == PlatformName.MacOSX && !UnifiedAPI)) if (Frameworks.HaveMetal)
ImplicitNamespaces.Add (Get ("Metal")); ImplicitNamespaces.Add (Get ("Metal"));
if (Frameworks.HaveCoreImage) if (Frameworks.HaveCoreImage)
ImplicitNamespaces.Add (Get ("CoreImage")); ImplicitNamespaces.Add (Get ("CoreImage"));
if (Frameworks.HavePhotos) if (Frameworks.HavePhotos)
ImplicitNamespaces.Add (Get ("Photos")); ImplicitNamespaces.Add (Get ("Photos"));
if (Frameworks.HaveMediaPlayer && UnifiedAPI) if (Frameworks.HaveMediaPlayer)
ImplicitNamespaces.Add (Get ("MediaPlayer")); ImplicitNamespaces.Add (Get ("MediaPlayer"));
if (Frameworks.HaveMessages) if (Frameworks.HaveMessages)
ImplicitNamespaces.Add (Get ("Messages")); ImplicitNamespaces.Add (Get ("Messages"));
@ -782,7 +778,7 @@ public class NamespaceManager
ImplicitNamespaces.Add (Get ("GameplayKit")); ImplicitNamespaces.Add (Get ("GameplayKit"));
if (Frameworks.HaveSpriteKit) if (Frameworks.HaveSpriteKit)
ImplicitNamespaces.Add (Get ("SpriteKit")); ImplicitNamespaces.Add (Get ("SpriteKit"));
if (Frameworks.HaveFileProvider && UnifiedAPI) if (Frameworks.HaveFileProvider)
ImplicitNamespaces.Add (Get ("FileProvider")); ImplicitNamespaces.Add (Get ("FileProvider"));
// These are both types and namespaces // These are both types and namespaces
@ -797,9 +793,7 @@ public class NamespaceManager
public string Get (string nsWithoutPrefix) public string Get (string nsWithoutPrefix)
{ {
if (String.IsNullOrEmpty (Prefix)) return nsWithoutPrefix;
return nsWithoutPrefix;
return Prefix + "." + nsWithoutPrefix;
} }
public string [] Get (IEnumerable<string> nsWithoutPrefix) public string [] Get (IEnumerable<string> nsWithoutPrefix)
@ -881,8 +875,6 @@ public partial class Generator : IMemberGatherer {
// //
Dictionary<string,MethodInfo> delegate_types = new Dictionary<string,MethodInfo> (); Dictionary<string,MethodInfo> delegate_types = new Dictionary<string,MethodInfo> ();
public bool Compat { get { return !UnifiedAPI; } }
public PlatformName CurrentPlatform { get { return BindingTouch.CurrentPlatform; } } public PlatformName CurrentPlatform { get { return BindingTouch.CurrentPlatform; } }
public string ApplicationClassName { public string ApplicationClassName {
@ -900,15 +892,12 @@ public partial class Generator : IMemberGatherer {
} }
} }
// Static version of the above (!Compat) field, set on each Go invocation, needed because some static
// helper methods need to access this. This is the exact opposite of Compat.
public bool UnifiedAPI { get { return BindingTouch.Unified; } }
public int XamcoreVersion { public int XamcoreVersion {
get { get {
switch (CurrentPlatform) { switch (CurrentPlatform) {
case PlatformName.MacOSX: case PlatformName.MacOSX:
case PlatformName.iOS: case PlatformName.iOS:
return UnifiedAPI ? 2 : 1; return 2;
case PlatformName.TvOS: case PlatformName.TvOS:
case PlatformName.WatchOS: case PlatformName.WatchOS:
return 3; return 3;
@ -1093,7 +1082,7 @@ public partial class Generator : IMemberGatherer {
t = TypeManager.GetUnderlyingEnumType (t); t = TypeManager.GetUnderlyingEnumType (t);
if (UnifiedAPI && AttributeManager.HasAttribute<NativeAttribute> (enumType)) { if (AttributeManager.HasAttribute<NativeAttribute> (enumType)) {
if (t != TypeManager.System_Int64 && t != TypeManager.System_UInt64) if (t != TypeManager.System_Int64 && t != TypeManager.System_UInt64)
throw new BindingException (1026, true, throw new BindingException (1026, true,
"`{0}`: Enums attributed with [{1}] must have an underlying type of `long` or `ulong`", "`{0}`: Enums attributed with [{1}] must have an underlying type of `long` or `ulong`",
@ -1307,11 +1296,9 @@ public partial class Generator : IMemberGatherer {
nsvalue_create_map [TypeManager.SCNVector3] = "Vector"; nsvalue_create_map [TypeManager.SCNVector3] = "Vector";
nsvalue_create_map [TypeManager.SCNVector4] = "Vector"; nsvalue_create_map [TypeManager.SCNVector4] = "Vector";
if (UnifiedAPI) { nsvalue_create_map [TypeManager.CoreGraphics_CGPoint] = "CGPoint";
nsvalue_create_map [TypeManager.CoreGraphics_CGPoint] = "CGPoint"; nsvalue_create_map [TypeManager.CoreGraphics_CGRect] = "CGRect";
nsvalue_create_map [TypeManager.CoreGraphics_CGRect] = "CGRect"; nsvalue_create_map [TypeManager.CoreGraphics_CGSize] = "CGSize";
nsvalue_create_map [TypeManager.CoreGraphics_CGSize] = "CGSize";
}
if (Frameworks.HaveUIKit) { if (Frameworks.HaveUIKit) {
nsvalue_create_map [TypeManager.UIEdgeInsets] = "UIEdgeInsets"; nsvalue_create_map [TypeManager.UIEdgeInsets] = "UIEdgeInsets";
@ -1432,11 +1419,9 @@ public partial class Generator : IMemberGatherer {
{ TypeManager.System_UInt32, ".UInt32Value" }, { TypeManager.System_UInt32, ".UInt32Value" },
{ TypeManager.System_UInt64, ".UInt64Value" }, { TypeManager.System_UInt64, ".UInt64Value" },
}; };
if (UnifiedAPI) { nsnumber_return_map [TypeManager.System_nfloat] = ".NFloatValue";
nsnumber_return_map [TypeManager.System_nfloat] = ".NFloatValue"; nsnumber_return_map [TypeManager.System_nint] = ".NIntValue";
nsnumber_return_map [TypeManager.System_nint] = ".NIntValue"; nsnumber_return_map [TypeManager.System_nuint] = ".NUIntValue";
nsnumber_return_map [TypeManager.System_nuint] = ".NUIntValue";
}
} }
return nsnumber_return_map; return nsnumber_return_map;
} }
@ -1456,11 +1441,9 @@ public partial class Generator : IMemberGatherer {
{ TypeManager.SCNVector4, ".Vector4Value" } { TypeManager.SCNVector4, ".Vector4Value" }
}; };
if (UnifiedAPI) { nsvalue_return_map [TypeManager.CoreGraphics_CGPoint] = ".CGPointValue";
nsvalue_return_map [TypeManager.CoreGraphics_CGPoint] = ".CGPointValue"; nsvalue_return_map [TypeManager.CoreGraphics_CGRect] = ".CGRectValue";
nsvalue_return_map [TypeManager.CoreGraphics_CGRect] = ".CGRectValue"; nsvalue_return_map [TypeManager.CoreGraphics_CGSize] = ".CGSizeValue";
nsvalue_return_map [TypeManager.CoreGraphics_CGSize] = ".CGSizeValue";
}
if (Frameworks.HaveUIKit) { if (Frameworks.HaveUIKit) {
nsvalue_return_map [TypeManager.UIEdgeInsets] = ".UIEdgeInsetsValue"; nsvalue_return_map [TypeManager.UIEdgeInsets] = ".UIEdgeInsetsValue";
@ -1669,7 +1652,7 @@ public partial class Generator : IMemberGatherer {
if (Frameworks.HaveAudioToolbox) { if (Frameworks.HaveAudioToolbox) {
if (pi.ParameterType == TypeManager.AudioBuffers){ if (pi.ParameterType == TypeManager.AudioBuffers){
pars.AppendFormat ("IntPtr {0}", pi.Name.GetSafeParamName ()); pars.AppendFormat ("IntPtr {0}", pi.Name.GetSafeParamName ());
invoke.AppendFormat ("new global::{0}AudioToolbox.AudioBuffers ({1})", UnifiedAPI ? "" : "MonoTouch.", pi.Name.GetSafeParamName ()); invoke.AppendFormat ("new global::AudioToolbox.AudioBuffers ({0})", pi.Name.GetSafeParamName ());
continue; continue;
} }
} }
@ -1716,7 +1699,7 @@ public partial class Generator : IMemberGatherer {
invoke.Append ($"ref {refname}"); invoke.Append ($"ref {refname}");
continue; continue;
} }
} else if (!Compat && IsNativeEnum (pi.ParameterType)) { } else if (IsNativeEnum (pi.ParameterType)) {
Type underlyingEnumType = TypeManager.GetUnderlyingEnumType (pi.ParameterType); Type underlyingEnumType = TypeManager.GetUnderlyingEnumType (pi.ParameterType);
pars.AppendFormat ("{0} {1}", GetNativeEnumType (pi.ParameterType), pi.Name.GetSafeParamName ()); pars.AppendFormat ("{0} {1}", GetNativeEnumType (pi.ParameterType), pi.Name.GetSafeParamName ());
invoke.AppendFormat ("({1}) ({2}) {0}", pi.Name.GetSafeParamName (), FormatType (null, pi.ParameterType), FormatType (null, underlyingEnumType)); invoke.AppendFormat ("({1}) ({2}) {0}", pi.Name.GetSafeParamName (), FormatType (null, pi.ParameterType), FormatType (null, underlyingEnumType));
@ -1819,7 +1802,7 @@ public partial class Generator : IMemberGatherer {
if (enum_mode != EnumMode.Compat && enum_mode != EnumMode.NativeBits && pi.ParameterType.IsEnum) if (enum_mode != EnumMode.Compat && enum_mode != EnumMode.NativeBits && pi.ParameterType.IsEnum)
return "(" + PrimitiveType (pi.ParameterType, enum_mode: enum_mode) + ")" + pi.Name.GetSafeParamName (); return "(" + PrimitiveType (pi.ParameterType, enum_mode: enum_mode) + ")" + pi.Name.GetSafeParamName ();
if (enum_mode == EnumMode.NativeBits && IsNativeEnum (pi.ParameterType) && !Compat) if (enum_mode == EnumMode.NativeBits && IsNativeEnum (pi.ParameterType))
return "(" + GetNativeEnumType (pi.ParameterType) + ") (" + PrimitiveType (TypeManager.GetUnderlyingEnumType (pi.ParameterType)) + ") " + pi.Name.GetSafeParamName (); return "(" + GetNativeEnumType (pi.ParameterType) + ") (" + PrimitiveType (TypeManager.GetUnderlyingEnumType (pi.ParameterType)) + ") " + pi.Name.GetSafeParamName ();
if (IsNativeType (pi.ParameterType)) if (IsNativeType (pi.ParameterType))
@ -1954,7 +1937,7 @@ public partial class Generator : IMemberGatherer {
public bool IsTarget (ParameterInfo pi) public bool IsTarget (ParameterInfo pi)
{ {
var is_target = AttributeManager.HasAttribute<TargetAttribute> (pi); var is_target = AttributeManager.HasAttribute<TargetAttribute> (pi);
if (is_target && UnifiedAPI) { if (is_target) {
throw new BindingException (1031, true, throw new BindingException (1031, true,
"The [Target] attribute is not supported for the Unified API (found on the member '{0}.{1}'). " + "The [Target] attribute is not supported for the Unified API (found on the member '{0}.{1}'). " +
"For Objective-C categories, create an api definition interface with the [Category] attribute instead.", "For Objective-C categories, create an api definition interface with the [Category] attribute instead.",
@ -2070,9 +2053,6 @@ public partial class Generator : IMemberGatherer {
bool HasNativeEnumInSignature (MethodInfo mi) bool HasNativeEnumInSignature (MethodInfo mi)
{ {
if (Compat)
return false;
if (IsNativeEnum (mi.ReturnType)) if (IsNativeEnum (mi.ReturnType))
return true; return true;
@ -2089,38 +2069,24 @@ public partial class Generator : IMemberGatherer {
return; return;
try { try {
if (Compat) { EnumMode[] modes;
var returnType = mi.ReturnType; if (HasNativeEnumInSignature (mi)) {
bool arm_stret = Stret.ArmNeedStret (returnType, this); modes = new EnumMode[] { EnumMode.Bit32, EnumMode.Bit64 };
bool is_aligned = AttributeManager.HasAttribute<AlignAttribute> (mi);
RegisterMethod (arm_stret, mi, MakeSig (mi, arm_stret, arm_stret && is_aligned), arm_stret && is_aligned);
RegisterMethod (arm_stret, mi, MakeSuperSig (mi, arm_stret, arm_stret && is_aligned), arm_stret && is_aligned);
bool x86_stret = Stret.X86NeedStret (returnType, this);
if (x86_stret != arm_stret){
RegisterMethod (x86_stret, mi, MakeSig (mi, x86_stret, x86_stret && is_aligned), x86_stret && is_aligned);
RegisterMethod (x86_stret, mi, MakeSuperSig (mi, x86_stret, x86_stret && is_aligned), x86_stret && is_aligned);
}
} else { } else {
EnumMode[] modes; modes = new EnumMode[] { EnumMode.Bit32 };
if (HasNativeEnumInSignature (mi)) { }
modes = new EnumMode[] { EnumMode.Bit32, EnumMode.Bit64 }; foreach (var mode in modes) {
} else { // arm64 never requires stret, so we'll always need the non-stret variants
modes = new EnumMode[] { EnumMode.Bit32 }; RegisterMethod (false, mi, MakeSig (mi, false, enum_mode: mode), false, mode);
} RegisterMethod (false, mi, MakeSuperSig (mi, false, enum_mode: mode), false, mode);
foreach (var mode in modes) {
// arm64 never requires stret, so we'll always need the non-stret variants
RegisterMethod (false, mi, MakeSig (mi, false, enum_mode: mode), false, mode);
RegisterMethod (false, mi, MakeSuperSig (mi, false, enum_mode: mode), false, mode);
if (CheckNeedStret (mi)) { if (CheckNeedStret (mi)) {
RegisterMethod (true, mi, MakeSig (mi, true, enum_mode: mode), false, mode); RegisterMethod (true, mi, MakeSig (mi, true, enum_mode: mode), false, mode);
RegisterMethod (true, mi, MakeSuperSig (mi, true, enum_mode: mode), false, mode); RegisterMethod (true, mi, MakeSuperSig (mi, true, enum_mode: mode), false, mode);
if (AttributeManager.HasAttribute<AlignAttribute> (mi)) { if (AttributeManager.HasAttribute<AlignAttribute> (mi)) {
RegisterMethod (true, mi, MakeSig (mi, true, true, mode), true, mode); RegisterMethod (true, mi, MakeSig (mi, true, true, mode), true, mode);
RegisterMethod (true, mi, MakeSuperSig (mi, true, true, mode), true, mode); RegisterMethod (true, mi, MakeSuperSig (mi, true, true, mode), true, mode);
}
} }
} }
} }
@ -2204,12 +2170,6 @@ public partial class Generator : IMemberGatherer {
if (t.IsUnavailable (this)) if (t.IsUnavailable (this))
return true; return true;
if (Compat)
return AttributeManager.GetCustomAttributes<AvailabilityBaseAttribute> (t)
.Any (attr => attr.AvailabilityKind == AvailabilityKind.Introduced &&
attr.Platform == CurrentPlatform &&
attr.Architecture == PlatformArchitecture.Arch64);
return false; return false;
} }
@ -2290,7 +2250,7 @@ public partial class Generator : IMemberGatherer {
m = GetOutputStream ("ObjCRuntime", "Messaging"); m = GetOutputStream ("ObjCRuntime", "Messaging");
Header (m); Header (m);
print (m, "namespace {0} {{", ns.ObjCRuntime); print (m, "namespace {0} {{", ns.ObjCRuntime);
print (m, "\t{0}partial class Messaging {{", Compat ? "public " : String.Empty); print (m, "\tpartial class Messaging {");
if (BindThirdPartyLibrary){ if (BindThirdPartyLibrary){
print (m, "\t\tstatic internal System.Reflection.Assembly this_assembly = typeof (Messaging).Assembly;\n"); print (m, "\t\tstatic internal System.Reflection.Assembly this_assembly = typeof (Messaging).Assembly;\n");
@ -2527,33 +2487,6 @@ public partial class Generator : IMemberGatherer {
Type GetCorrectGenericType (Type type) Type GetCorrectGenericType (Type type)
{ {
if (UnifiedAPI)
return type;
if (type != null && type.IsGenericType) {
// for compat we expose NSSet/NSDictionary instead of NSSet<TKey>/NSDictionary<TKey,TValue>
var bt = type.GetGenericTypeDefinition ();
switch (bt.FullName) {
case "MonoTouch.Foundation.NSDictionary`2":
case "MonoMac.Foundation.NSDictionary`2":
return bt.Assembly.GetType (bt.Namespace + ".NSDictionary");
case "MonoTouch.Foundation.NSMutableDictionary`2":
case "MonoMac.Foundation.NSMutableDictionary`2":
return bt.Assembly.GetType (bt.Namespace + ".NSMutableDictionary");
case "MonoTouch.Foundation.NSSet`1":
case "MonoMac.Foundation.NSSet`1":
return bt.Assembly.GetType (bt.Namespace + ".NSSet");
case "MonoTouch.Foundation.NSMutableSet`1":
case "MonoMac.Foundation.NSMutableSet`1":
return bt.Assembly.GetType (bt.Namespace + ".NSMutableSet");
case "MonoTouch.Foundation.NSMutableArray`1":
case "MonoMac.Foundation.NSMutableArray`1":
return bt.Assembly.GetType (bt.Namespace + ".NSMutableArray");
default:
return type;
}
}
return type; return type;
} }
@ -2860,13 +2793,13 @@ public partial class Generator : IMemberGatherer {
} else if (fetchType == TypeManager.System_nuint){ } else if (fetchType == TypeManager.System_nuint){
getter = "{1} GetNUIntValue ({0})"; getter = "{1} GetNUIntValue ({0})";
setter = "SetNumberValue ({0}, {1}value)"; setter = "SetNumberValue ({0}, {1}value)";
} else if (UnifiedAPI && fetchType == TypeManager.CoreGraphics_CGRect){ } else if (fetchType == TypeManager.CoreGraphics_CGRect){
getter = "{1} GetCGRectValue ({0})"; getter = "{1} GetCGRectValue ({0})";
setter = "SetCGRectValue ({0}, {1}value)"; setter = "SetCGRectValue ({0}, {1}value)";
} else if (UnifiedAPI && fetchType == TypeManager.CoreGraphics_CGSize){ } else if (fetchType == TypeManager.CoreGraphics_CGSize){
getter = "{1} GetCGSizeValue ({0})"; getter = "{1} GetCGSizeValue ({0})";
setter = "SetCGSizeValue ({0}, {1}value)"; setter = "SetCGSizeValue ({0}, {1}value)";
} else if (UnifiedAPI && fetchType == TypeManager.CoreGraphics_CGPoint){ } else if (fetchType == TypeManager.CoreGraphics_CGPoint){
getter = "{1} GetCGPointValue ({0})"; getter = "{1} GetCGPointValue ({0})";
setter = "SetCGPointValue ({0}, {1}value)"; setter = "SetCGPointValue ({0}, {1}value)";
} else if (Frameworks.HaveCoreMedia && fetchType == TypeManager.CMTime){ } else if (Frameworks.HaveCoreMedia && fetchType == TypeManager.CMTime){
@ -3449,9 +3382,6 @@ public partial class Generator : IMemberGatherer {
public bool Protocolize (ICustomAttributeProvider provider) public bool Protocolize (ICustomAttributeProvider provider)
{ {
if (!UnifiedAPI)
return false;
var attribs = AttributeManager.GetCustomAttributes<ProtocolizeAttribute> (provider); var attribs = AttributeManager.GetCustomAttributes<ProtocolizeAttribute> (provider);
if (attribs == null || attribs.Length == 0) if (attribs == null || attribs.Length == 0)
return false; return false;
@ -3472,7 +3402,7 @@ public partial class Generator : IMemberGatherer {
if (!minfo.is_ctor && !is_async){ if (!minfo.is_ctor && !is_async){
var prefix = ""; var prefix = "";
if (UnifiedAPI && !BindThirdPartyLibrary){ if (!BindThirdPartyLibrary){
var hasReturnTypeProtocolize = Protocolize (AttributeManager.GetReturnTypeCustomAttributes (minfo.method)); var hasReturnTypeProtocolize = Protocolize (AttributeManager.GetReturnTypeCustomAttributes (minfo.method));
if (hasReturnTypeProtocolize) { if (hasReturnTypeProtocolize) {
if (!IsProtocol (minfo.method.ReturnType)) { if (!IsProtocol (minfo.method.ReturnType)) {
@ -3797,39 +3727,6 @@ public partial class Generator : IMemberGatherer {
} }
} }
void GenerateInvoke (bool supercall, MethodInfo mi, MemberInformation minfo, string selector, string[] args, bool assign_to_temp, Type category_type)
{
if (!Compat) {
GenerateNewStyleInvoke (supercall, mi, minfo, selector, args, assign_to_temp, category_type);
return;
}
var returnType = mi.ReturnType;
bool arm_stret = Stret.ArmNeedStret (returnType, this);
bool x86_stret = Stret.X86NeedStret (returnType, this);
bool aligned = AttributeManager.HasAttribute<AlignAttribute> (mi);
if (CurrentPlatform == PlatformName.MacOSX) {
GenerateInvoke (x86_stret, supercall, mi, minfo, selector, args[0], assign_to_temp, category_type, aligned && x86_stret);
return;
}
bool need_two_paths = arm_stret != x86_stret;
if (need_two_paths){
print ("if (Runtime.Arch == Arch.DEVICE){");
indent++;
GenerateInvoke (arm_stret, supercall, mi, minfo, selector, args[0], assign_to_temp, category_type, aligned && arm_stret);
indent--;
print ("} else {");
indent++;
GenerateInvoke (x86_stret, supercall, mi, minfo, selector, args[0], assign_to_temp, category_type, aligned && arm_stret);
indent--;
print ("}");
} else {
GenerateInvoke (arm_stret, supercall, mi, minfo, selector, args[0], assign_to_temp, category_type, aligned && arm_stret);
}
}
void GenerateNewStyleInvoke (bool supercall, MethodInfo mi, MemberInformation minfo, string selector, string[] args, bool assign_to_temp, Type category_type) void GenerateNewStyleInvoke (bool supercall, MethodInfo mi, MemberInformation minfo, string selector, string[] args, bool assign_to_temp, Type category_type)
{ {
var returnType = mi.ReturnType; var returnType = mi.ReturnType;
@ -4225,7 +4122,7 @@ public partial class Generator : IMemberGatherer {
if (!needs_null_check) if (!needs_null_check)
continue; continue;
if (UnifiedAPI && !BindThirdPartyLibrary) { if (!BindThirdPartyLibrary) {
if (!mi.IsSpecialName && IsModel (pi.ParameterType) && !Protocolize (pi)) if (!mi.IsSpecialName && IsModel (pi.ParameterType) && !Protocolize (pi))
ErrorHelper.Warning (1106, "The parameter {2} in the method {0}.{1} exposes a model ({3}). Please expose the corresponding protocol type instead ({4}.I{5}).", ErrorHelper.Warning (1106, "The parameter {2} in the method {0}.{1} exposes a model ({3}). Please expose the corresponding protocol type instead ({4}.I{5}).",
mi.DeclaringType, mi.Name, pi.Name, pi.ParameterType, pi.ParameterType.Namespace, pi.ParameterType.Name); mi.DeclaringType, mi.Name, pi.Name, pi.ParameterType, pi.ParameterType.Namespace, pi.ParameterType.Name);
@ -4391,7 +4288,7 @@ public partial class Generator : IMemberGatherer {
((body_options & BodyOption.NeedsTempReturn) == BodyOption.NeedsTempReturn) || ((body_options & BodyOption.NeedsTempReturn) == BodyOption.NeedsTempReturn) ||
(mi.ReturnType.IsSubclassOf (TypeManager.System_Delegate)) || (mi.ReturnType.IsSubclassOf (TypeManager.System_Delegate)) ||
(AttributeManager.HasAttribute<ProxyAttribute> (AttributeManager.GetReturnTypeCustomAttributes (mi))) || (AttributeManager.HasAttribute<ProxyAttribute> (AttributeManager.GetReturnTypeCustomAttributes (mi))) ||
(!Compat && IsNativeEnum (mi.ReturnType)) || (IsNativeEnum (mi.ReturnType)) ||
(mi.Name != "Constructor" && by_ref_processing.Length > 0 && mi.ReturnType != TypeManager.System_Void) || (mi.Name != "Constructor" && by_ref_processing.Length > 0 && mi.ReturnType != TypeManager.System_Void) ||
needsPtrZeroCheck; needsPtrZeroCheck;
@ -4419,7 +4316,7 @@ public partial class Generator : IMemberGatherer {
if (minfo.is_virtual_method || mi.Name == "Constructor"){ if (minfo.is_virtual_method || mi.Name == "Constructor"){
//print ("if (this.GetType () == TypeManager.{0}) {{", type.Name); //print ("if (this.GetType () == TypeManager.{0}) {{", type.Name);
if (external || minfo.is_interface_impl || minfo.is_extension_method) { if (external || minfo.is_interface_impl || minfo.is_extension_method) {
GenerateInvoke (false, mi, minfo, sel, argsArray, needs_temp, category_type); GenerateNewStyleInvoke (false, mi, minfo, sel, argsArray, needs_temp, category_type);
} else { } else {
var may_throw = ShouldMarshalNativeExceptions (mi); var may_throw = ShouldMarshalNativeExceptions (mi);
var null_handle = may_throw && mi.Name == "Constructor"; var null_handle = may_throw && mi.Name == "Constructor";
@ -4430,8 +4327,8 @@ public partial class Generator : IMemberGatherer {
WriteIsDirectBindingCondition (sw, ref indent, is_direct_binding, WriteIsDirectBindingCondition (sw, ref indent, is_direct_binding,
mi.Name == "Constructor" ? is_direct_binding_value : null, // We only need to print the is_direct_binding value in constructors mi.Name == "Constructor" ? is_direct_binding_value : null, // We only need to print the is_direct_binding value in constructors
() => { GenerateInvoke (false, mi, minfo, sel, argsArray, needs_temp, category_type); return null; }, () => { GenerateNewStyleInvoke (false, mi, minfo, sel, argsArray, needs_temp, category_type); return null; },
() => { GenerateInvoke (true, mi, minfo, sel, argsArray, needs_temp, category_type); return null; } () => { GenerateNewStyleInvoke (true, mi, minfo, sel, argsArray, needs_temp, category_type); return null; }
); );
if (null_handle) { if (null_handle) {
@ -4445,7 +4342,7 @@ public partial class Generator : IMemberGatherer {
} }
} }
} else { } else {
GenerateInvoke (false, mi, minfo, sel, argsArray, needs_temp, category_type); GenerateNewStyleInvoke (false, mi, minfo, sel, argsArray, needs_temp, category_type);
} }
if (minfo.is_return_release) { if (minfo.is_return_release) {
@ -4699,25 +4596,23 @@ public partial class Generator : IMemberGatherer {
var mod = minfo.GetVisibility (); var mod = minfo.GetVisibility ();
minfo.protocolize = Protocolize (pi); minfo.protocolize = Protocolize (pi);
if (UnifiedAPI) { // We have some sub-optimal bindings in compat that trigger this exception, so we just don't fix those // So we don't hide the get or set of a parent property with the same name, we need to see if we have a parent declaring the same property
// So we don't hide the get or set of a parent property with the same name, we need to see if we have a parent declaring the same property PropertyInfo parentBaseType = GetParentTypeWithSameNamedProperty (ReflectionExtensions.GetBaseTypeAttribute (type, this), pi.Name);
PropertyInfo parentBaseType = GetParentTypeWithSameNamedProperty (ReflectionExtensions.GetBaseTypeAttribute (type, this), pi.Name);
// If so, we're not static, and we can't both read and write, but they can // If so, we're not static, and we can't both read and write, but they can
if (!minfo.is_static && !(pi.CanRead && pi.CanWrite) && (parentBaseType != null && parentBaseType.CanRead && parentBaseType.CanWrite)) { if (!minfo.is_static && !(pi.CanRead && pi.CanWrite) && (parentBaseType != null && parentBaseType.CanRead && parentBaseType.CanWrite)) {
// Make sure the selector matches, sanity check that we aren't hiding something of a different type // Make sure the selector matches, sanity check that we aren't hiding something of a different type
// We skip this for wrap'ed properties, as those get complicated to resolve the correct export // We skip this for wrap'ed properties, as those get complicated to resolve the correct export
if (wrap == null && if (wrap == null &&
((pi.CanRead && (GetGetterExportAttribute (pi).Selector != GetGetterExportAttribute (parentBaseType).Selector)) || ((pi.CanRead && (GetGetterExportAttribute (pi).Selector != GetGetterExportAttribute (parentBaseType).Selector)) ||
pi.CanWrite && (GetSetterExportAttribute (pi).Selector != GetSetterExportAttribute (parentBaseType).Selector))) { pi.CanWrite && (GetSetterExportAttribute (pi).Selector != GetSetterExportAttribute (parentBaseType).Selector))) {
throw new BindingException (1035, true, "The property {0} on class {1} is hiding a property from a parent class {2} but the selectors do not match.", pi.Name, type, parentBaseType.DeclaringType); throw new BindingException (1035, true, "The property {0} on class {1} is hiding a property from a parent class {2} but the selectors do not match.", pi.Name, type, parentBaseType.DeclaringType);
}
// Then let's not write out our copy, since we'll reduce visibility
return;
} }
// Then let's not write out our copy, since we'll reduce visibility
return;
} }
if (UnifiedAPI && !BindThirdPartyLibrary) { if (!BindThirdPartyLibrary) {
var elType = pi.PropertyType.IsArray ? pi.PropertyType.GetElementType () : pi.PropertyType; var elType = pi.PropertyType.IsArray ? pi.PropertyType.GetElementType () : pi.PropertyType;
if (IsModel (elType) && !minfo.protocolize) { if (IsModel (elType) && !minfo.protocolize) {
@ -4762,7 +4657,7 @@ public partial class Generator : IMemberGatherer {
print ("set {"); print ("set {");
indent++; indent++;
var is_protocol_wrapper = UnifiedAPI && IsProtocolInterface (pi.PropertyType, false); var is_protocol_wrapper = IsProtocolInterface (pi.PropertyType, false);
if (minfo.protocolize || is_protocol_wrapper){ if (minfo.protocolize || is_protocol_wrapper){
print ("var rvalue = value as NSObject;"); print ("var rvalue = value as NSObject;");
@ -5062,7 +4957,7 @@ public partial class Generator : IMemberGatherer {
if (minfo.is_void_async) if (minfo.is_void_async)
return "Task"; return "Task";
var ttype = GetAsyncTaskType (minfo); var ttype = GetAsyncTaskType (minfo);
if (UnifiedAPI && minfo.has_nserror && (ttype == "bool")) if (minfo.has_nserror && (ttype == "bool"))
ttype = "Tuple<bool,NSError>"; ttype = "Tuple<bool,NSError>";
return "Task<" + ttype + ">"; return "Task<" + ttype + ">";
} }
@ -5166,7 +5061,7 @@ public partial class Generator : IMemberGatherer {
var tuple = false; var tuple = false;
if (!minfo.is_void_async) { if (!minfo.is_void_async) {
ttype = GetAsyncTaskType (minfo); ttype = GetAsyncTaskType (minfo);
tuple = (UnifiedAPI && minfo.has_nserror && (ttype == "bool")); tuple = (minfo.has_nserror && (ttype == "bool"));
if (tuple) if (tuple)
ttype = "Tuple<bool,NSError>"; ttype = "Tuple<bool,NSError>";
} }
@ -5825,11 +5720,7 @@ public partial class Generator : IMemberGatherer {
// avoid (for unified) all the metadata for empty static classes, we can introduce them later when required // avoid (for unified) all the metadata for empty static classes, we can introduce them later when required
bool include_extensions = false; bool include_extensions = false;
if (UnifiedAPI) { include_extensions = optionalInstanceMethods.Any () || optionalInstanceProperties.Any () || requiredInstanceAsyncMethods.Any ();
include_extensions = optionalInstanceMethods.Any () || optionalInstanceProperties.Any () || requiredInstanceAsyncMethods.Any ();
} else {
include_extensions = true;
}
if (include_extensions) { if (include_extensions) {
// extension methods // extension methods
PrintAttributes (type, preserve:true, advice:true); PrintAttributes (type, preserve:true, advice:true);
@ -5916,9 +5807,6 @@ public partial class Generator : IMemberGatherer {
{ {
var dir = basedir; var dir = basedir;
if (!string.IsNullOrEmpty (@namespace))
dir = Path.Combine (dir, @namespace.Replace (ns.Prefix + ".", string.Empty));
var filename = Path.Combine (dir, name + ".g.cs"); var filename = Path.Combine (dir, name + ".g.cs");
var counter = 2; var counter = 2;
while (generated_files.Contains (filename)) { while (generated_files.Contains (filename)) {
@ -6073,12 +5961,6 @@ public partial class Generator : IMemberGatherer {
throw new BindingException (1042, true, $"Missing '[Field (LibraryName=value)]' for {propertyName} (e.g.\"__Internal\")"); throw new BindingException (1042, true, $"Missing '[Field (LibraryName=value)]' for {propertyName} (e.g.\"__Internal\")");
} else { } else {
library_name = type.Namespace; library_name = type.Namespace;
// note: not every binding namespace will start with ns.Prefix (e.g. MonoTouch.)
if (!String.IsNullOrEmpty (ns.Prefix) && library_name.StartsWith (ns.Prefix, StringComparison.Ordinal)) {
library_name = library_name.Substring (ns.Prefix.Length + 1);
library_name = library_name.Replace (".", string.Empty); // Remove dots from namespaces
}
} }
if (!libraries.ContainsKey (library_name)) if (!libraries.ContainsKey (library_name))
@ -6112,7 +5994,7 @@ public partial class Generator : IMemberGatherer {
public void Generate (Type type) public void Generate (Type type)
{ {
if (!Compat && ZeroCopyStrings) { if (ZeroCopyStrings) {
ErrorHelper.Warning (1027, "Support for ZeroCopy strings is not implemented. Strings will be marshalled as NSStrings."); ErrorHelper.Warning (1027, "Support for ZeroCopy strings is not implemented. Strings will be marshalled as NSStrings.");
ZeroCopyStrings = false; ZeroCopyStrings = false;
} }
@ -6372,7 +6254,7 @@ public partial class Generator : IMemberGatherer {
if (TypeName != "NSObject"){ if (TypeName != "NSObject"){
var initSelector = (InlineSelectors || BindThirdPartyLibrary) ? "Selector.GetHandle (\"init\")" : "Selector.Init"; var initSelector = (InlineSelectors || BindThirdPartyLibrary) ? "Selector.GetHandle (\"init\")" : "Selector.Init";
var initWithCoderSelector = (InlineSelectors || BindThirdPartyLibrary) ? "Selector.GetHandle (\"initWithCoder:\")" : "Selector.InitWithCoder"; var initWithCoderSelector = (InlineSelectors || BindThirdPartyLibrary) ? "Selector.GetHandle (\"initWithCoder:\")" : "Selector.InitWithCoder";
string v = UnifiedAPI && class_mod == "abstract " ? "protected" : ctor_visibility; string v = class_mod == "abstract " ? "protected" : ctor_visibility;
var is32BitNotSupported = Is64BitiOSOnly (type); var is32BitNotSupported = Is64BitiOSOnly (type);
if (external) { if (external) {
if (!disable_default_ctor) { if (!disable_default_ctor) {
@ -6427,18 +6309,13 @@ public partial class Generator : IMemberGatherer {
sw.WriteLine ("\t\t}"); sw.WriteLine ("\t\t}");
sw.WriteLine (); sw.WriteLine ();
} }
// old monotouch.dll (and MonoMac.dll, XamMac.dll) always included this .ctor even if the
// type did not conform to NSCopying. That made the .ctor throw a (native) exception and crash
var nscoding = ConformToNSCoding (type); var nscoding = ConformToNSCoding (type);
if (Compat || nscoding) { if (nscoding) {
// for compatibility we continue to include the .ctor(NSCoder) in the compat assemblies
// but we make it throw an InvalidOperationException if the type does not implement NSCoding
// because it's easier to catch (and won't crash on devices)
GeneratedCode (sw, 2); GeneratedCode (sw, 2);
sw.WriteLine ("\t\t[DesignatedInitializer]"); sw.WriteLine ("\t\t[DesignatedInitializer]");
sw.WriteLine ("\t\t[EditorBrowsable (EditorBrowsableState.Advanced)]"); sw.WriteLine ("\t\t[EditorBrowsable (EditorBrowsableState.Advanced)]");
sw.WriteLine ("\t\t[Export (\"initWithCoder:\")]"); sw.WriteLine ("\t\t[Export (\"initWithCoder:\")]");
sw.WriteLine ("\t\t{0} {1} (NSCoder coder) : base (NSObjectFlag.Empty)", UnifiedAPI ? v : "public", TypeName); sw.WriteLine ("\t\t{0} {1} (NSCoder coder) : base (NSObjectFlag.Empty)", v, TypeName);
sw.WriteLine ("\t\t{"); sw.WriteLine ("\t\t{");
if (is32BitNotSupported) { if (is32BitNotSupported) {
sw.WriteLine ("\t\t#if ARCH_32"); sw.WriteLine ("\t\t#if ARCH_32");
@ -6466,7 +6343,7 @@ public partial class Generator : IMemberGatherer {
if (!is_sealed) { if (!is_sealed) {
GeneratedCode (sw, 2); GeneratedCode (sw, 2);
sw.WriteLine ("\t\t[EditorBrowsable (EditorBrowsableState.Advanced)]"); sw.WriteLine ("\t\t[EditorBrowsable (EditorBrowsableState.Advanced)]");
sw.WriteLine ("\t\t{0} {1} (NSObjectFlag t) : base (t)", UnifiedAPI ? "protected" : "public", TypeName); sw.WriteLine ("\t\tprotected {0} (NSObjectFlag t) : base (t)", TypeName);
sw.WriteLine ("\t\t{"); sw.WriteLine ("\t\t{");
if (is32BitNotSupported) { if (is32BitNotSupported) {
sw.WriteLine ("\t\t#if ARCH_32"); sw.WriteLine ("\t\t#if ARCH_32");
@ -6483,7 +6360,7 @@ public partial class Generator : IMemberGatherer {
} }
GeneratedCode (sw, 2); GeneratedCode (sw, 2);
sw.WriteLine ("\t\t[EditorBrowsable (EditorBrowsableState.Advanced)]"); sw.WriteLine ("\t\t[EditorBrowsable (EditorBrowsableState.Advanced)]");
sw.WriteLine ("\t\t{0} {1} (IntPtr handle) : base (handle)", UnifiedAPI ? "protected internal" : "public", TypeName); sw.WriteLine ("\t\tprotected internal {0} (IntPtr handle) : base (handle)", TypeName);
sw.WriteLine ("\t\t{"); sw.WriteLine ("\t\t{");
if (is32BitNotSupported) { if (is32BitNotSupported) {
sw.WriteLine ("\t\t#if ARCH_32"); sw.WriteLine ("\t\t#if ARCH_32");
@ -6691,13 +6568,13 @@ public partial class Generator : IMemberGatherer {
field_pi.PropertyType == TypeManager.AVCaptureWhiteBalanceGains)) { field_pi.PropertyType == TypeManager.AVCaptureWhiteBalanceGains)) {
print ("return *(({3} *) Dlfcn.dlsym (Libraries.{2}.Handle, \"{1}\"));", field_pi.Name, fieldAttr.SymbolName, library_name, print ("return *(({3} *) Dlfcn.dlsym (Libraries.{2}.Handle, \"{1}\"));", field_pi.Name, fieldAttr.SymbolName, library_name,
FormatType (type, field_pi.PropertyType.Namespace, field_pi.PropertyType.Name)); FormatType (type, field_pi.PropertyType.Namespace, field_pi.PropertyType.Name));
} else if (UnifiedAPI && field_pi.PropertyType == TypeManager.System_nint) { } else if (field_pi.PropertyType == TypeManager.System_nint) {
print ("return Dlfcn.GetNInt (Libraries.{2}.Handle, \"{1}\");", field_pi.Name, fieldAttr.SymbolName, library_name); print ("return Dlfcn.GetNInt (Libraries.{2}.Handle, \"{1}\");", field_pi.Name, fieldAttr.SymbolName, library_name);
} else if (UnifiedAPI && field_pi.PropertyType == TypeManager.System_nuint) { } else if (field_pi.PropertyType == TypeManager.System_nuint) {
print ("return Dlfcn.GetNUInt (Libraries.{2}.Handle, \"{1}\");", field_pi.Name, fieldAttr.SymbolName, library_name); print ("return Dlfcn.GetNUInt (Libraries.{2}.Handle, \"{1}\");", field_pi.Name, fieldAttr.SymbolName, library_name);
} else if (UnifiedAPI && field_pi.PropertyType == TypeManager.System_nfloat) { } else if (field_pi.PropertyType == TypeManager.System_nfloat) {
print ("return Dlfcn.GetNFloat (Libraries.{2}.Handle, \"{1}\");", field_pi.Name, fieldAttr.SymbolName, library_name); print ("return Dlfcn.GetNFloat (Libraries.{2}.Handle, \"{1}\");", field_pi.Name, fieldAttr.SymbolName, library_name);
} else if (UnifiedAPI && field_pi.PropertyType == TypeManager.CoreGraphics_CGSize){ } else if (field_pi.PropertyType == TypeManager.CoreGraphics_CGSize){
print ("return Dlfcn.GetCGSize (Libraries.{2}.Handle, \"{1}\");", field_pi.Name, fieldAttr.SymbolName, library_name); print ("return Dlfcn.GetCGSize (Libraries.{2}.Handle, \"{1}\");", field_pi.Name, fieldAttr.SymbolName, library_name);
} else if (field_pi.PropertyType.IsEnum) { } else if (field_pi.PropertyType.IsEnum) {
var btype = field_pi.PropertyType.GetEnumUnderlyingType (); var btype = field_pi.PropertyType.GetEnumUnderlyingType ();
@ -6707,7 +6584,7 @@ public partial class Generator : IMemberGatherer {
print ("_{0} = Dlfcn.GetStringConstant (Libraries.{2}.Handle, \"{1}\");", field_pi.Name, fieldAttr.SymbolName, library_name); print ("_{0} = Dlfcn.GetStringConstant (Libraries.{2}.Handle, \"{1}\");", field_pi.Name, fieldAttr.SymbolName, library_name);
indent--; indent--;
print ($"return {smartEnumTypeName}Extensions.GetValue (_{field_pi.Name});"); print ($"return {smartEnumTypeName}Extensions.GetValue (_{field_pi.Name});");
} else if (UnifiedAPI && IsNativeEnum (field_pi.PropertyType)) { } else if (IsNativeEnum (field_pi.PropertyType)) {
if (btype == TypeManager.System_nint || btype == TypeManager.System_Int64) if (btype == TypeManager.System_nint || btype == TypeManager.System_Int64)
print ($"return ({fieldTypeName}) (long) Dlfcn.GetNInt (Libraries.{library_name}.Handle, \"{fieldAttr.SymbolName}\");" ); print ($"return ({fieldTypeName}) (long) Dlfcn.GetNInt (Libraries.{library_name}.Handle, \"{fieldAttr.SymbolName}\");" );
else if (btype == TypeManager.System_nuint || btype == TypeManager.System_UInt64) else if (btype == TypeManager.System_nuint || btype == TypeManager.System_UInt64)
@ -6761,19 +6638,19 @@ public partial class Generator : IMemberGatherer {
print ("Dlfcn.SetString (Libraries.{2}.Handle, \"{1}\", value);", field_pi.Name, fieldAttr.SymbolName, library_name); print ("Dlfcn.SetString (Libraries.{2}.Handle, \"{1}\", value);", field_pi.Name, fieldAttr.SymbolName, library_name);
} else if (field_pi.PropertyType.Name == "NSArray"){ } else if (field_pi.PropertyType.Name == "NSArray"){
print ("Dlfcn.SetArray (Libraries.{2}.Handle, \"{1}\", value);", field_pi.Name, fieldAttr.SymbolName, library_name); print ("Dlfcn.SetArray (Libraries.{2}.Handle, \"{1}\", value);", field_pi.Name, fieldAttr.SymbolName, library_name);
} else if (UnifiedAPI && field_pi.PropertyType == TypeManager.System_nint) { } else if (field_pi.PropertyType == TypeManager.System_nint) {
print ("Dlfcn.SetNInt (Libraries.{2}.Handle, \"{1}\", value);", field_pi.Name, fieldAttr.SymbolName, library_name); print ("Dlfcn.SetNInt (Libraries.{2}.Handle, \"{1}\", value);", field_pi.Name, fieldAttr.SymbolName, library_name);
} else if (UnifiedAPI && field_pi.PropertyType == TypeManager.System_nuint) { } else if (field_pi.PropertyType == TypeManager.System_nuint) {
print ("Dlfcn.SetNUInt (Libraries.{2}.Handle, \"{1}\", value);", field_pi.Name, fieldAttr.SymbolName, library_name); print ("Dlfcn.SetNUInt (Libraries.{2}.Handle, \"{1}\", value);", field_pi.Name, fieldAttr.SymbolName, library_name);
} else if (UnifiedAPI && field_pi.PropertyType == TypeManager.System_nfloat) { } else if (field_pi.PropertyType == TypeManager.System_nfloat) {
print ("Dlfcn.SetNFloat (Libraries.{2}.Handle, \"{1}\", value);", field_pi.Name, fieldAttr.SymbolName, library_name); print ("Dlfcn.SetNFloat (Libraries.{2}.Handle, \"{1}\", value);", field_pi.Name, fieldAttr.SymbolName, library_name);
} else if (UnifiedAPI && field_pi.PropertyType == TypeManager.CoreGraphics_CGSize) { } else if (field_pi.PropertyType == TypeManager.CoreGraphics_CGSize) {
print ("Dlfcn.SetCGSize (Libraries.{2}.Handle, \"{1}\", value);", field_pi.Name, fieldAttr.SymbolName, library_name); print ("Dlfcn.SetCGSize (Libraries.{2}.Handle, \"{1}\", value);", field_pi.Name, fieldAttr.SymbolName, library_name);
} else if (field_pi.PropertyType.IsEnum) { } else if (field_pi.PropertyType.IsEnum) {
var btype = field_pi.PropertyType.GetEnumUnderlyingType (); var btype = field_pi.PropertyType.GetEnumUnderlyingType ();
if (smartEnumTypeName != null) if (smartEnumTypeName != null)
print ($"Dlfcn.SetString (Libraries.{library_name}.Handle, \"{fieldAttr.SymbolName}\", value.GetConstant ());"); print ($"Dlfcn.SetString (Libraries.{library_name}.Handle, \"{fieldAttr.SymbolName}\", value.GetConstant ());");
else if (UnifiedAPI && IsNativeEnum (field_pi.PropertyType)) { else if (IsNativeEnum (field_pi.PropertyType)) {
if (btype == TypeManager.System_nint || (BindThirdPartyLibrary && btype == TypeManager.System_Int64)) if (btype == TypeManager.System_nint || (BindThirdPartyLibrary && btype == TypeManager.System_Int64))
print ($"Dlfcn.SetNInt (Libraries.{library_name}.Handle, \"{fieldAttr.SymbolName}\", (nint) (long) value);"); print ($"Dlfcn.SetNInt (Libraries.{library_name}.Handle, \"{fieldAttr.SymbolName}\", (nint) (long) value);");
else if (btype == TypeManager.System_nuint || (BindThirdPartyLibrary && btype == TypeManager.System_UInt64)) else if (btype == TypeManager.System_nuint || (BindThirdPartyLibrary && btype == TypeManager.System_UInt64))