コード例 #1
0
ファイル: nl_parser.c プロジェクト: j26w/mame
ATTR_COLD void parser_t::verror(pstring msg, int line_num, pstring line)
{
	m_setup.netlist().error("line %d: error: %s\n\t\t%s\n", line_num,
			msg.cstr(), line.cstr());

	//throw error;
}
コード例 #2
0
ファイル: pfunction.cpp プロジェクト: MASHinfo/mame
void pfunction::compile(const std::vector<pstring> &inputs, const pstring &expr)
{
	if (expr.startsWith("rpn:"))
		compile_postfix(inputs, expr.substr(4));
	else
		compile_infix(inputs, expr);
}
コード例 #3
0
ファイル: orcus_xml.cpp プロジェクト: Distrotech/liborcus
void orcus_xml::append_sheet(const pstring& name)
{
    if (name.empty())
        return;

    mp_impl->mp_import_factory->append_sheet(name.get(), name.size());
}
コード例 #4
0
bool ScriptHandler::LogInfo::find(pstring what)
{
    if (what[0] == '*') what.remove(0, 1);
    what.toupper();
    replace_ascii(what, '/', '\\');
    return logged.find(what) != logged.end();
}
コード例 #5
0
ファイル: nltool.c プロジェクト: ef1105/mameplus
const char *filetobuf(pstring fname)
{
	static pstring pbuf = "";

	if (fname == "-")
	{
		char lbuf[1024];
		while (!feof(stdin))
		{
			fgets(lbuf, 1024, stdin);
			pbuf += lbuf;
		}
		printf("%d\n",*(pbuf.right(1).cstr()+1));
		return pbuf.cstr();
	}
	else
	{
		FILE *f;
		f = fopen(fname, "rb");
		fseek(f, 0, SEEK_END);
		long fsize = ftell(f);
		fseek(f, 0, SEEK_SET);

		char *buf = (char *) malloc(fsize + 1);
		fread(buf, fsize, 1, f);
		buf[fsize] = 0;
		fclose(f);
		return buf;
	}
}
コード例 #6
0
ファイル: pdynlib.cpp プロジェクト: chrisisonwildcode/mame
pdynlib::pdynlib(const pstring libname)
: m_isLoaded(false), m_lib(nullptr)
{
#ifdef _WIN32
	//fprintf(stderr, "win: loading <%s>\n", libname.cstr());
	if (libname != "")
		m_lib = LoadLibrary(libname.cstr());
	else
		m_lib = GetModuleHandle(nullptr);
	if (m_lib != nullptr)
		m_isLoaded = true;
	//else
	//	fprintf(stderr, "win: library <%s> not found!\n", libname.cstr());
#else
	//printf("loading <%s>\n", libname.cstr());
	if (libname != "")
		m_lib = dlopen(libname.cstr(), RTLD_LAZY);
	else
		m_lib = dlopen(nullptr, RTLD_LAZY);
	if (m_lib != nullptr)
		m_isLoaded = true;
	//else
	//	printf("library <%s> not found!\n", libname.cstr());
#endif
	}
