Skip to content
This repository has been archived by the owner on Jan 16, 2020. It is now read-only.

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
pinnecke committed Aug 11, 2019
2 parents bf57adc + 1f0f04a commit 3b59e61
Show file tree
Hide file tree
Showing 11 changed files with 59 additions and 15 deletions.
14 changes: 14 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,17 @@ carbon-temp-statistics--cache-monitor.csv
examples/json
book/libcarbon/latest/book
book/spec/latest/book

CMakeFiles

CMakeCache

.DS_Store

.idea

Makefile

cmake_install.cmake

CMakeCache.txt
12 changes: 6 additions & 6 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@ project(libcarbon VERSION 1.0.0.0 DESCRIPTION "A library to operate with CARBON
set (CMAKE_C_STANDARD 11)

#if (${BUILD_TYPE} MATCHES Debug)
message("-- Debug build is enabled")
set(CMAKE_BUILD_TYPE Debug)
# message("-- Debug build is enabled")
# set(CMAKE_BUILD_TYPE Debug)
#else()
# message("-- Release build is enabled")
# set(CMAKE_BUILD_TYPE Release)
message("-- Release build is enabled")
set(CMAKE_BUILD_TYPE Release)
#endif()

file(MAKE_DIRECTORY ${CMAKE_HOME_DIRECTORY}/build)
Expand Down Expand Up @@ -68,13 +68,13 @@ if (${LOG_WARN} MATCHES "on")
endif()
endif()

set (CMAKE_C_FLAGS "-Wall -std=c11 -Wextra -Werror")
set (CMAKE_C_FLAGS "-std=c11 -Wall -Wextra -Werror")
set (CMAKE_C_FLAGS_DEBUG "-g")
set (CMAKE_C_FLAGS_MINSIZEREL "-Os -DNDEBUG")
set (CMAKE_C_FLAGS_RELEASE "-O3 -DNDEBUG")
set (CMAKE_C_FLAGS_RELWITHDEBINFO "-O2 -g")

set (CMAKE_CXX_FLAGS "-std=c++11 -Wall")
set (CMAKE_CXX_FLAGS "-std=c++11 -Wall -Wextra -Werror")
set (CMAKE_CXX_FLAGS_DEBUG "-g")
set (CMAKE_CXX_FLAGS_MINSIZEREL "-Os -DNDEBUG")
set (CMAKE_CXX_FLAGS_RELEASE "-O3 -DNDEBUG")
Expand Down
5 changes: 4 additions & 1 deletion NEWS.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
## 0.3.00.01 [2019-XX-XX]
## 0.5.00.01 [2019-XX-XX]
- JSON parser for carbon files (see `carbon_from_json` in `carbon.h`)

## 0.3.00.01 [2019-08-09]
- Add thread pool implementation (`struct thread_pool`)

## 0.3.00.00 [2019-04-11]
Expand Down
2 changes: 1 addition & 1 deletion src/ark-js/carbon/carbon-array-it.c
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ static bool update_in_place_constant(struct carbon_array_it *it, enum carbon_con
error(&it->err, ARK_ERR_INTERNALERR);
break;
}
offset_t datum;
offset_t datum = 0;
carbon_int_array_it_offset(&datum, it);
memfile_seek(&it->memfile, datum);
memfile_write(&it->memfile, &value, sizeof(u8));
Expand Down
2 changes: 1 addition & 1 deletion src/ark-js/carbon/carbon-int.c
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ ARK_EXPORT(bool) carbon_int_insert_column(struct memfile *memfile_in, struct err
error_if_null(memfile_in);
error_if_null(err_in);

enum carbon_field_type column_type;
ark_declare_and_init(enum carbon_field_type, column_type)

switch (type) {
case CARBON_COLUMN_TYPE_BOOLEAN:
Expand Down
14 changes: 10 additions & 4 deletions src/ark-js/carbon/carbon-key.c
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,9 @@ ARK_EXPORT(bool) carbon_key_skip(enum carbon_primary_key_type *out, struct memfi
ARK_EXPORT(bool) carbon_key_write_unsigned(struct memfile *file, u64 key)
{
error_if_null(file)
enum carbon_primary_key_type key_type;

ark_declare_and_init(enum carbon_primary_key_type, key_type)

carbon_key_read_type(&key_type, file);
if (carbon_key_is_unsigned_type(key_type)) {
memfile_write(file, &key, sizeof(u64));
Expand All @@ -107,7 +109,9 @@ ARK_EXPORT(bool) carbon_key_write_unsigned(struct memfile *file, u64 key)
ARK_EXPORT(bool) carbon_key_write_signed(struct memfile *file, i64 key)
{
error_if_null(file)
enum carbon_primary_key_type key_type;

ark_declare_and_init(enum carbon_primary_key_type, key_type)

carbon_key_read_type(&key_type, file);
if (carbon_key_is_signed_type(key_type)) {
memfile_write(file, &key, sizeof(i64));
Expand All @@ -121,7 +125,7 @@ ARK_EXPORT(bool) carbon_key_write_signed(struct memfile *file, i64 key)
ARK_EXPORT(bool) carbon_key_update_string(struct memfile *file, const char *key)
{
error_if_null(file)
enum carbon_primary_key_type key_type;
ark_declare_and_init(enum carbon_primary_key_type, key_type)
carbon_key_read_type(&key_type, file);
if (carbon_key_is_string_type(key_type)) {
carbon_string_update(file, key);
Expand All @@ -135,7 +139,9 @@ ARK_EXPORT(bool) carbon_key_update_string(struct memfile *file, const char *key)
ARK_EXPORT(bool) carbon_key_write_string(struct memfile *file, const char *key)
{
error_if_null(file)
enum carbon_primary_key_type key_type;

ark_declare_and_init(enum carbon_primary_key_type, key_type)

carbon_key_read_type(&key_type, file);
if (carbon_key_is_string_type(key_type)) {
carbon_string_write(file, key);
Expand Down
4 changes: 3 additions & 1 deletion src/ark-js/carbon/carbon-revision.c
Original file line number Diff line number Diff line change
Expand Up @@ -63,9 +63,11 @@ ARK_EXPORT(bool) carbon_revision_peek(u64 *revision, struct memfile *file)

ARK_EXPORT(bool) carbon_revision_inc(struct memfile *file)
{
u64 rev;
ark_declare_and_init(u64, rev)

carbon_revision_peek(&rev, file);
rev++;
memfile_update_varuint(file, rev);

return true;
}
8 changes: 8 additions & 0 deletions src/ark-js/carbon/carbon.c
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,14 @@ ARK_EXPORT(bool) carbon_create_empty_ex(struct carbon *doc, enum carbon_primary_
return true;
}

ARK_EXPORT(bool) carbon_from_json(struct carbon *doc, const char *json)
{
error_if_null(doc)
error_if_null(json)

return true;
}

ARK_EXPORT(bool) carbon_drop(struct carbon *doc)
{
error_if_null(doc);
Expand Down
2 changes: 2 additions & 0 deletions src/ark-js/carbon/carbon.h
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,8 @@ ARK_EXPORT(bool) carbon_create_empty(struct carbon *doc, enum carbon_primary_key
ARK_EXPORT(bool) carbon_create_empty_ex(struct carbon *doc, enum carbon_primary_key_type key_type, u64 doc_cap_byte,
u64 array_cap_byte);

ARK_EXPORT(bool) carbon_from_json(struct carbon *doc, const char *json);

ARK_EXPORT(bool) carbon_drop(struct carbon *doc);

ARK_EXPORT(bool) carbon_is_up_to_date(struct carbon *doc);
Expand Down
4 changes: 4 additions & 0 deletions src/ark-js/shared/common.h
Original file line number Diff line number Diff line change
Expand Up @@ -271,6 +271,10 @@ ark_func_unused static const char *basic_type_to_system_type_str(enum field_type
#define MARKER_SYMBOL_HASHTABLE_HEADER '#'
#define MARKER_SYMBOL_VECTOR_HEADER '|'

#define ark_declare_and_init(type, name) \
type name; \
ark_zero_memory(&name, sizeof(type));

#define ark_zero_memory(dst, len) \
memset((void *) dst, 0, len);

Expand Down
7 changes: 6 additions & 1 deletion tests/carbon/test-carbon.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -437,7 +437,7 @@ TEST(CarbonTest, BisonArrayIteratorStrings) {
for (i32 i = 0; i < 10; i++) {
u64 strlen = rand() % (100 + 1 - 4) + 4;
char buffer[strlen];
for (i32 j = 0; j < strlen; j++) {
for (u64 j = 0; j < strlen; j++) {
buffer[j] = 65 + (rand() % 25);
}
buffer[0] = '!';
Expand Down Expand Up @@ -7221,6 +7221,11 @@ TEST(CarbonTest, BisonUpdateSetToNull)
string_builder_drop(&sb);
}

TEST(CarbonTest, CarbonFromJson)
{

}

int main(int argc, char **argv) {
::testing::InitGoogleTest(&argc, argv);
return RUN_ALL_TESTS();
Expand Down

0 comments on commit 3b59e61

Please sign in to comment.