@@ -357,16 +357,16 @@ public class CSharpToCppTransformer : TextTransformer
357357 // TElement path[MaxPath] = { {0} };
358358 ( 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} };" , 0 ) ,
359359 // bool Equals(Range<T> other) { ... }
360- // bool operator ==(const Key & other) const { ... }
361- ( new Regex ( @"(?<before>\r?\n[^\n]+bool )Equals\((?<type>[^\n{]+) (?<variable>[a-zA-Z0-9]+)\)(?<after>(\s|\n)*{)" ) , "${before}operator ==(const ${type} & ${variable}) const${after}" , 0 ) ,
360+ // bool operator ==(const Key& other) const { ... }
361+ ( new Regex ( @"(?<before>\r?\n[^\n]+bool )Equals\((?<type>[^\n{]+) (?<variable>[a-zA-Z0-9]+)\)(?<after>(\s|\n)*{)" ) , "${before}operator ==(const ${type}& ${variable}) const${after}" , 0 ) ,
362362 // Insert scope borders.
363363 // class Range { ... public: override std::string ToString() { return ...; }
364364 // class Range {/*~Range<T>~*/ ... public: override std::string ToString() { return ...; }
365365 ( new Regex ( @"(?<classDeclarationBegin>\r?\n(?<indent>[\t ]*)template <typename (?<typeParameter>[^<>\n]+)> (struct|class) (?<type>[a-zA-Z0-9]+<\k<typeParameter>>)(\s*:\s*[^{\n]+)?[\t ]*(\r?\n)?[\t ]*{)(?<middle>((?!class|struct).|\n)+?)(?<toStringDeclaration>(?<access>(private|protected|public): )override std::string ToString\(\))" ) , "${classDeclarationBegin}/*~${type}~*/${middle}${toStringDeclaration}" , 0 ) ,
366366 // Inside the scope of ~!Range!~ replace:
367367 // public: override std::string ToString() { return ...; }
368- // public: operator std::string() const { return ...; }\n\npublic: friend std::ostream & operator <<(std::ostream & out, const A & obj) { return out << (std::string)obj; }
369- ( new Regex ( @"(?<scope>/\*~(?<type>[_a-zA-Z0-9<>:]+)~\*/)(?<separator>.|\n)(?<before>((?<!/\*~\k<type>~\*/)(.|\n))*?)(?<toStringDeclaration>\r?\n(?<indent>[ \t]*)(?<access>(private|protected|public): )override std::string ToString\(\) (?<toStringMethodBody>{[^}\n]+}))" ) , "${scope}${separator}${before}" + Environment . NewLine + "${indent}${access}operator std::string() const ${toStringMethodBody}" + Environment . NewLine + Environment . NewLine + "${indent}${access}friend std::ostream & operator <<(std::ostream & out, const ${type} & obj) { return out << (std::string)obj; }" , 0 ) ,
368+ // public: operator std::string() const { return ...; }\n\npublic: friend std::ostream& operator <<(std::ostream& out, const A& obj) { return out << (std::string)obj; }
369+ ( new Regex ( @"(?<scope>/\*~(?<type>[_a-zA-Z0-9<>:]+)~\*/)(?<separator>.|\n)(?<before>((?<!/\*~\k<type>~\*/)(.|\n))*?)(?<toStringDeclaration>\r?\n(?<indent>[ \t]*)(?<access>(private|protected|public): )override std::string ToString\(\) (?<toStringMethodBody>{[^}\n]+}))" ) , "${scope}${separator}${before}" + Environment . NewLine + "${indent}${access}operator std::string() const ${toStringMethodBody}" + Environment . NewLine + Environment . NewLine + "${indent}${access}friend std::ostream& operator <<(std::ostream& out, const ${type}& obj) { return out << (std::string)obj; }" , 0 ) ,
370370 // Remove scope borders.
371371 // /*~Range~*/
372372 //
@@ -578,8 +578,8 @@ public class CSharpToCppTransformer : TextTransformer
578578 ( new Regex ( @"(?<classDeclarationBegin>\r?\n(?<indent>[\t ]*)template <typename (?<typeParameter>[^\n]+)> (struct|class) (?<type>[a-zA-Z0-9]+<\k<typeParameter>>)(\s*:\s*[^{\n]+)?[\t ]*(\r?\n)?[\t ]*{)(?<middle>(.|\n)*)(?<endIndent>(?<=\r?\n)\k<indent>)(?<end>};)" ) , "${classDeclarationBegin}/*~start~type~${type}~${typeParameter}~*/${middle}${endIndent}/*~end~type~${type}~${typeParameter}~*/${end}" , 0 ) ,
579579 // Inside the scope replace:
580580 // /*~start~namespace~Platform::Ranges~*/ ... /*~start~type~Range<T>~T~*/ ... public: override std::int32_t GetHashCode() { return {Minimum, Maximum}.GetHashCode(); } ... /*~end~type~Range<T>~T~*/ ... /*~end~namespace~Platform::Ranges~*/
581- // /*~start~namespace~Platform::Ranges~*/ ... /*~start~type~Range<T>~T~*/ ... /*~end~type~Range<T>~T~*/ ... /*~end~namespace~Platform::Ranges~*/ namespace std { template <typename T> struct hash<Platform::Ranges::Range<T>> { std::size_t operator()(const Platform::Ranges::Range<T> & obj) const { return {Minimum, Maximum}.GetHashCode(); } }; }
582- ( new Regex ( @"(?<namespaceScopeStart>/\*~start~namespace~(?<namespace>[^~\n\*]+)~\*/)(?<betweenStartScopes>(.|\n)+)(?<typeScopeStart>/\*~start~type~(?<type>[^~\n\*]+)~(?<typeParameter>[^~\n\*]+)~\*/)(?<before>(.|\n)+?)(?<hashMethodDeclaration>\r?\n[ \t]*(?<access>(private|protected|public): )override std::int32_t GetHashCode\(\)(\s|\n)*{\s*(?<methodBody>[^\s][^\n]+[^\s])\s*}\s*)(?<after>(.|\n)+?)(?<typeScopeEnd>/\*~end~type~\k<type>~\k<typeParameter>~\*/)(?<betweenEndScopes>(.|\n)+)(?<namespaceScopeEnd>/\*~end~namespace~\k<namespace>~\*/)}\r?\n" ) , "${namespaceScopeStart}${betweenStartScopes}${typeScopeStart}${before}${after}${typeScopeEnd}${betweenEndScopes}${namespaceScopeEnd}}" + Environment . NewLine + Environment . NewLine + "namespace std" + Environment . NewLine + "{" + Environment . NewLine + " template <typename ${typeParameter}>" + Environment . NewLine + " struct hash<${namespace}::${type}>" + Environment . NewLine + " {" + Environment . NewLine + " std::size_t operator()(const ${namespace}::${type} &obj) const" + Environment . NewLine + " {" + Environment . NewLine + " /*~start~method~*/${methodBody}/*~end~method~*/" + Environment . NewLine + " }" + Environment . NewLine + " };" + Environment . NewLine + "}" + Environment . NewLine , 10 ) ,
581+ // /*~start~namespace~Platform::Ranges~*/ ... /*~start~type~Range<T>~T~*/ ... /*~end~type~Range<T>~T~*/ ... /*~end~namespace~Platform::Ranges~*/ namespace std { template <typename T> struct hash<Platform::Ranges::Range<T>> { std::size_t operator()(const Platform::Ranges::Range<T>& obj) const { return {Minimum, Maximum}.GetHashCode(); } }; }
582+ ( new Regex ( @"(?<namespaceScopeStart>/\*~start~namespace~(?<namespace>[^~\n\*]+)~\*/)(?<betweenStartScopes>(.|\n)+)(?<typeScopeStart>/\*~start~type~(?<type>[^~\n\*]+)~(?<typeParameter>[^~\n\*]+)~\*/)(?<before>(.|\n)+?)(?<hashMethodDeclaration>\r?\n[ \t]*(?<access>(private|protected|public): )override std::int32_t GetHashCode\(\)(\s|\n)*{\s*(?<methodBody>[^\s][^\n]+[^\s])\s*}\s*)(?<after>(.|\n)+?)(?<typeScopeEnd>/\*~end~type~\k<type>~\k<typeParameter>~\*/)(?<betweenEndScopes>(.|\n)+)(?<namespaceScopeEnd>/\*~end~namespace~\k<namespace>~\*/)}\r?\n" ) , "${namespaceScopeStart}${betweenStartScopes}${typeScopeStart}${before}${after}${typeScopeEnd}${betweenEndScopes}${namespaceScopeEnd}}" + Environment . NewLine + Environment . NewLine + "namespace std" + Environment . NewLine + "{" + Environment . NewLine + " template <typename ${typeParameter}>" + Environment . NewLine + " struct hash<${namespace}::${type}>" + Environment . NewLine + " {" + Environment . NewLine + " std::size_t operator()(const ${namespace}::${type}& obj) const" + Environment . NewLine + " {" + Environment . NewLine + " /*~start~method~*/${methodBody}/*~end~method~*/" + Environment . NewLine + " }" + Environment . NewLine + " };" + Environment . NewLine + "}" + Environment . NewLine , 10 ) ,
583583 // Inside scope of /*~start~method~*/ replace:
584584 // /*~start~method~*/ ... Minimum ... /*~end~method~*/
585585 // /*~start~method~*/ ... obj.Minimum ... /*~end~method~*/
@@ -624,7 +624,7 @@ public class CSharpToCppTransformer : TextTransformer
624624 // /*~app-domain~_currentDomain~*/ ... /* No translation. It is not possible to unsubscribe from std::atexit. */
625625 ( new Regex ( @"(?<before>(?<fieldScopeStart>/\*~app-domain~(?<field>[^~\n\*]+)~\*/)(.|\n)+?\r?\n[\t ]*)\k<field>\.ProcessExit[\t ]*\-=[\t ]*(?<eventHandler>[a-zA-Z_][a-zA-Z0-9_]*);" ) , "${before}/* No translation. It is not possible to unsubscribe from std::atexit. */" , 20 ) ,
626626 // Inside the scope replace:
627- // /*~process-exit-handler~OnProcessExit~*/ ... static void OnProcessExit(void * sender, EventArgs e)
627+ // /*~process-exit-handler~OnProcessExit~*/ ... static void OnProcessExit(void* sender, EventArgs e)
628628 // /*~process-exit-handler~OnProcessExit~*/ ... static void OnProcessExit()
629629 ( new Regex ( @"(?<before>(?<fieldScopeStart>/\*~process-exit-handler~(?<handler>[^~\n\*]+)~\*/)(.|\n)+?static[\t ]+void[\t ]+\k<handler>\()[^()\n]+\)" ) , "${before})" , 20 ) ,
630630 // Remove scope borders.
@@ -645,11 +645,11 @@ public class CSharpToCppTransformer : TextTransformer
645645 public static readonly IList < ISubstitutionRule > LastStage = new List < SubstitutionRule >
646646 {
647647 // IDisposable disposable)
648- // IDisposable & disposable)
649- ( new Regex ( @"(?<argumentAbstractType>I[A-Z][a-zA-Z0-9]+(<[^>\r\n]+>)?) (?<argument>[_a-zA-Z0-9]+)(?<after>,|\))" ) , "${argumentAbstractType} & ${argument}${after}" , 0 ) ,
648+ // IDisposable& disposable)
649+ ( new Regex ( @"(?<argumentAbstractType>I[A-Z][a-zA-Z0-9]+(<[^>\r\n]+>)?) (?<argument>[_a-zA-Z0-9]+)(?<after>,|\))" ) , "${argumentAbstractType}& ${argument}${after}" , 0 ) ,
650650 // ICounter<int, int> c1;
651651 // ICounter<int, int>* c1;
652- ( new Regex ( @"(?<abstractType>I[A-Z][a-zA-Z0-9]+(<[^>\r\n]+>)?) (?<variable>[_a-zA-Z0-9]+)(?<after> = null)?;" ) , "${abstractType} * ${variable}${after};" , 0 ) ,
652+ ( new Regex ( @"(?<abstractType>I[A-Z][a-zA-Z0-9]+(<[^>\r\n]+>)?) (?<variable>[_a-zA-Z0-9]+)(?<after> = null)?;" ) , "${abstractType}* ${variable}${after};" , 0 ) ,
653653 // (expression)
654654 // expression
655655 ( new Regex ( @"(\(| )\(([a-zA-Z0-9_\*:]+)\)(,| |;|\))" ) , "$1$2$3" , 0 ) ,
@@ -684,8 +684,8 @@ public class CSharpToCppTransformer : TextTransformer
684684 // 0
685685 ( new Regex ( @"(?<before>\r?\n[^""\r\n]*(""(\\""|[^""\r\n])*""[^""\r\n]*)*)(?<=\W)default(?<after>\W)" ) , "${before}0${after}" , 10 ) ,
686686 // object x
687- // void * x
688- ( new Regex ( @"(?<before>\r?\n[^""\r\n]*(""(\\""|[^""\r\n])*""[^""\r\n]*)*)(?<=\W)(?<!@)(object|System\.Object) (?<after>\w)" ) , "${before}void * ${after}" , 10 ) ,
687+ // void* x
688+ ( new Regex ( @"(?<before>\r?\n[^""\r\n]*(""(\\""|[^""\r\n])*""[^""\r\n]*)*)(?<=\W)(?<!@)(object|System\.Object) (?<after>\w)" ) , "${before}void* ${after}" , 10 ) ,
689689 // <object>
690690 // <void*>
691691 ( new Regex ( @"(?<before>\r?\n[^""\r\n]*(""(\\""|[^""\r\n])*""[^""\r\n]*)*)(?<=\W)(?<!@)(object|System\.Object)(?<after>\W)" ) , "${before}void*${after}" , 10 ) ,
0 commit comments