コード例 #7
0
ファイル: xls_xml_context.cpp プロジェクト: jvsg/orcus
void xls_xml_context::characters(const pstring& str, bool transient)
{
    if (str.empty())
        return;

    const xml_token_pair_t& elem = get_current_element();

    if (elem.first == NS_xls_xml_ss && elem.second == XML_Data)
    {
        switch (m_cur_cell_type)
        {
            case ct_string:
            {
                if (transient)
                    m_cur_cell_string.push_back(m_pool.intern(str).first);
                else
                    m_cur_cell_string.push_back(str);
            }
            break;
            case ct_number:
            {
                const char* p = str.get();
                m_cur_cell_value = to_double(p, p + str.size());
            }
            break;
            default:
                ;
        }
    }
}
コード例 #8
0
ファイル: nl_base.c プロジェクト: vorlenko/mame
ATTR_COLD nl_double netlist_param_model_t::model_value(const pstring &entity, const nl_double defval) const
{
	pstring tmp = this->Value();
	// .model 1N914 D(Is=2.52n Rs=.568 N=1.752 Cjo=4p M=.4 tt=20n Iave=200m Vpk=75 mfg=OnSemi type=silicon)
	int p = tmp.ucase().find(entity.ucase() + "=");
	if (p>=0)
	{
		int pblank = tmp.find(" ", p);
		if (pblank < 0) pblank = tmp.len() + 1;
		tmp = tmp.substr(p, pblank - p);
		int pequal = tmp.find("=", 0);
		if (pequal < 0)
			netlist().error("parameter %s misformat in model %s temp %s\n", entity.cstr(), Value().cstr(), tmp.cstr());
		tmp = tmp.substr(pequal+1);
		nl_double factor = NL_FCONST(1.0);
		switch (*(tmp.right(1).cstr()))
		{
			case 'm': factor = 1e-3; break;
			case 'u': factor = 1e-6; break;
			case 'n': factor = 1e-9; break;
			case 'p': factor = 1e-12; break;
			case 'f': factor = 1e-15; break;
			case 'a': factor = 1e-18; break;

		}
		if (factor != NL_FCONST(1.0))
			tmp = tmp.left(tmp.len() - 1);
		return (nl_double) atof(tmp.cstr()) * factor;
	}
	else
	{
		netlist().log("Entity %s not found in model %s\n", entity.cstr(), tmp.cstr());
		return defval;
	}
}
コード例 #9
0
ファイル: pstring.cpp プロジェクト: antonioginer/mame
void pstringbuffer::pcat(const pstring &s)
{
	const std::size_t slen = s.blen();
	const std::size_t nl = m_len + slen + 1;
	resize(nl);
	std::copy(s.c_str(), s.c_str() + slen, m_ptr + m_len);
	m_len += slen;
	m_ptr[m_len] = 0;
}
コード例 #10
0
ファイル: nlwav.c プロジェクト: matthewbauer/mame
	wav_t(const pstring &fn, unsigned sr)
	{
		m_f = std::fopen(fn.cstr(),"w");
		if (m_f==NULL)
			throw netlist::fatalerror_e("Error opening output file: %s", fn.cstr());
		initialize(sr);
		std::fwrite(&m_fh, sizeof(m_fh), 1, m_f);
		std::fwrite(&m_fmt, sizeof(m_fmt), 1, m_f);
		std::fwrite(&m_data, sizeof(m_data), 1, m_f);
	}
コード例 #11
0
void ScriptHandler::LogInfo::add(pstring what)
{
    if (what[0] == '*') what.remove(0, 1);
    what.toupper();
    replace_ascii(what, '/', '\\');    
    if (logged.find(what) == logged.end()) {
	logged.insert(what);
	ordered.push_back(&(*logged.find(what)));
    }
}
コード例 #12
0
ファイル: nl_convert.cpp プロジェクト: MASHinfo/mame
double nl_convert_base_t::get_sp_val(const pstring &sin)
{
	std::size_t p = 0;
	while (p < sin.length() && (m_numberchars.find(sin.substr(p, 1)) != pstring::npos))
		++p;
	pstring val = sin.left(p);
	pstring unit = sin.substr(p);
	double ret = get_sp_unit(unit) * val.as_double();
	return ret;
}
コード例 #13
0
ファイル: nl_convert.cpp プロジェクト: fesh0r/mame-full
double nl_convert_base_t::get_sp_val(const pstring &sin)
{
	std::size_t p = 0;
	while (p < sin.length() && (m_numberchars.find(sin.substr(p, 1)) != pstring::npos))
		++p;
	pstring val = plib::left(sin, p);
	pstring unit = sin.substr(p);
	double ret = get_sp_unit(unit) * plib::pstonum<double, true>(val);
	return ret;
}
コード例 #14
0
ファイル: nltool.c プロジェクト: matthewbauer/mame
	input_t(netlist::netlist_t *netlist, const pstring &line)
	{
		char buf[400];
		double t;
		int e = sscanf(line.cstr(), "%lf,%[^,],%lf", &t, buf, &m_value);
		if ( e!= 3)
			throw netlist::fatalerror_e("error %d scanning line %s\n", e, line.cstr());
		m_time = netlist::netlist_time::from_double(t);
		m_param = netlist->setup().find_param(buf, true);
	}
コード例 #15
0
ファイル: nl_convert.cpp プロジェクト: NULUSIOS/mame
double nl_convert_base_t::get_sp_val(const pstring &sin)
{
	int p = sin.len() - 1;
	while (p>=0 && (sin.substr(p,1) < "0" || sin.substr(p,1) > "9"))
		p--;
	pstring val = sin.substr(0,p + 1);
	pstring unit = sin.substr(p + 1);

	double ret = get_sp_unit(unit) * val.as_double();
	return ret;
}
コード例 #16
0
ScriptHandler::LabelInfo::iterator ScriptHandler::findLabel(pstring label)
{
    if (label[0] == '*') label.remove(0, 1);
    label.tolower();

    LabelInfo::dic::iterator e = label_names.find(label);
    if (e != label_names.end())
	return e->second;

    errorAndExit("Label \"" + label + "\" is not found.");
    return label_info.end(); // dummy
}
コード例 #17
0
ファイル: pfunction.cpp プロジェクト: MASHinfo/mame
static int get_prio(pstring v)
{
	if (v == "(" || v == ")")
		return 1;
	else if (v.left(1) >= "a" && v.left(1) <= "z")
		return 0;
	else if (v == "*" || v == "/")
		return 20;
	else if (v == "+" || v == "-")
		return 10;
	else if (v == "^")
		return 30;
	else
		return -1;
}
コード例 #18
0
 xml_token_t tokenize(const pstring& name) const
 {
     xml_token_t token = XML_UNKNOWN_TOKEN;
     if (!name.empty())
         token = m_tokens.get_token(name);
     return token;
 }
