[Mac,iOS] Generate create_classes as C methods so they can be used from objc. (#2158)

This change introduces the export of create_classes methods as objc compatible, without enforcing Objective-C++ as the development language for custom registrar embedders by moving the stringbuilder flushing inside the extern "C" block.
Mark the generated linking code as extern "C" too and also change the return type of xamarin_create_classes_Xamarin_Mac to void in mmp generation, as it was mistakenly set to int.
This commit is contained in:
Marius Ungureanu 2017-06-02 00:19:04 -07:00 коммит произвёл Rolf Bjarne Kvinge
Родитель d4e11db773
Коммит 51cda3b468
4 изменённых файлов: 16 добавлений и 7 удалений

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

@ -3803,20 +3803,21 @@ namespace XamCore.Registrar {
Specialize (sb);
methods.WriteLine ();
methods.AppendLine ();
methods.AppendLine (sb);
methods.StringBuilder.AppendLine ("} /* extern \"C\" */");
FlushTrace ();
Driver.WriteIfDifferent (source_path, methods.ToString ());
header.AppendLine ();
header.AppendLine (declarations);
header.AppendLine (interfaces);
Driver.WriteIfDifferent (header_path, header.ToString ());
methods.WriteLine ();
methods.AppendLine ();
methods.AppendLine (sb);
Driver.WriteIfDifferent (source_path, methods.ToString ());
header.Dispose ();
header = null;
declarations.Dispose ();

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

@ -1113,7 +1113,7 @@ namespace Xamarin.Bundler {
sw.WriteLine ("#import <AppKit/NSAlert.h>");
sw.WriteLine ("#import <Foundation/NSDate.h>"); // 10.7 wants this even if not needed on 10.9
if (Driver.registrar == RegistrarMode.PartialStatic)
sw.WriteLine ("extern int xamarin_create_classes_Xamarin_Mac ();");
sw.WriteLine ("extern \"C\" void xamarin_create_classes_Xamarin_Mac ();");
sw.WriteLine ();
sw.WriteLine ();
sw.WriteLine ();

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

@ -615,7 +615,7 @@ namespace Xamarin.Bundler
if (registration_methods != null) {
foreach (var method in registration_methods) {
sw.Write ("void ");
sw.Write ("extern \"C\" void ");
sw.Write (method);
sw.WriteLine ("();");
}

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

@ -9,8 +9,16 @@
#include "xamarin/xamarin.h"
#ifdef __cplusplus
extern "C" {
#endif
void xamarin_create_classes_Xamarin_iOS ();
#ifdef __cplusplus
}
#endif
void xamarin_setup_impl ()
{
#if DEBUG