diff options
author | jsdelfino <jsdelfino@13f79535-47bb-0310-9956-ffa450edef68> | 2013-01-03 08:10:25 +0000 |
---|---|---|
committer | jsdelfino <jsdelfino@13f79535-47bb-0310-9956-ffa450edef68> | 2013-01-03 08:10:25 +0000 |
commit | 2853156a2bce535bcaa440c37cf872916f76c03b (patch) | |
tree | 8e161033a9bac8274dcaca05940964b91cdb2bfc /sca-cpp/trunk/modules | |
parent | 55607ea78e10832838d52fdb17cbdfe4355c3265 (diff) |
Refactoring, rename isNil to isNull.
git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@1428206 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'sca-cpp/trunk/modules')
43 files changed, 414 insertions, 414 deletions
diff --git a/sca-cpp/trunk/modules/atom/atom.hpp b/sca-cpp/trunk/modules/atom/atom.hpp index 259769e2cb..b6f2788b1e 100644 --- a/sca-cpp/trunk/modules/atom/atom.hpp +++ b/sca-cpp/trunk/modules/atom/atom.hpp @@ -46,22 +46,22 @@ const value entry("entry"); */ const list<value> entryElementValues(const list<value>& e) { const list<value> lt = elementChildren("title", e); - const list<value> t = nilListValue + element + value("title") + (isNil(lt)? value(emptyString) : elementValue(car(lt))); + const list<value> t = nilListValue + element + value("title") + (isNull(lt)? value(emptyString) : elementValue(car(lt))); const list<value> li = elementChildren("id", e); - const list<value> i = nilListValue + element + value("id") + (isNil(li)? value(emptyString) : elementValue(car(li))); + const list<value> i = nilListValue + element + value("id") + (isNull(li)? value(emptyString) : elementValue(car(li))); const list<value> la = elementChildren("author", e); - const list<value> lan = isNil(la)? nilListValue : elementChildren("name", car(la)); - const list<value> lae = isNil(la)? nilListValue : elementChildren("email", car(la)); - const list<value> laa = isNil(lan)? lae : lan; - const list<value> a = isNil(laa)? nilListValue : mklist<value>(nilListValue + element + value("author") + elementValue(car(laa))); + const list<value> lan = isNull(la)? nilListValue : elementChildren("name", car(la)); + const list<value> lae = isNull(la)? nilListValue : elementChildren("email", car(la)); + const list<value> laa = isNull(lan)? lae : lan; + const list<value> a = isNull(laa)? nilListValue : mklist<value>(nilListValue + element + value("author") + elementValue(car(laa))); const list<value> lu = elementChildren("updated", e); - const list<value> u = isNil(lu)? nilListValue : mklist<value>(nilListValue + element + value("updated") + elementValue(car(lu))); + const list<value> u = isNull(lu)? nilListValue : mklist<value>(nilListValue + element + value("updated") + elementValue(car(lu))); const list<value> lc = elementChildren("content", e); - const list<value> c = isNil(lc)? nilListValue : isAttribute(elementValue(car(lc)))? nilListValue : + const list<value> c = isNull(lc)? nilListValue : isAttribute(elementValue(car(lc)))? nilListValue : mklist<value>(nilListValue + element + value("content") + elementValue(car(lc))); return append<value>(append<value>(append<value>(nilListValue + element + entry + value(t) + value(i), a), u), c); @@ -71,7 +71,7 @@ const list<value> entryElementValues(const list<value>& e) { * Convert a list of elements to a list of element values representing ATOM entries. */ const list<value> entriesElementValues(const list<value>& e) { - if (isNil(e)) + if (isNull(e)) return e; return cons<value>(entryElementValues(car(e)), entriesElementValues(cdr(e))); } @@ -99,7 +99,7 @@ const bool isATOMEntry(const list<string>& ls) { */ const failable<list<value> > readATOMEntry(const list<string>& ilist) { const list<value> e = content(xml::readElements(ilist)); - if (isNil(e)) + if (isNull(e)) return mkfailure<list<value> >("Empty entry"); return mklist<value>(entryElementValues(car(e))); } @@ -109,7 +109,7 @@ const failable<list<value> > readATOMEntry(const list<string>& ilist) { */ const failable<list<value> > readATOMFeed(const list<string>& ilist) { const list<value> f = content(xml::readElements(ilist)); - if (isNil(f)) + if (isNull(f)) return mkfailure<list<value> >("Empty feed"); const list<value> t = elementChildren("title", car(f)); const list<value> i = elementChildren("id", car(f)); @@ -136,18 +136,18 @@ const list<value> entryElement(const list<value>& l) { const value title = elementChild("title", l); const value id = elementChild("id", l); const value author = elementChild("author", l); - const bool email = isNil(author)? false : contains(elementValue(author), "@"); + const bool email = isNull(author)? false : contains(elementValue(author), "@"); const value updated = elementChild("updated", l); const value content = elementChild("content", l); - const bool text = isNil(content)? false : elementHasValue(content); + const bool text = isNull(content)? false : elementHasValue(content); return nilListValue + element + entry + (nilListValue + attribute + "xmlns" + "http://www.w3.org/2005/Atom") + (nilListValue + element + "title" + (nilListValue + attribute + "type" + "text") + elementValue(title)) + (nilListValue + element + "id" + elementValue(id)) - + (isNil(author)? nilListValue : (nilListValue + element + "author" + + + (isNull(author)? nilListValue : (nilListValue + element + "author" + (email? (nilListValue + element + "email" + elementValue(author)) : (nilListValue + element + "name" + elementValue(author))))) - + (isNil(updated)? nilListValue : (nilListValue + element + "updated" + elementValue(updated))) - + (isNil(content)? + + (isNull(updated)? nilListValue : (nilListValue + element + "updated" + elementValue(updated))) + + (isNull(content)? nilListValue : append<value>(nilListValue + element + "content" + (nilListValue + attribute + "type" + (text? "text" : "application/xml")), text? mklist<value>(elementValue(content)) : contentElementChildren(content))) @@ -158,7 +158,7 @@ const list<value> entryElement(const list<value>& l) { * Convert a list of element values representing ATOM entries to a list of elements. */ const list<value> entriesElements(const list<value>& l) { - if (isNil(l)) + if (isNull(l)) return l; return cons<value>(entryElement(car(l)), entriesElements(cdr(l))); } @@ -167,7 +167,7 @@ const list<value> entriesElements(const list<value>& l) { * Convert a list of element values representing an ATOM entry to an ATOM entry. */ template<typename R> const failable<R> writeATOMEntry(const lambda<const R(const string&, const R)>& reduce, const R& initial, const list<value>& ll) { - const list<value> l = isNil(ll)? ll : (list<value>)car(ll); + const list<value> l = isNull(ll)? ll : (list<value>)car(ll); return xml::writeElements<R>(reduce, initial, mklist<value>(entryElement(l))); } @@ -182,11 +182,11 @@ const failable<list<string> > writeATOMEntry(const list<value>& l) { * Convert a list of element values representing an ATOM feed to an ATOM feed. */ template<typename R> const failable<R> writeATOMFeed(const lambda<const R(const string&, const R)>& reduce, const R& initial, const list<value>& ll) { - const list<value> l = isNil(ll)? ll : (list<value>)car(ll); + const list<value> l = isNull(ll)? ll : (list<value>)car(ll); const list<value> lt = elementChildren("title", l); - const value t = isNil(lt)? value(emptyString) : elementValue(car(lt)); + const value t = isNull(lt)? value(emptyString) : elementValue(car(lt)); const list<value> li = elementChildren("id", l); - const value i = isNil(li)? value(emptyString) : elementValue(car(li)); + const value i = isNull(li)? value(emptyString) : elementValue(car(li)); const list<value> f = nilListValue + element + feed + (nilListValue + attribute + "xmlns" + "http://www.w3.org/2005/Atom") + (nilListValue + element + "title" + (nilListValue + attribute + "type" + "text") + t) @@ -194,11 +194,11 @@ template<typename R> const failable<R> writeATOMFeed(const lambda<const R(const // Write ATOM entries const list<value> le = elementChildren(entry, l); - if (isNil(le)) + if (isNull(le)) return xml::writeElements<R>(reduce, initial, mklist<value>(f)); // Write a single ATOM entry element with a list of values - if (!isNil(le) && !isNil(car(le)) && isList(car<value>(caddr<value>(car(le))))) { + if (!isNull(le) && !isNull(car(le)) && isList(car<value>(caddr<value>(car(le))))) { const list<value> fe = append(f, entriesElements(caddr<value>(car(le)))); return xml::writeElements<R>(reduce, initial, mklist<value>(fe)); } diff --git a/sca-cpp/trunk/modules/http/http.hpp b/sca-cpp/trunk/modules/http/http.hpp index cd0eb6c04b..04b0d4e490 100644 --- a/sca-cpp/trunk/modules/http/http.hpp +++ b/sca-cpp/trunk/modules/http/http.hpp @@ -367,7 +367,7 @@ public: */ size_t readCallback(void *ptr, size_t size, size_t nmemb, void *data) { CURLReadContext& rcx = *(CURLReadContext*)data; - if (isNil((const list<string>)rcx.ilist)) + if (isNull((const list<string>)rcx.ilist)) return 0; const list<string> f(fragment(rcx.ilist, size * nmemb)); const string s = car(f); @@ -403,7 +403,7 @@ template<typename R> size_t writeCallback(void *ptr, size_t size, size_t nmemb, * a reduce function used to process the response. */ curl_slist* headers(curl_slist* const cl, const list<string>& h) { - if (isNil(h)) + if (isNull(h)) return cl; return headers(curl_slist_append(cl, c_str(string(car(h)))), cdr(h)); } @@ -508,7 +508,7 @@ const failable<value> evalExpr(const value& expr, const string& url, const CURLS * Find and return a header. */ const maybe<string> header(const char* const prefix, const list<string>& h) { - if (isNil(h)) + if (isNull(h)) return maybe<string>(); const string s = car(h); if (find(s, prefix) != 0) @@ -676,7 +676,7 @@ const failable<list<list<string> > > contentRequest(const value& c, unused const // Write in the format requested by the client, if any const list<value> fmt = assoc<value>("format", nilListValue); - if (!isNil(fmt)) { + if (!isNull(fmt)) { if (cadr(fmt) == "scheme") return writeRequest(scheme::writeValue(c), "text/x-scheme; charset=utf-8"); if (cadr(fmt) == "json") @@ -692,26 +692,26 @@ const failable<list<list<string> > > contentRequest(const value& c, unused const } // Write an empty list as a JSON value - if (isNil((list<value>)c)) { + if (isNull((list<value>)c)) { debug(nilListValue, "http::contentRequest::empty"); return writeRequest(json::writeValue(c), "application/json; charset=utf-8"); } // Write content-type / content-list pair - if (isString(car<value>(c)) && !isNil(cdr<value>(c)) && isList(cadr<value>(c))) + if (isString(car<value>(c)) && !isNull(cdr<value>(c)) && isList(cadr<value>(c))) return writeRequest(convertValues<string>(cadr<value>(c)), car<value>(c)); // Write an assoc value as a JSON value - if (isSymbol(car<value>(c)) && !isNil(cdr<value>(c))) { + if (isSymbol(car<value>(c)) && !isNull(cdr<value>(c))) { debug(c, "http::contentRequest::assoc"); return writeRequest(json::writeValue(c), "application/json; charset=utf-8"); } // Write an ATOM feed or entry const list<value> e = valuesToElements(c); - if (isList(car<value>(e)) && !isNil(car<value>(e))) { + if (isList(car<value>(e)) && !isNull(car<value>(e))) { const list<value> el = car<value>(e); - if (isSymbol(car<value>(el)) && car<value>(el) == element && !isNil(cdr<value>(el)) && isSymbol(cadr<value>(el)) && elementHasChildren(el) && !elementHasValue(el)) { + if (isSymbol(car<value>(el)) && car<value>(el) == element && !isNull(cdr<value>(el)) && isSymbol(cadr<value>(el)) && elementHasChildren(el) && !elementHasValue(el)) { if (cadr<value>(el) == atom::feed) return writeRequest(atom::writeATOMFeed(e), "application/atom+xml; charset=utf-8"); if (cadr<value>(el) == atom::entry) @@ -943,14 +943,14 @@ const failable<size_t> recv(char* const c, const size_t l, const CURLSession& cs * Converts a list of key value pairs to a query string. */ ostringstream& queryString(const list<value>& args, ostringstream& os) { - if (isNil(args)) + if (isNull(args)) return os; const list<value> arg = car(args); debug(arg, "http::queryString::arg"); - if (isNil(arg) || isNil(cdr(arg))) + if (isNull(arg) || isNull(cdr(arg))) return queryString(cdr(args), os); os << car(arg) << "=" << c_str(cadr(arg)); - if (!isNil(cdr(args))) + if (!isNull(cdr(args))) os << "&"; return queryString(cdr(args), os); } diff --git a/sca-cpp/trunk/modules/http/httpd.hpp b/sca-cpp/trunk/modules/http/httpd.hpp index 255f0aa31b..bf06ed5d91 100644 --- a/sca-cpp/trunk/modules/http/httpd.hpp +++ b/sca-cpp/trunk/modules/http/httpd.hpp @@ -260,7 +260,7 @@ const string cookie(const request_rec* const r) { * Return the remaining part of a uri after the given path (aka the path info.) */ const list<value> pathInfo(const list<value>& uri, const list<value>& path) { - if (isNil(path)) + if (isNull(path)) return uri; return pathInfo(cdr(uri), cdr(path)); } @@ -347,14 +347,14 @@ const list<value> unescapeArgs(const list<value>& args) { const value queryArg(const string& s) { debug(s, "httpd::queryArg::string"); const list<string> t = tokenize("=", s); - if (isNil(cdr(t))) + if (isNull(cdr(t))) return mklist<value>(c_str(car(t)), emptyString); return mklist<value>(c_str(car(t)), cadr(t)); } const string fixupQueryArgs(const string& a) { const list<string> t = tokenize("?", a); - if (isNil(t) || isNil(cdr(t))) + if (isNull(t) || isNull(cdr(t))) return a; return join("&", t); } @@ -376,7 +376,7 @@ const list<value> queryArgs(const request_rec* const r) { * Converts the args received in a POST to a list of key value pairs. */ const list<value> postArgs(const list<value>& a) { - if (isNil(a)) + if (isNull(a)) return nilListValue; const list<value> l = car(a); return cons<value>(l, postArgs(cdr(a))); diff --git a/sca-cpp/trunk/modules/http/mod-openauth.cpp b/sca-cpp/trunk/modules/http/mod-openauth.cpp index 1b70f27744..3adc488301 100644 --- a/sca-cpp/trunk/modules/http/mod-openauth.cpp +++ b/sca-cpp/trunk/modules/http/mod-openauth.cpp @@ -127,7 +127,7 @@ static apr_status_t (*ap_session_set_fn)(request_rec * r, session_rec * z, const * Run the authnz hooks to authenticate a request. */ const failable<int> checkAuthnzProviders(const string& user, const string& pw, request_rec* const r, const list<AuthnProviderConf>& apcs) { - if(isNil(apcs)) + if(isNull(apcs)) return mkfailure<int>("Authentication failure for: " + user, HTTP_UNAUTHORIZED); const AuthnProviderConf apc = car<AuthnProviderConf>(apcs); if(apc.provider == NULL || !apc.provider->check_password) @@ -145,7 +145,7 @@ const failable<int> checkAuthnz(const string& user, const string& pw, request_re if(substr(user, 0, 1) == "/" && pw == "password") return mkfailure<int>(string("Encountered FakeBasicAuth spoof: ") + user, HTTP_UNAUTHORIZED); - if(isNil((const list<AuthnProviderConf>)dc.apcs)) { + if(isNull((const list<AuthnProviderConf>)dc.apcs)) { const authn_provider* provider = (const authn_provider*)ap_lookup_provider(AUTHN_PROVIDER_GROUP, AUTHN_DEFAULT_PROVIDER, AUTHN_PROVIDER_VERSION); return checkAuthnzProviders(user, pw, r, mklist<AuthnProviderConf>(AuthnProviderConf(AUTHN_DEFAULT_PROVIDER, provider))); } @@ -181,10 +181,10 @@ const failable<value> userInfoFromCookie(const value& sid, const string& realm, const list<value> info = httpd::queryArgs(sid); debug(info, "modopenauth::userInfoFromCookie::info"); const list<value> user = assoc<value>(realm + "-user", info); - if(isNil(user)) + if(isNull(user)) return userInfoFromSession(realm, r); const list<value> pw = assoc<value>(realm + "-pw", info); - if(isNil(pw)) + if(isNull(pw)) return mkfailure<value>("Couldn't retrieve password", HTTP_UNAUTHORIZED); return value(mklist<value>(mklist<value>("realm", realm), mklist<value>("id", cadr(user)), mklist<value>("password", cadr(pw)))); } @@ -217,12 +217,12 @@ const failable<int> authenticated(const list<value>& info, request_rec* const r) // Store user info in the request const list<value> realm = assoc<value>("realm", info); - if(isNil(realm) || isNil(cdr(realm))) + if(isNull(realm) || isNull(cdr(realm))) return mkfailure<int>("Couldn't retrieve realm", HTTP_UNAUTHORIZED); apr_table_set(r->subprocess_env, apr_pstrdup(r->pool, "REALM"), apr_pstrdup(r->pool, c_str(cadr(realm)))); const list<value> id = assoc<value>("id", info); - if(isNil(id) || isNil(cdr(id))) + if(isNull(id) || isNull(cdr(id))) return mkfailure<int>("Couldn't retrieve user id", HTTP_UNAUTHORIZED); r->user = apr_pstrdup(r->pool, c_str(cadr(id))); @@ -313,7 +313,7 @@ static int checkAuthn(request_rec* const r) { } // Decline if the request is for another authentication provider - if(!isNil(assoc<value>("openid_identifier", args))) + if(!isNull(assoc<value>("openid_identifier", args))) return DECLINED; // Redirect to the login page, unless we have a session id from another module diff --git a/sca-cpp/trunk/modules/http/openauth.hpp b/sca-cpp/trunk/modules/http/openauth.hpp index 1c49c4254c..70c6f658ad 100644 --- a/sca-cpp/trunk/modules/http/openauth.hpp +++ b/sca-cpp/trunk/modules/http/openauth.hpp @@ -49,13 +49,13 @@ const char* const cookieName(const char* const cs) { } const maybe<string> sessionID(const list<string>& c, const string& key) { - if (isNil(c)) + if (isNull(c)) return maybe<string>(); const string cn = cookieName(c_str(car(c))); const size_t i = find(cn, "="); if (i < length(cn)) { const list<string> kv = mklist<string>(substr(cn, 0, i), substr(cn, i+1)); - if (!isNil(kv) && !isNil(cdr(kv))) { + if (!isNull(kv) && !isNull(cdr(kv))) { if (car(kv) == key) return cadr(kv); } @@ -92,10 +92,10 @@ const string cookie(const string& key, const string& sid, const string& domain) * Redirect to the configured login page. */ const failable<int> login(const string& page, const value& ref, const value& attempt, request_rec* const r) { - const list<value> rarg = ref == string("/")? nilListValue : mklist<value>(mklist<value>("openauth_referrer", httpd::escape(httpd::url(isNil(ref)? r->uri : ref, r)))); - const list<value> aarg = isNil(attempt)? nilListValue : mklist<value>(mklist<value>("openauth_attempt", attempt)); + const list<value> rarg = ref == string("/")? nilListValue : mklist<value>(mklist<value>("openauth_referrer", httpd::escape(httpd::url(isNull(ref)? r->uri : ref, r)))); + const list<value> aarg = isNull(attempt)? nilListValue : mklist<value>(mklist<value>("openauth_attempt", attempt)); const list<value> largs = append(rarg, aarg); - const string loc = isNil(largs)? httpd::url(page, r) : httpd::url(page, r) + string("?") + http::queryString(largs); + const string loc = isNull(largs)? httpd::url(page, r) : httpd::url(page, r) + string("?") + http::queryString(largs); debug(loc, "openauth::login::uri"); return httpd::externalRedirect(loc, r); } diff --git a/sca-cpp/trunk/modules/java/driver.hpp b/sca-cpp/trunk/modules/java/driver.hpp index 4ffc84f4db..a8d162249c 100644 --- a/sca-cpp/trunk/modules/java/driver.hpp +++ b/sca-cpp/trunk/modules/java/driver.hpp @@ -38,7 +38,7 @@ namespace java { const value evalDriverLoop(const JavaRuntime& jr, const JavaClass jc, istream& in, ostream& out) { scheme::promptForInput(scheme::evalInputPrompt, out); const value input = content(scheme::readValue(in)); - if (isNil(input)) + if (isNull(input)) return input; const failable<value> output = evalClass(jr, input, jc); scheme::announceOutput(scheme::evalOutputPrompt, out); diff --git a/sca-cpp/trunk/modules/java/eval.hpp b/sca-cpp/trunk/modules/java/eval.hpp index 2c76b764fa..407e3d2a59 100644 --- a/sca-cpp/trunk/modules/java/eval.hpp +++ b/sca-cpp/trunk/modules/java/eval.hpp @@ -132,7 +132,7 @@ public: h.invokerLambda = h.env->GetFieldID(h.invokerClass, "lambda", "J"); h.iterableUtilClass = h.env->FindClass("org/apache/tuscany/IterableUtil"); h.iterableValueOf = h.env->GetStaticMethodID(h.iterableUtilClass, "list", "([Ljava/lang/Object;)Ljava/lang/Iterable;"); - h.iterableIsNil = h.env->GetStaticMethodID(h.iterableUtilClass, "isNil", "(Ljava/lang/Object;)Z"); + h.iterableIsNil = h.env->GetStaticMethodID(h.iterableUtilClass, "isNull", "(Ljava/lang/Object;)Z"); h.iterableCar = h.env->GetStaticMethodID(h.iterableUtilClass, "car", "(Ljava/lang/Object;)Ljava/lang/Object;"); h.iterableCdr = h.env->GetStaticMethodID(h.iterableUtilClass, "cdr", "(Ljava/lang/Object;)Ljava/lang/Iterable;"); h.uuidClass = h.env->FindClass("org/apache/tuscany/UUIDUtil"); @@ -257,7 +257,7 @@ public: } const value operator()(const list<value>& expr) const { - if (isNil(expr)) + if (isNull(expr)) return func(expr); const value& op(car(expr)); if (op == "equals") @@ -331,7 +331,7 @@ const jobject mkJavaLambda(const JavaRuntime& jr, unused const value& iface, con * Convert a list of values to a Java jobjectArray. */ const jobjectArray valuesToJarrayHelper(const JavaRuntime& jr, jobjectArray a, const list<value>& v, const int i) { - if (isNil(v)) + if (isNull(v)) return a; jr.h.env->SetObjectArrayElement(a, i, valueToJobject(jr, nilValue, car(v))); return valuesToJarrayHelper(jr, a, cdr(v), i + 1); @@ -375,7 +375,7 @@ const jobject valueToJobject(const JavaRuntime& jr, const value& jtype, const va * Convert a list of values to an array of jvalues. */ const jvalue* valuesToJvaluesHelper(const JavaRuntime& jr, jvalue* const a, const list<value>& types, const list<value>& v) { - if (isNil(v)) + if (isNull(v)) return a; a->l = valueToJobject(jr, car(types), car(v)); return valuesToJvaluesHelper(jr, a + 1, cdr(types), cdr(v)); @@ -542,7 +542,7 @@ const failable<value> evalClass(const JavaRuntime& jr, const value& expr, const // Lookup the Java function named as the expression operand const list<value> func = assoc<value>(car<value>(expr), jc.m); - if (isNil(func)) { + if (isNull(func)) { // The start, stop, and restart functions are optional const value fn = car<value>(expr); diff --git a/sca-cpp/trunk/modules/java/org/apache/tuscany/IterableUtil.java b/sca-cpp/trunk/modules/java/org/apache/tuscany/IterableUtil.java index 2366d79af6..58bb18cf72 100644 --- a/sca-cpp/trunk/modules/java/org/apache/tuscany/IterableUtil.java +++ b/sca-cpp/trunk/modules/java/org/apache/tuscany/IterableUtil.java @@ -61,9 +61,9 @@ public class IterableUtil { /** * Return true if a list is nil (empty). */ - public static boolean isNil(final Object l) { + public static boolean isNull(final Object l) { if(l instanceof BasicIterable<?>) - return ((BasicIterable<?>)l).isNil(); + return ((BasicIterable<?>)l).isNull(); if(l instanceof Collection<?>) return ((Collection<?>)l).isEmpty(); return !((Iterable<?>)l).iterator().hasNext(); @@ -144,7 +144,7 @@ public class IterableUtil { */ @SuppressWarnings("unchecked") public static <T> Iterable<T> append(final Object a, final Object b) { - if (isNil(a)) + if (isNull(a)) return (Iterable<T>)b; return cons(car(a), append(cdr(a), b)); } @@ -153,7 +153,7 @@ public class IterableUtil { * Return the first pair matching a key from a list of key value pairs. */ public static <T> Iterable<T> assoc(final Object k, final Object l) { - if(isNil(l)) + if(isNull(l)) return list(); if(k.equals(car(car(l)))) return car(l); @@ -168,11 +168,11 @@ public class IterableUtil { abstract Iterable<T> cdr(); - abstract Boolean isNil(); + abstract Boolean isNull(); @Override public int size() { - return this.isNil()? 0 : 1 + ((List<T>)this.cdr()).size(); + return this.isNull()? 0 : 1 + ((List<T>)this.cdr()).size(); } @Override @@ -194,7 +194,7 @@ public class IterableUtil { } @Override - Boolean isNil() { + Boolean isNull() { return this.a.length - this.start == 0; } @@ -243,7 +243,7 @@ public class IterableUtil { } @Override - Boolean isNil() { + Boolean isNull() { return this.l.size() - this.start == 0; } @@ -292,7 +292,7 @@ public class IterableUtil { } @Override - Boolean isNil() { + Boolean isNull() { return false; } @@ -365,12 +365,12 @@ public class IterableUtil { assert jl.get(2) == Integer.valueOf(2); final Iterable<Object> n = list(); - assert isNil(n); + assert isNull(n); assert n.toString().equals("[]"); final Iterable<Object> cn = cons(0, n); - assert !isNil(cn); - assert isNil(cdr(cn)); + assert !isNull(cn); + assert isNull(cdr(cn)); assert cn.toString().equals("[0]"); final Iterable<Object> al = new ArrayList<Object>(Arrays.asList(1, 2, 3)); diff --git a/sca-cpp/trunk/modules/java/test/ServerImpl.java b/sca-cpp/trunk/modules/java/test/ServerImpl.java index 4499681f78..8a6f0e95c9 100644 --- a/sca-cpp/trunk/modules/java/test/ServerImpl.java +++ b/sca-cpp/trunk/modules/java/test/ServerImpl.java @@ -28,7 +28,7 @@ public class ServerImpl { } public Iterable<?> get(final Iterable<String> id) { - if (isNil(id)) + if (isNull(id)) return list(list("'feed", list("'title", "Sample Feed"), list("'id", "123456789"), list("'entry", list( list(list("'title", "Item"), list("'id", "111"), list("'content", list("'item", list("'name", "Apple"), list("'currencyCode", "USD"), list("'currencySymbol", "$"), list("'price", 2.99)))), diff --git a/sca-cpp/trunk/modules/js/htdocs/atomutil.js b/sca-cpp/trunk/modules/js/htdocs/atomutil.js index 3d4e9d08d2..4b57b36fb4 100644 --- a/sca-cpp/trunk/modules/js/htdocs/atomutil.js +++ b/sca-cpp/trunk/modules/js/htdocs/atomutil.js @@ -27,22 +27,22 @@ var atom = {}; */ atom.entryElementValues = function(e) { var lt = filter(selector(mklist(element, "'title")), e); - var t = mklist(element, "'title", isNil(lt)? '' : elementValue(car(lt))); + var t = mklist(element, "'title", isNull(lt)? '' : elementValue(car(lt))); var li = filter(selector(mklist(element, "'id")), e); - var i = mklist(element, "'id", isNil(li)? '' : elementValue(car(li))); + var i = mklist(element, "'id", isNull(li)? '' : elementValue(car(li))); var la = filter(selector(mklist(element, "'author")), e); - var lan = isNil(la)? mklist() : filter(selector(mklist(element, "'name")), car(la)); - var lae = isNil(la)? mklist() : filter(selector(mklist(element, "'email")), car(la)); - var laa = isNil(lan)? lae : lan; - var a = isNil(laa)? mklist() : mklist(mklist(element, "'author", elementValue(car(laa)))); + var lan = isNull(la)? mklist() : filter(selector(mklist(element, "'name")), car(la)); + var lae = isNull(la)? mklist() : filter(selector(mklist(element, "'email")), car(la)); + var laa = isNull(lan)? lae : lan; + var a = isNull(laa)? mklist() : mklist(mklist(element, "'author", elementValue(car(laa)))); var lu = filter(selector(mklist(element, "'updated")), e); - var u = isNil(lu)? mklist() : mklist(mklist(element, "'updated", elementValue(car(lu)))); + var u = isNull(lu)? mklist() : mklist(mklist(element, "'updated", elementValue(car(lu)))); var lc = filter(selector(mklist(element, "'content")), e); - var c = isNil(lc)? mklist() : isAttribute(elementValue(car(lc)))? mklist() : mklist(mklist(element, "'content", elementValue(car(lc)))); + var c = isNull(lc)? mklist() : isAttribute(elementValue(car(lc)))? mklist() : mklist(mklist(element, "'content", elementValue(car(lc)))); return append(append(append(mklist(element, "'entry", t, i), a), u), c); }; @@ -51,7 +51,7 @@ atom.entryElementValues = function(e) { * Convert a list of elements to a list of values representing ATOM entries. */ atom.entriesElementValues = function(e) { - if (isNil(e)) + if (isNull(e)) return e; return cons(atom.entryElementValues(car(e)), atom.entriesElementValues(cdr(e))); }; @@ -70,7 +70,7 @@ atom.isATOMEntry = function(l) { */ atom.readATOMEntryDocument = function(doc) { var e = readXMLDocument(doc); - if (isNil(e)) + if (isNull(e)) return mklist(); return mklist(atom.entryElementValues(car(e))); }; @@ -96,7 +96,7 @@ atom.isATOMFeed = function(l) { */ atom.readATOMFeedDocument = function(doc) { var f = readXMLDocument(doc); - if (isNil(f)) + if (isNull(f)) return mklist(); var t = filter(selector(mklist(element, "'title")), car(f)); var i = filter(selector(mklist(element, "'id")), car(f)); @@ -120,17 +120,17 @@ atom.entryElement = function(l) { var title = elementValue(namedElementChild("'title", l)); var id = elementValue(namedElementChild("'id", l)); var author = namedElementChild("'author", l); - var email = isNil(author)? false : (elementValue(author).indexOf('@') != -1); + var email = isNull(author)? false : (elementValue(author).indexOf('@') != -1); var updated = namedElementChild("'updated", l); var content = namedElementChild("'content", l); - var text = isNil(content)? false : elementHasValue(content); + var text = isNull(content)? false : elementHasValue(content); return append(append(append(append( mklist(element, "'entry", mklist(attribute, "'xmlns", "http://www.w3.org/2005/Atom"), mklist(element, "'title", mklist(attribute, "'type", "text"), title), mklist(element, "'id", id)), - isNil(author)? mklist() : mklist(mklist(element, "'author", + isNull(author)? mklist() : mklist(mklist(element, "'author", (email? mklist(element, "'email", elementValue(author)) : mklist(element, "'name", elementValue(author)))))), - isNil(updated)? mklist() : mklist(mklist(element, "'updated", elementValue(updated)))), - isNil(content)? mklist() : + isNull(updated)? mklist() : mklist(mklist(element, "'updated", elementValue(updated)))), + isNull(content)? mklist() : mklist(append(mklist(element, "'content", mklist(attribute, "'type", text? "text" : "application/xml")), text? mklist(elementValue(content)) : elementChildren(content)))), mklist(mklist(element, "'link", mklist(attribute, "'href", id)))); @@ -140,7 +140,7 @@ atom.entryElement = function(l) { * Convert a list of values representing ATOM entries to a list of elements. */ atom.entriesElements = function(l) { - if (isNil(l)) + if (isNull(l)) return l; return cons(atom.entryElement(car(l)), atom.entriesElements(cdr(l))); }; @@ -149,7 +149,7 @@ atom.entriesElements = function(l) { * Convert a list of values representing an ATOM entry to an ATOM entry. */ atom.writeATOMEntry = function(ll) { - var l = isNil(ll)? ll : car(ll); + var l = isNull(ll)? ll : car(ll); return writeXML(mklist(atom.entryElement(l)), true); }; @@ -157,22 +157,22 @@ atom.writeATOMEntry = function(ll) { * Convert a list of values representing an ATOM feed to an ATOM feed. */ atom.writeATOMFeed = function(ll) { - var l = isNil(ll)? ll : car(ll); + var l = isNull(ll)? ll : car(ll); var lt = filter(selector(mklist(element, "'title")), l); - var t = isNil(lt)? '' : elementValue(car(lt)); + var t = isNull(lt)? '' : elementValue(car(lt)); var li = filter(selector(mklist(element, "'id")), l); - var i = isNil(li)? '' : elementValue(car(li)); + var i = isNull(li)? '' : elementValue(car(li)); var f = mklist(element, "'feed", mklist(attribute, "'xmlns", "http://www.w3.org/2005/Atom"), mklist(element, "'title", mklist(attribute, "'type", "text"), car(l)), mklist(element, "'id", cadr(l))); // Write ATOM entries var le = filter(selector(mklist(element, "'entry")), l); - if (isNil(le)) + if (isNull(le)) return writeXML(mklist(f), true); // Write a single ATOM entry element with a list of values - if (!isNil(le) && !isNil(car(le)) && isList(car(caddr(car(le))))) { + if (!isNull(le) && !isNull(car(le)) && isList(car(caddr(car(le))))) { var fe = append(f, atom.entriesElements(caddr(car(le)))); return writeXML(mklist(fe), true); } diff --git a/sca-cpp/trunk/modules/js/htdocs/elemutil.js b/sca-cpp/trunk/modules/js/htdocs/elemutil.js index 37d641f7b3..62050f5953 100644 --- a/sca-cpp/trunk/modules/js/htdocs/elemutil.js +++ b/sca-cpp/trunk/modules/js/htdocs/elemutil.js @@ -29,14 +29,14 @@ var atsign = "'@" * Return true if a value is an element. */ function isElement(v) { - return (!(!isList(v) || isNil(v) || car(v) != element)); + return (!(!isList(v) || isNull(v) || car(v) != element)); } /** * Return true if a value is an attribute. */ function isAttribute(v) { - return (!(!isList(v) || isNil(v) || car(v) != attribute)); + return (!(!isList(v) || isNull(v) || car(v) != attribute)); } /** @@ -58,7 +58,7 @@ elementName = cadr; * Return true if an element has children. */ function elementHasChildren(l) { - return !isNil(cddr(l)); + return !isNull(cddr(l)); } /** @@ -73,7 +73,7 @@ function elementHasValue(l) { var r = reverse(l); if (isSymbol(car(r))) return false; - return (!(isList(car(r)) && !isNil(car(r)) && isSymbol(car(car(r))))) + return (!(isList(car(r)) && !isNull(car(r)) && isSymbol(car(car(r))))) } /** @@ -89,7 +89,7 @@ function elementValue(l) { function elementToValueIsList(v) { if (!isList(v)) return false; - return isNil(v) || !isSymbol(car(v)); + return isNull(v) || !isSymbol(car(v)); } function elementToValue(t) { @@ -112,11 +112,11 @@ function elementToValue(t) { * Convert a list of elements to a list of values. */ function elementToValueIsSymbol(v) { - return (!(!isList(v)) || isNil(v) || !isSymbol(car(v))); + return (!(!isList(v)) || isNull(v) || !isSymbol(car(v))); } function elementToValueGroupValues(v, l) { - if (isNil(l) || !elementToValueIsSymbol(v) || !elementToValueIsSymbol(car(l))) + if (isNull(l) || !elementToValueIsSymbol(v) || !elementToValueIsSymbol(car(l))) return cons(v, l); if (car(car(l)) != car(v)) return cons(v, l); @@ -129,7 +129,7 @@ function elementToValueGroupValues(v, l) { } function elementsToValues(e) { - if (isNil(e)) + if (isNull(e)) return e; return elementToValueGroupValues(elementToValue(car(e)), elementsToValues(cdr(e))); } @@ -138,15 +138,15 @@ function elementsToValues(e) { * Convert a value to an element. */ function valueToElement(t) { - if (isList(t) && !isNil(t) && isSymbol(car(t))) { + if (isList(t) && !isNull(t) && isSymbol(car(t))) { var n = car(t); - var v = isNil(cdr(t))? mklist() : cadr(t); + var v = isNull(cdr(t))? mklist() : cadr(t); if (!isList(v)) { if (n.substring(0, 2) == atsign) return mklist(attribute, "'" + n.substring(2), v); return mklist(element, n, v); } - if (isNil(v) || !isSymbol(car(v))) + if (isNull(v) || !isSymbol(car(v))) return cons(element, cons(n, mklist(valuesToElements(v)))); return cons(element, cons(n, valuesToElements(cdr(t)))); } @@ -159,7 +159,7 @@ function valueToElement(t) { * Convert a list of values to a list of elements. */ function valuesToElements(l) { - if (isNil(l)) + if (isNull(l)) return l; return cons(valueToElement(car(l)), valuesToElements(cdr(l))); } @@ -169,9 +169,9 @@ function valuesToElements(l) { */ function selector(s) { function evalSelect(s, v) { - if (isNil(s)) + if (isNull(s)) return true; - if (isNil(v)) + if (isNull(v)) return false; if (car(s) != car(v)) return false; @@ -187,7 +187,7 @@ function selector(s) { function namedAttribute(name, l) { return memo(l, name, function() { var f = filter(function(v) { return isAttribute(v) && attributeName(v) == name; }, l); - if (isNil(f)) + if (isNull(f)) return null; return car(f); }); @@ -217,7 +217,7 @@ function namedElementChildren(name, l) { */ function namedElementChild(name, l) { var f = namedElementChildren(name, l); - if (isNil(f)) + if (isNull(f)) return null; return car(f); } diff --git a/sca-cpp/trunk/modules/js/htdocs/jsonutil.js b/sca-cpp/trunk/modules/js/htdocs/jsonutil.js index 8aa291bc89..9960a5d82f 100644 --- a/sca-cpp/trunk/modules/js/htdocs/jsonutil.js +++ b/sca-cpp/trunk/modules/js/htdocs/jsonutil.js @@ -41,13 +41,13 @@ json.Exception.prototype.toString = function() { * Return true if a list represents a JS array. */ json.isJSArray = function(l) { - if (isNil(l)) + if (isNull(l)) return true; var v = car(l); if (isSymbol(v)) return false; if (isList(v)) - if (!isNil(v) && isSymbol(car(v))) + if (!isNull(v) && isSymbol(car(v))) return false; return true; }; @@ -56,7 +56,7 @@ json.isJSArray = function(l) { * Converts JSON properties to values. */ json.jsPropertiesToValues = function(propertiesSoFar, o, i) { - if (isNil(i)) + if (isNull(i)) return propertiesSoFar; var p = car(i); var jsv = o[p]; @@ -92,7 +92,7 @@ json.jsValToValue = function(jsv) { * Return true if a list of strings contains a JSON document. */ json.isJSON = function(l) { - if (isNil(l)) + if (isNull(l)) return false; var s = car(l).slice(0, 1); return s == "[" || s == "{"; @@ -112,7 +112,7 @@ json.readJSON = function(l) { * Convert a list of values to JSON array elements. */ json.valuesToJSElements = function(a, l, i) { - if (isNil(l)) + if (isNull(l)) return a; var pv = json.valueToJSVal(car(l)); a[i] = pv @@ -134,7 +134,7 @@ json.valueToJSVal = function(v) { * Convert a list of values to JSON properties. */ json.valuesToJSProperties = function(o, l) { - if (isNil(l)) + if (isNull(l)) return o; var token = car(l); if (isTaggedList(token, attribute)) { diff --git a/sca-cpp/trunk/modules/js/htdocs/scdl.js b/sca-cpp/trunk/modules/js/htdocs/scdl.js index 50dab53e7c..fd0e08035f 100644 --- a/sca-cpp/trunk/modules/js/htdocs/scdl.js +++ b/sca-cpp/trunk/modules/js/htdocs/scdl.js @@ -27,7 +27,7 @@ var scdl = {}; */ scdl.composite = function(l) { var cs = namedElementChildren("'composite", l); - if (isNil(cs)) + if (isNull(cs)) return cs; return car(cs); }; @@ -37,7 +37,7 @@ scdl.composite = function(l) { */ scdl.components = function(l) { var cs = namedElementChildren("'composite", l); - if (isNil(cs)) + if (isNull(cs)) return cs; return namedElementChildren("'component", car(cs)); }; @@ -47,7 +47,7 @@ scdl.components = function(l) { */ scdl.promotions = function(l) { var cs = namedElementChildren("'composite", l); - if (isNil(cs)) + if (isNull(cs)) return cs; return namedElementChildren("'service", car(cs)); }; @@ -57,7 +57,7 @@ scdl.promotions = function(l) { */ scdl.promote = function(l) { var puri = namedAttributeValue("'promote", l); - if (isNil(puri)) + if (isNull(puri)) return puri; return car(tokens(puri)); }; @@ -74,7 +74,7 @@ scdl.name = function(l) { */ scdl.documentation = function(l) { var d = namedElementChildren("'documentation", l); - if (isNil(d)) + if (isNull(d)) return null; if (!elementHasValue(car(d))) return null; @@ -126,7 +126,7 @@ scdl.implementation = function(l) { } var n = filter(filterImplementation, l); - if (isNil(n)) + if (isNull(n)) return null; return car(n); }; @@ -204,21 +204,21 @@ scdl.bindingType = function(l) { scdl.target = function(l) { function targetURI() { function bindingsTarget(l) { - if (isNil(l)) + if (isNull(l)) return null; var u = scdl.uri(car(l)); - if (!isNil(u)) + if (!isNull(u)) return u; return bindingsTarget(cdr(l)); } var t = namedAttributeValue("'target", l); - if (!isNil(t)) + if (!isNull(t)) return t; return bindingsTarget(scdl.bindings(l)); } var turi = targetURI(); - if (isNil(turi)) + if (isNull(turi)) return turi; return car(tokens(turi)); }; @@ -243,7 +243,7 @@ scdl.propertyValue = function(l) { * Convert a list of elements to a name -> element assoc list. */ scdl.nameToElementAssoc = function(l) { - if (isNil(l)) + if (isNull(l)) return l; return cons(mklist(scdl.name(car(l)), car(l)), scdl.nameToElementAssoc(cdr(l))); }; diff --git a/sca-cpp/trunk/modules/js/htdocs/ui.js b/sca-cpp/trunk/modules/js/htdocs/ui.js index 0c80b92bcf..3aa9e1052a 100644 --- a/sca-cpp/trunk/modules/js/htdocs/ui.js +++ b/sca-cpp/trunk/modules/js/htdocs/ui.js @@ -31,7 +31,7 @@ ui.elementByID = function(node, id) { return null; for (var i in node.childNodes) { var child = node.childNodes[i]; - if (isNil(child)) + if (isNull(child)) continue; if (child.id == id) return child; @@ -275,7 +275,7 @@ ui.msieVersion = function() { */ ui.asyncFrame = null; ui.async = function(f) { - if (isNil(ui.asyncFrame)) + if (isNull(ui.asyncFrame)) // Use requestAnimationFrame when available, fallback to setTimeout ui.asyncFrame = window.requestAnimationFrame || window.webkitRequestAnimationFrame || window.mozRequestAnimationFrame || window.oRequestAnimationFrame || window.msRequestAnimationFrame || @@ -293,7 +293,7 @@ ui.delay = function(f, t) { var id = window.setTimeout(function() { delete ui.delayed[id]; return f(); - }, isNil(t)? 16 : t); + }, isNull(t)? 16 : t); ui.delayed[id] = id; return id; }; @@ -311,12 +311,12 @@ ui.cancelDelay = function(id) { */ ui.animationFrame = null; ui.animation = function(f) { - if (isNil(ui.animationFrame)) + if (isNull(ui.animationFrame)) // Use requestAnimationFrame when available, fallback to setInterval ui.animationFrame = window.requestAnimationFrame || window.webkitRequestAnimationFrame || window.mozRequestAnimationFrame || window.oRequestAnimationFrame || window.msRequestAnimationFrame || function(f) { - if (!('interval' in f) || isNil(f.interval)) { + if (!('interval' in f) || isNull(f.interval)) { // First call, setup the interval f.interval = window.setInterval(function animation() { f.clearInterval = true; @@ -370,7 +370,7 @@ ui.onload = function() { } else { // Style scroll bars var h = document.getElementsByTagName('html'); - if (!isNil(h)) + if (!isNull(h)) h[0].className = h[0].className? h[0].classname + ' flatscrollbars' : 'flatscrollbars'; } @@ -393,7 +393,7 @@ ui.onload = function() { ui.onorientationchange = function(e) { // Adjust filler height - if (!isNil(ui.filler)) + if (!isNull(ui.filler)) ui.filler.style.height = ui.pixpos(window.orientation == 0? screen.height : screen.width); // Scroll to hide the address bar @@ -524,7 +524,7 @@ ui.datatable = function(l) { } function rows(l, i) { - if (isNil(l)) + if (isNull(l)) return ''; var e = car(l); @@ -564,7 +564,7 @@ ui.datatable = function(l) { ui.datalist = function(l) { function rows(l, i) { - if (isNil(l)) + if (isNull(l)) return ''; var e = car(l); diff --git a/sca-cpp/trunk/modules/js/htdocs/util.js b/sca-cpp/trunk/modules/js/htdocs/util.js index 1cf086c60e..a8fec3994d 100644 --- a/sca-cpp/trunk/modules/js/htdocs/util.js +++ b/sca-cpp/trunk/modules/js/htdocs/util.js @@ -81,7 +81,7 @@ function range(a, b) { return l; } -function isNil(v) { +function isNull(v) { return (v == null || typeof v == 'undefined' || (v.constructor == Array && v.length == 0)); } @@ -98,7 +98,7 @@ function isList(v) { } function isTaggedList(v, t) { - return (isList(v) && !isNil(v) && car(v) == t); + return (isList(v) && !isNull(v) && car(v) == t); } var emptylist = new Array(); @@ -120,7 +120,7 @@ function length(l) { * Scheme-like associations. */ function assoc(k, l) { - if (isNil(l)) + if (isNull(l)) return emptylist; var n = l.length; for(var i = 0; i < n; i++) { @@ -134,7 +134,7 @@ function assoc(k, l) { * Map, filter and reduce functions. */ function map(f, l) { - if (isNil(l)) + if (isNull(l)) return l; var n = l.length; var a = new Array(); @@ -145,7 +145,7 @@ function map(f, l) { } function filter(f, l) { - if (isNil(l)) + if (isNull(l)) return l; var n = l.length; var a = new Array(); @@ -157,7 +157,7 @@ function filter(f, l) { } function reduce(f, i, l) { - if (isNil(l)) + if (isNull(l)) return i; return reduce(f, f(i, car(l)), cdr(l)); } @@ -223,7 +223,7 @@ function isIE() { * External build configuration. */ var config; -if (isNil(config)) +if (isNull(config)) config = {}; /** @@ -245,7 +245,7 @@ function assert(exp) { * Write a list of strings. */ function writeStrings(l) { - if (isNil(l)) + if (isNull(l)) return ''; var s = ''; var n = l.length; @@ -268,14 +268,14 @@ function writeValue(v) { } function writeList(l) { - if (isNil(l)) + if (isNull(l)) return ''; return ' ' + writeValue(car(l)) + writeList(cdr(l)); } if (!isList(v)) return writePrimitive(v); - if (isNil(v)) + if (isNull(v)) return '()'; return '(' + writeValue(car(v)) + writeList(cdr(v)) + ')'; } @@ -403,7 +403,7 @@ function domainname(host) { if (s != -1) return domainname(host.substring(0, s)); var h = reverse(host.split('.')); - var d = (!isNil(cddr(h)) && caddr(h) == 'www')? mklist(car(h), cadr(h), caddr(h)) : mklist(car(h), cadr(h)); + var d = (!isNull(cddr(h)) && caddr(h) == 'www')? mklist(car(h), cadr(h), caddr(h)) : mklist(car(h), cadr(h)); return reverse(d).join('.'); } @@ -536,7 +536,7 @@ function setcaddr(l, v) { * Append the elements of a list to a list. */ function setappend(a, b) { - if (isNil(b)) + if (isNull(b)) return a; a.push(car(b)); return setappend(a, cdr(b)); diff --git a/sca-cpp/trunk/modules/js/htdocs/xmlutil.js b/sca-cpp/trunk/modules/js/htdocs/xmlutil.js index 4d943cce75..29240dff9c 100644 --- a/sca-cpp/trunk/modules/js/htdocs/xmlutil.js +++ b/sca-cpp/trunk/modules/js/htdocs/xmlutil.js @@ -26,7 +26,7 @@ */ function nodeList(n) { var l = new Array(); - if (isNil(n)) + if (isNull(n)) return l; for (var i = 0; i < n.length; i++) l[i] = n[i]; @@ -37,7 +37,7 @@ function nodeList(n) { * Append a list of nodes to a parent node. */ function appendNodes(nodes, p) { - if (isNil(nodes)) + if (isNull(nodes)) return p; p.appendChild(car(nodes)); return appendNodes(cdr(nodes), p); @@ -71,7 +71,7 @@ function childText(e) { * Read a list of XML attributes. */ function readAttributes(p, a) { - if (isNil(a)) + if (isNull(a)) return a; var x = car(a); return cons(mklist(attribute, "'" + x.nodeName, x.nodeValue), readAttributes(p, cdr(a))); @@ -83,7 +83,7 @@ function readAttributes(p, a) { function readElement(e, childf) { var l = append(append(mklist(element, "'" + e.nodeName), readAttributes(e, childf(e))), readElements(childElements(e), childf)); var t = childText(e); - if (isNil(t)) + if (isNull(t)) return l; return append(l, mklist(car(t).nodeValue)); } @@ -92,7 +92,7 @@ function readElement(e, childf) { * Read a list of XML elements. */ function readElements(l, childf) { - if (isNil(l)) + if (isNull(l)) return l; return cons(readElement(car(l), childf), readElements(cdr(l), childf)); } @@ -101,7 +101,7 @@ function readElements(l, childf) { * Return true if a list of strings contains an XML document. */ function isXML(l) { - if (isNil(l)) + if (isNull(l)) return false; return car(l).substring(0, 5) == '<?xml'; } @@ -120,7 +120,7 @@ function parseXML(l) { */ function readXMLDocument(doc) { var root = childElements(doc); - if (isNil(root)) + if (isNull(root)) return mklist(); return mklist(readElement(car(root), childAttributes)); } @@ -133,7 +133,7 @@ function readXHTMLElement(xhtml) { function ieChildAttributes(e) { var a = filter(function(n) { // Filter out empty and internal DOM attributes - if (n.nodeType != 2 || isNil(n.nodeValue) || n.nodeValue == '') + if (n.nodeType != 2 || isNull(n.nodeValue) || n.nodeValue == '') return false; if (n.nodeName == 'contentEditable' || n.nodeName == 'maxLength' || n.nodeName == 'loop' || n.nodeName == 'start') return false; @@ -174,13 +174,13 @@ function writeXMLDocument(doc) { * Write a list of XML element and attribute tokens. */ function expandElementValues(n, l) { - if (isNil(l)) + if (isNull(l)) return l; return cons(cons(element, cons(n, car(l))), expandElementValues(n, cdr(l))); } function writeList(l, node, doc) { - if (isNil(l)) + if (isNull(l)) return node; var token = car(l); @@ -196,7 +196,7 @@ function writeList(l, node, doc) { function mkelem(tok, doc) { function xmlns(l) { - if (isNil(l)) + if (isNull(l)) return null; var t = car(l); if (isTaggedList(t, attribute)) { diff --git a/sca-cpp/trunk/modules/json/json.hpp b/sca-cpp/trunk/modules/json/json.hpp index 497624070b..caef19b835 100644 --- a/sca-cpp/trunk/modules/json/json.hpp +++ b/sca-cpp/trunk/modules/json/json.hpp @@ -58,13 +58,13 @@ public: * Returns true if a list represents a JS array. */ inline const bool isJSArray(const list<value>& l) { - if(isNil(l)) + if(isNull(l)) return true; const value v = car(l); if (isSymbol(v)) return false; if(isList(v)) { - if(!isNil((list<value>)v) && isSymbol(car<value>(v))) + if(!isNull((list<value>)v) && isSymbol(car<value>(v))) return false; } return true; @@ -94,7 +94,7 @@ inline const list<value> jsPropertiesToValues(const list<value>& propertiesSoFar const char* const name = json_object_iter_key(i); json_t* const jsv = json_object_iter_value(i); const value val = jsValToValue(jsv); - if (isNil(val) && !isList(val)) + if (isNull(val) && !isList(val)) return jsPropertiesToValues(cons<value> (mklist<value> (element, c_str(name), val), propertiesSoFar), o, json_object_iter_next(o, i)); if (substr(name, 0, 1) == atsign) return jsPropertiesToValues(cons<value>(mklist<value>(attribute, c_str(substr(name, 1)), val), propertiesSoFar), o, json_object_iter_next(o, i)); @@ -148,7 +148,7 @@ const value jsValToValue(json_t* const jsv) { */ inline json_t* const valuesToJSElements(json_t* const a, const list<value>& l) { json_t* const valueToJSVal(const value& val); - if (isNil(l)) + if (isNull(l)) return a; json_t* const v = valueToJSVal(car(l)); json_array_append(a, v); @@ -199,7 +199,7 @@ inline json_t* const valueToJSVal(const value& val) { * Converts a list of values to JS properties. */ inline json_t* const valuesToJSProperties(json_t* const o, const list<value>& l) { - if (isNil(l)) + if (isNull(l)) return o; // Write an attribute @@ -235,7 +235,7 @@ inline json_t* const valuesToJSProperties(json_t* const o, const list<value>& l) * Return true if a list of strings contains a JSON document. */ inline const bool isJSON(const list<string>& ls) { - if (isNil(ls)) + if (isNull(ls)) return false; const string s = substr(car(ls), 0, 1); return s == "[" || s == "{"; @@ -390,7 +390,7 @@ inline const string funcName(const string& f) { * of key value pairs. */ inline const list<value> queryParams(const list<value>& a) { - if (isNil(a)) + if (isNull(a)) return nilListValue; const list<value> p = car(a); if (car(p) == value("id") || car(p) == value("method")) diff --git a/sca-cpp/trunk/modules/oauth/mod-oauth1.cpp b/sca-cpp/trunk/modules/oauth/mod-oauth1.cpp index a7238804f8..b1786d1098 100644 --- a/sca-cpp/trunk/modules/oauth/mod-oauth1.cpp +++ b/sca-cpp/trunk/modules/oauth/mod-oauth1.cpp @@ -104,7 +104,7 @@ public: * Run the authnz hooks to authenticate a request. */ const failable<int> checkAuthnzProviders(const string& user, request_rec* const r, const list<AuthnProviderConf>& apcs) { - if (isNil(apcs)) + if (isNull(apcs)) return mkfailure<int>("Authentication failure for: " + user, HTTP_UNAUTHORIZED); const AuthnProviderConf apc = car<AuthnProviderConf>(apcs); if (apc.provider == NULL || !apc.provider->check_password) @@ -122,7 +122,7 @@ const failable<int> checkAuthnz(const string& user, request_rec* const r, const if (substr(user, 0, 1) == "/") return mkfailure<int>(string("Encountered FakeBasicAuth spoof: ") + user, HTTP_UNAUTHORIZED); - if (isNil(apcs)) { + if (isNull(apcs)) { const authn_provider* provider = (const authn_provider*)ap_lookup_provider(AUTHN_PROVIDER_GROUP, AUTHN_DEFAULT_PROVIDER, AUTHN_PROVIDER_VERSION); return checkAuthnzProviders(user, r, mklist<AuthnProviderConf>(AuthnProviderConf(AUTHN_DEFAULT_PROVIDER, provider))); } @@ -142,11 +142,11 @@ const failable<value> userInfo(const value& sid, const memcache::MemCached& mc) const failable<int> authenticated(const list<value>& userinfo, const bool check, request_rec* const r, const list<value>& scopeattrs, const list<AuthnProviderConf>& apcs) { debug(userinfo, "modoauth2::authenticated::userinfo"); - if (isNil(scopeattrs)) { + if (isNull(scopeattrs)) { // Store user id in an environment variable const list<value> id = assoc<value>("id", userinfo); - if (isNil(id) || isNil(cdr(id))) + if (isNull(id) || isNull(cdr(id))) return mkfailure<int>("Couldn't retrieve user id", HTTP_UNAUTHORIZED); apr_table_set(r->subprocess_env, "OAUTH2_ID", apr_pstrdup(r->pool, c_str(cadr(id)))); @@ -164,7 +164,7 @@ const failable<int> authenticated(const list<value>& userinfo, const bool check, // Store each configured OAuth scope attribute in an environment variable const list<value> a = car(scopeattrs); const list<value> v = assoc<value>(cadr(a), userinfo); - if (!isNil(v) && !isNil(cdr(v))) { + if (!isNull(v) && !isNull(cdr(v))) { // Map the REMOTE_USER attribute to the request user field if (string(car(a)) == "REMOTE_USER") @@ -192,7 +192,7 @@ const string header(const string& qs, const string& redir, const string& verif) << "oauth_consumer_key=\"" << string(cadr(assoc<value>("oauth_consumer_key", args))) << "\", "; const list<value> atok = assoc<value>("oauth_token", args); - if (!isNil(atok) && !isNil(cdr(atok))) + if (!isNull(atok) && !isNull(cdr(atok))) hdr << "oauth_token=\"" << string(cadr(atok)) << "\", "; if (length(verif) != 0) @@ -223,22 +223,22 @@ const list<string> sign(const string& verb, const string& uri, const list<value> const failable<int> authorize(const list<value>& args, request_rec* const r, const list<value>& appkeys, const memcache::MemCached& mc) { // Extract authorize, access_token, client ID and info URIs const list<value> ref = assoc<value>("openauth_referrer", args); - if (isNil(ref) || isNil(cdr(ref))) + if (isNull(ref) || isNull(cdr(ref))) return mkfailure<int>("Missing openauth_referrer parameter"); const list<value> req = assoc<value>("oauth1_request_token", args); - if (isNil(req) || isNil(cdr(req))) + if (isNull(req) || isNull(cdr(req))) return mkfailure<int>("Missing oauth1_request_token parameter"); const list<value> auth = assoc<value>("oauth1_authorize", args); - if (isNil(auth) || isNil(cdr(auth))) + if (isNull(auth) || isNull(cdr(auth))) return mkfailure<int>("Missing oauth1_authorize parameter"); const list<value> tok = assoc<value>("oauth1_access_token", args); - if (isNil(tok) || isNil(cdr(tok))) + if (isNull(tok) || isNull(cdr(tok))) return mkfailure<int>("Missing oauth1_access_token parameter"); const list<value> cid = assoc<value>("oauth1_client_id", args); - if (isNil(cid) || isNil(cdr(cid))) + if (isNull(cid) || isNull(cdr(cid))) return mkfailure<int>("Missing oauth1_client_id parameter"); const list<value> info = assoc<value>("oauth1_info", args); - if (isNil(info) || isNil(cdr(info))) + if (isNull(info) || isNull(cdr(info))) return mkfailure<int>("Missing oauth1_info parameter"); // Build the redirect URI @@ -248,7 +248,7 @@ const failable<int> authorize(const list<value>& args, request_rec* const r, con // Lookup client app configuration const list<value> app = assoc<value>(cadr(cid), appkeys); - if (isNil(app) || isNil(cdr(app))) + if (isNull(app) || isNull(cdr(app))) return mkfailure<int>(string("client id not found: ") + (string)cadr(cid)); list<value> appkey = cadr(app); @@ -271,13 +271,13 @@ const failable<int> authorize(const list<value>& args, request_rec* const r, con // Retrieve the request token const list<value> conf = assoc<value>("oauth_callback_confirmed", resargs); - if (isNil(conf) || isNil(cdr(conf)) || cadr(conf) != "true") + if (isNull(conf) || isNull(cdr(conf)) || cadr(conf) != "true") return mkfailure<int>("Couldn't confirm oauth_callback"); const list<value> tv = assoc<value>("oauth_token", resargs); - if (isNil(tv) || isNil(cdr(tv))) + if (isNull(tv) || isNull(cdr(tv))) return mkfailure<int>("Couldn't retrieve oauth_token"); const list<value> sv = assoc<value>("oauth_token_secret", resargs); - if (isNil(sv) || isNil(cdr(sv))) + if (isNull(sv) || isNull(cdr(sv))) return mkfailure<int>("Couldn't retrieve oauth_token_secret"); // Store the request token in memcached @@ -301,12 +301,12 @@ const failable<list<value> > profileUserInfo(const value& cid, const string& inf if (b == "[") { // Twitter JSON profile const list<value> infov(content(json::readValue(mklist<string>(info)))); - if (isNil(infov)) + if (isNull(infov)) return mkfailure<list<value> >("Couldn't retrieve user info"); debug(infov, "modoauth1::access_token::info"); const list<value> uv = assoc<value>("user", car(infov)); debug(uv, "modoauth1::access_token::userInfo"); - if (isNil(uv) || isNil(cdr(uv))) + if (isNull(uv) || isNull(cdr(uv))) return mkfailure<list<value> >("Couldn't retrieve user info"); const list<value> iv = cdr(uv); return cons<value>(mklist<value>("realm", cid), iv); @@ -314,12 +314,12 @@ const failable<list<value> > profileUserInfo(const value& cid, const string& inf if (b == "{") { // Foursquare JSON profile const list<value> infov(content(json::readValue(mklist<string>(info)))); - if (isNil(infov)) + if (isNull(infov)) return mkfailure<list<value> >("Couldn't retrieve user info"); debug(infov, "modoauth1::access_token::info"); const list<value> uv = assoc<value>("user", infov); debug(uv, "modoauth1::access_token::userInfo"); - if (isNil(uv) || isNil(cdr(uv))) + if (isNull(uv) || isNull(cdr(uv))) return mkfailure<list<value> >("Couldn't retrieve user info"); const list<value> iv = cdr(uv); return cons<value>(mklist<value>("realm", cid), iv); @@ -327,12 +327,12 @@ const failable<list<value> > profileUserInfo(const value& cid, const string& inf if (b == "<") { // XML profile const list<value> infov = elementsToValues(content(xml::readElements(mklist<string>(info)))); - if (isNil(infov)) + if (isNull(infov)) return mkfailure<list<value> >("Couldn't retrieve user info"); debug(infov, "modoauth1::access_token::info"); const list<value> pv = car(infov); debug(pv, "modoauth1::access_token::userInfo"); - if (isNil(pv) || isNil(cdr(pv))) + if (isNull(pv) || isNull(cdr(pv))) return mkfailure<list<value> >("Couldn't retrieve user info"); const list<value> iv = cdr(pv); return cons<value>(mklist<value>("realm", cid), iv); @@ -347,27 +347,27 @@ const failable<int> accessToken(const list<value>& args, request_rec* r, const l // Extract access_token URI, client ID and verification code const list<value> ref = assoc<value>("openauth_referrer", args); - if (isNil(ref) || isNil(cdr(ref))) + if (isNull(ref) || isNull(cdr(ref))) return mkfailure<int>("Missing openauth_referrer parameter"); const list<value> tok = assoc<value>("oauth1_access_token", args); - if (isNil(tok) || isNil(cdr(tok))) + if (isNull(tok) || isNull(cdr(tok))) return mkfailure<int>("Missing oauth1_access_token parameter"); const list<value> cid = assoc<value>("oauth1_client_id", args); - if (isNil(cid) || isNil(cdr(cid))) + if (isNull(cid) || isNull(cdr(cid))) return mkfailure<int>("Missing oauth1_client_id parameter"); const list<value> info = assoc<value>("oauth1_info", args); - if (isNil(info) || isNil(cdr(info))) + if (isNull(info) || isNull(cdr(info))) return mkfailure<int>("Missing oauth1_info parameter"); const list<value> tv = assoc<value>("oauth_token", args); - if (isNil(tv) || isNil(cdr(tv))) + if (isNull(tv) || isNull(cdr(tv))) return mkfailure<int>("Missing oauth_token parameter"); const list<value> vv = assoc<value>("oauth_verifier", args); - if (isNil(vv) || isNil(cdr(vv))) + if (isNull(vv) || isNull(cdr(vv))) return mkfailure<int>("Missing oauth_verifier parameter"); // Lookup client app configuration const list<value> app = assoc<value>(cadr(cid), appkeys); - if (isNil(app) || isNil(cdr(app))) + if (isNull(app) || isNull(cdr(app))) return mkfailure<int>(string("client id not found: ") + (string)cadr(cid)); const list<value> appkey = cadr(app); @@ -395,10 +395,10 @@ const failable<int> accessToken(const list<value>& args, request_rec* r, const l // Retrieve the access token const list<value> atv = assoc<value>("oauth_token", tokresargs); - if (isNil(atv) || isNil(cdr(atv))) + if (isNull(atv) || isNull(cdr(atv))) return mkfailure<int>("Couldn't retrieve oauth_token"); const list<value> asv = assoc<value>("oauth_token_secret", tokresargs); - if (isNil(asv) || isNil(cdr(asv))) + if (isNull(asv) || isNull(cdr(asv))) return mkfailure<int>("Couldn't retrieve oauth_token_secret"); debug(atv, "modoauth1::access_token::token"); @@ -498,7 +498,7 @@ static int checkAuthn(request_rec *r) { hasContent(openauth::sessionID(r, "TuscanyOpenAuth")) || hasContent(openauth::sessionID(r, "TuscanyOAuth2"))) return DECLINED; - if ((substr(string(r->uri), 0, 8) == "/oauth2/") || !isNil(assoc<value>("openid_identifier", args))) + if ((substr(string(r->uri), 0, 8) == "/oauth2/") || !isNull(assoc<value>("openid_identifier", args))) return DECLINED; r->ap_auth_type = const_cast<char*>(atype); @@ -515,9 +515,9 @@ int postConfigMerge(const ServerConf& mainsc, server_rec* const s) { debug(httpd::serverName(s), "modoauth1::postConfigMerge::serverName"); // Merge configuration from main server - if (isNil((list<value>)sc.appkeys)) + if (isNull((list<value>)sc.appkeys)) sc.appkeys = mainsc.appkeys; - if (isNil((list<string>)sc.mcaddrs)) + if (isNull((list<string>)sc.mcaddrs)) sc.mcaddrs = mainsc.mcaddrs; sc.mc = mainsc.mc; sc.cs = mainsc.cs; @@ -549,7 +549,7 @@ void childInit(apr_pool_t* const p, server_rec* const s) { ServerConf& sc = *psc; // Connect to Memcached - if (isNil((list<string>)sc.mcaddrs)) + if (isNull((list<string>)sc.mcaddrs)) sc.mc = *(new (gc_new<memcache::MemCached>()) memcache::MemCached("localhost", 11211)); else sc.mc = *(new (gc_new<memcache::MemCached>()) memcache::MemCached(sc.mcaddrs)); diff --git a/sca-cpp/trunk/modules/oauth/mod-oauth2.cpp b/sca-cpp/trunk/modules/oauth/mod-oauth2.cpp index 5bc212a681..0a4405ce2e 100644 --- a/sca-cpp/trunk/modules/oauth/mod-oauth2.cpp +++ b/sca-cpp/trunk/modules/oauth/mod-oauth2.cpp @@ -98,7 +98,7 @@ public: * Run the authnz hooks to authenticate a request. */ const failable<int> checkAuthnzProviders(const string& user, request_rec* const r, const list<AuthnProviderConf>& apcs) { - if (isNil(apcs)) + if (isNull(apcs)) return mkfailure<int>("Authentication failure for: " + user, HTTP_UNAUTHORIZED); const AuthnProviderConf apc = car<AuthnProviderConf>(apcs); if (apc.provider == NULL || !apc.provider->check_password) @@ -116,7 +116,7 @@ const failable<int> checkAuthnz(const string& user, request_rec* const r, const if (substr(user, 0, 1) == "/") return mkfailure<int>(string("Encountered FakeBasicAuth spoof: ") + user, HTTP_UNAUTHORIZED); - if (isNil(apcs)) { + if (isNull(apcs)) { const authn_provider* provider = (const authn_provider*)ap_lookup_provider(AUTHN_PROVIDER_GROUP, AUTHN_DEFAULT_PROVIDER, AUTHN_PROVIDER_VERSION); return checkAuthnzProviders(user, r, mklist<AuthnProviderConf>(AuthnProviderConf(AUTHN_DEFAULT_PROVIDER, provider))); } @@ -136,11 +136,11 @@ const failable<value> userInfo(const value& sid, const memcache::MemCached& mc) const failable<int> authenticated(const list<value>& userinfo, const bool check, request_rec* const r, const list<value>& scopeattrs, const list<AuthnProviderConf>& apcs) { debug(userinfo, "modoauth2::authenticated::userinfo"); - if (isNil(scopeattrs)) { + if (isNull(scopeattrs)) { // Store user id in an environment variable const list<value> id = assoc<value>("id", userinfo); - if (isNil(id) || isNil(cdr(id))) + if (isNull(id) || isNull(cdr(id))) return mkfailure<int>("Couldn't retrieve user id", HTTP_UNAUTHORIZED); apr_table_set(r->subprocess_env, "OAUTH2_ID", apr_pstrdup(r->pool, c_str(cadr(id)))); @@ -158,7 +158,7 @@ const failable<int> authenticated(const list<value>& userinfo, const bool check, // Store each configured OAuth scope attribute in an environment variable const list<value> a = car(scopeattrs); const list<value> v = assoc<value>(cadr(a), userinfo); - if (!isNil(v) && !isNil(cdr(v))) { + if (!isNull(v) && !isNull(cdr(v))) { // Map the REMOTE_USER attribute to the request user field if (string(car(a)) == "REMOTE_USER") @@ -175,22 +175,22 @@ const failable<int> authenticated(const list<value>& userinfo, const bool check, const failable<int> authorize(const list<value>& args, request_rec* const r, const list<value>& appkeys) { // Extract authorize, access_token, client ID and info URIs const list<value> ref = assoc<value>("openauth_referrer", args); - if (isNil(ref) || isNil(cdr(ref))) + if (isNull(ref) || isNull(cdr(ref))) return mkfailure<int>("Missing openauth_referrer parameter"); const list<value> auth = assoc<value>("oauth2_authorize", args); - if (isNil(auth) || isNil(cdr(auth))) + if (isNull(auth) || isNull(cdr(auth))) return mkfailure<int>("Missing oauth2_authorize parameter"); const list<value> tok = assoc<value>("oauth2_access_token", args); - if (isNil(tok) || isNil(cdr(tok))) + if (isNull(tok) || isNull(cdr(tok))) return mkfailure<int>("Missing oauth2_access_token parameter"); const list<value> cid = assoc<value>("oauth2_client_id", args); - if (isNil(cid) || isNil(cdr(cid))) + if (isNull(cid) || isNull(cdr(cid))) return mkfailure<int>("Missing oauth2_client_id parameter"); const list<value> info = assoc<value>("oauth2_info", args); - if (isNil(info) || isNil(cdr(info))) + if (isNull(info) || isNull(cdr(info))) return mkfailure<int>("Missing oauth2_info parameter"); const list<value> scope = assoc<value>("oauth2_scope", args); - if (isNil(scope) || isNil(cdr(scope))) + if (isNull(scope) || isNull(cdr(scope))) return mkfailure<int>("Missing oauth2_scope parameter"); const list<value> display = assoc<value>("oauth2_display", args); @@ -205,12 +205,12 @@ const failable<int> authorize(const list<value>& args, request_rec* const r, con // Lookup client app configuration const list<value> app = assoc<value>(cadr(cid), appkeys); - if (isNil(app) || isNil(cdr(app))) + if (isNull(app) || isNull(cdr(app))) return mkfailure<int>(string("client id not found: ") + (string)cadr(cid)); list<value> appkey = cadr(app); // Redirect to the authorize URI - const list<value> adisplay = (isNil(display) || isNil(cdr(display)))? nilListValue : mklist<value>("display", cadr(display)); + const list<value> adisplay = (isNull(display) || isNull(cdr(display)))? nilListValue : mklist<value>("display", cadr(display)); const list<value> aargs = mklist<value>(mklist<value>("response_type", "code"), mklist<value>("client_id", car(appkey)), mklist<value>("scope", cadr(scope)), adisplay, mklist<value>("redirect_uri", httpd::escape(redir)), mklist<value>("state", httpd::escape(state))); const string uri = httpd::unescape(cadr(auth)) + string("?") + http::queryString(aargs); debug(uri, "modoauth2::authorize::uri"); @@ -233,28 +233,28 @@ const failable<int> accessToken(const list<value>& args, request_rec* r, const l // Extract access_token URI, client ID and authorization code parameters const list<value> state = assoc<value>("state", args); - if (isNil(state) || isNil(cdr(state))) + if (isNull(state) || isNull(cdr(state))) return mkfailure<int>("Missing state parameter"); const list<value>& stargs = httpd::queryArgs(httpd::unescape(cadr(state))); const list<value> ref = assoc<value>("openauth_referrer", stargs); - if (isNil(ref) || isNil(cdr(ref))) + if (isNull(ref) || isNull(cdr(ref))) return mkfailure<int>("Missing openauth_referrer parameter"); const list<value> tok = assoc<value>("oauth2_access_token", stargs); - if (isNil(tok) || isNil(cdr(tok))) + if (isNull(tok) || isNull(cdr(tok))) return mkfailure<int>("Missing oauth2_access_token parameter"); const list<value> cid = assoc<value>("oauth2_client_id", stargs); - if (isNil(cid) || isNil(cdr(cid))) + if (isNull(cid) || isNull(cdr(cid))) return mkfailure<int>("Missing oauth2_client_id parameter"); const list<value> info = assoc<value>("oauth2_info", stargs); - if (isNil(info) || isNil(cdr(info))) + if (isNull(info) || isNull(cdr(info))) return mkfailure<int>("Missing oauth2_info parameter"); const list<value> code = assoc<value>("code", args); - if (isNil(code) || isNil(cdr(code))) + if (isNull(code) || isNull(cdr(code))) return mkfailure<int>("Missing code parameter"); // Lookup client app configuration const list<value> app = assoc<value>(cadr(cid), appkeys); - if (isNil(app) || isNil(cdr(app))) + if (isNull(app) || isNull(cdr(app))) return mkfailure<int>(string("client id not found: ") + (string)cadr(cid)); list<value> appkey = cadr(app); @@ -274,12 +274,12 @@ const failable<int> accessToken(const list<value>& args, request_rec* r, const l return mkfailure<int>(ftr); const value tr = content(ftr); debug(tr, "modoauth2::access_token::response"); - if (!isList(tr) || isNil(tr)) + if (!isList(tr) || isNull(tr)) return mkfailure<int>("Empty access token"); const list<value> tv = isString(car<value>(tr)) ? assoc<value>("access_token", httpd::queryArgs(join("", convertValues<string>(cadr<value>(tr))))) : assoc<value>("access_token", tr); - if (isNil(tv) || isNil(cdr(tv))) + if (isNull(tv) || isNull(cdr(tv))) return mkfailure<int>("Couldn't retrieve access_token"); debug(tv, "modoauth2::access_token::token"); @@ -373,7 +373,7 @@ static int checkAuthn(request_rec *r) { hasContent(openauth::sessionID(r, "TuscanyOpenAuth")) || hasContent(openauth::sessionID(r, "TuscanyOAuth1"))) return DECLINED; - if ((substr(string(r->uri), 0, 8) == "/oauth1/") || !isNil(assoc<value>("openid_identifier", args))) + if ((substr(string(r->uri), 0, 8) == "/oauth1/") || !isNull(assoc<value>("openid_identifier", args))) return DECLINED; r->ap_auth_type = const_cast<char*>(atype); @@ -390,9 +390,9 @@ int postConfigMerge(const ServerConf& mainsc, server_rec* const s) { debug(httpd::serverName(s), "modoauth2::postConfigMerge::serverName"); // Merge configuration from main server - if (isNil((list<value>)sc.appkeys)) + if (isNull((list<value>)sc.appkeys)) sc.appkeys = mainsc.appkeys; - if (isNil((list<string>)sc.mcaddrs)) + if (isNull((list<string>)sc.mcaddrs)) sc.mcaddrs = mainsc.mcaddrs; sc.mc = mainsc.mc; sc.cs = mainsc.cs; @@ -424,7 +424,7 @@ void childInit(apr_pool_t* const p, server_rec* const s) { ServerConf& sc = *psc; // Connect to Memcached - if (isNil((list<string>)sc.mcaddrs)) + if (isNull((list<string>)sc.mcaddrs)) sc.mc = *(new (gc_new<memcache::MemCached>()) memcache::MemCached("localhost", 11211)); else sc.mc = *(new (gc_new<memcache::MemCached>()) memcache::MemCached(sc.mcaddrs)); diff --git a/sca-cpp/trunk/modules/opencl/driver.hpp b/sca-cpp/trunk/modules/opencl/driver.hpp index c45bcf6ee4..f60e9c1dd3 100644 --- a/sca-cpp/trunk/modules/opencl/driver.hpp +++ b/sca-cpp/trunk/modules/opencl/driver.hpp @@ -38,7 +38,7 @@ namespace opencl { const value evalDriverLoop(const OpenCLProgram& clprog, istream& in, ostream& out, const OpenCLContext& cl) { scheme::promptForInput(scheme::evalInputPrompt, out); const value input = content(scheme::readValue(in)); - if (isNil(input)) + if (isNull(input)) return input; const failable<value> output = evalKernel(createKernel(input, clprog), input, 1, value::String, 512, cl); scheme::announceOutput(scheme::evalOutputPrompt, out); diff --git a/sca-cpp/trunk/modules/opencl/eval.hpp b/sca-cpp/trunk/modules/opencl/eval.hpp index f842ba783d..e910d427bc 100644 --- a/sca-cpp/trunk/modules/opencl/eval.hpp +++ b/sca-cpp/trunk/modules/opencl/eval.hpp @@ -412,7 +412,7 @@ const failable<OpenCLBuffer> readOnlyBuffer(const size_t size, const void* const * Fill an array of write events for a given list of buffers. */ const cl_uint writeBufferEvents(const list<OpenCLBuffer>& buf, cl_event* const evt) { - if (isNil(buf)) + if (isNull(buf)) return 0; const cl_event e = car(buf).evt; if (e == 0) @@ -486,7 +486,7 @@ const failable<OpenCLBuffer> valueToKernelArg(const value& v, const cl_uint i, c * Convert a list of values to kernel args. */ const failable<list<OpenCLBuffer>> valuesToKernelArgsListHelper(const list<value>& v, const cl_uint i, const OpenCLKernel& kernel, const OpenCLContext& cl, const cl_command_queue cq) { - if (isNil(v)) + if (isNull(v)) return list<OpenCLBuffer>(); const failable<OpenCLBuffer> a = valueToKernelArg(car(v), i, kernel, cl, cq); if (!hasContent(a)) diff --git a/sca-cpp/trunk/modules/python/driver.hpp b/sca-cpp/trunk/modules/python/driver.hpp index 41daed32c3..3b02302c65 100644 --- a/sca-cpp/trunk/modules/python/driver.hpp +++ b/sca-cpp/trunk/modules/python/driver.hpp @@ -38,7 +38,7 @@ namespace python { const value evalDriverLoop(PyObject* const script, istream& in, ostream& out, PythonRuntime& py) { scheme::promptForInput(scheme::evalInputPrompt, out); const value input = content(scheme::readValue(in)); - if (isNil(input)) + if (isNull(input)) return input; const failable<value> output = evalScript(input, script, py); scheme::announceOutput(scheme::evalOutputPrompt, out); diff --git a/sca-cpp/trunk/modules/python/eval.hpp b/sca-cpp/trunk/modules/python/eval.hpp index 3f9c6c20a2..3728cdb7bb 100644 --- a/sca-cpp/trunk/modules/python/eval.hpp +++ b/sca-cpp/trunk/modules/python/eval.hpp @@ -483,7 +483,7 @@ PyObject* const mkPyLambda(const lvvlambda& l, PythonRuntime* const py) { * Convert a list of values to a python list. */ PyObject* const valuesToPyListHelper(PyObject* const l, const list<value>& v, PythonRuntime* const py) { - if (isNil(v)) + if (isNull(v)) return l; PyObject* const pyv = valueToPyObject(car(v), py); PyList_Append(l, pyv); diff --git a/sca-cpp/trunk/modules/python/python-test.cpp b/sca-cpp/trunk/modules/python/python-test.cpp index 44a72f8f88..65b18c9b1b 100644 --- a/sca-cpp/trunk/modules/python/python-test.cpp +++ b/sca-cpp/trunk/modules/python/python-test.cpp @@ -197,7 +197,7 @@ const list<future<bool> > submitEvals(worker& w, const int max, const int i, PyO } const bool checkEvalResults(const list<future<bool> > r) { - if (isNil(r)) + if (isNull(r)) return true; assert(car(r) == true); return checkEvalResults(cdr(r)); diff --git a/sca-cpp/trunk/modules/rss/rss.hpp b/sca-cpp/trunk/modules/rss/rss.hpp index 348d50e8f3..e8edc0dcb1 100644 --- a/sca-cpp/trunk/modules/rss/rss.hpp +++ b/sca-cpp/trunk/modules/rss/rss.hpp @@ -46,14 +46,14 @@ const value entry("entry"); */ const list<value> entryElementValues(const list<value>& e) { const list<value> lt = elementChildren("title", e); - const value t = isNil(lt)? value(emptyString) : elementValue(car(lt)); + const value t = isNull(lt)? value(emptyString) : elementValue(car(lt)); const list<value> li = elementChildren("link", e); - const value i = isNil(li)? value(emptyString) : elementValue(car(li)); + const value i = isNull(li)? value(emptyString) : elementValue(car(li)); const list<value> ld = elementChildren("description", e); return append<value>(nilListValue + element + entry + value(nilListValue + element + value("title") + t) + value(nilListValue + element + value("id") + i), - isNil(ld)? nilListValue : isAttribute(elementValue(car(ld)))? nilListValue : + isNull(ld)? nilListValue : isAttribute(elementValue(car(ld)))? nilListValue : mklist<value>(value(nilListValue + element + value("content") + elementValue(car(ld))))); } @@ -61,7 +61,7 @@ const list<value> entryElementValues(const list<value>& e) { * Convert a list of elements to a list of element values representing ATOM entries. */ const list<value> entriesElementValues(const list<value>& e) { - if (isNil(e)) + if (isNull(e)) return e; return cons<value>(entryElementValues(car(e)), entriesElementValues(cdr(e))); } @@ -80,7 +80,7 @@ const bool isRSSFeed(const list<string>& ls) { */ const failable<list<value> > readRSSEntry(const list<string>& ilist) { const list<value> e = content(xml::readElements(ilist)); - if (isNil(e)) + if (isNull(e)) return mkfailure<list<value> >("Empty entry"); return mklist<value>(entryElementValues(car(e))); } @@ -90,7 +90,7 @@ const failable<list<value> > readRSSEntry(const list<string>& ilist) { */ const failable<list<value> > readRSSFeed(const list<string>& ilist) { const list<value> f = content(xml::readElements(ilist)); - if (isNil(f)) + if (isNull(f)) return mkfailure<list<value> >("Empty feed"); const list<value> c = elementChildren("channel", car(f)); const list<value> t = elementChildren("title", car(c)); @@ -109,12 +109,12 @@ const list<value> entryElement(const list<value>& l) { const value title = elementValue(elementChild("title", l)); const value id = elementValue(elementChild("id", l)); const value content = elementChild("content", l); - const bool text = isNil(content)? false : elementHasValue(content); + const bool text = isNull(content)? false : elementHasValue(content); return append<value>(nilListValue + element + "item" + (nilListValue + element + "title" + title) + (nilListValue + element + "link" + id), - isNil(content)? + isNull(content)? nilListValue : mklist<value>(append<value>(nilListValue + element + "description", text? mklist<value>(elementValue(content)) : elementChildren(content)))); @@ -124,7 +124,7 @@ const list<value> entryElement(const list<value>& l) { * Convert a list of values representing RSS entries to a list of elements. */ const list<value> entriesElements(const list<value>& l) { - if (isNil(l)) + if (isNull(l)) return l; return cons<value>(entryElement(car(l)), entriesElements(cdr(l))); } @@ -134,7 +134,7 @@ const list<value> entriesElements(const list<value>& l) { * The first two values in the list are the entry id and title. */ template<typename R> const failable<R> writeRSSEntry(const lambda<const R(const string&, const R)>& reduce, const R& initial, const list<value>& ll) { - const list<value> l = isNil(ll)? ll : (list<value>)car(ll); + const list<value> l = isNull(ll)? ll : (list<value>)car(ll); return xml::writeElements<R>(reduce, initial, mklist<value>(entryElement(l))); } @@ -150,11 +150,11 @@ const failable<list<string> > writeRSSEntry(const list<value>& l) { * The first two values in the list are the feed id and title. */ template<typename R> const failable<R> writeRSSFeed(const lambda<const R(const string&, const R)>& reduce, const R& initial, const list<value>& ll) { - const list<value> l = isNil(ll)? ll : (list<value>)car(ll); + const list<value> l = isNull(ll)? ll : (list<value>)car(ll); const list<value> lt = elementChildren("title", l); - const value t = isNil(lt)? value(emptyString) : elementValue(car(lt)); + const value t = isNull(lt)? value(emptyString) : elementValue(car(lt)); const list<value> li = elementChildren("id", l); - const value i = isNil(li)? value(emptyString) : elementValue(car(li)); + const value i = isNull(li)? value(emptyString) : elementValue(car(li)); const list<value> c = nilListValue + (nilListValue + element + "title" + t) + (nilListValue + element + "link" + i) @@ -162,7 +162,7 @@ template<typename R> const failable<R> writeRSSFeed(const lambda<const R(const s // Write RSS entries const list<value> le = elementChildren(entry, l); - if (isNil(le)) { + if (isNull(le)) { const list<value> fe = nilListValue + element + "rss" + (nilListValue + attribute + "version" + "2.0") + append(nilListValue + element + "channel", c); @@ -170,7 +170,7 @@ template<typename R> const failable<R> writeRSSFeed(const lambda<const R(const s } // Write a single RSS entry element with a list of values - if (!isNil(le) && !isNil(car(le)) && isList(car<value>(caddr<value>(car(le))))) { + if (!isNull(le) && !isNull(car(le)) && isList(car<value>(caddr<value>(car(le))))) { const list<value> ce = append(c, entriesElements(caddr<value>(car(le)))); const list<value> fe = nilListValue + element + "rss" + (nilListValue + attribute + "version" + "2.0") diff --git a/sca-cpp/trunk/modules/scdl/scdl.hpp b/sca-cpp/trunk/modules/scdl/scdl.hpp index 35a717d478..98afbe604c 100644 --- a/sca-cpp/trunk/modules/scdl/scdl.hpp +++ b/sca-cpp/trunk/modules/scdl/scdl.hpp @@ -40,7 +40,7 @@ namespace scdl { */ const list<value> components(const value& l) { const list<value> cs = elementChildren("composite", l); - if (isNil(cs)) + if (isNull(cs)) return cs; return elementChildren("component", car(cs)); } @@ -50,7 +50,7 @@ const list<value> components(const value& l) { */ const list<value> promotions(const value& l) { const list<value> cs = elementChildren("composite", l); - if (isNil(cs)) + if (isNull(cs)) return cs; return elementChildren("service", car(cs)); } @@ -73,7 +73,7 @@ const value name(const value& l) { * Convert a list of elements to a name -> element assoc list. */ const list<value> nameToElementAssoc(const list<value>& l) { - if (isNil(l)) + if (isNull(l)) return l; const value e(car(l)); return cons<value>(mklist<value>(name(e), e), nameToElementAssoc(cdr(l))); @@ -87,7 +87,7 @@ const value named(const value& n, const value& l) { return name(v) == n; }; const list<value> c = filter<value>(filterName, l); - if (isNil(c)) + if (isNull(c)) return nilValue; return car(c); } @@ -100,7 +100,7 @@ const value implementation(const value& l) { return isElement(v) && contains(string(cadr<value>(v)), "implementation."); }; const list<value> n = filter<value>(filterImplementation, l); - if (isNil(n)) + if (isNull(n)) return nilValue; return car(n); } @@ -148,17 +148,17 @@ const list<value> bindings(const value& l) { * Returns the target of a reference. */ const value bindingsTarget(const list<value>& l) { - if (isNil(l)) + if (isNull(l)) return nilValue; const value u = uri(car(l)); - if (!isNil(u)) + if (!isNull(u)) return u; return bindingsTarget(cdr(l)); } const value target(const value& l) { const value target = attributeValue("target", l); - if (!isNil(target)) + if (!isNull(target)) return target; return bindingsTarget(bindings(l)); } @@ -167,7 +167,7 @@ const value target(const value& l) { * Convert a list of references to a reference name -> target assoc list. */ const list<value> referenceToTargetAssoc(const list<value>& r) { - if (isNil(r)) + if (isNull(r)) return r; const value ref(car(r)); return cons<value>(mklist<value>(scdl::name(ref), scdl::target(ref)), referenceToTargetAssoc(cdr(r))); diff --git a/sca-cpp/trunk/modules/scheme/driver.hpp b/sca-cpp/trunk/modules/scheme/driver.hpp index c94af7bbf7..015348c9e1 100644 --- a/sca-cpp/trunk/modules/scheme/driver.hpp +++ b/sca-cpp/trunk/modules/scheme/driver.hpp @@ -56,7 +56,7 @@ const bool userPrint(const value val, ostream& out) { const value evalDriverLoop(istream& in, ostream& out, Env& env) { promptForInput(evalInputPrompt, out); const value input = content(readValue(in)); - if (isNil(input)) + if (isNull(input)) return input; const value output = evalExpr(input, env); announceOutput(evalOutputPrompt, out); diff --git a/sca-cpp/trunk/modules/scheme/environment.hpp b/sca-cpp/trunk/modules/scheme/environment.hpp index 1a295c74f4..ee82bc0401 100644 --- a/sca-cpp/trunk/modules/scheme/environment.hpp +++ b/sca-cpp/trunk/modules/scheme/environment.hpp @@ -81,16 +81,16 @@ const bool isDotVariable(const value& var) { } const Frame makeBinding(const Frame& frameSoFar, const list<value>& variables, const list<value> values) { - if (isNil(variables)) { - if (!isNil(values)) + if (isNull(variables)) { + if (!isNull(values)) logStream() << "Too many arguments supplied " << values << endl; return frameSoFar; } if (isDotVariable(car(variables))) return makeBinding(frameSoFar, cdr(variables), mklist<value>(values)); - if (isNil(values)) { - if (!isNil(variables)) + if (isNull(values)) { + if (!isNull(variables)) logStream() << "Too few arguments supplied " << variables << endl; return frameSoFar; } @@ -118,7 +118,7 @@ const value definitionVariable(const value& exp) { const value definitionValue(const value& exp) { const list<value> exps(exp); if(isSymbol(car(cdr(exps)))) { - if (isNil(cdr(cdr(exps)))) + if (isNull(cdr(cdr(exps)))) return nilValue; return car(cdr(cdr(exps))); } @@ -158,7 +158,7 @@ const Env setupEnvironment() { const value lookupEnvLoop(const value& var, const Env& env); const value lookupEnvScan(const value& var, const list<value>& vars, const list<value>& vals, const Env& env) { - if(isNil(vars)) + if(isNull(vars)) return lookupEnvLoop(var, enclosingEnvironment(env)); if(var == car(vars)) return car(vals); diff --git a/sca-cpp/trunk/modules/scheme/eval.hpp b/sca-cpp/trunk/modules/scheme/eval.hpp index 5074471931..17150a7b48 100644 --- a/sca-cpp/trunk/modules/scheme/eval.hpp +++ b/sca-cpp/trunk/modules/scheme/eval.hpp @@ -87,7 +87,7 @@ const list<value> operands(const value& exp) { } const list<value> listOfValues(const list<value> exps, Env& env) { - if(isNil(exps)) + if(isNull(exps)) return list<value> (); return cons(evalExpr(car(exps), env), listOfValues(cdr(exps), env)); } @@ -117,7 +117,7 @@ const Env procedureEnvironment(const value& exp) { } const bool isLastExp(const list<value>& seq) { - return isNil(cdr(seq)); + return isNull(cdr(seq)); } const value firstExp(const list<value>& seq) { @@ -151,7 +151,7 @@ const value applyProcedure(const value& procedure, list<value>& arguments) { } const value sequenceToExp(const list<value> exps) { - if(isNil(exps)) + if(isNull(exps)) return exps; if(isLastExp(exps)) return firstExp(exps); @@ -179,7 +179,7 @@ const value ifConsequent(const value& exp) { } const value ifAlternative(const value& exp) { - if(!isNil(cdr(cdr(cdr((list<value> )exp))))) + if(!isNull(cdr(cdr(cdr((list<value> )exp))))) return car(cdr(cdr(cdr((list<value> )exp)))); return false; } @@ -201,12 +201,12 @@ const value makeIf(value predicate, value consequent, value alternative) { } const value expandClauses(const list<value>& clauses) { - if(isNil(clauses)) + if(isNull(clauses)) return false; const value first = car(clauses); const list<value> rest = cdr(clauses); if(isCondElseClause(first)) { - if(isNil(rest)) + if(isNull(rest)) return sequenceToExp(condActions(first)); logStream() << "else clause isn't last " << clauses << endl; return nilValue; @@ -259,7 +259,7 @@ const value evalExpr(const value& exp, Env& env) { } const list<value> quotedParameters(const list<value>& p) { - if (isNil(p)) + if (isNull(p)) return p; return cons<value>(mklist<value>(quoteSymbol, car(p)), quotedParameters(cdr(p))); } @@ -268,7 +268,7 @@ const list<value> quotedParameters(const list<value>& p) { * Evaluate an expression against a script provided as a list of values. */ const value evalScriptLoop(const value& expr, const list<value>& script, scheme::Env& env) { - if (isNil(script)) + if (isNull(script)) return scheme::evalExpr(expr, env); scheme::evalExpr(car(script), env); return evalScriptLoop(expr, cdr(script), env); diff --git a/sca-cpp/trunk/modules/scheme/io.hpp b/sca-cpp/trunk/modules/scheme/io.hpp index 02f6923c86..c7177b54ae 100644 --- a/sca-cpp/trunk/modules/scheme/io.hpp +++ b/sca-cpp/trunk/modules/scheme/io.hpp @@ -231,7 +231,7 @@ inline const failable<list<string> > writeValue(const value& val) { inline const value readScript(istream& in) { const value val = content(readValue(in)); - if (isNil(val)) + if (isNull(val)) return nilListValue; return cons(val, (list<value>)readScript(in)); } diff --git a/sca-cpp/trunk/modules/scheme/primitive.hpp b/sca-cpp/trunk/modules/scheme/primitive.hpp index 4815e9a497..da0056d6da 100644 --- a/sca-cpp/trunk/modules/scheme/primitive.hpp +++ b/sca-cpp/trunk/modules/scheme/primitive.hpp @@ -118,10 +118,10 @@ inline const value treeSelectAssocProc(const list<value>& args) { inline const value nullProc(const list<value>& args) { const value v(car(args)); - if (isNil(v)) + if (isNull(v)) return true; if (isList(v)) - return isNil(list<value>(v)); + return isNull(list<value>(v)); return false; } @@ -138,13 +138,13 @@ inline const value lesserProc(const list<value>& args) { } inline const value addProc(const list<value>& args) { - if (isNil(cdr(args))) + if (isNull(cdr(args))) return (double)car(args); return (double)car(args) + (double)cadr(args); } inline const value subProc(const list<value>& args) { - if (isNil(cdr(args))) + if (isNull(cdr(args))) return (double)0 - (double)car(args); return (double)car(args) - (double)cadr(args); } @@ -162,7 +162,7 @@ inline const value sqrtProc(const list<value>& args) { } inline const value displayProc(const list<value>& args) { - if (isNil(args)) { + if (isNull(args)) { displayStream() << endl; return true; } @@ -171,7 +171,7 @@ inline const value displayProc(const list<value>& args) { } inline const value logProc(const list<value>& args) { - if (isNil(args)) { + if (isNull(args)) { logStream() << endl; return true; } @@ -225,7 +225,7 @@ inline const bool isPrimitiveProcedure(const value& proc) { } inline const bool isSelfEvaluating(const value& exp) { - if(isNil(exp)) + if(isNull(exp)) return true; if(isNumber(exp)) return true; diff --git a/sca-cpp/trunk/modules/server/client-test.hpp b/sca-cpp/trunk/modules/server/client-test.hpp index 29da9e4798..562fe9c68e 100644 --- a/sca-cpp/trunk/modules/server/client-test.hpp +++ b/sca-cpp/trunk/modules/server/client-test.hpp @@ -190,7 +190,7 @@ const list<future<bool> > startPost(worker& w, const int threads, const blambda& } const bool checkPost(const list<future<bool> >& r) { - if (isNil(r)) + if (isNull(r)) return true; assert(car(r) == true); return checkPost(cdr(r)); @@ -244,7 +244,7 @@ const list<pid_t> startPost(const int procs, const blambda& l) { } const bool checkPost(const list<pid_t>& r) { - if (isNil(r)) + if (isNull(r)) return true; int status; waitpid(car(r), &status, 0); diff --git a/sca-cpp/trunk/modules/server/mod-cpp.hpp b/sca-cpp/trunk/modules/server/mod-cpp.hpp index 1321466383..54742306b0 100644 --- a/sca-cpp/trunk/modules/server/mod-cpp.hpp +++ b/sca-cpp/trunk/modules/server/mod-cpp.hpp @@ -46,7 +46,7 @@ namespace modcpp { * Apply a C++ component implementation function. */ const list<value> failableResult(const value& func, const list<value>& v) { - if (isNil(cdr(v))) + if (isNull(cdr(v))) return v; // Report a failure with an empty reason as 'function not supported' @@ -69,7 +69,7 @@ const failable<lvvlambda > evalImplementation(const string& path, const value& i // Configure the implementation's lambda function const value ipath(attributeValue("path", impl)); const value iname(attributeValue("library", impl)); - const string fpath(isNil(ipath)? path + (string)iname : path + (string)ipath + "/" + (string)iname); + const string fpath(isNull(ipath)? path + (string)iname : path + (string)ipath + "/" + (string)iname); const lib ilib(*(new (gc_new<lib>()) lib(fpath + dynlibExt))); const failable<lvvlambda > fappl(dynlambda<const value(const list<value>&)>("apply", ilib)); if (!hasContent(fappl)) diff --git a/sca-cpp/trunk/modules/server/mod-eval.hpp b/sca-cpp/trunk/modules/server/mod-eval.hpp index 5a8a15bf43..204459e127 100644 --- a/sca-cpp/trunk/modules/server/mod-eval.hpp +++ b/sca-cpp/trunk/modules/server/mod-eval.hpp @@ -161,9 +161,9 @@ static APR_OPTIONAL_FN_TYPE(ap_authn_cache_store) *authnCacheStore = NULL; * failable monad. */ const failable<value> failableResult(const list<value>& v) { - if (isNil(cdr(v))) + if (isNull(cdr(v))) return car(v); - return mkfailure<value>(string(cadr(v)), isNil(cddr(v))? -1 : (int)caddr(v), false); + return mkfailure<value>(string(cadr(v)), isNull(cddr(v))? -1 : (int)caddr(v), false); } /** @@ -207,7 +207,7 @@ public: // Lookup the component implementation const list<value> impl(rbtreeAssoc<value>(cname, (list<value>)impls)); - if (isNil(impl)) + if (isNull(impl)) return mkfailure<value>(string("Couldn't find component implementation: ") + (string)cname); // Call its lambda function @@ -225,7 +225,7 @@ public: debug(params, "modeval::implProxy::input"); // If the reference was 'wiredByImpl' use the first param as target - if (isNil(name)) { + if (isNull(name)) { const value uri = cadr(params); const list<value> aparams = cons<value>(car(params), cddr(params)); debug(uri, "modeval::implProxy::wiredByImpl::uri"); @@ -313,7 +313,7 @@ const value mkrefProxy(const value& ref, const gc_mutable_ref<list<value> >& imp // Use an HTTP proxy or an internal proxy to the component implementation if (wbyimpl) return mkimplProxy(nilValue, impls, sslc, timeout); - if (isNil(target)) + if (isNull(target)) return mkunwiredProxy(scdl::name(ref)); if (http::isAbsolute(target)) return mkhttpProxy(target, timeout); @@ -321,7 +321,7 @@ const value mkrefProxy(const value& ref, const gc_mutable_ref<list<value> >& imp } const list<value> refProxies(const list<value>& refs, const gc_mutable_ref<list<value> >& impls, const SSLConf& sslc, const int timeout) { - if (isNil(refs)) + if (isNull(refs)) return refs; return cons(mkrefProxy(car(refs), impls, sslc, timeout), refProxies(cdr(refs), impls, sslc, timeout)); } @@ -352,7 +352,7 @@ const lvvlambda mkappPropProxy(const value& v) { if (currentRequest == NULL) return v; const RequestConf& reqc = httpd::requestConf<RequestConf>(currentRequest, &mod_tuscany_eval); - const value a = isNil((const list<value>)reqc.vpath)? v : car((const list<value>)reqc.vpath); + const value a = isNull((const list<value>)reqc.vpath)? v : car((const list<value>)reqc.vpath); debug(a, "modeval::appPropProxy::value"); return a; }; @@ -463,7 +463,7 @@ const value mkpropProxy(const value& prop) { } const list<value> propProxies(const list<value>& props) { - if (isNil(props)) + if (isNull(props)) return props; return cons(mkpropProxy(car(props)), propProxies(cdr(props))); } @@ -505,7 +505,7 @@ const value evalComponent(const string& contribPath, const value& comp, const gc * Return a list of component-name + configured-implementation pairs. */ const list<value> componentToImplementationAssoc(const list<value>& c, const string& contribPath, const gc_mutable_ref<list<value> >& impls, const lvvlambda& lifecycle, const SSLConf& sslc, const int timeout) { - if (isNil(c)) + if (isNull(c)) return c; return cons<value>(mklist<value>(scdl::name(car(c)), evalComponent(contribPath, car(c), impls, lifecycle, sslc, timeout)), @@ -531,11 +531,11 @@ const failable<list<value> > getComponents(const lvvlambda& contributor, const s return mkfailure<list<value> >(val); debug(content(val), "modeval::getComponents::val"); const list<value> valc = assoc<value>(value("content"), cdr<value>(car<value>(content(val)))); - if (isNil(valc)) + if (isNull(valc)) return mkfailure<list<value> >(string("Could not get composite: ") + name); const list<value> comp = assoc<value>(value("composite"), cdr<value>(valc)); debug(comp, "modeval::getComponents::comp"); - if (isNil(comp)) + if (isNull(comp)) return mkfailure<list<value> >(string("Could not get composite: ") + name); const failable<list<string> > x = xml::writeElements(car<value>(valuesToElements(mklist<value>(mklist<value>(comp))))); if (!hasContent(x)) @@ -548,7 +548,7 @@ const failable<list<value> > getComponents(const lvvlambda& contributor, const s * Return the functions returned by the component implementations. */ const failable<list<value> > applyLifecycleExpr(const list<value>& impls, const list<value>& expr) { - if (isNil(impls)) + if (isNull(impls)) return nilListValue; // Evaluate lifecycle expression against a component implementation lambda @@ -559,7 +559,7 @@ const failable<list<value> > applyLifecycleExpr(const list<value>& impls, const const lvvlambda rl = content(r); // Use the returned lambda function, if any, from now on - const lvvlambda al = isNil(rl)? l : rl; + const lvvlambda al = isNull(rl)? l : rl; // Continue with the rest of the list const failable<list<value> > nr = applyLifecycleExpr(cdr(impls), expr); @@ -577,7 +577,7 @@ const list<value> componentReferenceToTargetTree(const value& c) { } const list<value> componentReferenceToTargetAssoc(const list<value>& c) { - if (isNil(c)) + if (isNull(c)) return c; return cons<value>(componentReferenceToTargetTree(car(c)), componentReferenceToTargetAssoc(cdr(c))); } @@ -591,26 +591,26 @@ const list<value> defaultBindingURI(const string& cn, const string& sn) { } const list<value> bindingToComponentAssoc(const string& cn, const string& sn, const list<value>& b) { - if (isNil(b)) + if (isNull(b)) return b; const value uri(scdl::uri(car(b))); - if (isNil(uri)) + if (isNull(uri)) return cons<value>(mklist<value>(defaultBindingURI(cn, sn), cn), bindingToComponentAssoc(cn, sn, cdr(b))); return cons<value>(mklist<value>(pathValues(c_str(string(uri))), cn), bindingToComponentAssoc(cn, sn, cdr(b))); } const list<value> serviceToComponentAssoc(const string& cn, const list<value>& s) { - if (isNil(s)) + if (isNull(s)) return s; const string sn(scdl::name(car(s))); const list<value> btoc(bindingToComponentAssoc(cn, sn, scdl::bindings(car(s)))); - if (isNil(btoc)) + if (isNull(btoc)) return cons<value>(mklist<value>(defaultBindingURI(cn, sn), cn), serviceToComponentAssoc(cn, cdr(s))); return append<value>(btoc, serviceToComponentAssoc(cn, cdr(s))); } const list<value> uriToComponentAssoc(const list<value>& c) { - if (isNil(c)) + if (isNull(c)) return c; return append<value>(serviceToComponentAssoc(scdl::name(car(c)), scdl::services(car(c))), uriToComponentAssoc(cdr(c))); } @@ -625,7 +625,7 @@ const failable<Composite> confComponents(const string& contribPath, const string debug(vhost, "modeval::confComponents::vhost"); debug(impls, "modeval::confComponents::impls"); - const failable<list<value> > fcomps = isNil(contributor)? + const failable<list<value> > fcomps = isNull(contributor)? readComponents(scdl::resourcePath(length(vhost) != 0? contribPath + vhost + "/" : contribPath, composName)) : getComponents(contributor, vhost); if (!hasContent(fcomps)) @@ -641,7 +641,7 @@ const failable<Composite> confComponents(const string& contribPath, const string debug(flatten(svcs), "modeval::confComponents::svcs"); const list<value> cimpls = mkbrbtree(sort(componentToImplementationAssoc(comps, - isNil(contributor)? length(vhost) != 0? contribPath + vhost + "/" : contribPath : contribPath, + isNull(contributor)? length(vhost) != 0? contribPath + vhost + "/" : contribPath : contribPath, impls, lifecycle, sslc, timeout))); debug(flatten(cimpls), "modeval::confComponents::impls"); @@ -701,7 +701,7 @@ const failable<int> get(const list<value>& rpath, request_rec* const r, const lv const list<value> ma = assoc(value("method"), args); // Evaluate a JSON-RPC request and return a JSON result - if (!isNil(ia) && !isNil(ma)) { + if (!isNull(ia) && !isNull(ma)) { // Extract the request id, method and params const value id = cadr(ia); @@ -725,13 +725,13 @@ const failable<int> get(const list<value>& rpath, request_rec* const r, const lv debug(c, "modeval::get::content"); // Return a nil value as a not found status - if (!isList(c) && isNil(c)) + if (!isList(c) && isNull(c)) return HTTP_NOT_FOUND; // Write in the format requested by the client, if any const list<value> fmt = assoc<value>("format", args); - const value mtype = !isNil(fmt)? cadr(fmt) : acceptMediaType(r); - if (!isNil(mtype)) { + const value mtype = !isNull(fmt)? cadr(fmt) : acceptMediaType(r); + if (!isNull(mtype)) { if (mtype == "scheme") return httpd::writeResult(scheme::writeValue(c), "text/x-scheme; charset=utf-8", r); if (mtype == "json") @@ -747,26 +747,26 @@ const failable<int> get(const list<value>& rpath, request_rec* const r, const lv } // Write an empty list as a JSON value - if (isNil((list<value>)c)) { + if (isNull((list<value>)c)) { debug(nilListValue, "modeval::get::empty"); return httpd::writeResult(json::writeValue(c), "application/json; charset=utf-8", r); } // Write content-type / content-list pair - if (isString(car<value>(c)) && !isNil(cdr<value>(c)) && isList(cadr<value>(c))) + if (isString(car<value>(c)) && !isNull(cdr<value>(c)) && isList(cadr<value>(c))) return httpd::writeResult(convertValues<string>(cadr<value>(c)), car<value>(c), r); // Write an assoc value as a JSON value - if (isSymbol(car<value>(c)) && !isNil(cdr<value>(c))) { + if (isSymbol(car<value>(c)) && !isNull(cdr<value>(c))) { debug(c, "modeval::get::assoc"); return httpd::writeResult(json::writeValue(c), "application/json; charset=utf-8", r); } // Write an ATOM feed or entry const list<value> e = valuesToElements(c); - if (isList(car<value>(e)) && !isNil(car<value>(e))) { + if (isList(car<value>(e)) && !isNull(car<value>(e))) { const list<value> el = car<value>(e); - if (isSymbol(car<value>(el)) && car<value>(el) == element && !isNil(cdr<value>(el)) && isSymbol(cadr<value>(el)) && elementHasChildren(el) && !elementHasValue(el)) { + if (isSymbol(car<value>(el)) && car<value>(el) == element && !isNull(cdr<value>(el)) && isSymbol(cadr<value>(el)) && elementHasChildren(el) && !elementHasValue(el)) { if (cadr<value>(el) == atom::feed) return httpd::writeResult(atom::writeATOMFeed(e), "application/atom+xml; charset=utf-8", r); if (cadr<value>(el) == atom::entry) @@ -829,7 +829,7 @@ const failable<int> post(const list<value>& rpath, request_rec* const r, const l // Report HTTP status code const value rval = content(val); - if (isNil(rval) || rval == falseValue) + if (isNull(rval) || rval == falseValue) return HTTP_NOT_FOUND; if (isNumber(rval)) return (int)rval; @@ -870,7 +870,7 @@ const failable<int> put(const list<value>& rpath, request_rec* const r, const lv // Report HTTP status const value rval = content(val); - if (isNil(rval) || rval == falseValue) + if (isNull(rval) || rval == falseValue) return HTTP_NOT_FOUND; if (isNumber(rval)) return (int)rval; @@ -898,7 +898,7 @@ const failable<int> patch(const list<value>& rpath, request_rec* const r, const // Report HTTP status const value rval = content(val); - if (isNil(rval) || rval == falseValue) + if (isNull(rval) || rval == falseValue) return HTTP_NOT_FOUND; if (isNumber(rval)) return (int)rval; @@ -918,7 +918,7 @@ const failable<int> del(const list<value>& rpath, request_rec* const r, const lv // Report HTTP status const value rval = content(val); - if (isNil(rval) || rval == falseValue) + if (isNull(rval) || rval == falseValue) return HTTP_NOT_FOUND; if (isNumber(rval)) return (int)rval; @@ -954,10 +954,10 @@ int translateComponent(request_rec* const r, const list<value>& rpath, const lis debug(flatten(impls), "modeval::translateComponent::impls"); // Find the requested component - if (isNil(cdr(rpath))) + if (isNull(cdr(rpath))) return HTTP_NOT_FOUND; const list<value> impl(rbtreeAssoc(cadr(rpath), impls)); - if (isNil(impl)) + if (isNull(impl)) return HTTP_NOT_FOUND; debug(impl, "modeval::translateComponent::impl"); @@ -973,16 +973,16 @@ int translateReference(request_rec* const r, const list<value>& rpath, const lis debug(flatten(refs), "modeval::translateReference::refs"); // Find the requested component - if (isNil(cdr(rpath))) + if (isNull(cdr(rpath))) return HTTP_NOT_FOUND; const list<value> comp(rbtreeAssoc(cadr(rpath), refs)); - if (isNil(comp)) + if (isNull(comp)) return HTTP_NOT_FOUND; debug(comp, "modeval::translateReference::comp"); // Find the requested reference and target configuration const list<value> ref(rbtreeAssoc<value>(caddr(rpath), cadr(comp))); - if (isNil(ref)) + if (isNull(ref)) return HTTP_NOT_FOUND; debug(ref, "modeval::translateReference::ref"); @@ -1014,9 +1014,9 @@ int translateReference(request_rec* const r, const list<value>& rpath, const lis * Find a leaf matching a request path in a tree of URI paths. */ const int matchPath(const list<value>& k, const list<value>& p) { - if (isNil(p)) + if (isNull(p)) return true; - if (isNil(k)) + if (isNull(k)) return false; if (car(k) != car(p)) return false; @@ -1024,7 +1024,7 @@ const int matchPath(const list<value>& k, const list<value>& p) { } const list<value> assocPath(const value& k, const list<value>& tree) { - if (isNil(tree)) + if (isNull(tree)) return tree; if (matchPath(k, car<value>(car(tree)))) return car(tree); @@ -1041,10 +1041,10 @@ int translateService(request_rec* const r, const list<value>& rpath, const list< debug(flatten(svcs), "modeval::translateService::svcs"); // Find the requested component - if (isNil(rpath)) + if (isNull(rpath)) return HTTP_NOT_FOUND; const list<value> svc(assocPath(rpath, svcs)); - if (isNil(svc)) + if (isNull(svc)) return DECLINED; debug(svc, "modeval::translateService::svc"); @@ -1061,7 +1061,7 @@ int translateService(request_rec* const r, const list<value>& rpath, const list< const int translateRequest(request_rec* const r, const list<value>& rpath, const list<value>& vpath, const list<value>& refs, const list<value>& svcs, const list<value>& impls) { debug(vpath, "modeval::translateRequest::vpath"); debug(rpath, "modeval::translateRequest::rpath"); - const string prefix = isNil(rpath)? emptyStringValue : car(rpath); + const string prefix = isNull(rpath)? emptyStringValue : car(rpath); // Translate a component request if ((prefix == string("components") || prefix == string("c")) && translateComponent(r, rpath, vpath, impls) == OK) @@ -1076,7 +1076,7 @@ const int translateRequest(request_rec* const r, const list<value>& rpath, const return proceedToHandler(r, OK); // Attempt to map a request targeting the main host to an actual file - if (isNil(vpath)) { + if (isNull(vpath)) { const failable<request_rec*> fnr = httpd::internalSubRequest(r->uri, r); if (!hasContent(fnr)) return rcode(fnr); @@ -1095,7 +1095,7 @@ const int translateRequest(request_rec* const r, const list<value>& rpath, const // Make sure a document root request ends with a '/' using // an external redirect - if (isNil(rpath) && r->uri[strlen(r->uri) - 1] != '/') { + if (isNull(rpath) && r->uri[strlen(r->uri) - 1] != '/') { const string target = string(r->uri) + string("/") + (r->args != NULL? string("?") + string(r->args) : emptyString); debug(target, "modeval::translateRequest::location"); return proceedToHandler(r, httpd::externalRedirect(target, r)); @@ -1128,7 +1128,7 @@ int translate(request_rec *r) { const list<value> rpath = pathValues(r->uri); // Let default handler handle a resource request - const string prefix = isNil(rpath)? emptyStringValue : car(rpath); + const string prefix = isNull(rpath)? emptyStringValue : car(rpath); if (prefix == string("vhosts") || prefix == string("v")) return DECLINED; @@ -1137,7 +1137,7 @@ int translate(request_rec *r) { // If the request is targeting a virtual host, configure the components // in that virtual host - if (length(sc.vhostc.domain) != 0 && (length(sc.vhostc.contribPath) != 0 || !isNil(sc.vhostc.contributor)) && httpd::isVhostRequest(sc.server, sc.vhostc.domain, r)) { + if (length(sc.vhostc.domain) != 0 && (length(sc.vhostc.contribPath) != 0 || !isNull(sc.vhostc.contributor)) && httpd::isVhostRequest(sc.server, sc.vhostc.domain, r)) { const string vname = http::subDomain(httpd::hostName(r)); const failable<Composite> fvcompos = confComponents(sc.vhostc.contribPath, sc.vhostc.composName, sc.vhostc.contributor, vname, reqc.impls, (value)sc.lifecycle, sc.sslc, sc.timeout); if (!hasContent(fvcompos)) @@ -1158,7 +1158,7 @@ int translate(request_rec *r) { return rc; // Attempt to map the first segment of the request path to a virtual host - if (length(prefix) != 0 && (length(sc.vhostc.contribPath) != 0 || !isNil(sc.vhostc.contributor))) { + if (length(prefix) != 0 && (length(sc.vhostc.contribPath) != 0 || !isNull(sc.vhostc.contributor))) { const string vname = prefix; const failable<Composite> fvcompos = confComponents(sc.vhostc.contribPath, sc.vhostc.composName, sc.vhostc.contributor, vname, reqc.impls, (value)sc.lifecycle, sc.sslc, sc.timeout); if (!hasContent(fvcompos)) @@ -1180,7 +1180,7 @@ const int handleRequest(const list<value>& rpath, request_rec* const r, const li // Get the component implementation lambda const list<value> impl(rbtreeAssoc<value>(cadr(rpath), impls)); - if (isNil(impl)) { + if (isNull(impl)) { mkfailure<int>(string("Couldn't find component implementation: ") + (string)cadr(rpath)); return HTTP_NOT_FOUND; } @@ -1233,14 +1233,14 @@ int handler(request_rec* r) { debug(redir, "modeval::handler::internalredirect"); return httpd::internalRedirect(redir, r); } - if (isNil((const list<value>)reqc.rpath)) + if (isNull((const list<value>)reqc.rpath)) return HTTP_NOT_FOUND; // Get the server configuration const ServerConf& sc = httpd::serverConf<ServerConf>(r, &mod_tuscany_eval); // Handle a request targeting a component in a virtual host - if (!isNil((const list<value>)reqc.vpath)) { + if (!isNull((const list<value>)reqc.vpath)) { // Start the components in the virtual host const failable<list<value> > fsimpls = startComponents(reqc.impls); @@ -1280,7 +1280,7 @@ authn_status checkPassword(request_rec* r, const char* u, const char* p) { // Get the server configuration const ServerConf& sc = httpd::serverConf<ServerConf>(r, &mod_tuscany_eval); - if (isNil(sc.vhostc.authenticator)) { + if (isNull(sc.vhostc.authenticator)) { mkfailure<int>("SCA authenticator not configured"); return AUTH_GENERAL_ERROR; } @@ -1293,9 +1293,9 @@ authn_status checkPassword(request_rec* r, const char* u, const char* p) { return AUTH_USER_NOT_FOUND; } const value hval = content(val); - const list<value> hcontent = isList(hval) && !isNil(hval) && isList(car<value>(hval)) && !isNil(car<value>(hval))? assoc<value>(value("content"), cdr<value>(car<value>(hval))) : nilListValue; - const list<value> hassoc = isNil(hcontent)? nilListValue : assoc<value>(value("hash"), cdr<value>(hcontent)); - if (isNil(hassoc)) { + const list<value> hcontent = isList(hval) && !isNull(hval) && isList(car<value>(hval)) && !isNull(car<value>(hval))? assoc<value>(value("content"), cdr<value>(car<value>(hval))) : nilListValue; + const list<value> hassoc = isNull(hcontent)? nilListValue : assoc<value>(value("hash"), cdr<value>(hcontent)); + if (isNull(hassoc)) { mkfailure<int>(string("SCA authentication check user failed, hash not found: ") + user, -1, user != "admin"); return AUTH_USER_NOT_FOUND; } @@ -1330,10 +1330,10 @@ apr_status_t serverCleanup(void* v) { stopComponents(sc.compos.impls); // Call the module lifecycle function - if (isNil((value)sc.lifecycle)) + if (isNull((value)sc.lifecycle)) return APR_SUCCESS; const lvvlambda ll = (value)sc.lifecycle; - if (isNil(ll)) + if (isNull(ll)) return APR_SUCCESS; debug((value)sc.lifecycle, "modeval::serverCleanup::stop"); @@ -1449,7 +1449,7 @@ void childInit(apr_pool_t* p, server_rec* s) { // Get the vhost contributor component implementation lambda if (length(sc.vhostc.contributorName) != 0) { const list<value> impl(rbtreeAssoc<value>((string)sc.vhostc.contributorName, (const list<value>)sc.compos.impls)); - if (isNil(impl)) { + if (isNull(impl)) { mkfailure<int>(string("Couldn't find contributor component implementation: ") + sc.vhostc.contributorName); failureExitChild(); } @@ -1459,7 +1459,7 @@ void childInit(apr_pool_t* p, server_rec* s) { // Get the vhost authenticator component implementation lambda if (length(sc.vhostc.authenticatorName) != 0) { const list<value> impl(rbtreeAssoc<value>((string)sc.vhostc.authenticatorName, (const list<value>)sc.compos.impls)); - if (isNil(impl)) { + if (isNull(impl)) { mkfailure<int>(string("Couldn't find authenticator component implementation: ") + sc.vhostc.authenticatorName); failureExitChild(); } diff --git a/sca-cpp/trunk/modules/server/mod-scheme.hpp b/sca-cpp/trunk/modules/server/mod-scheme.hpp index 36d91dc904..6a387a0991 100644 --- a/sca-cpp/trunk/modules/server/mod-scheme.hpp +++ b/sca-cpp/trunk/modules/server/mod-scheme.hpp @@ -43,7 +43,7 @@ namespace modscheme { * Convert proxy lambdas to evaluator primitive procedures. */ const list<value> primitiveProcedures(const list<value>& l) { - if (isNil(l)) + if (isNull(l)) return l; return cons<value>(mklist<value>(scheme::primitiveSymbol, car(l)), primitiveProcedures(cdr(l))); } @@ -58,7 +58,7 @@ const failable<lvvlambda > evalImplementation(const string& path, const value& i if (fail(is)) return mkfailure<lvvlambda >(string("Could not read implementation: ") + fpath); const value script = scheme::readScript(is); - if (isNil(script)) + if (isNull(script)) return mkfailure<lvvlambda >(string("Could not read implementation: ") + fpath); const list<value> pxproc = scheme::quotedParameters(primitiveProcedures(px)); @@ -68,7 +68,7 @@ const failable<lvvlambda > evalImplementation(const string& path, const value& i debug(expr, "modeval::scheme::applyImplementation::input"); scheme::Env env = scheme::setupEnvironment(); const value res = scheme::evalScript(expr, script, env); - const value val = isNil(res)? mklist<value>(nilValue, string("Could not evaluate expression")) : mklist<value>(res); + const value val = isNull(res)? mklist<value>(nilValue, string("Could not evaluate expression")) : mklist<value>(res); debug(val, "modeval::scheme::applyImplementation::result"); return val; }; diff --git a/sca-cpp/trunk/modules/wsgi/atomutil.py b/sca-cpp/trunk/modules/wsgi/atomutil.py index 4b67ef216e..d65b26c41c 100644 --- a/sca-cpp/trunk/modules/wsgi/atomutil.py +++ b/sca-cpp/trunk/modules/wsgi/atomutil.py @@ -24,23 +24,23 @@ from xmlutil import * # Convert a list of elements to a list of values representing an ATOM entry def entryElementValues(e): lt = filter(selector((element, "'title")), e) - t = "" if isNil(lt) else elementValue(car(lt)) + t = "" if isNull(lt) else elementValue(car(lt)) li = filter(selector((element, "'id")), e) - i = "" if isNil(li) else elementValue(car(li)) + i = "" if isNull(li) else elementValue(car(li)) lc = filter(selector((element, "'content")), e) return append((element, "'entry", (element, "'title", t), (element, "'id", i)), - () if isNil(lc) else () if isAttribute(elementValue(car(lc))) else ((element, "'content", elementValue(car(lc))),)) + () if isNull(lc) else () if isAttribute(elementValue(car(lc))) else ((element, "'content", elementValue(car(lc))),)) # Convert a list of elements to a list of values representing ATOM entries def entriesElementValues(e): - if isNil(e): + if isNull(e): return e return cons(entryElementValues(car(e)), entriesElementValues(cdr(e))) # Convert a list of strings to a list of values representing an ATOM entry def readATOMEntry(l): e = readXML(l) - if isNil(e): + if isNull(e): return () return (entryElementValues(car(e)),) @@ -59,7 +59,7 @@ def isATOMEntry(l): # Convert a list of strings to a list of values representing an ATOM feed def readATOMFeed(l): f = readXML(l) - if isNil(f): + if isNull(f): return () t = filter(selector((element, "'title")), car(f)) i = filter(selector((element, "'id")), car(f)) @@ -73,44 +73,44 @@ def entryElement(l): title = elementValue(namedElementChild("'title", l)) id = elementValue(namedElementChild("'id", l)) content = namedElementChild("'content", l) - text = False if isNil(content) else elementHasValue(content) + text = False if isNull(content) else elementHasValue(content) return append(append( (element, "'entry", (attribute, "'xmlns", "http://www.w3.org/2005/Atom"), (element, "'title", (attribute, "'type", "text"), title), (element, "'id", id)), - () if isNil(content) else (append( + () if isNull(content) else (append( (element, "'content", (attribute, "'type", "text" if text else "application/xml")), (elementValue(content),) if text else elementChildren(content)),)), ((element, "'link", (attribute, "'href", id)),)) # Convert a list of values representing ATOM entries to a list of elements def entriesElements(l): - if isNil(l): + if isNull(l): return l return cons(entryElement(car(l)), entriesElements(cdr(l))) # Convert a list of values representing an ATOM entry to an ATOM entry def writeATOMEntry(ll): - l = ll if isNil(ll) else car(ll) + l = ll if isNull(ll) else car(ll) return writeXML((entryElement(l),), True) # Convert a list of values representing an ATOM feed to an ATOM feed def writeATOMFeed(ll): - l = ll if isNil(ll) else car(ll) + l = ll if isNull(ll) else car(ll) lt = filter(selector((element, "'title")), l) - t = '' if isNil(lt) else elementValue(car(lt)) + t = '' if isNull(lt) else elementValue(car(lt)) li = filter(selector((element, "'id")), l) - i = '' if isNil(li) else elementValue(car(li)) + i = '' if isNull(li) else elementValue(car(li)) f = (element, "'feed", (attribute, "'xmlns", "http://www.w3.org/2005/Atom"), (element, "'title", (attribute, "'type", "text"), t), (element, "'id", i)) # Write ATOM entries le = filter(selector((element, "'entry")), l) - if isNil(le): + if isNull(le): return writeXML((f,), True) # Write a single ATOM entry element with a list of values - if not isNil(le) and not isNil(car(le)) and isList(car(caddr(car(le)))): + if not isNull(le) and not isNull(car(le)) and isList(car(caddr(car(le)))): fe = append(f, entriesElements(caddr(car(le)))) return writeXML((fe,), True) diff --git a/sca-cpp/trunk/modules/wsgi/composite.py b/sca-cpp/trunk/modules/wsgi/composite.py index 77f2ecdb59..fbec66dc33 100755 --- a/sca-cpp/trunk/modules/wsgi/composite.py +++ b/sca-cpp/trunk/modules/wsgi/composite.py @@ -59,7 +59,7 @@ def requestIfNoneMatch(e): # Hash a list of strings into an MD5 signature def md5update(md, s): - if isNil(s): + if isNull(s): return md.hexdigest() md.update(car(s)) return md5update(md, cdr(s)) @@ -113,7 +113,7 @@ def fileresult(e, r, ct, f): # Converts the args received in a POST to a list of key value pairs def postArgs(a): - if isNil(a): + if isNull(a): return ((),) l = car(a); return cons(l, postArgs(cdr(a))) @@ -188,16 +188,16 @@ def application(e, r): return result(e, r, 200, (("Content-type", "application/json"),), writeJSON(())) # Write content-type / content-list pair - if isString(car(v)) and not isNil(cdr(v)) and isList(cadr(v)): + if isString(car(v)) and not isNull(cdr(v)) and isList(cadr(v)): return result(e, r, 200, (("Content-type", car(v)),), cadr(v)) # Convert list of values to element values ve = valuesToElements(v) # Write an assoc result as a JSON value - if isList(car(ve)) and not isNil(car(ve)): + if isList(car(ve)) and not isNull(car(ve)): el = car(ve) - if isSymbol(car(el)) and car(el) == element and not isNil(cdr(el)) and isSymbol(cadr(el)): + if isSymbol(car(el)) and car(el) == element and not isNull(cdr(el)) and isSymbol(cadr(el)): if cadr(el) == "'feed": return result(e, r, 200, (("Content-type", "application/atom+xml"),), writeATOMFeed(ve)) if cadr(el) == "'entry": @@ -224,7 +224,7 @@ def application(e, r): if contains(ct, "application/atom+xml"): ae = elementsToValues(readATOMEntry(requestBody(e))) v = comp("post", id, ae) - if isNil(v): + if isNull(v): return failure(e, r, 500) return result(e, r, 201, (("Location", request_uri(e) + "/" + "/".join(v)),)) return failure(e, r, 500) diff --git a/sca-cpp/trunk/modules/wsgi/elemutil.py b/sca-cpp/trunk/modules/wsgi/elemutil.py index 00b76c5c6e..bb176e7ffe 100644 --- a/sca-cpp/trunk/modules/wsgi/elemutil.py +++ b/sca-cpp/trunk/modules/wsgi/elemutil.py @@ -25,13 +25,13 @@ atsign = "'@" # Return true if a value is an element def isElement(v): - if not isList(v) or isNil(v) or v == None or car(v) != element: + if not isList(v) or isNull(v) or v == None or car(v) != element: return False return True # Return true if a value is an attribute def isAttribute(v): - if not isList(v) or isNil(v) or v == None or car(v) != attribute: + if not isList(v) or isNull(v) or v == None or car(v) != attribute: return False return True @@ -49,7 +49,7 @@ def elementName(l): # Return true if an element has children def elementHasChildren(l): - return not isNil(cddr(l)) + return not isNull(cddr(l)) # Return the children of an element def elementChildren(l): @@ -60,7 +60,7 @@ def elementHasValue(l): r = reverse(l) if isSymbol(car(r)): return False - if isList(car(r)) and not isNil(car(r)) and isSymbol(car(car(r))): + if isList(car(r)) and not isNull(car(r)) and isSymbol(car(car(r))): return False return True @@ -72,7 +72,7 @@ def elementValue(l): def elementToValueIsList(v): if not isList(v): return False - return isNil(v) or not isSymbol(car(v)) + return isNull(v) or not isSymbol(car(v)) def elementToValue(t): if isTaggedList(t, attribute): @@ -91,14 +91,14 @@ def elementToValue(t): def elementToValueIsSymbol(v): if not isList(v): return False - if (isNil(v)): + if (isNull(v)): return False if not isSymbol(car(v)): return False return True def elementToValueGroupValues(v, l): - if isNil(l) or not elementToValueIsSymbol(v) or not elementToValueIsSymbol(car(l)): + if isNull(l) or not elementToValueIsSymbol(v) or not elementToValueIsSymbol(car(l)): return cons(v, l) if car(car(l)) != car(v): return cons(v, l) @@ -109,20 +109,20 @@ def elementToValueGroupValues(v, l): return elementToValueGroupValues(g, cdr(l)) def elementsToValues(e): - if isNil(e): + if isNull(e): return e return elementToValueGroupValues(elementToValue(car(e)), elementsToValues(cdr(e))) # Convert a value to an element def valueToElement(t): - if isList(t) and not isNil(t) and isSymbol(car(t)): + if isList(t) and not isNull(t) and isSymbol(car(t)): n = car(t) - v = () if isNil(cdr(t)) else cadr(t) + v = () if isNull(cdr(t)) else cadr(t) if not isList(v): if n[0:2] == atsign: return (attribute, "'" + n[2:], v) return (element, n, v) - if isNil(v) or not isSymbol(car(v)): + if isNull(v) or not isSymbol(car(v)): return cons(element, cons(n, (valuesToElements(v),))) return cons(element, cons(n, valuesToElements(cdr(t)))) if not isList(t): @@ -131,15 +131,15 @@ def valueToElement(t): # Convert a list of values to a list of elements def valuesToElements(l): - if isNil(l): + if isNull(l): return l return cons(valueToElement(car(l)), valuesToElements(cdr(l))) # Return a selector lambda function which can be used to filter elements def evalSelect(s, v): - if isNil(s): + if isNull(s): return True - if isNil(v): + if isNull(v): return False if car(s) != car(v): return False @@ -151,7 +151,7 @@ def selector(s): # Return the value of the attribute with the given name def namedAttributeValue(name, l): f = filter(lambda v: isAttribute(v) and attributeName(v) == name, l) - if isNil(f): + if isNull(f): return None return caddr(car(f)) @@ -162,7 +162,7 @@ def namedElementChildren(name, l): # Return the child element with the given name def namedElementChild(name, l): f = namedElementChildren(name, l) - if isNil(f): + if isNull(f): return None return car(f) diff --git a/sca-cpp/trunk/modules/wsgi/jsonutil.py b/sca-cpp/trunk/modules/wsgi/jsonutil.py index 849b44405b..f284fd1a89 100644 --- a/sca-cpp/trunk/modules/wsgi/jsonutil.py +++ b/sca-cpp/trunk/modules/wsgi/jsonutil.py @@ -28,19 +28,19 @@ from elemutil import * # Return true if a list represents a JS array def isJSArray(l): - if isNil(l): + if isNull(l): return True v = car(l) if isSymbol(v): return False if isList(v): - if not isNil(v) and isSymbol(car(v)): + if not isNull(v) and isSymbol(car(v)): return False return True # Converts JSON properties to values def jsPropertiesToValues(propertiesSoFar, o, i): - if isNil(i): + if isNull(i): return propertiesSoFar p = car(i) jsv = o[p] @@ -69,7 +69,7 @@ def jsValToValue(jsv): # Return true if a list of strings contains a JSON document def isJSON(l): - if isNil(l): + if isNull(l): return False s = car(l)[0:1] return s == "[" or s == "{" @@ -83,7 +83,7 @@ def readJSON(l): # Convert a list of values to JSON array elements def valuesToJSElements(a, l, i): - if isNil(l): + if isNull(l): return a pv = valueToJSVal(car(l)) a[i] = pv @@ -99,7 +99,7 @@ def valueToJSVal(v): # Convert a list of values to JSON properties def valuesToJSProperties(o, l): - if isNil(l): + if isNull(l): return o token = car(l) if isTaggedList(token, attribute): diff --git a/sca-cpp/trunk/modules/wsgi/rssutil.py b/sca-cpp/trunk/modules/wsgi/rssutil.py index 984d71b690..c1b326c82d 100644 --- a/sca-cpp/trunk/modules/wsgi/rssutil.py +++ b/sca-cpp/trunk/modules/wsgi/rssutil.py @@ -24,22 +24,22 @@ from xmlutil import * # Convert a list of elements to a list of values representing an RSS entry def entryElementsToValues(e): lt = filter(selector((element, "'title")), e) - t = "" if isNil(lt) else elementValue(car(lt)) + t = "" if isNull(lt) else elementValue(car(lt)) li = filter(selector((element, "'link")), e) - i = "" if isNil(li) else elementValue(car(li)) + i = "" if isNull(li) else elementValue(car(li)) lc = filter(selector((element, "'description")), e) return (t, i, elementValue(car(lc))) # Convert a list of elements to a list of values representing RSS entries def entriesElementsToValues(e): - if isNil(e): + if isNull(e): return e return cons(entryElementsToValues(car(e)), entriesElementsToValues(cdr(e))) # Convert a list of strings to a list of values representing an RSS entry def readRSSEntry(l): e = readXML(l) - if isNil(e): + if isNull(e): return () return entryElementsToValues(car(e)) @@ -57,19 +57,19 @@ def isRSSFeed(l): # Convert a list of strings to a list of values representing an RSS feed def readRSSFeed(l): f = readXML(l) - if isNil(f): + if isNull(f): return () c = filter(selector((element, "'channel")), car(f)) t = filter(selector((element, "'title")), car(c)) i = filter(selector((element, "'link")), car(c)) e = filter(selector((element, "'item")), car(c)) - if isNil(e): + if isNull(e): return (elementValue(car(t)), elementValue(car(i))) return cons(elementValue(car(t)), cons(elementValue(car(i)), entriesElementsToValues(e))) # Convert an RSS feed containing elements to an RSS feed containing values def feedValuesLoop(e): - if (isNil(e)): + if (isNull(e)): return e return cons(entryValue(car(e)), feedValuesLoop(cdr(e))) @@ -85,7 +85,7 @@ def entryElement(l): # Convert a list of values representing RSS entries to a list of elements def entriesElements(l): - if isNil(l): + if isNull(l): return l return cons(entryElement(car(l)), entriesElements(cdr(l))) @@ -98,7 +98,7 @@ def writeRSSFeed(l): c = ((element, "'title", car(l)), (element, "'link", cadr(l)), (element, "'description", car(l))) - ce = c if isNil(cddr(l)) else append(c, entriesElements(cddr(l))) + ce = c if isNull(cddr(l)) else append(c, entriesElements(cddr(l))) fe = (element, "'rss", (attribute, "'version", "2.0"), append((element, "'channel"), ce)) return writeXML((fe,), True) @@ -108,7 +108,7 @@ def entryValuesToElements(v): # Convert an RSS feed containing values to an RSS feed containing elements def feedValuesToElementsLoop(v): - if isNil(v): + if isNull(v): return v return cons(entryValuesToElements(car(v)), feedValuesToElementsLoop(cdr(v))) diff --git a/sca-cpp/trunk/modules/wsgi/util.py b/sca-cpp/trunk/modules/wsgi/util.py index f630455901..97931c0c09 100644 --- a/sca-cpp/trunk/modules/wsgi/util.py +++ b/sca-cpp/trunk/modules/wsgi/util.py @@ -57,9 +57,9 @@ def reverse(l): r.reverse() return tuple(r) -def isNil(l): +def isNull(l): if isinstance(l, streampair): - return l.isNil() + return l.isNull() return l is None or l == () def isSymbol(v): @@ -76,7 +76,7 @@ def isList(v): return True def isTaggedList(v, t): - return isList(v) and not isNil(v) and car(v) == t + return isList(v) and not isNull(v) and car(v) == t # Scheme-like streams @@ -88,7 +88,7 @@ class streampair(object): def __repr__(self): return repr(self[0:len(self)]) - def isNil(self): + def isNull(self): return self.cdr == () def __len__(self): @@ -102,7 +102,7 @@ class streampair(object): return self.cdr()[i - 1] def __getslice__(self, i, j): - if isNil(self): + if isNull(self): return () if i > 0: if j == maxint: @@ -156,7 +156,7 @@ def curry(f, *args): # Convert a path represented as a list of values to a string def path(p): - if isNil(p): + if isNull(p): return "" return "/" + car(p) + path(cdr(p)) diff --git a/sca-cpp/trunk/modules/wsgi/xmlutil.py b/sca-cpp/trunk/modules/wsgi/xmlutil.py index 83b1cf2f92..bc1a1b376a 100644 --- a/sca-cpp/trunk/modules/wsgi/xmlutil.py +++ b/sca-cpp/trunk/modules/wsgi/xmlutil.py @@ -46,7 +46,7 @@ def readElements(l): # Return true if a list of strings represents an XML document def isXML(l): - if isNil(l): + if isNull(l): return False if car(l)[0:5] != "<?xml": return False @@ -86,12 +86,12 @@ def readXML(l): # Write a list of XML element and attribute tokens def expandElementValues(n, l): - if isNil(l): + if isNull(l): return l return cons(cons(element, cons(n, car(l))), expandElementValues(n, cdr(l))) def writeList(l, xml): - if isNil(l): + if isNull(l): return xml token = car(l) if isTaggedList(token, attribute): diff --git a/sca-cpp/trunk/modules/xml/xml.hpp b/sca-cpp/trunk/modules/xml/xml.hpp index 0a04d5f90a..70747e2157 100644 --- a/sca-cpp/trunk/modules/xml/xml.hpp +++ b/sca-cpp/trunk/modules/xml/xml.hpp @@ -192,7 +192,7 @@ inline const value readToken(XMLReader& reader) { */ inline const list<value> readList(const list<value>& listSoFar, XMLReader& reader) { const value token = readToken(reader); - if(isNil(token) || endElement == token) + if(isNull(token) || endElement == token) return reverse(listSoFar); if(startElement == token) return readList(cons<value>(readList(mklist(element), reader), listSoFar), reader); @@ -225,7 +225,7 @@ public: */ inline int readCallback(void *context, char* buffer, int len) { XMLReadContext& rc = *(XMLReadContext*)context; - if (isNil((const list<string>)rc.ilist)) + if (isNull((const list<string>)rc.ilist)) return 0; const list<string> f(fragment(rc.ilist, len)); const string s(car(f)); @@ -238,7 +238,7 @@ inline int readCallback(void *context, char* buffer, int len) { * Return true if a list of strings contains an XML document. */ inline const bool isXML(const list<string>& ls) { - if (isNil(ls)) + if (isNull(ls)) return false; return substr(car(ls), 0, 5) == "<?xml"; } @@ -266,13 +266,13 @@ const char* const encoding = "UTF-8"; * Write a list of XML element or attribute tokens. */ inline const list<value> expandElementValues(const value& n, const list<value>& l) { - if (isNil(l)) + if (isNull(l)) return l; return cons<value>(value(cons<value>(element, cons<value>(n, isList(car(l))? (list<value>)car(l) : mklist(car(l))))), expandElementValues(n, cdr(l))); } inline const failable<bool> writeList(const list<value>& l, const xmlTextWriterPtr xml) { - if (isNil(l)) + if (isNull(l)) return true; // Write an attribute |