コード例 #19
0
ファイル: pstream.cpp プロジェクト: Robbbert/store1
pofilestream::pofilestream(const pstring &fname)
: postream(0), m_file(fopen(fname.c_str(), "wb")), m_pos(0), m_actually_close(true), m_filename(fname)
{
	if (m_file == nullptr)
		throw file_open_e(m_filename);
	init();
}
コード例 #20
0
ファイル: nltool.cpp プロジェクト: Tauwasser/mame
void netlist_tool_t::vlog(const plib::plog_level &l, const pstring &ls) const
{
	pstring err = plib::pfmt("{}: {}\n")(l.name())(ls.c_str());
	// FIXME: ...
	m_app.pout("{}", err);
	if (l == plib::plog_level::FATAL)
		throw netlist::nl_exception(err);
}
コード例 #21
0
ファイル: nltool.cpp プロジェクト: gvsurenderreddy/mame
	input_t(netlist::netlist_t *netlist, const pstring &line)
	{
		char buf[400];
		double t;
		int e = sscanf(line.cstr(), "%lf,%[^,],%lf", &t, buf, &m_value);
		if ( e!= 3)
			throw netlist::fatalerror_e(plib::pfmt("error {1} scanning line {2}\n")(e)(line));
		m_time = netlist::netlist_time(t);
		m_param = netlist->setup().find_param(buf, true);
	}
コード例 #22
0
ファイル: nltool.cpp プロジェクト: Tauwasser/mame
	input_t(const netlist::setup_t &setup, const pstring &line)
	{
		char buf[400];
		double t;
		int e = sscanf(line.c_str(), "%lf,%[^,],%lf", &t, buf, &m_value);
		if (e != 3)
			throw netlist::nl_exception(plib::pfmt("error {1} scanning line {2}\n")(e)(line));
		m_time = netlist::netlist_time::from_double(t);
		m_param = setup.find_param(pstring(buf, pstring::UTF8), true);
	}
コード例 #23
0
ファイル: pparser.cpp プロジェクト: PugsyMAME/mame
pstring ppreprocessor::process_comments(pstring line)
{
	bool in_string = false;

	std::size_t e = line.size();
	pstring ret = "";
	for (std::size_t i=0; i < e; )
	{
		pstring c = plib::left(line, 1);
		line = line.substr(1);
		if (!m_comment)
		{
			if (c=="\"")
			{
				in_string = !in_string;
				ret += c;
			}
			else if (in_string && c=="\\")
			{
				i++;
				ret += (c + plib::left(line, 1));
				line = line.substr(1);
			}
			else if (!in_string && c=="/" && plib::left(line,1) == "*")
				m_comment = true;
			else if (!in_string && c=="/" && plib::left(line,1) == "/")
				break;
			else
				ret += c;
		}
		else
			if (c=="*" && plib::left(line,1) == "/")
			{
				i++;
				line = line.substr(1);
				m_comment = false;
			}
		i++;
	}
	return ret;
}
コード例 #24
0
ファイル: netlist.cpp プロジェクト: fesh0r/mame-full
	void vlog(const plib::plog_level &l, const pstring &ls) const override
	{
		switch (l)
		{
		case plib::plog_level::DEBUG:
			break;
		case plib::plog_level::VERBOSE:
			break;
		case plib::plog_level::INFO:
			osd_printf_verbose("netlist INFO: %s\n", ls.c_str());
			break;
		case plib::plog_level::WARNING:
			osd_printf_warning("netlist WARNING: %s\n", ls.c_str());
			break;
		case plib::plog_level::ERROR:
			osd_printf_error("netlist ERROR: %s\n", ls.c_str());
			break;
		case plib::plog_level::FATAL:
			throw emu_fatalerror(1, "netlist FATAL: %s\n", ls.c_str());
		}
	}
コード例 #25
0
ファイル: nltool.cpp プロジェクト: fesh0r/mame-full
	input_t(const netlist::setup_t &setup, const pstring &line)
	: m_value(0.0)
	{
		std::array<char, 400> buf; // NOLINT(cppcoreguidelines-pro-type-member-init)
		double t;
		// NOLINTNEXTLINE(cppcoreguidelines-pro-type-vararg)
		int e = sscanf(line.c_str(), "%lf,%[^,],%lf", &t, buf.data(), &m_value);
		if (e != 3)
			throw netlist::nl_exception(plib::pfmt("error {1} scanning line {2}\n")(e)(line));
		m_time = netlist::netlist_time::from_double(t);
		m_param = setup.find_param(pstring(buf.data()), true);
	}
コード例 #26
0
ファイル: nl_convert.cpp プロジェクト: NULUSIOS/mame
double nl_convert_base_t::get_sp_unit(const pstring &unit)
{
	int i = 0;
	while (m_units[i].m_unit != "-")
	{
		if (m_units[i].m_unit == unit)
			return m_units[i].m_mult;
		i++;
	}
	fprintf(stderr, "Unit %s unknown\n", unit.cstr());
	return 0.0;
}
コード例 #27
0
ファイル: measurement.cpp プロジェクト: CarterWeron/liborcus
length_t to_length(const pstring& str)
{
    length_t ret;
    if (str.empty())
        return ret;

    const char* p = str.get();
    const char* p_start = p;
    const char* p_end = p_start + str.size();
    ret.value = parse_numeric(p, p_end);

    // TODO: See if this part can be optimized.
    pstring tail(p, p_end-p);
    if (tail == "in")
        ret.unit = length_unit_inch;
    else if (tail == "cm")
        ret.unit = length_unit_centimeter;
    else if (tail == "pt")
        ret.unit = length_unit_point;

    return ret;
}
コード例 #28
0
ファイル: nltool.cpp プロジェクト: Tauwasser/mame
void tool_app_t::mac_out(const pstring &s, const bool cont)
{
	static constexpr unsigned RIGHT = 72;
	if (cont)
	{
		unsigned adj = 0;
		for (const auto &x : s)
			adj += (x == '\t' ? 3 : 0);
		pout("{1}\\\n", s.rpad(" ", RIGHT-1-adj));
	}
	else
		pout("{1}\n", s);
}
コード例 #29
0
ファイル: nltool.cpp プロジェクト: fesh0r/mame-full
void netlist_tool_callbacks_t::vlog(const plib::plog_level &l, const pstring &ls) const
{
	pstring err = plib::pfmt("{}: {}\n")(l.name())(ls.c_str());
	if (l == plib::plog_level::WARNING)
		m_app.m_warnings++;
	if (l == plib::plog_level::ERROR)
		m_app.m_errors++;
	if (l == plib::plog_level::FATAL)
	{
		m_app.m_errors++;
		throw netlist::nl_exception(err);
	}
	else
		m_app.pout("{}", err);
}
コード例 #30
0
ファイル: nagent.cpp プロジェクト: jpinelo/Depthmap
void AgentProgram::save(const pstring& filename)
{
    // standard ascii:
    ofstream file(filename.c_str());

    file << "Destination selection: ";
    switch (m_sel_type) {
    case SEL_STANDARD:
        file << "Standard" << endl;
        break;
    case SEL_LENGTH:
        file << "Gibsonian Length" << endl;
        break;
    case SEL_OPTIC_FLOW:
        file << "Gibsonian Optic Flow" << endl;
        break;
    case SEL_COMPARATIVE_LENGTH:
        file << "Gibsonian Comparative Length" << endl;
        break;
    case SEL_COMPARATIVE_OPTIC_FLOW:
        file << "Gibsonian Comparative Optic Flow" << endl;
        break;
    default:
        file << "Unknown" << endl;
    }

    file << "Steps: " << m_steps << endl;
    file << "Bins: " << ((m_vbin == -1) ? 32 : m_vbin * 2 + 1) << endl;
    /*
    file << "Ahead bins: " << m_vahead * 2 + 1 << endl;
    file << "Ahead threshold: " << m_ahead_threshold << endl;
    file << "Feeler threshold: " << m_feeler_threshold << endl;
    file << "Feeler probability: " << m_feeler_probability << endl;
    */
    file << "Rule order: " << m_rule_order[0] << " "
         << m_rule_order[1] << " "
         << m_rule_order[2] << " "
         << m_rule_order[3] << endl;

    for (int i = 0; i < 4; i++) {
        file << "Rule " << i << " (Bin -" << 1 + (i * 2) << "/+" << 1 + (i * 2) << ")" << endl;
        file << "Threshold: " << m_rule_threshold[i] << endl;
        file << "Turn Probability: " << m_rule_probability[i] << endl;
    }

    file << "Fitness: " << m_fitness << endl;
}