Changeset 161

Show
Ignore:
Timestamp:
06/29/06 17:50:59 (2 years ago)
Author:
h3r3tic
Message:

GenericLoader? static lib fixes, linux ALC fix, fixes for SDL and VorbisFile? examples

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/DerelictAL/derelict/openal/alctypes.d

    r153 r161  
    3737else 
    3838{ 
    39     struct ALCdevice {} 
    40     alias void ALCcontext; 
     39/+    struct ALCdevice {} 
     40    alias void ALCcontext;+/ 
    4141} 
    4242 
  • trunk/DerelictAL/derelict/openal/almanual.d

    r153 r161  
    127127    } 
    128128 
    129     alias   GenericLoader!("OpenAL32.dll", "libal.so, libAL.so, libopenal.so, libopenal.so.0", "", loadAL)  DerelictAL; 
    130  
    131129 
    132130    public void loadALU(SharedLib lib) 
     
    148146 
    149147 
    150     alias   GenericDependentLoader!(DerelictAL, loadALU) DerelictALU; 
     148    GenericLoader           DerelictAL; 
     149    GenericDependentLoader  DerelictALU; 
     150    static this() { 
     151        DerelictAL.setup( 
     152            "OpenAL32.dll", 
     153            "libal.so, libAL.so, libopenal.so, libopenal.so.0", 
     154            "", 
     155            &loadAL 
     156        ); 
     157        DerelictALU.setup(&DerelictAL, &loadALU); 
     158    } 
    151159 
    152160 
  • trunk/DerelictAL/derelict/openal/alstatic.d

    r154 r161  
    4242    } 
    4343 
    44     alias   GenericStaticLoader!() DerelictAL; 
    45     alias   GenericStaticLoader!() DerelictALU; 
     44    GenericStaticLoader DerelictAL; 
     45    GenericStaticLoader DerelictALU; 
     46 
     47    static this() { 
     48        DerelictAL.setup(); 
     49        DerelictALU.setup(); 
     50    } 
    4651 
    4752/*    version(Windows) 
  • trunk/DerelictFT/derelict/freetype/ftfuncs.d

    r149 r161  
    3939    } 
    4040 
    41     alias   GenericStaticLoader!() DerelictFT; 
     41    GenericStaticLoader DerelictFT; 
     42 
     43    static this() { 
     44        DerelictFT.setup(); 
     45    } 
    4246} 
    4347else 
     
    301305    } 
    302306 
    303     alias GenericLoader!("freetype.dll", "libfreetype.so", "", loadFT, "2.1.10") DerelictFT; 
     307    GenericLoader DerelictFT; 
     308    static this() { 
     309        DerelictFT.setup( 
     310            "freetype.dll", 
     311            "libfreetype.so", 
     312            "", 
     313            &loadFT, 
     314            "2.1.10" 
     315        ); 
     316    } 
    304317 
    305318 
  • trunk/DerelictGL/derelict/opengl/gl.d

    r149 r161  
    5656 
    5757 
    58 alias   GenericLoader!( "opengl32.dll", 
    59                         "libGL.so", 
    60                         "", 
    61                         loadAll) 
    62         DerelictGL; 
     58 
     59GenericLoader DerelictGL; 
     60static this () { 
     61    DerelictGL.setup ( 
     62        "opengl32.dll", 
     63        "libGL.so", 
     64        "", 
     65        &loadAll 
     66    ); 
     67
     68 
  • trunk/DerelictGLFW/derelict/glfw/glfw.d

    r152 r161  
    303303    pfglfwLoadTexture2D             loadTexture2D; 
    304304 
    305     private void load(SharedLib lib) 
     305    private extern(D) void load(SharedLib lib) 
    306306    { 
    307307        bindFunc(init)("init", lib); 
     
    449449    pfglfwLoadTexture2D             glfwLoadTexture2D; 
    450450 
    451     private void load(SharedLib lib) 
     451    private extern(D) void load(SharedLib lib) 
    452452    { 
    453453        bindFunc(glfwInit)("glfwInit", lib); 
     
    525525 
    526526 
    527 alias GenericLoader!("glfw.dll", "libglfw.so", "", load) DerelictGLFW; 
     527GenericLoader DerelictGLFW; 
     528static this() { 
     529    DerelictGLFW.setup( 
     530        "glfw.dll", 
     531        "libglfw.so", 
     532        "", 
     533        &load 
     534    ); 
     535
    528536 
    529537 
  • trunk/DerelictGLU/derelict/opengl/glu.d

    r149 r161  
    104104 
    105105 
    106 alias GenericLoader!("glu32.dll", "libGLU.so", "", load) DerelictGLU; 
     106GenericLoader DerelictGLU; 
     107static this() { 
     108    DerelictGLU.setup( 
     109        "glu32.dll", 
     110        "libGLU.so", 
     111        "", 
     112        &load 
     113    ); 
     114
    107115 
    108116//============================================================================== 
  • trunk/DerelictIL/derelict/devil/ilfuncs.d

    r149 r161  
    131131 
    132132 
    133 alias GenericLoader!("devil.dll", "libIL.so", "", loadIL) DerelictIL; 
     133GenericLoader DerelictIL; 
     134static this() { 
     135    DerelictIL.setup( 
     136        "devil.dll", 
     137        "libIL.so", 
     138        "", 
     139        &loadIL 
     140    ); 
     141
    134142 
    135143 
  • trunk/DerelictILU/derelict/devil/ilufuncs.d

    r149 r161  
    9090 
    9191 
    92 alias GenericLoader!("ilu.dll", "libILU.so", "", loadILU) DerelictILU; 
     92GenericLoader DerelictILU; 
     93static this() { 
     94    DerelictILU.setup( 
     95        "ilu.dll", 
     96        "libILU.so", 
     97        "", 
     98        &loadILU 
     99    ); 
     100
    93101 
    94102 
  • trunk/DerelictILUT/derelict/devil/ilutfuncs.d

    r149 r161  
    9191 
    9292 
    93 alias GenericLoader!("ilut.dll", "libILUT.so", "", loadILUT) DerelictILUT; 
     93GenericLoader DerelictILUT; 
     94static this() { 
     95    DerelictILUT.setup( 
     96        "ilut.dll", 
     97        "libILUT.so", 
     98        "", 
     99        &loadILUT 
     100    ); 
     101
    94102 
    95103 
  • trunk/DerelictOgg/derelict/ogg/ogg.d

    r149 r161  
    123123 
    124124 
    125 alias   GenericLoader!( "ogg.dll", 
    126                         "libogg.so, libogg.so.0", 
    127                         "", 
    128                         loadOgg) 
    129         DerelictOgg; 
     125GenericLoader DerelictOgg; 
     126static this() { 
     127    DerelictOgg.setup( 
     128        "ogg.dll", 
     129        "libogg.so, libogg.so.0", 
     130        "", 
     131        &loadOgg 
     132    ); 
     133
    130134 
    131135 
  • trunk/DerelictSDL/derelict/sdl/sdl.d

    r149 r161  
    305305 
    306306 
    307 alias   GenericLoader!( "sdl.dll", 
    308                         "libSDL.so, libSDL.so.0, libSDL-1.2.so, libSDL-1.2.so.0", 
    309                         "", 
    310                         load) 
    311         DerelictSDL; 
     307GenericLoader DerelictSDL; 
     308static this() { 
     309    DerelictSDL.setup( 
     310        "sdl.dll", 
     311        "libSDL.so, libSDL.so.0, libSDL-1.2.so, libSDL-1.2.so.0", 
     312        "", 
     313        &load 
     314    ); 
     315
  • trunk/DerelictSDLImage/derelict/sdl/image.d

    r149 r161  
    140140 
    141141 
    142 alias   GenericLoader!( "SDL_image.dll", 
    143                         "libSDL_image.so, libSDL_image-1.2.so, libSDL_image-1.2.so.0", 
    144                         "", 
    145                         load) 
    146         DerelictSDLImage; 
     142GenericLoader DerelictSDLImage; 
     143static this() { 
     144    DerelictSDLImage.setup( 
     145        "SDL_image.dll", 
     146        "libSDL_image.so, libSDL_image-1.2.so, libSDL_image-1.2.so.0", 
     147        "", 
     148        &load 
     149    ); 
     150
    147151 
  • trunk/DerelictSDLMixer/derelict/sdl/mixer.d

    r149 r161  
    340340 
    341341 
    342 alias   GenericLoader!( "SDL_mixer.dll", 
    343                         "libSDL_mixer.so, libSDL_mixer-1.2.so, libSDL_mixer-1.2.so.0", 
    344                         "", 
    345                         load) 
    346         DerelictSDLMixer; 
    347  
     342GenericLoader DerelictSDLMixer; 
     343static this() { 
     344    DerelictSDLMixer.setup( 
     345        "SDL_mixer.dll", 
     346        "libSDL_mixer.so, libSDL_mixer-1.2.so, libSDL_mixer-1.2.so.0", 
     347        "", 
     348        &load 
     349    ); 
     350
  • trunk/DerelictSDLNet/derelict/sdl/net.d

    r149 r161  
    262262 
    263263 
    264 alias   GenericLoader!( "SDL_net.dll", 
    265                         "libSDL_net.so, libSDL_net-1.2.so, libSDL_net-1.2.so.0", 
    266                         "", 
    267                         load) 
    268         DerelictSDLNet; 
    269  
     264GenericLoader DerelictSDLNet; 
     265static this() { 
     266    DerelictSDLNet.setup( 
     267        "SDL_net.dll", 
     268        "libSDL_net.so, libSDL_net-1.2.so, libSDL_net-1.2.so.0", 
     269        "", 
     270        &load 
     271    ); 
     272
  • trunk/DerelictSDLttf/derelict/sdl/ttf.d

    r149 r161  
    211211 
    212212 
    213 alias   GenericLoader!( "SDL_ttf.dll", 
    214                         "libSDL_ttf.so, libSDL_ttf-2.0.so, libSDL_ttf-2.0.so.0", 
    215                         "", 
    216                         load) 
    217         DerelictSDLttf; 
    218  
     213GenericLoader DerelictSDLttf; 
     214static this() { 
     215    DerelictSDLttf.setup( 
     216        "SDL_ttf.dll", 
     217        "libSDL_ttf.so, libSDL_ttf-2.0.so, libSDL_ttf-2.0.so.0", 
     218        "", 
     219        &load 
     220    ); 
     221
  • trunk/DerelictUtil/derelict/util/loader.d

    r149 r161  
    217217//============================================================================== 
    218218 
    219 package final class GenericLoader(char[] winLibs, char[] linLibs, char[] macLibs, alias userLoad, char[] versionStr = "") { 
    220     private import std.string; 
    221  
    222     public static void load(char[] libNameString = null) 
     219struct GenericLoader { 
     220    void setup(char[] winLibs, char[] linLibs, char[] macLibs, void function(SharedLib) userLoad, char[] versionStr = "") { 
     221        assert (userLoad !is null); 
     222        this.winLibs = winLibs; 
     223        this.linLibs = linLibs; 
     224        this.macLibs = macLibs; 
     225        this.userLoad = userLoad; 
     226        this.versionStr = versionStr; 
     227    } 
     228 
     229    void load(char[] libNameString = null) 
    223230    { 
    224231        if (myLib !is null) { 
    225232            return; 
    226233        } 
     234 
     235        // make sure the lib will be unloaded at progam termination 
     236        registeredLoaders ~= this; 
     237 
    227238 
    228239        if (libNameString is null) { 
     
    244255    } 
    245256 
    246     public static char[] versionString() 
     257    char[] versionString() 
    247258    { 
    248259        return versionStr; 
    249260    } 
    250261 
    251     public static void unload() 
    252     { 
    253         Derelict_UnloadSharedLib(myLib); 
     262    void unload() 
     263    { 
     264        if (myLib !is null) { 
     265            Derelict_UnloadSharedLib(myLib); 
     266            myLib = null; 
     267        } 
    254268    } 
    255269 
    256270    static ~this() 
    257271    { 
    258         unload(); 
    259     } 
    260  
    261     private this() 
    262     { 
    263         // don't create me ! 
    264     } 
    265  
    266     private static SharedLib myLib; 
    267 
    268  
    269 //============================================================================== 
    270  
    271 package final class GenericDependentLoader(alias dependence, alias userLoad) { 
    272     private static SharedLib myLib() { 
     272        foreach (x; registeredLoaders) { 
     273            x.unload(); 
     274        } 
     275    } 
     276 
     277    private { 
     278        static GenericLoader*[] registeredLoaders; 
     279 
     280        SharedLib myLib; 
     281        char[] winLibs; 
     282        char[] linLibs; 
     283        char[] macLibs; 
     284        char[] versionStr = ""; 
     285         
     286        void function(SharedLib) userLoad; 
     287    } 
     288
     289 
     290//============================================================================== 
     291 
     292struct GenericDependentLoader { 
     293    void setup(GenericLoader* dependence, void function(SharedLib) userLoad) { 
     294        assert (dependence !is null); 
     295        assert (userLoad !is null); 
     296 
     297        this.dependence = dependence; 
     298        this.userLoad = userLoad; 
     299    } 
     300 
     301    private SharedLib myLib() { 
    273302        return dependence.myLib; 
    274303    } 
    275304 
    276     public static void load() 
     305    void load() 
    277306    { 
    278307        assert (myLib !is null); 
     
    280309    } 
    281310 
    282     public static char[] versionString() 
     311    char[] versionString() 
    283312    { 
    284313        return dependence.versionString; 
    285314    } 
    286315 
    287     public static void unload() 
    288     { 
    289     } 
    290  
    291     static ~this() 
    292     { 
    293         unload(); 
    294     } 
    295  
    296     private this() 
    297     { 
    298         // don't create me ! 
    299     } 
    300 
    301  
    302 //============================================================================== 
    303  
    304 private void noLoader() {} 
    305  
    306 package final class GenericStaticLoader(alias userLoad = noLoader, char[] versionStr = "") { 
    307     private import std.string; 
    308  
    309     public static void load(char[] libNameString = null) 
    310     { 
    311         userLoad(); 
    312     } 
    313  
    314     public static char[] versionString() 
    315     { 
    316         return versionStr; 
    317     } 
    318  
    319     public static void unload() 
    320     { 
    321     } 
    322  
    323     static ~this() 
    324     { 
    325         unload(); 
    326     } 
    327  
    328     private this() 
    329     { 
    330         // don't create me ! 
    331     } 
    332 
     316    void unload() 
     317    { 
     318    } 
     319 
     320    private { 
     321        GenericLoader*              dependence; 
     322        void function(SharedLib)    userLoad; 
     323    } 
     324
     325 
     326//============================================================================== 
     327 
     328struct GenericStaticLoader { 
     329    void setup(void function() userLoad = null, char[] versionStr = "") { 
     330        this.userLoad = userLoad; 
     331        this.versionStr = versionStr; 
     332    } 
     333 
     334    void load() 
     335    { 
     336        if (userLoad !is null) { 
     337            userLoad(); 
     338        } 
     339    } 
     340 
     341    char[] versionString() 
     342    { 
     343        return versionString; 
     344    } 
     345 
     346    void unload() 
     347    { 
     348    } 
     349 
     350    private { 
     351        char[]          versionStr; 
     352        void function() userLoad; 
     353    } 
     354
     355 
    333356 
    334357//============================================================================== 
  • trunk/DerelictVorbis/derelict/ogg/vorbiscodec.d

    r151 r161  
    8989} // loadVorbis() 
    9090 
    91 alias   GenericLoader!( "vorbis.dll", 
    92                         "libvorbis.so, libvorbis.so.0, libvorbis.so.0.3.0", 
    93                         "", 
    94                         loadVorbis) 
    95         DerelictVorbis; 
     91 
     92GenericLoader DerelictVorbis; 
     93static this() { 
     94    DerelictVorbis.setup( 
     95        "vorbis.dll", 
     96        "libvorbis.so, libvorbis.so.0, libvorbis.so.0.3.0", 
     97        "", 
     98        &loadVorbis 
     99    ); 
     100
    96101 
    97102 
  • trunk/DerelictVorbis/derelict/ogg/vorbisfile.d

    r149 r161  
    9797 
    9898 
    99 alias   GenericLoader!( "vorbisfile.dll", 
    100                         "libvorbisfile.so, libvorbisfile.so.3, libvorbisfile.so.3.1.0", 
    101                         "", 
    102                         loadVorbisFile) 
    103         DerelictVorbisFile; 
    104  
     99GenericLoader DerelictVorbisFile; 
     100static this() { 
     101    DerelictVorbisFile.setup( 
     102        "vorbisfile.dll", 
     103        "libvorbisfile.so, libvorbisfile.so.3, libvorbisfile.so.3.1.0", 
     104        "", 
     105        &loadVorbisFile 
     106    ); 
     107
    105108 
    106109 
  • trunk/examples/sdl_ex1.d

    r114 r161  
    7373{ 
    7474    // load the SDL shared library 
    75     DerelictSDL_Load(); 
     75    DerelictSDL.load(); 
    7676     
    7777    // Initialize SDL 
  • trunk/examples/vorbisfile_example.d

    r149 r161  
    88import std.c.stdio; 
    99import std.file; 
    10 import derelict.vorbis.vorbisfile; 
     10import derelict.ogg.vorbisfile; 
     11import derelict.ogg.vorbistypes; 
    1112 
    1213// take 4k out of the data segment, not the stack 
     
    1718 
    1819    // Init 
    19     DerelictVorbis_LoadVorbisFile(); 
     20    DerelictVorbisFile.load(); 
    2021 
    2122    OggVorbis_File vf;