--> t3rmin4t0r (address@hidden) has joined #dotgnu --- Topic for #dotgnu is things are heating up on [bizplan] :) --- Topic for #dotgnu set by ChanServ at Tue Jan 29 19:37:03 hi rhysw sorry I'm late --- You have new mail (3 messages, 9200 bytes total). hello * t3rmin4t0r had a power failure So, what's on your mind? Ok, now how do I get on to implementing the native file methods rightio... after doing the Unxi API emulations....ILFileOpen(),ILFileRead() stuff, where should I go ? StepYou need to create a native method in the engine ... e.g. "lib_file.c" yep lib_file.c --- You have new mail (4 messages, 13341 bytes total). Ok, I read the Platform.FileMethods first, create a table of method mappings from the names in "Platform.FileMethods" to the actual functions that implement each. Look in "lib_platform.c" at "DirMethods" for an example of this. IL_METHOD_BEGIN(_ILPlatformDirMethods) IL_METHOD("GetPathInfo", "()vPlatform.PathInfo;", Platform_DirMethods_GetPathInfo) IL_METHOD("GetSystemDirectory", "()oSystem.String;", Platform_DirMethods_GetSystemDirectory) IL_METHOD_END That's the DirMethods version. You need to create something similar for "FileMethods". Ok, the export map ! Yup - the args are "name", "signature", and "function". The signature uses a Java-like string encoding, which is explained in "lookup.c" Yes, I'll work through a simple example with you: "FileMethods.Close". that's better Here's the table: IL_METHOD_BEGIN(_ILPlatformFileMethods) IL_METHOD("Close", "(j)Z", Platform_FileMethods_Close) IL_METHOD_END The "j" is the "IntPtr" parameter (it's an IL thing). The Z is the "bool" result type. yeah I've the lookup.c up here seems like easy to me.. should be - I designed it around Java's syntax because it was so easy. yeah Ljava/lang/String; ! looks like oSystem.String yeah - I took out the ugly / syntax from Java, because it was silly. :) Besides, IL uses "/" as a separator for nested types. Anyway, the code for Close: static ILBool Platform_FileMethods_Close (ILExecThread *thread, ILNativeInt handle) { return ILFileClose(handle); } TA DA! (actually, there is one more step) But one "small" prob, does Win32 use Int for file pointers ? The "IntPtr" is big enough to hold an "integer the same size as a pointer", and Windows uses pointers as handles. So what about ILNativeInt ? Now, to hook the method through to the rest of the engine, we need to go into "internal.c" (ILNativeInt is the engine type that corresponds to "IntPtr" - same size). In "internal.c", we declare the table as: extern ILMethodTableEntry const _ILPlatformFileMethods; And then add it to the "internalClassTable" with: {"FileMethods", "Platform", &_ILPlatformFileMethods}, Note: the table must be sorted into ascending order of class name (ignoring the namespace), so insert it in the right position. That's basically it. Rinse and repeat for all the other internalcall methods. Ok but I cannot compile pnetlib, to test this :-( The FileMethods stuff should already be hooked through from "System.IO.FileStream", which is part of the precompiled library. Adding new internalcall's will be a problem. I think your mscorlib doesn't have System.IO ? --> arun (address@hidden) has joined #dotgnu should be there - "ilfind" picked up "FileStream" just now. hi arun hi rhys how r u doing ok - taking it easy for a few days. ya, thats good, rhys what is the status of hacker docs planed ? pnetlib is done, the intro on pnet is done, and the rest is up in the brain waiting to be typed up i think you should put the pnetlib part online; it can help get more people for contributing rhysw: how can I test my code without recompiling Platform.FileMethods into mscorlib.dll * t3rmin4t0r can see no way out err ... have you added more methods to "FileMethods", or are you just implementing what is already declared? The C code I explained earlier is in the engine only - it doesn't need pnetlib to be recompiled unless you add a new InternalCall. arun: the pnetlib one is in the source. Isn't that enough? Ok, so where are the stub internalcalls declared ? (the dummy calls) stub internalcalls? I still don't get what you mean. yeah the [MethodImpl(MethodImplOptions.InternalCall)] extern public static bool CheckHandleAccess (IntPtr handle, FileAccess access); method's InternalCall The C code I gave you earlier _is_ the implementation of the InternalCall. Adding it to the table in "internal.c" makes sure that everything gets hooked through. So if an internal call is *not* implemented, it gets ignored ? "MissingMethodException" Ok, I get it. Unless I call the method the .dll works fine absolutely - on-demand loading of InternalCall methods. Wow ! Of course - it probably would be useful for someone to write a Perl/Python script to grep the code to make sure that all InternalCall's in pnetlib have a corresponding implementation in pnet. Perhaps something extra for the "class status" script that says "this internalcall not implemented in the engine". seems possible run ctags on lib_*.c and ... parse using python Something like that - it would probably be easier to grep for "IL_METHOD". ok, the export table ? I'll look into it yup thanx On to other matters ... I'm thinking of opening up the CVS server for more people to submit code. It would improve the turn-around on patches. What do you think? I don't have much experience with CVS, I prefer patches ;-) less chance of breaking the build by some foolish kid (/me) You'd only do that once - after I'd sent Bubba around to deal with you, you'll never do it again. :) Anyway, I think it is a good idea to announce about the internal call stuff... most people would jump at such an idea of extensibility Since you're inside there at the moment, how about drafting a "how to add an InternalCall" section for "engine/HACKING" and I'll put it in and then announce it. I'm game !