コード例 #1
0
ファイル: DefineProcessor.cs プロジェクト: akinomyoga/afh
 static AfhDefineProcessor()
 {
     methods.Add("equal", delegate(StringArray args){
         return(args[0] == args[1]?"true":"false");
     });
     methods.Add("iif", delegate(StringArray args){
         int c;
         bool eval = args[0] == "true" || int.TryParse(args[0], out c) && c != 0;
         return(eval?args[1]:args[2]);
     });
 }
コード例 #2
0
        //=================================================
        //		Preprocess Directives
        //=================================================
        private string PreprocessDirectives(string text)
        {
            Gen::Dictionary <int, string> errors = new Gen::Dictionary <int, string>();
            Gen::List <DefineMacro>       defs   = new Gen::List <DefineMacro>();

            DefineMacro def;
            string      text2 = reg_directive.Replace(text, delegate(System.Text.RegularExpressions.Match m){
                if (m.Groups["nspace"].Success)
                {
                    if (this.@namespace != null)
                    {
                        errors.Add(m.Index, "名前空間を複数指定する事は出来ません。");
                    }
                    this.@namespace = m.Groups["nspace"].Value;
                }
                else if (m.Groups["class"].Success)
                {
                    if (this.classname != null)
                    {
                        errors.Add(m.Index, "クラス名を複数指定する事は出来ません。");
                    }
                    this.classname = m.Groups["class"].Value;
                }
                else if (m.Groups["defname"].Success)
                {
                    def         = new DefineMacro();
                    def.name    = m.Groups["defname"].Value;
                    def.Content = m.Groups["defcontent"].Value;

                    // 引数リスト
                    System.Text.RegularExpressions.CaptureCollection capts = m.Groups["defarg"].Captures;
                    int iM   = capts.Count;
                    def.args = new string[capts.Count];
                    for (int i = 0; i < iM; i++)
                    {
                        def.args[i] = capts[i].Value;
                    }

                    defs.Add(def);
                }
                return(reg_remove.Replace(m.Value, ""));
            });

            foreach (DefineMacro define in defs)
            {
                define.Apply(ref text2);
            }

            return(text2);
        }
コード例 #3
0
            void update_cache(byte[] buffer, int boff, int len)
            {
                long off = boff * BLKSIZE;
                long end = off + len;

                // どのブロックまで取得成功しているか
                int iM;

                if (end == filesize)
                {
                    iM = (int)((end + (BLKSIZE - 1)) / BLKSIZE);
                }
                else
                {
                    iM = (int)(end / BLKSIZE);
                }

                for (int i = boff; i < iM; i++)
                {
                    block_t b;
                    if (!map.TryGetValue(i, out b))
                    {
                        b = parent.AllocBlock();
                        map.Add(i, b);
                    }
                    b.WriteCache(parent, buffer, (i - boff) * BLKSIZE, 0, BLKSIZE);
                }
            }
コード例 #4
0
        public static void RegisterVariable(string name)
        {
            int type = v_names.Count;

            v_names.Add(type, name);
            v_codes.Add(name, type);
        }
コード例 #5
0
        static BenchTypeBranch()
        {
            int i = 0;

            foreach (System.Type t in types)
            {
                Type分岐4_dic.Add(t, i++);
            }
        }
コード例 #6
0
 static Unit Register(Unit u)
 {
     if (u.name != "[Unknown Dimension]")
     {
         units.Add(u.name, u);
         units2.Add(u);
     }
     return(u);
 }
コード例 #7
0
        public static int RegisterColor(string name, Color color)
        {
            name = name.ToLower();
            int index = c_names.Count;

            c_indices.Add(name, index);            // 重複があれば茲で例外
            c_names.Add(name);
            c_values.Add(color);
            return(index);
        }
コード例 #8
0
 private static void RegisterCheckBox(string name, ITreeNodeCheckBox chk)
 {
     if (chk == null)
     {
         throw new System.ArgumentNullException("chk");
     }
     if (str2ins.ContainsKey(name))
     {
         throw new System.InvalidOperationException("指定した名前 " + name + " の ITreeNodeCheckBox は既に登録されています。");
     }
     str2ins.Add(name, chk);
     ins2str.Add(chk, name);
 }
