forked from zeromq/goczmq
-
Notifications
You must be signed in to change notification settings - Fork 0
/
sock_option.gsl
87 lines (76 loc) · 2.45 KB
/
sock_option.gsl
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
.# This is a code generator built using the iMatix GSL code generation
.# language. See https://github.com/imatix/gsl for details. This script
.# is licensed under MIT/X11.
.#
.output "./sock_option.go"
//go:generate gsl sockopts.xml
package goczmq
/* =========================================================================
zsock_option - get/set 0MQ socket options
****************************************************
* GENERATED SOURCE CODE, DO NOT EDIT!! *
* TO CHANGE THIS, EDIT sockopts.gsl *
* AND RUN gsl -q sockopts.xml *
****************************************************
Copyright (c) the Contributors as noted in the AUTHORS file.
This file is part of goczmq, the high-level go binding for CZMQ:
http://github.com/zeromq/goczmq
This Source Code Form is subject to the terms of the Mozilla Public
License, v. 2.0. If a copy of the MPL was not distributed with this
file, You can obtain one at http://mozilla.org/MPL/2.0/.
=========================================================================
*/
/*
#include "czmq.h"
#include <stdlib.h>
#include <string.h>
*/
import "C"
import (
"unsafe"
)
.for version
.if major = "4"
.for option
.if mode = "rw" | mode = "w"
.if type = "uint64" | type = "int64" | type = "uint32" | type = "int"
// SockSet$(name:pascal) sets the $(name) option for the socket
func SockSet$(name:pascal)(v $(gotype)) SockOption {
return func(s *Sock) {
C.zsock_set_$(name)(unsafe.Pointer(s.zsockT), C.int(v))
}
}
.endif
.if type = "string" | type = "key"
// SockSet$(name:pascal) sets the $(name) option for the socket
func SockSet$(name:pascal)(v $(gotype)) SockOption {
return func(s *Sock) {
cV := C.CString(v)
defer C.free(unsafe.Pointer(cV))
C.zsock_set_$(name)(unsafe.Pointer(s.zsockT), cV)
}
}
.endif
.endif
.if mode = "rw" | mode = "r"
.if type = "uint64" | type = "int64" | type = "uint32" | type = "int"
// $(name:pascal) returns the current value of the socket's $(name) option
func $(name:pascal)(s *Sock) $(gotype) {
val := C.zsock_$(name)(unsafe.Pointer(s.zsockT))
return int(val)
}
.endif
.if type = "string" | type = "key"
// $(name:pascal) returns the current value of the socket's $(name) option
func $(name:pascal)(s *Sock) $(gotype) {
val := C.zsock_$(name)(unsafe.Pointer(s.zsockT))
return C.GoString(val)
}
.endif
.endif
.endfor
.endif
.for source
$(string.trim(.):)
.endfor
.endfor