~octaspire/dern

2ceb5c2b041bf501d5d9fc84d27d258ccd32ece7 — octaspire 1 year, 5 months ago 9dc6200 v0.481.0
Build embedding example, ncurses plugin and socket plugin with MSVC in Windows
M dev/include/octaspire/dern/octaspire_dern_config.h => dev/include/octaspire/dern/octaspire_dern_config.h +1 -1
@@ 18,7 18,7 @@ limitations under the License.
#define OCTASPIRE_DERN_CONFIG_H

#define OCTASPIRE_DERN_CONFIG_VERSION_MAJOR "0"
#define OCTASPIRE_DERN_CONFIG_VERSION_MINOR "480"
#define OCTASPIRE_DERN_CONFIG_VERSION_MINOR "481"
#define OCTASPIRE_DERN_CONFIG_VERSION_PATCH "0"

#define OCTASPIRE_DERN_CONFIG_VERSION_STR "Octaspire Dern version " \

M release/how-to-build/windows-msvc.bat => release/how-to-build/windows-msvc.bat +37 -0
@@ 13,6 13,18 @@ cl /nologo /W3 /DOCTASPIRE_DERN_AMALGAMATED_UNIT_TEST_IMPLEMENTATION octaspire-d


@ECHO -----------------------------------------------------------------
@ECHO embedding example
@ECHO -----------------------------------------------------------------
cl /nologo /W2 /I. /DOCTASPIRE_DERN_CONFIG_BINARY_PLUGINS examples\embedding-example.c /link /out:embedding-example.exe
@ECHO.
@ECHO RUN WITH:
@ECHO embedding-example.exe
@ECHO.
@ECHO BUILD WITH:
@ECHO cl /W2 /I. /DOCTASPIRE_DERN_CONFIG_BINARY_PLUGINS examples\embedding-example.c /link /out:embedding-example.exe


@ECHO -----------------------------------------------------------------
@ECHO interactive Dern REPL:
@ECHO -----------------------------------------------------------------
cl /nologo /W2 /DOCTASPIRE_DERN_AMALGAMATED_REPL_IMPLEMENTATION /DOCTASPIRE_DERN_CONFIG_BINARY_PLUGINS octaspire-dern-amalgamated.c /link /out:octaspire-dern-repl.exe


@@ 34,3 46,28 @@ cl /nologo /W2 /I. /DOCTASPIRE_DERN_AMALGAMATED_IMPLEMENTATION /LD examples\myli
@ECHO.
@ECHO BUILD WITH:
@ECHO cl /W2 /I. /DOCTASPIRE_DERN_AMALGAMATED_IMPLEMENTATION /LD examples\mylib.c /link /out:libmylib.dll


@ECHO -----------------------------------------------------------------
@ECHO Dern socket plugin
@ECHO -----------------------------------------------------------------
cl /nologo /W2 /I. /DOCTASPIRE_DERN_AMALGAMATED_IMPLEMENTATION /LD plugins\dern_socket.c /link ws2_32.lib /out:libdern_socket.dll
@ECHO.
@ECHO RUN WITH:
@ECHO octaspire-dern-repl.exe examples\irc-client-ncurses.dern
@ECHO octaspire-dern-repl.exe examples\irc-client-nuklear.dern
@ECHO.
@ECHO BUILD WITH:
@ECHO cl /W2 /I. /DOCTASPIRE_DERN_AMALGAMATED_IMPLEMENTATION /LD plugins\dern_socket.c /link ws2_32.lib /out:libdern_socket.dll