コード例 #9
0
        /// <summary>
        /// System.Type を type_dic で利用できるように登録します。
        /// </summary>
        /// <param name="type">登録する型を指定します。</param>
        /// <returns>新しく登録した TypeCodes を返します。
        /// 既に登録されていた場合には、登録されていた TypeCodes を返します。</returns>
        public static TypeCodes RegisterTypeCode(System.Type type)
        {
            TypeCodes code;

            if (type_dic.TryGetValue(type, out code))
            {
                return(code);
            }
            else
            {
                code = (TypeCodes)type_dic.Count;
                type_dic.Add(type, code);
                return(code);
            }
        }
コード例 #10
0
ファイル: Window.cs プロジェクト: akinomyoga/mwg
        /// <summary>
        /// 実際の COM のインスタンスから Window クラスを生成します。
        /// </summary>
        /// <param name="obj">COM の HTMLWindow インスタンスを指定します。</param>
        /// <returns>引数に渡した obj に対応して作成した Window インスタンスを作成します。</returns>
        internal static Window FromObj(object obj)
        {
            if (obj == null)
            {
                return(null);
            }
            Window ret;

            if (!instances.TryGetValue(obj, out ret))
            {
                ret           = new Window(obj);
                ret.onunload += delegate(){ instances.Remove(obj); };
                instances.Add(obj, ret);
            }
            return(ret);
        }
コード例 #11
0
        public RootFsOperation(ProgramSetting setting)
        {
            rootdir = new FsDirectory("root");
            rootdir.info.Attributes |= System.IO.FileAttributes.System;
            rootdir.info.Attributes |= System.IO.FileAttributes.ReadOnly;

            FsFile file = rootdir.CreateFile("autorun.inf");

            file.info.Attributes |= System.IO.FileAttributes.ReadOnly;
            file.info.Attributes |= System.IO.FileAttributes.Hidden;
            file.info.Attributes |= System.IO.FileAttributes.System;
            file.SetContent("[autorun]\r\nicon=drive.ico\r\n");

            file = rootdir.CreateFile("desktop.ini");
            file.info.Attributes |= System.IO.FileAttributes.ReadOnly;
            file.info.Attributes |= System.IO.FileAttributes.Hidden;
            file.info.Attributes |= System.IO.FileAttributes.System;
            file.SetContent(GetDataFromResource("desktop.ini"));

            file = rootdir.CreateFile("drive.ico");
            file.info.Attributes |= System.IO.FileAttributes.ReadOnly;
            file.info.Attributes |= System.IO.FileAttributes.Hidden;
            file.info.Attributes |= System.IO.FileAttributes.System;
            file.SetContent(GetDataFromResource("DriveIcon.ico"));

            foreach (ISftpAccount acc in setting.accounts)
            {
                if (!acc.Enabled)
                {
                    continue;
                }

                FsMountPoint mnt = new FsMountSftp(acc);
                mnt.info.Attributes |= System.IO.FileAttributes.Offline;
                rootdir.files.Add(acc.Name, mnt);
                mntlist.Add("\\" + acc.Name, mnt);
            }
        }
コード例 #12
0
        static unsafe 漢字変換()
        {
            const int BUFFSIZE = 0x100;

            System.IO.Stream data   = Ref::Assembly.GetAssembly(typeof(漢字変換)).GetManifestResourceStream("afh.Text.kantai_shinji.bin");
            byte[]           buffer = new byte[BUFFSIZE];
            while (true)
            {
                int read = data.Read(buffer, 0, BUFFSIZE);
                if (read == 0)
                    break;
                fixed(byte *pBase = buffer)
                {
                    char *pwch  = (char *)pBase;
                    char *pwchM = (char *)(pBase + read);

                    while (pwch < pwchM)
                    {
                        kan_shin.Add(*pwch++, *pwch++);
                    }
                }
            }
        }
