diff options
author | Hadriel Kaplan <hadrielk@yahoo.com> | 2014-03-23 11:01:12 -0400 |
---|---|---|
committer | Anders Broman <a.broman58@gmail.com> | 2014-03-25 05:30:11 +0000 |
commit | de441241ef16262fa8ba1c5fbd77509a1ee86c67 (patch) | |
tree | dd71bffb6e8728958fb3dee0e9da6ea5e05a2397 /epan/wslua/wslua_int64.c | |
parent | e4756ccacf47234a766ab5e10d17bd9c5203061d (diff) | |
download | wireshark-de441241ef16262fa8ba1c5fbd77509a1ee86c67.tar.gz |
Enhance Lua API doc generator and add more API info
This enhances the Lua API doc generator Perl script to handle
meta-information in description comments, such as bold, italics,
raw code, version info, etc.
The supported markup and codes are documented in make-wsluarm.pl.
It's not beautiful Perl code (I don't know Perl), and I'd rather
do it using Lua, but I think keeping it Perl makes more sense in
the long run.
Change-Id: I477b3ebe770075dcea9ec52708e2d6fb5758d2f4
Reviewed-on: https://code.wireshark.org/review/802
Reviewed-by: Hadriel Kaplan <hadrielk@yahoo.com>
Reviewed-by: Anders Broman <a.broman58@gmail.com>
Diffstat (limited to 'epan/wslua/wslua_int64.c')
-rw-r--r-- | epan/wslua/wslua_int64.c | 494 |
1 files changed, 336 insertions, 158 deletions
diff --git a/epan/wslua/wslua_int64.c b/epan/wslua/wslua_int64.c index d5d5281e7c..ace9280659 100644 --- a/epan/wslua/wslua_int64.c +++ b/epan/wslua/wslua_int64.c @@ -41,18 +41,23 @@ either expressed or implied, of the FreeBSD Project. #include "wslua.h" -/* WSLUA_MODULE Int64 Handling 64-bit Integers */ +/* WSLUA_MODULE Int64 Handling 64-bit Integers + + Lua uses one single number representation which can be chosen at compile time and since + it is often set to IEEE 754 double precision floating point, one cannot store a 64 bit integer + with full precision. + + For details, see [[http://wiki.wireshark.org/LuaAPI/Int64]]. + */ #define LUATYPE64_STRING_SIZE 21 /* string to hold 18446744073709551615 */ WSLUA_CLASS_DEFINE_BASE(Int64,NOP,NOP,0); /* - Int64 represents a 64 bit signed integer. - Lua uses one single number representation which can be chosen at compile time and since - it is often set to IEEE 754 double precision floating point, we cannot store a 64 bit integer - with full precision. - For details, see: http://wiki.wireshark.org/LuaAPI/Int64 + `Int64` represents a 64 bit signed integer. + + For details, see [[http://wiki.wireshark.org/LuaAPI/Int64]]. */ /* A checkInt64 but that also auto-converts numbers, strings, and UINT64 to a gint64 */ @@ -77,7 +82,7 @@ static gint64 getInt64(lua_State *L, int i) } -/* Encodes Int64 userdata into Lua string struct with given endianess */ +/* Encodes Int64 userdata into Lua string struct with given endianness */ void Int64_pack(lua_State* L, luaL_Buffer *b, gint idx, gboolean asLittleEndian) { gint64 value = checkInt64(L,idx); gint8 buff[sizeof(gint64)]; @@ -100,8 +105,12 @@ void Int64_pack(lua_State* L, luaL_Buffer *b, gint idx, gboolean asLittleEndian) } WSLUA_METHOD Int64_encode(lua_State* L) { - /* Encodes the Int64 number into an 8-byte Lua string, using given endianess */ -#define WSLUA_OPTARG_Int64_encode_ENDIAN 2 /* If set to true then little-endian is used, if false then big-endian; if missing/nil, native host endian */ + /* Encodes the `Int64` number into an 8-byte Lua string, using given endianness. + @since 1.11.3 + */ +#define WSLUA_OPTARG_Int64_encode_ENDIAN 2 /* If set to true then little-endian is used, + if false then big-endian; if missing/nil, + native host endian. */ luaL_Buffer b; gboolean asLittleEndian = (G_BYTE_ORDER == G_LITTLE_ENDIAN)? TRUE : FALSE; @@ -115,10 +124,10 @@ WSLUA_METHOD Int64_encode(lua_State* L) { Int64_pack(L, &b, 1, asLittleEndian); luaL_pushresult(&b); - WSLUA_RETURN(1); /* The Lua string */ + WSLUA_RETURN(1); /* The Lua string. */ } -/* Decodes from string buffer struct into Int64 userdata, with given endianess */ +/* Decodes from string buffer struct into Int64 userdata, with given endianness */ int Int64_unpack(lua_State* L, const gchar *buff, gboolean asLittleEndian) { gint64 value = 0; gint i; @@ -141,9 +150,13 @@ int Int64_unpack(lua_State* L, const gchar *buff, gboolean asLittleEndian) { } WSLUA_CONSTRUCTOR Int64_decode(lua_State* L) { - /* Decodes an 8-byte Lua string, using given endianess, into a new Int64 object */ -#define WSLUA_ARG_Int64_decode_STRING 1 /* The Lua string containing a binary 64-bit integer */ -#define WSLUA_OPTARG_Int64_decode_ENDIAN 2 /* If set to true then little-endian is used, if false then big-endian; if missing/nil, native host endian */ + /* Decodes an 8-byte Lua string, using given endianness, into a new `Int64` object. + @since 1.11.3 + */ +#define WSLUA_ARG_Int64_decode_STRING 1 /* The Lua string containing a binary 64-bit integer. */ +#define WSLUA_OPTARG_Int64_decode_ENDIAN 2 /* If set to true then little-endian is used, + if false then big-endian; if missing/nil, native + host endian. */ gboolean asLittleEndian = (G_BYTE_ORDER == G_LITTLE_ENDIAN)? TRUE : FALSE; size_t len = 0; const gchar *s = luaL_checklstring(L, WSLUA_ARG_Int64_decode_STRING, &len); @@ -159,19 +172,27 @@ WSLUA_CONSTRUCTOR Int64_decode(lua_State* L) { lua_pushnil(L); } - WSLUA_RETURN(1); /* The Int64 object created, or nil on failure */ + WSLUA_RETURN(1); /* The `Int64` object created, or nil on failure. */ } -WSLUA_CONSTRUCTOR Int64_new(lua_State* L) { /* Creates a Int64 Object */ -#define WSLUA_OPTARG_Int64_new_VALUE 1 /* A number, UInt64, Int64, or string of ascii digits to assign the value of the new Int64 (default=0) */ -#define WSLUA_OPTARG_Int64_new_HIGHVALUE 2 /* If this is a number and the first argument was a number, then the first will be treated as a lower 32-bits, and this is the high-order 32 bit number */ +WSLUA_CONSTRUCTOR Int64_new(lua_State* L) { + /* Creates a `Int64` Object. + @since 1.11.3 + */ +#define WSLUA_OPTARG_Int64_new_VALUE 1 /* A number, `UInt64`, `Int64`, or string of ASCII digits + to assign the value of the new `Int64` (default=0). */ +#define WSLUA_OPTARG_Int64_new_HIGHVALUE 2 /* If this is a number and the first argument was + a number, then the first will be treated as a + lower 32-bits, and this is the high-order 32 + bit number. */ gint64 value = 0; if (lua_gettop(L) >= 1) { switch(lua_type(L, WSLUA_OPTARG_Int64_new_VALUE)) { case LUA_TNUMBER: value = wslua_togint64(L, WSLUA_OPTARG_Int64_new_VALUE); - if (lua_gettop(L) == 2 && lua_type(L, WSLUA_OPTARG_Int64_new_HIGHVALUE) == LUA_TNUMBER) { + if (lua_gettop(L) == 2 && + lua_type(L, WSLUA_OPTARG_Int64_new_HIGHVALUE) == LUA_TNUMBER) { gint64 h = wslua_togint64(L, WSLUA_OPTARG_Int64_new_HIGHVALUE); value &= G_GUINT64_CONSTANT(0x00000000FFFFFFFF); h <<= 32; h &= G_GUINT64_CONSTANT(0xFFFFFFFF00000000); @@ -190,33 +211,47 @@ WSLUA_CONSTRUCTOR Int64_new(lua_State* L) { /* Creates a Int64 Object */ pushInt64(L,value); - WSLUA_RETURN(1); /* The new Int64 object. */ + WSLUA_RETURN(1); /* The new `Int64` object. */ } -WSLUA_METAMETHOD Int64__call(lua_State* L) { /* Creates a Int64 Object */ +WSLUA_METAMETHOD Int64__call(lua_State* L) { + /* Creates a `Int64` Object. + @since 1.11.3 + */ lua_remove(L,1); /* remove the table */ - WSLUA_RETURN(Int64_new(L)); /* The new Int64 object. */ + WSLUA_RETURN(Int64_new(L)); /* The new `Int64` object. */ } -WSLUA_CONSTRUCTOR Int64_max(lua_State* L) { /* Gets the max possible value */ +WSLUA_CONSTRUCTOR Int64_max(lua_State* L) { + /* Gets the max possible value. + @since 1.11.3 + */ pushInt64(L, G_MAXINT64); - WSLUA_RETURN(1); /* The new Int64 object of the max value. */ + WSLUA_RETURN(1); /* The new `Int64` object of the max value. */ } -WSLUA_CONSTRUCTOR Int64_min(lua_State* L) { /* Gets the min possible value */ +WSLUA_CONSTRUCTOR Int64_min(lua_State* L) { + /* Gets the min possible value. + @since 1.11.3 + */ pushInt64(L, G_MININT64); - WSLUA_RETURN(1); /* The new Int64 object of the min value. */ + WSLUA_RETURN(1); /* The new `Int64` object of the min value. */ } WSLUA_METHOD Int64_tonumber(lua_State* L) { - /* Returns a Lua number of the Int64 value - this may lose precision. */ + /* Returns a Lua number of the `Int64` value - this may lose precision. + @since 1.11.3 + */ lua_pushnumber(L, (lua_Number)(checkInt64(L,1))); - WSLUA_RETURN(1); /* The Lua number */ + WSLUA_RETURN(1); /* The Lua number. */ } -WSLUA_CONSTRUCTOR Int64_fromhex(lua_State* L) { /* Creates an Int64 object from the given hex string */ -#define WSLUA_ARG_Int64_fromhex_HEX 1 /* The hex-ascii Lua string */ +WSLUA_CONSTRUCTOR Int64_fromhex(lua_State* L) { + /* Creates an `Int64` object from the given hex string. + @since 1.11.3 + */ +#define WSLUA_ARG_Int64_fromhex_HEX 1 /* The hex-ascii Lua string. */ guint64 result = 0; size_t len = 0; const gchar *s = luaL_checklstring(L,WSLUA_ARG_Int64_fromhex_HEX,&len); @@ -225,12 +260,15 @@ WSLUA_CONSTRUCTOR Int64_fromhex(lua_State* L) { /* Creates an Int64 object from sscanf(s, "%" G_GINT64_MODIFIER "x", &result); } pushInt64(L,(gint64)result); - WSLUA_RETURN(1); /* The new Int64 object. */ + WSLUA_RETURN(1); /* The new `Int64` object. */ } WSLUA_METHOD Int64_tohex(lua_State* L) { - /* Returns a hex string of the Int64 value. */ -#define WSLUA_OPTARG_Int64_new_NUMBYTES 2 /* The number of hex-chars/nibbles to generate, negative means uppercase (default=16) */ + /* Returns a hex string of the `Int64` value. + @since 1.11.3 + */ +#define WSLUA_OPTARG_Int64_new_NUMBYTES 2 /* The number of hex-chars/nibbles to generate, + negative means uppercase (default=16). */ gint64 b = getInt64(L,1); gint n = luaL_optint(L, WSLUA_OPTARG_Int64_new_NUMBYTES, 16); const gchar *hexdigits = "0123456789abcdef"; @@ -240,11 +278,14 @@ WSLUA_METHOD Int64_tohex(lua_State* L) { if (n > 16) n = 16; for (i = n-1; i >= 0; --i) { buf[i] = hexdigits[b & 15]; b >>= 4; } lua_pushlstring(L, buf, (size_t)n); - WSLUA_RETURN(1); /* The string hex */ + WSLUA_RETURN(1); /* The string hex. */ } WSLUA_METHOD Int64_higher(lua_State* L) { - /* Returns a Lua number of the higher 32-bits of the Int64 value. (negative Int64 will return a negative Lua number) */ + /* Returns a Lua number of the higher 32-bits of the `Int64` value. (negative `Int64` + will return a negative Lua number). + @since 1.11.3 + */ gint64 num = getInt64(L,1); gint64 b = num; lua_Number n = 0; @@ -254,32 +295,36 @@ WSLUA_METHOD Int64_higher(lua_State* L) { n = (lua_Number)(guint32)(b & G_GUINT64_CONSTANT(0x00000000FFFFFFFFF)); if (num < 0) n = -n; lua_pushnumber(L,n); - WSLUA_RETURN(1); /* The Lua number */ + WSLUA_RETURN(1); /* The Lua number. */ } WSLUA_METHOD Int64_lower(lua_State* L) { - /* Returns a Lua number of the lower 32-bits of the Int64 value. (always positive) */ + /* Returns a Lua number of the lower 32-bits of the `Int64` value. (always positive). + @since 1.11.3 + */ gint64 b = getInt64(L,1); if (b < 0) b = -b; /* masking/shifting negative int64 isn't working on some platforms */ lua_pushnumber(L,(guint32)(b & G_GUINT64_CONSTANT(0x00000000FFFFFFFFF))); - WSLUA_RETURN(1); /* The Lua number */ + WSLUA_RETURN(1); /* The Lua number. */ } WSLUA_METAMETHOD Int64__tostring(lua_State* L) { - /* Converts the Int64 into a string of decimal digits */ + /* Converts the `Int64` into a string of decimal digits. */ gint64 num = getInt64(L,1); gchar s[LUATYPE64_STRING_SIZE]; if (g_snprintf(s, LUATYPE64_STRING_SIZE, "%" G_GINT64_MODIFIER "d", num) < 0) { return luaL_error(L, "Error writing Int64 to a string"); } lua_pushstring(L,s); - WSLUA_RETURN(1); /* The Lua string */ + WSLUA_RETURN(1); /* The Lua string. */ } WSLUA_METAMETHOD Int64__unm(lua_State* L) { - /* Returns the negative of the Int64, in a new Int64 */ + /* Returns the negative of the `Int64`, in a new `Int64`. + @since 1.11.3 + */ pushInt64(L,-(getInt64(L,1))); - WSLUA_RETURN(1); /* The new Int64 */ + WSLUA_RETURN(1); /* The new `Int64`. */ } #define WSLUA_MATH_OP_FUNC(obj,op) \ @@ -290,46 +335,59 @@ WSLUA_METAMETHOD Int64__unm(lua_State* L) { return 1 WSLUA_METAMETHOD Int64__add(lua_State* L) { - /* Adds two Int64 together and returns a new one (this may wrap the value) */ + /* Adds two `Int64` together and returns a new one (this may wrap the value). + @since 1.11.3 + */ WSLUA_MATH_OP_FUNC(Int64,+); } WSLUA_METAMETHOD Int64__sub(lua_State* L) { - /* Subtracts two Int64 and returns a new one (this may wrap the value) */ + /* Subtracts two `Int64` and returns a new one (this may wrap the value). + @since 1.11.3 + */ WSLUA_MATH_OP_FUNC(Int64,-); } WSLUA_METAMETHOD Int64__mul(lua_State* L) { - /* Multiplies two Int64 and returns a new one (this may truncate the value) */ + /* Multiplies two `Int64` and returns a new one (this may truncate the value). + @since 1.11.3 + */ WSLUA_MATH_OP_FUNC(Int64,*); } WSLUA_METAMETHOD Int64__div(lua_State* L) { - /* Divides two Int64 and returns a new one (integer divide, no remainder). - Trying to divide by zero results in a Lua error. */ + /* Divides two `Int64` and returns a new one (integer divide, no remainder). + Trying to divide by zero results in a Lua error. + @since 1.11.3 + */ Int64 num1 = getInt64(L,1); Int64 num2 = getInt64(L,2); if (num2 == 0) { return luaL_error(L, "Trying to divide Int64 by zero"); } pushInt64(L, num1 / num2); - WSLUA_RETURN(1); /* The Int64 object */ + WSLUA_RETURN(1); /* The `Int64` object. */ } WSLUA_METAMETHOD Int64__mod(lua_State* L) { - /* Divides two Int64 and returns a new one of the remainder. - Trying to modulo by zero results in a Lua error. */ + /* Divides two `Int64` and returns a new one of the remainder. + Trying to modulo by zero results in a Lua error. + @since 1.11.3 + */ Int64 num1 = getInt64(L,1); Int64 num2 = getInt64(L,2); if (num2 == 0) { return luaL_error(L, "Trying to modulo Int64 by zero"); } pushInt64(L, num1 % num2); - WSLUA_RETURN(1); /* The Int64 object */ + WSLUA_RETURN(1); /* The `Int64` object. */ } WSLUA_METAMETHOD Int64__pow(lua_State* L) { - /* The first Int64 is taken to the power of the second Int64, returning a new one (this may truncate the value) */ + /* The first `Int64` is taken to the power of the second `Int64`, returning a new + one (this may truncate the value). + @since 1.11.3 + */ gint64 num1 = getInt64(L,1); gint64 num2 = getInt64(L,2); gint64 result; @@ -343,7 +401,7 @@ WSLUA_METAMETHOD Int64__pow(lua_State* L) { } } pushInt64(L,result); - WSLUA_RETURN(1); /* The Int64 object */ + WSLUA_RETURN(1); /* The `Int64` object. */ } #define WSLUA_COMP_OP_FUNC(obj,op) \ @@ -353,24 +411,32 @@ WSLUA_METAMETHOD Int64__pow(lua_State* L) { return 1 WSLUA_METAMETHOD Int64__eq(lua_State* L) { - /* Returns true if both Int64 are equal */ + /* Returns true if both `Int64` are equal. + @since 1.11.3 + */ WSLUA_COMP_OP_FUNC(Int64,==); } WSLUA_METAMETHOD Int64__lt(lua_State* L) { - /* Returns true if first Int64 < second */ + /* Returns true if first `Int64` < second. + @since 1.11.3 + */ WSLUA_COMP_OP_FUNC(Int64,<); } WSLUA_METAMETHOD Int64__le(lua_State* L) { - /* Returns true if first Int64 <= second */ + /* Returns true if first `Int64` <= second. + @since 1.11.3 + */ WSLUA_COMP_OP_FUNC(Int64,<=); } WSLUA_METHOD Int64_bnot(lua_State* L) { - /* Returns a Int64 of the bitwise 'not' operation. */ + /* Returns a `Int64` of the bitwise 'not' operation. + @since 1.11.3 + */ pushInt64(L,~(getInt64(L,1))); - WSLUA_RETURN(1); /* The Int64 object */ + WSLUA_RETURN(1); /* The `Int64` object. */ } #define WSLUA_BIT_OP_FUNC(obj,op) \ @@ -383,70 +449,97 @@ WSLUA_METHOD Int64_bnot(lua_State* L) { return 1 WSLUA_METHOD Int64_band(lua_State* L) { - /* Returns a Int64 of the bitwise 'and' operation, with the given number/Int64/UInt64. Note that multiple arguments are allowed. */ + /* Returns a `Int64` of the bitwise 'and' operation, with the given number/`Int64`/`UInt64`. + Note that multiple arguments are allowed. + @since 1.11.3 + */ WSLUA_BIT_OP_FUNC(Int64,&=); - WSLUA_RETURN(1); /* The Int64 object */ + WSLUA_RETURN(1); /* The `Int64` object. */ } WSLUA_METHOD Int64_bor(lua_State* L) { - /* Returns a Int64 of the bitwise 'or' operation, with the given number/Int64/UInt64. Note that multiple arguments are allowed. */ + /* Returns a `Int64` of the bitwise 'or' operation, with the given number/`Int64`/`UInt64`. + Note that multiple arguments are allowed. + @since 1.11.3 + */ WSLUA_BIT_OP_FUNC(Int64,|=); - WSLUA_RETURN(1); /* The Int64 object */ + WSLUA_RETURN(1); /* The `Int64` object. */ } WSLUA_METHOD Int64_bxor(lua_State* L) { - /* Returns a Int64 of the bitwise 'xor' operation, with the given number/Int64/UInt64. Note that multiple arguments are allowed. */ + /* Returns a `Int64` of the bitwise 'xor' operation, with the given number/`Int64`/`UInt64`. + Note that multiple arguments are allowed. + @since 1.11.3 + */ WSLUA_BIT_OP_FUNC(Int64,^=); - WSLUA_RETURN(1); /* The Int64 object */ + WSLUA_RETURN(1); /* The `Int64` object. */ } WSLUA_METHOD Int64_lshift(lua_State* L) { - /* Returns a Int64 of the bitwise logical left-shift operation, by the given number of bits. */ -#define WSLUA_ARG_Int64_lshift_NUMBITS 2 /* The number of bits to left-shift by */ + /* Returns a `Int64` of the bitwise logical left-shift operation, by the given + number of bits. + @since 1.11.3 + */ +#define WSLUA_ARG_Int64_lshift_NUMBITS 2 /* The number of bits to left-shift by. */ guint64 b = (guint64) getInt64(L,1); guint32 n = wslua_checkguint32(L,WSLUA_ARG_Int64_lshift_NUMBITS); pushInt64(L,(gint64)(b << n)); - WSLUA_RETURN(1); /* The Int64 object */ + WSLUA_RETURN(1); /* The `Int64` object. */ } WSLUA_METHOD Int64_rshift(lua_State* L) { - /* Returns a Int64 of the bitwise logical right-shift operation, by the given number of bits. */ -#define WSLUA_ARG_Int64_rshift_NUMBITS 2 /* The number of bits to right-shift by */ + /* Returns a `Int64` of the bitwise logical right-shift operation, by the + given number of bits. + @since 1.11.3 + */ +#define WSLUA_ARG_Int64_rshift_NUMBITS 2 /* The number of bits to right-shift by. */ guint64 b = (guint64) getInt64(L,1); guint32 n = wslua_checkguint32(L,WSLUA_ARG_Int64_rshift_NUMBITS); pushInt64(L,(gint64)(b >> n)); - WSLUA_RETURN(1); /* The Int64 object */ + WSLUA_RETURN(1); /* The `Int64` object. */ } WSLUA_METHOD Int64_arshift(lua_State* L) { - /* Returns a Int64 of the bitwise arithmetic right-shift operation, by the given number of bits. */ -#define WSLUA_ARG_Int64_arshift_NUMBITS 2 /* The number of bits to right-shift by */ + /* Returns a `Int64` of the bitwise arithmetic right-shift operation, by the + given number of bits. + @since 1.11.3 + */ +#define WSLUA_ARG_Int64_arshift_NUMBITS 2 /* The number of bits to right-shift by. */ gint64 b = getInt64(L,1); gint32 n = wslua_checkgint32(L,WSLUA_ARG_Int64_arshift_NUMBITS); pushInt64(L,(b >> n)); - WSLUA_RETURN(1); /* The Int64 object */ + WSLUA_RETURN(1); /* The `Int64` object. */ } WSLUA_METHOD Int64_rol(lua_State* L) { - /* Returns a Int64 of the bitwise left rotation operation, by the given number of bits (up to 63). */ -#define WSLUA_ARG_Int64_rol_NUMBITS 2 /* The number of bits to roll left by */ + /* Returns a `Int64` of the bitwise left rotation operation, by the given number of + bits (up to 63). + @since 1.11.3 + */ +#define WSLUA_ARG_Int64_rol_NUMBITS 2 /* The number of bits to roll left by. */ guint64 b = (guint64) getInt64(L,1); guint32 n = wslua_checkguint32(L,WSLUA_ARG_Int64_rol_NUMBITS); pushInt64(L,(gint64)((b << n) | (b >> (64-n)))); - WSLUA_RETURN(1); /* The Int64 object */ + WSLUA_RETURN(1); /* The `Int64` object. */ } WSLUA_METHOD Int64_ror(lua_State* L) { - /* Returns a Int64 of the bitwise right rotation operation, by the given number of bits (up to 63). */ -#define WSLUA_ARG_Int64_ror_NUMBITS 2 /* The number of bits to roll right by */ + /* Returns a `Int64` of the bitwise right rotation operation, by the given number of + bits (up to 63). + @since 1.11.3 + */ +#define WSLUA_ARG_Int64_ror_NUMBITS 2 /* The number of bits to roll right by. */ guint64 b = (guint64) getInt64(L,1); guint32 n = wslua_checkguint32(L,WSLUA_ARG_Int64_ror_NUMBITS); pushInt64(L,(gint64)((b << (64-n)) | (b >> n))); - WSLUA_RETURN(1); /* The Int64 object */ + WSLUA_RETURN(1); /* The `Int64` object. */ } WSLUA_METHOD Int64_bswap(lua_State* L) { - /* Returns a Int64 of the bytes swapped. This can be used to convert little-endian 64 bit numbers to big-endian 64 bit numbers or vice versa. */ + /* Returns a `Int64` of the bytes swapped. This can be used to convert little-endian + 64-bit numbers to big-endian 64 bit numbers or vice versa. + @since 1.11.3 + */ guint64 b = (guint64) getInt64(L,1); guint64 result = 0; size_t i; @@ -456,10 +549,10 @@ WSLUA_METHOD Int64_bswap(lua_State* L) { b >>= 8; } pushInt64(L,(gint64)result); - WSLUA_RETURN(1); /* The Int64 object */ + WSLUA_RETURN(1); /* The `Int64` object. */ } -/* Gets registered as metamethod automatically by WSLUA_REGISTER_CLASS/META */ +/* Gets registered as metamethod automatically by WSLUA_REGISTER_CLASS/META. */ static int Int64__gc(lua_State* L _U_) { return 0; } @@ -513,10 +606,12 @@ LUALIB_API int Int64_register(lua_State* L) { WSLUA_CLASS_DEFINE_BASE(UInt64,NOP,NOP,0); - /* UInt64 represents a 64 bit unsigned integer, similar to Int64. - For details, see: http://wiki.wireshark.org/LuaAPI/Int64 */ +/* `UInt64` represents a 64 bit unsigned integer, similar to `Int64`. + + For details, see: http://wiki.wireshark.org/LuaAPI/`Int64`. +*/ -/* A checkUInt64 but that also auto-converts numbers, strings, and Int64 to a guint64 */ +/* A checkUInt64 but that also auto-converts numbers, strings, and `Int64` to a guint64. */ static guint64 getUInt64(lua_State *L, int i) { gchar *end = NULL; @@ -537,7 +632,7 @@ static guint64 getUInt64(lua_State *L, int i) } } -/* Encodes UInt64 userdata into Lua string struct with given endianess */ +/* Encodes `UInt64` userdata into Lua string struct with given endianness */ void UInt64_pack(lua_State* L, luaL_Buffer *b, gint idx, gboolean asLittleEndian) { guint64 value = checkUInt64(L,idx); gint8 buff[sizeof(guint64)]; @@ -560,8 +655,12 @@ void UInt64_pack(lua_State* L, luaL_Buffer *b, gint idx, gboolean asLittleEndian } WSLUA_METHOD UInt64_encode(lua_State* L) { - /* Encodes the UInt64 number into an 8-byte Lua binary string, using given endianess */ -#define WSLUA_OPTARG_UInt64_encode_ENDIAN 2 /* If set to true then little-endian is used, if false then big-endian; if missing/nil, native host endian */ + /* Encodes the `UInt64` number into an 8-byte Lua binary string, using given endianness. + @since 1.11.3 + */ +#define WSLUA_OPTARG_UInt64_encode_ENDIAN 2 /* If set to true then little-endian is used, + if false then big-endian; if missing/nil, + native host endian. */ luaL_Buffer b; gboolean asLittleEndian = (G_BYTE_ORDER == G_LITTLE_ENDIAN)? TRUE : FALSE; @@ -575,10 +674,10 @@ WSLUA_METHOD UInt64_encode(lua_State* L) { UInt64_pack(L, &b, 1, asLittleEndian); luaL_pushresult(&b); - WSLUA_RETURN(1); /* The Lua binary string */ + WSLUA_RETURN(1); /* The Lua binary string. */ } -/* Decodes from string buffer struct into UInt64 userdata, with given endianess */ +/* Decodes from string buffer struct into `UInt64` userdata, with given endianness. */ int UInt64_unpack(lua_State* L, const gchar *buff, gboolean asLittleEndian) { guint64 value = 0; gint i; @@ -601,9 +700,13 @@ int UInt64_unpack(lua_State* L, const gchar *buff, gboolean asLittleEndian) { } WSLUA_CONSTRUCTOR UInt64_decode(lua_State* L) { - /* Decodes an 8-byte Lua binary string, using given endianess, into a new UInt64 object */ -#define WSLUA_ARG_UInt64_decode_STRING 1 /* The Lua string containing a binary 64-bit integer */ -#define WSLUA_OPTARG_UInt64_decode_ENDIAN 2 /* If set to true then little-endian is used, if false then big-endian; if missing/nil, native host endian */ + /* Decodes an 8-byte Lua binary string, using given endianness, into a new `UInt64` object. + @since 1.11.3 + */ +#define WSLUA_ARG_UInt64_decode_STRING 1 /* The Lua string containing a binary 64-bit integer. */ +#define WSLUA_OPTARG_UInt64_decode_ENDIAN 2 /* If set to true then little-endian is used, + if false then big-endian; if missing/nil, + native host endian. */ gboolean asLittleEndian = (G_BYTE_ORDER == G_LITTLE_ENDIAN)? TRUE : FALSE; size_t len = 0; const gchar *s = luaL_checklstring(L, WSLUA_ARG_UInt64_decode_STRING, &len); @@ -619,19 +722,27 @@ WSLUA_CONSTRUCTOR UInt64_decode(lua_State* L) { lua_pushnil(L); } - WSLUA_RETURN(1); /* The UInt64 object created, or nil on failure */ + WSLUA_RETURN(1); /* The `UInt64` object created, or nil on failure. */ } -WSLUA_CONSTRUCTOR UInt64_new(lua_State* L) { /* Creates a UInt64 Object */ -#define WSLUA_OPTARG_UInt64_new_VALUE 1 /* A number, UInt64, Int64, or string of digits to assign the value of the new UInt64 (default=0) */ -#define WSLUA_OPTARG_UInt64_new_HIGHVALUE 2 /* If this is a number and the first argument was a number, then the first will be treated as a lower 32-bits, and this is the high-order 32 bit number */ +WSLUA_CONSTRUCTOR UInt64_new(lua_State* L) { + /* Creates a `UInt64` Object. + @since 1.11.3 + */ +#define WSLUA_OPTARG_UInt64_new_VALUE 1 /* A number, `UInt64`, `Int64`, or string of digits + to assign the value of the new `UInt64` (default=0). */ +#define WSLUA_OPTARG_UInt64_new_HIGHVALUE 2 /* If this is a number and the first argument was + a number, then the first will be treated as a + lower 32-bits, and this is the high-order + 32-bit number. */ guint64 value = 0; if (lua_gettop(L) >= 1) { switch(lua_type(L, WSLUA_OPTARG_UInt64_new_VALUE)) { case LUA_TNUMBER: value = wslua_toguint64(L, WSLUA_OPTARG_UInt64_new_VALUE); - if (lua_gettop(L) == 2 && lua_type(L, WSLUA_OPTARG_UInt64_new_HIGHVALUE) == LUA_TNUMBER) { + if (lua_gettop(L) == 2 && + lua_type(L, WSLUA_OPTARG_UInt64_new_HIGHVALUE) == LUA_TNUMBER) { guint64 h = wslua_toguint64(L, WSLUA_OPTARG_UInt64_new_HIGHVALUE); value &= G_GUINT64_CONSTANT(0x00000000FFFFFFFF); h <<= 32; h &= G_GUINT64_CONSTANT(0xFFFFFFFF00000000); @@ -650,43 +761,57 @@ WSLUA_CONSTRUCTOR UInt64_new(lua_State* L) { /* Creates a UInt64 Object */ pushUInt64(L,value); - WSLUA_RETURN(1); /* The new UInt64 object. */ + WSLUA_RETURN(1); /* The new `UInt64` object. */ } -WSLUA_METAMETHOD UInt64__call(lua_State* L) { /* Creates a UInt64 Object */ +WSLUA_METAMETHOD UInt64__call(lua_State* L) { + /* Creates a `UInt64` Object. + @since 1.11.3 + */ lua_remove(L,1); /* remove the table */ - WSLUA_RETURN(UInt64_new(L)); /* The new UInt64 object. */ + WSLUA_RETURN(UInt64_new(L)); /* The new `UInt64` object. */ } -WSLUA_CONSTRUCTOR UInt64_max(lua_State* L) { /* Gets the max possible value */ +WSLUA_CONSTRUCTOR UInt64_max(lua_State* L) { + /* Gets the max possible value. + @since 1.11.3 + */ pushUInt64(L,G_MAXUINT64); WSLUA_RETURN(1); /* The max value. */ } -WSLUA_CONSTRUCTOR UInt64_min(lua_State* L) { /* Gets the min possible value (i.e., 0) */ +WSLUA_CONSTRUCTOR UInt64_min(lua_State* L) { + /* Gets the min possible value (i.e., 0). + @since 1.11.3 + */ pushUInt64(L,0); WSLUA_RETURN(1); /* The min value. */ } WSLUA_METHOD UInt64_tonumber(lua_State* L) { - /* Returns a Lua number of the UInt64 value - this may lose precision. */ + /* Returns a Lua number of the `UInt64` value - this may lose precision. + @since 1.11.3 + */ lua_pushnumber(L,(lua_Number)(checkUInt64(L,1))); - WSLUA_RETURN(1); /* The Lua number */ + WSLUA_RETURN(1); /* The Lua number. */ } WSLUA_METAMETHOD UInt64__tostring(lua_State* L) { - /* Converts the UInt64 into a string */ + /* Converts the `UInt64` into a string. */ guint64 num = getUInt64(L,1); gchar s[LUATYPE64_STRING_SIZE]; if (g_snprintf(s, LUATYPE64_STRING_SIZE, "%" G_GINT64_MODIFIER "u",(guint64)num) < 0) { return luaL_error(L, "Error writing UInt64 to a string"); } lua_pushstring(L,s); - WSLUA_RETURN(1); /* The Lua string */ + WSLUA_RETURN(1); /* The Lua string. */ } -WSLUA_CONSTRUCTOR UInt64_fromhex(lua_State* L) { /* Creates a UInt64 object from the given hex string */ -#define WSLUA_ARG_UInt64_fromhex_HEX 1 /* The hex-ascii Lua string */ +WSLUA_CONSTRUCTOR UInt64_fromhex(lua_State* L) { + /* Creates a `UInt64` object from the given hex string. + @since 1.11.3 + */ +#define WSLUA_ARG_UInt64_fromhex_HEX 1 /* The hex-ascii Lua string. */ guint64 result = 0; size_t len = 0; const gchar *s = luaL_checklstring(L,WSLUA_ARG_UInt64_fromhex_HEX,&len); @@ -695,12 +820,15 @@ WSLUA_CONSTRUCTOR UInt64_fromhex(lua_State* L) { /* Creates a UInt64 object from sscanf(s, "%" G_GINT64_MODIFIER "x", &result); } pushUInt64(L,result); - WSLUA_RETURN(1); /* The new UInt64 object. */ + WSLUA_RETURN(1); /* The new `UInt64` object. */ } WSLUA_METHOD UInt64_tohex(lua_State* L) { - /* Returns a hex string of the UInt64 value. */ -#define WSLUA_OPTARG_UInt64_new_NUMBYTES 2 /* The number of hex-chars/nibbles to generate, negative means uppercase (default=16) */ + /* Returns a hex string of the `UInt64` value. + @since 1.11.3 + */ +#define WSLUA_OPTARG_UInt64_new_NUMBYTES 2 /* The number of hex-chars/nibbles to generate, + negative means uppercase (default=16). */ guint64 b = getUInt64(L,1); gint n = luaL_optint(L, WSLUA_OPTARG_UInt64_new_NUMBYTES, 16); const gchar *hexdigits = "0123456789abcdef"; @@ -710,11 +838,11 @@ WSLUA_METHOD UInt64_tohex(lua_State* L) { if (n > 16) n = 16; for (i = n-1; i >= 0; --i) { buf[i] = hexdigits[b & 15]; b >>= 4; } lua_pushlstring(L, buf, (size_t)n); - WSLUA_RETURN(1); /* The string hex */ + WSLUA_RETURN(1); /* The string hex. */ } WSLUA_METHOD UInt64_higher(lua_State* L) { - /* Returns a Lua number of the higher 32-bits of the UInt64 value. */ + /* Returns a Lua number of the higher 32-bits of the `UInt64` value. */ guint64 num = getUInt64(L,1); guint64 b = num; lua_Number n = 0; @@ -722,63 +850,78 @@ WSLUA_METHOD UInt64_higher(lua_State* L) { b >>= 32; n = (lua_Number)(guint32)(b & G_GUINT64_CONSTANT(0x00000000FFFFFFFFF)); lua_pushnumber(L,n); - WSLUA_RETURN(1); /* The Lua number */ + WSLUA_RETURN(1); /* The Lua number. */ } WSLUA_METHOD UInt64_lower(lua_State* L) { - /* Returns a Lua number of the lower 32-bits of the UInt64 value. */ + /* Returns a Lua number of the lower 32-bits of the `UInt64` value. */ guint64 b = getUInt64(L,1); lua_pushnumber(L,(guint32)(b & G_GUINT64_CONSTANT(0x00000000FFFFFFFFF))); - WSLUA_RETURN(1); /* The Lua number */ + WSLUA_RETURN(1); /* The Lua number. */ } WSLUA_METAMETHOD UInt64__unm(lua_State* L) { - /* Returns the UInt64, in a new UInt64, since unsigned integers can't be negated. */ + /* Returns the `UInt64`, in a new `UInt64`, since unsigned integers can't be negated. + @since 1.11.3 + */ pushUInt64(L,getUInt64(L,1)); - WSLUA_RETURN(1); /* The UInt64 object */ + WSLUA_RETURN(1); /* The `UInt64` object. */ } WSLUA_METAMETHOD UInt64__add(lua_State* L) { - /* Adds two UInt64 together and returns a new one (this may wrap the value) */ + /* Adds two `UInt64` together and returns a new one (this may wrap the value). + @since 1.11.3 + */ WSLUA_MATH_OP_FUNC(UInt64,+); } WSLUA_METAMETHOD UInt64__sub(lua_State* L) { - /* Subtracts two UInt64 and returns a new one (this may wrap the value) */ + /* Subtracts two `UInt64` and returns a new one (this may wrap the value). + @since 1.11.3 + */ WSLUA_MATH_OP_FUNC(UInt64,-); } WSLUA_METAMETHOD UInt64__mul(lua_State* L) { - /* Multiplies two UInt64 and returns a new one (this may truncate the value) */ + /* Multiplies two `UInt64` and returns a new one (this may truncate the value). + @since 1.11.3 + */ WSLUA_MATH_OP_FUNC(UInt64,*); } WSLUA_METAMETHOD UInt64__div(lua_State* L) { - /* Divides two UInt64 and returns a new one (integer divide, no remainder). - Trying to divide by zero results in a Lua error. */ + /* Divides two `UInt64` and returns a new one (integer divide, no remainder). + Trying to divide by zero results in a Lua error. + @since 1.11.3 + */ UInt64 num1 = getUInt64(L,1); UInt64 num2 = getUInt64(L,2); if (num2 == 0) { return luaL_error(L, "Trying to divide UInt64 by zero"); } pushUInt64(L, num1 / num2); - WSLUA_RETURN(1); /* The UInt64 result */ + WSLUA_RETURN(1); /* The `UInt64` result. */ } WSLUA_METAMETHOD UInt64__mod(lua_State* L) { - /* Divides two UInt64 and returns a new one of the remainder. - Trying to modulo by zero results in a Lua error. */ + /* Divides two `UInt64` and returns a new one of the remainder. + Trying to modulo by zero results in a Lua error. + @since 1.11.3 + */ UInt64 num1 = getUInt64(L,1); UInt64 num2 = getUInt64(L,2); if (num2 == 0) { return luaL_error(L, "Trying to modulo UInt64 by zero"); } pushUInt64(L, num1 % num2); - WSLUA_RETURN(1); /* The UInt64 result */ + WSLUA_RETURN(1); /* The `UInt64` result. */ } WSLUA_METAMETHOD UInt64__pow(lua_State* L) { - /* The first UInt64 is taken to the power of the second UInt64/number, returning a new one (this may truncate the value) */ + /* The first `UInt64` is taken to the power of the second `UInt64`/number, + returning a new one (this may truncate the value). + @since 1.11.3 + */ guint64 num1 = getUInt64(L,1); guint64 num2 = getUInt64(L,2); guint64 result; @@ -792,95 +935,130 @@ WSLUA_METAMETHOD UInt64__pow(lua_State* L) { } } pushUInt64(L,result); - WSLUA_RETURN(1); /* The UInt64 object */ + WSLUA_RETURN(1); /* The `UInt64` object. */ } WSLUA_METAMETHOD UInt64__eq(lua_State* L) { - /* Returns true if both UInt64 are equal */ + /* Returns true if both `UInt64` are equal. + @since 1.11.3 + */ WSLUA_COMP_OP_FUNC(UInt64,==); } WSLUA_METAMETHOD UInt64__lt(lua_State* L) { - /* Returns true if first UInt64 < second */ + /* Returns true if first `UInt64` < second. + @since 1.11.3 + */ WSLUA_COMP_OP_FUNC(UInt64,<); } WSLUA_METAMETHOD UInt64__le(lua_State* L) { - /* Returns true if first UInt64 <= second */ + /* Returns true if first `UInt64` <= second. + @since 1.11.3 + */ WSLUA_COMP_OP_FUNC(UInt64,<=); } WSLUA_METHOD UInt64_bnot(lua_State* L) { - /* Returns a UInt64 of the bitwise 'not' operation. */ + /* Returns a `UInt64` of the bitwise 'not' operation. + @since 1.11.3 + */ pushUInt64(L,~(getUInt64(L,1))); - WSLUA_RETURN(1); /* The UInt64 object */ + WSLUA_RETURN(1); /* The `UInt64` object. */ } WSLUA_METHOD UInt64_band(lua_State* L) { - /* Returns a UInt64 of the bitwise 'and' operation, with the given number/Int64/UInt64. Note that multiple arguments are allowed. */ + /* Returns a `UInt64` of the bitwise 'and' operation, with the given number/`Int64`/`UInt64`. + Note that multiple arguments are allowed. + @since 1.11.3 + */ WSLUA_BIT_OP_FUNC(UInt64,&=); - WSLUA_RETURN(1); /* The UInt64 object */ + WSLUA_RETURN(1); /* The `UInt64` object. */ } WSLUA_METHOD UInt64_bor(lua_State* L) { - /* Returns a UInt64 of the bitwise 'or' operation, with the given number/Int64/UInt64. Note that multiple arguments are allowed. */ + /* Returns a `UInt64` of the bitwise 'or' operation, with the given number/`Int64`/`UInt64`. + Note that multiple arguments are allowed. + @since 1.11.3 + */ WSLUA_BIT_OP_FUNC(UInt64,|=); - WSLUA_RETURN(1); /* The UInt64 object */ + WSLUA_RETURN(1); /* The `UInt64` object. */ } WSLUA_METHOD UInt64_bxor(lua_State* L) { - /* Returns a UInt64 of the bitwise 'xor' operation, with the given number/Int64/UInt64. Note that multiple arguments are allowed. */ + /* Returns a `UInt64` of the bitwise 'xor' operation, with the given number/`Int64`/`UInt64`. + Note that multiple arguments are allowed. + @since 1.11.3 + */ WSLUA_BIT_OP_FUNC(UInt64,^=); - WSLUA_RETURN(1); /* The UInt64 object */ + WSLUA_RETURN(1); /* The `UInt64` object. */ } WSLUA_METHOD UInt64_lshift(lua_State* L) { - /* Returns a UInt64 of the bitwise logical left-shift operation, by the given number of bits. */ -#define WSLUA_ARG_UInt64_lshift_NUMBITS 2 /* The number of bits to left-shift by */ + /* Returns a `UInt64` of the bitwise logical left-shift operation, by the + given number of bits. + @since 1.11.3 + */ +#define WSLUA_ARG_UInt64_lshift_NUMBITS 2 /* The number of bits to left-shift by. */ guint64 b = getUInt64(L,1); guint32 n = wslua_checkguint32(L,WSLUA_ARG_UInt64_lshift_NUMBITS); pushUInt64(L,(b << n)); - WSLUA_RETURN(1); /* The UInt64 object */ + WSLUA_RETURN(1); /* The `UInt64` object. */ } WSLUA_METHOD UInt64_rshift(lua_State* L) { - /* Returns a UInt64 of the bitwise logical right-shift operation, by the given number of bits. */ -#define WSLUA_ARG_UInt64_rshift_NUMBITS 2 /* The number of bits to right-shift by */ + /* Returns a `UInt64` of the bitwise logical right-shift operation, by the + given number of bits. + @since 1.11.3 + */ +#define WSLUA_ARG_UInt64_rshift_NUMBITS 2 /* The number of bits to right-shift by. */ guint64 b = getUInt64(L,1); guint32 n = wslua_checkguint32(L,WSLUA_ARG_UInt64_rshift_NUMBITS); pushUInt64(L,(b >> n)); - WSLUA_RETURN(1); /* The UInt64 object */ + WSLUA_RETURN(1); /* The `UInt64` object. */ } WSLUA_METHOD UInt64_arshift(lua_State* L) { - /* Returns a UInt64 of the bitwise arithmetic right-shift operation, by the given number of bits. */ -#define WSLUA_ARG_UInt64_arshift_NUMBITS 2 /* The number of bits to right-shift by */ + /* Returns a `UInt64` of the bitwise arithmetic right-shift operation, by the + given number of bits. + @since 1.11.3 + */ +#define WSLUA_ARG_UInt64_arshift_NUMBITS 2 /* The number of bits to right-shift by. */ guint64 b = getUInt64(L,1); guint32 n = wslua_checkguint32(L,WSLUA_ARG_UInt64_arshift_NUMBITS); pushUInt64(L,(b >> n)); - WSLUA_RETURN(1); /* The UInt64 object */ + WSLUA_RETURN(1); /* The `UInt64` object. */ } WSLUA_METHOD UInt64_rol(lua_State* L) { - /* Returns a UInt64 of the bitwise left rotation operation, by the given number of bits (up to 63). */ -#define WSLUA_ARG_UInt64_rol_NUMBITS 2 /* The number of bits to roll left by */ + /* Returns a `UInt64` of the bitwise left rotation operation, by the + given number of bits (up to 63). + @since 1.11.3 + */ +#define WSLUA_ARG_UInt64_rol_NUMBITS 2 /* The number of bits to roll left by. */ guint64 b = getUInt64(L,1); guint32 n = wslua_checkguint32(L,WSLUA_ARG_UInt64_rol_NUMBITS); pushUInt64(L,((b << n) | (b >> (64-n)))); - WSLUA_RETURN(1); /* The UInt64 object */ + WSLUA_RETURN(1); /* The `UInt64` object. */ } WSLUA_METHOD UInt64_ror(lua_State* L) { - /* Returns a UInt64 of the bitwise right rotation operation, by the given number of bits (up to 63). */ -#define WSLUA_ARG_UInt64_ror_NUMBITS 2 /* The number of bits to roll right by */ + /* Returns a `UInt64` of the bitwise right rotation operation, by the + given number of bits (up to 63). + @since 1.11.3 + */ +#define WSLUA_ARG_UInt64_ror_NUMBITS 2 /* The number of bits to roll right by. */ guint64 b = getUInt64(L,1); guint32 n = wslua_checkguint32(L,WSLUA_ARG_UInt64_ror_NUMBITS); pushUInt64(L,((b << (64-n)) | (b >> n))); - WSLUA_RETURN(1); /* The UInt64 object */ + WSLUA_RETURN(1); /* The `UInt64` object. */ } WSLUA_METHOD UInt64_bswap(lua_State* L) { - /* Returns a UInt64 of the bytes swapped. This can be used to convert little-endian 64 bit numbers to big-endian 64 bit numbers or vice versa. */ + /* Returns a `UInt64` of the bytes swapped. This can be used to convert little-endian + 64-bit numbers to big-endian 64 bit numbers or vice versa. + @since 1.11.3 + */ guint64 b = getUInt64(L,1); guint64 result = 0; size_t i; @@ -890,7 +1068,7 @@ WSLUA_METHOD UInt64_bswap(lua_State* L) { b >>= 8; } pushUInt64(L,result); - WSLUA_RETURN(1); /* The UInt64 object */ + WSLUA_RETURN(1); /* The `UInt64` object. */ } /* Gets registered as metamethod automatically by WSLUA_REGISTER_CLASS/META */ |