[tests] Add tests for out/ref parameters.
This commit is contained in:
Родитель
6c2121057a
Коммит
b51aaf4b8b
|
@ -47,6 +47,7 @@
|
|||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ObjcBindingApiDefinition Include="ApiDefinition.cs" />
|
||||
<ObjcBindingApiDefinition Include="..\generator\tests\ref-out-parameters.cs" />
|
||||
<ObjcBindingApiDefinition Include="ApiDefinition.generated.cs" />
|
||||
<ObjcBindingApiDefinition Include="ApiProtocol.cs" />
|
||||
</ItemGroup>
|
||||
|
|
|
@ -16,8 +16,8 @@ public static class LibTest {
|
|||
static class LinkWithConstants
|
||||
{
|
||||
#if __WATCHOS__
|
||||
public const string Frameworks = "Foundation";
|
||||
public const string Frameworks = "Foundation CoreLocation";
|
||||
#else
|
||||
public const string Frameworks = "Foundation ModelIO";
|
||||
public const string Frameworks = "Foundation ModelIO CoreLocation";
|
||||
#endif
|
||||
}
|
||||
|
|
|
@ -588,6 +588,12 @@ namespace GeneratorTests
|
|||
[Test]
|
||||
public void GHIssue5692 () => BuildFile (Profile.iOS, "ghissue5692.cs");
|
||||
|
||||
public void RefOutParameters ()
|
||||
{
|
||||
BuildFile (Profile.macOSMobile, true, "tests/ref-out-parameters.cs");
|
||||
|
||||
}
|
||||
|
||||
BGenTool BuildFile (Profile profile, params string [] filenames)
|
||||
{
|
||||
return BuildFile (profile, true, false, filenames);
|
||||
|
|
|
@ -578,6 +578,63 @@ namespace BI1063Tests {
|
|||
bgen.AssertError (1063, "The 'WrapAttribute' can only be used at the property or at getter/setter level at a given time. Property: 'BI1063Tests.Wrappers.PresenceType'");
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void BI1064 ()
|
||||
{
|
||||
var bgen = new BGenTool {
|
||||
Profile = Profile.iOS,
|
||||
ProcessEnums = true
|
||||
};
|
||||
bgen.CreateTemporaryBinding (@"
|
||||
using System;
|
||||
using ObjCRuntime;
|
||||
using Foundation;
|
||||
|
||||
namespace BI1064Errors
|
||||
{
|
||||
[BaseType (typeof (NSObject))]
|
||||
interface C
|
||||
{
|
||||
[Export (""testINativeObjectArray:a:b:"")]
|
||||
void TestINativeObjectArray (int action, ref INativeObject[] refValues, out INativeObject[] outValues);
|
||||
|
||||
[Export (""invalid1:a:"")]
|
||||
void TestInvalid1 (ref DateTime[] refInvalid, out DateTime[] outInvalid);
|
||||
|
||||
[Export (""invalid2:a:"")]
|
||||
void TestInvalid2 (ref object[] refInvalid, out object[] outInvalid);
|
||||
|
||||
[Export (""invalid3:a:"")]
|
||||
void TestInvalid3 (ref int[] refInvalid, out int[] outInvalid);
|
||||
|
||||
[Export (""invalid4:a:"")]
|
||||
void TestInvalid4 (ref object refInvalid, out object outInvalid);
|
||||
|
||||
[Export (""testINativeObject:a:b:"")]
|
||||
void TestINativeObject (int action, ref INativeObject refValue, out INativeObject outValue);
|
||||
|
||||
[Export (""testSelectorArray:a:b:"")] // Can't put SEL into NSArray (SEL isn't an NSObject)
|
||||
void TestSelectorArray (int action, ref Selector[] refValues, out Selector[] outValues);
|
||||
}
|
||||
}");
|
||||
bgen.AssertExecuteError ("build");
|
||||
bgen.AssertError (1064, "Unsupported ref/out parameter type 'ObjCRuntime.INativeObject' for the parameter 'refValue' in BI1064Errors.C.TestINativeObject.");
|
||||
bgen.AssertError (1064, "Unsupported ref/out parameter type 'ObjCRuntime.INativeObject' for the parameter 'outValue' in BI1064Errors.C.TestINativeObject.");
|
||||
bgen.AssertError (1064, "Unsupported ref/out parameter type 'ObjCRuntime.INativeObject[]' for the parameter 'refValues' in BI1064Errors.C.TestINativeObjectArray.");
|
||||
bgen.AssertError (1064, "Unsupported ref/out parameter type 'ObjCRuntime.INativeObject[]' for the parameter 'outValues' in BI1064Errors.C.TestINativeObjectArray.");
|
||||
bgen.AssertError (1064, "Unsupported ref/out parameter type 'System.DateTime[]' for the parameter 'refInvalid' in BI1064Errors.C.TestInvalid1.");
|
||||
bgen.AssertError (1064, "Unsupported ref/out parameter type 'System.DateTime[]' for the parameter 'outInvalid' in BI1064Errors.C.TestInvalid1.");
|
||||
bgen.AssertError (1064, "Unsupported ref/out parameter type 'System.Object[]' for the parameter 'refInvalid' in BI1064Errors.C.TestInvalid2.");
|
||||
bgen.AssertError (1064, "Unsupported ref/out parameter type 'System.Object[]' for the parameter 'refInvalid' in BI1064Errors.C.TestInvalid2.");
|
||||
bgen.AssertError (1064, "Unsupported ref/out parameter type 'System.Int32[]' for the parameter 'outInvalid' in BI1064Errors.C.TestInvalid3.");
|
||||
bgen.AssertError (1064, "Unsupported ref/out parameter type 'System.Int32[]' for the parameter 'outInvalid' in BI1064Errors.C.TestInvalid3.");
|
||||
bgen.AssertError (1064, "Unsupported ref/out parameter type 'System.Object' for the parameter 'refInvalid' in BI1064Errors.C.TestInvalid4.");
|
||||
bgen.AssertError (1064, "Unsupported ref/out parameter type 'System.Object' for the parameter 'refInvalid' in BI1064Errors.C.TestInvalid4.");
|
||||
bgen.AssertError (1064, "Unsupported ref/out parameter type 'ObjCRuntime.Selector[]' for the parameter 'refValues' in BI1064Errors.C.TestSelectorArray.");
|
||||
bgen.AssertError (1064, "Unsupported ref/out parameter type 'ObjCRuntime.Selector[]' for the parameter 'outValues' in BI1064Errors.C.TestSelectorArray.");
|
||||
bgen.AssertErrorCount (14);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void BI1065 ()
|
||||
{
|
||||
|
|
|
@ -70,6 +70,7 @@
|
|||
<ItemGroup>
|
||||
<None Include="tests\is-direct-binding.cs" />
|
||||
<None Include="packages.config" />
|
||||
<None Include="tests\ref-out-parameters.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Folder Include="tests\" />
|
||||
|
|
|
@ -0,0 +1,50 @@
|
|||
using System;
|
||||
using CoreFoundation;
|
||||
using Foundation;
|
||||
using ObjCRuntime;
|
||||
|
||||
namespace BI1064
|
||||
{
|
||||
[BaseType (typeof (NSObject))]
|
||||
interface RefOutParameters
|
||||
{
|
||||
[Export ("testCFBundle:a:b:")]
|
||||
void TestCFBundle (int action, ref CFBundle refValue, out CFBundle outValue);
|
||||
|
||||
[Export ("testINSCoding:a:b:")]
|
||||
void TestINSCoding (int action, ref INSCoding refValue, out INSCoding outValue);
|
||||
|
||||
[Export ("testNSObject:a:b:")]
|
||||
void TestNSObject (int action, ref NSObject refValue, out NSObject outValue);
|
||||
|
||||
[Export ("testNSValue:a:b:")]
|
||||
void TestValue (int action, ref NSValue refValue, out NSValue outValue);
|
||||
|
||||
[Export ("testString:a:b:")]
|
||||
void TestString (int action, ref string refValue, out string outValue);
|
||||
|
||||
[Export ("testInt:a:b:")]
|
||||
void TestInt (int action, ref int refValue, out int outValue);
|
||||
|
||||
[Export ("testSelector:a:b:")]
|
||||
void TestSelector (int action, ref Selector refValue, out Selector outValue);
|
||||
|
||||
[Export ("testClass:a:b:")]
|
||||
void TestClass (int action, ref Class refValue, out Class outValue);
|
||||
|
||||
[Export ("testINSCodingArray:a:b:")]
|
||||
void TestINSCodingArray (int action, ref INSCoding[] refValues, out INSCoding[] outValues);
|
||||
|
||||
[Export ("testNSObjectArray:a:b:")]
|
||||
void TestNSObjectArray (int action, ref NSObject[] refValues, out NSObject[] outValues);
|
||||
|
||||
[Export ("testNSValueArray:a:b:")]
|
||||
void TestNSValueArray (int action, ref NSValue[] refValues, out NSValue[] outValues);
|
||||
|
||||
[Export ("testStringArray:a:b:")]
|
||||
void TestStringArray (int action, ref string[] refStrings, out string[] outStrings);
|
||||
|
||||
[Export ("testClassArray:a:b:")]
|
||||
void TestClassArray (int action, ref Class [] refStrings, out Class [] outStrings);
|
||||
}
|
||||
}
|
|
@ -245,6 +245,15 @@ namespace MonoTouch.ObjCRuntime
|
|||
[DllImport (LIBOBJC_DYLIB, EntryPoint="objc_msgSend_stret")]
|
||||
public extern static void CATransform3D_objc_msgSend_stret (out CATransform3D buf, IntPtr receiver, IntPtr selector);
|
||||
#endif // !__WATCHOS__
|
||||
|
||||
[DllImport (LIBOBJC_DYLIB, EntryPoint = "objc_msgSend")]
|
||||
public extern static void void_objc_msgSend_int_IntPtr_IntPtr (IntPtr receiver, IntPtr selector, int p1, ref IntPtr p2, out IntPtr p3);
|
||||
|
||||
[DllImport (LIBOBJC_DYLIB, EntryPoint = "objc_msgSend")]
|
||||
public extern static void void_objc_msgSend_int_IntPtr_IntPtr (IntPtr receiver, IntPtr selector, int p1, IntPtr p2, IntPtr p3);
|
||||
|
||||
[DllImport (LIBOBJC_DYLIB, EntryPoint = "objc_msgSend")]
|
||||
public extern static void void_objc_msgSend_int_int_int (IntPtr receiver, IntPtr selector, int p1, ref int p2, out int p3);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Разница между файлами не показана из-за своего большого размера
Загрузить разницу
|
@ -227,6 +227,27 @@ typedef void (^outerBlock) (innerBlock callback);
|
|||
-(void) dealloc;
|
||||
@end
|
||||
|
||||
@interface RefOutParameters : NSObject {
|
||||
}
|
||||
-(void) testCFBundle: (int) action a:(CFBundleRef *) refValue b:(CFBundleRef *) outValue;
|
||||
-(void) testINSCoding: (int) action a:(id<NSCoding>*) refValue b:(id<NSCoding>*) outValue;
|
||||
-(void) testNSObject: (int) action a:(id *) refValue b:(id *) outValue;
|
||||
-(void) testNSValue: (int) action a:(NSValue **) refValue b:(NSValue **) outValue;
|
||||
-(void) testString: (int) action a:(NSString **) refValue b:(NSString **) outValue;
|
||||
-(void) testInt: (int) action a:(int32_t *) refValue b:(int32_t *) outValue;
|
||||
-(void) testSelector: (int) action a:(SEL *) refValue b:(SEL *) outValue;
|
||||
-(void) testClass: (int) action a:(Class *) refValue b:(Class *) outValue;
|
||||
|
||||
-(void) testINSCodingArray: (int) action a:(NSArray **) refValue b:(NSArray **) outValue;
|
||||
-(void) testNSObjectArray: (int) action a:(NSArray **) refValue b:(NSArray **) outValue;
|
||||
-(void) testNSValueArray: (int) action a:(NSArray **) refValue b:(NSArray **) outValue;
|
||||
-(void) testStringArray: (int) action a:(NSArray **) refValue b:(NSArray **) outValue;
|
||||
// SEL can't be put into an NSArray, since it's not an NSObject.
|
||||
-(void) testClassArray: (int) action a:(NSArray **) refValue b:(NSArray **) outValue;
|
||||
// Class isn't an NSObject either, but it quacks like one, so it's possible to put them in NSArrays.
|
||||
// And Apple does (see UIAppearance appearanceWhenContainedInInstancesOfClasses for an example).
|
||||
@end
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /* extern "C" */
|
||||
#endif
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
#import <Foundation/Foundation.h>
|
||||
#import <MapKit/MapKit.h>
|
||||
|
||||
#include <objc/objc.h>
|
||||
#include <objc/runtime.h>
|
||||
|
@ -781,4 +782,439 @@ static void block_called ()
|
|||
}
|
||||
@end
|
||||
|
||||
@implementation RefOutParameters : NSObject {
|
||||
}
|
||||
-(void) testCFBundle: (int) action a:(CFBundleRef *) refValue b:(CFBundleRef *) outValue
|
||||
{
|
||||
// We should never get null pointers.
|
||||
assert (refValue != NULL);
|
||||
assert (outValue != NULL);
|
||||
|
||||
// out parameters from managed code should always be NULL upon entry
|
||||
assert (*outValue == NULL);
|
||||
|
||||
switch (action & 0xFF) {
|
||||
case 1: // Set both to null
|
||||
*refValue = NULL;
|
||||
*outValue = NULL;
|
||||
break;
|
||||
case 2: // verify that refValue points to something
|
||||
assert (*refValue != NULL);
|
||||
break;
|
||||
case 3: // set both parameteres to the same pointer of a CFBundle
|
||||
*refValue = CFBundleGetMainBundle ();
|
||||
*outValue = CFBundleGetMainBundle ();
|
||||
break;
|
||||
case 4: // set both parameteres to different pointers of a CFBundle
|
||||
*refValue = (CFBundleRef) CFArrayGetValueAtIndex (CFBundleGetAllBundles (), 0);
|
||||
*outValue = (CFBundleRef) CFArrayGetValueAtIndex (CFBundleGetAllBundles (), 1);
|
||||
break;
|
||||
default:
|
||||
abort ();
|
||||
}
|
||||
}
|
||||
|
||||
-(void) testINSCoding: (int) action a:(id<NSCoding>*) refValue b:(id<NSCoding>*) outValue
|
||||
{
|
||||
NSString *str = NULL;
|
||||
|
||||
// We should never get null pointers.
|
||||
assert (refValue != NULL);
|
||||
assert (outValue != NULL);
|
||||
|
||||
// out parameters from managed code should always be NULL upon entry
|
||||
assert (*outValue == NULL);
|
||||
|
||||
switch (action & 0xFF) {
|
||||
case 1: // Set both to null
|
||||
*refValue = NULL;
|
||||
*outValue = NULL;
|
||||
break;
|
||||
case 2: // verify that refValue points to something
|
||||
assert (*refValue != NULL);
|
||||
break;
|
||||
case 3: // set both parameteres to the same pointer of an NSString (which implements NSCoding)
|
||||
str = @"Some static string";
|
||||
*refValue = str;
|
||||
*outValue = str;
|
||||
return;
|
||||
case 4: // set both parameteres to different pointers of an NSString
|
||||
*refValue = @"A static string for ref";
|
||||
*outValue = @"A static string for out";
|
||||
break;
|
||||
default:
|
||||
abort ();
|
||||
}
|
||||
}
|
||||
|
||||
-(void) testNSObject: (int) action a:(id *) refValue b:(id *) outValue
|
||||
{
|
||||
NSObject *obj = NULL;
|
||||
|
||||
// We should never get null pointers.
|
||||
assert (refValue != NULL);
|
||||
assert (outValue != NULL);
|
||||
|
||||
// out parameters from managed code should always be NULL upon entry
|
||||
assert (*outValue == NULL);
|
||||
|
||||
switch (action & 0xFF) {
|
||||
case 1: // Set both to null
|
||||
*refValue = NULL;
|
||||
*outValue = NULL;
|
||||
break;
|
||||
case 2: // verify that refValue points to something
|
||||
assert (*refValue != NULL);
|
||||
break;
|
||||
case 3: // set both parameteres to the same pointer of an NSObject
|
||||
obj = [NSObject new];
|
||||
*refValue = obj;
|
||||
*outValue = obj;
|
||||
return;
|
||||
case 4: // set both parameteres to different objects
|
||||
*refValue = [NSObject new];
|
||||
*outValue = [NSObject new];
|
||||
break;
|
||||
default:
|
||||
abort ();
|
||||
}
|
||||
}
|
||||
|
||||
-(void) testNSValue: (int) action a:(NSValue **) refValue b:(NSValue **) outValue
|
||||
{
|
||||
NSValue *obj = NULL;
|
||||
|
||||
// We should never get null pointers.
|
||||
assert (refValue != NULL);
|
||||
assert (outValue != NULL);
|
||||
|
||||
// out parameters from managed code should always be NULL upon entry
|
||||
assert (*outValue == NULL);
|
||||
|
||||
switch (action & 0xFF) {
|
||||
case 1: // Set both to null
|
||||
*refValue = NULL;
|
||||
*outValue = NULL;
|
||||
break;
|
||||
case 2: // verify that refValue points to something
|
||||
assert (*refValue != NULL);
|
||||
break;
|
||||
case 3: // set both parameteres to the same pointer of an NSValue
|
||||
obj = [NSValue valueWithMKCoordinate: CLLocationCoordinate2DMake (3, 14)];
|
||||
*refValue = obj;
|
||||
*outValue = obj;
|
||||
return;
|
||||
case 4: // set both parameteres to different objects
|
||||
*refValue = [NSValue valueWithMKCoordinate: CLLocationCoordinate2DMake (3, 14)];
|
||||
*outValue = [NSValue valueWithMKCoordinate: CLLocationCoordinate2DMake (2, 71)];
|
||||
break;
|
||||
default:
|
||||
abort ();
|
||||
}
|
||||
}
|
||||
|
||||
-(void) testString: (int) action a:(NSString **) refValue b:(NSString **) outValue
|
||||
{
|
||||
NSString *obj = NULL;
|
||||
|
||||
// We should never get null pointers.
|
||||
assert (refValue != NULL);
|
||||
assert (outValue != NULL);
|
||||
|
||||
// out parameters from managed code should always be NULL upon entry
|
||||
assert (*outValue == NULL);
|
||||
|
||||
switch (action & 0xFF) {
|
||||
case 1: // Set both to null
|
||||
*refValue = NULL;
|
||||
*outValue = NULL;
|
||||
break;
|
||||
case 2: // verify that refValue points to something
|
||||
assert (*refValue != NULL);
|
||||
break;
|
||||
case 3: // set both parameteres to the same pointer of an NSString
|
||||
obj = @"A constant native string";
|
||||
*refValue = obj;
|
||||
*outValue = obj;
|
||||
return;
|
||||
case 4: // set both parameteres to different objects
|
||||
*refValue = [NSString stringWithUTF8String: "Hello Xamarin"];
|
||||
*outValue = [NSString stringWithUTF8String: "Hello Microsoft"];
|
||||
break;
|
||||
default:
|
||||
abort ();
|
||||
}
|
||||
}
|
||||
|
||||
-(void) testInt: (int) action a:(int32_t *) refValue b:(int32_t *) outValue
|
||||
{
|
||||
NSString *obj = NULL;
|
||||
|
||||
// We should never get null pointers.
|
||||
assert (refValue != NULL);
|
||||
assert (outValue != NULL);
|
||||
|
||||
switch (action & 0xFF) {
|
||||
case 1: // Set both to 0
|
||||
*refValue = 0;
|
||||
*outValue = 0;
|
||||
break;
|
||||
case 3: // set both parameteres to the same value
|
||||
obj = @"A constant native string";
|
||||
*refValue = 314159;
|
||||
*outValue = 314159;
|
||||
return;
|
||||
case 4: // set both parameteres to different objects
|
||||
*refValue = 3141592;
|
||||
*outValue = 2718282;
|
||||
break;
|
||||
default:
|
||||
abort ();
|
||||
}
|
||||
}
|
||||
|
||||
-(void) testSelector: (int) action a:(SEL *) refValue b:(SEL *) outValue
|
||||
{
|
||||
SEL obj = NULL;
|
||||
|
||||
// We should never get null pointers.
|
||||
assert (refValue != NULL);
|
||||
assert (outValue != NULL);
|
||||
|
||||
// out parameters from managed code should always be NULL upon entry
|
||||
assert (*outValue == NULL);
|
||||
|
||||
switch (action & 0xFF) {
|
||||
case 1: // Set both to null
|
||||
*refValue = NULL;
|
||||
*outValue = NULL;
|
||||
break;
|
||||
case 2: // verify that refValue points to something
|
||||
assert (*refValue != NULL);
|
||||
break;
|
||||
case 3: // set both parameteres to the same selector
|
||||
obj = @selector (testSelector);
|
||||
*refValue = obj;
|
||||
*outValue = obj;
|
||||
return;
|
||||
case 4: // set both parameteres to different selectors
|
||||
*refValue = @selector (testSelector:a:);
|
||||
*outValue = @selector (testSelector:b:);
|
||||
break;
|
||||
default:
|
||||
abort ();
|
||||
}
|
||||
}
|
||||
|
||||
-(void) testClass: (int) action a:(Class *) refValue b:(Class *) outValue
|
||||
{
|
||||
Class obj = NULL;
|
||||
|
||||
// We should never get null pointers.
|
||||
assert (refValue != NULL);
|
||||
assert (outValue != NULL);
|
||||
|
||||
// out parameters from managed code should always be NULL upon entry
|
||||
assert (*outValue == NULL);
|
||||
|
||||
switch (action & 0xFF) {
|
||||
case 1: // Set both to null
|
||||
*refValue = NULL;
|
||||
*outValue = NULL;
|
||||
break;
|
||||
case 2: // verify that refValue points to something
|
||||
assert (*refValue != NULL);
|
||||
break;
|
||||
case 3: // set both parameteres to the same class
|
||||
obj = [NSString class];
|
||||
*refValue = obj;
|
||||
*outValue = obj;
|
||||
return;
|
||||
case 4: // set both parameteres to different classes
|
||||
*refValue = [NSBundle class];
|
||||
*outValue = [NSDate class];
|
||||
break;
|
||||
default:
|
||||
abort ();
|
||||
}
|
||||
}
|
||||
|
||||
-(void) testINSCodingArray: (int) action a:(NSArray **) refValue b:(NSArray **) outValue
|
||||
{
|
||||
NSArray *arr = NULL;
|
||||
|
||||
// We should never get null pointers.
|
||||
assert (refValue != NULL);
|
||||
assert (outValue != NULL);
|
||||
|
||||
// out parameters from managed code should always be NULL upon entry
|
||||
assert (*outValue == NULL);
|
||||
|
||||
switch (action & 0xFF) {
|
||||
case 1: // Set both to null
|
||||
*refValue = NULL;
|
||||
*outValue = NULL;
|
||||
break;
|
||||
case 2: // verify that refValue points to something
|
||||
assert (*refValue != NULL);
|
||||
break;
|
||||
case 3: // set both parameteres to the same pointer of an NSArray of NSString (which implements NSCoding)
|
||||
arr =
|
||||
@[
|
||||
// This looks funny, but it's to ensure we don't get strings that are statically allocated (in which case the same pointer would be returned in multiple calls, which may throw off some of our tests)
|
||||
[[NSString stringWithUTF8String: "Hello"] stringByAppendingString: @"World"],
|
||||
[[NSString stringWithUTF8String: "Hello"] stringByAppendingString: @"Universe"]
|
||||
];
|
||||
*refValue = arr;
|
||||
*outValue = arr;
|
||||
return;
|
||||
case 4: // set both parameteres to different NSArrays
|
||||
*refValue = @[@3, @14];
|
||||
*outValue = @[[NSString stringWithUTF8String: "Hello"], [NSString stringWithUTF8String: "Xamarin"]];
|
||||
break;
|
||||
default:
|
||||
abort ();
|
||||
}
|
||||
}
|
||||
|
||||
-(void) testNSObjectArray: (int) action a:(NSArray **) refValue b:(NSArray **) outValue
|
||||
{
|
||||
NSArray *arr = NULL;
|
||||
|
||||
// We should never get null pointers.
|
||||
assert (refValue != NULL);
|
||||
assert (outValue != NULL);
|
||||
|
||||
// out parameters from managed code should always be NULL upon entry
|
||||
assert (*outValue == NULL);
|
||||
|
||||
switch (action & 0xFF) {
|
||||
case 1: // Set both to null
|
||||
*refValue = NULL;
|
||||
*outValue = NULL;
|
||||
break;
|
||||
case 2: // verify that refValue points to something
|
||||
assert (*refValue != NULL);
|
||||
break;
|
||||
case 3: // set both parameteres to the same pointer of an NSArray of NSString
|
||||
arr = @[@"Hello", @"World"];
|
||||
*refValue = arr;
|
||||
*outValue = arr;
|
||||
return;
|
||||
case 4: // set both parameteres to different NSArrays
|
||||
*refValue = @[@3, @14];
|
||||
*outValue = @[@"Hello", @"Xamarin"];
|
||||
break;
|
||||
default:
|
||||
abort ();
|
||||
}
|
||||
}
|
||||
|
||||
-(void) testNSValueArray: (int) action a:(NSArray **) refValue b:(NSArray **) outValue
|
||||
{
|
||||
NSArray *arr = NULL;
|
||||
|
||||
// We should never get null pointers.
|
||||
assert (refValue != NULL);
|
||||
assert (outValue != NULL);
|
||||
|
||||
// out parameters from managed code should always be NULL upon entry
|
||||
assert (*outValue == NULL);
|
||||
|
||||
switch (action & 0xFF) {
|
||||
case 1: // Set both to null
|
||||
*refValue = NULL;
|
||||
*outValue = NULL;
|
||||
break;
|
||||
case 2: // verify that refValue points to something
|
||||
assert (*refValue != NULL);
|
||||
break;
|
||||
case 3: // set both parameteres to the same pointer of an NSArray of NSValue
|
||||
arr = @[[NSValue valueWithMKCoordinate: CLLocationCoordinate2DMake (3, 14)], [NSValue valueWithMKCoordinate: CLLocationCoordinate2DMake (2, 71)]];
|
||||
*refValue = arr;
|
||||
*outValue = arr;
|
||||
return;
|
||||
case 4: // set both parameteres to different NSArrays
|
||||
*refValue = @[[NSValue valueWithMKCoordinate: CLLocationCoordinate2DMake (3, 14)], [NSValue valueWithMKCoordinate: CLLocationCoordinate2DMake (15, 92)]];
|
||||
*outValue = @[[NSValue valueWithMKCoordinate: CLLocationCoordinate2DMake (2, 71)], [NSValue valueWithMKCoordinate: CLLocationCoordinate2DMake (82, 82)]];
|
||||
break;
|
||||
default:
|
||||
abort ();
|
||||
}
|
||||
}
|
||||
|
||||
-(void) testStringArray: (int) action a:(NSArray **) refValue b:(NSArray **) outValue
|
||||
{
|
||||
NSArray *arr = NULL;
|
||||
|
||||
// We should never get null pointers.
|
||||
assert (refValue != NULL);
|
||||
assert (outValue != NULL);
|
||||
|
||||
// out parameters from managed code should always be NULL upon entry
|
||||
assert (*outValue == NULL);
|
||||
|
||||
switch (action & 0xFF) {
|
||||
case 1: // Set both to null
|
||||
*refValue = NULL;
|
||||
*outValue = NULL;
|
||||
break;
|
||||
case 2: // verify that refValue points to something
|
||||
assert (*refValue != NULL);
|
||||
break;
|
||||
case 3: // set both parameteres to the same pointer of an NSArray of NSString
|
||||
arr = @[@"Hello", @"World"];
|
||||
*refValue = arr;
|
||||
*outValue = arr;
|
||||
return;
|
||||
case 4: // set both parameteres to different NSArrays
|
||||
*refValue = @[@"Hello", @"Microsoft"];
|
||||
*outValue = @[@"Hello", @"Xamarin"];
|
||||
break;
|
||||
case 5: // assert that we got an immutable array
|
||||
// We'll never get a mutable array (the binding code creates NSArrays), so assert that.
|
||||
assert (![*refValue isKindOfClass: [NSMutableArray class]]);
|
||||
break;
|
||||
default:
|
||||
abort ();
|
||||
}
|
||||
}
|
||||
|
||||
-(void) testClassArray: (int) action a:(NSArray **) refValue b:(NSArray **) outValue
|
||||
{
|
||||
NSArray *arr = NULL;
|
||||
|
||||
// We should never get null pointers.
|
||||
assert (refValue != NULL);
|
||||
assert (outValue != NULL);
|
||||
|
||||
// out parameters from managed code should always be NULL upon entry
|
||||
assert (*outValue == NULL);
|
||||
|
||||
switch (action & 0xFF) {
|
||||
case 1: // Set both to null
|
||||
*refValue = NULL;
|
||||
*outValue = NULL;
|
||||
break;
|
||||
case 2: // verify that refValue points to something
|
||||
assert (*refValue != NULL);
|
||||
break;
|
||||
case 3: // set both parameteres to the same pointer of an NSArray of NSString
|
||||
arr = @[[NSString class], [NSDate class]];
|
||||
*refValue = arr;
|
||||
*outValue = arr;
|
||||
return;
|
||||
case 4: // set both parameteres to different NSArrays
|
||||
*refValue = @[[NSString class], [NSValue class]];
|
||||
*outValue = @[[NSData class], [NSDate class]];
|
||||
break;
|
||||
case 5: // assert that we got an immutable array
|
||||
// We'll never get a mutable array (the binding code creates NSArrays), so assert that.
|
||||
assert (![*refValue isKindOfClass: [NSMutableArray class]]);
|
||||
break;
|
||||
default:
|
||||
abort ();
|
||||
}
|
||||
}
|
||||
@end
|
||||
#include "libtest.decompile.m"
|
||||
|
|
|
@ -10,6 +10,7 @@
|
|||
#define FakeType2 object_FakeType2
|
||||
#define UltimateMachine object_UltimateMachine
|
||||
#define FrameworkTest object_FrameworkTest
|
||||
#define RefOutParameters object_RefOutParameters
|
||||
#define Sc object_Sc
|
||||
#define Scc object_Scc
|
||||
#define Sccc object_Sccc
|
||||
|
@ -78,6 +79,7 @@
|
|||
#define FakeType2 ar_FakeType2
|
||||
#define UltimateMachine ar_UltimateMachine
|
||||
#define FrameworkTest ar_FrameworkTest
|
||||
#define RefOutParameters ar_RefOutParameters
|
||||
#define Sc ar_Sc
|
||||
#define Scc ar_Scc
|
||||
#define Sccc ar_Sccc
|
||||
|
|
Загрузка…
Ссылка в новой задаче