コード例 #13
0
 static HTMLElement()
 {
     dictHtmlTagName = new Gen::Dictionary <string, bool>();
     string[] tagNames =
     {
         "a",        "abbr",      "acronym",    "address",  "applet",   "area",   "b",        "base",     "basefont", "bdo",
         "bgsound",  "big",       "blockquote", "body",     "br",       "button", "caption",  "center",   "cite",     "code",
         "col",      "colgroup",  "comment",    "dd",       "del",      "dfn",    "dir",      "div",      "dl",       "dt",
         "em",       "embed",     "fieldset",   "font",     "form",     "frame",  "frameset", "head",     "h1",       "h2",
         "h3",       "h4",        "h5",         "h6",       "hr",       "html",   "i",        "iframe",   "img",      "input",
         "ins",      "isindex",   "kbd",        "label",    "legend",   "li",     "link",     "listing",  "map",      "marquee",
         "menu",     "meta",      "nobr",       "noframes", "noscript", "object", "ol",       "optgroup", "option",   "p",
         "param",    "plaintext", "q",          "rt",       "ruby",     "rule",   "s",        "samp",     "script",   "select",
         "small",    "span",      "strike",     "strong",   "style",    "sub",    "sup",      "table",    "tbody",    "td",
         "textarea", "tfoot",     "th",         "thead",    "title",    "tr",     "tt",       "u",        "ul",       "var",
         "wbr",      "xmp",
         "blink",    "ilayer",    "layer",      "multicol", "nolayer",  "spacer"
     };
     foreach (string tagName in tagNames)
     {
         dictHtmlTagName.Add(tagName, true);
     }
 }
コード例 #14
0
 //----------------------------------------------------------------------
 //	登録
 //----------------------------------------------------------------------
 public void AddBinaryOperatorDef(string op, prio_t priorityL, prio_t priorityR, bool assocR)
 {
     data_suf.Add(op, new BinaryOperatorDef(op, priorityL, priorityR, assocR));
 }
コード例 #15
0
 public void AddSuffixOperatorDef(string op, prio_t priority)
 {
     data_suffix.Add(op, new SuffixOperatorDef(op, priority));
 }
コード例 #16
0
 private static void InitializeExpressionType()
 {
     exp_types.Add(typeof(IAddressDereferenceExpression), ExpressionType.AddressDereference);
     exp_types.Add(typeof(IAddressOfExpression), ExpressionType.AddressOf);
     exp_types.Add(typeof(IAddressOutExpression), ExpressionType.AddressOut);
     exp_types.Add(typeof(IAddressReferenceExpression), ExpressionType.AddressReference);
     exp_types.Add(typeof(IAnonymousMethodExpression), ExpressionType.AnonymousMethod);
     exp_types.Add(typeof(IArgumentListExpression), ExpressionType.ArgumentList);
     exp_types.Add(typeof(IArgumentReferenceExpression), ExpressionType.ArgumentReference);
     exp_types.Add(typeof(IArrayCreateExpression), ExpressionType.ArrayCreate);
     exp_types.Add(typeof(IArrayIndexerExpression), ExpressionType.ArrayIndexer);
     exp_types.Add(typeof(IAssignExpression), ExpressionType.Assign);
     exp_types.Add(typeof(IBaseReferenceExpression), ExpressionType.BaseReference);
     exp_types.Add(typeof(IBinaryExpression), ExpressionType.Binary);
     exp_types.Add(typeof(IBlockExpression), ExpressionType.Block);
     exp_types.Add(typeof(ICanCastExpression), ExpressionType.CanCast);
     exp_types.Add(typeof(ICastExpression), ExpressionType.Cast);
     exp_types.Add(typeof(IConditionExpression), ExpressionType.Condition);
     exp_types.Add(typeof(IDelegateCreateExpression), ExpressionType.DelegateCreate);
     exp_types.Add(typeof(IDelegateInvokeExpression), ExpressionType.DelegateInvoke);
     exp_types.Add(typeof(IEventReferenceExpression), ExpressionType.EventReference);
     exp_types.Add(typeof(IFieldOfExpression), ExpressionType.FieldOf);
     exp_types.Add(typeof(IFieldReferenceExpression), ExpressionType.FieldReference);
     exp_types.Add(typeof(IGenericDefaultExpression), ExpressionType.GenericDefault);
     exp_types.Add(typeof(ILambdaExpression), ExpressionType.Lambda);
     exp_types.Add(typeof(ILiteralExpression), ExpressionType.Literal);
     exp_types.Add(typeof(IMemberInitializerExpression), ExpressionType.MemberInitializer);
     exp_types.Add(typeof(IMethodInvokeExpression), ExpressionType.MethodInvoke);
     exp_types.Add(typeof(IMethodOfExpression), ExpressionType.MethodOf);
     exp_types.Add(typeof(IMethodReferenceExpression), ExpressionType.MethodReference);
     exp_types.Add(typeof(INullCoalescingExpression), ExpressionType.NullCoalescing);
     exp_types.Add(typeof(IObjectCreateExpression), ExpressionType.ObjectCreate);
     exp_types.Add(typeof(IPropertyIndexerExpression), ExpressionType.PropertyIndexer);
     exp_types.Add(typeof(IPropertyReferenceExpression), ExpressionType.PropertyReference);
     exp_types.Add(typeof(IQueryExpression), ExpressionType.Query);
     exp_types.Add(typeof(ISizeOfExpression), ExpressionType.SizeOf);
     exp_types.Add(typeof(ISnippetExpression), ExpressionType.Snippet);
     exp_types.Add(typeof(IStackAllocateExpression), ExpressionType.StackAlloc);
     exp_types.Add(typeof(IThisReferenceExpression), ExpressionType.ThisReference);
     exp_types.Add(typeof(ITryCastExpression), ExpressionType.TryCast);
     exp_types.Add(typeof(ITypedReferenceCreateExpression), ExpressionType.TypedReferenceCreate);
     exp_types.Add(typeof(ITypeOfExpression), ExpressionType.TypeOf);
     exp_types.Add(typeof(ITypeOfTypedReferenceExpression), ExpressionType.TypeOfTypedReference);
     exp_types.Add(typeof(ITypeReferenceExpression), ExpressionType.TypeReference);
     exp_types.Add(typeof(IUnaryExpression), ExpressionType.Unary);
     exp_types.Add(typeof(IValueOfTypedReferenceExpression), ExpressionType.ValueOfTypedReference);
     exp_types.Add(typeof(IVariableDeclarationExpression), ExpressionType.VariableDeclaration);
     exp_types.Add(typeof(IVariableReferenceExpression), ExpressionType.VariableReference);
 }
