Merge pull request #7387 from VincentDondain/d16-5-merge-master

Merge master into d16-5
This commit is contained in:
Vincent Dondain 2019-11-11 11:19:29 -05:00 коммит произвёл GitHub
Родитель d7b2c14982 44fd06324a
Коммит bde12ca5d4
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
171 изменённых файлов: 10655 добавлений и 5188 удалений

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

@ -31,7 +31,7 @@ $(TOP)/Make.config.inc: $(TOP)/Make.config $(TOP)/mk/mono.mk
include $(TOP)/Make.versions include $(TOP)/Make.versions
APIDIFF_REFERENCES=https://bosstoragemirror.blob.core.windows.net/wrench/jenkins/xcode11.1/e37549bc9052bff81d5c7da8a3b7992b47a08154/29/package/bundle.zip APIDIFF_REFERENCES=https://bosstoragemirror.blob.core.windows.net/wrench/jenkins/xcode11.2/a82239687c7c498844137779ee529154f260cb6f/48/package/bundle.zip
PACKAGE_HEAD_REV=$(shell git rev-parse HEAD) PACKAGE_HEAD_REV=$(shell git rev-parse HEAD)
@ -59,9 +59,9 @@ IOS_PACKAGE_VERSION_BUILD=$(IOS_COMMIT_DISTANCE)
IOS_PACKAGE_UPDATE_ID=$(shell printf "2%02d%02d%02d%03d" $(IOS_PACKAGE_VERSION_MAJOR) $(IOS_PACKAGE_VERSION_MINOR) $(IOS_PACKAGE_VERSION_REV) $(IOS_PACKAGE_VERSION_BUILD)) IOS_PACKAGE_UPDATE_ID=$(shell printf "2%02d%02d%02d%03d" $(IOS_PACKAGE_VERSION_MAJOR) $(IOS_PACKAGE_VERSION_MINOR) $(IOS_PACKAGE_VERSION_REV) $(IOS_PACKAGE_VERSION_BUILD))
# Xcode version should have both a major and a minor version (even if the minor version is 0) # Xcode version should have both a major and a minor version (even if the minor version is 0)
XCODE_VERSION=11.1 XCODE_VERSION=11.2
XCODE_URL=http://xamarin-storage/bot-provisioning/xcodes/Xcode_11.1.xip XCODE_URL=http://xamarin-storage/bot-provisioning/xcodes/Xcode_11.2.xip
XCODE_DEVELOPER_ROOT=/Applications/Xcode111.app/Contents/Developer XCODE_DEVELOPER_ROOT=/Applications/Xcode112.app/Contents/Developer
XCODE_PRODUCT_BUILD_VERSION:=$(shell /usr/libexec/PlistBuddy -c 'Print :ProductBuildVersion' $(XCODE_DEVELOPER_ROOT)/../version.plist) XCODE_PRODUCT_BUILD_VERSION:=$(shell /usr/libexec/PlistBuddy -c 'Print :ProductBuildVersion' $(XCODE_DEVELOPER_ROOT)/../version.plist)
# Mono version embedded in XI/XM (NEEDED_MONO_VERSION/BRANCH) are specified in mk/mono.mk # Mono version embedded in XI/XM (NEEDED_MONO_VERSION/BRANCH) are specified in mk/mono.mk
@ -97,11 +97,11 @@ MIN_OSX_BUILD_VERSION=10.14
MIN_OSX_VERSION_FOR_IOS=10.11 MIN_OSX_VERSION_FOR_IOS=10.11
MIN_OSX_VERSION_FOR_MAC=10.11 MIN_OSX_VERSION_FOR_MAC=10.11
IOS_SDK_VERSION=13.1 IOS_SDK_VERSION=13.2
# When bumping OSX_SDK_VERSION also update the macOS version where we execute on bots in jenkins/Jenkinsfile (in the 'node' element) # When bumping OSX_SDK_VERSION also update the macOS version where we execute on bots in jenkins/Jenkinsfile (in the 'node' element)
OSX_SDK_VERSION=10.15 OSX_SDK_VERSION=10.15
WATCH_SDK_VERSION=6.0 WATCH_SDK_VERSION=6.1
TVOS_SDK_VERSION=13.0 TVOS_SDK_VERSION=13.2
# If the max OS version does not match the SDK version (for instance the iOS # If the max OS version does not match the SDK version (for instance the iOS
# 12.2 SDK supported both iOS 12.3 and iOS 12.4), then these variables can be # 12.2 SDK supported both iOS 12.3 and iOS 12.4), then these variables can be
@ -190,7 +190,7 @@ IOS_CXX=$(XCODE_CXX)
SIMULATOR_BIN_PATH=$(XCODE_DEVELOPER_ROOT)/Platforms/iPhoneSimulator.platform/Developer/usr/bin SIMULATOR_BIN_PATH=$(XCODE_DEVELOPER_ROOT)/Platforms/iPhoneSimulator.platform/Developer/usr/bin
SIMULATOR_CC=$(IOS_CC) SIMULATOR_CC=$(IOS_CC)
CFLAGS= -Wall -fms-extensions -Wno-format-security CFLAGS= -Wall -fms-extensions -Wno-format-security -Wsign-compare -Wshorten-64-to-32
ifdef ENABLE_BITCODE_ON_IOS ifdef ENABLE_BITCODE_ON_IOS
BITCODE_CFLAGS=-fembed-bitcode-marker BITCODE_CFLAGS=-fembed-bitcode-marker

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

@ -35,6 +35,7 @@
<string>12.4</string> <string>12.4</string>
<string>13.0</string> <string>13.0</string>
<string>13.1</string> <string>13.1</string>
<string>13.2</string>
</array> </array>
<key>tvOS</key> <key>tvOS</key>
<array> <array>
@ -55,6 +56,7 @@
<string>12.3</string> <string>12.3</string>
<string>12.4</string> <string>12.4</string>
<string>13.0</string> <string>13.0</string>
<string>13.2</string>
</array> </array>
<key>watchOS</key> <key>watchOS</key>
<array> <array>
@ -74,6 +76,7 @@
<string>5.2</string> <string>5.2</string>
<string>5.3</string> <string>5.3</string>
<string>6.0</string> <string>6.0</string>
<string>6.1</string>
</array> </array>
</dict> </dict>
<key>RecommendedXcodeVersion</key> <key>RecommendedXcodeVersion</key>

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

@ -230,7 +230,32 @@ Incorrect:
NSString[] StringProp { get; } NSString[] StringProp { get; }
``` ```
### <a name='BI1072'/>BI1072: The BindAs type for the parameter "{parameterName}" in the method "{type}.{method}" must be an array when the parameter's type is an array. ### <a name='BI1072'/>BI1072: Missing [CoreImageFilterProperty] attribute on {type} property {name}
This error happens when a binding type, decorated with `[CoreImageFilter]` attribute, has properties that are not decorated with a `[CoreImageFilterProperty]` attribute. E.g.
```csharp
[CoreImageFilter]
[BaseType (typeof (CIFilter))]
interface CICustomFilter {
CGAffineTransform Transform { get; }
}
```
To solve this error you need to tell the `CIFilter` key that you want to map to the property, e.g.
```csharp
[CoreImageFilter]
[BaseType (typeof (CIFilter))]
interface CICustomFilter {
[CoreImageFilterProperty ("inputTransform")]
CGAffineTransform Transform { get; }
}
```
If the property is inlined from a protocol then the `[Export]` value, prefixed with `input`, will be used by default. You can override this with by adding the `[CoreImageFilterProperty]` attribute (e.g. for `output*` keys).
# BI11xx: warnings # BI11xx: warnings

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

@ -508,6 +508,18 @@ Consider using `lipo` to remove the unnecessary archtectures permanently from th
#### MM4134: Your application is using the '{0}' framework, which isn't included in the MacOS SDK you're using to build your app (this framework was introduced in OSX {2}, while you're building with the MacOS {1} SDK.) This configuration is not supported with the static registrar (pass --registrar:dynamic as an additional mmp argument in your project's Mac Build option to select). Alternatively select a newer SDK in your app's Mac Build options. #### MM4134: Your application is using the '{0}' framework, which isn't included in the MacOS SDK you're using to build your app (this framework was introduced in OSX {2}, while you're building with the MacOS {1} SDK.) This configuration is not supported with the static registrar (pass --registrar:dynamic as an additional mmp argument in your project's Mac Build option to select). Alternatively select a newer SDK in your app's Mac Build options.
<a name="MM4162" />
#### MM4162: The type '\*' (used as * {2}) is not available in * * (it was introduced in * *)\* Please build with a newer * SDK (usually done by using the most recent version of Xcode.
To build your application, Xamarin.Mac must compile against Xcode SDK header files, including new types not available in the SDK version specified in the error message. Since you are using an older version of the SDK, builds using those APIs fails at build time.
The recommended way to fix this error is to upgrade Xcode to get the needed SDK. If you have multiple versions of Xcode installed or want to use an Xcode in a non-default location, make sure to set the correct Xcode location in your IDE's preferences.
Alternatively, enable the managed linker to remove unused APIs, including (in most cases) the new ones which require the specified library. However, this will not work if your project requires APIs introduced in a newer SDK than the one your Xcode provides.
As a last-straw solution, use an older version of Xamarin.Mac that does not require these new SDKs to be present during the build process.
<a name="MM4173" /> <a name="MM4173" />
#### MM4173: The registrar can't compute the block signature for the delegate of type {delegate-type} in the method {method} because *. #### MM4173: The registrar can't compute the block signature for the delegate of type {delegate-type} in the method {method} because *.

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

@ -2407,9 +2407,13 @@ All fields in a structure that is exposed to Objective-C must also be structures
### MT4162: The type '\*' (used as * {2}) is not available in * * (it was introduced in * *)\* Please build with a newer * SDK (usually done by using the most recent version of Xcode. ### MT4162: The type '\*' (used as * {2}) is not available in * * (it was introduced in * *)\* Please build with a newer * SDK (usually done by using the most recent version of Xcode.
The registrar found a type which is not included in the current SDK. To build your application, Xamarin.iOS must compile against Xcode SDK header files, including new types not available in the SDK version specified in the error message. Since you are using an older version of the SDK, builds using those APIs fails at build time.
Please upgrade Xcode. The recommended way to fix this error is to upgrade Xcode to get the needed SDK. If you have multiple versions of Xcode installed or want to use an Xcode in a non-default location, make sure to set the correct Xcode location in your IDE's preferences.
Alternatively, enable the managed linker to remove unused APIs, including (in most cases) the new ones which require the specified library. However, this will not work if your project requires APIs introduced in a newer SDK than the one your Xcode provides.
As a last-straw solution, use an older version of Xamarin.iOS that does not require these new SDKs to be present during the build process.
<a name="MT4163" /> <a name="MT4163" />

2
jenkins/Jenkinsfile поставляемый
Просмотреть файл

@ -585,6 +585,8 @@ timestamps {
uploadFiles ("package/manifest", "wrench", "jenkins/${branchName}/${gitHash}") uploadFiles ("package/manifest", "wrench", "jenkins/${branchName}/${gitHash}")
// And also create a 'latest' version (which really means 'latest built', not 'latest hash', but it will hopefully be good enough) // And also create a 'latest' version (which really means 'latest built', not 'latest hash', but it will hopefully be good enough)
uploadFiles ("package/manifest", "wrench", "jenkins/${branchName}/latest") uploadFiles ("package/manifest", "wrench", "jenkins/${branchName}/latest")
// And finally create a per-hash manifest (which will be overwritten in rebuilds of the same hash)
uploadFiles ("package/manifest", "wrench", "jenkins/${gitHash}")
manifestFilename = "manifest" manifestFilename = "manifest"
} }

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

@ -1,4 +1,4 @@
NEEDED_MONO_VERSION := b601371d5f0b853b133608be25a18ea37f7628ed NEEDED_MONO_VERSION := 062f0ab8cae60d1d347e4d722884c065c9f34484
NEEDED_MONO_BRANCH := 2019-08 NEEDED_MONO_BRANCH := 2019-08
MONO_DIRECTORY := mono MONO_DIRECTORY := mono

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

@ -96,7 +96,7 @@ void * monotouch_IntPtr_objc_msgSendSuper_IntPtr (struct objc_super *super, SEL
* the code can be simplified once we require to remove dlsym or xcode 9 becomes the minimum supported version * the code can be simplified once we require to remove dlsym or xcode 9 becomes the minimum supported version
*/ */
typedef CGPoint (*vision_func) (vector_float2 faceLandmarkPoint, CGRect faceBoundingBox, size_t imageWidth, size_t imageHeight); typedef CGPoint (*vision_func) (vector_float2 faceLandmarkPoint, CGRect faceBoundingBox, xm_nuint_t imageWidth, xm_nuint_t imageHeight);
static vision_func static vision_func
get_vision_func (const char *func_name, const char **error_msg) get_vision_func (const char *func_name, const char **error_msg)

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

@ -52,7 +52,7 @@
new XDelegate ("MonoObject *", "IntPtr", "xamarin_get_block_wrapper_creator", new XDelegate ("MonoObject *", "IntPtr", "xamarin_get_block_wrapper_creator",
"MonoObject *", "IntPtr", "method", "MonoObject *", "IntPtr", "method",
"int", "int", "parameter" "unsigned long", "uint", "parameter"
) { ) {
WrappedManagedFunction = "GetBlockWrapperCreator", WrappedManagedFunction = "GetBlockWrapperCreator",
OnlyDynamicUsage = true, OnlyDynamicUsage = true,
@ -203,7 +203,7 @@
new XDelegate ("bool", "bool", "xamarin_is_parameter_out", new XDelegate ("bool", "bool", "xamarin_is_parameter_out",
"MonoReflectionMethod *", "IntPtr", "method", "MonoReflectionMethod *", "IntPtr", "method",
"int", "int", "parameter" "unsigned long", "uint", "parameter"
) { ) {
WrappedManagedFunction = "IsParameterOut", WrappedManagedFunction = "IsParameterOut",
OnlyDynamicUsage = true, OnlyDynamicUsage = true,

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

@ -669,6 +669,7 @@ int xamarin_main (int argc, char **argv, enum XamarinLaunchMode launch_mode)
} }
free (new_argv); free (new_argv);
free (env_argv);
} }
return rv; return rv;

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

@ -23,7 +23,7 @@ void monotouch_start_debugging ();
void monotouch_start_profiling (); void monotouch_start_profiling ();
void monotouch_set_connection_mode (const char *mode); void monotouch_set_connection_mode (const char *mode);
void monotouch_set_monodevelop_port (int port); void monotouch_set_monodevelop_port (long port);
typedef struct { typedef struct {

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

@ -43,10 +43,10 @@
#include "product.h" #include "product.h"
// permanent connection variables // permanent connection variables
static int monodevelop_port = -1; static long monodevelop_port = -1;
static int sdb_fd = -1; static int sdb_fd = -1;
static int heapshot_fd = -1; // this is the socket to write 'heapshot' to to requests heapshots from the profiler static int heapshot_fd = -1; // this is the socket to write 'heapshot' to to requests heapshots from the profiler
static int heapshot_port = -1; static long heapshot_port = -1;
static char *profiler_description = NULL; static char *profiler_description = NULL;
// old variables // old variables
static char *debug_host = NULL; static char *debug_host = NULL;
@ -198,8 +198,8 @@ static volatile int http_connect_counter = 0;
-(int) localDescriptor; -(int) localDescriptor;
-(void) reportCompletion: (bool) success; -(void) reportCompletion: (bool) success;
-(void) connect: (NSString *) ip port: (int) port completionHandler: (void (^)(bool)) completionHandler; -(void) connect: (NSString *) ip port: (unsigned long) port completionHandler: (void (^)(bool)) completionHandler;
-(void) sendData: (void *) buffer length: (int) length; -(void) sendData: (void *) buffer length: (long) length;
/* NSURLSessionDelegate */ /* NSURLSessionDelegate */
-(void) URLSession:(NSURLSession *)session didBecomeInvalidWithError:(NSError *)error; -(void) URLSession:(NSURLSession *)session didBecomeInvalidWithError:(NSError *)error;
@ -223,7 +223,7 @@ xamarin_http_send (void *c)
do { do {
LOG_HTTP ("%i http send reading to send data to fd=%i", connection.id, fd); LOG_HTTP ("%i http send reading to send data to fd=%i", connection.id, fd);
errno = 0; errno = 0;
int rv = read (fd, buf, 1024); long rv = read (fd, buf, 1024);
LOG_HTTP ("%i http send read %i bytes from fd=%i; %i=%s", connection.id, rv, fd, errno, strerror (errno)); LOG_HTTP ("%i http send read %i bytes from fd=%i; %i=%s", connection.id, rv, fd, errno, strerror (errno));
if (rv > 0) { if (rv > 0) {
[connection sendData: buf length: rv]; [connection sendData: buf length: rv];
@ -267,7 +267,7 @@ xamarin_http_send (void *c)
return http_sockets [1]; return http_sockets [1];
} }
-(void) connect: (NSString *) ip port: (int) port completionHandler: (void (^)(bool)) completionHandler -(void) connect: (NSString *) ip port: (unsigned long) port completionHandler: (void (^)(bool)) completionHandler
{ {
LOG_HTTP ("Connecting to: %@:%i", ip, port); LOG_HTTP ("Connecting to: %@:%i", ip, port);
@ -297,19 +297,19 @@ xamarin_http_send (void *c)
http_session = [NSURLSession sessionWithConfiguration: http_session_config delegate: self delegateQueue: NULL]; http_session = [NSURLSession sessionWithConfiguration: http_session_config delegate: self delegateQueue: NULL];
NSURL *downloadURL = [NSURL URLWithString: [NSString stringWithFormat: @"http://%@:%i/download?pid=%i&id=%i&uniqueRequest=%i", self.ip, monodevelop_port, getpid (), self.id, self.uniqueRequest]]; NSURL *downloadURL = [NSURL URLWithString: [NSString stringWithFormat: @"http://%@:%li/download?pid=%i&id=%i&uniqueRequest=%i", self.ip, monodevelop_port, getpid (), self.id, self.uniqueRequest]];
NSURLSessionDataTask *downloadTask = [http_session dataTaskWithURL: downloadURL]; NSURLSessionDataTask *downloadTask = [http_session dataTaskWithURL: downloadURL];
[downloadTask resume]; [downloadTask resume];
LOG_HTTP ("%i Connecting to: %@:%i downloadTask: %@", self.id, ip, port, [[downloadTask currentRequest] URL]); LOG_HTTP ("%i Connecting to: %@:%i downloadTask: %@", self.id, ip, port, [[downloadTask currentRequest] URL]);
} }
-(void) sendData: (void *) buffer length: (int) length -(void) sendData: (void *) buffer length: (long) length
{ {
int c = atomic_fetch_add (&http_send_counter, 1); int c = atomic_fetch_add (&http_send_counter, 1);
NSURL *uploadURL = [NSURL URLWithString: [NSString stringWithFormat: @"http://%@:%i/upload?pid=%i&id=%i&upload-id=%i", self.ip, monodevelop_port, getpid (), self.id, c]]; NSURL *uploadURL = [NSURL URLWithString: [NSString stringWithFormat: @"http://%@:%li/upload?pid=%i&id=%i&upload-id=%i", self.ip, monodevelop_port, getpid (), self.id, c]];
LOG_HTTP ("%i sendData length: %i url: %@", self.id, length, uploadURL); LOG_HTTP ("%i sendData length: %li url: %@", self.id, length, uploadURL);
NSMutableURLRequest *uploadRequest = [[[NSMutableURLRequest alloc] initWithURL: uploadURL] autorelease]; NSMutableURLRequest *uploadRequest = [[[NSMutableURLRequest alloc] initWithURL: uploadURL] autorelease];
uploadRequest.HTTPMethod = @"POST"; uploadRequest.HTTPMethod = @"POST";
NSURLSessionUploadTask *uploadTask = [http_session uploadTaskWithRequest: uploadRequest fromData: [NSData dataWithBytes: buffer length: length]]; NSURLSessionUploadTask *uploadTask = [http_session uploadTaskWithRequest: uploadRequest fromData: [NSData dataWithBytes: buffer length: length]];
@ -344,7 +344,7 @@ xamarin_http_send (void *c)
[data enumerateByteRangesUsingBlock: ^(const void *bytes, NSRange byteRange, BOOL *stop) { [data enumerateByteRangesUsingBlock: ^(const void *bytes, NSRange byteRange, BOOL *stop) {
int fd = self.localDescriptor; int fd = self.localDescriptor;
int wr; long wr;
NSUInteger total = byteRange.length; NSUInteger total = byteRange.length;
NSUInteger left = total; NSUInteger left = total;
while (left > 0) { while (left > 0) {
@ -381,7 +381,7 @@ monotouch_set_connection_mode (const char *mode)
} }
void void
monotouch_set_monodevelop_port (int port) monotouch_set_monodevelop_port (long port)
{ {
monodevelop_port = port; monodevelop_port = port;
} }
@ -572,7 +572,7 @@ void monotouch_configure_debugging ()
evar = getenv ("__XAMARIN_DEBUG_HOSTS__"); evar = getenv ("__XAMARIN_DEBUG_HOSTS__");
if (evar && *evar) { if (evar && *evar) {
NSArray *ips = [[NSString stringWithUTF8String:evar] componentsSeparatedByString:@";"]; NSArray *ips = [[NSString stringWithUTF8String:evar] componentsSeparatedByString:@";"];
for (int i = 0; i < [ips count]; i++) { for (unsigned int i = 0; i < [ips count]; i++) {
NSString *ip = [ips objectAtIndex:i]; NSString *ip = [ips objectAtIndex:i];
if (![hosts containsObject:ip]) { if (![hosts containsObject:ip]) {
[hosts addObject:ip]; [hosts addObject:ip];
@ -617,7 +617,7 @@ void monotouch_configure_debugging ()
} while (*++nline); } while (*++nline);
if (!strncmp (line, "__XAMARIN_DEBUG_PORT__=", 23)) { if (!strncmp (line, "__XAMARIN_DEBUG_PORT__=", 23)) {
int shm_monodevelop_port = strtol (line + 23, NULL, 10); long shm_monodevelop_port = strtol (line + 23, NULL, 10);
if (monodevelop_port == -1) { if (monodevelop_port == -1) {
monodevelop_port = shm_monodevelop_port; monodevelop_port = shm_monodevelop_port;
LOG (PRODUCT ": Found port %i in shared memory\n", monodevelop_port); LOG (PRODUCT ": Found port %i in shared memory\n", monodevelop_port);
@ -736,7 +736,7 @@ static void sdb_close2 (void)
static gboolean send_uninterrupted (int fd, const void *buf, int len) static gboolean send_uninterrupted (int fd, const void *buf, int len)
{ {
int res; long res;
do { do {
res = send (fd, buf, len, 0); res = send (fd, buf, len, 0);
@ -747,7 +747,7 @@ static gboolean send_uninterrupted (int fd, const void *buf, int len)
static int recv_uninterrupted (int fd, void *buf, int len) static int recv_uninterrupted (int fd, void *buf, int len)
{ {
int res; long res;
int total = 0; int total = 0;
int flags = 0; int flags = 0;
@ -795,7 +795,7 @@ static XamarinHttpConnection *connected_connection = NULL;
static NSString *connected_ip = NULL; static NSString *connected_ip = NULL;
static pthread_cond_t connected_event = PTHREAD_COND_INITIALIZER; static pthread_cond_t connected_event = PTHREAD_COND_INITIALIZER;
static pthread_mutex_t connected_mutex = PTHREAD_MUTEX_INITIALIZER; static pthread_mutex_t connected_mutex = PTHREAD_MUTEX_INITIALIZER;
static int pending_connections = 0; static unsigned long pending_connections = 0;
void void
xamarin_connect_http (NSMutableArray *ips) xamarin_connect_http (NSMutableArray *ips)
@ -803,7 +803,7 @@ xamarin_connect_http (NSMutableArray *ips)
// COOP: this is at startup and doesn't access managed memory, so we should be in safe mode here. // COOP: this is at startup and doesn't access managed memory, so we should be in safe mode here.
MONO_ASSERT_GC_STARTING; MONO_ASSERT_GC_STARTING;
int ip_count = [ips count]; unsigned long ip_count = [ips count];
NSMutableArray<XamarinHttpConnection *> *connections = NULL; NSMutableArray<XamarinHttpConnection *> *connections = NULL;
if (ip_count == 0) { if (ip_count == 0) {
@ -811,7 +811,7 @@ xamarin_connect_http (NSMutableArray *ips)
return; return;
} }
NSLog (@PRODUCT ": Connecting to %i IPs.", ip_count); NSLog (@PRODUCT ": Connecting to %lu IPs.", ip_count);
connections = [[[NSMutableArray<XamarinHttpConnection *> alloc] init] autorelease]; connections = [[[NSMutableArray<XamarinHttpConnection *> alloc] init] autorelease];
@ -828,7 +828,7 @@ xamarin_connect_http (NSMutableArray *ips)
pthread_mutex_unlock (&connected_mutex); pthread_mutex_unlock (&connected_mutex);
pending_connections = [ips count]; pending_connections = [ips count];
for (int i = 0; i < [ips count]; i++) { for (unsigned int i = 0; i < [ips count]; i++) {
XamarinHttpConnection *connection = [[[XamarinHttpConnection alloc] init] autorelease]; XamarinHttpConnection *connection = [[[XamarinHttpConnection alloc] init] autorelease];
connection.ip = [ips objectAtIndex: i]; connection.ip = [ips objectAtIndex: i];
connection.uniqueRequest = unique_request; connection.uniqueRequest = unique_request;
@ -875,14 +875,15 @@ monotouch_connect_wifi (NSMutableArray *ips)
// COOP: this is at startup and doesn't access managed memory, so we should be in safe mode here. // COOP: this is at startup and doesn't access managed memory, so we should be in safe mode here.
MONO_ASSERT_GC_STARTING; MONO_ASSERT_GC_STARTING;
int listen_port = monodevelop_port; long listen_port = monodevelop_port;
unsigned char sockaddr[sizeof (struct sockaddr_in6)]; unsigned char sockaddr[sizeof (struct sockaddr_in6)];
struct sockaddr_in6 *sin6 = (struct sockaddr_in6 *) sockaddr; struct sockaddr_in6 *sin6 = (struct sockaddr_in6 *) sockaddr;
struct sockaddr_in *sin = (struct sockaddr_in *) sockaddr; struct sockaddr_in *sin = (struct sockaddr_in *) sockaddr;
int family, waiting, len, rv, i; int family, waiting, len, rv;
int ip_count = [ips count]; unsigned long i, connection_port;
bool connected;
unsigned long ip_count = [ips count];
const char *family_str; const char *family_str;
int connected;
const char *ip; const char *ip;
int *sockets; int *sockets;
long flags; long flags;
@ -899,7 +900,7 @@ monotouch_connect_wifi (NSMutableArray *ips)
// Open a socket and try to establish a connection for each IP // Open a socket and try to establish a connection for each IP
do { do {
waiting = 0; waiting = 0;
connected = -1; connected = false;
for (i = 0; i < ip_count; i++) { for (i = 0; i < ip_count; i++) {
if (sockets [i] == -1) if (sockets [i] == -1)
continue; continue;
@ -937,7 +938,8 @@ monotouch_connect_wifi (NSMutableArray *ips)
// Connect to the host // Connect to the host
if ((rv = connect (sockets[i], (struct sockaddr *) sockaddr, len)) == 0) { if ((rv = connect (sockets[i], (struct sockaddr *) sockaddr, len)) == 0) {
// connection completed, this is our man. // connection completed, this is our man.
connected = i; connection_port = i;
connected = true;
break; break;
} }
@ -953,7 +955,7 @@ monotouch_connect_wifi (NSMutableArray *ips)
} }
// Wait for async socket connections to become available // Wait for async socket connections to become available
while (connected == -1 && waiting > 0) { while (!connected && waiting > 0) {
socklen_t optlen = sizeof (int); socklen_t optlen = sizeof (int);
fd_set rset, wset, xset; fd_set rset, wset, xset;
struct timeval tv; struct timeval tv;
@ -1028,27 +1030,28 @@ monotouch_connect_wifi (NSMutableArray *ips)
} }
// success! // success!
connected = i; connected = true;
connection_port = i;
break; break;
} }
} }
if (connected == -1) { if (!connected) {
free (sockets); free (sockets);
return; return;
} }
// close the remaining sockets // close the remaining sockets
for (i = 0; i < ip_count; i++) { for (i = 0; i < ip_count; i++) {
if (i == connected || sockets[i] < 0) if (i == connection_port || sockets[i] < 0)
continue; continue;
close (sockets[i]); close (sockets[i]);
sockets[i] = -1; sockets[i] = -1;
} }
LOG (PRODUCT ": Established connection with the IDE (fd: %i)\n", sockets [connected]); LOG (PRODUCT ": Established connection with the IDE (fd: %i)\n", sockets [connection_port]);
} while (monotouch_process_connection (sockets [connected])); } while (monotouch_process_connection (sockets [connection_port]));
free (sockets); free (sockets);
@ -1061,7 +1064,7 @@ monotouch_connect_usb ()
// COOP: this is at startup and doesn't access managed memory, so we should be in safe mode here. // COOP: this is at startup and doesn't access managed memory, so we should be in safe mode here.
MONO_ASSERT_GC_STARTING; MONO_ASSERT_GC_STARTING;
int listen_port = monodevelop_port; long listen_port = monodevelop_port;
struct sockaddr_in listen_addr; struct sockaddr_in listen_addr;
int listen_socket = -1; int listen_socket = -1;
int fd; int fd;
@ -1184,19 +1187,19 @@ monotouch_dump_objc_api (Class klass)
vars = class_copyIvarList (klass, &c); vars = class_copyIvarList (klass, &c);
printf ("\t%i instance variables:\n", c); printf ("\t%i instance variables:\n", c);
for (int i = 0; i < c; i++) for (unsigned int i = 0; i < c; i++)
printf ("\t\t#%i: %s\n", i + 1, ivar_getName (vars [i])); printf ("\t\t#%i: %s\n", i + 1, ivar_getName (vars [i]));
free (vars); free (vars);
methods = class_copyMethodList (klass, &c); methods = class_copyMethodList (klass, &c);
printf ("\t%i instance methods:\n", c); printf ("\t%i instance methods:\n", c);
for (int i = 0; i < c; i++) for (unsigned int i = 0; i < c; i++)
printf ("\t\t#%i: %s\n", i + 1, sel_getName (method_getName (methods [i]))); printf ("\t\t#%i: %s\n", i + 1, sel_getName (method_getName (methods [i])));
free (methods); free (methods);
props = class_copyPropertyList (klass, &c); props = class_copyPropertyList (klass, &c);
printf ("\t%i instance properties:\n", c); printf ("\t%i instance properties:\n", c);
for (int i = 0; i < c; i++) for (unsigned int i = 0; i < c; i++)
printf ("\t\t#%i: %s\n", i + 1, property_getName (props [i])); printf ("\t\t#%i: %s\n", i + 1, property_getName (props [i]));
free (props); free (props);
@ -1486,10 +1489,12 @@ int monotouch_debug_connect (NSMutableArray *ips, int debug_port, int output_por
unsigned char sockaddr[sizeof (struct sockaddr_in6)]; unsigned char sockaddr[sizeof (struct sockaddr_in6)];
struct sockaddr_in6 *sin6 = (struct sockaddr_in6 *) sockaddr; struct sockaddr_in6 *sin6 = (struct sockaddr_in6 *) sockaddr;
struct sockaddr_in *sin = (struct sockaddr_in *) sockaddr; struct sockaddr_in *sin = (struct sockaddr_in *) sockaddr;
int family, waiting, len, rv, i; int family, waiting, len, rv;
int ip_count = [ips count]; unsigned long i;
unsigned long ip_count = [ips count];
const char *family_str; const char *family_str;
int connected = -1; bool connected = false;
unsigned long connection_port;
const char *ip; const char *ip;
int *sockets; int *sockets;
long flags; long flags;
@ -1539,7 +1544,8 @@ int monotouch_debug_connect (NSMutableArray *ips, int debug_port, int output_por
// Connect to the host // Connect to the host
if ((rv = connect (sockets[i], (struct sockaddr *) sockaddr, len)) == 0) { if ((rv = connect (sockets[i], (struct sockaddr *) sockaddr, len)) == 0) {
// connection completed, this is our man. // connection completed, this is our man.
connected = i; connected = true;
connection_port = i;
break; break;
} }
@ -1555,7 +1561,7 @@ int monotouch_debug_connect (NSMutableArray *ips, int debug_port, int output_por
} }
// Wait for async socket connections to become available // Wait for async socket connections to become available
while (connected == -1 && waiting > 0) { while (!connected && waiting > 0) {
socklen_t optlen = sizeof (int); socklen_t optlen = sizeof (int);
fd_set rset, wset, xset; fd_set rset, wset, xset;
struct timeval tv; struct timeval tv;
@ -1630,30 +1636,31 @@ int monotouch_debug_connect (NSMutableArray *ips, int debug_port, int output_por
} }
// success! // success!
connected = i; connected = true;
connection_port = i;
break; break;
} }
} }
if (connected == -1) { if (!connected) {
free (sockets); free (sockets);
return 1; return 1;
} }
// make the socket block on reads/writes // make the socket block on reads/writes
flags = fcntl (sockets[connected], F_GETFL, NULL); flags = fcntl (sockets[connection_port], F_GETFL, NULL);
fcntl (sockets[connected], F_SETFL, flags & ~O_NONBLOCK); fcntl (sockets[connection_port], F_SETFL, flags & ~O_NONBLOCK);
LOG (PRODUCT ": Connected output to the IDE on %s:%d\n", [[ips objectAtIndex:i] UTF8String], output_port); LOG (PRODUCT ": Connected output to the IDE on %s:%d\n", [[ips objectAtIndex:i] UTF8String], output_port);
dup2 (sockets[connected], 1); dup2 (sockets[connection_port], 1);
dup2 (sockets[connected], 2); dup2 (sockets[connection_port], 2);
debug_host = strdup ([[ips objectAtIndex:connected] UTF8String]); debug_host = strdup ([[ips objectAtIndex:connection_port] UTF8String]);
// close the remaining sockets // close the remaining sockets
for (i = 0; i < ip_count; i++) { for (i = 0; i < ip_count; i++) {
if (i == connected || sockets[i] < 0) if (i == connection_port || sockets[i] < 0)
continue; continue;
close (sockets[i]); close (sockets[i]);

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

@ -94,7 +94,7 @@ assembly_preload_hook (MonoAssemblyName *aname, char **assemblies_path, void* us
// LOG (PRODUCT ": Looking for assembly '%s' (culture: '%s')\n", name, culture); // LOG (PRODUCT ": Looking for assembly '%s' (culture: '%s')\n", name, culture);
int len = strlen (name); size_t len = strlen (name);
int has_extension = len > 3 && name [len - 4] == '.' && (!strcmp ("exe", name + (len - 3)) || !strcmp ("dll", name + (len - 3))); int has_extension = len > 3 && name [len - 4] == '.' && (!strcmp ("exe", name + (len - 3)) || !strcmp ("dll", name + (len - 3)));
bool dual_check = false; bool dual_check = false;

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

@ -9,8 +9,8 @@ extern "C" {
const char * xamarin_get_locale_country_code (); const char * xamarin_get_locale_country_code ();
void xamarin_log (const unsigned short *unicodeMessage); void xamarin_log (const unsigned short *unicodeMessage);
void * xamarin_timezone_get_data (const char *name, int *size); void * xamarin_timezone_get_data (const char *name, unsigned long *size);
char ** xamarin_timezone_get_names (int *count); char ** xamarin_timezone_get_names (unsigned long *count);
char * xamarin_timezone_get_local_name (); char * xamarin_timezone_get_local_name ();
void xamarin_start_wwan (const char *uri); void xamarin_start_wwan (const char *uri);
void xamarin_os_log (os_log_t logger, os_log_type_t type, const char *message); void xamarin_os_log (os_log_t logger, os_log_type_t type, const char *message);

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

@ -16,7 +16,6 @@
#else #else
#error Unknown MONOTOUCH product #error Unknown MONOTOUCH product
#endif #endif
#define PRODUCT_COMPAT_ASSEMBLY "monotouch.dll"
#if TARGET_OS_WATCH #if TARGET_OS_WATCH
#define PRODUCT_DUAL_ASSEMBLY "Xamarin.WatchOS.dll" #define PRODUCT_DUAL_ASSEMBLY "Xamarin.WatchOS.dll"
#elif TARGET_OS_IOS #elif TARGET_OS_IOS
@ -26,7 +25,6 @@
#else #else
#error Unknown MONOTOUCH product for dual assembly #error Unknown MONOTOUCH product for dual assembly
#endif #endif
#define PRODUCT_COMPAT_NAMESPACE "MonoTouch"
#define PRODUCT_EXCEPTION_TYPE "MonoTouchException" #define PRODUCT_EXCEPTION_TYPE "MonoTouchException"
#ifdef __LP64__ #ifdef __LP64__
#define ARCH_SUBDIR ".monotouch-64" #define ARCH_SUBDIR ".monotouch-64"
@ -36,9 +34,7 @@
#elif MONOMAC #elif MONOMAC
#define PRODUCT "Xamarin.Mac" #define PRODUCT "Xamarin.Mac"
#define PRODUCT_COMPAT_ASSEMBLY "XamMac.dll"
#define PRODUCT_DUAL_ASSEMBLY "Xamarin.Mac.dll" #define PRODUCT_DUAL_ASSEMBLY "Xamarin.Mac.dll"
#define PRODUCT_COMPAT_NAMESPACE "MonoMac"
#define PRODUCT_EXCEPTION_TYPE "ObjCException" #define PRODUCT_EXCEPTION_TYPE "ObjCException"
#define ARCH_SUBDIR #define ARCH_SUBDIR
#else #else

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

@ -29,15 +29,6 @@
* the simlauncher binaries). * the simlauncher binaries).
*/ */
#if MONOMAC
bool xamarin_detect_unified_build = true;
#else
// no automatic detection for XI, mtouch should do the right thing in the generated main.
bool xamarin_detect_unified_build = false;
#endif
#if MONOMAC
bool xamarin_use_new_assemblies = false;
#endif
#if DEBUG #if DEBUG
bool xamarin_gc_pump = false; bool xamarin_gc_pump = false;
#endif #endif
@ -713,7 +704,7 @@ xamarin_check_for_gced_object (MonoObject *obj, SEL sel, id self, MonoMethod *me
// //
void void
xamarin_verify_parameter (MonoObject *obj, SEL sel, id self, id arg, int index, MonoClass *expected, MonoMethod *method) xamarin_verify_parameter (MonoObject *obj, SEL sel, id self, id arg, unsigned long index, MonoClass *expected, MonoMethod *method)
{ {
// COOP: Reads managed memory, needs to be in UNSAFE mode // COOP: Reads managed memory, needs to be in UNSAFE mode
MONO_ASSERT_GC_UNSAFE; MONO_ASSERT_GC_UNSAFE;
@ -894,7 +885,7 @@ gc_enable_new_refcount (void)
mono_gc_toggleref_register_callback (gc_toggleref_callback); mono_gc_toggleref_register_callback (gc_toggleref_callback);
xamarin_add_internal_call (xamarin_use_new_assemblies ? "Foundation.NSObject::RegisterToggleRef" : PRODUCT_COMPAT_NAMESPACE ".Foundation.NSObject::RegisterToggleRef", (const void *) gc_register_toggleref); xamarin_add_internal_call ("Foundation.NSObject::RegisterToggleRef", (const void *) gc_register_toggleref);
mono_profiler_install_gc (gc_event_callback, NULL); mono_profiler_install_gc (gc_event_callback, NULL);
} }
@ -1212,35 +1203,6 @@ pump_gc (void *context)
} }
#endif /* DEBUG */ #endif /* DEBUG */
#if MONOMAC
static void
detect_product_assembly ()
{
// COOP: Function only called at startup, I believe the mode here doesn't matter
if (!xamarin_detect_unified_build)
return;
char path [1024];
bool unified;
bool compat;
snprintf (path, sizeof (path), "%s/" ARCH_SUBDIR "/%s", xamarin_get_bundle_path (), PRODUCT_DUAL_ASSEMBLY);
unified = xamarin_file_exists (path);
snprintf (path, sizeof (path), "%s/" ARCH_SUBDIR "/%s", xamarin_get_bundle_path (), PRODUCT_COMPAT_ASSEMBLY);
compat = xamarin_file_exists (path);
if (unified && compat) {
xamarin_assertion_message ("Found both " PRODUCT_COMPAT_ASSEMBLY " and " PRODUCT_DUAL_ASSEMBLY " in the app. Only one can be present");
} else if (!unified && !compat) {
xamarin_assertion_message ("Found neither " PRODUCT_COMPAT_ASSEMBLY " nor " PRODUCT_DUAL_ASSEMBLY " in the app.");
} else if (unified) {
xamarin_use_new_assemblies = true;
} else {
xamarin_use_new_assemblies = false;
}
}
#endif
static void static void
log_callback (const char *log_domain, const char *log_level, const char *message, mono_bool fatal, void *user_data) log_callback (const char *log_domain, const char *log_level, const char *message, mono_bool fatal, void *user_data)
{ {
@ -1329,7 +1291,6 @@ xamarin_initialize ()
MonoAssembly *assembly = NULL; MonoAssembly *assembly = NULL;
MonoMethod *runtime_initialize; MonoMethod *runtime_initialize;
void* params[2]; void* params[2];
const char *product_dll = NULL;
guint32 exception_gchandle = 0; guint32 exception_gchandle = 0;
MonoObject *exc = NULL; MonoObject *exc = NULL;
@ -1347,10 +1308,6 @@ xamarin_initialize ()
xamarin_install_log_callbacks (); xamarin_install_log_callbacks ();
#if MONOMAC
detect_product_assembly ();
#endif
MonoGCFinalizerCallbacks gc_callbacks; MonoGCFinalizerCallbacks gc_callbacks;
gc_callbacks.version = MONO_GC_FINALIZER_EXTENSION_VERSION; gc_callbacks.version = MONO_GC_FINALIZER_EXTENSION_VERSION;
gc_callbacks.is_class_finalization_aware = is_class_finalization_aware; gc_callbacks.is_class_finalization_aware = is_class_finalization_aware;
@ -1365,16 +1322,14 @@ xamarin_initialize ()
NSSetUncaughtExceptionHandler (exception_handler); NSSetUncaughtExceptionHandler (exception_handler);
} }
product_dll = xamarin_use_new_assemblies ? PRODUCT_DUAL_ASSEMBLY : PRODUCT_COMPAT_ASSEMBLY; assembly = xamarin_open_assembly (PRODUCT_DUAL_ASSEMBLY);
assembly = xamarin_open_assembly (product_dll);
if (!assembly) if (!assembly)
xamarin_assertion_message ("Failed to load %s.", product_dll); xamarin_assertion_message ("Failed to load %s.", PRODUCT_DUAL_ASSEMBLY);
platform_image = mono_assembly_get_image (assembly); platform_image = mono_assembly_get_image (assembly);
const char *objcruntime = xamarin_use_new_assemblies ? "ObjCRuntime" : PRODUCT_COMPAT_NAMESPACE ".ObjCRuntime"; const char *objcruntime = "ObjCRuntime";
const char *foundation = xamarin_use_new_assemblies ? "Foundation" : PRODUCT_COMPAT_NAMESPACE ".Foundation"; const char *foundation = "Foundation";
runtime_class = get_class_from_name (platform_image, objcruntime, "Runtime"); runtime_class = get_class_from_name (platform_image, objcruntime, "Runtime");
inativeobject_class = get_class_from_name (platform_image, objcruntime, "INativeObject"); inativeobject_class = get_class_from_name (platform_image, objcruntime, "INativeObject");
@ -1383,8 +1338,8 @@ xamarin_initialize ()
nsvalue_class = get_class_from_name (platform_image, foundation, "NSValue", true); nsvalue_class = get_class_from_name (platform_image, foundation, "NSValue", true);
nsstring_class = get_class_from_name (platform_image, foundation, "NSString", true); nsstring_class = get_class_from_name (platform_image, foundation, "NSString", true);
xamarin_add_internal_call (xamarin_use_new_assemblies ? "Foundation.NSObject::xamarin_release_managed_ref" : PRODUCT_COMPAT_NAMESPACE ".Foundation.NSObject::xamarin_release_managed_ref", (const void *) xamarin_release_managed_ref); xamarin_add_internal_call ("Foundation.NSObject::xamarin_release_managed_ref", (const void *) xamarin_release_managed_ref);
xamarin_add_internal_call (xamarin_use_new_assemblies ? "Foundation.NSObject::xamarin_create_managed_ref" : PRODUCT_COMPAT_NAMESPACE ".Foundation.NSObject::xamarin_create_managed_ref", (const void *) xamarin_create_managed_ref); xamarin_add_internal_call ("Foundation.NSObject::xamarin_create_managed_ref", (const void *) xamarin_create_managed_ref);
runtime_initialize = mono_class_get_method_from_name (runtime_class, "Initialize", 1); runtime_initialize = mono_class_get_method_from_name (runtime_class, "Initialize", 1);
@ -1598,7 +1553,7 @@ objc_skip_type (const char *type)
} }
} }
int unsigned long
xamarin_objc_type_size (const char *type) xamarin_objc_type_size (const char *type)
{ {
const char *original_type = type; const char *original_type = type;
@ -1642,7 +1597,7 @@ xamarin_objc_type_size (const char *type)
xamarin_assertion_message ("Unhandled type encoding: %s", type); xamarin_assertion_message ("Unhandled type encoding: %s", type);
break; break;
case _C_ARY_B: { case _C_ARY_B: {
int size = 0; unsigned long size = 0;
int len = atoi (type+1); int len = atoi (type+1);
do { do {
type++; type++;
@ -1655,7 +1610,7 @@ xamarin_objc_type_size (const char *type)
return len * size; return len * size;
} }
case _C_UNION_B: { case _C_UNION_B: {
int size = 0; unsigned long size = 0;
do { do {
type++; type++;
@ -1670,7 +1625,7 @@ xamarin_objc_type_size (const char *type)
if (*type == 0) if (*type == 0)
xamarin_assertion_message ("Unsupported union type: %s", original_type); xamarin_assertion_message ("Unsupported union type: %s", original_type);
int tsize = xamarin_objc_type_size (type); unsigned long tsize = xamarin_objc_type_size (type);
type = objc_skip_type (type); type = objc_skip_type (type);
tsize = (tsize + (sizeof (void *) - 1)) & ~((sizeof (void *) - 1)); tsize = (tsize + (sizeof (void *) - 1)) & ~((sizeof (void *) - 1));
@ -1680,7 +1635,7 @@ xamarin_objc_type_size (const char *type)
return size; return size;
} }
case _C_STRUCT_B: { case _C_STRUCT_B: {
int size = 0; unsigned long size = 0;
do { do {
type++; type++;
@ -1694,7 +1649,7 @@ xamarin_objc_type_size (const char *type)
while (*type != _C_STRUCT_E) { while (*type != _C_STRUCT_E) {
if (*type == 0) if (*type == 0)
xamarin_assertion_message ("Unsupported struct type: %s", original_type); xamarin_assertion_message ("Unsupported struct type: %s", original_type);
int item_size = xamarin_objc_type_size (type); unsigned long item_size = xamarin_objc_type_size (type);
size += (item_size + (sizeof (void *) - 1)) & ~((sizeof (void *) - 1)); size += (item_size + (sizeof (void *) - 1)) & ~((sizeof (void *) - 1));
@ -2111,7 +2066,7 @@ xamarin_create_managed_ref (id self, gpointer managed_object, bool retain)
typedef struct { typedef struct {
MonoMethod *method; MonoMethod *method;
int par; unsigned long par;
} MethodAndPar; } MethodAndPar;
static gboolean static gboolean
@ -2139,7 +2094,7 @@ static MonoReferenceQueue *block_wrapper_queue;
* create the method * create the method
*/ */
static MonoObject * static MonoObject *
get_method_block_wrapper_creator (MonoMethod *method, int par, guint32 *exception_gchandle) get_method_block_wrapper_creator (MonoMethod *method, unsigned long par, guint32 *exception_gchandle)
{ {
// COOP: accesses managed memory: unsafe mode. // COOP: accesses managed memory: unsafe mode.
MONO_ASSERT_GC_UNSAFE; MONO_ASSERT_GC_UNSAFE;
@ -2207,7 +2162,7 @@ xamarin_release_block_on_main_thread (void *obj)
* Returns: the instantiated delegate. * Returns: the instantiated delegate.
*/ */
int * int *
xamarin_get_delegate_for_block_parameter (MonoMethod *method, guint32 token_ref, int par, void *nativeBlock, guint32 *exception_gchandle) xamarin_get_delegate_for_block_parameter (MonoMethod *method, guint32 token_ref, unsigned long par, void *nativeBlock, guint32 *exception_gchandle)
{ {
// COOP: accesses managed memory: unsafe mode. // COOP: accesses managed memory: unsafe mode.
MONO_ASSERT_GC_UNSAFE; MONO_ASSERT_GC_UNSAFE;
@ -2266,26 +2221,6 @@ xamarin_get_use_sgen ()
return true; return true;
} }
#if MONOMAC
void
xamarin_set_is_unified (bool value)
{
// COOP: no managed memory access: any mode.
if (initialize_started)
xamarin_assertion_message ("Fatal error: xamarin_set_is_unified called after xamarin_initialize.\n");
xamarin_use_new_assemblies = value;
xamarin_detect_unified_build = false;
}
#endif
bool
xamarin_get_is_unified ()
{
// COOP: no managed memory access: any mode.
return xamarin_use_new_assemblies;
}
void void
xamarin_set_gc_pump_enabled (bool value) xamarin_set_gc_pump_enabled (bool value)
{ {
@ -2576,7 +2511,7 @@ xamarin_vprintf (const char *format, va_list args)
void void
xamarin_get_assembly_name_without_extension (const char *aname, char *name, int namelen) xamarin_get_assembly_name_without_extension (const char *aname, char *name, int namelen)
{ {
int len = strlen (aname); size_t len = strlen (aname);
strlcpy (name, aname, namelen); strlcpy (name, aname, namelen);
if (namelen <= 4 || len <= 4) if (namelen <= 4 || len <= 4)
return; return;

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

@ -40,7 +40,7 @@ dump_state (struct XamarinCallState *state, const char *prefix)
#define dump_state(...) #define dump_state(...)
#endif #endif
static int static size_t
param_read_primitive (struct ParamIterator *it, const char *type_ptr, void *target, size_t total_size, guint32 *exception_gchandle) param_read_primitive (struct ParamIterator *it, const char *type_ptr, void *target, size_t total_size, guint32 *exception_gchandle)
{ {
// COOP: does not access managed memory: any mode. // COOP: does not access managed memory: any mode.
@ -182,7 +182,7 @@ param_iter_next (enum IteratorAction action, void *context, const char *type, si
const char *t = struct_name; const char *t = struct_name;
uint8_t *targ = (uint8_t *) target; uint8_t *targ = (uint8_t *) target;
do { do {
int c = param_read_primitive (it, t, targ, size, exception_gchandle); size_t c = param_read_primitive (it, t, targ, size, exception_gchandle);
if (*exception_gchandle != 0) if (*exception_gchandle != 0)
return; return;
if (targ != NULL) if (targ != NULL)
@ -230,7 +230,7 @@ marshal_return_value (void *context, const char *type, size_t size, void *vvalue
(size == 8 && !strncmp (struct_name, "d", 1))) { (size == 8 && !strncmp (struct_name, "d", 1))) {
LOGZ (" marshalling as %i doubles (struct name: %s)\n", (int) size / 8, struct_name); LOGZ (" marshalling as %i doubles (struct name: %s)\n", (int) size / 8, struct_name);
double* ptr = (double *) mono_object_unbox (value); double* ptr = (double *) mono_object_unbox (value);
for (int i = 0; i < size / 8; i++) { for (unsigned long i = 0; i < size / 8; i++) {
LOGZ (" #%i: %f\n", i, ptr [i]); LOGZ (" #%i: %f\n", i, ptr [i]);
it->q [i].d = ptr [i]; it->q [i].d = ptr [i];
} }
@ -240,7 +240,7 @@ marshal_return_value (void *context, const char *type, size_t size, void *vvalue
(size == 4 && !strncmp (struct_name, "f", 1))) { (size == 4 && !strncmp (struct_name, "f", 1))) {
LOGZ (" marshalling as %i floats (struct name: %s)\n", (int) size / 4, struct_name); LOGZ (" marshalling as %i floats (struct name: %s)\n", (int) size / 4, struct_name);
float* ptr = (float *) mono_object_unbox (value); float* ptr = (float *) mono_object_unbox (value);
for (int i = 0; i < size / 4; i++) { for (unsigned long i = 0; i < size / 4; i++) {
LOGZ (" #%i: %f\n", i, ptr [i]); LOGZ (" #%i: %f\n", i, ptr [i]);
it->q [i].f.f1 = ptr [i]; it->q [i].f.f1 = ptr [i];
} }

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

@ -48,7 +48,7 @@ typedef void (*marshal_return_value_func) (void *context, const char *type, size
void xamarin_invoke_trampoline (enum TrampolineType type, id self, SEL sel, iterator_func iterator, marshal_return_value_func marshal_return_value, void *context); void xamarin_invoke_trampoline (enum TrampolineType type, id self, SEL sel, iterator_func iterator, marshal_return_value_func marshal_return_value, void *context);
int xamarin_get_frame_length (id self, SEL sel); unsigned long xamarin_get_frame_length (id self, SEL sel);
const char * xamarin_skip_type_name (const char *ptr); const char * xamarin_skip_type_name (const char *ptr);
#ifdef __cplusplus #ifdef __cplusplus

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

@ -26,7 +26,7 @@ xamarin_get_exception_for_method (int code, guint32 inner_exception_gchandle, co
} }
guint32 guint32
xamarin_get_exception_for_parameter (int code, guint32 inner_exception_gchandle, const char *reason, SEL sel, MonoMethod *method, MonoType *p, int i, bool to_managed) xamarin_get_exception_for_parameter (int code, guint32 inner_exception_gchandle, const char *reason, SEL sel, MonoMethod *method, MonoType *p, unsigned long i, bool to_managed)
{ {
guint32 exception_gchandle = 0; guint32 exception_gchandle = 0;
char *to_name = xamarin_type_get_full_name (p, &exception_gchandle); char *to_name = xamarin_type_get_full_name (p, &exception_gchandle);
@ -114,8 +114,8 @@ xamarin_invoke_trampoline (enum TrampolineType type, id self, SEL sel, iterator_
// pre-prolog // pre-prolog
SList *dispose_list = NULL; SList *dispose_list = NULL;
SList *free_list = NULL; SList *free_list = NULL;
int num_arg; unsigned long num_arg;
int managed_arg_count; unsigned long managed_arg_count;
NSMethodSignature *sig; NSMethodSignature *sig;
if (is_static) { if (is_static) {
@ -134,7 +134,7 @@ xamarin_invoke_trampoline (enum TrampolineType type, id self, SEL sel, iterator_
bool isCategoryInstance; bool isCategoryInstance;
// setup callstack // setup callstack
int frame_length; unsigned long frame_length;
void **arg_frame; void **arg_frame;
void **arg_ptrs; void **arg_ptrs;
void **arg_copy = NULL; // used to detect if ref/out parameters were changed. void **arg_copy = NULL; // used to detect if ref/out parameters were changed.
@ -143,13 +143,13 @@ xamarin_invoke_trampoline (enum TrampolineType type, id self, SEL sel, iterator_
gboolean needs_writeback = FALSE; // determines if there are any ref/out parameters. gboolean needs_writeback = FALSE; // determines if there are any ref/out parameters.
MonoType *p; MonoType *p;
int ofs; int ofs;
int i; unsigned long i;
int mofs = 0; int mofs = 0;
int desc_arg_count = num_arg + 2; /* 1 for the return value + 1 if this is a category instance method */ unsigned long desc_arg_count = num_arg + 2; /* 1 for the return value + 1 if this is a category instance method */
size_t desc_size = desc_arg_count * sizeof (BindAsData) + sizeof (MethodDescription); size_t desc_size = desc_arg_count * sizeof (BindAsData) + sizeof (MethodDescription);
desc = (MethodDescription *) xamarin_calloc (desc_size); desc = (MethodDescription *) xamarin_calloc (desc_size);
desc->bindas_count = desc_arg_count; desc->bindas_count = (int32_t) desc_arg_count;
free_list = s_list_prepend (free_list, desc); free_list = s_list_prepend (free_list, desc);
if (is_ctor || is_static) { if (is_ctor || is_static) {
@ -193,7 +193,7 @@ xamarin_invoke_trampoline (enum TrampolineType type, id self, SEL sel, iterator_
for (i = 0, ofs = 0; i < num_arg; i++) { for (i = 0, ofs = 0; i < num_arg; i++) {
const char *type = xamarin_skip_encoding_flags ([sig getArgumentTypeAtIndex: (i+2)]); const char *type = xamarin_skip_encoding_flags ([sig getArgumentTypeAtIndex: (i+2)]);
int size = xamarin_objc_type_size (type); unsigned long size = xamarin_objc_type_size (type);
int frameofs = ofs; int frameofs = ofs;
p = mono_signature_get_params (msig, &iter); p = mono_signature_get_params (msig, &iter);
@ -415,7 +415,7 @@ xamarin_invoke_trampoline (enum TrampolineType type, id self, SEL sel, iterator_
} }
if (created && obj) { if (created && obj) {
bool is_transient = xamarin_is_parameter_transient (mono_method_get_object (domain, method, NULL), i, &exception_gchandle); bool is_transient = xamarin_is_parameter_transient (mono_method_get_object (domain, method, NULL), (int32_t) i, &exception_gchandle);
if (exception_gchandle != 0) if (exception_gchandle != 0)
goto exception_handling; goto exception_handling;
if (is_transient) if (is_transient)
@ -546,7 +546,7 @@ xamarin_invoke_trampoline (enum TrampolineType type, id self, SEL sel, iterator_
type = xamarin_skip_encoding_flags (type); type = xamarin_skip_encoding_flags (type);
int size = xamarin_objc_type_size (type); unsigned long size = xamarin_objc_type_size (type);
p = mono_signature_get_params (msig, &iter); p = mono_signature_get_params (msig, &iter);

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

@ -48,7 +48,7 @@ dump_state (struct XamarinCallState *state)
static const char* registers[] = { "rdi", "rsi", "rdx", "rcx", "r8", "r9", "err" }; static const char* registers[] = { "rdi", "rsi", "rdx", "rcx", "r8", "r9", "err" };
#endif #endif
static int static unsigned long
param_read_primitive (struct ParamIterator *it, const char **type_ptr, void *target, size_t total_size, guint32 *exception_gchandle) param_read_primitive (struct ParamIterator *it, const char **type_ptr, void *target, size_t total_size, guint32 *exception_gchandle)
{ {
// COOP: does not access managed memory: any mode. // COOP: does not access managed memory: any mode.
@ -119,11 +119,12 @@ param_read_primitive (struct ParamIterator *it, const char **type_ptr, void *tar
uint8_t *ptr; uint8_t *ptr;
bool read_register = true; bool read_register = true;
if (it->byte_count >= 48) { // 48 == 6 registers * 8 bytes unsigned long register_size = 48; // 48 == 6 registers * 8 bytes
if ((unsigned long)it->byte_count >= register_size) {
read_register = false; read_register = false;
} else if (48 - it->byte_count < total_size) { } else if (register_size - it->byte_count < total_size) {
read_register = false; read_register = false;
LOGZ (" total size (%i) is less that available register size (%i)", (int) total_size, 48 - it->byte_count); LOGZ (" total size (%i) is less that available register size (%i)", (int) total_size, register_size - it->byte_count);
} }
if (read_register) { if (read_register) {
@ -226,7 +227,7 @@ param_iter_next (enum IteratorAction action, void *context, const char *type, si
if (*t == 0) if (*t == 0)
break; break;
int c = param_read_primitive (it, &t, targ, size, exception_gchandle); unsigned long c = param_read_primitive (it, &t, targ, size, exception_gchandle);
if (*exception_gchandle != 0) if (*exception_gchandle != 0)
return; return;
if (targ != NULL) if (targ != NULL)
@ -349,7 +350,7 @@ marshal_return_value (void *context, const char *type, size_t size, void *vvalue
} }
// figure out where to put the values. // figure out where to put the values.
const char *t = xamarin_skip_type_name (type); const char *t = xamarin_skip_type_name (type);
int acc = 0; unsigned long acc = 0;
int stores = 0; int stores = 0;
while (true) { while (true) {
@ -364,7 +365,7 @@ marshal_return_value (void *context, const char *type, size_t size, void *vvalue
} }
bool is_float = *t == _C_FLT || *t == _C_DBL; bool is_float = *t == _C_FLT || *t == _C_DBL;
int s = xamarin_get_primitive_size (*t); unsigned long s = xamarin_get_primitive_size (*t);
t++; t++;

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

@ -80,8 +80,6 @@ xamarin_marshal_return_value_impl (MonoType *mtype, const char *type, MonoObject
/* Any changes in this method probably need to be reflected in the static registrar as well */ /* Any changes in this method probably need to be reflected in the static registrar as well */
switch (type [0]) { switch (type [0]) {
case _C_CLASS: case _C_CLASS:
return xamarin_get_handle_for_inativeobject (retval, exception_gchandle);
case _C_SEL: case _C_SEL:
return xamarin_get_handle_for_inativeobject (retval, exception_gchandle); return xamarin_get_handle_for_inativeobject (retval, exception_gchandle);
@ -134,10 +132,10 @@ xamarin_marshal_return_value_impl (MonoType *mtype, const char *type, MonoObject
} }
static guint32 static guint32
xamarin_get_exception_for_element_conversion_failure (guint32 inner_exception_gchandle, int index) xamarin_get_exception_for_element_conversion_failure (guint32 inner_exception_gchandle, unsigned long index)
{ {
guint32 exception_gchandle = 0; guint32 exception_gchandle = 0;
char *msg = xamarin_strdup_printf ("Failed to marshal the value at index %i.", index); char *msg = xamarin_strdup_printf ("Failed to marshal the value at index %lu.", index);
exception_gchandle = xamarin_create_product_exception_with_inner_exception (8036, inner_exception_gchandle, msg); exception_gchandle = xamarin_create_product_exception_with_inner_exception (8036, inner_exception_gchandle, msg);
xamarin_free (msg); xamarin_free (msg);
return exception_gchandle; return exception_gchandle;
@ -445,7 +443,7 @@ xamarin_collapse_struct_name (const char *type, char struct_name[], int max_char
return true; return true;
} }
int unsigned long
xamarin_get_frame_length (id self, SEL sel) xamarin_get_frame_length (id self, SEL sel)
{ {
if (self == NULL) if (self == NULL)
@ -455,7 +453,7 @@ xamarin_get_frame_length (id self, SEL sel)
// which NSMethodSignature chokes on: NSInvalidArgumentException Reason: +[NSMethodSignature signatureWithObjCTypes:]: unsupported type encoding spec '{?}' // which NSMethodSignature chokes on: NSInvalidArgumentException Reason: +[NSMethodSignature signatureWithObjCTypes:]: unsupported type encoding spec '{?}'
// So instead parse the description ourselves. // So instead parse the description ourselves.
int length = 0; unsigned long length = 0;
[self class]; // There's a bug in the ObjC runtime where we might get an uninitialized Class instance from object_getClass. See #6258. Calling the 'class' selector first makes sure the Class instance is initialized. [self class]; // There's a bug in the ObjC runtime where we might get an uninitialized Class instance from object_getClass. See #6258. Calling the 'class' selector first makes sure the Class instance is initialized.
Class cls = object_getClass (self); Class cls = object_getClass (self);
const char *method_description = get_method_description (cls, sel); const char *method_description = get_method_description (cls, sel);
@ -467,14 +465,14 @@ xamarin_get_frame_length (id self, SEL sel)
length = [sig frameLength]; length = [sig frameLength];
} @catch (NSException *ex) { } @catch (NSException *ex) {
length = sizeof (void *) * 64; // some high-ish number. length = sizeof (void *) * 64; // some high-ish number.
fprintf (stderr, PRODUCT ": Failed to calculate the frame size for the method [%s %s] (%s). Using a value of %i instead.\n", class_getName (cls), sel_getName (sel), [[ex description] UTF8String], length); fprintf (stderr, PRODUCT ": Failed to calculate the frame size for the method [%s %s] (%s). Using a value of %lu instead.\n", class_getName (cls), sel_getName (sel), [[ex description] UTF8String], length);
} }
} else { } else {
// The format of the method type encoding is described here: http://stackoverflow.com/a/11492151/183422 // The format of the method type encoding is described here: http://stackoverflow.com/a/11492151/183422
// the return type might have a number after it, which is the size of the argument frame // the return type might have a number after it, which is the size of the argument frame
// first get this number (if it's there), and use it as a minimum value for the frame length // first get this number (if it's there), and use it as a minimum value for the frame length
int rvlength = get_type_description_length (desc); int rvlength = get_type_description_length (desc);
int min_length = 0; unsigned long min_length = 0;
if (rvlength > 0) { if (rvlength > 0) {
const char *min_start = desc + rvlength; const char *min_start = desc + rvlength;
// the number is at the end of the return type encoding, so find any numbers // the number is at the end of the return type encoding, so find any numbers
@ -492,7 +490,7 @@ xamarin_get_frame_length (id self, SEL sel)
// skip the return value. // skip the return value.
desc += rvlength; desc += rvlength;
while (*desc) { while (*desc) {
int tl = xamarin_objc_type_size (desc); unsigned long tl = xamarin_objc_type_size (desc);
// round up to pointer size // round up to pointer size
if (tl % sizeof (void *) != 0) if (tl % sizeof (void *) != 0)
tl += sizeof (void *) - (tl % sizeof (void *)); tl += sizeof (void *) - (tl % sizeof (void *));
@ -615,7 +613,7 @@ xamarin_release_trampoline (id self, SEL sel)
// COOP: does not access managed memory: any mode, but it assumes safe mode upon entry (it takes locks, and doesn't switch to safe mode). // COOP: does not access managed memory: any mode, but it assumes safe mode upon entry (it takes locks, and doesn't switch to safe mode).
MONO_ASSERT_GC_SAFE_OR_DETACHED; MONO_ASSERT_GC_SAFE_OR_DETACHED;
int ref_count; unsigned long ref_count;
bool detach = false; bool detach = false;
pthread_mutex_lock (&refcount_mutex); pthread_mutex_lock (&refcount_mutex);
@ -1308,11 +1306,6 @@ xamarin_get_nsvalue_converter (MonoClass *managedType, MonoMethod *method, bool
if (*exception_gchandle != 0) if (*exception_gchandle != 0)
goto exception_handling; goto exception_handling;
#if MONOMAC
if (xamarin_use_new_assemblies && !strncmp (fullname, "MonoMac.", 8))
memmove (fullname, fullname + 8, strlen (fullname) - 7 /* also copy the null char */);
#endif
if (!strcmp (fullname, "Foundation.NSRange")) { if (!strcmp (fullname, "Foundation.NSRange")) {
func = to_managed ? (void *) xamarin_nsvalue_to_nsrange : (void *) xamarin_nsrange_to_nsvalue; func = to_managed ? (void *) xamarin_nsvalue_to_nsrange : (void *) xamarin_nsrange_to_nsvalue;
#if HAVE_UIKIT // yep, these CoreGraphics-looking category methods are defined in UIKit #if HAVE_UIKIT // yep, these CoreGraphics-looking category methods are defined in UIKit
@ -1501,7 +1494,7 @@ xamarin_convert_managed_to_nsarray_with_func (MonoArray *array, xamarin_managed_
if (array == NULL) if (array == NULL)
return NULL; return NULL;
int length = mono_array_length (array); unsigned long length = mono_array_length (array);
if (length == 0) if (length == 0)
return [NSArray array]; return [NSArray array];
@ -1512,7 +1505,7 @@ xamarin_convert_managed_to_nsarray_with_func (MonoArray *array, xamarin_managed_
element_size = mono_class_value_size (element_class, NULL); element_size = mono_class_value_size (element_class, NULL);
ptr = (char *) mono_array_addr_with_size (array, element_size, 0); ptr = (char *) mono_array_addr_with_size (array, element_size, 0);
} }
for (int i = 0; i < length; i++) { for (unsigned long i = 0; i < length; i++) {
MonoObject *value; MonoObject *value;
if (is_value_type) { if (is_value_type) {
value = mono_value_box (mono_domain_get (), element_class, ptr + element_size * i); value = mono_value_box (mono_domain_get (), element_class, ptr + element_size * i);
@ -1539,7 +1532,7 @@ xamarin_convert_nsarray_to_managed_with_func (NSArray *array, MonoClass *managed
if (array == NULL) if (array == NULL)
return NULL; return NULL;
int length = [array count]; unsigned long length = [array count];
MonoArray *rv = mono_array_new (mono_domain_get (), managedElementType, length); MonoArray *rv = mono_array_new (mono_domain_get (), managedElementType, length);
if (length == 0) if (length == 0)
@ -1555,7 +1548,7 @@ xamarin_convert_nsarray_to_managed_with_func (NSArray *array, MonoClass *managed
element_size = mono_class_value_size (managedElementType, NULL); element_size = mono_class_value_size (managedElementType, NULL);
ptr = (char *) mono_array_addr_with_size (rv, element_size, 0); ptr = (char *) mono_array_addr_with_size (rv, element_size, 0);
} }
for (int i = 0; i < length; i++) { for (unsigned long i = 0; i < length; i++) {
if (is_value_type) { if (is_value_type) {
valueptr = convert ([array objectAtIndex: i], valueptr, managedElementType, context, exception_gchandle); valueptr = convert ([array objectAtIndex: i], valueptr, managedElementType, context, exception_gchandle);
memcpy (ptr, valueptr, element_size); memcpy (ptr, valueptr, element_size);

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

@ -1,114 +0,0 @@
//
// launch.h: Public launch code for Xamarin.Mac.
// This header describes the launch sequence of Xamarin.Mac apps.
// This header is public.
//
// Authors:
// Rolf Bjarne Kvinge <rolf@xamarin.com>
//
// Copyright 2014 Xamarin Inc.
//
#ifndef __XAMARIN_LAUNCH_H__
#define __XAMARIN_LAUNCH_H__
#include <Foundation/Foundation.h>
#ifdef __cplusplus
extern "C" {
#endif
/*
* Xamarin.Mac will follow this startup logic:
*
* 1) If found, call the custom initialization function (xamarin_app_initialize). See later in this file how
* to declare this function.
*
* 2) (If not embedding Mono) Search for the system Mono in the following directories:
* a) As specified by the MONO_RUNTIME environment variable.
* b) Otherwise '/Library/Frameworks/Mono.framework/Versions/Current'
*
* 3) Ensure the following environment variables are set:
*
* appdir = /full/path/to/theapp.app ([[NSBundle mainBundle] bundlePath])
* resdir = $appdir/Contents/Resources
* bindir = $appdir/Contents/MacOS
* monodir = the path to the Mono runtime (as found in point 2 above)
*
* If not embedding Mono:
*
* DYLD_FALLBACK_LIBRARY_PATH=$resdir/lib:$monodir/lib:$DYLD_FALLBACK_LIBRARY_PATH
* PKG_CONFIG_PATH=/Library/Frameworks/Mono.framework/External/pkgconfig:$resdir/lib/pkgconfig:$resdir/share/pkgconfig:$PKG_CONFIG_PATH
* MONO_GAC_PREFIX=$resdir:$MONO_GAC_PREFIX
* PATH=$bindir:$PATH
*
* If embedding Mono:
*
* MONO_DISABLE_SHARED_AREA=1
* MONO_REGISTRY_PATH=~/Library/Application Support (NSApplicationSupportDirectory/$appid)
*
* The app does not need to set these variables. The app may end up relaunching in
* this process (some environment variables only take effect upon initial load, in
* particular any DYLD_* variables).
*
* 3b) (If embedding Mono) Change the current directory to $appdir/Contents/Resources
*
* 4) Ensure that the maximum number of open files is least 1024.
*
* 5) Verify the minimum Mono version. The minimum mono version is specified in:
* a) The bundle's Info.plist's MonoMinimumVersion field.
* b) The bundle's Info.plist's MonoMinVersion field.
* c) The minimum mono version Xamarin.Mac requires (currently 3.10)
*
* If the minimum Mono version requirement can't be met, a dialog will show an error
* and the app will exit.
*
* 6) Find the executable. The name is:
* a) The bundle's Info.plist's MonoBundleExecutable field.
* b) Otherwise the name of the executable + ".exe"
*
* The directory is by default the bundle's Contents/MonoBundle directory, but can be changed
* by calling xamarin_set_bundle_path.
*
* If the executable can't be found, a dialog will show an error and the app will exit.
*
* 7a) [If not embedding Mono] Don't parse any config files, leave it to the Mono runtime to load the defaults.
*
* 7b) [If embedding Mono] Parse $appdir/Contents/MonoBundle/machine.config and $appdir/Contents/MonoBundle/config
* (It is not an error to not find these files, but the app will most likely not work)
*
*/
/*
* To have a custom initialization method link a static library into the app,
* and include a function called 'xamarin_app_initialize'. The method will be
* called as described above.
*
* Example mmp command line:
* mmp --output pathToApp --name MyApp --no-root-assembly --profile=xammac --link_flags="-force_load custom-init.a" --use-system-mono --arch i386
*
* "-force_load" is required, because otherwise the native linker will see that
* it's not used, and remove it.
*/
typedef struct xamarin_initialize_data {
/* Input arguments */
int size; /* The size of this structure */
int argc;
char **argv;
bool is_relaunch; /* If we've been respawned or not */
const char *basename;
NSString *app_dir; /* The bundle directory */
/* Output arguments */
bool exit; // If initialization failed and the app should exit.
int exit_code; // The exit code to return if initialization failed.
bool requires_relaunch; // if the launcher should respawn itself (setting some environment variables require this, in particular DYLD_* variables). This is ignored if 'is_relaunch' is true.
enum XamarinLaunchMode launch_mode;
} xamarin_initialize_data;
typedef void (*xamarin_custom_initialize_func) (xamarin_initialize_data *data);
#ifdef __cplusplus
} /* extern "C" */
#endif
#endif /* __XAMARIN_LAUNCH_H__ */

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

@ -1,102 +0,0 @@
//
// main.h: Basic startup code for Xamarin.iOS/Xamarin.Mac
// This header contains definitions used by Xamarin when building applications.
// Do not consider anything here stable API (unless otherwise specified),
// it will change between releases.
//
// Authors:
// Rolf Bjarne Kvinge <rolf@xamarin.com>
//
// Copyright 2012-2014 Xamarin Inc.
//
#include <Foundation/Foundation.h>
#ifndef __XAMARIN_MAIN_H__
#define __XAMARIN_MAIN_H__
#ifdef __cplusplus
extern "C" {
#endif
/* This enum must always match the identical enum in src/ObjCRuntime/ExceptionMode.cs */
enum MarshalObjectiveCExceptionMode : int {
MarshalObjectiveCExceptionModeDefault = 0,
MarshalObjectiveCExceptionModeUnwindManagedCode = 1,
MarshalObjectiveCExceptionModeThrowManagedException = 2,
MarshalObjectiveCExceptionModeAbort = 3,
MarshalObjectiveCExceptionModeDisable = 4,
};
/* This enum must always match the identical enum in src/ObjCRuntime/ExceptionMode.cs */
enum MarshalManagedExceptionMode : int {
MarshalManagedExceptionModeDefault = 0,
MarshalManagedExceptionModeUnwindNativeCode = 1,
MarshalManagedExceptionModeThrowObjectiveCException = 2,
MarshalManagedExceptionModeAbort = 3,
MarshalManagedExceptionModeDisable = 4,
};
/* This enum must always match the identical enum in src/ObjCRuntime/Runtime.cs */
enum XamarinLaunchMode {
XamarinLaunchModeApp = 0,
XamarinLaunchModeExtension = 1,
XamarinLaunchModeEmbedded = 2,
};
extern bool mono_use_llvm; // this is defined inside mono
#if MONOMAC
extern bool xamarin_use_new_assemblies;
#else
#define xamarin_use_new_assemblies 1
#endif
#if DEBUG
extern bool xamarin_gc_pump;
#endif
extern bool xamarin_debug_mode;
extern bool xamarin_disable_lldb_attach;
#if MONOMAC
extern bool xamarin_mac_hybrid_aot;
extern bool xamarin_mac_modern;
extern char *xamarin_entry_assembly_path;
#endif
extern bool xamarin_init_mono_debug;
extern int xamarin_log_level;
extern const char *xamarin_executable_name;
extern const char *xamarin_arch_name;
extern bool xamarin_is_gc_coop;
extern enum MarshalObjectiveCExceptionMode xamarin_marshal_objectivec_exception_mode;
extern enum MarshalManagedExceptionMode xamarin_marshal_managed_exception_mode;
extern enum XamarinLaunchMode xamarin_launch_mode;
extern bool xamarin_supports_dynamic_registration;
typedef void (*xamarin_setup_callback) ();
typedef int (*xamarin_extension_main_callback) (int argc, char** argv);
extern xamarin_setup_callback xamarin_setup;
extern xamarin_extension_main_callback xamarin_extension_main;
void xamarin_set_use_sgen (bool value); /* Public API, but a no-op (only SGen is supported, so it defaults to true) */
bool xamarin_get_use_sgen (); /* Public API, always returns true */
void xamarin_set_is_unified (bool value); /* Public API */
bool xamarin_get_is_unified (); /* Public API */
int xamarin_get_launch_mode ();
int xamarin_watchextension_main (int argc, char **argv);
#ifndef MONOTOUCH
void xamarin_set_is_mkbundle (bool value); /* Not Public API, exact semantics is not defined yet */
bool xamarin_get_is_mkbundle (); /* Not Public API, exact semantics is not defined yet */
#endif
void xamarin_set_is_debug (bool value); /* Public API */
bool xamarin_get_is_debug (); /* Public API */
#ifdef __cplusplus
} /* extern "C" */
#endif
#endif /* __XAMARIN_MAIN_H__ */

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

@ -1,844 +0,0 @@
// vim: set filetype=c :
//
// mono-runtime.h: Header file to allow dynamic loading of
// Mono to be transparent from code including this header.
//
// Authors:
// Rolf Bjarne Kvinge <rolf@xamarin.com>
// Aaron Bockover <abock@xamarin.com>
//
// Copyright 2013-2014 Xamarin Inc.
//
#ifndef __MONO_RUNTIME__
#define __MONO_RUNTIME__
#ifdef __cplusplus
extern "C" {
#endif
/* This is copied from eglib's header files */
typedef unsigned int guint;
typedef int32_t gboolean;
typedef int32_t gint32;
typedef uint32_t guint32;
typedef char gchar;
typedef void * gpointer;
typedef const void * gconstpointer;
typedef guint (*GHashFunc) (gconstpointer key);
typedef gboolean (*GEqualFunc) (gconstpointer a, gconstpointer b);
#ifndef GPOINTER_TO_INT
#define GPOINTER_TO_INT(p) ((int) (long) (p))
#endif
#ifndef GINT_TO_POINTER
#define GINT_TO_POINTER(i) ((void *) (long) (i))
#endif
#include <stdint.h>
const char * xamarin_initialize_dynamic_runtime (const char *mono_runtime_prefix);
char *xamarin_get_mono_runtime_build_info (); // returns NULL if libmono couldn't be found (mono_get_runtime_build_info doesn't exist).
#ifdef DYNAMIC_MONO_RUNTIME
#define mono_class_from_name mono_class_from_name_impl
#define mono_class_get_method_from_name mono_class_get_method_from_name_impl
#define mono_class_get_field_from_name mono_class_get_field_from_name_impl
#define mono_class_is_assignable_from mono_class_is_assignable_from_impl
#define mono_class_from_mono_type mono_class_from_mono_type_impl
#define mono_class_is_delegate mono_class_is_delegate_impl
#define mono_class_get_element_class mono_class_get_element_class_impl
#define mono_class_get_namespace mono_class_get_namespace_impl
#define mono_class_get_name mono_class_get_name_impl
#define mono_class_get_parent mono_class_get_parent_impl
#define mono_class_is_subclass_of mono_class_is_subclass_of_impl
#define mono_class_is_valuetype mono_class_is_valuetype_impl
#define mono_class_is_enum mono_class_is_enum_impl
#define mono_class_enum_basetype mono_class_enum_basetype_impl
#define mono_class_value_size mono_class_value_size_impl
#define mono_class_get_type mono_class_get_type_impl
#define mono_class_is_nullable mono_class_is_nullable_impl
#define mono_class_get_nullable_param mono_class_get_nullable_param_impl
#define mono_method_full_name mono_method_full_name_impl
#define mono_runtime_invoke mono_runtime_invoke_impl
#define mono_gchandle_new mono_gchandle_new_impl
#define mono_gchandle_get_target mono_gchandle_get_target_impl
#define mono_gchandle_free mono_gchandle_free_impl
#define mono_gchandle_new_weakref mono_gchandle_new_weakref_impl
#define mono_raise_exception mono_raise_exception_impl
#define mono_array_addr_with_size mono_array_addr_with_size_impl
#define mono_string_new mono_string_new_impl
#define mono_array_new mono_array_new_impl
#define mono_object_unbox mono_object_unbox_impl
#define mono_string_to_utf8 mono_string_to_utf8_impl
#define mono_object_new mono_object_new_impl
#define mono_array_length mono_array_length_impl
#define mono_object_isinst mono_object_isinst_impl
#define mono_object_get_class mono_object_get_class_impl
#define mono_object_get_virtual_method mono_object_get_virtual_method_impl
#define mono_field_get_value mono_field_get_value_impl
#define mono_value_box mono_value_box_impl
#define mono_gc_wbarrier_set_arrayref mono_gc_wbarrier_set_arrayref_impl
#define mono_profiler_install mono_profiler_install_impl
#define mono_profiler_install_thread mono_profiler_install_thread_impl
#define mono_profiler_install_gc mono_profiler_install_gc_impl
#define mono_profiler_load mono_profiler_load_impl
#define mono_thread_is_foreign mono_thread_is_foreign_impl
#define mono_thread_current mono_thread_current_impl
#define mono_thread_attach mono_thread_attach_impl
#define mono_thread_detach_if_exiting mono_thread_detach_if_exiting_impl
#define mono_runtime_set_pending_exception mono_runtime_set_pending_exception_impl
#define mono_set_assemblies_path mono_set_assemblies_path_impl
#define mono_assembly_open mono_assembly_open_impl
#define mono_assembly_get_image mono_assembly_get_image_impl
#define mono_assembly_name_new mono_assembly_name_new_impl
#define mono_assembly_name_free mono_assembly_name_free_impl
#define mono_assembly_loaded mono_assembly_loaded_impl
#define mono_register_machine_config mono_register_machine_config_impl
#define mono_set_dirs mono_set_dirs_impl
#define mono_assembly_name_get_name mono_assembly_name_get_name_impl
#define mono_assembly_name_get_culture mono_assembly_name_get_culture_impl
#define mono_install_assembly_preload_hook mono_install_assembly_preload_hook_impl
#define mono_assembly_get_name mono_assembly_get_name_impl
#define mono_add_internal_call mono_add_internal_call_impl
#define mono_dangerous_add_raw_internal_call mono_dangerous_add_raw_internal_call_impl
#define mono_method_signature mono_method_signature_impl
#define mono_method_get_class mono_method_get_class_impl
#define mono_dllmap_insert mono_dllmap_insert_impl
#define mono_domain_get mono_domain_get_impl
#define mono_get_intptr_class mono_get_intptr_class_impl
#define mono_get_string_class mono_get_string_class_impl
#define mono_get_corlib mono_get_corlib_impl
#define mono_get_array_class mono_get_array_class_impl
#define mono_get_exception_class mono_get_exception_class_impl
#define mono_get_root_domain mono_get_root_domain_impl
#define mono_domain_set_config mono_domain_set_config_impl
#define mono_assembly_get_object mono_assembly_get_object_impl
#define mono_method_get_object mono_method_get_object_impl
#define mono_type_get_object mono_type_get_object_impl
#define mono_reflection_type_get_type mono_reflection_type_get_type_impl
#define mono_signature_get_params mono_signature_get_params_impl
#define mono_type_is_byref mono_type_is_byref_impl
#define mono_signature_get_return_type mono_signature_get_return_type_impl
#define mono_type_get_type mono_type_get_type_impl
#define mono_debug_init mono_debug_init_impl
#define mono_gc_collect mono_gc_collect_impl
#define mono_is_debugger_attached mono_is_debugger_attached_impl
#define mono_config_parse_memory mono_config_parse_memory_impl
#define mono_gc_max_generation mono_gc_max_generation_impl
#define mono_g_hash_table_new_type mono_g_hash_table_new_type_impl
#define mono_g_hash_table_lookup mono_g_hash_table_lookup_impl
#define mono_g_hash_table_insert mono_g_hash_table_insert_impl
#define mono_get_exception_execution_engine mono_get_exception_execution_engine_impl
#define mono_exception_from_name_msg mono_exception_from_name_msg_impl
#define mono_gc_reference_queue_new mono_gc_reference_queue_new_impl
#define mono_gc_reference_queue_free mono_gc_reference_queue_free_impl
#define mono_gc_reference_queue_add mono_gc_reference_queue_add_impl
#define mono_gc_register_finalizer_callbacks mono_gc_register_finalizer_callbacks_impl
#define mono_gc_toggleref_add mono_gc_toggleref_add_impl
#define mono_gc_toggleref_register_callback mono_gc_toggleref_register_callback_impl
#define mono_path_resolve_symlinks mono_path_resolve_symlinks_impl
#define mono_free mono_free_impl
#define mono_get_runtime_build_info mono_get_runtime_build_info_impl
#define mono_jit_init_version mono_jit_init_version_impl
#define mono_jit_init mono_jit_init_impl
#define mono_jit_exec mono_jit_exec_impl
#define mono_jit_parse_options mono_jit_parse_options_impl
#define mono_jit_set_aot_mode mono_jit_set_aot_mode_impl
#define mono_set_signal_chaining mono_set_signal_chaining_impl
#define mono_set_crash_chaining mono_set_crash_chaining_impl
#define mono_jit_set_trace_options mono_jit_set_trace_options_impl
#define mono_jit_thread_attach mono_jit_thread_attach_impl
#define mono_exception_walk_trace mono_exception_walk_trace_impl
#define mono_install_unhandled_exception_hook mono_install_unhandled_exception_hook_impl
#define mono_main mono_main_impl
#define mono_install_load_aot_data_hook mono_install_load_aot_data_hook_impl
#define mini_parse_debug_option mini_parse_debug_option_impl
#define mono_trace_set_log_handler mono_trace_set_log_handler_impl
#define mono_trace_set_print_handler mono_trace_set_print_handler_impl
#define mono_trace_set_printerr_handler mono_trace_set_printerr_handler_impl
#define mono_threads_enter_gc_unsafe_region mono_threads_enter_gc_unsafe_region_impl
#define mono_threads_exit_gc_unsafe_region mono_threads_exit_gc_unsafe_region_impl
#define mono_threads_enter_gc_safe_region mono_threads_enter_gc_safe_region_impl
#define mono_threads_exit_gc_safe_region mono_threads_exit_gc_safe_region_impl
#define mono_threads_assert_gc_safe_region mono_threads_assert_gc_safe_region_impl
#define mono_threads_assert_gc_unsafe_region mono_threads_assert_gc_unsafe_region_impl
#define mono_threads_assert_gc_starting_region mono_threads_assert_gc_starting_region_impl
#define mono_thread_info_current_unchecked mono_thread_info_current_unchecked_impl
#define mono_threads_attach_coop mono_threads_attach_coop_impl
#define mono_threads_detach_coop mono_threads_detach_coop_impl
#define mono_install_ftnptr_eh_callback mono_install_ftnptr_eh_callback_impl
#endif
/* This is copied from mono's header files */
/* utils/mono-publib.h */
#define MONO_API
typedef int32_t mono_bool;
/* metadata/image.h */
typedef struct _MonoAssembly MonoAssembly;
typedef struct _MonoAssemblyName MonoAssemblyName;
typedef struct _MonoImage MonoImage;
typedef enum {
MONO_IMAGE_OK,
MONO_IMAGE_ERROR_ERRNO,
MONO_IMAGE_MISSING_ASSEMBLYREF,
MONO_IMAGE_IMAGE_INVALID
} MonoImageOpenStatus;
/* metadata/metadata.h */
typedef struct _MonoClass MonoClass;
typedef struct _MonoDomain MonoDomain;
typedef struct _MonoMethod MonoMethod;
typedef struct _MonoMethodSignature MonoMethodSignature;
typedef struct _MonoType MonoType;
/* metadata/class.h */
typedef struct MonoVTable MonoVTable;
typedef struct _MonoClassField MonoClassField;
/* metadata/object.h */
typedef struct _MonoString MonoString;
typedef struct _MonoArray MonoArray;
typedef struct _MonoReflectionMethod MonoReflectionMethod;
typedef struct _MonoReflectionAssembly MonoReflectionAssembly;
typedef struct _MonoReflectionType MonoReflectionType;
typedef struct _MonoException MonoException;
typedef struct _MonoThread MonoThread;
typedef struct _MonoThreadsSync MonoThreadsSync;
typedef struct {
MonoVTable *vtable;
MonoThreadsSync *synchronisation;
} MonoObject;
typedef struct _MonoReferenceQueue MonoReferenceQueue;
typedef void (*mono_reference_queue_callback) (void *user_data);
#define mono_array_addr(array,type,index) ((type*)(void*) mono_array_addr_with_size (array, sizeof (type), index))
#define mono_array_get(array,type,index) ( *(type*)mono_array_addr ((array), type, (index)) )
#define mono_array_setref(array,index,value) \
do { \
void **__p = (void **) mono_array_addr ((array), void*, (index)); \
mono_gc_wbarrier_set_arrayref ((array), __p, (MonoObject*)(value)); \
/* *__p = (value);*/ \
} while (0)
/* metadata/assembly.h */
typedef MonoAssembly * (*MonoAssemblyPreLoadFunc) (MonoAssemblyName *aname, char **assemblies_path, void* user_data);
/* metadata/profiler.h */
typedef struct _MonoProfiler MonoProfiler;
typedef enum {
MONO_PROFILE_NONE = 0,
MONO_PROFILE_APPDOMAIN_EVENTS = 1 << 0,
MONO_PROFILE_ASSEMBLY_EVENTS = 1 << 1,
MONO_PROFILE_MODULE_EVENTS = 1 << 2,
MONO_PROFILE_CLASS_EVENTS = 1 << 3,
MONO_PROFILE_JIT_COMPILATION = 1 << 4,
MONO_PROFILE_INLINING = 1 << 5,
MONO_PROFILE_EXCEPTIONS = 1 << 6,
MONO_PROFILE_ALLOCATIONS = 1 << 7,
MONO_PROFILE_GC = 1 << 8,
MONO_PROFILE_THREADS = 1 << 9,
MONO_PROFILE_REMOTING = 1 << 10,
MONO_PROFILE_TRANSITIONS = 1 << 11,
MONO_PROFILE_ENTER_LEAVE = 1 << 12,
MONO_PROFILE_COVERAGE = 1 << 13,
MONO_PROFILE_INS_COVERAGE = 1 << 14,
MONO_PROFILE_STATISTICAL = 1 << 15,
MONO_PROFILE_METHOD_EVENTS = 1 << 16,
MONO_PROFILE_MONITOR_EVENTS = 1 << 17,
MONO_PROFILE_IOMAP_EVENTS = 1 << 18, /* this should likely be removed, too */
MONO_PROFILE_GC_MOVES = 1 << 19,
MONO_PROFILE_GC_ROOTS = 1 << 20
} MonoProfileFlags;
typedef enum {
MONO_GC_EVENT_START,
MONO_GC_EVENT_MARK_START,
MONO_GC_EVENT_MARK_END,
MONO_GC_EVENT_RECLAIM_START,
MONO_GC_EVENT_RECLAIM_END,
MONO_GC_EVENT_END,
MONO_GC_EVENT_PRE_STOP_WORLD,
MONO_GC_EVENT_POST_STOP_WORLD,
MONO_GC_EVENT_PRE_START_WORLD,
MONO_GC_EVENT_POST_START_WORLD
} MonoGCEvent;
typedef void (*MonoProfileFunc) (MonoProfiler *prof);
typedef void (*MonoProfileThreadFunc) (MonoProfiler *prof, uintptr_t tid);
typedef void (*MonoProfileGCFunc) (MonoProfiler *prof, MonoGCEvent event, int generation);
typedef void (*MonoProfileGCResizeFunc) (MonoProfiler *prof, int64_t new_size);
/* metadata/mono-debug.h */
typedef enum {
MONO_DEBUG_FORMAT_NONE,
MONO_DEBUG_FORMAT_MONO,
/* Deprecated, the mdb debugger is not longer supported. */
MONO_DEBUG_FORMAT_DEBUGGER
} MonoDebugFormat;
/* metadata/mini.h */
typedef gboolean (*MonoExceptionFrameWalk) (MonoMethod *method, gpointer ip, size_t native_offset, gboolean managed, gpointer user_data);
typedef void (*MonoUnhandledExceptionFunc) (MonoObject *exc, gpointer user_data);
typedef unsigned char* (*MonoLoadAotDataFunc) (MonoAssembly *assembly, int size, gpointer user_data, void **out_handle);
typedef void (*MonoFreeAotDataFunc) (MonoAssembly *assembly, int size, gpointer user_data, void *handle);
/* metadata/blob.h */
/*
* Encoding for type signatures used in the Metadata
*/
typedef enum {
MONO_TYPE_END = 0x00, /* End of List */
MONO_TYPE_VOID = 0x01,
MONO_TYPE_BOOLEAN = 0x02,
MONO_TYPE_CHAR = 0x03,
MONO_TYPE_I1 = 0x04,
MONO_TYPE_U1 = 0x05,
MONO_TYPE_I2 = 0x06,
MONO_TYPE_U2 = 0x07,
MONO_TYPE_I4 = 0x08,
MONO_TYPE_U4 = 0x09,
MONO_TYPE_I8 = 0x0a,
MONO_TYPE_U8 = 0x0b,
MONO_TYPE_R4 = 0x0c,
MONO_TYPE_R8 = 0x0d,
MONO_TYPE_STRING = 0x0e,
MONO_TYPE_PTR = 0x0f, /* arg: <type> token */
MONO_TYPE_BYREF = 0x10, /* arg: <type> token */
MONO_TYPE_VALUETYPE = 0x11, /* arg: <type> token */
MONO_TYPE_CLASS = 0x12, /* arg: <type> token */
MONO_TYPE_VAR = 0x13, /* number */
MONO_TYPE_ARRAY = 0x14, /* type, rank, boundsCount, bound1, loCount, lo1 */
MONO_TYPE_GENERICINST= 0x15, /* <type> <type-arg-count> <type-1> \x{2026} <type-n> */
MONO_TYPE_TYPEDBYREF = 0x16,
MONO_TYPE_I = 0x18,
MONO_TYPE_U = 0x19,
MONO_TYPE_FNPTR = 0x1b, /* arg: full method signature */
MONO_TYPE_OBJECT = 0x1c,
MONO_TYPE_SZARRAY = 0x1d, /* 0-based one-dim-array */
MONO_TYPE_MVAR = 0x1e, /* number */
MONO_TYPE_CMOD_REQD = 0x1f, /* arg: typedef or typeref token */
MONO_TYPE_CMOD_OPT = 0x20, /* optional arg: typedef or typref token */
MONO_TYPE_INTERNAL = 0x21, /* CLR internal type */
MONO_TYPE_MODIFIER = 0x40, /* Or with the following types */
MONO_TYPE_SENTINEL = 0x41, /* Sentinel for varargs method signature */
MONO_TYPE_PINNED = 0x45, /* Local var that points to pinned object */
MONO_TYPE_ENUM = 0x55 /* an enumeration */
} MonoTypeEnum;
/*
* From internal headers
*/
/* metadata/gc-internal.h */
enum {
MONO_GC_FINALIZER_EXTENSION_VERSION = 1,
};
typedef struct {
int version;
gboolean (*is_class_finalization_aware) (MonoClass *klass);
void (*object_queued_for_finalization) (MonoObject *object);
} MonoGCFinalizerCallbacks;
/* metadata/sgen-toggleref.h */
typedef enum {
MONO_TOGGLE_REF_DROP,
MONO_TOGGLE_REF_STRONG,
MONO_TOGGLE_REF_WEAK
} MonoToggleRefStatus;
typedef MonoToggleRefStatus (*MonoToggleRefCallback) (MonoObject *obj);
/* metadata/mono-hash.h */
typedef enum {
MONO_HASH_KEY_GC = 1,
MONO_HASH_VALUE_GC = 2,
MONO_HASH_KEY_VALUE_GC = MONO_HASH_KEY_GC | MONO_HASH_VALUE_GC,
} MonoGHashGCType;
typedef struct _MonoGHashTable MonoGHashTable;
/* utils/mono-logger.h */
typedef void (*MonoLogCallback) (const char *log_domain, const char *log_level, const char *message, mono_bool fatal, void *user_data);
typedef void (*MonoPrintCallback) (const char *string, mono_bool is_stdout);
/* mini/jit.h */
typedef enum {
MONO_AOT_MODE_NONE,
MONO_AOT_MODE_NORMAL,
MONO_AOT_MODE_HYBRID,
MONO_AOT_MODE_FULL,
MONO_AOT_MODE_LLVMONLY,
MONO_AOT_MODE_INTERP,
MONO_AOT_MODE_INTERP_LLVMONLY,
} MonoAotMode;
/* metadata/marshal.h */
typedef void (*MonoFtnPtrEHCallback) (guint32 gchandle);
/* not in any header */
void mono_gc_init_finalizer_thread ();
/*
* The functions we want to expose
*/
MONO_API MonoClass *
mono_class_from_name (MonoImage * image, const char * name_space, const char * name);
MONO_API MonoMethod *
mono_class_get_method_from_name (MonoClass * klass, const char * name, int param_count);
MONO_API MonoClassField *
mono_class_get_field_from_name (MonoClass * klass, const char * name);
MONO_API mono_bool
mono_class_is_assignable_from (MonoClass * klass, MonoClass * oklass);
MONO_API MonoClass *
mono_class_from_mono_type (MonoType * type);
MONO_API mono_bool
mono_class_is_delegate (MonoClass * klass);
MONO_API MonoClass *
mono_class_get_element_class (MonoClass * klass);
MONO_API const char *
mono_class_get_namespace (MonoClass * klass);
MONO_API const char *
mono_class_get_name (MonoClass * klass);
MONO_API MonoClass *
mono_class_get_parent (MonoClass * klass);
MONO_API mono_bool
mono_class_is_subclass_of (MonoClass * klass, MonoClass * klassc, mono_bool check_interfaces);
MONO_API mono_bool
mono_class_is_valuetype (MonoClass * klass);
MONO_API mono_bool
mono_class_is_enum (MonoClass * klass);
MONO_API MonoType *
mono_class_enum_basetype (MonoClass * klass);
MONO_API int32_t
mono_class_value_size (MonoClass * klass, uint32_t * align);
MONO_API MonoType *
mono_class_get_type (MonoClass * klass);
MONO_API gboolean
mono_class_is_nullable (MonoClass * klass);
MONO_API MonoClass *
mono_class_get_nullable_param (MonoClass * klass);
MONO_API char *
mono_method_full_name (MonoMethod * method, mono_bool signature);
MONO_API MonoObject *
mono_runtime_invoke (MonoMethod * method, void * obj, void ** params, MonoObject ** exc);
MONO_API uint32_t
mono_gchandle_new (MonoObject * obj, mono_bool pinned);
MONO_API MonoObject *
mono_gchandle_get_target (uint32_t gchandle);
MONO_API void
mono_gchandle_free (uint32_t gchandle);
MONO_API uint32_t
mono_gchandle_new_weakref (MonoObject * obj, mono_bool track_resurrection);
MONO_API void
mono_raise_exception (MonoException * ex);
MONO_API char*
mono_array_addr_with_size (MonoArray * array, int size, uintptr_t idx);
MONO_API MonoString *
mono_string_new (MonoDomain * domain, const char * text);
MONO_API MonoArray *
mono_array_new (MonoDomain * domain, MonoClass * eclass, uintptr_t n);
MONO_API void *
mono_object_unbox (MonoObject * obj);
MONO_API char *
mono_string_to_utf8 (MonoString * string_obj);
MONO_API MonoObject *
mono_object_new (MonoDomain * domain, MonoClass * klass);
MONO_API uintptr_t
mono_array_length (MonoArray * array);
MONO_API MonoObject *
mono_object_isinst (MonoObject * obj, MonoClass * klass);
MONO_API MonoClass *
mono_object_get_class (MonoObject * obj);
MONO_API MonoMethod *
mono_object_get_virtual_method (MonoObject * obj, MonoMethod * method);
MONO_API void
mono_field_get_value (MonoObject * obj, MonoClassField * field, void * value);
MONO_API MonoObject *
mono_value_box (MonoDomain * domain, MonoClass * klass, void * val);
MONO_API void
mono_gc_wbarrier_set_arrayref (MonoArray * arr, void * slot_ptr, MonoObject * value);
MONO_API void
mono_profiler_install (MonoProfiler * prof, MonoProfileFunc shutdown_callback);
MONO_API void
mono_profiler_install_thread (MonoProfileThreadFunc start, MonoProfileThreadFunc end);
MONO_API void
mono_profiler_install_gc (MonoProfileGCFunc callback, MonoProfileGCResizeFunc heap_resize_callback);
MONO_API void
mono_profiler_load (const char * desc);
MONO_API mono_bool
mono_thread_is_foreign (MonoThread * thread);
MONO_API MonoThread *
mono_thread_current (void);
MONO_API MonoThread *
mono_thread_attach (MonoDomain * domain);
MONO_API mono_bool
mono_thread_detach_if_exiting (void);
MONO_API void
mono_runtime_set_pending_exception (MonoException * exc, mono_bool overwrite);
MONO_API void
mono_set_assemblies_path (const char * path);
MONO_API MonoAssembly *
mono_assembly_open (const char * filename, MonoImageOpenStatus * status);
MONO_API MonoImage *
mono_assembly_get_image (MonoAssembly * assembly);
MONO_API MonoAssemblyName *
mono_assembly_name_new (const char * name);
MONO_API void
mono_assembly_name_free (MonoAssemblyName * aname);
MONO_API MonoAssembly *
mono_assembly_loaded (MonoAssemblyName * aname);
MONO_API void
mono_register_machine_config (const char * config_xml);
MONO_API void
mono_set_dirs (const char * assembly_dir, const char * config_dir);
MONO_API const char *
mono_assembly_name_get_name (MonoAssemblyName * aname);
MONO_API const char *
mono_assembly_name_get_culture (MonoAssemblyName * aname);
MONO_API void
mono_install_assembly_preload_hook (MonoAssemblyPreLoadFunc func, void * user_data);
MONO_API MonoAssemblyName *
mono_assembly_get_name (MonoAssembly * assembly);
MONO_API void
mono_add_internal_call (const char * name, const void * method);
MONO_API void
mono_dangerous_add_raw_internal_call (const char * name, const void * method);
MONO_API MonoMethodSignature *
mono_method_signature (MonoMethod * method);
MONO_API MonoClass *
mono_method_get_class (MonoMethod * method);
MONO_API void
mono_dllmap_insert (MonoImage * assembly, const char * dll, const char * func, const char * tdll, const char * tfunc);
MONO_API MonoDomain *
mono_domain_get (void);
MONO_API MonoClass *
mono_get_intptr_class (void);
MONO_API MonoClass *
mono_get_string_class (void);
MONO_API MonoImage *
mono_get_corlib (void);
MONO_API MonoClass *
mono_get_array_class (void);
MONO_API MonoClass *
mono_get_exception_class (void);
MONO_API MonoDomain *
mono_get_root_domain (void);
MONO_API void
mono_domain_set_config (MonoDomain * domain, const char * base_dir, const char * config_file_name);
MONO_API MonoReflectionAssembly *
mono_assembly_get_object (MonoDomain * domain, MonoAssembly * assembly);
MONO_API MonoReflectionMethod *
mono_method_get_object (MonoDomain * domain, MonoMethod * method, MonoClass * refclass);
MONO_API MonoReflectionType *
mono_type_get_object (MonoDomain * domain, MonoType * type);
MONO_API MonoType *
mono_reflection_type_get_type (MonoReflectionType * reftype);
MONO_API MonoType *
mono_signature_get_params (MonoMethodSignature * sig, void ** iter);
MONO_API mono_bool
mono_type_is_byref (MonoType * type);
MONO_API MonoType *
mono_signature_get_return_type (MonoMethodSignature * sig);
MONO_API int
mono_type_get_type (MonoType * type);
MONO_API void
mono_debug_init (MonoDebugFormat format);
MONO_API void
mono_gc_collect (int generation);
MONO_API mono_bool
mono_is_debugger_attached (void);
MONO_API void
mono_config_parse_memory (const char * buffer);
MONO_API int
mono_gc_max_generation (void);
MONO_API MonoGHashTable *
mono_g_hash_table_new_type (GHashFunc hash_func, GEqualFunc key_equal_func, MonoGHashGCType type);
MONO_API gpointer
mono_g_hash_table_lookup (MonoGHashTable * hash, gconstpointer key);
MONO_API void
mono_g_hash_table_insert (MonoGHashTable * hash, gpointer k, gpointer v);
MONO_API MonoException *
mono_get_exception_execution_engine (const char * msg);
MONO_API MonoException *
mono_exception_from_name_msg (MonoImage * image, const char * name_space, const char * name, const char * msg);
MONO_API MonoReferenceQueue *
mono_gc_reference_queue_new (mono_reference_queue_callback callback);
MONO_API void
mono_gc_reference_queue_free (MonoReferenceQueue * queue);
MONO_API gboolean
mono_gc_reference_queue_add (MonoReferenceQueue * queue, MonoObject * obj, void * user_data);
MONO_API void
mono_gc_register_finalizer_callbacks (MonoGCFinalizerCallbacks * callbacks);
MONO_API void
mono_gc_toggleref_add (MonoObject * object, mono_bool strong_ref);
MONO_API void
mono_gc_toggleref_register_callback (MonoToggleRefCallback process_toggleref);
MONO_API gchar *
mono_path_resolve_symlinks (const char * path);
MONO_API void
mono_free (void * ptr);
MONO_API char *
mono_get_runtime_build_info (void);
MONO_API MonoDomain *
mono_jit_init_version (const char * root_domain_name, const char * runtime_version);
MONO_API MonoDomain *
mono_jit_init (const char * file);
MONO_API int
mono_jit_exec (MonoDomain * domain, MonoAssembly * assembly, int argc, const char** argv);
MONO_API void
mono_jit_parse_options (int argc, char** argv);
MONO_API void
mono_jit_set_aot_mode (MonoAotMode mode);
MONO_API void
mono_set_signal_chaining (mono_bool chain_signals);
MONO_API void
mono_set_crash_chaining (mono_bool chain_signals);
MONO_API void
mono_jit_set_trace_options (const char * option);
MONO_API void*
mono_jit_thread_attach (MonoDomain * domain);
MONO_API gboolean
mono_exception_walk_trace (MonoException * exc, MonoExceptionFrameWalk func, gpointer user_data);
MONO_API void
mono_install_unhandled_exception_hook (MonoUnhandledExceptionFunc func, gpointer user_data);
MONO_API int
mono_main (int argc, char ** argv);
MONO_API void
mono_install_load_aot_data_hook (MonoLoadAotDataFunc load_func, MonoFreeAotDataFunc free_func, gpointer user_data);
MONO_API gboolean
mini_parse_debug_option (const char * option);
MONO_API void
mono_trace_set_log_handler (MonoLogCallback callback, void * user_data);
MONO_API void
mono_trace_set_print_handler (MonoPrintCallback callback);
MONO_API void
mono_trace_set_printerr_handler (MonoPrintCallback callback);
MONO_API void*
mono_threads_enter_gc_unsafe_region (void ** stackdata);
MONO_API void
mono_threads_exit_gc_unsafe_region (void * cookie, void ** stackdata);
MONO_API void*
mono_threads_enter_gc_safe_region (void ** stackdata);
MONO_API void
mono_threads_exit_gc_safe_region (void * cookie, void ** stackdata);
MONO_API void
mono_threads_assert_gc_safe_region (void);
MONO_API void
mono_threads_assert_gc_unsafe_region (void);
MONO_API void
mono_threads_assert_gc_starting_region (void);
MONO_API void*
mono_thread_info_current_unchecked (void);
MONO_API void *
mono_threads_attach_coop (MonoDomain * domain, gpointer* dummy);
MONO_API void *
mono_threads_detach_coop (gpointer cookie, gpointer* dummy);
MONO_API void
mono_install_ftnptr_eh_callback (MonoFtnPtrEHCallback callback);
bool
mono_class_is_nullable_exists ();
bool
mono_class_get_nullable_param_exists ();
bool
mono_runtime_set_pending_exception_exists ();
bool
mono_dangerous_add_raw_internal_call_exists ();
bool
mono_install_load_aot_data_hook_exists ();
bool
mini_parse_debug_option_exists ();
bool
mono_threads_enter_gc_unsafe_region_exists ();
bool
mono_threads_exit_gc_unsafe_region_exists ();
bool
mono_threads_enter_gc_safe_region_exists ();
bool
mono_threads_exit_gc_safe_region_exists ();
bool
mono_threads_assert_gc_safe_region_exists ();
bool
mono_threads_assert_gc_unsafe_region_exists ();
bool
mono_threads_assert_gc_starting_region_exists ();
bool
mono_thread_info_current_unchecked_exists ();
bool
mono_threads_attach_coop_exists ();
bool
mono_threads_detach_coop_exists ();
bool
mono_install_ftnptr_eh_callback_exists ();
#ifdef __cplusplus
} /* extern "C" */
#endif
#endif /* __MONO_RUNTIME__ */

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

@ -1,100 +0,0 @@
// vim: set filetype=c :
//
// delegates.h:
//
// Authors:
// Rolf Bjarne Kvinge <rolf@xamarin.com>
//
// Copyright 2018 Microsoft Inc.
//
/* Functions calling into ObjCRuntime.Runtime */
#ifndef __RUNTIME_GENERATED_H__
#define __RUNTIME_GENERATED_H__
#include "xamarin.h"
#ifdef __cplusplus
extern "C" {
#endif
void
xamarin_throw_ns_exception (NSException * exc);
void
xamarin_rethrow_managed_exception (guint32 original_exception_gchandle, guint32 *exception_gchandle);
int
xamarin_create_ns_exception (NSException * exc, guint32 *exception_gchandle);
NSException *
xamarin_unwrap_ns_exception (int exc_handle, guint32 *exception_gchandle);
MonoObject *
xamarin_create_block_proxy (MonoObject * method, void * block, guint32 *exception_gchandle);
id
xamarin_create_delegate_proxy (MonoObject * method, MonoObject * block, const char * signature, unsigned int token_ref, guint32 *exception_gchandle);
MonoObject *
xamarin_get_class (Class ptr, guint32 *exception_gchandle);
MonoObject *
xamarin_get_selector (SEL ptr, guint32 *exception_gchandle);
bool
xamarin_has_nsobject (id obj, guint32 *exception_gchandle);
id
xamarin_get_handle_for_inativeobject (MonoObject * obj, guint32 *exception_gchandle);
void
xamarin_unregister_nsobject (id native_obj, MonoObject * managed_obj, guint32 *exception_gchandle);
MonoObject *
xamarin_try_get_or_construct_nsobject (id obj, guint32 *exception_gchandle);
MonoObject *
xamarin_get_inative_object_dynamic (id obj, bool owns, void * type, guint32 *exception_gchandle);
MonoReflectionMethod *
xamarin_get_method_from_token (unsigned int token_ref, guint32 *exception_gchandle);
MonoReflectionMethod *
xamarin_get_generic_method_from_token (MonoObject * obj, unsigned int token_ref, guint32 *exception_gchandle);
MonoObject *
xamarin_get_inative_object_static (id obj, bool owns, unsigned int iface_token_ref, unsigned int implementation_token_ref, guint32 *exception_gchandle);
MonoObject *
xamarin_get_nsobject_with_type (id obj, void * type, int32_t * created, SEL selector, MonoReflectionMethod * method, guint32 *exception_gchandle);
void
xamarin_dispose (MonoObject * mobj, guint32 *exception_gchandle);
guint32
xamarin_create_product_exception_for_error (int code, const char * message, guint32 *exception_gchandle);
char *
xamarin_reflection_type_get_full_name (MonoReflectionType * type, guint32 *exception_gchandle);
char *
xamarin_lookup_managed_type_name (Class klass, guint32 *exception_gchandle);
enum MarshalManagedExceptionMode
xamarin_on_marshal_managed_exception (int exception, guint32 *exception_gchandle);
enum MarshalObjectiveCExceptionMode
xamarin_on_marshal_objectivec_exception (id exception, bool throwManagedAsDefault, guint32 *exception_gchandle);
int32_t
xamarin_create_runtime_exception (int32_t code, const char * message, guint32 *exception_gchandle);
#ifdef __cplusplus
} /* extern "C" */
#endif
#endif /* __RUNTIME_GENERATED_H__ */

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

@ -1,377 +0,0 @@
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
/*
* runtime.h: This header contains definitions used by Xamarin when building applications.
* Do not consider anything here stable API (unless otherwise specified),
* it will change between releases.
*
* Authors: Rolf Bjarne Kvinge
*
* Copyright (C) 2014 Xamarin Inc. (www.xamarin.com)
*
*/
#ifndef __XAMARIN_RUNTIME__
#define __XAMARIN_RUNTIME__
#include <stdbool.h>
#include <Foundation/Foundation.h>
#include "main.h"
#include "mono-runtime.h"
#include "runtime-generated.h"
#ifdef __cplusplus
extern "C" {
#endif
typedef struct {
const char *name;
const char *type;
int size;
int align;
} MTIvar;
typedef struct {
const char *selector;
const char *signature;
int isstatic;
void *trampoline;
} MTMethod;
typedef struct {
const char *name;
const char *supername;
int ivar_count;
int method_count;
int prop_count;
} MTClass;
typedef struct {
const char *name;
const char *type;
const char *argument_semantic;
} MTProperty;
// This structure completely describes everything required to resolve a metadata token
typedef struct MTFullTokenReference {
const char *assembly_name; /* the name of the assembly */
uint32_t module_token;
uint32_t token;
} MTFullTokenReference;
// This structure is packed to be exactly 32 bits
// If 'is_full_reference' is 1, then the remaining bits are an index into a table of MTFullTokenReference.
typedef struct __attribute__((packed)) {
uint8_t is_full_reference:1;
uint8_t assembly_index:7; /* 0-based index into the '__xamarin_registration_assemblies' array. Max 127 (registered) assemblies before a full token reference has to be used */
uint32_t token:24; /* RID of the corresponding metadata token. The exact type of metadata token depends on the context where the token reference is used. */
} MTTokenReference;
static const uint32_t INVALID_TOKEN_REF = 0xFFFFFFFF;
enum MTTypeFlags {
MTTypeFlagsNone = 0,
MTTypeFlagsCustomType = 1, // not a platform type
MTTypeFlagsUserType = 2, // not a wrapped type
};
typedef struct __attribute__((packed)) {
void *handle;
uint32_t /* MTTokenReference */ type_reference;
uint32_t /* MTTypeFlags */ flags;
} MTClassMap;
typedef struct __attribute__((packed)) {
uint32_t /* MTTokenReference */ skipped_reference;
uint32_t /* MTTokenReference */ actual_reference;
} MTManagedClassMap;
typedef struct __attribute__((packed)) {
uint32_t protocol_token;
uint32_t wrapper_token;
} MTProtocolWrapperMap;
typedef struct __attribute__((packed)) {
const uint32_t *protocol_tokens; // an array of token references to managed interfaces that represent protocols
// __unsafe_unretained needed to prevent "error: pointer to non-const type 'const Protocol *' with no explicit ownership" in Embeddinator
const __unsafe_unretained Protocol * const * protocols; // the corresponding native protocols
} MTProtocolMap;
struct MTRegistrationMap;
struct MTRegistrationMap {
const char **assembly;
MTClassMap *map;
const MTFullTokenReference *full_token_references;
// There are some managed types that are not registered because their ObjC
// class is already registered for a different managed type. For instance:
// The managed type "Foundation.NSArray<T>"" is not registered, because
// its ObjC class would be NSArray, which is already registered to
// "Foundation.NSArray". In order to be able to map all managed types to
// ObjC types we need to know which other managed type is the main type
// for the ObjC type (an alternative would be to map it directly to the
// ObjC class, but this is not a constant known at compile time, which
// means it can't be stored in read-only memory).
const MTManagedClassMap *skipped_map;
const MTProtocolWrapperMap *protocol_wrappers; // array of MTProtocolWrapperMap, sorted ascending by protocol_token
const MTProtocolMap protocols;
int assembly_count;
int map_count;
int full_token_reference_count;
int skipped_map_count;
int protocol_wrapper_count;
int protocol_count;
};
typedef struct {
MonoReflectionType *original_type;
} BindAsData;
typedef struct {
MonoReflectionMethod *method;
int32_t semantic;
int32_t bindas_count; // The number of elements available in the bindas_types array.
// An array of BindAs original types. Element 0 is for the return value,
// the rest are for parameters (parameters start at 1 even for void methods).
// The array must contain space for the return value and all the parameters,
// even for those that don't have BindAs attributes (the original_type entry will be NULL).
BindAsData bindas[];
} MethodDescription;
// This has a managed equivalent in NSObject2.cs
enum NSObjectFlags {
NSObjectFlagsDisposed = 1,
NSObjectFlagsNativeRef = 2,
NSObjectFlagsIsDirectBinding = 4,
NSObjectFlagsRegisteredToggleRef = 8,
NSObjectFlagsInFinalizerQueue = 16,
NSObjectFlagsHasManagedRef = 32,
// 64, // Used by SoM
NSObjectFlagsIsCustomType = 128,
};
struct AssemblyLocation {
const char *assembly_name; // base name (without extension) of the assembly
const char *location; // the directory where the assembly is
};
struct AssemblyLocations {
int length;
struct AssemblyLocation *locations;
};
void xamarin_initialize ();
void xamarin_initialize_embedded (); /* Public API, must not change - this is used by the embeddinator */
void xamarin_assertion_message (const char *msg, ...) __attribute__((__noreturn__));
const char * xamarin_get_bundle_path (); /* Public API */
// Sets the bundle path (where the managed executable is). By default APP/Contents/MonoBundle.
void xamarin_set_bundle_path (const char *path); /* Public API */
MonoObject * xamarin_get_managed_object_for_ptr (id self, guint32 *exception_gchandle);
MonoObject * xamarin_get_managed_object_for_ptr_fast (id self, guint32 *exception_gchandle);
void xamarin_check_for_gced_object (MonoObject *obj, SEL sel, id self, MonoMethod *method, guint32 *exception_gchandle);
int xamarin_objc_type_size (const char *type);
bool xamarin_is_class_nsobject (MonoClass *cls);
bool xamarin_is_class_inativeobject (MonoClass *cls);
bool xamarin_is_class_array (MonoClass *cls);
bool xamarin_is_class_nsnumber (MonoClass *cls);
bool xamarin_is_class_nsvalue (MonoClass *cls);
bool xamarin_is_class_nsstring (MonoClass *cls);
bool xamarin_is_class_nullable (MonoClass *cls, MonoClass **element_type, guint32 *exception_gchandle);
MonoClass * xamarin_get_nullable_type (MonoClass *cls, guint32 *exception_gchandle);
MonoType * xamarin_get_parameter_type (MonoMethod *managed_method, int index);
MonoObject * xamarin_get_nsobject_with_type_for_ptr (id self, bool owns, MonoType* type, SEL selector, MonoMethod *managed_method, guint32 *exception_gchandle);
MonoObject * xamarin_get_nsobject_with_type_for_ptr_created (id self, bool owns, MonoType *type, int32_t *created, SEL selector, MonoMethod *managed_method, guint32 *exception_gchandle);
int * xamarin_get_delegate_for_block_parameter (MonoMethod *method, guint32 token_ref, int par, void *nativeBlock, guint32 *exception_gchandle);
id xamarin_get_block_for_delegate (MonoMethod *method, MonoObject *delegate, const char *signature /* NULL allowed, but requires the dynamic registrar at runtime to compute */, guint32 token_ref /* INVALID_TOKEN_REF allowed, but requires the dynamic registrar at runtime */, guint32 *exception_gchandle);
id xamarin_get_nsobject_handle (MonoObject *obj);
void xamarin_set_nsobject_handle (MonoObject *obj, id handle);
uint8_t xamarin_get_nsobject_flags (MonoObject *obj);
void xamarin_set_nsobject_flags (MonoObject *obj, uint8_t flags);
void xamarin_throw_nsexception (MonoException *exc);
void xamarin_rethrow_managed_exception (guint32 original_gchandle, guint32 *exception_gchandle);
MonoException * xamarin_create_exception (const char *msg);
id xamarin_get_handle (MonoObject *obj, guint32 *exception_gchandle);
char * xamarin_strdup_printf (const char *msg, ...);
void * xamarin_calloc (size_t size);
void xamarin_free (void *ptr);
MonoMethod * xamarin_get_reflection_method_method (MonoReflectionMethod *method);
MonoMethod * xamarin_get_managed_method_for_token (guint32 token_ref, guint32 *exception_gchandle);
void xamarin_framework_peer_lock ();
void xamarin_framework_peer_unlock ();
bool xamarin_file_exists (const char *path);
MonoAssembly * xamarin_open_and_register (const char *path, guint32 *exception_gchandle);
void xamarin_unhandled_exception_handler (MonoObject *exc, gpointer user_data);
void xamarin_ftnptr_exception_handler (guint32 gchandle);
void xamarin_create_classes ();
const char * xamarin_skip_encoding_flags (const char *encoding);
void xamarin_add_registration_map (struct MTRegistrationMap *map, bool partial);
uint32_t xamarin_find_protocol_wrapper_type (uint32_t token_ref);
void xamarin_release_block_on_main_thread (void *obj);
bool xamarin_has_managed_ref (id self);
bool xamarin_has_managed_ref_safe (id self);
void xamarin_switch_gchandle (id self, bool to_weak);
int xamarin_get_gchandle (id self);
void xamarin_free_gchandle (id self, int gchandle);
void xamarin_clear_gchandle (id self);
int xamarin_get_gchandle_with_flags (id self);
void xamarin_set_gchandle (id self, int gchandle);
void xamarin_create_gchandle (id self, void *managed_object, int flags, bool force_weak);
void xamarin_create_managed_ref (id self, void * managed_object, bool retain);
void xamarin_release_managed_ref (id self, MonoObject *managed_obj);
void xamarin_notify_dealloc (id self, int gchandle);
int xamarin_main (int argc, char *argv[], enum XamarinLaunchMode launch_mode);
char * xamarin_type_get_full_name (MonoType *type, guint32 *exception_gchandle); // return value must be freed with 'mono_free'
char * xamarin_class_get_full_name (MonoClass *klass, guint32 *exception_gchandle); // return value must be freed with 'mono_free'
#if DEBUG
void xamarin_verify_parameter (MonoObject *obj, SEL sel, id self, id arg, int index, MonoClass *expected, MonoMethod *method);
void xamarin_check_objc_type (id obj, Class expected_class, SEL sel, id self, int index, MonoMethod *method);
#endif
void xamarin_set_gc_pump_enabled (bool value);
typedef void (*XamarinUnhandledExceptionFunc) (MonoObject *exc, const char *type_name, const char *message, const char *trace);
void xamarin_install_unhandled_exception_hook (XamarinUnhandledExceptionFunc func);
void xamarin_process_nsexception (NSException *exc);
void xamarin_process_nsexception_using_mode (NSException *ns_exception, bool throwManagedAsDefault);
void xamarin_process_managed_exception (MonoObject *exc);
void xamarin_process_managed_exception_gchandle (guint32 gchandle);
void xamarin_throw_product_exception (int code, const char *message);
guint32 xamarin_create_product_exception (int code, const char *message);
NSString * xamarin_print_all_exceptions (MonoObject *exc);
id xamarin_invoke_objc_method_implementation (id self, SEL sel, IMP xamarin_impl);
MonoClass * xamarin_get_nsnumber_class ();
MonoClass * xamarin_get_nsvalue_class ();
bool xamarin_is_managed_exception_marshaling_disabled ();
const char * xamarin_find_assembly_directory (const char *assembly_name);
void xamarin_set_assembly_directories (struct AssemblyLocations *directories);
void xamarin_get_assembly_name_without_extension (const char *aname, char *name, int namelen);
bool xamarin_locate_assembly_resource_for_name (MonoAssemblyName *assembly_name, const char *resource, char *path, int pathlen);
bool xamarin_locate_assembly_resource (const char *assembly_name, const char *culture, const char *resource, char *path, int pathlen);
// this functions support NSLog/NSString-style format specifiers.
void xamarin_printf (const char *format, ...);
void xamarin_vprintf (const char *format, va_list args);
void xamarin_install_log_callbacks ();
/*
* Look for an assembly in the app and open it.
*
* Stable API.
*/
MonoAssembly * xamarin_open_assembly (const char *name);
#if defined(__arm__) || defined(__aarch64__)
void mono_aot_register_module (void *aot_info);
#endif
typedef void (*xamarin_register_module_callback) ();
typedef void (*xamarin_register_assemblies_callback) ();
extern xamarin_register_module_callback xamarin_register_modules;
extern xamarin_register_assemblies_callback xamarin_register_assemblies;
#ifdef __cplusplus
class XamarinObject {
public:
id native_object;
int gc_handle;
~XamarinObject ();
};
#endif
#ifdef __OBJC__
@interface XamarinAssociatedObject : NSObject {
@public
id native_object;
int gc_handle;
}
-(void) dealloc;
@end
@interface NSObject (NonXamarinObject)
-(int) xamarinGetGCHandle;
@end
#endif
// Coop GC helper API
#if !TARGET_OS_WATCH
#define MONO_ENTER_GC_UNSAFE
#define MONO_EXIT_GC_UNSAFE
#define MONO_ENTER_GC_SAFE
#define MONO_EXIT_GC_SAFE
#define MONO_ASSERT_GC_SAFE
#define MONO_ASSERT_GC_SAFE_OR_DETACHED
#define MONO_ASSERT_GC_UNSAFE
#define MONO_ASSERT_GC_STARTING
#else
#define MONO_ENTER_GC_UNSAFE \
do { \
gpointer __dummy; \
gpointer __gc_unsafe_cookie = mono_threads_enter_gc_unsafe_region (&__dummy) \
#define MONO_EXIT_GC_UNSAFE \
mono_threads_exit_gc_unsafe_region (__gc_unsafe_cookie, &__dummy); \
} while (0)
#define MONO_ENTER_GC_SAFE \
do { \
gpointer __dummy; \
gpointer __gc_safe_cookie = mono_threads_enter_gc_safe_region (&__dummy) \
#define MONO_EXIT_GC_SAFE \
mono_threads_exit_gc_safe_region (__gc_safe_cookie, &__dummy); \
} while (0)
//#if DEBUG
#define MONO_ASSERT_GC_SAFE mono_threads_assert_gc_safe_region ()
#define MONO_ASSERT_GC_SAFE_OR_DETACHED \
do { \
if (mono_thread_info_current_unchecked ()) \
mono_threads_assert_gc_safe_region (); \
} while (0)
#define MONO_ASSERT_GC_UNSAFE mono_threads_assert_gc_unsafe_region ()
#define MONO_ASSERT_GC_STARTING
// There's no way to assert STARTING, tls values inside mono aren't initialized so mono's API end up accessing random memory, and thus randomly asserting // mono_threads_assert_gc_starting_region ()
//#else
// #define MONO_ASSERT_GC_SAFE
// #define MONO_ASSERT_GC_UNSAFE
//#endif /* DEBUG */
#endif /* !TARGET_OS_WATCH */
// Once we have one mono clone again the TARGET_OS_WATCH
// condition should be removed (DYNAMIC_MONO_RUNTIME should still
// be here though).
#if TARGET_OS_WATCH && !defined (DYNAMIC_MONO_RUNTIME)
#define MONO_THREAD_ATTACH \
do { \
gpointer __thread_dummy; \
gpointer __thread_cookie = mono_threads_attach_coop (NULL, &__thread_dummy) \
#define MONO_THREAD_DETACH \
mono_threads_detach_coop (__thread_cookie, &__thread_dummy); \
} while (0)
#else
#define MONO_THREAD_ATTACH \
do { \
mono_jit_thread_attach (NULL) \
#define MONO_THREAD_DETACH \
} while (0)
#endif
#ifdef __cplusplus
} /* extern "C" */
#endif
#endif /* __XAMARIN_RUNTIME__ */

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

@ -1,201 +0,0 @@
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
/*
* Authors: Rolf Bjarne Kvinge
*
* Copyright (C) 2014 Xamarin Inc. (www.xamarin.com)
*
*/
#ifndef __TRAMPOLINES_H__
#define __TRAMPOLINES_H__
#ifdef __cplusplus
extern "C" {
#endif
void * xamarin_trampoline (id self, SEL sel, ...);
void xamarin_stret_trampoline (void *buffer, id self, SEL sel, ...);
float xamarin_fpret_single_trampoline (id self, SEL sel, ...);
double xamarin_fpret_double_trampoline (id self, SEL sel, ...);
void xamarin_release_trampoline (id self, SEL sel);
void xamarin_calayer_release_trampoline (id self, SEL sel);
id xamarin_retain_trampoline (id self, SEL sel);
void xamarin_dealloc_trampoline (id self, SEL sel);
void * xamarin_static_trampoline (id self, SEL sel, ...);
void * xamarin_ctor_trampoline (id self, SEL sel, ...);
void xamarin_x86_double_abi_stret_trampoline ();
float xamarin_static_fpret_single_trampoline (id self, SEL sel, ...);
double xamarin_static_fpret_double_trampoline (id self, SEL sel, ...);
void xamarin_static_stret_trampoline (void *buffer, id self, SEL sel, ...);
void xamarin_static_x86_double_abi_stret_trampoline ();
long long xamarin_longret_trampoline (id self, SEL sel, ...);
long long xamarin_static_longret_trampoline (id self, SEL sel, ...);
id xamarin_copyWithZone_trampoline1 (id self, SEL sel, NSZone *zone);
id xamarin_copyWithZone_trampoline2 (id self, SEL sel, NSZone *zone);
int xamarin_get_gchandle_trampoline (id self, SEL sel);
void xamarin_set_gchandle_trampoline (id self, SEL sel, int gc_handle);
int xamarin_get_frame_length (id self, SEL sel);
enum ArgumentSemantic /* Xcode 4.4 doesn't like this ': int' */ {
ArgumentSemanticNone = -1,
ArgumentSemanticAssign = 0,
ArgumentSemanticCopy = 1,
ArgumentSemanticRetain = 2,
ArgumentSemanticMask = ArgumentSemanticAssign | ArgumentSemanticCopy | ArgumentSemanticRetain,
ArgumentSemanticRetainReturnValue = 1 << 10,
ArgumentSemanticCategoryInstance = 1 << 11,
};
/* Conversion functions */
// The xamarin_id_to_managed_func and xamarin_managed_to_id_func typedefs
// represents functions to convert to/from id and managed types.
//
// The `value` parameter is the value to convert.
//
// The `ptr` parameter is optional, if passed the resulting value type will be
// stored here. If NULL, memory is allocated and returned, and the return
// value must be freed using `xamarin_free`.
//
// The `managedType` parameter is the managed type to convert to.
//
// The `context` parameter is a conversion-specific value that may or may not
// be provided:
// * Smart enum conversions: The `context` parameter represents a token ref to
// the conversion method. The static registrar bakes those token refs in to
// the generated code, thus avoiding the need for finding the conversion
// method at runtime).
// * Other conversions: The `context` parameter is not used in other
// conversions at the moment.
//
// The `exception_gchandle` parameter is required, and will contain a GCHandle
// to any exceptions that occur.
//
// The return value is:
// * xamarin_id_to_managed_func: a pointer to the resulting value type. If
// `ptr` was passed, this value is also returned, otherwise newly allocated
// memory is returned (which must be freed with `xamarin_free`). If an
// exception occurs, 'ptr' is returned (and no memory allocated).
// * xamarin_managed_to_id_func: the resulting Objective-C object.
typedef void * (*xamarin_id_to_managed_func) (id value, void *ptr, MonoClass *managedType, guint32 context, guint32 *exception_gchandle);
typedef id (*xamarin_managed_to_id_func) (MonoObject *value, guint32 context, guint32 *exception_gchandle);
id xamarin_generate_conversion_to_native (MonoObject *value, MonoType *inputType, MonoType *outputType, MonoMethod *method, guint32 context, guint32 *exception_gchandle);
void * xamarin_generate_conversion_to_managed (id value, MonoType *inputType, MonoType *outputType, MonoMethod *method, guint32 *exception_gchandle, guint32 context, /*SList*/ void **free_list);
NSNumber * xamarin_convert_managed_to_nsnumber (MonoObject *value, MonoClass *managedType, MonoMethod *method, guint32 context, guint32 *exception_gchandle);
NSValue * xamarin_convert_managed_to_nsvalue (MonoObject *value, MonoClass *managedType, MonoMethod *method, guint32 context, guint32 *exception_gchandle);
NSString * xamarin_convert_managed_to_nsstring (MonoObject *value, MonoType *managedType, MonoType *nativeType, MonoMethod *method, guint32 *exception_gchandle);
MonoObject * xamarin_convert_nsnumber_to_managed (NSNumber *value, MonoType *nativeType, MonoType *managedType, MonoMethod *method, guint32 *exception_gchandle);
MonoObject * xamarin_convert_nsvalue_to_managed (NSValue *value, MonoType *nativeType, MonoType *managedType, MonoMethod *method, guint32 *exception_gchandle);
MonoObject * xamarin_convert_nsstring_to_managed (NSString *value, MonoType *nativeType, MonoType *managedType, MonoMethod *method, guint32 *exception_gchandle);
guint32 xamarin_create_bindas_exception (MonoType *inputType, MonoType *outputType, MonoMethod *method);
xamarin_id_to_managed_func xamarin_get_nsnumber_to_managed_func (MonoClass *managedType, MonoMethod *method, guint32 *exception_gchandle);
xamarin_managed_to_id_func xamarin_get_managed_to_nsnumber_func (MonoClass *managedType, MonoMethod *method, guint32 *exception_gchandle);
xamarin_id_to_managed_func xamarin_get_nsvalue_to_managed_func (MonoClass *managedType, MonoMethod *method, guint32 *exception_gchandle);
xamarin_managed_to_id_func xamarin_get_managed_to_nsvalue_func (MonoClass *managedType, MonoMethod *method, guint32 *exception_gchandle);
xamarin_id_to_managed_func xamarin_get_nsstring_to_smart_enum_func (MonoClass *managedType, MonoMethod *method, guint32 *exception_gchandle);
xamarin_managed_to_id_func xamarin_get_smart_enum_to_nsstring_func (MonoClass *managedType, MonoMethod *method, guint32 *exception_gchandle);
NSArray * xamarin_convert_managed_to_nsarray_with_func (MonoArray *array, xamarin_managed_to_id_func convert, guint32 context, guint32 *exception_gchandle);
MonoArray * xamarin_convert_nsarray_to_managed_with_func (NSArray *array, MonoClass *managedElementType, xamarin_id_to_managed_func convert, guint32 context, guint32 *exception_gchandle);
void * xamarin_nsstring_to_smart_enum (id value, void *ptr, MonoClass *managedType, guint32 context, guint32 *exception_gchandle);
void * xamarin_smart_enum_to_nsstring (MonoObject *value, guint32 context /* token ref */, guint32 *exception_gchandle);
// Returns a pointer to the value type, which must be freed using xamarin_free.
void *xamarin_nsnumber_to_bool (NSNumber *number, void *ptr, MonoClass *managedType, guint32 context, guint32 *exception_gchandle);
void *xamarin_nsnumber_to_sbyte (NSNumber *number, void *ptr, MonoClass *managedType, guint32 context, guint32 *exception_gchandle);
void *xamarin_nsnumber_to_byte (NSNumber *number, void *ptr, MonoClass *managedType, guint32 context, guint32 *exception_gchandle);
void *xamarin_nsnumber_to_short (NSNumber *number, void *ptr, MonoClass *managedType, guint32 context, guint32 *exception_gchandle);
void *xamarin_nsnumber_to_ushort (NSNumber *number, void *ptr, MonoClass *managedType, guint32 context, guint32 *exception_gchandle);
void *xamarin_nsnumber_to_int (NSNumber *number, void *ptr, MonoClass *managedType, guint32 context, guint32 *exception_gchandle);
void *xamarin_nsnumber_to_uint (NSNumber *number, void *ptr, MonoClass *managedType, guint32 context, guint32 *exception_gchandle);
void *xamarin_nsnumber_to_long (NSNumber *number, void *ptr, MonoClass *managedType, guint32 context, guint32 *exception_gchandle);
void *xamarin_nsnumber_to_ulong (NSNumber *number, void *ptr, MonoClass *managedType, guint32 context, guint32 *exception_gchandle);
void *xamarin_nsnumber_to_nint (NSNumber *number, void *ptr, MonoClass *managedType, guint32 context, guint32 *exception_gchandle);
void *xamarin_nsnumber_to_nuint (NSNumber *number, void *ptr, MonoClass *managedType, guint32 context, guint32 *exception_gchandle);
void *xamarin_nsnumber_to_float (NSNumber *number, void *ptr, MonoClass *managedType, guint32 context, guint32 *exception_gchandle);
void *xamarin_nsnumber_to_double (NSNumber *number, void *ptr, MonoClass *managedType, guint32 context, guint32 *exception_gchandle);
void *xamarin_nsnumber_to_nfloat (NSNumber *number, void *ptr, MonoClass *managedType, guint32 context, guint32 *exception_gchandle);
// Returns a pointer to the value type, which must be freed using xamarin_free
void *xamarin_nsvalue_to_nsrange (NSValue *value, void *ptr, MonoClass *managedType, guint32 context, guint32 *exception_ghandle);
void *xamarin_nsvalue_to_cgaffinetransform (NSValue *value, void *ptr, MonoClass *managedType, guint32 context, guint32 *exception_ghandle);
void *xamarin_nsvalue_to_cgpoint (NSValue *value, void *ptr, MonoClass *managedType, guint32 context, guint32 *exception_ghandle);
void *xamarin_nsvalue_to_cgrect (NSValue *value, void *ptr, MonoClass *managedType, guint32 context, guint32 *exception_ghandle);
void *xamarin_nsvalue_to_cgsize (NSValue *value, void *ptr, MonoClass *managedType, guint32 context, guint32 *exception_ghandle);
void *xamarin_nsvalue_to_cgvector (NSValue *value, void *ptr, MonoClass *managedType, guint32 context, guint32 *exception_ghandle);
void *xamarin_nsvalue_to_catransform3d (NSValue *value, void *ptr, MonoClass *managedType, guint32 context, guint32 *exception_ghandle);
void *xamarin_nsvalue_to_cllocationcoordinate2d (NSValue *value, void *ptr, MonoClass *managedType, guint32 context, guint32 *exception_ghandle);
void *xamarin_nsvalue_to_cmtime (NSValue *value, void *ptr, MonoClass *managedType, guint32 context, guint32 *exception_ghandle);
void *xamarin_nsvalue_to_cmtimemapping (NSValue *value, void *ptr, MonoClass *managedType, guint32 context, guint32 *exception_ghandle);
void *xamarin_nsvalue_to_cmtimerange (NSValue *value, void *ptr, MonoClass *managedType, guint32 context, guint32 *exception_ghandle);
void *xamarin_nsvalue_to_mkcoordinatespan (NSValue *value, void *ptr, MonoClass *managedType, guint32 context, guint32 *exception_ghandle);
void *xamarin_nsvalue_to_scnmatrix4 (NSValue *value, void *ptr, MonoClass *managedType, guint32 context, guint32 *exception_ghandle);
void *xamarin_nsvalue_to_scnvector3 (NSValue *value, void *ptr, MonoClass *managedType, guint32 context, guint32 *exception_ghandle);
void *xamarin_nsvalue_to_scnvector4 (NSValue *value, void *ptr, MonoClass *managedType, guint32 context, guint32 *exception_ghandle);
void *xamarin_nsvalue_to_uiedgeinsets (NSValue *value, void *ptr, MonoClass *managedType, guint32 context, guint32 *exception_ghandle);
void *xamarin_nsvalue_to_uioffset (NSValue *value, void *ptr, MonoClass *managedType, guint32 context, guint32 *exception_ghandle);
void *xamarin_nsvalue_to_nsdirectionaledgeinsets(NSValue *value, void *ptr, MonoClass *managedType, guint32 context, guint32 *exception_ghandle);
id xamarin_bool_to_nsnumber (MonoObject *value, guint32 contxt, guint32 *exception_gchandle);
id xamarin_sbyte_to_nsnumber (MonoObject *value, guint32 contxt, guint32 *exception_gchandle);
id xamarin_byte_to_nsnumber (MonoObject *value, guint32 contxt, guint32 *exception_gchandle);
id xamarin_short_to_nsnumber (MonoObject *value, guint32 contxt, guint32 *exception_gchandle);
id xamarin_ushort_to_nsnumber (MonoObject *value, guint32 contxt, guint32 *exception_gchandle);
id xamarin_int_to_nsnumber (MonoObject *value, guint32 contxt, guint32 *exception_gchandle);
id xamarin_uint_to_nsnumber (MonoObject *value, guint32 contxt, guint32 *exception_gchandle);
id xamarin_long_to_nsnumber (MonoObject *value, guint32 contxt, guint32 *exception_gchandle);
id xamarin_ulong_to_nsnumber (MonoObject *value, guint32 contxt, guint32 *exception_gchandle);
id xamarin_nint_to_nsnumber (MonoObject *value, guint32 contxt, guint32 *exception_gchandle);
id xamarin_nuint_to_nsnumber (MonoObject *value, guint32 contxt, guint32 *exception_gchandle);
id xamarin_float_to_nsnumber (MonoObject *value, guint32 contxt, guint32 *exception_gchandle);
id xamarin_double_to_nsnumber (MonoObject *value, guint32 contxt, guint32 *exception_gchandle);
id xamarin_nfloat_to_nsnumber (MonoObject *value, guint32 contxt, guint32 *exception_gchandle);
id xamarin_nfloat_to_nsnumber (MonoObject *value, guint32 contxt, guint32 *exception_gchandle);
id xamarin_nsrange_to_nsvalue (MonoObject *value, guint32 context, guint32 *exception_gchandle);
id xamarin_cgaffinetransform_to_nsvalue (MonoObject *value, guint32 context, guint32 *exception_gchandle);
id xamarin_cgpoint_to_nsvalue (MonoObject *value, guint32 context, guint32 *exception_gchandle);
id xamarin_cgrect_to_nsvalue (MonoObject *value, guint32 context, guint32 *exception_gchandle);
id xamarin_cgsize_to_nsvalue (MonoObject *value, guint32 context, guint32 *exception_gchandle);
id xamarin_cgvector_to_nsvalue (MonoObject *value, guint32 context, guint32 *exception_gchandle);
id xamarin_catransform3d_to_nsvalue (MonoObject *value, guint32 context, guint32 *exception_gchandle);
id xamarin_cllocationcoordinate2d_to_nsvalue (MonoObject *value, guint32 context, guint32 *exception_gchandle);
id xamarin_cmtime_to_nsvalue (MonoObject *value, guint32 context, guint32 *exception_gchandle);
id xamarin_cmtimemapping_to_nsvalue (MonoObject *value, guint32 context, guint32 *exception_gchandle);
id xamarin_cmtimerange_to_nsvalue (MonoObject *value, guint32 context, guint32 *exception_gchandle);
id xamarin_mkcoordinatespan_to_nsvalue (MonoObject *value, guint32 context, guint32 *exception_gchandle);
id xamarin_scnmatrix4_to_nsvalue (MonoObject *value, guint32 context, guint32 *exception_gchandle);
id xamarin_scnvector3_to_nsvalue (MonoObject *value, guint32 context, guint32 *exception_gchandle);
id xamarin_scnvector4_to_nsvalue (MonoObject *value, guint32 context, guint32 *exception_gchandle);
id xamarin_uiedgeinsets_to_nsvalue (MonoObject *value, guint32 context, guint32 *exception_gchandle);
id xamarin_uioffset_to_nsvalue (MonoObject *value, guint32 context, guint32 *exception_gchandle);
id xamarin_nsdirectionaledgeinsets_to_nsvalue(MonoObject *value, guint32 context, guint32 *exception_gchandle);
/* Copied from SGen */
static inline void
mt_dummy_use (void *v) {
#if defined(__GNUC__)
__asm__ volatile ("" : "=r"(v) : "r"(v));
#elif defined(_MSC_VER)
__asm {
mov eax, v;
and eax, eax;
};
#else
#error "Implement mt_dummy_use for your compiler"
#endif
}
#ifdef __cplusplus
} /* extern "C" */
#endif
#endif /* __TRAMPOLINES_H__ */

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

@ -1,18 +0,0 @@
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
/*
* Authors: Rolf Bjarne Kvinge
*
* Copyright (C) 2014 Xamarin Inc. (www.xamarin.com)
*
*/
#ifndef __XAMARIN_H__
#define __XAMARIN_H__
#include "main.h"
#include "mono-runtime.h"
#include "runtime.h"
#include "runtime-generated.h"
#include "trampolines.h"
#endif /* __XAMARIN_H__ */

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

@ -57,10 +57,10 @@ xamarin_log (const unsigned short *unicodeMessage)
// Write in chunks of max 4096 characters; older versions of iOS seems to have a bug where NSLog may hang with long strings (!). // Write in chunks of max 4096 characters; older versions of iOS seems to have a bug where NSLog may hang with long strings (!).
// https://github.com/xamarin/maccore/issues/1014 // https://github.com/xamarin/maccore/issues/1014
const char *utf8 = [msg UTF8String]; const char *utf8 = [msg UTF8String];
int len = strlen (utf8); size_t len = strlen (utf8);
const int max_size = 4096; const size_t max_size = 4096;
while (len > 0) { while (len > 0) {
int chunk_size = len > max_size ? max_size : len; size_t chunk_size = len > max_size ? max_size : len;
// Try to not break in the middle of a line, by looking backwards for a newline // Try to not break in the middle of a line, by looking backwards for a newline
while (chunk_size > 0 && utf8 [chunk_size] != 0 && utf8 [chunk_size] != '\n') while (chunk_size > 0 && utf8 [chunk_size] != 0 && utf8 [chunk_size] != '\n')
@ -69,7 +69,7 @@ xamarin_log (const unsigned short *unicodeMessage)
// No newline found, break in the middle. // No newline found, break in the middle.
chunk_size = len > max_size ? max_size : len; chunk_size = len > max_size ? max_size : len;
} }
NSLog (@"%.*s", chunk_size, utf8); NSLog (@"%.*s", (int) chunk_size, utf8);
len -= chunk_size; len -= chunk_size;
utf8 += chunk_size; utf8 += chunk_size;
@ -87,7 +87,7 @@ xamarin_log (const unsigned short *unicodeMessage)
// See in Mono sdks/ios/runtime/runtime.m // See in Mono sdks/ios/runtime/runtime.m
void* void*
xamarin_timezone_get_data (const char *name, int *size) xamarin_timezone_get_data (const char *name, unsigned long *size)
{ {
// COOP: no managed memory access: any mode. // COOP: no managed memory access: any mode.
NSTimeZone *tz = nil; NSTimeZone *tz = nil;
@ -106,13 +106,13 @@ xamarin_timezone_get_data (const char *name, int *size)
} }
char** char**
xamarin_timezone_get_names (int *count) xamarin_timezone_get_names (unsigned long *count)
{ {
// COOP: no managed memory access: any mode. // COOP: no managed memory access: any mode.
NSArray *array = [NSTimeZone knownTimeZoneNames]; NSArray *array = [NSTimeZone knownTimeZoneNames];
*count = array.count; *count = array.count;
char** result = (char**) malloc (sizeof (char*) * (*count)); char** result = (char**) malloc (sizeof (char*) * (*count));
for (int i = 0; i < *count; i++) { for (unsigned long i = 0; i < *count; i++) {
NSString *s = [array objectAtIndex: i]; NSString *s = [array objectAtIndex: i];
result [i] = strdup (s.UTF8String); result [i] = strdup (s.UTF8String);
} }

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

@ -46,11 +46,6 @@ enum XamarinLaunchMode {
extern bool mono_use_llvm; // this is defined inside mono extern bool mono_use_llvm; // this is defined inside mono
#if MONOMAC
extern bool xamarin_use_new_assemblies;
#else
#define xamarin_use_new_assemblies 1
#endif
#if DEBUG #if DEBUG
extern bool xamarin_gc_pump; extern bool xamarin_gc_pump;
#endif #endif

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

@ -169,7 +169,7 @@ void xamarin_set_bundle_path (const char *path); /* Public API */
MonoObject * xamarin_get_managed_object_for_ptr (id self, guint32 *exception_gchandle); MonoObject * xamarin_get_managed_object_for_ptr (id self, guint32 *exception_gchandle);
MonoObject * xamarin_get_managed_object_for_ptr_fast (id self, guint32 *exception_gchandle); MonoObject * xamarin_get_managed_object_for_ptr_fast (id self, guint32 *exception_gchandle);
void xamarin_check_for_gced_object (MonoObject *obj, SEL sel, id self, MonoMethod *method, guint32 *exception_gchandle); void xamarin_check_for_gced_object (MonoObject *obj, SEL sel, id self, MonoMethod *method, guint32 *exception_gchandle);
int xamarin_objc_type_size (const char *type); unsigned long xamarin_objc_type_size (const char *type);
bool xamarin_is_class_nsobject (MonoClass *cls); bool xamarin_is_class_nsobject (MonoClass *cls);
bool xamarin_is_class_inativeobject (MonoClass *cls); bool xamarin_is_class_inativeobject (MonoClass *cls);
bool xamarin_is_class_array (MonoClass *cls); bool xamarin_is_class_array (MonoClass *cls);
@ -181,7 +181,7 @@ MonoClass * xamarin_get_nullable_type (MonoClass *cls, guint32 *exception_gchan
MonoType * xamarin_get_parameter_type (MonoMethod *managed_method, int index); MonoType * xamarin_get_parameter_type (MonoMethod *managed_method, int index);
MonoObject * xamarin_get_nsobject_with_type_for_ptr (id self, bool owns, MonoType* type, guint32 *exception_gchandle); MonoObject * xamarin_get_nsobject_with_type_for_ptr (id self, bool owns, MonoType* type, guint32 *exception_gchandle);
MonoObject * xamarin_get_nsobject_with_type_for_ptr_created (id self, bool owns, MonoType *type, int32_t *created, guint32 *exception_gchandle); MonoObject * xamarin_get_nsobject_with_type_for_ptr_created (id self, bool owns, MonoType *type, int32_t *created, guint32 *exception_gchandle);
int * xamarin_get_delegate_for_block_parameter (MonoMethod *method, guint32 token_ref, int par, void *nativeBlock, guint32 *exception_gchandle); int * xamarin_get_delegate_for_block_parameter (MonoMethod *method, guint32 token_ref, unsigned long par, void *nativeBlock, guint32 *exception_gchandle);
id xamarin_get_block_for_delegate (MonoMethod *method, MonoObject *delegate, const char *signature /* NULL allowed, but requires the dynamic registrar at runtime to compute */, guint32 token_ref /* INVALID_TOKEN_REF allowed, but requires the dynamic registrar at runtime */, guint32 *exception_gchandle); id xamarin_get_block_for_delegate (MonoMethod *method, MonoObject *delegate, const char *signature /* NULL allowed, but requires the dynamic registrar at runtime to compute */, guint32 token_ref /* INVALID_TOKEN_REF allowed, but requires the dynamic registrar at runtime */, guint32 *exception_gchandle);
id xamarin_get_nsobject_handle (MonoObject *obj); id xamarin_get_nsobject_handle (MonoObject *obj);
void xamarin_set_nsobject_handle (MonoObject *obj, id handle); void xamarin_set_nsobject_handle (MonoObject *obj, id handle);
@ -227,7 +227,7 @@ char * xamarin_type_get_full_name (MonoType *type, guint32 *exception_gchandle
char * xamarin_class_get_full_name (MonoClass *klass, guint32 *exception_gchandle); // return value must be freed with 'mono_free' char * xamarin_class_get_full_name (MonoClass *klass, guint32 *exception_gchandle); // return value must be freed with 'mono_free'
#if DEBUG #if DEBUG
void xamarin_verify_parameter (MonoObject *obj, SEL sel, id self, id arg, int index, MonoClass *expected, MonoMethod *method); void xamarin_verify_parameter (MonoObject *obj, SEL sel, id self, id arg, unsigned long index, MonoClass *expected, MonoMethod *method);
void xamarin_check_objc_type (id obj, Class expected_class, SEL sel, id self, int index, MonoMethod *method); void xamarin_check_objc_type (id obj, Class expected_class, SEL sel, id self, int index, MonoMethod *method);
#endif #endif

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

@ -35,7 +35,7 @@ id xamarin_copyWithZone_trampoline2 (id self, SEL sel, NSZone *zone);
int xamarin_get_gchandle_trampoline (id self, SEL sel); int xamarin_get_gchandle_trampoline (id self, SEL sel);
void xamarin_set_gchandle_trampoline (id self, SEL sel, int gc_handle); void xamarin_set_gchandle_trampoline (id self, SEL sel, int gc_handle);
int xamarin_get_frame_length (id self, SEL sel); unsigned long xamarin_get_frame_length (id self, SEL sel);
bool xamarin_collapse_struct_name (const char *type, char struct_name[], int max_char, guint32 *exception_gchandle); bool xamarin_collapse_struct_name (const char *type, char struct_name[], int max_char, guint32 *exception_gchandle);
guint32 xamarin_create_mt_exception (char *msg); guint32 xamarin_create_mt_exception (char *msg);
size_t xamarin_get_primitive_size (char type); size_t xamarin_get_primitive_size (char type);
@ -95,7 +95,7 @@ MonoObject * xamarin_convert_nsnumber_to_managed (NSNumber *value, MonoType *
MonoObject * xamarin_convert_nsvalue_to_managed (NSValue *value, MonoType *nativeType, MonoType *managedType, MonoMethod *method, guint32 *exception_gchandle); MonoObject * xamarin_convert_nsvalue_to_managed (NSValue *value, MonoType *nativeType, MonoType *managedType, MonoMethod *method, guint32 *exception_gchandle);
MonoObject * xamarin_convert_nsstring_to_managed (NSString *value, MonoType *nativeType, MonoType *managedType, MonoMethod *method, guint32 *exception_gchandle); MonoObject * xamarin_convert_nsstring_to_managed (NSString *value, MonoType *nativeType, MonoType *managedType, MonoMethod *method, guint32 *exception_gchandle);
guint32 xamarin_create_bindas_exception (MonoType *inputType, MonoType *outputType, MonoMethod *method); guint32 xamarin_create_bindas_exception (MonoType *inputType, MonoType *outputType, MonoMethod *method);
guint32 xamarin_get_exception_for_parameter (int code, guint32 inner_exception_gchandle, const char *reason, SEL sel, MonoMethod *method, MonoType *p, int i, bool to_managed); guint32 xamarin_get_exception_for_parameter (int code, guint32 inner_exception_gchandle, const char *reason, SEL sel, MonoMethod *method, MonoType *p, unsigned long i, bool to_managed);
xamarin_id_to_managed_func xamarin_get_nsnumber_to_managed_func (MonoClass *managedType, MonoMethod *method, guint32 *exception_gchandle); xamarin_id_to_managed_func xamarin_get_nsnumber_to_managed_func (MonoClass *managedType, MonoMethod *method, guint32 *exception_gchandle);
xamarin_managed_to_id_func xamarin_get_managed_to_nsnumber_func (MonoClass *managedType, MonoMethod *method, guint32 *exception_gchandle); xamarin_managed_to_id_func xamarin_get_managed_to_nsnumber_func (MonoClass *managedType, MonoMethod *method, guint32 *exception_gchandle);

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

@ -105,6 +105,14 @@ namespace AVFoundation {
return AVMetadataObjectType.ITF14Code; return AVMetadataObjectType.ITF14Code;
else if (obj == AVMetadataObject.TypeDataMatrixCode) else if (obj == AVMetadataObject.TypeDataMatrixCode)
return AVMetadataObjectType.DataMatrixCode; return AVMetadataObjectType.DataMatrixCode;
else if (obj == AVMetadataObject.TypeCatBody)
return AVMetadataObjectType.CatBody;
else if (obj == AVMetadataObject.TypeDogBody)
return AVMetadataObjectType.DogBody;
else if (obj == AVMetadataObject.TypeHumanBody)
return AVMetadataObjectType.HumanBody;
else if (obj == AVMetadataObject.TypeSalientObject)
return AVMetadataObjectType.SalientObject;
else else
throw new ArgumentOutOfRangeException (string.Format ("Unexpected AVMetadataObjectType: {0}", obj)); throw new ArgumentOutOfRangeException (string.Format ("Unexpected AVMetadataObjectType: {0}", obj));
} }

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

@ -630,6 +630,18 @@ namespace AVFoundation {
[iOS (8,0)] [iOS (8,0)]
DataMatrixCode = 1 << 13, DataMatrixCode = 1 << 13,
[iOS (13,0)]
CatBody = 1 << 14,
[iOS (13,0)]
DogBody = 1 << 15,
[iOS (13,0)]
HumanBody = 1 << 16,
[iOS (13,0)]
SalientObject = 1 << 17,
} }
#if !MONOMAC #if !MONOMAC

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

@ -37,10 +37,6 @@ namespace AppKit {
private static Thread mainThread; private static Thread mainThread;
static NSApplication () {
class_ptr = Class.GetHandle ("NSApplication");
}
[DllImport (Constants.AppKitLibrary)] [DllImport (Constants.AppKitLibrary)]
extern static int /* int */ NSApplicationMain (int /* int */ argc, string [] argv); extern static int /* int */ NSApplicationMain (int /* int */ argc, string [] argv);

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

@ -0,0 +1,25 @@
using System;
using System.Runtime.InteropServices;
using CoreFoundation;
using Foundation;
using ObjCRuntime;
using CoreGraphics;
namespace AppKit {
[Mac (10, 15)]
public enum NSCollectionLayoutAnchorOffsetType {
Absolute,
Fractional,
}
public partial class NSCollectionLayoutAnchor {
public static NSCollectionLayoutAnchor Create (NSDirectionalRectEdge edges, NSCollectionLayoutAnchorOffsetType offsetType, CGPoint offset) =>
offsetType switch
{
NSCollectionLayoutAnchorOffsetType.Absolute => _LayoutAnchorWithEdgesAbsoluteOffset (edges, offset),
NSCollectionLayoutAnchorOffsetType.Fractional => _LayoutAnchorWithEdgesFractionalOffset (edges, offset),
_ => throw new ArgumentException (message: "Invalid enum value", paramName: nameof (offsetType)),
};
}
}

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

@ -185,5 +185,12 @@ namespace AppKit {
var ptr = _MonospacedDigitSystemFontOfSize (fontSize, weight); var ptr = _MonospacedDigitSystemFontOfSize (fontSize, weight);
return ptr == IntPtr.Zero ? null : new NSFont (ptr); return ptr == IntPtr.Zero ? null : new NSFont (ptr);
} }
[Mac (10,15)]
public static NSFont MonospacedSystemFont (nfloat fontSize, nfloat weight)
{
var ptr = _MonospacedSystemFont (fontSize, weight);
return ptr == IntPtr.Zero ? null : new NSFont (ptr);
}
} }
} }

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

@ -0,0 +1,27 @@
using System;
using System.Runtime.InteropServices;
using ObjCRuntime;
using Foundation;
using CoreFoundation;
namespace CoreFoundation {
public partial class CFBundle {
// from machine.h
// #define CPU_ARCH_ABI64 0x01000000
// #define CPU_TYPE_X86 ((cpu_type_t) 7)
// #define CPU_TYPE_X86_64 (CPU_TYPE_X86 | CPU_ARCH_ABI64)
// #define CPU_TYPE_ARM ((cpu_type_t) 12)
// #define CPU_TYPE_ARM64 (CPU_TYPE_ARM | CPU_ARCH_ABI64)
// #define CPU_TYPE_POWERPC ((cpu_type_t) 18)
// #define CPU_TYPE_POWERPC64 (CPU_TYPE_POWERPC | CPU_ARCH_ABI64)
public enum Architecture {
I386 = 0x00000007,
X86_64 = 0x01000007,
ARM = 0x00000012,
ARM64 = 0x01000012,
PPC = 0x00000018,
PPC64 = 0x01000018,
}
}
}

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

@ -10,7 +10,7 @@ using Foundation;
namespace CoreFoundation { namespace CoreFoundation {
public class CFBundle : INativeObject, IDisposable { public partial class CFBundle : INativeObject, IDisposable {
public enum PackageType { public enum PackageType {
Application, Application,
@ -18,23 +18,6 @@ namespace CoreFoundation {
Bundle Bundle
} }
// from machine.h
// #define CPU_ARCH_ABI64 0x01000000
// #define CPU_TYPE_X86 ((cpu_type_t) 7)
// #define CPU_TYPE_X86_64 (CPU_TYPE_X86 | CPU_ARCH_ABI64)
// #define CPU_TYPE_ARM ((cpu_type_t) 12)
// #define CPU_TYPE_ARM64 (CPU_TYPE_ARM | CPU_ARCH_ABI64)
// #define CPU_TYPE_POWERPC ((cpu_type_t) 18)
// #define CPU_TYPE_POWERPC64 (CPU_TYPE_POWERPC | CPU_ARCH_ABI64)
public enum Architecture {
I386 = 0x00000007,
X86_64 = 0x01000007,
ARM = 0x00000012,
ARM64 = 0x01000012,
PPC = 0x00000018,
PPC64 = 0x01000018,
}
public struct PackageInfo { public struct PackageInfo {
public PackageInfo (CFBundle.PackageType type, string creator) public PackageInfo (CFBundle.PackageType type, string creator)
{ {

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

@ -140,7 +140,11 @@ namespace CoreGraphics {
EventSourceUserID = 43, EventSourceUserID = 43,
EventSourceGroupID = 44, EventSourceGroupID = 44,
EventSourceStateID = 45, EventSourceStateID = 45,
ScrollWheelEventIsContinuous = 88 ScrollWheelEventIsContinuous = 88,
EventWindowUnderMousePointer = 91,
EventWindowUnderMousePointerThatCanHandleThisEvent = 92,
EventUnacceleratedPointerMovementX = 170,
EventUnacceleratedPointerMovementY = 171,
} }
// CGEventTypes.h:typedef uint32_t CGEventType; // CGEventTypes.h:typedef uint32_t CGEventType;

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

@ -119,6 +119,16 @@ namespace CoreImage {
SetBooleanValue (CIContext.CacheIntermediates, value); SetBooleanValue (CIContext.CacheIntermediates, value);
} }
} }
[iOS (13,0)][TV (13,0)][Mac (10,15)]
public bool? AllowLowPower {
get {
return GetBoolValue (CIContext.AllowLowPower);
}
set {
SetBooleanValue (CIContext.AllowLowPower, value);
}
}
} }
public partial class CIContext { public partial class CIContext {

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

@ -173,40 +173,59 @@ namespace CoreImage {
SetValueForKey (new NSNumber (value), nskey); SetValueForKey (new NSNumber (value), nskey);
} }
internal void SetNInt (string key, nint value)
{
using (var nskey = new NSString (key))
SetValueForKey (new NSNumber (value), nskey);
}
internal void SetBool (string key, bool value) internal void SetBool (string key, bool value)
{ {
using (var nskey = new NSString (key)) using (var nskey = new NSString (key))
SetValueForKey (new NSNumber (value ? 1 : 0), nskey); SetValueForKey (new NSNumber (value ? 1 : 0), nskey);
} }
internal void SetValue (string key, CGPoint value)
{
using (var nskey = new NSString (key))
using (var nsv = new CIVector (value.X, value.Y)) {
SetValueForKey (nsv, nskey);
}
}
internal void SetValue (string key, CGRect value)
{
using (var nskey = new NSString (key))
using (var nsv = new CIVector (value.X, value.Y, value.Width, value.Height)) {
SetValueForKey (nsv, nskey);
}
}
internal T Get<T> (string key) where T : class
{
using (var nskey = new NSString (key)) {
return ValueForKey (nskey) as T;
}
}
internal float GetFloat (string key) internal float GetFloat (string key)
{ {
using (var nskey = new NSString (key)){ return Get<NSNumber> (key)?.FloatValue ?? default (float);
var v = ValueForKey (nskey);
if (v is NSNumber)
return (v as NSNumber).FloatValue;
return 0;
}
} }
internal int GetInt (string key) internal int GetInt (string key)
{ {
using (var nskey = new NSString (key)){ return Get<NSNumber> (key)?.Int32Value ?? default (int);
var v = ValueForKey (nskey); }
if (v is NSNumber)
return (v as NSNumber).Int32Value; internal nint GetNInt (string key)
return 0; {
} return Get<NSNumber> (key)?.NIntValue ?? default (nint);
} }
internal bool GetBool (string key) internal bool GetBool (string key)
{ {
using (var nskey = new NSString (key)){ return Get<NSNumber> (key)?.BoolValue ?? default (bool);
var v = ValueForKey (nskey);
if (v is NSNumber)
return (v as NSNumber).BoolValue;
return false;
}
} }
internal void SetHandle (string key, IntPtr handle) internal void SetHandle (string key, IntPtr handle)
@ -237,31 +256,16 @@ namespace CoreImage {
return ret; return ret;
} }
internal CGPoint GetPoint (string key)
internal CIVector GetVector (string key)
{ {
return ValueForKey (key) as CIVector; var v = Get<CIVector> (key);
return v != null ? new CGPoint (v.X, v.Y) : default (CGPoint);
} }
internal CIColor GetColor (string key) internal CGRect GetRect (string key)
{ {
return ValueForKey (key) as CIColor; var v = Get<CIVector> (key);
} return v != null ? new CGRect (v.X, v.Y, v.Z, v.W) : default (CGRect);
internal CIImage GetInputImage ()
{
return ValueForKey (CIFilterInputKey.Image) as CIImage;
}
internal void SetInputImage (CIImage value)
{
SetValueForKey (value, CIFilterInputKey.Image);
}
internal CIImage GetImage (string key)
{
using (var nsstr = new NSString (key))
return ValueForKey (nsstr) as CIImage;
} }
#if MONOMAC #if MONOMAC
@ -673,29 +677,32 @@ namespace CoreImage {
} }
} }
#if !XAMCORE_4_0
// not every CIFilter supports inputImage, i.e. // not every CIFilter supports inputImage, i.e.
// NSUnknownKeyException [<CICheckerboardGenerator 0x1648cb20> valueForUndefinedKey:]: this class is not key value coding-compliant for the key inputImage. // NSUnknownKeyException [<CICheckerboardGenerator 0x1648cb20> valueForUndefinedKey:]: this class is not key value coding-compliant for the key inputImage.
// and those will crash (on devices) if the property is called - and that includes displaying it in the debugger // and those will crash (on devices) if the property is called - and that includes displaying it in the debugger
[Obsolete ("Use 'InputImage' instead. If not available then the filter does not support it.")]
public CIImage Image { public CIImage Image {
get { get {
return SupportsInputImage ? GetInputImage () : null; return SupportsInputImage ? ValueForKey (CIFilterInputKey.Image) as CIImage : null;
} }
set { set {
if (!SupportsInputImage) if (!SupportsInputImage)
throw new ArgumentException ("inputImage is not supported by this filter"); throw new ArgumentException ("inputImage is not supported by this filter");
SetInputImage (value); SetValueForKey (value, CIFilterInputKey.Image);
} }
} }
bool? supportsInputImage;
bool SupportsInputImage { bool SupportsInputImage {
get { get {
foreach (var key in InputKeys) { if (!supportsInputImage.HasValue)
if (key == "inputImage") supportsInputImage = Array.IndexOf (InputKeys, "inputImage") >= 0;
return true; return supportsInputImage.Value;
}
return false;
} }
} }
#endif
} }
#if MONOMAC && !XAMCORE_3_0 #if MONOMAC && !XAMCORE_3_0

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

@ -37,6 +37,7 @@ using CoreGraphics;
namespace ImageIO { namespace ImageIO {
#if !COREBUILD
// untyped enum -> CGImageSource.h // untyped enum -> CGImageSource.h
public enum CGImageSourceStatus { public enum CGImageSourceStatus {
Complete = 0, Complete = 0,
@ -109,9 +110,11 @@ namespace ImageIO {
return dict; return dict;
} }
} }
#endif
public partial class CGImageSource : INativeObject, IDisposable public partial class CGImageSource : INativeObject, IDisposable
{ {
#if !COREBUILD
[DllImport (Constants.ImageIOLibrary, EntryPoint="CGImageSourceGetTypeID")] [DllImport (Constants.ImageIOLibrary, EntryPoint="CGImageSourceGetTypeID")]
public extern static nint GetTypeID (); public extern static nint GetTypeID ();
@ -126,7 +129,7 @@ namespace ImageIO {
return array; return array;
} }
} }
#endif
internal IntPtr handle; internal IntPtr handle;
// invoked by marshallers // invoked by marshallers
@ -165,7 +168,8 @@ namespace ImageIO {
handle = IntPtr.Zero; handle = IntPtr.Zero;
} }
} }
#if !COREBUILD
[DllImport (Constants.ImageIOLibrary)] [DllImport (Constants.ImageIOLibrary)]
extern static /* CGImageSourceRef __nullable */ IntPtr CGImageSourceCreateWithURL ( extern static /* CGImageSourceRef __nullable */ IntPtr CGImageSourceCreateWithURL (
/* CFURLRef __nonnull */ IntPtr url, /* CFDictionaryRef __nullable */ IntPtr options); /* CFURLRef __nonnull */ IntPtr url, /* CFDictionaryRef __nullable */ IntPtr options);
@ -403,5 +407,6 @@ namespace ImageIO {
{ {
return CGImageSourceGetPrimaryImageIndex (handle); return CGImageSourceGetPrimaryImageIndex (handle);
} }
#endif
} }
} }

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

@ -14,6 +14,7 @@ using CoreFoundation;
using nw_advertise_descriptor_t=System.IntPtr; using nw_advertise_descriptor_t=System.IntPtr;
using OS_nw_advertise_descriptor=System.IntPtr; using OS_nw_advertise_descriptor=System.IntPtr;
using OS_nw_txt_record=System.IntPtr;
namespace Network { namespace Network {
[TV (12,0), Mac (10,14), iOS (12,0)] [TV (12,0), Mac (10,14), iOS (12,0)]
@ -61,5 +62,19 @@ namespace Network {
set => nw_advertise_descriptor_set_no_auto_rename (GetCheckedHandle (), value); set => nw_advertise_descriptor_set_no_auto_rename (GetCheckedHandle (), value);
get => nw_advertise_descriptor_get_no_auto_rename (GetCheckedHandle ()); get => nw_advertise_descriptor_get_no_auto_rename (GetCheckedHandle ());
} }
[TV (13,0), Mac (10,15), iOS (13,0), Watch (6,0)]
[DllImport (Constants.NetworkLibrary)]
static extern OS_nw_txt_record nw_advertise_descriptor_copy_txt_record_object (OS_nw_advertise_descriptor advertise_descriptor);
[TV (13,0), Mac (10,15), iOS (13,0), Watch (6,0)]
[DllImport (Constants.NetworkLibrary)]
static extern void nw_advertise_descriptor_set_txt_record_object (OS_nw_advertise_descriptor advertise_descriptor, OS_nw_txt_record txt_record);
[TV (13,0), Mac (10,15), iOS (13,0), Watch (6,0)]
public NWTxtRecord TxtRecord {
get => new NWTxtRecord (nw_advertise_descriptor_copy_txt_record_object (GetCheckedHandle ()), owns: true);
set => nw_advertise_descriptor_set_txt_record_object (GetCheckedHandle (), value.GetHandle ());
}
} }
} }

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

@ -0,0 +1,90 @@
//
// NWBrowseResult.cs: Bindings the Network nw_browse_result_t API.
//
// Authors:
// Manuel de la Pena (mandel@microsoft.com)
//
// Copyright 2019 Microsoft Inc
//
using System;
using System.Runtime.InteropServices;
using System.Runtime.CompilerServices;
using ObjCRuntime;
using Foundation;
using CoreFoundation;
using OS_nw_browse_result=System.IntPtr;
using OS_nw_endpoint=System.IntPtr;
using OS_nw_txt_record=System.IntPtr;
namespace Network {
[Flags, TV (13,0), Mac (10,15), iOS (13,0), Watch (6,0)]
public enum NWBrowseResultChange : ulong {
Invalid = 0x00,
Identical = 0x01,
ResultAdded = 0x02,
ResultRemoved = 0x04,
TxtRecordChanged = 0x20,
InterfaceAdded = 0x08,
InterfaceRemoved = 0x10,
}
[TV (13,0), Mac (10,15), iOS (13,0), Watch (6,0)]
public class NWBrowseResult : NativeObject {
internal NWBrowseResult (IntPtr handle, bool owns) : base (handle, owns) {}
[DllImport (Constants.NetworkLibrary)]
static extern OS_nw_endpoint nw_browse_result_copy_endpoint (OS_nw_browse_result result);
public NWEndpoint EndPoint => new NWEndpoint (nw_browse_result_copy_endpoint (GetCheckedHandle ()), owns: true);
[DllImport (Constants.NetworkLibrary)]
static extern nuint nw_browse_result_get_interfaces_count (OS_nw_browse_result result);
public nuint InterfacesCount => nw_browse_result_get_interfaces_count (GetCheckedHandle ());
[DllImport (Constants.NetworkLibrary)]
static extern OS_nw_txt_record nw_browse_result_copy_txt_record_object (OS_nw_browse_result result);
public NWTxtRecord TxtRecord => new NWTxtRecord (nw_browse_result_copy_txt_record_object (GetCheckedHandle ()), owns: true);
[DllImport (Constants.NetworkLibrary)]
static extern NWBrowseResultChange nw_browse_result_get_changes (OS_nw_browse_result old_result, OS_nw_browse_result new_result);
public static NWBrowseResultChange GetChanges (NWBrowseResult oldResult, NWBrowseResult newResult)
=> nw_browse_result_get_changes (oldResult.GetHandle (), newResult.GetHandle ());
[DllImport (Constants.NetworkLibrary)]
static extern void nw_browse_result_enumerate_interfaces (OS_nw_browse_result result, ref BlockLiteral enumerator);
delegate void nw_browse_result_enumerate_interfaces_t (IntPtr block, IntPtr nwInterface);
static nw_browse_result_enumerate_interfaces_t static_EnumerateInterfacesHandler = TrampolineEnumerateInterfacesHandler;
[MonoPInvokeCallback (typeof (nw_browse_result_enumerate_interfaces_t))]
static void TrampolineEnumerateInterfacesHandler (IntPtr block, IntPtr inter)
{
var del = BlockLiteral.GetTarget<Action<NWInterface>> (block);
if (del != null) {
var nwInterface = new NWInterface (inter, owns: false);
del (nwInterface);
}
}
[BindingImpl (BindingImplOptions.Optimizable)]
public void EnumerateInterfaces (Action<NWInterface> handler)
{
if (handler == null)
throw new ArgumentNullException (nameof (handler));
BlockLiteral block_handler = new BlockLiteral ();
block_handler.SetupBlockUnsafe (static_EnumerateInterfacesHandler, handler);
try {
nw_browse_result_enumerate_interfaces (GetCheckedHandle (), ref block_handler);
} finally {
block_handler.CleanupBlock ();
}
}
}
}

243
src/Network/NWBrowser.cs Normal file
Просмотреть файл

@ -0,0 +1,243 @@
//
// NWBrowser.cs: Bindings the Network nw_browser_t API.
//
// Authors:
// Manuel de la Pena (mandel@microsoft.com)
//
// Copyrigh 2019 Microsoft Inc
//
using System;
using System.Collections.Generic;
using System.Runtime.InteropServices;
using System.Runtime.CompilerServices;
using ObjCRuntime;
using Foundation;
using CoreFoundation;
using OS_nw_browser=System.IntPtr;
using OS_nw_browse_descriptor=System.IntPtr;
using OS_nw_parameters=System.IntPtr;
using dispatch_queue_t =System.IntPtr;
namespace Network {
[TV (13,0), Mac (10,15), iOS (13,0), Watch (6,0)]
public enum NWBrowserState {
Invalid = 0,
Ready = 1,
Failed = 2,
Cancelled = 3,
}
public delegate void NWBrowserChangesDelegate (NWBrowseResult oldResult, NWBrowseResult newResult, bool completed);
public delegate void NWBrowserCompleteChangesDelegate (List<(NWBrowseResult result, NWBrowseResultChange change)> changes);
[TV (13,0), Mac (10,15), iOS (13,0), Watch (6,0)]
public class NWBrowser : NativeObject {
bool started = false;
bool queueSet = false;
object startLock = new Object ();
internal NWBrowser (IntPtr handle, bool owns) : base (handle, owns)
{
SetChangesHandler (InternalChangesHandler);
}
[DllImport (Constants.NetworkLibrary)]
static extern OS_nw_browser nw_browser_create (OS_nw_browse_descriptor descriptor, OS_nw_parameters parameters);
public NWBrowser (NWBrowserDescriptor descriptor, NWParameters parameters)
{
if (descriptor == null)
throw new ArgumentNullException (nameof (descriptor));
InitializeHandle (nw_browser_create (descriptor.Handle, parameters.GetHandle ()));
SetChangesHandler (InternalChangesHandler);
}
public NWBrowser (NWBrowserDescriptor descriptor) : this (descriptor, null) {}
[DllImport (Constants.NetworkLibrary)]
static extern void nw_browser_set_queue (OS_nw_browser browser, dispatch_queue_t queue);
public void SetDispatchQueue (DispatchQueue queue)
{
if (queue == null)
throw new ArgumentNullException (nameof (queue));
lock (startLock) {
nw_browser_set_queue (GetCheckedHandle (), queue.Handle);
queueSet = true;
}
}
[DllImport (Constants.NetworkLibrary)]
static extern void nw_browser_start (OS_nw_browser browser);
public void Start ()
{
lock (startLock) {
if (!queueSet) {
throw new InvalidOperationException ("Cannot start the browser without a DispatchQueue.");
}
nw_browser_start (GetCheckedHandle ());
started = true;
}
}
[DllImport (Constants.NetworkLibrary)]
static extern void nw_browser_cancel (OS_nw_browser browser);
public void Cancel ()
{
lock (startLock) {
try {
nw_browser_cancel (GetCheckedHandle ());
} finally {
started = false;
}
}
}
public bool IsActive {
get {
lock (startLock)
return started;
}
}
[DllImport (Constants.NetworkLibrary)]
static extern OS_nw_browse_descriptor nw_browser_copy_browse_descriptor (OS_nw_browser browser);
public NWBrowserDescriptor Descriptor
=> new NWBrowserDescriptor (nw_browser_copy_browse_descriptor (GetCheckedHandle ()), owns: true);
[DllImport (Constants.NetworkLibrary)]
static extern OS_nw_parameters nw_browser_copy_parameters (OS_nw_browser browser);
public NWParameters Parameters
=> new NWParameters (nw_browser_copy_parameters (GetCheckedHandle ()), owns: true);
[DllImport (Constants.NetworkLibrary)]
unsafe static extern void nw_browser_set_browse_results_changed_handler (OS_nw_browser browser, void *handler);
delegate void nw_browser_browse_results_changed_handler_t (IntPtr block, IntPtr oldResult, IntPtr newResult, bool completed);
static nw_browser_browse_results_changed_handler_t static_ChangesHandler = TrampolineChangesHandler;
[MonoPInvokeCallback (typeof (nw_browser_browse_results_changed_handler_t))]
static void TrampolineChangesHandler (IntPtr block, IntPtr oldResult, IntPtr newResult, bool completed)
{
var del = BlockLiteral.GetTarget<NWBrowserChangesDelegate> (block);
if (del != null) {
// we do the cleanup of the objs in the internal handlers
NWBrowseResult nwOldResult = (oldResult == IntPtr.Zero) ? null : new NWBrowseResult (oldResult, owns: false);
NWBrowseResult nwNewResult = (newResult == IntPtr.Zero) ? null : new NWBrowseResult (newResult, owns: false);
del (nwOldResult, nwNewResult, completed);
}
}
public Action<NWBrowseResult, NWBrowseResult> IndividualChangesDelegate { get; set; }
// syntactic sugar for the user, nicer to get all the changes at once
public NWBrowserCompleteChangesDelegate CompleteChangesDelegate { get; set; }
object changesLock = new object ();
List<(NWBrowseResult result, NWBrowseResultChange change)> changes = new List<(NWBrowseResult result, NWBrowseResultChange change)> ();
void InternalChangesHandler (NWBrowseResult oldResult, NWBrowseResult newResult, bool completed)
{
// we allow the user to listen to both, individual changes AND complete ones, individual is simple, just
// call the cb, completed, we need to get a collection and call the cb when completed
var individualCb = IndividualChangesDelegate;
individualCb?.Invoke (oldResult, newResult);
var completeCb = CompleteChangesDelegate;
if (completeCb == null) {
// we do not want to keep a list of the new results if the user does not care, dispose and move on
// results can be null, since we could have a not old one
oldResult?.Dispose ();
newResult?.Dispose ();
return;
}
// get the change, add it to the list
var change = NWBrowseResult.GetChanges (oldResult, newResult);
var result = (result: newResult, change: change);
// at this point, we do not longer need the old result
// results can be null
oldResult?.Dispose ();
List<(NWBrowseResult result, NWBrowseResultChange change)> tmp_changes = null;
lock (changesLock) {
changes.Add (result);
// only call when we know we are done
if (completed) {
tmp_changes = changes;
changes = new List<(NWBrowseResult result, NWBrowseResultChange change)> ();
}
}
if (completed) {
completeCb.Invoke (tmp_changes);
foreach (var c in tmp_changes)
c.result?.Dispose ();
}
}
[BindingImpl (BindingImplOptions.Optimizable)]
void SetChangesHandler (NWBrowserChangesDelegate handler)
{
unsafe {
if (handler == null) {
nw_browser_set_browse_results_changed_handler (GetCheckedHandle (), null);
return;
}
BlockLiteral block_handler = new BlockLiteral ();
BlockLiteral *block_ptr_handler = &block_handler;
block_handler.SetupBlockUnsafe (static_ChangesHandler, handler);
try {
nw_browser_set_browse_results_changed_handler (GetCheckedHandle (), (void*) block_ptr_handler);
} finally {
block_handler.CleanupBlock ();
}
}
}
// let to not change the API, but would be nice to remove it in the following releases.
#if !XAMCORE_4_0
[Obsolete ("Uset the 'IndividualChangesDelegate' instead.")]
public void SetChangesHandler (Action<NWBrowseResult, NWBrowseResult> handler) => IndividualChangesDelegate = handler;
#endif
[DllImport (Constants.NetworkLibrary)]
unsafe static extern void nw_browser_set_state_changed_handler (OS_nw_browser browser, void *state_changed_handler);
delegate void nw_browser_set_state_changed_handler_t (IntPtr block, NWBrowserState state, IntPtr error);
static nw_browser_set_state_changed_handler_t static_StateChangesHandler = TrampolineStateChangesHandler;
[MonoPInvokeCallback (typeof (nw_browser_set_state_changed_handler_t))]
static void TrampolineStateChangesHandler (IntPtr block, NWBrowserState state, IntPtr error)
{
var del = BlockLiteral.GetTarget<Action<NWBrowserState, NWError>> (block);
if (del != null) {
var nwError = (error == IntPtr.Zero)? null : new NWError (error, owns: false);
del (state, nwError);
}
}
[BindingImpl (BindingImplOptions.Optimizable)]
public void SetStateChangesHandler (Action<NWBrowserState, NWError> handler)
{
unsafe {
if (handler == null) {
nw_browser_set_state_changed_handler (GetCheckedHandle (), null);
return;
}
BlockLiteral block_handler = new BlockLiteral ();
BlockLiteral *block_ptr_handler = &block_handler;
block_handler.SetupBlockUnsafe (static_StateChangesHandler, handler);
try {
nw_browser_set_state_changed_handler (GetCheckedHandle (), (void*) block_ptr_handler);
} finally {
block_handler.CleanupBlock ();
}
}
}
}
}

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

@ -0,0 +1,62 @@
//
// NWBrowseDescriptor.cs: Bindings the Network nw_browse_descriptor_t API.
//
// Authors:
// Manuel de la Pena (mandel@microsoft.com)
//
// Copyrigh 2019 Microsoft Inc
//
using System;
using System.Runtime.InteropServices;
using System.Runtime.CompilerServices;
using ObjCRuntime;
using Foundation;
using CoreFoundation;
using OS_nw_browse_descriptor=System.IntPtr;
namespace Network {
[TV (13,0), Mac (10,15), iOS (13,0), Watch (6,0)]
public class NWBrowserDescriptor: NativeObject {
internal NWBrowserDescriptor (IntPtr handle, bool owns) : base (handle, owns) {}
[DllImport (Constants.NetworkLibrary)]
static extern OS_nw_browse_descriptor nw_browse_descriptor_create_bonjour_service (string type, string domain);
public static NWBrowserDescriptor CreateBonjourService (string type, string domain)
{
// domain can be null, type CANNOT
if (type == null)
throw new ArgumentNullException (nameof (type));
return new NWBrowserDescriptor (nw_browse_descriptor_create_bonjour_service (type, domain), owns: true);
}
public static NWBrowserDescriptor CreateBonjourService (string type) => CreateBonjourService (type, null);
[DllImport (Constants.NetworkLibrary)]
static extern bool nw_browse_descriptor_get_include_txt_record (OS_nw_browse_descriptor descriptor);
[DllImport (Constants.NetworkLibrary)]
static extern void nw_browse_descriptor_set_include_txt_record (OS_nw_browse_descriptor descriptor, bool include_txt_record);
public bool IncludeTxtRecord {
get => nw_browse_descriptor_get_include_txt_record (GetCheckedHandle ());
set => nw_browse_descriptor_set_include_txt_record (GetCheckedHandle (), value);
}
[DllImport (Constants.NetworkLibrary, CharSet = CharSet.Ansi, CallingConvention = CallingConvention.Cdecl)]
static extern IntPtr nw_browse_descriptor_get_bonjour_service_type (OS_nw_browse_descriptor descriptor);
public string BonjourType
=> Marshal.PtrToStringAnsi (nw_browse_descriptor_get_bonjour_service_type (GetCheckedHandle ()));
[DllImport (Constants.NetworkLibrary, CharSet = CharSet.Ansi, CallingConvention = CallingConvention.Cdecl)]
static extern IntPtr nw_browse_descriptor_get_bonjour_service_domain (OS_nw_browse_descriptor descriptor);
public string BonjourDomain
=> Marshal.PtrToStringAnsi (nw_browse_descriptor_get_bonjour_service_domain (GetCheckedHandle ()));
}
}

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

@ -14,6 +14,7 @@ using CoreFoundation;
using nw_connection_t=System.IntPtr; using nw_connection_t=System.IntPtr;
using nw_endpoint_t=System.IntPtr; using nw_endpoint_t=System.IntPtr;
using nw_parameters_t=System.IntPtr; using nw_parameters_t=System.IntPtr;
using nw_establishment_report_t=System.IntPtr;
namespace Network { namespace Network {
[TV (12,0), Mac (10,14), iOS (12,0)] [TV (12,0), Mac (10,14), iOS (12,0)]
@ -42,6 +43,12 @@ namespace Network {
// //
public delegate void NWConnectionReceiveDispatchDataCompletion (DispatchData data, NWContentContext context, bool isComplete, NWError error); public delegate void NWConnectionReceiveDispatchDataCompletion (DispatchData data, NWContentContext context, bool isComplete, NWError error);
//
// Signature for a method invoked on data received, same as NWConnectionReceiveCompletion,
// but they receive ReadOnlySpan rather than a data + dataSize
//
public delegate void NWConnectionReceiveReadOnlySpanCompletion (ReadOnlySpan<byte> data, NWContentContext context, bool isComplete, NWError error);
[TV (12,0), Mac (10,14), iOS (12,0)] [TV (12,0), Mac (10,14), iOS (12,0)]
[Watch (6,0)] [Watch (6,0)]
public class NWConnection : NativeObject { public class NWConnection : NativeObject {
@ -251,6 +258,7 @@ namespace Network {
static nw_connection_receive_completion_t static_ReceiveCompletion = TrampolineReceiveCompletion; static nw_connection_receive_completion_t static_ReceiveCompletion = TrampolineReceiveCompletion;
static nw_connection_receive_completion_t static_ReceiveCompletionDispatchData = TrampolineReceiveCompletionData; static nw_connection_receive_completion_t static_ReceiveCompletionDispatchData = TrampolineReceiveCompletionData;
static nw_connection_receive_completion_t static_ReceiveCompletionDispatchReadnOnlyData = TrampolineReceiveCompletionReadOnlyData;
[MonoPInvokeCallback (typeof (nw_connection_receive_completion_t))] [MonoPInvokeCallback (typeof (nw_connection_receive_completion_t))]
static void TrampolineReceiveCompletion (IntPtr block, IntPtr dispatchDataPtr, IntPtr contentContext, bool isComplete, IntPtr error) static void TrampolineReceiveCompletion (IntPtr block, IntPtr dispatchDataPtr, IntPtr contentContext, bool isComplete, IntPtr error)
@ -300,6 +308,35 @@ namespace Network {
} }
} }
[MonoPInvokeCallback (typeof (nw_connection_receive_completion_t))]
static void TrampolineReceiveCompletionReadOnlyData (IntPtr block, IntPtr dispatchDataPtr, IntPtr contentContext, bool isComplete, IntPtr error)
{
var del = BlockLiteral.GetTarget<NWConnectionReceiveReadOnlySpanCompletion> (block);
if (del != null) {
DispatchData dispatchData = null, dataCopy = null;
IntPtr bufferAddress = IntPtr.Zero;
nuint bufferSize = 0;
if (dispatchDataPtr != IntPtr.Zero) {
dispatchData = new DispatchData (dispatchDataPtr, owns: false);
dataCopy = dispatchData.CreateMap (out bufferAddress, out bufferSize);
}
unsafe {
var spanData = new ReadOnlySpan<byte> ((void*)bufferAddress, (int)bufferSize);
del (spanData,
contentContext == IntPtr.Zero ? null : new NWContentContext (contentContext, owns: false),
isComplete,
error == IntPtr.Zero ? null : new NWError (error, owns: false));
}
if (dispatchData != null) {
dataCopy.Dispose ();
dispatchData.Dispose ();
}
}
}
[DllImport (Constants.NetworkLibrary)] [DllImport (Constants.NetworkLibrary)]
static extern void nw_connection_receive (IntPtr handle, /* uint32_t */ uint minimumIncompleteLength, /* uint32_t */ uint maximumLength, ref BlockLiteral callback); static extern void nw_connection_receive (IntPtr handle, /* uint32_t */ uint minimumIncompleteLength, /* uint32_t */ uint maximumLength, ref BlockLiteral callback);
@ -334,6 +371,22 @@ namespace Network {
} }
} }
[BindingImpl (BindingImplOptions.Optimizable)]
public void ReceiveReadOnlyData (uint minimumIncompleteLength, uint maximumLength, NWConnectionReceiveReadOnlySpanCompletion callback)
{
if (callback == null)
throw new ArgumentNullException (nameof (callback));
BlockLiteral block_handler = new BlockLiteral ();
block_handler.SetupBlockUnsafe (static_ReceiveCompletionDispatchReadnOnlyData, callback);
try {
nw_connection_receive (GetCheckedHandle (), minimumIncompleteLength, maximumLength, ref block_handler);
} finally {
block_handler.CleanupBlock ();
}
}
[DllImport (Constants.NetworkLibrary)] [DllImport (Constants.NetworkLibrary)]
static extern void nw_connection_receive_message (IntPtr handle, ref BlockLiteral callback); static extern void nw_connection_receive_message (IntPtr handle, ref BlockLiteral callback);
@ -369,6 +422,22 @@ namespace Network {
} }
} }
[BindingImpl (BindingImplOptions.Optimizable)]
public void ReceiveMessageReadOnlyData (NWConnectionReceiveReadOnlySpanCompletion callback)
{
if (callback == null)
throw new ArgumentNullException (nameof (callback));
BlockLiteral block_handler = new BlockLiteral ();
block_handler.SetupBlockUnsafe (static_ReceiveCompletionDispatchReadnOnlyData, callback);
try {
nw_connection_receive_message (GetCheckedHandle (), ref block_handler);
} finally {
block_handler.CleanupBlock ();
}
}
delegate void nw_connection_send_completion_t (IntPtr block, IntPtr error); delegate void nw_connection_send_completion_t (IntPtr block, IntPtr error);
static nw_connection_send_completion_t static_SendCompletion = TrampolineSendCompletion; static nw_connection_send_completion_t static_SendCompletion = TrampolineSendCompletion;
@ -491,6 +560,15 @@ namespace Network {
return new NWProtocolMetadata (x, owns: true); return new NWProtocolMetadata (x, owns: true);
} }
public T GetProtocolMetadata<T> (NWProtocolDefinition definition) where T : NWProtocolMetadata
{
if (definition == null)
throw new ArgumentNullException (nameof (definition));
var x = nw_connection_copy_protocol_metadata (GetCheckedHandle (), definition.Handle);
return Runtime.GetINativeObject<T> (x, owns: true);
}
[DllImport (Constants.NetworkLibrary)] [DllImport (Constants.NetworkLibrary)]
extern static /* uint32_t */ uint nw_connection_get_maximum_datagram_size (IntPtr handle); extern static /* uint32_t */ uint nw_connection_get_maximum_datagram_size (IntPtr handle);
@ -503,5 +581,41 @@ namespace Network {
{ {
BlockLiteral.SimpleCall (method, (arg)=> nw_connection_batch (GetCheckedHandle (), arg)); BlockLiteral.SimpleCall (method, (arg)=> nw_connection_batch (GetCheckedHandle (), arg));
} }
[Watch (6,0), TV (13,0), Mac (10,15), iOS (13,0)]
[DllImport (Constants.NetworkLibrary)]
unsafe static extern void nw_connection_access_establishment_report (IntPtr connection, IntPtr queue, ref BlockLiteral access_block);
delegate void nw_establishment_report_access_block_t (IntPtr block, nw_establishment_report_t report);
static nw_establishment_report_access_block_t static_GetEstablishmentReportHandler = TrampolineGetEstablishmentReportHandler;
[MonoPInvokeCallback (typeof (nw_establishment_report_access_block_t))]
static void TrampolineGetEstablishmentReportHandler (IntPtr block, nw_establishment_report_t report)
{
var del = BlockLiteral.GetTarget<Action<NWEstablishmentReport>> (block);
if (del != null) {
// the ownerthip of the object is for the caller
var nwReport = new NWEstablishmentReport (report, owns: true);
del (nwReport);
}
}
[TV (13,0), Mac (10,15), iOS (13,0), Watch (6,0)]
[BindingImpl (BindingImplOptions.Optimizable)]
public void GetEstablishmentReport (DispatchQueue queue, Action<NWEstablishmentReport> handler)
{
if (queue == null)
throw new ArgumentNullException (nameof (queue));
if (handler == null)
throw new ArgumentNullException (nameof (handler));
BlockLiteral block_handler = new BlockLiteral ();
block_handler.SetupBlockUnsafe (static_GetEstablishmentReportHandler, handler);
try {
nw_connection_access_establishment_report (GetCheckedHandle (), queue.Handle, ref block_handler);
} finally {
block_handler.CleanupBlock ();
}
}
} }
} }

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

@ -126,6 +126,14 @@ namespace Network {
return new NWProtocolMetadata (x, owns: true); return new NWProtocolMetadata (x, owns: true);
} }
public T GetProtocolMetadata<T> (NWProtocolDefinition protocolDefinition) where T : NWProtocolMetadata
{
if (protocolDefinition == null)
throw new ArgumentNullException (nameof (protocolDefinition));
var x = nw_content_context_copy_protocol_metadata (GetCheckedHandle (), protocolDefinition.Handle);
return Runtime.GetINativeObject<T> (x, owns: true);
}
[DllImport (Constants.NetworkLibrary)] [DllImport (Constants.NetworkLibrary)]
extern static void nw_content_context_set_metadata_for_protocol (IntPtr handle, IntPtr protocolMetadata); extern static void nw_content_context_set_metadata_for_protocol (IntPtr handle, IntPtr protocolMetadata);

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

@ -0,0 +1,170 @@
//
// NWDataTransferReport.cs: Bindings the Network nw_data_transfer_report_t API.
//
// Authors:
// Manuel de la Pena (mandel@microsoft.com)
//
// Copyright 2019 Microsoft Inc
//
using System;
using System.Runtime.InteropServices;
using System.Runtime.CompilerServices;
using ObjCRuntime;
using Foundation;
using CoreFoundation;
using OS_nw_data_transfer_report=System.IntPtr;
using OS_nw_connection=System.IntPtr;
using OS_nw_interface=System.IntPtr;
namespace Network {
[TV (13,0), Mac (10,15), iOS (13,0), Watch (6,0)]
public enum NWDataTransferReportState {
Collecting = 1,
Collected = 2,
}
[TV (13,0), Mac (10,15), iOS (13,0), Watch (6,0)]
public class NWDataTransferReport : NativeObject {
internal NWDataTransferReport (IntPtr handle, bool owns) : base (handle, owns) {}
[DllImport (Constants.NetworkLibrary)]
static extern OS_nw_data_transfer_report nw_connection_create_new_data_transfer_report (OS_nw_connection connection);
public NWDataTransferReport (NWConnection connection)
{
if (connection == null)
throw new ArgumentNullException (nameof (connection));
InitializeHandle (nw_connection_create_new_data_transfer_report (connection.Handle));
}
[DllImport (Constants.NetworkLibrary)]
static extern uint nw_data_transfer_report_get_path_count (OS_nw_data_transfer_report report);
public uint PathCount => nw_data_transfer_report_get_path_count (GetCheckedHandle ());
[DllImport (Constants.NetworkLibrary)]
static extern ulong nw_data_transfer_report_get_duration_milliseconds (OS_nw_data_transfer_report report);
public TimeSpan Duration => TimeSpan.FromMilliseconds (nw_data_transfer_report_get_duration_milliseconds (GetCheckedHandle ()));
[DllImport (Constants.NetworkLibrary)]
static extern OS_nw_interface nw_data_transfer_report_copy_path_interface (OS_nw_data_transfer_report report, uint path_index);
public NWInterface GetInterface (uint pathIndex)
=> new NWInterface (nw_data_transfer_report_copy_path_interface (GetCheckedHandle (), pathIndex), owns: true);
[DllImport (Constants.NetworkLibrary)]
static extern ulong nw_data_transfer_report_get_received_application_byte_count (OS_nw_data_transfer_report report, uint path_index);
public ulong GetApplicationReceivedByteCount (uint pathIndex)
=> nw_data_transfer_report_get_received_application_byte_count (GetCheckedHandle (), pathIndex);
[DllImport (Constants.NetworkLibrary)]
static extern ulong nw_data_transfer_report_get_sent_application_byte_count (OS_nw_data_transfer_report report, uint path_index);
public ulong GetApplicationSentByteCount (uint pathIndex)
=> nw_data_transfer_report_get_sent_application_byte_count (GetCheckedHandle (), pathIndex);
[DllImport (Constants.NetworkLibrary)]
static extern ulong nw_data_transfer_report_get_received_transport_byte_count (OS_nw_data_transfer_report report, uint path_index);
public ulong GetTransportReceivedByteCount (uint pathIndex)
=> nw_data_transfer_report_get_received_transport_byte_count (GetCheckedHandle (), pathIndex);
[DllImport (Constants.NetworkLibrary)]
static extern ulong nw_data_transfer_report_get_received_transport_duplicate_byte_count (OS_nw_data_transfer_report report, uint path_index);
public ulong GetTransportReceivedDuplicateByteCount (uint pathIndex)
=> nw_data_transfer_report_get_received_transport_duplicate_byte_count (GetCheckedHandle (), pathIndex);
[DllImport (Constants.NetworkLibrary)]
static extern ulong nw_data_transfer_report_get_received_transport_out_of_order_byte_count (OS_nw_data_transfer_report report, uint path_index);
public ulong GetTransportReceivedOutOfOrderByteCount (uint pathIndex)
=> nw_data_transfer_report_get_received_transport_duplicate_byte_count (GetCheckedHandle (), pathIndex);
[DllImport (Constants.NetworkLibrary)]
static extern ulong nw_data_transfer_report_get_sent_transport_byte_count (OS_nw_data_transfer_report report, uint path_index);
public ulong GetTransportSentByteCount (uint pathIndex)
=> nw_data_transfer_report_get_sent_transport_byte_count (GetCheckedHandle (), pathIndex);
[DllImport (Constants.NetworkLibrary)]
static extern ulong nw_data_transfer_report_get_sent_transport_retransmitted_byte_count (OS_nw_data_transfer_report report, uint path_index);
public ulong GetTransportRetransmittedByteCount (uint pathIndex)
=> nw_data_transfer_report_get_sent_transport_retransmitted_byte_count (GetCheckedHandle (), pathIndex);
[DllImport (Constants.NetworkLibrary)]
static extern ulong nw_data_transfer_report_get_transport_smoothed_rtt_milliseconds (OS_nw_data_transfer_report report, uint path_index);
public TimeSpan GetTransportSmoothedRoundTripTime (uint pathIndex)
=> TimeSpan.FromMilliseconds (nw_data_transfer_report_get_transport_smoothed_rtt_milliseconds (GetCheckedHandle (), pathIndex));
[DllImport (Constants.NetworkLibrary)]
static extern ulong nw_data_transfer_report_get_transport_minimum_rtt_milliseconds (OS_nw_data_transfer_report report, uint path_index);
public TimeSpan GetTransportMinimumRoundTripTime (uint pathIndex)
=> TimeSpan.FromMilliseconds (nw_data_transfer_report_get_transport_minimum_rtt_milliseconds (GetCheckedHandle (), pathIndex));
[DllImport (Constants.NetworkLibrary)]
static extern ulong nw_data_transfer_report_get_transport_rtt_variance (OS_nw_data_transfer_report report, uint path_index);
public ulong GetTransportRoundTripTimeVariance (uint pathIndex)
=> nw_data_transfer_report_get_transport_rtt_variance (GetCheckedHandle (), pathIndex);
[DllImport (Constants.NetworkLibrary)]
static extern ulong nw_data_transfer_report_get_received_ip_packet_count (OS_nw_data_transfer_report report, uint path_index);
public ulong GetTransportReceivedIPPackageCount (uint pathIndex)
=> nw_data_transfer_report_get_received_ip_packet_count (GetCheckedHandle (), pathIndex);
[DllImport (Constants.NetworkLibrary)]
static extern ulong nw_data_transfer_report_get_sent_ip_packet_count (OS_nw_data_transfer_report report, uint path_index);
public ulong GetTransportSentIPPackageCount (uint pathIndex)
=> nw_data_transfer_report_get_sent_ip_packet_count (GetCheckedHandle (), pathIndex);
[DllImport (Constants.NetworkLibrary)]
unsafe static extern void nw_data_transfer_report_collect (OS_nw_data_transfer_report report, IntPtr queue, ref BlockLiteral collect_block);
delegate void nw_data_transfer_report_collect_t (IntPtr block, IntPtr report);
static nw_data_transfer_report_collect_t static_CollectHandler = TrampolineCollectHandler;
[MonoPInvokeCallback (typeof (nw_data_transfer_report_collect_t))]
static void TrampolineCollectHandler (IntPtr block, IntPtr report)
{
var del = BlockLiteral.GetTarget<Action<NWDataTransferReport>> (block);
if (del != null) {
using (var nwReport = new NWDataTransferReport (report, owns: false))
del (nwReport);
}
}
[BindingImpl (BindingImplOptions.Optimizable)]
public void Collect (DispatchQueue queue, Action<NWDataTransferReport> handler)
{
if (queue == null)
throw new ArgumentNullException (nameof (queue));
if (handler == null)
throw new ArgumentNullException (nameof (handler));
BlockLiteral block_handler = new BlockLiteral ();
block_handler.SetupBlockUnsafe (static_CollectHandler, handler);
try {
nw_data_transfer_report_collect (GetCheckedHandle (), queue.Handle, ref block_handler);
} finally {
block_handler.CleanupBlock ();
}
}
[DllImport (Constants.NetworkLibrary)]
static extern NWDataTransferReportState nw_data_transfer_report_get_state (OS_nw_data_transfer_report report);
public NWDataTransferReportState State => nw_data_transfer_report_get_state (GetCheckedHandle ());
}
}

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

@ -112,5 +112,27 @@ namespace Network {
static extern IntPtr nw_endpoint_get_bonjour_service_domain (OS_nw_endpoint endpoint); static extern IntPtr nw_endpoint_get_bonjour_service_domain (OS_nw_endpoint endpoint);
public string BonjourServiceDomain => Marshal.PtrToStringAnsi (nw_endpoint_get_bonjour_service_domain (GetCheckedHandle ())); public string BonjourServiceDomain => Marshal.PtrToStringAnsi (nw_endpoint_get_bonjour_service_domain (GetCheckedHandle ()));
[Watch (6,0), TV (13,0), Mac (10,15), iOS (13,0)]
[DllImport (Constants.NetworkLibrary, CharSet = CharSet.Ansi, CallingConvention = CallingConvention.Cdecl)]
static extern OS_nw_endpoint nw_endpoint_create_url (string url);
[Watch (6,0), TV (13,0), Mac (10,15), iOS (13,0)]
public static NWEndpoint Create (string url)
{
if (url == null)
throw new ArgumentNullException (nameof (url));
var handle = nw_endpoint_create_url (url);
if (handle == IntPtr.Zero)
return null;
return new NWEndpoint (handle, owns: true);
}
[Watch (6,0), TV (13,0), Mac (10,15), iOS (13,0)]
[DllImport (Constants.NetworkLibrary, CharSet = CharSet.Ansi, CallingConvention = CallingConvention.Cdecl)]
static extern IntPtr nw_endpoint_get_url (OS_nw_endpoint endpoint);
[Watch (6,0), TV (13,0), Mac (10,15), iOS (13,0)]
public string Url => Marshal.PtrToStringAnsi (nw_endpoint_get_url (GetCheckedHandle ()));
} }
} }

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

@ -0,0 +1,134 @@
//
// NWDataTransferReport.cs: Bindings the Network nw_data_transfer_report_t API.
//
// Authors:
// Manuel de la Pena (mandel@microsoft.com)
//
// Copyright 2019 Microsoft Inc
//
using System;
using System.Runtime.InteropServices;
using System.Runtime.CompilerServices;
using ObjCRuntime;
using Foundation;
using CoreFoundation;
using OS_nw_establishment_report=System.IntPtr;
using nw_endpoint_t=System.IntPtr;
using nw_report_protocol_enumerator_t=System.IntPtr;
using nw_protocol_definition_t=System.IntPtr;
namespace Network {
[TV (13,0), Mac (10,15), iOS (13,0), Watch (6,0)]
public enum NWReportResolutionSource {
Query = 1,
Cache = 2,
ExpiredCache = 3,
}
[TV (13,0), Mac (10,15), iOS (13,0), Watch (6,0)]
public class NWEstablishmentReport : NativeObject {
internal NWEstablishmentReport (IntPtr handle, bool owns) : base (handle, owns) {}
[DllImport (Constants.NetworkLibrary)]
static extern bool nw_establishment_report_get_used_proxy (OS_nw_establishment_report report);
public bool UsedProxy => nw_establishment_report_get_used_proxy (GetCheckedHandle ());
[DllImport (Constants.NetworkLibrary)]
static extern bool nw_establishment_report_get_proxy_configured (OS_nw_establishment_report report);
public bool ProxyConfigured => nw_establishment_report_get_proxy_configured (GetCheckedHandle ());
[DllImport (Constants.NetworkLibrary)]
static extern uint nw_establishment_report_get_previous_attempt_count (OS_nw_establishment_report report);
public uint PreviousAttemptCount => nw_establishment_report_get_previous_attempt_count (GetCheckedHandle ());
[DllImport (Constants.NetworkLibrary)]
static extern ulong nw_establishment_report_get_duration_milliseconds (OS_nw_establishment_report report);
public TimeSpan Duration => TimeSpan.FromMilliseconds (nw_establishment_report_get_duration_milliseconds (GetCheckedHandle ()));
[DllImport (Constants.NetworkLibrary)]
static extern ulong nw_establishment_report_get_attempt_started_after_milliseconds (OS_nw_establishment_report report);
public TimeSpan ConnectionSetupTime => TimeSpan.FromMilliseconds (nw_establishment_report_get_attempt_started_after_milliseconds (GetCheckedHandle ()));
[DllImport (Constants.NetworkLibrary)]
static extern void nw_establishment_report_enumerate_resolutions (OS_nw_establishment_report report, ref BlockLiteral enumerate_block);
delegate void nw_report_resolution_enumerator_t (IntPtr block, NWReportResolutionSource source, nuint milliseconds, int endpoint_count, nw_endpoint_t successful_endpoint, nw_endpoint_t preferred_endpoint);
static nw_report_resolution_enumerator_t static_ResolutionEnumeratorHandler = TrampolineResolutionEnumeratorHandler;
[MonoPInvokeCallback (typeof (nw_report_resolution_enumerator_t))]
static void TrampolineResolutionEnumeratorHandler (IntPtr block, NWReportResolutionSource source, nuint milliseconds, int endpoint_count, nw_endpoint_t successful_endpoint, nw_endpoint_t preferred_endpoint)
{
var del = BlockLiteral.GetTarget<Action<NWReportResolutionSource, TimeSpan, int, NWEndpoint, NWEndpoint>> (block);
if (del != null) {
using (var nwSuccesfulEndpoint = new NWEndpoint (successful_endpoint, owns: false))
using (var nwPreferredEndpoint = new NWEndpoint (preferred_endpoint, owns: false))
del (source,TimeSpan.FromMilliseconds (milliseconds), endpoint_count, nwSuccesfulEndpoint, nwPreferredEndpoint);
}
}
[BindingImpl (BindingImplOptions.Optimizable)]
public void EnumerateResolutions (Action<NWReportResolutionSource, TimeSpan, int, NWEndpoint, NWEndpoint> handler)
{
if (handler == null)
throw new ArgumentNullException (nameof (handler));
BlockLiteral block_handler = new BlockLiteral ();
block_handler.SetupBlockUnsafe (static_ResolutionEnumeratorHandler, handler);
try {
nw_establishment_report_enumerate_resolutions (GetCheckedHandle (), ref block_handler);
} finally {
block_handler.CleanupBlock ();
}
}
[DllImport (Constants.NetworkLibrary)]
static extern void nw_establishment_report_enumerate_protocols (OS_nw_establishment_report report, ref BlockLiteral enumerate_block);
delegate void nw_establishment_report_enumerate_protocols_t (IntPtr block, nw_protocol_definition_t protocol, nuint handshake_milliseconds, nuint handshake_rtt_milliseconds);
static nw_establishment_report_enumerate_protocols_t static_EnumerateProtocolsHandler = TrampolineEnumerateProtocolsHandler;
[MonoPInvokeCallback (typeof (nw_establishment_report_enumerate_protocols_t))]
static void TrampolineEnumerateProtocolsHandler (IntPtr block, nw_protocol_definition_t protocol, nuint handshake_milliseconds, nuint handshake_rtt_milliseconds)
{
var del = BlockLiteral.GetTarget<Action<NWProtocolDefinition, TimeSpan, TimeSpan>> (block);
if (del != null) {
using (var nwProtocolDefinition = new NWProtocolDefinition (protocol, owns: false))
del (nwProtocolDefinition, TimeSpan.FromMilliseconds (handshake_milliseconds), TimeSpan.FromMilliseconds (handshake_rtt_milliseconds));
}
}
[BindingImpl (BindingImplOptions.Optimizable)]
public void EnumerateProtocols (Action<NWProtocolDefinition, TimeSpan, TimeSpan> handler)
{
if (handler == null)
throw new ArgumentNullException (nameof (handler));
BlockLiteral block_handler = new BlockLiteral ();
block_handler.SetupBlockUnsafe (static_EnumerateProtocolsHandler, handler);
try {
nw_establishment_report_enumerate_protocols (GetCheckedHandle (), ref block_handler);
} finally {
block_handler.CleanupBlock ();
}
}
[DllImport (Constants.NetworkLibrary)]
static extern nw_endpoint_t nw_establishment_report_copy_proxy_endpoint (OS_nw_establishment_report report);
public NWEndpoint ProxyEndpoint {
get {
var ptr = nw_establishment_report_copy_proxy_endpoint (GetCheckedHandle ());
return (ptr == IntPtr.Zero) ? null : new NWEndpoint (ptr, owns:true);
}
}
}
}

475
src/Network/NWFramer.cs Normal file
Просмотреть файл

@ -0,0 +1,475 @@
//
// NWFramer.cs: Bindings the Network nw_framer_t API.
//
// Authors:
// Manuel de la Pena (mandel@microsoft.com)
//
// Copyright 2019 Microsoft Inc
//
using System;
using System.Runtime.InteropServices;
using System.Runtime.CompilerServices;
using ObjCRuntime;
using Foundation;
using CoreFoundation;
using OS_nw_framer=System.IntPtr;
using OS_nw_protocol_metadata=System.IntPtr;
using OS_dispatch_data=System.IntPtr;
using OS_nw_protocol_definition=System.IntPtr;
using OS_nw_protocol_options=System.IntPtr;
using OS_nw_endpoint=System.IntPtr;
using OS_nw_parameters=System.IntPtr;
namespace Network {
// from System/Library/Frameworks/Network.framework/Headers/framer_options.h:
[Flags]
[TV (13,0), Mac (10,15), iOS (13,0), Watch (6,0)]
public enum NWFramerCreateFlags : uint {
Default = 0x00,
}
// from System/Library/Frameworks/Network.framework/Headers/framer_options.h:
[TV (13,0), Mac (10,15), iOS (13,0), Watch (6,0)]
public enum NWFramerStartResult {
Unknown = 0,
Ready = 1,
WillMarkReady = 2,
}
[TV (13,0), Mac (10,15), iOS (13,0), Watch (6,0)]
public class NWFramer : NativeObject {
internal NWFramer (IntPtr handle, bool owns) : base (handle, owns) {}
/*
[DllImport (Constants.NetworkLibrary)]
static extern bool nw_framer_write_output_no_copy (OS_nw_framer framer, nuint output_length);
public bool WriteOutput (nuint outputLength) => nw_framer_write_output_no_copy (GetCheckedHandle (), outputLength);
[DllImport (Constants.NetworkLibrary)]
static extern void nw_framer_write_output_data (OS_nw_framer framer, OS_dispatch_data output_data);
public void WriteOutput (DispatchData data)
{
if (data == null)
throw new ArgumentNullException (nameof (data));
nw_framer_write_output_data (GetCheckedHandle (), data.Handle);
}
[DllImport (Constants.NetworkLibrary)]
unsafe static extern void nw_framer_write_output (OS_nw_framer framer, byte *output_buffer, nuint output_length);
public void WriteOutput (ReadOnlySpan<byte> data)
{
unsafe {
fixed (byte *mh = data)
nw_framer_write_output (GetCheckedHandle (), mh, (nuint) data.Length);
}
}
[DllImport (Constants.NetworkLibrary)]
unsafe static extern void nw_framer_set_wakeup_handler (OS_nw_framer framer, void *wakeup_handler);
delegate void nw_framer_set_wakeup_handler_t (IntPtr block, OS_nw_framer framer);
static nw_framer_set_wakeup_handler_t static_WakeupHandler = TrampolineWakeupHandler;
[MonoPInvokeCallback (typeof (nw_framer_set_wakeup_handler_t))]
static void TrampolineWakeupHandler (IntPtr block, OS_nw_framer framer)
{
var del = BlockLiteral.GetTarget<Action<NWFramer>> (block);
if (del != null) {
var nwFramer = new NWFramer (framer, owns: true);
del (nwFramer);
}
}
[BindingImpl (BindingImplOptions.Optimizable)]
public Action<NWFramer> WakeupHandler {
set {
unsafe {
if (value == null) {
nw_framer_set_wakeup_handler (GetCheckedHandle (), null);
return;
}
BlockLiteral block_handler = new BlockLiteral ();
BlockLiteral *block_ptr_handler = &block_handler;
block_handler.SetupBlockUnsafe (static_WakeupHandler, value);
try {
nw_framer_set_wakeup_handler (GetCheckedHandle (), (void*) block_ptr_handler);
} finally {
block_handler.CleanupBlock ();
}
}
}
}
[DllImport (Constants.NetworkLibrary)]
unsafe static extern void nw_framer_set_stop_handler (OS_nw_framer framer, void *stop_handler);
delegate void nw_framer_set_stop_handler_t (IntPtr block, OS_nw_framer framer);
static nw_framer_set_stop_handler_t static_StopHandler = TrampolineStopHandler;
[MonoPInvokeCallback (typeof (nw_framer_set_stop_handler_t))]
static void TrampolineStopHandler (IntPtr block, OS_nw_framer framer)
{
var del = BlockLiteral.GetTarget<Action<NWFramer>> (block);
if (del != null) {
var nwFramer = new NWFramer (framer, owns: true);
del (nwFramer);
}
}
[BindingImpl (BindingImplOptions.Optimizable)]
public Action<NWFramer> StopHandler {
set {
unsafe {
if (value == null) {
nw_framer_set_stop_handler (GetCheckedHandle (), null);
return;
}
BlockLiteral block_handler = new BlockLiteral ();
BlockLiteral *block_ptr_handler = &block_handler;
block_handler.SetupBlockUnsafe (static_StopHandler, value);
try {
nw_framer_set_stop_handler (GetCheckedHandle (), (void*) block_ptr_handler);
} finally {
block_handler.CleanupBlock ();
}
}
}
}
[DllImport (Constants.NetworkLibrary)]
unsafe static extern void nw_framer_set_output_handler (OS_nw_framer framer, void *output_handler);
delegate void nw_framer_set_output_handler_t (IntPtr block, OS_nw_framer framer, OS_nw_protocol_metadata message, nuint message_length, bool is_complete);
static nw_framer_set_output_handler_t static_OutputHandler = TrampolineOutputHandler;
[MonoPInvokeCallback (typeof (nw_framer_set_output_handler_t))]
static void TrampolineOutputHandler (IntPtr block, OS_nw_framer framer, OS_nw_protocol_metadata message, nuint message_length, bool is_complete)
{
var del = BlockLiteral.GetTarget<Action<NWFramer, NWProtocolMetadata, nuint, bool>> (block);
if (del != null) {
var nwFramer = new NWFramer (framer, owns: true);
var nwProtocolMetadata = new NWProtocolMetadata (message, owns: true);
del (nwFramer, nwProtocolMetadata, message_length, is_complete);
}
}
[BindingImpl (BindingImplOptions.Optimizable)]
public Action<NWFramer, NWProtocolMetadata, nuint, bool> OutputHandler {
set {
unsafe {
if (value == null) {
nw_framer_set_output_handler (GetCheckedHandle (), null);
return;
}
BlockLiteral block_handler = new BlockLiteral ();
BlockLiteral *block_ptr_handler = &block_handler;
block_handler.SetupBlockUnsafe (static_OutputHandler, value);
try {
nw_framer_set_output_handler (GetCheckedHandle (), (void*) block_ptr_handler);
} finally {
block_handler.CleanupBlock ();
}
}
}
}
[DllImport (Constants.NetworkLibrary)]
unsafe static extern void nw_framer_set_input_handler (OS_nw_framer framer, void *input_handler);
delegate void nw_framer_set_input_handler_t (IntPtr block, OS_nw_framer framer);
static nw_framer_set_input_handler_t static_InputHandler = TrampolineInputHandler;
[MonoPInvokeCallback (typeof (nw_framer_set_input_handler_t))]
static void TrampolineInputHandler (IntPtr block, OS_nw_framer framer)
{
var del = BlockLiteral.GetTarget<Action<NWFramer>> (block);
if (del != null) {
var nwFramer = new NWFramer (framer, owns: true);
del (nwFramer);
}
}
[BindingImpl (BindingImplOptions.Optimizable)]
public Action<NWFramer> InputHandler {
set {
unsafe {
if (value == null) {
nw_framer_set_input_handler (GetCheckedHandle (), null);
return;
}
BlockLiteral block_handler = new BlockLiteral ();
BlockLiteral *block_ptr_handler = &block_handler;
block_handler.SetupBlockUnsafe (static_InputHandler, value);
try {
nw_framer_set_input_handler (GetCheckedHandle (), (void*) block_ptr_handler);
} finally {
block_handler.CleanupBlock ();
}
}
}
}
[DllImport (Constants.NetworkLibrary)]
unsafe static extern void nw_framer_set_cleanup_handler (OS_nw_framer framer, void *cleanup_handler);
delegate void nw_framer_set_cleanup_handler_t (IntPtr block, OS_nw_framer framer);
static nw_framer_set_input_handler_t static_CleanupHandler = TrampolineCleanupHandler;
[MonoPInvokeCallback (typeof (nw_framer_set_input_handler_t))]
static void TrampolineCleanupHandler (IntPtr block, OS_nw_framer framer)
{
var del = BlockLiteral.GetTarget<Action<NWFramer>> (block);
if (del != null) {
var nwFramer = new NWFramer (framer, owns: true);
del (nwFramer);
}
}
[BindingImpl (BindingImplOptions.Optimizable)]
public Action<NWFramer> CleanupHandler {
set {
unsafe {
if (value == null) {
nw_framer_set_cleanup_handler (GetCheckedHandle (), null);
return;
}
BlockLiteral block_handler = new BlockLiteral ();
BlockLiteral *block_ptr_handler = &block_handler;
block_handler.SetupBlockUnsafe (static_InputHandler, value);
try {
nw_framer_set_cleanup_handler (GetCheckedHandle (), (void*) block_ptr_handler);
} finally {
block_handler.CleanupBlock ();
}
}
}
}
[DllImport (Constants.NetworkLibrary)]
static extern void nw_framer_schedule_wakeup (OS_nw_framer framer, ulong milliseconds);
public void ScheduleWakeup (ulong milliseconds) => nw_framer_schedule_wakeup (GetCheckedHandle (), milliseconds);
*/
[DllImport (Constants.NetworkLibrary)]
static extern OS_nw_protocol_metadata nw_framer_message_create (OS_nw_framer framer);
public NWFramerMessage CreateMessage ()
=> new NWFramerMessage (nw_framer_message_create (GetCheckedHandle ()), owns: true);
/*
[DllImport (Constants.NetworkLibrary)]
static extern bool nw_framer_prepend_application_protocol (OS_nw_framer framer, OS_nw_protocol_options protocol_options);
public bool PrependApplicationProtocol (NWProtocolOptions options)
{
if (options == null)
throw new ArgumentNullException (nameof (options));
return nw_framer_prepend_application_protocol (GetCheckedHandle (), options.Handle);
}
[DllImport (Constants.NetworkLibrary)]
static extern void nw_framer_pass_through_output (OS_nw_framer framer);
public void PassThroughOutput () => nw_framer_pass_through_output (GetCheckedHandle ());
[DllImport (Constants.NetworkLibrary)]
static extern void nw_framer_pass_through_input (OS_nw_framer framer);
public void PassThroughInput () => nw_framer_pass_through_input (GetCheckedHandle ());
[DllImport (Constants.NetworkLibrary)]
static extern void nw_framer_mark_ready (OS_nw_framer framer);
public void MarkReady () => nw_framer_mark_ready (GetCheckedHandle ());
[DllImport (Constants.NetworkLibrary)]
static extern void nw_framer_mark_failed_with_error (OS_nw_framer framer, int error_code);
public void MarkFailedWithError (int errorCode) => nw_framer_mark_failed_with_error (GetCheckedHandle (), errorCode);
[DllImport (Constants.NetworkLibrary)]
static extern bool nw_framer_deliver_input_no_copy (OS_nw_framer framer, nuint input_length, OS_nw_protocol_metadata message, bool is_complete);
public bool DeliverInput (nuint length, NWProtocolMetadata message, bool isComplete)
{
if (message == null)
throw new ArgumentNullException (nameof (message));
return nw_framer_deliver_input_no_copy (GetCheckedHandle (), length, message.Handle, isComplete);
}
[DllImport (Constants.NetworkLibrary)]
static extern OS_nw_protocol_options nw_framer_create_options (OS_nw_protocol_definition framer_definition);
public static NWProtocolOptions CreateOptions (NWProtocolDefinition protocolDefinition)
{
if (protocolDefinition == null)
throw new ArgumentNullException (nameof (protocolDefinition));
return new NWProtocolOptions (nw_framer_create_options (protocolDefinition.Handle), owns: true);
}
[DllImport (Constants.NetworkLibrary)]
static extern OS_nw_endpoint nw_framer_copy_remote_endpoint (OS_nw_framer framer);
public NWEndpoint Endpoint => new NWEndpoint (nw_framer_copy_remote_endpoint (GetCheckedHandle ()), owns: true);
[DllImport (Constants.NetworkLibrary)]
static extern OS_nw_parameters nw_framer_copy_parameters (OS_nw_framer framer);
public NWParameters Parameters => new NWParameters (nw_framer_copy_parameters (GetCheckedHandle ()), owns: true);
[DllImport (Constants.NetworkLibrary)]
static extern OS_nw_endpoint nw_framer_copy_local_endpoint (OS_nw_framer framer);
public NWEndpoint LocalEndpoint => new NWEndpoint (nw_framer_copy_local_endpoint (GetCheckedHandle ()), owns: true);
[DllImport (Constants.NetworkLibrary)]
unsafe static extern void nw_framer_async (OS_nw_framer framer, void *async_block);
delegate void nw_framer_async_t (IntPtr block);
static nw_framer_async_t static_ScheduleHandler = TrampolineScheduleHandler;
[MonoPInvokeCallback (typeof (nw_framer_async_t))]
static void TrampolineScheduleHandler (IntPtr block)
{
var del = BlockLiteral.GetTarget<Action> (block);
if (del != null) {
del ();
}
}
[BindingImpl (BindingImplOptions.Optimizable)]
public void ScheduleAsync (Action handler)
{
unsafe {
if (handler == null) {
nw_framer_async (GetCheckedHandle (), null);
return;
}
BlockLiteral block_handler = new BlockLiteral ();
BlockLiteral *block_ptr_handler = &block_handler;
block_handler.SetupBlockUnsafe (static_ScheduleHandler, handler);
try {
nw_framer_async (GetCheckedHandle (), (void*) block_ptr_handler);
} finally {
block_handler.CleanupBlock ();
}
}
}
[DllImport (Constants.NetworkLibrary)]
static extern unsafe bool nw_framer_parse_output (OS_nw_framer framer, nuint minimum_incomplete_length, nuint maximum_length, byte *temp_buffer, ref BlockLiteral parse);
delegate void nw_framer_parse_output_t (IntPtr block, IntPtr buffer, nuint buffer_length, bool is_complete);
static nw_framer_parse_output_t static_ParseOutputHandler = TrampolineParseOutputHandler;
[MonoPInvokeCallback (typeof (nw_framer_parse_output_t))]
static void TrampolineParseOutputHandler (IntPtr block, IntPtr buffer, nuint buffer_length, bool is_complete)
{
var del = BlockLiteral.GetTarget<Action<Memory<byte>, bool>> (block);
if (del != null) {
var bBuffer = new byte[buffer_length];
Marshal.Copy (buffer, bBuffer, 0, (int)buffer_length);
var mValue = new Memory<byte>(bBuffer);
del (mValue, is_complete);
}
}
[BindingImpl (BindingImplOptions.Optimizable)]
public bool ParseOutput (nuint minimumIncompleteLength, nuint maximumLength, Memory<byte> tempBuffer, Action<Memory<byte>, bool> handler)
{
if (handler == null)
throw new ArgumentNullException (nameof (handler));
unsafe {
BlockLiteral block_handler = new BlockLiteral ();
block_handler.SetupBlockUnsafe (static_ParseOutputHandler, handler);
try {
using (var mh = tempBuffer.Pin ())
return nw_framer_parse_output (GetCheckedHandle (), minimumIncompleteLength, maximumLength, (byte*)mh.Pointer, ref block_handler);
} finally {
block_handler.CleanupBlock ();
}
}
}
[DllImport (Constants.NetworkLibrary)]
static extern unsafe bool nw_framer_parse_input (OS_nw_framer framer, nuint minimum_incomplete_length, nuint maximum_length, byte *temp_buffer, ref BlockLiteral parse);
delegate void nw_framer_parse_input_t (IntPtr block, IntPtr buffer, nuint buffer_length, bool is_complete);
static nw_framer_parse_input_t static_ParseInputHandler = TrampolineParseInputHandler;
[MonoPInvokeCallback (typeof (nw_framer_parse_input_t))]
static void TrampolineParseInputHandler (IntPtr block, IntPtr buffer, nuint buffer_length, bool is_complete)
{
var del = BlockLiteral.GetTarget<Action<Memory<byte>, bool>> (block);
if (del != null) {
var bBuffer = new byte[buffer_length];
Marshal.Copy (buffer, bBuffer, 0, (int)buffer_length);
var mValue = new Memory<byte>(bBuffer);
del (mValue, is_complete);
}
}
[BindingImpl (BindingImplOptions.Optimizable)]
public bool ParseInput (nuint minimumIncompleteLength, nuint maximumLength, Memory<byte> tempBuffer, Action<Memory<byte>, bool> handler)
{
if (handler == null)
throw new ArgumentNullException (nameof (handler));
unsafe {
BlockLiteral block_handler = new BlockLiteral ();
block_handler.SetupBlockUnsafe (static_ParseInputHandler, handler);
try {
using (var mh = tempBuffer.Pin ())
return nw_framer_parse_input (GetCheckedHandle (), minimumIncompleteLength, maximumLength, (byte*)mh.Pointer, ref block_handler);
} finally {
block_handler.CleanupBlock ();
}
}
}
[DllImport (Constants.NetworkLibrary)]
static extern unsafe void nw_framer_message_set_value (OS_nw_protocol_metadata message, string key, byte *value, void *dispose_value);
public void SetKey (string key, ReadOnlySpan<byte> value)
{
// the method takes a callback to cleanup the data, but we do not need that since we are managed
if (key == null)
throw new ArgumentNullException (nameof (key));
unsafe {
fixed (byte* mh = value)
nw_framer_message_set_value (GetCheckedHandle (), key, mh, null);
}
}
[DllImport (Constants.NetworkLibrary)]
static extern void nw_framer_message_set_object_value (OS_nw_protocol_metadata message, string key, IntPtr value);
public void SetObject (string key, NSObject value)
=> nw_framer_message_set_object_value (GetCheckedHandle (), key, value.GetHandle ());
[DllImport (Constants.NetworkLibrary)]
static extern IntPtr nw_framer_message_copy_object_value (OS_nw_protocol_metadata message, string key);
public NSObject GetValue (string key)
=> Runtime.GetNSObject (nw_framer_message_copy_object_value (GetCheckedHandle (), key));
[DllImport (Constants.NetworkLibrary)]
unsafe static extern void nw_framer_deliver_input (OS_nw_framer framer, byte *input_buffer, nuint input_length, OS_nw_protocol_metadata message, bool is_complete);
public void DeliverInput (ReadOnlySpan<byte> buffer, NWProtocolMetadata message, bool isComplete)
{
if (message == null)
throw new ArgumentNullException (nameof (message));
unsafe {
fixed (byte *mh = buffer)
nw_framer_deliver_input (GetCheckedHandle (),mh, (nuint)buffer.Length, message.Handle, isComplete);
}
}
*/
}
}

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

@ -0,0 +1,140 @@
//
// NWFramer.cs: Bindings the Network nw_framer_t API.
//
// Authors:
// Manuel de la Pena (mandel@microsoft.com)
//
// Copyright 2019 Microsoft
//
using System;
using System.Runtime.InteropServices;
using System.Runtime.CompilerServices;
using ObjCRuntime;
using Foundation;
using CoreFoundation;
using OS_nw_framer=System.IntPtr;
using OS_nw_protocol_metadata=System.IntPtr;
using OS_dispatch_data=System.IntPtr;
using OS_nw_protocol_definition=System.IntPtr;
using OS_nw_protocol_options=System.IntPtr;
using OS_nw_endpoint=System.IntPtr;
using OS_nw_parameters=System.IntPtr;
namespace Network {
[TV (13,0), Mac (10,15), iOS (13,0), Watch (6,0)]
public class NWFramerMessage : NWProtocolMetadata {
internal NWFramerMessage (IntPtr handle, bool owns) : base (handle, owns) {}
[DllImport (Constants.NetworkLibrary)]
static extern OS_nw_protocol_metadata nw_framer_protocol_create_message (OS_nw_protocol_definition definition);
// nw_framer_protocol can be condisered to be a nw_framer which is a protocol and is mapped to NWFramer, for a
// detailed explanation of the reasoning behind the naming please read the following discussion:
// https://github.com/xamarin/xamarin-macios/pull/7256#discussion_r337066971
public static NWFramerMessage Create (NWProtocolDefinition protocolDefinition)
{
if (protocolDefinition == null)
throw new ArgumentNullException (nameof (protocolDefinition));
return new NWFramerMessage (nw_framer_protocol_create_message (protocolDefinition.Handle), owns: true);
}
[DllImport (Constants.NetworkLibrary)]
static extern void nw_framer_message_set_value (OS_nw_protocol_metadata message, string key, IntPtr value, ref BlockLiteral dispose_value);
delegate void nw_framer_message_set_value_t (IntPtr block, IntPtr data);
static nw_framer_message_set_value_t static_SetDataHandler = TrampolineSetDataHandler;
[MonoPInvokeCallback (typeof (nw_framer_message_set_value_t))]
static void TrampolineSetDataHandler (IntPtr block, IntPtr data)
{
// get and call, this is internal and we are trying to do all the magic in the call
var del = BlockLiteral.GetTarget<Action<IntPtr>> (block);
if (del != null) {
del (data);
}
}
[BindingImpl (BindingImplOptions.Optimizable)]
public void SetData (string key, byte[] value)
{
// the method takes a callback to cleanup the data, but we do not need that since we are managed
if (key == null)
throw new ArgumentNullException (nameof (key));
// pin the handle so that is not collected, let our callback release it
var pinned = GCHandle.Alloc (value, GCHandleType.Pinned);
Action<IntPtr> callback = (_) => {
pinned.Free ();
};
BlockLiteral block_handler = new BlockLiteral ();
block_handler.SetupBlockUnsafe (static_SetDataHandler, callback);
try {
nw_framer_message_set_value (GetCheckedHandle (), key, pinned.AddrOfPinnedObject (), ref block_handler);
} finally {
block_handler.CleanupBlock ();
}
}
[DllImport (Constants.NetworkLibrary)]
static extern bool nw_framer_message_access_value (OS_nw_protocol_metadata message, string key, ref BlockLiteral access_value);
delegate bool nw_framer_message_access_value_t (IntPtr block, IntPtr data);
static nw_framer_message_access_value_t static_AccessValueHandler = TrampolineAccessValueHandler;
[MonoPInvokeCallback (typeof (nw_framer_message_access_value_t))]
static bool TrampolineAccessValueHandler (IntPtr block, IntPtr data)
{
// get and call, this is internal and we are trying to do all the magic in the call
var del = BlockLiteral.GetTarget<Func<IntPtr, bool>> (block);
if (del != null) {
return del (data);
}
return false;
}
[BindingImpl (BindingImplOptions.Optimizable)]
public bool GetData (string key, int dataLength, out ReadOnlySpan<byte> outData) {
IntPtr outPointer = IntPtr.Zero;
// create a function that will get the data, and the data length passed and will set the out param returning the value
Func<IntPtr, bool> callback = (inData) => {
if (inData != IntPtr.Zero) {
outPointer = inData;
return true;
} else {
return false;
}
};
BlockLiteral block_handler = new BlockLiteral ();
block_handler.SetupBlockUnsafe (static_AccessValueHandler, callback);
try {
// the callback is inlined!!!
var found = nw_framer_message_access_value (GetCheckedHandle (), key, ref block_handler);
if (found) {
unsafe {
outData = new ReadOnlySpan<byte>((void*) outPointer, dataLength);
}
} else {
outData = ReadOnlySpan<byte>.Empty;
}
return found;
} finally {
block_handler.CleanupBlock ();
}
}
[DllImport (Constants.NetworkLibrary)]
static extern void nw_framer_message_set_object_value (OS_nw_protocol_metadata message, string key, IntPtr value);
public void SetObject (string key, NSObject value)
=> nw_framer_message_set_object_value (GetCheckedHandle (), key, value.GetHandle ());
[DllImport (Constants.NetworkLibrary)]
static extern IntPtr nw_framer_message_copy_object_value (OS_nw_protocol_metadata message, string key);
public T GetObject<T> (string key) where T : NSObject
=> Runtime.GetNSObject<T> (nw_framer_message_copy_object_value (GetCheckedHandle (), key), owns: true);
}
}

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

@ -0,0 +1,42 @@
//
// NWIPMetadata.cs: Bindings the Netowrk nw_protocol_metadata_t API that is an IP.
//
// Authors:
// Manuel de la Pena <mandel@microsoft.com>
//
// Copyrigh 2019 Microsoft
//
using System;
using ObjCRuntime;
using Foundation;
using CoreFoundation;
namespace Network {
[TV (12,0), Mac (10,14), iOS (12,0), Watch (6,0)]
public class NWIPMetadata : NWProtocolMetadata {
internal NWIPMetadata (IntPtr handle, bool owns) : base (handle, owns) {}
public NWIPMetadata () : this (nw_ip_create_metadata (), owns: true) {}
public NWIPEcnFlag EcnFlag {
get => nw_ip_metadata_get_ecn_flag (GetCheckedHandle ());
set => nw_ip_metadata_set_ecn_flag (GetCheckedHandle (), value);
}
// A single tick represents one hundred nanoseconds, API returns: the time at which a packet was received, in nanoseconds
// so we get nanoseconds, divide by 100 and use from ticks
public TimeSpan ReceiveTime {
get {
var time = nw_ip_metadata_get_receive_time (GetCheckedHandle ());
return TimeSpan.FromTicks ((long) time / 100);
}
}
public NWServiceClass ServiceClass {
get => nw_ip_metadata_get_service_class (GetCheckedHandle ());
set => nw_ip_metadata_set_service_class (GetCheckedHandle (), value);
}
}
}

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

@ -26,6 +26,8 @@ namespace Network {
[TV (12,0), Mac (10,14), iOS (12,0)] [TV (12,0), Mac (10,14), iOS (12,0)]
[Watch (6,0)] [Watch (6,0)]
public class NWListener : NativeObject { public class NWListener : NativeObject {
bool connectionHandlerWasSet = false;
object connectionHandlerLock = new object ();
public NWListener (IntPtr handle, bool owns) : base (handle, owns) public NWListener (IntPtr handle, bool owns) : base (handle, owns)
{ {
} }
@ -99,7 +101,14 @@ namespace Network {
[DllImport (Constants.NetworkLibrary)] [DllImport (Constants.NetworkLibrary)]
extern static void nw_listener_start (IntPtr handle); extern static void nw_listener_start (IntPtr handle);
public void Start () => nw_listener_start (GetCheckedHandle ()); public void Start () {
lock (connectionHandlerLock) {
// we will get a sigabort if the handler is not set, lets be nicer.
if (!connectionHandlerWasSet)
throw new InvalidOperationException ("A connection handler should be set before starting a NWListener.");
nw_listener_start (GetCheckedHandle ());
}
}
[DllImport (Constants.NetworkLibrary)] [DllImport (Constants.NetworkLibrary)]
extern static void nw_listener_cancel (IntPtr handle); extern static void nw_listener_cancel (IntPtr handle);
@ -163,20 +172,23 @@ namespace Network {
[BindingImpl (BindingImplOptions.Optimizable)] [BindingImpl (BindingImplOptions.Optimizable)]
public void SetNewConnectionHandler (Action<NWConnection> callback) public void SetNewConnectionHandler (Action<NWConnection> callback)
{ {
unsafe { lock (connectionHandlerLock) {
if (callback == null){ unsafe {
nw_listener_set_new_connection_handler (GetCheckedHandle (), null); if (callback == null) {
return; nw_listener_set_new_connection_handler (GetCheckedHandle (), null);
} return;
}
BlockLiteral block_handler = new BlockLiteral (); BlockLiteral block_handler = new BlockLiteral ();
BlockLiteral *block_ptr_handler = &block_handler; BlockLiteral *block_ptr_handler = &block_handler;
block_handler.SetupBlockUnsafe (static_NewConnection, callback); block_handler.SetupBlockUnsafe (static_NewConnection, callback);
try { try {
nw_listener_set_new_connection_handler (GetCheckedHandle (), (void*) block_ptr_handler); nw_listener_set_new_connection_handler (GetCheckedHandle (), (void*) block_ptr_handler);
} finally { connectionHandlerWasSet = true;
block_handler.CleanupBlock (); } finally {
block_handler.CleanupBlock ();
}
} }
} }
} }
@ -228,5 +240,19 @@ namespace Network {
{ {
nw_listener_set_advertise_descriptor (GetCheckedHandle (), descriptor.GetHandle ()); nw_listener_set_advertise_descriptor (GetCheckedHandle (), descriptor.GetHandle ());
} }
[TV (13,0), Mac (10,15), iOS (13,0), Watch (6,0)]
[DllImport (Constants.NetworkLibrary)]
static extern uint nw_listener_get_new_connection_limit (IntPtr listener);
[TV (13,0), Mac (10,15), iOS (13,0), Watch (6,0)]
[DllImport (Constants.NetworkLibrary)]
static extern void nw_listener_set_new_connection_limit (IntPtr listener, uint new_connection_limit);
[TV (13,0), Mac (10,15), iOS (13,0), Watch (6,0)]
public uint ConnectionLimit {
get => nw_listener_get_new_connection_limit (GetCheckedHandle ());
set => nw_listener_set_new_connection_limit (GetCheckedHandle (), value);
}
} }
} }

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

@ -42,9 +42,25 @@ namespace Network {
{ {
var del = BlockLiteral.GetTarget<Action<NWProtocolOptions>> (block); var del = BlockLiteral.GetTarget<Action<NWProtocolOptions>> (block);
if (del != null) { if (del != null) {
var x = new NWProtocolOptions (iface, owns: false); using (var tempOptions = new NWProtocolOptions (iface, owns: false))
del (x); using (var definition = tempOptions.ProtocolDefinition) {
x.Dispose (); NWProtocolOptions castedOptions = null;
if (definition.Equals (NWProtocolDefinition.TcpDefinition)) {
castedOptions = new NWProtocolTcpOptions (iface, owns: false);
} else if (definition.Equals (NWProtocolDefinition.UdpDefinition)) {
castedOptions = new NWProtocolUdpOptions (iface, owns: false);
} else if (definition.Equals (NWProtocolDefinition.TlsDefinition)) {
castedOptions = new NWProtocolTlsOptions (iface, owns: false);
} else if (definition.Equals (NWProtocolDefinition.IPDefinition)) {
castedOptions = new NWProtocolIPOptions (iface, owns: false);
} else if (definition.Equals (NWProtocolDefinition.WebSocketDefinition)) {
castedOptions = new NWWebSocketOptions (iface, owns: false);
}
del (castedOptions ?? tempOptions);
castedOptions?.Dispose ();
}
} }
} }
@ -435,6 +451,21 @@ namespace Network {
get => nw_parameters_get_include_peer_to_peer (GetCheckedHandle ()); get => nw_parameters_get_include_peer_to_peer (GetCheckedHandle ());
set => nw_parameters_set_include_peer_to_peer (GetCheckedHandle (), value); set => nw_parameters_set_include_peer_to_peer (GetCheckedHandle (), value);
} }
[TV (13,0), Mac (10,15), iOS (13,0), Watch (6,0)]
[DllImport (Constants.NetworkLibrary)]
[return: MarshalAs (UnmanagedType.I1)]
static extern bool nw_parameters_get_prohibit_constrained (IntPtr parameters);
[TV (13,0), Mac (10,15), iOS (13,0), Watch (6,0)]
[DllImport (Constants.NetworkLibrary)]
static extern void nw_parameters_set_prohibit_constrained (IntPtr parameters, bool prohibit_constrained);
[TV (13,0), Mac (10,15), iOS (13,0), Watch (6,0)]
public bool ProhibitConstrained {
get => nw_parameters_get_prohibit_constrained (GetCheckedHandle ());
set => nw_parameters_set_prohibit_constrained (GetCheckedHandle (), value);
}
} }
[TV (12,0), Mac (10,14), iOS (12,0)] [TV (12,0), Mac (10,14), iOS (12,0)]

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

@ -130,5 +130,46 @@ namespace Network {
block_handler.CleanupBlock (); block_handler.CleanupBlock ();
} }
} }
[TV (13,0), Mac (10,15), iOS (13,0), Watch (6,0)]
[DllImport (Constants.NetworkLibrary)]
static extern bool nw_path_is_constrained (IntPtr path);
[TV (13,0), Mac (10,15), iOS (13,0), Watch (6,0)]
public bool IsConstrained => nw_path_is_constrained (GetCheckedHandle ());
[TV (13,0), Mac (10,15), iOS (13,0), Watch (6,0)]
[DllImport (Constants.NetworkLibrary)]
static extern void nw_path_enumerate_gateways (IntPtr path, ref BlockLiteral enumerate_block);
delegate void nw_path_enumerate_gateways_t (IntPtr block, IntPtr endpoint);
static nw_path_enumerate_gateways_t static_EnumerateGatewaysHandler = TrampolineGatewaysHandler;
[MonoPInvokeCallback (typeof (nw_path_enumerate_gateways_t))]
static void TrampolineGatewaysHandler (IntPtr block, IntPtr endpoint)
{
var del = BlockLiteral.GetTarget<Action<NWEndpoint>> (block);
if (del != null) {
var nwEndpoint = new NWEndpoint (endpoint, owns: false);
del (nwEndpoint);
}
}
[TV (13,0), Mac (10,15), iOS (13,0), Watch (6,0)]
[BindingImpl (BindingImplOptions.Optimizable)]
public void EnumerateGateways (Action<NWEndpoint> callback)
{
if (callback == null)
throw new ArgumentNullException (nameof (callback));
BlockLiteral block_handler = new BlockLiteral ();
block_handler.SetupBlockUnsafe (static_Enumerator, callback);
try {
nw_path_enumerate_gateways (GetCheckedHandle (), ref block_handler);
} finally {
block_handler.CleanupBlock ();
}
}
} }
} }

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

@ -17,12 +17,6 @@ using OS_nw_protocol_definition=System.IntPtr;
namespace Network { namespace Network {
public enum NWIPVersion {
Any = 0,
Version4 = 1,
Version6 = 2,
}
[TV (12,0), Mac (10,14), iOS (12,0)] [TV (12,0), Mac (10,14), iOS (12,0)]
[Watch (6,0)] [Watch (6,0)]
public class NWProtocolDefinition : NativeObject { public class NWProtocolDefinition : NativeObject {
@ -44,22 +38,85 @@ namespace Network {
[DllImport (Constants.NetworkLibrary)] [DllImport (Constants.NetworkLibrary)]
static extern OS_nw_protocol_definition nw_protocol_copy_ip_definition (); static extern OS_nw_protocol_definition nw_protocol_copy_ip_definition ();
#if !XAMCORE_4_0
[Obsolete ("Use 'CreateIPDefinition' method instead.")]
public static NWProtocolDefinition IPDefinition => new NWProtocolDefinition (nw_protocol_copy_ip_definition (), owns: true); public static NWProtocolDefinition IPDefinition => new NWProtocolDefinition (nw_protocol_copy_ip_definition (), owns: true);
#endif
public static NWProtocolDefinition CreateIPDefinition () => new NWProtocolDefinition (nw_protocol_copy_ip_definition (), owns: true);
[DllImport (Constants.NetworkLibrary)] [DllImport (Constants.NetworkLibrary)]
static extern OS_nw_protocol_definition nw_protocol_copy_tcp_definition (); static extern OS_nw_protocol_definition nw_protocol_copy_tcp_definition ();
#if !XAMCORE_4_0
[Obsolete ("Use 'CreateTcpDefinition' method instead.")]
public static NWProtocolDefinition TcpDefinition => new NWProtocolDefinition (nw_protocol_copy_tcp_definition (), owns: true); public static NWProtocolDefinition TcpDefinition => new NWProtocolDefinition (nw_protocol_copy_tcp_definition (), owns: true);
#endif
public static NWProtocolDefinition CreateTcpDefinition () => new NWProtocolDefinition (nw_protocol_copy_tcp_definition (), owns: true);
[DllImport (Constants.NetworkLibrary)] [DllImport (Constants.NetworkLibrary)]
static extern OS_nw_protocol_definition nw_protocol_copy_udp_definition (); static extern OS_nw_protocol_definition nw_protocol_copy_udp_definition ();
#if !XAMCORE_4_0
[Obsolete ("Use 'CreateUdpDefinition' method instead.")]
public static NWProtocolDefinition UdpDefinition => new NWProtocolDefinition (nw_protocol_copy_udp_definition (), owns: true); public static NWProtocolDefinition UdpDefinition => new NWProtocolDefinition (nw_protocol_copy_udp_definition (), owns: true);
#endif
public static NWProtocolDefinition CreateUdpDefinition () => new NWProtocolDefinition (nw_protocol_copy_udp_definition (), owns: true);
[DllImport (Constants.NetworkLibrary)] [DllImport (Constants.NetworkLibrary)]
static extern OS_nw_protocol_definition nw_protocol_copy_tls_definition (); static extern OS_nw_protocol_definition nw_protocol_copy_tls_definition ();
#if !XAMCORE_4_0
[Obsolete ("Use 'CreateTlsDefinition' method instead.")]
public static NWProtocolDefinition TlsDefinition => new NWProtocolDefinition (nw_protocol_copy_tls_definition (), owns: true); public static NWProtocolDefinition TlsDefinition => new NWProtocolDefinition (nw_protocol_copy_tls_definition (), owns: true);
#endif
public static NWProtocolDefinition CreateTlsDefinition () => new NWProtocolDefinition (nw_protocol_copy_tls_definition (), owns: true);
[TV (13,0), Mac (10,15), iOS (13,0), Watch (6,0)]
[DllImport (Constants.NetworkLibrary)]
static extern OS_nw_protocol_definition nw_protocol_copy_ws_definition ();
#if !XAMCORE_4_0
[Obsolete ("Use 'CreateWebSocketDefinition' method instead.")]
[TV (13,0), Mac (10,15), iOS (13,0), Watch (6,0)]
public static NWProtocolDefinition WebSocketDefinition => new NWProtocolDefinition (nw_protocol_copy_ws_definition (), owns: true);
#endif
[TV (13,0), Mac (10,15), iOS (13,0), Watch (6,0)]
public static NWProtocolDefinition CreateWebSocketDefinition () => new NWProtocolDefinition (nw_protocol_copy_ws_definition (), owns: true);
[Watch (6,0), TV (13,0), Mac (10,15), iOS (13,0)]
[DllImport (Constants.NetworkLibrary)]
static extern unsafe OS_nw_protocol_definition nw_framer_create_definition (string identifier, NWFramerCreateFlags flags, ref BlockLiteral start_handler);
delegate NWFramerStartResult nw_framer_create_definition_t (IntPtr block, IntPtr framer);
static nw_framer_create_definition_t static_CreateFramerHandler = TrampolineCreateFramerHandler;
[MonoPInvokeCallback (typeof (nw_framer_create_definition_t))]
static NWFramerStartResult TrampolineCreateFramerHandler (IntPtr block, IntPtr framer)
{
// get and call, this is internal and we are trying to do all the magic in the call
var del = BlockLiteral.GetTarget<Func<NWFramer,NWFramerStartResult>> (block);
if (del != null) {
var nwFramer = new NWFramer (framer, owns: true);
return del (nwFramer);
}
return NWFramerStartResult.Unknown;
}
[Watch (6,0), TV (13,0), Mac (10,15), iOS (13,0)]
[BindingImpl (BindingImplOptions.Optimizable)]
public static NWProtocolDefinition CreateFramerDefinition (string identifier, NWFramerCreateFlags flags, Func<NWFramer, NWFramerStartResult> startCallback)
{
BlockLiteral block_handler = new BlockLiteral ();
block_handler.SetupBlockUnsafe (static_CreateFramerHandler, startCallback);
try {
return new NWProtocolDefinition (nw_framer_create_definition (identifier, flags, ref block_handler), owns: true);
} finally {
block_handler.CleanupBlock ();
}
}
} }
} }

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

@ -0,0 +1,58 @@
//
// NWProtocolTls: Bindings the Netowrk nw_protocol_options API focus on TLS options.
//
// Authors:
// Manuel de la Pena <mandel@microsoft.com>
//
// Copyrigh 2019 Microsoft Inc
//
using System;
using System.Runtime.InteropServices;
using System.Runtime.CompilerServices;
using ObjCRuntime;
using Foundation;
using CoreFoundation;
using Security;
using OS_nw_protocol_definition=System.IntPtr;
using IntPtr=System.IntPtr;
namespace Network {
[Watch (6,0), TV (13,0), Mac (10,15), iOS (13,0)]
public enum NWIPLocalAddressPreference {
Default = 0,
Temporary = 1,
Stable = 2,
}
[Watch (6,0), TV (12,0), Mac (10,14), iOS (12,0)]
public enum NWIPVersion {
Any = 0,
Version4 = 1,
Version6 = 2,
}
[TV (13,0), Mac (10,15), iOS (13,0), Watch (6,0)]
public class NWProtocolIPOptions : NWProtocolOptions {
internal NWProtocolIPOptions (IntPtr handle, bool owns) : base (handle, owns) {}
public void SetVersion (NWIPVersion version)
=> nw_ip_options_set_version (GetCheckedHandle (), version);
public void SetHopLimit (nuint hopLimit)
=> nw_ip_options_set_hop_limit (GetCheckedHandle (), (byte) hopLimit);
public void SetUseMinimumMtu (bool useMinimumMtu)
=> nw_ip_options_set_use_minimum_mtu (GetCheckedHandle (), useMinimumMtu);
public void SetDisableFragmentation (bool disableFragmentation)
=> nw_ip_options_set_disable_fragmentation (GetCheckedHandle (), disableFragmentation);
public void SetCalculateReceiveTime (bool shouldCalculateReceiveTime)
=> nw_ip_options_set_calculate_receive_time (GetCheckedHandle (), shouldCalculateReceiveTime);
[TV (13,0), Mac (10,15), iOS (13,0)]
public void SetIPLocalAddressPreference (NWIPLocalAddressPreference localAddressPreference)
=> nw_ip_options_set_local_address_preference (GetCheckedHandle (), localAddressPreference);
}
}

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

@ -40,53 +40,60 @@ namespace Network {
public class NWProtocolMetadata : NativeObject { public class NWProtocolMetadata : NativeObject {
[DllImport (Constants.NetworkLibrary)] [DllImport (Constants.NetworkLibrary)]
static extern OS_nw_protocol_metadata nw_ip_create_metadata (); internal static extern OS_nw_protocol_metadata nw_ip_create_metadata ();
#if !XAMCORE_4_0
[Obsolete ("Use the 'NWIPMetadata' class and methods instead.")]
public static NWProtocolMetadata CreateIPMetadata () public static NWProtocolMetadata CreateIPMetadata ()
{ {
return new NWProtocolMetadata (nw_ip_create_metadata (), owns: true); return new NWProtocolMetadata (nw_ip_create_metadata (), owns: true);
} }
#endif
[DllImport (Constants.NetworkLibrary)] [DllImport (Constants.NetworkLibrary)]
static extern OS_nw_protocol_metadata nw_udp_create_metadata (); internal static extern OS_nw_protocol_metadata nw_udp_create_metadata ();
#if !XAMCORE_4_0
[Obsolete ("Use the 'NSUdpMetadata' class and methods instead.")]
public static NWProtocolMetadata CreateUdpMetadata () public static NWProtocolMetadata CreateUdpMetadata ()
{ {
return new NWProtocolMetadata (nw_udp_create_metadata (), owns: true); return new NWProtocolMetadata (nw_udp_create_metadata (), owns: true);
} }
#endif
public NWProtocolMetadata (IntPtr handle, bool owns) : base (handle, owns) {} public NWProtocolMetadata (IntPtr handle, bool owns) : base (handle, owns) {}
[DllImport (Constants.NetworkLibrary)] [DllImport (Constants.NetworkLibrary)]
static extern OS_nw_protocol_definition nw_protocol_metadata_copy_definition (OS_nw_protocol_metadata metadata); internal static extern OS_nw_protocol_definition nw_protocol_metadata_copy_definition (OS_nw_protocol_metadata metadata);
public NWProtocolDefinition ProtocolDefinition => new NWProtocolDefinition (nw_protocol_metadata_copy_definition (GetCheckedHandle ()), owns: true); public NWProtocolDefinition ProtocolDefinition => new NWProtocolDefinition (nw_protocol_metadata_copy_definition (GetCheckedHandle ()), owns: true);
[DllImport (Constants.NetworkLibrary)] [DllImport (Constants.NetworkLibrary)]
[return: MarshalAs (UnmanagedType.I1)] [return: MarshalAs (UnmanagedType.I1)]
static extern bool nw_protocol_metadata_is_ip (OS_nw_protocol_metadata metadata); internal static extern bool nw_protocol_metadata_is_ip (OS_nw_protocol_metadata metadata);
public bool IsIP => nw_protocol_metadata_is_ip (GetCheckedHandle ()); public bool IsIP => nw_protocol_metadata_is_ip (GetCheckedHandle ());
[DllImport (Constants.NetworkLibrary)] [DllImport (Constants.NetworkLibrary)]
[return: MarshalAs (UnmanagedType.I1)] [return: MarshalAs (UnmanagedType.I1)]
static extern bool nw_protocol_metadata_is_udp (OS_nw_protocol_metadata metadata); internal static extern bool nw_protocol_metadata_is_udp (OS_nw_protocol_metadata metadata);
public bool IsUdp => nw_protocol_metadata_is_udp (GetCheckedHandle ()); public bool IsUdp => nw_protocol_metadata_is_udp (GetCheckedHandle ());
[DllImport (Constants.NetworkLibrary)] [DllImport (Constants.NetworkLibrary)]
[return: MarshalAs (UnmanagedType.I1)] [return: MarshalAs (UnmanagedType.I1)]
static extern bool nw_protocol_metadata_is_tls (OS_nw_protocol_metadata metadata); internal static extern bool nw_protocol_metadata_is_tls (OS_nw_protocol_metadata metadata);
public bool IsTls => nw_protocol_metadata_is_tls (GetCheckedHandle ()); public bool IsTls => nw_protocol_metadata_is_tls (GetCheckedHandle ());
[DllImport (Constants.NetworkLibrary)] [DllImport (Constants.NetworkLibrary)]
[return: MarshalAs (UnmanagedType.I1)] [return: MarshalAs (UnmanagedType.I1)]
static extern bool nw_protocol_metadata_is_tcp (OS_nw_protocol_metadata metadata); internal static extern bool nw_protocol_metadata_is_tcp (OS_nw_protocol_metadata metadata);
public bool IsTcp => nw_protocol_metadata_is_tcp (GetCheckedHandle ()); public bool IsTcp => nw_protocol_metadata_is_tcp (GetCheckedHandle ());
[DllImport (Constants.NetworkLibrary)] [DllImport (Constants.NetworkLibrary)]
static extern IntPtr nw_tls_copy_sec_protocol_metadata (IntPtr handle); internal static extern IntPtr nw_tls_copy_sec_protocol_metadata (IntPtr handle);
void CheckIsIP () void CheckIsIP ()
{ {
@ -107,23 +114,26 @@ namespace Network {
} }
#if !XAMCORE_4_0 #if !XAMCORE_4_0
[Obsolete ("Use 'TlsSecProtocolMetadata' instead.")] [Obsolete ("Use the 'NWTlsMetadata' class and methods instead.")]
public SecProtocolMetadata SecProtocolMetadata => TlsSecProtocolMetadata; public SecProtocolMetadata SecProtocolMetadata => TlsSecProtocolMetadata;
#endif
[Obsolete ("Use the 'NWTlsMetadata' class and methods instead.")]
public SecProtocolMetadata TlsSecProtocolMetadata { public SecProtocolMetadata TlsSecProtocolMetadata {
get { get {
CheckIsTls (); CheckIsTls ();
return new SecProtocolMetadata (nw_tls_copy_sec_protocol_metadata (GetCheckedHandle ()), owns: true); return new SecProtocolMetadata (nw_tls_copy_sec_protocol_metadata (GetCheckedHandle ()), owns: true);
} }
} }
#endif
[DllImport (Constants.NetworkLibrary)] [DllImport (Constants.NetworkLibrary)]
static extern void nw_ip_metadata_set_ecn_flag (OS_nw_protocol_metadata metadata, NWIPEcnFlag ecn_flag); internal static extern void nw_ip_metadata_set_ecn_flag (OS_nw_protocol_metadata metadata, NWIPEcnFlag ecn_flag);
[DllImport (Constants.NetworkLibrary)] [DllImport (Constants.NetworkLibrary)]
static extern NWIPEcnFlag nw_ip_metadata_get_ecn_flag (OS_nw_protocol_metadata metadata); internal static extern NWIPEcnFlag nw_ip_metadata_get_ecn_flag (OS_nw_protocol_metadata metadata);
#if !XAMCORE_4_0
[Obsolete ("Use the 'NWIPMetadata' class and methods instead.")]
public NWIPEcnFlag IPMetadataEcnFlag { public NWIPEcnFlag IPMetadataEcnFlag {
get { get {
CheckIsIP (); CheckIsIP ();
@ -134,31 +144,35 @@ namespace Network {
nw_ip_metadata_set_ecn_flag (GetCheckedHandle (), value); nw_ip_metadata_set_ecn_flag (GetCheckedHandle (), value);
} }
} }
#endif
[DllImport (Constants.NetworkLibrary)] [DllImport (Constants.NetworkLibrary)]
static extern /* uint64_t */ ulong nw_ip_metadata_get_receive_time (OS_nw_protocol_metadata metadata); internal static extern /* uint64_t */ ulong nw_ip_metadata_get_receive_time (OS_nw_protocol_metadata metadata);
#if !XAMCORE_4_0
[Obsolete ("Use the 'NWIPMetadata' class and methods instead.")]
public ulong IPMetadataReceiveTime { public ulong IPMetadataReceiveTime {
get { get {
CheckIsIP (); CheckIsIP ();
return nw_ip_metadata_get_receive_time (GetCheckedHandle ()); return nw_ip_metadata_get_receive_time (GetCheckedHandle ());
} }
} }
#endif
[DllImport (Constants.NetworkLibrary)] [DllImport (Constants.NetworkLibrary)]
static extern void nw_ip_metadata_set_service_class (OS_nw_protocol_metadata metadata, NWServiceClass service_class); internal static extern void nw_ip_metadata_set_service_class (OS_nw_protocol_metadata metadata, NWServiceClass service_class);
[DllImport (Constants.NetworkLibrary)] [DllImport (Constants.NetworkLibrary)]
static extern NWServiceClass nw_ip_metadata_get_service_class (OS_nw_protocol_metadata metadata); internal static extern NWServiceClass nw_ip_metadata_get_service_class (OS_nw_protocol_metadata metadata);
#if !XAMCORE_4_0 #if !XAMCORE_4_0
[Obsolete ("Use 'IPServiceClass' instead.")] [Obsolete ("Use the 'NWIPMetadata' class and methods instead.")]
public NWServiceClass ServiceClass { public NWServiceClass ServiceClass {
get => IPServiceClass; get => IPServiceClass;
set => IPServiceClass = value; set => IPServiceClass = value;
} }
#endif
[Obsolete ("Use the 'NWIPMetadata' class and methods instead.")]
public NWServiceClass IPServiceClass { public NWServiceClass IPServiceClass {
get { get {
CheckIsIP (); CheckIsIP ();
@ -169,23 +183,44 @@ namespace Network {
nw_ip_metadata_set_service_class (GetCheckedHandle (), value); nw_ip_metadata_set_service_class (GetCheckedHandle (), value);
} }
} }
#endif
[DllImport (Constants.NetworkLibrary)] [DllImport (Constants.NetworkLibrary)]
extern static /* uint32_t */ uint nw_tcp_get_available_receive_buffer (IntPtr handle); internal extern static /* uint32_t */ uint nw_tcp_get_available_receive_buffer (IntPtr handle);
#if !XAMCORE_4_0
[Obsolete ("Use the 'NWTcpMetadata' class and methods instead.")]
public uint TcpGetAvailableReceiveBuffer () public uint TcpGetAvailableReceiveBuffer ()
{ {
CheckIsTcp (); CheckIsTcp ();
return nw_tcp_get_available_receive_buffer (GetCheckedHandle ()); return nw_tcp_get_available_receive_buffer (GetCheckedHandle ());
} }
#endif
[DllImport (Constants.NetworkLibrary)] [DllImport (Constants.NetworkLibrary)]
extern static /* uint32_t */ uint nw_tcp_get_available_send_buffer (IntPtr handle); internal extern static /* uint32_t */ uint nw_tcp_get_available_send_buffer (IntPtr handle);
#if !XAMCORE_4_0
[Obsolete ("Use the 'NWTcpMetadata' class and methods instead.")]
public uint TcpGetAvailableSendBuffer () public uint TcpGetAvailableSendBuffer ()
{ {
CheckIsTcp (); CheckIsTcp ();
return nw_tcp_get_available_send_buffer (GetCheckedHandle ()); return nw_tcp_get_available_send_buffer (GetCheckedHandle ());
} }
#endif
[TV (13,0), Mac (10,15), iOS (13,0), Watch (6,0)]
[DllImport (Constants.NetworkLibrary)]
internal static extern bool nw_protocol_metadata_is_framer_message (OS_nw_protocol_metadata metadata);
[TV (13,0), Mac (10,15), iOS (13,0), Watch (6,0)]
public bool IsFramerMessage => nw_protocol_metadata_is_framer_message (GetCheckedHandle ());
[TV (13,0), Mac (10,15), iOS (13,0), Watch (6,0)]
[DllImport (Constants.NetworkLibrary)]
internal static extern bool nw_protocol_metadata_is_ws (OS_nw_protocol_metadata metadata);
[TV (13,0), Mac (10,15), iOS (13,0), Watch (6,0)]
public bool IsWebSocket => nw_protocol_metadata_is_ws (GetCheckedHandle ());
} }
} }

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

@ -24,157 +24,196 @@ namespace Network {
public NWProtocolOptions (IntPtr handle, bool owns) : base (handle, owns) {} public NWProtocolOptions (IntPtr handle, bool owns) : base (handle, owns) {}
[DllImport (Constants.NetworkLibrary)] [DllImport (Constants.NetworkLibrary)]
static extern OS_nw_protocol_definition nw_protocol_options_copy_definition (IntPtr options); internal static extern OS_nw_protocol_definition nw_protocol_options_copy_definition (IntPtr options);
public NWProtocolDefinition ProtocolDefinition => new NWProtocolDefinition (nw_protocol_options_copy_definition (GetCheckedHandle ()), owns: true); public NWProtocolDefinition ProtocolDefinition => new NWProtocolDefinition (nw_protocol_options_copy_definition (GetCheckedHandle ()), owns: true);
[DllImport (Constants.NetworkLibrary)] [DllImport (Constants.NetworkLibrary)]
static extern IntPtr nw_tls_create_options (); internal static extern IntPtr nw_tls_create_options ();
[Obsolete ("Use the 'NWProtocolTlsOptions' class methods and constructors instead.")]
public static NWProtocolOptions CreateTls () public static NWProtocolOptions CreateTls ()
{ {
return new NWProtocolOptions (nw_tls_create_options (), owns: true); return new NWProtocolTlsOptions (nw_tls_create_options (), owns: true);
} }
[DllImport (Constants.NetworkLibrary)] [DllImport (Constants.NetworkLibrary)]
static extern IntPtr nw_tcp_create_options (); internal static extern IntPtr nw_tcp_create_options ();
[Obsolete ("Use the 'NWProtocolTcpOptions' class methods and constructors instead.")]
public static NWProtocolOptions CreateTcp () public static NWProtocolOptions CreateTcp ()
{ {
return new NWProtocolOptions (nw_tcp_create_options (), owns: true); return new NWProtocolTcpOptions (nw_tcp_create_options (), owns: true);
} }
[DllImport (Constants.NetworkLibrary)] [DllImport (Constants.NetworkLibrary)]
static extern IntPtr nw_udp_create_options (); internal static extern IntPtr nw_udp_create_options ();
[Obsolete ("Use the 'NWProtocolUdpOptions' class methods and constructors instead.")]
public static NWProtocolOptions CreateUdp () public static NWProtocolOptions CreateUdp ()
{ {
return new NWProtocolOptions (nw_udp_create_options (), owns: true); return new NWProtocolUdpOptions (nw_udp_create_options (), owns: true);
} }
// //
// IP Options // IP Options
// //
[DllImport (Constants.NetworkLibrary)] [DllImport (Constants.NetworkLibrary)]
static extern void nw_ip_options_set_version (IntPtr options, NWIPVersion version); internal static extern void nw_ip_options_set_version (IntPtr options, NWIPVersion version);
[Obsolete ("Use the 'NWProtocolIPOptions' class instead.")]
public void IPSetVersion (NWIPVersion version) public void IPSetVersion (NWIPVersion version)
{ {
nw_ip_options_set_version (GetCheckedHandle (), version); nw_ip_options_set_version (GetCheckedHandle (), version);
} }
[DllImport (Constants.NetworkLibrary)] [DllImport (Constants.NetworkLibrary)]
static extern void nw_ip_options_set_hop_limit (IntPtr options, byte hop_limit); internal static extern void nw_ip_options_set_hop_limit (IntPtr options, byte hop_limit);
[Obsolete ("Use the 'NWProtocolIPOptions' class instead.")]
public void IPSetHopLimit (byte hopLimit) public void IPSetHopLimit (byte hopLimit)
{ {
nw_ip_options_set_hop_limit (GetCheckedHandle (), hopLimit); nw_ip_options_set_hop_limit (GetCheckedHandle (), hopLimit);
} }
[DllImport (Constants.NetworkLibrary)] [DllImport (Constants.NetworkLibrary)]
static extern void nw_ip_options_set_use_minimum_mtu (IntPtr options, [MarshalAs (UnmanagedType.I1)] bool use_minimum_mtu); internal static extern void nw_ip_options_set_use_minimum_mtu (IntPtr options, [MarshalAs (UnmanagedType.I1)] bool use_minimum_mtu);
[Obsolete ("Use the 'NWProtocolIPOptions' class instead.")]
public void IPSetUseMinimumMtu (bool useMinimumMtu) public void IPSetUseMinimumMtu (bool useMinimumMtu)
{ {
nw_ip_options_set_use_minimum_mtu (GetCheckedHandle (), useMinimumMtu); nw_ip_options_set_use_minimum_mtu (GetCheckedHandle (), useMinimumMtu);
} }
[DllImport (Constants.NetworkLibrary)] [DllImport (Constants.NetworkLibrary)]
static extern void nw_ip_options_set_disable_fragmentation (IntPtr options, [MarshalAs (UnmanagedType.I1)] bool disable_fragmentation); internal static extern void nw_ip_options_set_disable_fragmentation (IntPtr options, [MarshalAs (UnmanagedType.I1)] bool disable_fragmentation);
[Obsolete ("Use the 'NWProtocolIPOptions' class instead.")]
public void IPSetDisableFragmentation (bool disableFragmentation) public void IPSetDisableFragmentation (bool disableFragmentation)
{ {
nw_ip_options_set_disable_fragmentation (GetCheckedHandle (), disableFragmentation); nw_ip_options_set_disable_fragmentation (GetCheckedHandle (), disableFragmentation);
} }
[DllImport (Constants.NetworkLibrary)] [DllImport (Constants.NetworkLibrary)]
static extern void nw_ip_options_set_calculate_receive_time (IntPtr options, bool calculateReceiveTime); internal static extern void nw_ip_options_set_calculate_receive_time (IntPtr options, bool calculateReceiveTime);
[Obsolete ("Use the 'NWProtocolIPOptions' class instead.")]
public void IPSetCalculateReceiveTime (bool calculateReceiveTime) public void IPSetCalculateReceiveTime (bool calculateReceiveTime)
{ {
nw_ip_options_set_calculate_receive_time (GetCheckedHandle (), calculateReceiveTime); nw_ip_options_set_calculate_receive_time (GetCheckedHandle (), calculateReceiveTime);
} }
[Watch (6,0), TV (13,0), Mac (10,15), iOS (13,0)]
[DllImport (Constants.NetworkLibrary)]
internal static extern void nw_ip_options_set_local_address_preference (IntPtr options, NWIPLocalAddressPreference preference);
[Obsolete ("Use the 'NWProtocolIPOptions' class instead.")]
[Watch (6,0), TV (13,0), Mac (10,15), iOS (13,0)]
public NWIPLocalAddressPreference IPLocalAddressPreference {
set => nw_ip_options_set_local_address_preference (GetCheckedHandle (), value);
}
// //
// TCP Options // TCP Options
// //
[DllImport (Constants.NetworkLibrary)]
extern static void nw_tcp_options_set_no_delay (IntPtr handle, [MarshalAs (UnmanagedType.U1)] bool noDelay);
[DllImport (Constants.NetworkLibrary)]
internal extern static void nw_tcp_options_set_no_delay (IntPtr handle, [MarshalAs (UnmanagedType.U1)] bool noDelay);
[Obsolete ("Use the 'NWProtocolTcpOptions' class instead.")]
public void TcpSetNoDelay (bool noDelay) => nw_tcp_options_set_no_delay (GetCheckedHandle (), noDelay); public void TcpSetNoDelay (bool noDelay) => nw_tcp_options_set_no_delay (GetCheckedHandle (), noDelay);
[DllImport (Constants.NetworkLibrary)] [DllImport (Constants.NetworkLibrary)]
extern static void nw_tcp_options_set_no_push (IntPtr handle, [MarshalAs (UnmanagedType.U1)] bool noPush); internal extern static void nw_tcp_options_set_no_push (IntPtr handle, [MarshalAs (UnmanagedType.U1)] bool noPush);
[Obsolete ("Use the 'NWProtocolTcpOptions' class instead.")]
public void TcpSetNoPush (bool noPush) => nw_tcp_options_set_no_push (GetCheckedHandle (), noPush); public void TcpSetNoPush (bool noPush) => nw_tcp_options_set_no_push (GetCheckedHandle (), noPush);
[DllImport (Constants.NetworkLibrary)] [DllImport (Constants.NetworkLibrary)]
extern static void nw_tcp_options_set_no_options (IntPtr handle, [MarshalAs (UnmanagedType.U1)] bool noOptions); internal extern static void nw_tcp_options_set_no_options (IntPtr handle, [MarshalAs (UnmanagedType.U1)] bool noOptions);
[Obsolete ("Use the 'NWProtocolTcpOptions' class instead.")]
public void TcpSetNoOptions (bool noOptions) => nw_tcp_options_set_no_options (GetCheckedHandle (), noOptions); public void TcpSetNoOptions (bool noOptions) => nw_tcp_options_set_no_options (GetCheckedHandle (), noOptions);
[DllImport (Constants.NetworkLibrary)] [DllImport (Constants.NetworkLibrary)]
extern static void nw_tcp_options_set_enable_keepalive (IntPtr handle, [MarshalAs (UnmanagedType.U1)] bool enableKeepAlive); internal extern static void nw_tcp_options_set_enable_keepalive (IntPtr handle, [MarshalAs (UnmanagedType.U1)] bool enableKeepAlive);
[Obsolete ("Use the 'NWProtocolTcpOptions' class instead.")]
public void TcpSetEnableKeepAlive (bool enableKeepAlive) => nw_tcp_options_set_enable_keepalive (GetCheckedHandle (), enableKeepAlive); public void TcpSetEnableKeepAlive (bool enableKeepAlive) => nw_tcp_options_set_enable_keepalive (GetCheckedHandle (), enableKeepAlive);
[DllImport (Constants.NetworkLibrary)] [DllImport (Constants.NetworkLibrary)]
extern static void nw_tcp_options_set_keepalive_count (IntPtr handle, uint keepaliveCount); internal extern static void nw_tcp_options_set_keepalive_count (IntPtr handle, uint keepaliveCount);
[Obsolete ("Use the 'NWProtocolTcpOptions' class instead.")]
public void TcpSetKeepAliveCount (uint keepaliveCount) => nw_tcp_options_set_keepalive_count (GetCheckedHandle (), keepaliveCount); public void TcpSetKeepAliveCount (uint keepaliveCount) => nw_tcp_options_set_keepalive_count (GetCheckedHandle (), keepaliveCount);
[DllImport (Constants.NetworkLibrary)] [DllImport (Constants.NetworkLibrary)]
extern static void nw_tcp_options_set_keepalive_idle_time (IntPtr handle, uint keepaliveIdleTime); internal extern static void nw_tcp_options_set_keepalive_idle_time (IntPtr handle, uint keepaliveIdleTime);
[Obsolete ("Use the 'NWProtocolTcpOptions' class instead.")]
public void TcpSetKeepAliveIdleTime (uint keepaliveIdleTime) => nw_tcp_options_set_keepalive_idle_time (GetCheckedHandle (), keepaliveIdleTime); public void TcpSetKeepAliveIdleTime (uint keepaliveIdleTime) => nw_tcp_options_set_keepalive_idle_time (GetCheckedHandle (), keepaliveIdleTime);
[DllImport (Constants.NetworkLibrary)] [DllImport (Constants.NetworkLibrary)]
extern static void nw_tcp_options_set_keepalive_interval (IntPtr handle, uint keepaliveInterval); internal extern static void nw_tcp_options_set_keepalive_interval (IntPtr handle, uint keepaliveInterval);
[Obsolete ("Use the 'NWProtocolTcpOptions' class instead.")]
public void TcpSetKeepAliveInterval (uint keepaliveInterval) => nw_tcp_options_set_keepalive_interval (GetCheckedHandle (), keepaliveInterval); public void TcpSetKeepAliveInterval (uint keepaliveInterval) => nw_tcp_options_set_keepalive_interval (GetCheckedHandle (), keepaliveInterval);
[DllImport (Constants.NetworkLibrary)] [DllImport (Constants.NetworkLibrary)]
extern static void nw_tcp_options_set_maximum_segment_size (IntPtr handle, uint maximumSegmentSize); internal extern static void nw_tcp_options_set_maximum_segment_size (IntPtr handle, uint maximumSegmentSize);
[Obsolete ("Use the 'NWProtocolTcpOptions' class instead.")]
public void TcpSetMaximumSegmentSize (uint maximumSegmentSize) => nw_tcp_options_set_maximum_segment_size (GetCheckedHandle (), maximumSegmentSize); public void TcpSetMaximumSegmentSize (uint maximumSegmentSize) => nw_tcp_options_set_maximum_segment_size (GetCheckedHandle (), maximumSegmentSize);
[DllImport (Constants.NetworkLibrary)] [DllImport (Constants.NetworkLibrary)]
extern static void nw_tcp_options_set_connection_timeout (IntPtr handle, uint connectionTimeout); internal extern static void nw_tcp_options_set_connection_timeout (IntPtr handle, uint connectionTimeout);
[Obsolete ("Use the 'NWProtocolTcpOptions' class instead.")]
public void TcpSetConnectionTimeout (uint connectionTimeout) => nw_tcp_options_set_connection_timeout (GetCheckedHandle (), connectionTimeout); public void TcpSetConnectionTimeout (uint connectionTimeout) => nw_tcp_options_set_connection_timeout (GetCheckedHandle (), connectionTimeout);
[DllImport (Constants.NetworkLibrary)] [DllImport (Constants.NetworkLibrary)]
extern static void nw_tcp_options_set_persist_timeout (IntPtr handle, uint persistTimeout); internal extern static void nw_tcp_options_set_persist_timeout (IntPtr handle, uint persistTimeout);
[Obsolete ("Use the 'NWProtocolTcpOptions' class instead.")]
public void TcpSetPersistTimeout (uint persistTimeout) => nw_tcp_options_set_persist_timeout (GetCheckedHandle (), persistTimeout); public void TcpSetPersistTimeout (uint persistTimeout) => nw_tcp_options_set_persist_timeout (GetCheckedHandle (), persistTimeout);
[DllImport (Constants.NetworkLibrary)] [DllImport (Constants.NetworkLibrary)]
extern static void nw_tcp_options_set_retransmit_connection_drop_time (IntPtr handle, uint retransmitConnectionDropTime); internal extern static void nw_tcp_options_set_retransmit_connection_drop_time (IntPtr handle, uint retransmitConnectionDropTime);
[Obsolete ("Use the 'NWProtocolTcpOptions' class instead.")]
public void TcpSetRetransmitConnectionDropTime (uint retransmitConnectionDropTime) => nw_tcp_options_set_retransmit_connection_drop_time (GetCheckedHandle (), retransmitConnectionDropTime); public void TcpSetRetransmitConnectionDropTime (uint retransmitConnectionDropTime) => nw_tcp_options_set_retransmit_connection_drop_time (GetCheckedHandle (), retransmitConnectionDropTime);
[DllImport (Constants.NetworkLibrary)] [DllImport (Constants.NetworkLibrary)]
extern static void nw_tcp_options_set_retransmit_fin_drop (IntPtr handle, [MarshalAs (UnmanagedType.U1)] bool retransmitFinDrop); internal extern static void nw_tcp_options_set_retransmit_fin_drop (IntPtr handle, [MarshalAs (UnmanagedType.U1)] bool retransmitFinDrop);
[Obsolete ("Use the 'NWProtocolTcpOptions' class instead.")]
public void TcpSetRetransmitFinDrop (bool retransmitFinDrop) => nw_tcp_options_set_retransmit_fin_drop (GetCheckedHandle (), retransmitFinDrop); public void TcpSetRetransmitFinDrop (bool retransmitFinDrop) => nw_tcp_options_set_retransmit_fin_drop (GetCheckedHandle (), retransmitFinDrop);
[DllImport (Constants.NetworkLibrary)] [DllImport (Constants.NetworkLibrary)]
extern static void nw_tcp_options_set_disable_ack_stretching (IntPtr handle, [MarshalAs (UnmanagedType.U1)] bool disableAckStretching); internal extern static void nw_tcp_options_set_disable_ack_stretching (IntPtr handle, [MarshalAs (UnmanagedType.U1)] bool disableAckStretching);
[Obsolete ("Use the 'NWProtocolTcpOptions' class instead.")]
public void TcpSetDisableAckStretching (bool disableAckStretching) => nw_tcp_options_set_disable_ack_stretching (GetCheckedHandle (), disableAckStretching); public void TcpSetDisableAckStretching (bool disableAckStretching) => nw_tcp_options_set_disable_ack_stretching (GetCheckedHandle (), disableAckStretching);
[DllImport (Constants.NetworkLibrary)] [DllImport (Constants.NetworkLibrary)]
extern static void nw_tcp_options_set_enable_fast_open (IntPtr handle, [MarshalAs (UnmanagedType.U1)] bool enableFastOpen); internal extern static void nw_tcp_options_set_enable_fast_open (IntPtr handle, [MarshalAs (UnmanagedType.U1)] bool enableFastOpen);
[Obsolete ("Use the 'NWProtocolTcpOptions' class instead.")]
public void TcpSetEnableFastOpen (bool enableFastOpen) => nw_tcp_options_set_enable_fast_open (GetCheckedHandle (), enableFastOpen); public void TcpSetEnableFastOpen (bool enableFastOpen) => nw_tcp_options_set_enable_fast_open (GetCheckedHandle (), enableFastOpen);
[DllImport (Constants.NetworkLibrary)] [DllImport (Constants.NetworkLibrary)]
extern static void nw_tcp_options_set_disable_ecn (IntPtr handle, [MarshalAs (UnmanagedType.U1)] bool disableEcn); internal extern static void nw_tcp_options_set_disable_ecn (IntPtr handle, [MarshalAs (UnmanagedType.U1)] bool disableEcn);
[Obsolete ("Use the 'NWProtocolTcpOptions' class instead.")]
public void TcpSetDisableEcn (bool disableEcn) => nw_tcp_options_set_disable_ecn (GetCheckedHandle (), disableEcn); public void TcpSetDisableEcn (bool disableEcn) => nw_tcp_options_set_disable_ecn (GetCheckedHandle (), disableEcn);
// //
// UDP Options // UDP Options
// //
[DllImport (Constants.NetworkLibrary)] [DllImport (Constants.NetworkLibrary)]
extern static void nw_udp_options_set_prefer_no_checksum (IntPtr handle, [MarshalAs (UnmanagedType.U1)] bool preferNoChecksums); internal extern static void nw_udp_options_set_prefer_no_checksum (IntPtr handle, [MarshalAs (UnmanagedType.U1)] bool preferNoChecksums);
[Obsolete ("Use the 'NWProtocolUdpOptions' class instead.")]
public void UdpSetPreferNoChecksum (bool preferNoChecksums) => nw_udp_options_set_prefer_no_checksum (GetCheckedHandle (), preferNoChecksums); public void UdpSetPreferNoChecksum (bool preferNoChecksums) => nw_udp_options_set_prefer_no_checksum (GetCheckedHandle (), preferNoChecksums);
// //
@ -182,8 +221,9 @@ namespace Network {
// //
[DllImport (Constants.NetworkLibrary)] [DllImport (Constants.NetworkLibrary)]
extern static IntPtr nw_tls_copy_sec_protocol_options (IntPtr options); internal extern static IntPtr nw_tls_copy_sec_protocol_options (IntPtr options);
[Obsolete ("Use the 'NWProtocolTlsOptions' class instead.")]
public SecProtocolOptions TlsProtocolOptions => new SecProtocolOptions (nw_tls_copy_sec_protocol_options (GetCheckedHandle ()), owns: true); public SecProtocolOptions TlsProtocolOptions => new SecProtocolOptions (nw_tls_copy_sec_protocol_options (GetCheckedHandle ()), owns: true);
} }
} }

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

@ -51,9 +51,25 @@ namespace Network {
{ {
var del = BlockLiteral.GetTarget<Action<NWProtocolOptions>> (block); var del = BlockLiteral.GetTarget<Action<NWProtocolOptions>> (block);
if (del != null) { if (del != null) {
var x = new NWProtocolOptions (options, owns: false); using (var tempOptions = new NWProtocolOptions (options, owns: false))
del (x); using (var definition = tempOptions.ProtocolDefinition) {
x.Dispose (); NWProtocolOptions castedOptions = null;
if (definition.Equals (NWProtocolDefinition.TcpDefinition)) {
castedOptions = new NWProtocolTcpOptions (options, owns: false);
} else if (definition.Equals (NWProtocolDefinition.UdpDefinition)) {
castedOptions = new NWProtocolUdpOptions (options, owns: false);
} else if (definition.Equals (NWProtocolDefinition.TlsDefinition)) {
castedOptions = new NWProtocolTlsOptions (options, owns: false);
} else if (definition.Equals (NWProtocolDefinition.IPDefinition)) {
castedOptions = new NWProtocolIPOptions (options, owns: false);
} else if (definition.Equals (NWProtocolDefinition.WebSocketDefinition)) {
castedOptions = new NWWebSocketOptions (options, owns: false);
}
del (castedOptions ?? tempOptions);
castedOptions?.Dispose ();
}
} }
} }
@ -80,13 +96,43 @@ namespace Network {
extern static void nw_protocol_stack_set_transport_protocol (nw_protocol_stack_t stack, IntPtr value); extern static void nw_protocol_stack_set_transport_protocol (nw_protocol_stack_t stack, IntPtr value);
public NWProtocolOptions TransportProtocol { public NWProtocolOptions TransportProtocol {
get => new NWProtocolOptions (nw_protocol_stack_copy_transport_protocol (GetCheckedHandle ()), owns: true); get {
var pHandle = nw_protocol_stack_copy_transport_protocol (GetCheckedHandle ());
if (pHandle == IntPtr.Zero)
return null;
var tempOptions = new NWProtocolOptions (pHandle, owns: true);
using (var definition = tempOptions.ProtocolDefinition) {
NWProtocolOptions castedOptions = null;
if (definition.Equals (NWProtocolDefinition.TcpDefinition)) {
castedOptions = new NWProtocolTcpOptions (pHandle, owns: true);
}
if (definition.Equals (NWProtocolDefinition.UdpDefinition)) {
castedOptions = new NWProtocolUdpOptions (pHandle, owns: true);
}
if (castedOptions == null) {
return tempOptions;
} else {
tempOptions.Dispose ();
return castedOptions;
}
}
}
set => nw_protocol_stack_set_transport_protocol (GetCheckedHandle (), value.GetHandle ()); set => nw_protocol_stack_set_transport_protocol (GetCheckedHandle (), value.GetHandle ());
} }
[DllImport (Constants.NetworkLibrary)] [DllImport (Constants.NetworkLibrary)]
extern static IntPtr nw_protocol_stack_copy_internet_protocol (nw_protocol_stack_t stack); extern static IntPtr nw_protocol_stack_copy_internet_protocol (nw_protocol_stack_t stack);
public NWProtocolOptions InternetProtocol => new NWProtocolOptions (nw_protocol_stack_copy_internet_protocol (GetCheckedHandle ()), owns: true); #if XAMCORE_4_0
public NWProtocolIPOptions InternetProtocol {
#else
public NWProtocolOptions InternetProtocol {
#endif
get {
var pHandle = nw_protocol_stack_copy_internet_protocol (GetCheckedHandle ());
return (pHandle == IntPtr.Zero) ? null : new NWProtocolIPOptions (pHandle, owns: true);
}
}
} }
} }

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

@ -0,0 +1,65 @@
//
// NWProtocolTcp: Bindings the Netowrk nw_protocol_options API focus on Tcp options.
//
// Authors:
// Manuel de la Pena <mandel@microsoft.com>
//
// Copyrigh 2019 Microsoft Inc
//
using System;
using System.Runtime.InteropServices;
using System.Runtime.CompilerServices;
using ObjCRuntime;
using Foundation;
using CoreFoundation;
using Security;
using OS_nw_protocol_definition=System.IntPtr;
using IntPtr=System.IntPtr;
namespace Network {
[TV (12,0), Mac (10,14), iOS (12,0), Watch (6,0)]
public class NWProtocolTcpOptions : NWProtocolOptions {
internal NWProtocolTcpOptions (IntPtr handle, bool owns) : base (handle, owns) {}
public NWProtocolTcpOptions () : this (nw_tcp_create_options (), owns: true) {}
public void SetNoDelay (bool noDelay) => nw_tcp_options_set_no_delay (GetCheckedHandle (), noDelay);
public void SetNoPush (bool noPush) => nw_tcp_options_set_no_push (GetCheckedHandle (), noPush);
public void SetNoOptions (bool noOptions) => nw_tcp_options_set_no_options (GetCheckedHandle (), noOptions);
public void SetEnableKeepAlive (bool enableKeepAlive) => nw_tcp_options_set_enable_keepalive (GetCheckedHandle (), enableKeepAlive);
public void SetKeepAliveCount (uint keepAliveCount) => nw_tcp_options_set_keepalive_count (GetCheckedHandle (), keepAliveCount);
public void SetKeepAliveIdleTime (TimeSpan keepAliveIdleTime)
=> nw_tcp_options_set_keepalive_idle_time (GetCheckedHandle (), (uint) keepAliveIdleTime.Seconds);
public void SetKeepAliveInterval (TimeSpan keepAliveInterval)
=> nw_tcp_options_set_keepalive_interval (GetCheckedHandle (), (uint) keepAliveInterval.Seconds);
public void SetMaximumSegmentSize (uint maximumSegmentSize)
=> nw_tcp_options_set_maximum_segment_size (GetCheckedHandle (), maximumSegmentSize);
public void SetConnectionTimeout (TimeSpan connectionTimeout)
=> nw_tcp_options_set_connection_timeout (GetCheckedHandle (), (uint) connectionTimeout.Seconds);
public void SetPersistTimeout (TimeSpan persistTimeout)
=> nw_tcp_options_set_persist_timeout (GetCheckedHandle (), (uint) persistTimeout.Seconds);
public void SetRetransmitConnectionDropTime (TimeSpan connectionDropTime)
=> nw_tcp_options_set_retransmit_connection_drop_time (GetCheckedHandle (), (uint) connectionDropTime.Seconds);
public void SetRetransmitFinDrop (bool retransmitFinDrop) => nw_tcp_options_set_retransmit_fin_drop (GetCheckedHandle (), retransmitFinDrop);
public void SetDisableAckStretching (bool disableAckStretching)
=> nw_tcp_options_set_disable_ack_stretching (GetCheckedHandle (), disableAckStretching);
public void SetEnableFastOpen (bool enableFastOpen) => nw_tcp_options_set_enable_fast_open (GetCheckedHandle (), enableFastOpen);
public void SetDisableEcn (bool disableEcn) => nw_tcp_options_set_disable_ecn (GetCheckedHandle (), disableEcn);
}
}

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

@ -0,0 +1,29 @@
//
// NWProtocolTls: Bindings the Netowrk nw_protocol_options API focus on Tls options.
//
// Authors:
// Manuel de la Pena <mandel@microsoft.com>
//
// Copyrigh 2019 Microsoft Inc
//
using System;
using System.Runtime.InteropServices;
using System.Runtime.CompilerServices;
using ObjCRuntime;
using Foundation;
using CoreFoundation;
using Security;
using OS_nw_protocol_definition=System.IntPtr;
using IntPtr=System.IntPtr;
namespace Network {
[TV (12,0), Mac (10,14), iOS (12,0), Watch (6,0)]
public class NWProtocolTlsOptions : NWProtocolOptions {
internal NWProtocolTlsOptions (IntPtr handle, bool owns) : base (handle, owns) {}
public NWProtocolTlsOptions () : this (nw_tls_create_options (), owns: true) {}
public SecProtocolOptions ProtocolOptions => new SecProtocolOptions (nw_tls_copy_sec_protocol_options (GetCheckedHandle ()), owns: true);
}
}

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

@ -0,0 +1,25 @@
//
// NWProtocolTls: Bindings the Netowrk nw_protocol_options API focus on Udp options.
//
// Authors:
// Manuel de la Pena <mandel@microsoft.com>
//
// Copyrigh 2019 Microsoft Inc
//
using System;
using ObjCRuntime;
using Foundation;
using CoreFoundation;
using Security;
namespace Network {
[TV (12,0), Mac (10,14), iOS (12,0), Watch (6,0)]
public class NWProtocolUdpOptions : NWProtocolOptions {
internal NWProtocolUdpOptions (IntPtr handle, bool owns) : base (handle, owns) {}
public NWProtocolUdpOptions () : this (nw_udp_create_options (), owns: true) {}
public void SetPreferNoChecksum (bool preferNoChecksum) => nw_udp_options_set_prefer_no_checksum (GetCheckedHandle (), preferNoChecksum);
}
}

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

@ -0,0 +1,25 @@
//
// NWTcpMetadata.cs: Bindings the Netowrk nw_protocol_metadata_t API that is an Tcp.
//
// Authors:
// Manuel de la Pena <mandel@microsoft.com>
//
// Copyrigh 2019 Microsoft
//
using System;
using ObjCRuntime;
using Foundation;
using CoreFoundation;
namespace Network {
[TV (12,0), Mac (10,14), iOS (12,0), Watch (6,0)]
public class NWTcpMetadata : NWProtocolMetadata {
internal NWTcpMetadata (IntPtr handle, bool owns) : base (handle, owns) {}
public uint AvailableReceiveBuffer => nw_tcp_get_available_receive_buffer (GetCheckedHandle ());
public uint AvailableSendBuffer => nw_tcp_get_available_send_buffer (GetCheckedHandle ());
}
}

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

@ -0,0 +1,26 @@
//
// NWTlsMetadata.cs: Bindings the Netowrk nw_protocol_metadata_t API that is an Tls.
//
// Authors:
// Manuel de la Pena <mandel@microsoft.com>
//
// Copyrigh 2019 Microsoft
//
using System;
using ObjCRuntime;
using Foundation;
using Security;
using CoreFoundation;
namespace Network {
[TV (12,0), Mac (10,14), iOS (12,0), Watch (6,0)]
public class NWTlsMetadata : NWProtocolMetadata {
internal NWTlsMetadata (IntPtr handle, bool owns) : base (handle, owns) {}
public SecProtocolMetadata SecProtocolMetadata
=> new SecProtocolMetadata (nw_tls_copy_sec_protocol_metadata (GetCheckedHandle ()), owns: true);
}
}

262
src/Network/NWTxtRecord.cs Normal file
Просмотреть файл

@ -0,0 +1,262 @@
//
// NWTxtRecord.cs: Bindings the Network nw_txt_record_t API
//
// Authors:
// Miguel de Icaza (miguel@microsoft.com)
//
// Copyright 2019 Microsoft Inc
//
using System;
using System.Runtime.InteropServices;
using System.Runtime.CompilerServices;
using System.Text;
using ObjCRuntime;
using Foundation;
using CoreFoundation;
using nw_advertise_descriptor_t=System.IntPtr;
using OS_nw_advertise_descriptor=System.IntPtr;
using OS_nw_txt_record=System.IntPtr;
namespace Network {
[TV (13,0), Mac (10,15), iOS (13,0), Watch (6,0)]
public enum NWTxtRecordFindKey {
Invalid = 0,
NotPresent = 1,
NoValue = 2,
EmptyValue = 3,
NonEmptyValue = 4,
}
[TV (13,0), Mac (10,15), iOS (13,0), Watch (6,0)]
public class NWTxtRecord : NativeObject {
internal NWTxtRecord (IntPtr handle, bool owns) : base (handle, owns) { }
[DllImport (Constants.NetworkLibrary)]
unsafe static extern IntPtr nw_txt_record_create_with_bytes (byte *txtBytes, nuint len);
public static NWTxtRecord FromBytes (ReadOnlySpan<byte> bytes)
{
unsafe {
fixed (byte* mh = bytes) {
var x = nw_txt_record_create_with_bytes (mh, (nuint) bytes.Length);
if (x == IntPtr.Zero)
return null;
return new NWTxtRecord (x, owns: true);
}
}
}
[DllImport (Constants.NetworkLibrary)]
static extern IntPtr nw_txt_record_create_dictionary ();
public static NWTxtRecord CreateDictionary ()
{
var x = nw_txt_record_create_dictionary ();
if (x == IntPtr.Zero)
return null;
return new NWTxtRecord (x, owns: true);
}
[DllImport (Constants.NetworkLibrary)]
static extern IntPtr nw_txt_record_copy (IntPtr other);
public NWTxtRecord Clone () => new NWTxtRecord (nw_txt_record_copy (GetCheckedHandle ()), owns: true);
[DllImport (Constants.NetworkLibrary)]
static extern NWTxtRecordFindKey nw_txt_record_find_key (IntPtr handle, string key);
public NWTxtRecordFindKey FindKey (string key) => nw_txt_record_find_key (GetCheckedHandle (), key);
[DllImport (Constants.NetworkLibrary)]
unsafe static extern byte nw_txt_record_set_key (IntPtr handle, string key, IntPtr value, nuint valueLen);
public bool Add (string key, ReadOnlySpan<byte> value)
{
unsafe {
fixed (byte* mh = value)
return nw_txt_record_set_key (GetCheckedHandle (), key, (IntPtr)mh, (nuint) value.Length) != 0;
}
}
public bool Add (string key) {
unsafe {
return nw_txt_record_set_key (GetCheckedHandle (), key, IntPtr.Zero, 0) != 0;
}
}
public bool Add (string key, string value)
=> Add (key, value == null ? null : Encoding.UTF8.GetBytes (value));
[DllImport (Constants.NetworkLibrary)]
static extern byte nw_txt_record_remove_key (IntPtr handle, string key);
public bool Remove (string key) => nw_txt_record_remove_key (GetCheckedHandle (), key) != 0;
[DllImport (Constants.NetworkLibrary)]
static extern long nw_txt_record_get_key_count (IntPtr handle);
public long KeyCount => nw_txt_record_get_key_count (GetCheckedHandle ());
[DllImport (Constants.NetworkLibrary)]
static extern byte nw_txt_record_is_dictionary (IntPtr handle);
public bool IsDictionary => nw_txt_record_is_dictionary (GetCheckedHandle ()) != 0;
[DllImport (Constants.NetworkLibrary)]
static extern bool nw_txt_record_is_equal (OS_nw_txt_record left, OS_nw_txt_record right);
public bool Equals (NWTxtRecord other)
{
if (other == null)
return false;
return nw_txt_record_is_equal (GetCheckedHandle (), other.GetCheckedHandle ());
}
[DllImport (Constants.NetworkLibrary)]
unsafe static extern bool nw_txt_record_apply (OS_nw_txt_record txt_record, ref BlockLiteral applier);
delegate bool nw_txt_record_apply_t (IntPtr block, string key, NWTxtRecordFindKey found, IntPtr value, nuint valueLen);
unsafe static nw_txt_record_apply_t static_ApplyHandler = TrampolineApplyHandler;
#if XAMCORE_4_0
public delegate bool NWTxtRecordApplyDelegate (string key, NWTxtRecordFindKey result, ReadOnlySpan<byte> value);
#else
public delegate void NWTxtRecordApplyDelegate (string key, NWTxtRecordFindKey rersult, ReadOnlySpan<byte> value);
public delegate bool NWTxtRecordApplyDelegate2 (string key, NWTxtRecordFindKey result, ReadOnlySpan<byte> value);
#endif
[MonoPInvokeCallback (typeof (nw_txt_record_apply_t))]
unsafe static bool TrampolineApplyHandler (IntPtr block, string key, NWTxtRecordFindKey found, IntPtr value, nuint valueLen)
{
#if XAMCORE_4_0
var del = BlockLiteral.GetTarget<NWTxtRecordApplyDelegate> (block);
#else
var del = BlockLiteral.GetTarget<MulticastDelegate> (block);
#endif
if (del == null)
return false;
var mValue = new ReadOnlySpan<byte> ((void*)value, (int)valueLen);
#if XAMCORE_4_0
return del (key, found, mValue);
#else
if (del is NWTxtRecordApplyDelegate apply) {
apply (key, found, mValue);
return true;
}
if (del is NWTxtRecordApplyDelegate2 apply2)
return apply2 (key, found, mValue);
return false;
#endif
}
#if !XAMCORE_4_0
[Obsolete ("Use the overload that takes an NWTxtRecordApplyDelegate2 instead.")]
#endif
[BindingImpl (BindingImplOptions.Optimizable)]
public bool Apply (NWTxtRecordApplyDelegate handler)
{
if (handler == null)
throw new ArgumentNullException (nameof (handler));
BlockLiteral block_handler = new BlockLiteral ();
block_handler.SetupBlockUnsafe (static_ApplyHandler, handler);
try {
return nw_txt_record_apply (GetCheckedHandle (), ref block_handler);
} finally {
block_handler.CleanupBlock ();
}
}
#if !XAMCORE_4_0
[BindingImpl (BindingImplOptions.Optimizable)]
public bool Apply (NWTxtRecordApplyDelegate2 handler)
{
if (handler == null)
throw new ArgumentNullException (nameof (handler));
BlockLiteral block_handler = new BlockLiteral ();
block_handler.SetupBlockUnsafe (static_ApplyHandler, handler);
try {
return nw_txt_record_apply (GetCheckedHandle (), ref block_handler);
} finally {
block_handler.CleanupBlock ();
}
}
#endif
[DllImport (Constants.NetworkLibrary)]
static extern unsafe bool nw_txt_record_access_key (OS_nw_txt_record txt_record, string key, ref BlockLiteral access_value);
unsafe delegate void nw_txt_record_access_key_t (IntPtr block, string key, NWTxtRecordFindKey found, IntPtr value, nuint valueLen);
unsafe static nw_txt_record_access_key_t static_AccessKeyHandler = TrampolineAccessKeyHandler;
public delegate void NWTxtRecordGetValueDelegete (string key, NWTxtRecordFindKey result, ReadOnlySpan<byte> value);
[MonoPInvokeCallback (typeof (nw_txt_record_access_key_t))]
unsafe static void TrampolineAccessKeyHandler (IntPtr block, string key, NWTxtRecordFindKey found, IntPtr value, nuint valueLen)
{
var del = BlockLiteral.GetTarget<NWTxtRecordGetValueDelegete> (block);
if (del != null) {
ReadOnlySpan<byte> mValue;
if (found == NWTxtRecordFindKey.NonEmptyValue)
mValue = new ReadOnlySpan<byte>((void*)value, (int)valueLen);
else
mValue = Array.Empty<byte> ();
del (key, found, mValue);
}
}
[BindingImpl (BindingImplOptions.Optimizable)]
public bool GetValue (string key, NWTxtRecordGetValueDelegete handler)
{
if (handler == null)
throw new ArgumentNullException (nameof (handler));
BlockLiteral block_handler = new BlockLiteral ();
block_handler.SetupBlockUnsafe (static_AccessKeyHandler, handler);
try {
return nw_txt_record_access_key (GetCheckedHandle (), key, ref block_handler);
} finally {
block_handler.CleanupBlock ();
}
}
[DllImport (Constants.NetworkLibrary)]
unsafe static extern bool nw_txt_record_access_bytes (OS_nw_txt_record txt_record, ref BlockLiteral access_bytes);
unsafe delegate void nw_txt_record_access_bytes_t (IntPtr block, IntPtr value, nuint valueLen);
unsafe static nw_txt_record_access_bytes_t static_RawBytesHandler = TrampolineRawBytesHandler;
public delegate void NWTxtRecordGetRawByteDelegate (ReadOnlySpan<byte> value);
[MonoPInvokeCallback (typeof (nw_txt_record_access_bytes_t))]
unsafe static void TrampolineRawBytesHandler (IntPtr block, IntPtr value, nuint valueLen)
{
var del = BlockLiteral.GetTarget<NWTxtRecordGetRawByteDelegate> (block);
if (del != null) {
var mValue = new ReadOnlySpan<byte>((void*)value, (int)valueLen);
del (mValue);
}
}
[BindingImpl (BindingImplOptions.Optimizable)]
public bool GetRawBytes (NWTxtRecordGetRawByteDelegate handler)
{
if (handler == null)
throw new ArgumentNullException (nameof (handler));
BlockLiteral block_handler = new BlockLiteral ();
block_handler.SetupBlockUnsafe (static_RawBytesHandler, handler);
try {
return nw_txt_record_access_bytes (GetCheckedHandle (), ref block_handler);
} finally {
block_handler.CleanupBlock ();
}
}
}
}

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

@ -0,0 +1,25 @@
//
// NWUdpMetadata.cs: Bindings the Netowrk nw_protocol_metadata_t API that is an Udp.
//
// Authors:
// Manuel de la Pena <mandel@microsoft.com>
//
// Copyrigh 2019 Microsoft
//
using System;
using ObjCRuntime;
using Foundation;
using Security;
using CoreFoundation;
namespace Network {
[TV (12,0), Mac (10,14), iOS (12,0), Watch (6,0)]
public class NWUdpMetadata : NWProtocolMetadata {
internal NWUdpMetadata (IntPtr handle, bool owns) : base (handle, owns) {}
public NWUdpMetadata () : this (nw_udp_create_metadata (), owns: true) {}
}
}

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

@ -0,0 +1,121 @@
//
// NWWebSocketMetadata.cs: Bindings the Network nw_browser_t API.
//
// Authors:
// Manuel de la Pena (mandel@microsoft.com)
//
// Copyrigh 2019 Microsoft Inc
//
using System;
using System.Runtime.InteropServices;
using System.Runtime.CompilerServices;
using ObjCRuntime;
using Foundation;
using CoreFoundation;
using OS_nw_protocol_metadata=System.IntPtr;
using OS_nw_ws_response=System.IntPtr;
using dispatch_queue_t =System.IntPtr;
namespace Network {
[TV (13,0), Mac (10,15), iOS (13,0), Watch (6,0)]
public enum NWWebSocketOpCode : int {
Cont = 0x0,
Text = 0x1,
Binary = 0x2,
Close = 0x8,
Ping = 0x9,
Pong = 0xA,
Invalid = -1,
}
[TV (13,0), Mac (10,15), iOS (13,0), Watch (6,0)]
public enum NWWebSocketCloseCode : int {
NormalClosure = 1000,
GoingAway = 1001,
ProtocolError = 1002,
UnsupportedData = 1003,
NoStatusReceived = 1005,
AbnormalClosure = 1006,
InvalidFramePayloadData = 1007,
PolicyViolation = 1008,
MessageTooBig = 1009,
MandatoryExtension = 1010,
InternalServerError = 1011,
TlsHandshake = 1015,
}
[TV (13,0), Mac (10,15), iOS (13,0), Watch (6,0)]
public class NWWebSocketMetadata : NWProtocolMetadata {
internal NWWebSocketMetadata (IntPtr handle, bool owns) : base (handle, owns) {}
[DllImport (Constants.NetworkLibrary)]
static extern OS_nw_protocol_metadata nw_ws_create_metadata (NWWebSocketOpCode opcode);
public NWWebSocketMetadata (NWWebSocketOpCode opcode) : this (nw_ws_create_metadata (opcode), owns: true) {}
[DllImport (Constants.NetworkLibrary)]
static extern NWWebSocketCloseCode nw_ws_metadata_get_close_code (OS_nw_protocol_metadata metadata);
[DllImport (Constants.NetworkLibrary)]
static extern void nw_ws_metadata_set_close_code (OS_nw_protocol_metadata metadata, NWWebSocketCloseCode close_code);
public NWWebSocketCloseCode CloseCode {
get => nw_ws_metadata_get_close_code (GetCheckedHandle ());
set => nw_ws_metadata_set_close_code (GetCheckedHandle (), value);
}
[DllImport (Constants.NetworkLibrary)]
static extern NWWebSocketOpCode nw_ws_metadata_get_opcode (OS_nw_protocol_metadata metadata);
public NWWebSocketOpCode OpCode => nw_ws_metadata_get_opcode (GetCheckedHandle ());
[DllImport (Constants.NetworkLibrary)]
static extern void nw_ws_metadata_set_pong_handler (OS_nw_protocol_metadata metadata, dispatch_queue_t client_queue, ref BlockLiteral pong_handler);
delegate void nw_ws_metadata_set_pong_handler_t (IntPtr block, IntPtr error);
static nw_ws_metadata_set_pong_handler_t static_PongHandler = TrampolinePongHandler;
[MonoPInvokeCallback (typeof (nw_ws_metadata_set_pong_handler_t))]
static void TrampolinePongHandler (IntPtr block, IntPtr error)
{
var del = BlockLiteral.GetTarget<Action<NWError>> (block);
if (del != null) {
var nwError = (error == IntPtr.Zero)? null : new NWError (error, owns: false);
del (nwError);
}
}
[BindingImpl (BindingImplOptions.Optimizable)]
public void SetPongHandler (DispatchQueue queue, Action<NWError> handler)
{
if (queue == null)
throw new ArgumentNullException (nameof (queue));
if (handler == null)
throw new ArgumentNullException (nameof (handler));
unsafe {
BlockLiteral block_handler = new BlockLiteral ();
block_handler.SetupBlockUnsafe (static_PongHandler, handler);
try {
nw_ws_metadata_set_pong_handler (GetCheckedHandle (), queue.Handle, ref block_handler);
} finally {
block_handler.CleanupBlock ();
}
}
}
[DllImport (Constants.NetworkLibrary)]
static extern OS_nw_ws_response nw_ws_metadata_copy_server_response (OS_nw_protocol_metadata metadata);
public NWWebSocketResponse ServerResponse {
get {
var reponsePtr = nw_ws_metadata_copy_server_response (GetCheckedHandle ());
return (reponsePtr == IntPtr.Zero) ? null : new NWWebSocketResponse (reponsePtr, owns: true);
}
}
}
}

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

@ -0,0 +1,129 @@
//
// NWWebSocketOptions.cs: Bindings the Network nw_browser_t API.
//
// Authors:
// Manuel de la Pena (mandel@microsoft.com)
//
// Copyrigh 2019 Microsoft Inc
//
using System;
using System.Runtime.InteropServices;
using System.Runtime.CompilerServices;
using ObjCRuntime;
using Foundation;
using CoreFoundation;
using OS_nw_protocol_options=System.IntPtr;
using nw_ws_request_t=System.IntPtr;
namespace Network {
// this maps to `nw_ws_version_t` in Network.framework/Headers/ws_options.h (and not the enum from NetworkExtension)
[TV (13,0), Mac (10,15), iOS (13,0), Watch (6,0)]
public enum NWWebSocketVersion {
Invalid = 0,
Version13 = 1,
}
[TV (13,0), Mac (10,15), iOS (13,0), Watch (6,0)]
public class NWWebSocketOptions : NWProtocolOptions {
bool autoReplyPing = false;
bool skipHandShake = false;
nuint maximumMessageSize = (nuint) 0;
internal NWWebSocketOptions (IntPtr handle, bool owns) : base (handle, owns) {}
[DllImport (Constants.NetworkLibrary)]
extern static IntPtr nw_ws_create_options (NWWebSocketVersion version);
public NWWebSocketOptions (NWWebSocketVersion version) : base (nw_ws_create_options (version), true) { }
[DllImport (Constants.NetworkLibrary, CharSet = CharSet.Ansi, CallingConvention = CallingConvention.Cdecl)]
static extern void nw_ws_options_add_additional_header (OS_nw_protocol_options options, string name, string value);
public void SetHeader (string header, string value)
{
if (header == null)
throw new ArgumentNullException (header);
nw_ws_options_add_additional_header (GetCheckedHandle(), header, value);
}
[DllImport (Constants.NetworkLibrary, CharSet = CharSet.Ansi, CallingConvention = CallingConvention.Cdecl)]
static extern void nw_ws_options_add_subprotocol (OS_nw_protocol_options options, string subprotocol);
public void AddSubprotocol (string subprotocol)
{
if (subprotocol == null)
throw new ArgumentNullException (nameof (subprotocol));
nw_ws_options_add_subprotocol (GetCheckedHandle (), subprotocol);
}
[DllImport (Constants.NetworkLibrary)]
static extern void nw_ws_options_set_auto_reply_ping (OS_nw_protocol_options options, bool auto_reply_ping);
public bool AutoReplyPing {
get { return autoReplyPing;}
set {
autoReplyPing = value;
nw_ws_options_set_auto_reply_ping (GetCheckedHandle (), value);
}
}
[DllImport (Constants.NetworkLibrary)]
static extern void nw_ws_options_set_maximum_message_size (OS_nw_protocol_options options, nuint maximum_message_size);
public nuint MaximumMessageSize {
get { return maximumMessageSize; }
set {
maximumMessageSize = value;
nw_ws_options_set_maximum_message_size (GetCheckedHandle(), value);
}
}
[DllImport (Constants.NetworkLibrary)]
static extern void nw_ws_options_set_skip_handshake (OS_nw_protocol_options options, bool skip_handshake);
public bool SkipHandShake {
get { return skipHandShake; }
set {
skipHandShake = value;
nw_ws_options_set_skip_handshake (GetCheckedHandle (), value);
}
}
[DllImport (Constants.NetworkLibrary)]
static extern void nw_ws_options_set_client_request_handler (OS_nw_protocol_options options, IntPtr client_queue, ref BlockLiteral handler);
delegate void nw_ws_options_set_client_request_handler_t (IntPtr block, nw_ws_request_t request);
static nw_ws_options_set_client_request_handler_t static_ClientRequestHandler = TrampolineClientRequestHandler;
[MonoPInvokeCallback (typeof (nw_ws_options_set_client_request_handler_t))]
static void TrampolineClientRequestHandler (IntPtr block, nw_ws_request_t request)
{
var del = BlockLiteral.GetTarget<Action<NWWebSocketRequest>> (block);
if (del != null) {
var nwRequest = new NWWebSocketRequest (request, owns: true);
del (nwRequest);
}
}
[BindingImpl (BindingImplOptions.Optimizable)]
public void SetClientRequestHandler (DispatchQueue queue, Action<NWWebSocketRequest> handler)
{
if (queue == null)
throw new ArgumentNullException (nameof (handler));
if (handler == null)
throw new ArgumentNullException (nameof (handler));
unsafe {
BlockLiteral block_handler = new BlockLiteral ();
block_handler.SetupBlockUnsafe (static_ClientRequestHandler, handler);
try {
nw_ws_options_set_client_request_handler (GetCheckedHandle (), queue.Handle, ref block_handler);
} finally {
block_handler.CleanupBlock ();
}
}
}
}
}

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

@ -0,0 +1,84 @@
//
// NWWebSocketRequest.cs: Bindings the Network nw_ws_request_t API.
//
// Authors:
// Manuel de la Pena (mandel@microsoft.com)
//
// Copyrigh 2019 Microsoft Inc
//
using System;
using System.Runtime.InteropServices;
using System.Runtime.CompilerServices;
using ObjCRuntime;
using Foundation;
using CoreFoundation;
using OS_nw_ws_request=System.IntPtr;
namespace Network {
[TV (13,0), Mac (10,15), iOS (13,0), Watch (6,0)]
public class NWWebSocketRequest : NativeObject {
internal NWWebSocketRequest (IntPtr handle, bool owns) : base (handle, owns) {}
[DllImport (Constants.NetworkLibrary)]
unsafe static extern bool nw_ws_request_enumerate_additional_headers (OS_nw_ws_request request, ref BlockLiteral enumerator);
delegate void nw_ws_request_enumerate_additional_headers_t (IntPtr block, string header, string value);
static nw_ws_request_enumerate_additional_headers_t static_EnumerateHeaderHandler = TrampolineEnumerateHeaderHandler;
[MonoPInvokeCallback (typeof (nw_ws_request_enumerate_additional_headers_t))]
static void TrampolineEnumerateHeaderHandler (IntPtr block, string header, string value)
{
var del = BlockLiteral.GetTarget<Action<string, string>> (block);
if (del != null) {
del (header, value);
}
}
[BindingImpl (BindingImplOptions.Optimizable)]
public void EnumerateAdditionalHeaders (Action<string, string> handler)
{
if (handler == null)
throw new ArgumentNullException (nameof (handler));
BlockLiteral block_handler = new BlockLiteral ();
block_handler.SetupBlockUnsafe (static_EnumerateHeaderHandler, handler);
try {
nw_ws_request_enumerate_additional_headers (GetCheckedHandle (), ref block_handler);
} finally {
block_handler.CleanupBlock ();
}
}
[DllImport (Constants.NetworkLibrary)]
static extern bool nw_ws_request_enumerate_subprotocols (OS_nw_ws_request request, ref BlockLiteral enumerator);
delegate void nw_ws_request_enumerate_subprotocols_t (IntPtr block, string subprotocol);
static nw_ws_request_enumerate_subprotocols_t static_EnumerateSubprotocolHandler = TrampolineEnumerateSubprotocolHandler;
[MonoPInvokeCallback (typeof (nw_ws_request_enumerate_subprotocols_t))]
static void TrampolineEnumerateSubprotocolHandler (IntPtr block, string subprotocol)
{
var del = BlockLiteral.GetTarget<Action<string>> (block);
if (del != null) {
del (subprotocol);
}
}
[BindingImpl (BindingImplOptions.Optimizable)]
public void EnumerateSubprotocols (Action<string> handler)
{
if (handler == null)
throw new ArgumentNullException (nameof (handler));
BlockLiteral block_handler = new BlockLiteral ();
block_handler.SetupBlockUnsafe (static_EnumerateSubprotocolHandler, handler);
try {
nw_ws_request_enumerate_subprotocols (GetCheckedHandle (), ref block_handler);
} finally {
block_handler.CleanupBlock ();
}
}
}
}

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

@ -0,0 +1,83 @@
//
// NWWebSocketResponse.cs: Bindings the Network nw_browser_t API.
//
// Authors:
// Manuel de la Pena (mandel@microsoft.com)
//
// Copyrigh 2019 Microsoft Inc
//
using System;
using System.Runtime.InteropServices;
using System.Runtime.CompilerServices;
using ObjCRuntime;
using Foundation;
using CoreFoundation;
using OS_nw_ws_response=System.IntPtr;
namespace Network {
[TV (13,0), Mac (10,15), iOS (13,0), Watch (6,0)]
public enum NWWebSocketResponseStatus {
Invalid = 0,
Accept = 1,
Reject = 2,
}
[TV (13,0), Mac (10,15), iOS (13,0), Watch (6,0)]
public class NWWebSocketResponse : NativeObject {
internal NWWebSocketResponse (IntPtr handle, bool owns) : base (handle, owns) {}
[DllImport (Constants.NetworkLibrary, CharSet = CharSet.Ansi, CallingConvention = CallingConvention.Cdecl)]
static extern unsafe OS_nw_ws_response nw_ws_response_create (NWWebSocketResponseStatus status, string selected_subprotocol);
public NWWebSocketResponse (NWWebSocketResponseStatus status, string subprotocol)
=> InitializeHandle (nw_ws_response_create (status, subprotocol));
[DllImport (Constants.NetworkLibrary, CharSet = CharSet.Ansi, CallingConvention = CallingConvention.Cdecl)]
static extern string nw_ws_response_get_selected_subprotocol (OS_nw_ws_response response);
public string SelectedSubprotocol => nw_ws_response_get_selected_subprotocol (GetCheckedHandle ());
[DllImport (Constants.NetworkLibrary)]
static extern NWWebSocketResponseStatus nw_ws_response_get_status (OS_nw_ws_response response);
public NWWebSocketResponseStatus Status => nw_ws_response_get_status (GetCheckedHandle ());
[DllImport (Constants.NetworkLibrary)]
unsafe static extern bool nw_ws_response_enumerate_additional_headers (OS_nw_ws_response response, ref BlockLiteral enumerator);
delegate void nw_ws_response_enumerate_additional_headers_t (IntPtr block, string header, string value);
static nw_ws_response_enumerate_additional_headers_t static_EnumerateHeadersHandler = TrampolineEnumerateHeadersHandler;
[MonoPInvokeCallback (typeof (nw_ws_response_enumerate_additional_headers_t))]
static void TrampolineEnumerateHeadersHandler (IntPtr block, string header, string value)
{
var del = BlockLiteral.GetTarget<Action<string, string>> (block);
if (del != null) {
del (header, value);
}
}
[BindingImpl (BindingImplOptions.Optimizable)]
public bool EnumerateAdditionalHeaders (Action<string, string> handler)
{
if (handler == null)
throw new ArgumentNullException (nameof (handler));
BlockLiteral block_handler = new BlockLiteral ();
block_handler.SetupBlockUnsafe (static_EnumerateHeadersHandler, handler);
try {
return nw_ws_response_enumerate_additional_headers (GetCheckedHandle (), ref block_handler);
} finally {
block_handler.CleanupBlock ();
}
}
[DllImport (Constants.NetworkLibrary, CharSet = CharSet.Ansi, CallingConvention = CallingConvention.Cdecl)]
static extern void nw_ws_response_add_additional_header (OS_nw_ws_response response, string name, string value);
public void SetHeader (string header, string value) => nw_ws_response_add_additional_header (GetCheckedHandle (), header, value);
}
}

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

@ -445,7 +445,7 @@ namespace ObjCRuntime {
} }
} }
static IntPtr GetBlockWrapperCreator (IntPtr method, int parameter) static IntPtr GetBlockWrapperCreator (IntPtr method, uint parameter)
{ {
return ObjectWrapper.Convert (GetBlockWrapperCreator ((MethodInfo) ObjectWrapper.Convert (method), parameter)); return ObjectWrapper.Convert (GetBlockWrapperCreator ((MethodInfo) ObjectWrapper.Convert (method), parameter));
} }
@ -727,7 +727,7 @@ namespace ObjCRuntime {
return parameters [parameter].IsDefined (typeof(TransientAttribute), false); return parameters [parameter].IsDefined (typeof(TransientAttribute), false);
} }
static bool IsParameterOut (IntPtr info, int parameter) static bool IsParameterOut (IntPtr info, uint parameter)
{ {
var minfo = ObjectWrapper.Convert (info) as MethodInfo; var minfo = ObjectWrapper.Convert (info) as MethodInfo;
if (minfo == null) if (minfo == null)
@ -773,7 +773,7 @@ namespace ObjCRuntime {
} }
#endregion #endregion
static MethodInfo GetBlockProxyAttributeMethod (MethodInfo method, int parameter) static MethodInfo GetBlockProxyAttributeMethod (MethodInfo method, uint parameter)
{ {
var attrs = method.GetParameters () [parameter].GetCustomAttributes (typeof (BlockProxyAttribute), true); var attrs = method.GetParameters () [parameter].GetCustomAttributes (typeof (BlockProxyAttribute), true);
if (attrs.Length == 1) { if (attrs.Length == 1) {
@ -840,7 +840,7 @@ namespace ObjCRuntime {
#else #else
public public
#endif #endif
static MethodInfo GetBlockWrapperCreator (MethodInfo method, int parameter) static MethodInfo GetBlockWrapperCreator (MethodInfo method, uint parameter)
{ {
// A mirror of this method is also implemented in StaticRegistrar:FindBlockProxyCreatorMethod // A mirror of this method is also implemented in StaticRegistrar:FindBlockProxyCreatorMethod
// If this method is changed, that method will probably have to be updated too (tests!!!) // If this method is changed, that method will probably have to be updated too (tests!!!)

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

@ -54,7 +54,6 @@ namespace ObjCRuntime {
} }
delegate void initialize_func (); delegate void initialize_func ();
delegate void set_bool_func (bool value);
unsafe delegate sbyte *get_sbyteptr_func (); unsafe delegate sbyte *get_sbyteptr_func ();
static volatile bool originalWorkingDirectoryIsSet; static volatile bool originalWorkingDirectoryIsSet;
@ -116,7 +115,6 @@ namespace ObjCRuntime {
VerifyMonoVersion (); VerifyMonoVersion ();
LookupInternalFunction<set_bool_func> ("xamarin_set_is_unified") (IsUnifiedBuild);
LookupInternalFunction<initialize_func> ("xamarin_initialize") (); LookupInternalFunction<initialize_func> ("xamarin_initialize") ();
} }

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

@ -14,10 +14,15 @@ using Foundation;
namespace UIKit { namespace UIKit {
#if !WATCH #if !WATCH
public partial class UITraitCollection { public partial class UITraitCollection {
#if !XAMCORE_4_0
[Obsolete ("Please use the static 'Create' method instead.")]
public UITraitCollection FromPreferredContentSizeCategory (UIContentSizeCategory category) public UITraitCollection FromPreferredContentSizeCategory (UIContentSizeCategory category)
{ => Create (category);
return FromPreferredContentSizeCategory (category.GetConstant ()); #endif
}
public static UITraitCollection Create (UIContentSizeCategory category)
=> FromPreferredContentSizeCategory (category.GetConstant ());
} }
#endif #endif
} }

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

@ -102,83 +102,6 @@ namespace UIKit {
#endif #endif
} }
[Watch (4,0), TV (11,0), iOS (11,0)]
[StructLayout (LayoutKind.Sequential)]
public struct NSDirectionalEdgeInsets {
// API match for NSDirectionalEdgeInsetsZero field/constant
[Field ("NSDirectionalEdgeInsetsZero")] // fake (but helps testing and could also help documentation)
public static readonly NSDirectionalEdgeInsets Zero;
public nfloat Top, Leading, Bottom, Trailing;
#if !COREBUILD
public NSDirectionalEdgeInsets (nfloat top, nfloat leading, nfloat bottom, nfloat trailing)
{
Top = top;
Leading = leading;
Bottom = bottom;
Trailing = trailing;
}
// note: NSDirectionalEdgeInsetsEqualToDirectionalEdgeInsets (UIGeometry.h) is a macro
public bool Equals (NSDirectionalEdgeInsets other)
{
if (Leading != other.Leading)
return false;
if (Trailing != other.Trailing)
return false;
if (Top != other.Top)
return false;
return (Bottom == other.Bottom);
}
public override bool Equals (object obj)
{
if (obj is NSDirectionalEdgeInsets)
return Equals ((NSDirectionalEdgeInsets) obj);
return false;
}
public static bool operator == (NSDirectionalEdgeInsets insets1, NSDirectionalEdgeInsets insets2)
{
return insets1.Equals (insets2);
}
public static bool operator != (NSDirectionalEdgeInsets insets1, NSDirectionalEdgeInsets insets2)
{
return !insets1.Equals (insets2);
}
public override int GetHashCode ()
{
return Top.GetHashCode () ^ Leading.GetHashCode () ^ Trailing.GetHashCode () ^ Bottom.GetHashCode ();
}
[DllImport (Constants.UIKitLibrary)]
extern static NSDirectionalEdgeInsets NSDirectionalEdgeInsetsFromString (IntPtr /* NSString */ s);
static public NSDirectionalEdgeInsets FromString (string s)
{
// note: null is allowed
var ptr = NSString.CreateNative (s);
var value = NSDirectionalEdgeInsetsFromString (ptr);
NSString.ReleaseNative (ptr);
return value;
}
[DllImport (Constants.UIKitLibrary)]
extern static IntPtr /* NSString */ NSStringFromDirectionalEdgeInsets (NSDirectionalEdgeInsets insets);
// note: ensure we can roundtrip ToString into FromString
public override string ToString ()
{
using (var ns = new NSString (NSStringFromDirectionalEdgeInsets (this)))
return ns.ToString ();
}
#endif
}
#if !WATCH #if !WATCH
[iOS (9,0)] [iOS (9,0)]
[StructLayout (LayoutKind.Sequential)] [StructLayout (LayoutKind.Sequential)]

116
src/XKit/Types.cs Normal file
Просмотреть файл

@ -0,0 +1,116 @@
//
// Copyright 2019 Microsoft Inc
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
using System;
using System.Runtime.InteropServices;
using ObjCRuntime;
using Foundation;
using CoreGraphics;
#if MONOMAC
namespace AppKit {
#else
namespace UIKit {
#endif
[Watch (4,0), TV (11,0), iOS (11,0)]
[StructLayout (LayoutKind.Sequential)]
public struct NSDirectionalEdgeInsets {
// API match for NSDirectionalEdgeInsetsZero field/constant
[Field ("NSDirectionalEdgeInsetsZero")] // fake (but helps testing and could also help documentation)
public static readonly NSDirectionalEdgeInsets Zero;
public nfloat Top, Leading, Bottom, Trailing;
#if !COREBUILD
public NSDirectionalEdgeInsets (nfloat top, nfloat leading, nfloat bottom, nfloat trailing)
{
Top = top;
Leading = leading;
Bottom = bottom;
Trailing = trailing;
}
// note: NSDirectionalEdgeInsetsEqualToDirectionalEdgeInsets (UIGeometry.h) is a macro
public bool Equals (NSDirectionalEdgeInsets other)
{
if (Leading != other.Leading)
return false;
if (Trailing != other.Trailing)
return false;
if (Top != other.Top)
return false;
return (Bottom == other.Bottom);
}
public override bool Equals (object obj)
{
if (obj is NSDirectionalEdgeInsets)
return Equals ((NSDirectionalEdgeInsets) obj);
return false;
}
public static bool operator == (NSDirectionalEdgeInsets insets1, NSDirectionalEdgeInsets insets2)
{
return insets1.Equals (insets2);
}
public static bool operator != (NSDirectionalEdgeInsets insets1, NSDirectionalEdgeInsets insets2)
{
return !insets1.Equals (insets2);
}
public override int GetHashCode ()
{
return Top.GetHashCode () ^ Leading.GetHashCode () ^ Trailing.GetHashCode () ^ Bottom.GetHashCode ();
}
#if !MONOMAC
[DllImport (Constants.UIKitLibrary)]
extern static NSDirectionalEdgeInsets NSDirectionalEdgeInsetsFromString (IntPtr /* NSString */ s);
static public NSDirectionalEdgeInsets FromString (string s)
{
// note: null is allowed
var ptr = NSString.CreateNative (s);
var value = NSDirectionalEdgeInsetsFromString (ptr);
NSString.ReleaseNative (ptr);
return value;
}
#endif
#if !MONOMAC
[DllImport (Constants.UIKitLibrary)]
extern static IntPtr /* NSString */ NSStringFromDirectionalEdgeInsets (NSDirectionalEdgeInsets insets);
// note: ensure we can roundtrip ToString into FromString
public override string ToString ()
{
using (var ns = new NSString (NSStringFromDirectionalEdgeInsets (this)))
return ns.ToString ();
}
#endif
#endif
}
}

Разница между файлами не показана из-за своего большого размера Загрузить разницу

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

@ -67,7 +67,11 @@ namespace ARKit {
InvalidReferenceObject = 301, InvalidReferenceObject = 301,
InvalidWorldMap = 302, InvalidWorldMap = 302,
InvalidConfiguration = 303, InvalidConfiguration = 303,
CollaborationDataUnavailable = 304, #if !XAMCORE_4_0
[Obsolete ("Please use the 'InvalidCollaborationData' value instead.")]
CollaborationDataUnavailable = InvalidCollaborationData,
#endif
InvalidCollaborationData = 304,
InsufficientFeatures = 400, InsufficientFeatures = 400,
ObjectMergeFailed = 401, ObjectMergeFailed = 401,
FileIOFailed = 500, FileIOFailed = 500,

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

@ -608,6 +608,8 @@ namespace AuthenticationServices {
enum ASAuthorizationAppleIdButtonType : long { enum ASAuthorizationAppleIdButtonType : long {
SignIn, SignIn,
Continue, Continue,
[TV (13,2), Mac (10,15,1), iOS (13,2)]
SignUp,
Default = SignIn, Default = SignIn,
} }

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

@ -6672,19 +6672,19 @@ namespace AVFoundation {
[Field ("AVMetadataObjectTypeDataMatrixCode")] [Field ("AVMetadataObjectTypeDataMatrixCode")]
NSString TypeDataMatrixCode { get; } NSString TypeDataMatrixCode { get; }
[NoWatch, NoTV, NoMac, iOS (13, 0)] [NoWatch, NoTV, iOS (13, 0), Mac (10, 15)]
[Field ("AVMetadataObjectTypeCatBody")] [Field ("AVMetadataObjectTypeCatBody")]
NSString TypeCatBody { get; } NSString TypeCatBody { get; }
[NoWatch, NoTV, NoMac, iOS (13, 0)] [NoWatch, NoTV, iOS (13, 0), Mac (10, 15)]
[Field ("AVMetadataObjectTypeDogBody")] [Field ("AVMetadataObjectTypeDogBody")]
NSString TypeDogBody { get; } NSString TypeDogBody { get; }
[NoWatch, NoTV, NoMac, iOS (13, 0)] [NoWatch, NoTV, iOS (13, 0), Mac (10, 15)]
[Field ("AVMetadataObjectTypeHumanBody")] [Field ("AVMetadataObjectTypeHumanBody")]
NSString TypeHumanBody { get; } NSString TypeHumanBody { get; }
[NoWatch, NoTV, NoMac, iOS (13, 0)] [NoWatch, NoTV, iOS (13, 0), Mac (10, 15)]
[Field ("AVMetadataObjectTypeSalientObject")] [Field ("AVMetadataObjectTypeSalientObject")]
NSString TypeSalientObject { get; } NSString TypeSalientObject { get; }
} }

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

@ -30,7 +30,9 @@ namespace CallKit {
[ErrorDomain ("CXErrorDomain")] [ErrorDomain ("CXErrorDomain")]
[Native] [Native]
public enum CXErrorCode : long { public enum CXErrorCode : long {
Unknown = 0 Unknown = 0,
Unentitled = 1,
InvalidArgument = 2,
} }
[iOS (10, 0)] [iOS (10, 0)]

Разница между файлами не показана из-за своего большого размера Загрузить разницу

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

@ -5482,7 +5482,7 @@ namespace Foundation
// Inlined from NSUserActivity (UISceneActivationConditions) // Inlined from NSUserActivity (UISceneActivationConditions)
[iOS (13,0), TV (13,0), NoMac, NoWatch] [iOS (13,0), TV (13,0), Mac (10,15), Watch (6,0)]
[NullAllowed, Export ("targetContentIdentifier")] [NullAllowed, Export ("targetContentIdentifier")]
string TargetContentIdentifier { get; set; } string TargetContentIdentifier { get; set; }
} }
@ -9009,6 +9009,17 @@ namespace Foundation
[Static] [Static]
[Export ("notApplicableSelectionMarker", ArgumentSemantic.Strong)] [Export ("notApplicableSelectionMarker", ArgumentSemantic.Strong)]
NSBindingSelectionMarker NotApplicableSelectionMarker { get; } NSBindingSelectionMarker NotApplicableSelectionMarker { get; }
[Mac (10,15)]
[Static]
[Export ("setDefaultPlaceholder:forMarker:onClass:withBinding:")]
void SetDefaultPlaceholder ([NullAllowed] NSObject placeholder, [NullAllowed] NSBindingSelectionMarker marker, Class objectClass, string binding);
[Mac (10,15)]
[Static]
[Export ("defaultPlaceholderForMarker:onClass:withBinding:")]
[return: NullAllowed]
NSObject GetDefaultPlaceholder ([NullAllowed] NSBindingSelectionMarker marker, Class objectClass, string binding);
} }
[Protocol (Name = "NSObject")] // exists both as a type and a protocol in ObjC, Swift uses NSObjectProtocol [Protocol (Name = "NSObject")] // exists both as a type and a protocol in ObjC, Swift uses NSObjectProtocol

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

@ -70,6 +70,7 @@ APPKIT_CORE_SOURCES = \
AppKit/Enums.cs \ AppKit/Enums.cs \
AppKit/XEnums.cs \ AppKit/XEnums.cs \
AppKit/NSAccessibility.cs \ AppKit/NSAccessibility.cs \
XKit/Types.cs \
APPKIT_SOURCES = \ APPKIT_SOURCES = \
AppKit/ActionDispatcher.cs \ AppKit/ActionDispatcher.cs \
@ -147,6 +148,7 @@ APPKIT_SOURCES = \
AppKit/NSColorPickerTouchBarItem.cs \ AppKit/NSColorPickerTouchBarItem.cs \
AppKit/NSSliderTouchBarItem.cs \ AppKit/NSSliderTouchBarItem.cs \
AppKit/NSView.cs \ AppKit/NSView.cs \
AppKit/NSCollectionLayoutAnchor.cs \
# ARKit # ARKit
@ -418,6 +420,7 @@ COREFOUNDATION_CORE_SOURCES = \
CoreFoundation/Dispatch.cs \ CoreFoundation/Dispatch.cs \
CoreFoundation/DispatchData.cs \ CoreFoundation/DispatchData.cs \
CoreFoundation/NativeObject.cs \ CoreFoundation/NativeObject.cs \
CoreFoundation/Architecture.cs \
COREFOUNDATION_SOURCES = \ COREFOUNDATION_SOURCES = \
CoreFoundation/CFAllocator.cs \ CoreFoundation/CFAllocator.cs \
@ -920,11 +923,13 @@ IMAGECAPTURECORE_API_SOURCES = \
IMAGEIO_API_SOURCES = \ IMAGEIO_API_SOURCES = \
ImageIO/Enums.cs \ ImageIO/Enums.cs \
IMAGEIO_CORE_SOURCES = \
ImageIO/CGImageSource.cs \
IMAGEIO_SOURCES = \ IMAGEIO_SOURCES = \
ImageIO/CGImageDestination.cs \ ImageIO/CGImageDestination.cs \
ImageIO/CGImageMetadata.cs \ ImageIO/CGImageMetadata.cs \
ImageIO/CGImageMetadataTag.cs \ ImageIO/CGImageMetadataTag.cs \
ImageIO/CGImageSource.cs \
ImageIO/CGImageSource.iOS.cs \ ImageIO/CGImageSource.iOS.cs \
ImageIO/CGMutableImageMetadata.cs \ ImageIO/CGMutableImageMetadata.cs \
@ -1166,12 +1171,21 @@ NATURALLANGUAGE_SOURCES = \
NETWORK_SOURCES = \ NETWORK_SOURCES = \
Network/NWAdvertiseDescriptor.cs \ Network/NWAdvertiseDescriptor.cs \
Network/NWBrowserDescriptor.cs \
Network/NWBrowseResult.cs \
Network/NWBrowser.cs \
Network/NWConnection.cs \ Network/NWConnection.cs \
Network/NWContentContext.cs \ Network/NWContentContext.cs \
Network/NWDataTransferReport.cs \
Network/NWEstablishmentReport.cs \
Network/NWEndpoint.cs \ Network/NWEndpoint.cs \
Network/NWError.cs \ Network/NWError.cs \
Network/NWFramer.cs \
Network/NWFramerMessage.cs \
Network/NWInterface.cs \ Network/NWInterface.cs \
Network/NWIPMetadata.cs \
Network/NWListener.cs \ Network/NWListener.cs \
Network/NWProtocolIPOptions.cs \
Network/NWParameters.cs \ Network/NWParameters.cs \
Network/NWPath.cs \ Network/NWPath.cs \
Network/NWPathMonitor.cs \ Network/NWPathMonitor.cs \
@ -1179,6 +1193,17 @@ NETWORK_SOURCES = \
Network/NWProtocolMetadata.cs \ Network/NWProtocolMetadata.cs \
Network/NWProtocolOptions.cs \ Network/NWProtocolOptions.cs \
Network/NWProtocolStack.cs \ Network/NWProtocolStack.cs \
Network/NWTcpMetadata.cs \
Network/NWTlsMetadata.cs \
Network/NWTxtRecord.cs \
Network/NWProtocolTcpOptions.cs \
Network/NWProtocolTlsOptions.cs \
Network/NWProtocolUdpOptions.cs \
Network/NWUdpMetadata.cs \
Network/NWWebSocketMetadata.cs \
Network/NWWebSocketOptions.cs \
Network/NWWebSocketRequest.cs \
Network/NWWebSocketResponse.cs \
# NetworkExtension # NetworkExtension
@ -1502,6 +1527,7 @@ UIKIT_CORE_SOURCES = \
UIKit/UIPrintInteractionController.cs \ UIKit/UIPrintInteractionController.cs \
UIKit/UIStringAttributes.cs \ UIKit/UIStringAttributes.cs \
UIKit/UITypes.cs \ UIKit/UITypes.cs \
XKit/Types.cs \
UIKIT_SOURCES = \ UIKIT_SOURCES = \
UIKit/Compat.cs \ UIKit/Compat.cs \

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

@ -1,10 +1,12 @@
// Copyright 2015 Xamarin Inc. All rights reserved. // Copyright 2015 Xamarin Inc. All rights reserved.
// Copyright Microsoft Corp.
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using IKVM.Reflection; using IKVM.Reflection;
using Type = IKVM.Reflection.Type; using Type = IKVM.Reflection.Type;
using Foundation; using Foundation;
using ObjCRuntime;
public partial class Generator { public partial class Generator {
@ -33,10 +35,16 @@ public partial class Generator {
// internal static CIFilter FromName (string filterName, IntPtr handle) // internal static CIFilter FromName (string filterName, IntPtr handle)
filters.Add (type_name); filters.Add (type_name);
// filters are now exposed as protocols so we need to conform to them
var interfaces = String.Empty;
foreach (var i in type.GetInterfaces ()) {
interfaces += $", I{i.Name}";
}
// type declaration // type declaration
print ("public{0} partial class {1} : {2} {{", print ("public{0} partial class {1} : {2}{3} {{",
is_abstract ? " abstract" : String.Empty, is_abstract ? " abstract" : String.Empty,
type_name, base_name); type_name, base_name, interfaces);
print (""); print ("");
indent++; indent++;
@ -105,12 +113,54 @@ public partial class Generator {
} }
// properties // properties
GenerateProperties (type);
// protocols
GenerateProtocolProperties (type, new HashSet<string> ());
indent--;
print ("}");
// namespace closing (it's optional to use namespaces even if it's a bad practice, ref #35283)
if (indent > 0) {
indent--;
print ("}");
}
}
void GenerateProtocolProperties (Type type, HashSet<string> processed)
{
foreach (var i in type.GetInterfaces ()) {
if (!IsProtocolInterface (i, false, out var protocol))
continue;
// the same protocol can be included more than once (interfaces) - but we must generate only once
var pname = i.Name;
if (processed.Contains (pname))
continue;
processed.Add (pname);
print ("");
print ($"// {pname} protocol members ");
GenerateProperties (i);
// also include base interfaces/protocols
GenerateProtocolProperties (i, processed);
}
}
void GenerateProperties (Type type)
{
foreach (var p in type.GetProperties (BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance)) { foreach (var p in type.GetProperties (BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance)) {
if (p.IsUnavailable (this)) if (p.IsUnavailable (this))
continue; continue;
if (AttributeManager.HasAttribute<StaticAttribute> (p))
continue;
print (""); print ("");
PrintPropertyAttributes (p);
print_generated_code (); print_generated_code ();
var ptype = p.PropertyType.Name; var ptype = p.PropertyType.Name;
// keep C# names as they are reserved keywords (e.g. Boolean also exists in OpenGL for Mac) // keep C# names as they are reserved keywords (e.g. Boolean also exists in OpenGL for Mac)
switch (ptype) { switch (ptype) {
@ -126,28 +176,57 @@ public partial class Generator {
case "String": case "String":
ptype = "string"; ptype = "string";
break; break;
// adding `using ImageIO;` would lead to `error CS0104: 'CGImageProperties' is an ambiguous reference between 'CoreGraphics.CGImageProperties' and 'ImageIO.CGImageProperties'`
case "CGImageMetadata":
ptype = "ImageIO.CGImageMetadata";
break;
} }
print ("public {0} {1} {{", ptype, p.Name); print ("public {0} {1} {{", ptype, p.Name);
indent++; indent++;
// an export will be present (only) if it's defined in a protocol
var export = AttributeManager.GetCustomAttribute<ExportAttribute> (p);
var name = AttributeManager.GetCustomAttribute<CoreImageFilterPropertyAttribute> (p)?.Name; var name = AttributeManager.GetCustomAttribute<CoreImageFilterPropertyAttribute> (p)?.Name;
if (p.GetGetMethod () != null) // we can skip the name when it's identical to a protocol selector
if (name == null) {
if (export == null)
throw new BindingException (1072, true, $"Missing [CoreImageFilterProperty] attribute on {0} property {1}", type.Name, p.Name);
var sel = export.Selector;
if (sel.StartsWith ("input", StringComparison.Ordinal))
name = sel;
else
name = "input" + Capitalize (sel);
}
if (p.GetGetMethod () != null) {
PrintFilterExport (p, export, setter: false);
GenerateFilterGetter (ptype, name); GenerateFilterGetter (ptype, name);
if (p.GetSetMethod () != null) }
if (p.GetSetMethod () != null) {
PrintFilterExport (p, export, setter: true);
GenerateFilterSetter (ptype, name); GenerateFilterSetter (ptype, name);
}
indent--; indent--;
print ("}"); print ("}");
} }
}
indent--; void PrintFilterExport (PropertyInfo p, ExportAttribute export, bool setter)
print ("}"); {
if (export == null)
return;
// namespace closing (it's optional to use namespaces even if it's a bad practice, ref #35283) var selector = export.Selector;
if (indent > 0) { if (setter)
indent--; selector = "set" + Capitalize (selector) + ":";
print ("}");
} if (export.ArgumentSemantic != ArgumentSemantic.None && !p.PropertyType.IsPrimitive)
print ($"[Export (\"{selector}\", ArgumentSemantic.{export.ArgumentSemantic})]");
else
print ($"[Export (\"{selector}\")]");
} }
void GenerateFilterGetter (string propertyType, string propertyName) void GenerateFilterGetter (string propertyType, string propertyName)
@ -166,22 +245,30 @@ public partial class Generator {
indent++; indent++;
print ("return nsv.CGAffineTransformValue;"); print ("return nsv.CGAffineTransformValue;");
indent--; indent--;
print ("return new CGAffineTransform (1, 0, 0, 1, 0, 0);"); print ("return CGAffineTransform.MakeIdentity ();");
break; break;
// NSObject should not be added // NSObject should not be added
// NSNumber should not be added - it should be bound as a float (common), int32 or bool
case "AVCameraCalibrationData": case "AVCameraCalibrationData":
case "CGColorSpace": case "CGColorSpace":
case "CGImage":
case "ImageIO.CGImageMetadata":
case "CIBarcodeDescriptor": case "CIBarcodeDescriptor":
case "MLModel":
case "NSAttributedString":
case "NSData":
print ("return Runtime.GetINativeObject <{0}> (GetHandle (\"{1}\"), false);", propertyType, propertyName); print ("return Runtime.GetINativeObject <{0}> (GetHandle (\"{1}\"), false);", propertyType, propertyName);
break; break;
case "CIColor": case "CIColor":
print ("return GetColor (\"{0}\");", propertyName);
break;
case "CIImage": case "CIImage":
print ("return GetImage (\"{0}\");", propertyName);
break;
case "CIVector": case "CIVector":
print ("return GetVector (\"{0}\");", propertyName); print ($"return ValueForKey (\"{propertyName}\") as {propertyType};");
break;
case "CGPoint":
print ("return GetPoint (\"{0}\");", propertyName);
break;
case "CGRect":
print ("return GetRect (\"{0}\");", propertyName);
break; break;
case "float": case "float":
print ("return GetFloat (\"{0}\");", propertyName); print ("return GetFloat (\"{0}\");", propertyName);
@ -189,11 +276,8 @@ public partial class Generator {
case "int": case "int":
print ("return GetInt (\"{0}\");", propertyName); print ("return GetInt (\"{0}\");", propertyName);
break; break;
case "MLModel": case "nint":
case "NSAttributedString": print ("return GetNInt (\"{0}\");", propertyName);
case "NSData":
// NSNumber should not be added - it should be bound as a float (common), int32 or bool
print ("return ValueForKey (\"{0}\") as {1};", propertyName, propertyType);
break; break;
case "string": case "string":
// NSString should not be added - it should be bound as a string // NSString should not be added - it should be bound as a string
@ -229,12 +313,19 @@ public partial class Generator {
case "int": case "int":
print ("SetInt (\"{0}\", value);", propertyName); print ("SetInt (\"{0}\", value);", propertyName);
break; break;
case "nint":
print ("SetNInt (\"{0}\", value);", propertyName);
break;
// NSObject should not be added // NSObject should not be added
case "AVCameraCalibrationData": case "AVCameraCalibrationData":
case "CGColorSpace": case "CGColorSpace":
case "CIBarcodeDescriptor": case "CIBarcodeDescriptor":
print ("SetHandle (\"{0}\", value == null ? IntPtr.Zero : value.Handle);", propertyName); case "CGImage":
case "ImageIO.CGImageMetadata":
print ($"SetHandle (\"{propertyName}\", value.GetHandle ());");
break; break;
case "CGPoint":
case "CGRect":
case "CIColor": case "CIColor":
case "CIImage": case "CIImage":
case "CIVector": case "CIVector":

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

@ -64,6 +64,7 @@ public class TypeManager {
public Type CGPDFPage; public Type CGPDFPage;
public Type CGGradient; public Type CGGradient;
public Type CGImage; public Type CGImage;
public Type CGImageSource;
public Type CGLayer; public Type CGLayer;
public Type CGLContext; public Type CGLContext;
public Type CGLPixelFormat; public Type CGLPixelFormat;
@ -256,6 +257,7 @@ public class TypeManager {
CGPDFPage = Lookup (platform_assembly, "CoreGraphics", "CGPDFPage"); CGPDFPage = Lookup (platform_assembly, "CoreGraphics", "CGPDFPage");
CGGradient = Lookup (platform_assembly, "CoreGraphics", "CGGradient"); CGGradient = Lookup (platform_assembly, "CoreGraphics", "CGGradient");
CGImage = Lookup (platform_assembly, "CoreGraphics", "CGImage"); CGImage = Lookup (platform_assembly, "CoreGraphics", "CGImage");
CGImageSource = Lookup (platform_assembly, "ImageIO", "CGImageSource");
CGLayer = Lookup (platform_assembly, "CoreGraphics", "CGLayer"); CGLayer = Lookup (platform_assembly, "CoreGraphics", "CGLayer");
if (Frameworks.HaveOpenGL) { if (Frameworks.HaveOpenGL) {
CGLContext = Lookup (platform_assembly, "OpenGL", "CGLContext"); CGLContext = Lookup (platform_assembly, "OpenGL", "CGLContext");

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

@ -1214,14 +1214,21 @@ public partial class Generator : IMemberGatherer {
bool IsProtocolInterface (Type type, bool checkPrefix = true) bool IsProtocolInterface (Type type, bool checkPrefix = true)
{ {
return IsProtocolInterface (type, checkPrefix, out var _);
}
bool IsProtocolInterface (Type type, bool checkPrefix, out Type protocol)
{
protocol = null;
// for subclassing the type (from the binding files) is not yet prefixed by an `I` // for subclassing the type (from the binding files) is not yet prefixed by an `I`
if (checkPrefix && type.Name [0] != 'I') if (checkPrefix && type.Name [0] != 'I')
return false; return false;
protocol = type;
if (AttributeManager.HasAttribute<ProtocolAttribute> (type)) if (AttributeManager.HasAttribute<ProtocolAttribute> (type))
return true; return true;
var protocol = type.Assembly.GetType (type.Namespace + "." + type.Name.Substring (1), false); protocol = type.Assembly.GetType (type.Namespace + "." + type.Name.Substring (1), false);
if (protocol == null) if (protocol == null)
return false; return false;
@ -2204,6 +2211,7 @@ public partial class Generator : IMemberGatherer {
marshal_types.Add (TypeManager.Class); marshal_types.Add (TypeManager.Class);
marshal_types.Add (TypeManager.CFRunLoop); marshal_types.Add (TypeManager.CFRunLoop);
marshal_types.Add (TypeManager.CGColorSpace); marshal_types.Add (TypeManager.CGColorSpace);
marshal_types.Add (TypeManager.CGImageSource);
marshal_types.Add (TypeManager.DispatchData); marshal_types.Add (TypeManager.DispatchData);
marshal_types.Add (TypeManager.DispatchQueue); marshal_types.Add (TypeManager.DispatchQueue);
marshal_types.Add (TypeManager.Protocol); marshal_types.Add (TypeManager.Protocol);
@ -2871,6 +2879,9 @@ public partial class Generator : IMemberGatherer {
} else if (pi.PropertyType.Name == "CGColorSpace") { } else if (pi.PropertyType.Name == "CGColorSpace") {
getter = "GetNativeValue<" + pi.PropertyType +"> ({0})"; getter = "GetNativeValue<" + pi.PropertyType +"> ({0})";
setter = "SetNativeValue ({0}, value)"; setter = "SetNativeValue ({0}, value)";
} else if (pi.PropertyType.Name == "CGImageSource") {
getter = "GetNativeValue<" + pi.PropertyType +"> ({0})";
setter = "SetNativeValue ({0}, value)";
} else { } else {
throw new BindingException (1031, true, throw new BindingException (1031, true,
"Limitation: can not automatically create strongly typed dictionary for " + "Limitation: can not automatically create strongly typed dictionary for " +
@ -3339,12 +3350,18 @@ public partial class Generator : IMemberGatherer {
var interfaceTag = protocolized == true ? "I" : ""; var interfaceTag = protocolized == true ? "I" : "";
string tname; string tname;
// we are adding the usage of ReflectedType just for those cases in which we have nested enums/classes, this soluction does not
// work with nested/nested/nested classes. But we are not writing a general solution because:
// 1. We have only encountered nested classes.
// 2. We are not going to complicate the code more than needed if we have never ever faced a situation with a crazy nested hierarchy,
// so we only solve the problem we have, no more.
var parentClass = (type.ReflectedType == null) ? String.Empty : type.ReflectedType.Name + ".";
if (types_that_must_always_be_globally_named.Contains (type.Name)) if (types_that_must_always_be_globally_named.Contains (type.Name))
tname = $"global::{type.Namespace}.{interfaceTag}{type.Name}"; tname = $"global::{type.Namespace}.{parentClass}{interfaceTag}{type.Name}";
else if ((usedInNamespace != null && type.Namespace == usedInNamespace) || ns.StandardNamespaces.Contains (type.Namespace) || string.IsNullOrEmpty (type.FullName)) else if ((usedInNamespace != null && type.Namespace == usedInNamespace) || ns.StandardNamespaces.Contains (type.Namespace) || string.IsNullOrEmpty (type.FullName))
tname = interfaceTag + type.Name; tname = interfaceTag + type.Name;
else else
tname = $"global::{type.Namespace}.{interfaceTag}{type.Name}"; tname = $"global::{type.Namespace}.{parentClass}{interfaceTag}{type.Name}";
var targs = type.GetGenericArguments (); var targs = type.GetGenericArguments ();
if (targs.Length > 0) { if (targs.Length > 0) {

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

@ -750,6 +750,10 @@ namespace HomeKit {
[Field ("HMUserFailedAccessoriesKey")] [Field ("HMUserFailedAccessoriesKey")]
NSString UserFailedAccessoriesKey { get; } NSString UserFailedAccessoriesKey { get; }
[Watch (6, 1), TV (13, 2), iOS (13, 2)]
[Export ("supportsAddingNetworkRouter")]
bool SupportsAddingNetworkRouter { get; }
} }
[TV (10,0)] [TV (10,0)]
@ -852,6 +856,10 @@ namespace HomeKit {
[Watch (4,0), TV (11,0), iOS (11,0)] [Watch (4,0), TV (11,0), iOS (11,0)]
[Export ("home:didUpdateHomeHubState:"), EventArgs ("HMHomeHubState")] [Export ("home:didUpdateHomeHubState:"), EventArgs ("HMHomeHubState")]
void DidUpdateHomeHubState (HMHome home, HMHomeHubState homeHubState); void DidUpdateHomeHubState (HMHome home, HMHomeHubState homeHubState);
[Watch (6,1), TV (13,2), iOS (13,2)]
[Export ("homeDidUpdateSupportedFeatures:")]
void DidUpdateSupportedFeatures (HMHome home);
} }
[TV (10,0)] [TV (10,0)]

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

@ -32,6 +32,7 @@ using UIImage=AppKit.NSImage;
using UIView=AppKit.NSView; using UIView=AppKit.NSView;
using UIEdgeInsets=AppKit.NSEdgeInsets; using UIEdgeInsets=AppKit.NSEdgeInsets;
using UIColor=AppKit.NSColor; using UIColor=AppKit.NSColor;
using UIScene=AppKit.NSColor;
#endif #endif
#if WATCH #if WATCH
// helper for [NoWatch] // helper for [NoWatch]
@ -320,13 +321,26 @@ namespace MapKit {
[NoTV] [NoTV]
[Export ("openInMapsWithLaunchOptions:"), Internal] [Export ("openInMapsWithLaunchOptions:"), Internal]
bool _OpenInMaps ([NullAllowed] NSDictionary launchOptions); bool _OpenInMaps ([NullAllowed] NSDictionary launchOptions);
[NoTV] [NoTV]
[Static] [Static]
[Export ("openMapsWithItems:launchOptions:"), Internal] [Export ("openMapsWithItems:launchOptions:"), Internal]
bool _OpenMaps ([NullAllowed] MKMapItem [] mapItems, [NullAllowed] NSDictionary launchOptions); bool _OpenMaps ([NullAllowed] MKMapItem [] mapItems, [NullAllowed] NSDictionary launchOptions);
[iOS (13, 2), NoMac, NoTV, NoWatch]
[Introduced (PlatformName.UIKitForMac, 13, 2)]
[Async]
[Export ("openInMapsWithLaunchOptions:fromScene:completionHandler:")]
void OpenInMaps ([NullAllowed] NSDictionary launchOptions, [NullAllowed] UIScene fromScene, Action<NSError> completionHandler);
[iOS (13, 2), NoMac, NoTV, NoWatch]
[Introduced (PlatformName.UIKitForMac, 13, 2)]
[Static]
[Async]
[Export ("openMapsWithItems:launchOptions:fromScene:completionHandler:")]
void OpenMaps ([NullAllowed] MKMapItem [] mapItems, [NullAllowed] NSDictionary launchOptions, [NullAllowed] UIScene fromScene, Action<NSError> completionHandler);
[NoTV] [NoTV]
[Field ("MKLaunchOptionsDirectionsModeKey"), Internal] [Field ("MKLaunchOptionsDirectionsModeKey"), Internal]
NSString MKLaunchOptionsDirectionsModeKey { get; } NSString MKLaunchOptionsDirectionsModeKey { get; }

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

@ -1899,6 +1899,10 @@ namespace MetalPerformanceShaders {
[TV (11, 0), iOS (11, 0)] [TV (11, 0), iOS (11, 0)]
[Export ("matrixBytes")] [Export ("matrixBytes")]
nuint MatrixBytes { get; } nuint MatrixBytes { get; }
[TV (13, 0), Mac (10, 15), iOS (13, 1)]
[Export ("offset")]
nuint Offset { get; }
} }
// MPSMatrixMultiplication.h // MPSMatrixMultiplication.h
@ -2089,6 +2093,10 @@ namespace MetalPerformanceShaders {
[TV (11,3), Mac (10,13,4), iOS (11,3)] [TV (11,3), Mac (10,13,4), iOS (11,3)]
[Export ("resourceSize")] [Export ("resourceSize")]
nuint ResourceSize { get; } nuint ResourceSize { get; }
[TV (13, 0), Mac (10, 15), iOS (13, 1)]
[Export ("offset")]
nuint Offset { get; }
} }
[TV (11,0), Mac (10, 13), iOS (11,0)] [TV (11,0), Mac (10, 13), iOS (11,0)]

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

@ -421,6 +421,10 @@ namespace NetworkExtension {
[NoiOS] [NoiOS]
[NullAllowed, Export ("sourceAppAuditToken")] [NullAllowed, Export ("sourceAppAuditToken")]
NSData SourceAppAuditToken { get; } NSData SourceAppAuditToken { get; }
[Mac (10, 15), iOS (13, 1)]
[Export ("identifier")]
NSUuid Identifier { get; }
} }
// according to Xcode7 SDK this was available (in parts) in iOS8 // according to Xcode7 SDK this was available (in parts) in iOS8

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

@ -73,6 +73,7 @@ namespace Photos
[Export ("hidden")] [Export ("hidden")]
bool Hidden { [Bind ("isHidden")] get; } bool Hidden { [Bind ("isHidden")] get; }
[Deprecated (PlatformName.MacOSX, 10, 15, message: "No longer supported.")]
[NoTV][NoiOS] [NoTV][NoiOS]
[Export ("syncFailureHidden")] [Export ("syncFailureHidden")]
bool SyncFailureHidden { [Bind ("isSyncFailureHidden")] get; } bool SyncFailureHidden { [Bind ("isSyncFailureHidden")] get; }

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

@ -873,8 +873,9 @@ namespace StoreKit {
[Mac (10,15)] [Mac (10,15)]
delegate void SKArcadeServiceSubscriptionHandler (NSData subscriptionStatus, uint /* uint32_t */ subscriptionStatusLength, NSData cmacOfNonce, uint /* uint32_t */ cmacOfNonceLength, NSError error); delegate void SKArcadeServiceSubscriptionHandler (NSData subscriptionStatus, uint /* uint32_t */ subscriptionStatusLength, NSData cmacOfNonce, uint /* uint32_t */ cmacOfNonceLength, NSError error);
[NoiOS][NoTV]
[Mac (10,15)] [Mac (10,15)]
[iOS (13,0)]
[TV (13,0)]
[BaseType (typeof (NSObject))] [BaseType (typeof (NSObject))]
[DisableDefaultCtor] // all static members so far [DisableDefaultCtor] // all static members so far
interface SKArcadeService { interface SKArcadeService {

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

@ -3437,12 +3437,26 @@ namespace UIKit {
[Export ("application:viewControllerWithRestorationIdentifierPath:coder:")] [Export ("application:viewControllerWithRestorationIdentifierPath:coder:")]
UIViewController GetViewController (UIApplication application, string [] restorationIdentifierComponents, NSCoder coder); UIViewController GetViewController (UIApplication application, string [] restorationIdentifierComponents, NSCoder coder);
[Deprecated (PlatformName.iOS, 13, 2, message: "Use 'ShouldSaveSecureApplicationState' instead.")]
[Deprecated (PlatformName.TvOS, 13, 2, message: "Use 'ShouldSaveSecureApplicationState' instead.")]
[Export ("application:shouldSaveApplicationState:")] [Export ("application:shouldSaveApplicationState:")]
bool ShouldSaveApplicationState (UIApplication application, NSCoder coder); bool ShouldSaveApplicationState (UIApplication application, NSCoder coder);
[iOS (13,2)]
[TV (13,2)]
[Export ("application:shouldSaveSecureApplicationState:")]
bool ShouldSaveSecureApplicationState (UIApplication application, NSCoder coder);
[Deprecated (PlatformName.iOS, 13, 2, message: "Use 'ShouldRestoreSecureApplicationState' instead.")]
[Deprecated (PlatformName.TvOS, 13, 2, message: "Use 'ShouldRestoreSecureApplicationState' instead.")]
[Export ("application:shouldRestoreApplicationState:")] [Export ("application:shouldRestoreApplicationState:")]
bool ShouldRestoreApplicationState (UIApplication application, NSCoder coder); bool ShouldRestoreApplicationState (UIApplication application, NSCoder coder);
[iOS (13,2)]
[TV (13,2)]
[Export ("application:shouldRestoreSecureApplicationState:")]
bool ShouldRestoreSecureApplicationState (UIApplication application, NSCoder coder);
[Export ("application:willEncodeRestorableStateWithCoder:")] [Export ("application:willEncodeRestorableStateWithCoder:")]
void WillEncodeRestorableState (UIApplication application, NSCoder coder); void WillEncodeRestorableState (UIApplication application, NSCoder coder);
@ -20838,89 +20852,6 @@ namespace UIKit {
UITabBarItemStateAppearance Focused { get; } UITabBarItemStateAppearance Focused { get; }
} }
[NoWatch, TV (13,0), iOS (13,0)]
[BaseType (typeof (NSObject))]
interface NSDiffableDataSourceSnapshot<SectionIdentifierType, ItemIdentifierType> : NSCopying
where SectionIdentifierType : NSObject
where ItemIdentifierType : NSObject {
[Export ("numberOfItems")]
nint NumberOfItems { get; }
[Export ("numberOfSections")]
nint NumberOfSections { get; }
[Export ("sectionIdentifiers")]
SectionIdentifierType [] SectionIdentifiers { get; }
[Export ("itemIdentifiers")]
ItemIdentifierType [] ItemIdentifiers { get; }
[Export ("numberOfItemsInSection:")]
nint GetNumberOfItems (SectionIdentifierType sectionIdentifier);
[Export ("itemIdentifiersInSectionWithIdentifier:")]
ItemIdentifierType [] GetItemIdentifiersInSection (SectionIdentifierType sectionIdentifier);
[Export ("sectionIdentifierForSectionContainingItemIdentifier:")]
[return: NullAllowed]
SectionIdentifierType GetSectionIdentifierForSection (ItemIdentifierType itemIdentifier);
[Export ("indexOfItemIdentifier:")]
nint GetIndex (ItemIdentifierType itemIdentifier);
[Export ("indexOfSectionIdentifier:")]
nint GetIndex (SectionIdentifierType sectionIdentifier);
[Export ("appendItemsWithIdentifiers:")]
void AppendItems (ItemIdentifierType [] identifiers);
[Export ("appendItemsWithIdentifiers:intoSectionWithIdentifier:")]
void AppendItems (ItemIdentifierType [] identifiers, SectionIdentifierType sectionIdentifier);
[Export ("insertItemsWithIdentifiers:beforeItemWithIdentifier:")]
void InsertItemsBefore (ItemIdentifierType [] identifiers, ItemIdentifierType itemIdentifier);
[Export ("insertItemsWithIdentifiers:afterItemWithIdentifier:")]
void InsertItemsAfter (ItemIdentifierType [] identifiers, ItemIdentifierType itemIdentifier);
[Export ("deleteItemsWithIdentifiers:")]
void DeleteItems (ItemIdentifierType [] identifiers);
[Export ("deleteAllItems")]
void DeleteAllItems ();
[Export ("moveItemWithIdentifier:beforeItemWithIdentifier:")]
void MoveItemBefore (ItemIdentifierType fromIdentifier, ItemIdentifierType toIdentifier);
[Export ("moveItemWithIdentifier:afterItemWithIdentifier:")]
void MoveItemAfter (ItemIdentifierType fromIdentifier, ItemIdentifierType toIdentifier);
[Export ("reloadItemsWithIdentifiers:")]
void ReloadItems (ItemIdentifierType [] identifiers);
[Export ("appendSectionsWithIdentifiers:")]
void AppendSections (SectionIdentifierType [] sectionIdentifiers);
[Export ("insertSectionsWithIdentifiers:beforeSectionWithIdentifier:")]
void InsertSectionsBefore (SectionIdentifierType [] sectionIdentifiers, SectionIdentifierType toSectionIdentifier);
[Export ("insertSectionsWithIdentifiers:afterSectionWithIdentifier:")]
void InsertSectionsAfter (SectionIdentifierType [] sectionIdentifiers, SectionIdentifierType toSectionIdentifier);
[Export ("deleteSectionsWithIdentifiers:")]
void DeleteSections (SectionIdentifierType [] sectionIdentifiers);
[Export ("moveSectionWithIdentifier:beforeSectionWithIdentifier:")]
void MoveSectionBefore (SectionIdentifierType fromSectionIdentifier, SectionIdentifierType toSectionIdentifier);
[Export ("moveSectionWithIdentifier:afterSectionWithIdentifier:")]
void MoveSectionAfter (SectionIdentifierType fromSectionIdentifier, SectionIdentifierType toSectionIdentifier);
[Export ("reloadSectionsWithIdentifiers:")]
void ReloadSections (SectionIdentifierType [] sectionIdentifiers);
}
[NoWatch, TV (13,0), iOS (13,0)] [NoWatch, TV (13,0), iOS (13,0)]
delegate UICollectionViewCell UICollectionViewDiffableDataSourceCellProvider (UICollectionView collectionView, NSIndexPath indexPath, NSObject obj); delegate UICollectionViewCell UICollectionViewDiffableDataSourceCellProvider (UICollectionView collectionView, NSIndexPath indexPath, NSObject obj);

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

@ -515,6 +515,14 @@ namespace WatchKit {
[Watch (6,0)][NoiOS] [Watch (6,0)][NoiOS]
[Export ("supportsAudioStreaming")] [Export ("supportsAudioStreaming")]
bool SupportsAudioStreaming { get; } bool SupportsAudioStreaming { get; }
[Watch (6,1)][NoiOS]
[Export ("enableWaterLock")]
void EnableWaterLock ();
[Watch (6,1)][NoiOS]
[Export ("isWaterLockEnabled")]
bool IsWaterLockEnabled { get; }
} }
[iOS (8,2)] [iOS (8,2)]
@ -704,6 +712,18 @@ namespace WatchKit {
[Export ("removeAllAnnotations")] [Export ("removeAllAnnotations")]
void RemoveAllAnnotations (); void RemoveAllAnnotations ();
[Watch (6,1)]
[Export ("setShowsUserHeading:")]
void SetShowsUserHeading (bool showsUserHeading);
[Watch (6,1)]
[Export ("setShowsUserLocation:")]
void SetShowsUserLocation (bool showsUserLocation);
[Watch (6,1)]
[Export ("setUserTrackingMode:animated:")]
void SetUserTrackingMode (WKInterfaceMapUserTrackingMode mode, bool animated);
} }
[iOS (8,2)] [iOS (8,2)]
@ -983,6 +1003,7 @@ namespace WatchKit {
[Watch (4,0)] [Watch (4,0)]
[Export ("enableWaterLock")] [Export ("enableWaterLock")]
[Deprecated (PlatformName.WatchOS, 6,1, message: "Use WKInterfaceDevice.EnableWaterLock ()")]
void EnableWaterLock (); void EnableWaterLock ();
[Watch (6,0)] [Watch (6,0)]
@ -1576,6 +1597,20 @@ namespace WatchKit {
Companion, Companion,
} }
[Watch (6,1), NoiOS]
[Native]
enum WKInterfaceAuthorizationAppleIdButtonStyle: long {
Default,
White,
}
[Watch (6,1), NoiOS]
[Native]
enum WKInterfaceMapUserTrackingMode: long {
None,
Follow,
}
interface IWKExtendedRuntimeSessionDelegate {} interface IWKExtendedRuntimeSessionDelegate {}
[Watch (6,0), NoiOS] [Watch (6,0), NoiOS]
@ -1637,9 +1672,13 @@ namespace WatchKit {
[BaseType (typeof (WKInterfaceObject), Name = "WKInterfaceAuthorizationAppleIDButton")] [BaseType (typeof (WKInterfaceObject), Name = "WKInterfaceAuthorizationAppleIDButton")]
[DisableDefaultCtor] // Handle is `nil` [DisableDefaultCtor] // Handle is `nil`
interface WKInterfaceAuthorizationAppleIdButton { interface WKInterfaceAuthorizationAppleIdButton {
[Export ("initWithTarget:action:")] [Export ("initWithTarget:action:")]
[Deprecated (PlatformName.WatchOS, 6,1, message: "Use 'new WKInterfaceAuthorizationAppleIdButton (WKInterfaceVolumeControlOrigin,NSObject,Selector)' instead.")]
IntPtr Constructor ([NullAllowed] NSObject target, Selector action); IntPtr Constructor ([NullAllowed] NSObject target, Selector action);
[Watch (6,1)]
[Export ("initWithStyle:target:action:")]
IntPtr Constructor (WKInterfaceAuthorizationAppleIdButtonStyle style, [NullAllowed] NSObject target, Selector action);
} }
[Watch (6,0), NoiOS] [Watch (6,0), NoiOS]

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

@ -1190,4 +1190,87 @@ namespace UIKit {
[Export ("layoutManager:shouldSetLineFragmentRect:lineFragmentUsedRect:baselineOffset:inTextContainer:forGlyphRange:")] [Export ("layoutManager:shouldSetLineFragmentRect:lineFragmentUsedRect:baselineOffset:inTextContainer:forGlyphRange:")]
bool ShouldSetLineFragmentRect (NSLayoutManager layoutManager, ref CGRect lineFragmentRect, ref CGRect lineFragmentUsedRect, ref nfloat baselineOffset, NSTextContainer textContainer, NSRange glyphRange); bool ShouldSetLineFragmentRect (NSLayoutManager layoutManager, ref CGRect lineFragmentRect, ref CGRect lineFragmentUsedRect, ref nfloat baselineOffset, NSTextContainer textContainer, NSRange glyphRange);
} }
[NoWatch, TV (13,0), Mac (10,15), iOS (13,0)]
[BaseType (typeof (NSObject))]
interface NSDiffableDataSourceSnapshot<SectionIdentifierType, ItemIdentifierType> : NSCopying
where SectionIdentifierType : NSObject
where ItemIdentifierType : NSObject {
[Export ("numberOfItems")]
nint NumberOfItems { get; }
[Export ("numberOfSections")]
nint NumberOfSections { get; }
[Export ("sectionIdentifiers")]
SectionIdentifierType [] SectionIdentifiers { get; }
[Export ("itemIdentifiers")]
ItemIdentifierType [] ItemIdentifiers { get; }
[Export ("numberOfItemsInSection:")]
nint GetNumberOfItems (SectionIdentifierType sectionIdentifier);
[Export ("itemIdentifiersInSectionWithIdentifier:")]
ItemIdentifierType [] GetItemIdentifiersInSection (SectionIdentifierType sectionIdentifier);
[Export ("sectionIdentifierForSectionContainingItemIdentifier:")]
[return: NullAllowed]
SectionIdentifierType GetSectionIdentifierForSection (ItemIdentifierType itemIdentifier);
[Export ("indexOfItemIdentifier:")]
nint GetIndex (ItemIdentifierType itemIdentifier);
[Export ("indexOfSectionIdentifier:")]
nint GetIndex (SectionIdentifierType sectionIdentifier);
[Export ("appendItemsWithIdentifiers:")]
void AppendItems (ItemIdentifierType [] identifiers);
[Export ("appendItemsWithIdentifiers:intoSectionWithIdentifier:")]
void AppendItems (ItemIdentifierType [] identifiers, SectionIdentifierType sectionIdentifier);
[Export ("insertItemsWithIdentifiers:beforeItemWithIdentifier:")]
void InsertItemsBefore (ItemIdentifierType [] identifiers, ItemIdentifierType itemIdentifier);
[Export ("insertItemsWithIdentifiers:afterItemWithIdentifier:")]
void InsertItemsAfter (ItemIdentifierType [] identifiers, ItemIdentifierType itemIdentifier);
[Export ("deleteItemsWithIdentifiers:")]
void DeleteItems (ItemIdentifierType [] identifiers);
[Export ("deleteAllItems")]
void DeleteAllItems ();
[Export ("moveItemWithIdentifier:beforeItemWithIdentifier:")]
void MoveItemBefore (ItemIdentifierType fromIdentifier, ItemIdentifierType toIdentifier);
[Export ("moveItemWithIdentifier:afterItemWithIdentifier:")]
void MoveItemAfter (ItemIdentifierType fromIdentifier, ItemIdentifierType toIdentifier);
[Export ("reloadItemsWithIdentifiers:")]
void ReloadItems (ItemIdentifierType [] identifiers);
[Export ("appendSectionsWithIdentifiers:")]
void AppendSections (SectionIdentifierType [] sectionIdentifiers);
[Export ("insertSectionsWithIdentifiers:beforeSectionWithIdentifier:")]
void InsertSectionsBefore (SectionIdentifierType [] sectionIdentifiers, SectionIdentifierType toSectionIdentifier);
[Export ("insertSectionsWithIdentifiers:afterSectionWithIdentifier:")]
void InsertSectionsAfter (SectionIdentifierType [] sectionIdentifiers, SectionIdentifierType toSectionIdentifier);
[Export ("deleteSectionsWithIdentifiers:")]
void DeleteSections (SectionIdentifierType [] sectionIdentifiers);
[Export ("moveSectionWithIdentifier:beforeSectionWithIdentifier:")]
void MoveSectionBefore (SectionIdentifierType fromSectionIdentifier, SectionIdentifierType toSectionIdentifier);
[Export ("moveSectionWithIdentifier:afterSectionWithIdentifier:")]
void MoveSectionAfter (SectionIdentifierType fromSectionIdentifier, SectionIdentifierType toSectionIdentifier);
[Export ("reloadSectionsWithIdentifiers:")]
void ReloadSections (SectionIdentifierType [] sectionIdentifiers);
}
} }

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

@ -386,6 +386,11 @@ vsts-device-tests: xharness/xharness.exe
ifdef ENABLE_XAMARIN ifdef ENABLE_XAMARIN
wrench-launch-external wrench-report-external: wrench-launch-external wrench-report-external:
$(MAKE) -C $(MACCORE_PATH)/tests/external $@ $(MAKE) -C $(MACCORE_PATH)/tests/external $@
# This will schedule a manual device test run for the current commit. The current commit must already have packages.
launch-manual-device-tests:
./launch-manual-device-tests.sh
else else
wrench-launch-external wrench-report-external: wrench-launch-external wrench-report-external:
@echo "External tests have been disabled" @echo "External tests have been disabled"

Некоторые файлы не были показаны из-за слишком большого количества измененных файлов Показать больше