Beispiel #1
0
// CreateCompileUnit creates lexical block debug metadata.
func (d *DIBuilder) CreateLexicalBlock(diScope Value, b DILexicalBlock) Value {
	result := C.LLVMDIBuilderCreateLexicalBlock(
		d.ref,
		diScope.C,
		b.File.C,
		C.unsigned(b.Line),
		C.unsigned(b.Column),
	)
	return Value{C: result}
}
Beispiel #2
0
// CreateCompileUnit creates lexical block debug metadata.
func (d *DIBuilder) CreateLexicalBlock(diScope Metadata, b DILexicalBlock) Metadata {
	result := C.LLVMDIBuilderCreateLexicalBlock(
		d.ref,
		diScope.C,
		b.File.C,
		C.unsigned(b.Line),
		C.unsigned(b.Column),
	)
	return Metadata{C: result}
}
Beispiel #3
0
func NewSignalInfo(rate float64, channels, precision uint, length uint64, mult *float64) *SignalInfo {
	var s SignalInfo
	s.cSignal = &C.sox_signalinfo_t{}
	s.cSignal.rate = C.sox_rate_t(rate)
	s.cSignal.channels = C.unsigned(channels)
	s.cSignal.precision = C.unsigned(precision)
	s.cSignal.length = C.sox_uint64_t(length)
	if mult != nil {
		var d C.double
		d = C.double(*mult)
		s.cSignal.mult = &d
	}
	return &s
}
Beispiel #4
0
func InitRepository(path string, bare bool) (*Repository, error) {
	repo := new(Repository)
	cpath := C.CString(path)
	defer C.free(unsafe.Pointer(cpath))
	cbare := C.unsigned(c_FALSE)
	if bare {
		cbare = C.unsigned(c_TRUE)
	}
	ecode := C.git_repository_init(&repo.git_repository, cpath, cbare)
	if ecode != git_SUCCESS {
		return nil, gitError()
	}
	return repo, nil
}
Beispiel #5
0
// CreateAutoVariable creates local variable debug metadata.
func (d *DIBuilder) CreateAutoVariable(scope Metadata, v DIAutoVariable) Metadata {
	name := C.CString(v.Name)
	defer C.free(unsafe.Pointer(name))
	result := C.LLVMDIBuilderCreateAutoVariable(
		d.ref,
		scope.C,
		name,
		v.File.C,
		C.unsigned(v.Line),
		v.Type.C,
		boolToCInt(v.AlwaysPreserve),
		C.unsigned(v.Flags),
	)
	return Metadata{C: result}
}
Beispiel #6
0
func (ctx *Context) NewFunction(name string, parameters []string, body string, source_url string, starting_line_number int) (*Object, error) {
	Cname := NewString(name)
	defer Cname.Release()

	Cparameters := make([]C.JSStringRef, len(parameters))
	defer release_jsstringref_array(Cparameters)
	for i := 0; i < len(parameters); i++ {
		Cparameters[i] = (C.JSStringRef)(unsafe.Pointer(NewString(parameters[i])))
	}

	Cbody := NewString(body)
	defer Cbody.Release()

	var sourceRef *String
	if source_url != "" {
		sourceRef = NewString(source_url)
		defer sourceRef.Release()
	}

	errVal := ctx.newErrorValue()
	ret := C.JSObjectMakeFunction(ctx.ref,
		(C.JSStringRef)(unsafe.Pointer(Cname)),
		C.unsigned(len(Cparameters)), &Cparameters[0],
		(C.JSStringRef)(unsafe.Pointer(Cbody)),
		(C.JSStringRef)(unsafe.Pointer(sourceRef)),
		C.int(starting_line_number), &errVal.ref)
	if errVal.ref != nil {
		return nil, errVal
	}
	return ctx.newObject(ret), nil
}
Beispiel #7
0
func New(c *Config) *Disassembler {
	if c.Buf != nil && c.Reader != nil {
		panic("New: must pass either bytes or a Reader")
	}
	d := &Disassembler{
		bytes: c.Buf,
		r:     c.Reader,
	}
	C.ud_init(&d.u)
	C.ud_set_user_opaque_data(&d.u, unsafe.Pointer(d))
	if d.bytes != nil {
		C.ud_set_input_buffer(&d.u, (*C.uint8_t)(unsafe.Pointer(&d.bytes[0])), C.size_t(len(d.bytes)))
	} else {
		C.ud_set_input_hook(&d.u, (*[0]byte)(C.ud_input_hook))
	}
	if c.Bits != 0 {
		C.ud_set_mode(&d.u, C.uint8_t(c.Bits))
	}
	if c.PC != 0 {
		C.ud_set_pc(&d.u, C.uint64_t(c.PC))
	}
	// We rely on the fact that the zero value is also the default
	// to udis86, and don't check if it is set.
	C.ud_set_vendor(&d.u, C.unsigned(c.Vendor))
	switch c.Syntax {
	case SyntaxIntel:
		C.ud_set_syntax(&d.u, (*[0]byte)(C.UD_SYN_INTEL))
	case SyntaxATT:
		C.ud_set_syntax(&d.u, (*[0]byte)(C.UD_SYN_ATT))
	}
	return d
}
Beispiel #8
0
func RemoveOverlaps(rects Rectangles) {
	if rects.Len() == 0 {
		return
	}

	rcv := make([]C.struct_rect, rects.Len())
	for i := 0; i < rects.Len(); i++ {
		rc := &rcv[i]
		x0, y0, x1, y1 := rects.Position(i)
		rc.x0 = C.double(x0)
		rc.x1 = C.double(x1)
		rc.y0 = C.double(y0)
		rc.y1 = C.double(y1)
		rc.fixed = boolchar(rects.Fixed(i))
		rc.allow_overlap = boolchar(rects.AllowOverlap(i))
	}

	removeOverlapsMtx.Lock()
	C.remove_overlaps(&rcv[0], C.unsigned(len(rcv)))
	removeOverlapsMtx.Unlock()

	for i := 0; i < rects.Len(); i++ {
		rc := &rcv[i]
		x0 := float64(rc.x0)
		x1 := float64(rc.x1)
		y0 := float64(rc.y0)
		y1 := float64(rc.y1)
		rects.SetPosition(i, x0, y0, x1, y1)
	}
}
Beispiel #9
0
// CreateLocalVariable creates local variable debug metadata.
func (d *DIBuilder) CreateLocalVariable(scope Value, v DILocalVariable) Value {
	name := C.CString(v.Name)
	defer C.free(unsafe.Pointer(name))
	result := C.LLVMDIBuilderCreateLocalVariable(
		d.ref,
		C.unsigned(v.Tag),
		scope.C,
		name,
		v.File.C,
		C.unsigned(v.Line),
		v.Type.C,
		boolToCInt(v.AlwaysPreserve),
		C.unsigned(v.Flags),
		C.unsigned(v.ArgNo),
	)
	return Value{C: result}
}
Beispiel #10
0
// CreateReplaceableCompositeType creates replaceable composite type debug metadata.
func (d *DIBuilder) CreateReplaceableCompositeType(scope Metadata, t DIReplaceableCompositeType) Metadata {
	name := C.CString(t.Name)
	defer C.free(unsafe.Pointer(name))
	result := C.LLVMDIBuilderCreateReplaceableCompositeType(
		d.ref,
		C.unsigned(t.Tag),
		name,
		scope.C,
		t.File.C,
		C.unsigned(t.Line),
		C.unsigned(t.RuntimeLang),
		C.uint64_t(t.SizeInBits),
		C.uint32_t(t.AlignInBits),
		C.unsigned(t.Flags),
	)
	return Metadata{C: result}
}
Beispiel #11
0
// CreateMemberType creates struct type debug metadata.
func (d *DIBuilder) CreateMemberType(scope Metadata, t DIMemberType) Metadata {
	name := C.CString(t.Name)
	defer C.free(unsafe.Pointer(name))
	result := C.LLVMDIBuilderCreateMemberType(
		d.ref,
		scope.C,
		name,
		t.File.C,
		C.unsigned(t.Line),
		C.uint64_t(t.SizeInBits),
		C.uint32_t(t.AlignInBits),
		C.uint64_t(t.OffsetInBits),
		C.unsigned(t.Flags),
		t.Type.C,
	)
	return Metadata{C: result}
}
Beispiel #12
0
// CreateMemberType creates struct type debug metadata.
func (d *DIBuilder) CreateMemberType(scope Value, t DIMemberType) Value {
	name := C.CString(t.Name)
	result := C.DIBuilderCreateMemberType(
		d.ref,
		scope.C,
		name,
		t.File.C,
		C.unsigned(t.Line),
		C.uint64_t(t.SizeInBits),
		C.uint64_t(t.AlignInBits),
		C.uint64_t(t.OffsetInBits),
		C.unsigned(t.Flags),
		t.Type.C,
	)
	C.free(unsafe.Pointer(name))
	return Value{C: result}
}
Beispiel #13
0
// CreateStructType creates struct type debug metadata.
func (d *DIBuilder) CreateStructType(scope Metadata, t DIStructType) Metadata {
	elements := d.getOrCreateArray(t.Elements)
	name := C.CString(t.Name)
	defer C.free(unsafe.Pointer(name))
	result := C.LLVMDIBuilderCreateStructType(
		d.ref,
		scope.C,
		name,
		t.File.C,
		C.unsigned(t.Line),
		C.uint64_t(t.SizeInBits),
		C.uint32_t(t.AlignInBits),
		C.unsigned(t.Flags),
		t.DerivedFrom.C,
		elements.C,
	)
	return Metadata{C: result}
}
Beispiel #14
0
func CheckStateNotify(param1 uint32) error {
	code, err := C.T32_CheckStateNotify(C.unsigned(param1))
	if err != nil {
		return err
	} else if code != 0 {
		return errors.New("T32_CheckStateNotify Error")
	}
	return nil
}
Beispiel #15
0
// ChannelMap.InitAuto initializes the ChannelMap using the given mapping
// and number of channels.
//
// If there is no default channel map known for the given number of channels
// and mapping, then the ChannelMap remains unchanged and an error is returned.
func (m *ChannelMap) InitAuto(channels uint, mapping ChannelMapDef) error {
	cmap := &C.pa_channel_map{}
	mapped := C.pa_channel_map_init_auto(cmap, C.unsigned(channels), C.pa_channel_map_def_t(mapping))
	if mapped == nil {
		return fmt.Errorf("Could not map %d channels with ChannelMapDef %v", channels, mapping)
	}
	m.fromC(cmap)
	return nil
}
Beispiel #16
0
func (e *GT) ScalarMult(base *GT, k *big.Int) *GT {
	words, bitLen := powerToWords(k)
	if bitLen == 0 {
		C.gt_set(&e.p, &base.p)
	} else {
		C.gt_scalar_mult(&e.p, &base.p, (*C.ulonglong)(unsafe.Pointer(&words[0])), C.unsigned(bitLen))
	}
	return e
}
Beispiel #17
0
func (ee ExecutionEngine) RunFunction(f Value, args []GenericValue) (g GenericValue) {
	nargs := len(args)
	var argptr *GenericValue
	if nargs > 0 {
		argptr = &args[0]
	}
	g.C = C.LLVMRunFunction(ee.C, f.C,
		C.unsigned(nargs), llvmGenericValueRefPtr(argptr))
	return
}
Beispiel #18
0
func (obj *Object) SetPropertyAtIndex(index uint16, rhs *Value) error {
	errVal := obj.ctx.newErrorValue()

	C.JSObjectSetPropertyAtIndex(obj.ctx.ref, obj.ref, C.unsigned(index), rhs.ref, &errVal.ref)
	if errVal.ref != nil {
		return errVal
	}

	return nil
}
Beispiel #19
0
func (obj *Object) GetPropertyAtIndex(index uint16) (*Value, error) {
	errVal := obj.ctx.newErrorValue()

	ret := C.JSObjectGetPropertyAtIndex(obj.ctx.ref, obj.ref, C.unsigned(index), &errVal.ref)
	if errVal.ref != nil {
		return nil, errVal
	}

	return obj.ctx.newValue(ret), nil
}
Beispiel #20
0
func ChannelLayouts() []ChannelLayout {
	var cls []ChannelLayout
	for index := C.unsigned(0); ; index++ {
		var cCL C.uint64_t
		if C.av_get_standard_channel_layout(index, &cCL, nil) != 0 {
			break
		}
		cls = append(cls, ChannelLayout(cCL))
	}
	return cls
}
Beispiel #21
0
// CreateBasicType creates basic type debug metadata.
func (d *DIBuilder) CreateBasicType(t DIBasicType) Metadata {
	name := C.CString(t.Name)
	defer C.free(unsafe.Pointer(name))
	result := C.LLVMDIBuilderCreateBasicType(
		d.ref,
		name,
		C.uint64_t(t.SizeInBits),
		C.unsigned(t.Encoding),
	)
	return Metadata{C: result}
}
Beispiel #22
0
// CreateCompileUnit creates compile unit debug metadata.
func (d *DIBuilder) CreateCompileUnit(cu DICompileUnit) Metadata {
	file := C.CString(cu.File)
	defer C.free(unsafe.Pointer(file))
	dir := C.CString(cu.Dir)
	defer C.free(unsafe.Pointer(dir))
	producer := C.CString(cu.Producer)
	defer C.free(unsafe.Pointer(producer))
	flags := C.CString(cu.Flags)
	defer C.free(unsafe.Pointer(flags))
	result := C.LLVMDIBuilderCreateCompileUnit(
		d.ref,
		C.unsigned(cu.Language),
		file, dir,
		producer,
		boolToCInt(cu.Optimized),
		flags,
		C.unsigned(cu.RuntimeVersion),
	)
	return Metadata{C: result}
}
Beispiel #23
0
func NewJITCompiler(m Module, optLevel int) (ee ExecutionEngine, err error) {
	var cmsg *C.char
	fail := C.LLVMCreateJITCompilerForModule(&ee.C, m.C, C.unsigned(optLevel), &cmsg)
	if fail == 0 {
		err = nil
	} else {
		ee.C = nil
		err = errors.New(C.GoString(cmsg))
		C.LLVMDisposeMessage(cmsg)
	}
	return
}
Beispiel #24
0
// CreateBasicType creates basic type debug metadata.
func (d *DIBuilder) CreateBasicType(t DIBasicType) Value {
	name := C.CString(t.Name)
	result := C.DIBuilderCreateBasicType(
		d.ref,
		name,
		C.uint64_t(t.SizeInBits),
		C.uint64_t(t.AlignInBits),
		C.unsigned(t.Encoding),
	)
	C.free(unsafe.Pointer(name))
	return Value{C: result}
}
Beispiel #25
0
// Name returns the name of the pool.
func (pool *Pool) Name() string {
	bufLen := 64
	for {
		bufAddr := bufferAddress(bufLen)
		ret := C.rados_ioctx_get_pool_name(pool.context, bufAddr, C.unsigned(bufLen))
		if int(ret) == -int(syscall.ERANGE) {
			bufLen *= 2
			continue
		}
		return C.GoStringN(bufAddr, ret)
	}
}
Beispiel #26
0
// CreateCompileUnit creates function debug metadata.
func (d *DIBuilder) CreateFunction(diScope Metadata, f DIFunction) Metadata {
	name := C.CString(f.Name)
	defer C.free(unsafe.Pointer(name))
	linkageName := C.CString(f.LinkageName)
	defer C.free(unsafe.Pointer(linkageName))
	result := C.LLVMDIBuilderCreateFunction(
		d.ref,
		diScope.C,
		name,
		linkageName,
		f.File.C,
		C.unsigned(f.Line),
		f.Type.C,
		boolToCInt(f.LocalToUnit),
		boolToCInt(f.IsDefinition),
		C.unsigned(f.ScopeLine),
		C.unsigned(f.Flags),
		boolToCInt(f.Optimized),
	)
	return Metadata{C: result}
}
Beispiel #27
0
// CreateTypedef creates typedef type debug metadata.
func (d *DIBuilder) CreateTypedef(t DITypedef) Metadata {
	name := C.CString(t.Name)
	defer C.free(unsafe.Pointer(name))
	result := C.LLVMDIBuilderCreateTypedef(
		d.ref,
		t.Type.C,
		name,
		t.File.C,
		C.unsigned(t.Line),
		t.Context.C,
	)
	return Metadata{C: result}
}
Beispiel #28
0
// CreateCompileUnit creates function debug metadata.
func (d *DIBuilder) CreateFunction(diScope Value, f DIFunction) Value {
	name := C.CString(f.Name)
	linkageName := C.CString(f.LinkageName)
	result := C.DIBuilderCreateFunction(
		d.ref,
		diScope.C,
		name,
		linkageName,
		f.File.C,
		C.unsigned(f.Line),
		f.Type.C,
		boolToCInt(f.LocalToUnit),
		boolToCInt(f.IsDefinition),
		C.unsigned(f.ScopeLine),
		C.unsigned(f.Flags),
		boolToCInt(f.Optimized),
		f.Function.C,
	)
	C.free(unsafe.Pointer(name))
	C.free(unsafe.Pointer(linkageName))
	return Value{C: result}
}
Beispiel #29
0
func (cl ChannelLayout) NameOk() (string, bool) {
	for index := C.unsigned(0); ; index++ {
		var cCL C.uint64_t
		var cName *C.char
		if C.av_get_standard_channel_layout(index, &cCL, &cName) != 0 {
			break
		}
		if ChannelLayout(cCL) == cl {
			return cStringToStringOk(cName)
		}
	}
	return "", false
}
Beispiel #30
0
// CreateTypedef creates typedef type debug metadata.
func (d *DIBuilder) CreateTypedef(t DITypedef) Value {
	name := C.CString(t.Name)
	result := C.DIBuilderCreateTypedef(
		d.ref,
		t.Type.C,
		name,
		t.File.C,
		C.unsigned(t.Line),
		t.Context.C,
	)
	C.free(unsafe.Pointer(name))
	return Value{C: result}
}