Skip to content

Commit

Permalink
add depository
Browse files Browse the repository at this point in the history
  • Loading branch information
ggeorgiev committed Jun 19, 2016
1 parent af625eb commit ec67626
Show file tree
Hide file tree
Showing 14 changed files with 151 additions and 17 deletions.
1 change: 0 additions & 1 deletion src/doim/url/url.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
//

#include "doim/url/url.h"
#include <functional>

namespace doim
{
Expand Down
3 changes: 0 additions & 3 deletions src/doim/url/url.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,9 @@

#include "doim/element.hpp"
#include "doim/set.hpp"
#include <boost/hana/for_each.hpp>
#include <functional>
#include <memory>
#include <str>
#include <tuple>
#include <unordered>

namespace doim
{
Expand Down
6 changes: 4 additions & 2 deletions src/dom/prj/depository.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,12 @@ Depository::Depository()
ECode Depository::updateType(const EType& type)
{
mType = type;
EHEnd;
}

ECode Depository::updateUrl(const doim::UrlSPtr& url)
ECode Depository::updateGitUrl(const doim::UrlSPtr& url)
{
mUrl = url;
mGitUrl = url;
EHEnd;
}
}
10 changes: 4 additions & 6 deletions src/dom/prj/depository.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@
#include "doim/url/url.h"
#include "err/err.h"
#include <memory>
#include <str>
#include <tuple>

namespace dom
{
Expand All @@ -31,18 +29,18 @@ class Depository : public Element<Depository>
return mType;
}

doim::UrlSPtr url()
doim::UrlSPtr gitUrl()
{
return mUrl;
return mGitUrl;
}

// Updates
ECode updateType(const EType& type);

ECode updateUrl(const doim::UrlSPtr& url);
ECode updateGitUrl(const doim::UrlSPtr& url);

private:
EType mType;
doim::UrlSPtr mUrl;
doim::UrlSPtr mGitUrl;
};
}
20 changes: 19 additions & 1 deletion src/parser/dbs/dbs_parser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,14 @@
#include "parser/dbs/e_attribute.hpp"
#include "parser/dbs/e_cxx_library.hpp"
#include "parser/dbs/e_cxx_program.hpp"
#include "parser/dbs/e_depository.hpp"
#include "parser/dbs/e_directory.hpp"
#include "parser/dbs/e_file.hpp"
#include "parser/dbs/e_file_set.hpp"
#include "parser/dbs/e_object.hpp"
#include "parser/dbs/e_particle.hpp"
#include "parser/dbs/e_position.hpp"
#include "parser/dbs/e_url.hpp"
#include "doim/fs/fs_directory.h"
#include <boost/filesystem/operations.hpp>
#include <fstream> // IWYU pragma: keep
Expand Down Expand Up @@ -57,17 +59,32 @@ ECode DbsParser::parse(const doim::FsFileSPtr& dbsFile)
FileSet files(file);
auto r_files = r_empty() >> files.reset() & *(r_file >> e_ref(files));

// Url
Url url;
auto r_url = r_ws & (r_ident() & r_colon & r_slash & r_slash & r_path) >> e_ref(url);

// Object
Object object(location);
auto r_object = r_ws & r_path >> e_ref(object);
auto r_objectCxxLibrary = r_empty() >> object.cxxLibrary() & r_object;
auto r_objectCxxProgram = r_empty() >> object.cxxProgram() & r_object;
auto r_objectDepository = r_empty() >> object.depository() & r_object;

// Annex
Annex annex(errors, file);
auto r_annex =
r_ws & r_annexKw & r_he & r_resetDir & *(r_file >> e_ref(annex)) & r_se;

// Depository Ref
DepositoryRef depositoryRef(object);
auto r_depositoryRef = r_objectDepository >> e_ref(depositoryRef);

// Depository
Depository depository(url, depositoryRef);
auto r_depositoryName = r_depositoryRef >> depository.name();
auto r_git = r_ws & r_gitKw & r_he & r_url >> depository.gitUrl() & r_se;
auto r_depository = r_ws & r_depositoryKw & r_depositoryName & r_he & r_git & r_se;

// CxxLibrary Ref
CxxLibraryRef cxxLibraryRef(object);
auto r_cxxLibraryRef = r_objectCxxLibrary >> e_ref(cxxLibraryRef);
Expand Down Expand Up @@ -126,7 +143,8 @@ ECode DbsParser::parse(const doim::FsFileSPtr& dbsFile)
auto r_cxxProgram = r_ws & r_cxxProgramKw & r_cxxProgramName & r_he &
*(r_cxxProgramCxxFile | r_cxxProgramCxxLibrary) & r_se;

const auto& r_dbs = ~r_annex & *(r_cxxLibrary | r_cxxProgram) & r_ws & r_end();
const auto& r_dbs =
~r_annex & *(r_depository | r_cxxLibrary | r_cxxProgram) & r_ws & r_end();

// Dbs file
const auto& path = dbsFile->path();
Expand Down
60 changes: 60 additions & 0 deletions src/parser/dbs/e_depository.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
// Copyright © 2016 George Georgiev. All rights reserved.
//

