Browse Source

buffer: proper API export for Windows

So that Windows users can properly include smalloc and node_buffer,
NODE_EXTERN was added to the headers that export this functionality.
v0.11.3-release
Trevor Norris 12 years ago
parent
commit
7373c4ddb7
  1. 29
      src/node_buffer.h
  2. 27
      src/smalloc.h

29
src/node_buffer.h

@ -19,6 +19,7 @@
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
// USE OR OTHER DEALINGS IN THE SOFTWARE.
#include "node.h"
#include "smalloc.h"
#include "v8.h"
@ -31,29 +32,29 @@ namespace Buffer {
static const unsigned int kMaxLength = smalloc::kMaxLength;
bool HasInstance(v8::Handle<v8::Value> val);
bool HasInstance(v8::Handle<v8::Object> val);
char* Data(v8::Handle<v8::Value> val);
char* Data(v8::Handle<v8::Object> val);
size_t Length(v8::Handle<v8::Value> val);
size_t Length(v8::Handle<v8::Object> val);
NODE_EXTERN bool HasInstance(v8::Handle<v8::Value> val);
NODE_EXTERN bool HasInstance(v8::Handle<v8::Object> val);
NODE_EXTERN char* Data(v8::Handle<v8::Value> val);
NODE_EXTERN char* Data(v8::Handle<v8::Object> val);
NODE_EXTERN size_t Length(v8::Handle<v8::Value> val);
NODE_EXTERN size_t Length(v8::Handle<v8::Object> val);
// public constructor
v8::Local<v8::Object> New(size_t length);
NODE_EXTERN v8::Local<v8::Object> New(size_t length);
// public constructor from string
v8::Local<v8::Object> New(v8::Handle<v8::String> string);
NODE_EXTERN v8::Local<v8::Object> New(v8::Handle<v8::String> string);
// public constructor - data is copied
// TODO(trevnorris): should be something like Copy()
v8::Local<v8::Object> New(const char* data, size_t len);
NODE_EXTERN v8::Local<v8::Object> New(const char* data, size_t len);
// public constructor - data is used, callback is passed data on object gc
v8::Local<v8::Object> New(char* data,
size_t length,
smalloc::FreeCallback callback,
void* hint);
NODE_EXTERN v8::Local<v8::Object> New(char* data,
size_t length,
smalloc::FreeCallback callback,
void* hint);
// public constructor - data is used.
// TODO(trevnorris): should be New() for consistency
v8::Local<v8::Object> Use(char* data, uint32_t len);
NODE_EXTERN v8::Local<v8::Object> Use(char* data, uint32_t len);
} // namespace Buffer

27
src/smalloc.h

@ -22,6 +22,7 @@
#ifndef NODE_SMALLOC_H_
#define NODE_SMALLOC_H_
#include "node.h"
#include "v8.h"
namespace node {
@ -38,29 +39,29 @@ namespace smalloc {
// mirrors deps/v8/src/objects.h
static const unsigned int kMaxLength = 0x3fffffff;
typedef void (*FreeCallback)(char* data, void* hint);
NODE_EXTERN typedef void (*FreeCallback)(char* data, void* hint);
/**
* Allocate external memory and set to passed object. If data is passed then
* will use that instead of allocating new.
*/
void Alloc(v8::Handle<v8::Object> obj, size_t length);
void Alloc(v8::Handle<v8::Object> obj, char* data, size_t length);
void Alloc(v8::Handle<v8::Object> obj,
size_t length,
FreeCallback fn,
void* hint);
void Alloc(v8::Handle<v8::Object> obj,
char* data,
size_t length,
FreeCallback fn,
void* hint);
NODE_EXTERN void Alloc(v8::Handle<v8::Object> obj, size_t length);
NODE_EXTERN void Alloc(v8::Handle<v8::Object> obj, char* data, size_t length);
NODE_EXTERN void Alloc(v8::Handle<v8::Object> obj,
size_t length,
FreeCallback fn,
void* hint);
NODE_EXTERN void Alloc(v8::Handle<v8::Object> obj,
char* data,
size_t length,
FreeCallback fn,
void* hint);
/**
* Free memory associated with an externally allocated object. If no external
* memory is allocated to the object then nothing will happen.
*/
void AllocDispose(v8::Handle<v8::Object> obj);
NODE_EXTERN void AllocDispose(v8::Handle<v8::Object> obj);
} // namespace smalloc

Loading…
Cancel
Save