public static _Struct Copy(_Struct x, string name) { var r = new _Struct(name, x.forwardDecl); r.isInterface = x.isInterface; r.attributes = x.attributes; r.members = x.members; return(r); }
void _InitSymbols() { for (int i = 0; i < _ns.Length; i++) { _ns[i] = new _Namespace(); } _sbType = _ns[0].sb; _km = _keywordMemory = (char *)Marshal.AllocHGlobal(4000); //Add C++ keywords and types, except those that can only be in function body or other places where we skip. //The commented keywords/types are currently not supported and not expected to be in C/C++ headers that we'll parse. _Keyword k; //_AddKeywords(new _Keyword(cannotStartStatement:true), "__based", "_based"); //0 in SDK //_AddKeyword("__event", new _Keyword()); //0 in SDK //_AddKeyword("__identifier", new _Keyword()); //0 in SDK //_AddKeywords(new _Keyword(), "__if_exists", "_if_exists", "__if_not_exists", "_if_not_exists"); //0 in SDK. Usually used only in function body. //_AddKeywords(new _Keyword(cannotStartStatement: true), "__multiple_inheritance", "_multiple_inheritance", "__single_inheritance", "_single_inheritance", "__virtual_inheritance", "_virtual_inheritance"); //0 in SDK //_AddKeyword("__uuidof", new _Keyword(cannotStartStatement: true)); //should be only in function body //_AddKeyword("alignas", k = new _Keyword(cannotStartStatement: true)); //removed in script //_AddKeywords(new _Keyword(cannotStartStatement: true), "alignof", "__alignof"); //should be only in function body //_AddKeywords(new _Keyword(cannotStartStatement: true), "false", "true", "nullptr"); //we add enum values for it //_AddKeyword("property", k = new _Keyword()); //0 in SDK //_AddKeyword("signed", k = new _Keyword()); //replaced in script //_AddKeywords(new _Keyword(cannotStartStatement: true), "throw", "noexcept"); //eg void f() throw(int); //will be skipped together with functions //_AddKeyword("unsigned", k = new _Keyword()); //replaced in script k = new _Keyword(cannotStartStatement: true); _AddKeyword("sizeof", k); //can be like 'member[sizeof(X)]' or '#define X sizeof(Y)' k = new _Keyword(); _AddKeyword("const", k); _AddKeyword("extern", k); _AddKeyword("namespace", k); //0 in SDK (1 in CRT, which is removed) _AddKeyword("using", k); _AddKeyword("virtual", k); k = new _Keyword(_KeywordT.TypeDecl); _AddKeyword("__interface", k); _AddKeyword("class", k); _AddKeyword("enum", k); _AddKeyword("struct", k); _AddKeyword("typedef", k); _AddKeyword("union", k); _AddKeywords(new _Keyword(_KeywordT.CallConv, cannotStartStatement: true), "__cdecl", "_cdecl", "__fastcall", "_fastcall", "__stdcall", "_stdcall", "__thiscall"); _AddKeywords(new _Keyword(_KeywordT.IgnoreFuncEtc), "__forceinline", "__inline", "_inline", "inline", "template", "operator", "static_assert"); _AddKeywords(new _Keyword(_KeywordT.PubPrivProt), "private", "protected", "public"); //_AddKeywords(new _Keyword(_KeywordT.Ignore), "__unaligned", "__w64", "_w64", "volatile", "explicit", "friend", "mutable", "static", and so on); //removed in script //_AddKeywords(k = new _Keyword(_KeywordT.Declspec), "__declspec", "_declspec"); //removed in script _AddKeyword("uuid", k = new _Keyword(cannotStartStatement: true)); //was '__declspec(uuid', replaced in script _AddKeywords(new _CppType("sbyte", 1, false), "__int8", "char"); _AddKeywords(new _CppType("short", 2, false), "__int16", "short"); _AddKeywords(new _CppType("int", 4, false), "__int32", "int", "long"); _AddKeyword("__int64", new _CppType("long", 8, false)); _AddKeyword("double", new _CppType("double", 8, false)); _AddKeyword("float", new _CppType("float", 4, false)); _AddKeywords(new _CppType("char", 2, true), "__wchar_t", "wchar_t", "char16_t"); //our preprocessor script replaced 'unsigned type' to 'u$type' //also the script replaced 'signed type' to 'type, 'long long' to '__int64', 'long double' to 'double' _AddKeywords(new _CppType("byte", 1, true), "u$__int8", "u$char"); _AddKeywords(new _CppType("ushort", 2, true), "u$__int16", "u$short"); _AddKeywords(new _CppType("uint", 4, true), "u$__int32", "u$int", "u$long", "char32_t"); _AddKeyword("u$__int64", new _CppType("ulong", 8, true)); _AddKeyword("bool", new _CppType("bool", 1, false)); _AddKeyword("void", new _CppType("void", 0, false)); //_AddKeywords(new _Keyword(), "__m128", "__m128d", "__m128i"); //our script defined these as struct, because C# does not have a matching type //_AddKeywords(new _Keyword(), "__m64"); //not used in SDK _AddKeyword("auto", new _CppType("var", 1, false)); //has two meanings depending on compiler options. The old auto is a local variable, and we will not encounter it because we skip function bodies. The new auto is like C# var; it can also be applied to global variables too, unlike in C#; we'll ignore all variable declarations. _AddKeyword("IntPtr", new _CppType("IntPtr", _is32bit ? 4 : 8, false)); _AddSymbol("LPARAM", _sym_LPARAM = new _Struct("LPARAM", false), 0); _AddSymbol("HWND", _sym_Wnd = new _Struct("AWnd", false), 0); }