#pragma once

#include "parser/dbs/e_annex.hpp"
#include "parser/dbs/e_attribute.hpp"
#include "parser/dbs/e_directory.hpp"
#include "parser/dbs/e_file.hpp"
#include "parser/dbs/e_file_set.hpp"
#include "parser/dbs/e_object.hpp"
#include "parser/dbs/e_position.hpp"
#include "parser/dbs/e_url.hpp"
#include "dom/prj/depository.h"

namespace parser
{
static auto r_depositoryKw = r_str("depository");
static auto r_gitKw = r_str("git");

struct DepositoryRef
{
DepositoryRef(Object& object)
: mObject(object)
{
}

void operator()(I& i1, I& i2)
{
mDepository = dom::Depository::obtain(mObject.mObject);
}

Object& mObject;
dom::DepositorySPtr mDepository;
};

struct Depository
{
Depository(Url& url, DepositoryRef& depositoryRef)
: mUrl(url)
, mDepositoryRef(depositoryRef)
{
}

auto gitUrl()
{
return e_ref([this](I& i1, I& i2) { mDepository->updateGitUrl(mUrl.mUrl); });
}

auto name()
{
return e_ref([this](I& i1, I& i2) { mDepository = mDepositoryRef.mDepository; });
}

Url& mUrl;
DepositoryRef& mDepositoryRef;

dom::DepositorySPtr mDepository;
};
}
6 changes: 6 additions & 0 deletions src/parser/dbs/e_object.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,12 @@ struct Object
[this](I& i1, I& i2) { mObjType = doim::Object::EType::kCxxProgram; });
}

auto depository()
{
return e_ref(
[this](I& i1, I& i2) { mObjType = doim::Object::EType::kDepository; });
}

