示例#1
0
        private static MetaAsset SearchDownForMetaAsset(ParseNode node)
        {
            if (node == null)
            {
                return(null);
            }

            MetaAsset meta;

            if (node.RuleName == RULE_NAME_CLASS_DECL && node.Count >= 2 && node[0].RuleName == RULE_NAME_CLASS)
            {
                ParseNode className = SearchDownFor(node[1], RULE_NAME_IDENTIFIER);
                if (className != null)
                {
                    ParseNode parent = SearchUpForDeclarationContent(node);
                    if (parent != null)
                    {
                        int i = 0;
                        while (i < parent.Count && !HasRuleWithValue(parent[i], RULE_NAME_IDENTIFIER, META_ASSET))
                        {
                            ++i;
                        }
                        ++i;
                        if (i < parent.Count)
                        {
                            meta = new MetaAsset(className.Value);
                            Dictionary <string, string> attr = SearchDownForAttributes(parent[i]);
                            if (attr != null)
                            {
                                foreach (string key in attr.Keys)
                                {
                                    if (key == META_ATTR_NAME)
                                    {
                                        meta.Name = attr[key];
                                    }
                                    else if (key == META_ATTR_DESCRIPTION)
                                    {
                                        meta.Description = attr[key];
                                    }
                                }
                            }
                            return(meta);
                        }
                    }
                }
            }

            foreach (ParseNode child in node)
            {
                meta = SearchDownForMetaAsset(child);
                if (meta != null)
                {
                    return(meta);
                }
            }

            return(null);
        }
示例#2
0
        public static string GenerateMetaAssetJson(string cppContent, out string status)
        {
            MetaAsset meta = GenerateMetaAsset(cppContent, out status);

            return(meta == null ? null : Newtonsoft.Json.JsonConvert.SerializeObject(meta, Newtonsoft.Json.Formatting.Indented));
        }