当前位置: 首页>>代码示例>>Golang>>正文


Golang Packer.UnpackInt方法代码示例

本文整理汇总了Golang中github.com/paulfchristiano/dwimmer/term/intern.Packer.UnpackInt方法的典型用法代码示例。如果您正苦于以下问题:Golang Packer.UnpackInt方法的具体用法?Golang Packer.UnpackInt怎么用?Golang Packer.UnpackInt使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在github.com/paulfchristiano/dwimmer/term/intern.Packer的用法示例。


在下文中一共展示了Packer.UnpackInt方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。

示例1: unpickleC

func unpickleC(packer intern.Packer, kind int, packed intern.Packed) (C, bool) {
	switch kind {
	case compoundC:
		result := &CompoundC{}
		if packed, args, ok := packer.UnpackPair(packed); ok {
			if args, ok := packer.UnpackList(args); ok {
				result.args = make([]C, len(args))
				for i, arg := range args {
					unpacked, ok := packer.UnpackPickler(arg, &CompoundC{})
					if !ok {
						return nil, false
					}
					result.args[i] = unpacked.(C)
				}
				id, ok := unpickleTemplateID(packer, packed)
				if !ok {
					return nil, false
				}
				result.TemplateID = id
				return result, true
			}
		}
	case referenceC:
		n, ok := packer.UnpackInt(packed)
		return ReferenceC{n}, ok
	case constantC:
		unpacked, ok := packer.UnpackPickler(packed, &CompoundT{})
		if !ok {
			return nil, false
		}
		return ConstC{unpacked.(T)}, ok
	}
	return nil, false
}
开发者ID:paulfchristiano,项目名称:dwimmer,代码行数:34,代码来源:pickle.go

示例2: Unpickle

func (s *SettingT) Unpickle(packer intern.Packer, pickled intern.Packed) (intern.Pickler, bool) {
	if v, val, ok := packer.UnpackPair(pickled); ok {
		if v, ok := packer.UnpackInt(v); ok && v == v1SettingT {
			if setting, packedArgs, ok := packer.UnpackPair(val); ok {
				result := &SettingT{}
				unpacked, ok := packer.UnpackPickler(setting, &Setting{})
				if !ok {
					return nil, false
				}
				result.Setting = unpacked.(*Setting)
				args, ok := packer.UnpackList(packedArgs)
				if !ok {
					return nil, false
				}
				result.Args = make([]T, len(args))
				for i, arg := range args {
					unpacked, ok := packer.UnpackPickler(arg, &CompoundT{})
					if !ok {
						return nil, false
					}
					result.Args[i] = unpacked.(T)
				}
				return result, true
			}
		}
	}
	return nil, false
}
开发者ID:paulfchristiano,项目名称:dwimmer,代码行数:28,代码来源:pickle.go

示例3: unpickleT

func unpickleT(packer intern.Packer, kind int, packed intern.Packed) (T, bool) {
	switch kind {
	case chanT:
		unpickled, ok := packer.UnpackPickler(packed, &SettingT{})
		if !ok {
			return nil, false
		}
		setting, ok := unpickled.(*SettingT)
		return MakeChannel(setting), ok
	case intT:
		result, ok := packer.UnpackInt(packed)
		if !ok {
			//panic(fmt.Errorf("failed to unpickle int from %v", packed))
		}
		return Int(result), ok
	case strT:
		result, ok := packer.UnpackString(packed)
		return Str(result), ok
	case quotedT:
		unpickled, ok := packer.UnpackPickler(packed, &CompoundT{})
		if !ok {
			return nil, false
		}
		return Quote(unpickled.(T)), true
	case wrapperT:
		return Make("a term that stands in for a wrapped go object that could not be pickled").T(), true
	case compoundT:
		result := &CompoundT{}
		if packed, args, ok := packer.UnpackPair(packed); ok {
			if args, ok := packer.UnpackList(args); ok {
				result.args = make([]T, len(args))
				for i, arg := range args {
					unpacked, ok := packer.UnpackPickler(arg, &CompoundT{})
					if !ok {
						return nil, false
					}
					result.args[i] = unpacked.(T)
				}
				id, ok := unpickleTemplateID(packer, packed)
				if !ok {
					return nil, false
				}
				result.TemplateID = id
				return result, true
			}
		}
	}
	return nil, false
}
开发者ID:paulfchristiano,项目名称:dwimmer,代码行数:49,代码来源:pickle.go


注:本文中的github.com/paulfchristiano/dwimmer/term/intern.Packer.UnpackInt方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。