@@ -160,6 +160,9 @@ public class CSharpToCppTransformer : TextTransformer
160160 // Action<TElement> free
161161 // std::function<void(TElement)> free
162162 ( new Regex ( @"Action<([a-zA-Z0-9]+)> ([a-zA-Z0-9]+)" ) , "std::function<void($1)> $2" , 0 ) ,
163+ // Action action
164+ // std::function<void()> action
165+ ( new Regex ( @"Action ([a-zA-Z0-9]+)" ) , "std::function<void()> $1" , 0 ) ,
163166 // Predicate<TArgument> predicate
164167 // std::function<bool(TArgument)> predicate
165168 ( new Regex ( @"Predicate<([a-zA-Z0-9]+)> ([a-zA-Z0-9]+)" ) , "std::function<bool($1)> $2" , 0 ) ,
@@ -217,9 +220,6 @@ public class CSharpToCppTransformer : TextTransformer
217220 // char*[] args
218221 // char* args[]
219222 ( new Regex ( @"([_a-zA-Z0-9:\*]?)\[\] ([a-zA-Z0-9]+)" ) , "$1 $2[]" , 0 ) ,
220- // @object
221- // object
222- ( new Regex ( @"@([_a-zA-Z0-9]+)" ) , "$1" , 0 ) ,
223223 // float.MinValue
224224 // std::numeric_limits<float>::lowest()
225225 ( new Regex ( @"(?<before>\W)(?<type>std::[a-z0-9_]+|float|double)\.MinValue(?<after>\W)" ) , "${before}std::numeric_limits<${type}>::lowest()${after}" , 0 ) ,
@@ -334,6 +334,9 @@ public class CSharpToCppTransformer : TextTransformer
334334 // public: static event EventHandler<std::exception> ExceptionIgnored = OnExceptionIgnored; ... };
335335 // ... public: static inline Platform::Delegates::MulticastDelegate<void(void*, const std::exception&)> ExceptionIgnored = OnExceptionIgnored; };
336336 ( new Regex ( @"(?<begin>\r?\n(\r?\n)?(?<halfIndent>[ \t]+)\k<halfIndent>)(?<access>(private|protected|public): )?static event EventHandler<(?<argumentType>[^;\r\n]+)> (?<name>[_a-zA-Z0-9]+) = (?<defaultDelegate>[_a-zA-Z0-9]+);(?<middle>(.|\n)+?)(?<end>\r?\n\k<halfIndent>};)" ) , "${middle}" + Environment . NewLine + Environment . NewLine + "${halfIndent}${halfIndent}${access}static inline Platform::Delegates::MulticastDelegate<void(void*, const ${argumentType}&)> ${name} = ${defaultDelegate};${end}" , 0 ) ,
337+ // public: event Disposal OnDispose;
338+ // public: Platform::Delegates::MulticastDelegate<Disposal> OnDispose;
339+ ( new Regex ( @"(?<begin>(?<access>(private|protected|public): )?(static )?)event (?<type>[a-zA-Z][:_a-zA-Z0-9]+) (?<name>[a-zA-Z][_a-zA-Z0-9]+);" ) , "${begin}Platform::Delegates::MulticastDelegate<${type}> ${name};" , 0 ) ,
337340 // Insert scope borders.
338341 // class IgnoredExceptions { ... private: inline static std::vector<std::exception> _exceptionsBag;
339342 // class IgnoredExceptions {/*~_exceptionsBag~*/ ... private: inline static std::vector<std::exception> _exceptionsBag;
@@ -578,10 +581,13 @@ public class CSharpToCppTransformer : TextTransformer
578581 ( new Regex ( @"(?<before>\r?\n[^""\r\n]*(""(\\""|[^""\r\n])*""[^""\r\n]*)*)(?<=\W)default(?<after>\W)" ) , "${before}0${after}" , 10 ) ,
579582 // object x
580583 // void *x
581- ( new Regex ( @"(?<before>\r?\n[^""\r\n]*(""(\\""|[^""\r\n])*""[^""\r\n]*)*)(?<=\W)([O|o]bject |System\.Object) (?<after>\w)" ) , "${before}void *${after}" , 10 ) ,
584+ ( new Regex ( @"(?<before>\r?\n[^""\r\n]*(""(\\""|[^""\r\n])*""[^""\r\n]*)*)(?<=\W)(?<!@)(object |System\.Object) (?<after>\w)" ) , "${before}void *${after}" , 10 ) ,
582585 // <object>
583586 // <void*>
584- ( new Regex ( @"(?<before>\r?\n[^""\r\n]*(""(\\""|[^""\r\n])*""[^""\r\n]*)*)(?<=\W)(?<!\w )([O|o]bject|System\.Object)(?<after>\W)" ) , "${before}void*${after}" , 10 ) ,
587+ ( new Regex ( @"(?<before>\r?\n[^""\r\n]*(""(\\""|[^""\r\n])*""[^""\r\n]*)*)(?<=\W)(?<!@)(object|System\.Object)(?<after>\W)" ) , "${before}void*${after}" , 10 ) ,
588+ // @object
589+ // object
590+ ( new Regex ( @"@([_a-zA-Z0-9]+)" ) , "$1" , 0 ) ,
585591 // ArgumentNullException
586592 // std::invalid_argument
587593 ( new Regex ( @"(?<before>\r?\n[^""\r\n]*(""(\\""|[^""\r\n])*""[^""\r\n]*)*)(?<=\W)(System\.)?ArgumentNullException(?<after>\W)" ) , "${before}std::invalid_argument${after}" , 10 ) ,
@@ -594,6 +600,12 @@ public class CSharpToCppTransformer : TextTransformer
594600 // template <typename T> struct Range : IEquatable<Range<T>>
595601 // template <typename T> struct Range {
596602 ( new Regex ( @"(?<before>template <typename (?<typeParameter>[^\n]+)> (struct|class) (?<type>[a-zA-Z0-9]+<[^\n]+>)) : (public )?IEquatable<\k<type>>(?<after>(\s|\n)*{)" ) , "${before}${after}" , 0 ) ,
603+ // public: delegate void Disposal(bool manual, bool wasDisposed);
604+ // public: delegate void Disposal(bool, bool);
605+ ( new Regex ( @"(?<before>(?<access>(private|protected|public): )delegate (?<returnType>[a-zA-Z][a-zA-Z0-9:]+) (?<delegate>[a-zA-Z][a-zA-Z0-9]+)\(((?<leftArgumentType>[a-zA-Z][a-zA-Z0-9:]+), )*)(?<argumentType>[a-zA-Z][a-zA-Z0-9:]+) (?<argumentName>[a-zA-Z][a-zA-Z0-9]+)(?<after>(, (?<rightArgumentType>[a-zA-Z][a-zA-Z0-9:]+) (?<rightArgumentName>[a-zA-Z][a-zA-Z0-9]+))*\);)" ) , "${before}${argumentType}${after}" , 20 ) ,
606+ // public: delegate void Disposal(bool, bool);
607+ // using Disposal = void(bool, bool);
608+ ( new Regex ( @"(?<access>(private|protected|public): )delegate (?<returnType>[a-zA-Z][a-zA-Z0-9:]+) (?<delegate>[a-zA-Z][a-zA-Z0-9]+)\((?<argumentTypes>[^\(\)\n]*)\);" ) , "using ${delegate} = ${returnType}(${argumentTypes});" , 20 ) ,
597609 // #region Always
598610 //
599611 ( new Regex ( @"(^|\r?\n)[ \t]*\#(region|endregion)[^\r\n]*(\r?\n|$)" ) , "" , 0 ) ,
0 commit comments