コード例 #17
0
        private static void InitializeOperatorPrecedence()
        {
            prec_exp.Add(ExpressionType.ThisReference, 15);
            prec_exp.Add(ExpressionType.ArgumentReference, 15);
            prec_exp.Add(ExpressionType.VariableReference, 15);
            prec_exp.Add(ExpressionType.Literal, 15);
            prec_exp.Add(ExpressionType.Block, 15);
            prec_exp.Add(ExpressionType.TryCast, 15);
            prec_exp.Add(ExpressionType.SizeOf, 15);                                         // sizeof(<typename>) のみ (リファレンスでは 12 と同じだが)

            // :: 系統
            prec_exp.Add(ExpressionType.BaseReference, 14);
            prec_exp.Add(ExpressionType.TypeOf, 14);

            // 後置演算子の類
            prec_exp.Add(ExpressionType.EventReference, PREC_MEM_ACCESS);
            prec_exp.Add(ExpressionType.FieldReference, PREC_MEM_ACCESS);
            prec_exp.Add(ExpressionType.MethodReference, PREC_MEM_ACCESS);
            prec_exp.Add(ExpressionType.PropertyReference, PREC_MEM_ACCESS);
            prec_exp.Add(ExpressionType.ArrayIndexer, PREC_POST);
            prec_exp.Add(ExpressionType.PropertyIndexer, PREC_POST);
            prec_exp.Add(ExpressionType.MethodInvoke, PREC_POST);
            prec_unary.Add(UnaryOperator.PostDecrement, PREC_POST);
            prec_unary.Add(UnaryOperator.PostIncrement, PREC_POST);

            // 前置演算子の類
            prec_exp.Add(ExpressionType.ObjectCreate, 12);                         // gcnew / typename() の二つの場合
            prec_exp.Add(ExpressionType.AddressDereference, PREC_PRE);             // *
            prec_exp.Add(ExpressionType.AddressOf, PREC_PRE);                      // &
            prec_exp.Add(ExpressionType.Cast, PREC_CAST);                          // (typename)
            prec_exp.Add(ExpressionType.ArrayCreate, PREC_PRE);                    // gcnew
            prec_unary.Add(UnaryOperator.PreDecrement, PREC_PRE);                  // --
            prec_unary.Add(UnaryOperator.PreIncrement, PREC_PRE);                  // ++
            prec_unary.Add(UnaryOperator.Negate, PREC_PRE);                        // -
            prec_unary.Add(UnaryOperator.BooleanNot, PREC_PRE);                    // !
            prec_unary.Add(UnaryOperator.BitwiseNot, PREC_PRE);                    // ~

            prec_binop.Add(BinaryOperator.Divide, PREC_BI_MUL);
            prec_binop.Add(BinaryOperator.Modulus, PREC_BI_MUL);
            prec_binop.Add(BinaryOperator.Multiply, PREC_BI_MUL);

            prec_binop.Add(BinaryOperator.Subtract, 9);
            prec_binop.Add(BinaryOperator.Add, 9);

            prec_binop.Add(BinaryOperator.ShiftLeft, 8);
            prec_binop.Add(BinaryOperator.ShiftRight, 8);

            prec_binop.Add(BinaryOperator.GreaterThan, 7);
            prec_binop.Add(BinaryOperator.GreaterThanOrEqual, 7);
            prec_binop.Add(BinaryOperator.LessThan, 7);
            prec_binop.Add(BinaryOperator.LessThanOrEqual, 7);

            prec_binop.Add(BinaryOperator.IdentityEquality, 6);
            prec_binop.Add(BinaryOperator.IdentityInequality, 6);
            prec_binop.Add(BinaryOperator.ValueEquality, 6);
            prec_binop.Add(BinaryOperator.ValueInequality, 6);
            prec_exp.Add(ExpressionType.CanCast, 6);

            prec_binop.Add(BinaryOperator.BitwiseAnd, 5);
            prec_binop.Add(BinaryOperator.BitwiseExclusiveOr, 4);
            prec_binop.Add(BinaryOperator.BitwiseOr, 3);

            prec_binop.Add(BinaryOperator.BooleanAnd, 2);
            prec_binop.Add(BinaryOperator.BooleanOr, 1);

            prec_exp.Add(ExpressionType.Condition, PREC_COND);            // ==0;

            prec_exp.Add(ExpressionType.Assign, -1);
        }
