xamarin-macios/tests/bindings-test/ApiDefinition.cs

326 строки
6.6 KiB
C#
Исходник Обычный вид История

2016-04-26 22:40:23 +03:00
using System;
#if __UNIFIED__
using ObjCRuntime;
using Foundation;
#if __MACOS__
using AppKit;
#else
2016-04-26 22:40:23 +03:00
using UIKit;
#endif
2016-04-26 22:40:23 +03:00
#else
#if !__WATCHOS__
using System.Drawing;
#endif
2016-04-26 22:40:23 +03:00
using MonoTouch.ObjCRuntime;
using MonoTouch.Foundation;
using MonoTouch.UIKit;
#endif
namespace Bindings.Test {
#if __UNIFIED__ && FRAMEWORK_TEST
[BaseType (typeof (NSObject))]
public interface FrameworkTest
{
[Export ("func")]
int Func ();
}
#endif
[BaseType (typeof (NSObject))]
public interface UltimateMachine
{
[Export ("getAnswer")]
int GetAnswer ();
[Export ("sharedInstance")]
[Static]
UltimateMachine SharedInstance { get; }
}
delegate uint RegistrarTestBlock (uint magic);
/*
* ObjC test class used for registrar
*/
[BaseType (typeof (NSObject))]
partial interface ObjCRegistrarTest {
2016-04-26 22:40:23 +03:00
[Export ("Pi1")]
int Pi1 { get; set; }
[Export ("Pi2")]
int Pi2 { get; set; }
[Export ("Pi3")]
int Pi3 { get; set; }
[Export ("Pi4")]
int Pi4 { get; set; }
[Export ("Pi5")]
int Pi5 { get; set; }
[Export ("Pi6")]
int Pi6 { get; set; }
[Export ("Pi7")]
int Pi7 { get; set; }
[Export ("Pi8")]
int Pi8 { get; set; }
[Export ("Pi9")]
int Pi9 { get; set; }
[Export ("Pf1")]
float Pf1 { get; set; }
[Export ("Pf2")]
float Pf2 { get; set; }
[Export ("Pf3")]
float Pf3 { get; set; }
[Export ("Pf4")]
float Pf4 { get; set; }
[Export ("Pf5")]
float Pf5 { get; set; }
[Export ("Pf6")]
float Pf6 { get; set; }
[Export ("Pf7")]
float Pf7 { get; set; }
[Export ("Pf8")]
float Pf8 { get; set; }
[Export ("Pf9")]
float Pf9 { get; set; }
[Export ("Pd1")]
double Pd1 { get; set; }
[Export ("Pd2")]
double Pd2 { get; set; }
[Export ("Pd3")]
double Pd3 { get; set; }
[Export ("Pd4")]
double Pd4 { get; set; }
[Export ("Pd5")]
double Pd5 { get; set; }
[Export ("Pd6")]
double Pd6 { get; set; }
[Export ("Pd7")]
double Pd7 { get; set; }
[Export ("Pd8")]
double Pd8 { get; set; }
[Export ("Pd9")]
double Pd9 { get; set; }
[Export ("Pc1")]
sbyte Pc1 { get; set; }
[Export ("Pc2")]
sbyte Pc2 { get; set; }
[Export ("Pc3")]
sbyte Pc3 { get; set; }
[Export ("Pc4")]
sbyte Pc4 { get; set; }
[Export ("Pc5")]
sbyte Pc5 { get; set; }
[Export ("V")]
void V ();
[Export ("F")]
float F ();
[Export ("D")]
double D ();
[Export ("Sd")]
Sd Sd ();
[Export ("Sf")]
Sf Sf ();
[Export ("V:i:i:i:i:i:i:")]
void V (int i1, int i2, int i3, int i4, int i5, int i6, int i7);
[Export ("V:f:f:f:f:f:f:f:f:")]
void V (float f1, float f2, float f3, float f4, float f5, float f6, float f7, float f8, float f9);
[Export ("V:i:i:i:i:i:i:f:f:f:f:f:f:f:f:f:")]
void V (int i1, int i2, int i3, int i4, int i5, int i6, int i7, float f1, float f2, float f3, float f4, float f5, float f6, float f7, float f8, float f9);
[Export ("V:d:d:d:d:d:d:d:d:")]
void V (double d1, double d2, double d3, double d4, double d5, double d6, double d7, double d8, double d9);
[Export ("V:i:Siid:i:i:d:d:d:i:i:i:")]
void V (int i1, int i2, Siid Siid, int i3, int i4, double d1, double d2, double d3, int i5, int i6, int i7);
[Export ("V:i:f:Siid:i:i:d:d:d:i:i:i:")]
void V (int i1, int i2, float f1, Siid Siid, int i3, int i4, double d1, double d2, double d3, int i5, int i6, int i7);
[Export ("V:c:c:c:c:i:d:")]
void V (sbyte c1, sbyte c2, sbyte c3, sbyte c4, sbyte c5, int i1, double d1);
[Export ("V:n:")]
void V (out NSObject n1, out NSString n2);
2016-04-26 22:40:23 +03:00
[Export ("invoke_V")]
void Invoke_V ();
[Export ("invoke_F")]
float Invoke_F ();
[Export ("invoke_D")]
double Invoke_D ();
[Export ("Sf_invoke")]
Sf Sf_invoke ();
[Export ("invoke_V_null_out")]
void Invoke_V_null_out ();
2016-04-26 22:40:23 +03:00
[Export ("methodReturningBlock")]
RegistrarTestBlock MethodReturningBlock ();
[Export ("propertyReturningBlock")]
RegistrarTestBlock PropertyReturningBlock { get; }
[Export ("testBlocks")]
bool TestBlocks ();
[Export ("idAsIntPtr:")]
void IdAsIntPtr (IntPtr id);
[Export ("outNSErrorOnStack:i:i:i:i:i:err:")]
void OutNSErrorOnStack (int i1, int i2, int i3, int i4, int i5, int i6, out NSError error);
[Export ("outNSErrorOnStack:obj:obj:int64:i:err:")]
void OutNSErrorOnStack (NSObject i1, NSObject i2, NSObject i3, long i4, int i5, out NSError error);
}
[BaseType (typeof (NSObject))]
interface ObjCExceptionTest {
[Export ("throwObjCException")]
void ThrowObjCException ();
[Export ("throwManagedException")]
void ThrowManagedException ();
[Export ("invokeManagedExceptionThrower")]
void InvokeManagedExceptionThrower ();
[Export ("invokeManagedExceptionThrowerAndRethrow")]
void InvokeManagedExceptionThrowerAndRethrow ();
[Export ("invokeManagedExceptionThrowerAndCatch")]
void InvokeManagedExceptionThrowerAndCatch ();
2016-04-26 22:40:23 +03:00
}
[BaseType (typeof (NSObject))]
interface CtorChaining1
{
[Export ("initCalled")]
bool InitCalled { get; set; }
[Export ("initCallsInitCalled")]
bool InitCallsInitCalled { get; set; }
[Export ("initCallsInit:")]
IntPtr Constructor (int value);
}
[BaseType (typeof (NSObject))]
[Model]
[Protocol]
interface ObjCProtocolTest
{
[Export ("idAsIntPtr:")]
void IdAsIntPtr (IntPtr p1);
}
[Protocol]
interface ObjCProtocolBlockTest
{
[Abstract]
[Export ("requiredCallback:")]
void RequiredCallback (Action<int> completionHandler);
[Abstract]
[Static]
[Export ("requiredStaticCallback:")]
void RequiredStaticCallback (Action<int> completionHandler);
[Export ("optionalCallback:")]
void OptionalCallback (Action<int> completionHandler);
[Static]
[Export ("optionalStaticCallback:")]
void OptionalStaticCallback (Action<int> completionHandler);
}
interface IObjCProtocolBlockTest { }
[BaseType (typeof (NSObject))]
interface ObjCBlockTester
{
[Export ("TestObject", ArgumentSemantic.Retain)]
IObjCProtocolBlockTest TestObject { get; set; }
[Static]
[Export ("TestClass")]
Class TestClass { get; set; }
[Export ("classCallback:")]
void ClassCallback (Action<int> completionHandler);
[Export ("callClassCallback")]
void CallClassCallback ();
[Export ("callRequiredCallback")]
void CallRequiredCallback ();
[Static]
[Export ("callRequiredStaticCallback")]
void CallRequiredStaticCallback ();
[Export ("callOptionalCallback")]
void CallOptionalCallback ();
[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
[Static]
[Export ("callOptionalStaticCallback")]
void CallOptionalStaticCallback ();
[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
[Export ("testFreedBlocks")]
void TestFreedBlocks ();
[Static]
[Export ("freedBlockCount")]
int FreedBlockCount { get; }
}
[BaseType (typeof (NSObject))]
interface EvilDeallocator
{
[Export ("evilCallback")]
Action<int> EvilCallback { get; set; }
}
2016-04-26 22:40:23 +03:00
}