Search in sources :

Example 6 with UDFPlus

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;
}
Also used : UDFPlus(lucee.runtime.type.UDFPlus)

Example 7 with UDFPlus

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);
}
Also used : UDFPlus(lucee.runtime.type.UDFPlus) Member(lucee.runtime.component.Member)

Example 8 with UDFPlus

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);
}
Also used : UDFPlus(lucee.runtime.type.UDFPlus) Member(lucee.runtime.component.Member)

Example 9 with UDFPlus

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();
}
Also used : ApplicationException(lucee.runtime.exp.ApplicationException) UDF(lucee.runtime.type.UDF) UDFPlus(lucee.runtime.type.UDFPlus) ArgumentIntKey(lucee.runtime.type.scope.ArgumentIntKey)

Example 10 with UDFPlus

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;
}
Also used : UDF(lucee.runtime.type.UDF) UDFPlus(lucee.runtime.type.UDFPlus) ArgumentIntKey(lucee.runtime.type.scope.ArgumentIntKey)

Aggregations

UDFPlus (lucee.runtime.type.UDFPlus)12 Member (lucee.runtime.component.Member)9 DataMember (lucee.runtime.component.DataMember)5 ArgumentIntKey (lucee.runtime.type.scope.ArgumentIntKey)4 ExpressionException (lucee.runtime.exp.ExpressionException)3 Component (lucee.runtime.Component)2 UDF (lucee.runtime.type.UDF)2 ResultSet (java.sql.ResultSet)1 ArrayList (java.util.ArrayList)1 List (java.util.List)1 Entry (java.util.Map.Entry)1 Set (java.util.Set)1 PageContext (lucee.runtime.PageContext)1 ThreadLocalPageContext (lucee.runtime.engine.ThreadLocalPageContext)1 ApplicationException (lucee.runtime.exp.ApplicationException)1 CasterException (lucee.runtime.exp.CasterException)1 PageException (lucee.runtime.exp.PageException)1 JavaObject (lucee.runtime.java.JavaObject)1 XMLMultiElementArray (lucee.runtime.text.xml.struct.XMLMultiElementArray)1 XMLMultiElementStruct (lucee.runtime.text.xml.struct.XMLMultiElementStruct)1