Skip to content

Commit 417aa43

Browse files
ydnardeadprogram
authored andcommitted
internal/reflectlite, reflect: move StringHeader and SliceHeader back to package reflect
1 parent bf88cde commit 417aa43

File tree

5 files changed

+24
-16
lines changed

5 files changed

+24
-16
lines changed

src/internal/reflectlite/value.go

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1686,12 +1686,6 @@ type funcHeader struct {
16861686
Code unsafe.Pointer
16871687
}
16881688

1689-
type SliceHeader struct {
1690-
Data uintptr
1691-
Len intw
1692-
Cap intw
1693-
}
1694-
16951689
// Slice header that matches the underlying structure. Used for when we switch
16961690
// to a precise GC, which needs to know exactly where pointers live.
16971691
type sliceHeader struct {
@@ -1700,11 +1694,6 @@ type sliceHeader struct {
17001694
cap uintptr
17011695
}
17021696

1703-
type StringHeader struct {
1704-
Data uintptr
1705-
Len intw
1706-
}
1707-
17081697
// Like sliceHeader, this type is used internally to make sure pointer and
17091698
// non-pointer fields match those of actual strings.
17101699
type stringHeader struct {
@@ -1716,9 +1705,7 @@ type stringHeader struct {
17161705
// See https://github.com/tinygo-org/tinygo/pull/4156
17171706
// and https://github.com/tinygo-org/tinygo/issues/1284.
17181707
var (
1719-
_ [unsafe.Sizeof([]byte{})]byte = [unsafe.Sizeof(SliceHeader{})]byte{}
17201708
_ [unsafe.Sizeof([]byte{})]byte = [unsafe.Sizeof(sliceHeader{})]byte{}
1721-
_ [unsafe.Sizeof("")]byte = [unsafe.Sizeof(StringHeader{})]byte{}
17221709
_ [unsafe.Sizeof("")]byte = [unsafe.Sizeof(stringHeader{})]byte{}
17231710
)
17241711

src/internal/reflectlite/intw.go renamed to src/reflect/intw.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
//go:build !avr
22

3-
package reflectlite
3+
package reflect
44

55
// intw is an integer type, used in places where an int is typically required,
66
// except architectures where the size of an int != word size.

src/internal/reflectlite/intw_avr.go renamed to src/reflect/intw_avr.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
//go:build avr
22

3-
package reflectlite
3+
package reflect
44

55
// intw is an integer type, used in places where an int is typically required,
66
// except architectures where the size of an int != word size.

src/internal/reflectlite/intw_test.go renamed to src/reflect/intw_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
//go:build !avr
22

3-
package reflectlite_test
3+
package reflect_test
44

55
import (
66
"reflect"

src/reflect/value.go

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -226,3 +226,24 @@ func (v Value) Recv() (x Value, ok bool) {
226226
func NewAt(typ Type, p unsafe.Pointer) Value {
227227
panic("unimplemented: reflect.New()")
228228
}
229+
230+
// Deprecated: Use unsafe.Slice or unsafe.SliceData instead.
231+
type SliceHeader struct {
232+
Data uintptr
233+
Len intw
234+
Cap intw
235+
}
236+
237+
// Deprecated: Use unsafe.String or unsafe.StringData instead.
238+
type StringHeader struct {
239+
Data uintptr
240+
Len intw
241+
}
242+
243+
// Verify SliceHeader and StringHeader sizes.
244+
// See https://github.com/tinygo-org/tinygo/pull/4156
245+
// and https://github.com/tinygo-org/tinygo/issues/1284.
246+
var (
247+
_ [unsafe.Sizeof([]byte{})]byte = [unsafe.Sizeof(SliceHeader{})]byte{}
248+
_ [unsafe.Sizeof("")]byte = [unsafe.Sizeof(StringHeader{})]byte{}
249+
)

0 commit comments

Comments
 (0)