use of lucee.runtime.type.UDF in project Lucee by lucee.
the class CallStackGet method _getTagContext.
public static void _getTagContext(PageContext pc, Array tagContext, Throwable t, Collection.Key lineNumberName) {
// Throwable root = t.getRootCause();
Throwable cause = t.getCause();
if (cause != null)
_getTagContext(pc, tagContext, cause, lineNumberName);
StackTraceElement[] traces = t.getStackTrace();
UDF[] udfs = ((PageContextImpl) pc).getUDFs();
int line = 0;
String template;
Struct item;
StackTraceElement trace = null;
String functionName, methodName;
int index = udfs.length - 1;
for (int i = 0; i < traces.length; i++) {
trace = traces[i];
template = trace.getFileName();
if (trace.getLineNumber() <= 0 || template == null || ResourceUtil.getExtension(template, "").equals("java"))
continue;
methodName = trace.getMethodName();
if (methodName != null && methodName.startsWith("udfCall") && index > -1)
functionName = udfs[index--].getFunctionName();
else
functionName = "";
item = new StructImpl();
line = trace.getLineNumber();
item.setEL(KeyConstants._function, functionName);
/* template is now a absolute path
try {
template=ExpandPath.call(pc, template);
}
catch (PageException e) {}*/
item.setEL(KeyConstants._template, abs((PageContextImpl) pc, template));
item.setEL(lineNumberName, new Double(line));
tagContext.appendEL(item);
}
}
use of lucee.runtime.type.UDF in project Lucee by lucee.
the class _CreateComponent method call.
public static Object call(PageContext pc, Object[] objArr) throws PageException {
String path = Caster.toString(objArr[objArr.length - 1]);
// not store the index to make it faster
Component c = CreateObject.doComponent(pc, path);
// no init method
if (!(c.get(KeyConstants._init, null) instanceof UDF)) {
if (objArr.length > 1) {
Object arg1 = objArr[0];
if (arg1 instanceof FunctionValue) {
Struct args = Caster.toFunctionValues(objArr, 0, objArr.length - 1);
EntityNew.setPropeties(pc, c, args, true);
} else if (Decision.isStruct(arg1)) {
Struct args = Caster.toStruct(arg1);
EntityNew.setPropeties(pc, c, args, true);
}
}
return c;
}
Object rtn;
// no arguments
if (objArr.length == 1) {
rtn = c.call(pc, KeyConstants._init, EMPTY);
} else // named arguments
if (objArr[0] instanceof FunctionValue) {
Struct args = Caster.toFunctionValues(objArr, 0, objArr.length - 1);
rtn = c.callWithNamedValues(pc, KeyConstants._init, args);
} else // no name arguments
{
Object[] args = new Object[objArr.length - 1];
for (int i = 0; i < objArr.length - 1; i++) {
args[i] = objArr[i];
if (args[i] instanceof FunctionValue)
throw new ExpressionException("invalid argument defintion, when using named parameters to a function, every parameter must have a name.");
}
rtn = c.call(pc, KeyConstants._init, args);
}
if (rtn == null || (c.getPageSource() != null && c.getPageSource().getDialect() == CFMLEngine.DIALECT_LUCEE))
return c;
return rtn;
}
Aggregations