Calvin Rose
2dd852da54
Use ATEND macros to add fields to abstract types.
...
This means we can add new properties to abstract types without
breaking old code. We can also make simple abstract types without
needing to add many NULL fields to the type.
2020-01-20 13:06:50 -06:00
Calvin Rose
f4077b678a
Allow calling next on abstracts.
...
This will allow the creation of infinte
streams, low cost generators, etc.
2020-01-18 18:09:20 -06:00
Calvin Rose
a68ee7aac6
Update Copyright 2020.
2020-01-12 10:50:37 -06: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
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
b8004555ea
Start cleaning up defines in janet.h
2019-12-15 15:41:58 -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
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
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
Andrew Chambers
88f28773da
Add missing fileno method to file, sort method list.
2019-11-28 14:47:16 +13:00
Calvin Rose
c9521e093e
Fix windows issue with (file/read file :all)
...
When file was created with file/popen, the current optimization
of using fseek on windows fails due to windows not properly returning
and error code and just returning 0. Windows :(.
2019-11-11 20:05:00 -05:00
Calvin Rose
bb54b940c0
Don't call fwrite with size = 0
2019-10-19 10:51:11 -05:00
Calvin Rose
8dd8af742a
Add eprintf and make printf a C function.
...
This allows some more optimizations when printing to
buffers or when output is disabled. It also makes printf
more consistent with print and prin (Same with eprintf).
2019-10-19 10:30:29 -05:00
Calvin Rose
d47804d222
Add prin, eprint, and eprin functions.
...
The print family of functions now writes output
to an optional buffer instead of a file bound to :out.
This means output can be more easily captured an redirected.
2019-10-19 09:44:27 -05:00
Calvin Rose
d9a4ef05ac
Update docstring format.
...
Also add :p flag to fiber/new, change implemntation of with-dyns, and
make meson build install static library by default.
2019-06-08 10:30:43 -04:00
Andrew Chambers
2b7428ed2b
Add file/{fdopen,fileno} functions.
2019-06-08 10:33:29 +12:00
Calvin Rose
15d95d8803
Windows include issue.
2019-05-30 18:50:52 -04:00
Calvin Rose
46950a8cb3
Convert os/execute to use posix_spawn.
2019-05-30 18:40:10 -04:00
Calvin Rose
4d47d92a4a
Windows WEXITSTATUS fix?
2019-05-29 11:53:57 -04:00
Calvin Rose
b39ad97a87
Fix up close to return proper exit code.
2019-05-29 11:50:46 -04:00
Calvin Rose
af23040d9c
file/close returns an integer.
...
If opened with popen, returns the exit code. Otherwise
returns nil.
2019-05-29 11:40:58 -04:00
Calvin Rose
f2313b9959
file/read on eof will return nil.
...
Also add documentation for :exit in import.
Address issue #91
Partially adress issue #93
2019-05-14 11:05:19 -04:00
Calvin Rose
7918add47d
Allow dynamically setting output for printers
...
Some functions like print and debug/stacktrace print
to a file, usually stdout. This file can now be optionally set
via a dynamic variable.
2019-04-16 21:44:19 -04:00
Calvin Rose
513d551df6
Move print in source code to io module.
...
print now reads the dynamic binding for :out
when choosing where to write to.
2019-04-16 19:10:01 -04:00
Calvin Rose
94a2084723
Add tostring method for abstract types.
...
This lets abstract types customize how they
print for debugging.
2019-03-19 13:36:26 -04:00
Calvin Rose
8cc2c964c1
Add :export option to import
...
Also allow NULL ptr to janet_getfile for flags.
2019-03-02 11:46:31 -05:00
J.-F. Cap
1753f8bc18
Added janet_getfile C API function and revert core/file AT registering
2019-03-02 15:36:34 +01:00
J.-F. Cap
d70049dbb1
Register core/file abstract type
2019-02-27 10:54:10 +01:00
J.-F. Cap
9c1c7fb384
Remove AT id use name as tag
2019-02-24 02:51:34 +01:00
J.-F. Cap
af48912f11
Simplify Abstract type introspection
2019-02-24 02:02:54 +01:00
Calvin Rose
b14fcb068b
Update janet_pcall interface
...
The programmer can now not only get the used fiber, but
provide a fiber to reuse if many calls are made in succession.
2019-02-22 17:10:24 -05:00
Calvin Rose
9d4effc02e
Add make format to format code.
...
A consistent style should help with contributors and
readability. We use astyle as the formatter as can make a pretty
good approximation of the current style and my preferred style.
Astyle can be found at http://astyle.sourceforge.net/astyle.html
2019-02-19 20:51:34 -05:00
Calvin Rose
ed72dcf82d
Rename the header <janet/janet.h> to <janet.h>
...
Makes it easier to use and remember, and makes the
variable `module/*headerpath*` make more sense.
2019-02-18 20:13:35 -05:00
Calvin Rose
f161002390
Address #35
2019-02-15 13:20:20 -05:00
Calvin Rose
fe27df528c
Boot core library from image rather than source
...
This should speed up start time and reduce malloc/free
usage to about 15% of what is what previously for startup.
The current cost is slightly larger binary as the representaion
of the image is currently less compact than source code.
2019-02-08 00:44:30 -05:00
Calvin Rose
6321c30cb1
Add methods for file io.
2019-02-06 17:58:27 -05:00
J.-F. Cap
960cf76eb5
Experimental getter/setter for abstract types
2019-02-05 17:14:13 +01:00
Calvin Rose
611543c48b
Add source amalgamation
...
The amalgamated source concatenates all sources
to a file janet.c which can be used for
embedding janet, much in the same way as sqlite
or mongoose.
2019-01-24 00:15:58 -05:00
Calvin Rose
3ae6f64de5
Fix popen bug.
2019-01-08 21:42:16 -05:00
Calvin Rose
6f3bc3d577
Update copyright date, fix types, remove trailing whitespace.
2019-01-06 03:23:03 -05:00
Calvin Rose
5865692401
Surround embedded documentation with a macro so it
...
can be disabled in a future build.
2019-01-06 01:49:56 -05:00
Calvin Rose
7b28032f5c
More explicit casts to please Microsoft compiler.
2019-01-05 21:58:39 -05:00
Calvin Rose
1f98eff33a
Fix compiler warnings on emscripten.
2019-01-05 20:52:32 -05:00