-
Notifications
You must be signed in to change notification settings - Fork 11
/
c-shared-utils.go
42 lines (38 loc) · 1.13 KB
/
c-shared-utils.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
package main
/*
#include "c-shared.h"
*/
import "C"
import "github.com/varnamproject/govarnam/govarnam"
func cSymbolToGoSymbol(symbol C.struct_Symbol_t) govarnam.Symbol {
var goSymbol govarnam.Symbol
goSymbol.Identifier = int(symbol.Identifier)
goSymbol.Type = int(symbol.Type)
goSymbol.MatchType = int(symbol.MatchType)
goSymbol.Pattern = C.GoString(symbol.Pattern)
goSymbol.Value1 = C.GoString(symbol.Value1)
goSymbol.Value2 = C.GoString(symbol.Value2)
goSymbol.Value3 = C.GoString(symbol.Value3)
goSymbol.Tag = C.GoString(symbol.Tag)
goSymbol.Weight = int(symbol.Weight)
goSymbol.Priority = int(symbol.Priority)
goSymbol.AcceptCondition = int(symbol.AcceptCondition)
goSymbol.Flags = int(symbol.Flags)
return goSymbol
}
func goSymbolToCSymbol(symbol govarnam.Symbol) *C.struct_Symbol_t {
return C.makeSymbol(
C.int(symbol.Identifier),
C.int(symbol.Type),
C.int(symbol.MatchType),
C.CString(symbol.Pattern),
C.CString(symbol.Value1),
C.CString(symbol.Value2),
C.CString(symbol.Value3),
C.CString(symbol.Tag),
C.int(symbol.Weight),
C.int(symbol.Priority),
C.int(symbol.AcceptCondition),
C.int(symbol.Flags),
)
}