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


Golang BinaryReader.Uint16方法代码示例

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


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

示例1: String

func (a *attribute_info) String(c *ConstantPool) (ret string) {
	ret = c.Lut(a.Attribute_name_index).String()
	switch n := c.Lut(a.Attribute_name_index).String(); n {
	case "Signature", "SourceFile":
		ret += "="
		br := binary.BinaryReader{bytes.NewReader(a.Info), binary.BigEndian}
		if i16, err := br.Uint16(); err != nil {
			ret += err.Error()
		} else {
			ret += c.Lut(u2(i16)).String()
		}
	case "Code":
		ret += " ("
		var cl Code_attribute
		br := binary.BinaryReader{bytes.NewReader(a.Info), binary.BigEndian}
		if err := br.ReadInterface(&cl); err != nil {
			ret += err.Error()
		} else {
			for _, a2 := range cl.Attributes {
				ret += fmt.Sprintf(" %s", c.Lut(a2.Attribute_name_index))
			}
		}
		ret += " )"
	}
	return ret
}
开发者ID:NeoTse,项目名称:completion,代码行数:26,代码来源:class.go

示例2: testparse

func testparse(c *Class, members []member_info, method bool, t *testing.T) {
	for i := range members {
		var p descriptors.DESCRIPTORS
		desc := c.Constant_pool.Lut(members[i].Descriptor_index).String()
		if !p.Parse(desc) || p.RootNode().Range.End() != len(desc) {
			t.Errorf("Failed to parse descriptor: %s\n%s\n%s", p.Error(), desc, p.RootNode())
		}
		var p2 signatures.SIGNATURES
		for _, attr := range members[i].Attributes {
			if c.Constant_pool.Lut(attr.Attribute_name_index).String() == "Signature" {
				br := binary.BinaryReader{bytes.NewReader(attr.Info), binary.BigEndian}
				if i16, err := br.Uint16(); err != nil {
					t.Error(err)
				} else {
					sign := c.Constant_pool.Lut(u2(i16)).String()
					p2.SetData(sign)
					var ret bool
					if method {
						ret = p2.MethodTypeSignature()
					} else {
						ret = p2.FieldTypeSignature()
					}
					p2.RootNode().UpdateRange()
					if !ret || p2.RootNode().Range.End() != len(sign) {
						t.Errorf("Failed to parse signature: %s\n%s\n%s", p2.Error(), desc, p2.RootNode())
					}
				}
			}
		}
	}
}
开发者ID:NeoTse,项目名称:completion,代码行数:31,代码来源:class_all_test.go

示例3: ReadIndex

func (m *MetadataUtil) ReadIndex(br *binary.BinaryReader, size uint) (uint32, error) {
	if size != 2 {
		return br.Uint32()
	} else if v, e := br.Uint16(); e != nil {
		return 0, e
	} else {
		return uint32(v), nil
	}
}
开发者ID:NeoTse,项目名称:completion,代码行数:9,代码来源:metadata.go

示例4: Read

func (ih *Header) Read(br *binary.BinaryReader) error {
	if v, err := br.Uint32(); err != nil {
		return err
	} else if v != 0xffffffff {
		ih.Length = uint64(v)
	} else if v, err := br.Uint64(); err != nil {
		return err
	} else {
		ih.is64 = true
		ih.Length = v
	}
	var err error
	ih.Version, err = br.Uint16()
	return err
}
开发者ID:NeoTse,项目名称:completion,代码行数:15,代码来源:info.go

示例5: String

func (a *attribute_info) String(c *ConstantPool) (ret string) {
	ret = c.Lut(a.Attribute_name_index).String()
	switch n := c.Lut(a.Attribute_name_index).String(); n {
	case "Signature", "SourceFile":
		ret += "="
		br := binary.BinaryReader{Reader: bytes.NewReader(a.Info), Endianess: binary.BigEndian}
		if i16, err := br.Uint16(); err != nil {
			ret += err.Error()
		} else {
			ret += c.Lut(u2(i16)).String()
		}
	case "Code":
		ret += " ( "
		var cl Code_attribute
		br := binary.BinaryReader{Reader: bytes.NewReader(a.Info), Endianess: binary.BigEndian}
		if err := br.ReadInterface(&cl); err != nil {
			ret += err.Error()
		} else {
			ret += strings.Join(sortStrings(cl.Attributes, c), " ")
		}
		ret += " )"
	}
	return ret
}
开发者ID:noname007,项目名称:completion,代码行数:24,代码来源:class.go

示例6: data

func (ie *InfoEntry) data(form DW_FORM, br binary.BinaryReader) interface{} {
	if form == DW_FORM_ref_addr && ie.header.Version < 3 {
		form = DW_FORM_addr
	}
	switch form {
	case DW_FORM_flag_present:
		return true
	case DW_FORM_exprloc, DW_FORM_block:
		var size LEB128
		br.ReadInterface(&size)
		r, _ := br.Read(int(size))
		return r
	case DW_FORM_block1:
		size, _ := br.Uint8()
		r, _ := br.Read(int(size))
		return r
	case DW_FORM_block2:
		size, _ := br.Uint16()
		r, _ := br.Read(int(size))
		return r
	case DW_FORM_block4:
		size, _ := br.Uint32()
		r, _ := br.Read(int(size))
		return r
	case DW_FORM_addr:
		if ie.header.AddressSize == 8 {
			v, _ := br.Uint64()
			return v
		} else {
			v, _ := br.Uint32()
			return uint64(v)
		}
	case DW_FORM_ref_addr, DW_FORM_strp, DW_FORM_sec_offset:
		if ie.header.is64 {
			v, _ := br.Uint64()
			return v
		} else {
			v, _ := br.Uint32()
			return uint64(v)
		}
	case DW_FORM_ref1, DW_FORM_flag, DW_FORM_data1:
		v, _ := br.Uint8()
		return uint64(v)
	case DW_FORM_ref2, DW_FORM_data2:
		v, _ := br.Uint16()
		return uint64(v)
	case DW_FORM_ref4, DW_FORM_data4:
		v, _ := br.Uint32()
		return uint64(v)
	case DW_FORM_ref8, DW_FORM_data8:
		v, _ := br.Uint64()
		return v
	case DW_FORM_sdata, DW_FORM_udata:
		var r LEB128
		br.ReadInterface(&r)
		return uint64(r)
	case DW_FORM_string:
		buf := make([]byte, 4096)

		for i := range buf {
			if v, err := br.Uint8(); err != nil {
				return err
			} else if v == 0 {
				buf = buf[:i]
				break
			} else {
				buf[i] = byte(v)
			}
		}
		return string(buf)
	}
	panic(fmt.Errorf("Unimplemented format: %s", form))
}
开发者ID:NeoTse,项目名称:completion,代码行数:73,代码来源:info.go

示例7: parseModelEntryVSET

func parseModelEntryVSET(entry *ModelEntry) error {
	reader := binary.BinaryReader{Reader: entry.Data, Endianess: binary.LittleEndian}

	var err error

	unk, err := reader.Uint16()
	count, err := reader.Uint16()

	fmt.Printf("Count: %04x\n", count)
	fmt.Printf("Unk: %04x\n", unk)

	for i := uint16(0); i < count && err == nil; i++ {
		var identifier uint16
		identifier, err = reader.Uint16()
		var data []uint8

		if err != nil {
			break
		}

		if identifier&0x8000 != 0 { // Size is fucked up
			var sz, unk uint8
			unk, err = reader.Uint8()

			var size uint16
			if unk == 0x10 {
				size, err = reader.Uint16()
			} else if unk == 0x08 {
				sz, err = reader.Uint8()
				size = uint16(sz)
			} else {
				return errors.New("Unknown size flag")
			}

			fmt.Printf("Oh %02x, %04x\n", unk, size)
			x := 2
			data = make([]uint8, x*int(size+1))
		} else if identifier&0x0900 != 0 { // and 0x0900
			data = make([]uint8, 4)
		} else if identifier&0x0600 == 0x0600 { // and 0x0600
			data = make([]uint8, 2)
		} else if identifier&0xff00 != 0 {
			fmt.Printf("what the fuck is %04x\n", identifier&0xff00)
			//break
		}

		_, err = util.ReadN(entry.Data, data)

		fmt.Printf("\t\t%04x (%08x): %x\n", identifier, len(data), data)
	}

	if _, err = entry.Data.Read(make([]uint8, 1)); err != io.EOF {
		return errors.New("Expected EOF")
	}

	if err == io.EOF {
		return nil
	}

	return err
}
开发者ID:keyphact,项目名称:pso2-go,代码行数:61,代码来源:model.go


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