Skip to content

Commit

Permalink
Merge pull request #5 from go-gst/prepare_release
Browse files Browse the repository at this point in the history
prepare v1.0.0 release
  • Loading branch information
RSWilli committed Mar 28, 2024
2 parents 6d6aaf0 + f8b0724 commit 60ae101
Show file tree
Hide file tree
Showing 16 changed files with 105 additions and 43 deletions.
40 changes: 40 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
name: Build

on:
push:
branches:
- main
pull_request:
branches:
- main

jobs:
matrix:
strategy:
matrix:
os:
- ubuntu-latest
# - windows-latest # see https://github.com/go-gst/go-gst/issues/64
- macos-latest
runs-on: ${{ matrix.os }}
steps:
# - name: Downgrade mingw to 11.2.0
# if: runner.os == 'Windows'
# run: choco install mingw --version 11.2.0 --allow-downgrade
- name: Setup GStreamer
id: setup_gstreamer
uses: blinemedical/setup-gstreamer@v1.4.0
- name: checkout
uses: actions/checkout@v3
- uses: actions/setup-go@v5
with:
go-version: "stable"
- name: build
shell: bash
run: |
packages=$(go list ./...)
for package in $packages; do
echo "Building: $package"
go build $package || exit 1
echo "Build done: $package"
done
34 changes: 34 additions & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
name: Tests

on:
pull_request:
branches:
- main

jobs:
setup:
name: Tests on codebase
runs-on: ubuntu-latest
steps:
- name: Setup GStreamer
id: setup_gstreamer
uses: blinemedical/setup-gstreamer@v1.4.0
- name: Check out code into the Go module directory
uses: actions/checkout@v2
- uses: actions/setup-go@v4
with:
go-version: "stable"
- name: Check formatting
uses: Jerome1337/gofmt-action@v1.0.5
with:
gofmt-flags: "-l -d"
- name: Check spellings
uses: reviewdog/action-misspell@v1
with:
locale: "US"
fail_on_error: true
filter_mode: nofilter
ignore: "cancellable,cancelled" # needs to be ignored because glib has a function called cancellable
- uses: dominikh/staticcheck-action@v1.3.0
with:
install-go: false
2 changes: 0 additions & 2 deletions .golangci.yml

This file was deleted.

16 changes: 0 additions & 16 deletions Makefile

This file was deleted.

6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,8 @@
# go-glib

Glib bindings for go. Originally forked from gotk3/gotk3.

These are intended to be used together with https://github.com/go-gst/go-gst

