-
Notifications
You must be signed in to change notification settings - Fork 0
/
goxtp.swigcxx
103 lines (78 loc) · 2.59 KB
/
goxtp.swigcxx
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
/* Copyright 2011 The Go Authors. All rights reserved.
Use of this source code is governed by a BSD-style
license that can be found in the LICENSE file. */
/* An example of writing a C++ virtual function in Go. */
%module(directors="1") goxtp
%init %{
//printf("Initialization goxtp done.\n");
%}
%include "stdint.i"
%typemap(gotype) (char **ticker, int count) "[]string"
%typemap(in) (char **ticker, int count)
%{
{
int i;
_gostring_* a;
$2 = $input.len;
a = (_gostring_*) $input.array;
$1 = (char **) malloc (($2 + 1) * sizeof (char *));
for (i = 0; i < $2; i++) {
/*Work well*/
_gostring_ *ps = &a[i];
$1[i] = (char*) malloc(ps->n + 1);
memcpy($1[i], ps->p, ps->n);
$1[i][ps->n] = '\0';
}
$1[i] = NULL;
}
%}
%typemap(argout) (char **ticker, int count) "" /* override char *[] default */
%typemap(freearg) (char **ticker, int count)
%{
{
int i;
for (i = 0; i < $2; i++)
{
free ($1[i]);
}
free($1);
}
%}
%typemap(gotype) (int64_t *bid1_qty, int32_t bid1_count) "[]int64"
%typemap(gotype) (int64_t *ask1_qty, int32_t ask1_count) "[]int64"
%typemap(in) (int64_t *bid1_qty, int32_t bid1_count), (int64_t *ask1_qty, int32_t ask1_count) ""
%typemap(directorin) (int64_t *bid1_qty, int32_t bid1_count), (int64_t *ask1_qty, int32_t ask1_count)
%{
{
$input.len = $2;
$input.array = $1;
}
%}
// %typemap(directorout) (int64_t *bid1_qty, int32_t bid_count), (int64_t *ask1_qty, int32_t ask1_count) "/*directorout*/" /* override char *[] default */
%typemap(freearg) (int64_t *bid1_qty, int32_t bid_count), (int64_t *ask1_qty, int32_t ask1_count)
%{
// do nothing
%}
/* Includes the header files in the wrapper code */
%header %{
#include "./api/include/xtp_api_struct_common.h"
#include "./api/include/xtp_api_struct.h"
#include "./api/include/xtp_api_data_type.h"
#include "./api/include/xoms_api_fund_struct.h"
#include "./api/include/xoms_api_struct.h"
#include "./api/include/xquote_api_struct.h"
#include "./api/include/xtp_quote_api.h"
#include "./api/include/xtp_trader_api.h"
%}
/* Parse the header files to generate wrappers */
%include "std_string.i"
%feature("director") XTP::API::QuoteSpi;
%feature("director") XTP::API::TraderSpi;
%include "./api/include/xtp_api_struct_common.h"
%include "./api/include/xtp_api_struct.h"
%include "./api/include/xoms_api_fund_struct.h"
%include "./api/include/xoms_api_struct.h"
%include "./api/include/xquote_api_struct.h"
%include "./api/include/xtp_api_data_type.h"
%include "./api/include/xtp_quote_api.h"
%include "./api/include/xtp_trader_api.h"