Commit Graph

47 Commits

Author SHA1 Message Date
Veit Heller
d3a6ca562f
docs: document core modules (#1271) 2021-07-05 14:48:35 +02:00
Veit Heller
bdaf96550f
refactor: use quasiquoting in STDLIB and go through array in quasiquote (#1135) 2021-01-21 06:20:03 +01:00
Veit Heller
2023c93d62
feat: Quasiquotation (#1129)
* feat: quasiquotation

* test: add tests for quasiquotation

* fix: fix typo in call to doc

* fix: do not evaluate quasiquote too eagerly

* test: pull quasiquote test into macro

* docs: fix unquote example with better constant

* feat: add quasiquote literals

* refactor: simplify reader macros
2021-01-15 10:50:04 +01:00
Veit Heller
02936cc74c
feat: Derive (#1120)
* core: add derive

* fix: fix errors with set!

Notably, don't type check dynamic bindings (which can be set to
whatever) and eliminate a hang that resulted from not handling an error
at the end of the `set!` call. Also refactors some of the code in
efforts to make it a bit cleaner.

Also adds an error when `set!` can't find the variable one calls set!
on.

* feat: better derive

* test: add error test for derive

* document derive

* add derive to core documentation to generate

* core: add derive

* fix: fix errors with set!

Notably, don't type check dynamic bindings (which can be set to
whatever) and eliminate a hang that resulted from not handling an error
at the end of the `set!` call. Also refactors some of the code in
efforts to make it a bit cleaner.

Also adds an error when `set!` can't find the variable one calls set!
on.

* feat: better derive

* document derive

* feat: first completely working version of derive

* feat: make name of derivable customizable (thanks @scolsen)

* refactor: implement doc edits provided by @scolsen

* feat: change argument order for derive

* fix: change deriver error test

* test: add derive tests

* fix: change order of derive back

* docs: fix typo in derive document

Co-authored-by: scottolsen <scg.olsen@gmail.com>
2021-01-15 10:48:34 +01:00
Erik Svedäng
6f7aeaff73
feat: 'delete' interface (deciding whether a type is managed or not) (#1061)
* feat: 'delete' interface (deciding whether a type is managed or not)

* refactor: Move implements function to Interface module

* feat: Automatically implement 'delete' for types defined with `deftype`

* fix: Don't implement `delete` for Pointer

* refactor: Clarify `memberInfo` function

* fix: Also check if function types are managed

* fix: Implement 'delete' for String and StaticArray.

* fix: Manage String and Pattern. Tests run!

* feat: Add `managed?` primitive

* docs: Note about primitiveIsManaged

* test: Basic test cases for managed / nonmanaged external types

* test: Make sure `managed?` primitive works

* test: Inactivate sanitizer since we're creating leaks intentionally

* feat: Removed 'isExternalType' function

* refactor: Decide if struct member takes ref or not when printing

..based on blitable interface, and 'prn' implemntation

* refactor: Use 'blit' everywhere

* refactor: Implement `strTakesRefOrNot` in terms of `memberStrCallingConvention`

* refactor: Use `remove` over `filter not`
2020-12-20 21:21:14 +01:00
Erik Svedäng
f78fd16a71
refactor: Move code out of Macros.carp into other files (#1014)
* refactor: Move code out of Macros.carp into other files

* fix: Move back some macros needed in --no-core mode

* refactor: Remove weird 'evaluate' macros

* fix: Put back more macros

* fix: Remove transitive loading of Macros.carp

* refactor: Remove ArrayMacros.carp and put 'for' at top of Array.carp instead

* refactor: More splitting up

* refactor: Move back save-docs

* fix: Moved back some stuff

Co-authored-by: Erik Svedang <erik@Eriks-iMac.local>
2020-11-28 12:53:18 +01:00
Tim Dévé
36f41e39a7
Adds Function.unsafe-ptr & Function.unsafe-env-ptr (#1026)
This functions are useful with binding callback based C APIs
2020-11-27 10:17:29 +01:00
Scott Olsen
c1e794c4cc
More Unit type member enhancements (#986)
* Emit/Deftype: Add a few more special cases for Unit members

There were a few gaps remaining in our handling of Unit types as members
of user defined types, most notably, generic setters weren't handling
Units appropriately. This commit adds special checks for Unit types in
generic setters, and also accounts for a Unit refs:

- Specialize generic setter functions against Unit members
- Specialize calls to str/prn against Unit members in StructUtils
  (rather than accessing the struct member, which doesn't exist in the
  Unit case, we simple call Unit's prn function (added in the next
  commit).
- Don't bind references to Unit values to variables. This fixes an error
  whereby a reference to a Unit would generate invalid C such as:
  `void* _9 = &;`
  Likewise, we omit references to Units from function arguments just as
  we omit Unit values.

* Unit: Add Unit type implementations for common interfaces.

Now that Unit can be used as a member type it is subject to several
interfaces, such as prn, that it previously hadn't implemented.

This commit adds Unit.carp to core which implements `prn`, `copy`, and
`zero` for the Unit type.

* Deftype: Return null pointers for Unit getters

This is *hopefully* one of the final updates needed to fully support
Unit's as member types. Getters for fields of such types have no struct
member to read, but are expected to return a void pointer; so we return
a NULL void pointer instead.

This commit also updates our emissions for function calls to prevent
assigning the results of functions with Unit and (Ref Unit) return types
to variables.

* Emit: Filter void args from lambda calls

Just as we filter void argument types from other function calls, we now
filter them from calls to lambdas.
2020-11-21 05:57:03 +01:00
Tim Dévé
cbda258fcc Moves StdInt functions with dependency on String into String.carp
This allows to import StdInt.carp by itself in --no-core situations
2020-10-26 19:14:50 +00:00
Jorge Acereda
58a61dd42e Add support for cross-compilation. 2020-10-10 20:01:18 +02:00
scottolsen
204ebc85e4 Load the Opaque type 2020-06-17 18:16:58 -04:00
Erik Svedäng
bbb7920332
Merge pull request #815 from hellerve/veit/fix-776
Make Array.range safe
2020-05-26 20:55:16 +02:00
Scott Olsen
7f095d754c Add Introspect module
The introspect module contains functions that return information about
program bindings based on their s-expressions.
2020-05-22 01:16:55 -04:00
hellerve
74d734903e core: move range into array ext and add unsafe-range 2020-05-21 15:23:29 +02:00
Dhananjay Balan
05bf39827b Add signal.h on FreeBSD platforms
The SIGNAL definitions are in signal.h, this also adds a macro freebsd-only, in the style of other platform-only macros.
2020-05-13 16:10:00 +02:00
hellerve
fe2c08c1ff core: rearrange templates 2020-05-12 21:58:40 +02:00
hellerve
d2235112dd core: move the first function into carp template 2020-05-12 11:32:26 +02:00
Erik Svedäng
870d549da9 Merge branch 'master' into do-not-reload-core-libs 2020-05-06 10:08:56 +02:00
hellerve
80d1086cb7 tests: better dynamic tests 2020-05-05 15:09:18 +02:00
Erik Svedäng
ca804beace Added support for (load-once). 2020-05-05 15:00:57 +02:00
hellerve
5838136f83 core: rename dynor and dynand and check in docs 2020-05-04 23:47:06 +02:00
hellerve
a761b561e3 all: use dynor and dynand 2020-05-01 12:50:31 +02:00
Erik Svedäng
89dcad4e79 Merge branch 'master' into static-arrays 2020-04-29 10:39:44 +02:00
Erik Svedäng
de8104eb14 Add Control.iterate-until. 2020-04-28 14:48:39 +02:00
Erik Svedäng
14b608a36e Static array kinda works now. 2020-04-28 10:06:17 +02:00
hellerve
6185099044 interim 2020-04-17 11:58:26 +02:00
Erik Svedäng
608634e471
Merge pull request #690 from hellerve/veit/stdint-print
Using formatting macros for stdint
2020-02-21 13:00:10 +01:00
hellerve
238365bcc2 core: fix #688 by using the correct formatting macros\n\n(and pray that windows does c99) 2020-02-21 12:28:34 +01:00
Scott Olsen
edee6d9dc9 Add basic tests for the binary module
I've also added the Binary module to Core.carp.
2020-02-18 15:34:41 -05:00
hellerve
657f27c6ac core: add stdint types 2020-02-17 10:42:07 +01:00
Erik Svedäng
ea045be426 Merge branch 'byte-type' of https://github.com/hellerve/Carp into hellerve-byte-type 2020-01-27 10:10:58 +01:00
Erik Svedäng
99bf013b81
Merge pull request #626 from nateupstairs/master
[win] attempt to fix windows compilation
2019-11-29 14:15:32 +01:00
Erik Svedäng
34c314e6fe
Merge pull request #618 from sdilts/fopen-safe
Add open-file function
2019-11-25 12:42:42 +01:00
Erik Svedäng
cf276f4488
Merge pull request #608 from hellerve/pointer-arith
Add pointer arithmetic
2019-11-25 12:36:10 +01:00
nateupstairs
539804d9b0 [win] attempt to fix windows compilation 2019-11-20 13:26:59 -08:00
sdilts
77614b21d9 Add errno to System.carp
+ Error values included are those that can be set from calling `fopen`
+ Change order of imports so that the System module is available before the IO module
2019-11-01 17:26:56 -06:00
hellerve
f1f252639f core: add a byte type 2019-11-01 10:52:34 +01:00
GrayJack
2ac9d7fc12 Add 2 missing includes on core/Core.carp 2019-10-31 05:42:14 -03:00
hellerve
2819d22729 core: add pointer arithmetic (references #423) 2019-10-30 08:09:18 +01:00
Jorge Acereda
4a4107fffd Preserve includes order in generated output. 2019-10-03 00:23:27 +02:00
Jorge Acereda
08af49dc62 Working on generics.
- Added Generics module.
- Some Geometry/Vector* functions hardcoded parameters to Double.
2019-09-08 13:02:04 +02:00
hellerve
ae62154afc core: add result draft 2019-02-13 19:31:47 +01:00
Erik Svedäng
da8fb684c9 Some memory tests, etc. 2019-02-01 14:07:10 +01:00
Chris Hall
1543fac3fb Issue #252 adding Sort module in Carp using Heap.Heapsort 2018-06-26 15:08:34 +10:00
Chris Hall
24e8cee18f Adding Heap module including HeapSort implementation and test suite 2018-06-26 15:08:34 +10:00
hellerve
913e8e3892 core: add map 2018-06-11 20:50:54 +02:00
Erik Svedäng
644119a7ec Added 'Core.carp' file that contains files to load at boot. 2018-06-05 13:28:28 +02:00