Permalink
Browse files

candor: update candor

* buffer: stub out
  • Loading branch information...
1 parent cf775b2 commit fe9d51c55430159a0e119326392e046ca69f6b84 @indutny committed Nov 3, 2012
Showing with 41 additions and 1 deletion.
  1. +1 −0 candor.io.gyp
  2. +1 −1 deps/candor
  3. +37 −0 src/bindings/buffer.h
  4. +2 −0 src/bindings/fs.h
View
@@ -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',
View
@@ -0,0 +1,37 @@
+#ifndef _SRC_BINDINGS_BUFFER_H_
+#define _SRC_BINDINGS_BUFFER_H_
+
+#include <candor.h>
+#include <sys/types.h> // size_t
+#include <stdlib.h> // 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_
View
@@ -20,6 +20,8 @@ class FSWrap : public candor::CWrapper {
uv_fs_t* req_;
candor::Handle<candor::Function> cb_;
+
+ static const int magic;
};
class FS {

0 comments on commit fe9d51c

Please sign in to comment.