mirror of
https://github.com/gosticks/gml.git
synced 2025-10-16 12:05:33 +00:00
further progress
This commit is contained in:
parent
640030f0bb
commit
0cf1eb3930
11
TODO.md
11
TODO.md
@ -1,9 +1,10 @@
|
|||||||
# TODO
|
# TODO
|
||||||
- finish verbose mode
|
|
||||||
- set core.QCoreApplication_SetApplicationName("App") core.QCoreApplication_SetOrganizationName("Desertbit")
|
- set core.QCoreApplication_SetApplicationName("App") core.QCoreApplication_SetOrganizationName("Desertbit")
|
||||||
- ImageProvider
|
- slots return values
|
||||||
- signals & slots
|
|
||||||
- docker container
|
- docker container
|
||||||
- call qml slots directly from go
|
- properties
|
||||||
|
- models
|
||||||
- dp for pixels
|
- dp for pixels
|
||||||
- document, that slot names must not overlap with QObject names!
|
- add catch exception also to free methods.
|
||||||
|
- document, that slot names must not overlap with QObject names!
|
||||||
|
- call qml slots directly from go?
|
||||||
|
|||||||
99
app.go
99
app.go
@ -52,13 +52,13 @@ func init() {
|
|||||||
C.gml_app_init()
|
C.gml_app_init()
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: free
|
|
||||||
type App struct {
|
type App struct {
|
||||||
|
freed bool
|
||||||
threadID int
|
threadID int
|
||||||
|
|
||||||
app C.gml_app
|
app C.gml_app
|
||||||
argc int
|
argc int
|
||||||
argv **C.char // TODO: free
|
argv **C.char
|
||||||
|
|
||||||
mutex sync.Mutex
|
mutex sync.Mutex
|
||||||
ctxPropMap map[string]interface{}
|
ctxPropMap map[string]interface{}
|
||||||
@ -78,6 +78,9 @@ func NewAppWithArgs(args []string) (a *App, err error) {
|
|||||||
// Ensure the thread is locked within this context of app creation.
|
// Ensure the thread is locked within this context of app creation.
|
||||||
runtime.LockOSThread()
|
runtime.LockOSThread()
|
||||||
|
|
||||||
|
apiErr := errorPool.Get()
|
||||||
|
defer errorPool.Put(apiErr)
|
||||||
|
|
||||||
a = &App{
|
a = &App{
|
||||||
threadID: utils.GetThreadID(),
|
threadID: utils.GetThreadID(),
|
||||||
argc: len(args),
|
argc: len(args),
|
||||||
@ -85,10 +88,31 @@ func NewAppWithArgs(args []string) (a *App, err error) {
|
|||||||
ctxPropMap: make(map[string]interface{}),
|
ctxPropMap: make(map[string]interface{}),
|
||||||
imgProvMap: make(map[string]*ImageProvider),
|
imgProvMap: make(map[string]*ImageProvider),
|
||||||
}
|
}
|
||||||
a.app = C.gml_app_new(C.int(a.argc), a.argv)
|
|
||||||
|
a.app = C.gml_app_new(C.int(a.argc), a.argv, apiErr.err)
|
||||||
|
if a.app == nil {
|
||||||
|
err = apiErr.Err("failed to create new app")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// Always free the C value.
|
||||||
|
runtime.SetFinalizer(a, freeApp)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func freeApp(a *App) {
|
||||||
|
if a.freed {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
a.freed = true
|
||||||
|
C.gml_app_free(a.app)
|
||||||
|
freeCharArray(a.argv, a.argc)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (a *App) Free() {
|
||||||
|
freeApp(a)
|
||||||
|
}
|
||||||
|
|
||||||
// RunMain runs the function on the applications main thread.
|
// RunMain runs the function on the applications main thread.
|
||||||
func (a *App) RunMain(f func()) {
|
func (a *App) RunMain(f func()) {
|
||||||
// Check if already running on the main thread.
|
// Check if already running on the main thread.
|
||||||
@ -106,11 +130,10 @@ func (a *App) RunMain(f func()) {
|
|||||||
ptr := pointer.Save(cb)
|
ptr := pointer.Save(cb)
|
||||||
defer pointer.Unref(ptr)
|
defer pointer.Unref(ptr)
|
||||||
|
|
||||||
// TODO:
|
ret := C.gml_app_run_main(a.app, ptr)
|
||||||
_ = C.gml_app_run_main(a.app, ptr)
|
if ret != 0 {
|
||||||
/*if error {
|
|
||||||
return
|
return
|
||||||
}*/
|
}
|
||||||
|
|
||||||
<-doneChan
|
<-doneChan
|
||||||
}
|
}
|
||||||
@ -121,31 +144,39 @@ func (a *App) Load(url string) error {
|
|||||||
urlC := C.CString(url)
|
urlC := C.CString(url)
|
||||||
defer C.free(unsafe.Pointer(urlC))
|
defer C.free(unsafe.Pointer(urlC))
|
||||||
|
|
||||||
// TODO:
|
apiErr := errorPool.Get()
|
||||||
_ = int(C.gml_app_load(a.app, urlC))
|
defer errorPool.Put(apiErr)
|
||||||
|
|
||||||
|
ret := C.gml_app_load(a.app, urlC, apiErr.err)
|
||||||
|
if ret != 0 {
|
||||||
|
return apiErr.Err("failed to load url")
|
||||||
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// Load the QML given in data.
|
// LoadData loads the QML given in data.
|
||||||
// Hint: Must be called within main thread.
|
// Hint: Must be called within main thread.
|
||||||
func (a *App) LoadData(data string) error {
|
func (a *App) LoadData(data string) error {
|
||||||
dataC := C.CString(data)
|
dataC := C.CString(data)
|
||||||
defer C.free(unsafe.Pointer(dataC))
|
defer C.free(unsafe.Pointer(dataC))
|
||||||
|
|
||||||
// TODO:
|
apiErr := errorPool.Get()
|
||||||
_ = int(C.gml_app_load_data(a.app, dataC))
|
defer errorPool.Put(apiErr)
|
||||||
|
|
||||||
|
ret := C.gml_app_load_data(a.app, dataC, apiErr.err)
|
||||||
|
if ret != 0 {
|
||||||
|
return apiErr.Err("failed to load data")
|
||||||
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// AddImportPath adds the given import path to the app engine.
|
// AddImportPath adds the given import path to the app engine.
|
||||||
// Hint: Must be called within main thread.
|
// Hint: Must be called within main thread.
|
||||||
func (a *App) AddImportPath(path string) error {
|
func (a *App) AddImportPath(path string) {
|
||||||
pathC := C.CString(path)
|
pathC := C.CString(path)
|
||||||
defer C.free(unsafe.Pointer(pathC))
|
defer C.free(unsafe.Pointer(pathC))
|
||||||
|
|
||||||
// TODO:
|
C.gml_app_add_import_path(a.app, pathC)
|
||||||
_ = int(C.gml_app_add_import_path(a.app, pathC))
|
|
||||||
return nil
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// AddImageProvider adds the image provider to the app engine for the given id.
|
// AddImageProvider adds the image provider to the app engine for the given id.
|
||||||
@ -153,9 +184,16 @@ func (a *App) AddImageProvider(id string, ip *ImageProvider) error {
|
|||||||
idC := C.CString(id)
|
idC := C.CString(id)
|
||||||
defer C.free(unsafe.Pointer(idC))
|
defer C.free(unsafe.Pointer(idC))
|
||||||
|
|
||||||
|
apiErr := errorPool.Get()
|
||||||
|
defer errorPool.Put(apiErr)
|
||||||
|
|
||||||
|
var ret C.int
|
||||||
a.RunMain(func() {
|
a.RunMain(func() {
|
||||||
_ = int(C.gml_app_add_imageprovider(a.app, idC, ip.ip))
|
ret = C.gml_app_add_imageprovider(a.app, idC, ip.ip, apiErr.err)
|
||||||
})
|
})
|
||||||
|
if ret != 0 {
|
||||||
|
return apiErr.Err("failed to add image provider")
|
||||||
|
}
|
||||||
|
|
||||||
// Add to map to ensure it gets not garbage collected.
|
// Add to map to ensure it gets not garbage collected.
|
||||||
// It is in use by the C++ context;
|
// It is in use by the C++ context;
|
||||||
@ -169,16 +207,23 @@ func (a *App) AddImageProvider(id string, ip *ImageProvider) error {
|
|||||||
// Exec executes the application and returns the exit code.
|
// Exec executes the application and returns the exit code.
|
||||||
// This method is blocking.
|
// This method is blocking.
|
||||||
// Hint: Must be called within main thread.
|
// Hint: Must be called within main thread.
|
||||||
func (a *App) Exec() int {
|
func (a *App) Exec() (retCode int, err error) {
|
||||||
return int(C.gml_app_exec(a.app))
|
apiErr := errorPool.Get()
|
||||||
|
defer errorPool.Put(apiErr)
|
||||||
|
|
||||||
|
retCode = int(C.gml_app_exec(a.app, apiErr.err))
|
||||||
|
if retCode != 0 {
|
||||||
|
err = apiErr.Err("app execution failed")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
// Quit the application.
|
// Quit the application.
|
||||||
func (a *App) Quit() (retCode int) {
|
func (a *App) Quit() {
|
||||||
a.RunMain(func() {
|
a.RunMain(func() {
|
||||||
retCode = int(C.gml_app_quit(a.app))
|
C.gml_app_quit(a.app)
|
||||||
})
|
})
|
||||||
return
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (a *App) SetContextProperty(name string, v interface{}) (err error) {
|
func (a *App) SetContextProperty(name string, v interface{}) (err error) {
|
||||||
@ -195,10 +240,16 @@ func (a *App) SetContextProperty(name string, v interface{}) (err error) {
|
|||||||
nameC := C.CString(name)
|
nameC := C.CString(name)
|
||||||
defer C.free(unsafe.Pointer(nameC))
|
defer C.free(unsafe.Pointer(nameC))
|
||||||
|
|
||||||
|
apiErr := errorPool.Get()
|
||||||
|
defer errorPool.Put(apiErr)
|
||||||
|
|
||||||
|
var ret C.int
|
||||||
a.RunMain(func() {
|
a.RunMain(func() {
|
||||||
// TODO:
|
ret = C.gml_app_set_root_context_property(a.app, nameC, obj.cObject(), apiErr.err)
|
||||||
_ = int(C.gml_app_set_root_context_property(a.app, nameC, obj.cObject()))
|
|
||||||
})
|
})
|
||||||
|
if ret != 0 {
|
||||||
|
return apiErr.Err("failed to set context property")
|
||||||
|
}
|
||||||
|
|
||||||
// Add to map to ensure it gets not garbage collected.
|
// Add to map to ensure it gets not garbage collected.
|
||||||
// It is in use by the C++ context;
|
// It is in use by the C++ context;
|
||||||
|
|||||||
68
error.go
Normal file
68
error.go
Normal file
@ -0,0 +1,68 @@
|
|||||||
|
/*
|
||||||
|
* GML - Go QML
|
||||||
|
*
|
||||||
|
* The MIT License (MIT)
|
||||||
|
*
|
||||||
|
* Copyright (c) 2019 Roland Singer <roland.singer[at]desertbit.com>
|
||||||
|
* Copyright (c) 2019 Sebastian Borchers <sebastian[at]desertbit.com>
|
||||||
|
*
|
||||||
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
* of this software and associated documentation files (the "Software"), to deal
|
||||||
|
* in the Software without restriction, including without limitation the rights
|
||||||
|
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
* copies of the Software, and to permit persons to whom the Software is
|
||||||
|
* furnished to do so, subject to the following conditions:
|
||||||
|
*
|
||||||
|
* The above copyright notice and this permission notice shall be included in all
|
||||||
|
* copies or substantial portions of the Software.
|
||||||
|
*
|
||||||
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||||
|
* SOFTWARE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package gml
|
||||||
|
|
||||||
|
// #include <gml.h>
|
||||||
|
import "C"
|
||||||
|
import "errors"
|
||||||
|
|
||||||
|
type apiError struct {
|
||||||
|
err C.gml_error
|
||||||
|
}
|
||||||
|
|
||||||
|
func newAPIError() *apiError {
|
||||||
|
return &apiError{
|
||||||
|
err: C.gml_error_new(),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (e *apiError) Free() {
|
||||||
|
C.gml_error_free(e.err)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (e *apiError) String() string {
|
||||||
|
return C.GoString(C.gml_error_get_msg(e.err))
|
||||||
|
}
|
||||||
|
|
||||||
|
func (e *apiError) Reset() {
|
||||||
|
C.gml_error_reset(e.err)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (e *apiError) Err(prefix ...string) error {
|
||||||
|
s := e.String()
|
||||||
|
if len(prefix) > 0 {
|
||||||
|
if len(s) == 0 {
|
||||||
|
s = prefix[0]
|
||||||
|
} else {
|
||||||
|
s = prefix[0] + ": " + s
|
||||||
|
}
|
||||||
|
} else if len(s) == 0 {
|
||||||
|
s = "unknown error"
|
||||||
|
}
|
||||||
|
return errors.New(s)
|
||||||
|
}
|
||||||
83
errors.go
Normal file
83
errors.go
Normal file
@ -0,0 +1,83 @@
|
|||||||
|
/*
|
||||||
|
* GML - Go QML
|
||||||
|
*
|
||||||
|
* The MIT License (MIT)
|
||||||
|
*
|
||||||
|
* Copyright (c) 2019 Roland Singer <roland.singer[at]desertbit.com>
|
||||||
|
* Copyright (c) 2019 Sebastian Borchers <sebastian[at]desertbit.com>
|
||||||
|
*
|
||||||
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
* of this software and associated documentation files (the "Software"), to deal
|
||||||
|
* in the Software without restriction, including without limitation the rights
|
||||||
|
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
* copies of the Software, and to permit persons to whom the Software is
|
||||||
|
* furnished to do so, subject to the following conditions:
|
||||||
|
*
|
||||||
|
* The above copyright notice and this permission notice shall be included in all
|
||||||
|
* copies or substantial portions of the Software.
|
||||||
|
*
|
||||||
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||||
|
* SOFTWARE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package gml
|
||||||
|
|
||||||
|
const (
|
||||||
|
errorPoolSize = 50
|
||||||
|
)
|
||||||
|
|
||||||
|
var (
|
||||||
|
errorPool = newAPIErrorPool(errorPoolSize)
|
||||||
|
)
|
||||||
|
|
||||||
|
type apiErrorPool struct {
|
||||||
|
pool chan *apiError
|
||||||
|
}
|
||||||
|
|
||||||
|
func newAPIErrorPool(poolSize int) *apiErrorPool {
|
||||||
|
return &apiErrorPool{
|
||||||
|
pool: make(chan *apiError, poolSize),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Get an error from the pool.
|
||||||
|
// Allocates new memory if the pool is empty.
|
||||||
|
func (p *apiErrorPool) Get() (e *apiError) {
|
||||||
|
select {
|
||||||
|
case e = <-p.pool:
|
||||||
|
default:
|
||||||
|
e = newAPIError()
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// Put an error back to the pool.
|
||||||
|
func (p *apiErrorPool) Put(e *apiError) {
|
||||||
|
// Reset the error message.
|
||||||
|
e.Reset()
|
||||||
|
|
||||||
|
select {
|
||||||
|
case p.pool <- e:
|
||||||
|
default:
|
||||||
|
// Just let it go. The pool is full.
|
||||||
|
e.Free()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Reset empties the pool.
|
||||||
|
func (p *apiErrorPool) Reset() {
|
||||||
|
var e *apiError
|
||||||
|
for {
|
||||||
|
select {
|
||||||
|
case e = <-p.pool:
|
||||||
|
e.Free()
|
||||||
|
default:
|
||||||
|
return
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
14
gml.go
14
gml.go
@ -32,3 +32,17 @@ package gml
|
|||||||
// #cgo LDFLAGS: -lstdc++
|
// #cgo LDFLAGS: -lstdc++
|
||||||
// #include <gml.h>
|
// #include <gml.h>
|
||||||
import "C"
|
import "C"
|
||||||
|
import (
|
||||||
|
"fmt"
|
||||||
|
"os"
|
||||||
|
)
|
||||||
|
|
||||||
|
// Exec executes the app, prints errors and exits
|
||||||
|
// the application with the specific exit code.
|
||||||
|
func Exec(a *App) {
|
||||||
|
ret, err := a.Exec()
|
||||||
|
if err != nil {
|
||||||
|
fmt.Println(err)
|
||||||
|
}
|
||||||
|
os.Exit(ret)
|
||||||
|
}
|
||||||
|
|||||||
17
image.go
17
image.go
@ -78,8 +78,17 @@ func (img *Image) Free() {
|
|||||||
freeImage(img)
|
freeImage(img)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (img *Image) LoadFromData(data []byte) (err error) {
|
func (img *Image) LoadFromData(data []byte) error {
|
||||||
// TODO:
|
if len(data) == 0 {
|
||||||
_ = C.gml_image_load_from_data(img.img, (*C.char)(unsafe.Pointer(&data[0])), C.int(len(data)))
|
return fmt.Errorf("empty data")
|
||||||
return
|
}
|
||||||
|
|
||||||
|
apiErr := errorPool.Get()
|
||||||
|
defer errorPool.Put(apiErr)
|
||||||
|
|
||||||
|
ret := C.gml_image_load_from_data(img.img, (*C.char)(unsafe.Pointer(&data[0])), C.int(len(data)), apiErr.err)
|
||||||
|
if ret != 0 {
|
||||||
|
return apiErr.Err("failed to load from data")
|
||||||
|
}
|
||||||
|
return nil
|
||||||
}
|
}
|
||||||
|
|||||||
@ -31,6 +31,7 @@
|
|||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
|
|
||||||
|
#include "gml_error.h"
|
||||||
#include "gml_app.h"
|
#include "gml_app.h"
|
||||||
#include "gml_image.h"
|
#include "gml_image.h"
|
||||||
#include "gml_object.h"
|
#include "gml_object.h"
|
||||||
|
|||||||
@ -32,6 +32,7 @@
|
|||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#include "gml_error.h"
|
||||||
#include "gml_object.h"
|
#include "gml_object.h"
|
||||||
#include "gml_imageprovider.h"
|
#include "gml_imageprovider.h"
|
||||||
|
|
||||||
@ -40,18 +41,18 @@ typedef void* gml_app;
|
|||||||
typedef void (*gml_app_run_main_cb_t)(void* go_ptr);
|
typedef void (*gml_app_run_main_cb_t)(void* go_ptr);
|
||||||
void gml_app_run_main_cb_register(gml_app_run_main_cb_t cb);
|
void gml_app_run_main_cb_register(gml_app_run_main_cb_t cb);
|
||||||
|
|
||||||
gml_app gml_app_new (int argv, char** argc);
|
gml_app gml_app_new (int argv, char** argc, gml_error err);
|
||||||
void gml_app_free(gml_app app);
|
void gml_app_free(gml_app app);
|
||||||
int gml_app_exec(gml_app app);
|
int gml_app_exec(gml_app app, gml_error err);
|
||||||
int gml_app_quit(gml_app app);
|
void gml_app_quit(gml_app app);
|
||||||
int gml_app_run_main(gml_app app, void* go_ptr);
|
int gml_app_run_main(gml_app app, void* go_ptr);
|
||||||
|
|
||||||
int gml_app_load (gml_app app, const char* url);
|
int gml_app_load (gml_app app, const char* url, gml_error err);
|
||||||
int gml_app_load_data(gml_app app, const char* data);
|
int gml_app_load_data(gml_app app, const char* data, gml_error err);
|
||||||
int gml_app_add_import_path(gml_app app, const char* path);
|
void gml_app_add_import_path(gml_app app, const char* path);
|
||||||
int gml_app_add_imageprovider(gml_app app, const char* id, gml_imageprovider ip);
|
int gml_app_add_imageprovider(gml_app app, const char* id, gml_imageprovider ip, gml_error err);
|
||||||
|
|
||||||
int gml_app_set_root_context_property(gml_app app, const char* name, gml_object obj);
|
int gml_app_set_root_context_property(gml_app app, const char* name, gml_object obj, gml_error err);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
|
|||||||
@ -32,7 +32,12 @@
|
|||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
typedef void* gml_object;
|
typedef void* gml_error;
|
||||||
|
|
||||||
|
gml_error gml_error_new();
|
||||||
|
void gml_error_free (gml_error err);
|
||||||
|
void gml_error_reset (gml_error err);
|
||||||
|
const char* gml_error_get_msg(gml_error err);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
|
|||||||
@ -36,7 +36,7 @@ typedef void* gml_image;
|
|||||||
|
|
||||||
gml_image gml_image_new();
|
gml_image gml_image_new();
|
||||||
void gml_image_free(gml_image img);
|
void gml_image_free(gml_image img);
|
||||||
int gml_image_load_from_data(gml_image img, char* data, int size);
|
int gml_image_load_from_data(gml_image img, char* data, int size, gml_error err);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
|
|||||||
@ -41,17 +41,17 @@ void gml_app_run_main_cb_register(gml_app_run_main_cb_t cb) {
|
|||||||
gml_app_run_main_cb = cb;
|
gml_app_run_main_cb = cb;
|
||||||
}
|
}
|
||||||
|
|
||||||
gml_app gml_app_new(int argc, char** argv) {
|
gml_app gml_app_new(int argc, char** argv, gml_error err) {
|
||||||
try {
|
try {
|
||||||
GmlApp* a = new GmlApp(argc, argv);
|
GmlApp* a = new GmlApp(argc, argv);
|
||||||
return (void*)a;
|
return (void*)a;
|
||||||
}
|
}
|
||||||
catch (std::exception& e) {
|
catch (std::exception& e) {
|
||||||
//api_error_set_msg(err, e.what()); TODO:
|
gml_error_set_msg(err, e.what());
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
catch (...) {
|
catch (...) {
|
||||||
//api_error_set_unknown_msg(err); TODO:
|
gml_error_set_catched_exception_msg(err);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -65,34 +65,31 @@ void gml_app_free(gml_app app) {
|
|||||||
app = NULL;
|
app = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
int gml_app_exec(gml_app app) {
|
int gml_app_exec(gml_app app, gml_error err) {
|
||||||
try {
|
try {
|
||||||
GmlApp* a = (GmlApp*)app;
|
GmlApp* a = (GmlApp*)app;
|
||||||
return a->app.exec();
|
return a->app.exec();
|
||||||
}
|
}
|
||||||
catch (std::exception& e) {
|
catch (std::exception& e) {
|
||||||
//api_error_set_msg(err, e.what()); TODO:
|
gml_error_set_msg(err, e.what());
|
||||||
return -1; // TODO:
|
return -1;
|
||||||
}
|
}
|
||||||
catch (...) {
|
catch (...) {
|
||||||
//api_error_set_unknown_msg(err); TODO:
|
gml_error_set_catched_exception_msg(err);
|
||||||
return -1; // TODO:
|
return -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int gml_app_quit(gml_app app) {
|
void gml_app_quit(gml_app app) {
|
||||||
try {
|
try {
|
||||||
GmlApp* a = (GmlApp*)app;
|
GmlApp* a = (GmlApp*)app;
|
||||||
a->app.quit();
|
a->app.quit();
|
||||||
return 0; // TODO:
|
|
||||||
}
|
}
|
||||||
catch (std::exception& e) {
|
catch (std::exception& e) {
|
||||||
//api_error_set_msg(err, e.what()); TODO:
|
gml_error_log_exception(e.what());
|
||||||
return -1; // TODO:
|
|
||||||
}
|
}
|
||||||
catch (...) {
|
catch (...) {
|
||||||
//api_error_set_unknown_msg(err); TODO:
|
gml_error_log_exception();
|
||||||
return -1; // TODO:
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -100,97 +97,94 @@ int gml_app_run_main(gml_app app, void* go_ptr) {
|
|||||||
try {
|
try {
|
||||||
GmlApp* a = (GmlApp*)app;
|
GmlApp* a = (GmlApp*)app;
|
||||||
emit a->requestRunMain(go_ptr);
|
emit a->requestRunMain(go_ptr);
|
||||||
return 0; // TODO:
|
return 0;
|
||||||
}
|
}
|
||||||
catch (std::exception& e) {
|
catch (std::exception& e) {
|
||||||
//api_error_set_msg(err, e.what()); TODO:
|
gml_error_log_exception(e.what());
|
||||||
return -1; // TODO:
|
return -1;
|
||||||
}
|
}
|
||||||
catch (...) {
|
catch (...) {
|
||||||
//api_error_set_unknown_msg(err); TODO:
|
gml_error_log_exception();
|
||||||
return -1; // TODO:
|
return -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int gml_app_load(gml_app app, const char* url) {
|
int gml_app_load(gml_app app, const char* url, gml_error err) {
|
||||||
try {
|
try {
|
||||||
GmlApp* a = (GmlApp*)app;
|
GmlApp* a = (GmlApp*)app;
|
||||||
a->engine.load(QUrl(url));
|
a->engine.load(QUrl(url));
|
||||||
return 0; // TODO:
|
return 0;
|
||||||
}
|
}
|
||||||
catch (std::exception& e) {
|
catch (std::exception& e) {
|
||||||
//api_error_set_msg(err, e.what()); TODO:
|
gml_error_set_msg(err, e.what());
|
||||||
return -1; // TODO:
|
return -1;
|
||||||
}
|
}
|
||||||
catch (...) {
|
catch (...) {
|
||||||
//api_error_set_unknown_msg(err); TODO:
|
gml_error_set_catched_exception_msg(err);
|
||||||
return -1; // TODO:
|
return -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int gml_app_load_data(gml_app app, const char* data) {
|
int gml_app_load_data(gml_app app, const char* data, gml_error err) {
|
||||||
try {
|
try {
|
||||||
GmlApp* a = (GmlApp*)app;
|
GmlApp* a = (GmlApp*)app;
|
||||||
a->engine.loadData(data);
|
a->engine.loadData(data);
|
||||||
return 0; // TODO:
|
return 0;
|
||||||
}
|
}
|
||||||
catch (std::exception& e) {
|
catch (std::exception& e) {
|
||||||
//api_error_set_msg(err, e.what()); TODO:
|
gml_error_set_msg(err, e.what());
|
||||||
return -1; // TODO:
|
return -1;
|
||||||
}
|
}
|
||||||
catch (...) {
|
catch (...) {
|
||||||
//api_error_set_unknown_msg(err); TODO:
|
gml_error_set_catched_exception_msg(err);
|
||||||
return -1; // TODO:
|
return -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int gml_app_add_import_path(gml_app app, const char* path) {
|
void gml_app_add_import_path(gml_app app, const char* path) {
|
||||||
try {
|
try {
|
||||||
GmlApp* a = (GmlApp*)app;
|
GmlApp* a = (GmlApp*)app;
|
||||||
a->engine.addImportPath(path);
|
a->engine.addImportPath(path);
|
||||||
return 0; // TODO:
|
|
||||||
}
|
}
|
||||||
catch (std::exception& e) {
|
catch (std::exception& e) {
|
||||||
//api_error_set_msg(err, e.what()); TODO:
|
gml_error_log_exception(e.what());
|
||||||
return -1; // TODO:
|
|
||||||
}
|
}
|
||||||
catch (...) {
|
catch (...) {
|
||||||
//api_error_set_unknown_msg(err); TODO:
|
gml_error_log_exception();
|
||||||
return -1; // TODO:
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int gml_app_add_imageprovider(gml_app app, const char* id, gml_imageprovider ip) {
|
int gml_app_add_imageprovider(gml_app app, const char* id, gml_imageprovider ip, gml_error err) {
|
||||||
try {
|
try {
|
||||||
GmlApp* a = (GmlApp*)app;
|
GmlApp* a = (GmlApp*)app;
|
||||||
GmlImageProvider* gip = (GmlImageProvider*)ip;
|
GmlImageProvider* gip = (GmlImageProvider*)ip;
|
||||||
a->engine.addImageProvider(id, gip);
|
a->engine.addImageProvider(id, gip);
|
||||||
return 0; // TODO:
|
return 0;
|
||||||
}
|
}
|
||||||
catch (std::exception& e) {
|
catch (std::exception& e) {
|
||||||
//api_error_set_msg(err, e.what()); TODO:
|
gml_error_set_msg(err, e.what());
|
||||||
return -1; // TODO:
|
return -1;
|
||||||
}
|
}
|
||||||
catch (...) {
|
catch (...) {
|
||||||
//api_error_set_unknown_msg(err); TODO:
|
gml_error_set_catched_exception_msg(err);
|
||||||
return -1; // TODO:
|
return -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int gml_app_set_root_context_property(gml_app app, const char* name, gml_object obj) {
|
int gml_app_set_root_context_property(gml_app app, const char* name, gml_object obj, gml_error err) {
|
||||||
try {
|
try {
|
||||||
GmlApp* a = (GmlApp*)app;
|
GmlApp* a = (GmlApp*)app;
|
||||||
QObject* o = (QObject*)obj;
|
QObject* o = (QObject*)obj;
|
||||||
a->engine.rootContext()->setContextProperty(name, o);
|
a->engine.rootContext()->setContextProperty(name, o);
|
||||||
return 0; // TODO:
|
return 0;
|
||||||
}
|
}
|
||||||
catch (std::exception& e) {
|
catch (std::exception& e) {
|
||||||
//api_error_set_msg(err, e.what()); TODO:
|
gml_error_set_msg(err, e.what());
|
||||||
return -1; // TODO:
|
return -1;
|
||||||
}
|
}
|
||||||
catch (...) {
|
catch (...) {
|
||||||
//api_error_set_unknown_msg(err); TODO:
|
gml_error_set_catched_exception_msg(err);
|
||||||
return -1; // TODO:
|
return -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -29,6 +29,7 @@
|
|||||||
#define GML_APP_H
|
#define GML_APP_H
|
||||||
|
|
||||||
#include "gml_includes.h"
|
#include "gml_includes.h"
|
||||||
|
#include "gml_error.h"
|
||||||
#include "gml_imageprovider.h"
|
#include "gml_imageprovider.h"
|
||||||
|
|
||||||
class GmlApp : public QObject
|
class GmlApp : public QObject
|
||||||
|
|||||||
105
internal/binding/sources/gml_error.cpp
Normal file
105
internal/binding/sources/gml_error.cpp
Normal file
@ -0,0 +1,105 @@
|
|||||||
|
/*
|
||||||
|
* GML - Go QML
|
||||||
|
*
|
||||||
|
* The MIT License (MIT)
|
||||||
|
*
|
||||||
|
* Copyright (c) 2019 Roland Singer <roland.singer[at]desertbit.com>
|
||||||
|
* Copyright (c) 2019 Sebastian Borchers <sebastian[at]desertbit.com>
|
||||||
|
*
|
||||||
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
* of this software and associated documentation files (the "Software"), to deal
|
||||||
|
* in the Software without restriction, including without limitation the rights
|
||||||
|
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
* copies of the Software, and to permit persons to whom the Software is
|
||||||
|
* furnished to do so, subject to the following conditions:
|
||||||
|
*
|
||||||
|
* The above copyright notice and this permission notice shall be included in all
|
||||||
|
* copies or substantial portions of the Software.
|
||||||
|
*
|
||||||
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||||
|
* SOFTWARE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "gml_error.h"
|
||||||
|
|
||||||
|
//#############//
|
||||||
|
//### C API ###//
|
||||||
|
//#############//
|
||||||
|
|
||||||
|
gml_error gml_error_new() {
|
||||||
|
try {
|
||||||
|
GmlError* gerr = new GmlError();
|
||||||
|
return (void*)gerr;
|
||||||
|
}
|
||||||
|
catch (std::exception& e) {
|
||||||
|
gml_error_log_exception("new gml_error: " + string(e.what()));
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
catch (...) {
|
||||||
|
gml_error_log_exception("new gml_error");
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void gml_error_free(gml_error err) {
|
||||||
|
if (err == NULL) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
GmlError* gerr = (GmlError*)err;
|
||||||
|
delete gerr;
|
||||||
|
err = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
void gml_error_reset(gml_error err) {
|
||||||
|
try {
|
||||||
|
GmlError* gerr = (GmlError*)err;
|
||||||
|
gerr->msg = "";
|
||||||
|
}
|
||||||
|
catch (std::exception& e) {
|
||||||
|
gml_error_log_exception("reset error message: " + string(e.what()));
|
||||||
|
}
|
||||||
|
catch (...) {
|
||||||
|
gml_error_log_exception("reset error message");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const char* gml_error_get_msg(gml_error err) {
|
||||||
|
try {
|
||||||
|
GmlError* gerr = (GmlError*)err;
|
||||||
|
return gerr->msg.c_str();
|
||||||
|
}
|
||||||
|
catch (std::exception& e) {
|
||||||
|
gml_error_log_exception("get error message: " + string(e.what()));
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
catch (...) {
|
||||||
|
gml_error_log_exception("get error message");
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//################//
|
||||||
|
//### Internal ###//
|
||||||
|
//################//
|
||||||
|
|
||||||
|
void gml_error_set_msg(gml_error err, const std::string& msg) {
|
||||||
|
GmlError* gerr = (GmlError*)err;
|
||||||
|
gerr->msg = msg;
|
||||||
|
}
|
||||||
|
|
||||||
|
void gml_error_set_catched_exception_msg(gml_error err) {
|
||||||
|
gml_error_set_msg(err, "catched unknown exception");
|
||||||
|
}
|
||||||
|
|
||||||
|
void gml_error_log_exception(const string& msg) {
|
||||||
|
if (msg == "") {
|
||||||
|
cerr << "gml: catched unknown exception" << endl;
|
||||||
|
} else {
|
||||||
|
cerr << "gml: catched exception: " << msg << endl;
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -25,13 +25,17 @@
|
|||||||
* SOFTWARE.
|
* SOFTWARE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef GML_APP_H
|
#ifndef GML_ERROR_H
|
||||||
#define GML_APP_H
|
#define GML_ERROR_H
|
||||||
|
|
||||||
#include "gml_includes.h"
|
#include "gml_includes.h"
|
||||||
|
|
||||||
struct GmlError struct {
|
struct GmlError {
|
||||||
string msg;
|
string msg;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
void gml_error_set_msg(gml_error err, const string& msg);
|
||||||
|
void gml_error_set_catched_exception_msg(gml_error err);
|
||||||
|
void gml_error_log_exception(const string& msg = "");
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@ -26,6 +26,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include "gml_includes.h"
|
#include "gml_includes.h"
|
||||||
|
#include "gml_error.h"
|
||||||
|
|
||||||
//#############//
|
//#############//
|
||||||
//### C API ###//
|
//### C API ###//
|
||||||
@ -37,11 +38,11 @@ gml_image gml_image_new() {
|
|||||||
return (void*)qImg;
|
return (void*)qImg;
|
||||||
}
|
}
|
||||||
catch (std::exception& e) {
|
catch (std::exception& e) {
|
||||||
cerr << "gml: catched variant exception: " << e.what() << endl;
|
gml_error_log_exception(e.what());
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
catch (...) {
|
catch (...) {
|
||||||
cerr << "gml: catched variant exception" << endl;
|
gml_error_log_exception();
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -55,18 +56,18 @@ void gml_image_free(gml_image img) {
|
|||||||
img = NULL;
|
img = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
int gml_image_load_from_data(gml_image img, char* data, int size) {
|
int gml_image_load_from_data(gml_image img, char* data, int size, gml_error err) {
|
||||||
try {
|
try {
|
||||||
QImage* qImg = (QImage*)img;
|
QImage* qImg = (QImage*)img;
|
||||||
qImg->loadFromData((const unsigned char*)(data), size);
|
qImg->loadFromData((const unsigned char*)(data), size);
|
||||||
return 0; // TODO:
|
return 0;
|
||||||
}
|
}
|
||||||
catch (std::exception& e) {
|
catch (std::exception& e) {
|
||||||
cerr << "gml: catched variant exception: " << e.what() << endl;
|
gml_error_set_msg(err, e.what());
|
||||||
return -1; // TODO:
|
return -1;
|
||||||
}
|
}
|
||||||
catch (...) {
|
catch (...) {
|
||||||
cerr << "gml: catched variant exception" << endl;
|
gml_error_set_catched_exception_msg(err);
|
||||||
return -1; // TODO:
|
return -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -26,6 +26,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include "gml_imageprovider.h"
|
#include "gml_imageprovider.h"
|
||||||
|
#include "gml_error.h"
|
||||||
|
|
||||||
//########################//
|
//########################//
|
||||||
//### Static Variables ###//
|
//### Static Variables ###//
|
||||||
@ -55,11 +56,11 @@ gml_imageprovider gml_imageprovider_new(
|
|||||||
return (void*)gip;
|
return (void*)gip;
|
||||||
}
|
}
|
||||||
catch (std::exception& e) {
|
catch (std::exception& e) {
|
||||||
//api_error_set_msg(err, e.what()); TODO:
|
gml_error_log_exception(e.what());
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
catch (...) {
|
catch (...) {
|
||||||
//api_error_set_unknown_msg(err); TODO:
|
gml_error_log_exception();
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -79,10 +80,10 @@ void gml_image_response_emit_finished(gml_image_response img_resp, char* error_s
|
|||||||
gimg_resp->finalize(QString(error_string));
|
gimg_resp->finalize(QString(error_string));
|
||||||
}
|
}
|
||||||
catch (std::exception& e) {
|
catch (std::exception& e) {
|
||||||
cerr << "gml: catched image response exception: emit finished: " << e.what() << endl;
|
gml_error_log_exception("image response: emit finished: " + string(e.what()));
|
||||||
}
|
}
|
||||||
catch (...) {
|
catch (...) {
|
||||||
cerr << "gml: catched image response exception: emit finished: " << endl;
|
gml_error_log_exception("image response: emit finished");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -112,10 +113,10 @@ GmlAsyncImageResponse::GmlAsyncImageResponse(
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
catch (std::exception& e) {
|
catch (std::exception& e) {
|
||||||
cerr << "gml: catched GmlAsyncImageResponse exception: " << e.what() << endl;
|
gml_error_log_exception("image async response: request: " + string(e.what()));
|
||||||
}
|
}
|
||||||
catch (...) {
|
catch (...) {
|
||||||
cerr << "gml: catched GmlAsyncImageResponse exception: " << endl;
|
gml_error_log_exception("image async response: request");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -133,7 +134,6 @@ void GmlAsyncImageResponse::finalize(const QString& errorString) {
|
|||||||
errorStr = errorString;
|
errorStr = errorString;
|
||||||
} else if (!requestedSize.isNull() && requestedSize.isValid()) {
|
} else if (!requestedSize.isNull() && requestedSize.isValid()) {
|
||||||
// Resize the image to the requested size
|
// Resize the image to the requested size
|
||||||
cout << requestedSize.width() << ", " << requestedSize.height() << endl;
|
|
||||||
img = img.scaled(requestedSize, Qt::IgnoreAspectRatio, transformMode);
|
img = img.scaled(requestedSize, Qt::IgnoreAspectRatio, transformMode);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -32,6 +32,7 @@
|
|||||||
|
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
#include <string>
|
||||||
|
|
||||||
#include <QObject>
|
#include <QObject>
|
||||||
#include <QUrl>
|
#include <QUrl>
|
||||||
@ -45,6 +46,7 @@
|
|||||||
#include <QQuickAsyncImageProvider>
|
#include <QQuickAsyncImageProvider>
|
||||||
#include <QQuickImageResponse>
|
#include <QQuickImageResponse>
|
||||||
|
|
||||||
|
using std::string;
|
||||||
using std::cout;
|
using std::cout;
|
||||||
using std::cerr;
|
using std::cerr;
|
||||||
using std::endl;
|
using std::endl;
|
||||||
|
|||||||
@ -26,6 +26,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include "gml_includes.h"
|
#include "gml_includes.h"
|
||||||
|
#include "gml_error.h"
|
||||||
|
|
||||||
//#############//
|
//#############//
|
||||||
//### C API ###//
|
//### C API ###//
|
||||||
@ -46,11 +47,11 @@ gml_variant gml_variant_new() {
|
|||||||
return (void*)v;
|
return (void*)v;
|
||||||
}
|
}
|
||||||
catch (std::exception& e) {
|
catch (std::exception& e) {
|
||||||
cerr << "gml: catched variant exception: " << e.what() << endl;
|
gml_error_log_exception("variant: " + string(e.what()));
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
catch (...) {
|
catch (...) {
|
||||||
cerr << "gml: catched variant exception" << endl;
|
gml_error_log_exception("variant");
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -61,11 +62,11 @@ gml_variant gml_variant_new_from_bool(u_int8_t b) {
|
|||||||
return (void*)v;
|
return (void*)v;
|
||||||
}
|
}
|
||||||
catch (std::exception& e) {
|
catch (std::exception& e) {
|
||||||
cerr << "gml: catched variant exception: " << e.what() << endl;
|
gml_error_log_exception("variant: " + string(e.what()));
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
catch (...) {
|
catch (...) {
|
||||||
cerr << "gml: catched variant exception" << endl;
|
gml_error_log_exception("variant");
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -76,11 +77,11 @@ gml_variant gml_variant_new_from_float(float f) {
|
|||||||
return (void*)v;
|
return (void*)v;
|
||||||
}
|
}
|
||||||
catch (std::exception& e) {
|
catch (std::exception& e) {
|
||||||
cerr << "gml: catched variant exception: " << e.what() << endl;
|
gml_error_log_exception("variant: " + string(e.what()));
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
catch (...) {
|
catch (...) {
|
||||||
cerr << "gml: catched variant exception" << endl;
|
gml_error_log_exception("variant");
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -91,11 +92,11 @@ gml_variant gml_variant_new_from_double(double d) {
|
|||||||
return (void*)v;
|
return (void*)v;
|
||||||
}
|
}
|
||||||
catch (std::exception& e) {
|
catch (std::exception& e) {
|
||||||
cerr << "gml: catched variant exception: " << e.what() << endl;
|
gml_error_log_exception("variant: " + string(e.what()));
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
catch (...) {
|
catch (...) {
|
||||||
cerr << "gml: catched variant exception" << endl;
|
gml_error_log_exception("variant");
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -106,11 +107,11 @@ gml_variant gml_variant_new_from_int(int i) {
|
|||||||
return (void*)v;
|
return (void*)v;
|
||||||
}
|
}
|
||||||
catch (std::exception& e) {
|
catch (std::exception& e) {
|
||||||
cerr << "gml: catched variant exception: " << e.what() << endl;
|
gml_error_log_exception("variant: " + string(e.what()));
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
catch (...) {
|
catch (...) {
|
||||||
cerr << "gml: catched variant exception" << endl;
|
gml_error_log_exception("variant");
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -121,11 +122,11 @@ gml_variant gml_variant_new_from_int8(int8_t i) {
|
|||||||
return (void*)v;
|
return (void*)v;
|
||||||
}
|
}
|
||||||
catch (std::exception& e) {
|
catch (std::exception& e) {
|
||||||
cerr << "gml: catched variant exception: " << e.what() << endl;
|
gml_error_log_exception("variant: " + string(e.what()));
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
catch (...) {
|
catch (...) {
|
||||||
cerr << "gml: catched variant exception" << endl;
|
gml_error_log_exception("variant");
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -136,11 +137,11 @@ gml_variant gml_variant_new_from_uint8(u_int8_t i) {
|
|||||||
return (void*)v;
|
return (void*)v;
|
||||||
}
|
}
|
||||||
catch (std::exception& e) {
|
catch (std::exception& e) {
|
||||||
cerr << "gml: catched variant exception: " << e.what() << endl;
|
gml_error_log_exception("variant: " + string(e.what()));
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
catch (...) {
|
catch (...) {
|
||||||
cerr << "gml: catched variant exception" << endl;
|
gml_error_log_exception("variant");
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -151,11 +152,11 @@ gml_variant gml_variant_new_from_int16(int16_t i) {
|
|||||||
return (void*)v;
|
return (void*)v;
|
||||||
}
|
}
|
||||||
catch (std::exception& e) {
|
catch (std::exception& e) {
|
||||||
cerr << "gml: catched variant exception: " << e.what() << endl;
|
gml_error_log_exception("variant: " + string(e.what()));
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
catch (...) {
|
catch (...) {
|
||||||
cerr << "gml: catched variant exception" << endl;
|
gml_error_log_exception("variant");
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -166,11 +167,11 @@ gml_variant gml_variant_new_from_uint16(u_int16_t i) {
|
|||||||
return (void*)v;
|
return (void*)v;
|
||||||
}
|
}
|
||||||
catch (std::exception& e) {
|
catch (std::exception& e) {
|
||||||
cerr << "gml: catched variant exception: " << e.what() << endl;
|
gml_error_log_exception("variant: " + string(e.what()));
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
catch (...) {
|
catch (...) {
|
||||||
cerr << "gml: catched variant exception" << endl;
|
gml_error_log_exception("variant");
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -181,11 +182,11 @@ gml_variant gml_variant_new_from_int32(int32_t i) {
|
|||||||
return (void*)v;
|
return (void*)v;
|
||||||
}
|
}
|
||||||
catch (std::exception& e) {
|
catch (std::exception& e) {
|
||||||
cerr << "gml: catched variant exception: " << e.what() << endl;
|
gml_error_log_exception("variant: " + string(e.what()));
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
catch (...) {
|
catch (...) {
|
||||||
cerr << "gml: catched variant exception" << endl;
|
gml_error_log_exception("variant");
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -196,11 +197,11 @@ gml_variant gml_variant_new_from_uint32(u_int32_t i) {
|
|||||||
return (void*)v;
|
return (void*)v;
|
||||||
}
|
}
|
||||||
catch (std::exception& e) {
|
catch (std::exception& e) {
|
||||||
cerr << "gml: catched variant exception: " << e.what() << endl;
|
gml_error_log_exception("variant: " + string(e.what()));
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
catch (...) {
|
catch (...) {
|
||||||
cerr << "gml: catched variant exception" << endl;
|
gml_error_log_exception("variant");
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -211,11 +212,11 @@ gml_variant gml_variant_new_from_int64(int64_t i) {
|
|||||||
return (void*)v;
|
return (void*)v;
|
||||||
}
|
}
|
||||||
catch (std::exception& e) {
|
catch (std::exception& e) {
|
||||||
cerr << "gml: catched variant exception: " << e.what() << endl;
|
gml_error_log_exception("variant: " + string(e.what()));
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
catch (...) {
|
catch (...) {
|
||||||
cerr << "gml: catched variant exception" << endl;
|
gml_error_log_exception("variant");
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -226,11 +227,11 @@ gml_variant gml_variant_new_from_uint64(u_int64_t i) {
|
|||||||
return (void*)v;
|
return (void*)v;
|
||||||
}
|
}
|
||||||
catch (std::exception& e) {
|
catch (std::exception& e) {
|
||||||
cerr << "gml: catched variant exception: " << e.what() << endl;
|
gml_error_log_exception("variant: " + string(e.what()));
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
catch (...) {
|
catch (...) {
|
||||||
cerr << "gml: catched variant exception" << endl;
|
gml_error_log_exception("variant");
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -241,11 +242,11 @@ gml_variant gml_variant_new_from_qchar(int32_t r) {
|
|||||||
return (void*)v;
|
return (void*)v;
|
||||||
}
|
}
|
||||||
catch (std::exception& e) {
|
catch (std::exception& e) {
|
||||||
cerr << "gml: catched variant exception: " << e.what() << endl;
|
gml_error_log_exception("variant: " + string(e.what()));
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
catch (...) {
|
catch (...) {
|
||||||
cerr << "gml: catched variant exception" << endl;
|
gml_error_log_exception("variant");
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -256,11 +257,11 @@ gml_variant gml_variant_new_from_string(char* s) {
|
|||||||
return (void*)v;
|
return (void*)v;
|
||||||
}
|
}
|
||||||
catch (std::exception& e) {
|
catch (std::exception& e) {
|
||||||
cerr << "gml: catched variant exception: " << e.what() << endl;
|
gml_error_log_exception("variant: " + string(e.what()));
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
catch (...) {
|
catch (...) {
|
||||||
cerr << "gml: catched variant exception" << endl;
|
gml_error_log_exception("variant");
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -271,11 +272,11 @@ gml_variant gml_variant_new_from_bytes(char* b, int size) {
|
|||||||
return (void*)v;
|
return (void*)v;
|
||||||
}
|
}
|
||||||
catch (std::exception& e) {
|
catch (std::exception& e) {
|
||||||
cerr << "gml: catched variant exception: " << e.what() << endl;
|
gml_error_log_exception("variant: " + string(e.what()));
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
catch (...) {
|
catch (...) {
|
||||||
cerr << "gml: catched variant exception" << endl;
|
gml_error_log_exception("variant");
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -32,7 +32,7 @@ import (
|
|||||||
"text/template"
|
"text/template"
|
||||||
)
|
)
|
||||||
|
|
||||||
var qtProTmpl = template.Must(template.New("t").Funcs(tmplFuncMap).Parse(qtProData))
|
var qtProTmpl = template.Must(template.New("t").Parse(qtProData))
|
||||||
|
|
||||||
func prepareQtProject(ctx *Context) (err error) {
|
func prepareQtProject(ctx *Context) (err error) {
|
||||||
// Create or open the config file.
|
// Create or open the config file.
|
||||||
|
|||||||
@ -34,7 +34,7 @@ import (
|
|||||||
"text/template"
|
"text/template"
|
||||||
)
|
)
|
||||||
|
|
||||||
var qmlResTmpl = template.Must(template.New("t").Funcs(tmplFuncMap).Parse(qmlResData))
|
var qmlResTmpl = template.Must(template.New("t").Parse(qmlResData))
|
||||||
|
|
||||||
func prepareResources(ctx *Context) (err error) {
|
func prepareResources(ctx *Context) (err error) {
|
||||||
// Create the resources file.
|
// Create the resources file.
|
||||||
|
|||||||
@ -29,7 +29,6 @@ package main
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"log"
|
"log"
|
||||||
"os"
|
|
||||||
|
|
||||||
"github.com/desertbit/gml"
|
"github.com/desertbit/gml"
|
||||||
)
|
)
|
||||||
@ -45,7 +44,7 @@ func main() {
|
|||||||
log.Fatalln(err)
|
log.Fatalln(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
os.Exit(app.Exec())
|
gml.Exec(app)
|
||||||
}
|
}
|
||||||
|
|
||||||
const qmlData = `
|
const qmlData = `
|
||||||
|
|||||||
@ -30,7 +30,6 @@ package main
|
|||||||
import (
|
import (
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"log"
|
"log"
|
||||||
"os"
|
|
||||||
|
|
||||||
"github.com/desertbit/gml"
|
"github.com/desertbit/gml"
|
||||||
_ "github.com/desertbit/gml/samples/signals_slots/testy"
|
_ "github.com/desertbit/gml/samples/signals_slots/testy"
|
||||||
@ -82,5 +81,5 @@ func main() {
|
|||||||
log.Fatalln(err)
|
log.Fatalln(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
os.Exit(app.Exec())
|
gml.Exec(app)
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user