/* Index Offsets {{{ */
size_t CYGetIndex(const CYUTF8String &value) {
if (value.data[0] != '0') {
- char *end;
- size_t index(strtoul(value.data, &end, 10));
- if (value.data + value.size == end)
- return index;
- } else if (value.data[1] == '\0')
+ size_t index(0);
+ for (size_t i(0); i != value.size; ++i) {
+ if (!DigitRange_[value.data[i]])
+ return _not(size_t);
+ index *= 10;
+ index += value.data[i] - '0';
+ }
+ return index;
+ } else if (value.size == 1)
return 0;
- return _not(size_t);
+ else
+ return _not(size_t);
}
size_t CYGetIndex(apr_pool_t *pool, JSContextRef context, JSStringRef value) {
return CYGetIndex(CYPoolUTF8String(pool, context, value));
}
+// XXX: this isn't actually right
bool CYGetOffset(const char *value, ssize_t &index) {
if (value[0] != '0') {
char *end;
}
};
-void Structor_(apr_pool_t *pool, const char *name, const char *types, sig::Type *&type) {
- if (name == NULL)
+void Structor_(apr_pool_t *pool, sig::Type *&type) {
+ if (
+ type->primitive == sig::pointer_P &&
+ type->data.data.type != NULL &&
+ type->data.data.type->primitive == sig::struct_P &&
+ strcmp(type->data.data.type->name, "_objc_class") == 0
+ ) {
+ type->primitive = sig::typename_P;
+ type->data.data.type = NULL;
+ return;
+ }
+
+ if (type->primitive != sig::struct_P || type->name == NULL)
return;
sqlite3_stmt *statement;
" limit 1"
, -1, &statement, NULL));
- _sqlcall(sqlite3_bind_text(statement, 1, name, -1, SQLITE_STATIC));
+ _sqlcall(sqlite3_bind_text(statement, 1, type->name, -1, SQLITE_STATIC));
int mode;
const char *value;
static JSValueRef $cyq(JSContextRef context, JSObjectRef object, JSObjectRef _this, size_t count, const JSValueRef arguments[], JSValueRef *exception) {
CYPool pool;
- const char *name(apr_psprintf(pool, "%s%zu", CYPoolCString(pool, context, arguments[0]), Nonce_++));
+ const char *name(apr_psprintf(pool, "%s%"APR_SIZE_T_FMT"", CYPoolCString(pool, context, arguments[0]), Nonce_++));
return CYCastJSValue(context, name);
}
message_ = apr_pvsprintf(pool_, format, args);
}
+JSValueRef CYCastJSError(JSContextRef context, const char *message) {
+ JSValueRef arguments[1] = {CYCastJSValue(context, message)};
+
+ JSValueRef exception(NULL);
+ JSValueRef value(JSObjectCallAsConstructor(context, Error_, 1, arguments, &exception));
+ CYThrow(context, exception);
+
+ return value;
+}
+
JSValueRef CYPoolError::CastJSValue(JSContextRef context) const {
- return CYCastJSValue(context, message_);
+ return CYCastJSError(context, message_);
}
CYJSError::CYJSError(JSContextRef context, const char *format, ...) {
const char *message(apr_pvsprintf(pool, format, args));
va_end (args);
- JSValueRef arguments[1] = {CYCastJSValue(context, CYJSString(message))};
-
- JSValueRef exception(NULL);
- value_ = JSObjectCallAsConstructor(context, Error_, 1, arguments, &exception);
- CYThrow(context, exception);
+ value_ = CYCastJSError(context, message);
}
JSGlobalContextRef CYGetJSContext() {