Граф коммитов

379 Коммитов

Автор SHA1 Сообщение Дата
Jonathan Peppers b37ec4dc61 [tests] added NUnit project for MonoEmbeddinator4000
Added lots of projects to generator.sln
2017-07-05 14:42:01 -05:00
Jonathan Peppers 6ed12403e6 [tests] PCL and Android projects need CustomBuildActions.targets 2017-07-05 09:00:49 -05:00
Jonathan Peppers 3cd5b94fdb [android] fix for startup of Embeddinator
- GenerateAndroidManifest method
- Add
- Android content provider now invokes static constructor of
`Native_managed_dll`
- Removed some stuff in sample app
2017-07-03 17:03:00 -05:00
Jonathan Peppers b111581cf7 [android] unit test verifying an Android Asset
- Include a text file in /Assets/
- Add a JUnit test checking for it in final APK
- Fixed an issue in cake build script, copying AAR
2017-07-03 08:25:20 -05:00
Jonathan Peppers 8aa14e1b25 [build] fixes
- Cake was copying `Test.java` to the wrong place
- A `Makefile` was still using `-xamarinPath`
2017-06-30 16:48:17 -05:00
Jonathan Peppers 77d3331f3a [android] full test for custom view
- Layout loading `ViewSubclass`
- `ViewSubclass` applies theme attributes
- Fixed casing issues in JNI calls
- Java unit test verifies the right text comes out
2017-06-30 08:30:34 -05:00
Jonathan Peppers a4a8fe0575 [android] wider resource support
- Included better references for Resource.designer.dll
- Resource.designer.dll runs through the linker (which should clean up
its references)
- Added an android theme with attributes
- Support for int[] resource fields
- Needs tests validating the attributes and theme works
2017-06-30 08:30:34 -05:00
Jonathan Peppers 7871f2ce4b [android] preload Resource.designer.dll up front 2017-06-30 08:30:34 -05:00
Jonathan Peppers 39b85ff6fb [android] tests verifying that R.java is working 2017-06-30 08:30:34 -05:00
Jonathan Peppers 04c9a781f8 [android] prototyped mappings for R.java
- C# resource Ids need to be remapped to what is generated from Java in
the final APK
- This generates `Resource.designer.dll` which hooks into
`ResourceIdManager`
- Right now I have hardcoded C# code that gets our tests to pass
2017-06-30 08:30:34 -05:00
Jonathan Peppers ab4e0baca4 [android] working C# activity
Limitations include
- Have to call `Native_managed_dll.INSTANCE` from Java
- Android Resources not working
2017-06-30 08:30:34 -05:00
Jonathan Peppers 0a387e262f [android] manifest generation working
- [Activity] properly gets registered in manifest
- Cleaned up namespaces in tests
- Added a simple C# activity
- Wrote a test to launch an activity (not passing yet)
2017-06-30 08:30:34 -05:00
Jonathan Peppers 41c43b14ef [android] update gradle, fixed code completion in tests 2017-06-30 08:30:33 -05:00
Jonathan Peppers 0aa711c441 [android] test for Button Click event 2017-06-30 08:30:33 -05:00
Jonathan Peppers 1ad31fed53 [android] cleanup ViewSubclass some 2017-06-30 08:30:33 -05:00
Jonathan Peppers c10e9c1b65 [android] fixed our crazy package name 2017-06-30 08:30:33 -05:00
Jonathan Peppers 800921d985 [android] tests using [Export]
- Decorated C# members with `[Export]`
- Added a Java test calling these members
- Had to add some additional MSBuild plumbing for it to work
2017-06-30 08:30:33 -05:00
Jonathan Peppers 4fa8919a3c [android] first working unit test C# subclassing Java
- Include XA java stubs in Java compile
- Include AndroidTests.java for testing `ViewSubclass`
2017-06-30 08:30:33 -05:00
Jonathan Peppers de14ecdfba [android] changes to get tests passing
- Put master build of Xamarin.Android at external/Xamarin.Android (add
to ignore list)
- Use -xamarinPath parameter to point to it
- Convert -xamarinPath to absolute path in CLI.cs
- Remove `PortablePdbFiles` as it was removed with newer XA
2017-06-30 08:30:33 -05:00
Jonathan Peppers 2818225ddd [tests] Android Library Project for testing
- ViewSubclass to be used in Android tests
- Changed Makefile to use it
2017-06-30 08:29:53 -05:00
Jonathan Peppers 6066781cd6 [android] test running needs to disable compression on DLLs 2017-06-30 08:29:06 -05:00
Joao Matos 1c0b165cc6 [support] mono_embeddinator_decimal_to_gstring now takes decimal parameter by value. 2017-06-28 19:12:37 +01:00
Joao Matos 4d14a29751 [tests][c] Added C tests for decimal number support. 2017-06-27 16:24:03 +01:00
Jonathan Peppers 9778ec5b5e [tests] added PCL project
- Only had to create a couple `#if` to support PCL
- We can use this project later for testing PCLs
- Made `pcl-compile` and `pcl-run` make targets
2017-06-26 11:08:09 -05:00
Jonathan Peppers 07916c583a Merge pull request #403 from jonathanpeppers/windows-android
[android] support for generating AARs on Windows
2017-06-23 08:04:26 -05:00
Joao Matos d699210a60 [ci] Setup the PATH env variable on OSX before running the test suite. 2017-06-22 16:15:10 +01:00
Jonathan Peppers 4615b0cdb0 [windows] fixed CustomBuildActions.targets
- Implemented two custom commands on Windows
- Need to incude .nuget/nuget.exe on Windows
2017-06-21 15:12:08 -05:00
Joao Matos 6b4a9e2e92 [c] Improve naming of generated C primitive array types to better follow .NET naming. 2017-06-21 15:52:11 +01:00
Joao Matos e9c0771ee5 [android] Added missing/git ignored file gradle-wrapper.jar. 2017-06-13 14:59:31 +01:00
Joao Matos 6bd298008d [tests] Add Android testing project and build/testing machinery. 2017-06-08 20:58:45 +01:00
Joao Matos b2c6f3ca8b [tests] Move Java tests to the mono.embeddinator package/directory. 2017-06-08 20:53:58 +01:00
Joao Matos 5af3ec7110 [tests] Move shared Make helpers to a common shared file. 2017-06-08 18:34:03 +01:00
Chris Hamons 5a032796e8 Implement TypeMapper to improve duplication code (#377)
- https://github.com/mono/Embeddinator-4000/issues/369
- Push ProcessedTypes into all post processing steps and add containing type info
- Improve duplicate detection by using "real" selector instead of hack
- More work to be done in other places, but at least removes the "temporary quasi-duplicate" code
2017-06-01 16:22:26 -05:00
Jonathan Peppers ba513de26f [java] - embed JNA into Embeddinator-generated jar file
- We don’t want developers to have to pull jna-4.4.0.jar into their
project
- This unzips it into our jar, so they just have to worry about a
single file
- Updated tests, so it is not using the jar from /external/jna
2017-06-01 10:52:51 -05:00
Jonathan Peppers 35cccd96d3 [java] update tests Makefile to not rely on javac and jar commands
- Now uses `—compile` option on embeddinator instead of manually
calling `javac` and `jar`
- I like this a lot better because CI is actually testing the code I’ve
been modifying
- Hopefully this fixes the build
2017-06-01 08:23:16 -05:00
Alex Soto 1d4c32dc04 [objc] Add NSDate <-> DateTime support. (#344)
* [objc] Add NSDate <-> DateTime support.

DateTime v.s. NSDate
====================

From [NSDate's](https://developer.apple.com/reference/foundation/nsdate?language=objc) documentation:

> NSDate objects encapsulate a single point in time, independent of any particular calendrical system or time zone. Date objects are immutable, representing an invariant time interval relative to an absolute reference date (00:00:00 UTC on 1 January 2001).

Due to NSDate reference date, all conversions between it and DateTime must be done in UTC.

DateTime to NSDate
==================

When converting from `DateTime` to `NSDate` the DateTime's `Kind` property is taken into account.

| Kind         | Results                                                                                            |
| ------------ | -------------------------------------------------------------------------------------------------- |
| Utc          | Conversion is performed using the provided DateTime object as is.                                  |
| Local        | The result of calling `ToUniversalTime ()` in the provided DateTime object is used for conversion. |
| Unspecified  | The provided DateTime object is assumed to be UTC, so same behavior as Kind == Utc.                |

The conversion is done by using the following formula:

**TimeInterval** = DateTimeObjectTicks - NSDateReferenceDateTicks[dt] / [TicksPerSecond](https://msdn.microsoft.com/en-us/library/system.timespan.tickspersecond(v=vs.110).aspx)

Once we have the TimeInterval we use NSDate's [dateWithTimeIntervalSinceReferenceDate:](https://developer.apple.com/reference/foundation/nsdate/1591577-datewithtimeintervalsincereferen?language=objc) selector to create it.

NSDate to DateTime
==================

Going from NSDate to DateTime we assume we are getting a NSDate instance which's reference date is **00:00:00 UTC on 1 January 2001** and use the following formula:

**DateTimeTicks** = NSDateTimeIntervalSinceReferenceDate * [TicksPerSecond](https://msdn.microsoft.com/en-us/library/system.timespan.tickspersecond(v=vs.110).aspx) + NSDateReferenceDateTicks[dt]

Once we calculated the **DateTimeTicks** we use the following DateTime [constructor](https://msdn.microsoft.com/en-us/library/w0d47c9c(v=vs.110).aspx) setting its `kind` to `DateTimeKind.Utc`.

There are some considerations that you must be aware of, NSDate can be `nil` but a DateTime is a struct in .NET and by definition it can't be `null`. If you give a `nil` NSDate we will translate it to the default DateTime value which maps to `DateTime.MinValue`.

MinValue and MaxValue are also different, NSDate can support greater and lower boundaries than DateTime's so whenever you give a greater or lower value we will set it to DateTime's [MaxValue](https://msdn.microsoft.com/en-us/library/system.datetime.maxvalue(v=vs.110).aspx) or [MinValue](https://msdn.microsoft.com/en-us/library/system.datetime.minvalue(v=vs.110).aspx) respectively.

**dt**: NSDate reference date **00:00:00 UTC on 1 January 2001** => `new DateTime (year:2001, month:1, day:1, hour:0, minute:0, second:0, kind:DateTimeKind.Utc).Ticks;`

* [objc] Implement feedback

* Code was simplified a lot by just harcoding the following values

$ csharp -e 'DateTime.MaxValue.Ticks'
3155378975999999999
$ csharp -e 'DateTime.MinValue.Ticks'
0
$ csharp -e 'TimeSpan.TicksPerSecond'
10000000

// NSDate reference date 00:00:00 UTC on 1 January 2001
// https://developer.apple.com/reference/foundation/nsdate
define NSDateRefDateTicks 631139040000000000LL
define NetTicksPerSecond 10000000LL
define DateTimeMaxValueTicks 3155378975999999999LL
define DateTimeMinValueTicks 0LL

* Added a strongly defined type for DateTime (E4KDateTime) instead
  of just using void*

* Fixed some issues in docs

* [objc] Remove unused members from DateTime linker support

* [objc] Fix variable scope issue when clang optimizes code

* [objc] Replace DateTime for DBNull in TypeMatchFailure test since we now implement DateTime support
2017-05-31 09:32:32 -05:00
Chris Hamons 344cee7aaa Refuse to generate elements that conflict with some "important" obj-c… (#363)
- https://github.com/mono/Embeddinator-4000/issues/346
- Rename methods/properties/fields hiding important obj-c selectors instead of skipping
2017-05-30 10:14:07 -05:00
Chris Hamons 61f72a4550 Split driver.cs into three files (#372) 2017-05-26 08:00:46 -05:00
Joao Matos c88c186364 [c][tests] Fixed array tests broken by the merge. 2017-05-24 23:32:52 +01:00
Joao Matos d9bcdc5c93 Merge branch 'objc'
# Conflicts:
#	.gitignore
#	docs/Contributing.md
#	docs/ObjC.md
#	docs/errors.md
#	docs/getting-started-objective-c.md
#	docs/releases/Embeddinator-4000_0.1.md
#	generator.sln
#	objcgen/EqualsHelper.cs
#	objcgen/HashHelper.cs
#	objcgen/Make.config
#	objcgen/Makefile
#	objcgen/NameGenerator.cs
#	objcgen/classhelper.cs
#	objcgen/driver.cs
#	objcgen/extensions.cs
#	objcgen/generator.cs
#	objcgen/methodhelper.cs
#	objcgen/objcgen.csproj
#	objcgen/objcgenerator-helpers.cs
#	objcgen/objcgenerator-postprocessor.cs
#	objcgen/objcgenerator-processor.cs
#	objcgen/objcgenerator.cs
#	objcgen/operatoroverloads.cs
#	objcgen/processedtypes.cs
#	objcgen/protocolhelper.cs
#	samples/Makefile
#	support/mono-support.h
#	support/mono_embeddinator.c
#	support/mono_embeddinator.h
#	support/objc-support.h
#	support/objc-support.m
#	tests/managed/CustomBuildActions.targets
#	tests/managed/Makefile
#	tests/managed/Makefile.include
#	tests/managed/arrays.cs
#	tests/managed/equalsHashOverrides.cs
#	tests/managed/interfaces.cs
#	tests/managed/ios/managed-ios.csproj
#	tests/managed/managed-shared.projitems
#	tests/managed/overloads.cs
#	tests/managed/types.cs
#	tests/objc-cli/Makefile
#	tests/objc-cli/libmanaged/Tests/Tests.m
#	tests/objcgentest/Asserts.cs
#	tests/objcgentest/objcgentest.csproj
2017-05-24 15:08:41 +01:00
Rolf Bjarne Kvinge 41cc79bf2b [objc] Make sure to attach/detach from threads. Fixes issue #357. (#362) 2017-05-22 18:42:35 +02:00
Joao Matos 54b1d6a977 [tests][java] Added managed fields tests to the Java testsuite. 2017-05-16 16:18:44 +01:00
realvictorprm 6521cbbada Fixing windows test support
Signed-off-by: Victor Peter Rouven Müller <mueller.vpr@gmail.com>
2017-05-15 18:12:50 +02:00
Chris Hamons 41bd55e4a8 Make TextTransform.exe invocation platform safe. Needs windows implem… (#338)
* Make TextTransform.exe invocation platform safe. Needs windows implementation

- https://github.com/mono/Embeddinator-4000/issues/337

* Move to nuget Mono.TextTransform.1.0.0
2017-05-15 09:12:19 -04:00
Sebastien Pouliot 98bb8f4cd9 [objc] Add `--nowarn:` and `--warnaserror:` options to the driver (#339)
Code was already present (copied from mtouch/mmp with ErrorHelper.cs) so
it's an easy and useful thing to expose.

Use `--nowarn` on UnitsNet sample to reduce the warnings that we cannot
fix (since we're using a binary downloaded from nuget)

Add unit tests for `--nowarn`. The one for `--warnaserror` did not work,
at least inside VSfM, due to bug #55801, resulting in:

> mono_os_mutex_lock: pthread_mutex_lock failed with "Invalid argument" (22)
2017-05-12 18:21:24 -04:00
Joao Matos 3af3f6e6a1 [c] Implement support for fields in reference and value types. 2017-05-12 17:08:46 +01:00
Alex Soto 3637c8effd [objc] Add decimal array ref support (#332) 2017-05-12 10:16:05 -04:00
Joao Matos 5aa2e66aaf [ast] Ignore non-public members when processing managed types. 2017-05-12 12:22:11 +01:00
Sebastien Pouliot c2b88dd5d4 [objc] Add support for System.TimeSpan into generated projects (#327)
This replace the older (not linker friendly) PR #251.

It brings, if required, `System.TimeSpan` inside your projects since
there is direct, good alternative, i.e. `NSTimeInterval` is just a
typedef on `double`.

* [mac] Link SDK is only supported for the modern profile

* [mac] Provide `--nolink` to mmp when the linker is not supported

The earlier problem (and test failures) is that, by default `mmp` (like
`mtouch`) does a **link all**.

It's easy to forget since we don’t normally use the command line (but
the UI of an IDE) to call `mmp`.
2017-05-11 22:26:20 -04:00
Rolf Bjarne Kvinge b2dbd06f34 [objc] Add tvOS support. (#329) 2017-05-11 15:18:19 -04:00
Rolf Bjarne Kvinge b2534eeaa7 [objc][tests] Show error message if error code assert fails. (#330)
In my case this made it a lot faster to realize tests were failing because of
outdated dependencies.
2017-05-11 14:22:00 -04:00
Rolf Bjarne Kvinge 1e073e355d [objc] Fix typo in comment. (#326) 2017-05-11 12:28:44 -04:00
Rolf Bjarne Kvinge d8d9b45717 [objc] Add support for creating Xamarin.Mac frameworks. (#324)
* Add multiple new platforms, one for each Xamarin.Mac flavor
  (modern/full/system), and make these new platform values build a framework
  using mmp.

* Add support for creating a framework for the existing `macOS` platform
  (which does not include Xamarin.Mac).

* Rework testing significantly, adding unit tests for Xamarin.Mac framework support:

    * Make managed.csproj a shared library project, and make another project
      managed-*.csproj for each platform we support that references this
      shared project.

    * Add managed unit tests that runs the embeddinator on the corresponding
      managed-*.csproj, generates an Xcode test project, and runs the tests in
      the generated Xcode project. This is a replacement for a few identical
      tests in tests/objc-cli/Makefile (and those are now removed).

* [objc] Document the various Objective-C platforms we can target.
2017-05-11 11:15:17 -04:00
Sebastien Pouliot cb0f3f4e94 Fix unit tests (fails due to multiple merges) (#325) 2017-05-11 10:18:51 -04:00
Vincent Dondain 85dfa1660a [objc] Use word 'Value' after type name in methods name (#315)
Fixes issue 194: [objc] Use word "Value" in method's names after a type
(https://github.com/mono/Embeddinator-4000/issues/194)

- We now have nice names when using types in methods names (no more Int16, Int32, Int64...)
  and they use the word 'Value' at the end which is standard in Objective-C.
  See: https://developer.apple.com/library/content/documentation/Cocoa/Conceptual/CodingGuidelines/Articles/NamingMethods.html#//apple_ref/doc/uid/20001282-BCIGIJJF
  The method's argument description also use the new friendly names which is better since it matches the Objective-C types and the argument's names.
- Use camel case for method's argument description so we have `findFirstName: lastName:`.
- Fixed up tests accordingly.
2017-05-11 08:55:24 -04:00
Alex Soto 2255126579 [objc] Add array ref parameter support. Fixes Issue #314 (#321) 2017-05-11 08:54:08 -04:00
Alex Soto 347f1586e9 [objc] Add NSDecimalNumber <-> decimal support (#292)
* [objc] Add NSDecimalNumber ReturnType support

Array return type pending

* [objc] Implement feedback and added ReturnType array support

* Added linker.xml to mtouch so it keeps decimal.ToString(IFormatProvider)
* Moved nsdecimalnumber creation logic into its own method to reduce code
  duplication. mono_embeddinator_get_nsdecimalnumber
* Added mono_embeddinator_get_decimal_class to cache its value
* Added MonoDecimal struct definition from
  https://github.com/mono/mono/blob/master/mono/metadata/decimal-ms.h
  needed by mono_array_get.
* Added ReturnType array support
* Moar tests!! 🐟 🐈

* [objc] Fix link.xml identation and added a note about issue #301

* [objc] Move MonoDecimal to mono-support.h and fix feedback

* [objc] Add NSDecimal <-> decimal parameter[Array] support

* [objc] remove indentation fixes so it can be PR'ed separately

* [objc] implement feedback

* Add Quote to --xml path
* Reduced if nesting on decimal mono_array_set
* Renamed mono_embeddinator_get_monodecimal to mono_embeddinator_get_system_decimal
2017-05-11 08:33:29 -04:00
Alex Soto 0b1fb8b592 [objc] Turn indetation spaces into tabs in libmanaged/Tests.m (#318) 2017-05-10 20:21:49 -05:00
Sebastien Pouliot a9092bdfb6 [objc] Hide `[]` and `&` when we use type names as parameter names to avoid duplicates on overloads. Fixes #309 (#312)
reference:
https://github.com/mono/Embeddinator-4000/issues/309
2017-05-10 12:46:15 -04:00
Sebastien Pouliot d413d51e46 [wip] Start migrating logic from generator to processor (#284)
This is required so we can detect, fix or select duplicate members
correctly. The processor will have all the information and will give
a working set of Processed* instance to the generator (where no
validations will be needed)

note: known failures running tests (signatures are incorrect for members
with default values)
2017-05-10 08:12:02 -04:00
Timothy Risi 37523e7b2b Add support for IEquatable. Fixes #219 (#299) 2017-05-09 20:09:34 -04:00
Joao Matos c438227b20 [tests][java] [tests][c] Added tests for managed interfaces to the Java test suite. 2017-05-09 22:39:08 +01:00
Chris Hamons 5b25a2eff7 Handle operators (friendly and normal) name generation the same (#290)
- https://github.com/mono/Embeddinator-4000/issues/204
2017-05-09 09:26:39 -05:00
Joao Matos 242de36e93 [tests] Remove UIViewLib test as its covered by samples. 2017-05-09 08:52:59 +01:00
Vincent Dondain 1039da601a [objc] Update command line options for compilation target (#288)
- drop all single arguments for compilation target (--dll, --shared, --static).
- use the right value names for --target.
- [tests] Update Static_Unsupported to use --target
2017-05-08 14:42:15 -04:00
Alex Soto 3df3483cf7 [objc][tests] Add objcgen warning and error tests. Fixes issue #104 (#203)
* [objc][tests] Add objcgen warning and error tests. Fixes issue #104

* Adds support for testing error conditions in Xcode projects
  see XcodeBuildErrorTest inside ObjCGenErrWarnTests.cs
* Adds a library to create warning conditions to test objcgen
  and its correponding test (GenWarningTest inside ObjCGenErrWarnTests.cs).

* Fix atrocious spaces identation

* Fix more identation thanks to VS4Mac not honouring my settings...

* [objc][objcgentest] Add support for not finding a warning message

* Kill more spaces with 🔥 I mean tabs

* [objc][tests] Implemented feedback

* XcodeApp prop was made public in order for it to be accesible by tests
* Removed Xcode project usage and replaced it with clang
* Replaced manually created temp dirs by our shared
  Xamarin.Cache.CreateTemporaryDirectory ();

* [objc] Use xcrun clang instead
2017-05-08 14:13:51 -04:00
Joao Matos 01dbe9ef1e [tests][c] Added tests for managed interfaces to the C test suite. 2017-05-08 16:01:32 +01:00
Alex Soto f00c4afe64 [objc] Add Array support (#252)
* [objc] Add Array support for ReturnTypes

* byte [] to NSData
* string [] to NSArray<NSString *> *
* Foo [] to NSArray<Foo *> *
* numeric valueType [] to NSArray<NSNumber *> *

* [objc] Fix GetArrayTypeName, byte[] and memory allocation for temp array

We now use `mono_array_addr` to marshal byte[] to NSData.

Fixed GetArrayTypeName to return the correct type name.

Fixed a null case and added tests for readonly props.

Notes on temp array (__resarrbuf):

According to [Transitioning to ARC Release Notes](1) in order to
create a C array of retained pointers under ARC you must meet the
following conditions:

* The allocated memory must be zero-filled.
* You must set each element to nil before freeing.
* Don’t rely on the default variable qualifier to be __strong, it
  is __autoreleasing.
* You should avoid memcpy/realloc.

So adjusted code to do so.

[0]: https://developer.apple.com/library/content/releasenotes/ObjectiveC/RN-TransitioningToARC/Introduction/Introduction.html

* [objc] Fix feedback, add interface arr and parameters arr support

Also made ReturnArrayValue code smaller for NSNumber boxed types

* [objc] Fix implicit declaration of function x is invalid in c99

* [objc] Fix all the spaces!!
2017-05-08 08:22:56 -04:00
Joao Matos 1078932bd4 [tests] Clean managed project when cleaning tests project. 2017-05-08 12:14:30 +01:00
Alex Soto 990c16ca27 [objc][tests] Fix testObjectIndexedSubscripting boolCollection test (#282)
warning: initialization of pointer of type 'id _Nonnull' to null from a
constant boolean expression [-Wbool-conversion]
2017-05-07 10:53:14 -04:00
Joao Matos 6455200cf1 [build] Use Mono.TextTransform for T4 template generation instead of XS. 2017-05-05 11:00:07 +01:00
Timothy Risi 3dfc4a5e87 Add support for nested classes (#262) 2017-05-05 06:34:58 +02:00
Joao Matos d4d8b12d79 [tests/managed] Add arrays and builtin types files to shared project. 2017-05-04 23:54:32 +01:00
Joao Matos 3fe3ab7be7 [tests] Minor clean ups to tests make logic. 2017-05-04 23:54:32 +01:00
Joao Matos 1ef5b00c06 [tests] Setup Mono runtime includes in the native test projects. 2017-05-04 23:54:32 +01:00
Joao Matos af14b13ac5 [tests] Update tests logic to changes from objc branch. 2017-05-04 23:54:32 +01:00
Joao Matos c4bc5f7dbb [git] Merge tip of objc branch into master. 2017-05-04 23:54:32 +01:00
Sebastien Pouliot 387f633205 [objc] Make sure we can build for iOS release using mtouch. Partial fix for #237 (#238)
Embedding with Xamarin.iOS is different than doing it directly with mono.
This requires some methods to be defined, like the ones only used for
release (when `TOKENLOOKUP` is defined).

The integration with mtouch is also incomplete (for non-debug build) as
some steps (MdbSym) and SymbolStrip (only used in release by default)
causes FileNotFoundException (some state is not set correctly).

This PR is a fix for the former (headers), a workaround for the later
(mtouch invocation) and a Makefile change to make sure we always build
release/iOS on bots (because untested stuff never works, for long)

ref: https://github.com/mono/Embeddinator-4000/issues/237
2017-05-04 13:51:45 -04:00
Chris Hamons afdb0d9d8a Handle Equality Operators Better (#247)
- This was made somewhat harder as equals is "special" and not in methods list
- https://github.com/mono/Embeddinator-4000/issues/221
2017-05-03 11:05:44 -05:00
Sebastien Pouliot 06c6f5b66e [objc] Do not create categories for extension methods on primitive types. Fix issue #249 (#253)
Creating categories on primitive types is not possible with ObjC.
Instead just create a _normal_ static method so the API can still be
used.

https://github.com/mono/Embeddinator-4000/issues/249
2017-05-03 10:51:19 -04:00
Sebastien Pouliot c2968251bd [objc] Skip generation for subclasses of unsupported types (#250)
In such case a warning will be displayed and nothing will be generated.

Test added so we can ensure such condition does not stop the generation
with an error.
2017-05-03 10:51:01 -04:00
Joao Matos f57256d4f5 [java] Added tests for structs / value types to the Java test suite. 2017-05-03 01:11:38 +01:00
Joao Matos dc596ed027 [c] Added tests for structs / value types to the C test suite. 2017-05-03 01:11:29 +01:00
Joao Matos c9fd01ad27 [java] Added more tests for managed methods. 2017-05-02 22:49:50 +01:00
Chris Hamons 52510ae136 Mutate operator methods that are in duplicate (#244)
- https://github.com/mono/Embeddinator-4000/issues/207
- Also refactor GetSignatures a bit
2017-05-02 17:41:39 -04:00
Chris Hamons cc45f787cb Fix silly subsript restriction on read/write only properties (#245)
- https://github.com/mono/Embeddinator-4000/issues/239
2017-05-02 13:28:57 -04:00
Sebastien Pouliot dada06598a [objc] Move the processing of extension methods after we check for unsupported types (#236)
Solve:
```
Generating binding code...
error EM0009: The feature `Returning type Nullable`1 from native code` is not currently supported by the tool
```

when a nullable type (not yet supported [1]) was used in extensions
methods.

[1] https://github.com/mono/Embeddinator-4000/issues/229
2017-05-02 13:24:54 -04:00
Timothy Risi bac509ea38 Parameter names should be at least 3 characters long. Fixes #195 (#215)
* Arguments should be at least 3 charactesr long

* Only add the parameter name to short arguments if there are multiple of the same type

* Method implementations also need the updated parameter names

* Fix spacing

* Use Extension for ExtendedName on parameters

* Fix indentation (spaces -> tabs) issues

* Move ObjCTypeToArgument dictionary to NameGenerator

* Move the ExtendedName extension method to a NameGenerator method
2017-05-02 13:24:39 -04:00
Joao Matos 6710e26380 [java] Added tests for methods and ref/out parameters to the Java test suite. 2017-05-02 18:06:41 +01:00
Joao Matos 99f63c924a [ast] Fixed conversion of out parameters. 2017-05-02 17:42:36 +01:00
Joao Matos 2c6f173c6a [java][tests] Added tests for enums to the Java test suite. 2017-05-02 13:03:29 +01:00
Chris Hamons a148d47741 Allow many operator overloads (#234)
- c36d639770 removed need for exception but it was not removed
- Fixes https://github.com/mono/Embeddinator-4000/issues/207 from operator issues. Now hitting:
	error EM0009: The feature `Returning type Nullable`1 from native code` is not currently supported by the tool
2017-05-01 17:43:36 -04:00
Chris Hamons c36d639770 Fix FindOperatorPairs did not find expected number of op_ methods (#226)
- https://github.com/mono/Embeddinator-4000/issues/207
- Multiple operators of the same type but different arguments would fail unnecessarily
- Move overloads tests to new file due to length.
2017-05-01 16:49:10 -04:00
Sebastien Pouliot c964c2c99c [objc] Correctly expose types that conforms to (bound) protocols (#216)
and add unit tests. This required a few other changes like:

* Getting the managed instance, if it exists, from a native instance is
  moved to the support code (so it can be shared for multiple usages);

* Most (unless static) bound types now expose `xamarinGetGCHandle`, i.e.
  not just the one where `isEqual:` is implemented);

* `xamarinGetGCHandle` exists only inside the implementation (.m), not
  in the header (.h) file and is commented to be for internal uses only;

* EqualsHelper is modified to reuse the shared code;
2017-05-01 07:52:55 -04:00
Chris Hamons befc43a46a Centralize name generation in one place (#201)
- Both to get more code out of objcgenerator*.cs and pave the way to possible future caching
2017-04-28 08:36:36 -05:00
Sebastien Pouliot 95f1ecaed2 [objc] Support ValueType with no default constructor (#206)
This happens if there's no initialization. Previously the lack of a
public `.ctor()` meant we did not generate the code (nothing to call).

This was not correct (since it's valid in .net) so we detect the
condition and generate a simpler `init` method in such case.

Unit tests added (for the existing `Point` type that suffered, unnoticed,
from this)
2017-04-28 07:31:44 +02:00
Chris Hamons 0cbb8566ca Only generate raw operator bindings when "friendly" variant not inclu… (#190)
- https://github.com/mono/Embeddinator-4000/issues/183
2017-04-27 16:42:09 -05:00
Rolf Bjarne Kvinge 75d1de3985 [objc] Add support for NSObject subclasses by reusing the output from the static registrar. (#199)
* [objc] Don't generate code for types that inherit from NSObject, the static registrar does that.

* [objc] Find referenced platform assemblies.

* [objc] Copy the registrar.h file mtouch generated into the framework.

And also create an umbrella header that includes everything else, for easy
consumption by framework consumers.

* [objc] Add an initialization method for the generated registrar code.

* [tests][objc] Add tests for NSObject subclasses.

* [objc] Bump required XI version.

* [tests][objc] Rework the managed tests to use a shared project.

We now have the following structure:

* tests/managed/managed-shared.shproj: this is a shared project that contains
  all the source code.
* tests/managed/generic/managed-generic.csproj: this is a project that builds
  the shared projects for desktop, without referencing neither Xamarin.Mac nor
  Xamarin.iOS.
* tests/managed/ios/managed-ios.csproj: this is a project that builds the
  shared project for iOS.
2017-04-27 16:11:39 +02:00
Rolf Bjarne Kvinge e89b306be1 [tests] Fix Asserts.ThrowsEmbeddinatorException to throw if no exception was thrown. (#198) 2017-04-27 09:03:50 -04:00
Rolf Bjarne Kvinge 9622beab60 [tests] Fix compile warnings. (#200) 2017-04-27 09:03:13 -04:00
Sebastien Pouliot 4be5b4d0d7 [objc] Add basic interface/protocol support (#191)
This allow an .NET API to return an interface. That interface is defined
as a protocol in ObjC.

We also supply an internal `__*Wrapper` class so ObjC can call the
interface members.

Also fix virtual calls - the current code was calling the interface
itself, not the implementation for it.

Note: it's basic in the sense that it does not allow .NET to call back
into ObjC code (that conforms to the protocol).
2017-04-26 20:37:46 -04:00
Sebastien Pouliot 5a4cfe2c9b [objc] Add ProcessedAssembly and uniqueness validation (#186)
* Detect any duplication based on the assembly (internal) name and also
  it's sanitized (safe) name. Otherwise generated code won't work;

* Avoid recomputing the name (or safe name) whenever possible;

* Adjust unit tests for some code movement that ease reuse;
2017-04-26 08:07:45 -04:00
Sebastien Pouliot 505e7a1b49 [objc] Fix Implements extension method to work on interfaces (#179)
and not just types. Add unit tests.
2017-04-25 19:28:07 -04:00
Chris Hamons 51ffae02ca Framework to handle duplicate identifiers via postprocessing (#156)
* Post-process steps to handle duplicate methods

- https://github.com/mono/Embeddinator-4000/issues/71
- https://github.com/mono/Embeddinator-4000/issues/144

* Fix duplicate ctors and improve post processing support

- ProcessedConstructor and ProcessedFieldInfo join Methods and Fields
- Not all are used, but now we are consistent
- Move a misplaced test

* Fix merge

* Add total hack to get test passing

* Fix double suffix issue

* Correctly handle duplicate methods by resolving against more than just name

- Foo () and Foo (int) do not conflict, even if names collide
- So use representation that takes number of arguments in mind

* Fix build

* Fix regression from merge
2017-04-25 15:15:18 -04:00
Timothy Risi ae89610d77 [objc] Add support for overriding Equals and GetHashCode. Fixes issue #123 (#159) 2017-04-25 10:30:56 -04:00
Sebastien Pouliot f703a3d83a [objc] Add support for default values on .ctor/method parameters (#157) 2017-04-25 08:51:47 -04:00
Rolf Bjarne Kvinge 5754f59991 Merge pull request #149 from rolfbjarne/objc-compile-to-frameworks
[objc] Add support for compiling to frameworks.
2017-04-21 17:19:44 +02:00
Rolf Bjarne Kvinge 3a563e80ec [objc] Disable the C tests according to conversation with João. 2017-04-21 16:56:27 +02:00
Sebastien Pouliot b91288a65a [objc] Add support for extension methods using categories (#153)
Fix https://github.com/mono/Embeddinator-4000/issues/152
2017-04-20 16:49:13 -04:00
Joao Matos 311c9d72dd [tests][java] Added Java tests for managed constructors. 2017-04-20 15:33:11 +01:00
Sebastien Pouliot ec7e982eeb [objc] Fix clang warnings about nullability (#151)
In general we don't encourage `null` since it's likely to get managed
`ArgumentNullException` which cannot be well handled on the ObjC side.
That's covered by:

> NS_ASSUME_NONNULL_BEGIN

Right now we lack any metadata to make this more precise :-(. However,
when possible, we can put specific annotations on some API, e.g.

1. Any managed exception in a `.ctor` (or the `.cctor`) will make the
corresponding `init*` method return `nil`, so we always mark them as
`nullable`.

2. `ref` and `out` on reference types can be `nullable`

3. Our custom support for `IComparable` and `IComparable<T>` is null safe
   so mark it as such;

Warnings from our unit tests, which abuse `nil` since it knows the
managed code internals, now ignore those warnings (pragma)
2017-04-20 10:29:22 -04:00
Joao Matos 7c6496f084 [tests][java] Factor unsigned type size limits as static helpers. 2017-04-20 15:21:54 +01:00
Joao Matos e2603e5b72 [tests][java] Pass extra verbose diagnostics flag to Java compiler. 2017-04-20 14:55:19 +01:00
Joao Matos 3f3cf158de [tests][objc] Remove unused tests. 2017-04-20 14:53:54 +01:00
Joao Matos 8a619056b2 [tests][java] Added Java tests for managed exceptions. 2017-04-20 12:30:00 +01:00
Rolf Bjarne Kvinge 17c180bcf4 [tests][objc] Automatically test building to iOS frameworks.
Frameworks for other platforms haven't been tested (tvOS/watchOS), or is not
fully implemented yet (macOS).
2017-04-20 13:29:29 +02:00
Rolf Bjarne Kvinge ea36161949 [tests][objc] Add Xcode project to run iOS tests in simulator/device. 2017-04-20 13:29:29 +02:00
Rolf Bjarne Kvinge 1139e4d64e [objc] Add support for compiling to frameworks. 2017-04-20 13:29:29 +02:00
Joao Matos 370c84514f [tests][java] Added Java tests for namespaces. 2017-04-20 10:14:53 +01:00
Rolf Bjarne Kvinge 2132b77d91 [objc] Separate out the code that defines/includes Mono API to a separate file.
Xamarin.iOS/Mac will need to customize this code, since it can't include the
system Mono headers, and it's a lot easier to customize the code if it's in a
single file.
2017-04-20 10:14:57 +02:00
Sebastien Pouliot 1db245e8ec [objc] Add support for `IComparable<T>` (#148)
This gets priority over the `IComparable` implementation, using
`System.Object`, if present.

We let the normal generation cover cses of `IComparable<T>` when `T` is
not the declaring type. E.g.

> public class X : IComparable<Y>, IComparable<Z> {}
2017-04-20 09:58:18 +02:00
Rolf Bjarne Kvinge fa65e66441 [objc] Sanitize the generated names so that we don't print invalid Objective-C identifiers. (#147)
* [objc] Don't use static state.

It confuses the tests suite, which may run multiple tests in the same process.

* [objc] Sanitize the generated names so that we don't print invalid Objective-C identifiers.
2017-04-19 18:11:50 -04:00
Sebastien Pouliot 38f9c6b379 [objc] Add support for non-generic `IComparable` interface (#146)
* [objc] Add support for non-generic `IComparable` interface

We cannot support the _normal_ `IComparable` signature
> Int32 CompareTo(System.Object)
because `System.Object` is not `NSObject`. It's also not the pattern used
in Apple frameworks.'

But we can easily match it to the common (Foundation) signature
> - (NSComparisonResult)compare:(NSSomething *)other;

Part of the fix for:
https://github.com/mono/Embeddinator-4000/issues/124

* [tests][objc] Add missing file
2017-04-19 17:58:05 -04:00
Joao Matos c492529524 [tests][java] Added Java tests for managed properties. 2017-04-19 19:35:40 +01:00
Chris Hamons ad5966a78d Implement Indexed and Keyed Subscripting (#141)
- For indexed properties with integral input types, we can expose those via "Indexed Subscripting":
   (id)objectAtIndexedSubscript:(*IndexType*)idx;
   (void)setObject:(id)obj atIndexedSubscript:(*IndexType*)idx;
2017-04-19 12:33:41 -04:00
Joao Matos d37d2f686e [tests][java] Improved Makefile targets and added JUnit test runner invocation. 2017-04-19 17:24:27 +01:00
Joao Matos 69c5d86f99 [tests][java] Fixed Java unsigned type tests comparison. 2017-04-19 17:22:33 +01:00
Joao Matos 796efc4ca6 [java] Re-enable Java support in the testsuite. 2017-04-19 15:13:50 +01:00
Alex Soto 3f10052451 [objc] Check if __result is not null to create an object (#139)
The managed API could return `null` even if no exception occurred
so we tried to create an object with `mono_embeddinator_create_object (__result);`
and 💥  so we check now if `__result` is `null` and return `nil` instead.
2017-04-18 16:18:00 -04:00
Sebastien Pouliot cfcce4be3d [objc] Add support for writing to exposed, managed fields (#136) 2017-04-18 11:57:21 -04:00
Joao Matos f31e803f5a [tests][c] Added a few more tests for methods. 2017-04-18 13:35:08 +01:00
Joao Matos 9c5590490d [c] Refactored string handling as a primitive type.
* As a side-effect, now string arrays have an improved naming in generated C code.
2017-04-18 11:43:18 +01:00
Rolf Bjarne Kvinge a33e1b604d [tests][objc] Make sure variables are declared with the right type. (#131)
Otherwise we might not be able to call methods, because clang will look for any matching selector in any type it knows about, which results compiler errors like:

```
In module 'XCTest' imported from /work/Embeddinator-4000/tests/objc-cli/libmanaged/Tests/Tests.m:1:
In module 'UIKit' imported from /Applications/Xcode83.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/Library/Frameworks/XCTest.framework/Headers/XCUIElement.h:8:
/Applications/Xcode83.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator10.3.sdk/System/Library/Frameworks/UIKit.framework/Headers/UIAccelerometer.h:24:51: note: one possibility
@property(nonatomic,readonly) UIAccelerationValue x;
                                                  ^
In file included from /work/Embeddinator-4000/tests/objc-cli/libmanaged/Tests/Tests.m:3:
../build/test-framework-ios-temp-dir/iPhoneSimulator/managed.framework/Headers/managed.h:323:39: note: also found
@property (nonatomic, readonly) float x;
                                      ^
/work/Embeddinator-4000/tests/objc-cli/libmanaged/Tests/Tests.m:171:13: error: multiple methods named 'y' found with mismatched result, parameter type or attributes
        XCTAssert ([p2 y] == -2.0f, "y 2");
                   ^~~~~~
```

So by declaring the proper type for variables, clang doesn't have to guess.
2017-04-17 20:30:46 -05:00
Joao Matos c63d2544a4 [tests] Temporarily remove Java generator from default testing.
It's currently breaking CI and I'm still not ready to upstream all local fixes.
2017-04-17 20:25:46 +01:00
Joao Matos 416a28eed5 [tests][docs] Rename "Basic" testsuite in readme.md to match new "common" name. 2017-04-17 19:23:13 +01:00
Joao Matos 0d8d293c75 [tests][c] Added a few more tests for enums. 2017-04-17 19:08:49 +01:00
Joao Matos bbdb54218c Merge branch 'objc' of github.com:mono/embeddinator-4000 2017-04-17 15:58:25 +01:00
Joao Matos 801e852c0c [tests][c] Added a few more tests for exceptions. 2017-04-17 15:49:36 +01:00
Joao Matos ee1d6acd74 [tests][c] Provide our own test runner main and setup a dummy error handler. 2017-04-17 15:44:52 +01:00
Joao Matos 11aba98d4a [tests][c] Added a few more tests for types. 2017-04-17 15:13:21 +01:00
Sebastien Pouliot 27e5f34941 [objc] Add basic (readonly) support for fields (#129)
We cannot access them directly but we can provide (ObjC) property
wrappers around them, making them usable from ObjC code.
2017-04-17 10:03:46 -04:00
Joao Matos 3bc2bd73bb [tests][c] Added a few more tests for constructors. 2017-04-17 14:50:33 +01:00
Joao Matos caeab300ed [tests][c] Added a few more tests for namespaces. 2017-04-17 13:37:25 +01:00
Joao Matos 95bb6f2ea2 [tests][c] Added a few more tests for properties. 2017-04-17 13:37:07 +01:00
Sebastien Pouliot 943b1da124 [objc] Generated (property) indexers as methods (#125)
That's basic support. The nicer way would be to use subscripts [1]

[1] https://github.com/mono/Embeddinator-4000/issues/122
2017-04-14 15:13:20 -04:00
Sebastien Pouliot 24a1f3e543 [objc] Fix the case where bound type A creates instance of bound type B (#121)
As Alex pointed out this scenario requires the `_object` field to be
public.
2017-04-13 22:24:57 -04:00
Sebastien Pouliot 64b7df0d19 [objc] Generate better looking names for operators (#120)
Remove the `op_` prefix on operators.

Also fix a (non fatal) typo, extra `)`, when computing mono signatures.
2017-04-13 21:41:21 -04:00
Sebastien Pouliot 44b14b6e67 [objc] Add support for enums and [Flags] (#119) 2017-04-13 21:07:52 -04:00
Sebastien Pouliot 02202b7743 [objc] Add support for structs / valuetype (#118) 2017-04-13 17:59:28 -04:00
Sebastien Pouliot 4c60ece830 [objc] Add support for `ref` and `out` arguments (#115) 2017-04-12 21:20:37 -04:00
Alex Soto a33c458113 [objc] Avoid objc ctor inheritance. Fixes issue #72 (#103)
.NET .ctor are not inherited but `init*` methods are in ObjC, we now
mark as `NS_UNAVAILABLE` the ctors that are not available.

Also this commit introduces `objcgenerator-helpers.cs` which its main
intention is to move the small ObjC related functions like
`GetSignatures` or `GetUnavailableParentCtors` to avoid
polluting too much `objcgenerator.cs` readability
2017-04-12 21:20:21 -04:00
Rolf Bjarne Kvinge f92f01b0b0 [objc] Add support for --abi to limit the number of architectures we build. Fixes #74. (#114) 2017-04-12 13:52:20 -04:00
Rolf Bjarne Kvinge d5d341431e [tests][objc] Build debug tests into a subdirectory as well. (#108)
* [tests][objc] Build debug tests into a subdirectory as well.

This cleans up the current directory quite a bit.

Also modify the cli/perf tests a little bit to be able to run the
debug/release versions in parallel.

* [tests][objc] Don't fail to create directory if directory already exists.

* [tests][objc-cli] Make sure libmanaged.dylib is built before xctest.

Since the corresponding xcode project builds libmanaged.dylib if it's not
already built (by executing make), we may end up with two make process trying
to build the same target simultaneously, which breaks everything.
2017-04-12 17:02:16 +02:00
Rolf Bjarne Kvinge 98ac5de4eb [objcgen] Create an embedder class that contains the state required to run the embeddinator. (#110)
This makes it easier to test, because Driver.Main can be called multiple
times, each time independent from previous executions.
2017-04-12 08:57:26 -04:00
Rolf Bjarne Kvinge 75dfc163b5 [objc] Add a header (embeddinator.h) that's meant to be included by generated headers. (#109)
This way we can limit the API surface of the generated code.
2017-04-12 08:55:44 -04:00
Rolf Bjarne Kvinge eb8a9970af [objc] Use msbuild instead of xbuild. (#106)
This prevents fleeting visions of red text in the terminal.
2017-04-12 08:49:38 -04:00
Sebastien Pouliot a16e5478fe [objc][generator] Produce better names for ObjC methods (#105)
* Better name for setter only properties, e.g.
	-       [query set_Secret: 1];
	+       [query setSecret: 1];

* Second method argument should be lowercased, e.g. `second`
	[Methods_Parameters concatFirst:@"first" second:@"second"]

* Reduce some code duplication, to avoid fixing things multiple times, e.g.
	* Unify the signatures generation for ObjC and Mono;
	* Unify the parameter marshaling code (the one for methods was missing a lot)

* Simplify `ImplementMethod` arguments
2017-04-12 07:48:25 +02:00
Vincent Dondain bb16097c23 [objc][generator] Update type/pointer spacing to follow ObjC conventions (#95)
* [objc][generator] Update type/pointer spacing to follow ObjC conventions

The convention is that there's a space between the type and the pointer character (*) in Objective-C.
See: https://developer.apple.com/library/content/documentation/Cocoa/Conceptual/CodingGuidelines/Articles/NamingMethods.html#//apple_ref/doc/uid/20001282-BCIGIJJF
_Note: Apple's frameworks are using this convention too._

* [objc][generator][tests] Fixed NSString * test
2017-04-11 12:00:22 -05:00
Sebastien Pouliot 1bdeef1dd8 [objc][generator] Use metadata token lookup when building release (#91)
* [objc][generator] Use metadata token lookup when building release

where release is non-debug.

https://github.com/mono/Embeddinator-4000/issues/82

* [tests] Run test-cli and perf-cli in release (non debug) mode
2017-04-11 17:21:54 +02:00
Rolf Bjarne Kvinge 7de0e3f0cc [objc] Add support fat and static libraries for all platforms. (#97)
[objc] Add support fat and static libraries for all platforms.
2017-04-11 15:25:40 +02:00
Joao Matos 9fedc6a59c [tests] Fixed path to JNA Jar file to work with non-submodule'd JNA. 2017-04-11 13:09:37 +01:00
Joao Matos 0f370e3d2c Merge branch 'objc' 2017-04-11 12:52:42 +01:00
Sebastien Pouliot e62cb1b80e [objc][support] Move MonoString to NSString conversion into it's own routine (to avoid several dupes in generated code) (#94) 2017-04-11 08:35:10 +02:00
Joao Matos 3322a1bef5 [java][tests] Added initial implementation and build rules of unit testing for Java. 2017-04-10 22:59:12 +01:00
Joao Matos 47dbbc4c63 [c] Implemented marshaling for explicitly signed char types. 2017-04-10 22:46:48 +01:00
Joao Matos 5d0e4c7315 [git] Updated Git ignore patterns to ignore Java build artifacts. 2017-04-10 19:57:44 +01:00
Sebastien Pouliot 7d20bde00f [objc] Fix subclassing when `init` is not available (#85)
It's similar to XI/XM NSObjectFlag - we need a different road to call
the base classes without calling managed code twice (e.g. the Super
and Base tests for exceptions).

Note: `init` is not always exposed, so we cannot trust it blindly.

This allow the same "internal" `initWithSuper` to be re-used to return
instance of types being bound (e.g. a `+create` without a `-init`).
2017-04-10 19:12:24 +02:00
Rolf Bjarne Kvinge 790046d6ac [objc] Improve Makefile dependencies to only rebuild things if needed. (#76) 2017-04-07 20:05:25 +02:00
Sebastien Pouliot 64720b0859 [test][objc] Fix Makefile not to delete leak-at-exit.c (#81)
That one is not a generated file
2017-04-07 17:12:17 +02:00
Joao Matos 8337944b02 [tests] Renamed Basic test project to common. 2017-04-07 12:29:03 +01:00
Rolf Bjarne Kvinge 79fa12070a [tests][objc] Improve Makefile dependencies to only rebuild things if needed. (#78) 2017-04-07 12:24:53 +02:00
Rolf Bjarne Kvinge b75dc6aa62 [tests][leaktest] Use pid-specific control files. (#77)
Use pid-specific control files so multiple leak tests can run in parallel.
2017-04-07 12:24:39 +02:00
Joao Matos 6fc2759ede [tests] Overhauled generator test suite to re-use "managed" shared test project.
Additionally the test logic is now driven by a Makefile instead of just Premake.
2017-04-07 03:05:51 +01:00
Joao Matos 88077be14c [tests] Extend managed test suite project with pre-existing tests. 2017-04-07 01:47:35 +01:00
Rolf Bjarne Kvinge 21f7a853c1 [objc] Use enums instead of string values for platform/target/compilationtarget, and add initial scaffolding for iOS/watchOS/tvOS + framework support. (#69) 2017-04-06 17:28:24 +02:00
Joao Matos a0d18a5e80 [tests] Remove generated makefiles. 2017-04-06 16:22:19 +01:00
Sebastien Pouliot a13e48abc6 [objc] The same type name can exists in several namespaces (#68)
Not common, but has to work. Unit test added.
2017-04-06 10:15:51 -05:00
Rolf Bjarne Kvinge c2e0eba081 [objc] Add memory leak tests, and fix a few issues those found. (#65)
* [tests] [objc-cli] Improve a few Makefile targets to have correct dependencies.

* [objc] Generate a dealloc method that handles object destruction.

* [objc] Fix a memory leak when searching for assemblies.

`mono_embeddinator_search_assembly` returns a string that must be freed, so
free it.

* [objc][tests] Add leak tests.

* [tests][objc] Try running leaks with sudo if we don't have a controlling terminal.

Otherwise this happens on Jenkins:

> leaks[33383]: [fatal] unable to ask for permission to examine process; run tool using sudo, or without redirecting stdin and stderr.

* [objc] Fix chained init methods and avoid chaining dealloc.

In an init method we must only create the managed object if a derived class
hasn't already created it.

Also we must only dealloc once in the inheritance hierarchy.
2017-04-06 15:50:43 +02:00
Sebastien Pouliot 946ed79896 [objc] Initial support for methods (#67)
This also handle the case of setter-only properties (generated as a
set* method).

Unit tests added for existing methods (previously not generated)

Replace PR https://github.com/mono/Embeddinator-4000/pull/63
2017-04-06 08:46:24 -05:00
Sebastien Pouliot 7c2384d729 [objc][generator] Fix subclassing when both types are bound (#62)
E.g. `public class SuperUnique : Unique {}`

This raise an interesting issue (to be solved later) since ObjC and .NET
semantics differs for init*/.ctor. A test case (with a FIXME) is added.

and I now recall why headers were a bad idea:

./bindings.h:75:39: error: attempting to use the forward class 'Constructors_Unique' as superclass of 'Constructors_SuperUnique'

so the ordering of forwarders had to be altered a bit.
2017-04-06 11:59:58 +02:00
Sebastien Pouliot 38357f1ac7 [objc][driver] Command-line options parity with master (#61)
This will help scripts to switch between implementations.
2017-04-06 09:29:16 +02:00
Rolf Bjarne Kvinge 3bae118183 [objc] Enforce ARC. (#60)
Also remove the NSAutoreleasePool code, the current code doesn't build with
ARC, and in any case it's the consumer's responsibility to ensure there's an
NSAutoreleasePool on the stack.
2017-04-05 14:08:52 -05:00
Sebastien Pouliot 9db995bfe1 [objc] Add support for non-default init* methods (constructors) (#59) 2017-04-05 08:46:12 +02:00
Sebastien Pouliot ca5545cae4 [objc][tests] Add more unit tests for existing features (#56)
For
* instance properties (uncomment them);
* namespaces;
* exceptions inside `init`;
2017-04-04 09:43:01 +02:00
Rolf Bjarne Kvinge d6003c415b [objc][tests] Remove the 'libmanaged' target from the Xcode cli test project. (#55)
Remove the 'libmanaged' target from the Xcode test project, and instead link
with the libmanaged.dylib that the embeddinator compiles. This ensures we're
not compiling with different compiler flags in the Xcode project.

This also requires adding an rpath to the built library so that the test
executable can find it.

Also add makefile target to run the Xcode test project from the command line.
2017-04-03 13:25:34 -05:00
Sebastien Pouliot b560ed5c39 [objc] Add -c[ompile] option to the driver (#54) 2017-04-03 11:53:21 -05:00
Rolf Bjarne Kvinge b89e3cf8a0 [objc] Add support for building the native library with debug information. (#53) 2017-04-03 10:55:50 -05:00
Rolf Bjarne Kvinge c0b00f4222 [objc] Add support for more primitive types. (#51) 2017-04-03 10:42:32 -05:00
Rolf Bjarne Kvinge 7c09a324ef [objc][tests] Automatically rebuild the generator before running tests. (#52) 2017-04-03 10:14:25 -05:00
Sebastien Pouliot d49fc8c666 [objc] Add support for -o (output directory) and -v (verbosity) and add some error codes (#39)
* EM0000 is now shown for unhandled exceptions - asking for a bug report
  to be submitted;

* EM0001 is reported when the output directory cannot be found;

* EM1000 is reported when the generator throws a NotImplementedException,
  no bug report is required, but contributions are welcome :)
2017-04-03 09:24:36 -05:00
Rolf Bjarne Kvinge 0ff824da7c [objc][tests] Always rebuild managed.dll before running cli tests. (#50) 2017-04-03 08:55:42 -05:00
Rolf Bjarne Kvinge 3553b9951d [objc][tests] Build the project file instead of having separate build logic. (#49) 2017-04-03 08:55:14 -05:00
Sebastien Pouliot d4775744bf [objc] Add support for default .ctor/init and namespaces (#38) 2017-04-03 08:23:57 -05:00
Sebastien Pouliot fdb0041515 [objc] Add xcode support for objc-cli to build the libmanaged.dylib and it's unit tests (#42)
This allows debugging the generated code with Xcode as well as
running the native unit tests with XCTest (which might not be the
best tool but it's good to support).

This commit requires a addition to mono_embeddinator so we can
override where the assemblies are loaded from - we cannot assume
they will be with the executable (e.g. plugin) and we hit this
case with Xcode unit tests.
2017-04-03 14:33:05 +02:00
Sebastien Pouliot 83ec1a965d [objc] Merge master. (#46)
This should fix travis-ci marking all macOS builds as broken/red.
2017-04-02 13:37:16 -05:00
Sebastien Pouliot 514e20f437 [docs] Start a limitations document and add read me for the new directories created in the objc branch (#45) 2017-04-02 13:25:42 -05:00
Sebastien Pouliot 7d1ac85de2 [build] .gitignore had an entry for Makefile so some were not committed previously (#44) 2017-04-02 13:13:47 -05:00
Sebastien Pouliot 6e35580f8f [tests] Remove generated files from tests/objc-cli (#41) 2017-04-01 16:28:36 -05:00
Rolf Bjarne Kvinge 2c7052bf69 [objc] Add support for running tests from the command line. (#34)
* [objc] Add support for running tests from the command line.

* [objc][test] Write test results in NUnit v2 format.

So that Jenkins understands it.
2017-03-31 13:13:51 -05:00
Rolf Bjarne Kvinge 7d22482959 [objc] Add error handling. (#33) 2017-03-31 13:12:12 -05:00