Browse Source

Fixed the FunctionToStaticMethod pass to make sure we do not apply it when the function and class have different translation units. This can be improved in the future, for which I left a TODO.

pull/144/head
triton 12 years ago
parent
commit
db2652c9e4
  1. 8
      src/Generator/Passes/FunctionToStaticMethodPass.cs

8
src/Generator/Passes/FunctionToStaticMethodPass.cs

@ -26,12 +26,18 @@ namespace CppSharp.Passes
if (@class == null) if (@class == null)
return false; return false;
// TODO: If the translation units of the declarations are different,
// and we apply the pass, we might need additional includes in the
// generated translation unit of the class.
if (@class.TranslationUnit != function.TranslationUnit)
return false;
// Clean up the name of the function now that it will be a static method. // Clean up the name of the function now that it will be a static method.
var name = function.Name.Substring(@class.Name.Length); var name = function.Name.Substring(@class.Name.Length);
function.ExplicityIgnored = true; function.ExplicityIgnored = true;
// Create a new fake method so it acts as a static method. // Create a new fake method so it acts as a static method.
var method = new Method() var method = new Method
{ {
Namespace = @class, Namespace = @class,
OriginalNamespace = function.Namespace, OriginalNamespace = function.Namespace,

Loading…
Cancel
Save