www.digitalmars.com         C & C++   DMDScript  

D - module D.win32.module

reply "Matthew Wilson" <matthew stlsoft.org> writes:
I'm writing a simple Win32 module loader class, and naturally I can't call
it D.win32.module, so wondered whether anyone had any good ideas?

"library" doesn't cut it for me, since it's possible to load things other
than libraries with it (such as exes).
"mod" is unpleasant because it's a contraction
"win32module" is unpleasant because it contains redundant information

:(
Oct 18 2003
next sibling parent reply "Matthew Wilson" <matthew stlsoft.org> writes:
I've used exemod (executable module, which is what these things are), but I
confess it'd not pretty.

"Matthew Wilson" <matthew stlsoft.org> wrote in message
news:bmqpqn$coq$1 digitaldaemon.com...
 I'm writing a simple Win32 module loader class, and naturally I can't call
 it D.win32.module, so wondered whether anyone had any good ideas?

 "library" doesn't cut it for me, since it's possible to load things other
 than libraries with it (such as exes).
 "mod" is unpleasant because it's a contraction
 "win32module" is unpleasant because it contains redundant information

 :(
Oct 18 2003
parent reply "Walter" <walter digitalmars.com> writes:
How about exefile? exeimage? image?

"Matthew Wilson" <matthew stlsoft.org> wrote in message
news:bmqqo7$du9$1 digitaldaemon.com...
 I've used exemod (executable module, which is what these things are), but
I
 confess it'd not pretty.

 "Matthew Wilson" <matthew stlsoft.org> wrote in message
 news:bmqpqn$coq$1 digitaldaemon.com...
 I'm writing a simple Win32 module loader class, and naturally I can't
call
 it D.win32.module, so wondered whether anyone had any good ideas?

 "library" doesn't cut it for me, since it's possible to load things
other
 than libraries with it (such as exes).
 "mod" is unpleasant because it's a contraction
 "win32module" is unpleasant because it contains redundant information

 :(
Oct 18 2003
parent reply "Matthew Wilson" <matthew stlsoft.org> writes:
I like "image".

"Walter" <walter digitalmars.com> wrote in message
news:bmqv3b$lok$3 digitaldaemon.com...
 How about exefile? exeimage? image?

 "Matthew Wilson" <matthew stlsoft.org> wrote in message
 news:bmqqo7$du9$1 digitaldaemon.com...
 I've used exemod (executable module, which is what these things are),
but
 I
 confess it'd not pretty.

 "Matthew Wilson" <matthew stlsoft.org> wrote in message
 news:bmqpqn$coq$1 digitaldaemon.com...
 I'm writing a simple Win32 module loader class, and naturally I can't
call
 it D.win32.module, so wondered whether anyone had any good ideas?

 "library" doesn't cut it for me, since it's possible to load things
other
 than libraries with it (such as exes).
 "mod" is unpleasant because it's a contraction
 "win32module" is unpleasant because it contains redundant information

 :(
Oct 18 2003
parent reply "Sean L. Palmer" <palmer.sean verizon.net> writes:
Image sounds like something for graphics.

I was thinking "overlay" but that has similar graphics connotations.

Hmm.  What a conundrum!  how about "dynamiccode"?  "codynamic"?  Nobody
would ever be able to search for it.

Thesaurus.com doesn't pull up anything good for it either.

Sean

"Matthew Wilson" <matthew stlsoft.org> wrote in message
news:bmr03h$n21$2 digitaldaemon.com...
 I like "image".

 "Walter" <walter digitalmars.com> wrote in message
 news:bmqv3b$lok$3 digitaldaemon.com...
 How about exefile? exeimage? image?

 "Matthew Wilson" <matthew stlsoft.org> wrote in message
 news:bmqqo7$du9$1 digitaldaemon.com...
 I've used exemod (executable module, which is what these things are),
but
 I
 confess it'd not pretty.

 "Matthew Wilson" <matthew stlsoft.org> wrote in message
 news:bmqpqn$coq$1 digitaldaemon.com...
 I'm writing a simple Win32 module loader class, and naturally I
can't
 call
 it D.win32.module, so wondered whether anyone had any good ideas?

 "library" doesn't cut it for me, since it's possible to load things
other
 than libraries with it (such as exes).
 "mod" is unpleasant because it's a contraction
 "win32module" is unpleasant because it contains redundant
information
 :(
Oct 18 2003
parent reply "Matthew Wilson" <matthew stlsoft.org> writes:
I've settled on

    D.win32.loader

with the class

    ExeModule

and the free functions

    HMODULE ExeModuleLoad(in char[] moduleName);
    HMODULE ExeModuleIncRef(in HMODULE hModule);
    void ExeModuleDecRef(inout HMODULE hModule);
    char[] ExeModuleGetFileName(HMODULE hModule);

These'll stick until someone comes up with something better.

I'm still pretty unhappy about the way we're supposed to name free
functions. To just call them Load, IncRef, DecRef and GetFileName are way
too general. This is so little discussed that I wonder whether all the
people who use D are only thinking about it in terms of class and methods.
No-one ever mentions free functions.

Maybe I just don't understand the explicit qualification mechanisms, and
this can all just go away, i.e. one might write
D.win32.loader.GetFileName(...), but I don't have a handle to the idiom as
yet.


"Sean L. Palmer" <palmer.sean verizon.net> wrote in message
news:bmr1rv$p4q$1 digitaldaemon.com...
 Image sounds like something for graphics.

 I was thinking "overlay" but that has similar graphics connotations.

 Hmm.  What a conundrum!  how about "dynamiccode"?  "codynamic"?  Nobody
 would ever be able to search for it.

 Thesaurus.com doesn't pull up anything good for it either.

 Sean

 "Matthew Wilson" <matthew stlsoft.org> wrote in message
 news:bmr03h$n21$2 digitaldaemon.com...
 I like "image".

 "Walter" <walter digitalmars.com> wrote in message
 news:bmqv3b$lok$3 digitaldaemon.com...
 How about exefile? exeimage? image?

 "Matthew Wilson" <matthew stlsoft.org> wrote in message
 news:bmqqo7$du9$1 digitaldaemon.com...
 I've used exemod (executable module, which is what these things
are),
 but
 I
 confess it'd not pretty.

 "Matthew Wilson" <matthew stlsoft.org> wrote in message
 news:bmqpqn$coq$1 digitaldaemon.com...
 I'm writing a simple Win32 module loader class, and naturally I
can't
 call
 it D.win32.module, so wondered whether anyone had any good ideas?

 "library" doesn't cut it for me, since it's possible to load
things
 other
 than libraries with it (such as exes).
 "mod" is unpleasant because it's a contraction
 "win32module" is unpleasant because it contains redundant
information
 :(
Oct 18 2003
next sibling parent Helmut Leitner <leitner hls.via.at> writes:
Matthew Wilson wrote:
 
 I'm still pretty unhappy about the way we're supposed to name free
 functions. To just call them Load, IncRef, DecRef and GetFileName are way
 too general. This is so little discussed that I wonder whether all the
 people who use D are only thinking about it in terms of class and methods.
 No-one ever mentions free functions.
I think we can treat such functions in an isomorphic way. This means that you can consider a method in a class ExeModule.GetFileName(); identical to a free function ExeModuleGetFileName(module); In fact the object reference is passed as an hidden parameter, so that the calls are technically equivalent (in this case this is not quite true, because "module" is a handle, not an object reference, that would be part of the object data) In general there are different types of objects (not only "implementaion" objects in an OO sense). There are objects, that - are not handled by other types of reference (customer id, object in database) (FileDelete(filename)) - virtual objects that are represented by a group of parameters ("mem" in C, consisting of pointer and size) (x.SetCenterPoint(x,y) versus x.SetCenterPoint(p)) - implicit object that don't need a reference because they are unique ("SystemReboot()") Nevertheless we can treat them all alike (if we want) and have smooth transistions in code: SystemReboot() can also be a System.Reboot(); FileDelete(filename) can also be a File.Delete(filename); (though awkward) and even data (a "virtual structure"): CustomerName can become Customer.Name CustomerAdress can become Customer.Adress What are the advantages of free functions: - no ctor/dtor of objects (FileDelete(filename), string=read(filename)) - transformations not bound into classes ( tree=DirectoryRetTree(path)) - sometime more flexibility - smaller granularity (in development and linking) Disadvantages of free functions: - sometimes less save - not good for inheritance (but who needs to inherit a SystemReboot) -- Helmut Leitner leitner hls.via.at Graz, Austria www.hls-software.com
Oct 18 2003
prev sibling parent reply "Sean L. Palmer" <palmer.sean verizon.net> writes:
Good.

In C++ this is what namespaces were for... but in D, it seems

import Foo;

injects all the identifiers of Foo directly into the importing scope.  You
can still do Foo.method(), but method() will also work, which is not what we
want in this case.  Maybe:

import D.win32.Foo as food;

food.method();

From what Walter says, I guess this works now:

import D.win32.Foo;
alias D.win32.Foo food;

food.method();

Sean


"Matthew Wilson" <matthew stlsoft.org> wrote in message
news:bmr2p1$q6m$2 digitaldaemon.com...
 I've settled on

     D.win32.loader

 with the class

     ExeModule

 and the free functions

     HMODULE ExeModuleLoad(in char[] moduleName);
     HMODULE ExeModuleIncRef(in HMODULE hModule);
     void ExeModuleDecRef(inout HMODULE hModule);
     char[] ExeModuleGetFileName(HMODULE hModule);

 These'll stick until someone comes up with something better.

 I'm still pretty unhappy about the way we're supposed to name free
 functions. To just call them Load, IncRef, DecRef and GetFileName are way
 too general. This is so little discussed that I wonder whether all the
 people who use D are only thinking about it in terms of class and methods.
 No-one ever mentions free functions.

 Maybe I just don't understand the explicit qualification mechanisms, and
 this can all just go away, i.e. one might write
 D.win32.loader.GetFileName(...), but I don't have a handle to the idiom as
 yet.
Oct 18 2003
parent "Matthew Wilson" <matthew.hat stlsoft.dot.org> writes:
I'm still totally clueless about the imports. I guess if the private/public
import is now functional, that should help a lot with these things.

"Sean L. Palmer" <palmer.sean verizon.net> wrote in message
news:bms675$27iv$1 digitaldaemon.com...
 Good.

 In C++ this is what namespaces were for... but in D, it seems

 import Foo;

 injects all the identifiers of Foo directly into the importing scope.  You
 can still do Foo.method(), but method() will also work, which is not what
we
 want in this case.  Maybe:

 import D.win32.Foo as food;

 food.method();

 From what Walter says, I guess this works now:

 import D.win32.Foo;
 alias D.win32.Foo food;

 food.method();

 Sean


 "Matthew Wilson" <matthew stlsoft.org> wrote in message
 news:bmr2p1$q6m$2 digitaldaemon.com...
 I've settled on

     D.win32.loader

 with the class

     ExeModule

 and the free functions

     HMODULE ExeModuleLoad(in char[] moduleName);
     HMODULE ExeModuleIncRef(in HMODULE hModule);
     void ExeModuleDecRef(inout HMODULE hModule);
     char[] ExeModuleGetFileName(HMODULE hModule);

 These'll stick until someone comes up with something better.

 I'm still pretty unhappy about the way we're supposed to name free
 functions. To just call them Load, IncRef, DecRef and GetFileName are
way
 too general. This is so little discussed that I wonder whether all the
 people who use D are only thinking about it in terms of class and
methods.
 No-one ever mentions free functions.

 Maybe I just don't understand the explicit qualification mechanisms, and
 this can all just go away, i.e. one might write
 D.win32.loader.GetFileName(...), but I don't have a handle to the idiom
as
 yet.
Nov 19 2003
prev sibling parent reply Helmut Leitner <leitner hls.via.at> writes:
Matthew Wilson wrote:
 
 I'm writing a simple Win32 module loader class, and naturally I can't call
 it D.win32.module, so wondered whether anyone had any good ideas?
 
 "library" doesn't cut it for me, since it's possible to load things other
 than libraries with it (such as exes).
 "mod" is unpleasant because it's a contraction
 "win32module" is unpleasant because it contains redundant information
Why not D.win32.loader ? -- Helmut Leitner leitner hls.via.at Graz, Austria www.hls-software.com
Oct 18 2003
parent reply "Matthew Wilson" <matthew stlsoft.org> writes:
I kind of like that as well, but I think image is better.

I think I'll change it to D.win32.image, with an Image class that does the
business. I can also make a few nice image-related functions in there for
the moment, and then eventually do a lot of IMAGEHLP type smarts when I get
time.


"Helmut Leitner" <leitner hls.via.at> wrote in message
news:3F90FACF.3A194A hls.via.at...
 Matthew Wilson wrote:
 I'm writing a simple Win32 module loader class, and naturally I can't
call
 it D.win32.module, so wondered whether anyone had any good ideas?

 "library" doesn't cut it for me, since it's possible to load things
other
 than libraries with it (such as exes).
 "mod" is unpleasant because it's a contraction
 "win32module" is unpleasant because it contains redundant information
Why not D.win32.loader ? -- Helmut Leitner leitner hls.via.at Graz, Austria www.hls-software.com
Oct 18 2003
parent reply Helmut Leitner <leitner hls.via.at> writes:
Matthew Wilson wrote:
 
 I kind of like that as well, but I think image is better.
 
 I think I'll change it to D.win32.image, with an Image class that does the
 business. I can also make a few nice image-related functions in there for
 the moment, and then eventually do a lot of IMAGEHLP type smarts when I get
 time.
Please don't. There's no need for this name collision. Image is *the* universal data structure for all graphical, picture, image and image processing work. -- Helmut Leitner leitner hls.via.at Graz, Austria www.hls-software.com
Oct 18 2003
parent reply "Matthew Wilson" <matthew stlsoft.org> writes:
Yeah true, I suppose. Doesn't the module (namespace) mechanism protect us
from such concerns?

I confess I've not really done any thinking about, or use of, the module
stuff in terms of name disambiguation, so am quite unclear as to how it
works.

If I have Image in D.win32.exeimage, and also in D.win32.graphics, how do I
explicitly select one over the other in client code?

In terms of the naming, do you have any better suggestions?

We have (module/class):

 image / Image
 exemod / Module
 exeimage / ExeImage
 loader / ExeModule

any others?


"Helmut Leitner" <leitner hls.via.at> wrote in message
news:3F9106DC.FA440C23 hls.via.at...
 Matthew Wilson wrote:
 I kind of like that as well, but I think image is better.

 I think I'll change it to D.win32.image, with an Image class that does
the
 business. I can also make a few nice image-related functions in there
for
 the moment, and then eventually do a lot of IMAGEHLP type smarts when I
get
 time.
Please don't. There's no need for this name collision. Image is *the* universal data structure for all graphical, picture, image and image processing work. -- Helmut Leitner leitner hls.via.at Graz, Austria www.hls-software.com
Oct 18 2003
parent reply Helmut Leitner <leitner hls.via.at> writes:
What functionality will you provide in this module?

Matthew Wilson wrote:
 ...
 In terms of the naming, do you have any better suggestions?
 
 We have (module/class):
 
  image / Image
  exemod / Module
  exeimage / ExeImage
  loader / ExeModule
 
 any others?
-- Helmut Leitner leitner hls.via.at Graz, Austria www.hls-software.com
Oct 18 2003
parent "Matthew Wilson" <matthew stlsoft.org> writes:
At the moment, it has four free functions (see another part of this thread),
and the ExeModule class, which is an auto class that manages HMODULE via
LoadLibrary/FreeLibrary.

I would think it will grow to include various other smarts, but that's all
there is for now. It's currently only used in the implementation of the
Win32Exception class, in order that the second of its two TranslateError()
methods can load translating messages from a specified handle, as in:

// phobos_D_win32_exception_test.d

import D.win32.exceptions;

int main(char[][] args)
{
    try
    {
        throw new Win32Exception("Just a test", 1013);
    }
    catch(Win32Exception x)
    {
        printf("%.*s: %.*s\n", x.toString(), x.LookupError());
    }

    try
    {
        throw new Win32Exception("Just a test", 12026);
    }
    catch(Win32Exception x)
    {
        printf("%.*s: %.*s\n", x.toString(), x.LookupError("wininet"));
    }

    return 0;
}


which prints

"
Just a test (1013): The configuration registry key could not be written
Just a test (12026): There are outstanding requests
"



"Helmut Leitner" <leitner hls.via.at> wrote in message
news:3F91116F.3F1350EB hls.via.at...
 What functionality will you provide in this module?

 Matthew Wilson wrote:
 ...
 In terms of the naming, do you have any better suggestions?

 We have (module/class):

  image / Image
  exemod / Module
  exeimage / ExeImage
  loader / ExeModule

 any others?
-- Helmut Leitner leitner hls.via.at Graz, Austria www.hls-software.com
Oct 18 2003