Skip to content

Commit

Permalink
clang: add missing clang-v3.9 files
Browse files Browse the repository at this point in the history
Signed-off-by: Koichi Shiraishi <[email protected]>
  • Loading branch information
zchee committed Nov 3, 2021
1 parent 578ed1d commit 2e7dc09
Show file tree
Hide file tree
Showing 3 changed files with 102 additions and 1 deletion.
2 changes: 1 addition & 1 deletion clang/clang-c/doc.go
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
// Package clang-c holds clang binding C header files.
// Package clang_c holds clang binding C header files.
package clang_c
51 changes: 51 additions & 0 deletions clang/modulemapdescriptor_gen.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,59 @@ package clang
// #include "./clang-c/BuildSystem.h"
// #include "go-clang.h"
import "C"
import "unsafe"

// Object encapsulating information about a module.map file.
type ModuleMapDescriptor struct {
c C.CXModuleMapDescriptor
}

/*
Create a CXModuleMapDescriptor object.
Must be disposed with clang_ModuleMapDescriptor_dispose().
Parameter options is reserved, always pass 0.
*/
func NewModuleMapDescriptor(options uint32) ModuleMapDescriptor {
return ModuleMapDescriptor{C.clang_ModuleMapDescriptor_create(C.uint(options))}
}

// Sets the framework module name that the module.map describes. Returns 0 for success, non-zero to indicate an error.
func (mmd ModuleMapDescriptor) SetFrameworkModuleName(name string) ErrorCode {
c_name := C.CString(name)
defer C.free(unsafe.Pointer(c_name))

return ErrorCode(C.clang_ModuleMapDescriptor_setFrameworkModuleName(mmd.c, c_name))
}

// Sets the umbrealla header name that the module.map describes. Returns 0 for success, non-zero to indicate an error.
func (mmd ModuleMapDescriptor) SetUmbrellaHeader(name string) ErrorCode {
c_name := C.CString(name)
defer C.free(unsafe.Pointer(c_name))

return ErrorCode(C.clang_ModuleMapDescriptor_setUmbrellaHeader(mmd.c, c_name))
}

/*
Write out the CXModuleMapDescriptor object to a char buffer.
Parameter options is reserved, always pass 0.
Parameter out_buffer_ptr pointer to receive the buffer pointer, which should be
disposed using clang_free().
Parameter out_buffer_size pointer to receive the buffer size.
Returns 0 for success, non-zero to indicate an error.
*/
func (mmd ModuleMapDescriptor) WriteToBuffer(options uint32) (string, uint32, ErrorCode) {
var outBufferPtr *C.char
defer C.free(unsafe.Pointer(outBufferPtr))
var outBufferSize C.uint

o := ErrorCode(C.clang_ModuleMapDescriptor_writeToBuffer(mmd.c, C.uint(options), &outBufferPtr, &outBufferSize))

return C.GoString(outBufferPtr), uint32(outBufferSize), o
}

// Dispose a CXModuleMapDescriptor object.
func (mmd ModuleMapDescriptor) Dispose() {
C.clang_ModuleMapDescriptor_dispose(mmd.c)
}
50 changes: 50 additions & 0 deletions clang/virtualfileoverlay_gen.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,58 @@ package clang
// #include "./clang-c/BuildSystem.h"
// #include "go-clang.h"
import "C"
import "unsafe"

// Object encapsulating information about overlaying virtual file/directories over the real file system.
type VirtualFileOverlay struct {
c C.CXVirtualFileOverlay
}

/*
Create a CXVirtualFileOverlay object.
Must be disposed with clang_VirtualFileOverlay_dispose().
Parameter options is reserved, always pass 0.
*/
func NewVirtualFileOverlay(options uint32) VirtualFileOverlay {
return VirtualFileOverlay{C.clang_VirtualFileOverlay_create(C.uint(options))}
}

// Map an absolute virtual file path to an absolute real one. The virtual path must be canonicalized (not contain "."/".."). Returns 0 for success, non-zero to indicate an error.
func (vfo VirtualFileOverlay) AddFileMapping(virtualPath string, realPath string) ErrorCode {
c_virtualPath := C.CString(virtualPath)
defer C.free(unsafe.Pointer(c_virtualPath))
c_realPath := C.CString(realPath)
defer C.free(unsafe.Pointer(c_realPath))

return ErrorCode(C.clang_VirtualFileOverlay_addFileMapping(vfo.c, c_virtualPath, c_realPath))
}

// Set the case sensitivity for the CXVirtualFileOverlay object. The CXVirtualFileOverlay object is case-sensitive by default, this option can be used to override the default. Returns 0 for success, non-zero to indicate an error.
func (vfo VirtualFileOverlay) SetCaseSensitivity(caseSensitive int32) ErrorCode {
return ErrorCode(C.clang_VirtualFileOverlay_setCaseSensitivity(vfo.c, C.int(caseSensitive)))
}

/*
Write out the CXVirtualFileOverlay object to a char buffer.
Parameter options is reserved, always pass 0.
Parameter out_buffer_ptr pointer to receive the buffer pointer, which should be
disposed using clang_free().
Parameter out_buffer_size pointer to receive the buffer size.
Returns 0 for success, non-zero to indicate an error.
*/
func (vfo VirtualFileOverlay) WriteToBuffer(options uint32) (string, uint32, ErrorCode) {
var outBufferPtr *C.char
defer C.free(unsafe.Pointer(outBufferPtr))
var outBufferSize C.uint

o := ErrorCode(C.clang_VirtualFileOverlay_writeToBuffer(vfo.c, C.uint(options), &outBufferPtr, &outBufferSize))

return C.GoString(outBufferPtr), uint32(outBufferSize), o
}

// Dispose a CXVirtualFileOverlay object.
func (vfo VirtualFileOverlay) Dispose() {
C.clang_VirtualFileOverlay_dispose(vfo.c)
}

0 comments on commit 2e7dc09

Please sign in to comment.