-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Map C++ [u]intXX_t types to Go [u]intXX types
This required reimplementing HostToNetXX/NetToHostXX functions as helpers instead of simply exposing templated version under custom names, because apparently typemap intercept does not work on template argument types.
- Loading branch information
Eugene Kim
committed
Dec 7, 2018
1 parent
d5e3d01
commit cbee330
Showing
3 changed files
with
40 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,26 @@ | ||
%{ | ||
#include <stdint.h> | ||
#include <cstdint> | ||
%} | ||
|
||
typedef unsigned char uint8_t; | ||
typedef signed char int8_t; | ||
typedef unsigned short uint16_t; | ||
typedef signed short int16_t; | ||
typedef unsigned int uint32_t; | ||
typedef signed int int32_t; | ||
typedef unsigned long uint64_t; | ||
typedef signed long int64_t; | ||
%include "stdint.i" | ||
|
||
namespace std { | ||
using uint8_t = ::uint8_t; | ||
using int8_t = ::int8_t; | ||
using uint16_t = ::uint16_t; | ||
using int16_t = ::int16_t; | ||
using uint32_t = ::uint32_t; | ||
using int32_t = ::int32_t; | ||
using uint64_t = ::uint64_t; | ||
using int64_t = ::int64_t; | ||
} | ||
|
||
%typemap(gotype) uint8_t, uint8_t const, uint8_t const &, std::uint8_t, std::uint8_t const, std::uint8_t const & "uint8" | ||
%typemap(gotype) int8_t, int8_t const, int8_t const &, std::int8_t, std::int8_t const, std::int8_t const & "int8" | ||
%typemap(gotype) uint16_t, uint16_t const, uint16_t const &, std::uint16_t, std::uint16_t const, std::uint16_t const & "uint16" | ||
%typemap(gotype) int16_t, int16_t const, int16_t const &, std::int16_t, std::int16_t const, std::int16_t const & "int16" | ||
%typemap(gotype) uint32_t, uint32_t const, uint32_t const &, std::uint32_t, std::uint32_t const, std::uint32_t const & "uint32" | ||
%typemap(gotype) int32_t, int32_t const, int32_t const &, std::int32_t, std::int32_t const, std::int32_t const & "int32" | ||
%typemap(gotype) uint64_t, uint64_t const, uint64_t const &, std::uint64_t, std::uint64_t const, std::uint64_t const & "uint64" | ||
%typemap(gotype) int64_t, int64_t const, int64_t const &, std::int64_t, std::int64_t const, std::int64_t const & "int64" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters