Ejemplo n.º 1
0
        public void DeclareFunction(RoutineDelegate /*!*/ arglessStub, string /*!*/ fullName, PhpMemberAttributes memberAttributes, MethodInfo argfull)
        {
            var desc = new PhpRoutineDesc(memberAttributes, arglessStub, true);

            if (argfull != null)                              // only if we have the argfull
            {
                new PurePhpFunction(desc, fullName, argfull); // writes desc.Member
            }
            functions[fullName] = desc;
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Add at runtime a method to a type
        /// </summary>
        /// <param name="typedesc">Type to modify</param>
        /// <param name="attributes">New method attributes</param>
        /// <param name="func_name">Method name</param>
        /// <param name="callback">Method body</param>
        /// <remarks>Used by PDO_SQLITE</remarks>
        public void AddMethodToType(DTypeDesc typedesc, PhpMemberAttributes attributes, string func_name, Func <object, PhpStack, object> callback)
        {
            Debug.Assert(typedesc != null);

            var name        = new Name(func_name);
            var method_desc = new PhpRoutineDesc(typedesc, attributes);

            if (!typedesc.Methods.ContainsKey(name))
            {
                typedesc.Methods.Add(name, method_desc);

                // assign member:
                if (method_desc.Member == null)
                {
                    Func <ScriptContext, object> dummyArgFullCallback = DummyArgFull;
                    PhpMethod method = new PhpMethod(name, (PhpRoutineDesc)method_desc, dummyArgFullCallback.Method, (callback != null) ? callback.Method : null);
                    method.WriteUp(PhpRoutineSignature.FromArgfullInfo(method, dummyArgFullCallback.Method));
                    method_desc.Member = method;
                }
            }
        }