Merge pull request #452 from ngladitz/lua-char-typemap
lua: push characters as unformatted 1-character strings
This commit is contained in:
commit
f1be7ad3ee
6 changed files with 37 additions and 4 deletions
15
Examples/test-suite/chartest.i
Normal file
15
Examples/test-suite/chartest.i
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
%module chartest
|
||||
|
||||
%inline %{
|
||||
char printable_global_char = 'a';
|
||||
char unprintable_global_char = 0x7F;
|
||||
|
||||
char GetPrintableChar() {
|
||||
return 'a';
|
||||
}
|
||||
|
||||
char GetUnprintableChar() {
|
||||
return 0x7F;
|
||||
}
|
||||
|
||||
%}
|
||||
|
|
@ -138,6 +138,7 @@ CPP_TEST_CASES += \
|
|||
casts \
|
||||
char_binary \
|
||||
char_strings \
|
||||
chartest \
|
||||
class_forward \
|
||||
class_ignore \
|
||||
class_scope_weird \
|
||||
|
|
|
|||
14
Examples/test-suite/lua/chartest_runme.lua
Normal file
14
Examples/test-suite/lua/chartest_runme.lua
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
require("import") -- the import fn
|
||||
import("chartest") -- import code
|
||||
|
||||
function char_assert(char, code)
|
||||
assert(type(char) == 'string')
|
||||
assert(char:len() == 1)
|
||||
assert(char:byte() == code)
|
||||
end
|
||||
|
||||
char_assert(chartest.GetPrintableChar(), 0x61)
|
||||
char_assert(chartest.GetUnprintableChar(), 0x7F)
|
||||
|
||||
char_assert(chartest.printable_global_char, 0x61)
|
||||
char_assert(chartest.unprintable_global_char, 0x7F)
|
||||
Loading…
Add table
Add a link
Reference in a new issue