generator using tabs in structs

This commit is contained in:
sonoro1234
2018-04-27 17:50:27 +02:00
parent c735efe55a
commit 851df218da
2 changed files with 349 additions and 349 deletions

View File

@@ -40,33 +40,19 @@ repeat -- simulate continue with break
elseif in_imgui then
--[[
-- Windows likes to add __stdcall__ to everything, but it isn't needed and is actually harmful when using under linux.
-- However, it is needed for callbacks in windows.
--if line:find("typedef") >= 0 and line.find(" PFNGL") < 0:
if line:find("typedef") and not line:find(" PFNGL") then
--line = line:gsub("__attribute__%(%(__stdcall__%)%) ", 'WINDOWS_STDCALL ')
line = line:gsub('GL_APIENTRY ' , 'WINDOWS_STDCALL ')
else
--line = line:gsub("__attribute__%(%(__stdcall__%)%) ", '')
line = line:gsub('GL_APIENTRY ', '')
end
-- While linux likes to add __attribute__((visibility("default")))
line = line:gsub('__attribute__%(%(visibility%("default"%)%)%) ', '')
line = line:gsub("__attribute__%(%(__stdcall__%)%) ", '')
--]]
--if in_function discard
if in_function then
if line:match(function_closing_re) then
in_function = false
end
break
end
if line:match(function_re) and not line:match("typedef.*%b().*%b().*") then
--if not line:match("typedef.*%b().*%b().*") then --functypedef
-- function and functypedef
if not line:match(function_closed_re) then
in_function = true
end
--end
elseif line:match("template") then
--nothing
elseif line:match("public") then
@@ -92,16 +78,38 @@ local struct_op_close_re = "%b{}"
local structnames = {}
local innerstructs = {}
-- Output the file
print("/////////////// BEGIN AUTOGENERATED SEGMENT")
print("#ifndef IMGUI_STRUCTS_INCLUDED")
print("#define IMGUI_STRUCTS_INCLUDED")
print("/////////////// BEGIN AUTOGENERATED SEGMENT")
for i,line in ipairs(cdefs) do
repeat -- simulating continue with break
if line:match(namespace_re) then
in_namespace = true
end
structnames[#structnames + 1] = line:match(struct_re)
local structbegin = line:match(struct_re)
if structbegin then
structnames[#structnames + 1] = structbegin
if #structnames < 2 and structbegin~= "ImVector" then --not inner and not ImVector
io.write(line,"\n")
break
end
end
if structnames[#structnames] == "ImVector" then
if line:match(struct_closing_re) then
io.write[[struct ImVector
{
int Size;
int Capacity;
void* Data;
};
typedef struct ImVector ImVector;]]
structnames[#structnames] = nil
end
break -- dont write
end
if in_namespace then
if line:match(function_closing_re) then
@@ -111,23 +119,13 @@ local innerstructs = {}
break -- dont write anything inside
end
if structnames[#structnames] == "ImVector" then
if line:match(struct_closing_re) then
io.write[[struct ImVector
{
int Size;
int Capacity;
void* Data;
};
typedef struct ImVector ImVector;]]
structnames[#structnames] = nil
end
break -- dont write
end
if #structnames < 2 then -- not inner
if (#structnames > 0) and line:match("typedef") then --dont allow inner typedefs
if (#structnames > 0) then
if line:match("typedef") then --dont allow inner typedefs
break
elseif not line:match("^{$") and not line:match(struct_closing_re) then --avoid tab { and };
line = " "..line
end
end
io.write( line,"\n")
local struct_closed_name = line:match(struct_closed_re)
@@ -136,11 +134,13 @@ typedef struct ImVector ImVector;]]
end
end
--if structnames[#structnames] then
if #structnames > 0 then
if #structnames > 1 then --inner
if #structnames > 1 then --inner structs
innerstructs[structnames[#structnames]] = innerstructs[structnames[#structnames]] or {}
local st = innerstructs[structnames[#structnames]]
if not line:match("struct") and not line:match("^{$") and not line:match(struct_closing_re) then --avoid tab in struct { and };
line = " "..line
end
st[#st + 1] = line
if line:match(struct_closing_re) and not line:match(struct_op_close_re) then
local structname = structnames[#structnames]
@@ -162,6 +162,6 @@ typedef struct ImVector ImVector;]]
print(line)
end
end
print("//////////////// END AUTOGENERATED SEGMENT ")
print("#endif //IMGUI_STRUCTS_INCLUDED")
print("//////////////// END AUTOGENERATED SEGMENT ")

View File

@@ -1,6 +1,6 @@
/////////////// BEGIN AUTOGENERATED SEGMENT
#ifndef IMGUI_STRUCTS_INCLUDED
#define IMGUI_STRUCTS_INCLUDED
/////////////// BEGIN AUTOGENERATED SEGMENT
struct ImDrawChannel;
typedef struct ImDrawChannel ImDrawChannel;
struct ImDrawCmd;
@@ -74,12 +74,12 @@ typedef void (*ImGuiSizeCallback)(ImGuiSizeCallbackData* data);
typedef unsigned long long ImU64;
struct ImVec2
{
float x, y;
float x, y;
};
typedef struct ImVec2 ImVec2;
struct ImVec4
{
float x, y, z, w;
float x, y, z, w;
};
typedef struct ImVec4 ImVec4;
enum ImGuiWindowFlags_
@@ -396,110 +396,110 @@ ImGuiCond_Appearing = 1 << 3
};
struct ImGuiStyle
{
float Alpha;
ImVec2 WindowPadding;
float WindowRounding;
float WindowBorderSize;
ImVec2 WindowMinSize;
ImVec2 WindowTitleAlign;
float ChildRounding;
float ChildBorderSize;
float PopupRounding;
float PopupBorderSize;
ImVec2 FramePadding;
float FrameRounding;
float FrameBorderSize;
ImVec2 ItemSpacing;
ImVec2 ItemInnerSpacing;
ImVec2 TouchExtraPadding;
float IndentSpacing;
float ColumnsMinSpacing;
float ScrollbarSize;
float ScrollbarRounding;
float GrabMinSize;
float GrabRounding;
ImVec2 ButtonTextAlign;
ImVec2 DisplayWindowPadding;
ImVec2 DisplaySafeAreaPadding;
float MouseCursorScale;
bool AntiAliasedLines;
bool AntiAliasedFill;
float CurveTessellationTol;
ImVec4 Colors[ImGuiCol_COUNT];
float Alpha;
ImVec2 WindowPadding;
float WindowRounding;
float WindowBorderSize;
ImVec2 WindowMinSize;
ImVec2 WindowTitleAlign;
float ChildRounding;
float ChildBorderSize;
float PopupRounding;
float PopupBorderSize;
ImVec2 FramePadding;
float FrameRounding;
float FrameBorderSize;
ImVec2 ItemSpacing;
ImVec2 ItemInnerSpacing;
ImVec2 TouchExtraPadding;
float IndentSpacing;
float ColumnsMinSpacing;
float ScrollbarSize;
float ScrollbarRounding;
float GrabMinSize;
float GrabRounding;
ImVec2 ButtonTextAlign;
ImVec2 DisplayWindowPadding;
ImVec2 DisplaySafeAreaPadding;
float MouseCursorScale;
bool AntiAliasedLines;
bool AntiAliasedFill;
float CurveTessellationTol;
ImVec4 Colors[ImGuiCol_COUNT];
};
typedef struct ImGuiStyle ImGuiStyle;
struct ImGuiIO
{
ImGuiConfigFlags ConfigFlags;
ImGuiBackendFlags BackendFlags;
ImVec2 DisplaySize;
float DeltaTime;
float IniSavingRate;
const char* IniFilename;
const char* LogFilename;
float MouseDoubleClickTime;
float MouseDoubleClickMaxDist;
float MouseDragThreshold;
int KeyMap[ImGuiKey_COUNT];
float KeyRepeatDelay;
float KeyRepeatRate;
void* UserData;
ImFontAtlas* Fonts;
float FontGlobalScale;
bool FontAllowUserScaling;
ImFont* FontDefault;
ImVec2 DisplayFramebufferScale;
ImVec2 DisplayVisibleMin;
ImVec2 DisplayVisibleMax;
bool OptMacOSXBehaviors;
bool OptCursorBlink;
void* ClipboardUserData;
void* ImeWindowHandle;
ImVec2 MousePos;
bool MouseDown[5];
float MouseWheel;
float MouseWheelH;
bool MouseDrawCursor;
bool KeyCtrl;
bool KeyShift;
bool KeyAlt;
bool KeySuper;
bool KeysDown[512];
ImWchar InputCharacters[16+1];
float NavInputs[ImGuiNavInput_COUNT];
bool WantCaptureMouse;
bool WantCaptureKeyboard;
bool WantTextInput;
bool WantSetMousePos;
bool NavActive;
bool NavVisible;
float Framerate;
int MetricsRenderVertices;
int MetricsRenderIndices;
int MetricsActiveWindows;
ImVec2 MouseDelta;
ImVec2 MousePosPrev;
ImVec2 MouseClickedPos[5];
float MouseClickedTime[5];
bool MouseClicked[5];
bool MouseDoubleClicked[5];
bool MouseReleased[5];
bool MouseDownOwned[5];
float MouseDownDuration[5];
float MouseDownDurationPrev[5];
ImVec2 MouseDragMaxDistanceAbs[5];
float MouseDragMaxDistanceSqr[5];
float KeysDownDuration[512];
float KeysDownDurationPrev[512];
float NavInputsDownDuration[ImGuiNavInput_COUNT];
float NavInputsDownDurationPrev[ImGuiNavInput_COUNT];
ImGuiConfigFlags ConfigFlags;
ImGuiBackendFlags BackendFlags;
ImVec2 DisplaySize;
float DeltaTime;
float IniSavingRate;
const char* IniFilename;
const char* LogFilename;
float MouseDoubleClickTime;
float MouseDoubleClickMaxDist;
float MouseDragThreshold;
int KeyMap[ImGuiKey_COUNT];
float KeyRepeatDelay;
float KeyRepeatRate;
void* UserData;
ImFontAtlas* Fonts;
float FontGlobalScale;
bool FontAllowUserScaling;
ImFont* FontDefault;
ImVec2 DisplayFramebufferScale;
ImVec2 DisplayVisibleMin;
ImVec2 DisplayVisibleMax;
bool OptMacOSXBehaviors;
bool OptCursorBlink;
void* ClipboardUserData;
void* ImeWindowHandle;
ImVec2 MousePos;
bool MouseDown[5];
float MouseWheel;
float MouseWheelH;
bool MouseDrawCursor;
bool KeyCtrl;
bool KeyShift;
bool KeyAlt;
bool KeySuper;
bool KeysDown[512];
ImWchar InputCharacters[16+1];
float NavInputs[ImGuiNavInput_COUNT];
bool WantCaptureMouse;
bool WantCaptureKeyboard;
bool WantTextInput;
bool WantSetMousePos;
bool NavActive;
bool NavVisible;
float Framerate;
int MetricsRenderVertices;
int MetricsRenderIndices;
int MetricsActiveWindows;
ImVec2 MouseDelta;
ImVec2 MousePosPrev;
ImVec2 MouseClickedPos[5];
float MouseClickedTime[5];
bool MouseClicked[5];
bool MouseDoubleClicked[5];
bool MouseReleased[5];
bool MouseDownOwned[5];
float MouseDownDuration[5];
float MouseDownDurationPrev[5];
ImVec2 MouseDragMaxDistanceAbs[5];
float MouseDragMaxDistanceSqr[5];
float KeysDownDuration[512];
float KeysDownDurationPrev[512];
float NavInputsDownDuration[ImGuiNavInput_COUNT];
float NavInputsDownDurationPrev[ImGuiNavInput_COUNT];
};
typedef struct ImGuiIO ImGuiIO;
struct ImVector
{
int Size;
int Capacity;
void* Data;
int Size;
int Capacity;
void* Data;
};
typedef struct ImVector ImVector;struct ImNewDummy {};
struct ImGuiOnceUponAFrame
@@ -509,92 +509,92 @@ struct ImGuiOnceUponAFrame
typedef struct ImGuiOnceUponAFrame ImGuiOnceUponAFrame;
struct ImGuiTextFilter
{
char InputBuf[256];
ImVector/*<TextRange>*/ Filters;
int CountGrep;
char InputBuf[256];
ImVector/*<TextRange>*/ Filters;
int CountGrep;
};
typedef struct ImGuiTextFilter ImGuiTextFilter;
struct ImGuiTextBuffer
{
ImVector/*<char>*/ Buf;
ImVector/*<char>*/ Buf;
};
typedef struct ImGuiTextBuffer ImGuiTextBuffer;
struct ImGuiStorage
{
ImVector/*<Pair>*/ Data;
ImVector/*<Pair>*/ Data;
};
typedef struct ImGuiStorage ImGuiStorage;
struct ImGuiTextEditCallbackData
{
ImGuiInputTextFlags EventFlag;
ImGuiInputTextFlags Flags;
void* UserData;
bool ReadOnly;
ImWchar EventChar;
ImGuiKey EventKey;
char* Buf;
int BufTextLen;
int BufSize;
bool BufDirty;
int CursorPos;
int SelectionStart;
int SelectionEnd;
ImGuiInputTextFlags EventFlag;
ImGuiInputTextFlags Flags;
void* UserData;
bool ReadOnly;
ImWchar EventChar;
ImGuiKey EventKey;
char* Buf;
int BufTextLen;
int BufSize;
bool BufDirty;
int CursorPos;
int SelectionStart;
int SelectionEnd;
};
typedef struct ImGuiTextEditCallbackData ImGuiTextEditCallbackData;
struct ImGuiSizeCallbackData
{
void* UserData;
ImVec2 Pos;
ImVec2 CurrentSize;
ImVec2 DesiredSize;
void* UserData;
ImVec2 Pos;
ImVec2 CurrentSize;
ImVec2 DesiredSize;
};
typedef struct ImGuiSizeCallbackData ImGuiSizeCallbackData;
struct ImGuiPayload
{
const void* Data;
int DataSize;
ImGuiID SourceId;
ImGuiID SourceParentId;
int DataFrameCount;
char DataType[32+1];
bool Preview;
bool Delivery;
const void* Data;
int DataSize;
ImGuiID SourceId;
ImGuiID SourceParentId;
int DataFrameCount;
char DataType[32+1];
bool Preview;
bool Delivery;
};
typedef struct ImGuiPayload ImGuiPayload;
struct ImColor
{
ImVec4 Value;
ImVec4 Value;
};
typedef struct ImColor ImColor;
struct ImGuiListClipper
{
float StartPosY;
float ItemsHeight;
int ItemsCount, StepNo, DisplayStart, DisplayEnd;
float StartPosY;
float ItemsHeight;
int ItemsCount, StepNo, DisplayStart, DisplayEnd;
};
typedef struct ImGuiListClipper ImGuiListClipper;
typedef void (*ImDrawCallback)(const ImDrawList* parent_list, const ImDrawCmd* cmd);
struct ImDrawCmd
{
unsigned int ElemCount;
ImVec4 ClipRect;
ImTextureID TextureId;
ImDrawCallback UserCallback;
void* UserCallbackData;
unsigned int ElemCount;
ImVec4 ClipRect;
ImTextureID TextureId;
ImDrawCallback UserCallback;
void* UserCallbackData;
};
typedef struct ImDrawCmd ImDrawCmd;
typedef unsigned short ImDrawIdx;
struct ImDrawVert
{
ImVec2 pos;
ImVec2 uv;
ImU32 col;
ImVec2 pos;
ImVec2 uv;
ImU32 col;
};
typedef struct ImDrawVert ImDrawVert;
struct ImDrawChannel
{
ImVector/*<ImDrawCmd>*/ CmdBuffer;
ImVector/*<ImDrawIdx>*/ IdxBuffer;
ImVector/*<ImDrawCmd>*/ CmdBuffer;
ImVector/*<ImDrawIdx>*/ IdxBuffer;
};
typedef struct ImDrawChannel ImDrawChannel;
enum ImDrawCornerFlags_
@@ -616,58 +616,58 @@ ImDrawListFlags_AntiAliasedFill = 1 << 1
};
struct ImDrawList
{
ImVector/*<ImDrawCmd>*/ CmdBuffer;
ImVector/*<ImDrawIdx>*/ IdxBuffer;
ImVector/*<ImDrawVert>*/ VtxBuffer;
ImDrawListFlags Flags;
const ImDrawListSharedData* _Data;
const char* _OwnerName;
unsigned int _VtxCurrentIdx;
ImDrawVert* _VtxWritePtr;
ImDrawIdx* _IdxWritePtr;
ImVector/*<ImVec4>*/ _ClipRectStack;
ImVector/*<ImTextureID>*/ _TextureIdStack;
ImVector/*<ImVec2>*/ _Path;
int _ChannelsCurrent;
int _ChannelsCount;
ImVector/*<ImDrawChannel>*/ _Channels;
ImVector/*<ImDrawCmd>*/ CmdBuffer;
ImVector/*<ImDrawIdx>*/ IdxBuffer;
ImVector/*<ImDrawVert>*/ VtxBuffer;
ImDrawListFlags Flags;
const ImDrawListSharedData* _Data;
const char* _OwnerName;
unsigned int _VtxCurrentIdx;
ImDrawVert* _VtxWritePtr;
ImDrawIdx* _IdxWritePtr;
ImVector/*<ImVec4>*/ _ClipRectStack;
ImVector/*<ImTextureID>*/ _TextureIdStack;
ImVector/*<ImVec2>*/ _Path;
int _ChannelsCurrent;
int _ChannelsCount;
ImVector/*<ImDrawChannel>*/ _Channels;
};
typedef struct ImDrawList ImDrawList;
struct ImDrawData
{
bool Valid;
ImDrawList** CmdLists;
int CmdListsCount;
int TotalIdxCount;
int TotalVtxCount;
bool Valid;
ImDrawList** CmdLists;
int CmdListsCount;
int TotalIdxCount;
int TotalVtxCount;
};
typedef struct ImDrawData ImDrawData;
struct ImFontConfig
{
void* FontData;
int FontDataSize;
bool FontDataOwnedByAtlas;
int FontNo;
float SizePixels;
int OversampleH;
int OversampleV;
bool PixelSnapH;
ImVec2 GlyphExtraSpacing;
ImVec2 GlyphOffset;
const ImWchar* GlyphRanges;
bool MergeMode;
unsigned int RasterizerFlags;
float RasterizerMultiply;
char Name[40];
ImFont* DstFont;
void* FontData;
int FontDataSize;
bool FontDataOwnedByAtlas;
int FontNo;
float SizePixels;
int OversampleH;
int OversampleV;
bool PixelSnapH;
ImVec2 GlyphExtraSpacing;
ImVec2 GlyphOffset;
const ImWchar* GlyphRanges;
bool MergeMode;
unsigned int RasterizerFlags;
float RasterizerMultiply;
char Name[40];
ImFont* DstFont;
};
typedef struct ImFontConfig ImFontConfig;
struct ImFontGlyph
{
ImWchar Codepoint;
float AdvanceX;
float X0, Y0, X1, Y1;
float U0, V0, U1, V1;
ImWchar Codepoint;
float AdvanceX;
float X0, Y0, X1, Y1;
float U0, V0, U1, V1;
};
typedef struct ImFontGlyph ImFontGlyph;
enum ImFontAtlasFlags_
@@ -677,71 +677,71 @@ ImFontAtlasFlags_NoMouseCursors = 1 << 1
};
struct ImFontAtlas
{
ImFontAtlasFlags Flags;
ImTextureID TexID;
int TexDesiredWidth;
int TexGlyphPadding;
unsigned char* TexPixelsAlpha8;
unsigned int* TexPixelsRGBA32;
int TexWidth;
int TexHeight;
ImVec2 TexUvScale;
ImVec2 TexUvWhitePixel;
ImVector/*<ImFont*>*/ Fonts;
ImVector/*<CustomRect>*/ CustomRects;
ImVector/*<ImFontConfig>*/ ConfigData;
int CustomRectIds[1];
ImFontAtlasFlags Flags;
ImTextureID TexID;
int TexDesiredWidth;
int TexGlyphPadding;
unsigned char* TexPixelsAlpha8;
unsigned int* TexPixelsRGBA32;
int TexWidth;
int TexHeight;
ImVec2 TexUvScale;
ImVec2 TexUvWhitePixel;
ImVector/*<ImFont*>*/ Fonts;
ImVector/*<CustomRect>*/ CustomRects;
ImVector/*<ImFontConfig>*/ ConfigData;
int CustomRectIds[1];
};
typedef struct ImFontAtlas ImFontAtlas;
struct ImFont
{
float FontSize;
float Scale;
ImVec2 DisplayOffset;
ImVector/*<ImFontGlyph>*/ Glyphs;
ImVector/*<float>*/ IndexAdvanceX;
ImVector/*<unsigned short>*/ IndexLookup;
const ImFontGlyph* FallbackGlyph;
float FallbackAdvanceX;
ImWchar FallbackChar;
short ConfigDataCount;
ImFontConfig* ConfigData;
ImFontAtlas* ContainerAtlas;
float Ascent, Descent;
bool DirtyLookupTables;
int MetricsTotalSurface;
float FontSize;
float Scale;
ImVec2 DisplayOffset;
ImVector/*<ImFontGlyph>*/ Glyphs;
ImVector/*<float>*/ IndexAdvanceX;
ImVector/*<unsigned short>*/ IndexLookup;
const ImFontGlyph* FallbackGlyph;
float FallbackAdvanceX;
ImWchar FallbackChar;
short ConfigDataCount;
ImFontConfig* ConfigData;
ImFontAtlas* ContainerAtlas;
float Ascent, Descent;
bool DirtyLookupTables;
int MetricsTotalSurface;
};
typedef struct ImFont ImFont;
struct GlyphRangesBuilder
{
ImVector/*<unsigned char>*/ UsedChars;
ImVector/*<unsigned char>*/ UsedChars;
};
typedef struct GlyphRangesBuilder GlyphRangesBuilder;
struct CustomRect
{
unsigned int ID;
unsigned short Width, Height;
unsigned short X, Y;
float GlyphAdvanceX;
ImVec2 GlyphOffset;
ImFont* Font;
unsigned int ID;
unsigned short Width, Height;
unsigned short X, Y;
float GlyphAdvanceX;
ImVec2 GlyphOffset;
ImFont* Font;
};
typedef struct CustomRect CustomRect;
struct TextRange
{
const char* b;
const char* e;
const char* b;
const char* e;
};
typedef struct TextRange TextRange;
struct Pair
{
ImGuiID key;
ImGuiID key;
union { int val_i; float val_f; void* val_p; };
};
typedef struct Pair Pair;
//////////////// END AUTOGENERATED SEGMENT
#endif //IMGUI_STRUCTS_INCLUDED
//////////////// END AUTOGENERATED SEGMENT