From 2853156a2bce535bcaa440c37cf872916f76c03b Mon Sep 17 00:00:00 2001 From: jsdelfino Date: Thu, 3 Jan 2013 08:10:25 +0000 Subject: Refactoring, rename isNil to isNull. git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@1428206 13f79535-47bb-0310-9956-ffa450edef68 --- sca-cpp/trunk/modules/server/mod-eval.hpp | 122 +++++++++++++++--------------- 1 file changed, 61 insertions(+), 61 deletions(-) (limited to 'sca-cpp/trunk/modules/server/mod-eval.hpp') 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 failableResult(const list& v) { - if (isNil(cdr(v))) + if (isNull(cdr(v))) return car(v); - return mkfailure(string(cadr(v)), isNil(cddr(v))? -1 : (int)caddr(v), false); + return mkfailure(string(cadr(v)), isNull(cddr(v))? -1 : (int)caddr(v), false); } /** @@ -207,7 +207,7 @@ public: // Lookup the component implementation const list impl(rbtreeAssoc(cname, (list)impls)); - if (isNil(impl)) + if (isNull(impl)) return mkfailure(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 aparams = cons(car(params), cddr(params)); debug(uri, "modeval::implProxy::wiredByImpl::uri"); @@ -313,7 +313,7 @@ const value mkrefProxy(const value& ref, const gc_mutable_ref >& 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 >& imp } const list refProxies(const list& refs, const gc_mutable_ref >& 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(currentRequest, &mod_tuscany_eval); - const value a = isNil((const list)reqc.vpath)? v : car((const list)reqc.vpath); + const value a = isNull((const list)reqc.vpath)? v : car((const list)reqc.vpath); debug(a, "modeval::appPropProxy::value"); return a; }; @@ -463,7 +463,7 @@ const value mkpropProxy(const value& prop) { } const list propProxies(const list& 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 componentToImplementationAssoc(const list& c, const string& contribPath, const gc_mutable_ref >& impls, const lvvlambda& lifecycle, const SSLConf& sslc, const int timeout) { - if (isNil(c)) + if (isNull(c)) return c; return cons(mklist(scdl::name(car(c)), evalComponent(contribPath, car(c), impls, lifecycle, sslc, timeout)), @@ -531,11 +531,11 @@ const failable > getComponents(const lvvlambda& contributor, const s return mkfailure >(val); debug(content(val), "modeval::getComponents::val"); const list valc = assoc(value("content"), cdr(car(content(val)))); - if (isNil(valc)) + if (isNull(valc)) return mkfailure >(string("Could not get composite: ") + name); const list comp = assoc(value("composite"), cdr(valc)); debug(comp, "modeval::getComponents::comp"); - if (isNil(comp)) + if (isNull(comp)) return mkfailure >(string("Could not get composite: ") + name); const failable > x = xml::writeElements(car(valuesToElements(mklist(mklist(comp))))); if (!hasContent(x)) @@ -548,7 +548,7 @@ const failable > getComponents(const lvvlambda& contributor, const s * Return the functions returned by the component implementations. */ const failable > applyLifecycleExpr(const list& impls, const list& expr) { - if (isNil(impls)) + if (isNull(impls)) return nilListValue; // Evaluate lifecycle expression against a component implementation lambda @@ -559,7 +559,7 @@ const failable > applyLifecycleExpr(const list& 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 > nr = applyLifecycleExpr(cdr(impls), expr); @@ -577,7 +577,7 @@ const list componentReferenceToTargetTree(const value& c) { } const list componentReferenceToTargetAssoc(const list& c) { - if (isNil(c)) + if (isNull(c)) return c; return cons(componentReferenceToTargetTree(car(c)), componentReferenceToTargetAssoc(cdr(c))); } @@ -591,26 +591,26 @@ const list defaultBindingURI(const string& cn, const string& sn) { } const list bindingToComponentAssoc(const string& cn, const string& sn, const list& b) { - if (isNil(b)) + if (isNull(b)) return b; const value uri(scdl::uri(car(b))); - if (isNil(uri)) + if (isNull(uri)) return cons(mklist(defaultBindingURI(cn, sn), cn), bindingToComponentAssoc(cn, sn, cdr(b))); return cons(mklist(pathValues(c_str(string(uri))), cn), bindingToComponentAssoc(cn, sn, cdr(b))); } const list serviceToComponentAssoc(const string& cn, const list& s) { - if (isNil(s)) + if (isNull(s)) return s; const string sn(scdl::name(car(s))); const list btoc(bindingToComponentAssoc(cn, sn, scdl::bindings(car(s)))); - if (isNil(btoc)) + if (isNull(btoc)) return cons(mklist(defaultBindingURI(cn, sn), cn), serviceToComponentAssoc(cn, cdr(s))); return append(btoc, serviceToComponentAssoc(cn, cdr(s))); } const list uriToComponentAssoc(const list& c) { - if (isNil(c)) + if (isNull(c)) return c; return append(serviceToComponentAssoc(scdl::name(car(c)), scdl::services(car(c))), uriToComponentAssoc(cdr(c))); } @@ -625,7 +625,7 @@ const failable confComponents(const string& contribPath, const string debug(vhost, "modeval::confComponents::vhost"); debug(impls, "modeval::confComponents::impls"); - const failable > fcomps = isNil(contributor)? + const failable > 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 confComponents(const string& contribPath, const string debug(flatten(svcs), "modeval::confComponents::svcs"); const list 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 get(const list& rpath, request_rec* const r, const lv const list 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 get(const list& 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 fmt = assoc("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 get(const list& rpath, request_rec* const r, const lv } // Write an empty list as a JSON value - if (isNil((list)c)) { + if (isNull((list)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(c)) && !isNil(cdr(c)) && isList(cadr(c))) + if (isString(car(c)) && !isNull(cdr(c)) && isList(cadr(c))) return httpd::writeResult(convertValues(cadr(c)), car(c), r); // Write an assoc value as a JSON value - if (isSymbol(car(c)) && !isNil(cdr(c))) { + if (isSymbol(car(c)) && !isNull(cdr(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 e = valuesToElements(c); - if (isList(car(e)) && !isNil(car(e))) { + if (isList(car(e)) && !isNull(car(e))) { const list el = car(e); - if (isSymbol(car(el)) && car(el) == element && !isNil(cdr(el)) && isSymbol(cadr(el)) && elementHasChildren(el) && !elementHasValue(el)) { + if (isSymbol(car(el)) && car(el) == element && !isNull(cdr(el)) && isSymbol(cadr(el)) && elementHasChildren(el) && !elementHasValue(el)) { if (cadr(el) == atom::feed) return httpd::writeResult(atom::writeATOMFeed(e), "application/atom+xml; charset=utf-8", r); if (cadr(el) == atom::entry) @@ -829,7 +829,7 @@ const failable post(const list& 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 put(const list& 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 patch(const list& 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 del(const list& 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& 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 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& 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 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 ref(rbtreeAssoc(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& rpath, const lis * Find a leaf matching a request path in a tree of URI paths. */ const int matchPath(const list& k, const list& 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& k, const list& p) { } const list assocPath(const value& k, const list& tree) { - if (isNil(tree)) + if (isNull(tree)) return tree; if (matchPath(k, car(car(tree)))) return car(tree); @@ -1041,10 +1041,10 @@ int translateService(request_rec* const r, const list& 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 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& rpath, const list< const int translateRequest(request_rec* const r, const list& rpath, const list& vpath, const list& refs, const list& svcs, const list& 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& 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 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& 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 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 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 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& rpath, request_rec* const r, const li // Get the component implementation lambda const list impl(rbtreeAssoc(cadr(rpath), impls)); - if (isNil(impl)) { + if (isNull(impl)) { mkfailure(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)reqc.rpath)) + if (isNull((const list)reqc.rpath)) return HTTP_NOT_FOUND; // Get the server configuration const ServerConf& sc = httpd::serverConf(r, &mod_tuscany_eval); // Handle a request targeting a component in a virtual host - if (!isNil((const list)reqc.vpath)) { + if (!isNull((const list)reqc.vpath)) { // Start the components in the virtual host const failable > 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(r, &mod_tuscany_eval); - if (isNil(sc.vhostc.authenticator)) { + if (isNull(sc.vhostc.authenticator)) { mkfailure("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 hcontent = isList(hval) && !isNil(hval) && isList(car(hval)) && !isNil(car(hval))? assoc(value("content"), cdr(car(hval))) : nilListValue; - const list hassoc = isNil(hcontent)? nilListValue : assoc(value("hash"), cdr(hcontent)); - if (isNil(hassoc)) { + const list hcontent = isList(hval) && !isNull(hval) && isList(car(hval)) && !isNull(car(hval))? assoc(value("content"), cdr(car(hval))) : nilListValue; + const list hassoc = isNull(hcontent)? nilListValue : assoc(value("hash"), cdr(hcontent)); + if (isNull(hassoc)) { mkfailure(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 impl(rbtreeAssoc((string)sc.vhostc.contributorName, (const list)sc.compos.impls)); - if (isNil(impl)) { + if (isNull(impl)) { mkfailure(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 impl(rbtreeAssoc((string)sc.vhostc.authenticatorName, (const list)sc.compos.impls)); - if (isNil(impl)) { + if (isNull(impl)) { mkfailure(string("Couldn't find authenticator component implementation: ") + sc.vhostc.authenticatorName); failureExitChild(); } -- cgit v1.2.3