Changeset 40

Show
Ignore:
Timestamp:
03/28/05 00:10:14 (4 years ago)
Author:
pragma
Message:

--

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/core/Utils.d

    r37 r40  
    445445} 
    446446 
    447 /+ 
     447/* 
    448448debug{ 
    449449    private import mango.io.Buffer; 
     
    481481    } 
    482482} 
    483 +
     483*
  • trunk/expat/expat.d

    r37 r40  
    2525module expat.expat; 
    2626 
     27version(build){  
     28    pragma(nolink);  
     29    pragma(link,expat); 
     30} 
    2731 
    2832version(EXPAT_UTF16){ 
  • trunk/misc/DLLStub.d

    r36 r40  
    4444    import std.moduleinit; 
    4545 
    46     void debugModuleCtor(){ 
    47        writefln("\n--MODULE INFO--\n"); 
    48  
    49        foreach(ModuleInfo info; _moduleinfo_array){ 
    50           writefln("%s", info.name); 
    51           foreach(ModuleInfo imported; info.importedModules){ 
    52              writefln("\timport %s",imported.name); 
    53           } 
    54        } 
    55     } 
    56          
    5746    extern (Windows) BOOL DllMain(HINSTANCE hInstance, ULONG ulReason, LPVOID pvReserved) 
    5847    { 
     
    8877        return true; 
    8978    } 
    90      
    91     version(build){ 
    92         pragma(build_def, "LIBRARY         'typelib'"); 
    93         pragma(build_def, "DESCRIPTION     'D Type Library'"); 
    94         pragma(build_def, "EXETYPE          NT"); 
    95         pragma(build_def, "SUBSYSTEM        WINDOWS"); 
    96         pragma(build_def, "CODE            PRELOAD DISCARDABLE"); 
    97         pragma(build_def, "DATA            PRELOAD SINGLE"); 
    98         pragma(build_def, "EXPORTS"); 
    99         pragma(build_def, "__initalizeDll"); 
    100         pragma(build_def, "__finalizeDll"); 
    101     }    
    10279} 
    10380else{ 
     
    10582} 
    10683 
     84 
     85// exports section 
    10786extern(C){ 
    10887    export void __initalizeDll(void* gcHandle){ 
  • trunk/misc/Exportable.d

    r36 r40  
    2424*/ 
    2525module misc.Exportable; 
    26  
     26     
    2727interface IExportable{ 
    2828    byte[] serialize(); 
     
    3232template ExportableAdapterMixin(){ 
    3333    public byte[] serialize(){ 
     34        return null; 
    3435    } 
    3536    public void deserialize(byte[] data){ 
    3637    } 
    3738} 
    38  
     39     
    3940// Performs a dynamic cast via classname, and expects an 'interface' reference 
    4041// as an input. 
  • trunk/misc/Finalizable.d

    r36 r40  
    2323    OTHER DEALINGS IN THE SOFTWARE. 
    2424*/ 
    25 module misc.finalizable; 
     25module misc.Finalizable; 
    2626 
    2727interface IFinalizable{ 
  • trunk/misc/Library.d

    r36 r40  
    2424*/ 
    2525 
    26 module misc.library; 
     26module misc.Library; 
    2727private import std.string; 
    2828private import std.gc; 
     
    114114/*** Library ***/ 
    115115 
     116alias char[] function() GetExceptionHandle; 
     117 
    116118class Library: LibraryBase{ 
    117119    private LibraryModule lib; 
    118120    private char[] libraryPath; 
     121 
     122    protected GetExceptionHandle getExceptionImpl; 
    119123 
    120124    public LibraryNotificationDelegate[] onUnload; 
     
    157161            if(dllInit){ 
    158162                dllInit(std.gc.getGCHandle()); 
    159             } 
     163            }            
     164            getExceptionImpl = cast(GetExceptionHandle)(getSymbol("__getException")); 
    160165        } 
    161166    } 
     
    179184        return(getSymbolImpl(lib,symbolName)); 
    180185    } 
     186     
     187    public Exception getException(){ 
     188        if(getExceptionImpl){ 
     189            return new Exception(getExceptionImpl().dup); 
     190        } 
     191        return null; 
     192    } 
    181193} 
    182194 
  • trunk/misc/LibraryCache.d

    r36 r40  
    2626private import misc.Library; 
    2727private import misc.Finalizable; 
    28 private import std.string; 
    29 private import std.gc; 
    3028 
    3129/*** LibraryCache *** 
     
    4341 
    4442class LibraryCache: IFinalizable{ 
    45     Library[char[]] cache; 
     43    protected Library[char[]] cache; 
    4644     
    4745    public this(){ 
     
    6563    } 
    6664     
    67     protected synchronized void unloadLibrary(Library lib){ 
     65    protected void unloadLibrary(Library lib){ 
    6866        cache[lib.getPath()] = null; 
    6967    } 
    7068     
    71     public synchronized Library load(char[] libPath,Library function(char[]) createLibrary){ 
     69    public Library load(char[] libPath,Library function(char[]) createLibrary){ 
    7270        Library lib; 
    7371        lib = cache[libPath]; 
     
    8684    } 
    8785     
    88     public synchronized Library load(char[] libPath){ 
     86    public Library load(char[] libPath){ 
    8987        return this.load(libPath,&Library.create); 
    9088    } 
    9189     
    9290    // perform an operation, 'callback', on each entry in the cache 
    93     public synchronized void ForEach(bit delegate(Library) callback){ 
     91    public void ForEach(bit delegate(Library) callback){ 
    9492        foreach(Library lib; cache){ 
    9593            if(lib && callback(lib)) break; 
  • trunk/misc/ObjectProxy.d

    r36 r40  
    2525module misc.ObjectProxy; 
    2626 
    27 private import misc.Exportable; 
    28 private import misc.TypeLibrary; 
     27private import  misc.Exportable, 
     28                misc.Library, 
     29                misc.TypeLibrary; 
    2930 
    3031class ExportableObjectProxy{ 
     
    3233    char[] remoteClass; 
    3334    byte[] serializationData; 
     35    GetExceptionHandle getExceptionImpl; 
    3436     
    35     public this(IExportable remote,char[] typename){ 
     37    public this(IExportable remote,char[] typename,GetExceptionHandle getExceptionImpl){ 
    3638        this.remote = remote; 
    3739        this.remoteClass = typename; 
    3840        this.serializationData = null; 
     41        this.getExceptionImpl = getExceptionImpl; 
    3942    } 
    4043     
     
    6568        return this.remote; 
    6669    } 
     70     
     71    public void processCallException(){ 
     72        if(getExceptionImpl){ 
     73            char[] e = getExceptionImpl(); 
     74            //TODO: should try to dynamically recreate the type of exception object here 
     75            //      since the object re-thrown is just a plain 'ol "exception" 
     76            if(e) throw new Exception(e.dup); 
     77        } 
     78    }    
    6779} 
    6880 
     
    7789    } 
    7890    protected TInterface getInstance(){ 
    79         IExportable remote = __proxy.getInstance(); 
     91        IExportable remote = this.__proxy.getInstance(); 
    8092        return export_cast!(TInterface)(remote); 
    8193    } 
    82      
     94    protected void processCallException(){ 
     95        this.__proxy.processCallException(); 
     96    }    
    8397} 
  • trunk/misc/TypeLibrary.d

    r36 r40  
    2424*/ 
    2525 
    26 module misc.typeLibrary; 
     26module misc.TypeLibrary; 
    2727 
    2828private import misc.Library; 
    2929private import misc.Exportable; 
    3030private import misc.ObjectProxy; 
    31 private import misc.Util; 
    32  
    33 static this(){ 
    34 } 
    3531 
    3632alias TypeInfo[char[]] function() GetTypesHandle; 
    3733alias void* function(char[] typename) GetInstanceHandle; 
    3834alias void function(IExportable obj) DestroyObjectHandle; 
    39  
    4035 
    4136/*** TypeLibrary ***/ 
     
    7166            throw new LibraryException(this,"could not locate type library handles"); 
    7267        } 
     68        else{ 
     69            printf("load complete!\n"); 
     70        } 
    7371    } 
    7472 
     
    8280        if(!remote) return null; 
    8381         
    84         ExportableObjectProxy proxy = new ExportableObjectProxy(remote,typename); 
     82        ExportableObjectProxy proxy = new ExportableObjectProxy(remote,typename,getExceptionImpl); 
    8583        this.proxies[proxy] = proxy; 
    8684        return(proxy); 
     
    106104    public void destroyObject(ExportableObjectProxy proxy){ 
    107105        destroyObjectImpl(proxy.getInstance()); 
     106        this.proxies[proxy] = null; //TODO: remove from list 
    108107    } 
    109108} 
  • trunk/misc/TypeLibrary.def

    r36 r40  
    66CODE            PRELOAD DISCARDABLE 
    77DATA            PRELOAD SINGLE 
     8 
     9EXPORTS 
  • trunk/misc/TypeLibraryDLLStub.d

    r36 r40  
    2626module misc.TypeLibraryDLLStub; 
    2727 
    28 import misc.Exportable; 
    29 import misc.SystemFinalizer; 
     28private import misc.Exportable; 
     29private import misc.SystemFinalizer; 
     30private import misc.DLLStub; 
    3031 
    3132/*** stub variables ***/ 
     
    5758IExportable getInstanceImpl(char[] typename){ 
    5859    IExportable obj = null; 
    59      
     60         
     61    //writefln("TypeLibraryDLLStub.getInstanceImpl(%s)",typename); 
     62         
    6063    if(typename in typeConstructors){ 
    6164        obj = typeConstructors[typename](); 
     
    6669        } 
    6770    } 
     71    //else{ 
     72    //  writefln("failed: %s not in typeConstructors",typename); 
     73    //} 
    6874             
    6975    return(obj); 
     
    95101} 
    96102 
    97 version(Windows) version(build){ 
    98     pragma (build_def, "getTypes"); 
    99     pragma (build_def, "getInstance"); 
    100     pragma (build_def, "destroyObject"); 
    101 } 
    102  
    103103/*** CtorAdapter ***/ 
    104104class CtorAdapter{ 
     
    113113    } 
    114114} 
     115 
     116private import std.stdio; 
    115117 
    116118/*** exportType ***/