コード例 #18
0
ファイル: CppScanner.cs プロジェクト: akinomyoga/afh
        private void process(string text)
        {
            CppWordReader wr_orig = this.wr;

            this.wr = new CppWordReader(text);
            while (wr.ReadNext())
            {
                switch (wr.CurrentType.value)
                {
                case WordType.vKeyWord:
                    // @ マクロ
                    break;

                case WordType.vTag:
                    // # マクロ
                    // #line
                {
                    Rgx.Capture c = Rgx.Match(@"#:bline:b((?<line>\d+):b)?(?<filename>:"")", wr.CurrentWord);
                    if (c != null)
                    {
                        filename = c.Groups["filename"].Last.Value;
                        if (c.Groups["line"].Count > 0)
                        {
                            int line;
                            if (int.TryParse(c.Groups["line"].Last.Value, out line))
                            {
                                wr.LineNumber = line - 1;
                            }
                        }
                        buf.AppendFormat("#line {0} {1}", wr.LineNumber + 1, filename);
                        break;
                    }
                }
                    // #pragma begin(define)
                    {
                        Rgx.Capture c = DefineMacro.REG_DECL.Match(wr.CurrentWord);
                        if (c != null)
                        {
                            DefineMacro macro = this.ReadDefineMacro(c);
                            if (!macros.ContainsKey(macro.Name))
                            {
                                macros.Add(macro.Name, macro);
                                break;
                            }
                            else
                            {
                                buf.AppendLine();
                                buf.AppendLine("#error マクロ " + macro.Name + " は既に定義されています");
                                buf.AppendFormat("#line {0} {1}", wr.LineNumber + 1, filename);
                            }
                        }
                    }
                    // #pragma undef
                    {
                        Rgx.Capture c = DefineMacro.REG_UNDEF.Match(wr.CurrentWord);
                        if (c != null)
                        {
                            string name = c.Groups["name"].Last.Value;
                            if (macros.Remove(name))
                            {
                                break;
                            }
                            buf.AppendLine("#error " + name + " は定義されていないマクロです");
                            buf.AppendFormat("#line {0} {1}\r\n", wr.LineNumber + 1, filename);
                        }
                    }
                    goto default;

                case WordType.vIdentifier:
                    if (!macros.ContainsKey(wr.CurrentWord))
                    {
                        goto default;
                    }
                    this.ReadMacroRef(wr.CurrentWord);
                    break;

                case WordType.vComment:
                default:
                    buf.Append(wr.CurrentWord);
                    break;
                }
            }
            this.wr = wr_orig;
        }
