Commit Graph

119 Commits

Author SHA1 Message Date
Koichi Shiraishi 96528cbae4
Fix resolve conflict to #55 2020-11-16 23:39:33 +09:00
Cuong Manh Le 6b1d701387
Fix all invalid usages of unsafe.Pointer
Most of the invalid usages due to the conversion from uintptr to
unsafe.Pointer. In general, unsafe.Pointer(p) where p of type uintptr is
considered unsafe.

To fix that, use &p instead of p, then introduce another dereference.
Example, the invalid usage:

	*(*int)(unsafe.Pointer(p)) = int(v)

wil become:

	**(**int)(unsafe.Pointer(&p)) = int(v)

Closes #53
2020-11-16 20:37:12 +07:00
Cuong Manh Le e58b1eabaf
Remove all usages of reflect.SliceHeader
There're some problem with current usage of reflect.SliceHeader.

First, it violates the unsafe pointer conversion (rule 6th), that said,
reflect.SliceHeader must not used as plain struct.

Second, the lowest version that go-json supports, go1.12, reflect
package did not use SliceHeader in typedslicecopy, but use the safety
version. There's no reason that go-json continue using them.

See:

 - https://golang.org/pkg/unsafe/#Pointer
 - https://github.com/golang/go/blob/release-branch.go1.12/src/reflect/value.go#L2702
2020-11-16 20:33:49 +07:00
Masaaki Goshima 3e1a1ac1ad Fix recursive anonymous field 2020-11-16 21:28:33 +09:00
Masaaki Goshima 4994bc5d04 Fix handling of comma as delimiter
Conflicts:
	encode_vm.go
