forked from tiiuae/rclgo
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Int8.gen.go
146 lines (118 loc) · 4.35 KB
/
Int8.gen.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
/*
This file is part of rclgo
Copyright © 2021 Technology Innovation Institute, United Arab Emirates
Licensed under the Apache License, Version 2.0 (the "License");
http://www.apache.org/licenses/LICENSE-2.0
*/
/*
THIS FILE IS AUTOGENERATED BY 'rclgo-gen generate'
*/
package example_interfaces_msg
import (
"unsafe"
"github.com/mehmetkillioglu/rclgo/pkg/rclgo/types"
"github.com/mehmetkillioglu/rclgo/pkg/rclgo/typemap"
)
/*
#cgo LDFLAGS: -L/opt/ros/galactic/lib -Wl,-rpath=/opt/ros/galactic/lib -lrcl -lrosidl_runtime_c -lrosidl_typesupport_c -lrcutils -lrmw_implementation
#cgo LDFLAGS: -lexample_interfaces__rosidl_typesupport_c -lexample_interfaces__rosidl_generator_c
#cgo CFLAGS: -I/opt/ros/galactic/include
#include <rosidl_runtime_c/message_type_support_struct.h>
#include <example_interfaces/msg/int8.h>
*/
import "C"
func init() {
typemap.RegisterMessage("example_interfaces/Int8", Int8TypeSupport)
}
// Do not create instances of this type directly. Always use NewInt8
// function instead.
type Int8 struct {
Data int8 `yaml:"data"`// This is an example message of using a primitive datatype, in8.If you want to test with this that's fine, but if you are deployingit into a system you should create a semantically meaningful message type.If you want to embed it in another message, use the primitive data type instead.
}
// NewInt8 creates a new Int8 with default values.
func NewInt8() *Int8 {
self := Int8{}
self.SetDefaults()
return &self
}
func (t *Int8) Clone() *Int8 {
c := &Int8{}
c.Data = t.Data
return c
}
func (t *Int8) CloneMsg() types.Message {
return t.Clone()
}
func (t *Int8) SetDefaults() {
t.Data = 0
}
// CloneInt8Slice clones src to dst by calling Clone for each element in
// src. Panics if len(dst) < len(src).
func CloneInt8Slice(dst, src []Int8) {
for i := range src {
dst[i] = *src[i].Clone()
}
}
// Modifying this variable is undefined behavior.
var Int8TypeSupport types.MessageTypeSupport = _Int8TypeSupport{}
type _Int8TypeSupport struct{}
func (t _Int8TypeSupport) New() types.Message {
return NewInt8()
}
func (t _Int8TypeSupport) PrepareMemory() unsafe.Pointer { //returns *C.example_interfaces__msg__Int8
return (unsafe.Pointer)(C.example_interfaces__msg__Int8__create())
}
func (t _Int8TypeSupport) ReleaseMemory(pointer_to_free unsafe.Pointer) {
C.example_interfaces__msg__Int8__destroy((*C.example_interfaces__msg__Int8)(pointer_to_free))
}
func (t _Int8TypeSupport) AsCStruct(dst unsafe.Pointer, msg types.Message) {
m := msg.(*Int8)
mem := (*C.example_interfaces__msg__Int8)(dst)
mem.data = C.int8_t(m.Data)
}
func (t _Int8TypeSupport) AsGoStruct(msg types.Message, ros2_message_buffer unsafe.Pointer) {
m := msg.(*Int8)
mem := (*C.example_interfaces__msg__Int8)(ros2_message_buffer)
m.Data = int8(mem.data)
}
func (t _Int8TypeSupport) TypeSupport() unsafe.Pointer {
return unsafe.Pointer(C.rosidl_typesupport_c__get_message_type_support_handle__example_interfaces__msg__Int8())
}
type CInt8 = C.example_interfaces__msg__Int8
type CInt8__Sequence = C.example_interfaces__msg__Int8__Sequence
func Int8__Sequence_to_Go(goSlice *[]Int8, cSlice CInt8__Sequence) {
if cSlice.size == 0 {
return
}
*goSlice = make([]Int8, int64(cSlice.size))
for i := 0; i < int(cSlice.size); i++ {
cIdx := (*C.example_interfaces__msg__Int8__Sequence)(unsafe.Pointer(
uintptr(unsafe.Pointer(cSlice.data)) + (C.sizeof_struct_example_interfaces__msg__Int8 * uintptr(i)),
))
Int8TypeSupport.AsGoStruct(&(*goSlice)[i], unsafe.Pointer(cIdx))
}
}
func Int8__Sequence_to_C(cSlice *CInt8__Sequence, goSlice []Int8) {
if len(goSlice) == 0 {
return
}
cSlice.data = (*C.example_interfaces__msg__Int8)(C.malloc((C.size_t)(C.sizeof_struct_example_interfaces__msg__Int8 * uintptr(len(goSlice)))))
cSlice.capacity = C.size_t(len(goSlice))
cSlice.size = cSlice.capacity
for i, v := range goSlice {
cIdx := (*C.example_interfaces__msg__Int8)(unsafe.Pointer(
uintptr(unsafe.Pointer(cSlice.data)) + (C.sizeof_struct_example_interfaces__msg__Int8 * uintptr(i)),
))
Int8TypeSupport.AsCStruct(unsafe.Pointer(cIdx), &v)
}
}
func Int8__Array_to_Go(goSlice []Int8, cSlice []CInt8) {
for i := 0; i < len(cSlice); i++ {
Int8TypeSupport.AsGoStruct(&goSlice[i], unsafe.Pointer(&cSlice[i]))
}
}
func Int8__Array_to_C(cSlice []CInt8, goSlice []Int8) {
for i := 0; i < len(goSlice); i++ {
Int8TypeSupport.AsCStruct(unsafe.Pointer(&cSlice[i]), &goSlice[i])
}
}