コード例 #19
0
ファイル: HTMLParser.cs プロジェクト: akinomyoga/afh
        private static void initialize_judgeNest()
        {
            //----------------------------------------------------------------------
            // 親要素になる事の出来ない要素のリストを作成します。
            //----------------------------------------------------------------------
            judgeNest_denyList.Add("meta");
            judgeNest_denyList.Add("link");
            judgeNest_denyList.Add("br");
            judgeNest_denyList.Add("hr");
            judgeNest_denyList.Add("img");
            judgeNest_denyList.Add("col");
            judgeNest_denyList.Add("embed");
            judgeNest_denyList.Add("param");
            judgeNest_denyList.Add("area");
            judgeNest_denyList.Add("keygen");
            judgeNest_denyList.Add("source");
            judgeNest_denyList.Add("base");

            //----------------------------------------------------------------------
            // 子要素として持つ事が出来ない要素のリストを作成します。
            //----------------------------------------------------------------------
            // block element
            System.Collections.Generic.List <string> blockElements = new System.Collections.Generic.List <string>(new string[] {
                "p", "div", "h1", "h2", "h3", "h4", "h5", "h6",
                "dl", "ol", "ul", "table", "address", "blockquote", "center",
                "pre", "xmp", "listing", "plaintext"
            });
            judgeNest_denyTable.Add("p", blockElements);
            judgeNest_denyTable.Add("h1", blockElements);
            judgeNest_denyTable.Add("h2", blockElements);
            judgeNest_denyTable.Add("h3", blockElements);
            judgeNest_denyTable.Add("h4", blockElements);
            judgeNest_denyTable.Add("h5", blockElements);
            judgeNest_denyTable.Add("h6", blockElements);
            judgeNest_denyTable.Add("address", blockElements);

            judgeNest_denyTable.Add("li", new Gen::List <string>(new string[] { "li" }));

            // dictionary element
            Gen::List <string> list = new Gen::List <string> {
                "dt", "dd"
            };

            list.AddRange(blockElements);
            judgeNest_denyTable.Add("dt", list);
            judgeNest_denyTable.Add("dd", list);

            // table element
            list = new System.Collections.Generic.List <string>(new string[] { "thead", "tbody", "tfoot" });
            judgeNest_denyTable.Add("thead", list);
            judgeNest_denyTable.Add("tbody", list);
            judgeNest_denyTable.Add("tfoot", list);
            list = new System.Collections.Generic.List <string>(new string[] { "tr", "thead", "tbody", "tfoot" });
            judgeNest_denyTable.Add("tr", list);
            judgeNest_denyTable.Add("caption", list);
            list = new System.Collections.Generic.List <string>(new string[] { "td", "th", "tr", "thead", "tbody", "tfoot" });
            judgeNest_denyTable.Add("td", list);
            judgeNest_denyTable.Add("th", list);

            // ruby element
            list = new System.Collections.Generic.List <string>(new string[] { "rb", "rt", "rp" });
            judgeNest_denyTable.Add("rb", list);
            judgeNest_denyTable.Add("rt", list);
            judgeNest_denyTable.Add("rp", list);
        }
コード例 #20
0
        public void dbg_NearImage()
        {
            ImageDirectory overlap = new ImageDirectory("<重複検索>", root);
            Gen::Dictionary <Image, ImageDirectory> groups = new Gen::Dictionary <Image, ImageDirectory>();

            afh.ImageArrange.ProgressDialog progress = new ProgressDialog();
            progress.Title       = "重複比較中 ...";
            progress.ProgressMax = this.sorted.Count;

            progress.Show();
            for (int i = 0; i < this.sorted.Count; i++)
            {
                Image img1 = new Image(this.root, this.sorted[i]);

                if (i % 50 == 0)
                {
                    progress.Description = "画像 '" + img1.thm.filepath + "' の類似画像を探索中 ...";
                    if (progress.IsCanceled)
                    {
                        return;
                    }
                }

                for (int j = i + 1; j < this.sorted.Count; j++)
                {
                    Image img2 = new Image(this.root, this.sorted[j]);
                    if (!Image.EqualAspect(img1, img2))
                    {
                        break;
                    }

                    if (Image.Resembles(img1, img2))
                    {
                        ImageDirectory group1 = null;
                        ImageDirectory group2 = null;
                        bool           b1     = groups.TryGetValue(img1, out group1);
                        bool           b2     = groups.TryGetValue(img2, out group2);
                        switch ((b1?1:0) | (b2?2:0))
                        {
                        case 3:                                 // 両方
                            if (group1 == group2)
                            {
                                break;
                            }
                            // 両グループの併合
                            overlap.dirs.Remove(group2);
                            foreach (Image img in group2.EnumImages())
                            {
                                group1.Add(img);
                                groups[img] = group1;
                            }
                            break;

                        case 1:                                 // group1 だけ
                            group1.Add(img2);
                            groups.Add(img2, group1);
                            break;

                        case 2:                                 // group2 だけ
                            group2.Add(img1);
                            groups.Add(img1, group2);
                            break;

                        case 0:                                 // 両者未登録
                            ImageDirectory group = new ImageDirectory("Group " + overlap.dirs.Count.ToString(), root);
                            group.Add(img1);
                            group.Add(img2);
                            groups.Add(img1, group);
                            groups.Add(img2, group);
                            overlap.Add(group);
                            break;

                        default:
                            throw new System.InvalidProgramException();
                        }
                        //System.Console.WriteLine("次の画像は似ています\r\n    {0}\r\n    {1}",thm1.filepath,thm2.filepath);
                    }
                }
                if (i % 10 == 0)
                {
                    progress.Progress = i;
                }
            }
            progress.Close();

            this.root.dirs.Add(overlap);
        }
