Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

fixed: compile error, test/test.js

  • Loading branch information...
commit 643e07d4766585549e7624aeeddd57707744cece 1 parent d23fe8c
@mah0x211 authored
Showing with 162 additions and 160 deletions.
  1. +5 −5 lib/ossp_uuid.js
  2. +5 −5 package.json
  3. +85 −84 src/uuid.cc
  4. +21 −21 test/test.js
  5. +46 −45 wscript
View
10 lib/ossp_uuid.js
@@ -15,9 +15,9 @@ module.exports.v4 = (1 << 2); /* DCE 1.1 v4 UUID */
module.exports.v5 = (1 << 3); /* DCE 1.1 v5 UUID */
// module.exports.MC = (1 << 4); /* enforce multi-cast MAC address */
module.exports.ns = {
- nil: "nil", /* 00000000-0000-0000-0000-000000000000 ("Nil UUID") */
- dns: "ns:DNS", /* 6ba7b810-9dad-11d1-80b4-00c04fd430c8 (see RFC 4122) */
- url: "ns:URL", /* 6ba7b811-9dad-11d1-80b4-00c04fd430c8 (see RFC 4122) */
- oid: "ns:OID", /* 6ba7b812-9dad-11d1-80b4-00c04fd430c8 (see RFC 4122) */
- x500: "ns:X500" /* 6ba7b814-9dad-11d1-80b4-00c04fd430c8 (see RFC 4122) */
+ nil: "nil", /* 00000000-0000-0000-0000-000000000000 ("Nil UUID") */
+ dns: "ns:DNS", /* 6ba7b810-9dad-11d1-80b4-00c04fd430c8 (see RFC 4122) */
+ url: "ns:URL", /* 6ba7b811-9dad-11d1-80b4-00c04fd430c8 (see RFC 4122) */
+ oid: "ns:OID", /* 6ba7b812-9dad-11d1-80b4-00c04fd430c8 (see RFC 4122) */
+ x500: "ns:X500" /* 6ba7b814-9dad-11d1-80b4-00c04fd430c8 (see RFC 4122) */
};
View
10 package.json
@@ -2,12 +2,12 @@
"name" : "ossp-uuid",
"keywords": [
"ossp",
- "uuid",
- "Universally Unique Identifier"
+ "uuid",
+ "Universally Unique Identifier"
],
"description": "OSSP uuid bindings for node.js",
"homepage": "http://github.com/mah0x211/node-ossp-uuid",
- "version" : "0.0.4",
+ "version" : "0.0.5",
"main" : "./lib/ossp_uuid",
"directories" : {
"lib" : "./lib"
@@ -16,12 +16,12 @@
"install" : "./install.sh"
},
"engines" : {
- "node" : ">= 0.3.7"
+ "node" : ">= 0.4.7"
},
"maintainers": [
{
"name": "Masatoshi Teruya",
- "email": "mah0x211@gmail",
+ "email": "mah0x211@gmail.com",
"web": "http://kontext.jp/"
}
],
View
169 src/uuid.cc
@@ -1,6 +1,7 @@
#include <node.h>
#include <node_buffer.h>
+#include <stdlib.h>
#include <stdio.h>
#include "uuid.h"
@@ -10,99 +11,99 @@ using namespace node;
Handle<Value> version( const Arguments &args )
{
- HandleScope scope;
- return scope.Close( Uint32::New( uuid_version() ) );
+ HandleScope scope;
+ return scope.Close( Uint32::New( uuid_version() ) );
}
Handle<Value> generate( const Arguments &args )
{
- HandleScope scope;
- Handle<Value> retval;
- uuid_t *uid = NULL;
- uuid_rc_t rc = uuid_create( &uid );
- char *errstr = NULL;
+ HandleScope scope;
+ Handle<Value> retval;
+ uuid_t *uid = NULL;
+ uuid_rc_t rc = uuid_create( &uid );
+ char *errstr = NULL;
- if( rc != UUID_RC_OK ){
- asprintf( &errstr, "failed to uuid_create: %s", uuid_error( rc ) );
- }
- else
- {
- int nargs = args.Length();
- uuid_fmt_t fmt = UUID_FMT_STR;
- int vers = UUID_MAKE_V4;
-
- if( nargs > 0 ){
- fmt = (uuid_fmt_t)args[0]->IntegerValue();
- }
- if( nargs > 1 ){
- vers = args[1]->IntegerValue();
- }
-
- if( vers == UUID_MAKE_V3 || vers == UUID_MAKE_V5 )
- {
- uuid_t *uid_ns = NULL;
- String::Utf8Value ns ( args[2]->ToString() );
- String::Utf8Value name ( args[3]->ToString() );
-
- if( ( rc = uuid_create( &uid_ns ) ) != UUID_RC_OK ){
- asprintf( &errstr, "failed to uuid_create: %s", uuid_error( rc ) );
- }
- else
- {
- if( ( rc = uuid_load( uid_ns, *ns ) ) != UUID_RC_OK ){
- asprintf( &errstr, "failed to uuid_load( namespace:%s ): %s", *ns, uuid_error( rc ) );
- }
- else if( ( rc = uuid_make( uid, vers, uid_ns, *name ) ) != UUID_RC_OK ){
- asprintf( &errstr, "failed to uuid_make( version:%d, name:%s ): %s", vers, *name, uuid_error( rc ) );
- }
- uuid_destroy( uid_ns );
- }
- }
- else if( ( rc = uuid_make( uid, vers ) ) != UUID_RC_OK ){
- asprintf( &errstr, "failed to uuid_make( version:%d ): %s", vers, uuid_error( rc ) );
- }
-
- if( rc == UUID_RC_OK )
- {
- void *gen = NULL;
- size_t len = 0;
-
- if( ( rc = uuid_export( uid, fmt, &gen, &len ) ) != UUID_RC_OK ){
- asprintf( &errstr, "failed to uuid_export( format:%d ): %s", fmt, uuid_error( rc ) );
- }
- else
- {
- if( fmt == UUID_FMT_BIN ){
- Buffer *retbuf = Buffer::New( len );
- memcpy( Buffer::Data( retbuf ), gen, len );
- retval = retbuf->handle_;
- }
- else if( fmt == UUID_FMT_SIV ){
- len = strlen( (char*)gen );
- retval = Encode( gen, len, UTF8 );
- }
- else{
- retval = Encode( gen, len, UTF8 );
- }
- free( gen );
- }
- }
- uuid_destroy( uid );
- }
-
- if( errstr ){
- retval = ThrowException( Exception::Error( String::New( uuid_error( rc ) ) ) );
- free( errstr );
- }
-
- return scope.Close( retval );
+ if( rc != UUID_RC_OK ){
+ asprintf( &errstr, "failed to uuid_create: %s", uuid_error( rc ) );
+ }
+ else
+ {
+ int nargs = args.Length();
+ uuid_fmt_t fmt = UUID_FMT_STR;
+ int vers = UUID_MAKE_V4;
+
+ if( nargs > 0 ){
+ fmt = (uuid_fmt_t)args[0]->IntegerValue();
+ }
+ if( nargs > 1 ){
+ vers = args[1]->IntegerValue();
+ }
+
+ if( vers == UUID_MAKE_V3 || vers == UUID_MAKE_V5 )
+ {
+ uuid_t *uid_ns = NULL;
+ String::Utf8Value ns ( args[2]->ToString() );
+ String::Utf8Value name ( args[3]->ToString() );
+
+ if( ( rc = uuid_create( &uid_ns ) ) != UUID_RC_OK ){
+ asprintf( &errstr, "failed to uuid_create: %s", uuid_error( rc ) );
+ }
+ else
+ {
+ if( ( rc = uuid_load( uid_ns, *ns ) ) != UUID_RC_OK ){
+ asprintf( &errstr, "failed to uuid_load( namespace:%s ): %s", *ns, uuid_error( rc ) );
+ }
+ else if( ( rc = uuid_make( uid, vers, uid_ns, *name ) ) != UUID_RC_OK ){
+ asprintf( &errstr, "failed to uuid_make( version:%d, name:%s ): %s", vers, *name, uuid_error( rc ) );
+ }
+ uuid_destroy( uid_ns );
+ }
+ }
+ else if( ( rc = uuid_make( uid, vers ) ) != UUID_RC_OK ){
+ asprintf( &errstr, "failed to uuid_make( version:%d ): %s", vers, uuid_error( rc ) );
+ }
+
+ if( rc == UUID_RC_OK )
+ {
+ void *gen = NULL;
+ size_t len = 0;
+
+ if( ( rc = uuid_export( uid, fmt, &gen, &len ) ) != UUID_RC_OK ){
+ asprintf( &errstr, "failed to uuid_export( format:%d ): %s", fmt, uuid_error( rc ) );
+ }
+ else
+ {
+ if( fmt == UUID_FMT_BIN ){
+ Buffer *retbuf = Buffer::New( len );
+ memcpy( Buffer::Data( retbuf ), gen, len );
+ retval = retbuf->handle_;
+ }
+ else if( fmt == UUID_FMT_SIV ){
+ len = strlen( (char*)gen );
+ retval = Encode( gen, len, UTF8 );
+ }
+ else{
+ retval = Encode( gen, len, UTF8 );
+ }
+ free( gen );
+ }
+ }
+ uuid_destroy( uid );
+ }
+
+ if( errstr ){
+ retval = ThrowException( Exception::Error( String::New( uuid_error( rc ) ) ) );
+ free( errstr );
+ }
+
+ return scope.Close( retval );
}
extern "C"
void init( Handle<Object> target )
{
- HandleScope scope;
- NODE_SET_METHOD( target, "version", version );
- NODE_SET_METHOD( target, "generate", generate );
+ HandleScope scope;
+ NODE_SET_METHOD( target, "version", version );
+ NODE_SET_METHOD( target, "generate", generate );
};
View
42 test/test.js
@@ -1,27 +1,27 @@
var sys = require('sys'),
- uuid = require('../lib/ossp_uuid');
+ uuid = require( __dirname + '/../lib/ossp_uuid');
console.log(
- "version 1\n" +
- ' str: ' + uuid.generate( uuid.STR, uuid.V1 ) + "\n" +
- ' siv: ' + uuid.generate( uuid.SIV, uuid.V1 ) + "\n" +
- ' bin: ' + sys.inspect( uuid.generate( uuid.BIN, uuid.V1 ) ) + "\n" +
- " txt: \n" + uuid.generate( uuid.TXT, uuid.V1 ) );
+ "version 1\n" +
+ ' str: ' + uuid.generate( uuid.STR, uuid.v1 ) + "\n" +
+ ' siv: ' + uuid.generate( uuid.SIV, uuid.v1 ) + "\n" +
+ ' bin: ' + sys.inspect( uuid.generate( uuid.BIN, uuid.v1 ) ) + "\n" +
+ " txt: \n" + uuid.generate( uuid.TXT, uuid.v1 ) );
console.log(
- "version 3\n" +
- ' str: ' + uuid.generate( uuid.STR, uuid.V3, uuid.ns.url, 'http://example.com/' ) + "\n" +
- ' siv: ' + uuid.generate( uuid.SIV, uuid.V3, uuid.ns.url, 'http://example.com/' ) + "\n" +
- ' bin: ' + sys.inspect( uuid.generate( uuid.BIN, uuid.V3, uuid.ns.url, 'http://example.com/' ) ) + "\n" +
- ' txt: ' + uuid.generate( uuid.TXT, uuid.V3, uuid.ns.url, 'http://example.com/' ) );
+ "version 3\n" +
+ ' str: ' + uuid.generate( uuid.STR, uuid.v3, uuid.ns.url, 'http://example.com/' ) + "\n" +
+ ' siv: ' + uuid.generate( uuid.SIV, uuid.v3, uuid.ns.url, 'http://example.com/' ) + "\n" +
+ ' bin: ' + sys.inspect( uuid.generate( uuid.BIN, uuid.v3, uuid.ns.url, 'http://example.com/' ) ) + "\n" +
+ ' txt: ' + uuid.generate( uuid.TXT, uuid.v3, uuid.ns.url, 'http://example.com/' ) );
console.log(
- "version 4\n" +
- ' str: ' + uuid.generate( uuid.STR, uuid.V4 ) + "\n" +
- ' siv: ' + uuid.generate( uuid.SIV, uuid.V4 ) + "\n" +
- ' bin: ' + sys.inspect( uuid.generate( uuid.BIN, uuid.V4 ) ) + "\n" +
- " txt: \n" + uuid.generate( uuid.TXT, uuid.V4 ) );
+ "version 4\n" +
+ ' str: ' + uuid.generate( uuid.STR, uuid.v4 ) + "\n" +
+ ' siv: ' + uuid.generate( uuid.SIV, uuid.v4 ) + "\n" +
+ ' bin: ' + sys.inspect( uuid.generate( uuid.BIN, uuid.v4 ) ) + "\n" +
+ " txt: \n" + uuid.generate( uuid.TXT, uuid.v4 ) );
console.log(
- "version 5\n" +
- ' str: ' + uuid.generate( uuid.STR, uuid.V5, uuid.ns.url, 'http://example.com/' ) + "\n" +
- ' siv: ' + uuid.generate( uuid.SIV, uuid.V5, uuid.ns.url, 'http://example.com/' ) + "\n" +
- ' bin: ' + sys.inspect( uuid.generate( uuid.BIN, uuid.V5, uuid.ns.url, 'http://example.com/' ) ) + "\n" +
- " txt: \n" + uuid.generate( uuid.TXT, uuid.V5, uuid.ns.url, 'http://example.com/' ) );
+ "version 5\n" +
+ ' str: ' + uuid.generate( uuid.STR, uuid.v5, uuid.ns.url, 'http://example.com/' ) + "\n" +
+ ' siv: ' + uuid.generate( uuid.SIV, uuid.v5, uuid.ns.url, 'http://example.com/' ) + "\n" +
+ ' bin: ' + sys.inspect( uuid.generate( uuid.BIN, uuid.v5, uuid.ns.url, 'http://example.com/' ) ) + "\n" +
+ " txt: \n" + uuid.generate( uuid.TXT, uuid.v5, uuid.ns.url, 'http://example.com/' ) );
View
91 wscript
@@ -6,56 +6,57 @@ from os.path import join, dirname, abspath, normpath
srcdir = '.'
blddir = 'build'
-VERSION = '0.0.1'
+VERSION = '0.0.5'
def set_options(opt):
- opt.tool_options('compiler_cxx')
- opt.tool_options('compiler_cc')
- opt.tool_options('misc')
-
- opt.add_option( '--ossp-uuid-includes'
- , action='store'
- , type='string'
- , default=False
- , help='Directory containing libev header files'
- , dest='uuid_includes'
- )
-
- opt.add_option( '--ossp-uuid'
- , action='store'
- , type='string'
- , default=False
- , help='Link to a shared uuid libraries'
- , dest='uuid'
- )
+ opt.tool_options('compiler_cxx')
+ opt.tool_options('compiler_cc')
+ opt.tool_options('misc')
+
+ opt.add_option( '--ossp-uuid-includes'
+ , action='store'
+ , type='string'
+ , default=False
+ , help='Directory containing libev header files'
+ , dest='uuid_includes'
+ )
+
+ opt.add_option( '--ossp-uuid'
+ , action='store'
+ , type='string'
+ , default=False
+ , help='Link to a shared uuid libraries'
+ , dest='uuid'
+ )
def configure(conf):
- conf.check_tool('compiler_cxx')
- if not conf.env.CXX: conf.fatal('c++ compiler not found')
- conf.check_tool('compiler_cc')
- if not conf.env.CC: conf.fatal('c compiler not found')
- conf.check_tool('node_addon')
-
- o = Options.options
-
- if o.uuid_includes:
- conf.env.append_value("CPPFLAGS", '-I%s' % o.uuid_includes)
-
- if o.uuid:
- conf.env.append_value("LINKFLAGS", '-L%s' % o.uud)
-
- # print conf.env
-
- # check ossp-uuid libs
- conf.check_cc( lib='uuid', mandatory=True )
+ conf.check_tool('compiler_cxx')
+ if not conf.env.CXX: conf.fatal('c++ compiler not found')
+ conf.check_tool('compiler_cc')
+ if not conf.env.CC: conf.fatal('c compiler not found')
+ conf.check_tool('node_addon')
+
+ o = Options.options
+
+ if o.uuid_includes:
+ conf.env.append_value("CPPFLAGS", '-I%s' % o.uuid_includes)
+
+ if o.uuid:
+ conf.env.append_value("LDFLAGS", '-L%s' % o.uud)
+ # conf.env.append_value("LINKFLAGS", '-L%s' % o.uud)
+
+ # print conf.env
+
+ # check ossp-uuid libs
+ conf.check_cc( lib='uuid', mandatory=True )
def build(bld):
- print 'build'
- obj = bld.new_task_gen('cxx', 'shlib', 'node_addon')
- obj.target = 'uuid_binding'
- obj.source = './src/uuid.cc'
- obj.includes = ['.']
- obj.lib = ['uuid']
+ print 'build'
+ obj = bld.new_task_gen('cxx', 'shlib', 'node_addon')
+ obj.target = 'uuid_binding'
+ obj.source = './src/uuid.cc'
+ obj.includes = ['.']
+ obj.lib = ['uuid']
def shutdown(ctx):
- pass
+ pass
Please sign in to comment.
Something went wrong with that request. Please try again.