Calvin Rose
a15d841b5b
Address #232
...
Fix segfault on macro arity mismatch in compile.c by adding missing return statements.
2019-12-31 11:33:03 -05:00
Calvin Rose
75bb8fbcd1
Amalg script included janet.h before test macros.
2019-12-30 22:08:12 -05:00
Calvin Rose
9cb25ad7b1
Remove some feature test macros.
...
_BSD_SOURCE is deprecated and not needed.
2019-12-30 21:30:13 -05:00
Calvin Rose
f361830cb2
Update feature test macro in line.c
2019-12-30 20:24:40 -05:00
Calvin Rose
9dd152dc28
Add features.h for feature test macros.
...
Because we use an amalgated build, feature
test macros should be set in a single file that
is included before any other headers, and is placed
at the top of the amalgamated build.
2019-12-30 19:06:15 -05:00
Calvin Rose
2ba4337e6f
Remove all feature test macros from janet.h
...
This should help improve compatibility with other C code.
2019-12-30 15:12:17 -05:00
Calvin Rose
48fcd927ab
Merge branch 'master' of github.com:janet-lang/janet
2019-12-30 14:26:38 -05:00
Calvin Rose
407d8af026
Address #233
...
Move _POSIX_C_SOURCE to internal header.
2019-12-30 12:31:26 -05:00
Calvin Rose
d0570b55b1
Merge pull request #231 from andrewchambers/tempfile
...
Add file/temp.
2019-12-29 20:00:17 -05:00
Calvin Rose
a964a95c1e
Fix warnings on BSDs.
2019-12-29 19:53:35 -05:00
Andrew Chambers
c2f8441572
Add file/temp.
2019-12-30 12:00:35 +13:00
Andrew Chambers
2bebace8eb
Extend file api to allow creating and checking.
2019-12-30 04:02:46 +13:00
Calvin Rose
022be217a2
Remove ==, not==, and order[<,<=,>,>=].
...
This unifies equality and comparison checking. Before, we had
separate functions and vm opcodes for comparing general values vs.
for comparing numbers, where the numberic functions were polymorphic and
had special cases for handling NaNs. By unfiying them, abstract types
can now better integrate with other number types and behave as keys.
For now, the old functions are aliased but will eventually be removed.
2019-12-28 16:04:15 -05:00
Andrew Chambers
ddc4274314
Expand docs to explain pclose semantics.
2019-12-28 15:24:10 +13:00
Calvin Rose
3492ed6d88
Windows installer pulls version from interpreter.
...
This should make version updates simpler. Also
try an make installer write to ProgramFiles instead
of ProgramFiles (x86) for 64 bit build.
2019-12-19 13:18:46 -05:00
Calvin Rose
e28262f5ab
Add array/fill
...
This function has similar semantics to buffer/fill.
2019-12-19 12:58:11 -05:00
Calvin Rose
94246f7574
Use infinite timeout to indicate non-blocking.
...
Makes more sense than negative numbers.
2019-12-18 16:07:06 -05:00
Calvin Rose
07b0ef1648
Throw error on bad thread creation.
2019-12-18 15:49:57 -05:00
Calvin Rose
6a39c4b91d
Pass thread body explicitly in thread/new.
...
Doing it via thread/send make sense, but is a bit
strange. Passing the body explicitly will make more
sense to API users.
2019-12-18 15:07:46 -05:00
Calvin Rose
b9f0f14e31
Add array/new-filled
...
Similar function signature to buffer/new-filled.
2019-12-18 13:02:50 -05:00
Calvin Rose
4238379552
Use _setjmp/_longjmp on BSDs.
...
This doesn't save the signal mask so should be a bit faster.
2019-12-18 12:18:31 -05:00
Calvin Rose
2b2c1ff917
Get rid of warning on BSDs.
2019-12-15 16:04:43 -06:00
Calvin Rose
c7912249b2
Typo in #ifdef.
2019-12-15 15:56:26 -06:00
Calvin Rose
b8004555ea
Start cleaning up defines in janet.h
2019-12-15 15:41:58 -06:00
Calvin Rose
58ff7f0788
BSD os.c fix with arc4random.
2019-12-15 12:47:12 -06:00
Calvin Rose
f1afc5b0b4
Address #214
...
This adds several common patterns, which are defined in
boot.janet. This essentially gives more primitive patterns
to work with out of the box.
Fix build when JANET_REDUCED_OS is defined.
2019-12-14 20:39:14 -06:00
Calvin Rose
bc8ee207d5
Address #219 .
...
Adds several shorthands to the C API.
2019-12-14 11:31:46 -06:00
Calvin Rose
76342540dc
Add buffer/fill. Address #221
2019-12-14 10:54:29 -06:00
Calvin Rose
56784a34a1
Address #224 - Exposed file flags in janet.h
...
A caller can check if a file is closed with
if (flags & JANET_FILE_CLOSED) ...
2019-12-14 09:03:56 -06:00
Calvin Rose
c3f1b54171
Update jpm path settings.
...
This will make it easier to use jpm as a per-project
management tool, as well as easier to set up individual
module trees.
2019-12-12 19:35:40 -06:00
Calvin Rose
9b7d642c38
Window x86 needs isnan.
2019-12-12 19:04:13 -06:00
Calvin Rose
7c2ae45809
Fix some merge issues.
...
Make everything compile, and test-install pass.
2019-12-12 17:14:36 -06:00
Calvin Rose
36b2f27873
Merge branch 'master' into threads-3
2019-12-12 17:07:03 -06:00
Calvin Rose
b8e02afd1a
Improve error messages in os.c and jpm
...
In os/* functions, show failed path name. In jpm, indicate
a permission issue if we can't stat the file.
2019-12-12 03:20:20 -06:00
Calvin Rose
0fc36aa5d0
Signal to pending threads more often.
2019-12-12 02:19:56 -06:00
Calvin Rose
38f7e256d0
Port threads code to Windows API
...
Can run demo in examples/threads.janet
2019-12-10 20:32:41 -05:00
Calvin Rose
4187c972a3
Switch to multiple buffers per mailbox.
...
Needs less copying.
2019-12-10 13:26:00 -06:00
Calvin Rose
8700a407ce
Update janet_getmethod to better match new get api.
2019-12-09 18:45:05 -06:00
Andrew Chambers
57ccfb692c
Abstract type getters can indicate key absence.
...
This change to the c api allows abstract types to indicate
to the runtime if a key was absent, or if it meant to return nil.
2019-12-09 16:50:33 +13:00
Calvin Rose
eb1c21b0da
Fix some example issue and warnings under -Os.
2019-12-08 12:40:05 -06:00
Calvin Rose
66d82c4513
Add mailbox capacity for back pressure.
...
(thread/send thread msg &opt timeout) can now timeout. Also
changed thread/self to thread/current for better consistency with
fibers, and all blocking operations will by default timeout after 1
second. I think its bad to make things block forerver by default.
2019-12-08 12:30:30 -06:00
Calvin Rose
c9c4424261
Add thread/self.
2019-12-07 17:54:08 -06:00
Calvin Rose
131733549d
Get mailbox API working.
2019-12-07 16:51:00 -06:00
Calvin Rose
ee646dadf2
Merge branch 'master' into threads-3
2019-12-07 12:14:44 -06:00
Calvin Rose
73f5314141
Work on moving to mailbox abstraction.
...
Should be more efficient in the common case.
2019-12-07 12:14:16 -06:00
Calvin Rose
546669082f
New unmarshal proposal.
...
Gives more control over unmarshalling
abstract types. This should also
make it possible/easy to write abstract types that cannot
cause unmarshal to segfault.
2019-12-06 22:12:18 -06:00
Calvin Rose
4a0ee5df7d
Address #215
...
Also update docs for module/expand-path.
2019-12-06 19:54:11 -06:00
Calvin Rose
0e690b4fa0
Add timeout to thread/receive.
...
If provided, throws an error if no message is received before
timeout. Perhaps should return nil?.
2019-12-06 09:21:36 -06:00
Calvin Rose
c804ae9f7c
Update threads.c to avoid a deadlock.
2019-12-06 01:46:23 -06:00
Calvin Rose
dbcceefc20
Fix bad merge.
2019-12-04 22:41:30 -06:00
Calvin Rose
1a4035b02c
Merge branch 'master' into threads-3
2019-12-04 22:39:30 -06:00
Calvin Rose
e908029392
Work on thread/receive doubling as select.
2019-12-04 22:31:01 -06:00
Calvin Rose
fd4220f254
Keep single global pthread_cond_t per thread.
...
This will allow thread/select to be implemented.
Also add thread/close and close method to threads.
2019-12-04 21:44:53 -06:00
Calvin Rose
de6c3d6d70
Simplify structure JanetThread and JanetChannel.
...
Remove JanetThreadShared.
2019-12-04 21:04:43 -06:00
Calvin Rose
49954c7a30
Remove top-level unquote for comptime macro
...
True top level unquote currently requires basically double compilation
as it currently stands. Also, implementing such double compilation
looses all source mapping information. This is a compromise
implementation that makes it clear that this works differently than
a true top-level unquote.
2019-12-04 19:53:13 -06:00
Calvin Rose
2487162ccf
Add top level unquote and macro envs.
...
This improves macros that eval their arguments and
makes them easier to write.
2019-12-04 18:39:13 -06:00
Calvin Rose
4199c42fe2
Add support for nested quasiquotation.
...
This brings Janet more in line with Scheme,
Common Lisp, and Clojure.
2019-12-04 16:40:53 -06:00
Calvin Rose
70328437f1
Add math/rng-buffer.
...
Allow math/seedrandom to use buffer as seed.
2019-12-03 20:33:21 -06:00
Calvin Rose
600bed9f6d
Merge pull request #209 from andrewchambers/cryptorand2
...
Add os/cryptorand.
2019-12-03 19:12:32 -06:00
Andrew Chambers
0ac5b243c7
Add os/cryptorand.
2019-12-04 14:02:37 +13:00
Andrew Chambers
9911c90b1d
Handle missing get case.
2019-12-04 13:58:21 +13:00
Calvin Rose
a1f35e21c7
Merge branch 'master' into threads-3
2019-12-03 18:11:32 -06:00
Calvin Rose
9ccdab0bc7
Merge pull request #208 from andrewchambers/explain_why
...
Explain the logic behind negative slice indices.
2019-12-03 10:42:46 -05:00
Andrew Chambers
a20e956f6d
Explain the logic behind negative slice indices.
2019-12-03 22:05:43 +13:00
Calvin Rose
59668133a2
Merge pull request #206 from andrewchambers/unkown
...
Fix typo.
2019-12-03 03:34:46 -05:00
Andrew Chambers
73db8584e0
Fix typo.
2019-12-03 21:14:00 +13:00
Calvin Rose
cecc7e6b9d
Rename 'get' opcode to 'in', add new 'get' opcode.
...
This makes the names of the opcodes match their implied functionality.
We also rename the C functions to match the opcodes and source level
functionality.
2019-12-02 21:26:28 -06:00
Calvin Rose
8368e55151
Merge branch 'master' into threads-3
2019-12-02 17:49:39 -06:00
Calvin Rose
ac85fca8a1
Fix warnings for appveyor.
2019-12-02 09:07:49 -06:00
Calvin Rose
e5fbe5c557
Change printf to add trailing newlines.
...
Also add prinf and eprinf for old behavior. This
is consistent with the naming of print and prin.
2019-12-02 04:45:03 -06:00
Calvin Rose
474bcd50a1
Add methods to threads.
2019-12-02 04:39:13 -06:00
Calvin Rose
70c8b6838d
Use make-image-dict and load-image-dict in thread/new
...
Rather than messing with janet_core_dictionary, we
instead cache the core enevironment, and pull out the
needed tables from there. This is more flexible, more correct, and
also exposes janet_resolve_core, which can be easily used from the C
API.
2019-12-02 04:15:22 -06:00
Calvin Rose
212479188a
Have separate encode and decode dicts for threads
...
This is more correct and mirrors the way marshal -> unmarshal works.
2019-12-01 21:53:39 -06:00
Calvin Rose
5b1e59b535
Merge branch 'master' of github.com:janet-lang/janet into threads-3
2019-12-01 21:26:22 -06:00
Calvin Rose
779d788efa
Merge pull request #204 from andrewchambers/get_permissive
...
New capi janet_get_permissive
2019-12-01 22:06:44 -05:00
Andrew Chambers
6233d804c8
New capi janet_get_permissive
...
The janet_get_permissive function implements the core semantics
of the 'get' function. The original janet_get implements the semantics of
the 'in' function and also the OP_GET opcode. This slight oddity is
to avoid a backwards incompatible change.
2019-12-02 15:49:51 +13:00
Calvin Rose
8f31a53276
Add thread example.
...
Also remove reference to pthread_t in the JanetThread structure.
2019-12-01 20:47:22 -06:00
Calvin Rose
6a763aac95
Work on threads.
...
Add send and receive.
2019-12-01 20:28:12 -06:00
Calvin Rose
5cd6580c2d
Merge branch 'threads-3' of github.com:janet-lang/janet into threads-3
2019-12-01 20:25:57 -06:00
Andrew Chambers
8a58be81ba
Update documentation for in and get builtins.
...
Try to clarify documentation and teach users the correct
way to read the 'in' so it is less likely to be confused
with python's usage of the keyword.
2019-12-02 12:35:54 +13:00
Calvin Rose
fc53445d08
Merge pull request #198 from andrewchambers/intprint
...
Integers convert to plain number strings.
2019-12-01 13:00:09 -05:00
Calvin Rose
db261aabf4
Fix bad integer printing range.
2019-12-01 09:46:20 -05:00
Calvin Rose
36ef1c4749
Print proper integers as integers.
2019-12-01 09:40:34 -05:00
Andrew Chambers
5ae520a2c9
Integers convert to plain number strings.
...
A user can use (type n) to find the true type, the old behavior did not
seem useful for most uses of the string function.
2019-12-01 23:10:52 +13:00
Calvin Rose
570f04ca05
Fix typo.
2019-11-30 21:27:36 -05:00
Calvin Rose
bf609445c1
Merge pull request #186 from quexxon/fix-array-ensure-documentation
...
Add missing documentation for array/ensure's growth parameter
2019-11-29 22:39:04 -05:00
Calvin Rose
4e4cdb6356
Run formatter.
2019-11-28 23:26:11 -05:00
Calvin Rose
688d297a18
Address Issue #184 .
...
Fix strtod.c with better range checking to prevent DOS.
2019-11-28 23:23:37 -05:00
Will Clardy
9e1c3e0f41
Add missing documentation for array/ensure's growth parameter
2019-11-28 23:16:32 -05:00
Calvin Rose
967a8b5a70
Merge pull request #183 from andrewchambers/environ
...
Add os/environ.
2019-11-28 21:33:43 -05:00
Calvin Rose
92b7d91697
Merge pull request #182 from andrewchambers/scratch_finalizer
...
Add an optional finalizer to scratch resources.
2019-11-28 21:07:42 -05:00
Andrew Chambers
07db4c530e
Add os/environ.
2019-11-28 19:00:52 +13:00
Andrew Chambers
a3fb2d6e0a
Add an optional finalizer to scratch resources.
...
A finalizer can be attached to scratch allocations efficiently at any point in
it's lifecycle via janet_sfinalizer. Care was taken to keep allocations aligned
with platform alignment requirements.
A big drawbacks to this approach is the waste of up to 16 bytes per scratch
allocation in the case the scratch memory does not require a finalizer.
2019-11-28 17:32:12 +13:00
Andrew Chambers
88f28773da
Add missing fileno method to file, sort method list.
2019-11-28 14:47:16 +13:00
Calvin Rose
e542ba7e4d
Fix amalg build.
2019-11-27 12:43:45 -06:00
Calvin Rose
bca0392738
First work on threading.
...
Posix only, needs to be disabled on windows. Also
the Makefile needs to be configurable, and meson.build
needs to take pthreads into account.
2019-11-26 23:13:53 -06:00
Calvin Rose
74d51ab08b
Address issue #180 - string/check-set
...
Fix the function and add test to further clarify that
implementation is correct. Also fix empty string case.
2019-11-25 20:33:16 -06:00
Calvin Rose
7df0ec6aed
Fix up debug/step and janet_step.
...
Also allow debugging on all signals, including errors.
This is gated behind (setdyn :debug true) in the repl.
2019-11-25 20:00:13 -06:00
Calvin Rose
6988fd3cab
Add debug/step to single step a fiber.
...
Very useful for implementing debuggers.
2019-11-25 18:14:34 -06:00
Calvin Rose
c3273e8751
Merge branch 'master' of github.com:janet-lang/janet
2019-11-24 17:54:14 -06:00