Browse Source

Fixed a regression causing a run-time crash with moved operators.

Signed-off-by: Dimitar Dobrev <dpldobrev@yahoo.com>
pull/57/head
Dimitar Dobrev 12 years ago
parent
commit
2848ee7453
  1. 6
      src/AST/Method.cs
  2. 2
      src/Generator/Passes/CheckOperatorsOverloads.cs
  3. 21
      src/Generator/Passes/MoveOperatorToClassPass.cs

6
src/AST/Method.cs

@ -92,6 +92,12 @@ namespace CppSharp.AST @@ -92,6 +92,12 @@ namespace CppSharp.AST
Conversion = method.Conversion;
}
public Method(Function function)
: base(function)
{
}
public AccessSpecifierDecl AccessDecl { get; set; }
public bool IsVirtual { get; set; }

2
src/Generator/Passes/CheckOperatorsOverloads.cs

@ -54,6 +54,8 @@ namespace CppSharp.Passes @@ -54,6 +54,8 @@ namespace CppSharp.Passes
@operator.ExplicityIgnored = true;
continue;
}
if (@operator.SynthKind == FunctionSynthKind.NonMemberOperator)
continue;
// Handle missing operator parameters
if (@operator.IsStatic)

21
src/Generator/Passes/MoveOperatorToClassPass.cs

@ -23,27 +23,20 @@ namespace CppSharp.Passes @@ -23,27 +23,20 @@ namespace CppSharp.Passes
if (!FunctionToInstanceMethodPass.GetClassParameter(param, out @class))
return false;
function.ExplicityIgnored = true;
// Create a new fake method so it acts as a static method.
var method = new Method()
var method = new Method(function)
{
Namespace = @class,
OriginalNamespace = @class,
Name = function.Name,
OriginalName = function.OriginalName,
Mangled = function.Mangled,
Access = AccessSpecifier.Public,
Kind = CXXMethodKind.Operator,
ReturnType = function.ReturnType,
Parameters = new List<Parameter>(function.Parameters).Skip(1).ToList(),
CallingConvention = function.CallingConvention,
IsVariadic = function.IsVariadic,
IsInline = function.IsInline,
OperatorKind = function.OperatorKind,
SynthKind = FunctionSynthKind.NonMemberOperator
SynthKind = FunctionSynthKind.NonMemberOperator,
OriginalFunction = null,
IsStatic = true
};
function.ExplicityIgnored = true;
@class.Methods.Add(method);
Driver.Diagnostics.Debug("Function converted to operator: {0}::{1}",

Loading…
Cancel
Save