reloaded 0.1.0

Live Reloading D code with dynamic libraries


To use this package, run the following command in your project's root directory:

Manual usage
Put the following dependency into your project's dependences section:

ReloadeD

ReloadeD is a simple library for live code reloading based on dynamic libraries.

ReloadeD is on experimental stage and have been tested only on windows.

Show And Tell

ReloadeD works with a simple Host application, and a Client Library.

//HOST APPLICATION

struct Data
{
    int value;
}

void main()
{
    import reloaded : Reloaded;
    import std.stdio : writeln;

    Reloaded script;
    Data userdata;
    /*
    Load the library, and pass the data that will be shared between HOST and CLIENT.
    */
    script.load("path/lib.dll", userdata );

    /*
    update() will call the method with same name at the client side and will reload the library when it changes automatically(and will call load()/unload() when necessary).
    */

    while(true)
    {
        script.update();
        //see the data changed by the client here
        writeln(data);
    }
}

The client can be used with 5 functions:

void init(void*) and void uninit(void*)

Will be called on the first lib load and when the host is destroyed(or you change the lib path). It receive the userdata;

void load(void*) and void unload(void*)

Will be called once every time the client changes. It receive the userdata;

void update()

Can be called at will on the host side (normally inside a loop).

ReloadeD will continue to work even if you don´t declare all possible functions.

Note that you don´t need Reloaded module on the client side so you can reload dynamic libraries from any language :)

//CLIENT LIBRARY

import core.sys.windows.dll;
import core.stdc.stdio : printf;
mixin SimpleDllMain;

extern(C):
nothrow:

//Same struct declared on Host
struct Data
{
    int x;
    int y;
}

Data* userdata;

void load( void* _userdata )
{
    printf("load\n");
    //capture data coming from Host.
    userdata = cast(Data*) _userdata;
}
void unload(void* userdata){
    printf("unload\n");
}
void init(void* userdata){
    printf("init\n");
}
void uninit(void* userdata){
    printf("uninit\n");
}
void update()
{
    //change value here, recompile and see the changes on the host side :)
    userdata.value = 10;
}

Reloaded was inspired by cr.h.

License

The MIT License (MIT)

Copyright (c) 2017 Danny Angelo Carminati Grein

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Authors:
  • Patric Dexheimer
Dependencies:
derelict-util, fswatch
Versions:
0.1.5 2019-Jun-13
0.1.4 2018-Oct-17
0.1.3 2018-Oct-16
0.1.2 2018-Sep-24
0.1.1 2018-Sep-24
Show all 7 versions
Download Stats:
  • 0 downloads today

  • 0 downloads this week

  • 0 downloads this month

  • 893 downloads total

Score:
1.9
Short URL:
reloaded.dub.pm