Ok, so what I'm doing is this:
Files:
++++
std/filestat
std/posix/filestat
std/win32/filestat
classes:
+++++++
std/filestat:
=========
class FileStat_class[os, ..others]
{
virtual ...
}
include "std/posix/filestat";
include "std/win32/filestat";
// default to Host OS class
class FileStat {
if PLAT_WIN32 do
inherit Win32FileStat;
else
inherit PosixFileStat;
}
std/posix/filestat:
=============
class PosixFileStat {
// posix specific stuff
type stat_t = "posix_stat";
..
// inherit the generic code
inherit FileStat_class[Posix, stat_t];
// instantiate generic code
instance FileStat_class[Posix, stat_t] {
..
}
}
So now, FileStat works as before for your host OS
However if you're on Linux and want to generate C++ for Windows,
you can write:
Win32FileStat::filetime(s)
The parametric form is:
FileStat_class[os]::filetime(s)
The point of this is that on ANY platform you can generate C++ for ANY
platform with a command line switch:
flx --target=Win32 ....
At present there's no such switch, however you can probably do some
include file tricks to work around it, eg
include "mymacros";
and then set the target OS in that:
typedef os = Win32;
Note the parametric form is DIFFERENT to the "generic" form
in a second way: it GUARANTEES PORTABILITY. Using
FileStat does not, because it inherits platform dependent
features from PosixFileStat (for example) and if you try
to build on Windows you might run aground.
========================================
We should note here: Felix provides two kinds of platform independence.
Some things are done by C++ conditional compilation or link time
library selection. This means the generated C++ is portable to all
platforms.
With the mechanism above, however, the Felix code is portable to
all platforms, but the C++ code is not.
We might recover C++ source portability with plugins, i.e. at the link stage,
in a similar way that C++ is rendered portable by a standard API to the
non-portable implementation of C/C++ libraries.
--
john skaller
[email protected]
http://felix-lang.org
------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and
threat landscape has changed and how IT managers can respond. Discussions
will include endpoint security, mobile security and the latest in malware
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
Felix-language mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/felix-language