use of lucee.transformer.library.function.FunctionLib in project Lucee by lucee.
the class ConfigImpl method setFunctionDirectory.
protected void setFunctionDirectory(Resource functionDirectory) {
this.functionMapping = new MappingImpl(this, "/mapping-function/", functionDirectory.getAbsolutePath(), null, ConfigImpl.INSPECT_NEVER, true, true, true, true, false, true, null, -1, -1);
FunctionLib flc = cfmlFlds[cfmlFlds.length - 1];
FunctionLib fll = luceeFlds[luceeFlds.length - 1];
// now overwrite with new data
if (functionDirectory.isDirectory()) {
String[] files = functionDirectory.list(new ExtensionResourceFilter(Constants.getTemplateExtensions()));
for (int i = 0; i < files.length; i++) {
if (flc != null)
createFunction(flc, files[i]);
if (fll != null)
createFunction(fll, files[i]);
}
combinedCFMLFLDs = null;
combinedLuceeFLDs = null;
}
}
use of lucee.transformer.library.function.FunctionLib in project Lucee by lucee.
the class MemberUtil method getMembers.
public static Map<Collection.Key, FunctionLibFunction> getMembers(PageContext pc, short type) {
Map<Short, Map<Key, FunctionLibFunction>> matches = pc.getCurrentTemplateDialect() == CFMLEngine.DIALECT_LUCEE ? matchesLucee : matchesCFML;
Map<Key, FunctionLibFunction> match = matches.get(type);
if (match != null)
return match;
FunctionLib[] flds = ((ConfigWebImpl) pc.getConfig()).getFLDs(pc.getCurrentTemplateDialect());
Iterator<FunctionLibFunction> it;
FunctionLibFunction f;
match = new HashMap<Collection.Key, FunctionLibFunction>();
String[] names;
for (int i = 0; i < flds.length; i++) {
it = flds[i].getFunctions().values().iterator();
while (it.hasNext()) {
f = it.next();
names = f.getMemberNames();
if (!ArrayUtil.isEmpty(names) && f.getMemberType() == type && f.getArgType() == FunctionLibFunction.ARG_FIX) {
for (int y = 0; y < names.length; y++) match.put(KeyImpl.getInstance(names[y]), f);
}
}
}
matches.put(type, match);
return match;
}
use of lucee.transformer.library.function.FunctionLib in project Lucee by lucee.
the class GetFunctionData method _call.
private static Struct _call(PageContext pc, String strFunctionName, int dialect) throws PageException {
FunctionLib[] flds;
flds = ((ConfigImpl) pc.getConfig()).getFLDs(dialect);
FunctionLibFunction function = null;
for (int i = 0; i < flds.length; i++) {
function = flds[i].getFunction(strFunctionName.toLowerCase());
if (function != null)
break;
}
if (function == null)
throw new ExpressionException("function [" + strFunctionName + "] is not a built in function");
// CFML Based Function
Class clazz = null;
try {
clazz = function.getFunctionClassDefinition().getClazz();
} catch (Throwable t) {
ExceptionUtil.rethrowIfNecessary(t);
}
if (clazz == lucee.runtime.functions.system.CFFunction.class) {
return cfmlBasedFunction(pc, function);
}
return javaBasedFunction(function);
}
use of lucee.transformer.library.function.FunctionLib in project Lucee by lucee.
the class GetFunctionList method _call.
private static lucee.runtime.type.Struct _call(PageContext pc, int dialect) throws PageException {
Struct sct = new StructImpl();
// synchronized(sct) {
// hasSet=true;
FunctionLib[] flds;
flds = ((ConfigImpl) pc.getConfig()).getFLDs(dialect);
FunctionLibFunction func;
Map<String, FunctionLibFunction> _functions;
Iterator<Entry<String, FunctionLibFunction>> it;
Entry<String, FunctionLibFunction> e;
for (int i = 0; i < flds.length; i++) {
_functions = flds[i].getFunctions();
it = _functions.entrySet().iterator();
while (it.hasNext()) {
e = it.next();
func = e.getValue();
if (func.getStatus() != TagLib.STATUS_HIDDEN && func.getStatus() != TagLib.STATUS_UNIMPLEMENTED)
sct.set(e.getKey(), "");
}
}
return sct;
}
use of lucee.transformer.library.function.FunctionLib in project Lucee by lucee.
the class Admin method doGetFLDs.
/**
* @throws PageException
*/
private void doGetFLDs() throws PageException {
lucee.runtime.type.Query qry = new QueryImpl(new String[] { "displayname", "namespace", "namespaceseparator", "shortname", "description", "uri", "source" }, new String[] { "varchar", "varchar", "varchar", "varchar", "varchar", "varchar", "varchar" }, 0, "tlds");
int dialect = "lucee".equalsIgnoreCase(getString("dialect", "cfml")) ? CFMLEngine.DIALECT_LUCEE : CFMLEngine.DIALECT_CFML;
FunctionLib[] libs = config.getFLDs(dialect);
for (int i = 0; i < libs.length; i++) {
qry.addRow();
qry.setAt("displayname", i + 1, libs[i].getDisplayName());
// TODO support for namespace
qry.setAt("namespace", i + 1, "");
qry.setAt("namespaceseparator", i + 1, "");
qry.setAt("shortname", i + 1, libs[i].getShortName());
qry.setAt("description", i + 1, libs[i].getDescription());
qry.setAt("uri", i + 1, Caster.toString(libs[i].getUri()));
qry.setAt("source", i + 1, StringUtil.emptyIfNull(libs[i].getSource()));
}
pageContext.setVariable(getString("admin", action, "returnVariable"), qry);
}
Aggregations