@@ -230,7 +230,19 @@ public class CSharpToCppTransformer : Transformer
230230 ( new Regex ( @"(\r?\n[\t ]+)[a-zA-Z0-9]+ ([a-zA-Z0-9]+) = new ([a-zA-Z0-9]+)\[([_a-zA-Z0-9]+)\];" ) , "$1$3 $2[$4] = { {0} };" , null , 0 ) ,
231231 // public: static event EventHandler<std::exception> ExceptionIgnored = OnExceptionIgnored; ... };
232232 // ... public: static inline Platform::Delegates::MulticastDelegate<void(void*, const std::exception&)> ExceptionIgnored = OnExceptionIgnored; };
233- ( 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 + "${halfIndent}${halfIndent}${access}static inline Platform::Delegates::MulticastDelegate<void(void*, const ${argumentType}&)> ${name} = ${defaultDelegate};${end}" , null , 0 ) ,
233+ ( 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 + "${halfIndent}${halfIndent}${access}static inline Platform::Delegates::MulticastDelegate<void(void*, const ${argumentType}&)> ${name} = ${defaultDelegate};${end}" , null , 0 ) ,
234+ // Insert scope borders.
235+ // class IgnoredExceptions { ... public: static inline Platform::Delegates::MulticastDelegate<void(void*, const std::exception&)> ExceptionIgnored = OnExceptionIgnored;
236+ // class IgnoredExceptions {/*~ExceptionIgnored~*/ ... public: static inline Platform::Delegates::MulticastDelegate<void(void*, const std::exception&)> ExceptionIgnored = OnExceptionIgnored;
237+ ( new Regex ( @"(?<classDeclarationBegin>\r?\n(?<indent>[\t ]*)class [^{\r\n] \r\n[\t ]*{)(?<middle>((?!class).|\n)+?)(?<eventDeclaration>(?<access>(private|protected|public): )static inline Platform::Delegates::MulticastDelegate<(?<argumentType>[^;\r\n]+)> (?<name>[_a-zA-Z0-9]+) = (?<defaultDelegate>[_a-zA-Z0-9]+);)" ) , "${classDeclarationBegin}/*~${name}~*/${middle}${eventDeclaration}" , null , 0 ) ,
238+ // Inside the scope of ~!ExceptionIgnored!~ replace:
239+ // ExceptionIgnored.Invoke(NULL, exception);
240+ // ExceptionIgnored(NULL, exception);
241+ ( new Regex ( @"(?<scope>/\*~(?<eventName>[a-zA-Z0-9]+)~\*/)(?<separator>.|\n)(?<before>((?<!/\*~\k<eventName>~\*/)(.|\n))*?)\k<eventName>\.Invoke" ) , "${scope}${separator}${before}${eventName}" , null , 10 ) ,
242+ // Remove scope borders.
243+ // /*~ExceptionIgnored~*/
244+ //
245+ ( new Regex ( @"/\*~[a-zA-Z0-9]+~\*/" ) , "" , null , 0 ) ,
234246 // Insert scope borders.
235247 // auto added = new StringBuilder();
236248 // /*~sb~*/std::string added;
@@ -254,7 +266,7 @@ public class CSharpToCppTransformer : Transformer
254266 // Remove scope borders.
255267 // /*~sb~*/
256268 //
257- ( new Regex ( @"/\*~(?<pointer> [a-zA-Z0-9]+) ~\*/" ) , "" , null , 0 ) ,
269+ ( new Regex ( @"/\*~[a-zA-Z0-9]+~\*/" ) , "" , null , 0 ) ,
258270 // Insert scope borders.
259271 // auto added = new HashSet<TElement>();
260272 // ~!added!~std::unordered_set<TElement> added;
@@ -273,7 +285,7 @@ public class CSharpToCppTransformer : Transformer
273285 // Remove scope borders.
274286 // ~!added!~
275287 //
276- ( new Regex ( @"~!(?<pointer> [a-zA-Z0-9]+) !~" ) , "" , null , 5 ) ,
288+ ( new Regex ( @"~![a-zA-Z0-9]+!~" ) , "" , null , 5 ) ,
277289 // Insert scope borders.
278290 // auto random = new System.Random(0);
279291 // std::srand(0);
@@ -285,7 +297,7 @@ public class CSharpToCppTransformer : Transformer
285297 // Remove scope borders.
286298 // ~!random!~
287299 //
288- ( new Regex ( @"~!(?<pointer> [a-zA-Z0-9]+) !~" ) , "" , null , 5 ) ,
300+ ( new Regex ( @"~![a-zA-Z0-9]+!~" ) , "" , null , 5 ) ,
289301 // Insert method body scope starts.
290302 // void PrintNodes(TElement node, StringBuilder sb, int level) {
291303 // void PrintNodes(TElement node, StringBuilder sb, int level) {/*method-start*/
@@ -332,8 +344,8 @@ public class CSharpToCppTransformer : Transformer
332344 // return &_elements[node];
333345 ( new Regex ( @"return ref ([_a-zA-Z0-9]+)\[([_a-zA-Z0-9\*]+)\];" ) , "return &$1[$2];" , null , 0 ) ,
334346 // null
335- // NULL
336- ( new Regex ( @"(?<before>\r?\n[^""\r\n]*(""(\\""|[^""\r\n])*""[^""\r\n]*)*)(?<=\W)null(?<after>\W)" ) , "${before}NULL$ {after}" , null , 10 ) ,
347+ // nullptr
348+ ( new Regex ( @"(?<before>\r?\n[^""\r\n]*(""(\\""|[^""\r\n])*""[^""\r\n]*)*)(?<=\W)null(?<after>\W)" ) , "${before}nullptr {after}" , null , 10 ) ,
337349 // default
338350 // 0
339351 ( new Regex ( @"(?<before>\r?\n[^""\r\n]*(""(\\""|[^""\r\n])*""[^""\r\n]*)*)(?<=\W)default(?<after>\W)" ) , "${before}0${after}" , null , 10 ) ,
0 commit comments