2020-11-16 19:16:45 +09:00
Masaaki Goshima 9351afdb88 Fix pointer fields 2020-09-17 21:50:27 +09:00
Masaaki Goshima d76012422a Fix stream encoding 2020-09-17 01:26:39 +09:00
Masaaki Goshima 2b5effab31 Remove unused operation ( RootMap ) 2020-09-16 18:49:47 +09:00
Masaaki Goshima aaea586778 Enable switch map processing at runtime 2020-09-16 18:15:47 +09:00
Masaaki Goshima 898d58b8b8 Supported sorted map 2020-09-16 14:51:37 +09:00
Masaaki Goshima 92fb386db5 Optimize encoding for byteSlice type 2020-09-15 23:22:35 +09:00
Masaaki Goshima 6cac23acc3 Remove unused condition 2020-09-15 20:48:32 +09:00
Masaaki Goshima e9e9aa8874 Use next code index for recursive call 2020-09-15 20:48:16 +09:00
Masaaki Goshima acee1ef8ba Refactor errUnsupportedValue 2020-09-15 20:48:02 +09:00
Masaaki Goshima 02e04238a2 Add keepRefs field 2020-09-04 20:28:27 +09:00
Masaaki Goshima 3e4e83bf34 Save iter value 2020-09-04 19:33:46 +09:00
Masaaki Goshima f297c99af1 Remove unused arguments 2020-09-04 13:53:25 +09:00
Masaaki Goshima 3a3122c286 Add opStructFieldRecursiveEnd 2020-09-04 13:48:21 +09:00
Masaaki Goshima efcf2dec06 Refactor 2020-09-03 22:05:46 +09:00
Masaaki Goshima 34b662b98e Add InterfaceEnd operation 2020-09-03 15:36:11 +09:00
Masaaki Goshima 3aa921e884 Fix encoding engine 2020-09-01 22:26:26 +09:00
Masaaki Goshima 72bc598dd4 Remove state variables from opcode 2020-08-31 21:59:22 +09:00
Masaaki Goshima a6276c4d8e Optimize opcode.idx and seenPtr 2020-08-31 03:14:37 +09:00
Masaaki Goshima 70f8f01ef3 Use encodeRuntimeContext.ptrs instead of opcode.ptr 2020-08-30 23:58:58 +09:00
Masaaki Goshima cb194687a0 Add encodeRuntimeContext 2020-08-30 17:52:59 +09:00
Masaaki Goshima e508ad41ba Refactor indent parameter 2020-08-29 15:35:03 +09:00
Masaaki Goshima 7dcadbd6ce Refactor with encodeCompileContext 2020-08-29 15:11:31 +09:00
Masaaki Goshima a75d05a74f Fix unnecessary pointer assignment 2020-08-27 21:05:37 +09:00
Masaaki Goshima 8463646eb0 Fix encoding for Indent/MarshalIndent 2020-08-27 21:01:53 +09:00
Masaaki Goshima e28091e4c7 Improve performance for []byte type 2020-08-25 17:19:41 +09:00
Masaaki Goshima 6681db131f Fix StructFieldHead operation 2020-08-25 17:19:19 +09:00
Masaaki Goshima 9ba13f68ff Add special operation for opStructFieldHead and opStructField 2020-08-24 01:50:18 +09:00
Masaaki Goshima 1e765df4f7 Fix indent for empty struct 2020-08-23 00:54:43 +09:00
Masaaki Goshima ff33d8e78d Fix condition for indent 2020-08-23 00:54:19 +09:00
Masaaki Goshima f7a6d65195 Fix new line char 2020-08-23 00:53:38 +09:00
Masaaki Goshima 6a0fd170c6 Fix head operation 2020-08-22 18:28:03 +09:00
Masaaki Goshima 47d7d26a50 Fix head operation 2020-08-22 18:16:06 +09:00
Masaaki Goshima a718a9a1ef Fix anonymous fields 2020-08-22 12:58:34 +09:00
Masaaki Goshima 3e03bdc53f Fix null validation 2020-08-21 11:51:33 +09:00
Masaaki Goshima 95bfc8c549 Add validation for null value 2020-08-21 11:07:55 +09:00
Masaaki Goshima d7518e3151 Fix seenPtr 2020-08-21 01:01:24 +09:00
Masaaki Goshima 7ac966b81e Fix cycle pointer value 2020-08-20 23:56:12 +09:00
Masaaki Goshima 8d029cddbe Fix map key by UnmarshalText 2020-08-20 17:47:38 +09:00
Masaaki Goshima 22f3bba9a8 Support string tag operation 2020-08-19 19:56:02 +09:00
Masaaki Goshima 13a15040b3 Support encoding of []byte type 2020-08-19 10:34:11 +09:00
Masaaki Goshima 9c8cd890af Remove debug print 2020-08-19 00:41:55 +09:00
Masaaki Goshima 1d2beb8473 Add test cases for MarshalJSON and MarshalText 2020-08-19 00:32:45 +09:00
Masaaki Goshima 7ffe1ddb35 Fix MarshalJSON/MarshalText 2020-08-18 13:36:36 +09:00
Masaaki Goshima 92ed6c6d7e
Merge pull request #25 from goccy/feature/support-anonymous-struct
Support embedded field
2020-08-15 18:40:52 +09:00
Masaaki Goshima bcc5738c6f Optimize StrucrFieldHead operation 2020-08-15 18:36:02 +09:00
Masaaki Goshima 64cd28839f Add AnonymousOmitEmpty type 2020-08-15 18:17:48 +09:00
Masaaki Goshima 025ac2a53b Support embedded struct 2020-08-15 17:41:38 +09:00
Masaaki Goshima cff09d2448 Fix Compact 2020-08-14 18:18:32 +09:00
Masaaki Goshima 2a99704531 Fix recursive definition of struct 2020-08-13 15:26:35 +09:00
Masaaki Goshima b71f7da8bc Fix recursive type definition 2020-08-12 18:42:29 +09:00
Masaaki Goshima ee13701278 Add Compact/Indent/HTMLEscape/Valid 2020-08-12 16:54:15 +09:00
Masaaki Goshima 7eafd08a56 Fix encoding of struct field after omitempty field 2020-08-08 18:53:01 +09:00
Masaaki Goshima aae63769a1 Support MarshalerError 2020-05-09 01:38:00 +09:00
Masaaki Goshima d8d711ecf9 Add error type compatible with encoding/json 2020-05-09 01:07:33 +09:00
Masaaki Goshima c23e5f43a7 Support UnmarshalJSON 2020-05-08 20:22:57 +09:00
Masaaki Goshima 33dcd50a5d Support MarshalJSON/MarshalText 2020-05-04 18:39:17 +09:00
Masaaki Goshima 6602d2d38c Support SetEscapeHTML 2020-05-03 17:41:33 +09:00
Masaaki Goshima 3d7267abc8 Add MarshalIndent 2020-05-02 23:35:41 +09:00
Masaaki Goshima 03a21193fc Support omitempty 2020-05-01 13:12:01 +09:00
Masaaki Goshima 4edbe3a346 Refactor encoder 2020-04-30 13:52:24 +09:00
Masaaki Goshima 090887bf7e Support Map and Interfacfe{} type for encoding of vm based 2020-04-30 13:39:47 +09:00
Masaaki Goshima 95b2194742 Add optimized code 2020-04-30 11:56:56 +09:00
Masaaki Goshima 40544f1ea2 Optimize opcode 2020-04-30 01:44:48 +09:00
Masaaki Goshima 4f3b1262b2 Add VirtualMachine for Encoder 2020-04-30 00:31:50 +09:00