I like the good humor around and I'm laughing a bit with this !
I'm looking for interpreted languages for a while and allways come back to lua by it's simplicity, I don't love it but I know how to do dirty job faster with it.
Attached is my actuall dirty preprocessor write in lua: It's used like this: lua lpp.lua one_file_cpp_or_hIt writes a backup "one_file_cpp_or_h.lpb" and rewrite the original "one_file_cpp_or_h", it preserve the macros/luacode on the original document so we can reprocess it over and over, example:
Generated code is marked with the lines bellow and are regenereated every time, anything else remains untouched.
The advantage of it is that it's not a limited preprocessor we can do anything that lua language can do.
// generated-code:begin
// generated-code:end
-------
/*lua
--
--lua code can be hidden inside C/C++ comments
--
function write_list_keys(tbl, fmt)
local sorted_tbl = {}
for k,v in pairs(tbl) do
table.insert(sorted_tbl, k)
end
table.sort(sorted_tbl)
for k,v in pairs(sorted_tbl) do
_putsnl_(fmt:gsub("#s", v))
end
end
function write_db_sql_enums(db_images)
_putsnl_("enum fldn {")
write_list_keys(db_images, "efld_#s,")
_putsnl_("};")
end
db_images = {
id = {readonly=true},
name = true,
description = true,
img_type = true,
thumbnail = true,
mdate = {readonly=true},
cdate = {readonly=true},
}
lua*/
class Db_images : public Db_Sql
{
protected:
public:
typedef Db_images THISCLASS;
//#write_db_sql_enums(db_images) -- one line lua code also hidden from
C/C++
// generated-code:begin
enum fldn {
efld_cdate,
efld_description,
efld_id,
efld_img_type,
efld_mdate,
efld_name,
efld_thumbnail,
};
// generated-code:end
Db_images(CppSQLite3DB &adb):Db_Sql(adb, 7)
{
_table_name = "images";
//#write_list_keys(db_images, '_add_db_field("#t");') -- one line lua
code also hidden from C/C++
// generated-code:begin
_add_db_field("cdate");
_add_db_field("description");
_add_db_field("id");
_add_db_field("img_type");
_add_db_field("mdate");
_add_db_field("name");
_add_db_field("thumbnail");
// generated-code:end
}
};
-------
En 22/12/2010 00:03:57, Matthias Melcher <[email protected]> escribió:
Yeah, that would be the hit. I can already see the "Boing Boing" and "Engadget" news:"Insane User Interface Library integrating Ancient Scripting Language." or "What's next? Hieroglyphs for MFC? - Oh wait, it already is." - Matthias
lpp.lua
Description: Binary data
_______________________________________________ fltk-dev mailing list [email protected] http://lists.easysw.com/mailman/listinfo/fltk-dev
