Lua: bit.value
This commit is contained in:
parent
626ff5e200
commit
66fca7925c
3 changed files with 41 additions and 3 deletions
16
manual.lyx
16
manual.lyx
|
@ -2163,6 +2163,16 @@ There are two special bit positions, true and false, standing for always
|
|||
set bit and always clear bit.
|
||||
\end_layout
|
||||
|
||||
\begin_layout Subsubsection
|
||||
bit.value([number bit1[, number bit2,...]])
|
||||
\end_layout
|
||||
|
||||
\begin_layout Standard
|
||||
Returns bitwise OR of 1 left shifted by bit1 places, 1 left shifted by bit2
|
||||
places and so on.
|
||||
As special value, nil argument is no-op.
|
||||
\end_layout
|
||||
|
||||
\begin_layout Subsection
|
||||
Table gui:
|
||||
\end_layout
|
||||
|
@ -2461,7 +2471,7 @@ Returns a new palette (initially all transparent).
|
|||
\end_layout
|
||||
|
||||
\begin_layout Subsubsection
|
||||
gui.bitmap_new(number w, number h, boolean direct)
|
||||
gui.bitmap_new(number w, number h, boolean direct[, bool icolor])
|
||||
\end_layout
|
||||
|
||||
\begin_layout Standard
|
||||
|
@ -2482,6 +2492,10 @@ h: The height of new bitmap
|
|||
direct: If true, the returned bitmap is dbitmap, otherwise bitmap.
|
||||
\end_layout
|
||||
|
||||
\begin_layout Itemize
|
||||
icolor: Initital fill color (defaults to 0 on BITMAP, -1 on DBITMAP)
|
||||
\end_layout
|
||||
|
||||
\begin_layout Subsubsection
|
||||
gui.bitmap_load(string file)
|
||||
\end_layout
|
||||
|
|
12
manual.txt
12
manual.txt
|
@ -1054,6 +1054,12 @@ Notes:
|
|||
• There are two special bit positions, true and false, standing
|
||||
for always set bit and always clear bit.
|
||||
|
||||
8.2.11 bit.value([number bit1[, number bit2,...]])
|
||||
|
||||
Returns bitwise OR of 1 left shifted by bit1 places, 1 left
|
||||
shifted by bit2 places and so on. As special value, nil argument
|
||||
is no-op.
|
||||
|
||||
8.3 Table gui:
|
||||
|
||||
Most of these functions can only be called in on_paint and
|
||||
|
@ -1211,7 +1217,8 @@ Draw a bitmap on screen. Parameters:
|
|||
Returns a new palette (initially all transparent). Can be used
|
||||
anywhere.
|
||||
|
||||
8.3.15 gui.bitmap_new(number w, number h, boolean direct)
|
||||
8.3.15 gui.bitmap_new(number w, number h, boolean direct[, bool
|
||||
icolor])
|
||||
|
||||
Returns a new bitmap/dbitmap. Can be used anywhere. Parameters:
|
||||
|
||||
|
@ -1222,6 +1229,9 @@ Returns a new bitmap/dbitmap. Can be used anywhere. Parameters:
|
|||
• direct: If true, the returned bitmap is dbitmap, otherwise
|
||||
bitmap.
|
||||
|
||||
• icolor: Initital fill color (defaults to 0 on BITMAP, -1 on
|
||||
DBITMAP)
|
||||
|
||||
8.3.16 gui.bitmap_load(string file)
|
||||
|
||||
Returns loaded bitmap/dbitmap (if bitmap, the second return value
|
||||
|
|
|
@ -102,7 +102,7 @@ namespace
|
|||
}
|
||||
};
|
||||
|
||||
function_ptr_luafun lua_print("bit.extract", [](lua_State* LS, const std::string& fname) -> int {
|
||||
function_ptr_luafun lua_bextract("bit.extract", [](lua_State* LS, const std::string& fname) -> int {
|
||||
uint64_t num = get_numeric_argument<uint64_t>(LS, 1, fname.c_str());
|
||||
uint64_t ret = 0;
|
||||
for(size_t i = 0;; i++) {
|
||||
|
@ -119,6 +119,20 @@ namespace
|
|||
return 1;
|
||||
});
|
||||
|
||||
function_ptr_luafun lua_bvalue("bit.value", [](lua_State* LS, const std::string& fname) -> int {
|
||||
uint64_t ret = 0;
|
||||
for(size_t i = 0;; i++) {
|
||||
if(lua_isnumber(LS, i + 1)) {
|
||||
uint8_t bit = get_numeric_argument<uint8_t>(LS, i + 1, fname.c_str());
|
||||
ret |= (1ULL << bit);
|
||||
} else if(lua_isnil(LS, i + 1)) {
|
||||
} else
|
||||
break;
|
||||
}
|
||||
lua_pushnumber(LS, ret);
|
||||
return 1;
|
||||
});
|
||||
|
||||
lua_symmetric_bitwise<combine_none, BITWISE_MASK> bit_none("bit.none");
|
||||
lua_symmetric_bitwise<combine_none, BITWISE_MASK> bit_bnot("bit.bnot");
|
||||
lua_symmetric_bitwise<combine_any, 0> bit_any("bit.any");
|
||||
|
|
Loading…
Add table
Reference in a new issue