You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucy.apache.org by nw...@apache.org on 2013/09/01 22:17:02 UTC
[lucy-commits] [14/24] git commit: refs/heads/cfish-string-prep1 - Rename CharBuf to
String (cnick Str)
Rename CharBuf to String (cnick Str)
Project: http://git-wip-us.apache.org/repos/asf/lucy/repo
Commit: http://git-wip-us.apache.org/repos/asf/lucy/commit/2c3dbf15
Tree: http://git-wip-us.apache.org/repos/asf/lucy/tree/2c3dbf15
Diff: http://git-wip-us.apache.org/repos/asf/lucy/diff/2c3dbf15
Branch: refs/heads/cfish-string-prep1
Commit: 2c3dbf1582a24194bca5d730f54cbad9003ebdcf
Parents: a7926f4
Author: Nick Wellnhofer <we...@aevum.de>
Authored: Wed Aug 28 23:02:42 2013 +0200
Committer: Nick Wellnhofer <we...@aevum.de>
Committed: Sun Sep 1 19:20:00 2013 +0200
----------------------------------------------------------------------
c/sample/getting_started.c | 30 +-
c/src/Lucy/Analysis/RegexTokenizer.c | 12 +-
c/src/Lucy/Document/Doc.c | 10 +-
c/src/Lucy/Index/DocReader.c | 6 +-
c/src/Lucy/Index/Inverter.c | 12 +-
clownfish/compiler/perl/t/105-object_type.t | 2 +-
clownfish/compiler/perl/t/301-param_list.t | 2 +-
clownfish/compiler/perl/t/401-class.t | 6 +-
clownfish/compiler/perl/t/600-parser.t | 4 +-
clownfish/compiler/src/CFCBindCore.c | 2 +-
clownfish/compiler/src/CFCBindMethod.c | 2 +-
clownfish/compiler/src/CFCPerl.c | 4 +-
clownfish/compiler/src/CFCPerlMethod.c | 2 +-
clownfish/compiler/src/CFCPerlSub.c | 2 +-
clownfish/compiler/src/CFCPerlTypeMap.c | 6 +-
clownfish/compiler/src/CFCRuby.c | 2 +-
clownfish/compiler/src/CFCTestClass.c | 8 +-
clownfish/compiler/src/CFCTestParser.c | 4 +-
clownfish/compiler/src/CFCTestType.c | 2 +-
clownfish/compiler/src/CFCTestVariable.c | 2 +-
clownfish/compiler/src/CFCType.c | 2 +-
clownfish/runtime/c/src/Clownfish/Err.c | 14 +-
clownfish/runtime/c/src/Clownfish/VTable.c | 10 +-
clownfish/runtime/core/Clownfish/CharBuf.c | 912 -------------------
clownfish/runtime/core/Clownfish/CharBuf.cfh | 392 --------
clownfish/runtime/core/Clownfish/Err.c | 56 +-
clownfish/runtime/core/Clownfish/Err.cfh | 22 +-
clownfish/runtime/core/Clownfish/Hash.c | 2 +-
clownfish/runtime/core/Clownfish/Method.c | 12 +-
clownfish/runtime/core/Clownfish/Method.cfh | 12 +-
clownfish/runtime/core/Clownfish/Num.c | 18 +-
clownfish/runtime/core/Clownfish/Num.cfh | 8 +-
clownfish/runtime/core/Clownfish/Obj.c | 10 +-
clownfish/runtime/core/Clownfish/Obj.cfh | 4 +-
clownfish/runtime/core/Clownfish/String.c | 912 +++++++++++++++++++
clownfish/runtime/core/Clownfish/String.cfh | 392 ++++++++
.../runtime/core/Clownfish/Test/TestCharBuf.c | 258 +++---
clownfish/runtime/core/Clownfish/Test/TestErr.c | 8 +-
.../runtime/core/Clownfish/Test/TestHash.c | 10 +-
.../core/Clownfish/Test/TestLockFreeRegistry.c | 2 +-
.../Clownfish/Test/TestLockFreeRegistry.cfh | 2 +-
clownfish/runtime/core/Clownfish/Test/TestNum.c | 30 +-
clownfish/runtime/core/Clownfish/Test/TestObj.c | 26 +-
.../runtime/core/Clownfish/Test/TestVArray.c | 72 +-
.../core/Clownfish/Test/Util/TestStringHelper.c | 2 +-
.../Clownfish/TestHarness/TestBatchRunner.c | 4 +-
.../core/Clownfish/TestHarness/TestFormatter.c | 6 +-
.../core/Clownfish/TestHarness/TestSuite.c | 6 +-
.../core/Clownfish/TestHarness/TestSuite.cfh | 2 +-
.../core/Clownfish/TestHarness/TestUtils.c | 12 +-
.../core/Clownfish/TestHarness/TestUtils.cfh | 6 +-
clownfish/runtime/core/Clownfish/VTable.c | 42 +-
clownfish/runtime/core/Clownfish/VTable.cfh | 16 +-
.../perl/buildlib/Clownfish/Build/Binding.pm | 34 +-
clownfish/runtime/perl/lib/Clownfish.pm | 10 +-
clownfish/runtime/perl/lib/Clownfish/CharBuf.pm | 2 +-
clownfish/runtime/perl/t/021-vtable.t | 2 +-
clownfish/runtime/perl/t/binding/016-varray.t | 2 +-
clownfish/runtime/perl/t/binding/017-hash.t | 4 +-
clownfish/runtime/perl/t/binding/029-charbuf.t | 8 +-
.../perl/t/binding/038-lock_free_registry.t | 2 +-
clownfish/runtime/perl/xs/XSBind.c | 64 +-
clownfish/runtime/perl/xs/XSBind.h | 14 +-
clownfish/runtime/ruby/ext/Bind.c | 8 +-
clownfish/runtime/ruby/ext/Bind.h | 4 +-
clownfish/runtime/ruby/ext/Clownfish.c | 2 +-
core/Lucy/Analysis/Analyzer.c | 18 +-
core/Lucy/Analysis/Analyzer.cfh | 4 +-
core/Lucy/Analysis/CaseFolder.c | 2 +-
core/Lucy/Analysis/CaseFolder.cfh | 2 +-
core/Lucy/Analysis/EasyAnalyzer.c | 16 +-
core/Lucy/Analysis/EasyAnalyzer.cfh | 8 +-
core/Lucy/Analysis/Normalizer.c | 24 +-
core/Lucy/Analysis/Normalizer.cfh | 4 +-
core/Lucy/Analysis/PolyAnalyzer.c | 10 +-
core/Lucy/Analysis/PolyAnalyzer.cfh | 6 +-
core/Lucy/Analysis/RegexTokenizer.c | 16 +-
core/Lucy/Analysis/RegexTokenizer.cfh | 8 +-
core/Lucy/Analysis/SnowballStemmer.c | 18 +-
core/Lucy/Analysis/SnowballStemmer.cfh | 6 +-
core/Lucy/Analysis/SnowballStopFilter.c | 40 +-
core/Lucy/Analysis/SnowballStopFilter.cfh | 6 +-
core/Lucy/Analysis/StandardTokenizer.c | 6 +-
core/Lucy/Analysis/StandardTokenizer.cfh | 2 +-
core/Lucy/Document/Doc.cfh | 4 +-
core/Lucy/Document/HitDoc.c | 2 +-
core/Lucy/Highlight/Highlighter.c | 178 ++--
core/Lucy/Highlight/Highlighter.cfh | 42 +-
core/Lucy/Index/BackgroundMerger.c | 38 +-
core/Lucy/Index/BackgroundMerger.cfh | 2 +-
core/Lucy/Index/BitVecDelDocs.c | 6 +-
core/Lucy/Index/BitVecDelDocs.cfh | 6 +-
core/Lucy/Index/DataWriter.c | 2 +-
core/Lucy/Index/DeletionsReader.c | 8 +-
core/Lucy/Index/DeletionsWriter.c | 20 +-
core/Lucy/Index/DeletionsWriter.cfh | 8 +-
core/Lucy/Index/DocReader.c | 6 +-
core/Lucy/Index/DocVector.c | 18 +-
core/Lucy/Index/DocVector.cfh | 6 +-
core/Lucy/Index/DocWriter.c | 12 +-
core/Lucy/Index/FilePurger.c | 32 +-
core/Lucy/Index/HighlightReader.c | 8 +-
core/Lucy/Index/HighlightWriter.c | 8 +-
core/Lucy/Index/IndexManager.c | 48 +-
core/Lucy/Index/IndexManager.cfh | 12 +-
core/Lucy/Index/IndexReader.c | 6 +-
core/Lucy/Index/IndexReader.cfh | 4 +-
core/Lucy/Index/Indexer.c | 50 +-
core/Lucy/Index/Indexer.cfh | 4 +-
core/Lucy/Index/Inverter.c | 10 +-
core/Lucy/Index/Inverter.cfh | 8 +-
core/Lucy/Index/LexIndex.c | 16 +-
core/Lucy/Index/LexIndex.cfh | 4 +-
core/Lucy/Index/Lexicon.c | 6 +-
core/Lucy/Index/Lexicon.cfh | 6 +-
core/Lucy/Index/LexiconReader.c | 20 +-
core/Lucy/Index/LexiconReader.cfh | 16 +-
core/Lucy/Index/LexiconWriter.c | 24 +-
core/Lucy/Index/LexiconWriter.cfh | 10 +-
core/Lucy/Index/PolyLexicon.c | 6 +-
core/Lucy/Index/PolyLexicon.cfh | 4 +-
core/Lucy/Index/PolyReader.c | 38 +-
core/Lucy/Index/PolyReader.cfh | 2 +-
core/Lucy/Index/Posting.cfh | 2 +-
core/Lucy/Index/Posting/MatchPosting.c | 10 +-
core/Lucy/Index/Posting/MatchPosting.cfh | 2 +-
core/Lucy/Index/Posting/RichPosting.c | 6 +-
core/Lucy/Index/Posting/RichPosting.cfh | 2 +-
core/Lucy/Index/Posting/ScorePosting.c | 6 +-
core/Lucy/Index/Posting/ScorePosting.cfh | 2 +-
core/Lucy/Index/PostingList.cfh | 2 +-
core/Lucy/Index/PostingListReader.c | 2 +-
core/Lucy/Index/PostingListReader.cfh | 4 +-
core/Lucy/Index/PostingListWriter.c | 18 +-
core/Lucy/Index/PostingPool.c | 42 +-
core/Lucy/Index/PostingPool.cfh | 6 +-
core/Lucy/Index/RawLexicon.c | 4 +-
core/Lucy/Index/RawLexicon.cfh | 4 +-
core/Lucy/Index/RawPostingList.c | 6 +-
core/Lucy/Index/RawPostingList.cfh | 6 +-
core/Lucy/Index/SegLexicon.c | 8 +-
core/Lucy/Index/SegLexicon.cfh | 4 +-
core/Lucy/Index/SegPostingList.c | 14 +-
core/Lucy/Index/SegPostingList.cfh | 8 +-
core/Lucy/Index/SegReader.c | 6 +-
core/Lucy/Index/SegReader.cfh | 6 +-
core/Lucy/Index/SegWriter.c | 14 +-
core/Lucy/Index/SegWriter.cfh | 4 +-
core/Lucy/Index/Segment.c | 40 +-
core/Lucy/Index/Segment.cfh | 20 +-
core/Lucy/Index/Similarity.c | 10 +-
core/Lucy/Index/SkipStepper.c | 4 +-
core/Lucy/Index/SkipStepper.cfh | 2 +-
core/Lucy/Index/Snapshot.c | 34 +-
core/Lucy/Index/Snapshot.cfh | 14 +-
core/Lucy/Index/SortCache.c | 4 +-
core/Lucy/Index/SortCache.cfh | 4 +-
core/Lucy/Index/SortCache/NumericSortCache.c | 18 +-
core/Lucy/Index/SortCache/NumericSortCache.cfh | 18 +-
core/Lucy/Index/SortCache/TextSortCache.c | 18 +-
core/Lucy/Index/SortCache/TextSortCache.cfh | 6 +-
core/Lucy/Index/SortFieldWriter.c | 38 +-
core/Lucy/Index/SortFieldWriter.cfh | 6 +-
core/Lucy/Index/SortReader.c | 12 +-
core/Lucy/Index/SortReader.cfh | 4 +-
core/Lucy/Index/SortWriter.c | 28 +-
core/Lucy/Index/TermInfo.c | 4 +-
core/Lucy/Index/TermInfo.cfh | 2 +-
core/Lucy/Index/TermVector.c | 16 +-
core/Lucy/Index/TermVector.cfh | 8 +-
core/Lucy/Index/ZombieKeyedHash.c | 4 +-
core/Lucy/Plan/BlobType.c | 10 +-
core/Lucy/Plan/FullTextType.c | 10 +-
core/Lucy/Plan/NumericType.c | 36 +-
core/Lucy/Plan/NumericType.cfh | 10 +-
core/Lucy/Plan/Schema.c | 64 +-
core/Lucy/Plan/Schema.cfh | 10 +-
core/Lucy/Plan/StringType.c | 10 +-
core/Lucy/Plan/TextType.c | 44 +-
core/Lucy/Plan/TextType.cfh | 4 +-
core/Lucy/Search/ANDQuery.c | 14 +-
core/Lucy/Search/ANDQuery.cfh | 2 +-
core/Lucy/Search/Collector/SortCollector.c | 4 +-
core/Lucy/Search/Compiler.c | 12 +-
core/Lucy/Search/Compiler.cfh | 4 +-
core/Lucy/Search/HitQueue.c | 2 +-
core/Lucy/Search/IndexSearcher.c | 2 +-
core/Lucy/Search/IndexSearcher.cfh | 2 +-
core/Lucy/Search/LeafQuery.c | 26 +-
core/Lucy/Search/LeafQuery.cfh | 14 +-
core/Lucy/Search/MatchAllQuery.c | 4 +-
core/Lucy/Search/MatchAllQuery.cfh | 2 +-
core/Lucy/Search/NOTQuery.c | 8 +-
core/Lucy/Search/NOTQuery.cfh | 4 +-
core/Lucy/Search/NoMatchQuery.c | 4 +-
core/Lucy/Search/NoMatchQuery.cfh | 2 +-
core/Lucy/Search/ORQuery.c | 14 +-
core/Lucy/Search/ORQuery.cfh | 2 +-
core/Lucy/Search/PhraseQuery.c | 38 +-
core/Lucy/Search/PhraseQuery.cfh | 12 +-
core/Lucy/Search/PolyQuery.c | 4 +-
core/Lucy/Search/PolyQuery.cfh | 2 +-
core/Lucy/Search/PolySearcher.c | 2 +-
core/Lucy/Search/PolySearcher.cfh | 2 +-
core/Lucy/Search/Query.c | 8 +-
core/Lucy/Search/QueryParser.c | 80 +-
core/Lucy/Search/QueryParser.cfh | 16 +-
core/Lucy/Search/QueryParser/QueryLexer.c | 20 +-
core/Lucy/Search/QueryParser/QueryLexer.cfh | 2 +-
core/Lucy/Search/RangeQuery.c | 26 +-
core/Lucy/Search/RangeQuery.cfh | 8 +-
core/Lucy/Search/RequiredOptionalQuery.c | 8 +-
core/Lucy/Search/RequiredOptionalQuery.cfh | 2 +-
core/Lucy/Search/Searcher.c | 4 +-
core/Lucy/Search/Searcher.cfh | 2 +-
core/Lucy/Search/SortRule.c | 8 +-
core/Lucy/Search/SortRule.cfh | 8 +-
core/Lucy/Search/TermQuery.c | 24 +-
core/Lucy/Search/TermQuery.cfh | 12 +-
core/Lucy/Store/CompoundFileReader.c | 58 +-
core/Lucy/Store/CompoundFileReader.cfh | 16 +-
core/Lucy/Store/CompoundFileWriter.c | 32 +-
core/Lucy/Store/DirHandle.c | 12 +-
core/Lucy/Store/DirHandle.cfh | 10 +-
core/Lucy/Store/FSDirHandle.c | 36 +-
core/Lucy/Store/FSDirHandle.cfh | 4 +-
core/Lucy/Store/FSFileHandle.c | 76 +-
core/Lucy/Store/FSFileHandle.cfh | 4 +-
core/Lucy/Store/FSFolder.c | 144 +--
core/Lucy/Store/FSFolder.cfh | 20 +-
core/Lucy/Store/FileHandle.c | 10 +-
core/Lucy/Store/FileHandle.cfh | 8 +-
core/Lucy/Store/Folder.c | 132 +--
core/Lucy/Store/Folder.cfh | 56 +-
core/Lucy/Store/InStream.c | 16 +-
core/Lucy/Store/InStream.cfh | 6 +-
core/Lucy/Store/Lock.c | 64 +-
core/Lucy/Store/Lock.cfh | 30 +-
core/Lucy/Store/LockFactory.c | 10 +-
core/Lucy/Store/LockFactory.cfh | 10 +-
core/Lucy/Store/OutStream.c | 10 +-
core/Lucy/Store/OutStream.cfh | 4 +-
core/Lucy/Store/RAMDirHandle.c | 8 +-
core/Lucy/Store/RAMFileHandle.c | 26 +-
core/Lucy/Store/RAMFileHandle.cfh | 4 +-
core/Lucy/Store/RAMFolder.c | 72 +-
core/Lucy/Store/RAMFolder.cfh | 20 +-
core/Lucy/Store/SharedLock.c | 36 +-
core/Lucy/Store/SharedLock.cfh | 6 +-
core/Lucy/Test/Analysis/TestAnalyzer.c | 4 +-
core/Lucy/Test/Analysis/TestCaseFolder.c | 4 +-
core/Lucy/Test/Analysis/TestNormalizer.c | 30 +-
core/Lucy/Test/Analysis/TestPolyAnalyzer.c | 30 +-
core/Lucy/Test/Analysis/TestRegexTokenizer.c | 4 +-
core/Lucy/Test/Analysis/TestSnowballStemmer.c | 18 +-
.../Lucy/Test/Analysis/TestSnowballStopFilter.c | 2 +-
core/Lucy/Test/Analysis/TestStandardTokenizer.c | 46 +-
core/Lucy/Test/Highlight/TestHighlighter.c | 142 +--
core/Lucy/Test/Index/TestSegment.c | 40 +-
core/Lucy/Test/Index/TestSnapshot.c | 20 +-
core/Lucy/Test/Plan/TestFieldMisc.c | 62 +-
core/Lucy/Test/Plan/TestFieldType.c | 2 +-
core/Lucy/Test/Search/TestQueryParser.c | 2 +-
core/Lucy/Test/Search/TestQueryParser.cfh | 4 +-
core/Lucy/Test/Search/TestQueryParserLogic.c | 20 +-
core/Lucy/Test/Search/TestQueryParserSyntax.c | 20 +-
core/Lucy/Test/Search/TestSortSpec.c | 158 ++--
core/Lucy/Test/Store/MockFileHandle.c | 4 +-
core/Lucy/Test/Store/MockFileHandle.cfh | 4 +-
core/Lucy/Test/Store/TestCompoundFileReader.c | 48 +-
core/Lucy/Test/Store/TestCompoundFileWriter.c | 28 +-
core/Lucy/Test/Store/TestFSDirHandle.c | 14 +-
core/Lucy/Test/Store/TestFSFileHandle.c | 26 +-
core/Lucy/Test/Store/TestFSFolder.c | 22 +-
core/Lucy/Test/Store/TestFileHandle.c | 10 +-
core/Lucy/Test/Store/TestFolder.c | 80 +-
core/Lucy/Test/Store/TestFolderCommon.c | 52 +-
core/Lucy/Test/Store/TestInStream.c | 10 +-
core/Lucy/Test/Store/TestRAMDirHandle.c | 12 +-
core/Lucy/Test/Store/TestRAMFileHandle.c | 2 +-
core/Lucy/Test/Store/TestRAMFolder.c | 52 +-
core/Lucy/Test/TestSchema.c | 4 +-
core/Lucy/Test/TestUtils.c | 34 +-
core/Lucy/Test/TestUtils.cfh | 4 +-
core/Lucy/Test/Util/TestFreezer.c | 12 +-
core/Lucy/Test/Util/TestIndexFileNames.c | 20 +-
core/Lucy/Test/Util/TestJson.c | 66 +-
core/Lucy/Util/Freezer.c | 54 +-
core/Lucy/Util/Freezer.cfh | 8 +-
core/Lucy/Util/IndexFileNames.c | 18 +-
core/Lucy/Util/IndexFileNames.cfh | 8 +-
core/Lucy/Util/Json.c | 136 +--
core/Lucy/Util/Json.cfh | 12 +-
core/Lucy/Util/Json/JsonParser.y | 4 +-
core/Lucy/Util/ToolSet.h | 2 +-
core/LucyX/Search/ProximityQuery.c | 42 +-
core/LucyX/Search/ProximityQuery.cfh | 12 +-
example-lang/README | 2 +-
example-lang/src/CFBind.h | 2 +-
perl/buildlib/Lucy/Build/Binding/Index.pm | 4 +-
perl/buildlib/Lucy/Build/Binding/Misc.pm | 4 +-
perl/buildlib/Lucy/Build/Binding/Search.pm | 4 +-
perl/buildlib/Lucy/Build/Binding/Util.pm | 4 +-
perl/t/021-vtable.t | 2 +-
perl/t/109-read_locking.t | 2 +-
perl/t/505-hit_queue.t | 2 +-
perl/t/520-match_doc.t | 4 +-
perl/t/binding/016-varray.t | 2 +-
perl/t/binding/017-hash.t | 4 +-
perl/t/binding/029-charbuf.t | 8 +-
perl/t/binding/038-lock_free_registry.t | 2 +-
perl/xs/Lucy/Analysis/RegexTokenizer.c | 16 +-
perl/xs/Lucy/Document/Doc.c | 24 +-
perl/xs/Lucy/Index/DocReader.c | 2 +-
perl/xs/Lucy/Index/Inverter.c | 8 +-
ruby/src/CFBind.h | 2 +-
316 files changed, 4005 insertions(+), 4005 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/lucy/blob/2c3dbf15/c/sample/getting_started.c
----------------------------------------------------------------------
diff --git a/c/sample/getting_started.c b/c/sample/getting_started.c
index efdf050..2897258 100644
--- a/c/sample/getting_started.c
+++ b/c/sample/getting_started.c
@@ -31,7 +31,7 @@
#include <string.h>
#define LUCY_USE_SHORT_NAMES
-#include "Clownfish/CharBuf.h"
+#include "Clownfish/String.h"
#include "Lucy/Analysis/EasyAnalyzer.h"
#include "Lucy/Document/Doc.h"
#include "Lucy/Document/HitDoc.h"
@@ -45,7 +45,7 @@ static Schema*
S_create_schema();
static void
-S_index_documents(Schema *schema, CharBuf *folder);
+S_index_documents(Schema *schema, String *folder);
static void
S_add_document(Indexer *indexer, const char *title, const char *content);
@@ -59,7 +59,7 @@ main() {
lucy_bootstrap_parcel();
Schema *schema = S_create_schema();
- CharBuf *folder = CB_newf("lucy_index");
+ String *folder = Str_newf("lucy_index");
S_index_documents(schema, folder);
@@ -81,7 +81,7 @@ S_create_schema() {
Schema *schema = Schema_new();
// Create an analyzer.
- CharBuf *language = CB_newf("en");
+ String *language = Str_newf("en");
EasyAnalyzer *analyzer = EasyAnalyzer_new(language);
// Specify fields.
@@ -89,13 +89,13 @@ S_create_schema() {
FullTextType *type = FullTextType_new((Analyzer*)analyzer);
{
- CharBuf *field_cb = CB_newf("title");
+ String *field_cb = Str_newf("title");
Schema_Spec_Field(schema, field_cb, (FieldType*)type);
DECREF(field_cb);
}
{
- CharBuf *field_cb = CB_newf("content");
+ String *field_cb = Str_newf("content");
Schema_Spec_Field(schema, field_cb, (FieldType*)type);
DECREF(field_cb);
}
@@ -107,7 +107,7 @@ S_create_schema() {
}
static void
-S_index_documents(Schema *schema, CharBuf *folder) {
+S_index_documents(Schema *schema, String *folder) {
Indexer *indexer = Indexer_new(schema, (Obj*)folder, NULL,
Indexer_CREATE | Indexer_TRUNCATE);
@@ -139,8 +139,8 @@ S_add_document(Indexer *indexer, const char *title, const char *content) {
{
// Store 'title' field
- CharBuf *field_cb = CB_newf("title");
- CharBuf *value_cb = CB_new_from_utf8(title, strlen(title));
+ String *field_cb = Str_newf("title");
+ String *value_cb = Str_new_from_utf8(title, strlen(title));
Doc_Store(doc, field_cb, (Obj*)value_cb);
DECREF(field_cb);
DECREF(value_cb);
@@ -148,8 +148,8 @@ S_add_document(Indexer *indexer, const char *title, const char *content) {
{
// Store 'content' field
- CharBuf *field_cb = CB_newf("content");
- CharBuf *value_cb = CB_new_from_utf8(content, strlen(content));
+ String *field_cb = Str_newf("content");
+ String *value_cb = Str_new_from_utf8(content, strlen(content));
Doc_Store(doc, field_cb, (Obj*)value_cb);
DECREF(field_cb);
DECREF(value_cb);
@@ -165,18 +165,18 @@ S_search(IndexSearcher *searcher, const char *query) {
printf("Searching for: %s\n", query);
// Execute search query.
- CharBuf *query_cb = CB_new_from_utf8(query, strlen(query));
+ String *query_cb = Str_new_from_utf8(query, strlen(query));
Hits *hits = IxSearcher_Hits(searcher, (Obj*)query_cb, 0, 10, NULL);
- CharBuf *field_cb = CB_newf("title");
+ String *field_cb = Str_newf("title");
HitDoc *hit;
int i = 1;
// Loop over search results.
while (NULL != (hit = Hits_Next(hits))) {
- CharBuf *value_cb = (CharBuf*)HitDoc_Extract(hit, field_cb, NULL);
+ String *value_cb = (String*)HitDoc_Extract(hit, field_cb, NULL);
- printf("Result %d: %s\n", i, CB_Get_Ptr8(value_cb));
+ printf("Result %d: %s\n", i, Str_Get_Ptr8(value_cb));
DECREF(hit);
i++;
http://git-wip-us.apache.org/repos/asf/lucy/blob/2c3dbf15/c/src/Lucy/Analysis/RegexTokenizer.c
----------------------------------------------------------------------
diff --git a/c/src/Lucy/Analysis/RegexTokenizer.c b/c/src/Lucy/Analysis/RegexTokenizer.c
index b52d445..4780430 100644
--- a/c/src/Lucy/Analysis/RegexTokenizer.c
+++ b/c/src/Lucy/Analysis/RegexTokenizer.c
@@ -24,7 +24,7 @@
#include <string.h>
#include "Lucy/Analysis/RegexTokenizer.h"
-#include "Clownfish/CharBuf.h"
+#include "Clownfish/String.h"
#include "Clownfish/Err.h"
#include "Clownfish/Util/Memory.h"
#include "Clownfish/Util/StringHelper.h"
@@ -44,19 +44,19 @@ RegexTokenizer_is_available(void) {
}
RegexTokenizer*
-RegexTokenizer_init(RegexTokenizer *self, const CharBuf *pattern) {
+RegexTokenizer_init(RegexTokenizer *self, const String *pattern) {
Analyzer_init((Analyzer*)self);
RegexTokenizerIVARS *const ivars = RegexTokenizer_IVARS(self);
const char *pattern_ptr;
if (pattern) {
- ivars->pattern = CB_Clone(pattern);
- pattern_ptr = (char*)CB_Get_Ptr8(ivars->pattern);
+ ivars->pattern = Str_Clone(pattern);
+ pattern_ptr = (char*)Str_Get_Ptr8(ivars->pattern);
}
else {
pattern_ptr = "\\w+(?:['\\x{2019}]\\w+)*";
ivars->pattern
- = CB_new_from_trusted_utf8(pattern_ptr, strlen(pattern_ptr));
+ = Str_new_from_trusted_utf8(pattern_ptr, strlen(pattern_ptr));
}
int options = PCRE_UTF8 | PCRE_NO_UTF8_CHECK;
@@ -162,7 +162,7 @@ RegexTokenizer_is_available(void) {
}
RegexTokenizer*
-RegexTokenizer_init(RegexTokenizer *self, const CharBuf *pattern) {
+RegexTokenizer_init(RegexTokenizer *self, const String *pattern) {
UNUSED_VAR(self);
UNUSED_VAR(pattern);
THROW(ERR,
http://git-wip-us.apache.org/repos/asf/lucy/blob/2c3dbf15/c/src/Lucy/Document/Doc.c
----------------------------------------------------------------------
diff --git a/c/src/Lucy/Document/Doc.c b/c/src/Lucy/Document/Doc.c
index e3deedb..8a682b7 100644
--- a/c/src/Lucy/Document/Doc.c
+++ b/c/src/Lucy/Document/Doc.c
@@ -22,7 +22,7 @@
#include "charmony.h"
#include "Lucy/Document/Doc.h"
-#include "Clownfish/CharBuf.h"
+#include "Clownfish/String.h"
#include "Clownfish/Err.h"
#include "Clownfish/Hash.h"
#include "Clownfish/VTable.h"
@@ -62,7 +62,7 @@ Doc_Get_Size_IMP(Doc *self) {
}
void
-Doc_Store_IMP(Doc *self, const CharBuf *field, Obj *value) {
+Doc_Store_IMP(Doc *self, const String *field, Obj *value) {
Hash *hash = (Hash*)Doc_IVARS(self)->fields;
Hash_Store(hash, (Obj *)field, value);
INCREF(value);
@@ -85,12 +85,12 @@ Doc_Deserialize_IMP(Doc *self, InStream *instream) {
}
Obj*
-Doc_Extract_IMP(Doc *self, CharBuf *field, ViewCharBuf *target) {
+Doc_Extract_IMP(Doc *self, String *field, ViewCharBuf *target) {
Hash *hash = (Hash*)Doc_IVARS(self)->fields;
Obj *obj = Hash_Fetch(hash, (Obj *)field);
- if (target && obj && Obj_Is_A(obj, CHARBUF)) {
- ViewCB_Assign(target, (CharBuf *)obj);
+ if (target && obj && Obj_Is_A(obj, STRING)) {
+ ViewCB_Assign(target, (String *)obj);
}
return obj;
http://git-wip-us.apache.org/repos/asf/lucy/blob/2c3dbf15/c/src/Lucy/Index/DocReader.c
----------------------------------------------------------------------
diff --git a/c/src/Lucy/Index/DocReader.c b/c/src/Lucy/Index/DocReader.c
index f2c8b98..5a62738 100644
--- a/c/src/Lucy/Index/DocReader.c
+++ b/c/src/Lucy/Index/DocReader.c
@@ -22,7 +22,7 @@
#include "Lucy/Index/DocReader.h"
#include "Clownfish/ByteBuf.h"
-#include "Clownfish/CharBuf.h"
+#include "Clownfish/String.h"
#include "Clownfish/Err.h"
#include "Clownfish/Hash.h"
#include "Clownfish/Num.h"
@@ -68,7 +68,7 @@ DefDocReader_Fetch_Doc_IMP(DefaultDocReader *self, int32_t doc_id) {
// Find the Field's FieldType.
StackString *field_name_zcb
= SSTR_WRAP_STR(field_name, field_name_len);
- type = Schema_Fetch_Type(schema, (CharBuf*)field_name_zcb);
+ type = Schema_Fetch_Type(schema, (String*)field_name_zcb);
// Read the field value.
switch (FType_Primitive_ID(type) & FType_PRIMITIVE_ID_MASK) {
@@ -77,7 +77,7 @@ DefDocReader_Fetch_Doc_IMP(DefaultDocReader *self, int32_t doc_id) {
char *buf = (char*)MALLOCATE(value_len + 1);
InStream_Read_Bytes(dat_in, buf, value_len);
buf[value_len] = '\0';
- value = (Obj*)CB_new_steal_from_trusted_str(
+ value = (Obj*)Str_new_steal_from_trusted_str(
buf, value_len, value_len + 1);
break;
}
http://git-wip-us.apache.org/repos/asf/lucy/blob/2c3dbf15/c/src/Lucy/Index/Inverter.c
----------------------------------------------------------------------
diff --git a/c/src/Lucy/Index/Inverter.c b/c/src/Lucy/Index/Inverter.c
index ab920c4..99b5579 100644
--- a/c/src/Lucy/Index/Inverter.c
+++ b/c/src/Lucy/Index/Inverter.c
@@ -22,7 +22,7 @@
#include "Lucy/Index/Inverter.h"
#include "Clownfish/ByteBuf.h"
-#include "Clownfish/CharBuf.h"
+#include "Clownfish/String.h"
#include "Clownfish/Err.h"
#include "Clownfish/Hash.h"
#include "Clownfish/Num.h"
@@ -33,7 +33,7 @@
#include "Lucy/Plan/Schema.h"
static InverterEntry*
-S_fetch_entry(InverterIVARS *ivars, CharBuf *field) {
+S_fetch_entry(InverterIVARS *ivars, String *field) {
Schema *const schema = ivars->schema;
int32_t field_num = Seg_Field_Num(ivars->segment, field);
if (!field_num) {
@@ -53,7 +53,7 @@ S_fetch_entry(InverterIVARS *ivars, CharBuf *field) {
InverterEntry *entry
= (InverterEntry*)VA_Fetch(ivars->entry_pool, field_num);
if (!entry) {
- entry = InvEntry_new(schema, (CharBuf*)field, field_num);
+ entry = InvEntry_new(schema, (String*)field, field_num);
VA_Store(ivars->entry_pool, field_num, (Obj*)entry);
}
return entry;
@@ -72,7 +72,7 @@ Inverter_Invert_Doc_IMP(Inverter *self, Doc *doc) {
while (num_keys--) {
Obj *key, *obj;
Hash_Next(fields, &key, &obj);
- CharBuf *field = (CharBuf*)CERTIFY(key, CHARBUF);
+ String *field = (String*)CERTIFY(key, STRING);
InverterEntry *inventry = S_fetch_entry(ivars, field);
InverterEntryIVARS *inventry_ivars = InvEntry_IVARS(inventry);
FieldType *type = inventry_ivars->type;
@@ -80,8 +80,8 @@ Inverter_Invert_Doc_IMP(Inverter *self, Doc *doc) {
// Get the field value.
switch (FType_Primitive_ID(type) & FType_PRIMITIVE_ID_MASK) {
case FType_TEXT: {
- CharBuf *char_buf
- = (CharBuf*)CERTIFY(obj, CHARBUF);
+ String *char_buf
+ = (String*)CERTIFY(obj, STRING);
ViewCharBuf *value
= (ViewCharBuf*)inventry_ivars->value;
ViewCB_Assign(value, char_buf);
http://git-wip-us.apache.org/repos/asf/lucy/blob/2c3dbf15/clownfish/compiler/perl/t/105-object_type.t
----------------------------------------------------------------------
diff --git a/clownfish/compiler/perl/t/105-object_type.t b/clownfish/compiler/perl/t/105-object_type.t
index d20d01f..6bf4c65 100644
--- a/clownfish/compiler/perl/t/105-object_type.t
+++ b/clownfish/compiler/perl/t/105-object_type.t
@@ -126,7 +126,7 @@ ok( !$foo_type->equals($const_foo), "different const spoils equals" );
like( $const_foo->to_c, qr/const/, "const included in C representation" );
my $string_type
- = Clownfish::CFC::Model::Type->new_object( specifier => 'CharBuf', );
+ = Clownfish::CFC::Model::Type->new_object( specifier => 'String', );
ok( !$foo_type->is_string_type, "Not is_string_type" );
ok( $string_type->is_string_type, "is_string_type" );
http://git-wip-us.apache.org/repos/asf/lucy/blob/2c3dbf15/clownfish/compiler/perl/t/301-param_list.t
----------------------------------------------------------------------
diff --git a/clownfish/compiler/perl/t/301-param_list.t b/clownfish/compiler/perl/t/301-param_list.t
index fb6505b..b315e9a 100644
--- a/clownfish/compiler/perl/t/301-param_list.t
+++ b/clownfish/compiler/perl/t/301-param_list.t
@@ -28,7 +28,7 @@ isa_ok(
$parser->parse($_),
"Clownfish::CFC::Model::Variable",
"param_variable: $_"
-) for ( 'uint32_t baz', 'CharBuf *stuff', 'float **ptr', );
+) for ( 'uint32_t baz', 'String *stuff', 'float **ptr', );
my $obj_class = $parser->parse("class Obj {}");
http://git-wip-us.apache.org/repos/asf/lucy/blob/2c3dbf15/clownfish/compiler/perl/t/401-class.t
----------------------------------------------------------------------
diff --git a/clownfish/compiler/perl/t/401-class.t b/clownfish/compiler/perl/t/401-class.t
index f6eac88..76b5ae3 100644
--- a/clownfish/compiler/perl/t/401-class.t
+++ b/clownfish/compiler/perl/t/401-class.t
@@ -180,18 +180,18 @@ $class_content = q|
* Wow wow wow.
*/
public class Animal::Dog inherits Animal {
- public inert Dog* init(Dog *self, CharBuf *name, CharBuf *fave_food);
+ public inert Dog* init(Dog *self, String *name, String *fave_food);
inert uint32_t count();
inert uint64_t num_dogs;
public inert Dog* top_dog;
- CharBuf *name;
+ String *name;
bool likes_to_go_fetch;
ChewToy *squishy;
Owner *mom;
void Destroy(Dog *self);
- public CharBuf* Bark(Dog *self);
+ public String* Bark(Dog *self);
public void Eat(Dog *self);
public void Bite(Dog *self, Enemy *enemy);
public Thing *Fetch(Dog *self, Thing *thing);
http://git-wip-us.apache.org/repos/asf/lucy/blob/2c3dbf15/clownfish/compiler/perl/t/600-parser.t
----------------------------------------------------------------------
diff --git a/clownfish/compiler/perl/t/600-parser.t b/clownfish/compiler/perl/t/600-parser.t
index 6d9f297..94dbed3 100644
--- a/clownfish/compiler/perl/t/600-parser.t
+++ b/clownfish/compiler/perl/t/600-parser.t
@@ -84,7 +84,7 @@ is( $parser->parse("(double foo = $_)")->get_initial_values->[0],
$_, "float_constant: $_" )
for (qw( 1.0 -9999.999 0.1 0.0 ));
-is( $parser->parse("(CharBuf *foo = $_)")->get_initial_values->[0],
+is( $parser->parse("(String *foo = $_)")->get_initial_values->[0],
$_, "string_literal: $_" )
for ( q|"blah"|, q|"blah blah"|, q|"\\"blah\\" \\"blah\\""| );
@@ -94,7 +94,7 @@ for my $composite (@composites) {
ok( $parsed && $parsed->is_composite, "composite_type: $composite" );
}
-my @object_types = ( 'Obj *', "incremented Foo*", "decremented CharBuf *" );
+my @object_types = ( 'Obj *', "incremented Foo*", "decremented String *" );
for my $object_type (@object_types) {
my $parsed = $parser->parse($object_type);
ok( $parsed && $parsed->is_object, "object_type: $object_type" );
http://git-wip-us.apache.org/repos/asf/lucy/blob/2c3dbf15/clownfish/compiler/src/CFCBindCore.c
----------------------------------------------------------------------
diff --git a/clownfish/compiler/src/CFCBindCore.c b/clownfish/compiler/src/CFCBindCore.c
index c797600..50661a2 100644
--- a/clownfish/compiler/src/CFCBindCore.c
+++ b/clownfish/compiler/src/CFCBindCore.c
@@ -428,7 +428,7 @@ S_write_parcel_c(CFCBindCore *self, CFCParcel *parcel) {
"%s\n"
"#include \"%sparcel.h\"\n"
"#include \"callbacks.h\"\n"
- "#include \"Clownfish/CharBuf.h\"\n" // Needed for dump/load.
+ "#include \"Clownfish/String.h\"\n" // Needed for dump/load.
"#include \"Clownfish/Err.h\"\n" // Needed for dump/load.
"#include \"Clownfish/Num.h\"\n" // Needed for dump/load.
"#include \"Clownfish/VArray.h\"\n" // Needed for dump/load.
http://git-wip-us.apache.org/repos/asf/lucy/blob/2c3dbf15/clownfish/compiler/src/CFCBindMethod.c
----------------------------------------------------------------------
diff --git a/clownfish/compiler/src/CFCBindMethod.c b/clownfish/compiler/src/CFCBindMethod.c
index 5ad25b8..c60cc98 100644
--- a/clownfish/compiler/src/CFCBindMethod.c
+++ b/clownfish/compiler/src/CFCBindMethod.c
@@ -264,7 +264,7 @@ CFCBindMeth_abstract_method_def(CFCMethod *method) {
char pattern[] =
"%s\n"
"%s(%s) {\n"
- " cfish_CharBuf *klass = self ? CFISH_Obj_Get_Class_Name((cfish_Obj*)self) : %s->name;%s\n"
+ " cfish_String *klass = self ? CFISH_Obj_Get_Class_Name((cfish_Obj*)self) : %s->name;%s\n"
" CFISH_THROW(CFISH_ERR, \"Abstract method '%s' not defined by %%o\", klass);%s\n"
"}\n";
char *abstract_def
http://git-wip-us.apache.org/repos/asf/lucy/blob/2c3dbf15/clownfish/compiler/src/CFCPerl.c
----------------------------------------------------------------------
diff --git a/clownfish/compiler/src/CFCPerl.c b/clownfish/compiler/src/CFCPerl.c
index 9868a50..698d71a 100644
--- a/clownfish/compiler/src/CFCPerl.c
+++ b/clownfish/compiler/src/CFCPerl.c
@@ -253,7 +253,7 @@ S_write_boot_c(CFCPerl *self) {
"%s"
" CFISH_SStr_Assign_Str(alias, \"%s\", %u);\n"
" cfish_VTable_add_alias_to_registry(%s,\n"
- " (cfish_CharBuf*)alias);\n";
+ " (cfish_String*)alias);\n";
char *new_alias_adds
= CFCUtil_sprintf(pattern, alias_adds, alias,
(unsigned)alias_len, vtable_var);
@@ -287,7 +287,7 @@ S_write_boot_c(CFCPerl *self) {
"#include \"perl.h\"\n"
"#include \"XSUB.h\"\n"
"#include \"boot.h\"\n"
- "#include \"Clownfish/CharBuf.h\"\n"
+ "#include \"Clownfish/String.h\"\n"
"#include \"Clownfish/VTable.h\"\n"
"%s\n"
"\n"
http://git-wip-us.apache.org/repos/asf/lucy/blob/2c3dbf15/clownfish/compiler/src/CFCPerlMethod.c
----------------------------------------------------------------------
diff --git a/clownfish/compiler/src/CFCPerlMethod.c b/clownfish/compiler/src/CFCPerlMethod.c
index 7e378ca..84fc04a 100644
--- a/clownfish/compiler/src/CFCPerlMethod.c
+++ b/clownfish/compiler/src/CFCPerlMethod.c
@@ -474,7 +474,7 @@ S_callback_start(CFCMethod *method) {
if (CFCType_is_string_type(type)) {
// Convert Clownfish string type to UTF-8 Perl string scalars.
params = CFCUtil_cat(params, " mPUSHs(XSBind_cb_to_sv(",
- "(cfish_CharBuf*)", name, "));\n", NULL);
+ "(cfish_String*)", name, "));\n", NULL);
}
else if (CFCType_is_object(type)) {
// Wrap other Clownfish object types in Perl objects.
http://git-wip-us.apache.org/repos/asf/lucy/blob/2c3dbf15/clownfish/compiler/src/CFCPerlSub.c
----------------------------------------------------------------------
diff --git a/clownfish/compiler/src/CFCPerlSub.c b/clownfish/compiler/src/CFCPerlSub.c
index 4cb9878..c71e990 100644
--- a/clownfish/compiler/src/CFCPerlSub.c
+++ b/clownfish/compiler/src/CFCPerlSub.c
@@ -147,7 +147,7 @@ S_allot_params_arg(CFCType *type, const char *label, int required) {
// Share buffers rather than copy between Perl scalars and Clownfish
// string types.
int use_sv_buffer = false;
- if (strcmp(struct_sym, "cfish_CharBuf") == 0
+ if (strcmp(struct_sym, "cfish_String") == 0
|| strcmp(struct_sym, "cfish_Obj") == 0
) {
use_sv_buffer = true;
http://git-wip-us.apache.org/repos/asf/lucy/blob/2c3dbf15/clownfish/compiler/src/CFCPerlTypeMap.c
----------------------------------------------------------------------
diff --git a/clownfish/compiler/src/CFCPerlTypeMap.c b/clownfish/compiler/src/CFCPerlTypeMap.c
index 9613b4d..a50e013 100644
--- a/clownfish/compiler/src/CFCPerlTypeMap.c
+++ b/clownfish/compiler/src/CFCPerlTypeMap.c
@@ -42,7 +42,7 @@ CFCPerlTypeMap_from_perl(CFCType *type, const char *xs_var) {
const char *struct_sym = CFCType_get_specifier(type);
const char *vtable_var = CFCType_get_vtable_var(type);
const char *allocation;
- if (strcmp(struct_sym, "cfish_CharBuf") == 0
+ if (strcmp(struct_sym, "cfish_String") == 0
|| strcmp(struct_sym, "cfish_Obj") == 0
) {
// Share buffers rather than copy between Perl scalars and
@@ -212,7 +212,7 @@ static const char typemap_start[] =
"uint32_t\tCFISH_UNSIGNED_INT\n"
"uint64_t\tCFISH_BIG_UNSIGNED_INT\n"
"\n"
- "const cfish_CharBuf*\tCONST_CHARBUF\n";
+ "const cfish_String*\tCONST_CHARBUF\n";
static const char typemap_input[] =
@@ -234,7 +234,7 @@ static const char typemap_input[] =
" $var = (sizeof(UV) == 8) ? ($type)SvUV($arg) : ($type)SvNV($arg);\n"
"\n"
"CONST_CHARBUF\n"
- " $var = (const cfish_CharBuf*)CFISH_SStr_WRAP_STR(SvPVutf8_nolen($arg), SvCUR($arg));\n"
+ " $var = (const cfish_String*)CFISH_SStr_WRAP_STR(SvPVutf8_nolen($arg), SvCUR($arg));\n"
"\n";
static const char typemap_output[] =
http://git-wip-us.apache.org/repos/asf/lucy/blob/2c3dbf15/clownfish/compiler/src/CFCRuby.c
----------------------------------------------------------------------
diff --git a/clownfish/compiler/src/CFCRuby.c b/clownfish/compiler/src/CFCRuby.c
index 19055b2..4b67022 100644
--- a/clownfish/compiler/src/CFCRuby.c
+++ b/clownfish/compiler/src/CFCRuby.c
@@ -197,7 +197,7 @@ S_write_boot_c(CFCRuby *self) {
"#include \"charmony.h\"\n"
"#include \"%s\"\n"
"#include \"%sparcel.h\"\n"
- "#include \"Clownfish/CharBuf.h\"\n"
+ "#include \"Clownfish/String.h\"\n"
"#include \"Clownfish/VTable.h\"\n"
"%s\n"
"\n"
http://git-wip-us.apache.org/repos/asf/lucy/blob/2c3dbf15/clownfish/compiler/src/CFCTestClass.c
----------------------------------------------------------------------
diff --git a/clownfish/compiler/src/CFCTestClass.c b/clownfish/compiler/src/CFCTestClass.c
index 81e09bb..01ef19b 100644
--- a/clownfish/compiler/src/CFCTestClass.c
+++ b/clownfish/compiler/src/CFCTestClass.c
@@ -254,19 +254,19 @@ S_run_tests(CFCTest *test) {
" * Wow wow wow.\n"
" */\n"
"public class Animal::Dog inherits Animal {\n"
- " public inert Dog* init(Dog *self, CharBuf *name,\n"
- " CharBuf *fave_food);\n"
+ " public inert Dog* init(Dog *self, String *name,\n"
+ " String *fave_food);\n"
" inert uint32_t count();\n"
" inert uint64_t num_dogs;\n"
" public inert Dog *top_dog;\n"
"\n"
- " CharBuf *name;\n"
+ " String *name;\n"
" bool likes_to_go_fetch;\n"
" ChewToy *squishy;\n"
" Owner *mom;\n"
"\n"
" void Destroy(Dog *self);\n"
- " public CharBuf* Bark(Dog *self);\n"
+ " public String* Bark(Dog *self);\n"
" public void Eat(Dog *self);\n"
" public void Bite(Dog *self, Enemy *enemy);\n"
" public Thing *Fetch(Dog *self, Thing *thing);\n"
http://git-wip-us.apache.org/repos/asf/lucy/blob/2c3dbf15/clownfish/compiler/src/CFCTestParser.c
----------------------------------------------------------------------
diff --git a/clownfish/compiler/src/CFCTestParser.c b/clownfish/compiler/src/CFCTestParser.c
index ca8ad2c..556a135 100644
--- a/clownfish/compiler/src/CFCTestParser.c
+++ b/clownfish/compiler/src/CFCTestParser.c
@@ -192,7 +192,7 @@ S_run_tests(CFCTest *test) {
static const char *const string_literals[] = {
"\"blah\"", "\"blah blah\"", "\"\\\"blah\\\" \\\"blah\\\"\"", NULL
};
- S_test_initial_value(test, parser, string_literals, "CharBuf*",
+ S_test_initial_value(test, parser, string_literals, "String*",
"string_literal:");
}
@@ -211,7 +211,7 @@ S_run_tests(CFCTest *test) {
{
static const char *const object_types[5] = {
- "Obj *", "incremented Foo*", "decremented CharBuf *"
+ "Obj *", "incremented Foo*", "decremented String *"
};
for (int i = 0; i < 3; ++i) {
const char *object_type = object_types[i];
http://git-wip-us.apache.org/repos/asf/lucy/blob/2c3dbf15/clownfish/compiler/src/CFCTestType.c
----------------------------------------------------------------------
diff --git a/clownfish/compiler/src/CFCTestType.c b/clownfish/compiler/src/CFCTestType.c
index af85017..f452767 100644
--- a/clownfish/compiler/src/CFCTestType.c
+++ b/clownfish/compiler/src/CFCTestType.c
@@ -383,7 +383,7 @@ S_run_object_tests(CFCTest *test) {
}
{
- CFCType *string_type = CFCType_new_object(0, NULL, "CharBuf", 1);
+ CFCType *string_type = CFCType_new_object(0, NULL, "String", 1);
OK(test, CFCType_is_string_type(string_type), "%s", "is_string_type");
OK(test, !CFCType_is_string_type(foo), "not %s", "not is_string_type");
CFCBase_decref((CFCBase*)string_type);
http://git-wip-us.apache.org/repos/asf/lucy/blob/2c3dbf15/clownfish/compiler/src/CFCTestVariable.c
----------------------------------------------------------------------
diff --git a/clownfish/compiler/src/CFCTestVariable.c b/clownfish/compiler/src/CFCTestVariable.c
index f0cbcac..e8096e7 100644
--- a/clownfish/compiler/src/CFCTestVariable.c
+++ b/clownfish/compiler/src/CFCTestVariable.c
@@ -88,7 +88,7 @@ S_run_tests(CFCTest *test) {
"public inert int32_t **foo;",
"Dog *fido;",
"uint32_t baz",
- "CharBuf *stuff",
+ "String *stuff",
"float **ptr"
};
for (int i = 0; i < 7; ++i) {
http://git-wip-us.apache.org/repos/asf/lucy/blob/2c3dbf15/clownfish/compiler/src/CFCType.c
----------------------------------------------------------------------
diff --git a/clownfish/compiler/src/CFCType.c b/clownfish/compiler/src/CFCType.c
index e63241c..a41ecbd 100644
--- a/clownfish/compiler/src/CFCType.c
+++ b/clownfish/compiler/src/CFCType.c
@@ -184,7 +184,7 @@ CFCType_new_object(int flags, CFCParcel *parcel, const char *specifier,
// Add flags.
flags |= CFCTYPE_OBJECT;
- if (strstr(specifier, "CharBuf")) {
+ if (strstr(specifier, "String")) {
// Determine whether this type is a string type.
flags |= CFCTYPE_STRING_TYPE;
}
http://git-wip-us.apache.org/repos/asf/lucy/blob/2c3dbf15/clownfish/runtime/c/src/Clownfish/Err.c
----------------------------------------------------------------------
diff --git a/clownfish/runtime/c/src/Clownfish/Err.c b/clownfish/runtime/c/src/Clownfish/Err.c
index 5240a87..cba995a 100644
--- a/clownfish/runtime/c/src/Clownfish/Err.c
+++ b/clownfish/runtime/c/src/Clownfish/Err.c
@@ -25,7 +25,7 @@
#include <stdlib.h>
#include "Clownfish/Err.h"
-#include "Clownfish/CharBuf.h"
+#include "Clownfish/String.h"
#include "Clownfish/VTable.h"
/* TODO: Thread safety */
@@ -57,8 +57,8 @@ Err_do_throw(Err *error) {
longjmp(*current_env, 1);
}
else {
- CharBuf *message = Err_Get_Mess(error);
- fprintf(stderr, "%s", CB_Get_Ptr8(message));
+ String *message = Err_Get_Mess(error);
+ fprintf(stderr, "%s", Str_Get_Ptr8(message));
exit(EXIT_FAILURE);
}
}
@@ -71,17 +71,17 @@ Err_To_Host_IMP(Err *self) {
}
void
-Err_throw_mess(VTable *vtable, CharBuf *message) {
+Err_throw_mess(VTable *vtable, String *message) {
Err *err = (Err*)VTable_Make_Obj(vtable);
- Err_init(err, CB_new(0));
+ Err_init(err, Str_new(0));
Err_Cat_Mess(err, message);
DECREF(message);
Err_do_throw(err);
}
void
-Err_warn_mess(CharBuf *message) {
- fprintf(stderr, "%s", CB_Get_Ptr8(message));
+Err_warn_mess(String *message) {
+ fprintf(stderr, "%s", Str_Get_Ptr8(message));
DECREF(message);
}
http://git-wip-us.apache.org/repos/asf/lucy/blob/2c3dbf15/clownfish/runtime/c/src/Clownfish/VTable.c
----------------------------------------------------------------------
diff --git a/clownfish/runtime/c/src/Clownfish/VTable.c b/clownfish/runtime/c/src/Clownfish/VTable.c
index 46a5834..ac822db 100644
--- a/clownfish/runtime/c/src/Clownfish/VTable.c
+++ b/clownfish/runtime/c/src/Clownfish/VTable.c
@@ -22,7 +22,7 @@
#include "charmony.h"
#include "Clownfish/VTable.h"
-#include "Clownfish/CharBuf.h"
+#include "Clownfish/String.h"
#include "Clownfish/Err.h"
#include "Clownfish/Util/Memory.h"
#include "Clownfish/VArray.h"
@@ -58,16 +58,16 @@ VTable_register_with_host(VTable *singleton, VTable *parent) {
}
VArray*
-VTable_fresh_host_methods(const CharBuf *class_name) {
+VTable_fresh_host_methods(const String *class_name) {
UNUSED_VAR(class_name);
return VA_new(0);
}
-CharBuf*
-VTable_find_parent_class(const CharBuf *class_name) {
+String*
+VTable_find_parent_class(const String *class_name) {
UNUSED_VAR(class_name);
THROW(ERR, "TODO");
- UNREACHABLE_RETURN(CharBuf*);
+ UNREACHABLE_RETURN(String*);
}
void*
http://git-wip-us.apache.org/repos/asf/lucy/blob/2c3dbf15/clownfish/runtime/core/Clownfish/CharBuf.c
----------------------------------------------------------------------
diff --git a/clownfish/runtime/core/Clownfish/CharBuf.c b/clownfish/runtime/core/Clownfish/CharBuf.c
deleted file mode 100644
index 590209c..0000000
--- a/clownfish/runtime/core/Clownfish/CharBuf.c
+++ /dev/null
@@ -1,912 +0,0 @@
-/* Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#define C_CFISH_CHARBUF
-#define C_CFISH_VIEWCHARBUF
-#define C_CFISH_STACKSTRING
-#define CFISH_USE_SHORT_NAMES
-#define CHY_USE_SHORT_NAMES
-
-#include "charmony.h"
-
-#include <string.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <ctype.h>
-
-#include "Clownfish/VTable.h"
-#include "Clownfish/CharBuf.h"
-
-#include "Clownfish/Err.h"
-#include "Clownfish/Util/Memory.h"
-#include "Clownfish/Util/StringHelper.h"
-
-// Helper function for throwing invalid UTF-8 error. Since THROW uses
-// a CharBuf internally, calling THROW with invalid UTF-8 would create an
-// infinite loop -- so we fwrite some of the bogus text to stderr and
-// invoke THROW with a generic message.
-#define DIE_INVALID_UTF8(text, size) \
- S_die_invalid_utf8(text, size, __FILE__, __LINE__, CFISH_ERR_FUNC_MACRO)
-static void
-S_die_invalid_utf8(const char *text, size_t size, const char *file, int line,
- const char *func);
-
-// Helper function for throwing invalid pattern error.
-static void
-S_die_invalid_pattern(const char *pattern);
-
-CharBuf*
-CB_new(size_t size) {
- CharBuf *self = (CharBuf*)VTable_Make_Obj(CHARBUF);
- return CB_init(self, size);
-}
-
-CharBuf*
-CB_init(CharBuf *self, size_t size) {
- // Derive.
- self->ptr = (char*)MALLOCATE(size + 1);
-
- // Init.
- *self->ptr = '\0'; // Empty string.
-
- // Assign.
- self->size = 0;
- self->cap = size + 1;
-
- return self;
-}
-
-CharBuf*
-CB_new_from_utf8(const char *ptr, size_t size) {
- if (!StrHelp_utf8_valid(ptr, size)) {
- DIE_INVALID_UTF8(ptr, size);
- }
- return CB_new_from_trusted_utf8(ptr, size);
-}
-
-CharBuf*
-CB_new_from_trusted_utf8(const char *ptr, size_t size) {
- CharBuf *self = (CharBuf*)VTable_Make_Obj(CHARBUF);
-
- // Derive.
- self->ptr = (char*)MALLOCATE(size + 1);
-
- // Copy.
- memcpy(self->ptr, ptr, size);
-
- // Assign.
- self->size = size;
- self->cap = size + 1;
- self->ptr[size] = '\0'; // Null terminate.
-
- return self;
-}
-
-CharBuf*
-CB_new_steal_from_trusted_str(char *ptr, size_t size, size_t cap) {
- CharBuf *self = (CharBuf*)VTable_Make_Obj(CHARBUF);
- return CB_init_steal_trusted_str(self, ptr, size, cap);
-}
-
-CharBuf*
-CB_init_steal_trusted_str(CharBuf *self, char *ptr, size_t size, size_t cap) {
- self->ptr = ptr;
- self->size = size;
- self->cap = cap;
- return self;
-}
-
-CharBuf*
-CB_new_steal_str(char *ptr, size_t size, size_t cap) {
- if (!StrHelp_utf8_valid(ptr, size)) {
- DIE_INVALID_UTF8(ptr, size);
- }
- return CB_new_steal_from_trusted_str(ptr, size, cap);
-}
-
-CharBuf*
-CB_newf(const char *pattern, ...) {
- CharBuf *self = CB_new(strlen(pattern));
- va_list args;
- va_start(args, pattern);
- CB_VCatF(self, pattern, args);
- va_end(args);
- return self;
-}
-
-void
-CB_Destroy_IMP(CharBuf *self) {
- FREEMEM(self->ptr);
- SUPER_DESTROY(self, CHARBUF);
-}
-
-int32_t
-CB_Hash_Sum_IMP(CharBuf *self) {
- uint32_t hashvalue = 5381;
- StackString *iterator = SSTR_WRAP(self);
-
- const ViewCB_Nibble_t nibble = METHOD_PTR(iterator->vtable,
- CFISH_ViewCB_Nibble);
- while (iterator->size) {
- uint32_t code_point = (uint32_t)nibble((ViewCharBuf*)iterator);
- hashvalue = ((hashvalue << 5) + hashvalue) ^ code_point;
- }
-
- return (int32_t) hashvalue;
-}
-
-static void
-S_grow(CharBuf *self, size_t size) {
- if (size >= self->cap) {
- CB_Grow(self, size);
- }
-}
-
-char*
-CB_Grow_IMP(CharBuf *self, size_t size) {
- if (size >= self->cap) {
- self->cap = size + 1;
- self->ptr = (char*)REALLOCATE(self->ptr, self->cap);
- }
- return self->ptr;
-}
-
-static void
-S_die_invalid_utf8(const char *text, size_t size, const char *file, int line,
- const char *func) {
- fprintf(stderr, "Invalid UTF-8, aborting: '");
- fwrite(text, sizeof(char), size < 200 ? size : 200, stderr);
- if (size > 200) { fwrite("[...]", sizeof(char), 5, stderr); }
- fprintf(stderr, "' (length %lu)\n", (unsigned long)size);
- Err_throw_at(ERR, file, line, func, "Invalid UTF-8");
-}
-
-static void
-S_die_invalid_pattern(const char *pattern) {
- size_t pattern_len = strlen(pattern);
- fprintf(stderr, "Invalid pattern, aborting: '");
- fwrite(pattern, sizeof(char), pattern_len, stderr);
- fprintf(stderr, "'\n");
- THROW(ERR, "Invalid pattern.");
-}
-
-void
-CB_catf(CharBuf *self, const char *pattern, ...) {
- va_list args;
- va_start(args, pattern);
- CB_VCatF(self, pattern, args);
- va_end(args);
-}
-
-void
-CB_VCatF_IMP(CharBuf *self, const char *pattern, va_list args) {
- size_t pattern_len = strlen(pattern);
- const char *pattern_start = pattern;
- const char *pattern_end = pattern + pattern_len;
- char buf[64];
-
- for (; pattern < pattern_end; pattern++) {
- const char *slice_end = pattern;
-
- // Consume all characters leading up to a '%'.
- while (slice_end < pattern_end && *slice_end != '%') { slice_end++; }
- if (pattern != slice_end) {
- size_t size = slice_end - pattern;
- CB_Cat_Trusted_Str(self, pattern, size);
- pattern = slice_end;
- }
-
- if (pattern < pattern_end) {
- pattern++; // Move past '%'.
-
- switch (*pattern) {
- case '%': {
- CB_Cat_Trusted_Str(self, "%", 1);
- }
- break;
- case 'o': {
- Obj *obj = va_arg(args, Obj*);
- if (!obj) {
- CB_Cat_Trusted_Str(self, "[NULL]", 6);
- }
- else if (Obj_Is_A(obj, CHARBUF)) {
- CB_Cat(self, (CharBuf*)obj);
- }
- else {
- CharBuf *string = Obj_To_String(obj);
- CB_Cat(self, string);
- DECREF(string);
- }
- }
- break;
- case 'i': {
- int64_t val = 0;
- size_t size;
- if (pattern[1] == '8') {
- val = va_arg(args, int32_t);
- pattern++;
- }
- else if (pattern[1] == '3' && pattern[2] == '2') {
- val = va_arg(args, int32_t);
- pattern += 2;
- }
- else if (pattern[1] == '6' && pattern[2] == '4') {
- val = va_arg(args, int64_t);
- pattern += 2;
- }
- else {
- S_die_invalid_pattern(pattern_start);
- }
- size = sprintf(buf, "%" PRId64, val);
- CB_Cat_Trusted_Str(self, buf, size);
- }
- break;
- case 'u': {
- uint64_t val = 0;
- size_t size;
- if (pattern[1] == '8') {
- val = va_arg(args, uint32_t);
- pattern += 1;
- }
- else if (pattern[1] == '3' && pattern[2] == '2') {
- val = va_arg(args, uint32_t);
- pattern += 2;
- }
- else if (pattern[1] == '6' && pattern[2] == '4') {
- val = va_arg(args, uint64_t);
- pattern += 2;
- }
- else {
- S_die_invalid_pattern(pattern_start);
- }
- size = sprintf(buf, "%" PRIu64, val);
- CB_Cat_Trusted_Str(self, buf, size);
- }
- break;
- case 'f': {
- if (pattern[1] == '6' && pattern[2] == '4') {
- double num = va_arg(args, double);
- char bigbuf[512];
- size_t size = sprintf(bigbuf, "%g", num);
- CB_Cat_Trusted_Str(self, bigbuf, size);
- pattern += 2;
- }
- else {
- S_die_invalid_pattern(pattern_start);
- }
- }
- break;
- case 'x': {
- if (pattern[1] == '3' && pattern[2] == '2') {
- unsigned long val = va_arg(args, uint32_t);
- size_t size = sprintf(buf, "%.8lx", val);
- CB_Cat_Trusted_Str(self, buf, size);
- pattern += 2;
- }
- else {
- S_die_invalid_pattern(pattern_start);
- }
- }
- break;
- case 's': {
- char *string = va_arg(args, char*);
- if (string == NULL) {
- CB_Cat_Trusted_Str(self, "[NULL]", 6);
- }
- else {
- size_t size = strlen(string);
- if (StrHelp_utf8_valid(string, size)) {
- CB_Cat_Trusted_Str(self, string, size);
- }
- else {
- CB_Cat_Trusted_Str(self, "[INVALID UTF8]", 14);
- }
- }
- }
- break;
- default: {
- // Assume NULL-terminated pattern string, which
- // eliminates the need for bounds checking if '%' is
- // the last visible character.
- S_die_invalid_pattern(pattern_start);
- }
- }
- }
- }
-}
-
-CharBuf*
-CB_To_String_IMP(CharBuf *self) {
- return CB_new_from_trusted_utf8(self->ptr, self->size);
-}
-
-void
-CB_Cat_Char_IMP(CharBuf *self, uint32_t code_point) {
- const size_t MAX_UTF8_BYTES = 4;
- if (self->size + MAX_UTF8_BYTES >= self->cap) {
- S_grow(self, Memory_oversize(self->size + MAX_UTF8_BYTES,
- sizeof(char)));
- }
- char *end = self->ptr + self->size;
- size_t count = StrHelp_encode_utf8_char(code_point, (uint8_t*)end);
- self->size += count;
- *(end + count) = '\0';
-}
-
-int32_t
-CB_Swap_Chars_IMP(CharBuf *self, uint32_t match, uint32_t replacement) {
- int32_t num_swapped = 0;
-
- if (match > 127) {
- THROW(ERR, "match point too high: %u32", match);
- }
- else if (replacement > 127) {
- THROW(ERR, "replacement code point too high: %u32", replacement);
- }
- else {
- char *ptr = self->ptr;
- char *const limit = ptr + self->size;
- for (; ptr < limit; ptr++) {
- if (*ptr == (char)match) {
- *ptr = (char)replacement;
- num_swapped++;
- }
- }
- }
-
- return num_swapped;
-}
-
-int64_t
-CB_To_I64_IMP(CharBuf *self) {
- return CB_BaseX_To_I64(self, 10);
-}
-
-int64_t
-CB_BaseX_To_I64_IMP(CharBuf *self, uint32_t base) {
- StackString *iterator = SSTR_WRAP(self);
- int64_t retval = 0;
- bool is_negative = false;
-
- // Advance past minus sign.
- if (SStr_Code_Point_At(iterator, 0) == '-') {
- SStr_Nibble(iterator);
- is_negative = true;
- }
-
- // Accumulate.
- while (iterator->size) {
- int32_t code_point = SStr_Nibble(iterator);
- if (isalnum(code_point)) {
- int32_t addend = isdigit(code_point)
- ? code_point - '0'
- : tolower(code_point) - 'a' + 10;
- if (addend > (int32_t)base) { break; }
- retval *= base;
- retval += addend;
- }
- else {
- break;
- }
- }
-
- // Apply minus sign.
- if (is_negative) { retval = 0 - retval; }
-
- return retval;
-}
-
-static double
-S_safe_to_f64(CharBuf *self) {
- size_t amount = self->size < 511 ? self->size : 511;
- char buf[512];
- memcpy(buf, self->ptr, amount);
- buf[amount] = 0; // NULL-terminate.
- return strtod(buf, NULL);
-}
-
-double
-CB_To_F64_IMP(CharBuf *self) {
- char *end;
- double value = strtod(self->ptr, &end);
- size_t consumed = end - self->ptr;
- if (consumed > self->size) { // strtod overran
- value = S_safe_to_f64(self);
- }
- return value;
-}
-
-CharBuf*
-CB_To_CB8_IMP(CharBuf *self) {
- return CB_new_from_trusted_utf8(self->ptr, self->size);
-}
-
-CharBuf*
-CB_Clone_IMP(CharBuf *self) {
- return CB_new_from_trusted_utf8(self->ptr, self->size);
-}
-
-void
-CB_Mimic_Str_IMP(CharBuf *self, const char* ptr, size_t size) {
- if (!StrHelp_utf8_valid(ptr, size)) {
- DIE_INVALID_UTF8(ptr, size);
- }
- if (size >= self->cap) { S_grow(self, size); }
- memmove(self->ptr, ptr, size);
- self->size = size;
- self->ptr[size] = '\0';
-}
-
-void
-CB_Mimic_IMP(CharBuf *self, Obj *other) {
- CharBuf *twin = (CharBuf*)CERTIFY(other, CHARBUF);
- if (twin->size >= self->cap) { S_grow(self, twin->size); }
- memmove(self->ptr, twin->ptr, twin->size);
- self->size = twin->size;
- self->ptr[twin->size] = '\0';
-}
-
-void
-CB_Cat_Str_IMP(CharBuf *self, const char* ptr, size_t size) {
- if (!StrHelp_utf8_valid(ptr, size)) {
- DIE_INVALID_UTF8(ptr, size);
- }
- CB_Cat_Trusted_Str_IMP(self, ptr, size);
-}
-
-void
-CB_Cat_Trusted_Str_IMP(CharBuf *self, const char* ptr, size_t size) {
- const size_t new_size = self->size + size;
- if (new_size >= self->cap) {
- size_t amount = Memory_oversize(new_size, sizeof(char));
- S_grow(self, amount);
- }
- memcpy((self->ptr + self->size), ptr, size);
- self->size = new_size;
- self->ptr[new_size] = '\0';
-}
-
-void
-CB_Cat_IMP(CharBuf *self, const CharBuf *other) {
- const size_t new_size = self->size + other->size;
- if (new_size >= self->cap) {
- size_t amount = Memory_oversize(new_size, sizeof(char));
- S_grow(self, amount);
- }
- memcpy((self->ptr + self->size), other->ptr, other->size);
- self->size = new_size;
- self->ptr[new_size] = '\0';
-}
-
-bool
-CB_Starts_With_IMP(CharBuf *self, const CharBuf *prefix) {
- return CB_Starts_With_Str_IMP(self, prefix->ptr, prefix->size);
-}
-
-bool
-CB_Starts_With_Str_IMP(CharBuf *self, const char *prefix, size_t size) {
- if (size <= self->size
- && (memcmp(self->ptr, prefix, size) == 0)
- ) {
- return true;
- }
- else {
- return false;
- }
-}
-
-bool
-CB_Equals_IMP(CharBuf *self, Obj *other) {
- CharBuf *const twin = (CharBuf*)other;
- if (twin == self) { return true; }
- if (!Obj_Is_A(other, CHARBUF)) { return false; }
- return CB_Equals_Str_IMP(self, twin->ptr, twin->size);
-}
-
-int32_t
-CB_Compare_To_IMP(CharBuf *self, Obj *other) {
- CERTIFY(other, CHARBUF);
- return CB_compare(&self, &other);
-}
-
-bool
-CB_Equals_Str_IMP(CharBuf *self, const char *ptr, size_t size) {
- if (self->size != size) {
- return false;
- }
- return (memcmp(self->ptr, ptr, self->size) == 0);
-}
-
-bool
-CB_Ends_With_IMP(CharBuf *self, const CharBuf *postfix) {
- return CB_Ends_With_Str_IMP(self, postfix->ptr, postfix->size);
-}
-
-bool
-CB_Ends_With_Str_IMP(CharBuf *self, const char *postfix, size_t postfix_len) {
- if (postfix_len <= self->size) {
- char *start = self->ptr + self->size - postfix_len;
- if (memcmp(start, postfix, postfix_len) == 0) {
- return true;
- }
- }
-
- return false;
-}
-
-int64_t
-CB_Find_IMP(CharBuf *self, const CharBuf *substring) {
- return CB_Find_Str(self, substring->ptr, substring->size);
-}
-
-int64_t
-CB_Find_Str_IMP(CharBuf *self, const char *ptr, size_t size) {
- StackString *iterator = SSTR_WRAP(self);
- int64_t location = 0;
-
- while (iterator->size) {
- if (SStr_Starts_With_Str(iterator, ptr, size)) {
- return location;
- }
- SStr_Nip(iterator, 1);
- location++;
- }
-
- return -1;
-}
-
-uint32_t
-CB_Trim_IMP(CharBuf *self) {
- return CB_Trim_Top(self) + CB_Trim_Tail(self);
-}
-
-uint32_t
-CB_Trim_Top_IMP(CharBuf *self) {
- char *ptr = self->ptr;
- char *end = ptr + self->size;
- uint32_t count = 0;
-
- while (ptr < end) {
- uint32_t code_point = StrHelp_decode_utf8_char(ptr);
- if (!StrHelp_is_whitespace(code_point)) { break; }
- ptr += StrHelp_UTF8_COUNT[*(uint8_t*)ptr];
- count++;
- }
- if (ptr > end) {
- DIE_INVALID_UTF8(self->ptr, self->size);
- }
-
- if (count) {
- // Copy string backwards.
- self->size = end - ptr;
- memmove(self->ptr, ptr, self->size);
- }
-
- return count;
-}
-
-uint32_t
-CB_Trim_Tail_IMP(CharBuf *self) {
- uint32_t count = 0;
- char *const top = self->ptr;
- const char *ptr = top + self->size;
- size_t new_size = self->size;
-
- while (NULL != (ptr = StrHelp_back_utf8_char(ptr, top))) {
- uint32_t code_point = StrHelp_decode_utf8_char(ptr);
- if (!StrHelp_is_whitespace(code_point)) { break; }
- new_size = ptr - top;
- count++;
- }
- self->size = new_size;
-
- return count;
-}
-
-size_t
-CB_Length_IMP(CharBuf *self) {
- size_t len = 0;
- char *ptr = self->ptr;
- char *end = ptr + self->size;
- while (ptr < end) {
- ptr += StrHelp_UTF8_COUNT[*(uint8_t*)ptr];
- len++;
- }
- if (ptr != end) {
- DIE_INVALID_UTF8(self->ptr, self->size);
- }
- return len;
-}
-
-size_t
-CB_Truncate_IMP(CharBuf *self, size_t count) {
- uint32_t num_code_points;
- StackString *iterator = SSTR_WRAP(self);
- num_code_points = SStr_Nip(iterator, count);
- self->size -= iterator->size;
- return num_code_points;
-}
-
-uint32_t
-CB_Code_Point_At_IMP(CharBuf *self, size_t tick) {
- size_t count = 0;
- char *ptr = self->ptr;
- char *const end = ptr + self->size;
-
- for (; ptr < end; ptr += StrHelp_UTF8_COUNT[*(uint8_t*)ptr]) {
- if (count == tick) {
- if (ptr > end) {
- DIE_INVALID_UTF8(self->ptr, self->size);
- }
- return StrHelp_decode_utf8_char(ptr);
- }
- count++;
- }
-
- return 0;
-}
-
-uint32_t
-CB_Code_Point_From_IMP(CharBuf *self, size_t tick) {
- size_t count = 0;
- char *top = self->ptr;
- const char *ptr = top + self->size;
-
- for (count = 0; count < tick; count++) {
- if (NULL == (ptr = StrHelp_back_utf8_char(ptr, top))) { return 0; }
- }
- return StrHelp_decode_utf8_char(ptr);
-}
-
-CharBuf*
-CB_SubString_IMP(CharBuf *self, size_t offset, size_t len) {
- StackString *iterator = SSTR_WRAP(self);
- char *sub_start;
- size_t byte_len;
-
- SStr_Nip(iterator, offset);
- sub_start = iterator->ptr;
- SStr_Nip(iterator, len);
- byte_len = iterator->ptr - sub_start;
-
- return CB_new_from_trusted_utf8(sub_start, byte_len);
-}
-
-int
-CB_compare(const void *va, const void *vb) {
- const CharBuf *a = *(const CharBuf**)va;
- const CharBuf *b = *(const CharBuf**)vb;
- StackString *iterator_a = SSTR_WRAP(a);
- StackString *iterator_b = SSTR_WRAP(b);
- while (iterator_a->size && iterator_b->size) {
- int32_t code_point_a = SStr_Nibble(iterator_a);
- int32_t code_point_b = SStr_Nibble(iterator_b);
- const int32_t comparison = code_point_a - code_point_b;
- if (comparison != 0) { return comparison; }
- }
- if (iterator_a->size != iterator_b->size) {
- return iterator_a->size < iterator_b->size ? -1 : 1;
- }
- return 0;
-}
-
-bool
-CB_less_than(const void *va, const void *vb) {
- return CB_compare(va, vb) < 0 ? 1 : 0;
-}
-
-void
-CB_Set_Size_IMP(CharBuf *self, size_t size) {
- self->size = size;
-}
-
-size_t
-CB_Get_Size_IMP(CharBuf *self) {
- return self->size;
-}
-
-uint8_t*
-CB_Get_Ptr8_IMP(CharBuf *self) {
- return (uint8_t*)self->ptr;
-}
-
-/*****************************************************************/
-
-ViewCharBuf*
-ViewCB_new_from_utf8(const char *utf8, size_t size) {
- if (!StrHelp_utf8_valid(utf8, size)) {
- DIE_INVALID_UTF8(utf8, size);
- }
- return ViewCB_new_from_trusted_utf8(utf8, size);
-}
-
-ViewCharBuf*
-ViewCB_new_from_trusted_utf8(const char *utf8, size_t size) {
- ViewCharBuf *self = (ViewCharBuf*)VTable_Make_Obj(VIEWCHARBUF);
- return ViewCB_init(self, utf8, size);
-}
-
-ViewCharBuf*
-ViewCB_init(ViewCharBuf *self, const char *utf8, size_t size) {
- self->ptr = (char*)utf8;
- self->size = size;
- self->cap = 0;
- return self;
-}
-
-void
-ViewCB_Destroy_IMP(ViewCharBuf *self) {
- // Note that we do not free self->ptr, and that we invoke the
- // SUPER_DESTROY with CHARBUF instead of VIEWCHARBUF.
- SUPER_DESTROY(self, CHARBUF);
-}
-
-void
-ViewCB_Assign_IMP(ViewCharBuf *self, const CharBuf *other) {
- self->ptr = other->ptr;
- self->size = other->size;
-}
-
-void
-ViewCB_Assign_Str_IMP(ViewCharBuf *self, const char *utf8, size_t size) {
- if (!StrHelp_utf8_valid(utf8, size)) {
- DIE_INVALID_UTF8(utf8, size);
- }
- self->ptr = (char*)utf8;
- self->size = size;
-}
-
-void
-ViewCB_Assign_Trusted_Str_IMP(ViewCharBuf *self, const char *utf8, size_t size) {
- self->ptr = (char*)utf8;
- self->size = size;
-}
-
-uint32_t
-ViewCB_Trim_Top_IMP(ViewCharBuf *self) {
- uint32_t count = 0;
- char *ptr = self->ptr;
- char *end = ptr + self->size;
-
- while (ptr < end) {
- uint32_t code_point = StrHelp_decode_utf8_char(ptr);
- if (!StrHelp_is_whitespace(code_point)) { break; }
- ptr += StrHelp_UTF8_COUNT[*(uint8_t*)ptr];
- count++;
- }
-
- if (count) {
- if (ptr > end) {
- DIE_INVALID_UTF8(self->ptr, self->size);
- }
- self->size = end - ptr;
- self->ptr = ptr;
- }
-
- return count;
-}
-
-size_t
-ViewCB_Nip_IMP(ViewCharBuf *self, size_t count) {
- size_t num_nipped;
- char *ptr = self->ptr;
- char *end = ptr + self->size;
- for (num_nipped = 0;
- ptr < end && count--;
- ptr += StrHelp_UTF8_COUNT[*(uint8_t*)ptr]
- ) {
- num_nipped++;
- }
- if (ptr > end) {
- DIE_INVALID_UTF8(self->ptr, self->size);
- }
- self->size = end - ptr;
- self->ptr = ptr;
- return num_nipped;
-}
-
-int32_t
-ViewCB_Nibble_IMP(ViewCharBuf *self) {
- if (self->size == 0) {
- return 0;
- }
- else {
- int32_t retval = (int32_t)StrHelp_decode_utf8_char(self->ptr);
- size_t consumed = StrHelp_UTF8_COUNT[*(uint8_t*)self->ptr];
- if (consumed > self->size) {
- DIE_INVALID_UTF8(self->ptr, self->size);
- }
- self->ptr += consumed;
- self->size -= consumed;
- return retval;
- }
-}
-
-size_t
-ViewCB_Chop_IMP(ViewCharBuf *self, size_t count) {
- size_t num_chopped = 0;
- char *top = self->ptr;
- const char *ptr = top + self->size;
- for (num_chopped = 0; num_chopped < count; num_chopped++) {
- const char *end = ptr;
- if (NULL == (ptr = StrHelp_back_utf8_char(ptr, top))) { break; }
- self->size -= (end - ptr);
- }
- return num_chopped;
-}
-
-char*
-ViewCB_Grow_IMP(ViewCharBuf *self, size_t size) {
- UNUSED_VAR(size);
- THROW(ERR, "Can't grow a ViewCharBuf ('%o')", self);
- UNREACHABLE_RETURN(char*);
-}
-
-/*****************************************************************/
-
-StackString*
-SStr_new(void *allocation) {
- static char empty_string[] = "";
- StackString *self
- = (StackString*)VTable_Init_Obj(STACKSTRING, allocation);
- self->cap = 0;
- self->size = 0;
- self->ptr = empty_string;
- return self;
-}
-
-StackString*
-SStr_newf(void *allocation, size_t alloc_size, const char *pattern, ...) {
- StackString *self
- = (StackString*)VTable_Init_Obj(STACKSTRING, allocation);
- self->cap = alloc_size - sizeof(StackString);
- self->size = 0;
- self->ptr = ((char*)allocation) + sizeof(StackString);
-
- va_list args;
- va_start(args, pattern);
- SStr_VCatF(self, pattern, args);
- va_end(args);
-
- return self;
-}
-
-StackString*
-SStr_wrap_str(void *allocation, const char *ptr, size_t size) {
- StackString *self
- = (StackString*)VTable_Init_Obj(STACKSTRING, allocation);
- self->cap = 0;
- self->size = size;
- self->ptr = (char*)ptr;
- return self;
-}
-
-StackString*
-SStr_wrap(void *allocation, const CharBuf *source) {
- return SStr_wrap_str(allocation, source->ptr, source->size);
-}
-
-size_t
-SStr_size() {
- return sizeof(StackString);
-}
-
-void
-SStr_Destroy_IMP(StackString *self) {
- THROW(ERR, "Can't destroy a StackString ('%o')", self);
-}
-
-
http://git-wip-us.apache.org/repos/asf/lucy/blob/2c3dbf15/clownfish/runtime/core/Clownfish/CharBuf.cfh
----------------------------------------------------------------------
diff --git a/clownfish/runtime/core/Clownfish/CharBuf.cfh b/clownfish/runtime/core/Clownfish/CharBuf.cfh
deleted file mode 100644
index a224f4a..0000000
--- a/clownfish/runtime/core/Clownfish/CharBuf.cfh
+++ /dev/null
@@ -1,392 +0,0 @@
-/* Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-parcel Clownfish;
-
-/**
- * Growable buffer holding Unicode characters.
- */
-
-class Clownfish::CharBuf cnick CB
- inherits Clownfish::Obj {
-
- char *ptr;
- size_t size;
- size_t cap; /* allocated bytes, including terminating null */
-
- inert incremented CharBuf*
- new(size_t size);
-
- inert CharBuf*
- init(CharBuf *self, size_t size);
-
- /** Return a new CharBuf which holds a copy of the passed-in string.
- * Check for UTF-8 validity.
- */
- inert incremented CharBuf*
- new_from_utf8(const char *utf8, size_t size);
-
- /** Return a new CharBuf which holds a copy of the passed-in string. No
- * validity checking is performed.
- */
- inert incremented CharBuf*
- new_from_trusted_utf8(const char *utf8, size_t size);
-
- /** Return a pointer to a new CharBuf which assumes ownership of the
- * passed-in string. Check validity of supplied UTF-8.
- */
- inert incremented CharBuf*
- new_steal_str(char *ptr, size_t size, size_t cap);
-
- /** Return a pointer to a new CharBuf which assumes ownership of the
- * passed-in string. Do not check validity of supplied UTF-8.
- */
- inert incremented CharBuf*
- new_steal_from_trusted_str(char *ptr, size_t size, size_t cap);
-
- /** Initialize the CharBuf using the passed-in string. Do not check
- * validity of supplied UTF-8.
- */
- public inert CharBuf*
- init_steal_trusted_str(decremented CharBuf *self, char *ptr,
- size_t size, size_t cap);
-
- /** Return a pointer to a new CharBuf which contains formatted data
- * expanded according to CB_VCatF.
- *
- * Note: a user-supplied <code>pattern</code> string is a security hole
- * and must not be allowed.
- */
- inert incremented CharBuf*
- newf(const char *pattern, ...);
-
- /** Perform lexical comparison of two CharBufs, with level of indirection
- * set to please qsort and friends.
- */
- inert int
- compare(const void *va, const void *vb);
-
- /** Perform lexical comparison of two CharBufs, with level of indirection
- * set to please qsort and friends, and return true if <code>a</code> is
- * less than <code>b</code>.
- */
- inert bool
- less_than(const void *va, const void *vb);
-
- public void
- Mimic(CharBuf *self, Obj *other);
-
- void
- Mimic_Str(CharBuf *self, const char *ptr, size_t size);
-
- /** Concatenate the passed-in string onto the end of the CharBuf.
- */
- void
- Cat_Str(CharBuf *self, const char *ptr, size_t size);
-
- /** Concatenate the contents of <code>other</code> onto the end of the
- * caller.
- */
- void
- Cat(CharBuf *self, const CharBuf *other);
-
- /** Concatenate formatted arguments. Similar to the printf family, but
- * only accepts minimal options (just enough for decent error messages).
- *
- * Objects: %o
- * char*: %s
- * integers: %i8 %i32 %i64 %u8 %u32 %u64
- * floats: %f64
- * hex: %x32
- *
- * Note that all Clownfish Objects, including CharBufs, are printed via
- * %o (which invokes Obj_To_String()).
- */
- void
- VCatF(CharBuf *self, const char *pattern, va_list args);
-
- /** Invokes CB_VCatF to concatenate formatted arguments. Note that this
- * is only a function and not a method.
- */
- inert void
- catf(CharBuf *self, const char *pattern, ...);
-
- /** Concatenate one Unicode character onto the end of the CharBuf.
- */
- void
- Cat_Char(CharBuf *self, uint32_t code_point);
-
- /** Replace all instances of one character for the other. For now, both
- * the source and replacement code points must be ASCII.
- */
- int32_t
- Swap_Chars(CharBuf *self, uint32_t match, uint32_t replacement);
-
- public int64_t
- To_I64(CharBuf *self);
-
- /** Extract a 64-bit integer from a variable-base stringified version.
- */
- int64_t
- BaseX_To_I64(CharBuf *self, uint32_t base);
-
- public double
- To_F64(CharBuf *self);
-
- /** Assign more memory to the CharBuf, if it doesn't already have enough
- * room to hold a string of <code>size</code> bytes. Cannot shrink the
- * allocation.
- *
- * @return a pointer to the raw buffer.
- */
- char*
- Grow(CharBuf *self, size_t size);
-
- /** Test whether the CharBuf starts with the content of another.
- */
- bool
- Starts_With(CharBuf *self, const CharBuf *prefix);
-
- /** Test whether the CharBuf starts with the passed-in string.
- */
- bool
- Starts_With_Str(CharBuf *self, const char *prefix, size_t size);
-
- /** Test whether the CharBuf ends with the content of another.
- */
- bool
- Ends_With(CharBuf *self, const CharBuf *postfix);
-
- /** Test whether the CharBuf ends with the passed-in string.
- */
- bool
- Ends_With_Str(CharBuf *self, const char *postfix, size_t size);
-
- /** Return the location of the substring within the CharBuf (measured in
- * code points), or -1 if the substring does not match.
- */
- int64_t
- Find(CharBuf *self, const CharBuf *substring);
-
- int64_t
- Find_Str(CharBuf *self, const char *ptr, size_t size);
-
- /** Test whether the CharBuf matches the passed-in string.
- */
- bool
- Equals_Str(CharBuf *self, const char *ptr, size_t size);
-
- /** Return the number of Unicode code points in the object's string.
- */
- size_t
- Length(CharBuf *self);
-
- /** Set the CharBuf's <code>size</code> attribute.
- */
- void
- Set_Size(CharBuf *self, size_t size);
-
- /** Get the CharBuf's <code>size</code> attribute.
- */
- size_t
- Get_Size(CharBuf *self);
-
- /** Return the internal backing array for the CharBuf if its internal
- * encoding is UTF-8. If it is not encoded as UTF-8 throw an exception.
- */
- uint8_t*
- Get_Ptr8(CharBuf *self);
-
- /** Return a fresh copy of the string data in a CharBuf with an internal
- * encoding of UTF-8.
- */
- CharBuf*
- To_CB8(CharBuf *self);
-
- public incremented CharBuf*
- Clone(CharBuf *self);
-
- public void
- Destroy(CharBuf *self);
-
- public bool
- Equals(CharBuf *self, Obj *other);
-
- public int32_t
- Compare_To(CharBuf *self, Obj *other);
-
- public int32_t
- Hash_Sum(CharBuf *self);
-
- public incremented CharBuf*
- To_String(CharBuf *self);
-
- /** Remove Unicode whitespace characters from both top and tail.
- */
- uint32_t
- Trim(CharBuf *self);
-
- /** Remove leading Unicode whitespace.
- */
- uint32_t
- Trim_Top(CharBuf *self);
-
- /** Remove trailing Unicode whitespace.
- */
- uint32_t
- Trim_Tail(CharBuf *self);
-
- /** Truncate the CharBuf so that it contains no more than
- * <code>count</code>characters.
- *
- * @param count Maximum new length, in Unicode code points.
- * @return The number of code points left in the string after truncation.
- */
- size_t
- Truncate(CharBuf *self, size_t count);
-
- /** Return the Unicode code point at the specified number of code points
- * in. Return 0 if the string length is exceeded. (XXX It would be
- * better to throw an exception, but that's not practical with UTF-8 and
- * no cached length.)
- */
- uint32_t
- Code_Point_At(CharBuf *self, size_t tick);
-
- /** Return the Unicode code point at the specified number of code points
- * counted backwards from the end of the string. Return 0 if outside the
- * string.
- */
- uint32_t
- Code_Point_From(CharBuf *self, size_t tick);
-
- /** Return a newly allocated CharBuf containing a copy of the indicated
- * substring.
- * @param offset Offset from the top, in code points.
- * @param len The desired length of the substring, in code points.
- */
- incremented CharBuf*
- SubString(CharBuf *self, size_t offset, size_t len);
-
- /** Concatenate the supplied text onto the end of the CharBuf. Don't
- * check for UTF-8 validity.
- */
- void
- Cat_Trusted_Str(CharBuf *self, const char *ptr, size_t size);
-}
-
-class Clownfish::ViewCharBuf cnick ViewCB
- inherits Clownfish::CharBuf {
-
- inert incremented ViewCharBuf*
- new_from_utf8(const char *utf8, size_t size);
-
- inert incremented ViewCharBuf*
- new_from_trusted_utf8(const char *utf8, size_t size);
-
- inert ViewCharBuf*
- init(ViewCharBuf *self, const char *utf8, size_t size);
-
- void
- Assign(ViewCharBuf *self, const CharBuf *other);
-
- void
- Assign_Str(ViewCharBuf *self, const char *utf8, size_t size);
-
- void
- Assign_Trusted_Str(ViewCharBuf *self, const char *utf8, size_t size);
-
- uint32_t
- Trim_Top(ViewCharBuf *self);
-
- /** Remove characters (measured in code points) from the top of the
- * ViewCharBuf. Returns the number nipped.
- */
- size_t
- Nip(ViewCharBuf *self, size_t count);
-
- /** Remove one character from the top of the ViewCharBuf. Returns the
- * code point, or 0 if the string was empty.
- */
- int32_t
- Nibble(ViewCharBuf *self);
-
- /** Remove characters (measured in code points) from the end of the
- * ViewCharBuf. Returns the number chopped.
- */
- size_t
- Chop(ViewCharBuf *self, size_t count);
-
- /** Throws an error. */
- char*
- Grow(ViewCharBuf *self, size_t size);
-
- public void
- Destroy(ViewCharBuf *self);
-}
-
-class Clownfish::StackString cnick SStr
- inherits Clownfish::ViewCharBuf {
-
- /** Return a StackString with a blank string.
- */
- inert incremented StackString*
- new(void *allocation);
-
- /**
- * @param allocation A single block of memory which will be used for both
- * the StackString object and its buffer.
- * @param alloc_size The size of the allocation.
- * @param pattern A format pattern.
- */
- inert incremented StackString*
- newf(void *allocation, size_t alloc_size, const char *pattern, ...);
-
- inert incremented StackString*
- wrap(void *allocation, const CharBuf *source);
-
- inert incremented StackString*
- wrap_str(void *allocation, const char *ptr, size_t size);
-
- /** Return the size for a StackString struct.
- */
- inert size_t
- size();
-
- /** Throws an error.
- */
- public void
- Destroy(StackString *self);
-}
-
-__C__
-
-#define CFISH_SStr_BLANK() cfish_SStr_new(cfish_alloca(cfish_SStr_size()))
-
-#define CFISH_SStr_WRAP(source) \
- cfish_SStr_wrap(cfish_alloca(cfish_SStr_size()), source)
-
-#define CFISH_SStr_WRAP_STR(ptr, size) \
- cfish_SStr_wrap_str(cfish_alloca(cfish_SStr_size()), ptr, size)
-
-#ifdef CFISH_USE_SHORT_NAMES
- #define SStr_BLANK CFISH_SStr_BLANK
- #define SSTR_WRAP CFISH_SStr_WRAP
- #define SSTR_WRAP_STR CFISH_SStr_WRAP_STR
-#endif
-__END_C__
-
-