@ECHO -----------------------------------------------------------------
@ECHO Dern ncurses plugin
@ECHO -----------------------------------------------------------------
cl /nologo /W2 /I. /DOCTASPIRE_DERN_AMALGAMATED_IMPLEMENTATION /LD plugins\dern_ncurses.c /link pdcurses.lib /out:libdern_ncurses.dll
@ECHO.
@ECHO RUN WITH:
@ECHO octaspire-dern-repl.exe examples\dern-ncurses-example.dern
@ECHO.
@ECHO BUILD WITH:
@ECHO cl /nologo /W2 /I. /DOCTASPIRE_DERN_AMALGAMATED_IMPLEMENTATION /LD plugins\dern_ncurses.c /link pdcurses.lib /out:libdern_ncurses.dll

M release/octaspire-dern-amalgamated.c => release/octaspire-dern-amalgamated.c +1 -1
@@ 26336,7 26336,7 @@ limitations under the License.
#define OCTASPIRE_DERN_CONFIG_H

#define OCTASPIRE_DERN_CONFIG_VERSION_MAJOR "0"
#define OCTASPIRE_DERN_CONFIG_VERSION_MINOR "480"
#define OCTASPIRE_DERN_CONFIG_VERSION_MINOR "481"
#define OCTASPIRE_DERN_CONFIG_VERSION_PATCH "0"

#define OCTASPIRE_DERN_CONFIG_VERSION_STR "Octaspire Dern version " \

M release/plugins/dern_ncurses.c => release/plugins/dern_ncurses.c +80 -2
@@ 59,12 59,18 @@ limitations under the License.

static char const * const DERN_NCURSES_PLUGIN_NAME = "dern_ncurses";

#ifdef _MSC_VER
extern __declspec(dllexport)
#endif
void dern_ncurses_window_clean_up_callback(void *payload)
{
    octaspire_helpers_verify_not_null(payload);
    endwin();
}

#ifdef _MSC_VER
extern __declspec(dllexport)
#endif
octaspire_dern_value_t *dern_ncurses_initscr(
    octaspire_dern_vm_t * const vm,
    octaspire_dern_value_t * const arguments,


@@ 89,7 95,9 @@ octaspire_dern_value_t *dern_ncurses_initscr(
        window);
}


#ifdef _MSC_VER
extern __declspec(dllexport)
#endif
octaspire_dern_value_t *dern_ncurses_getmaxyx(
    octaspire_dern_vm_t * const vm,
    octaspire_dern_value_t * const arguments,


@@ 164,6 172,9 @@ octaspire_dern_value_t *dern_ncurses_getmaxyx(
        octaspire_dern_vm_create_new_value_integer(vm, (int32_t)x));
}

#ifdef _MSC_VER
extern __declspec(dllexport)
#endif
octaspire_dern_value_t *dern_ncurses_getch(
    octaspire_dern_vm_t * const vm,
    octaspire_dern_value_t * const arguments,


@@ 235,7 246,9 @@ octaspire_dern_value_t *dern_ncurses_getch(
        }

        case KEY_DC:
#ifndef _MSC_VER
        case OCTASPIRE_DERN_NCURSES_ADDITIONAL_KEY_DC:
#endif
        {
            return octaspire_dern_vm_create_new_value_symbol_from_c_string(vm, "KEY_DC");
        }


@@ 250,6 263,9 @@ octaspire_dern_value_t *dern_ncurses_getch(
    }
}

