diff options
Diffstat (limited to 'sca-cpp/trunk/modules/js/htdocs/scdl.js')
-rw-r--r-- | sca-cpp/trunk/modules/js/htdocs/scdl.js | 109 |
1 files changed, 109 insertions, 0 deletions
diff --git a/sca-cpp/trunk/modules/js/htdocs/scdl.js b/sca-cpp/trunk/modules/js/htdocs/scdl.js index a98056d790..5f3934b060 100644 --- a/sca-cpp/trunk/modules/js/htdocs/scdl.js +++ b/sca-cpp/trunk/modules/js/htdocs/scdl.js @@ -21,4 +21,113 @@ * SCDL parsing functions. */ +/** + * Returns a list of components in a composite. + */ +function components(l) { + var cs = namedElementChildren("'composite", l); + if (isNil(cs)) + return cs; + return namedElementChildren("'component", car(cs)); +} + +/** + * Returns the name of a component, service or reference. + */ +function name(l) { + return namedAttributeValue("'name", l); +} + +/** + * Returns the implementation of a component. + */ +function implementation(l) { + function filterImplementation(v) { + return isElement(v) && cadr(v).match("implementation.") != null; + } + + var n = filter(filterImplementation, l); + if (isNil(n)) + return null; + return car(n); +} + +/** + * Returns the type of an implementation. + */ +function implementationType(l) { + return elementName(l).substring(1); +} + +/** + * Returns the URI of a service, reference or implementation. + */ +function uri(l) { + return namedAttributeValue("'uri", l); +} + +/** + * Returns a list of services in a component. + */ +function services(l) { + return namedElementChildren("'service", l); +} + +/** + * Returns a list of references in a component. + */ +function references(l) { + return namedElementChildren("'reference", l); +} + +/** + * Returns a list of bindings in a service or reference. + */ +function bindings(l) { + function filterBinding(v) { + return isElement(v) && cadr(v).match("binding.") != null; + } + + return filter(filterBinding, l); +} + +/** + * Returns the type of a binding. + */ +function bindingType(l) { + return elementName(l).substring(1); +} + +/** + * Returns the target of a reference. + */ +function target(l) { + function bindingsTarget(l) { + if (isNil(l)) + return null; + var u = uri(car(l)); + if (!isNil(u)) + return u; + return bindingsTarget(cdr(l)); + } + + var t = namedAttributeValue("'target", l); + if (!isNil(t)) + return t; + return bindingsTarget(bindings(l)); +} + +/** + * Returns a list of properties in a component. + */ +function properties(l) { + return namedElementChildren("'property", l); +} + +/** + * Returns the value of a property. + */ +function propertyValue(l) { + return elementValue(l); +} |