Skip to content

Commit

Permalink
[Go] Minor update on Go wrapper.
Browse files Browse the repository at this point in the history
Fine-tuned output of Go wrapper generator. Use 'nil' instead of 'NULL' and remove C-style literal suffixes.
  • Loading branch information
LukasBanana committed Jul 5, 2024
1 parent 01beccf commit 03a8000
Show file tree
Hide file tree
Showing 5 changed files with 159 additions and 143 deletions.
20 changes: 16 additions & 4 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,12 +1,24 @@
# macOS Finder file .DS_Store
.DS_Store

# Intermediate build system files
Makefile
CMakeFiles
tests/Output
build*/
*.aps
Screenshot.*
Capture.*
*.cache
*.spvasm
Makefile

# Runtime output files for testing
Screenshot.*
Capture.*

# Output files from individual tests (Testbed is handled separately)
tests/Output

# Binary files for Go wrapper (libLLGL.dll, libLLGL.dll.a)
*.dll
*.dll.a

# RenderDoc .cap capture files
*.cap
3 changes: 3 additions & 0 deletions scripts/WrapperGen/llgl_module.py
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,9 @@ def isDynamicArray(self):
def isPointerOrString(self):
return self.isPointer or self.typename in [LLGLMeta.UTF8STRING, LLGLMeta.STRING]

def isStringOfAnyKind(self):
return self.typename in [LLGLMeta.UTF8STRING, LLGLMeta.STRING] or (self.isPointer and self.baseType in [StdType.CHAR, StdType.WCHAR])

def getFixedBitsize(self):
if self.baseType in [StdType.INT8, StdType.UINT8]:
return 8
Expand Down
10 changes: 5 additions & 5 deletions scripts/WrapperGen/llgl_translator_golang.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,8 @@ def toTypenameWithoutStdSuffix(typename):
# Write C-include boilerplate code
self.statement('package llgl')
self.statement()
self.statement('// #cgo LDFLAGS: libLLGL.dll.a') #TEST
self.statement('// #cgo CFLAGS: -I ../include') #TEST
self.statement('// #cgo LDFLAGS: libLLGL.dll.a') #TODO: this is for experimentation only
self.statement('// #cgo CFLAGS: -I ../../include') #TODO: this is for experimentation only
self.statement('// #include <LLGL-C/LLGL.h>')
self.statement('import "C"')
self.statement()
Expand Down Expand Up @@ -190,12 +190,12 @@ def translateStructField(fieldType, name):

def translateFieldInitializer(fieldType, init):
if fieldType.isDynamicArray():
return 'NULL'
return 'nil'
if init:
if init == 'nullptr':
return 'LLGL_NULL_OBJECT' if fieldType.isInterface() else 'NULL'
return '""' if fieldType.isStringOfAnyKind() else 'nil'
else:
return re.sub(r'(\w+::)', r'LLGL\1', init).replace('::', '').replace('|', ' | ').replace('Flags', '')
return re.sub(r'(\w+::)', r'\1', init).replace('::', '').replace('|', ' | ').replace('Flags', '').replace('.0f', '.0')
return None

self.statement('/* ----- Structures ----- */')
Expand Down
1 change: 1 addition & 0 deletions wrapper/C99/C99RenderSystem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -234,6 +234,7 @@ static void ConvertBufferDesc(BufferDescriptor& dst, SmallVector<VertexAttribute
for_range(i, src.numVertexAttribs)
ConvertVertexAttrib(dstVertexAttribs[i], src.vertexAttribs[i]);

dst.debugName = src.debugName;
dst.size = src.size;
dst.stride = src.stride;
dst.format = (Format)src.format;
Expand Down
Loading

0 comments on commit 03a8000

Please sign in to comment.