5 #include <node_object_wrap.h>
11 class Binary : public ObjectWrap {
14 uint32_t number_of_bytes;
18 Binary(uint32_t sub_type, uint32_t number_of_bytes, uint32_t index, char *data);
22 static inline bool HasInstance(Handle<Value> val) {
23 if (!val->IsObject()) return false;
24 Local<Object> obj = val->ToObject();
25 return constructor_template->HasInstance(obj);
28 // Functions available from V8
29 static void Initialize(Handle<Object> target);
30 static Handle<Value> ToString(const Arguments &args);
31 static Handle<Value> Inspect(const Arguments &args);
32 static Handle<Value> Data(const Arguments &args);
33 static Handle<Value> Length(const Arguments &args);
34 static Handle<Value> Put(const Arguments &args);
35 static Handle<Value> Write(const Arguments &args);
36 static Handle<Value> Read(const Arguments &args);
39 * Writes this binary data into node Buffer passed as first js arg.
40 * Optional second js arg: internal data offset of this binary (Integer)
41 * Up to Min(Buffer.length, Binary.length - offset) bytes will be writen into buffer.
42 * Return number of bytes actually written into buffer.
44 static Handle<Value> ReadInto(const Arguments &args);
46 // Constructor used for creating new Long objects from C++
47 static Persistent<FunctionTemplate> constructor_template;
49 // Getter and Setter for object values
50 static Handle<Value> SubtypeGetter(Local<String> property, const AccessorInfo& info);
51 static void SubtypeSetter(Local<String> property, Local<Value> value, const AccessorInfo& info);
54 static Handle<Value> New(const Arguments &args);