Browse Source

Fixed a regression in the generator of C++/CLI.

Restored the sorting by order of definition.

Signed-off-by: Dimitar Dobrev <dpldobrev@protonmail.com>
pull/1149/head
Dimitar Dobrev 7 years ago
parent
commit
9a12db86d9
  1. 29
      src/AST/DeclarationsList.cs
  2. 44
      src/CppParser/Bindings/CLI/AST.h
  3. 15140
      src/CppParser/Bindings/CSharp/i686-apple-darwin12.4.0/CppSharp.CppParser.cs
  4. 15540
      src/CppParser/Bindings/CSharp/i686-pc-win32-msvc/CppSharp.CppParser.cs
  5. 15142
      src/CppParser/Bindings/CSharp/x86_64-apple-darwin12.4.0/CppSharp.CppParser.cs
  6. 15542
      src/CppParser/Bindings/CSharp/x86_64-linux-gnu-cxx11abi/CppSharp.CppParser.cs
  7. 15102
      src/CppParser/Bindings/CSharp/x86_64-linux-gnu/CppSharp.CppParser.cs
  8. 15544
      src/CppParser/Bindings/CSharp/x86_64-pc-win32-msvc/CppSharp.CppParser.cs

29
src/AST/DeclarationsList.cs

@ -33,13 +33,15 @@ namespace CppSharp.AST
{ {
Kind kind = GetKind(item); Kind kind = GetKind(item);
int offset = GetOffset(kind); int offset = GetOffset(kind);
if (GetStart(kind) < index && index < offset) // USR null means an artificial declaration, add at the end
if (item.USR == null)
{ {
base.InsertItem(index, item); base.InsertItem(offset, item);
} }
else else
{ {
base.InsertItem(offset, item); int i = BinarySearch(GetStart(kind), offset, item);
base.InsertItem(i, item);
} }
for (Kind i = kind; i <= Kind.Event; i++) for (Kind i = kind; i <= Kind.Event; i++)
{ {
@ -127,6 +129,27 @@ namespace CppSharp.AST
return 0; return 0;
} }
private int BinarySearch(int start, int end, Declaration item)
{
int middle = end;
while (start < end)
{
middle = (start + end) / 2;
if (item.DefinitionOrder < this[middle].DefinitionOrder &&
item.DefinitionOrder >= this[middle - 1].DefinitionOrder)
break;
if (item.DefinitionOrder < this[middle].DefinitionOrder)
end = middle;
else
start = ++middle;
}
return middle;
}
private Dictionary<Kind, int> offsets = new Dictionary<Kind, int>(); private Dictionary<Kind, int> offsets = new Dictionary<Kind, int>();
private enum Kind private enum Kind

44
src/CppParser/Bindings/CLI/AST.h

@ -444,7 +444,7 @@ namespace CppSharp
static operator CppSharp::Parser::AST::Type^(CppSharp::Parser::AST::TypeKind kind); static operator CppSharp::Parser::AST::Type^(CppSharp::Parser::AST::TypeKind kind);
protected: protected:
bool __ownsNativeInstance; bool __ownsNativeInstance;
}; };
@ -485,7 +485,7 @@ namespace CppSharp
void set(bool); void set(bool);
} }
protected: protected:
bool __ownsNativeInstance; bool __ownsNativeInstance;
}; };
@ -520,7 +520,7 @@ namespace CppSharp
void set(CppSharp::Parser::AST::TypeQualifiers^); void set(CppSharp::Parser::AST::TypeQualifiers^);
} }
protected: protected:
bool __ownsNativeInstance; bool __ownsNativeInstance;
}; };
@ -818,7 +818,7 @@ namespace CppSharp
void set(long); void set(long);
} }
protected: protected:
bool __ownsNativeInstance; bool __ownsNativeInstance;
}; };
@ -1131,7 +1131,7 @@ namespace CppSharp
void set(CppSharp::Parser::AST::Declaration^); void set(CppSharp::Parser::AST::Declaration^);
} }
protected: protected:
bool __ownsNativeInstance; bool __ownsNativeInstance;
}; };
@ -1171,7 +1171,7 @@ namespace CppSharp
void ClearComponents(); void ClearComponents();
protected: protected:
bool __ownsNativeInstance; bool __ownsNativeInstance;
}; };
@ -1218,7 +1218,7 @@ namespace CppSharp
void set(CppSharp::Parser::AST::VTableLayout^); void set(CppSharp::Parser::AST::VTableLayout^);
} }
protected: protected:
bool __ownsNativeInstance; bool __ownsNativeInstance;
}; };
@ -1265,7 +1265,7 @@ namespace CppSharp
void set(::System::IntPtr); void set(::System::IntPtr);
} }
protected: protected:
bool __ownsNativeInstance; bool __ownsNativeInstance;
}; };
@ -1300,7 +1300,7 @@ namespace CppSharp
void set(CppSharp::Parser::AST::Class^); void set(CppSharp::Parser::AST::Class^);
} }
protected: protected:
bool __ownsNativeInstance; bool __ownsNativeInstance;
}; };
@ -1416,7 +1416,7 @@ namespace CppSharp
void ClearBases(); void ClearBases();
protected: protected:
bool __ownsNativeInstance; bool __ownsNativeInstance;
}; };
@ -1583,7 +1583,7 @@ namespace CppSharp
static operator CppSharp::Parser::AST::Declaration^(CppSharp::Parser::AST::DeclarationKind kind); static operator CppSharp::Parser::AST::Declaration^(CppSharp::Parser::AST::DeclarationKind kind);
protected: protected:
bool __ownsNativeInstance; bool __ownsNativeInstance;
}; };
@ -1870,7 +1870,7 @@ namespace CppSharp
void set(System::String^); void set(System::String^);
} }
protected: protected:
bool __ownsNativeInstance; bool __ownsNativeInstance;
}; };
@ -2400,7 +2400,7 @@ namespace CppSharp
void set(int); void set(int);
} }
protected: protected:
bool __ownsNativeInstance; bool __ownsNativeInstance;
}; };
@ -2949,7 +2949,7 @@ namespace CppSharp
void ClearArguments(); void ClearArguments();
protected: protected:
bool __ownsNativeInstance; bool __ownsNativeInstance;
}; };
@ -3098,7 +3098,7 @@ namespace CppSharp
void set(CppSharp::Parser::AST::DeclarationKind); void set(CppSharp::Parser::AST::DeclarationKind);
} }
protected: protected:
bool __ownsNativeInstance; bool __ownsNativeInstance;
}; };
@ -3277,7 +3277,7 @@ namespace CppSharp
void ClearDependencies(); void ClearDependencies();
protected: protected:
bool __ownsNativeInstance; bool __ownsNativeInstance;
}; };
@ -3319,7 +3319,7 @@ namespace CppSharp
void ClearTranslationUnits(); void ClearTranslationUnits();
protected: protected:
bool __ownsNativeInstance; bool __ownsNativeInstance;
}; };
@ -3350,7 +3350,7 @@ namespace CppSharp
static operator CppSharp::Parser::AST::Comment^(CppSharp::Parser::AST::CommentKind kind); static operator CppSharp::Parser::AST::Comment^(CppSharp::Parser::AST::CommentKind kind);
protected: protected:
bool __ownsNativeInstance; bool __ownsNativeInstance;
}; };
@ -3489,7 +3489,7 @@ namespace CppSharp
void set(System::String^); void set(System::String^);
} }
protected: protected:
bool __ownsNativeInstance; bool __ownsNativeInstance;
}; };
@ -3702,7 +3702,7 @@ namespace CppSharp
void set(System::String^); void set(System::String^);
} }
protected: protected:
bool __ownsNativeInstance; bool __ownsNativeInstance;
}; };
@ -3796,7 +3796,7 @@ namespace CppSharp
void set(System::String^); void set(System::String^);
} }
protected: protected:
bool __ownsNativeInstance; bool __ownsNativeInstance;
}; };
@ -3913,7 +3913,7 @@ namespace CppSharp
void set(CppSharp::Parser::AST::FullComment^); void set(CppSharp::Parser::AST::FullComment^);
} }
protected: protected:
bool __ownsNativeInstance; bool __ownsNativeInstance;
}; };
} }

15140
src/CppParser/Bindings/CSharp/i686-apple-darwin12.4.0/CppSharp.CppParser.cs

File diff suppressed because it is too large Load Diff

15540
src/CppParser/Bindings/CSharp/i686-pc-win32-msvc/CppSharp.CppParser.cs

File diff suppressed because it is too large Load Diff

15142
src/CppParser/Bindings/CSharp/x86_64-apple-darwin12.4.0/CppSharp.CppParser.cs

File diff suppressed because it is too large Load Diff

15542
src/CppParser/Bindings/CSharp/x86_64-linux-gnu-cxx11abi/CppSharp.CppParser.cs

File diff suppressed because it is too large Load Diff

15102
src/CppParser/Bindings/CSharp/x86_64-linux-gnu/CppSharp.CppParser.cs

File diff suppressed because it is too large Load Diff

15544
src/CppParser/Bindings/CSharp/x86_64-pc-win32-msvc/CppSharp.CppParser.cs

File diff suppressed because it is too large Load Diff
Loading…
Cancel
Save