Commit graph

124 commits

Author SHA1 Message Date
Orion Henry
4860adfa52 fmt & clippy 2022-09-29 15:59:10 -05:00
Alex Good
e295a55b41 Add #[derive(Eq)] to satisfy clippy
The latest clippy (90.1.65 for me) added a lint which checks for types
that implement `PartialEq` and could implement `Eq`
(`derive_partial_eq_without_eq`). Add a `derive(Eq)` in a bunch of
places to satisfy this lint.
2022-09-01 12:24:00 +01:00
Jason Kankiewicz
22f720c465 Emphasize that an AMbyteSpan is only a view onto
the memory that it references.
2022-08-25 13:51:15 -07:00
Jason Kankiewicz
7da1832b52 Fix documentation bug caused by missing /. 2022-08-23 06:04:22 -07:00
Jason Kankiewicz
5e37ebfed0 Add AMchangesInit() for @rkuhn in #411.
Expose `automerge::AutoCommit::with_actor()` through `AMcreate()`.
Add notes to clarify the purpose of `AMfreeStack()`, `AMpop()`,
`AMpush()`, `AMpushCallback()`, and `AMresultStack`.
2022-08-23 05:34:45 -07:00
Jason Kankiewicz
1ed67a7658 Add missing documentation for the AMvalue.unknown
variant, the `AMunknownValue.bytes` member and the
`AMunknownValue.type_code` member.
2022-08-22 23:31:55 -07:00
Jason Kankiewicz
3ddde2fff2 Normalize the header include statement for all C
source files.
Normalize the header include statement within the documentation.
Limit `AMpush()` usage within the quickstart example to variable
assignment.
2022-08-22 22:28:23 -07:00
Alex Good
9ac8827219
Remove storage-v2 feature flag
Signed-off-by: Alex Good <alex@memoryandthought.me>
2022-08-22 21:21:21 +01:00
Alex Good
9c86c09aaa
Rename Change::compressed_bytes -> Change::bytes 2022-08-22 21:18:11 +01:00
Jason Kankiewicz
632da04d60
Add the -DFEATURE_FLAG_STORAGE_V2 CMake option
for toggling the "storage-v2" feature flag in a Cargo invocation.
Correct the `AMunknownValue` struct misnomer.
Ease the rebasing of changes to the `AMvalue` struct declaration with
pending upstream changes to same.
2022-08-22 21:18:07 +01:00
Alex Good
d53d107076
Expose storage-v2 in automerge-c
Signed-off-by: Alex Good <alex@memoryandthought.me>
2022-08-22 21:16:47 +01:00
Alex Good
3a3df45b85
Access change fields through field accessors
The representation of changes in storage-v2 is different to the existing
representation so add accessor methods to the fields of `Change` and
make all accesses go through them. This allows the change representation
in storage-v2 to be a drop-in.

Signed-off-by: Alex Good <alex@memoryandthought.me>
2022-08-22 21:16:42 +01:00
Alex Good
d785c319b8
Add ScalarValue::Unknown
The colunar storage format allows for values which we do not know the
type of. In order that we can handle these types in a forward compatible
way we add ScalarValue::Unknown.

