xamarin-macios/tests/test-libraries/libtest.h

301 строка
11 KiB
C
Исходник Обычный вид История

2016-04-26 15:00:35 +03:00
#import <Foundation/Foundation.h>
#include <simd/simd.h>
[ObjCRuntime] Don't double-retain blocks. (#3717) * [ObjCRuntime] Don't double-retain blocks. First there was darkness; no blocks were retained. Then came the light; and all blocks were retained [1] Forever. But all that once is, must one day not be, and thus the light gave way to darkness, and blocks were only retained as long as need be [2]. But before there was a balance, there was a crossroad. In some places the light shone forever, and all blocks were retained. In other places there was a balance, and the light shone only as long as needed. A desire to unify arose. Alas, it could not be. It was a bright and sunny day When a merge failed [3]. And all blocks were retained. Twice. Once [here][4] and once [there][5]. For many years we could not see. Until a dark and rainy night, when an awareness arose. And the desire to unify the balance could finally be fulfilled. [1]: https://github.com/xamarin/maccore/commit/6efca92acb5d0f2b1b495a40ac2e89586200d206 [2]: https://github.com/xamarin/maccore/commit/a22f877539058b889555ae4decae0f2e9aca029c [3]: https://github.com/xamarin/maccore/commit/befa0477cf9f3c9602d3fda6b9dee65e5bba506f [4]: https://github.com/xamarin/xamarin-macios/blob/5158a3c00138ae9bc45979487ca6a0fbc3fccc4d/src/ObjCRuntime/Runtime.cs#L858 [5]: https://github.com/xamarin/xamarin-macios/blob/5158a3c00138ae9bc45979487ca6a0fbc3fccc4d/runtime/runtime.m#L2091 * [tests] Fix test builds. * [monotouch-test] RegistrarTest.BlockCollection: allocate more and wait longer for the GC. Allocate more objects and wait longer for the GC to run. Hopefully fixes this problem: [FAIL] RegistrarTest.BlockCollection : freed blocks Expected: greater than 0 But was: 0 The blocks are freed if we just wait long enough... The problem is that we don't want to wait very long (makes the tests slow to run), so try to speed things up by allocating more.
2018-03-13 14:30:32 +03:00
#include <libkern/OSAtomic.h>
2016-04-26 15:00:35 +03:00
#include "rename.h"
#if !TARGET_OS_WATCH
#import <ModelIO/ModelIO.h>
#endif
[SceneKit] Fix SCNMatrix4 in .NET. Fixes #15094. (#15160) When we changed SCNMatrix4 to be column-major instead of row-major in .NET, there were several other related changes we should have done but didn't do. In particular we should have made transformation operations based on column-vectors instead of row-vectors. In legacy Xamarin, a vector would be transformed by a transformation matrix by doing matrix multiplication like this: [ x y z w] * [ 11 21 31 41 ] | 12 22 32 42 | | 13 23 33 43 | [ 14 24 34 41 ] In this case the vector is a row-vector, and it's the left operand in the multiplication. When using column-major matrices, we want to use column-vectors, where the vector is the right operand, like this: [ 11 21 31 41 ] * [ x ] | 12 22 32 42 | | y | | 13 23 33 43 | | z | [ 14 24 34 41 ] [ w ] This affects numerous APIs in SCNMatrix4, SCNVector3 and SCNVector4: * The M## fields have been changed to make the first number the column and the second number the row, to reflect that it's a column-major matrix (this is also how it's defined in the native SCNMatrix4 type). * Functions that return a transformation matrix have been modified to return column-vector transformers. Technically this means that these matrices are transposed compared to legacy Xamarin. The functions involved are: * CreateFromAxisAngle * CreateRotation[X|Y|Z] * CreateTranslation * CreatePerspectiveFieldOfView * CreatePerspectiveOffCenter * Rotate * LookAt * Combining two column-vector transforming transformation matrices is done by multiplying them in the reverse order, so the Mult function (and the multiplication operator) have been modified to multiply the given matrices in the opposite order (this matches how the SCNMatrix4Mult function does it). To make things clearer I've changed the parameter names for XAMCORE_5_0. * Functions that transform a vector using a transformation matrix have been modified to do a column-vector transformation instead of a row-vector transformation. This involves the following functions: * SCNVector3.TransformVector * SCNVector3.TransformNormal * SCNVector3.TransformNormalInverse * SCNVector3.TransformPosition * SCNVector4.Transform * Numerous new tests. Fixes https://github.com/xamarin/xamarin-macios/issues/15094.
2022-06-17 21:17:05 +03:00
#import <SceneKit/SceneKit.h>
2016-04-26 15:00:35 +03:00
#ifdef __cplusplus
extern "C" {
#endif
int theUltimateAnswer ();
void useZLib ();
Optimize calls to BlockLiteral.SetupBlock to inject the block signature. (#3391) * [linker] Optimize calls to BlockLiteral.SetupBlock to inject the block signature. Optimize calls to BlockLiteral.SetupBlock[Unsafe] to calculate the block signature at build time, and inject it into the call site. This makes block invocations 10-15x faster (I've added tests that asserts at least an 8x increase). It's also required in order to be able to remove the dynamic registrar code in the future (since calculating the block signature at runtime requires the dynamic registrar). * [mtouch/mmp] Add support for reporting errors/warnings that point to the code line causing the error/warning. Add support for reporting errors/warnings that point to the code line causing the error/warning by adding ErrorHelper overloads that take the exact instruction to report (previously we defaulted to the first line/instruction in a method). * [tests] Add support for asserting filename/linenumber in warning messages. * Make all methods that manually create BlockLiterals optimizable. * [tests] Create a BaseOptimizeGeneratedCodeTest test that's included in both XI's and XM's link all test. * [tests] Add link all test (for both XI and XM) to test the BlockLiteral.SetupBlock optimization. * [tests] Add mtouch/mmp tests for the BlockLiteral.SetupBlock optimization. * [tests][linker] Make the base test class abstract, so tests in the base class aren't executed twice. * [tests][linker] Don't execute linkall-only tests in linksdk. The optimization tests only apply when the test assembly is linked, and that only happens in linkall, so exclude those tests in linksdk. * [tests][mmptest] Update test according to mmp changes. Fixes these test failures: 1) Failed : Xamarin.MMP.Tests.MMPTests.MM0132("inline-runtime-arch") The warning 'MM0132: Unknown optimization: 'inline-runtime-arch'. Valid optimizations are: remove-uithread-checks, dead-code-elimination, inline-isdirectbinding, inline-intptr-size.' was not found in the output: Message #1 did not match: actual: 'Unknown optimization: 'inline-runtime-arch'. Valid optimizations are: remove-uithread-checks, dead-code-elimination, inline-isdirectbinding, inline-intptr-size, blockliteral-setupblock.' expected: 'Unknown optimization: 'inline-runtime-arch'. Valid optimizations are: remove-uithread-checks, dead-code-elimination, inline-isdirectbinding, inline-intptr-size.' Message #2 did not match: actual: 'Unknown optimization: 'inline-runtime-arch'. Valid optimizations are: remove-uithread-checks, dead-code-elimination, inline-isdirectbinding, inline-intptr-size, blockliteral-setupblock.' expected: 'Unknown optimization: 'inline-runtime-arch'. Valid optimizations are: remove-uithread-checks, dead-code-elimination, inline-isdirectbinding, inline-intptr-size.' 2) Failed : Xamarin.MMP.Tests.MMPTests.MM0132("foo") The warning 'MM0132: Unknown optimization: 'foo'. Valid optimizations are: remove-uithread-checks, dead-code-elimination, inline-isdirectbinding, inline-intptr-size.' was not found in the output: Message #1 did not match: actual: 'Unknown optimization: 'foo'. Valid optimizations are: remove-uithread-checks, dead-code-elimination, inline-isdirectbinding, inline-intptr-size, blockliteral-setupblock.' expected: 'Unknown optimization: 'foo'. Valid optimizations are: remove-uithread-checks, dead-code-elimination, inline-isdirectbinding, inline-intptr-size.' Message #2 did not match: actual: 'Unknown optimization: 'foo'. Valid optimizations are: remove-uithread-checks, dead-code-elimination, inline-isdirectbinding, inline-intptr-size, blockliteral-setupblock.' expected: 'Unknown optimization: 'foo'. Valid optimizations are: remove-uithread-checks, dead-code-elimination, inline-isdirectbinding, inline-intptr-size.' * [tests][linker] Fix typo. Fixes this test failure: 1) SetupBlock_CustomDelegate (Linker.Shared.BaseOptimizeGeneratedCodeTest.SetupBlock_CustomDelegate) Counter Expected: 1 But was: 2 * [registrar] Minor adjustment to error message to match previous (and better) behavior. Fixes this test failure: 1) Failed : Xamarin.Registrar.GenericType_WithInvalidParameterTypes The error 'MT4136: The registrar cannot marshal the parameter type 'System.Collections.Generic.List`1<U>' of the parameter 'arg' in the method 'Open`1.Bar(System.Collections.Generic.List`1<U>)'' was not found in the output: Message #1 did not match: actual: 'The registrar cannot marshal the parameter type 'System.Collections.Generic.List`1<Foundation.NSObject>' of the parameter 'arg' in the method 'Open`1.Bar(System.Collections.Generic.List`1<U>)'' expected: 'The registrar cannot marshal the parameter type 'System.Collections.Generic.List`1<U>' of the parameter 'arg' in the method 'Open`1.Bar(System.Collections.Generic.List`1<U>)'' * [docs] mmp shows MM errors/warnings. * [docs] Improve according to reviews. * [tests] Fix merge failure causing test duplication.
2018-02-06 09:08:15 +03:00
typedef void (^x_block_callback)();
void x_call_block (x_block_callback block);
void* x_call_func_3 (void* (*fptr)(void*, void*, void*), void* p1, void* p2, void* p3);
Optimize calls to BlockLiteral.SetupBlock to inject the block signature. (#3391) * [linker] Optimize calls to BlockLiteral.SetupBlock to inject the block signature. Optimize calls to BlockLiteral.SetupBlock[Unsafe] to calculate the block signature at build time, and inject it into the call site. This makes block invocations 10-15x faster (I've added tests that asserts at least an 8x increase). It's also required in order to be able to remove the dynamic registrar code in the future (since calculating the block signature at runtime requires the dynamic registrar). * [mtouch/mmp] Add support for reporting errors/warnings that point to the code line causing the error/warning. Add support for reporting errors/warnings that point to the code line causing the error/warning by adding ErrorHelper overloads that take the exact instruction to report (previously we defaulted to the first line/instruction in a method). * [tests] Add support for asserting filename/linenumber in warning messages. * Make all methods that manually create BlockLiterals optimizable. * [tests] Create a BaseOptimizeGeneratedCodeTest test that's included in both XI's and XM's link all test. * [tests] Add link all test (for both XI and XM) to test the BlockLiteral.SetupBlock optimization. * [tests] Add mtouch/mmp tests for the BlockLiteral.SetupBlock optimization. * [tests][linker] Make the base test class abstract, so tests in the base class aren't executed twice. * [tests][linker] Don't execute linkall-only tests in linksdk. The optimization tests only apply when the test assembly is linked, and that only happens in linkall, so exclude those tests in linksdk. * [tests][mmptest] Update test according to mmp changes. Fixes these test failures: 1) Failed : Xamarin.MMP.Tests.MMPTests.MM0132("inline-runtime-arch") The warning 'MM0132: Unknown optimization: 'inline-runtime-arch'. Valid optimizations are: remove-uithread-checks, dead-code-elimination, inline-isdirectbinding, inline-intptr-size.' was not found in the output: Message #1 did not match: actual: 'Unknown optimization: 'inline-runtime-arch'. Valid optimizations are: remove-uithread-checks, dead-code-elimination, inline-isdirectbinding, inline-intptr-size, blockliteral-setupblock.' expected: 'Unknown optimization: 'inline-runtime-arch'. Valid optimizations are: remove-uithread-checks, dead-code-elimination, inline-isdirectbinding, inline-intptr-size.' Message #2 did not match: actual: 'Unknown optimization: 'inline-runtime-arch'. Valid optimizations are: remove-uithread-checks, dead-code-elimination, inline-isdirectbinding, inline-intptr-size, blockliteral-setupblock.' expected: 'Unknown optimization: 'inline-runtime-arch'. Valid optimizations are: remove-uithread-checks, dead-code-elimination, inline-isdirectbinding, inline-intptr-size.' 2) Failed : Xamarin.MMP.Tests.MMPTests.MM0132("foo") The warning 'MM0132: Unknown optimization: 'foo'. Valid optimizations are: remove-uithread-checks, dead-code-elimination, inline-isdirectbinding, inline-intptr-size.' was not found in the output: Message #1 did not match: actual: 'Unknown optimization: 'foo'. Valid optimizations are: remove-uithread-checks, dead-code-elimination, inline-isdirectbinding, inline-intptr-size, blockliteral-setupblock.' expected: 'Unknown optimization: 'foo'. Valid optimizations are: remove-uithread-checks, dead-code-elimination, inline-isdirectbinding, inline-intptr-size.' Message #2 did not match: actual: 'Unknown optimization: 'foo'. Valid optimizations are: remove-uithread-checks, dead-code-elimination, inline-isdirectbinding, inline-intptr-size, blockliteral-setupblock.' expected: 'Unknown optimization: 'foo'. Valid optimizations are: remove-uithread-checks, dead-code-elimination, inline-isdirectbinding, inline-intptr-size.' * [tests][linker] Fix typo. Fixes this test failure: 1) SetupBlock_CustomDelegate (Linker.Shared.BaseOptimizeGeneratedCodeTest.SetupBlock_CustomDelegate) Counter Expected: 1 But was: 2 * [registrar] Minor adjustment to error message to match previous (and better) behavior. Fixes this test failure: 1) Failed : Xamarin.Registrar.GenericType_WithInvalidParameterTypes The error 'MT4136: The registrar cannot marshal the parameter type 'System.Collections.Generic.List`1<U>' of the parameter 'arg' in the method 'Open`1.Bar(System.Collections.Generic.List`1<U>)'' was not found in the output: Message #1 did not match: actual: 'The registrar cannot marshal the parameter type 'System.Collections.Generic.List`1<Foundation.NSObject>' of the parameter 'arg' in the method 'Open`1.Bar(System.Collections.Generic.List`1<U>)'' expected: 'The registrar cannot marshal the parameter type 'System.Collections.Generic.List`1<U>' of the parameter 'arg' in the method 'Open`1.Bar(System.Collections.Generic.List`1<U>)'' * [docs] mmp shows MM errors/warnings. * [docs] Improve according to reviews. * [tests] Fix merge failure causing test duplication.
2018-02-06 09:08:15 +03:00
void x_get_matrix_float2x2 (id self, const char *sel, float* r0c0, float* r0c1, float* r1c0, float* r1c1);
void x_get_matrix_float3x3 (id self, const char *sel, float* r0c0, float* r0c1, float* r0c2, float* r1c0, float* r1c1, float* r1c2, float* r2c0, float* r2c1, float* r2c2);
void x_get_matrix_float4x4 (id self, const char *sel, float* r0c0, float* r0c1, float* r0c2, float* r0c3, float* r1c0, float* r1c1, float* r1c2, float* r1c3, float* r2c0, float* r2c1, float* r2c2, float* r2c3, float* r3c0, float* r3c1, float* r3c2, float* r3c3);
void x_get_matrix_float4x3 (id self, const char *sel, float* r0c0, float* r0c1, float* r0c2, float* r0c3, float* r1c0, float* r1c1, float* r1c2, float* r1c3, float* r2c0, float* r2c1, float* r2c2, float* r2c3);
#if !TARGET_OS_WATCH
void x_mdltransformcomponent_get_local_transform (id<MDLTransformComponent> self, NSTimeInterval time, float* r0c0, float* r0c1, float* r0c2, float* r0c3, float* r1c0, float* r1c1, float* r1c2, float* r1c3, float* r2c0, float* r2c1, float* r2c2, float* r2c3, float* r3c0, float* r3c1, float* r3c2, float* r3c3);
void x_mdltransform_create_global_transform (MDLObject *object, NSTimeInterval time, float* r0c0, float* r0c1, float* r0c2, float* r0c3, float* r1c0, float* r1c1, float* r1c2, float* r1c3, float* r2c0, float* r2c1, float* r2c2, float* r2c3, float* r3c0, float* r3c1, float* r3c2, float* r3c3);
void x_mdltransform_get_rotation_matrix (MDLTransform *self, NSTimeInterval time, float* r0c0, float* r0c1, float* r0c2, float* r0c3, float* r1c0, float* r1c1, float* r1c2, float* r1c3, float* r2c0, float* r2c1, float* r2c2, float* r2c3, float* r3c0, float* r3c1, float* r3c2, float* r3c3);
#endif
[SceneKit] Fix SCNMatrix4 in .NET. Fixes #15094. (#15160) When we changed SCNMatrix4 to be column-major instead of row-major in .NET, there were several other related changes we should have done but didn't do. In particular we should have made transformation operations based on column-vectors instead of row-vectors. In legacy Xamarin, a vector would be transformed by a transformation matrix by doing matrix multiplication like this: [ x y z w] * [ 11 21 31 41 ] | 12 22 32 42 | | 13 23 33 43 | [ 14 24 34 41 ] In this case the vector is a row-vector, and it's the left operand in the multiplication. When using column-major matrices, we want to use column-vectors, where the vector is the right operand, like this: [ 11 21 31 41 ] * [ x ] | 12 22 32 42 | | y | | 13 23 33 43 | | z | [ 14 24 34 41 ] [ w ] This affects numerous APIs in SCNMatrix4, SCNVector3 and SCNVector4: * The M## fields have been changed to make the first number the column and the second number the row, to reflect that it's a column-major matrix (this is also how it's defined in the native SCNMatrix4 type). * Functions that return a transformation matrix have been modified to return column-vector transformers. Technically this means that these matrices are transposed compared to legacy Xamarin. The functions involved are: * CreateFromAxisAngle * CreateRotation[X|Y|Z] * CreateTranslation * CreatePerspectiveFieldOfView * CreatePerspectiveOffCenter * Rotate * LookAt * Combining two column-vector transforming transformation matrices is done by multiplying them in the reverse order, so the Mult function (and the multiplication operator) have been modified to multiply the given matrices in the opposite order (this matches how the SCNMatrix4Mult function does it). To make things clearer I've changed the parameter names for XAMCORE_5_0. * Functions that transform a vector using a transformation matrix have been modified to do a column-vector transformation instead of a row-vector transformation. This involves the following functions: * SCNVector3.TransformVector * SCNVector3.TransformNormal * SCNVector3.TransformNormalInverse * SCNVector3.TransformPosition * SCNVector4.Transform * Numerous new tests. Fixes https://github.com/xamarin/xamarin-macios/issues/15094.
2022-06-17 21:17:05 +03:00
#if TARGET_OS_OSX
#define pfloat CGFloat
#else
#define pfloat float
#endif
SCNMatrix4 x_SCNMatrix4MakeTranslation (pfloat tx, pfloat ty, pfloat tz);
SCNMatrix4 x_SCNMatrix4MakeScale (pfloat tx, pfloat ty, pfloat tz);
SCNMatrix4 x_SCNMatrix4Translate (SCNMatrix4 m, pfloat tx, pfloat ty, pfloat tz);
2016-04-26 15:00:35 +03:00
/*
* Various structs used in ObjCRegistrarTest
*/
#include "libtest.structs.h"
2016-04-26 15:00:35 +03:00
typedef unsigned int (^RegistrarTestBlock) (unsigned int magic);
/*
* ObjC test class used for registrar tests.
*/
@interface ObjCRegistrarTest : NSObject {
}
@property int Pi1;
@property int Pi2;
@property int Pi3;
@property int Pi4;
@property int Pi5;
@property int Pi6;
@property int Pi7;
@property int Pi8;
@property int Pi9;
@property float Pf1;
@property float Pf2;
@property float Pf3;
@property float Pf4;
@property float Pf5;
@property float Pf6;
@property float Pf7;
@property float Pf8;
@property float Pf9;
@property double Pd1;
@property double Pd2;
@property double Pd3;
@property double Pd4;
@property double Pd5;
@property double Pd6;
@property double Pd7;
@property double Pd8;
@property double Pd9;
@property char Pc1;
@property char Pc2;
@property char Pc3;
@property char Pc4;
@property char Pc5;
@property (nonatomic, retain) NSObject* someObject;
@property (nonatomic, retain) NSArray* someArray;
#include "libtest.properties.h"
2016-04-26 15:00:35 +03:00
-(void) V;
+(void) staticV;
2016-04-26 15:00:35 +03:00
-(float) F;
-(double) D;
-(struct Sd) Sd;
-(struct Sf) Sf;
-(void) V:(int)i1 i:(int)i2 i:(int)i3 i:(int)i4 i:(int)i5 i:(int)i6 i:(int)i7; // 6 in regs, 7th in mem.
-(void) V:(float)f1 f:(float)f2 f:(float)f3 f:(float)f4 f:(float)f5 f:(float)f6 f:(float)f7 f:(float)f8 f:(float)f9; // 8 in regs, 9th in mem.
-(void) V:(int)i1 i:(int)i2 i:(int)i3 i:(int)i4 i:(int)i5 i:(int)i6 i:(int)i7 f:(float)f1 f:(float)f2 f:(float)f3 f:(float)f4 f:(float)f5 f:(float)f6 f:(float)f7 f:(float)f8 f:(float)f9; // 6 ints in regs, 8 floats in in regs, 1 int in mem, 1 float in mem.
-(void) V:(double)d1 d:(double)d2 d:(double)d3 d:(double)d4 d:(double)d5 d:(double)d6 d:(double)d7 d:(double)d8 d:(double)d9; // 8 in regs, 9th in mem.
-(void) V:(int)i1 i:(int)i2 Siid:(struct Siid)Siid1 i:(int)i3 i:(int)i4 d:(double)d1 d:(double)d2 d:(double)d3 i:(int)i5 i:(int)i6 i:(int)i7;
-(void) V:(int)i1 i:(int)i2 f:(float)f1 Siid:(struct Siid)Siid1 i:(int)i3 i:(int)i4 d:(double)d1 d:(double)d2 d:(double)d3 i:(int)i5 i:(int)i6 i:(int)i7;
-(void) V:(char)c1 c:(char)c2 c:(char)c3 c:(char)c4 c:(char)c5 i:(int)i1 d:(double)d1;
-(void) invoke_V;
-(float) invoke_F;
-(double) invoke_D;
-(struct Sf) Sf_invoke;
-(RegistrarTestBlock) methodReturningBlock;
@property (nonatomic, readonly) RegistrarTestBlock propertyReturningBlock;
-(bool) testBlocks;
-(void) idAsIntPtr: (id)p1;
#include "libtest.methods.h"
-(void) outNSErrorOnStack:(int)i1 i:(int)i2 i:(int)i3 i:(int)i4 i:(int)i5 i:(int)i6 err:(NSError **)err; // 6 in regs, 7th (out) in mem (on all architectures)
-(void) outNSErrorOnStack:(id)obj1 obj:(id)obj2 obj:(id)obj3 int64:(long long)l4 i:(int)i5 err:(NSError **)err; // 5 in regs, 6th (out) in mem (on at least x86-64)
@property (nonatomic, retain) NSArray *stringArrayProperty;
-(void) setStringArrayMethod:(NSArray *) array;
-(NSArray *) getStringArrayMethod;
@property (nonatomic, retain) NSArray *nsobjectArrayProperty;
-(void) setNSObjectArrayMethod: (NSArray *) array;
-(NSArray *) getNSObjectArrayMethod;
@property (nonatomic, retain) NSArray *INSCodingArrayProperty;
-(void) setINSCodingArrayMethod: (NSArray *) array;
-(NSArray *) getINSCodingArrayMethod;
2016-04-26 15:00:35 +03:00
@end
@protocol ProtocolAssignerProtocol
@end
@interface ProtocolAssigner : NSObject {
}
-(void) setProtocol;
-(void) completedSetProtocol: (id<ProtocolAssignerProtocol>) value;
@end
@interface ObjCProtocolTestImpl : NSObject <ProtocolAssignerProtocol>
@end
/*
* ObjC test class used for exception tests.
*/
@interface ObjCExceptionTest : NSObject {
}
-(void) throwObjCException;
-(void) throwManagedException;
-(void) invokeManagedExceptionThrower;
-(void) invokeManagedExceptionThrowerAndRethrow;
-(void) invokeManagedExceptionThrowerAndCatch;
@end
@protocol ObjCProtocolTest
@required
-(void) idAsIntPtr: (id)p1;
@optional
-(void) methodEncodings:
(inout NSObject **) obj1P
obj2: (in NSObject **) obj2P
obj3: (out NSObject **) obj3P
obj4: (const NSObject **) obj4P
obj5: (bycopy NSObject **) obj5P
obj6: (byref NSObject **) obj6P
obj7: (oneway NSObject **) obj7P
;
@end
// We need this class so that the ObjCProtocolTest protocol
// actually ends up in the library.
@interface ObjCProtocolClassTest : NSObject<ObjCProtocolTest> {
}
-(void) idAsIntPtr: (id)p1;
@end
typedef void (^int_callback)(int32_t magic_number);
@protocol ObjCProtocolBlockTest
@required
-(void) requiredCallback: (int_callback)completionHandler;
+(void) requiredStaticCallback: (int_callback)completionHandler;
-(int_callback) requiredReturnValue;
+(int_callback) requiredStaticReturnValue;
@optional
-(void) optionalCallback: (int_callback)completionHandler;
+(void) optionalStaticCallback: (int_callback)completionHandler;
-(int_callback) optionalReturnValue;
+(int_callback) optionalStaticReturnValue;
@end
typedef void (^simple_callback)();
@protocol ProtocolWithBlockProperties
@required
@property simple_callback myRequiredProperty;
@property (class) simple_callback myRequiredStaticProperty;
@optional
@property simple_callback myOptionalProperty;
@property (class) simple_callback myOptionalStaticProperty;
@end
@interface ObjCBlockTester : NSObject {
}
@property (retain) NSObject<ObjCProtocolBlockTest>* TestObject;
@property (class, retain) Class TestClass;
-(void) classCallback: (void (^)(int32_t magic_number))completionHandler;
-(void) callClassCallback;
-(void) callRequiredCallback;
+(void) callRequiredStaticCallback;
-(void) callOptionalCallback;
+(void) callOptionalStaticCallback;
typedef void (^innerBlock) (int magic_number);
typedef void (^outerBlock) (innerBlock callback);
+(void) callAssertMainThreadBlockRelease: (outerBlock) completionHandler;
+(void) callAssertMainThreadBlockReleaseQOS: (outerBlock) completionHandler;
-(void) callAssertMainThreadBlockReleaseCallback;
-(void) callAssertMainThreadBlockReleaseCallbackQOS;
-(void) assertMainThreadBlockReleaseCallback: (innerBlock) completionHandler;
[ObjCRuntime] Don't double-retain blocks. (#3717) * [ObjCRuntime] Don't double-retain blocks. First there was darkness; no blocks were retained. Then came the light; and all blocks were retained [1] Forever. But all that once is, must one day not be, and thus the light gave way to darkness, and blocks were only retained as long as need be [2]. But before there was a balance, there was a crossroad. In some places the light shone forever, and all blocks were retained. In other places there was a balance, and the light shone only as long as needed. A desire to unify arose. Alas, it could not be. It was a bright and sunny day When a merge failed [3]. And all blocks were retained. Twice. Once [here][4] and once [there][5]. For many years we could not see. Until a dark and rainy night, when an awareness arose. And the desire to unify the balance could finally be fulfilled. [1]: https://github.com/xamarin/maccore/commit/6efca92acb5d0f2b1b495a40ac2e89586200d206 [2]: https://github.com/xamarin/maccore/commit/a22f877539058b889555ae4decae0f2e9aca029c [3]: https://github.com/xamarin/maccore/commit/befa0477cf9f3c9602d3fda6b9dee65e5bba506f [4]: https://github.com/xamarin/xamarin-macios/blob/5158a3c00138ae9bc45979487ca6a0fbc3fccc4d/src/ObjCRuntime/Runtime.cs#L858 [5]: https://github.com/xamarin/xamarin-macios/blob/5158a3c00138ae9bc45979487ca6a0fbc3fccc4d/runtime/runtime.m#L2091 * [tests] Fix test builds. * [monotouch-test] RegistrarTest.BlockCollection: allocate more and wait longer for the GC. Allocate more objects and wait longer for the GC to run. Hopefully fixes this problem: [FAIL] RegistrarTest.BlockCollection : freed blocks Expected: greater than 0 But was: 0 The blocks are freed if we just wait long enough... The problem is that we don't want to wait very long (makes the tests slow to run), so try to speed things up by allocating more.
2018-03-13 14:30:32 +03:00
-(void) testFreedBlocks;
+(int) freedBlockCount;
+(void) callProtocolWithBlockProperties: (id<ProtocolWithBlockProperties>) obj required: (bool) required instance: (bool) instance;
+(void) callProtocolWithBlockReturnValue: (id<ObjCProtocolBlockTest>) obj required: (bool) required instance: (bool) instance;
+(void) setProtocolWithBlockProperties: (id<ProtocolWithBlockProperties>) obj required: (bool) required instance: (bool) instance;
+(int) calledBlockCount;
[ObjCRuntime] Don't double-retain blocks. (#3717) * [ObjCRuntime] Don't double-retain blocks. First there was darkness; no blocks were retained. Then came the light; and all blocks were retained [1] Forever. But all that once is, must one day not be, and thus the light gave way to darkness, and blocks were only retained as long as need be [2]. But before there was a balance, there was a crossroad. In some places the light shone forever, and all blocks were retained. In other places there was a balance, and the light shone only as long as needed. A desire to unify arose. Alas, it could not be. It was a bright and sunny day When a merge failed [3]. And all blocks were retained. Twice. Once [here][4] and once [there][5]. For many years we could not see. Until a dark and rainy night, when an awareness arose. And the desire to unify the balance could finally be fulfilled. [1]: https://github.com/xamarin/maccore/commit/6efca92acb5d0f2b1b495a40ac2e89586200d206 [2]: https://github.com/xamarin/maccore/commit/a22f877539058b889555ae4decae0f2e9aca029c [3]: https://github.com/xamarin/maccore/commit/befa0477cf9f3c9602d3fda6b9dee65e5bba506f [4]: https://github.com/xamarin/xamarin-macios/blob/5158a3c00138ae9bc45979487ca6a0fbc3fccc4d/src/ObjCRuntime/Runtime.cs#L858 [5]: https://github.com/xamarin/xamarin-macios/blob/5158a3c00138ae9bc45979487ca6a0fbc3fccc4d/runtime/runtime.m#L2091 * [tests] Fix test builds. * [monotouch-test] RegistrarTest.BlockCollection: allocate more and wait longer for the GC. Allocate more objects and wait longer for the GC to run. Hopefully fixes this problem: [FAIL] RegistrarTest.BlockCollection : freed blocks Expected: greater than 0 But was: 0 The blocks are freed if we just wait long enough... The problem is that we don't want to wait very long (makes the tests slow to run), so try to speed things up by allocating more.
2018-03-13 14:30:32 +03:00
@end
@interface FreedNotifier : NSObject {
}
-(void) dealloc;
@end
@interface EvilDeallocator : NSObject {
}
@property (copy) void (^evilCallback)(int32_t magic_number);
-(void) dealloc;
@end
// This object asserts that its dealloc function is called on the main thread
@interface MainThreadDeallocator : NSObject {
}
-(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 c:(int32_t *) pointerValue;
-(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
@protocol ConstructorProtocol
@required
-(id) initRequired: (NSString *) p0;
@optional
-(id) initOptional: (NSDate *) p0;
@end
@interface TypeProvidingProtocolConstructors : NSObject <ConstructorProtocol> {
}
-(id) initRequired: (NSString *) p0;
-(id) initOptional: (NSDate *) p0;
@property (copy) NSString* stringValue;
@property (copy) NSDate* dateValue;
@end
2016-04-26 15:00:35 +03:00
#ifdef __cplusplus
} /* extern "C" */
#endif