Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test #1

Merged
merged 26 commits into from
Sep 18, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
3cbc9cb
fix(user_db): unwanted implicit instantiation of UserDbFormat template
lotem Mar 5, 2018
831ffba
fix(config_compiler): "/" mistaken as path separator in merged map ke…
kionz Mar 7, 2018
cafd5c4
fix(ConfigFileUpdate): no need to create user build if shared build i…
lotem Mar 8, 2018
45a04dd
fix(SchemaUpdate): read compiled schema from shared build if there is…
lotem Mar 8, 2018
3d28bf6
chore(release tag): deprecating tag name prefix 'rime-' in favor of c…
lotem Mar 9, 2018
4240511
chore(CMakeLists.txt): bump version to 1.3.0
lotem Mar 9, 2018
854ad2b
chore(release): 1.3.0 :tada:
lotem Mar 9, 2018
6f7be0d
chore(tags): adopt semver "X.Y.Z" without prefix [ci skip]
lotem Mar 10, 2018
8d8d2e6
fix(config_file_update): clean up deprecated user copy (#193)
lotem Mar 16, 2018
6f6056a
fix(thirdparty/src/leveldb): do not link to snappy library
lotem Mar 18, 2018
af1542a
chore(bump-version.sh): npm version script
lotem Apr 1, 2018
bec7e87
chore(release): 1.3.1 :tada:
lotem Apr 1, 2018
794898b
docs(README): replace rime/brise with rime/plum
lotem Apr 1, 2018
1a6e021
Add ENABLE_ASAN option
timxx Apr 16, 2018
030c389
Fix a heap-use-after-free error found by asan
timxx Apr 16, 2018
55b487f
chore(engine.cc): Google code style; more informative name
lotem Apr 17, 2018
253d8d1
chore(REAME.md): require boost>=1.48, for boost::locale [ci skip]
lotem Apr 21, 2018
0784eb0
fix(config_compiler): support creating list in-place by __patch and _…
lotem Apr 24, 2018
99573e3
fix(CMakeLists.txt): do not link binaries when building static library
lotem May 8, 2018
7f9b056
refactor(editor): extract helper class key_binding_processor
lotem Jun 9, 2018
122893d
refactor(navigator): key bindings
lotem Jun 12, 2018
b86b647
fix(config_compiler): ambiguous operator overload with cmake option E…
lotem Jul 2, 2018
9f774e7
feat(language): shared user dictionary per language (Closes #184) (#214)
lotem Aug 2, 2018
74e31bc
fix(table_translator): enable encoding uniquified commit history
nameoverflow Aug 14, 2018
19cea07
feat: always_show_comments option (#220)
ztl8702 Aug 22, 2018
56f1267
Merge branch 'wasm' into master
ztl8702 Sep 18, 2018
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .npmrc
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
tag-version-prefix="rime-"
tag-version-prefix=""
message="chore(release): %s :tada:"
36 changes: 36 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,39 @@
<a name="1.3.1"></a>
## [1.3.1](https://github.com/rime/librime/compare/1.3.0...1.3.1) (2018-04-01)


### Bug Fixes

* **config_file_update:** clean up deprecated user copy ([#193](https://github.com/rime/librime/issues/193)) ([8d8d2e6](https://github.com/rime/librime/commit/8d8d2e6))
* **thirdparty/src/leveldb:** do not link to snappy library ([6f6056a](https://github.com/rime/librime/commit/6f6056a))



<a name="1.3.0"></a>
# 1.3.0 (2018-03-09)


### Bug Fixes

* **CMakeLists.txt, build.bat:** install header files (public API) ([06c9e86](https://github.com/rime/librime/commit/06c9e86))
* **config_compiler:** "/" mistaken as path separator in merged map key ([#192](https://github.com/rime/librime/issues/192)) ([831ffba](https://github.com/rime/librime/commit/831ffba)), closes [#190](https://github.com/rime/librime/issues/190)
* **ConfigFileUpdate:** no need to create user build if shared build is up-to-date ([cafd5c4](https://github.com/rime/librime/commit/cafd5c4))
* **SchemaUpdate:** read compiled schema from shared build if there is no user build ([45a04dd](https://github.com/rime/librime/commit/45a04dd))
* **simplifier:** fix typo ([9e1114e](https://github.com/rime/librime/commit/9e1114e)), closes [#183](https://github.com/rime/librime/issues/183)
* **user_db:** unwanted implicit instantiation of UserDbFormat template ([3cbc9cb](https://github.com/rime/librime/commit/3cbc9cb)), closes [#188](https://github.com/rime/librime/issues/188)


### Chores

* **release tag:** deprecating tag name prefix 'rime-' in favor of semver 'X.Y.Z'


### BREAKING CHANGES

* **release tag:** After 1.3.0 release, we'll no longer be creating tags in the format 'rime-X.Y.Z'. Downstream packagers please change automated scripts accordingly.



<a name="1.2.10"></a>
## 1.2.10 (2018-02-21)

Expand Down
23 changes: 18 additions & 5 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ set(CMAKE_USER_MAKE_RULES_OVERRIDE_CXX ${CMAKE_CURRENT_SOURCE_DIR}/cmake/cxx_fla
project(rime)
cmake_minimum_required(VERSION 2.8.11)

set(rime_version 1.2.10)
set(rime_version 1.3.1)
set(rime_soversion 1)

add_definitions(-DRIME_VERSION="${rime_version}")
Expand All @@ -17,8 +17,9 @@ option(BUILD_SEPARATE_LIBS "Build a separate rime-gears library" OFF)
option(ENABLE_LOGGING "Enable logging with google-glog library" ON)
option(BOOST_USE_CXX11 "Boost has been built with C++11 support" OFF)
option(BOOST_USE_SIGNALS2 "Boost use signals2 instead of signals" ON)
option(ENABLE_ASAN "Enable Address Sanitizer (Unix Only)" OFF)

SET(rime_data_dir "/share/rime-data" CACHE STRING "Target directory for Rime data")
set(rime_data_dir "/share/rime-data" CACHE STRING "Target directory for Rime data")

if(WIN32)
set(ext ".exe")
Expand All @@ -27,6 +28,15 @@ endif(WIN32)
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${PROJECT_SOURCE_DIR}/cmake")
set(CMAKE_PREFIX_PATH ${CMAKE_PREFIX_PATH} "${PROJECT_SOURCE_DIR}/thirdparty")

if (ENABLE_ASAN)
set(asan_cflags "-fsanitize=address -fno-omit-frame-pointer")
set(asan_lflags "-fsanitize=address -lasan")
set(CMAKE_C_FLAGS "${asan_cflags} ${CMAKE_C_FLAGS}")
set(CMAKE_CXX_FLAGS "${asan_cflags} ${CMAKE_CXX_FLAGS}")
set(CMAKE_EXE_LINKER_FLAGS "${asan_lflags} ${CMAKE_EXE_LINKER_FLAGS}")
set(CMAKE_SHARED_LINKER_FLAGS "${asan_lflags} ${CMAKE_SHARED_LINKER_FLAGS}")
endif()

set(Boost_USE_STATIC_LIBS ${BUILD_STATIC})
set(Gflags_STATIC ${BUILD_STATIC})
set(Glog_STATIC ${BUILD_STATIC})
Expand Down Expand Up @@ -186,8 +196,11 @@ else()
endif()

add_subdirectory(src)
add_subdirectory(tools)

if(GTEST_FOUND)
add_subdirectory(test)
if(BUILD_SHARED_LIBS)
add_subdirectory(tools)

if(GTEST_FOUND)
add_subdirectory(test)
endif()
endif()
7 changes: 3 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ Build dependencies
---
- compiler with C++11 support
- cmake>=2.8
- libboost>=1.46
- libboost>=1.48
- libglog (optional)
- libleveldb
- libmarisa
Expand Down Expand Up @@ -79,10 +79,9 @@ Plugins

Related works
===
- [brise](https://github.com/rime/brise): Rime schema repository
- Combo Pinyin: an innovative chord-typing practice to input Pinyin
- [plum](https://github.com/rime/plum): Rime configuration manager and input schema repository
- [Combo Pinyin](https://github.com/rime/home/wiki/ComboPinyin): an innovative chord-typing practice to input Pinyin
- essay: the vocabulary and language model for Rime
- [rimekit](https://github.com/lotem/rimekit): configuration tools for Rime (under construction)
- [SCU](https://github.com/neolee/SCU/): Squirrel Configuration Utilities

Credits
Expand Down
12 changes: 12 additions & 0 deletions bump-version.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#!/bin/bash

set -e

version=$(node -p 'require("./package.json").version')

sed -i'~' 's/set(\(rime_version\) .*)/set(\1 '$version')/' CMakeLists.txt
rm 'CMakeLists.txt~'
git add CMakeLists.txt

conventional-changelog -p angular -i CHANGELOG.md -s
git add CHANGELOG.md
8 changes: 8 additions & 0 deletions data/test/config_merge_test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -46,3 +46,11 @@ merge_tree:
zerg:
# overwrite existing list
ground_units: []

create_list_with_inplace_patch:
# map node without data key-value (exclude compiler directives) can be converted to list
all_ground_units:
__patch:
- __append: [scv, marine, firebat, vulture, tank]
- __append: {__include: starcraft/protoss/ground_units}
- __append: {__include: starcraft/zerg/ground_units}
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "librime",
"version": "1.2.10",
"version": "1.3.1",
"description": "Rime Input Method Engine",
"main": "index.js",
"directories": {
Expand All @@ -9,7 +9,7 @@
},
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"version": "conventional-changelog -p angular -i CHANGELOG.md -s && git add CHANGELOG.md"
"version": "./bump-version.sh"
},
"repository": {
"type": "git",
Expand Down
2 changes: 2 additions & 0 deletions src/rime/common.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@
// call a pointer to member function on this
#define RIME_THIS_CALL(f) (this->*(f))

#define RIME_THIS_CALL_AS(T, f) ((T*)this->*(f))

namespace rime {

using std::function;
Expand Down
59 changes: 39 additions & 20 deletions src/rime/config/config_compiler.cc
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,14 @@

namespace rime {

std::ostream& operator<< (std::ostream& stream, const Reference& reference) {
return stream << reference.repr();
}

std::ostream& operator<< (std::ostream& stream, const Dependency& dependency) {
return stream << dependency.repr();
}

struct ConfigDependencyGraph {
map<string, of<ConfigResource>> resources;
vector<of<ConfigItemRef>> node_stack;
Expand Down Expand Up @@ -97,8 +105,13 @@ static bool AppendToList(an<ConfigItemRef> target, an<ConfigList> list) {
return false;
auto existing_list = As<ConfigList>(**target);
if (!existing_list) {
LOG(ERROR) << "trying to append list to other value";
return false;
if (!(**target)->empty()) {
LOG(ERROR) << "trying to append list to incompatible node type";
return false;
}
// convert empty node (usually map with only compiler directives) to list;
// refer to test case RimeConfigMergeTest.CreateListWithInplacePatch
existing_list = target->AsList();
}
if (list->empty())
return true;
Expand Down Expand Up @@ -155,33 +168,39 @@ inline static string StripOperator(const string& key, bool adding) {
}

// defined in config_data.cc
bool TraverseCopyOnWrite(an<ConfigItemRef> root, const string& path,
function<bool (an<ConfigItemRef> target)> writer);
an<ConfigItemRef> TypeCheckedCopyOnWrite(an<ConfigItemRef> parent,
const string& key);
an<ConfigItemRef> TraverseCopyOnWrite(an<ConfigItemRef> head,
const string& path);

static bool EditNode(an<ConfigItemRef> target,
static bool EditNode(an<ConfigItemRef> head,
const string& key,
const an<ConfigItem>& value,
bool merge_tree) {
DLOG(INFO) << "EditNode(" << key << "," << merge_tree << ")";
DLOG(INFO) << "edit node: " << key << ", merge_tree: " << merge_tree;
bool appending = IsAppending(key);
bool merging = IsMerging(key, value, merge_tree);
auto writer = [=](an<ConfigItemRef> target) {
if ((appending || merging) && **target) {
DLOG(INFO) << "writer: editing node";
return !value ||
(appending && (AppendToString(target, As<ConfigValue>(value)) ||
AppendToList(target, As<ConfigList>(value)))) ||
(merging && MergeTree(target, As<ConfigMap>(value)));
} else {
DLOG(INFO) << "writer: overwriting node";
*target = value;
return true;
}
};
string path = StripOperator(key, appending || merging);
DLOG(INFO) << "appending: " << appending << ", merging: " << merging
<< ", path: " << path;
return TraverseCopyOnWrite(target, path, writer);
auto find_target_node =
merge_tree ? &TypeCheckedCopyOnWrite : &TraverseCopyOnWrite;
auto target = find_target_node(head, path);
if (!target) {
// error finding target node; cannot write
return false;
}
if ((appending || merging) && **target) {
DLOG(INFO) << "writer: editing node";
return !value || // no-op
(appending && (AppendToString(target, As<ConfigValue>(value)) ||
AppendToList(target, As<ConfigList>(value)))) ||
(merging && MergeTree(target, As<ConfigMap>(value)));
} else {
DLOG(INFO) << "writer: overwriting node";
*target = value;
return true;
}
}

bool PatchLiteral::Resolve(ConfigCompiler* compiler) {
Expand Down
6 changes: 2 additions & 4 deletions src/rime/config/config_compiler.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
#ifndef RIME_CONFIG_COMPILER_H_
#define RIME_CONFIG_COMPILER_H_

#include <ostream>
#include <rime/common.h>
#include <rime/config/config_data.h>
#include <rime/config/config_types.h>
Expand Down Expand Up @@ -35,10 +36,7 @@ struct Reference {
string repr() const;
};

template <class StreamT>
StreamT& operator<< (StreamT& stream, const Reference& reference) {
return stream << reference.repr();
}
std::ostream& operator<< (std::ostream& stream, const Reference& reference);

class ConfigCompilerPlugin;
class ResourceResolver;
Expand Down
6 changes: 2 additions & 4 deletions src/rime/config/config_compiler_impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
#ifndef RIME_CONFIG_COMPILER_IMPL_H_
#define RIME_CONFIG_COMPILER_IMPL_H_

#include <ostream>
#include <rime/common.h>
#include <rime/config/config_compiler.h>
#include <rime/config/config_types.h>
Expand Down Expand Up @@ -32,10 +33,7 @@ struct Dependency {
virtual bool Resolve(ConfigCompiler* compiler) = 0;
};

template <class StreamT>
StreamT& operator<< (StreamT& stream, const Dependency& dependency) {
return stream << dependency.repr();
}
std::ostream& operator<< (std::ostream& stream, const Dependency& dependency);

struct PendingChild : Dependency {
string child_path;
Expand Down
43 changes: 29 additions & 14 deletions src/rime/config/config_data.cc
Original file line number Diff line number Diff line change
Expand Up @@ -159,37 +159,52 @@ class ConfigDataRootRef : public ConfigItemRef {
ConfigData* data_;
};

bool TraverseCopyOnWrite(an<ConfigItemRef> root, const string& path,
function<bool (an<ConfigItemRef> target)> writer) {
an<ConfigItemRef> TypeCheckedCopyOnWrite(an<ConfigItemRef> parent,
const string& key) {
// special case to allow editing current node by __append: __merge: /+: /=:
if (key.empty()) {
return parent;
}
bool is_list = ConfigData::IsListItemReference(key);
auto expected_node_type = is_list ? ConfigItem::kList : ConfigItem::kMap;
an<ConfigItem> existing_node = *parent;
if (existing_node && existing_node->type() != expected_node_type) {
LOG(ERROR) << "copy on write failed; incompatible node type: " << key;
return nullptr;
}
return Cow(parent, key);
}

an<ConfigItemRef> TraverseCopyOnWrite(an<ConfigItemRef> head,
const string& path) {
DLOG(INFO) << "TraverseCopyOnWrite(" << path << ")";
if (path.empty() || path == "/") {
return writer(root);
return head;
}
an<ConfigItemRef> head = root;
vector<string> keys = ConfigData::SplitPath(path);
size_t n = keys.size();
for (size_t i = 0; i < n; ++i) {
const auto& key = keys[i];
bool is_list = ConfigData::IsListItemReference(key);
auto expected_node_type = is_list ? ConfigItem::kList : ConfigItem::kMap;
an<ConfigItem> existing_node = *head;
if (existing_node && existing_node->type() != expected_node_type) {
LOG(ERROR) << "copy on write failed; incompatible node type: " << key;
return false;
if (auto child = TypeCheckedCopyOnWrite(head, key)) {
head = child;
} else {
LOG(ERROR) << "while writing to " << path;
return nullptr;
}
head = Cow(head, key);
}
return writer(head);
return head;
}

bool ConfigData::TraverseWrite(const string& path, an<ConfigItem> item) {
LOG(INFO) << "write: " << path;
auto root = New<ConfigDataRootRef>(this);
return TraverseCopyOnWrite(root, path, [=](an<ConfigItemRef> target) {
if (auto target = TraverseCopyOnWrite(root, path)) {
*target = item;
set_modified();
return true;
});
} else {
return false;
}
}

vector<string> ConfigData::SplitPath(const string& path) {
Expand Down
8 changes: 6 additions & 2 deletions src/rime/dict/level_db.cc
Original file line number Diff line number Diff line change
Expand Up @@ -345,10 +345,14 @@ bool LevelDb::CommitTransaction() {
}

template <>
const string UserDbFormat<LevelDb>::extension(".userdb");
string UserDbComponent<LevelDb>::extension() const {
return ".userdb";
}

template <>
const string UserDbFormat<LevelDb>::snapshot_extension(".userdb.txt");
string UserDbComponent<LevelDb>::snapshot_extension() const {
return ".userdb.txt";
}

template <>
UserDbWrapper<LevelDb>::UserDbWrapper(const string& db_name)
Expand Down
Loading