github.com/lxt1045/json@v0.0.0-20231013032136-54d6b1d6e525/func_marshal_unmarshal.go (about)

     1  // MIT License
     2  //
     3  // Copyright (c) 2021 Xiantu Li
     4  //
     5  // Permission is hereby granted, free of charge, to any person obtaining a copy
     6  // of this software and associated documentation files (the "Software"), to deal
     7  // in the Software without restriction, including without limitation the rights
     8  // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
     9  // copies of the Software, and to permit persons to whom the Software is
    10  // furnished to do so, subject to the following conditions:
    11  //
    12  // The above copyright notice and this permission notice shall be included in all
    13  // copies or substantial portions of the Software.
    14  //
    15  // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
    16  // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
    17  // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
    18  // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
    19  // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
    20  // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
    21  // SOFTWARE.
    22  
    23  package json
    24  
    25  import (
    26  	"encoding/base64"
    27  	"strconv"
    28  	"strings"
    29  	"unsafe"
    30  
    31  	lxterrs "github.com/lxt1045/errors"
    32  )
    33  
    34  type unmFunc = func(idxSlash int, store PoolStore, stream string) (i, iSlash int)
    35  type mFunc = func(store Store, in []byte) (out []byte)
    36  
    37  func pointerOffset(p unsafe.Pointer, offset uintptr) (pOut unsafe.Pointer) {
    38  	return unsafe.Pointer(uintptr(p) + uintptr(offset))
    39  }
    40  
    41  func bytesSet(store PoolStore, bs string) (pBase unsafe.Pointer) {
    42  	pBase = store.obj
    43  	pbs := (*[]byte)(store.obj)
    44  	// *pbs = make([]byte, len(bs)*2)
    45  	// n, err := base64.StdEncoding.Decode(*pbs, stringBytes(bs))
    46  	var err error
    47  	*pbs, err = base64.StdEncoding.DecodeString(bs)
    48  	if err != nil {
    49  		err = lxterrs.Wrap(err, ErrStream(bs))
    50  		return
    51  	}
    52  	// *pbs = (*pbs)[:n]
    53  	return
    54  }
    55  func bytesGet(store Store, in []byte) (out []byte) {
    56  	pObj := store.obj
    57  	bs := *(*[]byte)(pObj)
    58  	l, need := len(in), base64.StdEncoding.EncodedLen(len(bs))
    59  	if l+need > cap(in) {
    60  		//没有足够空间
    61  		in = append(in, make([]byte, need)...)
    62  	}
    63  	base64.StdEncoding.Encode(in[l:l+need], bs)
    64  	out = in[:l+need]
    65  	return
    66  }
    67  
    68  func boolMFuncs(pidx *uintptr) (fUnm unmFunc, fM mFunc) {
    69  	if pidx == nil {
    70  		fUnm = func(idxSlash int, store PoolStore, stream string) (i, iSlash int) {
    71  			iSlash = idxSlash
    72  			store.obj = pointerOffset(store.obj, store.tag.Offset)
    73  			if stream[0] == 't' && stream[1] == 'r' && stream[2] == 'u' && stream[3] == 'e' {
    74  				i = 4
    75  				*(*bool)(store.obj) = true
    76  			} else if stream[0] == 'f' && stream[1] == 'a' && stream[2] == 'l' && stream[3] == 's' && stream[4] == 'e' {
    77  				i = 5
    78  				*(*bool)(store.obj) = false
    79  			} else {
    80  				err := lxterrs.New("should be \"false\" or \"true\", not [%s]", ErrStream(stream))
    81  				panic(err)
    82  			}
    83  			return
    84  		}
    85  		// fM = boolGet
    86  		fM = func(store Store, in []byte) (out []byte) {
    87  			// store.obj = pointerOffset(store.obj, store.tag.Offset)
    88  			if *(*bool)(store.obj) {
    89  				out = append(in, "true"...)
    90  			} else {
    91  				out = append(in, "false"...)
    92  			}
    93  			return
    94  		}
    95  		return
    96  	}
    97  
    98  	fUnm = func(idxSlash int, store PoolStore, stream string) (i, iSlash int) {
    99  		iSlash = idxSlash
   100  		store.obj = pointerOffset(store.obj, store.tag.Offset)
   101  		if stream[0] == 't' && stream[1] == 'r' && stream[2] == 'u' && stream[3] == 'e' {
   102  			i = 4
   103  			store.obj = store.Idx(*pidx)
   104  			*(*bool)(store.obj) = true
   105  		} else if stream[0] == 'f' && stream[1] == 'a' && stream[2] == 'l' && stream[3] == 's' && stream[4] == 'e' {
   106  			i = 5
   107  			store.obj = store.Idx(*pidx)
   108  			*(*bool)(store.obj) = false
   109  		} else if stream[0] == 'n' && stream[1] == 'u' && stream[2] == 'l' && stream[3] == 'l' {
   110  			i = 4
   111  			return
   112  		} else {
   113  			err := lxterrs.New("should be \"false\" or \"true\", not [%s]", ErrStream(stream))
   114  			panic(err)
   115  		}
   116  		return
   117  	}
   118  	fM = func(store Store, in []byte) (out []byte) {
   119  		pObj := *(*unsafe.Pointer)(store.obj)
   120  		if pObj == nil {
   121  			out = append(in, "null"...)
   122  		} else if *(*bool)(pObj) {
   123  			out = append(in, "true"...)
   124  		} else {
   125  			out = append(in, "false"...)
   126  		}
   127  		return
   128  	}
   129  	return
   130  }
   131  
   132  func float64UnmFuncs(stream string) (f float64, i int) {
   133  	for ; i < len(stream); i++ {
   134  		c := stream[i]
   135  		if spaceTable[c] || c == ']' || c == '}' || c == ',' {
   136  			break
   137  		}
   138  	}
   139  	f, err := strconv.ParseFloat(stream[:i], 64)
   140  	if err != nil {
   141  		err = lxterrs.Wrap(err, ErrStream(stream[:i]))
   142  		panic(err)
   143  	}
   144  	return
   145  }
   146  
   147  func uint64MFuncs(pidx *uintptr) (fUnm unmFunc, fM mFunc) {
   148  	if pidx == nil {
   149  		fUnm = func(idxSlash int, store PoolStore, stream string) (i, iSlash int) {
   150  			iSlash = idxSlash
   151  			for ; i < len(stream); i++ {
   152  				c := stream[i]
   153  				if spaceTable[c] || c == ']' || c == '}' || c == ',' {
   154  					break
   155  				}
   156  			}
   157  			store.obj = pointerOffset(store.obj, store.tag.Offset)
   158  			num, err := strconv.ParseUint(stream[:i], 10, 64)
   159  			if err != nil {
   160  				err = lxterrs.Wrap(err, ErrStream(stream[:i]))
   161  				panic(err)
   162  			}
   163  			*(*uint64)(store.obj) = num
   164  			return
   165  		}
   166  		fM = func(store Store, in []byte) (out []byte) {
   167  			// store.obj = pointerOffset(store.obj, store.tag.Offset)
   168  			num := *(*uint64)(store.obj)
   169  			out = strconv.AppendUint(in, num, 10)
   170  			return
   171  		}
   172  		return
   173  	}
   174  	fUnm = func(idxSlash int, store PoolStore, stream string) (i, iSlash int) {
   175  		iSlash = idxSlash
   176  		for ; i < len(stream); i++ {
   177  			c := stream[i]
   178  			if spaceTable[c] || c == ']' || c == '}' || c == ',' {
   179  				break
   180  			}
   181  		}
   182  		store.obj = pointerOffset(store.obj, store.tag.Offset)
   183  		store.obj = store.Idx(*pidx)
   184  		num, err := strconv.ParseUint(stream[:i], 10, 64)
   185  		if err != nil {
   186  			err = lxterrs.Wrap(err, ErrStream(stream[:i]))
   187  			panic(err)
   188  		}
   189  		*(*uint64)(store.obj) = num
   190  		return
   191  	}
   192  	fM = func(store Store, in []byte) (out []byte) {
   193  		// store.obj = pointerOffset(store.obj, store.tag.Offset)
   194  		store.obj = *(*unsafe.Pointer)(store.obj)
   195  		if store.obj == nil {
   196  			out = append(in, "null"...)
   197  			return
   198  		}
   199  		num := *(*uint64)(store.obj)
   200  		out = strconv.AppendUint(in, num, 10)
   201  		return
   202  	}
   203  	return
   204  }
   205  
   206  func int64MFuncs(pidx *uintptr) (fUnm unmFunc, fM mFunc) {
   207  	if pidx == nil {
   208  		fUnm = func(idxSlash int, store PoolStore, stream string) (i, iSlash int) {
   209  			iSlash = idxSlash
   210  			if stream[0] == 'n' && stream[1] == 'u' && stream[2] == 'l' && stream[3] == 'l' {
   211  				i = 4
   212  				return
   213  			}
   214  			num, i := ParseInt(stream)
   215  			store.obj = pointerOffset(store.obj, store.tag.Offset)
   216  			*(*int64)(store.obj) = num
   217  			return
   218  		}
   219  		fM = func(store Store, in []byte) (out []byte) {
   220  			// store.obj = pointerOffset(store.obj, store.tag.Offset)
   221  			num := *(*int64)(store.obj)
   222  			out = strconv.AppendInt(in, num, 10)
   223  			return
   224  		}
   225  		return
   226  	}
   227  	fUnm = func(idxSlash int, store PoolStore, stream string) (i, iSlash int) {
   228  		iSlash = idxSlash
   229  		num, i := ParseInt(stream)
   230  		store.obj = pointerOffset(store.obj, store.tag.Offset)
   231  		store.obj = store.Idx(*pidx)
   232  		*(*int64)(store.obj) = num
   233  		return
   234  	}
   235  	fM = func(store Store, in []byte) (out []byte) {
   236  		// store.obj = pointerOffset(store.obj, store.tag.Offset)
   237  		store.obj = *(*unsafe.Pointer)(store.obj)
   238  		if store.obj == nil {
   239  			out = append(in, "null"...)
   240  			return
   241  		}
   242  		num := *(*int64)(store.obj)
   243  		out = strconv.AppendInt(in, num, 10)
   244  		return
   245  	}
   246  	return
   247  }
   248  
   249  func uint32MFuncs(pidx *uintptr) (fUnm unmFunc, fM mFunc) {
   250  	if pidx == nil {
   251  		fUnm = func(idxSlash int, store PoolStore, stream string) (i, iSlash int) {
   252  			iSlash = idxSlash
   253  			for ; i < len(stream); i++ {
   254  				c := stream[i]
   255  				if spaceTable[c] || c == ']' || c == '}' || c == ',' {
   256  					break
   257  				}
   258  			}
   259  			store.obj = pointerOffset(store.obj, store.tag.Offset)
   260  			num, err := strconv.ParseUint(stream[:i], 10, 64)
   261  			if err != nil {
   262  				err = lxterrs.Wrap(err, ErrStream(stream[:i]))
   263  				panic(err)
   264  			}
   265  			*(*uint32)(store.obj) = uint32(num)
   266  			return
   267  		}
   268  		fM = func(store Store, in []byte) (out []byte) {
   269  			// store.obj = pointerOffset(store.obj, store.tag.Offset)
   270  			num := *(*uint32)(store.obj)
   271  			out = strconv.AppendUint(in, uint64(num), 10)
   272  			return
   273  		}
   274  		return
   275  	}
   276  	fUnm = func(idxSlash int, store PoolStore, stream string) (i, iSlash int) {
   277  		iSlash = idxSlash
   278  		for ; i < len(stream); i++ {
   279  			c := stream[i]
   280  			if spaceTable[c] || c == ']' || c == '}' || c == ',' {
   281  				break
   282  			}
   283  		}
   284  		store.obj = pointerOffset(store.obj, store.tag.Offset)
   285  		store.obj = store.Idx(*pidx)
   286  		num, err := strconv.ParseUint(stream[:i], 10, 64)
   287  		if err != nil {
   288  			err = lxterrs.Wrap(err, ErrStream(stream[:i]))
   289  			panic(err)
   290  		}
   291  		*(*uint32)(store.obj) = uint32(num)
   292  		return
   293  	}
   294  	fM = func(store Store, in []byte) (out []byte) {
   295  		// store.obj = pointerOffset(store.obj, store.tag.Offset)
   296  		store.obj = *(*unsafe.Pointer)(store.obj)
   297  		if store.obj == nil {
   298  			out = append(in, "null"...)
   299  			return
   300  		}
   301  		num := *(*uint32)(store.obj)
   302  		out = strconv.AppendUint(in, uint64(num), 10)
   303  		return
   304  	}
   305  	return
   306  }
   307  
   308  func int32MFuncs(pidx *uintptr) (fUnm unmFunc, fM mFunc) {
   309  	if pidx == nil {
   310  		fUnm = func(idxSlash int, store PoolStore, stream string) (i, iSlash int) {
   311  			iSlash = idxSlash
   312  			num, i := ParseInt(stream)
   313  			store.obj = pointerOffset(store.obj, store.tag.Offset)
   314  			*(*int32)(store.obj) = int32(num)
   315  			return
   316  		}
   317  		fM = func(store Store, in []byte) (out []byte) {
   318  			// store.obj = pointerOffset(store.obj, store.tag.Offset)
   319  			num := *(*int32)(store.obj)
   320  			out = strconv.AppendInt(in, int64(num), 10)
   321  			return
   322  		}
   323  		return
   324  	}
   325  	fUnm = func(idxSlash int, store PoolStore, stream string) (i, iSlash int) {
   326  		iSlash = idxSlash
   327  		num, i := ParseInt(stream)
   328  		store.obj = pointerOffset(store.obj, store.tag.Offset)
   329  		store.obj = store.Idx(*pidx)
   330  		*(*int32)(store.obj) = int32(num)
   331  		return
   332  	}
   333  	fM = func(store Store, in []byte) (out []byte) {
   334  		// store.obj = pointerOffset(store.obj, store.tag.Offset)
   335  		store.obj = *(*unsafe.Pointer)(store.obj)
   336  		if store.obj == nil {
   337  			out = append(in, "null"...)
   338  			return
   339  		}
   340  		num := *(*int64)(store.obj)
   341  		out = strconv.AppendInt(in, num, 10)
   342  		return
   343  	}
   344  	return
   345  }
   346  
   347  func uint16MFuncs(pidx *uintptr) (fUnm unmFunc, fM mFunc) {
   348  	if pidx == nil {
   349  		fUnm = func(idxSlash int, store PoolStore, stream string) (i, iSlash int) {
   350  			iSlash = idxSlash
   351  			for ; i < len(stream); i++ {
   352  				c := stream[i]
   353  				if spaceTable[c] || c == ']' || c == '}' || c == ',' {
   354  					break
   355  				}
   356  			}
   357  			store.obj = pointerOffset(store.obj, store.tag.Offset)
   358  			num, err := strconv.ParseUint(stream[:i], 10, 64)
   359  			if err != nil {
   360  				err = lxterrs.Wrap(err, ErrStream(stream[:i]))
   361  				panic(err)
   362  			}
   363  			*(*uint16)(store.obj) = uint16(num)
   364  			return
   365  		}
   366  		fM = func(store Store, in []byte) (out []byte) {
   367  			// store.obj = pointerOffset(store.obj, store.tag.Offset)
   368  			num := *(*uint16)(store.obj)
   369  			out = strconv.AppendUint(in, uint64(num), 10)
   370  			return
   371  		}
   372  		return
   373  	}
   374  	fUnm = func(idxSlash int, store PoolStore, stream string) (i, iSlash int) {
   375  		iSlash = idxSlash
   376  		for ; i < len(stream); i++ {
   377  			c := stream[i]
   378  			if spaceTable[c] || c == ']' || c == '}' || c == ',' {
   379  				break
   380  			}
   381  		}
   382  		store.obj = pointerOffset(store.obj, store.tag.Offset)
   383  		store.obj = store.Idx(*pidx)
   384  		num, err := strconv.ParseUint(stream[:i], 10, 64)
   385  		if err != nil {
   386  			err = lxterrs.Wrap(err, ErrStream(stream[:i]))
   387  			panic(err)
   388  		}
   389  		*(*uint16)(store.obj) = uint16(num)
   390  		return
   391  	}
   392  	fM = func(store Store, in []byte) (out []byte) {
   393  		// store.obj = pointerOffset(store.obj, store.tag.Offset)
   394  		store.obj = *(*unsafe.Pointer)(store.obj)
   395  		if store.obj == nil {
   396  			out = append(in, "null"...)
   397  			return
   398  		}
   399  		num := *(*uint16)(store.obj)
   400  		out = strconv.AppendUint(in, uint64(num), 10)
   401  		return
   402  	}
   403  	return
   404  }
   405  
   406  func int16MFuncs(pidx *uintptr) (fUnm unmFunc, fM mFunc) {
   407  	if pidx == nil {
   408  		fUnm = func(idxSlash int, store PoolStore, stream string) (i, iSlash int) {
   409  			iSlash = idxSlash
   410  			num, i := ParseInt(stream)
   411  			store.obj = pointerOffset(store.obj, store.tag.Offset)
   412  			*(*int16)(store.obj) = int16(num)
   413  			return
   414  		}
   415  		fM = func(store Store, in []byte) (out []byte) {
   416  			// store.obj = pointerOffset(store.obj, store.tag.Offset)
   417  			num := *(*int16)(store.obj)
   418  			out = strconv.AppendInt(in, int64(num), 10)
   419  			return
   420  		}
   421  		return
   422  	}
   423  	fUnm = func(idxSlash int, store PoolStore, stream string) (i, iSlash int) {
   424  		iSlash = idxSlash
   425  		num, i := ParseInt(stream)
   426  		store.obj = pointerOffset(store.obj, store.tag.Offset)
   427  		store.obj = store.Idx(*pidx)
   428  		*(*int16)(store.obj) = int16(num)
   429  		return
   430  	}
   431  	fM = func(store Store, in []byte) (out []byte) {
   432  		// store.obj = pointerOffset(store.obj, store.tag.Offset)
   433  		store.obj = *(*unsafe.Pointer)(store.obj)
   434  		if store.obj == nil {
   435  			out = append(in, "null"...)
   436  			return
   437  		}
   438  		num := *(*int16)(store.obj)
   439  		out = strconv.AppendInt(in, int64(num), 10)
   440  		return
   441  	}
   442  	return
   443  }
   444  
   445  func uint8MFuncs(pidx *uintptr) (fUnm unmFunc, fM mFunc) {
   446  	if pidx == nil {
   447  		fUnm = func(idxSlash int, store PoolStore, stream string) (i, iSlash int) {
   448  			iSlash = idxSlash
   449  			for ; i < len(stream); i++ {
   450  				c := stream[i]
   451  				if spaceTable[c] || c == ']' || c == '}' || c == ',' {
   452  					break
   453  				}
   454  			}
   455  			store.obj = pointerOffset(store.obj, store.tag.Offset)
   456  			num, err := strconv.ParseUint(stream[:i], 10, 64)
   457  			if err != nil {
   458  				err = lxterrs.Wrap(err, ErrStream(stream[:i]))
   459  				panic(err)
   460  			}
   461  			*(*uint8)(store.obj) = uint8(num)
   462  			return
   463  		}
   464  		fM = func(store Store, in []byte) (out []byte) {
   465  			// store.obj = pointerOffset(store.obj, store.tag.Offset)
   466  			num := *(*uint8)(store.obj)
   467  			out = strconv.AppendUint(in, uint64(num), 10)
   468  			return
   469  		}
   470  		return
   471  	}
   472  	fUnm = func(idxSlash int, store PoolStore, stream string) (i, iSlash int) {
   473  		iSlash = idxSlash
   474  		for ; i < len(stream); i++ {
   475  			c := stream[i]
   476  			if spaceTable[c] || c == ']' || c == '}' || c == ',' {
   477  				break
   478  			}
   479  		}
   480  		store.obj = pointerOffset(store.obj, store.tag.Offset)
   481  		store.obj = store.Idx(*pidx)
   482  		num, err := strconv.ParseUint(stream[:i], 10, 64)
   483  		if err != nil {
   484  			err = lxterrs.Wrap(err, ErrStream(stream[:i]))
   485  			panic(err)
   486  		}
   487  		*(*uint8)(store.obj) = uint8(num)
   488  		return
   489  	}
   490  	fM = func(store Store, in []byte) (out []byte) {
   491  		// store.obj = pointerOffset(store.obj, store.tag.Offset)
   492  		store.obj = *(*unsafe.Pointer)(store.obj)
   493  		if store.obj == nil {
   494  			out = append(in, "null"...)
   495  			return
   496  		}
   497  		num := *(*uint8)(store.obj)
   498  		out = strconv.AppendUint(in, uint64(num), 10)
   499  		return
   500  	}
   501  	return
   502  }
   503  
   504  func int8MFuncs1(pidx *uintptr) (fUnm unmFunc, fM mFunc) {
   505  	if pidx == nil {
   506  		fUnm = func(idxSlash int, store PoolStore, stream string) (i, iSlash int) {
   507  			iSlash = idxSlash
   508  			for ; i < len(stream); i++ {
   509  				c := stream[i]
   510  				if spaceTable[c] || c == ']' || c == '}' || c == ',' {
   511  					break
   512  				}
   513  			}
   514  			store.obj = pointerOffset(store.obj, store.tag.Offset)
   515  			num, err := strconv.ParseInt(stream[:i], 10, 64)
   516  			if err != nil {
   517  				err = lxterrs.Wrap(err, ErrStream(stream[:i]))
   518  				panic(err)
   519  			}
   520  			*(*int8)(store.obj) = int8(num)
   521  			return
   522  		}
   523  		fM = func(store Store, in []byte) (out []byte) {
   524  			// store.obj = pointerOffset(store.obj, store.tag.Offset)
   525  			num := *(*int64)(store.obj)
   526  			out = strconv.AppendInt(in, num, 10)
   527  			return
   528  		}
   529  		return
   530  	}
   531  	fUnm = func(idxSlash int, store PoolStore, stream string) (i, iSlash int) {
   532  		iSlash = idxSlash
   533  		num, i := ParseInt(stream)
   534  		store.obj = pointerOffset(store.obj, store.tag.Offset)
   535  		store.obj = store.Idx(*pidx)
   536  		*(*int8)(store.obj) = int8(num)
   537  		return
   538  	}
   539  	fM = func(store Store, in []byte) (out []byte) {
   540  		// store.obj = pointerOffset(store.obj, store.tag.Offset)
   541  		store.obj = *(*unsafe.Pointer)(store.obj)
   542  		if store.obj == nil {
   543  			out = append(in, "null"...)
   544  			return
   545  		}
   546  		num := *(*int8)(store.obj)
   547  		out = strconv.AppendInt(in, int64(num), 10)
   548  		return
   549  	}
   550  	return
   551  }
   552  
   553  // 数值:十进制数,不能有前导0,可以为负数,可以有小数部分。还可以用e或者E表示指数部分。
   554  // 不能包含非数,如NaN。不区分整数与浮点数。JavaScript用双精度浮点数表示所有数值。
   555  var toNums = func() (out [128]int8) {
   556  	nums := map[int]int8{
   557  		'0': 0, '1': 1, '2': 2, '3': 3, '4': 4,
   558  		'5': 5, '6': 6, '7': 7, '8': 8, '9': 9,
   559  	}
   560  	for c := range out {
   561  		if spaceTable[c] || c == ']' || c == '}' || c == ',' {
   562  			out[c] = -3
   563  			continue
   564  		}
   565  		if n, ok := nums[c]; ok {
   566  			out[c] = n
   567  			continue
   568  		}
   569  		out[c] = -4
   570  	}
   571  	out['.'] = -1
   572  	out['e'] = -2
   573  	out['E'] = -2
   574  	out['-'] = -5
   575  	out['+'] = -6
   576  	return
   577  }()
   578  
   579  func ParseInt(stream string) (num int64, i int) {
   580  	var e, float, nFloat int64 = 0, 0, 0
   581  	sign, eFlag, floatFlag := false, false, false
   582  	for i < len(stream) {
   583  		c := stream[i]
   584  		nextNum := toNums[c]
   585  		if nextNum >= 0 {
   586  			num = num*10 + int64(nextNum)
   587  			i++
   588  			continue
   589  		}
   590  		if nextNum == -3 {
   591  			break // 退出条件
   592  		}
   593  
   594  		// 非主流逻辑分支后置,保持主要分支简单快速
   595  		if i == 0 {
   596  			if stream[0] == '-' {
   597  				sign = true
   598  				i++
   599  				continue
   600  			} else if stream[0] == '+' {
   601  				i++
   602  				continue
   603  			}
   604  		}
   605  		if !eFlag && nextNum == -1 {
   606  			eFlag = true // e 或 E
   607  			for i++; i < len(stream); i++ {
   608  				c := stream[i]
   609  				nextNum = toNums[c]
   610  				if nextNum >= 0 {
   611  					e = e*10 + int64(nextNum)
   612  					continue
   613  				}
   614  				break
   615  			}
   616  			if nextNum == -3 {
   617  				E := int64(1)
   618  				for j := int64(0); j < e; j++ {
   619  					E *= 10
   620  				}
   621  				if num == 0 && E > 1 {
   622  					num = 1
   623  				}
   624  				num *= E
   625  				if float > 0 {
   626  					f := float64(float)
   627  					nFloat = nFloat - e
   628  					if nFloat > 0 {
   629  						for j := int64(0); j < nFloat; j++ {
   630  							f /= 10
   631  						}
   632  					} else {
   633  						nFloat = -nFloat
   634  						for j := int64(0); j < nFloat; j++ {
   635  							f *= 10
   636  						}
   637  					}
   638  					num = num + int64(f)
   639  				}
   640  				break
   641  			}
   642  			continue
   643  		}
   644  		if !eFlag && !floatFlag && nextNum == -2 {
   645  			floatFlag = true // .
   646  			for i++; i < len(stream); i++ {
   647  				c := stream[i]
   648  				nextNum = toNums[c]
   649  				if nextNum >= 0 {
   650  					float = float*10 + int64(nextNum)
   651  					nFloat++
   652  					continue
   653  				}
   654  				break
   655  			}
   656  			continue
   657  		}
   658  		err := lxterrs.New("error ParseInt:%s", ErrStream(stream[:i]))
   659  		panic(err)
   660  	}
   661  	if sign {
   662  		num = num * -1
   663  	}
   664  	return
   665  }
   666  
   667  func int8MFuncs(pidx *uintptr) (fUnm unmFunc, fM mFunc) {
   668  	if pidx == nil {
   669  		fUnm = func(idxSlash int, store PoolStore, stream string) (i, iSlash int) {
   670  			iSlash = idxSlash
   671  			num, i := ParseInt(stream)
   672  			*(*int8)(store.obj) = int8(num)
   673  			return
   674  		}
   675  		fM = func(store Store, in []byte) (out []byte) {
   676  			// store.obj = pointerOffset(store.obj, store.tag.Offset)
   677  			num := *(*int64)(store.obj)
   678  			out = strconv.AppendInt(in, num, 10)
   679  			return
   680  		}
   681  		return
   682  	}
   683  	fUnm = func(idxSlash int, store PoolStore, stream string) (i, iSlash int) {
   684  		iSlash = idxSlash
   685  		num, i := ParseInt(stream)
   686  		store.obj = pointerOffset(store.obj, store.tag.Offset)
   687  		store.obj = store.Idx(*pidx)
   688  		*(*int8)(store.obj) = int8(num)
   689  		return
   690  	}
   691  	fM = func(store Store, in []byte) (out []byte) {
   692  		// store.obj = pointerOffset(store.obj, store.tag.Offset)
   693  		store.obj = *(*unsafe.Pointer)(store.obj)
   694  		if store.obj == nil {
   695  			out = append(in, "null"...)
   696  			return
   697  		}
   698  		num := *(*int8)(store.obj)
   699  		out = strconv.AppendInt(in, int64(num), 10)
   700  		return
   701  	}
   702  	return
   703  }
   704  
   705  func float64MFuncs(pidx *uintptr) (fUnm unmFunc, fM mFunc) {
   706  	if pidx == nil {
   707  		fUnm = func(idxSlash int, store PoolStore, stream string) (i, iSlash int) {
   708  			iSlash = idxSlash
   709  			for ; i < len(stream); i++ {
   710  				c := stream[i]
   711  				if spaceTable[c] || c == ']' || c == '}' || c == ',' {
   712  					break
   713  				}
   714  			}
   715  			store.obj = pointerOffset(store.obj, store.tag.Offset)
   716  			f, err := strconv.ParseFloat(stream[:i], 64)
   717  			if err != nil {
   718  				err = lxterrs.Wrap(err, ErrStream(stream[:i]))
   719  				panic(err)
   720  			}
   721  			*(*float64)(store.obj) = f
   722  			return
   723  		}
   724  		fM = func(store Store, in []byte) (out []byte) {
   725  			// store.obj = pointerOffset(store.obj, store.tag.Offset)
   726  			num := *(*float64)(store.obj)
   727  			out = strconv.AppendFloat(in, float64(num), 'f', -1, 64)
   728  			return
   729  		}
   730  		return
   731  	}
   732  	fUnm = func(idxSlash int, store PoolStore, stream string) (i, iSlash int) {
   733  		iSlash = idxSlash
   734  		for ; i < len(stream); i++ {
   735  			c := stream[i]
   736  			if spaceTable[c] || c == ']' || c == '}' || c == ',' {
   737  				break
   738  			}
   739  		}
   740  		store.obj = pointerOffset(store.obj, store.tag.Offset)
   741  		store.obj = store.Idx(*pidx)
   742  		f, err := strconv.ParseFloat(stream[:i], 64)
   743  		if err != nil {
   744  			err = lxterrs.Wrap(err, ErrStream(stream[:i]))
   745  			panic(err)
   746  		}
   747  		*(*float64)(store.obj) = f
   748  		return
   749  	}
   750  	fM = func(store Store, in []byte) (out []byte) {
   751  		// store.obj = pointerOffset(store.obj, store.tag.Offset)
   752  		store.obj = *(*unsafe.Pointer)(store.obj)
   753  		if store.obj == nil {
   754  			out = append(in, "null"...)
   755  			return
   756  		}
   757  		num := *(*float64)(store.obj)
   758  		out = strconv.AppendFloat(in, float64(num), 'f', -1, 64)
   759  		return
   760  	}
   761  	return
   762  }
   763  func float32MFuncs(pidx *uintptr) (fUnm unmFunc, fM mFunc) {
   764  	if pidx == nil {
   765  		fUnm = func(idxSlash int, store PoolStore, stream string) (i, iSlash int) {
   766  			iSlash = idxSlash
   767  			for ; i < len(stream); i++ {
   768  				c := stream[i]
   769  				if spaceTable[c] || c == ']' || c == '}' || c == ',' {
   770  					break
   771  				}
   772  			}
   773  			store.obj = pointerOffset(store.obj, store.tag.Offset)
   774  			f, err := strconv.ParseFloat(stream[:i], 64)
   775  			if err != nil {
   776  				err = lxterrs.Wrap(err, ErrStream(stream[:i]))
   777  				panic(err)
   778  			}
   779  			*(*float32)(store.obj) = float32(f)
   780  			return
   781  		}
   782  		fM = func(store Store, in []byte) (out []byte) {
   783  			// store.obj = pointerOffset(store.obj, store.tag.Offset)
   784  			num := *(*float32)(store.obj)
   785  			out = strconv.AppendFloat(in, float64(num), 'f', -1, 64)
   786  			return
   787  		}
   788  		return
   789  	}
   790  	fUnm = func(idxSlash int, store PoolStore, stream string) (i, iSlash int) {
   791  		iSlash = idxSlash
   792  		for ; i < len(stream); i++ {
   793  			c := stream[i]
   794  			if spaceTable[c] || c == ']' || c == '}' || c == ',' {
   795  				break
   796  			}
   797  		}
   798  		store.obj = pointerOffset(store.obj, store.tag.Offset)
   799  		store.obj = store.Idx(*pidx)
   800  		f, err := strconv.ParseFloat(stream[:i], 64)
   801  		if err != nil {
   802  			err = lxterrs.Wrap(err, ErrStream(stream[:i]))
   803  			panic(err)
   804  		}
   805  		*(*float32)(store.obj) = float32(f)
   806  		return
   807  	}
   808  	fM = func(store Store, in []byte) (out []byte) {
   809  		// store.obj = pointerOffset(store.obj, store.tag.Offset)
   810  		store.obj = *(*unsafe.Pointer)(store.obj)
   811  		if store.obj == nil {
   812  			out = append(in, "null"...)
   813  			return
   814  		}
   815  		num := *(*float32)(store.obj)
   816  		out = strconv.AppendFloat(in, float64(num), 'f', -1, 64)
   817  		return
   818  	}
   819  	return
   820  }
   821  
   822  func structMFuncs(pidx, sonPidx *uintptr) (fUnm unmFunc, fM mFunc) {
   823  	if pidx == nil {
   824  		fUnm = func(idxSlash int, store PoolStore, stream string) (i, iSlash int) {
   825  			if stream[0] == 'n' && stream[1] == 'u' && stream[2] == 'l' && stream[3] == 'l' {
   826  				i = 4
   827  				iSlash = idxSlash
   828  				return
   829  			}
   830  			store.obj = pointerOffset(store.obj, store.tag.Offset)
   831  			store.pointerPool = pointerOffset(store.pointerPool, *sonPidx) //这里有问题,这个 pool 导致 slicePool 的偏移
   832  			store.slicePool = pointerOffset(store.slicePool, store.tag.idxSliceObjPool)
   833  			n, iSlash := parseObj(idxSlash-1, stream[1:], store)
   834  			iSlash++
   835  			i += n + 1
   836  			return
   837  		}
   838  		fM = func(store Store, in []byte) (out []byte) {
   839  			// store.obj = pointerOffset(store.obj, store.tag.Offset)
   840  			out = marshalStruct(store, in)
   841  			return
   842  		}
   843  		return
   844  	}
   845  	fUnm = func(idxSlash int, store PoolStore, stream string) (i, iSlash int) {
   846  		if stream[0] == 'n' && stream[1] == 'u' && stream[2] == 'l' && stream[3] == 'l' {
   847  			i = 4
   848  			iSlash = idxSlash
   849  			return
   850  		}
   851  		store.obj = pointerOffset(store.obj, store.tag.Offset)
   852  		store.pointerPool = pointerOffset(store.pointerPool, *sonPidx) //这里有问题,这个 pool 导致 slicePool 的偏移
   853  		store.slicePool = pointerOffset(store.slicePool, store.tag.idxSliceObjPool)
   854  		p := *(*unsafe.Pointer)(store.obj)
   855  		if p == nil {
   856  			store.obj = store.Idx(*pidx)
   857  		}
   858  		n, iSlash := parseObj(idxSlash-1, stream[1:], store)
   859  		iSlash++
   860  		i += n + 1
   861  		return
   862  	}
   863  	fM = func(store Store, in []byte) (out []byte) {
   864  		// store.obj = pointerOffset(store.obj, store.tag.Offset)
   865  		store.obj = *(*unsafe.Pointer)(store.obj)
   866  		out = marshalStruct(store, in)
   867  		return
   868  	}
   869  	return
   870  }
   871  
   872  func sliceIntsMFuncs(pidx *uintptr) (fUnm unmFunc, fM mFunc) {
   873  	if pidx == nil {
   874  		fUnm = func(idxSlash int, store PoolStore, stream string) (i, iSlash int) {
   875  			if stream[0] == 'n' && stream[1] == 'u' && stream[2] == 'l' && stream[3] == 'l' {
   876  				i = 4
   877  				iSlash = idxSlash
   878  				store.obj = pointerOffset(store.obj, store.tag.Offset)
   879  				pHeader := (*SliceHeader)(store.obj)
   880  				pHeader.Data = store.obj
   881  				return
   882  			}
   883  			store.obj = pointerOffset(store.obj, store.tag.Offset) //
   884  			n, iSlash := parseIntSlice(idxSlash-1, stream[1:], store)
   885  			iSlash++
   886  			i += n + 1
   887  			return
   888  		}
   889  		fM = func(store Store, in []byte) (out []byte) {
   890  			// store.obj = pointerOffset(store.obj, store.tag.Offset)
   891  			pHeader := (*SliceHeader)(store.obj)
   892  			son := store.tag.ChildList[0]
   893  			out = marshalSlice(in, Store{obj: pHeader.Data, tag: son}, pHeader.Len)
   894  			return
   895  		}
   896  		return
   897  	}
   898  	fUnm = func(idxSlash int, store PoolStore, stream string) (i, iSlash int) {
   899  		if stream[0] == 'n' && stream[1] == 'u' && stream[2] == 'l' && stream[3] == 'l' {
   900  			i = 4
   901  			iSlash = idxSlash
   902  			store.obj = pointerOffset(store.obj, store.tag.Offset)
   903  			store.obj = store.Idx(*pidx)
   904  			pHeader := (*SliceHeader)(store.obj)
   905  			pHeader.Data = store.obj
   906  			return
   907  		}
   908  		store.obj = pointerOffset(store.obj, store.tag.Offset) //
   909  		p := *(*unsafe.Pointer)(store.obj)
   910  		if p == nil {
   911  			store.obj = store.Idx(*pidx)
   912  		}
   913  		n, iSlash := parseIntSlice(idxSlash-1, stream[1:], store)
   914  		iSlash++
   915  		i += n + 1
   916  		return
   917  	}
   918  	fM = func(store Store, in []byte) (out []byte) {
   919  		// store.obj = pointerOffset(store.obj, store.tag.Offset)
   920  		store.obj = *(*unsafe.Pointer)(store.obj)
   921  		if store.obj == nil {
   922  			out = append(in, "null"...)
   923  			return
   924  		}
   925  		pHeader := (*SliceHeader)(store.obj)
   926  		son := store.tag.ChildList[0]
   927  		out = marshalSlice(in, Store{obj: pHeader.Data, tag: son}, pHeader.Len)
   928  		return
   929  	}
   930  	return
   931  }
   932  func sliceNoscanMFuncs(pidx *uintptr) (fUnm unmFunc, fM mFunc) {
   933  	if pidx == nil {
   934  		fUnm = func(idxSlash int, store PoolStore, stream string) (i, iSlash int) {
   935  			if stream[0] == 'n' && stream[1] == 'u' && stream[2] == 'l' && stream[3] == 'l' {
   936  				i = 4
   937  				iSlash = idxSlash
   938  				store.obj = pointerOffset(store.obj, store.tag.Offset)
   939  				pHeader := (*SliceHeader)(store.obj)
   940  				pHeader.Data = store.obj
   941  				return
   942  			}
   943  			store.obj = pointerOffset(store.obj, store.tag.Offset) //
   944  			n, iSlash := parseNoscanSlice(idxSlash-1, stream[1:], store)
   945  			iSlash++
   946  			i += n + 1
   947  			return
   948  		}
   949  		fM = func(store Store, in []byte) (out []byte) {
   950  			// store.obj = pointerOffset(store.obj, store.tag.Offset)
   951  			pHeader := (*SliceHeader)(store.obj)
   952  			son := store.tag.ChildList[0]
   953  			out = marshalSlice(in, Store{obj: pHeader.Data, tag: son}, pHeader.Len)
   954  			return
   955  		}
   956  		return
   957  	}
   958  	fUnm = func(idxSlash int, store PoolStore, stream string) (i, iSlash int) {
   959  		if stream[0] == 'n' && stream[1] == 'u' && stream[2] == 'l' && stream[3] == 'l' {
   960  			i = 4
   961  			iSlash = idxSlash
   962  			store.obj = pointerOffset(store.obj, store.tag.Offset)
   963  			store.obj = store.Idx(*pidx)
   964  			pHeader := (*SliceHeader)(store.obj)
   965  			pHeader.Data = store.obj
   966  			return
   967  		}
   968  		store.obj = pointerOffset(store.obj, store.tag.Offset) //
   969  		p := *(*unsafe.Pointer)(store.obj)
   970  		if p == nil {
   971  			store.obj = store.Idx(*pidx)
   972  		}
   973  		n, iSlash := parseNoscanSlice(idxSlash-1, stream[1:], store)
   974  		iSlash++
   975  		i += n + 1
   976  		return
   977  	}
   978  	fM = func(store Store, in []byte) (out []byte) {
   979  		// store.obj = pointerOffset(store.obj, store.tag.Offset)
   980  		store.obj = *(*unsafe.Pointer)(store.obj)
   981  		if store.obj == nil {
   982  			out = append(in, "null"...)
   983  			return
   984  		}
   985  		pHeader := (*SliceHeader)(store.obj)
   986  		son := store.tag.ChildList[0]
   987  		out = marshalSlice(in, Store{obj: pHeader.Data, tag: son}, pHeader.Len)
   988  		return
   989  	}
   990  	return
   991  }
   992  
   993  func sliceNoscanMFuncs2(pidx *uintptr) (fUnm unmFunc, fM mFunc) {
   994  	if pidx == nil {
   995  		fUnm = func(idxSlash int, store PoolStore, stream string) (i, iSlash int) {
   996  			if stream[0] == 'n' && stream[1] == 'u' && stream[2] == 'l' && stream[3] == 'l' {
   997  				i = 4
   998  				iSlash = idxSlash
   999  				store.obj = pointerOffset(store.obj, store.tag.Offset)
  1000  				pHeader := (*SliceHeader)(store.obj)
  1001  				pHeader.Data = store.obj
  1002  				return
  1003  			}
  1004  			store.obj = pointerOffset(store.obj, store.tag.Offset) //
  1005  			n, iSlash := parseNoscanSlice(idxSlash-1, stream[1:], store)
  1006  			iSlash++
  1007  			i += n + 1
  1008  			return
  1009  		}
  1010  		fM = func(store Store, in []byte) (out []byte) {
  1011  			// store.obj = pointerOffset(store.obj, store.tag.Offset)
  1012  			pHeader := (*SliceHeader)(store.obj)
  1013  			son := store.tag.ChildList[0]
  1014  			out = marshalSlice(in, Store{obj: pHeader.Data, tag: son}, pHeader.Len)
  1015  			return
  1016  		}
  1017  		return
  1018  	}
  1019  	fUnm = func(idxSlash int, store PoolStore, stream string) (i, iSlash int) {
  1020  		if stream[0] == 'n' && stream[1] == 'u' && stream[2] == 'l' && stream[3] == 'l' {
  1021  			i = 4
  1022  			iSlash = idxSlash
  1023  			store.obj = pointerOffset(store.obj, store.tag.Offset)
  1024  			store.obj = store.Idx(*pidx)
  1025  			pHeader := (*SliceHeader)(store.obj)
  1026  			pHeader.Data = store.obj
  1027  			return
  1028  		}
  1029  		store.obj = pointerOffset(store.obj, store.tag.Offset) //
  1030  		p := *(*unsafe.Pointer)(store.obj)
  1031  		if p == nil {
  1032  			store.obj = store.Idx(*pidx)
  1033  		}
  1034  		n, iSlash := parseNoscanSlice(idxSlash-1, stream[1:], store)
  1035  		iSlash++
  1036  		i += n + 1
  1037  		return
  1038  	}
  1039  	fM = func(store Store, in []byte) (out []byte) {
  1040  		// store.obj = pointerOffset(store.obj, store.tag.Offset)
  1041  		store.obj = *(*unsafe.Pointer)(store.obj)
  1042  		if store.obj == nil {
  1043  			out = append(in, "null"...)
  1044  			return
  1045  		}
  1046  		pHeader := (*SliceHeader)(store.obj)
  1047  		son := store.tag.ChildList[0]
  1048  		out = marshalSlice(in, Store{obj: pHeader.Data, tag: son}, pHeader.Len)
  1049  		return
  1050  	}
  1051  	return
  1052  }
  1053  
  1054  func sliceMFuncs(pidx *uintptr) (fUnm unmFunc, fM mFunc) {
  1055  	if pidx == nil {
  1056  		fUnm = func(idxSlash int, store PoolStore, stream string) (i, iSlash int) {
  1057  			if stream[0] == 'n' && stream[1] == 'u' && stream[2] == 'l' && stream[3] == 'l' {
  1058  				i = 4
  1059  				iSlash = idxSlash
  1060  				store.obj = pointerOffset(store.obj, store.tag.Offset)
  1061  				pHeader := (*SliceHeader)(store.obj)
  1062  				pHeader.Data = store.obj
  1063  				return
  1064  			}
  1065  			store.obj = pointerOffset(store.obj, store.tag.Offset) //
  1066  			store.slicePool = pointerOffset(store.slicePool, store.tag.idxSliceObjPool)
  1067  			n, iSlash := parseSlice(idxSlash-1, stream[1:], store)
  1068  			iSlash++
  1069  			i += n + 1
  1070  			return
  1071  		}
  1072  		fM = func(store Store, in []byte) (out []byte) {
  1073  			// store.obj = pointerOffset(store.obj, store.tag.Offset)
  1074  			pHeader := (*SliceHeader)(store.obj)
  1075  			son := store.tag.ChildList[0]
  1076  			out = marshalSlice(in, Store{obj: pHeader.Data, tag: son}, pHeader.Len)
  1077  			return
  1078  		}
  1079  		return
  1080  	}
  1081  	fUnm = func(idxSlash int, store PoolStore, stream string) (i, iSlash int) {
  1082  		if stream[0] == 'n' && stream[1] == 'u' && stream[2] == 'l' && stream[3] == 'l' {
  1083  			i = 4
  1084  			iSlash = idxSlash
  1085  			store.obj = pointerOffset(store.obj, store.tag.Offset)
  1086  			store.obj = store.Idx(*pidx)
  1087  			pHeader := (*SliceHeader)(store.obj)
  1088  			pHeader.Data = store.obj
  1089  			return
  1090  		}
  1091  		store.obj = pointerOffset(store.obj, store.tag.Offset) //
  1092  		store.slicePool = pointerOffset(store.slicePool, store.tag.idxSliceObjPool)
  1093  		p := *(*unsafe.Pointer)(store.obj)
  1094  		if p == nil {
  1095  			store.obj = store.Idx(*pidx) // TODO 这个可以 pidx==nil 合并? 这时 *pidx==0?
  1096  		}
  1097  		n, iSlash := parseSlice(idxSlash-1, stream[1:], store)
  1098  		iSlash++
  1099  		i += n + 1
  1100  		return
  1101  	}
  1102  	fM = func(store Store, in []byte) (out []byte) {
  1103  		// store.obj = pointerOffset(store.obj, store.tag.Offset)
  1104  		store.obj = *(*unsafe.Pointer)(store.obj)
  1105  		if store.obj == nil {
  1106  			out = append(in, "null"...)
  1107  			return
  1108  		}
  1109  		pHeader := (*SliceHeader)(store.obj)
  1110  		son := store.tag.ChildList[0]
  1111  		out = marshalSlice(in, Store{obj: pHeader.Data, tag: son}, pHeader.Len)
  1112  		return
  1113  	}
  1114  	return
  1115  }
  1116  
  1117  func bytesMFuncs(pidx *uintptr) (fUnm unmFunc, fM mFunc) {
  1118  	if pidx == nil {
  1119  		fUnm = func(idxSlash int, store PoolStore, stream string) (i, iSlash int) {
  1120  			if stream[0] == 'n' && stream[1] == 'u' && stream[2] == 'l' && stream[3] == 'l' {
  1121  				i = 4
  1122  				iSlash = idxSlash
  1123  				store.obj = pointerOffset(store.obj, store.tag.Offset)
  1124  				pHeader := (*SliceHeader)(store.obj)
  1125  				pHeader.Data = store.obj
  1126  				return
  1127  			}
  1128  			store.obj = pointerOffset(store.obj, store.tag.Offset) //
  1129  
  1130  			//TODO : 解析长度(,]}),hex.Decode
  1131  			bytesSet(store, stream[i:])
  1132  			return
  1133  		}
  1134  		fM = bytesGet
  1135  		return
  1136  	}
  1137  	fUnm = func(idxSlash int, store PoolStore, stream string) (i, iSlash int) {
  1138  		if stream[0] == 'n' && stream[1] == 'u' && stream[2] == 'l' && stream[3] == 'l' {
  1139  			i = 4
  1140  			iSlash = idxSlash
  1141  			store.obj = pointerOffset(store.obj, store.tag.Offset)
  1142  			pHeader := (*SliceHeader)(store.obj)
  1143  			pHeader.Data = store.obj
  1144  			return
  1145  		}
  1146  		store.obj = pointerOffset(store.obj, store.tag.Offset) //
  1147  		p := *(*unsafe.Pointer)(store.obj)
  1148  		if p == nil {
  1149  			store.obj = store.Idx(*pidx)
  1150  		}
  1151  		n, iSlash := parseSlice(idxSlash-1, stream[1:], store)
  1152  		iSlash++
  1153  		i += n + 1
  1154  		return
  1155  	}
  1156  	fM = func(store Store, in []byte) (out []byte) {
  1157  		// store.obj = pointerOffset(store.obj, store.tag.Offset)
  1158  		store.obj = *(*unsafe.Pointer)(store.obj)
  1159  		bytesGet(store, in)
  1160  		return
  1161  	}
  1162  	return
  1163  }
  1164  
  1165  func slicePointerMFuncs(pidx *uintptr) (fUnm unmFunc, fM mFunc) {
  1166  	fUnm = func(idxSlash int, store PoolStore, stream string) (i, iSlash int) {
  1167  		if stream[0] == 'n' && stream[1] == 'u' && stream[2] == 'l' && stream[3] == 'l' {
  1168  			i = 4
  1169  			iSlash = idxSlash
  1170  			store.obj = pointerOffset(store.obj, store.tag.Offset)
  1171  			store.obj = *(*unsafe.Pointer)(store.obj)
  1172  			if store.obj == nil {
  1173  				store.obj = store.Idx(*pidx)
  1174  			}
  1175  			pHeader := (*SliceHeader)(store.obj)
  1176  			pHeader.Data = store.obj
  1177  			return
  1178  		}
  1179  		store.obj = pointerOffset(store.obj, store.tag.Offset) //
  1180  		store.obj = *(*unsafe.Pointer)(store.obj)
  1181  		if store.obj == nil {
  1182  			store.obj = store.Idx(*pidx)
  1183  		}
  1184  
  1185  		n, iSlash := parseSlice(idxSlash-1, stream[1:], store)
  1186  		iSlash++
  1187  		i += n + 1
  1188  		return
  1189  	}
  1190  	fM = func(store Store, in []byte) (out []byte) {
  1191  		store.obj = pointerOffset(store.obj, store.tag.Offset)
  1192  		// pHeader := (*SliceHeader)(store.obj)
  1193  		// son := store.tag.ChildList[0]
  1194  		// out = marshalSlice(in, Store{obj: pHeader.Data, tag: son}, pHeader.Len)
  1195  		return
  1196  	}
  1197  	return
  1198  }
  1199  
  1200  func sliceStringsMFuncs() (fUnm unmFunc, fM mFunc) {
  1201  	fUnm = func(idxSlash int, store PoolStore, stream string) (i, iSlash int) {
  1202  		if stream[0] == 'n' && stream[1] == 'u' && stream[2] == 'l' && stream[3] == 'l' {
  1203  			i = 4
  1204  			iSlash = idxSlash
  1205  			store.obj = pointerOffset(store.obj, store.tag.Offset)
  1206  			pHeader := (*SliceHeader)(store.obj)
  1207  			pHeader.Data = store.obj
  1208  			return
  1209  		}
  1210  		store.obj = pointerOffset(store.obj, store.tag.Offset) //
  1211  		n, iSlash := parseSliceString(idxSlash-1, stream[1:], store)
  1212  		iSlash++
  1213  		i += n + 1
  1214  		return
  1215  	}
  1216  	fM = func(store Store, in []byte) (out []byte) {
  1217  		// store.obj = pointerOffset(store.obj, store.tag.Offset)
  1218  		pHeader := (*SliceHeader)(store.obj)
  1219  		son := store.tag.ChildList[0]
  1220  		out = marshalSlice(in, Store{obj: pHeader.Data, tag: son}, pHeader.Len)
  1221  		return
  1222  	}
  1223  	return
  1224  }
  1225  
  1226  func stringUnm(idxSlash int, store PoolStore, stream string) (i, iSlash int) {
  1227  	if stream[0] == 'n' && stream[1] == 'u' && stream[2] == 'l' && stream[3] == 'l' {
  1228  		i = 4
  1229  		iSlash = idxSlash
  1230  		return
  1231  	}
  1232  	store.obj = pointerOffset(store.obj, store.tag.Offset)
  1233  	pstr := (*string)(store.obj)
  1234  	{
  1235  		i = strings.IndexByte(stream[1:], '"')
  1236  		if idxSlash > i+1 {
  1237  			i++
  1238  			*pstr = stream[1:i]
  1239  			i++
  1240  			iSlash = idxSlash
  1241  		} else {
  1242  			i++
  1243  			*pstr, i, iSlash = parseUnescapeStr(stream, i, idxSlash)
  1244  		}
  1245  	}
  1246  	return
  1247  }
  1248  func stringM(store Store, in []byte) (out []byte) {
  1249  	str := *(*string)(store.obj)
  1250  	out = append(in, '"')
  1251  	// strings.ReplaceAll(str, "\\", "\\\\")
  1252  	nQuote := strings.Count(str, "\"") // 只处理 " , \ 可以不处理
  1253  	if nQuote == 0 {
  1254  		out = append(out, str...) // TODO 需要转义: \ --> \\
  1255  	} else {
  1256  		for {
  1257  			i := strings.IndexByte(str, '"')
  1258  			if i == -1 {
  1259  				out = append(out, str...)
  1260  				break
  1261  			}
  1262  			out = append(out, str[:i]...)
  1263  			out = append(out, '\\', '"')
  1264  			str = str[i+1:]
  1265  		}
  1266  	}
  1267  	/*
  1268  		nSlash := strings.Count(str, "\\")
  1269  		nQuote := strings.Count(str, "\"")
  1270  		if nSlash == 0 {
  1271  			if nQuote == 0 {
  1272  				out = append(out, str...) // TODO 需要转义: \ --> \\
  1273  			} else {
  1274  				for {
  1275  					i := strings.IndexByte(str, '"')
  1276  					if i == -1 {
  1277  						out = append(out, str...)
  1278  						break
  1279  					}
  1280  					out = append(out, str[:i]...)
  1281  					out = append(out, '\\', '"')
  1282  					str = str[i+1:]
  1283  				}
  1284  			}
  1285  		} else if nQuote == 0 {
  1286  			for {
  1287  				i := strings.IndexByte(str, '\\')
  1288  				if i == -1 {
  1289  					out = append(out, str...)
  1290  					break
  1291  				}
  1292  				out = append(out, str[:i]...)
  1293  				out = append(out, '\\', '\\')
  1294  				str = str[i+1:]
  1295  			}
  1296  		} else {
  1297  			iSlash, iQuote := strings.IndexByte(str, '\\'), strings.IndexByte(str, '"')
  1298  			for iSlash == -1 && iQuote == -1 {
  1299  				if iSlash==
  1300  				if iSlash < iQuote {
  1301  
  1302  				}
  1303  
  1304  				i := strings.IndexByte(str, '\\')
  1305  				if i == -1 {
  1306  					out = append(out, str...)
  1307  					break
  1308  				}
  1309  				out = append(out, str[:i]...)
  1310  				out = append(out, '\\', '\\')
  1311  				str = str[i+1:]
  1312  			}
  1313  		}
  1314  	*/
  1315  	out = append(out, '"')
  1316  	return
  1317  }
  1318  
  1319  func stringMFuncs(pidx *uintptr) (fUnm unmFunc, fM mFunc) {
  1320  	if pidx == nil {
  1321  		fUnm = func(idxSlash int, store PoolStore, stream string) (i, iSlash int) {
  1322  			if stream[0] == 'n' && stream[1] == 'u' && stream[2] == 'l' && stream[3] == 'l' {
  1323  				i = 4
  1324  				iSlash = idxSlash
  1325  				return
  1326  			}
  1327  			store.obj = pointerOffset(store.obj, store.tag.Offset)
  1328  			pstr := (*string)(store.obj)
  1329  			{
  1330  				i = strings.IndexByte(stream[1:], '"')
  1331  				if idxSlash > i+1 {
  1332  					i++
  1333  					*pstr = stream[1:i]
  1334  					i++
  1335  					iSlash = idxSlash
  1336  				} else {
  1337  					i++
  1338  					*pstr, i, iSlash = parseUnescapeStr(stream, i, idxSlash)
  1339  				}
  1340  			}
  1341  			return
  1342  		}
  1343  		fM = stringM
  1344  		return
  1345  	}
  1346  	fUnm = func(idxSlash int, store PoolStore, stream string) (i, iSlash int) {
  1347  		store.obj = pointerOffset(store.obj, store.tag.Offset)
  1348  		store.obj = store.Idx(*pidx)
  1349  		if stream[0] == 'n' && stream[1] == 'u' && stream[2] == 'l' && stream[3] == 'l' {
  1350  			i = 4
  1351  			iSlash = idxSlash
  1352  			return
  1353  		}
  1354  		pstr := (*string)(store.obj)
  1355  		{
  1356  			i = strings.IndexByte(stream[1:], '"')
  1357  			if idxSlash > i+1 {
  1358  				i++
  1359  				*pstr = stream[1:i]
  1360  				i++
  1361  				iSlash = idxSlash
  1362  			} else {
  1363  				i++
  1364  				*pstr, i, iSlash = parseUnescapeStr(stream, i, idxSlash)
  1365  			}
  1366  		}
  1367  		return
  1368  	}
  1369  
  1370  	fM = func(store Store, in []byte) (out []byte) {
  1371  		store.obj = *(*unsafe.Pointer)(store.obj)
  1372  		if store.obj == nil {
  1373  			out = append(in, "null"...)
  1374  			return
  1375  		}
  1376  		return stringM(store, in)
  1377  	}
  1378  	return
  1379  }
  1380  
  1381  func interfaceMFuncs(pidx *uintptr) (fUnm unmFunc, fM mFunc) {
  1382  	if pidx == nil {
  1383  		fUnm = func(idxSlash int, store PoolStore, stream string) (i, iSlash int) {
  1384  			if stream[0] == 'n' && stream[1] == 'u' && stream[2] == 'l' && stream[3] == 'l' {
  1385  				i = 4
  1386  				iSlash = idxSlash
  1387  				return
  1388  			}
  1389  			iSlash = idxSlash
  1390  			n := trimSpace(stream[i:])
  1391  			i += n
  1392  			iv := (*interface{})(pointerOffset(store.obj, store.tag.Offset))
  1393  			n, iSlash = parseInterface(idxSlash-i, stream[i:], iv)
  1394  			idxSlash += i
  1395  			i += n
  1396  			// *iv = iface
  1397  			return
  1398  		}
  1399  		fM = func(store Store, in []byte) (out []byte) {
  1400  			iface := *(*interface{})(store.obj)
  1401  			out = marshalInterface(in, iface)
  1402  			return
  1403  		}
  1404  		return
  1405  	}
  1406  	fUnm = func(idxSlash int, store PoolStore, stream string) (i, iSlash int) {
  1407  		if stream[0] == 'n' && stream[1] == 'u' && stream[2] == 'l' && stream[3] == 'l' {
  1408  			i = 4
  1409  			iSlash = idxSlash
  1410  			return
  1411  		}
  1412  		iSlash = idxSlash
  1413  		n := trimSpace(stream[i:])
  1414  		i += n
  1415  		store.obj = pointerOffset(store.obj, store.tag.Offset)
  1416  		store.obj = store.Idx(*pidx)
  1417  		iv := (*interface{})(store.obj)
  1418  		n, iSlash = parseInterface(idxSlash-i, stream[i:], iv)
  1419  		idxSlash += i
  1420  		i += n
  1421  		// *iv = iface
  1422  		return
  1423  	}
  1424  	fM = func(store Store, in []byte) (out []byte) {
  1425  		store.obj = *(*unsafe.Pointer)(store.obj)
  1426  		if store.obj == nil {
  1427  			out = append(in, "null"...)
  1428  			return
  1429  		}
  1430  		iface := *(*interface{})(store.obj)
  1431  		out = marshalInterface(in, iface)
  1432  		return
  1433  	}
  1434  	return
  1435  }
  1436  
  1437  func mapMFuncs(pidx *uintptr) (fUnm unmFunc, fM mFunc) {
  1438  	if pidx == nil {
  1439  		fUnm = func(idxSlash int, store PoolStore, stream string) (i, iSlash int) {
  1440  			if stream[0] == 'n' && stream[1] == 'u' && stream[2] == 'l' && stream[3] == 'l' {
  1441  				i = 4
  1442  				iSlash = idxSlash
  1443  				return
  1444  			}
  1445  			store.obj = pointerOffset(store.obj, store.tag.Offset)
  1446  			m, i, iSlash := parseMapInterface(idxSlash-1, stream[1:])
  1447  			iSlash++
  1448  			i++
  1449  			p := (*map[string]interface{})(store.obj)
  1450  			*p = m
  1451  			return
  1452  		}
  1453  		fM = func(store Store, in []byte) (out []byte) {
  1454  			// store.obj = pointerOffset(store.obj, store.tag.Offset)
  1455  			m := *(*map[string]interface{})(store.obj)
  1456  			out = marshalMapInterface(in, m)
  1457  			return
  1458  		}
  1459  		return
  1460  	}
  1461  	fUnm = func(idxSlash int, store PoolStore, stream string) (i, iSlash int) {
  1462  		if stream[0] == 'n' && stream[1] == 'u' && stream[2] == 'l' && stream[3] == 'l' {
  1463  			i = 4
  1464  			iSlash = idxSlash
  1465  			return
  1466  		}
  1467  		store.obj = pointerOffset(store.obj, store.tag.Offset)
  1468  		store.obj = store.Idx(*pidx)
  1469  		m, i, iSlash := parseMapInterface(idxSlash-1, stream[1:])
  1470  		iSlash++
  1471  		i++
  1472  		p := (*map[string]interface{})(store.obj)
  1473  		*p = m
  1474  		return
  1475  	}
  1476  	fM = func(store Store, in []byte) (out []byte) {
  1477  		// store.obj = pointerOffset(store.obj, store.tag.Offset)
  1478  		store.obj = *(*unsafe.Pointer)(store.obj)
  1479  		if store.obj == nil {
  1480  			out = append(in, "null"...)
  1481  			return
  1482  		}
  1483  		m := *(*map[string]interface{})(store.obj)
  1484  		out = marshalMapInterface(in, m)
  1485  		return
  1486  	}
  1487  	return
  1488  }