forked from tiiuae/rclgo
-
Notifications
You must be signed in to change notification settings - Fork 0
/
UInt16.gen.go
146 lines (118 loc) · 4.48 KB
/
UInt16.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/u_int16.h>
*/
import "C"
func init() {
typemap.RegisterMessage("example_interfaces/UInt16", UInt16TypeSupport)
}
// Do not create instances of this type directly. Always use NewUInt16
// function instead.
type UInt16 struct {
Data uint16 `yaml:"data"`// This is an example message of using a primitive datatype, uint16.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.
}
// NewUInt16 creates a new UInt16 with default values.
func NewUInt16() *UInt16 {
self := UInt16{}
self.SetDefaults()
return &self
}
func (t *UInt16) Clone() *UInt16 {
c := &UInt16{}
c.Data = t.Data
return c
}
func (t *UInt16) CloneMsg() types.Message {
return t.Clone()
}
func (t *UInt16) SetDefaults() {
t.Data = 0
}
// CloneUInt16Slice clones src to dst by calling Clone for each element in
// src. Panics if len(dst) < len(src).
func CloneUInt16Slice(dst, src []UInt16) {
for i := range src {
dst[i] = *src[i].Clone()
}
}
// Modifying this variable is undefined behavior.
var UInt16TypeSupport types.MessageTypeSupport = _UInt16TypeSupport{}
type _UInt16TypeSupport struct{}
func (t _UInt16TypeSupport) New() types.Message {
return NewUInt16()
}
func (t _UInt16TypeSupport) PrepareMemory() unsafe.Pointer { //returns *C.example_interfaces__msg__UInt16
return (unsafe.Pointer)(C.example_interfaces__msg__UInt16__create())
}
func (t _UInt16TypeSupport) ReleaseMemory(pointer_to_free unsafe.Pointer) {
C.example_interfaces__msg__UInt16__destroy((*C.example_interfaces__msg__UInt16)(pointer_to_free))
}
func (t _UInt16TypeSupport) AsCStruct(dst unsafe.Pointer, msg types.Message) {
m := msg.(*UInt16)
mem := (*C.example_interfaces__msg__UInt16)(dst)
mem.data = C.uint16_t(m.Data)
}
func (t _UInt16TypeSupport) AsGoStruct(msg types.Message, ros2_message_buffer unsafe.Pointer) {
m := msg.(*UInt16)
mem := (*C.example_interfaces__msg__UInt16)(ros2_message_buffer)
m.Data = uint16(mem.data)
}
func (t _UInt16TypeSupport) TypeSupport() unsafe.Pointer {
return unsafe.Pointer(C.rosidl_typesupport_c__get_message_type_support_handle__example_interfaces__msg__UInt16())
}
type CUInt16 = C.example_interfaces__msg__UInt16
type CUInt16__Sequence = C.example_interfaces__msg__UInt16__Sequence
func UInt16__Sequence_to_Go(goSlice *[]UInt16, cSlice CUInt16__Sequence) {
if cSlice.size == 0 {
return
}
*goSlice = make([]UInt16, int64(cSlice.size))
for i := 0; i < int(cSlice.size); i++ {
cIdx := (*C.example_interfaces__msg__UInt16__Sequence)(unsafe.Pointer(
uintptr(unsafe.Pointer(cSlice.data)) + (C.sizeof_struct_example_interfaces__msg__UInt16 * uintptr(i)),
))
UInt16TypeSupport.AsGoStruct(&(*goSlice)[i], unsafe.Pointer(cIdx))
}
}
func UInt16__Sequence_to_C(cSlice *CUInt16__Sequence, goSlice []UInt16) {
if len(goSlice) == 0 {
return
}
cSlice.data = (*C.example_interfaces__msg__UInt16)(C.malloc((C.size_t)(C.sizeof_struct_example_interfaces__msg__UInt16 * uintptr(len(goSlice)))))
cSlice.capacity = C.size_t(len(goSlice))
cSlice.size = cSlice.capacity
for i, v := range goSlice {
cIdx := (*C.example_interfaces__msg__UInt16)(unsafe.Pointer(
uintptr(unsafe.Pointer(cSlice.data)) + (C.sizeof_struct_example_interfaces__msg__UInt16 * uintptr(i)),
))
UInt16TypeSupport.AsCStruct(unsafe.Pointer(cIdx), &v)
}
}
func UInt16__Array_to_Go(goSlice []UInt16, cSlice []CUInt16) {
for i := 0; i < len(cSlice); i++ {
UInt16TypeSupport.AsGoStruct(&goSlice[i], unsafe.Pointer(&cSlice[i]))
}
}
func UInt16__Array_to_C(cSlice []CUInt16, goSlice []UInt16) {
for i := 0; i < len(goSlice); i++ {
UInt16TypeSupport.AsCStruct(unsafe.Pointer(&cSlice[i]), &goSlice[i])
}
}