[![godoc reference](https://img.shields.io/badge/godoc-reference-blue.svg)](https://godoc.org/github.com/go-gst/go-glib)
[![GoReportCard](https://goreportcard.com/badge/github.com/go-gst/go-glib)](https://goreportcard.com/report/github.com/go-gst/go-glib)
2 changes: 1 addition & 1 deletion glib/gcancellable.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ func wrapCancellable(obj *Object) *Cancellable {
func CancellableNew() (*Cancellable, error) {
c := C.g_cancellable_new()
if c == nil {
return nil, nilPtrErr
return nil, errNilPtr
}
return wrapCancellable(wrapObject(unsafe.Pointer(c))), nil
}
Expand Down
2 changes: 1 addition & 1 deletion glib/gfile.go
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ func FileNewForPath(path string) (*File, error) {

c := C.g_file_new_for_path(cstr)
if c == nil {
return nil, nilPtrErr
return nil, errNilPtr
}
return wrapFile(Take(unsafe.Pointer(c))), nil
}
Expand Down
2 changes: 1 addition & 1 deletion glib/gicon.go
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ func FileIconNewN(file *File) (*Icon, error) {

c := C.g_file_icon_new(file.native())
if c == nil {
return nil, nilPtrErr
return nil, errNilPtr
}
return wrapIcon(Take(unsafe.Pointer(c))), nil
}
Expand Down
15 changes: 6 additions & 9 deletions glib/glib.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,7 @@ func gbool(b bool) C.gboolean {
return C.gboolean(0)
}
func gobool(b C.gboolean) bool {
if b != 0 {
return true
}
return false
return b != 0
}

/*
Expand All @@ -61,7 +58,7 @@ type closureContext struct {
}

var (
nilPtrErr = errors.New("cgo returned unexpected nil pointer")
errNilPtr = errors.New("cgo returned unexpected nil pointer")

closures = struct {
sync.RWMutex
Expand Down Expand Up @@ -307,7 +304,7 @@ func IdleAdd(f interface{}, args ...interface{}) (SourceHandle, error) {
// Create an idle source func to be added to the main loop context.
idleSrc := C.g_idle_source_new()
if idleSrc == nil {
return 0, nilPtrErr
return 0, errNilPtr
}
return sourceAttach(idleSrc, rf, args...)
}
Expand All @@ -329,7 +326,7 @@ func TimeoutAdd(timeout uint, f interface{}, args ...interface{}) (SourceHandle,
// Create a timeout source func to be added to the main loop context.
timeoutSrc := C.g_timeout_source_new(C.guint(timeout))
if timeoutSrc == nil {
return 0, nilPtrErr
return 0, errNilPtr
}

return sourceAttach(timeoutSrc, rf, args...)
Expand All @@ -338,7 +335,7 @@ func TimeoutAdd(timeout uint, f interface{}, args ...interface{}) (SourceHandle,
// sourceAttach attaches a source to the default main loop context.
func sourceAttach(src *C.struct__GSource, rf reflect.Value, args ...interface{}) (SourceHandle, error) {
if src == nil {
return 0, nilPtrErr
return 0, errNilPtr
}

// rf must be a func with no parameters.
Expand Down Expand Up @@ -434,7 +431,7 @@ func GetUserRuntimeDir() string {
func GetUserSpecialDir(directory UserDirectory) (string, error) {
c := C.g_get_user_special_dir(C.GUserDirectory(directory))
if c == nil {
return "", nilPtrErr
return "", errNilPtr
}
return C.GoString((*C.char)(c)), nil
}
Expand Down
1 change: 1 addition & 0 deletions glib/glib_since_2_42.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
// Same copyright and license as the rest of the files in this project

//go:build !glib_2_40
// +build !glib_2_40

package glib
Expand Down
1 change: 1 addition & 0 deletions glib/glib_since_2_44.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
// Same copyright and license as the rest of the files in this project

//go:build !glib_2_40 && !glib_2_42
// +build !glib_2_40,!glib_2_42

package glib
Expand Down
1 change: 1 addition & 0 deletions glib/glib_since_2_64.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
// Same copyright and license as the rest of the files in this project

//go:build !glib_2_40 && !glib_2_42 && !glib_2_44 && !glib_2_46 && !glib_2_48 && !glib_2_50 && !glib_2_52 && !glib_2_54 && !glib_2_56 && !glib_2_58 && !glib_2_60 && !glib_2_62
// +build !glib_2_40,!glib_2_42,!glib_2_44,!glib_2_46,!glib_2_48,!glib_2_50,!glib_2_52,!glib_2_54,!glib_2_56,!glib_2_58,!glib_2_60,!glib_2_62

package glib
Expand Down
2 changes: 1 addition & 1 deletion glib/go_object.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ type Initter interface {
// TypeInstance is a loose binding around the glib GTypeInstance. It holds the information required to assign
// various capabilities of a GoObjectSubclass.
type TypeInstance struct {
// The GType cooresponding to this GoType
// The GType corresponding to this GoType
GType Type
// A pointer to the underlying C instance being instantiated.
GTypeInstance unsafe.Pointer
Expand Down
16 changes: 8 additions & 8 deletions glib/gobject.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ func TransferNone(ptr unsafe.Pointer) *Object { return Take(ptr) }

// TransferFull wraps a unsafe.Pointer as a glib.Object, taking ownership of it.
// it does not increase the ref count on the object. A finalizer is placed on the object
// to clear the transfered ref.
// to clear the transferred ref.
func TransferFull(ptr unsafe.Pointer) *Object {
obj := newObject(ToGObject(ptr))
runtime.SetFinalizer(obj, (*Object).Unref)
Expand Down Expand Up @@ -211,7 +211,7 @@ func (v *Object) SetProperty(name string, value interface{}) error {
}
p, err := gValue(value)
if err != nil {
return fmt.Errorf("Unable to perform type conversion: %s", err.Error())
return fmt.Errorf("unable to perform type conversion: %s", err.Error())
}
return v.SetPropertyValue(name, p)
}
Expand All @@ -228,7 +228,7 @@ func (v *Object) SetPropertyValue(name string, value *Value) error {
return err
}
if valType != propType {
return fmt.Errorf("Invalid type %s for property %s", value.TypeName(), name)
return fmt.Errorf("invalid type %s for property %s", value.TypeName(), name)
}
cstr := C.CString(name)
defer C.free(unsafe.Pointer(cstr))
Expand Down Expand Up @@ -280,13 +280,13 @@ func (v *Object) Emit(s string, args ...interface{}) (interface{}, error) {
// Add args and valv
val, err := GValue(v)
if err != nil {
return nil, errors.New("Error converting Object to GValue: " + err.Error())
return nil, errors.New("error converting Object to GValue: " + err.Error())
}
C.val_list_insert(valv, C.int(0), val.native())
for i := range args {
val, err := GValue(args[i])
if err != nil {
return nil, fmt.Errorf("Error converting arg %d to GValue: %s", i, err.Error())
return nil, fmt.Errorf("error converting arg %d to GValue: %s", i, err.Error())
}
C.val_list_insert(valv, C.int(i+1), val.native())
}
Expand All @@ -297,7 +297,7 @@ func (v *Object) Emit(s string, args ...interface{}) (interface{}, error) {

ret, err := ValueAlloc()
if err != nil {
return nil, errors.New("Error creating Value for return value")
return nil, errors.New("error creating Value for return value")
}
C.g_signal_emitv(valv, id, C.GQuark(0), ret.native())

Expand Down Expand Up @@ -378,7 +378,7 @@ func WithPointerTransferOriginal(o unsafe.Pointer, f func(*Object, GoObjectSubcl
}

// WithPointerTransferNone will take a pointer to an object retrieved with transfer-none and call
// the cooresponding function with it wrapped in an Object. If the object has an instantiated
// the corresponding function with it wrapped in an Object. If the object has an instantiated
// Go counterpart, it will be sent to the function as well. It is an alternative to using finalizers
// around bindings calls.
func WithPointerTransferNone(o unsafe.Pointer, f func(*Object, GoObjectSubclass)) {
Expand All @@ -393,7 +393,7 @@ func WithPointerTransferNone(o unsafe.Pointer, f func(*Object, GoObjectSubclass)
}

// WithPointerTransferFull will take a pointer to an object retrieved with transfer-full and call
// the cooresponding function with it wrapped in an Object. If the object has an instantiated
// the corresponding function with it wrapped in an Object. If the object has an instantiated
// Go counterpart, it will be sent to the function as well. It is an alternative to using finalizers
// around binding calls.
func WithPointerTransferFull(o unsafe.Pointer, f func(*Object, GoObjectSubclass)) {
Expand Down
6 changes: 3 additions & 3 deletions glib/gvalue.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ func (v *Value) TypeName() string {
func ValueAlloc() (*Value, error) {
c := C._g_value_alloc()
if c == nil {
return nil, nilPtrErr
return nil, errNilPtr
}

v := &Value{c}
Expand Down Expand Up @@ -91,7 +91,7 @@ func ValueAlloc() (*Value, error) {
func ValueInit(t Type) (*Value, error) {
c := C._g_value_init(C.GType(t))
if c == nil {
return nil, nilPtrErr
return nil, errNilPtr
}
v := &Value{c}
runtime.SetFinalizer(v, (*Value).unset)
Expand Down Expand Up @@ -594,7 +594,7 @@ func (v *Value) GetPointer() unsafe.Pointer {
func (v *Value) GetString() (string, error) {
c := C.g_value_get_string(v.native())
if c == nil {
return "", nilPtrErr
return "", errNilPtr
}
return C.GoString((*C.char)(c)), nil
}
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
module github.com/go-gst/go-glib

go 1.21
go 1.22

require github.com/mattn/go-pointer v0.0.1

0 comments on commit 60ae101

Please sign in to comment.