From f541af4f83989b0ef190bfcf2199ee3b2fb1fb85 Mon Sep 17 00:00:00 2001 From: "Meredith L. Patterson" <mlp@thesmartpolitenerd.com> Date: Thu, 12 Sep 2013 20:44:05 +0200 Subject: [PATCH] C++ bindings build, tests not running yet though. --- src/bindings/cpp/hammer.cxx | 8 ++++---- src/bindings/cpp/hammer.hxx | 12 +++++++----- 2 files changed, 11 insertions(+), 9 deletions(-) diff --git a/src/bindings/cpp/hammer.cxx b/src/bindings/cpp/hammer.cxx index e7f3cb74..4022f26d 100644 --- a/src/bindings/cpp/hammer.cxx +++ b/src/bindings/cpp/hammer.cxx @@ -5,8 +5,8 @@ namespace hammer { typedef variant<BytesResult, UintResult, IntResult, NullResult, SequenceResult> AnyResult; const BytesResult::result_type BytesResult::result() { return _bytes; } - const UintResult::result_type UintResult::result() { return _uint; } - const IntResult::result_type IntResult::result() { return _sint; } + UintResult::result_type UintResult::result() { return _uint; } + IntResult::result_type IntResult::result() { return _sint; } const SequenceResult::result_type SequenceResult::result() { return _seq; } template<> @@ -47,13 +47,13 @@ namespace hammer { template<> NullResult Parser<NullResult>::parse(const string &input) { - HParseResult *res = h_parse(_parser, reinterpret_cast<const uint8_t*>(input.c_str()), input.size()); + h_parse(_parser, reinterpret_cast<const uint8_t*>(input.c_str()), input.size()); return NullResult(); } template<> NullResult Parser<NullResult>::parse(const uint8_t *input, size_t length) { - HParseResult *res = h_parse(_parser, input, length); + h_parse(_parser, input, length); return NullResult(); } diff --git a/src/bindings/cpp/hammer.hxx b/src/bindings/cpp/hammer.hxx index c0c39c5a..f1a20e63 100644 --- a/src/bindings/cpp/hammer.hxx +++ b/src/bindings/cpp/hammer.hxx @@ -34,7 +34,7 @@ namespace hammer { public: typedef uint64_t result_type; UintResult(const uint64_t res) : _uint(res) { } - const result_type result(); + result_type result(); private: UintResult() { } result_type _uint; @@ -44,7 +44,7 @@ namespace hammer { public: typedef int64_t result_type; IntResult(const int64_t res) : _sint(res) { } - const result_type result(); + result_type result(); private: IntResult() { } result_type _sint; @@ -54,7 +54,7 @@ namespace hammer { public: NullResult() { } typedef void* result_type; - const result_type result() { return NULL; } + result_type result() { return NULL; } }; class SequenceResult : public ParseResult<vector<variant<BytesResult, UintResult, IntResult, NullResult, SequenceResult> > > { @@ -73,7 +73,7 @@ namespace hammer { template<class T> class Optional; class RepeatN; class Ignore; - class Indirect; + template<class T> class Indirect; template<class T> class IntRange; template<typename T> @@ -491,9 +491,11 @@ namespace hammer { } */ Indirect() : _p(0) {} - bind(Parser<T> &p) { + Indirect bind(Parser<T> &p) { this->_parser = h_indirect(); + this->_p = p; h_bind_indirect(this->_parser, p.parser()); + return *this; } private: Parser<T> _p; -- GitLab