Skip to content

Commit 234d8c6

Browse files
authored
Merge pull request #25 from goccy/fix-checkptr-error
Fix checkptr error
2 parents b6d23c3 + c9b6bcb commit 234d8c6

File tree

3 files changed

+7
-3
lines changed

3 files changed

+7
-3
lines changed

Diff for: .github/workflows/go.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ jobs:
2020
- name: checkout
2121
uses: actions/checkout@v2
2222
- name: test
23-
run: go test -v ./ -count=1
23+
run: go test -race -v ./ -count=1
2424
env:
2525
CC: clang
2626
CXX: clang++

Diff for: internal/helper/bind.go

+4
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,10 @@ func PtrToSlice(p unsafe.Pointer, cb func(unsafe.Pointer)) {
5555
}
5656
}
5757

58+
func IntPtr(v int) unsafe.Pointer {
59+
return *(*unsafe.Pointer)(unsafe.Pointer(&v))
60+
}
61+
5862
func SliceToPtr(v interface{}, cb func(int) unsafe.Pointer) unsafe.Pointer {
5963
rv := reflect.ValueOf(v)
6064
slice := (*reflect.SliceHeader)(C.malloc(C.ulong(unsafe.Sizeof(reflect.SliceHeader{}))))

Diff for: language_options.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ func (o *LanguageOptions) SupportsStatementKind(kind resolved_ast.Kind) bool {
5252
// explicitly opt in to support other statements.
5353
func (o *LanguageOptions) SetSupportedStatementKinds(kinds []resolved_ast.Kind) {
5454
internal.LanguageOptions_SetSupportedStatementKinds(o.raw, helper.SliceToPtr(kinds, func(i int) unsafe.Pointer {
55-
return unsafe.Pointer(uintptr(int(kinds[i])))
55+
return helper.IntPtr(int(kinds[i]))
5656
}))
5757
}
5858

@@ -91,7 +91,7 @@ func (o *LanguageOptions) EnableLanguageFeature(feature LanguageFeature) {
9191

9292
func (o *LanguageOptions) SetEnabledLanguageFeatures(features []LanguageFeature) {
9393
internal.LanguageOptions_SetEnabledLanguageFeatures(o.raw, helper.SliceToPtr(features, func(i int) unsafe.Pointer {
94-
return unsafe.Pointer(uintptr(int(features[i])))
94+
return helper.IntPtr(int(features[i]))
9595
}))
9696
}
9797

0 commit comments

Comments
 (0)