On 11/20/02 Jonathan Pryor wrote:
> I would suggest an alternative approach.  Use P/Invoke for everything,
> but instead of having the C# values differ from the platform-specific
> values, let them be the same.  Instead, use P/Invoke to also get the
> platform-specific values.
> 
> It could look like this:
> 
>       public sealed class OpenMode {
>               [DllImport ("posix-values")]
>               private static extern int posix_get_O_CREAT ();
[...]
> The advantage to this is that you don't have to write as much custom
> code.  All of the `posix_get_CONSTANT()' functions can be generated with
> a single perl script:

It's better to make the script generate properties:

        public static int O_EXCL {
                get {return 0xwhatever;}
        }

The jit will inline the call and constant-fold if you use multiple
options (it cannot do that if you pinvoke a function).
Using properties still allows to have separate values on different
platforms without having a C library at runtime.

lupus

-- 
-----------------------------------------------------------------
[EMAIL PROTECTED]                                     debian/rules
[EMAIL PROTECTED]                             Monkeys do it better

_______________________________________________
Mono-list maillist  -  [EMAIL PROTECTED]
http://lists.ximian.com/mailman/listinfo/mono-list

Reply via email to