Search in sources :

Example 6 with Argument

use of lucee.runtime.type.scope.Argument 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);
}
Also used : Argument(lucee.runtime.type.scope.Argument) FunctionArgument(lucee.runtime.type.FunctionArgument) UDF(lucee.runtime.type.UDF) ArgumentImpl(lucee.runtime.type.scope.ArgumentImpl) ComponentIterator(lucee.runtime.type.it.ComponentIterator) ComponentEntryIterator(lucee.runtime.type.cfc.ComponentEntryIterator) StringIterator(lucee.runtime.type.it.StringIterator) Iterator(java.util.Iterator) ComponentValueIterator(lucee.runtime.type.cfc.ComponentValueIterator) Member(lucee.runtime.component.Member) DataMember(lucee.runtime.component.DataMember) FunctionArgument(lucee.runtime.type.FunctionArgument) ArgumentIntKey(lucee.runtime.type.scope.ArgumentIntKey)

Example 7 with Argument

use of lucee.runtime.type.scope.Argument in project Lucee by lucee.

the class VariableInterpreter method _variable.

public static Object _variable(PageContext pc, String str, Object value, Scope scope) throws PageException {
    // define a ohter enviroment for the function
    if (scope != null) {
        // Variables Scope
        Variables var = null;
        if (scope instanceof Variables) {
            var = (Variables) scope;
        } else if (scope instanceof CallerImpl) {
            var = ((CallerImpl) scope).getVariablesScope();
        }
        if (var != null) {
            Variables current = pc.variablesScope();
            pc.setVariablesScope(var);
            try {
                if (value != NULL)
                    return setVariable(pc, str, value);
                return getVariable(pc, str);
            } finally {
                pc.setVariablesScope(current);
            }
        } else // Undefined Scope
        if (scope instanceof Undefined) {
            PageContextImpl pci = (PageContextImpl) pc;
            Undefined undefined = (Undefined) scope;
            boolean check = undefined.getCheckArguments();
            Variables orgVar = pc.variablesScope();
            Argument orgArgs = pc.argumentsScope();
            Local orgLocal = pc.localScope();
            pci.setVariablesScope(undefined.variablesScope());
            if (check)
                pci.setFunctionScopes(undefined.localScope(), undefined.argumentsScope());
            try {
                if (value != NULL)
                    return setVariable(pc, str, value);
                return getVariable(pc, str);
            } finally {
                pc.setVariablesScope(orgVar);
                if (check)
                    pci.setFunctionScopes(orgLocal, orgArgs);
            }
        }
    }
    if (value != NULL)
        return setVariable(pc, str, value);
    return getVariable(pc, str);
}
Also used : Variables(lucee.runtime.type.scope.Variables) Undefined(lucee.runtime.type.scope.Undefined) CallerImpl(lucee.runtime.type.scope.CallerImpl) Argument(lucee.runtime.type.scope.Argument) Local(lucee.runtime.type.scope.Local) PageContextImpl(lucee.runtime.PageContextImpl)

Aggregations

Argument (lucee.runtime.type.scope.Argument)7 PageContextImpl (lucee.runtime.PageContextImpl)5 Key (lucee.runtime.type.Collection.Key)4 Local (lucee.runtime.type.scope.Local)4 Undefined (lucee.runtime.type.scope.Undefined)4 Iterator (java.util.Iterator)2 Entry (java.util.Map.Entry)2 Log (lucee.commons.io.log.Log)2 ConfigImpl (lucee.runtime.config.ConfigImpl)2 PageException (lucee.runtime.exp.PageException)2 FunctionArgument (lucee.runtime.type.FunctionArgument)2 ArgumentIntKey (lucee.runtime.type.scope.ArgumentIntKey)2 LocalImpl (lucee.runtime.type.scope.LocalImpl)2 ArrayList (java.util.ArrayList)1 Date (java.util.Date)1 Map (java.util.Map)1 BodyContent (javax.servlet.jsp.tagext.BodyContent)1 DevNullOutputStream (lucee.commons.io.DevNullOutputStream)1 Pair (lucee.commons.lang.Pair)1 Page (lucee.runtime.Page)1