medfall

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs

commit bdc0edc92ae2ae00eea7df5959accb941a9798ac
parent 6905c1b8eb2e8a740246f94dfd00c717048410c2
Author: Michael Savage <mikejsavage@gmail.com>
Date:   Fri Oct 28 20:28:08 +0300

Remove int_conversions generator since we just use checked_cast now

Diffstat:
manualgen/int_conversions.lua | 55-------------------------------------------------------
1 file changed, 0 insertions(+), 55 deletions(-)
diff --git a/manualgen/int_conversions.lua b/manualgen/int_conversions.lua @@ -1,55 +0,0 @@ -#! /usr/bin/lua - -local s = { "s64", "s32", "s16", "s8" } -local u = { "u64", "u32", "u16", "u8" } - -local function printf( form, ... ) - print( form:format( ... ) ) -end - -local function codes( t ) - printf( - "template< typename T >\n" .. - "%s check_%s( T x ) {\n" .. - "\tif( IS_SIGNED( T ) ) assert( x >= %s_MIN );\n" .. - "\tassert( x <= %s_MAX );\n" .. - "\treturn ( %s ) x;\n" .. - "}\n" .. - "\n" .. - "template< typename T >\n" .. - "%s check_%s( T x ) {\n" .. - "#pragma GCC diagnostic push // GCC warns even though the optimiser removes the branch\n" .. - "#pragma GCC diagnostic ignored \"-Wsign-compare\"\n" .. - "\tif( IS_SIGNED( T ) ) assert( x >= %s_MIN );\n" .. - "#pragma GCC diagnostic pop\n" .. - "\tassert( x <= %s_MAX );\n" .. - "\treturn ( %s ) x;\n" .. - "}", - t, t, t:upper(), t:upper(), t, - t, t, t:upper(), t:upper(), t ) -end - -local function codeu( t ) - printf( - "template< typename T >\n" .. - "%s check_%s( T x ) {\n" .. - "\tassert( x >= 0 && x <= %s_MAX );\n" .. - "\treturn ( %s ) x;\n" .. - "}\n" .. - "\n" .. - "template< typename T >\n" .. - "%s clamp_%s( T x ) {\n" .. - "\tif( x < 0 ) return 0;\n" .. - "\tif( x > %s_MAX ) return %s_MAX;\n" .. - "\treturn ( %s ) x;\n" .. - "}\n", - t, t, t:upper(), t, - t, t, t:upper(), t:upper(), t ) -end - -for _, t in ipairs( s ) do - codes( t ) -end -for _, t in ipairs( u ) do - codeu( t ) -end