use of lucee.runtime.type.UDF in project Lucee by lucee.
the class Invoke method doFunction.
private void doFunction(PageContext pc) throws PageException {
// execute
if (StringUtil.isEmpty(method, true))
throw new ApplicationException("Attribute [method] for tag [invoke] is required in this context.");
Object oUDF = pc.getVariable(method);
if (!(oUDF instanceof UDF))
throw new ApplicationException("there is no function with name " + method);
Object rtn = ((UDF) oUDF).callWithNamedValues(pageContext, data, false);
// return
if (!StringUtil.isEmpty(returnvariable))
pageContext.setVariable(returnvariable, rtn);
}
use of lucee.runtime.type.UDF in project Lucee by lucee.
the class ComponentUtil method md5.
public static String md5(ComponentSpecificAccess cw) throws IOException {
Key[] keys = cw.keys();
Arrays.sort(keys);
StringBuffer _interface = new StringBuffer();
Object member;
UDF udf;
FunctionArgument[] args;
FunctionArgument arg;
for (int y = 0; y < keys.length; y++) {
member = cw.get(keys[y], null);
if (member instanceof UDF) {
udf = (UDF) member;
// print.out(udf.);
_interface.append(udf.getAccess());
_interface.append(udf.getOutput());
_interface.append(udf.getFunctionName());
_interface.append(udf.getReturnTypeAsString());
args = udf.getFunctionArguments();
for (int i = 0; i < args.length; i++) {
arg = args[i];
_interface.append(arg.isRequired());
_interface.append(arg.getName());
_interface.append(arg.getTypeAsString());
}
}
}
return MD5.getDigestAsString(_interface.toString().toLowerCase());
}
use of lucee.runtime.type.UDF in project Lucee by lucee.
the class PropertyFactory method addHas.
public static void addHas(ComponentImpl comp, Property prop) throws ApplicationException {
Member m = comp.getMember(Component.ACCESS_PRIVATE, KeyImpl.getInstance("has" + getSingularName(prop)), true, false);
if (!(m instanceof UDF)) {
UDF udf = new UDFHasProperty(comp, prop);
comp.registerUDF(KeyImpl.init(udf.getFunctionName()), udf);
}
}
use of lucee.runtime.type.UDF in project Lucee by lucee.
the class PropertyFactory method addSet.
public static void addSet(ComponentImpl comp, Property prop) throws PageException {
Member m = comp.getMember(Component.ACCESS_PRIVATE, KeyImpl.getInstance("set" + prop.getName()), true, false);
if (!(m instanceof UDF)) {
UDF udf = new UDFSetterProperty(comp, prop);
comp.registerUDF(KeyImpl.init(udf.getFunctionName()), udf);
}
}
use of lucee.runtime.type.UDF in project Lucee by lucee.
the class ComponentImpl method onMissingMethod.
public Object onMissingMethod(PageContext pc, int access, Member member, String name, Object[] _args, Struct _namedArgs, boolean superAccess) throws PageException {
Member ommm = access == -1 ? getMember(pc, KeyConstants._onmissingmethod, false, superAccess) : getMember(access, KeyConstants._onmissingmethod, false, superAccess);
if (ommm instanceof UDF) {
Argument args = new ArgumentImpl();
if (_args != null) {
for (int i = 0; i < _args.length; i++) {
args.setEL(ArgumentIntKey.init(i + 1), _args[i]);
}
} else if (_namedArgs != null) {
UDFUtil.argumentCollection(_namedArgs, new FunctionArgument[] {});
Iterator<Entry<Key, Object>> it = _namedArgs.entryIterator();
Entry<Key, Object> e;
while (it.hasNext()) {
e = it.next();
args.setEL(e.getKey(), e.getValue());
}
}
// Struct newArgs=new StructImpl(StructImpl.TYPE_SYNC);
// newArgs.setEL(MISSING_METHOD_NAME, name);
// newArgs.setEL(MISSING_METHOD_ARGS, args);
Object[] newArgs = new Object[] { name, args };
return _call(pc, KeyConstants._onmissingmethod, (UDFPlus) ommm, null, newArgs);
}
if (member == null)
throw ComponentUtil.notFunction(this, KeyImpl.init(name), null, access);
throw ComponentUtil.notFunction(this, KeyImpl.init(name), member.getValue(), access);
}
Aggregations