use of lucee.runtime.type.UDFPlus in project Lucee by lucee.
the class Props method getProps.
private static Props getProps(PageContext pc, Object o, int urlReturnFormat, int headerReturnFormat) {
Props props = new Props();
props.strType = "any";
props.secureJson = pc.getApplicationContext().getSecureJson();
int udfReturnFormat = -1;
if (o instanceof UDFPlus) {
UDFPlus udf = ((UDFPlus) o);
udfReturnFormat = udf.getReturnFormat(-1);
props.type = udf.getReturnType();
props.strType = udf.getReturnTypeAsString();
props.output = udf.getOutput();
if (udf.getSecureJson() != null)
props.secureJson = udf.getSecureJson().booleanValue();
}
// format
if (isValid(urlReturnFormat))
props.format = urlReturnFormat;
else if (isValid(udfReturnFormat))
props.format = udfReturnFormat;
else if (isValid(headerReturnFormat))
props.format = headerReturnFormat;
else
props.format = UDF.RETURN_FORMAT_WDDX;
// return type XML ignore WDDX
if (props.type == CFTypes.TYPE_XML) {
if (UDF.RETURN_FORMAT_WDDX == props.format)
props.format = UDF.RETURN_FORMAT_PLAIN;
}
return props;
}
use of lucee.runtime.type.UDFPlus in project Lucee by lucee.
the class ComponentScopeShadow method callWithNamedValues.
/*public Object callWithNamedValues(PageContext pc, String key,Struct args) throws PageException {
return callWithNamedValues(pc, KeyImpl.init(key), args);
}*/
@Override
public Object callWithNamedValues(PageContext pc, Key key, Struct args) throws PageException {
// first check variables
Object o = shadow.get(key);
if (o instanceof UDFPlus) {
return ((UDFPlus) o).callWithNamedValues(pc, key, args, false);
}
Member m = component.getMember(access, key, false, false);
if (m != null) {
if (m instanceof UDFPlus)
return ((UDFPlus) m).callWithNamedValues(pc, key, args, false);
return MemberUtil.callWithNamedValues(pc, this, key, args, CFTypes.TYPE_STRUCT, "struct");
// throw ComponentUtil.notFunction(component, key, m.getValue(),access);
}
return MemberUtil.callWithNamedValues(pc, this, key, args, CFTypes.TYPE_STRUCT, "struct");
// throw ComponentUtil.notFunction(component, key, null,access);
}
use of lucee.runtime.type.UDFPlus in project Lucee by lucee.
the class ComponentScopeShadow method call.
/*public Object call(PageContext pc, String key, Object[] arguments) throws PageException {
return call(pc, KeyImpl.init(key), arguments);
}*/
@Override
public Object call(PageContext pc, Collection.Key key, Object[] arguments) throws PageException {
// first check variables
Object o = shadow.get(key);
if (o instanceof UDFPlus) {
return ((UDFPlus) o).call(pc, key, arguments, false);
}
// then check in component
Member m = component.getMember(access, key, false, false);
if (m != null) {
if (m instanceof UDFPlus)
return ((UDFPlus) m).call(pc, key, arguments, false);
}
return MemberUtil.call(pc, this, key, arguments, new short[] { CFTypes.TYPE_STRUCT }, new String[] { "struct" });
// throw ComponentUtil.notFunction(component, key, m!=null?m.getValue():null,access);
}
use of lucee.runtime.type.UDFPlus in project Lucee by lucee.
the class ComponentImpl method checkInterface.
public void checkInterface(PageContext pc, ComponentPageImpl componentPage) throws PageException {
// no records == nothing to do
if (absFin == null || !absFin.hasUDFs())
return;
// ABSTRACT: check if the component define all functions defined in interfaces and abstract components
if (getModifier() != MODIFIER_ABSTRACT && absFin.hasAbstractUDFs()) {
Map<Key, UDF> udfs = absFin.removeAbstractUDFs();
// print.e(udfs);
Iterator<Entry<Key, UDF>> it = udfs.entrySet().iterator();
Entry<Key, UDF> entry;
UDFPlus iUdf, cUdf;
while (it.hasNext()) {
entry = it.next();
iUdf = (UDFPlus) entry.getValue();
cUdf = (UDFPlus) _udfs.get(entry.getKey());
checkFunction(pc, componentPage, iUdf, cUdf);
}
}
// FINAL: does a function overwrite a final method
if (absFin.hasFinalUDFs()) {
Map<Key, UDF> udfs = absFin.getFinalUDFs();
Iterator<Entry<Key, UDF>> it = udfs.entrySet().iterator();
Entry<Key, UDF> entry;
UDFPlus iUdf, cUdf;
while (it.hasNext()) {
entry = it.next();
iUdf = (UDFPlus) entry.getValue();
cUdf = (UDFPlus) _udfs.get(entry.getKey());
// if this is not the same, it was overwritten
if (iUdf != cUdf)
throw new ApplicationException("the function [" + entry.getKey() + "] from component [" + cUdf.getSource() + "] tries to override a final method with the same name from component [" + iUdf.getSource() + "]");
}
}
// MUST componentPage.ckecked();
}
use of lucee.runtime.type.UDFPlus in project Lucee by lucee.
the class ComponentImpl method duplicateUTFMap.
public static MapPro<Key, UDF> duplicateUTFMap(ComponentImpl src, ComponentImpl trg, MapPro<Key, UDF> srcMap, MapPro<Key, UDF> trgMap) {
Iterator<Entry<Key, UDF>> it = srcMap.entrySet().iterator();
Entry<Key, UDF> entry;
UDF udf;
while (it.hasNext()) {
entry = it.next();
udf = entry.getValue();
if (udf.getOwnerComponent() == src) {
UDFPlus clone = (UDFPlus) entry.getValue().duplicate();
clone.setOwnerComponent(trg);
clone.setAccess(udf.getAccess());
trgMap.put(entry.getKey(), clone);
}
}
return trgMap;
}
Aggregations