コード例 #21
0
 public void AddOpenParenDef(string op, Context ctx)
 {
     data_openp.Add(op, new OpenParenDef(op, ctx));
 }
コード例 #22
0
        private static void InitializeStatementType()
        {
            state_types.Add(typeof(IAttachEventStatement), StatementType.AttachEvent);
            state_types.Add(typeof(IBlockStatement), StatementType.Block);
            state_types.Add(typeof(IBreakStatement), StatementType.Break);
            state_types.Add(typeof(ICommentStatement), StatementType.Comment);
            state_types.Add(typeof(IConditionStatement), StatementType.Condition);
            state_types.Add(typeof(IContinueStatement), StatementType.Continue);
            state_types.Add(typeof(IDebugBreakStatement), StatementType.DebugBreak);
            state_types.Add(typeof(IDoStatement), StatementType.Do);
            state_types.Add(typeof(IExpressionStatement), StatementType.Expression);
            state_types.Add(typeof(IFixedStatement), StatementType.Fixed);
            state_types.Add(typeof(IForEachStatement), StatementType.ForEach);
            state_types.Add(typeof(IForStatement), StatementType.For);
            state_types.Add(typeof(IGotoStatement), StatementType.Goto);
            state_types.Add(typeof(ILabeledStatement), StatementType.Labeled);
            state_types.Add(typeof(ILockStatement), StatementType.Lock);
            state_types.Add(typeof(IMemoryCopyStatement), StatementType.MemoryCopy);
            state_types.Add(typeof(IMemoryInitializeStatement), StatementType.MemoryInitialize);
            state_types.Add(typeof(IMethodReturnStatement), StatementType.MethodReturn);
            state_types.Add(typeof(IRemoveEventStatement), StatementType.RemoveEvent);
            state_types.Add(typeof(ISwitchStatement), StatementType.Switch);
            state_types.Add(typeof(IThrowExceptionStatement), StatementType.ThrowException);
            state_types.Add(typeof(ITryCatchFinallyStatement), StatementType.TryCatch);
            state_types.Add(typeof(IUsingStatement), StatementType.Using);
            state_types.Add(typeof(IWhileStatement), StatementType.While);

            // 追加
            state_types.Add(typeof(LocalRefVariableStatement), StatementType.LocalRefVariable);
            state_types.Add(typeof(DeleteStatement), StatementType.Delete);
            state_types.Add(typeof(LabelStatement), StatementType.Label);
            state_types.Add(typeof(DefaultConstructionStatement), StatementType.DefaultConstruction);
        }
コード例 #23
0
 public static void AddGlobalCommand(string commandName, ICommand command)
 {
     cmdreg_.Add(commandName, command);
 }
コード例 #24
0
 public void AddFunctionParenDef(string op, prio_t prioL, Context ctx)
 {
     data_openf.Add(op, new FunctionParenDef(op, prioL, ctx));
 }
コード例 #25
0
 public void AddPrefixOperatorDef(string op, prio_t priority)
 {
     data_pre.Add(op, new PrefixOperatorDef(op, priority));
 }
コード例 #26
0
 private static void InitializeTypeToRefs()
 {
     type_refs.Add(typeof(bool), new CTypeFromClrType(typeof(bool)));
     type_refs.Add(typeof(sbyte), new CTypeFromClrType(typeof(sbyte)));
     type_refs.Add(typeof(byte), new CTypeFromClrType(typeof(byte)));
     type_refs.Add(typeof(short), new CTypeFromClrType(typeof(short)));
     type_refs.Add(typeof(ushort), new CTypeFromClrType(typeof(ushort)));
     type_refs.Add(typeof(int), new CTypeFromClrType(typeof(int)));
     type_refs.Add(typeof(uint), new CTypeFromClrType(typeof(uint)));
     type_refs.Add(typeof(long), new CTypeFromClrType(typeof(long)));
     type_refs.Add(typeof(ulong), new CTypeFromClrType(typeof(ulong)));
     type_refs.Add(typeof(float), new CTypeFromClrType(typeof(float)));
     type_refs.Add(typeof(double), new CTypeFromClrType(typeof(double)));
     type_refs.Add(typeof(decimal), new CTypeFromClrType(typeof(decimal)));
     type_refs.Add(typeof(char), new CTypeFromClrType(typeof(char)));
     type_refs.Add(typeof(string), new CTypeFromClrType(typeof(string)));
 }
コード例 #27
0
ファイル: HTMLParser.cs プロジェクト: akinomyoga/afh
        private static void initialize_judgeNest()
        {
            Gen::Dictionary <string, bool> listNoChild = new Gen::Dictionary <string, bool>();

            listNoChild.Add(JUDGENEST_LISTKEY_DEFAULT, false);
            foreach (string tagName in readElement_closedElem)
            {
                judgeNest_table.Add(tagName, listNoChild);
            }

            Gen::Dictionary <string, bool> listNoBlock = new Gen::Dictionary <string, bool>();

            listNoBlock.Add(JUDGENEST_LISTKEY_DEFAULT, true);
            foreach (string childTag in TAGS_BLOCKELEM)
            {
                listNoBlock.Add(childTag, false);
            }
            judgeNest_table.Add("p", listNoBlock);
            judgeNest_table.Add("h1", listNoBlock);
            judgeNest_table.Add("h2", listNoBlock);
            judgeNest_table.Add("h3", listNoBlock);
            judgeNest_table.Add("h4", listNoBlock);
            judgeNest_table.Add("h5", listNoBlock);
            judgeNest_table.Add("h6", listNoBlock);
            judgeNest_table.Add("address", listNoBlock);

            {
                Gen::Dictionary <string, bool> listLi = new Gen::Dictionary <string, bool>();
                listLi.Add(JUDGENEST_LISTKEY_DEFAULT, true);
                listLi.Add("li", false);
                judgeNest_table.Add("li", listLi);

                Gen::Dictionary <string, bool> listDt = new Gen::Dictionary <string, bool>(listNoBlock);
                listDt.Add("dt", false);
                listDt.Add("dd", false);
                judgeNest_table.Add("dt", listDt);

                Gen::Dictionary <string, bool> listDd = new Gen::Dictionary <string, bool>();
                listDd.Add(JUDGENEST_LISTKEY_DEFAULT, true);
                listDd.Add("dt", false);
                listDd.Add("dd", false);
                judgeNest_table.Add("dd", listDd);
            }

            {
                Gen::Dictionary <string, bool> listTablePart = new Gen::Dictionary <string, bool>();
                listTablePart.Add(JUDGENEST_LISTKEY_DEFAULT, true);
                listTablePart.Add("thead", false);
                listTablePart.Add("tbody", false);
                listTablePart.Add("tfoot", false);
                judgeNest_table.Add("thead", listTablePart);
                judgeNest_table.Add("tbody", listTablePart);
                judgeNest_table.Add("tfoot", listTablePart);

                Gen::Dictionary <string, bool> listTableRow = new Gen::Dictionary <string, bool>(listTablePart);
                listTableRow.Add("tr", false);
                judgeNest_table.Add("tr", listTableRow);
                judgeNest_table.Add("caption", listTableRow);

                Gen::Dictionary <string, bool> listTableCell = new Gen::Dictionary <string, bool>(listTableRow);
                listTableCell.Add("th", false);
                listTableCell.Add("td", false);
                judgeNest_table.Add("th", listTableCell);
                judgeNest_table.Add("td", listTableCell);
            }

            {
                Gen::Dictionary <string, bool> list = new Gen::Dictionary <string, bool>(listNoBlock);
                list.Add("rb", false);
                list.Add("rt", false);
                list.Add("rp", false);
                judgeNest_table.Add("rb", list);
                judgeNest_table.Add("rt", list);
                judgeNest_table.Add("rp", list);
            }
        }