Commit 0f2165e1 authored by Oscar Campos's avatar Oscar Campos Committed by Oscar Campos
Browse files

fix: fixed signals and removed unused imports

parent 995747d3
......@@ -24,8 +24,6 @@ import (
"os"
"reflect"
"strings"
"gopkg.in/bufio.v1"
)
const (
......@@ -716,9 +714,15 @@ func parseKeyValueExpr(expr *ast.KeyValueExpr) (string, string) {
func parseSignalArgs(composite *ast.CompositeLit) string {
buffer := bufio.NewBuffer(nil)
// buffer := bufio.NewBuffer(nil)
// fileSet := token.NewFileSet()
// printer.Fprint(buffer, fileSet, composite)
// return buffer.String()
buffer := []byte{}
buf := bytes.NewBuffer(buffer)
fileSet := token.NewFileSet()
printer.Fprint(buffer, fileSet, composite)
return buffer.String()
printer.Fprint(buf, fileSet, composite)
return buf.String()
}
......@@ -78,22 +78,7 @@ godot_variant cgo_gateway_property_get_func(godot_object *obj,
return ret;
}
godot_signal_argument **go_godot_signal_argument_build_array(int length) {
godot_signal_argument **arr =
malloc(sizeof(godot_signal_argument *) * length);
return arr;
}
void go_godot_signal_argument_add_element(godot_signal_argument **array,
godot_signal_argument *element,
int index) {
godot_signal_argument copy;
copy.default_value = element->default_value;
copy.hint_string = element->hint_string;
copy.usage = element->usage;
copy.name = element->name;
copy.hint = element->hint;
copy.type = element->type;
array[index] = ©
godot_signal_argument *go_godot_new_signal_argument() {
godot_signal_argument *arg = malloc(sizeof(godot_signal_argument));
return arg;
}
......@@ -394,20 +394,20 @@ func (n *nativeScript) RegisterSignal(name string, signal *Signal) {
signal.base.num_default_args = signal.NumDefaultArgs.getBase()
// Build the arguments
argsArray := C.go_godot_signal_argument_build_array(C.int(signal.NumArgs))
// argsArray := C.go_godot_signal_argument_build_array(C.int(signal.NumArgs))
argsArray := make([]*C.godot_signal_argument, int(signal.NumArgs))
for i, arg := range signal.Args {
var cArg C.godot_signal_argument
cArg.name = *(arg.Name.getBase())
cArg._type = arg.Type.getBase()
cArg.default_value = *(arg.DefaultValue.getBase())
cArg.hint = arg.Hint.getBase()
cArg.hint_string = *(arg.HintString.getBase())
cArg.usage = arg.Usage.getBase()
C.go_godot_signal_argument_add_element(argsArray, (*C.godot_signal_argument)(unsafe.Pointer(&cArg)), C.int(i))
cArg := C.go_godot_new_signal_argument()
(*cArg).name = *(arg.Name.getBase())
(*cArg)._type = arg.Type.getBase()
(*cArg).default_value = *(arg.DefaultValue.getBase())
(*cArg).hint = arg.Hint.getBase()
(*cArg).hint_string = *(arg.HintString.getBase())
(*cArg).usage = arg.Usage.getBase()
argsArray[i] = cArg
}
signal.base.args = *(**C.godot_signal_argument)(unsafe.Pointer(&argsArray))
signal.base.args = argsArray[0]
// Build the default arguments
variantArray := C.go_godot_variant_build_array(C.int(signal.NumDefaultArgs))
......
......@@ -22,7 +22,6 @@ typedef void (*free_func)(void *);
typedef godot_variant (*method)(godot_object *, void *, void *, int, godot_variant **);
typedef void (*set_property_func)(godot_object *, void *, void *, godot_variant *);
typedef godot_variant (*get_property_func)(godot_object *, void *, void *);
godot_signal_argument **go_godot_signal_argument_build_array(int length);
void go_godot_signal_argument_add_element(godot_signal_argument **array,
godot_signal_argument *element, int index);
godot_signal_argument *go_godot_new_signal_argument();
#endif
......@@ -13,3 +13,9 @@ void go_godot_variant_add_element(godot_variant **array, godot_variant *element,
godot_variant copy = *element;
array[index] = ©
}
godot_variant *go_godot_new_variant() {
godot_variant *var = malloc(sizeof(godot_variant));
return var;
}
......@@ -6,5 +6,6 @@
godot_variant **go_godot_variant_build_array(int);
void go_godot_variant_add_element(godot_variant **, godot_variant *, int);
godot_variant *go_godot_new_variant();
#endif
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment