mirror of
https://github.com/janet-lang/janet
synced 2026-10-21 06:52:27 +00:00
Add example file for compiling native modules (hello.so).
This commit is contained in:
+12
-9
@@ -917,15 +917,18 @@ onvalue."
|
||||
(error (string "circular dependency: module " path " is loading")))
|
||||
(def check (get cache path))
|
||||
(if check check (do
|
||||
(def newenv (make-env))
|
||||
(put cache path newenv)
|
||||
(put loading path true)
|
||||
(def f (file-open path))
|
||||
(defn chunks [buf] (file-read f 1024 buf))
|
||||
(run-context newenv chunks identity default-error-handler)
|
||||
(file-close f)
|
||||
(put loading path nil)
|
||||
newenv)))))
|
||||
(if (= ".so" (string-slice path -3 -1))
|
||||
((native path))
|
||||
(do
|
||||
(def newenv (make-env))
|
||||
(put cache path newenv)
|
||||
(put loading path true)
|
||||
(def f (file-open path))
|
||||
(defn chunks [buf] (file-read f 1024 buf))
|
||||
(run-context newenv chunks identity default-error-handler)
|
||||
(file-close f)
|
||||
(put loading path nil)
|
||||
newenv)))))))
|
||||
|
||||
(defn import* [env path & args]
|
||||
(def newenv (require path))
|
||||
|
||||
+1
-1
@@ -37,7 +37,7 @@ typedef HINSTANCE Clib;
|
||||
typedef int Clib;
|
||||
#define load_clib(name) 0
|
||||
#define symbol_clib(lib, sym) 0
|
||||
#define error_clib() "could not load dynamic library"
|
||||
#define error_clib() "dynamic libraries not supported"
|
||||
#else
|
||||
#include <dlfcn.h>
|
||||
typedef void *Clib;
|
||||
|
||||
@@ -0,0 +1,33 @@
|
||||
/*
|
||||
* Copyright (c) 2017 Calvin Rose
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#ifndef DST_OS_H
|
||||
#define DST_OS_H
|
||||
|
||||
#include <dst/dst.h>
|
||||
|
||||
int dst_os_execute(DstArgs args);
|
||||
int dst_os_getenv(DstArgs args);
|
||||
int dst_os_setenv(DstArgs args);
|
||||
int dst_os_exit(DstArgs args);
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,240 @@
|
||||
{
|
||||
dst_array;
|
||||
dst_array_init;
|
||||
dst_array_deinit;
|
||||
dst_array_ensure;
|
||||
dst_array_setcount;
|
||||
dst_array_push;
|
||||
dst_array_pop;
|
||||
dst_array_peek;
|
||||
|
||||
dst_buffer;
|
||||
dst_buffer_init;
|
||||
dst_buffer_deinit;
|
||||
dst_buffer_ensure;
|
||||
dst_buffer_extra;
|
||||
dst_buffer_push_bytes;
|
||||
dst_buffer_push_cstring;
|
||||
dst_buffer_push_u8;
|
||||
dst_buffer_push_u16;
|
||||
dst_buffer_push_u32;
|
||||
dst_buffer_push_u64;
|
||||
|
||||
dst_tuple_begin;
|
||||
dst_tuple_end;
|
||||
dst_tuple_n;
|
||||
dst_tuple_equal;
|
||||
dst_tuple_compare;
|
||||
|
||||
dst_string_begin;
|
||||
dst_string_end;
|
||||
dst_string;
|
||||
dst_cstring;
|
||||
dst_string_compare;
|
||||
dst_string_equal;
|
||||
dst_string_equalconst;
|
||||
dst_string_unique;
|
||||
dst_cstring_unique;
|
||||
dst_description;
|
||||
dst_to_string;
|
||||
dst_to_zerostring;
|
||||
dst_formatc;
|
||||
dst_puts;
|
||||
|
||||
dst_symbol;
|
||||
dst_symbol_from_string;
|
||||
dst_csymbol;
|
||||
dst_symbol_gen;
|
||||
|
||||
dst_struct_begin;
|
||||
dst_struct_put;
|
||||
dst_struct_end;
|
||||
dst_struct_get;
|
||||
dst_struct_next;
|
||||
dst_struct_to_table;
|
||||
dst_struct_equal;
|
||||
dst_struct_compare;
|
||||
dst_struct_find;
|
||||
|
||||
dst_table;
|
||||
dst_table_init;
|
||||
dst_table_deinit;
|
||||
dst_table_get;
|
||||
dst_table_rawget;
|
||||
dst_table_remove;
|
||||
dst_table_put;
|
||||
dst_table_next;
|
||||
dst_table_to_struct;
|
||||
dst_table_merge_table;
|
||||
dst_table_merge_struct;
|
||||
dst_table_find;
|
||||
|
||||
dst_fiber;
|
||||
|
||||
dst_seq_view;
|
||||
dst_chararray_view;
|
||||
dst_hashtable_view;
|
||||
|
||||
dst_abstract;
|
||||
|
||||
dst_native;
|
||||
|
||||
dst_mark;
|
||||
dst_sweep;
|
||||
dst_collect;
|
||||
dst_clear_memory;
|
||||
dst_gcroot;
|
||||
dst_gcunroot;
|
||||
dst_gcunrootall;
|
||||
dst_gclock;
|
||||
dst_gcunlock;
|
||||
|
||||
dst_funcdef_alloc;
|
||||
dst_thunk;
|
||||
dst_verify;
|
||||
dst_quick_asm;
|
||||
|
||||
dst_equals;
|
||||
dst_hash;
|
||||
dst_compare;
|
||||
dst_get;
|
||||
dst_put;
|
||||
dst_next;
|
||||
dst_length;
|
||||
dst_getindex;
|
||||
dst_setindex;
|
||||
dst_cstrcmp;
|
||||
|
||||
dst_init;
|
||||
dst_deinit;
|
||||
dst_run;
|
||||
dst_resume;
|
||||
|
||||
dst_env_def;
|
||||
dst_env_var;
|
||||
dst_env_cfuns;
|
||||
dst_env_resolve;
|
||||
dst_env_arg;
|
||||
|
||||
dst_stl_env;
|
||||
|
||||
dst_asm;
|
||||
dst_disasm;
|
||||
dst_asm_decode_instruction;
|
||||
dst_asm_cfun;
|
||||
dst_disasm_cfun;
|
||||
|
||||
dst_lib_asm;
|
||||
|
||||
dst_compile;
|
||||
|
||||
dst_compile_cfun;
|
||||
dst_lib_compile;
|
||||
|
||||
dst_stl_env;
|
||||
|
||||
dst_dobytes;
|
||||
dst_dostring;
|
||||
|
||||
dst_core_native;
|
||||
|
||||
dst_int;
|
||||
dst_real;
|
||||
dst_add;
|
||||
dst_subtract;
|
||||
dst_multiply;
|
||||
dst_divide;
|
||||
dst_modulo;
|
||||
dst_rand;
|
||||
dst_srand;
|
||||
dst_strict_equal;
|
||||
dst_strict_notequal;
|
||||
dst_ascending;
|
||||
dst_descending;
|
||||
dst_notdescending;
|
||||
dst_notascending;
|
||||
dst_numeric_eq;
|
||||
dst_numeric_neq;
|
||||
dst_numeric_gt;
|
||||
dst_numeric_lt;
|
||||
dst_numeric_gte;
|
||||
dst_numeric_lte;
|
||||
dst_bor;
|
||||
dst_band;
|
||||
dst_bxor;
|
||||
dst_bnot;
|
||||
dst_lshift;
|
||||
dst_rshift;
|
||||
dst_lshiftu;
|
||||
dst_not;
|
||||
|
||||
dst_cos;
|
||||
dst_sin;
|
||||
dst_tan;
|
||||
dst_acos;
|
||||
dst_asin;
|
||||
dst_atan;
|
||||
dst_exp;
|
||||
dst_log;
|
||||
dst_log10;
|
||||
dst_sqrt;
|
||||
dst_floor;
|
||||
dst_ceil;
|
||||
dst_pow;
|
||||
|
||||
dst_core_print;
|
||||
dst_core_describe;
|
||||
dst_core_string;
|
||||
dst_core_symbol;
|
||||
dst_core_buffer;
|
||||
dst_core_tuple;
|
||||
dst_core_array;
|
||||
dst_core_table;
|
||||
dst_core_struct;
|
||||
dst_core_buffer;
|
||||
dst_core_gensym;
|
||||
dst_core_length;
|
||||
dst_core_get;
|
||||
dst_core_rawget;
|
||||
dst_core_getproto;
|
||||
dst_core_setproto;
|
||||
dst_core_put;
|
||||
dst_core_type;
|
||||
dst_core_next;
|
||||
dst_core_hash;
|
||||
dst_core_string_slice;
|
||||
|
||||
dst_core_gccollect;
|
||||
dst_core_gcsetinterval;
|
||||
dst_core_gcinterval;
|
||||
|
||||
dst_lib_io;
|
||||
dst_lib_math;
|
||||
dst_lib_array;
|
||||
dst_lib_tuple;
|
||||
dst_lib_buffer;
|
||||
dst_lib_table;
|
||||
dst_lib_fiber;
|
||||
dst_lib_os;
|
||||
|
||||
dst_ast_wrap;
|
||||
dst_ast_node;
|
||||
dst_ast_unwrap1;
|
||||
dst_ast_unwrap;
|
||||
|
||||
dst_scan_number;
|
||||
dst_scan_integer;
|
||||
dst_scan_real;
|
||||
|
||||
dst_parser_init;
|
||||
dst_parser_deinit;
|
||||
dst_parser_consume;
|
||||
dst_parser_status;
|
||||
dst_parser_produce;
|
||||
dst_parser_error;
|
||||
|
||||
dst_parse_cfun;
|
||||
|
||||
dst_lib_parse;
|
||||
|
||||
};
|
||||
Reference in New Issue
Block a user