void operator()(I& i1, I& i2)
{
auto size = std::distance(i1, i2);
Expand Down
4 changes: 0 additions & 4 deletions src/parser/dbs/e_tag.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,6 @@ namespace parser
{
struct Tag
{
Tag()
{
}

void operator()(I& i1, I& i2)
{
mTag = doim::Tag::unique(string(i1, i2));
Expand Down
25 changes: 25 additions & 0 deletions src/parser/dbs/e_url.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
// Copyright © 2016 George Georgiev. All rights reserved.
//

#pragma once

#include "parser/dbs/e_directory.hpp"
#include "doim/fs/fs_file.h"
#include "doim/generic/attribute.h"
#include "doim/generic/attribute_name.h"
#include "doim/generic/attribute_value.h"
#include "doim/url/url.h"
#include "err/err.h"

namespace parser
{
struct Url
{
void operator()(I& i1, I& i2)
{
mUrl = doim::Url::unique(string(i1, i2));
};

doim::UrlSPtr mUrl;
};
}
16 changes: 16 additions & 0 deletions src/parser/gtest/dbs/dbs_parser-utest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#include "parser/dbs/dbs_parser.h"
#include "dom/cxx/cxx_library.h"
#include "dom/cxx/cxx_program.h"
#include "dom/prj/depository.h"
#include "doim/cxx/cxx_file.h"
#include "doim/fs/fs_directory.h"
#include "doim/fs/fs_file.h"
Expand Down Expand Up @@ -220,3 +221,18 @@ TEST(DbsParserTest, SLOW_CxxProgramCxxFile)

ASSERT_EQ(1, cxxProgramCxxFiles->cxxFilesList().size());
}

TEST(DbsParserTest, SLOW_Depository)
{
parse();

auto mDbsDirectory =
doim::FsDirectory::obtain(testing::gTestResourceDirectory, "dbs");

auto depositoryObject =
doim::Object::obtain(doim::Object::EType::kDepository, mDbsDirectory, "depo");

auto depo = dom::Depository::find(depositoryObject);
ASSERT_NE(nullptr, depo);
ASSERT_NE(nullptr, depo->gitUrl());
}
2 changes: 2 additions & 0 deletions src/parser/parser.dbs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ cxx_library parser
parser/dbs/e_cxx_library.hpp
parser/dbs/e_cxx_program.hpp
parser/dbs/e_directory.hpp
parser/dbs/e_depository.hpp
parser/dbs/e_file_set.hpp
parser/dbs/e_file.hpp
parser/dbs/e_object.hpp
Expand All @@ -21,6 +22,7 @@ cxx_library parser
parser/dbs/e_tag_expression.hpp
parser/dbs/e_tag_set.hpp
parser/dbs/e_tag.hpp
parser/dbs/e_url.hpp
;

cxx_library:
Expand Down
3 changes: 3 additions & 0 deletions test_resource/dbs/depository.dbs
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
depository depo:
git: https://github.com/madler/zlib.git;
;
2 changes: 2 additions & 0 deletions test_resource/dbs/main.dbs
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,6 @@ annex:

cxx_library.dbs
cxx_program.dbs

depository.dbs
;
10 changes: 10 additions & 0 deletions xcode/dbs-build.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,8 @@
5E8E184E1D1626FF009783BD /* depository.h in Headers */ = {isa = PBXBuildFile; fileRef = 5E8E184C1D1626FF009783BD /* depository.h */; };
5E8E18521D1634C2009783BD /* url.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 5E8E18501D1634C2009783BD /* url.cpp */; };
5E8E18531D1634C2009783BD /* url.h in Headers */ = {isa = PBXBuildFile; fileRef = 5E8E18511D1634C2009783BD /* url.h */; };
5E8E18561D1649A0009783BD /* e_depository.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 5E8E18551D1649A0009783BD /* e_depository.hpp */; };
5E8E18581D165A93009783BD /* e_url.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 5E8E18571D165A93009783BD /* e_url.hpp */; };
5EABCABB1CE057FD00E79FFD /* sys_executable.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 5EABCAB91CE057FD00E79FFD /* sys_executable.cpp */; };
5EABCABC1CE057FD00E79FFD /* sys_executable.h in Headers */ = {isa = PBXBuildFile; fileRef = 5EABCABA1CE057FD00E79FFD /* sys_executable.h */; };
5EAE67701C7295B2005B3F8D /* cxx_object_file.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 5EAE676E1C7295B2005B3F8D /* cxx_object_file.cpp */; };
Expand Down Expand Up @@ -469,6 +471,9 @@
5E8E184C1D1626FF009783BD /* depository.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = depository.h; sourceTree = "<group>"; };
5E8E18501D1634C2009783BD /* url.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = url.cpp; sourceTree = "<group>"; };
5E8E18511D1634C2009783BD /* url.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = url.h; sourceTree = "<group>"; };
5E8E18541D1648B6009783BD /* depository.dbs */ = {isa = PBXFileReference; lastKnownFileType = text; path = depository.dbs; sourceTree = "<group>"; };
5E8E18551D1649A0009783BD /* e_depository.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = e_depository.hpp; sourceTree = "<group>"; };
5E8E18571D165A93009783BD /* e_url.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = e_url.hpp; sourceTree = "<group>"; };
5EABCAB91CE057FD00E79FFD /* sys_executable.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = sys_executable.cpp; sourceTree = "<group>"; };
5EABCABA1CE057FD00E79FFD /* sys_executable.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = sys_executable.h; sourceTree = "<group>"; };
5EAE676E1C7295B2005B3F8D /* cxx_object_file.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = cxx_object_file.cpp; sourceTree = "<group>"; };
Expand Down Expand Up @@ -1256,6 +1261,7 @@
5E8E182D1D15F0BA009783BD /* e_attribute.hpp */,
5E8E18391D15F6B1009783BD /* e_cxx_library.hpp */,
5E8E183B1D15F87E009783BD /* e_cxx_program.hpp */,
5E8E18551D1649A0009783BD /* e_depository.hpp */,
5E8E182F1D15F1FE009783BD /* e_directory.hpp */,
5E8E18331D15F39C009783BD /* e_file_set.hpp */,
5E8E18311D15F274009783BD /* e_file.hpp */,
Expand All @@ -1265,6 +1271,7 @@
5E8E18431D16130B009783BD /* e_tag_expression.hpp */,
5E8E18411D160F6F009783BD /* e_tag_set.hpp */,
5E8E183F1D160EA3009783BD /* e_tag.hpp */,
5E8E18571D165A93009783BD /* e_url.hpp */,
);
path = dbs;
sourceTree = "<group>";
Expand Down Expand Up @@ -1298,6 +1305,7 @@
5E87B9E21CF17A1F00F042B4 /* cxx_library.dbs */,
5E5A04FB1CF9FC5700DA4443 /* cxx_program_headers.dbs */,
5EEBDB371CF3FD9D008E1848 /* cxx_program.dbs */,
5E8E18541D1648B6009783BD /* depository.dbs */,
5E87B9E11CF1607300F042B4 /* main.dbs */,
);
path = dbs;
Expand Down Expand Up @@ -1367,6 +1375,7 @@
5E10B3BB1C70F272009C73E4 /* location.hpp in Headers */,
5E5692711C727076000A233C /* element.hpp in Headers */,
5E8E18531D1634C2009783BD /* url.h in Headers */,
5E8E18561D1649A0009783BD /* e_depository.hpp in Headers */,
5E8E182E1D15F0BA009783BD /* e_attribute.hpp in Headers */,
5E10B3B11C70F272009C73E4 /* database.h in Headers */,
5E10B3DD1C70F272009C73E4 /* performance_arbiter.h in Headers */,
Expand Down Expand Up @@ -1425,6 +1434,7 @@
5E8079B71D0C693F00BB6C1C /* server.h in Headers */,
5E10B3E51C70F272009C73E4 /* log.h in Headers */,
5E875BC81CFBBDE8008AC423 /* cxx_iwyu.h in Headers */,
5E8E18581D165A93009783BD /* e_url.hpp in Headers */,
5EABCABC1CE057FD00E79FFD /* sys_executable.h in Headers */,
5E10B3F71C70F272009C73E4 /* cxx_source_crc_task.h in Headers */,
5E5A05041CFA499200DA4443 /* protobuf_file.h in Headers */,
Expand Down

0 comments on commit ec67626

Please sign in to comment.