use of lucee.runtime.type.UDF 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.UDF in project Lucee by lucee.
the class ComponentImpl method getUDFs.
private static void getUDFs(PageContext pc, Iterator<UDF> it, ComponentImpl comp, int access, ArrayImpl arr) throws PageException {
UDF udf;
while (it.hasNext()) {
udf = it.next();
if (udf instanceof UDFGSProperty)
continue;
if (udf.getAccess() > access)
continue;
if (!udf.getPageSource().equals(comp._getPageSource()))
continue;
arr.append(ComponentUtil.getMetaData(pc, (UDFPropertiesBase) ((UDFImpl) udf).properties));
}
}
use of lucee.runtime.type.UDF in project Lucee by lucee.
the class ComponentImpl method addUDFS.
private static void addUDFS(ComponentImpl trgComp, Map src, Map trg) {
Iterator it = src.entrySet().iterator();
Map.Entry entry;
Object key, value;
UDF udf;
ComponentImpl comp, owner;
boolean done;
while (it.hasNext()) {
entry = (Entry) it.next();
key = entry.getKey();
value = entry.getValue();
if (value instanceof UDF) {
udf = (UDF) value;
done = false;
// get udf from _udf
owner = (ComponentImpl) udf.getOwnerComponent();
if (owner != null) {
comp = trgComp;
do {
if (owner.pageSource == comp.pageSource)
break;
} while ((comp = comp.base) != null);
if (comp != null) {
value = comp._udfs.get(key);
trg.put(key, value);
done = true;
}
}
// udf with no owner
if (!done)
trg.put(key, udf.duplicate());
// print.o(owner.pageSource.getComponentName()+":"+udf.getFunctionName());
}
}
}
use of lucee.runtime.type.UDF in project Lucee by lucee.
the class ComponentImpl method duplicateDataMember.
/**
* duplicate the datamember in the map, ignores the udfs
* @param c
* @param map
* @param newMap
* @param deepCopy
* @return
*/
public static MapPro duplicateDataMember(ComponentImpl c, MapPro map, MapPro newMap, boolean deepCopy) {
Iterator it = map.entrySet().iterator();
Map.Entry entry;
Object value;
while (it.hasNext()) {
entry = (Entry) it.next();
value = entry.getValue();
if (!(value instanceof UDF)) {
if (deepCopy)
value = Duplicator.duplicate(value, deepCopy);
newMap.put(entry.getKey(), value);
}
}
return newMap;
}
use of lucee.runtime.type.UDF 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