Skip to content

Commit

Permalink
style: use objclean
Browse files Browse the repository at this point in the history
  • Loading branch information
srijs committed Feb 19, 2014
1 parent dd9291f commit ea6cd5c
Show file tree
Hide file tree
Showing 8 changed files with 110 additions and 32 deletions.
19 changes: 19 additions & 0 deletions Nodelike.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@
B572DDA418B4EB7D005E6403 /* test-timers-uncaught-exception.js in Resources */ = {isa = PBXBuildFile; fileRef = B5FD81351899AD13007FB460 /* test-timers-uncaught-exception.js */; };
B572DDA518B4EB7D005E6403 /* test-timers-unref.js in Resources */ = {isa = PBXBuildFile; fileRef = B5FD81361899AD13007FB460 /* test-timers-unref.js */; };
B572DDA618B4EB7D005E6403 /* test-timers-zero-timeout.js in Resources */ = {isa = PBXBuildFile; fileRef = B5FD81371899AD13007FB460 /* test-timers-zero-timeout.js */; };
B572DDA918B4F6E3005E6403 /* StyleSettings.plist in Resources */ = {isa = PBXBuildFile; fileRef = B572DDA818B4F6E3005E6403 /* StyleSettings.plist */; };
B578842418944F2000EA1A81 /* NLBuffer.m in Sources */ = {isa = PBXBuildFile; fileRef = B578842318944F2000EA1A81 /* NLBuffer.m */; };
B578842718945E9900EA1A81 /* NLNatives.m in Sources */ = {isa = PBXBuildFile; fileRef = B578842618945E9900EA1A81 /* NLNatives.m */; };
B599FF2C185A7ED000057DD6 /* NLTCP.m in Sources */ = {isa = PBXBuildFile; fileRef = B599FF2B185A7ED000057DD6 /* NLTCP.m */; };
Expand Down Expand Up @@ -237,6 +238,7 @@
B572DD7018B4E92A005E6403 /* vm.js */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.javascript; path = vm.js; sourceTree = "<group>"; };
B572DD7118B4E92A005E6403 /* zlib.js */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.javascript; path = zlib.js; sourceTree = "<group>"; };
B572DD9B18B4EB15005E6403 /* nodelike.js */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.javascript; name = nodelike.js; path = lib/nodelike.js; sourceTree = "<group>"; };
B572DDA818B4F6E3005E6403 /* StyleSettings.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = StyleSettings.plist; sourceTree = "<group>"; };
B5741C851899CDBA0055EF30 /* test-common.js */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.javascript; path = "test-common.js"; sourceTree = "<group>"; };
B578842318944F2000EA1A81 /* NLBuffer.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = NLBuffer.m; sourceTree = "<group>"; };
B578842518945E9900EA1A81 /* NLNatives.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = NLNatives.h; sourceTree = "<group>"; };
Expand Down Expand Up @@ -520,6 +522,7 @@
B541731C1894341600B6636B /* Nodelike Tests */,
B5B44641180AB78E009ADEF9 /* Frameworks */,
B5B44640180AB78E009ADEF9 /* Products */,
B572DDA818B4F6E3005E6403 /* StyleSettings.plist */,
);
sourceTree = "<group>";
};
Expand Down Expand Up @@ -618,6 +621,7 @@
B59EA08B180CB587005BF5C1 /* Frameworks */,
B59EA0BE180CB677005BF5C1 /* Resources */,
B572DD4718B4E6BA005E6403 /* Retrieve Native Modules */,
B572DDAC18B4F7CF005E6403 /* Objective-Clean Run Script */,
);
buildRules = (
);
Expand Down Expand Up @@ -728,6 +732,7 @@
isa = PBXResourcesBuildPhase;
buildActionMask = 2147483647;
files = (
B572DDA918B4F6E3005E6403 /* StyleSettings.plist in Resources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Expand Down Expand Up @@ -762,6 +767,20 @@
shellPath = /bin/sh;
shellScript = "curl https://registry.npmjs.org/node-natives/-/node-natives-0.10.25.tgz | tar -xf -";
};
B572DDAC18B4F7CF005E6403 /* Objective-Clean Run Script */ = {
isa = PBXShellScriptBuildPhase;
buildActionMask = 2147483647;
files = (
);
inputPaths = (
);
name = "Objective-Clean Run Script";
outputPaths = (
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/bash;
shellScript = "if [[ -z ${SKIP_OBJCLEAN} || ${SKIP_OBJCLEAN} != 1 ]]; then\nif [[ -d \"${LOCAL_APPS_DIR}/Objective-Clean.app\" ]]; then\n\"${LOCAL_APPS_DIR}\"/Objective-Clean.app/Contents/Resources/ObjClean.app/Contents/MacOS/ObjClean \"${SRCROOT}\"?NL\nelse\necho \"warning: You have to install and set up Objective-Clean to use its features!\"\nfi\nfi";
};
/* End PBXShellScriptBuildPhase section */

/* Begin PBXSourcesBuildPhase section */
Expand Down
9 changes: 5 additions & 4 deletions Nodelike/NLCares.m
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,11 @@
static int isIP(const char *ip) {
struct in6_addr address_buffer;
int rc = 0;
if (uv_inet_pton(AF_INET, ip, &address_buffer) == 0)
if (uv_inet_pton(AF_INET, ip, &address_buffer) == 0) {
rc = 4;
else if (uv_inet_pton(AF_INET6, ip, &address_buffer) == 0)
} else if (uv_inet_pton(AF_INET6, ip, &address_buffer) == 0) {
rc = 6;
}
return rc;
}

Expand Down Expand Up @@ -75,8 +76,8 @@ + (NSNumber *)getAddrInfo:(JSValue *)obj hostname:(NSString *)hostname family:(N

}

static void afterGetAddrInfo(uv_getaddrinfo_t* req, int status, struct addrinfo* res) {
struct getaddrinfoWrap* wrap = req->data;
static void afterGetAddrInfo(uv_getaddrinfo_t *req, int status, struct addrinfo *res) {
struct getaddrinfoWrap *wrap = req->data;
JSValue *object = CFBridgingRelease(wrap->value);

if (status == 0) {
Expand Down
2 changes: 1 addition & 1 deletion Nodelike/NLContext.m
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ + (void)attachToContext:(JSContext *)context {
kill(pid.intValue, sig.intValue);
};

process[@"nextTick"] = ^(JSValue * cb) {
process[@"nextTick"] = ^(JSValue *cb) {
dispatch_async(dispatch_get_main_queue(), ^(void) {
[cb callWithArguments:@[]];
});
Expand Down
18 changes: 9 additions & 9 deletions Nodelike/NLHTTPParser.m
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ @implementation NLHTTPParser {
bool got_exception_;
JSValue *current_buffer_;
size_t current_buffer_len_;
char* current_buffer_data_;
char *current_buffer_data_;
struct http_parser_settings settings;
}

Expand Down Expand Up @@ -198,27 +198,27 @@ - (void)flush {
have_flushed_ = true;
}

static int on_message_begin (http_parser* p) {
static int on_message_begin (http_parser *p) {
NLHTTPParser *parser = (__bridge NLHTTPParser *)(p->data);
parser->num_fields_ = parser->num_values_ = 0;
[parser->url_ setLength:0];
[parser->status_message_ setLength:0];
return 0;
}

static int on_url (http_parser* p, const char* at, size_t length) {
static int on_url (http_parser *p, const char *at, size_t length) {
NLHTTPParser *parser = (__bridge NLHTTPParser *)(p->data);
[parser->url_ appendBytes:at length:length];
return 0;
}

static int on_status (http_parser* p, const char* at, size_t length) {
static int on_status (http_parser *p, const char *at, size_t length) {
NLHTTPParser *parser = (__bridge NLHTTPParser *)(p->data);
[parser->status_message_ appendBytes:at length:length];
return 0;
}

static int on_header_field (http_parser* p, const char* at, size_t length) {
static int on_header_field (http_parser *p, const char *at, size_t length) {
NLHTTPParser *parser = (__bridge NLHTTPParser *)(p->data);
if (parser->num_fields_ == parser->num_values_) {
parser->num_fields_++;
Expand All @@ -233,7 +233,7 @@ static int on_header_field (http_parser* p, const char* at, size_t length) {
return 0;
}

static int on_header_value (http_parser* p, const char* at, size_t length) {
static int on_header_value (http_parser *p, const char *at, size_t length) {
NLHTTPParser *parser = (__bridge NLHTTPParser *)(p->data);
if (parser->num_values_ != parser->num_fields_) {
// start of new header value
Expand All @@ -244,7 +244,7 @@ static int on_header_value (http_parser* p, const char* at, size_t length) {
return 0;
}

static int on_headers_complete (http_parser* p) {
static int on_headers_complete (http_parser *p) {
NLHTTPParser *parser = (__bridge NLHTTPParser *)(p->data);

JSContext *ctx = JSContext.currentContext;
Expand Down Expand Up @@ -303,7 +303,7 @@ static int on_headers_complete (http_parser* p) {

}

static int on_body (http_parser* p, const char* at, size_t length) {
static int on_body (http_parser *p, const char *at, size_t length) {
NLHTTPParser *parser = (__bridge NLHTTPParser *)(p->data);

JSContext *ctx = JSContext.currentContext;
Expand Down Expand Up @@ -333,7 +333,7 @@ static int on_body (http_parser* p, const char* at, size_t length) {
return 0;
}

static int on_message_complete (http_parser* p) {
static int on_message_complete (http_parser *p) {
NLHTTPParser *parser = (__bridge NLHTTPParser *)(p->data);

JSContext *ctx = JSContext.currentContext;
Expand Down
12 changes: 6 additions & 6 deletions Nodelike/NLStream.m
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ - (NSNumber *)writeObject:(JSValue *)obj withData:(const char *)data ofLength:(s
if (!isNamedPipeIPC(_stream)) {
err = _callbacks->doWrite(writeWrap, &buf, 1, NULL, afterWrite);
} else {
uv_handle_t* send_handle = NULL;
uv_handle_t *send_handle = NULL;
if (sendHandle != nil) {
send_handle = sendHandle.handle;
[obj setValue:sendHandle forProperty:@"handle"];
Expand Down Expand Up @@ -145,7 +145,7 @@ static void onReadCommon(uv_stream_t *handle, ssize_t nread, const uv_buf_t *buf
wrap.callbacks->doRead(handle, nread, buf, pending);
}

static void doAlloc(uv_handle_t* handle, size_t suggested_size, uv_buf_t* buf) {
static void doAlloc(uv_handle_t *handle, size_t suggested_size, uv_buf_t *buf) {
buf->base = malloc(suggested_size);
buf->len = suggested_size;
}
Expand Down Expand Up @@ -194,7 +194,7 @@ static void doRead(uv_stream_t *handle, ssize_t nread, const uv_buf_t *buf, uv_h

}

static int doWrite(struct writeWrap* w, uv_buf_t* bufs, size_t count, uv_stream_t* send_handle, uv_write_cb cb) {
static int doWrite(struct writeWrap *w, uv_buf_t *bufs, size_t count, uv_stream_t *send_handle, uv_write_cb cb) {

NLStream *wrap = (__bridge NLStream *)w->wrap;

Expand Down Expand Up @@ -223,7 +223,7 @@ static void afterWriteCallback(struct writeWrap *w) {
return;
}

static void afterWrite(uv_write_t* req, int status) {
static void afterWrite(uv_write_t *req, int status) {
struct writeWrap *reqWrap = req->data;
NLStream *wrap = (__bridge NLStream *)(reqWrap->wrap);
JSValue *object = (JSValue *)CFBridgingRelease(reqWrap->object);
Expand All @@ -236,12 +236,12 @@ static void afterWrite(uv_write_t* req, int status) {
free(reqWrap);
}

int doShutdown(struct shutdownWrap* w, uv_shutdown_cb cb) {
int doShutdown(struct shutdownWrap *w, uv_shutdown_cb cb) {
NLStream *wrap = (__bridge NLStream *)w->wrap;
return uv_shutdown(&w->req, wrap.stream, cb);
}

void afterShutdown(uv_shutdown_t* req, int status) {
void afterShutdown(uv_shutdown_t *req, int status) {
struct shutdownWrap *shutdownWrap = req->data;
NLStream *wrap = (__bridge NLStream *)(shutdownWrap->wrap);
JSValue *object = (JSValue *)CFBridgingRelease(shutdownWrap->object);
Expand Down
8 changes: 4 additions & 4 deletions Nodelike/NLTCP.m
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ - (NSNumber *)getsockname:(JSValue *)out {
(struct sockaddr *)&address,
&addrlen);
if (err == 0) {
const struct sockaddr* addr = (const struct sockaddr *)&address;
const struct sockaddr *addr = (const struct sockaddr *)&address;
AddressToJS(NLContext.currentContext, addr, out);
}
return [NSNumber numberWithInt:err];
Expand All @@ -55,7 +55,7 @@ - (NSNumber *)getpeername:(JSValue *)out {
(struct sockaddr *)&address,
&addrlen);
if (err == 0) {
const struct sockaddr* addr = (const struct sockaddr *)&address;
const struct sockaddr *addr = (const struct sockaddr *)&address;
AddressToJS(NLContext.currentContext, addr, out);
}
return [NSNumber numberWithInt:err];
Expand Down Expand Up @@ -122,7 +122,7 @@ - (NSNumber *)connect6:(JSValue *)obj address:(longlived NSString *)address port
return [NSNumber numberWithInt:err];
}

static void afterConnect(uv_connect_t* req, int status) {
static void afterConnect(uv_connect_t *req, int status) {

JSValue *connectWrap = CFBridgingRelease(((struct connectWrap *)req->data)->value);
NLStream *wrap = (__bridge NLStream *)(req->handle->data);
Expand Down Expand Up @@ -159,7 +159,7 @@ static void onConnection(uv_stream_t *handle, int status) {

}

static JSValue *AddressToJS (JSContext *context, const struct sockaddr* addr, JSValue *info) {
static JSValue *AddressToJS (JSContext *context, const struct sockaddr *addr, JSValue *info) {

char ip[INET6_ADDRSTRLEN];
const struct sockaddr_in *a4;
Expand Down
16 changes: 8 additions & 8 deletions Nodelike/NLUDP.m
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ - (NSNumber *)getsockname:(JSValue *)out {
(struct sockaddr *)&address,
&addrlen);
if (err == 0) {
const struct sockaddr* addr = (const struct sockaddr *)&address;
const struct sockaddr *addr = (const struct sockaddr *)&address;
AddressToJS(NLContext.currentContext, addr, out);
}
return [NSNumber numberWithInt:err];
Expand Down Expand Up @@ -90,7 +90,7 @@ - (NSNumber *)setMulticastLoopback:(NSNumber *)flag {
}

- (NSNumber *)addMembership:(longlived NSString *)address iface:(longlived JSValue *)iface {
const char* iface_cstr = NULL;
const char *iface_cstr = NULL;
if (!iface.isUndefined && !iface.isNull) {
iface_cstr = iface.toString.UTF8String;
}
Expand All @@ -99,7 +99,7 @@ - (NSNumber *)addMembership:(longlived NSString *)address iface:(longlived JSVal
}

- (NSNumber *)dropMembership:(longlived NSString *)address iface:(longlived JSValue *)iface {
const char* iface_cstr = NULL;
const char *iface_cstr = NULL;
if (!iface.isUndefined && !iface.isNull) {
iface_cstr = iface.toString.UTF8String;
}
Expand Down Expand Up @@ -167,7 +167,7 @@ - (NSNumber *)recvStop {
return [NSNumber numberWithInt:err];
}

static void onSend (uv_udp_send_t* req, int status) {
static void onSend (uv_udp_send_t *req, int status) {
struct sendWrap *sendWrap = req->data;
JSValue *value = (__bridge JSValue *)(sendWrap->value);
if (sendWrap->hasCallback) {
Expand All @@ -176,12 +176,12 @@ static void onSend (uv_udp_send_t* req, int status) {
free(sendWrap);
}

static void onAlloc (uv_handle_t* handle, size_t suggested_size, uv_buf_t* buf) {
static void onAlloc (uv_handle_t *handle, size_t suggested_size, uv_buf_t *buf) {
buf->base = malloc(suggested_size);
buf->len = suggested_size;
}

static void onRecv (uv_udp_t* handle, ssize_t nread, const uv_buf_t* buf, const struct sockaddr* addr, unsigned int flags) {
static void onRecv (uv_udp_t *handle, ssize_t nread, const uv_buf_t *buf, const struct sockaddr *addr, unsigned int flags) {
if (nread == 0) {
if (buf->base != NULL)
free(buf->base);
Expand All @@ -200,15 +200,15 @@ static void onRecv (uv_udp_t* handle, ssize_t nread, const uv_buf_t* buf, const
return;
}

char* base = realloc(buf->base, nread);
char *base = realloc(buf->base, nread);

args[2] = [NLBuffer useData:base ofLength:nread inContext:wrapObj.context];
args[3] = AddressToJS(wrap.context, addr, NULL);
[wrapObj invokeMethod:@"onmessage" withArguments:args];

}

static JSValue *AddressToJS (JSContext *context, const struct sockaddr* addr, JSValue *info) {
static JSValue *AddressToJS (JSContext *context, const struct sockaddr *addr, JSValue *info) {

char ip[INET6_ADDRSTRLEN];
const struct sockaddr_in *a4;
Expand Down
58 changes: 58 additions & 0 deletions StyleSettings.plist
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>kRequireSpaceAfterColon</key>
<false/>
<key>kRequireOpenBraceOnMethodSignatureLine</key>
<true/>
<key>kRequireOpenBraceOnConditionalStatementLine</key>
<true/>
<key>kRequireSpaceBeforeOpeningBrace</key>
<true/>
<key>kMethodParameterPrefix</key>
<string></string>
<key>kElseFormatRule</key>
<integer>0</integer>
<key>kEqualSpacingRule</key>
<integer>1</integer>
<key>kRequireSpaceAfterConditionalStatement</key>
<true/>
<key>kMathSpacingRule</key>
<integer>1</integer>
<key>kElseIfFormatRule</key>
<integer>0</integer>
<key>kInterfaceColonSpacingRule</key>
<integer>1</integer>
<key>kRequireSpaceAfterCommas</key>
<true/>
<key>kRequireSpaceBeforeCaseColons</key>
<false/>
<key>kSignatureAsteriskSpacingRule</key>
<integer>2</integer>
<key>kViolationsShouldBeErrors</key>
<false/>
<key>kRequireSpaceAfterParameterType</key>
<false/>
<key>kStaticVariableAsteriskSpacingRule</key>
<integer>2</integer>
<key>kComparisonSpacingRule</key>
<integer>1</integer>
<key>kRequireSpaceAfterPropertyDeclaration</key>
<true/>
<key>kRequireSpaceAfterMethodType</key>
<true/>
<key>kRequireSpaceAfterReturnType</key>
<false/>
<key>kRequireSpaceAfterPropertyTypeDeclaration</key>
<true/>
<key>kAsteriskSpacingRule</key>
<integer>2</integer>
<key>kRequireSpaceBeforeProtocolDeclarations</key>
<true/>
<key>kRequireSpaceBetweenTernaryOperators</key>
<true/>
<key>kRequireSpaceBeforeParameter</key>
<false/>
</dict>
</plist>

0 comments on commit ea6cd5c

Please sign in to comment.