Signed-off-by: Alex Good <alex@memoryandthought.me>
2022-08-22 21:04:19 +01:00
Jason Kankiewicz
bc28faee71 Replace NULL with std::ptr::null() within the
safety notes for @alexjg in #414.
2022-08-07 20:04:49 -07:00
Jason Kankiewicz
50981acc5a Replace to_del!() and to_pos!() with
`to_index!()` for @alexjg in #414.
2022-08-07 19:37:48 -07:00
Jason Kankiewicz
7ec17b26a9 Replace `From<&AMvalue<'_>> for Result<
am::ScalarValue, am::AutomergeError>` with `TryFrom<&AMvalue<'_>> for
am::ScalarValue` for @alexjg in #414.
2022-08-07 19:24:47 -07:00
Jason Kankiewicz
825342cbb1 Remove reflexive struct reference from a Doxygen
variable declaration.
2022-08-07 08:07:00 -07:00
Jason Kankiewicz
04d0175113 Add missing past-the-end checks to the unit tests
for `AMmapRange()`.
2022-08-06 16:20:35 -07:00
Jason Kankiewicz
14bd8fbe97 Port the WASM API's basic unit tests to C.
Weave the original TypeScript code into the C ports of the WASM API's
sync tests.
Fix misnomers in the WASM API's basic and sync unit tests.
Fix misspellings in the WASM API's basic and sync unit tests.
2022-08-06 16:18:59 -07:00
Jason Kankiewicz
d48e366272 Fix some documentation content bugs.
Fix some documentation formatting bugs.
2022-08-06 15:56:21 -07:00
Jason Kankiewicz
4217019cbc Expose automerge::AutoCommit::get_all() as AMlistGetAll() and AMmapGetAll().
Add symbolic last index specification to `AMlist{Delete,Get,Increment}()`.
Add symbolic last index specification to `AMlistPut{Bool,Bytes,Counter,
F64,Int,Null,Object,Str,Timestamp,Uint}()`.
Prevent `doc::utils::to_str(NULL)` from segfaulting.
Fix some documentation content bugs.
Fix some documentation formatting bugs.
2022-08-06 15:47:53 -07:00
Jason Kankiewicz
eeb75f74f4 Fix AMstrsCmp().
Fix some documentation content bugs.
Fix some documentation formatting bugs.
2022-08-06 15:07:48 -07:00
Jason Kankiewicz
a22afdd70d Expose automerge::AutoCommit::get_change_by_hash()
as `AMgetChangeByHash()`.
Add the `AM_CHANGE_HASH_SIZE` macro define constant for
`AMgetChangeByHash()`.
Replace the literal `32` with the `automerge::types::HASH_SIZE` constant.
Expose `automerge::AutoCommit::splice()` as `AMsplice()`.
Add the `automerge::error::AutomergeError::InvalidValueType` variant for
`AMsplice()`.
Add push functionality to `AMspliceText()`.
Fix some documentation content bugs.
Fix some documentation formatting bugs.
2022-08-06 15:04:46 -07:00
Orion Henry
5c6f375f99
Merge pull request #410 from jkankiewicz/add_range_functions_to_C_API
Add range functions to C API
2022-08-03 10:47:44 -05:00
Jason Kankiewicz
3a556c5991 Expose Autocommit::fork_at().
Rename `AMdup()` to `AMclone()` to match the WASM API.
Rename `AMgetActor()` to `AMgetActorId()` to match the WASM API.
Rename `AMsetActor()` to `AMsetActorId()` to match the WASM API.
2022-08-01 07:02:30 -07:00
Jason Kankiewicz
69de8187a5 Update the build system with the added and
renamed source files.
Defer `BTreeMap` creation until necessary for  `AMresult::Changes`.
Add `AMvalueEqual()` to enable direct comparison of two `AMvalue` structs regardless of their respective variants.
2022-07-25 01:41:52 -07:00
Jason Kankiewicz
877744d40b Add equality comparison to the AM* types from
which it was missing.
Add equality comparison to `automerge::sync::message`.
Defer `std::ffi::CString` creation until necessary.
2022-07-25 01:33:50 -07:00
Jason Kankiewicz
14b55c4a73 Fix a bug with the iterators when they pass their
initial positions in reverse.
Rename `AMstrings` to `AMstrs` for consistency with the `AMvalue.str`
field.
2022-07-25 01:23:26 -07:00
Jason Kankiewicz
23fbb4917a Replace _INCLUDED with _H as the suffix for
include guards in C headers like the one generated by cbindgen.
2022-07-25 01:04:35 -07:00
Jason Kankiewicz
877dbbfce8 Simplify the unit tests with AMresultStack et.
al.
2022-07-25 01:00:50 -07:00
Jason Kankiewicz
a22bcb916b Promoted ResultStack/StackNode from the
quickstart example up to the library as `AMresultStack` so that it can
appear in the README.md and be used to simplify the unit tests.
Promoted `free_results()` to `AMfreeStack()` and `push()` to `AMpush()`.
Added `AMpop()` because no stack should be without one.
2022-07-25 00:50:40 -07:00
Jason Kankiewicz
42ab1639db Add heads argument to AMmapGet() to expose
`automerge::AutoCommit::get_at()`.
Add `AMmapRange()` to expose `automerge::AutoCommit::map_range()` and
`automerge::AutoCommit::map_range_at()`.
Add `AMmapItems` for `AMlistRange()`.
Add `AMmapItem` for `AMmapItems`.
2022-07-25 00:11:00 -07:00
Jason Kankiewicz
eba18d1ad6 Add heads argument to AMlistGet() to expose
`automerge::AutoCommit::get_at()`.
Add `AMlistRange()` to expose `automerge::AutoCommit::list_range()` and
`automerge::AutoCommit::list_range_at()`.
Add `AMlistItems` for `AMlistRange()`.
Add `AMlistItem` for `AMlistItems`.
2022-07-24 22:41:32 -07:00
Jason Kankiewicz
ee68645f31 Add AMfork() to expose `automerge::AutoCommit::
fork()`.
Add `AMobjValues()` to expose `automerge::AutoCommit::values()` and
`automerge::AutoCommit::values_at()`.
Add `AMobjIdActorId()`, `AMobjIdCounter()`, and `AMobjIdIndex()` to expose `automerge::ObjId::Id` fields.
Change `AMactorId` to reference an `automerge::ActorId` instead of
owning one for `AMobjIdActorId()`.
Add `AMactorIdCmp()` for `AMobjIdActorId()` comparison.
Add `AMobjItems` for `AMobjValues()`.
Add `AMobjItem` for `AMobjItems`.
Add `AMobjIdEqual()` for property comparison.
Rename `to_doc!()` to `to_doc_mut!()` and `to_doc_const!()` to `to_doc!()`
for consistency with the Rust standard library.
2022-07-24 22:23:54 -07:00
Jason Kankiewicz
cc19a37f01 Remove the makefile for the original C
API to prevent confusion.
2022-07-23 08:48:19 -07:00
Jason Kankiewicz
15c9adf965 Remove the obsolete test suite for the original
C API to prevent confusion.
2022-07-23 08:47:21 -07:00
Jason Kankiewicz
52a558ee4d Cease writing a pristine copy of the generated
header file into the root of the C API's source directory to prevent
confusion.
2022-07-23 08:44:41 -07:00
Jason Kankiewicz
e5a8b67b11 Added AMspliceText().
Added `AMtext()`.
Replaced `*mut` function arguments with `*const`
function arguments where possible.
Added "out" directions to the documentation for
out function parameters.
2022-06-20 23:15:25 -07:00
Jason Kankiewicz
aeb8db556c Added "out" directions to the documentation for
out function parameters.
2022-06-20 23:11:03 -07:00
Jason Kankiewicz
eb462cb228 Made free_results() reset the stack pointer. 2022-06-20 15:55:31 -07:00
Jason Kankiewicz
0cbacaebb6 Simplified the AMstrings struct to directly
reference `std::ffi::CString` values.
Switched the `AMresult` struct to store a `Vec<CString>` instead of a
`Vec<String>`.
2022-06-20 14:35:30 -07:00
Jason Kankiewicz
bf4988dcca Fixed AM{change_hashes,changes,haves,strings}Prev(). 2022-06-20 13:50:05 -07:00
Jason Kankiewicz
770c064978 Made cosmetic changes to the quickstart example. 2022-06-20 13:45:32 -07:00
Jason Kankiewicz
db0333fc5a Added AM_ROOT usage to the documentation.
Renamed the `value` argument of `AM{list,map}PutBytes()` to `src` for
consistency with standard `memcpy()`.
2022-06-20 02:16:33 -07:00
Jason Kankiewicz
7bdf726ce1 Sublimated memory management in the quickstart
example.
2022-06-20 02:07:33 -07:00
Jason Kankiewicz
47c5277406 Added AMkeys().
Removed `AMobjSizeAt()`.
Added an optional `AMchangeHashes` argument to `AMobjSize()`.
Replaced the term "length" with "size" in the
documentation.
2022-06-20 01:53:31 -07:00
Jason Kankiewicz
ea8bd32cc1 Added the AMstrings type. 2022-06-20 01:38:32 -07:00
Jason Kankiewicz
be130560f0 Added a check for a 0 increment in the iterator
types.
Improved the documentation for the `detail` field in the iterator types.
2022-06-20 01:34:36 -07:00
Jason Kankiewicz
103d729bd1 Replaced the term "length" with "size" in the
documentation.
2022-06-20 01:31:08 -07:00
Jason Kankiewicz
7b30c84a4c Added AMchangeHashesInit(). 2022-06-20 01:17:20 -07:00