From fe9d51c55430159a0e119326392e046ca69f6b84 Mon Sep 17 00:00:00 2001 From: Fedor Indutny Date: Sat, 3 Nov 2012 22:10:46 +0400 Subject: [PATCH] candor: update candor * buffer: stub out --- candor.io.gyp | 1 + deps/candor | 2 +- src/bindings/buffer.h | 37 +++++++++++++++++++++++++++++++++++++ src/bindings/fs.h | 2 ++ 4 files changed, 41 insertions(+), 1 deletion(-) create mode 100644 src/bindings/buffer.h diff --git a/candor.io.gyp b/candor.io.gyp index 9f43edc..529c973 100644 --- a/candor.io.gyp +++ b/candor.io.gyp @@ -29,6 +29,7 @@ 'src/natives.cc', 'src/bindings.cc', 'src/bindings/fs.cc', + 'src/bindings/buffer.cc', '<@(library_files)', '<(SHARED_INTERMEDIATE_DIR)/can_natives.h', diff --git a/deps/candor b/deps/candor index 939677b..0a2b974 160000 --- a/deps/candor +++ b/deps/candor @@ -1 +1 @@ -Subproject commit 939677ba9512adf0a33dce6549b3877e91d586e4 +Subproject commit 0a2b9746723c0a3497be9428f0277316b1d83c62 diff --git a/src/bindings/buffer.h b/src/bindings/buffer.h new file mode 100644 index 0000000..f84fd48 --- /dev/null +++ b/src/bindings/buffer.h @@ -0,0 +1,37 @@ +#ifndef _SRC_BINDINGS_BUFFER_H_ +#define _SRC_BINDINGS_BUFFER_H_ + +#include +#include // size_t +#include // NULL + +namespace can { + +class Buffer : public candor::CWrapper { + public: + Buffer(size_t size) : candor::CWrapper(&magic), size_(size) { + data_ = new char[size]; + } + + ~Buffer() { + delete[] data_; + data_ = NULL; + } + + inline char* data() { return data_; } + inline size_t size() { return size_; } + + static void New(uint32_t argc, candor::Value** argv); + static void Init(candor::Object* target); + + // Magic word + static const int magic; + + protected: + char* data_; + size_t size_; +}; + +} // namespace can + +#endif // _SRC_BINDINGS_BUFFER_H_ diff --git a/src/bindings/fs.h b/src/bindings/fs.h index 2c2e2d1..212ef8e 100644 --- a/src/bindings/fs.h +++ b/src/bindings/fs.h @@ -20,6 +20,8 @@ class FSWrap : public candor::CWrapper { uv_fs_t* req_; candor::Handle cb_; + + static const int magic; }; class FS {