nativescript.c 3.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. #include <gdnative/gdnative.h>
  2. #include <gdnative_api_struct.gen.h>
  3. #include <nativescript/godot_nativescript.h>
  4. #include <stdio.h>
  5. #include <stdlib.h>
  6. // This is a gateway function for the create method.
  7. void *cgo_gateway_create_func(godot_object *obj, void *method_data) {
  8. // printf("CGO: C.go_create_func_cgo()\n");
  9. void *ret;
  10. void *go_create_func(godot_object *, void *);
  11. ret = go_create_func(obj, method_data); // Execute our Go function.
  12. return ret;
  13. }
  14. // This is a gateway function for the destroy method.
  15. void *cgo_gateway_destroy_func(godot_object *obj, void *method_data,
  16. void *user_data) {
  17. // printf("CGO: C.go_destroy_func_cgo()\n");
  18. void *ret;
  19. void *go_destroy_func(godot_object *, void *, void *);
  20. ret = go_destroy_func(obj, method_data,
  21. user_data); // Execute our Go function.
  22. return ret;
  23. }
  24. // This is a gateway function for the free method.
  25. void *cgo_gateway_free_func(void *method_data) {
  26. // printf("CGO: C.go_free_func_cgo()\n");
  27. void *ret;
  28. void *go_free_func(void *);
  29. ret = go_free_func(method_data); // Execute our Go function.
  30. return ret;
  31. }
  32. // This is a gateway function for the method
  33. // GDCALLINGCONV godot_variant (*method)(godot_object *, void *, void *, int,
  34. // godot_variant **);
  35. // func go_method_func(godotObject *C.godot_object, methodData unsafe.Pointer,
  36. // userData unsafe.Pointer, numArgs C.uint, args **C.godot_variant) {
  37. godot_variant cgo_gateway_method_func(godot_object *obj, void *method_data,
  38. void *user_data, int num_args,
  39. godot_variant **args) {
  40. // printf("CGO: C.go_method_func_cgo()\n");
  41. // printf("CGO: Number of arguments: %d\n", num_args);
  42. godot_variant ret;
  43. godot_variant go_method_func(godot_object *, void *, void *, int,
  44. godot_variant **);
  45. ret = go_method_func(obj, method_data, user_data, num_args,
  46. args); // Execute our Go function.
  47. return ret;
  48. }
  49. // This is a gateway function for the set property method.
  50. // GDCALLINGCONV void (*set_func)(godot_object *, void *, void *, godot_variant
  51. // *);
  52. void cgo_gateway_property_set_func(godot_object *obj, void *method_data,
  53. void *user_data, godot_variant *property) {
  54. // printf("CGO: C.go_set_property_func()\n");
  55. void go_set_property_func(godot_object *, void *, void *,
  56. godot_variant *);
  57. go_set_property_func(obj, method_data, user_data,
  58. property); // Execute our Go function.
  59. }
  60. // This is a gateway function for the get property method.
  61. // GDCALLINGCONV godot_variant (*get_func)(godot_object *, void *, void *);
  62. godot_variant cgo_gateway_property_get_func(godot_object *obj,
  63. void *method_data,
  64. void *user_data) {
  65. // printf("CGO: C.go_get_property_func()\n");
  66. godot_variant ret;
  67. godot_variant go_get_property_func(godot_object *, void *, void *);
  68. ret = go_get_property_func(obj, method_data,
  69. user_data); // Execute our Go function.
  70. return ret;
  71. }
  72. godot_signal_argument *go_godot_new_signal_argument() {
  73. godot_signal_argument *arg = malloc(sizeof(godot_signal_argument));
  74. return arg;
  75. }