Skip to content

Commit

Permalink
Merge pull request #48 from errcw/str-uint8
Browse files Browse the repository at this point in the history
Use uint8 for GLchar and GLcharARB. Fix #47.
  • Loading branch information
errcw committed Nov 15, 2014
2 parents 2178a17 + 68e8245 commit cd1168c
Show file tree
Hide file tree
Showing 26 changed files with 894 additions and 905 deletions.
4 changes: 2 additions & 2 deletions conversions.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -52,12 +52,12 @@ func PtrOffset(offset int) unsafe.Pointer {
// Str takes a null-terminated Go string and returns its GL-compatible address.
// This function reaches into Go string storage in an unsafe way so the caller
// must ensure the string is not garbage collected.
func Str(str string) *int8 {
func Str(str string) *uint8 {
if !strings.HasSuffix(str, "\x00") {
log.Fatal("str argument missing null terminator", str)
}
header := (*reflect.StringHeader)(unsafe.Pointer(&str))
return (*int8)(unsafe.Pointer(header.Data))
return (*uint8)(unsafe.Pointer(header.Data))
}

// GoStr takes a null-terminated string returned by OpenGL and constructs a
Expand Down
4 changes: 2 additions & 2 deletions gl-compatibility/3.2/gl/conversions.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,12 +50,12 @@ func PtrOffset(offset int) unsafe.Pointer {
// Str takes a null-terminated Go string and returns its GL-compatible address.
// This function reaches into Go string storage in an unsafe way so the caller
// must ensure the string is not garbage collected.
func Str(str string) *int8 {
func Str(str string) *uint8 {
if !strings.HasSuffix(str, "\x00") {
log.Fatal("str argument missing null terminator", str)
}
header := (*reflect.StringHeader)(unsafe.Pointer(&str))
return (*int8)(unsafe.Pointer(header.Data))
return (*uint8)(unsafe.Pointer(header.Data))
}

// GoStr takes a null-terminated string returned by OpenGL and constructs a
Expand Down
163 changes: 81 additions & 82 deletions gl-compatibility/3.2/gl/package.go

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions gl-compatibility/3.3/gl/conversions.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,12 +50,12 @@ func PtrOffset(offset int) unsafe.Pointer {
// Str takes a null-terminated Go string and returns its GL-compatible address.
// This function reaches into Go string storage in an unsafe way so the caller
// must ensure the string is not garbage collected.
func Str(str string) *int8 {
func Str(str string) *uint8 {
if !strings.HasSuffix(str, "\x00") {
log.Fatal("str argument missing null terminator", str)
}
header := (*reflect.StringHeader)(unsafe.Pointer(&str))
return (*int8)(unsafe.Pointer(header.Data))
return (*uint8)(unsafe.Pointer(header.Data))
}

// GoStr takes a null-terminated string returned by OpenGL and constructs a
Expand Down
163 changes: 81 additions & 82 deletions gl-compatibility/3.3/gl/package.go

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions gl-compatibility/4.1/gl/conversions.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,12 +50,12 @@ func PtrOffset(offset int) unsafe.Pointer {
// Str takes a null-terminated Go string and returns its GL-compatible address.
// This function reaches into Go string storage in an unsafe way so the caller
// must ensure the string is not garbage collected.
func Str(str string) *int8 {
func Str(str string) *uint8 {
if !strings.HasSuffix(str, "\x00") {
log.Fatal("str argument missing null terminator", str)
}
header := (*reflect.StringHeader)(unsafe.Pointer(&str))
return (*int8)(unsafe.Pointer(header.Data))
return (*uint8)(unsafe.Pointer(header.Data))
}

// GoStr takes a null-terminated string returned by OpenGL and constructs a
Expand Down
163 changes: 81 additions & 82 deletions gl-compatibility/4.1/gl/package.go

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions gl-compatibility/4.4/gl/conversions.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,12 +50,12 @@ func PtrOffset(offset int) unsafe.Pointer {
// Str takes a null-terminated Go string and returns its GL-compatible address.
// This function reaches into Go string storage in an unsafe way so the caller
// must ensure the string is not garbage collected.
func Str(str string) *int8 {
func Str(str string) *uint8 {
if !strings.HasSuffix(str, "\x00") {
log.Fatal("str argument missing null terminator", str)
}
header := (*reflect.StringHeader)(unsafe.Pointer(&str))
return (*int8)(unsafe.Pointer(header.Data))
return (*uint8)(unsafe.Pointer(header.Data))
}

// GoStr takes a null-terminated string returned by OpenGL and constructs a
Expand Down
163 changes: 81 additions & 82 deletions gl-compatibility/4.4/gl/package.go

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions gl-compatibility/4.5/gl/conversions.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,12 +50,12 @@ func PtrOffset(offset int) unsafe.Pointer {
// Str takes a null-terminated Go string and returns its GL-compatible address.
// This function reaches into Go string storage in an unsafe way so the caller
// must ensure the string is not garbage collected.
func Str(str string) *int8 {
func Str(str string) *uint8 {
if !strings.HasSuffix(str, "\x00") {
log.Fatal("str argument missing null terminator", str)
}
header := (*reflect.StringHeader)(unsafe.Pointer(&str))
return (*int8)(unsafe.Pointer(header.Data))
return (*uint8)(unsafe.Pointer(header.Data))
}

// GoStr takes a null-terminated string returned by OpenGL and constructs a
Expand Down
163 changes: 81 additions & 82 deletions gl-compatibility/4.5/gl/package.go

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions gl-core/3.2/gl/conversions.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,12 +50,12 @@ func PtrOffset(offset int) unsafe.Pointer {
// Str takes a null-terminated Go string and returns its GL-compatible address.
// This function reaches into Go string storage in an unsafe way so the caller
// must ensure the string is not garbage collected.
func Str(str string) *int8 {
func Str(str string) *uint8 {
if !strings.HasSuffix(str, "\x00") {
log.Fatal("str argument missing null terminator", str)
}
header := (*reflect.StringHeader)(unsafe.Pointer(&str))
return (*int8)(unsafe.Pointer(header.Data))
return (*uint8)(unsafe.Pointer(header.Data))
}

// GoStr takes a null-terminated string returned by OpenGL and constructs a
Expand Down
Loading

0 comments on commit cd1168c

Please sign in to comment.