2ceb5c2b041bf501d5d9fc84d27d258ccd32ece7 — octaspire 7 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 @@ #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 @@   
  @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 @@ @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 @@ #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 @@   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 @@ 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_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 @@ }
  
          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 @@ }
  }
  
+ #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 @@ 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 @@ 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 @@ 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 @@ 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 @@ 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 @@ 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 @@ 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 @@ 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 @@ 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 @@ 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 @@ 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 @@ 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 @@ 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 @@ 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 @@ 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 @@ 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 @@ 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 @@ 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 @@ 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 @@ 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 @@ 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 @@ 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 @@ #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 @@ }
  #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 @@ #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 @@ #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 @@ #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 @@ #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 @@ #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 @@ 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)