Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
7
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Switch to GitLab Next
Sign in / Register
Toggle navigation
Open sidebar
PimPam Games Studio
gdnative-go
Commits
0f2165e1
Commit
0f2165e1
authored
Oct 10, 2020
by
Oscar Campos
Committed by
Oscar Campos
Oct 11, 2020
Browse files
fix: fixed signals and removed unused imports
parent
995747d3
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
33 additions
and
38 deletions
+33
-38
gdnative/ast.go
gdnative/ast.go
+9
-5
gdnative/nativescript.c
gdnative/nativescript.c
+3
-18
gdnative/nativescript.go
gdnative/nativescript.go
+12
-12
gdnative/nativescript.h
gdnative/nativescript.h
+2
-3
gdnative/variant.c
gdnative/variant.c
+6
-0
gdnative/variant.h
gdnative/variant.h
+1
-0
No files found.
gdnative/ast.go
View file @
0f2165e1
...
...
@@ -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
(
buf
fer
,
fileSet
,
composite
)
return
buf
fer
.
String
()
printer
.
Fprint
(
buf
,
fileSet
,
composite
)
return
buf
.
String
()
}
gdnative/nativescript.c
View file @
0f2165e1
...
...
@@ -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
]
=
&
copy
;
godot_signal_argument
*
go_godot_new_signal_argument
()
{
godot_signal_argument
*
arg
=
malloc
(
sizeof
(
godot_signal_argument
));
return
arg
;
}
gdnative/nativescript.go
View file @
0f2165e1
...
...
@@ -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
))
...
...
gdnative/nativescript.h
View file @
0f2165e1
...
...
@@ -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
gdnative/variant.c
View file @
0f2165e1
...
...
@@ -13,3 +13,9 @@ void go_godot_variant_add_element(godot_variant **array, godot_variant *element,
godot_variant
copy
=
*
element
;
array
[
index
]
=
&
copy
;
}
godot_variant
*
go_godot_new_variant
()
{
godot_variant
*
var
=
malloc
(
sizeof
(
godot_variant
));
return
var
;
}
gdnative/variant.h
View file @
0f2165e1
...
...
@@ -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
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment