static void parse_parameter(rapidxml::xml_node<>* node, parameter& p)
{
    // #define: <param><defname>Point</defname></param>
    // template: <param><type>typename</type><declname>CoordinateType</declname><defname>CoordinateType</defname></param>
    // template with default: <param><type>typename</type><declname>CoordinateSystem</declname><defname>CoordinateSystem</defname><defval><ref ....>cs::cartesian</ref></defval></param>
    // with enum: <type><ref refid="group__enum_1ga7d33eca9a5389952bdf719972eb802b6" kindref="member">closure_selector</ref></type>
    if (node != NULL)
    {
        std::string name = node->name();
        if (name == "type")
        {
            get_contents(node->first_node(), p.fulltype);
            p.type = p.fulltype;
            boost::replace_all(p.type, " const", "");
            boost::trim(p.type);
            boost::replace_all(p.type, "&", "");
            boost::replace_all(p.type, "*", "");
            boost::trim(p.type);
        }
        else if (name == "declname") p.name = node->value();
        else if (name == "parametername") p.name = node->value();
        else if (name == "defname") p.name = node->value(); 
        else if (name == "defval") 
        {
             parse_para(node, p.default_value, p.skip);
        }
        else if (name == "para")
        {
             parse_para(node, p.brief_description, p.skip);
        }

        parse_parameter(node->first_node(), p);
        parse_parameter(node->next_sibling(), p);
    }
}
Esempio n. 2
0
var_decl_list_t parse_para_list(tokenizer_t t) {
    var_decl_list_t param = mk_var_decl_list();
    if(cur_tok(t).kind == TOK_RPAREN) {
    }
    else if(cur_tok(t).kind == TOK_INT) {
        var_decl_t x = parse_para(t);
        var_decl_list_add(param, x);
        while(cur_tok(t).kind == TOK_COMMA) {
            eat_it(t, TOK_COMMA);
            x = parse_para(t);
            var_decl_list_add(param, x);
        }
    }
    return param;
}
static void parse_enumeration_value(rapidxml::xml_node<>* node, enumeration_value& value)
{
    // <enumvalue><name>green</name><initializer> 2</initializer>
    //    <briefdescription><para>...</para></briefdescription>
    //    <detaileddescription><para>...</para></detaileddescription>
    // </enumvalue>
    if (node != NULL)
    {
        std::string node_name = node->name();

        if (node_name == "name") value.name = node->value();
        else if (node_name == "para")
        {
            // Parses both brief AND detailed into this description
            parse_para(node, value.brief_description, value.skip);
        }
        else if (node_name == "initializer")
        {
            value.initializer = node->value();
        }

        parse_enumeration_value(node->first_node(), value);
        parse_enumeration_value(node->next_sibling(), value);
    }
}
Esempio n. 4
0
static int set_display_axis(int recovery)
{
    int fd;
    char *path = "/sys/class/display/axis";
    char str[128];
    int count, i;
    fd = open(path, O_CREAT|O_RDWR | O_TRUNC, 0644);
    if (fd >= 0) {
        if (!recovery) {
            read(fd, str, 128);
            printf("read axis %s, length %d\n", str, strlen(str));
            count = parse_para(str, 8, axis);
        }
        if (recovery) {
            sprintf(str, "%d %d %d %d %d %d %d %d", 
                axis[0],axis[1], axis[2], axis[3], axis[4], axis[5], axis[6], axis[7]);
        } else {
            sprintf(str, "2048 %d %d %d %d %d %d %d", 
                axis[1], axis[2], axis[3], axis[4], axis[5], axis[6], axis[7]);
        }
        write(fd, str, strlen(str));
        close(fd);
        return 0;
    }

    return -1;
}
/*
This is used for different purposes within Doxygen. 
- Either a detailed description, possibly containing several sections (para's)
  -> so parse next siblings
- Or a detailed description also containing qbk records

So we have to list explicitly either where to recurse, or where not to...

*/
static void parse_para(rapidxml::xml_node<>* node, std::string& contents, bool& skip, bool first = true)
{
    if (node != NULL)
    {
        if (node->type() == rapidxml::node_element)
        {
            //std::cout << "ELEMENT: " << node->name() << "=" << node->value() << std::endl;
            std::string name = node->name();
            if (boost::equals(name, "qbk.skip"))
            {
                skip = true;
                return;
            }
            else if (! (
                (boost::equals(name, "para") && first)
                || boost::equals(name, "ref")
                || boost::equals(name, "defval")
                || boost::equals(name, "verbatim")
                || boost::equals(name, "bold")
                || boost::equals(name, "emphasis")
                || boost::equals(name, "linebreak")
                ))
            {
                return;
            }
        }
        else if (node->type() == rapidxml::node_data)
        {
            contents += node->value();
            //std::cout << "DATA: " << node->name() << "=" << node->value() << std::endl;
        }
        else
        {
            //std::cout << "OTHER: " << node->name() << "=" << node->value() << std::endl;
        }
        parse_para(node->first_node(), contents, skip, false);
        parse_para(node->next_sibling(), contents, skip, false);
    }
}
Esempio n. 6
0
static ssize_t store_scale_axis(struct device *device, struct device_attribute *attr,
			 const char *buf, size_t count)
{
	struct fb_info *fb_info = dev_get_drvdata(device);
	int parsed[4];

	if (likely(parse_para(buf, 4, parsed) == 4)) {
		osddev_set_scale_axis(fb_info->node, parsed[0], parsed[1], parsed[2], parsed[3]);
	} else {
		amlog_level(LOG_LEVEL_HIGH, "set scale axis error\n");
	}

	return count;
}
Esempio n. 7
0
static ssize_t store_block_windows(struct device *device, struct device_attribute *attr,
			 const char *buf, size_t count)
{
	struct fb_info *fb_info = dev_get_drvdata(device);
	int parsed[8];

	if (likely(parse_para(buf, 8, parsed) == 8)) {
		osddev_set_block_windows(fb_info->node, parsed);
	} else {
		amlog_level(LOG_LEVEL_HIGH, "set block windows error\n");
	}

	return count;
}
static  void  read_reg(char *para)
{
	char  count=1;
	vout_reg_t  reg;

	memcpy(&reg.addr,parse_para(para+1,&count),sizeof(unsigned int));

	if (((*para) == 'm') || ((*para) == 'M'))
	{
		amlog_level(LOG_LEVEL_HIGH,"[0x%x] : 0x%x\r\n", CBUS_REG_ADDR(reg.addr), READ_MPEG_REG(reg.addr));
	}else if (((*para) == 'p') || ((*para) == 'P')) {
		if (APB_REG_ADDR_VALID(reg.addr))
		    amlog_level(LOG_LEVEL_HIGH,"[0x%x] : 0x%x\r\n", APB_REG_ADDR(reg.addr), READ_APB_REG(reg.addr));
	}else if (((*para) == 'h') || ((*para) == 'H')) {
	    amlog_level(LOG_LEVEL_HIGH,"[0x%x] : 0x%x\r\n", AHB_REG_ADDR(reg.addr), READ_AHB_REG(reg.addr));
	}
}
//axis type : 0x12  0x100 0x120 0x130
static void  set_vout_window(char *para) 
{
#define   OSD_COUNT   2
	static  disp_rect_t  disp_rect[OSD_COUNT];
	char  count=OSD_COUNT*4;	
	int   *pt=&disp_rect[0].x;
	

	//parse window para .
	memcpy(pt,parse_para(para,&count),sizeof(disp_rect_t)*OSD_COUNT);
	
	if(count >=4 && count <8 )
	{
		disp_rect[1]=disp_rect[0] ;
	}
	amlog_mask_level(LOG_MASK_PARA,LOG_LEVEL_LOW,"osd0=>x:%d ,y:%d,w:%d,h:%d\r\n osd1=> x:%d,y:%d,w:%d,h:%d \r\n", \
			*pt,*(pt+1),*(pt+2),*(pt+3),*(pt+4),*(pt+5),*(pt+6),*(pt+7));
	vout2_notifier_call_chain(VOUT_EVENT_OSD_DISP_AXIS,&disp_rect[0]) ;
}
static  void  write_reg(char *para)
{
	char  count=2;
	vout_reg_t  reg;

	memcpy(&reg, parse_para(para+1,&count), sizeof(vout_reg_t));

	if (((*para) == 'm') || ((*para) == 'M')){
		WRITE_MPEG_REG(reg.addr,reg.value);
		amlog_level(LOG_LEVEL_HIGH,"[0x%x] = 0x%x 0x%x\r\n", CBUS_REG_ADDR(reg.addr), reg.value, READ_MPEG_REG(reg.addr));
	}
	else if (((*para) == 'p') || ((*para) == 'P')) {
		if (APB_REG_ADDR_VALID(reg.addr)){
			WRITE_APB_REG(reg.addr,reg.value);
			amlog_level(LOG_LEVEL_HIGH,"[0x%x] = 0x%x 0x%x\r\n", APB_REG_ADDR(reg.addr), reg.value, READ_APB_REG(reg.addr));
		}
	}		
	else if (((*para) == 'h') || ((*para) == 'H')) {
		WRITE_AHB_REG(reg.addr,reg.value);
		amlog_level(LOG_LEVEL_HIGH,"[0x%x] = 0x%x 0x%x\r\n", AHB_REG_ADDR(reg.addr), reg.value, READ_AHB_REG(reg.addr));
	}	
}
static void parse_element(rapidxml::xml_node<>* node, configuration const& config, std::string const& parent, Element& el)
{
    if (node != NULL)
    {
        std::string name = node->name();
        std::string full = parent + "." + name;

        if (full == ".briefdescription.para")
        {
            parse_para(node, el.brief_description, el.skip);
        }
        else if (full == ".detaileddescription.para")
        {
            std::string para;
            parse_para(node, para, el.skip);
            if (!para.empty() && !el.detailed_description.empty())
            {
                el.detailed_description += "\n\n";
            }
            el.detailed_description += para;
        }
        else if (full == ".location")
        {
            std::string loc = get_attribute(node, "file");
            // Location of (header)file. It is a FULL path, so find the start
            // and strip the rest
            std::size_t pos = loc.rfind(config.start_include);
            if (pos != std::string::npos)
            {
                loc = loc.substr(pos);
            }
            el.location = loc;
            el.line = atol(get_attribute(node, "line").c_str());
        }
        else if (full == ".detaileddescription.para.qbk")
        {
            el.qbk_markup.push_back(markup(node->value()));
        }
        else if (full == ".detaileddescription.para.qbk.after.synopsis")
        {
            el.qbk_markup.push_back(markup(markup_after, markup_synopsis, node->value()));
        }
        else if (full == ".detaileddescription.para.qbk.before.synopsis")
        {
            el.qbk_markup.push_back(markup(markup_before, markup_synopsis, node->value()));
        }
        else if (full == ".detaileddescription.para.qbk.distinguish")
        {
            el.additional_description = node->value();
            boost::trim(el.additional_description);
        }
        else if (full == ".templateparamlist")
        {
            parse_parameter_list(node->first_node(), el.template_parameters);
        }
        else if (full == ".detaileddescription.para.parameterlist")
        {
            std::string kind = get_attribute(node, "kind");
            if (kind == "param")
            {
                parse_parameter_list(node->first_node(), el.parameters);
            }
            else if (kind == "templateparam")
            {
                parse_parameter_list(node->first_node(), el.template_parameters);
            }
        }

        parse_element(node->first_node(), config, full, el);
        parse_element(node->next_sibling(), config, parent, el);
    }
}
Esempio n. 12
0
static void parse_para(rapidxml::xml_node<>* node, configuration const& config, std::string& contents, bool& skip, bool first = true, text_block tb = not_in_block)
{
    if (node != NULL)
    {
        if (node->type() == rapidxml::node_element)
        {
            //std::cout << "ELEMENT: " << node->name() << "=" << node->value() << std::endl;
            std::string name = node->name();
            if ( boost::equals(name, "itemizedlist") )
            {
                contents += "\n\n";
                parse_para(node->first_node(), config, contents, skip, true, tb);
                contents += "\n";
                parse_para(node->next_sibling(), config, contents, skip, true, tb);
                return;
            }
            else if ( boost::equals(name, "listitem") )
            {
                contents += "* ";
                parse_para(node->first_node(), config, contents, skip, true, tb);
                contents += "\n";
                parse_para(node->next_sibling(), config, contents, skip, true, tb);
                return;
            }
            else if ( boost::equals(name, "verbatim") )
            {
                contents += "\n``\n";
                parse_para(node->first_node(), config, contents, skip, false, tb);
                contents += "``\n";
                parse_para(node->next_sibling(), config, contents, skip, false, tb);
                return;
            }
            else if ( boost::equals(name, "bold") )
            {
                contents += "[*";
                parse_para(node->first_node(), config, contents, skip, false, in_block);
                contents += "]";
                parse_para(node->next_sibling(), config, contents, skip, false, tb);
                return;
            }
            else if ( boost::equals(name, "emphasis") )
            {
                contents += "['";
                parse_para(node->first_node(), config, contents, skip, false, in_block);
                contents += "]";
                parse_para(node->next_sibling(), config, contents, skip, false, tb);
                return;
            }
            else if ( boost::equals(name, "computeroutput") )
            {
                contents += "[^";
                parse_para(node->first_node(), config, contents, skip, false, tb == in_block ? in_block : in_code_block);
                contents += "]";
                parse_para(node->next_sibling(), config, contents, skip, false, tb);
                return;
            }
            else if ( boost::equals(name, "ref") )
            {
                // If alternative output is used - insert links
                if ( configuration::alt == config.output_style )
                {
                    std::string refid = node->first_attribute("refid")->value();
                    if ( !refid.empty() )
                    {
                        contents += std::string("[link ") + refid + " ";
                        parse_para(node->first_node(), config, contents, skip, false, in_block);
                        contents += "]";                        
                        parse_para(node->next_sibling(), config, contents, skip, false, tb);
                        return;
                    }
                }                                
            }
            else if (! (
                (boost::equals(name, "para") && first)
                || boost::equals(name, "defval")
                || boost::equals(name, "linebreak")
                ))
            {
                return;
            }
        }
        else if (node->type() == rapidxml::node_data)
        {
            std::string str = node->value();
            if ( tb == in_block )
            {
                boost::replace_all(str, "\\", "\\\\");
                boost::replace_all(str, "[", "\\[");
                boost::replace_all(str, "]", "\\]");
            }
            else if ( tb == in_code_block )
            {
                if ( str.find('`') == std::string::npos )
                str = std::string("`") + str + "`";
            }
            contents += str;
            //std::cout << "DATA: " << node->name() << "=" << node->value() << std::endl;
        }
        else
        {
            //std::cout << "OTHER: " << node->name() << "=" << node->value() << std::endl;
        }

        parse_para(node->first_node(), config, contents, skip, false, tb);
        parse_para(node->next_sibling(), config, contents, skip, false, tb);
    }
}