#ifdef _MSC_VER
extern __declspec(dllexport)
#endif
octaspire_dern_value_t *dern_ncurses_getstr(
    octaspire_dern_vm_t * const vm,
    octaspire_dern_value_t * const arguments,


@@ 371,6 387,9 @@ octaspire_dern_value_t *dern_ncurses_getstr(
    return octaspire_dern_vm_create_new_value_string(vm, resultStr);
}

#ifdef _MSC_VER
extern __declspec(dllexport)
#endif
octaspire_dern_value_t *dern_ncurses_set_raw(
    octaspire_dern_vm_t * const vm,
    octaspire_dern_value_t * const arguments,


@@ 412,6 431,9 @@ octaspire_dern_value_t *dern_ncurses_set_raw(
    return octaspire_dern_vm_create_new_value_boolean(vm, result != ERR);
}

#ifdef _MSC_VER
extern __declspec(dllexport)
#endif
octaspire_dern_value_t *dern_ncurses_set_timeout(
    octaspire_dern_vm_t * const vm,
    octaspire_dern_value_t * const arguments,


@@ 465,6 487,9 @@ octaspire_dern_value_t *dern_ncurses_set_timeout(
    return octaspire_dern_vm_create_new_value_integer(vm, delay);
}

#ifdef _MSC_VER
extern __declspec(dllexport)
#endif
octaspire_dern_value_t *dern_ncurses_set_cbreak(
    octaspire_dern_vm_t * const vm,
    octaspire_dern_value_t * const arguments,


@@ 505,6 530,9 @@ octaspire_dern_value_t *dern_ncurses_set_cbreak(
    return octaspire_dern_vm_create_new_value_boolean(vm, result != ERR);
}

#ifdef _MSC_VER
extern __declspec(dllexport)
#endif
octaspire_dern_value_t *dern_ncurses_set_echo(
    octaspire_dern_vm_t * const vm,
    octaspire_dern_value_t * const arguments,


@@ 545,6 573,9 @@ octaspire_dern_value_t *dern_ncurses_set_echo(
    return octaspire_dern_vm_create_new_value_boolean(vm, result != ERR);
}

#ifdef _MSC_VER
extern __declspec(dllexport)
#endif
octaspire_dern_value_t *dern_ncurses_set_nl(
    octaspire_dern_vm_t * const vm,
    octaspire_dern_value_t * const arguments,


@@ 585,6 616,9 @@ octaspire_dern_value_t *dern_ncurses_set_nl(
    return octaspire_dern_vm_create_new_value_nil(vm);
}

#ifdef _MSC_VER
extern __declspec(dllexport)
#endif
octaspire_dern_value_t *dern_ncurses_set_cursor(
    octaspire_dern_vm_t * const vm,
    octaspire_dern_value_t * const arguments,


@@ 685,6 719,9 @@ octaspire_dern_value_t *dern_ncurses_set_cursor(
    return octaspire_dern_vm_create_new_value_symbol_from_c_string(vm, "very-visible");
}

#ifdef _MSC_VER
extern __declspec(dllexport)
#endif
octaspire_dern_value_t *dern_ncurses_set_keypad(
    octaspire_dern_vm_t * const vm,
    octaspire_dern_value_t * const arguments,


@@ 759,6 796,9 @@ octaspire_dern_value_t *dern_ncurses_set_keypad(
    return octaspire_dern_vm_create_new_value_boolean(vm, result != ERR);
}

#ifdef _MSC_VER
extern __declspec(dllexport)
#endif
octaspire_dern_value_t *dern_ncurses_erase(
    octaspire_dern_vm_t * const vm,
    octaspire_dern_value_t * const arguments,


@@ 818,6 858,9 @@ octaspire_dern_value_t *dern_ncurses_erase(
    return octaspire_dern_vm_create_new_value_boolean(vm, result != ERR);
}

#ifdef _MSC_VER
extern __declspec(dllexport)
#endif
octaspire_dern_value_t *dern_ncurses_clear(
    octaspire_dern_vm_t * const vm,
    octaspire_dern_value_t * const arguments,


@@ 994,6 1037,9 @@ static int dern_ncurses_private_print_symbol(
    return result;
}

#ifdef _MSC_VER
extern __declspec(dllexport)
#endif
octaspire_dern_value_t *dern_ncurses_print(
    octaspire_dern_vm_t * const vm,
    octaspire_dern_value_t * const arguments,


@@ 1250,6 1296,9 @@ octaspire_dern_value_t *dern_ncurses_print(
    abort();
}

#ifdef _MSC_VER
extern __declspec(dllexport)
#endif
octaspire_dern_value_t *dern_ncurses_halfdelay(
    octaspire_dern_vm_t * const vm,
    octaspire_dern_value_t * const arguments,


@@ 1292,6 1341,9 @@ octaspire_dern_value_t *dern_ncurses_halfdelay(
    return octaspire_dern_vm_create_new_value_boolean(vm, result != ERR);
}

#ifdef _MSC_VER
extern __declspec(dllexport)
#endif
octaspire_dern_value_t *dern_ncurses_move(
    octaspire_dern_vm_t * const vm,
    octaspire_dern_value_t * const arguments,


@@ 1388,6 1440,9 @@ octaspire_dern_value_t *dern_ncurses_move(
    return octaspire_dern_vm_create_new_value_boolean(vm, result != ERR);
}

#ifdef _MSC_VER
extern __declspec(dllexport)
#endif
octaspire_dern_value_t *dern_ncurses_attron(
    octaspire_dern_vm_t * const vm,
    octaspire_dern_value_t * const arguments,


@@ 1506,6 1561,9 @@ octaspire_dern_value_t *dern_ncurses_attron(
    return octaspire_dern_vm_create_new_value_boolean(vm, result != ERR);
}

#ifdef _MSC_VER
extern __declspec(dllexport)
#endif
octaspire_dern_value_t *dern_ncurses_attroff(
    octaspire_dern_vm_t * const vm,
    octaspire_dern_value_t * const arguments,


@@ 1624,6 1682,9 @@ octaspire_dern_value_t *dern_ncurses_attroff(
    return octaspire_dern_vm_create_new_value_boolean(vm, result != ERR);
}

#ifdef _MSC_VER
extern __declspec(dllexport)
#endif
octaspire_dern_value_t *dern_ncurses_has_colors(
    octaspire_dern_vm_t * const vm,
    octaspire_dern_value_t * const arguments,


@@ 1651,6 1712,9 @@ octaspire_dern_value_t *dern_ncurses_has_colors(
    return octaspire_dern_vm_create_new_value_boolean(vm, result);
}

#ifdef _MSC_VER
extern __declspec(dllexport)
#endif
octaspire_dern_value_t *dern_ncurses_init_color(
    octaspire_dern_vm_t * const vm,
    octaspire_dern_value_t * const arguments,


@@ 1713,6 1777,9 @@ octaspire_dern_value_t *dern_ncurses_init_color(
    return octaspire_dern_vm_create_new_value_boolean(vm, result != ERR);
}

#ifdef _MSC_VER
extern __declspec(dllexport)
#endif
octaspire_dern_value_t *dern_ncurses_init_pair(
    octaspire_dern_vm_t * const vm,
    octaspire_dern_value_t * const arguments,


@@ 1829,6 1896,9 @@ octaspire_dern_value_t *dern_ncurses_init_pair(
    return octaspire_dern_vm_create_new_value_boolean(vm, result != ERR);
}

#ifdef _MSC_VER
extern __declspec(dllexport)
#endif
octaspire_dern_value_t *dern_ncurses_start_color(
    octaspire_dern_vm_t * const vm,
    octaspire_dern_value_t * const arguments,


@@ 1856,7 1926,9 @@ octaspire_dern_value_t *dern_ncurses_start_color(
    return octaspire_dern_vm_create_new_value_boolean(vm, result != ERR);
}


#ifdef _MSC_VER
extern __declspec(dllexport)
#endif
octaspire_dern_value_t *dern_ncurses_refresh(
    octaspire_dern_vm_t * const vm,
    octaspire_dern_value_t * const arguments,


@@ 1884,6 1956,9 @@ octaspire_dern_value_t *dern_ncurses_refresh(
    return octaspire_dern_vm_create_new_value_boolean(vm, result != ERR);
}

#ifdef _MSC_VER
extern __declspec(dllexport)
#endif
octaspire_dern_value_t *dern_ncurses_endwin(
    octaspire_dern_vm_t * const vm,
    octaspire_dern_value_t * const arguments,


@@ 1911,6 1986,9 @@ octaspire_dern_value_t *dern_ncurses_endwin(
    return octaspire_dern_vm_create_new_value_boolean(vm, result != ERR);
}

#ifdef _MSC_VER
extern __declspec(dllexport)
#endif
bool dern_ncurses_init(
    octaspire_dern_vm_t * const vm,
    octaspire_dern_environment_t * const targetEnv,

M release/plugins/dern_socket.c => release/plugins/dern_socket.c +32 -4
@@ 14,15 14,20 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
******************************************************************************/
#include "octaspire-dern-amalgamated.c"
#ifdef _WIN32
#include <winsock2.h>
#else
#include <winsock2.h> // winsock2.h must be included before windows.h
#endif

#include "octaspire-dern-amalgamated.c"

#ifndef _WIN32
#include <arpa/inet.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <netdb.h>
#include <unistd.h>
#endif

#ifdef __FreeBSD__
#include <netinet/in.h>
#endif


@@ 33,7 38,6 @@ limitations under the License.
#include <string.h>
#include <stdlib.h>
#include <locale.h>
#include <unistd.h>
#include <stdint.h>

static char const * const DERN_SOCKET_PLUGIN_NAME = "dern_socket";


@@ 65,12 69,18 @@ static char const *dern_socket_private_format_win32_error_message(void)
}
#endif

#ifdef _MSC_VER
extern __declspec(dllexport)
#endif
void dern_socket_socket_clean_up_callback(void *payload)
{
    octaspire_helpers_verify_not_null(payload);
    close((intptr_t)payload);
}

#ifdef _MSC_VER
extern __declspec(dllexport)
#endif
octaspire_dern_value_t *dern_socket_new_ipv4_stream_socket(
    octaspire_dern_vm_t * const vm,
    octaspire_dern_value_t * const arguments,


@@ 324,6 334,9 @@ octaspire_dern_value_t *dern_socket_new_ipv4_stream_socket(
#endif
}

#ifdef _MSC_VER
extern __declspec(dllexport)
#endif
octaspire_dern_value_t *dern_socket_close(
    octaspire_dern_vm_t * const vm,
    octaspire_dern_value_t * const arguments,


@@ 413,6 426,9 @@ octaspire_dern_value_t *dern_socket_close(
#endif
}

#ifdef _MSC_VER
extern __declspec(dllexport)
#endif
octaspire_dern_value_t *dern_socket_accept(
    octaspire_dern_vm_t * const vm,
    octaspire_dern_value_t * const arguments,


@@ 536,6 552,9 @@ octaspire_dern_value_t *dern_socket_accept(
#endif
}

#ifdef _MSC_VER
extern __declspec(dllexport)
#endif
octaspire_dern_value_t *dern_socket_receive(
    octaspire_dern_vm_t * const vm,
    octaspire_dern_value_t * const arguments,


@@ 711,6 730,9 @@ octaspire_dern_value_t *dern_socket_receive(
#endif
}

#ifdef _MSC_VER
extern __declspec(dllexport)
#endif
octaspire_dern_value_t *dern_socket_send(
    octaspire_dern_vm_t * const vm,
    octaspire_dern_value_t * const arguments,


@@ 874,6 896,9 @@ octaspire_dern_value_t *dern_socket_send(
#endif
}

#ifdef _MSC_VER
extern __declspec(dllexport)
#endif
bool dern_socket_init(
    octaspire_dern_vm_t * const vm,
    octaspire_dern_environment_t * const targetEnv,


@@ 1046,6 1071,9 @@ bool dern_socket_init(
    return true;
}

#ifdef _MSC_VER
extern __declspec(dllexport)
#endif
bool dern_socket_clean(
    octaspire_dern_vm_t * const vm,
    octaspire_dern_environment_t * const targetEnv)