Previous 199869 Revisions Next

r34469 Sunday 18th January, 2015 at 19:37:11 UTC by Couriersud
More netlist code reschuffle to separate setup from run. (nw)
[src/emu/machine]netlist.c
[src/emu/netlist]nl_base.c nl_config.h nl_dice_compat.h nl_factory.c nl_factory.h nl_parser.c nl_setup.c nl_setup.h
[src/mame/drivers]nl_pongd.c

trunk/src/emu/machine/netlist.c
r242980r242981
4848#include "netlist.h"
4949#include "netlist/nl_base.h"
5050#include "netlist/nl_setup.h"
51#include "netlist/nl_factory.h"
5152#include "netlist/devices/net_lib.h"
5253#include "debugger.h"
5354
r242980r242981
134135   pstring dname = "OUT_" + m_in;
135136   m_delegate.bind_relative_to(owner()->machine().root_device());
136137   NETLIB_NAME(analog_callback) *dev = downcast<NETLIB_NAME(analog_callback) *>(
137         setup.factory().new_device_by_classname("nld_analog_callback", setup));
138         setup.register_dev("nld_analog_callback", dname));
138139
139   setup.register_dev(dev, dname);
140140   dev->register_callback(m_delegate);
141141   setup.register_link(dname + ".IN", m_in);
142142}
r242980r242981
208208{
209209   NETLIB_NAME(sound_in) *snd_in = setup.netlist().get_first_device<NETLIB_NAME(sound_in)>();
210210   if (snd_in == NULL)
211   {
212      snd_in = dynamic_cast<NETLIB_NAME(sound_in) *>(setup.factory().new_device_by_classname("nld_sound_in", setup));
213      setup.register_dev(snd_in, "STREAM_INPUT");
214   }
211      snd_in = dynamic_cast<NETLIB_NAME(sound_in) *>(setup.register_dev("nld_sound_in", "STREAM_INPUT"));
215212
216213   pstring sparam = pstring::sprintf("STREAM_INPUT.CHAN%d", m_channel);
217214   setup.register_param(sparam, m_param_name);
r242980r242981
247244
248245void netlist_mame_stream_output_t::custom_netlist_additions(netlist_setup_t &setup)
249246{
250   NETLIB_NAME(sound_out) *snd_out;
247   //NETLIB_NAME(sound_out) *snd_out;
251248   pstring sname = pstring::sprintf("STREAM_OUT_%d", m_channel);
252249
253   snd_out = dynamic_cast<NETLIB_NAME(sound_out) *>(setup.factory().new_device_by_classname("nld_sound_out", setup));
254   setup.register_dev(snd_out, sname);
250   //snd_out = dynamic_cast<NETLIB_NAME(sound_out) *>(setup.register_dev("nld_sound_out", sname));
251   setup.register_dev("nld_sound_out", sname);
255252
256253   setup.register_param(sname + ".CHAN" , m_channel);
257254   setup.register_param(sname + ".MULT",  m_mult);
trunk/src/emu/netlist/nl_base.c
r242980r242981
10021002   net.set_time(netlist().time() + m_inc);
10031003}
10041004
1005// ----------------------------------------------------------------------------------------
1006// net_device_t_base_factory
1007// ----------------------------------------------------------------------------------------
1008
1009ATTR_COLD const nl_util::pstring_list net_device_t_base_factory::term_param_list()
1010{
1011   if (m_def_param.startsWith("+"))
1012      return nl_util::split(m_def_param.substr(1), ",");
1013   else
1014      return nl_util::pstring_list();
1015}
1016
1017ATTR_COLD const nl_util::pstring_list net_device_t_base_factory::def_params()
1018{
1019   if (m_def_param.startsWith("+") || m_def_param.equals("-"))
1020      return nl_util::pstring_list();
1021   else
1022      return nl_util::split(m_def_param, ",");
1023}
trunk/src/emu/netlist/nl_config.h
r242980r242981
159159#else
160160#define nl_assert(x)               do { } while (0)
161161//#define assert_always(x, msg)   do { if (!(x)) throw emu_fatalerror("Fatal error: %s (%s:%d)", msg, __FILE__, __LINE__); } while (0)
162#define nl_assert_always(x, msg)   do { } while (0)
162#define nl_assert_always(x, msg)    do { if (!(x)) throw nl_fatalerror("Fatal error: %s\nCaused by assert: %s:%d: %s", msg, __FILE__, __LINE__, #x); } while (0)
163163#endif
164164
165165//============================================================
trunk/src/emu/netlist/nl_dice_compat.h
r242980r242981
88#ifndef NL_DICE_COMPAT_H_
99#define NL_DICE_COMPAT_H_
1010
11#include "netlist/devices/net_lib.h"
12
1113/* --------------------------------------------------------------------
1214 * Compatibility macros for DICE netlists ...
1315 * -------------------------------------------------------------------- */
1416
15//#define CHIP(_n, _t) netlist.register_dev(NET_NEW(_t ## _dip), _n);
17/*
18 * define NETLIST_DEVELOPMENT in IDEs before including this header file
19 * to get compile time errors on unknown devices. This should only be
20 * a temporary support and not be used in commits.
21 */
22
23#ifdef NETLIST_DEVELOPMENT
1624#define CHIP(_n, _t) setup.register_dev( nl_alloc(nld_ ## _t ## _dip), _n);
25#else
26#define CHIP(_n, _t) setup.register_dev(NETLIB_NAME_STR(_t ## _dip), _n);
27#endif
1728
1829#define CONNECTION( ... ) CONNECTIONY( CONNECTIONX( __VA_ARGS__ ) )
1930#define CONNECTIONY(_a) _a
trunk/src/emu/netlist/nl_factory.c
r242980r242981
5050#include "nl_factory.h"
5151#include "nl_setup.h"
5252
53// ----------------------------------------------------------------------------------------
54// net_device_t_base_factory
55// ----------------------------------------------------------------------------------------
56
57ATTR_COLD const nl_util::pstring_list net_device_t_base_factory::term_param_list()
58{
59    if (m_def_param.startsWith("+"))
60        return nl_util::split(m_def_param.substr(1), ",");
61    else
62        return nl_util::pstring_list();
63}
64
65ATTR_COLD const nl_util::pstring_list net_device_t_base_factory::def_params()
66{
67    if (m_def_param.startsWith("+") || m_def_param.equals("-"))
68        return nl_util::pstring_list();
69    else
70        return nl_util::split(m_def_param, ",");
71}
72
73
5374netlist_factory_t::netlist_factory_t()
5475{
5576}
r242980r242981
6485   m_list.clear();
6586}
6687
67netlist_device_t *netlist_factory_t::new_device_by_classname(const pstring &classname, netlist_setup_t &setup) const
88netlist_device_t *netlist_factory_t::new_device_by_classname(const pstring &classname) const
6889{
6990   for (net_device_t_base_factory * const *e = m_list.first(); e != NULL; e = m_list.next(e))
7091   {
r242980r242981
7697      }
7798      p++;
7899   }
79   setup.netlist().error("Class %s not found!\n", classname.cstr());
80100   return NULL; // appease code analysis
81101}
82102
trunk/src/emu/netlist/nl_factory.h
r242980r242981
8080      m_list.add(nl_alloc(net_device_t_factory< _C >, name, classname, def_param));
8181   }
8282
83   ATTR_COLD netlist_device_t *new_device_by_classname(const pstring &classname, netlist_setup_t &setup) const;
83   ATTR_COLD netlist_device_t *new_device_by_classname(const pstring &classname) const;
8484   ATTR_COLD netlist_device_t *new_device_by_name(const pstring &name, netlist_setup_t &setup) const;
8585   ATTR_COLD net_device_t_base_factory * factory_by_name(const pstring &name, netlist_setup_t &setup) const;
8686
trunk/src/emu/netlist/nl_parser.c
r242980r242981
66 */
77
88#include "nl_parser.h"
9#include "nl_factory.h"
910
1011//#undef NL_VERBOSE_OUT
1112//#define NL_VERBOSE_OUT(x) printf x
trunk/src/emu/netlist/nl_setup.c
r242980r242981
99#include "nl_setup.h"
1010#include "nl_parser.h"
1111#include "nl_util.h"
12#include "nl_factory.h"
1213#include "devices/net_lib.h"
1314#include "devices/nld_system.h"
1415#include "analog/nld_solver.h"
r242980r242981
3738   , m_proxy_cnt(0)
3839{
3940   netlist.set_setup(this);
41   m_factory = nl_alloc(netlist_factory_t);
4042}
4143
4244void netlist_setup_t::init()
r242980r242981
5557   m_params_temp.clear();
5658
5759   netlist().set_setup(NULL);
60   nl_free(m_factory);
5861
5962   pstring::resetmem();
6063}
r242980r242981
9295   return dev;
9396}
9497
98netlist_device_t *netlist_setup_t::register_dev(const pstring &classname, const pstring &name)
99{
100    netlist_device_t *dev = factory().new_device_by_classname(classname);
101    if (dev == NULL)
102        netlist().error("Class %s not found!\n", classname.cstr());
103    return register_dev(dev, name);
104}
105
95106template <class T>
96107static void remove_start_with(T &hm, pstring &sw)
97108{
r242980r242981
695706      {
696707         NL_VERBOSE_OUT(("%d: <%s>\n",i, ll[i].cstr()));
697708         NL_VERBOSE_OUT(("%d: <%s>\n",i, ll[i].cstr()));
698         netlist_device_t *nc = factory().new_device_by_classname("nld_log", *this);
709         netlist_device_t *nc = factory().new_device_by_classname("nld_log");
699710         pstring name = "log_" + ll[i];
700711         register_dev(nc, name);
701712         register_link(name + ".I", ll[i]);
trunk/src/emu/netlist/nl_setup.h
r242980r242981
33/*
44 * nlsetup.h
55 *
6 *  Created on: 3 Nov 2013
7 *      Author: andre
86 */
97
108#ifndef NLSETUP_H_
119#define NLSETUP_H_
1210
1311#include "nl_base.h"
14#include "nl_factory.h"
12//#include "nl_factory.h"
1513
1614//============================================================
1715//  MACROS / inline netlist definitions
r242980r242981
2523#define ALIAS(_alias, _name)                                                        \
2624   setup.register_alias(# _alias, # _name);
2725
28#define NET_NEW(_type)  setup.factory().new_device_by_classname(NETLIB_NAME_STR(_type), setup)
26//#define NET_NEW(_type)  setup.factory().new_device_by_classname(NETLIB_NAME_STR(_type), setup)
2927
3028#define NET_REGISTER_DEV(_type, _name)                                              \
31      setup.register_dev(NET_NEW(_type), # _name);
29      setup.register_dev(NETLIB_NAME_STR(_type), # _name);
3230
3331#define NET_REMOVE_DEV(_name)                                                       \
3432      setup.remove_dev(# _name);
r242980r242981
6765      setup.namespace_pop();
6866
6967// ----------------------------------------------------------------------------------------
70// FIXME: Clean this up
71// ----------------------------------------------------------------------------------------
72
73//class NETLIB_NAME(analog_callback);
74
75// ----------------------------------------------------------------------------------------
7668// netlist_setup_t
7769// ----------------------------------------------------------------------------------------
7870
71// Forward definition so we keep nl_factory.h out of the public
72class netlist_factory_t;
73
7974class netlist_setup_t
8075{
8176   NETLIST_PREVENT_COPYING(netlist_setup_t)
r242980r242981
118113
119114   netlist_base_t &netlist() { return m_netlist; }
120115   const netlist_base_t &netlist() const { return m_netlist; }
121   netlist_factory_t &factory() { return m_factory; }
122   const netlist_factory_t &factory() const { return m_factory; }
123116
124117   pstring build_fqn(const pstring &obj_name) const;
125118
126119   netlist_device_t *register_dev(netlist_device_t *dev, const pstring &name);
120   netlist_device_t *register_dev(const pstring &classname, const pstring &name);
127121   void remove_dev(const pstring &name);
128122
129123   void register_model(const pstring &model);
r242980r242981
152146   void namespace_push(const pstring &aname);
153147   void namespace_pop();
154148
155   /* not ideal, but needed for save_state */
156   tagmap_terminal_t  m_terminals;
149    netlist_factory_t &factory() { return *m_factory; }
150    const netlist_factory_t &factory() const { return *m_factory; }
157151
158   void print_stats() const;
152    /* not ideal, but needed for save_state */
153    tagmap_terminal_t  m_terminals;
159154
155    void print_stats() const;
156
160157protected:
161158
162159private:
r242980r242981
168165   tagmap_link_t   m_links;
169166   tagmap_nstring_t m_params_temp;
170167
171   netlist_factory_t m_factory;
168   netlist_factory_t *m_factory;
172169
173170   plinearlist_t<pstring> m_models;
174171
trunk/src/mame/drivers/nl_pongd.c
r242980r242981
6565 *
6666 */
6767
68// identify unknown devices in IDE
6869
70//#define NETLIST_DEVELOPMENT 1
71
6972#include "netlist/nl_dice_compat.h"
7073#include "netlist/devices/net_lib.h"
7174#include "netlist/analog/nld_twoterm.h"


Previous 199869 Revisions Next


© 1997-2024 The MAME Team