Exemple #1
0
            /// <exception cref="TjsException"></exception>
            protected internal override int Process(Variant result, Variant[] param, Dispatch2
                                                    objthis)
            {
                RegExpNI _this = (RegExpNI)objthis.GetNativeInstance(RegExpClass.mClassID
                                                                     );

                if (_this == null)
                {
                    return(Error.E_NATIVECLASSCRASH);
                }
                if (param.Length < 1)
                {
                    return(Error.E_BADPARAMCOUNT);
                }
                RegExpClass.Compile(param, _this);
                return(Error.S_OK);
            }
Exemple #2
0
            /// <exception cref="VariantException"></exception>
            /// <exception cref="TjsException"></exception>
            protected internal override int Process(Variant result, Variant[] param, Dispatch2
                                                    objthis)
            {
                RegExpNI _this = (RegExpNI)objthis.GetNativeInstance(RegExpClass.mClassID
                                                                     );

                if (_this == null)
                {
                    return(Error.E_NATIVECLASSCRASH);
                }
                int hr = _this.Construct(param, objthis);

                if (hr < 0)
                {
                    return(hr);
                }
                if (param.Length >= 1)
                {
                    RegExpClass.Compile(param, _this);
                }
                return(Error.S_OK);
            }
Exemple #3
0
            /// <exception cref="TjsException"></exception>
            protected internal override int Process(Variant result, Variant[] param, Dispatch2
                                                    objthis)
            {
                RegExpNI _this = (RegExpNI)objthis.GetNativeInstance(RegExpClass.mClassID
                                                                     );

                if (_this == null)
                {
                    return(Error.E_NATIVECLASSCRASH);
                }
                if (param.Length < 1)
                {
                    return(Error.E_BADPARAMCOUNT);
                }
                string target = param[0].AsString();

                RegExpClass.Exec(target, _this);
                RegExpClass.mLastRegExp = new Variant(objthis, objthis);
                if (result != null)
                {
                    result.Set(_this.mArray);
                }
                return(Error.S_OK);
            }
Exemple #4
0
            /// <exception cref="TjsException"></exception>
            protected internal override int Process(Variant result, Variant[] param, Dispatch2
                                                    objthis)
            {
                RegExpNI _this = (RegExpNI)objthis.GetNativeInstance(RegExpClass.mClassID
                                                                     );

                if (_this == null)
                {
                    return(Error.E_NATIVECLASSCRASH);
                }
                if (param.Length < 1)
                {
                    return(Error.E_BADPARAMCOUNT);
                }
                if (result != null)
                {
                    string    target  = param[0].AsString();
                    bool      matched = RegExpClass.Match(target, _this);
                    Dispatch2 array   = RegExpClass.GetResultArray(matched, _this, _this.
                                                                   mMatch);
                    result.Set(array, array);
                }
                return(Error.S_OK);
            }
Exemple #5
0
            /// <exception cref="TjsException"></exception>
            protected internal override int Process(Variant result, Variant[] param, Dispatch2
                                                    objthis)
            {
                RegExpNI _this = (RegExpNI)objthis.GetNativeInstance(RegExpClass.mClassID
                                                                     );

                if (_this == null)
                {
                    return(Error.E_NATIVECLASSCRASH);
                }
                if (param.Length < 2)
                {
                    return(Error.E_BADPARAMCOUNT);
                }
                string         target = param[0].AsString();
                string         to     = null;
                bool           func;
                VariantClosure funcval = null;

                if (param[1].IsObject() != true)
                {
                    to   = param[1].AsString();
                    func = false;
                }
                else
                {
                    funcval = param[1].AsObjectClosure();
                    if (funcval.mObjThis == null)
                    {
                        funcval.mObjThis = objthis;
                    }
                    func = true;
                }
                string  ret = null;
                Matcher m   = _this.RegEx.Matcher(target);

                if (func == false)
                {
                    ret = m.ReplaceAll(to);
                }
                else
                {
                    int            hr;
                    VariantClosure clo      = new VariantClosure(null, null);
                    Variant        funcret  = new Variant();
                    Variant        arrayval = new Variant(clo);
                    Variant[]      args     = new Variant[1];
                    args[0] = arrayval;
                    int size = target.Length;
                    ret = string.Empty;
                    for (int i = 0; i < size;)
                    {
                        if (m.Find(i))
                        {
                            ret += Sharpen.Runtime.Substring(target, i, m.Start());
                            Dispatch2 array = RegExpClass.GetResultArray(true, _this, m);
                            clo.Set(array, array);
                            hr = funcval.FuncCall(0, null, funcret, args, null);
                            if (hr >= 0)
                            {
                                ret += funcret.AsString();
                            }
                            i = m.End();
                        }
                        else
                        {
                            break;
                        }
                    }
                }
                if (result != null)
                {
                    result.Set(ret);
                }
                return(Error.S_OK);
            }