Previous 199869 Revisions Next

r31375 Tuesday 22nd July, 2014 at 06:21:54 UTC by Miodrag Milanović
More cleanups, there is issue with srcclean that needs to be taken care as well, just doing now what we can
[hash]abc80.xml cc40_cart.xml hp9835a_rom.xml hp9845a_rom.xml hp9845b_rom.xml msx1_cart.xml msx2_cart.xml msx2_flop.xml neogeo.xml nes.xml sc3000_cass.xml snes.xml tandy2k.xml
[src/emu]addrmap.h digfx.h luaengine.h mame.h memory.h sound.h video.h
[src/emu/bus/a1bus]a1bus.h
[src/emu/bus/a2bus]a2bus.h a2eauxslot.h a2mcms.h
[src/emu/bus/amiga/zorro]a2052.h a2232.h a590.h action_replay.h buddha.h cards.h zorro.h
[src/emu/bus/bml3]bml3bus.h
[src/emu/bus/centronics]epson_ex800.h epson_lx800.h
[src/emu/bus/coco]cococart.h
[src/emu/bus/cpc]cpc_rs232.h cpcexp.h
[src/emu/bus/gameboy]mbc.h
[src/emu/bus/iq151]iq151.h
[src/emu/bus/isa]aga.h gus.h isa.h
[src/emu/bus/kc]kc.h
[src/emu/bus/msx_cart]ascii.h konami.h yamaha.h
[src/emu/bus/msx_slot]bunsetsu.h cartridge.h disk.h music.h ram.h ram_mm.h
[src/emu/bus/neogeo]banked_cart.h bootleg_prot.h cmc_prot.h fatfury2_prot.h kof2002_prot.h kof98_prot.h mslugx_prot.h neogeo_intf.h pcm2_prot.h pvc_prot.h sbp_prot.h sma_prot.h
[src/emu/bus/nes]mmc5.h
[src/emu/bus/nubus]nubus.h
[src/emu/bus/oricext]jasmin.h microdisc.h oricext.h
[src/emu/bus/pc_kbd]pc_kbdc.h
[src/emu/bus/pet]diag.h
[src/emu/bus/ql]cst_q_plus4.h cst_qdisc.h cumana_fdi.h exp.h kempston_di.h miracle_gold_card.h miracle_hd.h mp_fdi.h opd_basic_master.h pcml_qdisk.h qubide.h rom.h sandy_superdisk.h sandy_superqboard.h trumpcard.h
[src/emu/bus/scsi]scsihle.h
[src/emu/bus/tvc]tvc.h
[src/emu/bus/vtech/ioexp]carts.h ioexp.h joystick.h printer.h
[src/emu/bus/vtech/memexp]carts.h floppy.h memexp.h memory.h rs232.h wordpro.h
[src/emu/bus/x68k]x68kexp.h
[src/emu/bus/z88]z88.h
[src/emu/cpu]cpu.mak
[src/emu/cpu/adsp2100]adsp2100.h
[src/emu/cpu/g65816]g65816op.h
[src/emu/cpu/m68000]m68000.h m68kmmu.h
[src/emu/cpu/mb86233]mb86233.h
[src/emu/cpu/minx]minxfunc.h minxops.h
[src/emu/cpu/mips]mips3.h
[src/emu/cpu/powerpc]ppc.h
[src/emu/cpu/rsp]rsp.h
[src/emu/cpu/scudsp]scudsp.h
[src/emu/cpu/sh2]sh2.h
[src/emu/cpu/sharc]sharcops.inc
[src/emu/cpu/tms7000]tms7000.h tms70op.inc
[src/emu/cpu/upd7725]upd7725.h
[src/emu/cpu/z80]tmpz84c011.h tmpz84c015.h
[src/emu/imagedev]cartslot.h cassette.h diablo.h flopdrv.h harddriv.h midiin.h
[src/emu/machine]53c810.h 6525tpi.h 6532riot.h 68307.h 6840ptm.h 74123.h 8042kbdc.h aakart.h adc0808.h adc1038.h akiko.h am9517a.h at_keybc.h autoconfig.h ay31015.h corvushd.h cr511b.h dmac.h dp8390.h eepromser.h gayle.h hd63450.h i8255.h i8271.h i8279.h ins8250.h kb3600.h keyboard.h mb89352.h mb89363b.h mc6854.h mos6530.h ncr539x.h roc10937.h s2636.h s3c2400.h s3c2410.h s3c2440.h s3c44b0.h terminal.h tms9902.h upd71071.h wd11c00_17.h wd17xx.h wd2010.h ym2148.h z80ctc.h z80dart.h z80dma.h z80pio.h z80sti.h
[src/emu/netlist]nl_base.h nl_dice_compat.h nl_lists.h nl_setup.h nl_time.h plists.h pstate.h
[src/emu/netlist/analog]nld_bjt.h nld_fourterm.h nld_ms_direct.h nld_ms_direct1.h nld_ms_direct2.h nld_ms_gauss_seidel.h nld_opamps.h nld_solver.h nld_twoterm.h
[src/emu/netlist/devices]nld_4020.h nld_4066.h nld_74123.h nld_7474.h nld_7490.h nld_74ls629.h nld_cmos.h nld_log.h nld_r2r_dac.h nld_system.h nld_truthtable.h
[src/emu/sound]amiga.h ay8910.h discrete.h es5506.h gaelco.h namco.h nes_apu.h okim6258.h pokey.h rf5c68.h segapcm.h tms36xx.h tms5110.h vrender0.h
[src/emu/video]crtc_ega.h huc6202.h mc6845.h mc6847.h ramdac.h snes_ppu.h t6a04.h tms3556.h tms9928a.h vic4567.h vooddefs.h voodoo.h
[src/lib/lua]lapi.h lauxlib.h lcode.h lctype.h ldebug.h ldo.h lfunc.h lgc.h llex.h llimits.h lmem.h lobject.h lopcodes.h lparser.h lstate.h lstring.h ltable.h ltm.h lua.h luaconf.h lualib.h lundump.h lvm.h lzio.h
[src/lib/lua/bridge]LuaBridge.h
[src/lib/lua/bridge/detail]CFunctions.h ClassInfo.h Constructor.h FuncTraits.h Iterator.h LuaException.h LuaHelpers.h LuaRef.h Namespace.h Stack.h TypeList.h TypeTraits.h Userdata.h dump.h
[src/lib/sqlite3]shell.c sqlite3.h sqlite3ext.h
[src/lib/util]cdrom.h
[src/lib/web]mongoose.h
[src/mame]mame.lst mame.mak
[src/mame/audio]cage.h cps3.h dcs.h taitosnd.h
[src/mame/drivers]bfm_sc45_helper.h
[src/mame/includes]amiga.h armedf.h atari.h atarigt.h bfm_sc45.h boogwing.h chqflag.h darkseal.h deco32.h esd16.h gaelco3d.h gstriker.h harddriv.h kaneko16.h konamigx.h megadriv.h midtunit.h midzeus.h model3.h mystwarr.h neogeo.h niyanpai.h plygonet.h rpunch.h spbactn.h taito_z.h toaplan2.h unico.h wc90.h wpc_pin.h
[src/mame/layout]fireball.lay kenseim.lay
[src/mame/machine]c117.h konppc.h midwayic.h ng_memcard.h nmk112.h wpc_out.h
[src/mame/video]deco16ic.h deco_zoomspr.h excellent_spr.h k001005.h k001604.h k051316.h k051960.h k052109.h k053244_k053245.h k053246_k053247_k055673.h k053936.h k054156_k054157_k056832.h kan_pand.h mb60553.h neogeo_spr.h pc080sn.h pc090oj.h tc0080vco.h tc0100scn.h tc0480scp.h tecmo_mix.h tecmo_spr.h vs920a.h
[src/mess]mess.lst
[src/mess/includes]apollo.h apple2.h bebox.h coco.h cybiko.h dgnalpha.h hec2hrp.h hp48.h msx.h newbrain.h p2000t.h ql.h thomson.h x68k.h
[src/mess/layout]fb01.lay
[src/mess/machine]ie15_kbd.h mega32x.h micropolis.h msx_matsushita.h msx_s1985.h msx_systemflags.h smartmed.h
[src/mess/machine/ti99]videowrp.h
[src/mess/video]crt.h gime.h vtvideo.h
[src/osd]osdcomm.h osdepend.h
[src/osd/modules/debugger]debugint.h debugosx.h debugqt.h debugwin.h none.h
[src/osd/modules/sound]direct_sound.h js_sound.h none.h sdl_sound.h
[src/osd/sdl]osdsdl.h window.h
[src/osd/windows]winmain.h

trunk/hash/abc80.xml
r31374r31375
6363      <description>Kundregister</description>
6464      <year>19??</year>
6565      <publisher>&lt;unknown&gt;</publisher>
66     
66
6767      <part name="flop1" interface="floppy_5_25">
6868         <dataarea name="flop" size="79143">
6969            <rom name="fd2_bifak.imd" size="79143" crc="a741ad5d" sha1="a0cb8cc31a30fcbea258dd5249845819930e60c2" offset="0" />
trunk/hash/msx2_cart.xml
r31374r31375
836836        <info name="alt_title" value="ミケランジェロⅡ" />
837837        <part name="cart" interface="msx_cart">
838838            <feature name="pcb" value="1M-8KB" />
839         <feature name="slot" value="ascii8" />
839            <feature name="slot" value="ascii8" />
840840            <feature name="mapper" value="NEOS MR6401" />
841841            <dataarea name="rom" size="131072">
842842                <rom name="rp231024d" size="131072" crc="" sha1="" offset="0" />
r31374r31375
31673167      </part>
31683168   </software>
31693169
3170   <!-- This is the sound cartridge that came with the game SD Snatcher. This should eventually be
3170   <!-- This is the sound cartridge that came with the game SD Snatcher. This should eventually be
31713171        combined in one software description including the Sound cartridge and the floppies.
31723172        This sound cartridge can _not_ be used with the MSX Game Collections from Konami.
31733173   -->
r31374r31375
31773177      <publisher>Konami</publisher>
31783178      <part name="cart" interface="msx_cart">
31793179         <feature name="slot" value="sound_sdsnatch" />
3180         <dataarea name="ram" size="65536">     
3180         <dataarea name="ram" size="65536">
31813181         </dataarea>
31823182      </part>
31833183   </software>
trunk/hash/sc3000_cass.xml
r31374r31375
1313         </dataarea>
1414      </part>
1515   </software>
16     
16
1717</softwarelist>
trunk/hash/hp9845a_rom.xml
r31374r31375
22<!DOCTYPE softwarelist SYSTEM "softwarelist.dtd">
33
44<softwarelist name="hp9845a_rom" description="HP 9845A/S Option ROMs">
5   
5
66   <software name="mass">
77      <description>Mass Storage</description>
88      <year>198?</year>
r31374r31375
1515         </dataarea>
1616      </part>
1717   </software>
18   
18
1919   <software name="iolpu">
2020      <description>I/O LPU</description>
2121      <year>198?</year>
r31374r31375
2828         </dataarea>
2929      </part>
3030   </software>
31   
31
3232   <software name="ioppu">
3333      <description>I/O PPU</description>
3434      <year>198?</year>
r31374r31375
4141         </dataarea>
4242      </part>
4343   </software>
44   
44
4545   <software name="graphics">
4646      <description>Graphics</description>
4747      <year>198?</year>
r31374r31375
5454         </dataarea>
5555      </part>
5656   </software>
57   
57
5858   <software name="pdr45">
5959      <description>PDR-45</description>
6060      <year>198?</year>
r31374r31375
6868         </dataarea>
6969      </part>
7070   </software>
71   
71
7272   <software name="progtkit">
7373      <description>Programmer's Toolkit</description>
7474      <year>198?</year>
r31374r31375
8282         </dataarea>
8383      </part>
8484   </software>
85   
85
8686   <software name="cfmms">
8787      <description>HP 9845B Command File/Memory Mass Storage ROM (Rev A)</description>
8888      <year>198?</year>
r31374r31375
9595         </dataarea>
9696      </part>
9797   </software>
98   
98
9999   <software name="cfmmsb" cloneof="cfmms">
100100      <description>HP 9845B Command File/Memory Mass Storage ROM (Rev B)</description>
101101      <year>198?</year>
trunk/hash/msx1_cart.xml
r31374r31375
10381038        <info name="alt_title" value="スーパーレイドック(THE LINKS NETWORK VERSION)" />
10391039        <part name="cart" interface="msx_cart">
10401040            <feature name="pcb" value="TA6228" />
1041         <feature name="slot" value="ascii8" />
1041            <feature name="slot" value="ascii8" />
10421042            <feature name="mapper" value="M60002-0125SP" />
10431043            <dataarea name="rom" size="262144">
10441044                <rom name="lh532045" size="262144" crc="" sha1="" offset="0" />
r31374r31375
10711071        <info name="alt_title" value="シンセサウルス" />
10721072        <part name="cart" interface="msx_cart">
10731073            <feature name="pcb" value="TAS-1M-008S" />
1074         <feature name="slot" value="ascii8" />
1074            <feature name="slot" value="ascii8" />
10751075            <feature name="mapper" value="LZ93A13" />
10761076            <dataarea name="rom" size="131072">
10771077                <rom name="m5m27512p" size="131072" crc="" sha1="" offset="0" />
r31374r31375
10881088        <info name="alt_title" value="シンセサウルス" />
10891089        <part name="cart" interface="msx_cart">
10901090            <feature name="pcb" value="TAS-2M008-E2M" />
1091         <feature name="slot" value="ascii8" />
1091            <feature name="slot" value="ascii8" />
10921092            <feature name="mapper" value="LZ93A13" />
10931093            <dataarea name="rom" size="262144">
10941094                <rom name="m5m27512p" size="131072" crc="" sha1="" offset="0" />
r31374r31375
1456814568<!--
1456914569This memory is currently declared as a memory region inside the nms1205 implementation otherwise the
1457014570legacy FM implementations cannot find it.
14571         <dataarea name="ram" size="32768">
14572         </dataarea>
14571            <dataarea name="ram" size="32768">
14572            </dataarea>
1457314573-->
1457414574      </part>
1457514575   </software>
1457614576
1457714577<!--
14578   <software name="nms1205v10" cloneof="nms1205" supported="no">
14579   <description>Philips NMS-1205 Music Module v1.0</description>
14580      <year>198?</year>
14581      <publisher>Philips</publisher>
14582      <part name="cart" interface="msx_cart">
14583         <feature name="slot" value="msxaud_nms1205" />
14584         <dataarea name="rom" size="32768">
14585            <!- - SUM16: 53BF - ->
14586            <rom name="nms1205_53bf.bin" size="32768" crc="6e68bd44" sha1="146d9738b6d534277dab9b41a07556ffec9065b9" status="baddump" offset="0" />
14587         </dataarea>
14578    <software name="nms1205v10" cloneof="nms1205" supported="no">
14579    <description>Philips NMS-1205 Music Module v1.0</description>
14580        <year>198?</year>
14581        <publisher>Philips</publisher>
14582        <part name="cart" interface="msx_cart">
14583            <feature name="slot" value="msxaud_nms1205" />
14584            <dataarea name="rom" size="32768">
14585                <!- - SUM16: 53BF - ->
14586                <rom name="nms1205_53bf.bin" size="32768" crc="6e68bd44" sha1="146d9738b6d534277dab9b41a07556ffec9065b9" status="baddump" offset="0" />
14587            </dataarea>
1458814588<!- -
1458914589This memory is currently declared as a memory region inside the nms1205 implementation otherwise the
1459014590legacy FM implementations cannot find it.
14591         <dataarea name="ram" size="32768">
14592         </dataarea>
14591            <dataarea name="ram" size="32768">
14592            </dataarea>
1459314593- ->
14594      </part>
14595   </software>
14594        </part>
14595    </software>
1459614596-->
1459714597
1459814598<!-- Dictionary ROMs? -->
trunk/hash/msx2_flop.xml
r31374r31375
297297   </software>
298298
299299<!--
300   <software name="">
301      <description></description>
302      <year></year>
303      <publisher></publisher>
304      <part name="flop1" interface="floppy_3_5">
305         <dataarea name="flop" size="737280">
306            <rom name="" size="737280" crc="" sha1="" offset="0" />
307         </dataarea>
308      </part>
309   </software>
300    <software name="">
301        <description></description>
302        <year></year>
303        <publisher></publisher>
304        <part name="flop1" interface="floppy_3_5">
305            <dataarea name="flop" size="737280">
306                <rom name="" size="737280" crc="" sha1="" offset="0" />
307            </dataarea>
308        </part>
309    </software>
310310-->
311311
312312   <software name="arc">
trunk/hash/snes.xml
r31374r31375
32623262   </software>
32633263
32643264   <software name="contra3p" cloneof="sprobot">
3265      <!-- Notes: this rom image was released in 2014 without any documentation, despite its name, it is a prototype of Contra III
3265      <!-- Notes: this rom image was released in 2014 without any documentation, despite its name, it is a prototype of Contra III
32663266                  the rom was overdumped to 4MiB likely due to header based dumping tools, the right size "should be" 1MiB -->
32673267      <description>Contra IV - The Alien Wars (USA, Prototype)</description>
32683268      <year>1992</year>
trunk/hash/neogeo.xml
r31374r31375
2121
2222<softwarelist name="neogeo" description="SNK Neo-Geo cartridges">
2323
24  <!--***************************************
25   ID-0001
26   . NGM-001
27   NEO-MVS PROG-NAM / NEO-MVS CHA-32
28   . NGH-001
29   NEO-AEG PROG-NAM / NEO-AEG CHA-32
30  ***************************************-->
24   <!--***************************************
25   ID-0001
26   . NGM-001
27   NEO-MVS PROG-NAM / NEO-MVS CHA-32
28   . NGH-001
29   NEO-AEG PROG-NAM / NEO-AEG CHA-32
30   ***************************************-->
3131
3232   <software name="nam1975">
3333      <!-- MVS AND AES VERSION -->
r31374r31375
8080      </part>
8181   </software>
8282
83  <!--***************************************
84 ID-0002
85 . NGM-002
86 NEO-MVS PROG-EP / NEO-MVS CHA-32
87 . NGH-002
88 NEO-AEG PROG-4A / NEO-AEG CHA-32
83   <!--***************************************
84   ID-0002
85   . NGM-002
86   NEO-MVS PROG-EP / NEO-MVS CHA-32
87   . NGH-002
88   NEO-AEG PROG-4A / NEO-AEG CHA-32
8989***************************************-->
9090
9191
r31374r31375
191191      </part>
192192   </software>
193193
194  <!--***************************************
195 ID-0003
196 . NGM-003
197 NEO-MVS PROG-EP / NEO-MVS CHA-32
198 . NGH-003
199 NEO-AEG PROG-4B / NEO-AEG CHA-32
194   <!--***************************************
195   ID-0003
196   . NGM-003
197   NEO-MVS PROG-EP / NEO-MVS CHA-32
198   . NGH-003
199   NEO-AEG PROG-4B / NEO-AEG CHA-32
200200***************************************-->
201201
202202   <software name="tpgolf">
r31374r31375
258258      </part>
259259   </software>
260260
261  <!--***************************************
262 ID-0004
263 . NGM-004
264 NEO-MVS PROG-EP / NEO-MVS CHA-32
265 . NGH-004
266 NEO-AEG PROG B  / NEO-AEG CHA-32
261   <!--***************************************
262   ID-0004
263   . NGM-004
264   NEO-MVS PROG-EP / NEO-MVS CHA-32
265   . NGH-004
266   NEO-AEG PROG B  / NEO-AEG CHA-32
267267***************************************-->
268268
269269   <software name="mahretsu">
r31374r31375
313313      </part>
314314   </software>
315315
316  <!--***************************************
317 ID-0005
318 . NGM-005
319 NEO-MVS PROG-EP / NEO-MVS CHA-32
320 . NGH-005
321 NEO-AEG PROG-4B / NEO-AEG CHA-32
316   <!--***************************************
317   ID-0005
318   . NGM-005
319   NEO-MVS PROG-EP / NEO-MVS CHA-32
320   . NGH-005
321   NEO-AEG PROG-4B / NEO-AEG CHA-32
322322***************************************-->
323323
324324   <software name="maglord">
r31374r31375
415415      </part>
416416   </software>
417417
418  <!--***************************************
419 ID-0006
420 . NGM-006
421 NEO-MVS PROG-HERO / NEO-MVS CHA-32
422 . NGH-006
423 NEO-AEG PROG-HERO / NEO-AEG CHA-32
418   <!--***************************************
419   ID-0006
420   . NGM-006
421   NEO-MVS PROG-HERO / NEO-MVS CHA-32
422   . NGH-006
423   NEO-AEG PROG-HERO / NEO-AEG CHA-32
424424***************************************-->
425425
426426   <software name="ridhero">
r31374r31375
528528      </part>
529529   </software>
530530
531  <!--***************************************
532 ID-0007
533 . NGM-007
534 NEO-MVS PROG42G / NEO-MVS CHA42G
535 . NGH-007
536 NEO-AEG PROG42G / NEO-AEG CHA42G
531   <!--***************************************
532   ID-0007
533   . NGM-007
534   NEO-MVS PROG42G / NEO-MVS CHA42G
535   . NGH-007
536   NEO-AEG PROG42G / NEO-AEG CHA42G
537537***************************************-->
538538
539539   <software name="alpham2">
r31374r31375
616616      </part>
617617   </software>
618618
619  <!--***************************************
620 ID-0008
621 Sunshine (prototype) 1990 SNK
619   <!--***************************************
620   ID-0008
621   Sunshine (prototype) 1990 SNK
622622***************************************-->
623623
624  <!--***************************************
625 ID-0009
626 . NGM-009
627 NEO-MVS PROG-EP / NEO-MVS CHA-32
628 . NGH-009
629 NEO-AEG PROG-4A / NEO-AEG CHA-32
624   <!--***************************************
625   ID-0009
626   . NGM-009
627   NEO-MVS PROG-EP / NEO-MVS CHA-32
628   . NGH-009
629   NEO-AEG PROG-4A / NEO-AEG CHA-32
630630***************************************-->
631631
632632   <software name="ncombat">
r31374r31375
727727      </part>
728728   </software>
729729
730  <!--***************************************
731 ID-0010
732 . NGM-010
733 NEO-MVS PROG-EP / NEO-MVS CHA-32
734 . NGH-010
730   <!--***************************************
731   ID-0010
732   . NGM-010
733   NEO-MVS PROG-EP / NEO-MVS CHA-32
734   . NGH-010
735735***************************************-->
736736
737737   <software name="cyberlip">
r31374r31375
785785      </part>
786786   </software>
787787
788  <!--***************************************
789 ID-0011
790 . NGM-011
791 NEO-MVS PROG-8MB / NEO-MVS CHA-8M
792 . NGH-011
793 NEO-AEG PROG-8MB / NEO-AEG CHA-8M
788   <!--***************************************
789   ID-0011
790   . NGM-011
791   NEO-MVS PROG-8MB / NEO-MVS CHA-8M
792   . NGH-011
793   NEO-AEG PROG-8MB / NEO-AEG CHA-8M
794794***************************************-->
795795
796796   <software name="superspy">
r31374r31375
838838      </part>
839839   </software>
840840
841  <!--***************************************
842 ID-0012
843 unknown
841   <!--***************************************
842   ID-0012
843   unknown
844844***************************************-->
845845
846  <!--***************************************
847 ID-0013
848 unknown
846   <!--***************************************
847   ID-0013
848   unknown
849849***************************************-->
850850
851  <!--***************************************
852 ID-0014
853 . NGM-014
854 NEO-MVS PROG42G-1 / NEO-MVS CHA42G-1
855 . NGH-014
856 NEO-AEG PROG42G-1 / NEO-AEG CHA42G-1
851   <!--***************************************
852   ID-0014
853   . NGM-014
854   NEO-MVS PROG42G-1 / NEO-MVS CHA42G-1
855   . NGH-014
856   NEO-AEG PROG42G-1 / NEO-AEG CHA42G-1
857857***************************************-->
858858
859859   <software name="mutnat">
r31374r31375
895895      </part>
896896   </software>
897897
898  <!--***************************************
899 ID-0015
900 unknown
898   <!--***************************************
899   ID-0015
900   unknown
901901***************************************-->
902902
903  <!--***************************************
904 ID-0016
905 . NGM-016
906 NEO-MVS PROG42G   / NEO-MVS CHA42G
907 NEO-MVS PROG42G-1 / NEO-MVS CHA42G-1
908 . NGH-016
909 NEO-AEG PROG42G / NEO-AEG CHA42G
903   <!--***************************************
904   ID-0016
905   . NGM-016
906   NEO-MVS PROG42G   / NEO-MVS CHA42G
907   NEO-MVS PROG42G-1 / NEO-MVS CHA42G-1
908   . NGH-016
909   NEO-AEG PROG42G / NEO-AEG CHA42G
910910***************************************-->
911911
912912   <software name="kotm">
r31374r31375
991991      </part>
992992   </software>
993993
994  <!--***************************************
995 ID-0017
996 . NGM-017
997 NEO-MVS PROG42G / NEO-MVS CHA42G
998 . NGH-017
999 NEO-AEG PROG42G / NEO-AEG CHA42G
994   <!--***************************************
995   ID-0017
996   . NGM-017
997   NEO-MVS PROG42G / NEO-MVS CHA42G
998   . NGH-017
999   NEO-AEG PROG42G / NEO-AEG CHA42G
10001000***************************************-->
10011001
10021002   <software name="sengoku">
r31374r31375
10811081      </part>
10821082   </software>
10831083
1084  <!--***************************************
1085 ID-0018
1086 . NGM-018
1087 NEO-MVS PROG42G-1 / NEO-MVS CHA42G-1
1088 also found on (seen several times; CHA and PROG board are 'manually patched up' with wires and resistors)
1089 NEO-MVS PROG42G / NEO-MVS CHA42G
1090 . NGH-018
1091 NEO-AEG PROG42G / NEO-AEG CHA42G
1084   <!--***************************************
1085   ID-0018
1086   . NGM-018
1087   NEO-MVS PROG42G-1 / NEO-MVS CHA42G-1
1088   also found on (seen several times; CHA and PROG board are 'manually patched up' with wires and resistors)
1089   NEO-MVS PROG42G / NEO-MVS CHA42G
1090   . NGH-018
1091   NEO-AEG PROG42G / NEO-AEG CHA42G
10921092***************************************-->
10931093
10941094   <software name="burningf">
r31374r31375
12081208      </part>
12091209   </software>
12101210
1211  <!--***************************************
1212 ID-0019
1213 . NGM-019
1214 NEO-MVS PROG-HERO / NEO-MVS CHA-32
1215 . NGH-019
1216 NEO-AEG PROG-HERO / NEO-AEG CHA-32
1211   <!--***************************************
1212   ID-0019
1213   . NGM-019
1214   NEO-MVS PROG-HERO / NEO-MVS CHA-32
1215   . NGH-019
1216   NEO-AEG PROG-HERO / NEO-AEG CHA-32
12171217***************************************-->
12181218
12191219   <software name="lbowling">
r31374r31375
12591259      </part>
12601260   </software>
12611261
1262  <!--***************************************
1263 ID-0020
1264 . NGM-020
1265 NEO-MVS PROG8M42 / NEO-MVS CHA-8M
1266 . NGH-020
1267 NEO-AEG PROG8M42 / NEO-AEG CHA-8M
1262   <!--***************************************
1263   ID-0020
1264   . NGM-020
1265   NEO-MVS PROG8M42 / NEO-MVS CHA-8M
1266   . NGH-020
1267   NEO-AEG PROG8M42 / NEO-AEG CHA-8M
12681268***************************************-->
12691269
12701270   <software name="gpilots">
r31374r31375
13571357      </part>
13581358   </software>
13591359
1360  <!--***************************************
1361 ID-0021
1362 . NGM-021
1363 NEO-MVS PROG-EP / NEO-MVS CHA-32
1364 . NGH-021
1365 NEO-AEG PROG B  / NEO-AEG CHA-32
1360   <!--***************************************
1361   ID-0021
1362   . NGM-021
1363   NEO-MVS PROG-EP / NEO-MVS CHA-32
1364   . NGH-021
1365   NEO-AEG PROG B  / NEO-AEG CHA-32
13661366***************************************-->
13671367
13681368   <software name="joyjoy">
r31374r31375
14021402      </part>
14031403   </software>
14041404
1405  <!--***************************************
1406 ID-0022
1407 . ALM-001
1408 NEO-MVS PROG8M42  / NEO-MVS CHA-8M
1409 . ALH-001
1410 NEO-AEG PROG 8M42 / NEO-AEG CHA-8M
1405   <!--***************************************
1406   ID-0022
1407   . ALM-001
1408   NEO-MVS PROG8M42  / NEO-MVS CHA-8M
1409   . ALH-001
1410   NEO-AEG PROG 8M42 / NEO-AEG CHA-8M
14111411***************************************-->
14121412
14131413   <software name="bjourney">
r31374r31375
14491449      </part>
14501450   </software>
14511451
1452  <!--***************************************
1453 ID-0023
1454 . NGM-023
1455 NEO-MVS PROG42G / NEO-MVS CHA42G
1456 . NGH-023
1457 NEO-AEG PROG42G-1 / NEO-AEG CHA42G-1
1452   <!--***************************************
1453   ID-0023
1454   . NGM-023
1455   NEO-MVS PROG42G / NEO-MVS CHA42G
1456   . NGH-023
1457   NEO-AEG PROG42G-1 / NEO-AEG CHA42G-1
14581458***************************************-->
14591459
14601460   <software name="quizdais">
r31374r31375
15181518      </part>
15191519   </software>
15201520
1521  <!--***************************************
1522 ID-0024
1523 . NGM-024
1524 NEO-MVS PROG42G-1 / NEO-MVS CHA42G-1
1525 . NGH-024
1521   <!--***************************************
1522   ID-0024
1523   . NGM-024
1524   NEO-MVS PROG42G-1 / NEO-MVS CHA42G-1
1525   . NGH-024
15261526***************************************-->
15271527
15281528   <software name="lresort">
r31374r31375
15631563      </part>
15641564   </software>
15651565
1566  <!--***************************************
1567 ID-0025
1568 . NGM-025
1569 NEO-MVS PROG42G-1 / NEO-MVS CHA42G-1
1570 . NGH-025
1571 NEO-AEG PROG42G / NEO-AEG CHA42G
1566   <!--***************************************
1567   ID-0025
1568   . NGM-025
1569   NEO-MVS PROG42G-1 / NEO-MVS CHA42G-1
1570   . NGH-025
1571   NEO-AEG PROG42G / NEO-AEG CHA42G
15721572***************************************-->
15731573
15741574   <software name="eightman">
r31374r31375
16101610      </part>
16111611   </software>
16121612
1613  <!--***************************************
1614 ID-0026
1615 Fun Fun Brothers (prototype) 1991 Alpha
1613   <!--***************************************
1614   ID-0026
1615   Fun Fun Brothers (prototype) 1991 Alpha
16161616***************************************-->
16171617
1618  <!--***************************************
1619 ID-0027
1620 . MOM-001
1621 NEO-MVS PROG-8MB / NEO-MVS CHA-8M
1622 . MOH-001
1623 NEO-AEG PROG-8MB / NEO-AEG CHA-8M
1618   <!--***************************************
1619   ID-0027
1620   . MOM-001
1621   NEO-MVS PROG-8MB / NEO-MVS CHA-8M
1622   . MOH-001
1623   NEO-AEG PROG-8MB / NEO-AEG CHA-8M
16241624***************************************-->
16251625
16261626   <software name="minasan">
r31374r31375
16641664      </part>
16651665   </software>
16661666
1667  <!--***************************************
1668 ID-0028
1669 Dunk Star (prototype) Sammy
1667   <!--***************************************
1668   ID-0028
1669   Dunk Star (prototype) Sammy
16701670***************************************-->
16711671
1672  <!--***************************************
1673 ID-0029
1674 . ??M-029
1675 NEO-MVS PROG42G-1 / NEO-MVS CHA42G-1
1676 . ??H-029
1672   <!--***************************************
1673   ID-0029
1674   . ??M-029
1675   NEO-MVS PROG42G-1 / NEO-MVS CHA42G-1
1676   . ??H-029
16771677***************************************-->
16781678
16791679   <software name="legendos">
r31374r31375
17121712      </part>
17131713   </software>
17141714
1715  <!--***************************************
1716 ID-0030
1717 . NGM-030
1718 NEO-MVS PROG42G-1 / NEO-MVS CHA42G-1
1719 . NGH-030
1720 NEO-AEG PROG42G-1 / NEO-AEG CHA42G-1
1715   <!--***************************************
1716   ID-0030
1717   . NGM-030
1718   NEO-MVS PROG42G-1 / NEO-MVS CHA42G-1
1719   . NGH-030
1720   NEO-AEG PROG42G-1 / NEO-AEG CHA42G-1
17211721***************************************-->
17221722
17231723   <software name="2020bb">
r31374r31375
18351835      </part>
18361836   </software>
18371837
1838  <!--***************************************
1839 ID-0031
1840 . NGM-031
1841 NEO-MVS PROG42G-1 / NEO-MVS CHA42G-1
1842 . NGH-031
1843 NEO-AEG PROG42G-1 / NEO-AEG CHA42G-1
1838   <!--***************************************
1839   ID-0031
1840   . NGM-031
1841   NEO-MVS PROG42G-1 / NEO-MVS CHA42G-1
1842   . NGH-031
1843   NEO-AEG PROG42G-1 / NEO-AEG CHA42G-1
18441844***************************************-->
18451845
18461846   <software name="socbrawl">
r31374r31375
19211921      </part>
19221922   </software>
19231923
1924  <!--***************************************
1925 ID-0032
1926 . NGM-032
1927 NEO-MVS PROG42G-1 / NEO-MVS CHA42G-1
1928 . NGH-032
1929 NEO-AEG PROG42G-1 / NEO-AEG CHA42G-1
1924   <!--***************************************
1925   ID-0032
1926   . NGM-032
1927   NEO-MVS PROG42G-1 / NEO-MVS CHA42G-1
1928   . NGH-032
1929   NEO-AEG PROG42G-1 / NEO-AEG CHA42G-1
19301930***************************************-->
19311931
19321932   <software name="roboarmy">
r31374r31375
19681968   </software>
19691969
19701970
1971  <!--***************************************
1972 ID-0033
1973 . NGM-033
1974 NEO-MVS PROG42G-1 / NEO-MVS CHA42G-1
1975 . NGH-033
1976 NEO-AEG PROG42G-1 / NEO-AEG CHA42G-1
1971   <!--***************************************
1972   ID-0033
1973   . NGM-033
1974   NEO-MVS PROG42G-1 / NEO-MVS CHA42G-1
1975   . NGH-033
1976   NEO-AEG PROG42G-1 / NEO-AEG CHA42G-1
19771977***************************************-->
19781978
19791979   <software name="fatfury1">
r31374r31375
20192019      </part>
20202020   </software>
20212021
2022  <!--***************************************
2023 ID-0034
2024 . NGM-034
2025 NEO-MVS PROG42G-1 / NEO-MVS CHA42G-1
2026 . NGH-034
2027 NEO-AEG PROG42G-1 / NEO-AEG CHA42G-1
2022   <!--***************************************
2023   ID-0034
2024   . NGM-034
2025   NEO-MVS PROG42G-1 / NEO-MVS CHA42G-1
2026   . NGH-034
2027   NEO-AEG PROG42G-1 / NEO-AEG CHA42G-1
20282028***************************************-->
20292029
20302030   <software name="fbfrenzy">
r31374r31375
20662066      </part>
20672067   </software>
20682068
2069  <!--***************************************
2070 ID-0035
2071 Mystic Wand (prototype) 1991 Alpha
2069   <!--***************************************
2070   ID-0035
2071   Mystic Wand (prototype) 1991 Alpha
20722072***************************************-->
20732073
2074  <!--***************************************
2075 ID-0036
2076 . MOM-002
2077 NEO-MVS PROG42G-1 / NEO-MVS CHA42G-1
2078 . MOH-002
2079 NEO-AEG PROG42G / NEO-AEG CHA42G
2074   <!--***************************************
2075   ID-0036
2076   . MOM-002
2077   NEO-MVS PROG42G-1 / NEO-MVS CHA42G-1
2078   . MOH-002
2079   NEO-AEG PROG42G / NEO-AEG CHA42G
20802080***************************************-->
20812081
20822082   <software name="bakatono">
r31374r31375
21182118      </part>
21192119   </software>
21202120
2121  <!--***************************************
2122 ID-0037
2123 . ALM-002
2124 NEO-MVS PROG42G-1 / NEO-MVS CHA42G-1
2125 . ALH-002
2126 NEO-AEG PROG42G / NEO-AEG CHA42G
2121   <!--***************************************
2122   ID-0037
2123   . ALM-002
2124   NEO-MVS PROG42G-1 / NEO-MVS CHA42G-1
2125   . ALH-002
2126   NEO-AEG PROG42G / NEO-AEG CHA42G
21272127***************************************-->
21282128
21292129   <software name="crsword">
r31374r31375
21632163      </part>
21642164   </software>
21652165
2166  <!--***************************************
2167 ID-0038
2168 . ALM-003
2169 NEO-MVS PROG42G-COM / NEO-MVS CHA42G-1
2170 . ALH-003
2171 NEO-AEG PROG42G-COM / NEO-AEG CHA42G-1
2166   <!--***************************************
2167   ID-0038
2168   . ALM-003
2169   NEO-MVS PROG42G-COM / NEO-MVS CHA42G-1
2170   . ALH-003
2171   NEO-AEG PROG42G-COM / NEO-AEG CHA42G-1
21722172***************************************-->
21732173
21742174   <software name="trally">
r31374r31375
22162216      </part>
22172217   </software>
22182218
2219  <!--***************************************
2220 ID-0039
2221 . NGM-039
2222 NEO-MVS PROG16 / NEO-MVS CHA42G-1
2223 . NGH-039
2224 NEO-AEG PROG16 / NEO-AEG CHA42G-1
2219   <!--***************************************
2220   ID-0039
2221   . NGM-039
2222   NEO-MVS PROG16 / NEO-MVS CHA42G-1
2223   . NGH-039
2224   NEO-AEG PROG16 / NEO-AEG CHA42G-1
22252225***************************************-->
22262226
22272227   <software name="kotm2">
r31374r31375
23092309      </part>
23102310   </software>
23112311
2312  <!--***************************************
2313 ID-0040
2314 . NGM-040
2315 NEO-MVS PROG 4096 / NEO-MVS CHA 42G-2
2316 . NGH-040
2312   <!--***************************************
2313   ID-0040
2314   . NGM-040
2315   NEO-MVS PROG 4096 / NEO-MVS CHA 42G-2
2316   . NGH-040
23172317***************************************-->
23182318
23192319   <software name="sengoku2">
r31374r31375
23482348      </part>
23492349   </software>
23502350
2351  <!--***************************************
2352 ID-0041
2353 . NGM-041
2354 NEO-MVS PROG42G-1 / NEO-MVS CHA42G-1
2355 . NGH-041
2351   <!--***************************************
2352   ID-0041
2353   . NGM-041
2354   NEO-MVS PROG42G-1 / NEO-MVS CHA42G-1
2355   . NGH-041
23562356***************************************-->
23572357
23582358   <software name="bstars2">
r31374r31375
23952395      </part>
23962396   </software>
23972397
2398  <!--***************************************
2399 ID-0042
2400 . NGM-042
2401 NEO-MVS PROG42G-1 / NEO-MVS CHA42G-1
2402 . NGH-042
2403 NEO-AEG PROG42G-1 / NEO-AEG CHA42G-1
2398   <!--***************************************
2399   ID-0042
2400   . NGM-042
2401   NEO-MVS PROG42G-1 / NEO-MVS CHA42G-1
2402   . NGH-042
2403   NEO-AEG PROG42G-1 / NEO-AEG CHA42G-1
24042404***************************************-->
24052405
24062406   <software name="quizdai2">
r31374r31375
24422442      </part>
24432443   </software>
24442444
2445  <!--***************************************
2446 ID-0043
2447 . NGM-043
2448 NEO-MVS PROG 4096 / NEO-MVS CHA 42G-2
2449 . NGH-043
2450 NEO-AEG PROG16 / NEO-AEG CHA42G-1
2445   <!--***************************************
2446   ID-0043
2447   . NGM-043
2448   NEO-MVS PROG 4096 / NEO-MVS CHA 42G-2
2449   . NGH-043
2450   NEO-AEG PROG16 / NEO-AEG CHA42G-1
24512451***************************************-->
24522452
24532453   <software name="3countb">
r31374r31375
24942494      </part>
24952495   </software>
24962496
2497  <!--***************************************
2498 ID-0044
2499 . NGM-044
2500 NEO-MVS PROG16 / NEO-MVS CHA42G-1
2501 . NGH-044
2502 NEO-AEG PROG16 / NEO-AEG CHA42G-1
2497   <!--***************************************
2498   ID-0044
2499   . NGM-044
2500   NEO-MVS PROG16 / NEO-MVS CHA42G-1
2501   . NGH-044
2502   NEO-AEG PROG16 / NEO-AEG CHA42G-1
25032503***************************************-->
25042504
25052505   <software name="aof">
r31374r31375
25452545      </part>
25462546   </software>
25472547
2548  <!--***************************************
2549 ID-0045
2550 . NGM-045
2551 NEO-MVS PROGGSC / NEO-MVS CHA 42G-3
2552 . NGH-045
2553 NEO-AEG PROGGS / NEO-AEG CHA42G-4
2548   <!--***************************************
2549   ID-0045
2550   . NGM-045
2551   NEO-MVS PROGGSC / NEO-MVS CHA 42G-3
2552   . NGH-045
2553   NEO-AEG PROGGS / NEO-AEG CHA42G-4
25542554***************************************-->
25552555
25562556   <software name="samsho">
r31374r31375
26432643      </part>
26442644   </software>
26452645
2646  <!--***************************************
2647 ID-0046
2648 . NGM-046
2649 NEO-MVS PROGTOP / NEO-MVS CHA256B
2650 . NGH-046
2651 NEO-AEG PROGTOP / NEO-AEG CHA256[B]
2646   <!--***************************************
2647   ID-0046
2648   . NGM-046
2649   NEO-MVS PROGTOP / NEO-MVS CHA256B
2650   . NGH-046
2651   NEO-AEG PROGTOP / NEO-AEG CHA256[B]
26522652***************************************-->
26532653
26542654   <software name="tophuntr">
r31374r31375
27572757      </part>
27582758   </software>
27592759
2760  <!--***************************************
2761 ID-0047
2762 . NGM-047
2763 NEO-MVS PROG-G2 (SNK-9201) / NEO-MVS CHA42G-1
2764 . NGH-047
2765 NEO-AEG PROG-G2 (PRO-CT0) / NEO-AEG CHA42G-2B
2760   <!--***************************************
2761   ID-0047
2762   . NGM-047
2763   NEO-MVS PROG-G2 (SNK-9201) / NEO-MVS CHA42G-1
2764   . NGH-047
2765   NEO-AEG PROG-G2 (PRO-CT0) / NEO-AEG CHA42G-2B
27662766***************************************-->
27672767
27682768   <software name="fatfury2">
r31374r31375
28102810      </part>
28112811   </software>
28122812
2813  <!--***************************************
2814 ID-0048
2815 . ??M-048
2816 NEO-MVS PROGGSC / NEO-MVS CHA256
2813   <!--***************************************
2814   ID-0048
2815   . ??M-048
2816   NEO-MVS PROGGSC / NEO-MVS CHA256
28172817***************************************-->
28182818
28192819   <software name="janshin">
r31374r31375
28492849      </part>
28502850   </software>
28512851
2852  <!--***************************************
2853 ID-0049
2854 . NGM-049
2855 NEO-MVS PROG16 / NEO-MVS CHA42G-1
2856 . NGH-049
2857 NEO-AEG PROG16 / NEO-AEG CHA42G-1
2852   <!--***************************************
2853   ID-0049
2854   . NGM-049
2855   NEO-MVS PROG16 / NEO-MVS CHA42G-1
2856   . NGH-049
2857   NEO-AEG PROG16 / NEO-AEG CHA42G-1
28582858***************************************-->
28592859
28602860   <software name="androdun">
r31374r31375
28922892      </part>
28932893   </software>
28942894
2895  <!--***************************************
2896 ID-0050
2897 . ALM-004
2898 NEO-MVS PROG42G-1 / NEO-MVS CHA42G-1
2899 . ALH-004
2895   <!--***************************************
2896   ID-0050
2897   . ALM-004
2898   NEO-MVS PROG42G-1 / NEO-MVS CHA42G-1
2899   . ALH-004
29002900***************************************-->
29012901
29022902   <software name="ncommand">
r31374r31375
29372937      </part>
29382938   </software>
29392939
2940  <!--***************************************
2941 ID-0051
2942 . AIM-051
2943 NEO-MVS PROG-G2 / NEO-MVS CHA42G-1
2944 . AIH-051
2940   <!--***************************************
2941   ID-0051
2942   . AIM-051
2943   NEO-MVS PROG-G2 / NEO-MVS CHA42G-1
2944   . AIH-051
29452945***************************************-->
29462946
29472947   <software name="viewpoin">
r31374r31375
29812981      </part>
29822982   </software>
29832983
2984  <!--***************************************
2985 ID-0052
2986 . NGM-052
2987 NEO-MVS PROG-G2 (SNK-9201) / NEO-MVS CHA 42G-2
2988 . NGH-052
2984   <!--***************************************
2985   ID-0052
2986   . NGM-052
2987   NEO-MVS PROG-G2 (SNK-9201) / NEO-MVS CHA 42G-2
2988   . NGH-052
29892989***************************************-->
29902990
29912991   <software name="ssideki">
r31374r31375
30233023      </part>
30243024   </software>
30253025
3026  <!--***************************************
3027 ID-0053
3028 . ALM-005
3029 NEO-MVS PROG16 / NEO-MVS CHA42G-1
3030 . ALH-005
3031 NEO-AEG PROG16 / NEO-AEG CHA42G-1
3026   <!--***************************************
3027   ID-0053
3028   . ALM-005
3029   NEO-MVS PROG16 / NEO-MVS CHA42G-1
3030   . ALH-005
3031   NEO-AEG PROG16 / NEO-AEG CHA42G-1
30323032***************************************-->
30333033
30343034   <software name="wh1">
r31374r31375
31593159      </part>
31603160   </software>
31613161
3162  <!--***************************************
3163 ID-0054
3164 Crossed Swords 2 (CD only? not confirmed, MVS might exist)
3162   <!--***************************************
3163   ID-0054
3164   Crossed Swords 2 (CD only? not confirmed, MVS might exist)
31653165***************************************-->
31663166
3167  <!--***************************************
3168 ID-0055
3169 . NGM-055
3170 NEO-MVS PROGTOP / NEO-MVS CHA256
3171 . NGH-055
3172 NEO-AEG PROGRK / NEO-AEG CHA256
3167   <!--***************************************
3168   ID-0055
3169   . NGM-055
3170   NEO-MVS PROGTOP / NEO-MVS CHA256
3171   . NGH-055
3172   NEO-AEG PROGRK / NEO-AEG CHA256
31733173***************************************-->
31743174
31753175   <software name="kof94">
r31374r31375
32223222      </part>
32233223   </software>
32243224
3225  <!--***************************************
3226 ID-0056
3227 . NGM-056
3228 NEO-MVS PROGGSC / NEO-MVS CHA256
3229 . NGH-056
3230 NEO-AEG PROGRKB / NEO-AEG CHA256[B]
3225   <!--***************************************
3226   ID-0056
3227   . NGM-056
3228   NEO-MVS PROGGSC / NEO-MVS CHA256
3229   . NGH-056
3230   NEO-AEG PROGRKB / NEO-AEG CHA256[B]
32313231***************************************-->
32323232
32333233   <software name="aof2">
r31374r31375
33333333      </part>
33343334   </software>
33353335
3336  <!--***************************************
3337 ID-0057
3338 . ALM-006
3339 NEO-MVS PROG 4096 B / NEO-MVS CHA 42G-3
3340 . ALH-006
3341 NEO-AEG PROG4096 B / NEO-AEG CHA42G-3
3336   <!--***************************************
3337   ID-0057
3338   . ALM-006
3339   NEO-MVS PROG 4096 B / NEO-MVS CHA 42G-3
3340   . ALH-006
3341   NEO-AEG PROG4096 B / NEO-AEG CHA42G-3
33423342***************************************-->
33433343
33443344   <software name="wh2">
r31374r31375
33853385      </part>
33863386   </software>
33873387
3388  <!--***************************************
3389 ID-0058
3390 . NGM-058
3391 NEO-MVS PROGGSC / NEO-MVS CHA 42G-3B
3392 . NGH-058
3393 NEO-AEG PROGGS / NEO-AEG CHA42G-4
3388   <!--***************************************
3389   ID-0058
3390   . NGM-058
3391   NEO-MVS PROGGSC / NEO-MVS CHA 42G-3B
3392   . NGH-058
3393   NEO-AEG PROGGS / NEO-AEG CHA42G-4
33943394***************************************-->
33953395
33963396   <software name="fatfursp">
r31374r31375
34913491      </part>
34923492   </software>
34933493
3494  <!--***************************************
3495 ID-0059
3496 . NGM-059
3497 NEO-MVS PROGTOP / NEO-MVS CHA256
3498 . NGH-059
3494   <!--***************************************
3495   ID-0059
3496   . NGM-059
3497   NEO-MVS PROGTOP / NEO-MVS CHA256
3498   . NGH-059
34993499***************************************-->
35003500
35013501   <software name="savagere">
r31374r31375
35473547      </part>
35483548   </software>
35493549
3550  <!--***************************************
3551 ID-0060
3552 . ??M-060
3553 NEO-MVS PROGGSC / NEO-MVS CHA256B
3550   <!--***************************************
3551   ID-0060
3552   . ??M-060
3553   NEO-MVS PROGGSC / NEO-MVS CHA256B
35543554***************************************-->
35553555
35563556   <software name="fightfev">
r31374r31375
36343634      </part>
36353635   </software>
36363636
3637  <!--***************************************
3638 ID-0061
3639 . NGM-061
3640 NEO-MVS PROGGSC / NEO-MVS CHA256
3641 . NGH-061
3642 NEO-AEG PROGRKB / NEO-AEG CHA256[B]
3637   <!--***************************************
3638   ID-0061
3639   . NGM-061
3640   NEO-MVS PROGGSC / NEO-MVS CHA256
3641   . NGH-061
3642   NEO-AEG PROGRKB / NEO-AEG CHA256[B]
36433643***************************************-->
36443644
36453645   <software name="ssideki2">
r31374r31375
36823682      </part>
36833683   </software>
36843684
3685  <!--***************************************
3686 ID-0062
3687 . DEM-001
3688 NEO-MVS PROGGSC / NEO-MVS CHA256
3689 . DEH-001
3685   <!--***************************************
3686   ID-0062
3687   . DEM-001
3688   NEO-MVS PROGGSC / NEO-MVS CHA256
3689   . DEH-001
36903690***************************************-->
36913691
36923692   <software name="spinmast">
r31374r31375
37353735      </part>
37363736   </software>
37373737
3738  <!--***************************************
3739 ID-0063
3740 . NGM-063
3741 NEO-MVS PROGTOP / NEO-MVS CHA256
3742 . NGH-063
3743 NEO-AEG PROGTOP2 / NEO-AEG CHA256 B
3738   <!--***************************************
3739   ID-0063
3740   . NGM-063
3741   NEO-MVS PROGTOP / NEO-MVS CHA256
3742   . NGH-063
3743   NEO-AEG PROGTOP2 / NEO-AEG CHA256 B
37443744***************************************-->
37453745
37463746   <software name="samsho2">
r31374r31375
38513851      </part>
38523852   </software>
38533853
3854  <!--***************************************
3855 ID-0064
3856 . ADM-007
3857 NEO-MVS PROGGSC / NEO-MVS CHA256
3858 . ADH-007
3859 NEO-AEG PROGRK / NEO-AEG CHA256
3854   <!--***************************************
3855   ID-0064
3856   . ADM-007
3857   NEO-MVS PROGGSC / NEO-MVS CHA256
3858   . ADH-007
3859   NEO-AEG PROGRK / NEO-AEG CHA256
38603860***************************************-->
38613861
38623862   <software name="wh2j">
r31374r31375
39073907      </part>
39083908   </software>
39093909
3910  <!--***************************************
3911 ID-0065
3912 . DEM-002
3913 NEO-MVS PROG42G-1 / NEO-MVS CHA42G-1
3914 . DEH-002
3910   <!--***************************************
3911   ID-0065
3912   . DEM-002
3913   NEO-MVS PROG42G-1 / NEO-MVS CHA42G-1
3914   . DEH-002
39153915***************************************-->
39163916
39173917   <software name="wjammers">
r31374r31375
39563956      </part>
39573957   </software>
39583958
3959  <!--***************************************
3960 ID-0066
3961 . DEM-003
3962 NEO-MVS PROGGSC / NEO-MVS CHA256
3963 . DEH-003
3959   <!--***************************************
3960   ID-0066
3961   . DEM-003
3962   NEO-MVS PROGGSC / NEO-MVS CHA256
3963   . DEH-003
39643964***************************************-->
39653965
39663966   <software name="karnovr">
r31374r31375
40034003      </part>
40044004   </software>
40054005
4006  <!--***************************************
4007 ID-0067
4008 . ??M-067
4009 NEO-MVS PROG16 / NEO-MVS CHA256B
4006   <!--***************************************
4007   ID-0067
4008   . ??M-067
4009   NEO-MVS PROG16 / NEO-MVS CHA256B
40104010***************************************-->
40114011
40124012   <software name="gururin">
r31374r31375
40424042      </part>
40434043   </software>
40444044
4045  <!--***************************************
4046 ID-0068
4047 . NGM-068
4048 NEO-MVS PROGTOP / NEO-MVS CHA256
4045   <!--***************************************
4046   ID-0068
4047   . NGM-068
4048   NEO-MVS PROGTOP / NEO-MVS CHA256
40494049***************************************-->
40504050
40514051   <software name="pspikes2">
r31374r31375
40934093      </part>
40944094   </software>
40954095
4096  <!--***************************************
4097 ID-0069
4098 . NGM-069
4099 NEO-MVS PROGBK1 / NEO-MVS CHA256
4096   <!--***************************************
4097   ID-0069
4098   . NGM-069
4099   NEO-MVS PROGBK1 / NEO-MVS CHA256
41004100. NGH-069
4101 NEO-AEG PROGBK1Y / NEO-AEG CHA256RY
4101   NEO-AEG PROGBK1Y / NEO-AEG CHA256RY
41024102***************************************-->
41034103
41044104   <software name="fatfury3">
r31374r31375
41484148      </part>
41494149   </software>
41504150
4151  <!--***************************************
4152 ID-0070
4153 . ??M-070
4154 NEO-MVS PROGBK1 / NEO-MVS CHAFIO (1999.6.14) (NEO-CMC 7042)
4151   <!--***************************************
4152   ID-0070
4153   . ??M-070
4154   NEO-MVS PROGBK1 / NEO-MVS CHAFIO (1999.6.14) (NEO-CMC 7042)
41554155***************************************-->
41564156
41574157   <software name="zupapa">
r31374r31375
41914191      </part>
41924192   </software>
41934193
4194  <!--***************************************
4195 ID-0071
4196 Bang Bang Busters (prototype) 1994 Visco
4197 Released in 2010 for MVS and AES (Releaser claims that it is officially licensed by VISCO)
4194   <!--***************************************
4195   ID-0071
4196   Bang Bang Busters (prototype) 1994 Visco
4197   Released in 2010 for MVS and AES (Releaser claims that it is officially licensed by VISCO)
41984198
4199 Reported UNIVERSE BIOS CRC32:
4200  ROM     EC861CAF
4201  BANK 0  NOT USED
4202  BANK 1  NOT USED
4203  BANK 2  NOT USED
4204  BANK 3  NOT USED
4205 ***************************************-->
4199   Reported UNIVERSE BIOS CRC32:
4200   ROM     EC861CAF
4201   BANK 0  NOT USED
4202   BANK 1  NOT USED
4203   BANK 2  NOT USED
4204   BANK 3  NOT USED
4205   ***************************************-->
42064206
4207  <!--***************************************
4208 ID-0072
4209 Last Odyssey Pinball Fantasia (prototype) 1995 Monolith
4210 A video of this was on youtube in 2010/2011.
4211 ***************************************-->
4207   <!--***************************************
4208   ID-0072
4209   Last Odyssey Pinball Fantasia (prototype) 1995 Monolith
4210   A video of this was on youtube in 2010/2011.
4211   ***************************************-->
42124212
4213  <!--***************************************
4214 ID-0073
4215 . ??M-073
4216 NEO-MVS PROGTOP / NEO-MVS CHA256
4213   <!--***************************************
4214   ID-0073
4215   . ??M-073
4216   NEO-MVS PROGTOP / NEO-MVS CHA256
42174217***************************************-->
42184218
42194219   <software name="panicbom">
r31374r31375
42514251      </part>
42524252   </software>
42534253
4254  <!--***************************************
4255 ID-0074
4256 . ADM-008
4257 NEO-MVS PROGTOP / NEO-MVS CHA256B
4258 . ADH-008
4259 NEO-AEG PROGRK / NEO-AEG CHA256
4254   <!--***************************************
4255   ID-0074
4256   . ADM-008
4257   NEO-MVS PROGTOP / NEO-MVS CHA256B
4258   . ADH-008
4259   NEO-AEG PROGRK / NEO-AEG CHA256
42604260***************************************-->
42614261
42624262   <software name="aodk">
r31374r31375
43074307      </part>
43084308   </software>
43094309
4310  <!--***************************************
4311 ID-0075
4312 . NGM-075
4313 NEO-MVS PROGGSC / NEO-MVS CHA256
4314 . NGH-075
4310   <!--***************************************
4311   ID-0075
4312   . NGM-075
4313   NEO-MVS PROGGSC / NEO-MVS CHA256
4314   . NGH-075
43154315***************************************-->
43164316
43174317   <software name="sonicwi2">
r31374r31375
43534353      </part>
43544354   </software>
43554355
4356  <!--***************************************
4357 ID-0076
4358 . ??M-076
4359 NEO-MVS PROGGSC / NEO-MVS CHA256
4356   <!--***************************************
4357   ID-0076
4358   . ??M-076
4359   NEO-MVS PROGGSC / NEO-MVS CHA256
43604360***************************************-->
43614361
43624362   <software name="zedblade">
r31374r31375
44004400      </part>
44014401   </software>
44024402
4403  <!--***************************************
4404 ID-0077
4405 The Warlocks of the Fates (prototype) 1995 Astec
4403   <!--***************************************
4404   ID-0077
4405   The Warlocks of the Fates (prototype) 1995 Astec
44064406***************************************-->
44074407
4408  <!--***************************************
4409 ID-0078
4410 . NGM-078
4411 NEO-MVS PROGTOP / NEO-MVS CHA256
4412 . NGH-078
4408   <!--***************************************
4409   ID-0078
4410   . NGM-078
4411   NEO-MVS PROGTOP / NEO-MVS CHA256
4412   . NGH-078
44134413***************************************-->
44144414
44154415   <software name="galaxyfg">
r31374r31375
44614461      </part>
44624462   </software>
44634463
4464  <!--***************************************
4465 ID-0079
4466 . DEM-004
4467 NEO-MVS PROGGSC / NEO-MVS CHA256
4468 . DEH-004
4469 NEO-AEG PROGRK  / NEO-AEG CHA256
4464   <!--***************************************
4465   ID-0079
4466   . DEM-004
4467   NEO-MVS PROGGSC / NEO-MVS CHA256
4468   . DEH-004
4469   NEO-AEG PROGRK  / NEO-AEG CHA256
44704470***************************************-->
44714471
44724472   <software name="strhoop">
r31374r31375
45094509      </part>
45104510   </software>
45114511
4512  <!--***************************************
4513 ID-0080
4514 . SAM-080
4515 NEO-MVS PROGGSC / NEO-MVS CHA256
4516 . SAH-080
4517 NEO-AEG PROGTOP2 / NEO-AEG CHA256 B
4512   <!--***************************************
4513   ID-0080
4514   . SAM-080
4515   NEO-MVS PROGGSC / NEO-MVS CHA256
4516   . SAH-080
4517   NEO-AEG PROGTOP2 / NEO-AEG CHA256 B
45184518***************************************-->
45194519
45204520   <software name="quizkof">
r31374r31375
45934593      </part>
45944594   </software>
45954595
4596  <!--***************************************
4597 ID-0081
4598 . NGM-081
4599 NEO-MVS PROGTOP / NEO-MVS CHA42G-3B
4600 NEO-MVS PROGTOP / NEO-MVS CHA256
4601 . NGH-081
4596   <!--***************************************
4597   ID-0081
4598   . NGM-081
4599   NEO-MVS PROGTOP / NEO-MVS CHA42G-3B
4600   NEO-MVS PROGTOP / NEO-MVS CHA256
4601   . NGH-081
46024602***************************************-->
46034603
46044604   <software name="ssideki3">
r31374r31375
46464646      </part>
46474647   </software>
46484648
4649  <!--***************************************
4650 ID-0082
4651 . NGM-082
4652 NEO-MVS PROGTOP / NEO-MVS CHA256
4653 NEO-MVS PROGTOP / NEO-MVS CHA 42G-3
4654 NEO-MVS PROGBK1 / NEO-MVS CHA256
4655 . NGH-082
4649   <!--***************************************
4650   ID-0082
4651   . NGM-082
4652   NEO-MVS PROGTOP / NEO-MVS CHA256
4653   NEO-MVS PROGTOP / NEO-MVS CHA 42G-3
4654   NEO-MVS PROGBK1 / NEO-MVS CHA256
4655   . NGH-082
46564656***************************************-->
46574657
46584658   <software name="doubledr">
r31374r31375
47024702      </part>
47034703   </software>
47044704
4705  <!--***************************************
4706 ID-0083
4707 . NGM-083
4708 NEO-MVS PROGTOP / NEO-MVS CHA256
4705   <!--***************************************
4706   ID-0083
4707   . NGM-083
4708   NEO-MVS PROGTOP / NEO-MVS CHA256
47094709***************************************-->
47104710
47114711   <software name="pbobblen">
r31374r31375
47164716      <sharedfeat name="compatibility" value="MVS,AES" />
47174717      <part name="cart" interface="neo_cart">
47184718         <!-- MVS ONLY RELEASE -->
4719      <!-- This set uses CHA and PROG board from Power Spikes II. Six Power Spikes II prom's are replaced with
4719      <!-- This set uses CHA and PROG board from Power Spikes II. Six Power Spikes II prom's are replaced with
47204720   Puzzle Bobble prom's. Confirmed on several original carts. Do other layouts also exist? -->
47214721         <dataarea name="maincpu" width="16" endianness="big" size="0x100000">
47224722            <rom loadflag="load16_word_swap" name="d96-07.ep1" offset="0x000000" size="0x080000" crc="6102ca14" sha1="328429d11de5b327a0654ae0548da4d0025a2ae6" />
r31374r31375
47634763      </part>
47644764   </software>
47654765
4766  <!--***************************************
4767 ID-0084
4768 . NGM-084
4769 NEO-MVS PROGBK1 / NEO-MVS CHA256
4770 NEO-MVS PROGSM / NEO-MVS CHA256
4771 . NGH-084
4772 NEO-AEG PROGBK1Y / NEO-AEG CHA256RY
4766   <!--***************************************
4767   ID-0084
4768   . NGM-084
4769   NEO-MVS PROGBK1 / NEO-MVS CHA256
4770   NEO-MVS PROGSM / NEO-MVS CHA256
4771   . NGH-084
4772   NEO-AEG PROGBK1Y / NEO-AEG CHA256RY
47734773***************************************-->
47744774
47754775   <software name="kof95">
r31374r31375
48774877      </part>
48784878   </software>
48794879
4880  <!--***************************************
4881 ID-0085
4882 Shinsetsu Samurai Spirits Bushidoretsuden / Samurai Shodown RPG (CD only)
4880   <!--***************************************
4881   ID-0085
4882   Shinsetsu Samurai Spirits Bushidoretsuden / Samurai Shodown RPG (CD only)
48834883***************************************-->
48844884
4885  <!--***************************************
4886 ID-0086
4887 . ??M-086
4888 NEO-MVS PROGBK1 / NEO-MVS CHA256B
4885   <!--***************************************
4886   ID-0086
4887   . ??M-086
4888   NEO-MVS PROGBK1 / NEO-MVS CHA256B
48894889***************************************-->
48904890
48914891   <software name="tws96">
r31374r31375
49274927      </part>
49284928   </software>
49294929
4930  <!--***************************************
4931 ID-0087
4932 . NGM-087
4933 NEO-MVS PROGSS3 / NEO-MVS CHA256
4934 . NGH-087
4935 NEO-AEG PROGBK1Y / NEO-AEG CHA256RY
4930   <!--***************************************
4931   ID-0087
4932   . NGM-087
4933   NEO-MVS PROGSS3 / NEO-MVS CHA256
4934   . NGH-087
4935   NEO-AEG PROGBK1Y / NEO-AEG CHA256RY
49364936***************************************-->
49374937
49384938   <software name="samsho3">
r31374r31375
50895089      </part>
50905090   </software>
50915091
5092  <!--***************************************
5093 ID-0088
5094 . NGM-088
5095 NEO-MVS PROGBK1 / NEO-MVS CHA42-3B
5096 . NGH-088
5092   <!--***************************************
5093   ID-0088
5094   . NGM-088
5095   NEO-MVS PROGBK1 / NEO-MVS CHA42-3B
5096   . NGH-088
50975097***************************************-->
50985098
50995099   <software name="stakwin">
r31374r31375
51335133      </part>
51345134   </software>
51355135
5136  <!--***************************************
5137 ID-0089
5138 . NGM-089
5139 NEO-MVS PROGBK1 / NEO-MVS CHA256
5140 . NGH-089
5136   <!--***************************************
5137   ID-0089
5138   . NGM-089
5139   NEO-MVS PROGBK1 / NEO-MVS CHA256
5140   . NGH-089
51415141***************************************-->
51425142
51435143   <software name="pulstar">
r31374r31375
51885188      </part>
51895189   </software>
51905190
5191  <!--***************************************
5192 ID-0090
5193 . ADM-009
5194 NEO-MVS PROGTOP / NEO-MVS CHA256
5195 . ADH-009
5191   <!--***************************************
5192   ID-0090
5193   . ADM-009
5194   NEO-MVS PROGTOP / NEO-MVS CHA256
5195   . ADH-009
51965196***************************************-->
51975197
51985198   <software name="whp">
r31374r31375
52465246      </part>
52475247   </software>
52485248
5249  <!--***************************************
5250 ID-0091
5251 unknown
5249   <!--***************************************
5250   ID-0091
5251   unknown
52525252***************************************-->
52535253
5254  <!--***************************************
5255 ID-0092
5256 . NGM-092
5257 NEO-MVS PROGBK1 / NEO-MVS CHA256
5258 . NGH-092
5254   <!--***************************************
5255   ID-0092
5256   . NGM-092
5257   NEO-MVS PROGBK1 / NEO-MVS CHA256
5258   . NGH-092
52595259***************************************-->
52605260
52615261   <software name="kabukikl">
r31374r31375
53015301      </part>
53025302   </software>
53035303
5304  <!--***************************************
5305 ID-0093
5306 . ??M-093
5307 NEO-MVS PROGBK1 / NEO-MVS CHA256
5304   <!--***************************************
5305   ID-0093
5306   . ??M-093
5307   NEO-MVS PROGBK1 / NEO-MVS CHA256
53085308***************************************-->
53095309
53105310   <software name="neobombe">
r31374r31375
53465346      </part>
53475347   </software>
53485348
5349  <!--***************************************
5350 ID-0094
5351 . NGM-094
5352 NEO-MVS PROGBK1 / NEO-MVS CHA42G-3B
5353 . NGH-094
5349   <!--***************************************
5350   ID-0094
5351   . NGM-094
5352   NEO-MVS PROGBK1 / NEO-MVS CHA42G-3B
5353   . NGH-094
53545354***************************************-->
53555355
53565356   <software name="gowcaizr">
r31374r31375
54025402      </part>
54035403   </software>
54045404
5405  <!--***************************************
5406 ID-0095
5407 . NGM-095
5408 NEO-MVS PROGBK1 / NEO-MVS CHA256
5409 . NGH-095
5410 NEO-AEG PROGBK1Y / NEO-AEG CHA256RY
5405   <!--***************************************
5406   ID-0095
5407   . NGM-095
5408   NEO-MVS PROGBK1 / NEO-MVS CHA256
5409   . NGH-095
5410   NEO-AEG PROGBK1Y / NEO-AEG CHA256RY
54115411***************************************-->
54125412
54135413   <software name="rbff1">
r31374r31375
55185518      </part>
55195519   </software>
55205520
5521  <!--***************************************
5522 ID-0096
5523 . NGM-096
5524 NEO-MVS PROGBK1 / NEO-MVS CHA256
5525 . NGH-096
5521   <!--***************************************
5522   ID-0096
5523   . NGM-096
5524   NEO-MVS PROGBK1 / NEO-MVS CHA256
5525   . NGH-096
55265526***************************************-->
55275527
55285528   <software name="aof3">
r31374r31375
56265626      </part>
56275627   </software>
56285628
5629  <!--***************************************
5630 ID-0097
5631 . NGM-097
5632 NEO-MVS PROGBK1 / NEO-MVS CHA256
5633 . NGH-097
5629   <!--***************************************
5630   ID-0097
5631   . NGM-097
5632   NEO-MVS PROGBK1 / NEO-MVS CHA256
5633   . NGH-097
56345634***************************************-->
56355635
56365636   <software name="sonicwi3">
r31374r31375
56725672      </part>
56735673   </software>
56745674
5675  <!--***************************************
5676 ID-0098
5677 Idol Mahjong - final romance 2 (CD only? not confirmed, MVS might exist)
5675   <!--***************************************
5676   ID-0098
5677   Idol Mahjong - final romance 2 (CD only? not confirmed, MVS might exist)
56785678***************************************-->
56795679
5680  <!--***************************************
5681 ID-0099
5682 Neo Pool Masters
5680   <!--***************************************
5681   ID-0099
5682   Neo Pool Masters
56835683***************************************-->
56845684
56855685
56865686      <!-- ID range from 100 - 199 is used for Korean (some) and Neo Print carts -->
56875687
5688  <!--
5688   <!--
56895689   The following ID's are used by Korean releases:
56905690
56915691   ID-0122 - Pae Wang Jeon Seol / Legend of a Warrior (Korean censored Samurai Shodown IV)
r31374r31375
57005700-->
57015701
57025702
5703  <!--***************************************
5704 ID-0200
5705 . NGM-200
5706 NEO-MVS PROGBK1 / NEO-MVS CHA256B
5707 . NGH-200
5703   <!--***************************************
5704   ID-0200
5705   . NGM-200
5706   NEO-MVS PROGBK1 / NEO-MVS CHA256B
5707   . NGH-200
57085708***************************************-->
57095709
57105710   <software name="turfmast">
r31374r31375
57465746      </part>
57475747   </software>
57485748
5749  <!--***************************************
5750 ID-0201
5751 . NGM-201
5752 NEO-MVS PROGBK1 / NEO-MVS CHA256
5753 . NGH-201
5749   <!--***************************************
5750   ID-0201
5751   . NGM-201
5752   NEO-MVS PROGBK1 / NEO-MVS CHA256
5753   . NGH-201
57545754***************************************-->
57555755
57565756   <software name="mslug">
r31374r31375
57925792      </part>
57935793   </software>
57945794
5795  <!--***************************************
5796 ID-0202
5797 . ??M-202
5798 NEO-MVS PROG 4096 / NEO-MVS CHA 42G-2
5795   <!--***************************************
5796   ID-0202
5797   . ??M-202
5798   NEO-MVS PROG 4096 / NEO-MVS CHA 42G-2
57995799***************************************-->
58005800
58015801   <software name="puzzledp">
r31374r31375
58315831      </part>
58325832   </software>
58335833
5834  <!--***************************************
5835 ID-0203
5836 . ADM-010
5837 NEO-MVS PROGTOP / NEO-MVS CHA42G-3B
5838 . ADH-010
5834   <!--***************************************
5835   ID-0203
5836   . ADM-010
5837   NEO-MVS PROGTOP / NEO-MVS CHA42G-3B
5838   . ADH-010
58395839***************************************-->
58405840
58415841   <software name="mosyougi">
r31374r31375
58705870      </part>
58715871   </software>
58725872
5873  <!--***************************************
5874 ID-0204
5875 QP (prototype)
5873   <!--***************************************
5874   ID-0204
5875   QP (prototype)
58765876***************************************-->
58775877
5878  <!--***************************************
5879 ID-0205
5880 Neo-Geo CD Special (CD only)
5878   <!--***************************************
5879   ID-0205
5880   Neo-Geo CD Special (CD only)
58815881***************************************-->
58825882
5883  <!--***************************************
5884 ID-0206
5885 . ??M-206
5886 NEO-MVS PROGBK1 / NEO-MVS CHA256
5887 . ??H-206
5883   <!--***************************************
5884   ID-0206
5885   . ??M-206
5886   NEO-MVS PROGBK1 / NEO-MVS CHA256
5887   . ??H-206
58885888***************************************-->
58895889
58905890   <software name="marukodq">
r31374r31375
59255925      </part>
59265926   </software>
59275927
5928  <!--***************************************
5929 ID-0207
5930 . ??M-207
5931 NEO-MVS PROGBK1 / NEO-MVS CHA42G-3B
5928   <!--***************************************
5929   ID-0207
5930   . ??M-207
5931   NEO-MVS PROGBK1 / NEO-MVS CHA42G-3B
59325932***************************************-->
59335933
59345934   <software name="neomrdo">
r31374r31375
59645964      </part>
59655965   </software>
59665966
5967  <!--***************************************
5968 ID-0208
5969 . ??M-208
5970 NEO-MVS PROGBK1 / NEO-MVS CHA256B
5967   <!--***************************************
5968   ID-0208
5969   . ??M-208
5970   NEO-MVS PROGBK1 / NEO-MVS CHA256B
59715971***************************************-->
59725972
59735973   <software name="sdodgeb">
r31374r31375
60086008      </part>
60096009   </software>
60106010
6011  <!--***************************************
6012 ID-0209
6013 . ??M-209
6014 NEO-MVS PROGBK1 / NEO-MVS CHA256
6011   <!--***************************************
6012   ID-0209
6013   . ??M-209
6014   NEO-MVS PROGBK1 / NEO-MVS CHA256
60156015***************************************-->
60166016
60176017   <software name="goalx3">
r31374r31375
60526052      </part>
60536053   </software>
60546054
6055  <!--***************************************
6056 ID-0210
6057 Karate Ninja Sho (prototype) 1995 Yumekobo
6055   <!--***************************************
6056   ID-0210
6057   Karate Ninja Sho (prototype) 1995 Yumekobo
60586058***************************************-->
60596059
6060  <!--***************************************
6061 ID-0211
6062 Oshidashi Zintrick (CD only? not confirmed, MVS might exist) 1996 SNK/ADK
6060   <!--***************************************
6061   ID-0211
6062   Oshidashi Zintrick (CD only? not confirmed, MVS might exist) 1996 SNK/ADK
60636063***************************************-->
60646064
6065  <!--***************************************
6066 ID-0212
6067 . ADM-011
6068 NEO-MVS PROGBK1 / NEO-MVS CHA256
6069 . ADH-011
6065   <!--***************************************
6066   ID-0212
6067   . ADM-011
6068   NEO-MVS PROGBK1 / NEO-MVS CHA256
6069   . ADH-011
60706070***************************************-->
60716071
60726072   <software name="overtop">
r31374r31375
61106110      </part>
61116111   </software>
61126112
6113  <!--***************************************
6114 ID-0213
6115 . ??M-213
6116 NEO-MVS PROGBK1 / NEO-MVS CHA256B
6113   <!--***************************************
6114   ID-0213
6115   . ??M-213
6116   NEO-MVS PROGBK1 / NEO-MVS CHA256B
61176117***************************************-->
61186118
61196119   <software name="neodrift">
r31374r31375
61526152      </part>
61536153   </software>
61546154
6155  <!--***************************************
6156 ID-0214
6157 . NGM-214
6158 NEO-MVS PROGBK1 / NEO-MVS CHA256
6159 . NGH-214
6155   <!--***************************************
6156   ID-0214
6157   . NGM-214
6158   NEO-MVS PROGBK1 / NEO-MVS CHA256
6159   . NGH-214
61606160***************************************-->
61616161
61626162   <software name="kof96">
r31374r31375
62596259      </part>
62606260   </software>
62616261
6262  <!--***************************************
6263 ID-0215
6264 . NGM-215
6265 NEO-MVS PROGBK1 / NEO-MVS CHA256
6266 . NGH-215
6262   <!--***************************************
6263   ID-0215
6264   . NGM-215
6265   NEO-MVS PROGBK1 / NEO-MVS CHA256
6266   . NGH-215
62676267***************************************-->
62686268
62696269   <software name="ssideki4">
r31374r31375
63096309      </part>
63106310   </software>
63116311
6312  <!--***************************************
6313 ID-0216
6314 . ??M-216
6315 NEO-MVS PROGTOP / NEO-MVS CHA256
6316 . ??H-216
6312   <!--***************************************
6313   ID-0216
6314   . ??M-216
6315   NEO-MVS PROGTOP / NEO-MVS CHA256
6316   . ??H-216
63176317***************************************-->
63186318
63196319   <software name="kizuna">
r31374r31375
63696369      </part>
63706370   </software>
63716371
6372  <!--***************************************
6373 ID-0217
6374 . ADM-012
6375 NEO-MVS PROGBK1 / NEO-MVS CHA256
6376 . ADH-012
6372   <!--***************************************
6373   ID-0217
6374   . ADM-012
6375   NEO-MVS PROGBK1 / NEO-MVS CHA256
6376   . ADH-012
63776377***************************************-->
63786378
63796379   <software name="ninjamas">
r31374r31375
64246424      </part>
64256425   </software>
64266426
6427  <!--***************************************
6428 ID-0218
6429 . NGM-218
6430 NEO-MVS PROGBK1 / NEO-MVS CHA256
6431 . NGH-218
6427   <!--***************************************
6428   ID-0218
6429   . NGM-218
6430   NEO-MVS PROGBK1 / NEO-MVS CHA256
6431   . NGH-218
64326432***************************************-->
64336433
64346434   <software name="ragnagrd">
r31374r31375
64786478      </part>
64796479   </software>
64806480
6481  <!--***************************************
6482 ID-0219
6483 . NGM-219
6484 NEO-MVS PROGBK1 / NEO-MVS CHA256
6481   <!--***************************************
6482   ID-0219
6483   . NGM-219
6484   NEO-MVS PROGBK1 / NEO-MVS CHA256
64856485***************************************-->
64866486
64876487   <software name="pgoal">
r31374r31375
65226522      </part>
65236523   </software>
65246524
6525  <!--***************************************
6526 ID-0220
6527 Choutetsu Brikin'ger - Iron clad (prototype) 1996 Saurus
6525   <!--***************************************
6526   ID-0220
6527   Choutetsu Brikin'ger - Iron clad (prototype) 1996 Saurus
65286528***************************************-->
65296529
65306530   <software name="ironclad">
r31374r31375
65876587      </part>
65886588   </software>
65896589
6590  <!--***************************************
6591 ID-0221
6592 . NGM-221
6593 NEO-MVS PROGBK1 / NEO-MVS CHA256B
6594 . NGH-221
6590   <!--***************************************
6591   ID-0221
6592   . NGM-221
6593   NEO-MVS PROGBK1 / NEO-MVS CHA256B
6594   . NGH-221
65956595***************************************-->
65966596
65976597   <software name="magdrop2">
r31374r31375
66266626      </part>
66276627   </software>
66286628
6629  <!--***************************************
6630 ID-0222
6631 . NGM-222
6632 NEO-MVS PROGBK1 / NEO-MVS CHA256B
6633 . NGH-222
6634 NEO-AEG PROGBK1Y / NEO-AEG CHA256RY
6629   <!--***************************************
6630   ID-0222
6631   . NGM-222
6632   NEO-MVS PROGBK1 / NEO-MVS CHA256B
6633   . NGH-222
6634   NEO-AEG PROGBK1Y / NEO-AEG CHA256RY
66356635***************************************-->
66366636
66376637   <software name="samsho4">
r31374r31375
67356735      </part>
67366736   </software>
67376737
6738  <!--***************************************
6739 ID-0223
6740 . NGM-223
6741 NEO-MVS PROGBK1 / NEO-MVS CHA256B
6742 . NGH-223
6738   <!--***************************************
6739   ID-0223
6740   . NGM-223
6741   NEO-MVS PROGBK1 / NEO-MVS CHA256B
6742   . NGH-223
67436743***************************************-->
67446744
67456745   <software name="rbffspec">
r31374r31375
68446844      </part>
68456845   </software>
68466846
6847  <!--***************************************
6848 ID-0224
6849 . ADM-013
6850 NEO-MVS PROGBK1 / NEO-MVS CHA256B
6851 . ADH-013
6847   <!--***************************************
6848   ID-0224
6849   . ADM-013
6850   NEO-MVS PROGBK1 / NEO-MVS CHA256B
6851   . ADH-013
68526852***************************************-->
68536853
68546854   <software name="twinspri">
r31374r31375
68906890      </part>
68916891   </software>
68926892
6893  <!--***************************************
6894 ID-0225
6895 . SUM-225
6896 NEO-MVS PROGBK1 / NEO-MVS CHA256B
6897 . SUH-225
6893   <!--***************************************
6894   ID-0225
6895   . SUM-225
6896   NEO-MVS PROGBK1 / NEO-MVS CHA256B
6897   . SUH-225
68986898***************************************-->
68996899
69006900   <software name="wakuwak7">
r31374r31375
69416941      </part>
69426942   </software>
69436943
6944  <!--***************************************
6945 ID-0226
6946 Pair Pair Wars (prototype) 1996 Sunsoft?
6944   <!--***************************************
6945   ID-0226
6946   Pair Pair Wars (prototype) 1996 Sunsoft?
69476947***************************************-->
69486948
6949  <!--***************************************
6950 ID-0227
6951 . NGM-227
6952 NEO-MVS PROGBK1 / NEO-MVS CHA256
6953 . NGH-227
6949   <!--***************************************
6950   ID-0227
6951   . NGM-227
6952   NEO-MVS PROGBK1 / NEO-MVS CHA256
6953   . NGH-227
69546954***************************************-->
69556955
69566956   <software name="stakwin2">
r31374r31375
69926992      </part>
69936993   </software>
69946994
6995  <!--***************************************
6996 ID-0228
6997 Ghostlop (prototype) 1996 Data East Corp.
6995   <!--***************************************
6996   ID-0228
6997   Ghostlop (prototype) 1996 Data East Corp.
69986998***************************************-->
69996999
70007000   <software name="ghostlop">
r31374r31375
70247024      </part>
70257025   </software>
70267026
7027  <!--***************************************
7028 ID-0229
7029 King of Fighters '96 CD Collection (CD only)
7027   <!--***************************************
7028   ID-0229
7029   King of Fighters '96 CD Collection (CD only)
70307030***************************************-->
70317031
70327032
70337033      <!-- With ID-0230 the product ID code changed from xxM-xxx / xxH-xxx to xxM-xxx0 / xxH-xxx0 -->
70347034
70357035
7036  <!--***************************************
7037 ID-0230
7038 . NGM-2300
7039 NEO-MVS PROGBK1 / NEO-MVS CHA256B
7040 . NGH-2300
7036   <!--***************************************
7037   ID-0230
7038   . NGM-2300
7039   NEO-MVS PROGBK1 / NEO-MVS CHA256B
7040   . NGH-2300
70417041***************************************-->
70427042
70437043   <software name="breakers">
r31374r31375
70797079      </part>
70807080   </software>
70817081
7082  <!--***************************************
7083 ID-0231
7084 . ??M-2310
7085 NEO-MVS PROGBK1 / NEO-MVS CHA42G-3B
7082   <!--***************************************
7083   ID-0231
7084   . ??M-2310
7085   NEO-MVS PROGBK1 / NEO-MVS CHA42G-3B
70867086***************************************-->
70877087
70887088   <software name="miexchng">
r31374r31375
71227122      </part>
71237123   </software>
71247124
7125  <!--***************************************
7126 ID-0232
7127 . NGM-2320
7128 NEO-MVS PROGBK1 / NEO-MVS CHA512Y
7129 . NGH-2320
7130 NEO-AEG PROGBK1Y / NEO-AEG CHA512Y
7125   <!--***************************************
7126   ID-0232
7127   . NGM-2320
7128   NEO-MVS PROGBK1 / NEO-MVS CHA512Y
7129   . NGH-2320
7130   NEO-AEG PROGBK1Y / NEO-AEG CHA512Y
71317131***************************************-->
71327132
71337133   <software name="kof97">
r31374r31375
72717271      </part>
72727272   </software>
72737273
7274  <!--***************************************
7275 ID-0233
7276 . NGM-2330
7277 NEO-MVS PROGBK1 / NEO-MVS CHA256
7278 . NGH-2330
7274   <!--***************************************
7275   ID-0233
7276   . NGM-2330
7277   NEO-MVS PROGBK1 / NEO-MVS CHA256
7278   . NGH-2330
72797279***************************************-->
72807280
72817281   <software name="magdrop3">
r31374r31375
73167316      </part>
73177317   </software>
73187318
7319  <!--***************************************
7320 ID-0234
7321 . NGM-2340
7322 NEO-MVS PROGBK1 / NEO-MVS CHA512Y
7323 . NGH-2340
7324 NEO-AEG PROGBK1Y / NEO-AEG CHA512Y
7319   <!--***************************************
7320   ID-0234
7321   . NGM-2340
7322   NEO-MVS PROGBK1 / NEO-MVS CHA512Y
7323   . NGH-2340
7324   NEO-AEG PROGBK1Y / NEO-AEG CHA512Y
73257325***************************************-->
73267326
73277327   <software name="lastblad">
r31374r31375
74727472      </part>
74737473   </software>
74747474
7475  <!--***************************************
7476 ID-0235
7477 . ??M-2350
7478 NEO-MVS PROG 4096 / NEO-MVS CHA 42G-2
7475   <!--***************************************
7476   ID-0235
7477   . ??M-2350
7478   NEO-MVS PROG 4096 / NEO-MVS CHA 42G-2
74797479***************************************-->
74807480
74817481   <software name="puzzldpr" cloneof="puzzledp">
r31374r31375
75097509      </part>
75107510   </software>
75117511
7512  <!--***************************************
7513 ID-0236
7514 . ??M-2360
7515 NEO-MVS PROGBK1 / NEO-MVS CHA512Y
7512   <!--***************************************
7513   ID-0236
7514   . ??M-2360
7515   NEO-MVS PROGBK1 / NEO-MVS CHA512Y
75167516***************************************-->
75177517
75187518      <!-- Irritating Maze requires a Custom BIOS and is still loaded in neodrvr.c -->
75197519
7520  <!--***************************************
7521 ID-0237
7522 . ??M-2370
7523 NEO-MVS PROG 4096 / NEO-MVS CHA42G-3B
7520   <!--***************************************
7521   ID-0237
7522   . ??M-2370
7523   NEO-MVS PROG 4096 / NEO-MVS CHA42G-3B
75247524***************************************-->
75257525
75267526   <software name="popbounc">
r31374r31375
75567556      </part>
75577557   </software>
75587558
7559  <!--***************************************
7560 ID-0238
7561 . ??M-2380
7562 NEO-MVS PROGBK1 / NEO-MVS CHA256
7559   <!--***************************************
7560   ID-0238
7561   . ??M-2380
7562   NEO-MVS PROGBK1 / NEO-MVS CHA256
75637563***************************************-->
75647564
75657565   <software name="shocktro">
r31374r31375
76597659      </part>
76607660   </software>
76617661
7662  <!--***************************************
7663 ID-0239
7664 . NGM-2390
7665 NEO-MVS PROGBK1 / NEO-MVS CHA512Y
7666 . NGH-2390
7662   <!--***************************************
7663   ID-0239
7664   . NGM-2390
7665   NEO-MVS PROGBK1 / NEO-MVS CHA512Y
7666   . NGH-2390
76677667***************************************-->
76687668
76697669   <software name="blazstar">
r31374r31375
77147714      </part>
77157715   </software>
77167716
7717  <!--***************************************
7718 ID-0240
7719 . NGM-2400
7720 NEO-MVS PROGBK1 / NEO-MVS CHA512Y
7721 . NGH-2400
7722 NEO-AEG PROGBK1Y / NEO-AEG CHA512Y
7717   <!--***************************************
7718   ID-0240
7719   . NGM-2400
7720   NEO-MVS PROGBK1 / NEO-MVS CHA512Y
7721   . NGH-2400
7722   NEO-AEG PROGBK1Y / NEO-AEG CHA512Y
77237723***************************************-->
77247724
77257725   <software name="rbff2">
r31374r31375
78707870      </part>
78717871   </software>
78727872
7873  <!--***************************************
7874 ID-0241
7875 . NGM-2410
7876 NEO-MVS PROGBK1 / NEO-MVS CHA512Y
7877 . NGH-2410
7878 NEO-AEG PROGBK1Y / NEO-AEG CHA512Y
7873   <!--***************************************
7874   ID-0241
7875   . NGM-2410
7876   NEO-MVS PROGBK1 / NEO-MVS CHA512Y
7877   . NGH-2410
7878   NEO-AEG PROGBK1Y / NEO-AEG CHA512Y
78797879***************************************-->
78807880
78817881   <software name="mslug2">
r31374r31375
79187918      </part>
79197919   </software>
79207920
7921  <!--***************************************
7922 ID-0242
7923 . NGM-2420
7924 NEO-MVS PROGSF1 (protected board) / NEO-MVS CHA512Y
7925 NEO-MVS PROGBK1 / NEO-MVS CHA512Y
7926 . NGH-2420
7927 NEO-AEG PROGBK1Y / NEO-AEG CHA512Y
7921   <!--***************************************
7922   ID-0242
7923   . NGM-2420
7924   NEO-MVS PROGSF1 (protected board) / NEO-MVS CHA512Y
7925   NEO-MVS PROGBK1 / NEO-MVS CHA512Y
7926   . NGH-2420
7927   NEO-AEG PROGBK1Y / NEO-AEG CHA512Y
79287928***************************************-->
79297929
79307930   <software name="kof98">
r31374r31375
81498149      </part>
81508150   </software>
81518151
8152  <!--***************************************
8153 ID-0243
8154 . NGM-2430
8155 NEO-MVS PROGBK1 / NEO-MVS CHA512Y
8156 . NGH-2430
8157 NEO-AEG PROGBK1Y / NEO-AEG CHA512Y
8152   <!--***************************************
8153   ID-0243
8154   . NGM-2430
8155   NEO-MVS PROGBK1 / NEO-MVS CHA512Y
8156   . NGH-2430
8157   NEO-AEG PROGBK1Y / NEO-AEG CHA512Y
81588158***************************************-->
81598159
81608160   <software name="lastbld2">
r31374r31375
82078207      </part>
82088208   </software>
82098209
8210  <!--***************************************
8211 ID-0244
8212 . ??M-2440
8213 NEO-MVS PROGBK1 / NEO-MVS CHA512Y
8214 . ??H-2440
8210   <!--***************************************
8211   ID-0244
8212   . ??M-2440
8213   NEO-MVS PROGBK1 / NEO-MVS CHA512Y
8214   . ??H-2440
82158215***************************************-->
82168216
82178217   <software name="neocup98">
r31374r31375
82498249      </part>
82508250   </software>
82518251
8252  <!--***************************************
8253 ID-0245
8254 . ??M-2450
8255 NEO-MVS PROGBK1 / NEO-MVS CHA512Y
8252   <!--***************************************
8253   ID-0245
8254   . ??M-2450
8255   NEO-MVS PROGBK1 / NEO-MVS CHA512Y
82568256***************************************-->
82578257
82588258   <software name="breakrev">
r31374r31375
83008300      </part>
83018301   </software>
83028302
8303  <!--***************************************
8304 ID-0246
8305 . NGM-2460
8306 NEO-MVS PROGBK1 / NEO-MVS CHA512Y
8307 . NGH-2460
8303   <!--***************************************
8304   ID-0246
8305   . NGM-2460
8306   NEO-MVS PROGBK1 / NEO-MVS CHA512Y
8307   . NGH-2460
83088308***************************************-->
83098309
83108310   <software name="shocktr2">
r31374r31375
83538353      </part>
83548354   </software>
83558355
8356  <!--***************************************
8357 ID-0247
8358 . ??M-2470
8359 NEO-MVS PROGBK1 / NEO-MVS CHA256
8356   <!--***************************************
8357   ID-0247
8358   . ??M-2470
8359   NEO-MVS PROGBK1 / NEO-MVS CHA256
83608360***************************************-->
83618361
83628362   <software name="flipshot">
r31374r31375
83928392      </part>
83938393   </software>
83948394
8395  <!--***************************************
8396 ID-0248
8397 . ??M-2480
8398 NEO-MVS PROGBK1 / NEO-MVS CHA256
8395   <!--***************************************
8396   ID-0248
8397   . ??M-2480
8398   NEO-MVS PROGBK1 / NEO-MVS CHA256
83998399***************************************-->
84008400
84018401   <software name="pbobbl2n">
r31374r31375
84928492      </part>
84938493   </software>
84948494
8495  <!--***************************************
8496 ID-0249
8497 . ??M-2490
8498 NEO-MVS PROGBK1 / NEO-MVS CHA256
8499 NEO-MVS PROGBK1 / NEO-MVS CHA512Y
8495   <!--***************************************
8496   ID-0249
8497   . ??M-2490
8498   NEO-MVS PROGBK1 / NEO-MVS CHA256
8499   NEO-MVS PROGBK1 / NEO-MVS CHA512Y
85008500***************************************-->
85018501
85028502   <software name="ctomaday">
r31374r31375
85358535      </part>
85368536   </software>
85378537
8538  <!--***************************************
8539 ID-0250
8540 . NGM-2500
8541 NEO-MVS PROGEOP / NEO-MVS CHA512Y
8542 . NGH-2500
8543 NEO-AEG PROGEOP (1999.4.2) / NEO-AEG CHA512Y
8538   <!--***************************************
8539   ID-0250
8540   . NGM-2500
8541   NEO-MVS PROGEOP / NEO-MVS CHA512Y
8542   . NGH-2500
8543   NEO-AEG PROGEOP (1999.4.2) / NEO-AEG CHA512Y
85448544***************************************-->
85458545
85468546   <software name="mslugx">
r31374r31375
85908590      </part>
85918591   </software>
85928592
8593  <!--***************************************
8594 ID-0251
8595 . NGM-2510
8596 SMA protected version found on:
8597 NEO-MVS PROGLBA (NEO-SMA) / NEO-MVS CHAFIO (1999.6.14) (NEO-CMC 7042)
8598 Non SMA protected version found on:
8599 NEO-MVS PROGBK1 / NEO-MVS CHAFIO (1999.6.14) (NEO-CMC 7042)
8600 . NGH-2510
8601 NEO-AEG PROGLBA / NEO-AEG CHAFIO (1999.8.10) (NEO-CMC 7042)
8593   <!--***************************************
8594   ID-0251
8595   . NGM-2510
8596   SMA protected version found on:
8597   NEO-MVS PROGLBA (NEO-SMA) / NEO-MVS CHAFIO (1999.6.14) (NEO-CMC 7042)
8598   Non SMA protected version found on:
8599   NEO-MVS PROGBK1 / NEO-MVS CHAFIO (1999.6.14) (NEO-CMC 7042)
8600   . NGH-2510
8601   NEO-AEG PROGLBA / NEO-AEG CHAFIO (1999.8.10) (NEO-CMC 7042)
86028602***************************************-->
86038603
86048604   <software name="kof99">
r31374r31375
88758875      </part>
88768876   </software>
88778877
8878  <!--***************************************
8879 ID-0252
8880 . ??M-2520
8881 NEO-MVS PROGBK1 / NEO-MVS CHAFIO (1999.6.14) (NEO-CMC 7042)
8878   <!--***************************************
8879   ID-0252
8880   . ??M-2520
8881   NEO-MVS PROGBK1 / NEO-MVS CHAFIO (1999.6.14) (NEO-CMC 7042)
88828882***************************************-->
88838883
88848884   <software name="ganryu">
r31374r31375
89138913      </part>
89148914   </software>
89158915
8916  <!--***************************************
8917 ID-0253
8918 . NGM-2530
8919 NEO-MVS PROGLBA (NEO-SMA) (LBA-SUB) / NEO-MVS CHAFIO (1999.6.14) (NEO-CMC 7042)
8920 . NGH-2530
8921 NEO-AEG PROGLBA (NEO-SMA) / NEO-AEG CHAFIO (1999.8.10) (NEO-CMC 7042)
8916   <!--***************************************
8917   ID-0253
8918   . NGM-2530
8919   NEO-MVS PROGLBA (NEO-SMA) (LBA-SUB) / NEO-MVS CHAFIO (1999.6.14) (NEO-CMC 7042)
8920   . NGH-2530
8921   NEO-AEG PROGLBA (NEO-SMA) / NEO-AEG CHAFIO (1999.8.10) (NEO-CMC 7042)
89228922***************************************-->
89238923
89248924   <software name="garou">
r31374r31375
90789078      </part>
90799079   </software>
90809080
9081  <!--***************************************
9082 ID-0254
9083 . ??M-2540
9084 NEO-MVS PROGBK1 / NEO-MVS CHAFIO (1999.6.14) (NEO-CMC 7042)
9081   <!--***************************************
9082   ID-0254
9083   . ??M-2540
9084   NEO-MVS PROGBK1 / NEO-MVS CHAFIO (1999.6.14) (NEO-CMC 7042)
90859085***************************************-->
90869086
90879087   <software name="s1945p">
r31374r31375
91249124      </part>
91259125   </software>
91269126
9127  <!--***************************************
9128 ID-0255
9129 . ??M-2550
9130 NEO-MVS PROGBK1 / NEO-MVS CHAFIO (1999.6.14) (NEO-CMC 7042)
9127   <!--***************************************
9128   ID-0255
9129   . ??M-2550
9130   NEO-MVS PROGBK1 / NEO-MVS CHAFIO (1999.6.14) (NEO-CMC 7042)
91319131***************************************-->
91329132
91339133   <software name="preisle2">
r31374r31375
91679167      </part>
91689168   </software>
91699169
9170  <!--***************************************
9171 ID-0256
9172 . NGM-2560
9173 SMA protected version found on:
9174 NEO-MVS PROGLBA (NEO-SMA)(LBA-SUB) / NEO-MVS CHAFIO (1999.6.14) (NEO-CMC 7042)
9175 Non SMA protected version found on:
9176 NEO-MVS PROGBK1 / NEO-MVS CHAFIO (1999.6.14) (NEO-CMC 7042)
9177 . NGH-2560
9170   <!--***************************************
9171   ID-0256
9172   . NGM-2560
9173   SMA protected version found on:
9174   NEO-MVS PROGLBA (NEO-SMA)(LBA-SUB) / NEO-MVS CHAFIO (1999.6.14) (NEO-CMC 7042)
9175   Non SMA protected version found on:
9176   NEO-MVS PROGBK1 / NEO-MVS CHAFIO (1999.6.14) (NEO-CMC 7042)
9177   . NGH-2560
91789178***************************************-->
91799179
91809180   <software name="mslug3">
r31374r31375
92929292      </part>
92939293   </software>
92949294
9295  <!--***************************************
9296 ID-0257
9297 . NGM-2570
9298 SMA protected version found on:
9299 NEO-MVS PROGLBA (NEO-SMA)(LBA-SUB) / NEO-MVS CHAFIO (1999.6.14) (NEO-CMC 7050)
9300 Non SMA protected version found on:
9301 NEO-MVS PROGBK1 / NEO-MVS CHAFIO (1999.6.14) (NEO-CMC 7050)
9302 . NGH-2570
9303 NEO-AEG PROGLBA (NEO-SMA) / NEO-AEG CHAFIO (1999.8.10) (NEO-CMC 7050)
9295   <!--***************************************
9296   ID-0257
9297   . NGM-2570
9298   SMA protected version found on:
9299   NEO-MVS PROGLBA (NEO-SMA)(LBA-SUB) / NEO-MVS CHAFIO (1999.6.14) (NEO-CMC 7050)
9300   Non SMA protected version found on:
9301   NEO-MVS PROGBK1 / NEO-MVS CHAFIO (1999.6.14) (NEO-CMC 7050)
9302   . NGH-2570
9303   NEO-AEG PROGLBA (NEO-SMA) / NEO-AEG CHAFIO (1999.8.10) (NEO-CMC 7050)
93049304***************************************-->
93059305
93069306   <software name="kof2000">
r31374r31375
94169416      </part>
94179417   </software>
94189418
9419  <!--***************************************
9420 ID-0258
9421 SNK vs. Capcom?
9419   <!--***************************************
9420   ID-0258
9421   SNK vs. Capcom?
94229422***************************************-->
94239423
9424  <!--***************************************
9425 ID-0259
9426 . ??M-2590
9427 NEO-MVS PROGBK1 / NEO-MVS CHAFIO (1999.6.14) (NEO-CMC 7042)
9424   <!--***************************************
9425   ID-0259
9426   . ??M-2590
9427   NEO-MVS PROGBK1 / NEO-MVS CHAFIO (1999.6.14) (NEO-CMC 7042)
94289428***************************************-->
94299429
94309430   <software name="bangbead">
r31374r31375
94619461   </software>
94629462
94639463
9464  <!--***************************************
9465 ID-0260
9466 . ??M-2600
9467 NEO-MVS PROGBK1 / NEO-MVS CHAFIO (1999.6.14) (NEO-CMC 7042)
9464   <!--***************************************
9465   ID-0260
9466   . ??M-2600
9467   NEO-MVS PROGBK1 / NEO-MVS CHAFIO (1999.6.14) (NEO-CMC 7042)
94689468***************************************-->
94699469
94709470   <software name="nitd">
r31374r31375
94989498      </part>
94999499   </software>
95009500
9501  <!--***************************************
9502 ID-0261
9503 . NGM-2610
9504 NEO-MVS PROGBK1 / NEO-MVS CHAFIO (1999.6.14) (NEO-CMC 7042)
9505 . NGH-2610
9501   <!--***************************************
9502   ID-0261
9503   . NGM-2610
9504   NEO-MVS PROGBK1 / NEO-MVS CHAFIO (1999.6.14) (NEO-CMC 7042)
9505   . NGH-2610
95069506***************************************-->
95079507
95089508   <software name="sengoku3">
r31374r31375
95509550      </part>
95519551   </software>
95529552
9553  <!--***************************************
9554 ID-0262
9555 . NGM-262?
9556 MVS PROGBK2 REV1.0 (NEO-PCM2 SNK)/ MVS CHAFIO REV1.0 (NEO-CMC 7050)
9557 . NGH-2621
9558 NEO-AEG PROGBK1F / NEO-AEG CHAFIO (1999.8.10) (NEO-CMC 7050)
9559  - Distribution by BrezzaSoft
9553   <!--***************************************
9554   ID-0262
9555   . NGM-262?
9556   MVS PROGBK2 REV1.0 (NEO-PCM2 SNK)/ MVS CHAFIO REV1.0 (NEO-CMC 7050)
9557   . NGH-2621
9558   NEO-AEG PROGBK1F / NEO-AEG CHAFIO (1999.8.10) (NEO-CMC 7050)
9559   - Distribution by BrezzaSoft
95609560***************************************-->
95619561
95629562   <software name="kof2001">
r31374r31375
96739673      </part>
96749674   </software>
96759675
9676  <!--***************************************
9677 ID-0263
9678 . NGM-2630
9679 NEO-MVS PROGBK2 (NEO-PCM2 SNK)/ NEO-MVS CHAFIO (NEO-CMC 7050)
9680 . NGH-2630
9681 NEO-AEG PROGBK2 (NEO-PCM2 SNK) / NEO-AEG CHAFIO (1999.8.10) (NEO-CMC 7050)
9676   <!--***************************************
9677   ID-0263
9678   . NGM-2630
9679   NEO-MVS PROGBK2 (NEO-PCM2 SNK)/ NEO-MVS CHAFIO (NEO-CMC 7050)
9680   . NGH-2630
9681   NEO-AEG PROGBK2 (NEO-PCM2 SNK) / NEO-AEG CHAFIO (1999.8.10) (NEO-CMC 7050)
96829682***************************************-->
96839683
96849684   <software name="mslug4">
r31374r31375
97829782      </part>
97839783   </software>
97849784
9785  <!--***************************************
9786 ID-0264
9787 . NGM-264?
9788 NEO-MVS PROGBK2 (NEO-PCM2 SNK) / NEO-MVS CHAFIO (1999.6.14) (NEO-CMC 7050)
9789 . NGH-2641
9790 NEO-AEG PROGBK2 (NEO-PCM2 SNK) / NEO-AEG CHAFIO (1999.8.10) (NEO-CMC 7050)
9791  - Distribution by BrezzaSoft
9785   <!--***************************************
9786   ID-0264
9787   . NGM-264?
9788   NEO-MVS PROGBK2 (NEO-PCM2 SNK) / NEO-MVS CHAFIO (1999.6.14) (NEO-CMC 7050)
9789   . NGH-2641
9790   NEO-AEG PROGBK2 (NEO-PCM2 SNK) / NEO-AEG CHAFIO (1999.8.10) (NEO-CMC 7050)
9791   - Distribution by BrezzaSoft
97929792***************************************-->
97939793
97949794   <software name="rotd">
r31374r31375
98439843      </part>
98449844   </software>
98459845
9846  <!--***************************************
9847 ID-0265
9848 . NGM-2650
9849 NEO-MVS PROGBK2 (NEO-PCM2 PLAYMORE) / NEO-MVS CHAFIO (1999.6.14) (NEO-CMC 7050)
9850 . NGH-2650
9851 NEO-AEG PROGBK2 (NEO-PCM2 PLAYMORE) / NEO-AEG CHAFIO (1999.8.10) (NEO-CMC 7050)
9846   <!--***************************************
9847   ID-0265
9848   . NGM-2650
9849   NEO-MVS PROGBK2 (NEO-PCM2 PLAYMORE) / NEO-MVS CHAFIO (1999.6.14) (NEO-CMC 7050)
9850   . NGH-2650
9851   NEO-AEG PROGBK2 (NEO-PCM2 PLAYMORE) / NEO-AEG CHAFIO (1999.8.10) (NEO-CMC 7050)
98529852***************************************-->
98539853
98549854   <software name="kof2002">
r31374r31375
99059905      </part>
99069906   </software>
99079907
9908  <!--***************************************
9909 ID-0266
9910 . NGM-2660
9911 NEO-MVS PROGBK2 (NEO-PCM2 PLAYMORE) / NEO-MVS CHAFIO (1999.6.14) (NEO-CMC 7050)
9912 . NGH-2660
9913 NEO-AEG PROGBK2 (NEO-PCM2 PLAYMORE) / NEO-AEG CHAFIO (1999.8.10) (NEO-CMC 7050)
9908   <!--***************************************
9909   ID-0266
9910   . NGM-2660
9911   NEO-MVS PROGBK2 (NEO-PCM2 PLAYMORE) / NEO-MVS CHAFIO (1999.6.14) (NEO-CMC 7050)
9912   . NGH-2660
9913   NEO-AEG PROGBK2 (NEO-PCM2 PLAYMORE) / NEO-AEG CHAFIO (1999.8.10) (NEO-CMC 7050)
99149914***************************************-->
99159915
99169916   <software name="matrim">
r31374r31375
99679967      </part>
99689968   </software>
99699969
9970  <!--***************************************
9971 ID-0267
9972 . ??M-2670
9973 NEO-MVS PROGBK2 (NEO-PCM2 SNK) / NEO-MVS CHAFIO (1999.6.14) (NEO-CMC 7050)
9970   <!--***************************************
9971   ID-0267
9972   . ??M-2670
9973   NEO-MVS PROGBK2 (NEO-PCM2 SNK) / NEO-MVS CHAFIO (1999.6.14) (NEO-CMC 7050)
99749974***************************************-->
99759975
99769976   <software name="pnyaa">
r31374r31375
1001110011      </part>
1001210012   </software>
1001310013
10014  <!--***************************************
10015 ID-0268
10016 . NGM-2680
10017 NEO-MVS PROGBK3S (NEO-PCM2 PLAYMORE) (NEO-PVC) / NEO-MVS CHAFIO (2003.7.24) (NEO-CMC 7050)
10018 . NGH-2680
10014   <!--***************************************
10015   ID-0268
10016   . NGM-2680
10017   NEO-MVS PROGBK3S (NEO-PCM2 PLAYMORE) (NEO-PVC) / NEO-MVS CHAFIO (2003.7.24) (NEO-CMC 7050)
10018   . NGH-2680
1001910019***************************************-->
1002010020
1002110021   <software name="mslug5">
r31374r31375
1012410124      </part>
1012510125   </software>
1012610126
10127  <!--***************************************
10128 ID-0269
10129 . NGM-2690
10130 NEO-MVS PROGBK3R (NEO-PCM2 PLAYMORE) (NEO-PVC) / NEO-MVS CHAFIO (2003.7.24) (NEO-CMC 7050)
10131 . NGH-2690
10132 NEO-AEG PROGBK3R (NEO-PCM2 PLAYMORE) (NEO-PVC) / NEO-AEG CHAFIO (2003.7.24) (NEO-CMC 7050)
10127   <!--***************************************
10128   ID-0269
10129   . NGM-2690
10130   NEO-MVS PROGBK3R (NEO-PCM2 PLAYMORE) (NEO-PVC) / NEO-MVS CHAFIO (2003.7.24) (NEO-CMC 7050)
10131   . NGH-2690
10132   NEO-AEG PROGBK3R (NEO-PCM2 PLAYMORE) (NEO-PVC) / NEO-AEG CHAFIO (2003.7.24) (NEO-CMC 7050)
1013310133***************************************-->
1013410134
1013510135   <software name="svc">
r31374r31375
1018610186      </part>
1018710187   </software>
1018810188
10189  <!--***************************************
10190 ID-0270
10191 . NGM-2700
10192 NEO-MVS PROGBK2R (NEO-PCM2 PLAYMORE) / NEO-MVS CHAFIO (2003.7.24) (NEO-CMC 7050)
10193 . NGH-2700
10194 NEO-AEG PROGBK2S (NEO-PCM2 PLAYMORE) / NEO-AEG CHAFIO (2003.7.24) (NEO-CMC 7050)
10189   <!--***************************************
10190   ID-0270
10191   . NGM-2700
10192   NEO-MVS PROGBK2R (NEO-PCM2 PLAYMORE) / NEO-MVS CHAFIO (2003.7.24) (NEO-CMC 7050)
10193   . NGH-2700
10194   NEO-AEG PROGBK2S (NEO-PCM2 PLAYMORE) / NEO-AEG CHAFIO (2003.7.24) (NEO-CMC 7050)
1019510195***************************************-->
1019610196
1019710197   <software name="samsho5">
r31374r31375
1030310303      </part>
1030410304   </software>
1030510305
10306  <!--***************************************
10307 ID-0271
10308 . NGM-2710
10309 NEO-MVS PROGBK3S (NEO-PCM2 PLAYMORE) (NEO-PVC) / NEO-MVS CHAFIO (2003.7.24) (NEO-CMC 7050)
10310 . NGH-2710
10311 NEO-AEG PROGBK3S (NEO-PCM2 PLAYMORE) (NEO-PVC) / NEO-AEG CHAFIO (2003.7.24) (NEO-CMC 7050)
10306   <!--***************************************
10307   ID-0271
10308   . NGM-2710
10309   NEO-MVS PROGBK3S (NEO-PCM2 PLAYMORE) (NEO-PVC) / NEO-MVS CHAFIO (2003.7.24) (NEO-CMC 7050)
10310   . NGH-2710
10311   NEO-AEG PROGBK3S (NEO-PCM2 PLAYMORE) (NEO-PVC) / NEO-AEG CHAFIO (2003.7.24) (NEO-CMC 7050)
1031210312***************************************-->
1031310313
1031410314   <software name="kof2003">
r31374r31375
1042410424      </part>
1042510425   </software>
1042610426
10427  <!--***************************************
10428 ID-0272
10429 . NGM-2720
10430 NEO-MVS PROGBK2S (NEO-PCM2 PLAYMORE) / NEO-MVS CHAFIO (2003.7.24) (NEO-CMC 7050)
10431 . NGH-2720
10427   <!--***************************************
10428   ID-0272
10429   . NGM-2720
10430   NEO-MVS PROGBK2S (NEO-PCM2 PLAYMORE) / NEO-MVS CHAFIO (2003.7.24) (NEO-CMC 7050)
10431   . NGH-2720
1043210432***************************************-->
1043310433
1043410434   <software name="samsh5sp">
r31374r31375
1056210562      <!-- BrezzaSoft games, licensed? -->
1056310563
1056410564
10565  <!--***************************************
10566 B-J-02
10567 . ???-????
10568 MVS PROGV (2000.11.17) / NEO-MVS CHAFIO (1999.6.14)
10565   <!--***************************************
10566   B-J-02
10567   . ???-????
10568   MVS PROGV (2000.11.17) / NEO-MVS CHAFIO (1999.6.14)
1056910569***************************************-->
1057010570
1057110571      <!-- jockeygp requires very specific hardware and is loaded in neodrvr.c -->
1057210572
10573  <!--***************************************
10574 B-V-01
10575 . ???-????
10576 MVS PROGV (2000.11.17) / MVS CHAV (2000.10.26)
10573   <!--***************************************
10574   B-V-01
10575   . ???-????
10576   MVS PROGV (2000.11.17) / MVS CHAV (2000.10.26)
1057710577***************************************-->
1057810578
1057910579      <!-- vliner requires very specific hardware and is loaded in neodrvr.c -->
r31374r31375
1058210582      <!-- Jamma PCB sets -->
1058310583
1058410584
10585  <!--***************************************
10586 ID-2680
10587 . MV-0 ????
10588 NEO-MVH MVOBR 2003.8.4
10585   <!--***************************************
10586   ID-2680
10587   . MV-0 ????
10588   NEO-MVH MVOBR 2003.8.4
1058910589***************************************-->
1059010590
1059110591      <!-- ms5pcb is not an MVS cart and is loaded in neodrvr.c -->
1059210592
10593  <!--***************************************
10594 ID-2690
10595 . MV-0 ????
10596 NEO-MVH MVO 2003.6.5
10593   <!--***************************************
10594   ID-2690
10595   . MV-0 ????
10596   NEO-MVH MVO 2003.6.5
1059710597***************************************-->
1059810598
1059910599      <!-- svcpcb is not an MVS cart and is loaded in neodrvr.c -->
1060010600
10601  <!--***************************************
10602 ID-2690
10603 . MV-0 ????
10604 NEO-MVH MVOB 2003.7.9
10601   <!--***************************************
10602   ID-2690
10603   . MV-0 ????
10604   NEO-MVH MVOB 2003.7.9
1060510605***************************************-->
1060610606
1060710607      <!-- svcpcba is not an MVS cart and is loaded in neodrvr.c -->
1060810608
10609  <!--***************************************
10610 ID-2710
10611 . MV-0 ????
10612 NEO-MVH MVOC 2003.11.3
10609   <!--***************************************
10610   ID-2710
10611   . MV-0 ????
10612   NEO-MVH MVOC 2003.11.3
1061310613***************************************-->
1061410614
1061510615      <!-- kof2003pcb is not an MVS cart and is loaded in neodrvr.c -->
r31374r31375
1061910619
1062010620      <!-- Bootleg sets -->
1062110621
10622  <!--
10622   <!--
1062310623   About supported sets:
1062410624
1062510625   For many bootleg sets, only P's (program rom), M1 (sound driver) and S1 (text layer) roms were dumped.
r31374r31375
1063110631
1063210632      <!-- Zintrick bootleg -->
1063310633
10634  <!-- This Zintrick set appears to be a bootleg made from the CD version, not a genuine
10634   <!-- This Zintrick set appears to be a bootleg made from the CD version, not a genuine
1063510635   prototype the code is based on that of the NeoCD version with some minor patches,
1063610636   for example the ADK SAMPLE TEST text that appears on the screen is actually a hacked
1063710637   PROG LOAD ERROR message. The set is supported in order to distinguish the hacks from
trunk/hash/hp9835a_rom.xml
r31374r31375
22<!DOCTYPE softwarelist SYSTEM "softwarelist.dtd">
33
44<softwarelist name="hp9835a_rom" description="HP 9835A/B Option ROMs">
5   
5
66   <software name="mass">
77      <description>Mass Storage</description>
88      <year>198?</year>
r31374r31375
1616         </dataarea>
1717      </part>
1818   </software>
19   
19
2020   <software name="io">
2121      <description>I/O</description>
2222      <year>198?</year>
r31374r31375
3232         </dataarea>
3333      </part>
3434   </software>
35   
35
3636   <software name="asmexec">
3737      <description>Assembly Execution</description>
3838      <year>198?</year>
r31374r31375
4545         </dataarea>
4646      </part>
4747   </software>
48   
48
4949   <software name="asmdev">
5050      <description>Assembly Language Development &amp; Execution</description>
5151      <year>198?</year>
trunk/hash/cc40_cart.xml
r31374r31375
55
66<!--
77
8   Not included in list:
9   - SS-1000 16KB RAM
10   - SS-2000 8KB RAM, battery backed
11   
12   Also, not sure if these exist, probably canceled:
13   - Business Graphics
14   - Games II
15   - Perspective Drawing
8    Not included in list:
9    - SS-1000 16KB RAM
10    - SS-2000 8KB RAM, battery backed
1611
12    Also, not sure if these exist, probably canceled:
13    - Business Graphics
14    - Games II
15    - Perspective Drawing
16
1717-->
1818
1919   <software name="aee">
trunk/hash/tandy2k.xml
r31374r31375
44
55   <!--
66
7      Undumped and most wanted:
7       Undumped and most wanted:
88
9      #700-2611   Driver disk for Windows 1.03
9       #700-2611   Driver disk for Windows 1.03
1010
1111   -->
1212
trunk/hash/hp9845b_rom.xml
r31374r31375
22<!DOCTYPE softwarelist SYSTEM "softwarelist.dtd">
33
44<softwarelist name="hp9845b_rom" description="HP 9845B/T/C Option ROMs">
5   
5
66   <software name="mass">
77      <description>Mass Storage (Rev B)</description>
88      <year>198?</year>
r31374r31375
1616         </dataarea>
1717      </part>
1818   </software>
19   
19
2020   <software name="massc" cloneof="mass">
2121      <description>Mass Storage (Rev C)</description>
2222      <year>198?</year>
r31374r31375
3030         </dataarea>
3131      </part>
3232   </software>
33   
33
3434   <software name="massd" cloneof="mass">
3535      <description>Mass Storage (Rev D)</description>
3636      <year>198?</year>
r31374r31375
4545         </dataarea>
4646      </part>
4747   </software>
48   
48
4949   <software name="graphics">
5050      <description>Graphics</description>
5151      <year>198?</year>
r31374r31375
5959         </dataarea>
6060      </part>
6161   </software>
62   
62
6363   <software name="iolpu">
6464      <description>I/O LPU (Rev A)</description>
6565      <year>198?</year>
r31374r31375
7373         </dataarea>
7474      </part>
7575   </software>
76   
76
7777   <software name="iolpub" cloneof="iolpu">
7878      <description>I/O LPU (Rev B)</description>
7979      <year>198?</year>
r31374r31375
8787         </dataarea>
8888      </part>
8989   </software>
90   
90
9191   <software name="ioppu">
9292      <description>I/O PPU (Rev B)</description>
9393      <year>198?</year>
r31374r31375
101101         </dataarea>
102102      </part>
103103   </software>
104   
104
105105   <software name="ioppuc" cloneof="ioppu">
106106      <description>I/O PPU (Rev C)</description>
107107      <year>198?</year>
r31374r31375
115115         </dataarea>
116116      </part>
117117   </software>
118   
118
119119   <software name="advprog">
120120      <description>Advanced Programming</description>
121121      <year>198?</year>
r31374r31375
128128         </dataarea>
129129      </part>
130130   </software>
131   
131
132132   <software name="asmexec">
133133      <description>Assembly Execution</description>
134134      <year>198?</year>
r31374r31375
142142         </dataarea>
143143      </part>
144144   </software>
145   
145
146146   <software name="asmdev">
147147      <description>Assembly Development &amp; Execution</description>
148148      <year>198?</year>
r31374r31375
158158         </dataarea>
159159      </part>
160160   </software>
161   
161
162162   <software name="image45">
163163      <description>IMAGE/45 Database Manager (Rev B)</description>
164164      <year>198?</year>
r31374r31375
178178         </dataarea>
179179      </part>
180180   </software>
181   
181
182182   <software name="image45c" cloneof="image45">
183183      <description>IMAGE/45 Database Manager (Rev C)</description>
184184      <year>198?</year>
r31374r31375
198198         </dataarea>
199199      </part>
200200   </software>
201   
201
202202   <software name="strucprg">
203203      <description>Structured Programming</description>
204204      <year>198?</year>
r31374r31375
211211         </dataarea>
212212      </part>
213213   </software>
214   
214
215215   <software name="resmgmt">
216216      <description>Resource Management</description>
217217      <year>198?</year>
r31374r31375
229229         </dataarea>
230230      </part>
231231   </software>
232   
232
233233   <software name="test">
234234      <description>Test ROM</description>
235235      <year>198?</year>
r31374r31375
243243         </dataarea>
244244      </part>
245245   </software>
246   
246
247247   <software name="datacomm">
248248      <description>BASIC Datacomm</description>
249249      <year>198?</year>
r31374r31375
259259         </dataarea>
260260      </part>
261261   </software>
262   
262
263263   <software name="bisync">
264264      <description>RJE Bisync</description>
265265      <year>198?</year>
r31374r31375
273273         </dataarea>
274274      </part>
275275   </software>
276   
276
277277   <software name="colorgfx">
278278      <description>Color Graphics</description>
279279      <year>198?</year>
r31374r31375
289289         </dataarea>
290290      </part>
291291   </software>
292   
292
293293   <software name="enhgfx">
294294      <description>Enhanced Graphics (Rev A)</description>
295295      <year>198?</year>
r31374r31375
306306         </dataarea>
307307      </part>
308308   </software>
309   
309
310310   <software name="enhgfxb" cloneof="enhgfx">
311311      <description>Enhanced Graphics (Rev B)</description>
312312      <year>198?</year>
trunk/hash/nes.xml
r31374r31375
84288428         <feature name="mmc1_type" value="MMC1B2" />
84298429         <feature name="pcb_model" value="HVC-SXROM-01" />
84308430         <feature name="u1" value="U1 PRG-ROM" />
8431         <feature name="u2" value="U2 CHR-RAM" />   <!-- LH5168FB-10L -->
8431         <feature name="u2" value="U2 CHR-RAM" />    <!-- LH5168FB-10L -->
84328432         <feature name="u3" value="U3 MMC1" />
8433         <feature name="u4" value="U4 W-RAM" />   <!-- LH52A256-10LL -->
8434         <feature name="u5" value="U5 HCU04" />   <!-- 74HCU04AP -->
8433         <feature name="u4" value="U4 W-RAM" />  <!-- LH52A256-10LL -->
8434         <feature name="u5" value="U5 HCU04" />  <!-- 74HCU04AP -->
84358435         <dataarea name="prg" size="131072">
84368436            <rom name="ath-87-0 prg.u1" size="131072" crc="d1e50064" sha1="bd442a386741ee63c0dcbbd46b3f53fb60a6d45d" offset="00000" />
84378437         </dataarea>
trunk/src/mame/layout/fireball.lay
r31374r31375
99         <color red="1.0" green="0.25" blue="0.0" />
1010      </led7seg>
1111   </element>
12   
12
1313   <element name="red_led">
1414      <rect>
1515         <color red="1.0" green="0.0" blue="0.0" />
r31374r31375
2222         <color red="0.0" green="0.0" blue="0.0" />
2323      </rect>
2424   </element>
25   
25
2626   <element name="P0"><text string="Score"><color red="1.0" green="1.0" blue="1.0" /></text></element>
2727   <element name="P1"><text string="Ball"><color red="1.0" green="1.0" blue="1.0" /></text></element>
2828   <element name="P2"><text string="On board"><color red="1.0" green="1.0" blue="1.0" /></text></element>
r31374r31375
3838   <element name="P11"><text string="Shot Valve"><color red="1.0" green="1.0" blue="1.0" /></text></element>
3939   <element name="P12"><text string="Feed Back Valve"><color red="1.0" green="1.0" blue="1.0" /></text></element>
4040   <element name="P13"><text string="Return Valve"><color red="1.0" green="1.0" blue="1.0" /></text></element>
41   
42   
41
42
4343   <view name="Default Layout">
4444
4545      <!-- Background -->
r31374r31375
7575      <bezel name="digit7" element="digit">
7676         <bounds left="330" top="65" right="350" bottom="84" />
7777      </bezel>
78     
78
7979      <!-- Game Lamp -->
8080      <bezel name="Hopper1" element="red_led">
8181         <bounds x="10" y="110" width="30" height="5" />
8282      </bezel>
83     
83
8484      <bezel name="Hopper2" element="red_led">
8585         <bounds x="50" y="110" width="30" height="5" />
8686      </bezel>
87     
87
8888      <bezel name="Hopper3" element="red_led">
8989         <bounds x="90" y="110" width="30" height="5" />
90      </bezel>   
90      </bezel>
9191
9292      <bezel name="Title" element="red_led">
9393         <bounds x="10" y="140" width="30" height="5" />
94      </bezel>     
94      </bezel>
9595
9696      <bezel name="GameOver" element="red_led">
9797         <bounds x="50" y="140" width="30" height="5" />
9898      </bezel>
99     
99
100100      <bezel name="Credit" element="red_led">
101101         <bounds x="90" y="140" width="30" height="5" />
102      </bezel>   
103     
102      </bezel>
103
104104      <bezel name="SS" element="red_led">
105105         <bounds x="130" y="140" width="30" height="5" />
106      </bezel>         
107     
106      </bezel>
107
108108      <bezel name="C_LOCK" element="red_led">
109109         <bounds x="170" y="140" width="30" height="5" />
110      </bezel>         
111     
110      </bezel>
111
112112      <bezel name="SV" element="red_led">
113113         <bounds x="210" y="140" width="30" height="5" />
114114      </bezel>
115     
115
116116      <bezel name="FBV" element="red_led">
117117         <bounds x="250" y="140" width="30" height="5" />
118118      </bezel>
119     
119
120120      <bezel name="RV" element="red_led">
121121         <bounds x="290" y="140" width="30" height="5" />
122122      </bezel>
123     
123
124124      <bezel element="P0"><bounds left="71" right="115" top="30" bottom="42" /></bezel>
125125      <bezel element="P1"><bounds left="247" right="288" top="30" bottom="42" /></bezel>
126126      <bezel element="P2"><bounds left="330" right="350" top="50" bottom="62" /></bezel>
r31374r31375
131131
132132      <bezel element="P6"><bounds left="10" right="40" top="120" bottom="134" /></bezel>
133133      <bezel element="P7"><bounds left="50" right="80" top="120" bottom="134" /></bezel>
134      <bezel element="P8"><bounds left="90" right="120" top="120" bottom="134" /></bezel>     
135      <bezel element="P9"><bounds left="130" right="160" top="120" bottom="134" /></bezel>   
136     
134      <bezel element="P8"><bounds left="90" right="120" top="120" bottom="134" /></bezel>
135      <bezel element="P9"><bounds left="130" right="160" top="120" bottom="134" /></bezel>
136
137137      <bezel element="P10"><bounds left="170" right="200" top="120" bottom="134" /></bezel>
138138      <bezel element="P11"><bounds left="210" right="240" top="120" bottom="134" /></bezel>
139      <bezel element="P12"><bounds left="250" right="280" top="120" bottom="134" /></bezel>     
139      <bezel element="P12"><bounds left="250" right="280" top="120" bottom="134" /></bezel>
140140      <bezel element="P13"><bounds left="290" right="320" top="120" bottom="134" /></bezel>
141     
141
142142   </view>
143143</mamelayout>
trunk/src/mame/layout/kenseim.lay
r31374r31375
2020      </rect>
2121   </element>
2222
23    <element name="startbutton" defstate="0">
23   <element name="startbutton" defstate="0">
2424      <disk state = "0">
2525         <color red="0.7" green="0.7" blue="0.7" />
2626      </disk>
2727      <disk state = "1">
2828         <color red="1.0" green="1.0" blue="1.0" />
2929      </disk>
30   </element>
30   </element>
3131
3232   <element name="text_level_l">
3333      <rect><color red="0" green="0.13333" blue="0.86666" /></rect>
r31374r31375
5050      <text string="Start"><color red="0.3" green="0.3" blue="0.3" /></text>
5151   </element>
5252
53    <element name="mole_sim_red" defstate="0">
53   <element name="mole_sim_red" defstate="0">
5454      <disk state = "0"><color blue="0.05" green="0.05" red="0.20" /></disk>
5555      <disk state = "1"><color blue="0.05" green="0.05" red="0.21" /></disk>
5656      <disk state = "2"><color blue="0.05" green="0.05" red="0.22" /></disk>
r31374r31375
6161      <disk state = "7"><color blue="0.05" green="0.05" red="0.27" /></disk>
6262      <disk state = "8"><color blue="0.05" green="0.05" red="0.28" /></disk>
6363      <disk state = "9"><color blue="0.05" green="0.05" red="0.29" /></disk>
64       <disk state ="10"><color blue="0.05" green="0.05" red="0.30" /></disk>
64      <disk state ="10"><color blue="0.05" green="0.05" red="0.30" /></disk>
6565      <disk state ="11"><color blue="0.05" green="0.05" red="0.31" /></disk>
6666      <disk state ="12"><color blue="0.05" green="0.05" red="0.32" /></disk>
6767      <disk state ="13"><color blue="0.05" green="0.05" red="0.33" /></disk>
r31374r31375
7171      <disk state ="17"><color blue="0.05" green="0.05" red="0.37" /></disk>
7272      <disk state ="18"><color blue="0.05" green="0.05" red="0.38" /></disk>
7373      <disk state ="19"><color blue="0.05" green="0.05" red="0.39" /></disk>
74       <disk state ="20"><color blue="0.05" green="0.05" red="0.40" /></disk>
74      <disk state ="20"><color blue="0.05" green="0.05" red="0.40" /></disk>
7575      <disk state ="21"><color blue="0.05" green="0.05" red="0.41" /></disk>
7676      <disk state ="22"><color blue="0.05" green="0.05" red="0.42" /></disk>
7777      <disk state ="23"><color blue="0.05" green="0.05" red="0.43" /></disk>
r31374r31375
8181      <disk state ="27"><color blue="0.06" green="0.06" red="0.47" /></disk>
8282      <disk state ="28"><color blue="0.07" green="0.07" red="0.48" /></disk>
8383      <disk state ="29"><color blue="0.07" green="0.07" red="0.49" /></disk>
84       <disk state ="30"><color blue="0.07" green="0.07" red="0.50" /></disk>
84      <disk state ="30"><color blue="0.07" green="0.07" red="0.50" /></disk>
8585      <disk state ="31"><color blue="0.07" green="0.07" red="0.51" /></disk>
8686      <disk state ="32"><color blue="0.08" green="0.08" red="0.52" /></disk>
8787      <disk state ="33"><color blue="0.08" green="0.08" red="0.53" /></disk>
r31374r31375
9191      <disk state ="37"><color blue="0.09" green="0.09" red="0.57" /></disk>
9292      <disk state ="38"><color blue="0.09" green="0.09" red="0.58" /></disk>
9393      <disk state ="39"><color blue="0.09" green="0.09" red="0.59" /></disk>
94       <disk state ="40"><color blue="0.10" green="0.10" red="0.60" /></disk>
94      <disk state ="40"><color blue="0.10" green="0.10" red="0.60" /></disk>
9595      <disk state ="41"><color blue="0.10" green="0.10" red="0.61" /></disk>
9696      <disk state ="42"><color blue="0.10" green="0.10" red="0.62" /></disk>
9797      <disk state ="43"><color blue="0.10" green="0.10" red="0.63" /></disk>
r31374r31375
121121      <disk state ="67"><color blue="0.16" green="0.16" red="0.87" /></disk>
122122      <disk state ="68"><color blue="0.17" green="0.17" red="0.88" /></disk>
123123      <disk state ="69"><color blue="0.17" green="0.17" red="0.89" /></disk>
124       <disk state ="70"><color blue="0.17" green="0.17" red="0.90" /></disk>
124      <disk state ="70"><color blue="0.17" green="0.17" red="0.90" /></disk>
125125      <disk state ="71"><color blue="0.17" green="0.17" red="0.91" /></disk>
126126      <disk state ="72"><color blue="0.18" green="0.18" red="0.92" /></disk>
127127      <disk state ="73"><color blue="0.18" green="0.18" red="0.93" /></disk>
r31374r31375
131131      <disk state ="77"><color blue="0.19" green="0.19" red="0.97" /></disk>
132132      <disk state ="78"><color blue="0.19" green="0.19" red="0.98" /></disk>
133133      <disk state ="79"><color blue="0.19" green="0.19" red="0.99" /></disk>
134      <disk state ="80"><color blue="0.20" green="0.20" red="1.00" /></disk>
134      <disk state ="80"><color blue="0.20" green="0.20" red="1.00" /></disk>
135135   </element>
136136
137    <element name="mole_sim_blu" defstate="0">
137   <element name="mole_sim_blu" defstate="0">
138138      <disk state = "0"><color red="0.05" green="0.05" blue="0.20" /></disk>
139139      <disk state = "1"><color red="0.05" green="0.05" blue="0.21" /></disk>
140140      <disk state = "2"><color red="0.05" green="0.05" blue="0.22" /></disk>
r31374r31375
145145      <disk state = "7"><color red="0.05" green="0.05" blue="0.27" /></disk>
146146      <disk state = "8"><color red="0.05" green="0.05" blue="0.28" /></disk>
147147      <disk state = "9"><color red="0.05" green="0.05" blue="0.29" /></disk>
148       <disk state ="10"><color red="0.05" green="0.05" blue="0.30" /></disk>
148      <disk state ="10"><color red="0.05" green="0.05" blue="0.30" /></disk>
149149      <disk state ="11"><color red="0.05" green="0.05" blue="0.31" /></disk>
150150      <disk state ="12"><color red="0.05" green="0.05" blue="0.32" /></disk>
151151      <disk state ="13"><color red="0.05" green="0.05" blue="0.33" /></disk>
r31374r31375
155155      <disk state ="17"><color red="0.05" green="0.05" blue="0.37" /></disk>
156156      <disk state ="18"><color red="0.05" green="0.05" blue="0.38" /></disk>
157157      <disk state ="19"><color red="0.05" green="0.05" blue="0.39" /></disk>
158       <disk state ="20"><color red="0.05" green="0.05" blue="0.40" /></disk>
158      <disk state ="20"><color red="0.05" green="0.05" blue="0.40" /></disk>
159159      <disk state ="21"><color red="0.05" green="0.05" blue="0.41" /></disk>
160160      <disk state ="22"><color red="0.05" green="0.05" blue="0.42" /></disk>
161161      <disk state ="23"><color red="0.05" green="0.05" blue="0.43" /></disk>
r31374r31375
165165      <disk state ="27"><color red="0.06" green="0.06" blue="0.47" /></disk>
166166      <disk state ="28"><color red="0.07" green="0.07" blue="0.48" /></disk>
167167      <disk state ="29"><color red="0.07" green="0.07" blue="0.49" /></disk>
168       <disk state ="30"><color red="0.07" green="0.07" blue="0.50" /></disk>
168      <disk state ="30"><color red="0.07" green="0.07" blue="0.50" /></disk>
169169      <disk state ="31"><color red="0.07" green="0.07" blue="0.51" /></disk>
170170      <disk state ="32"><color red="0.08" green="0.08" blue="0.52" /></disk>
171171      <disk state ="33"><color red="0.08" green="0.08" blue="0.53" /></disk>
r31374r31375
175175      <disk state ="37"><color red="0.09" green="0.09" blue="0.57" /></disk>
176176      <disk state ="38"><color red="0.09" green="0.09" blue="0.58" /></disk>
177177      <disk state ="39"><color red="0.09" green="0.09" blue="0.59" /></disk>
178       <disk state ="40"><color red="0.10" green="0.10" blue="0.60" /></disk>
178      <disk state ="40"><color red="0.10" green="0.10" blue="0.60" /></disk>
179179      <disk state ="41"><color red="0.10" green="0.10" blue="0.61" /></disk>
180180      <disk state ="42"><color red="0.10" green="0.10" blue="0.62" /></disk>
181181      <disk state ="43"><color red="0.10" green="0.10" blue="0.63" /></disk>
r31374r31375
205205      <disk state ="67"><color red="0.16" green="0.16" blue="0.87" /></disk>
206206      <disk state ="68"><color red="0.17" green="0.17" blue="0.88" /></disk>
207207      <disk state ="69"><color red="0.17" green="0.17" blue="0.89" /></disk>
208       <disk state ="70"><color red="0.17" green="0.17" blue="0.90" /></disk>
208      <disk state ="70"><color red="0.17" green="0.17" blue="0.90" /></disk>
209209      <disk state ="71"><color red="0.17" green="0.17" blue="0.91" /></disk>
210210      <disk state ="72"><color red="0.18" green="0.18" blue="0.92" /></disk>
211211      <disk state ="73"><color red="0.18" green="0.18" blue="0.93" /></disk>
r31374r31375
215215      <disk state ="77"><color red="0.19" green="0.19" blue="0.97" /></disk>
216216      <disk state ="78"><color red="0.19" green="0.19" blue="0.98" /></disk>
217217      <disk state ="79"><color red="0.19" green="0.19" blue="0.99" /></disk>
218      <disk state ="80"><color red="0.20" green="0.20" blue="1.00" /></disk>
218      <disk state ="80"><color red="0.20" green="0.20" blue="1.00" /></disk>
219219   </element>
220220
221221
r31374r31375
357357      <bezel element="text_ryu">
358358         <bounds x="118" y="254" width="24" height="6"/>
359359      </bezel>
360       <bezel element="text_start">
360      <bezel element="text_start">
361361         <bounds x="118" y="261" width="24" height="6"/>
362362      </bezel>
363363
r31374r31375
371371      <bezel element="text_chunli">
372372         <bounds x="180" y="254" width="24" height="6"/>
373373      </bezel>
374       <bezel element="text_start">
374      <bezel element="text_start">
375375         <bounds x="180" y="261" width="24" height="6"/>
376      </bezel>
376      </bezel>
377377
378378      <bezel element="disk_black">
379379         <bounds x="163" y="251" width="19" height="19" />
trunk/src/mame/drivers/bfm_sc45_helper.h
r31374r31375
22
33void bfm_sc45_layout_helper(running_machine &machine);
44int find_project_string(running_machine &machine, int addrxor, int mode);
5
trunk/src/mame/mame.lst
r31374r31375
100100mspacmat        // hack
101101msheartb        // hack
102102mspacmanbg      // bootleg
103mspacmanbgd      // bootleg
103mspacmanbgd     // bootleg
104104woodpeck        // (c) 1981 Amenip (Palcom Queen River)
105105woodpeca        // (c) 1981 Amenip Nova Games Ltd.
106106mspacmab        // bootleg
r31374r31375
175175galturbo        // hack
176176swarm           // hack
177177zerotime        // hack
178zerotimed      // hack
178zerotimed       // hack
179179starfght        // hack
180180galaxbsf        // hack
181181galaxianbl      // bootleg
r31374r31375
324324ckongs          // bootleg
325325froggers        // bootleg
326326frogf           // bootleg
327quaak         // bootleg
327quaak           // bootleg
328328amidars         // GX337 (c) 1982 Konami
329329triplep         // (c) 1982 KKI / made by Sanritsu?
330330triplepa        // (c) 1982 KKI / made by Sanritsu?
r31374r31375
701701pleiadsb2       // bootleg
702702pleiadbl        // bootleg
703703pleiadce        // (c) 1981 Centuri + Tehkan
704pleiadsi      // bootleg?
705pleiadss      // bootleg
704pleiadsi        // bootleg?
705pleiadss        // bootleg
706706capitol         // bootleg?
707707survival        // (c) 1982 Rock-ola
708708naughtyb        // (c) 1982 Jaleco
r31374r31375
866866pacmania        // (c) 1987
867867pacmaniaj       // (c) 1987 (Japan)
868868galaga88        // (c) 1987
869galaga88a      // (c) 1987
869galaga88a       // (c) 1987
870870galaga88j       // (c) 1987 (Japan)
871871ws              // (c) 1988 (Japan)
872872berabohm        // (c) 1988 (Japan, Rev C)
r31374r31375
14631463invasionb       // bootleg
14641464invasionrz      // bootleg
14651465invasionrza     // bootleg
1466invadersem      // Electromar
1466invadersem      // Electromar
14671467sstrangr        // (c) 1978 Yachiyo Electronics, Ltd.
14681468sstrangr2       // (c) 1979 Yachiyo Electronics, Ltd.
14691469sinvemag        // Zenitone-Microsec Ltd.
r31374r31375
29942994blktigera       //  8/1987 (c) 1987 (US)
29952995blktigerb1      // bootleg
29962996blktigerb2      // bootleg
2997blktigerb3         // bootleg?
2997blktigerb3          // bootleg?
29982998blkdrgon        //  8/1987 (c) 1987 (Japan)
29992999blkdrgonb       // bootleg, hacked to say Black Tiger
30003000sf              //  8/1987 (c) 1987 (World)
r31374r31375
30873087cawingbl        // bootleg
30883088cawingb2        // bootleg
30893089nemo            // 30/11/1990 (c) 1990 (World)
3090nemor1      // 09/11/1990 (c) 1990 (World)
3090nemor1      // 09/11/1990 (c) 1990 (World)
30913091nemoj           // 20/11/1990 (c) 1990 (Japan)
30923092sf2             // 22/05/1991 (c) 1991 (World)
30933093sf2eb           // 14/02/1991 (c) 1991 (World)
r31374r31375
45524552passsht         // (c) 1988 (FD1094, decrypted)
45534553passshta        // (c) 1988 (FD1094, decrypted)
45544554passshtj        // (c) 1988 (FD1094, decrypted)
4555cencourt      // (c) 1988 (MC-8123B)
4555cencourt        // (c) 1988 (MC-8123B)
45564556riotcity        // (c) 1991 Sega / Westone (Unprotected)
45574557ryukyu          // (c) 1990 (FD1094, decrypted)
45584558sdib            // (c) 1987 (FD1089A, decrypted)
r31374r31375
50775077
50785078// System C-2 games
50795079borench         // (c) 1990 Sega
5080borencha      // (c) 1990 Sega
5080borencha        // (c) 1990 Sega
50815081tfrceac         // (c) 1990 Sega / Technosoft
50825082tfrceacj        // (c) 1990 Sega / Technosoft
50835083tfrceacb        // bootleg
r31374r31375
54015401pokasuka        // 2007.07 Pokasuka Ghost!
54025402sl2007          // 2007.07 Shooting Love
54035403asndynmt        // 2007.07 Dynamite Deka EX - Asian dynamite
5404rhytngk            // 2007.09 Rhythm Tengoku
5404rhytngk         // 2007.09 Rhythm Tengoku
54055405ausfache        // 2008.02 Akatsuki Denkou Senki Ausf.Achse
54065406illvelo         // 2008.06 Illvelo (Illmatic Envelope)
54075407mamonoro        // 2008.07 Mamoru-kun wa Norowarete Shimatta!
r31374r31375
54355435vf4b            // 2001.08.20 Virtua Fighter 4 (Rev B) (cartridge)
54365436vf4c            // 2002.01.31 Virtua Fighter 4 (Rev C) (cartridge)
54375437kingrt66        // 2002.02 The King of Route 66 (Rev A)
5438              // 2002.02.14 Initial D Arcade Stage (Japan)
5438            // 2002.02.14 Initial D Arcade Stage (Japan)
54395439initd           // 2002.03 Initial D Arcade Stage (Japan) (Rev B)
54405440            // 2002.06 World Club Champion Football Serie A 2001-2002
54415441soulsurf        // 2002.07 Soul Surfer
r31374r31375
54515451initdexpo       // 2002.?? Initial D Arcade Stage (Export)
54525452            // 2002.?? Sega Driving Simulator
54535453            // 2003.03 World Club Champion Football Serie A 2001-2002 Ver.2
5454                // 2003.05 Initial D Arcade Stage Ver. 2 (Japan) (Rev A)
5454            // 2003.05 Initial D Arcade Stage Ver. 2 (Japan) (Rev A)
54555455initdv2j        // 2003.05.27 Initial D Arcade Stage Ver. 2 (Japan) (Rev B)
54565456            // 2003.09 World Club Champion Football Serie A 2002-2003
54575457            // 2003.?? Club Kart Cycraft Edition
r31374r31375
55285528triforce        // 2002.?? Triforce BIOS
55295529vs2002ex        // 2002.07.30 Virtua Striker 2002 (Export)
55305530vs2002j         // 2002.10 Virtua Striker 2002 (Japan)
5531fzeroaxc      // 2003.06.11 F-Zero AX (Rev. C)
5531fzeroaxc        // 2003.06.11 F-Zero AX (Rev. C)
55325532avalons         // 2003.07 The Key Of Avalon: The Wizard Master (server) (Rev C)
55335533            // 2003.10 The Key Of Avalon 1.01
55345534gekpurya        // 2003.10 Gekitou Pro Yakyuu Mizushima Shinji All Stars vs. Pro Yakyuu (Rev C)
5535fzeroax         // 2003.12 F-Zero AX (Rev. E)
5535fzeroax         // 2003.12 F-Zero AX (Rev. E)
55365536            // 2003.12 The Key Of Avalon 1.10
55375537            // 2004.04 The Key Of Avalon 1.20 - Summon The New Monsters
55385538avalon13        // 2004.06.08 The Key Of Avalon 1.30 - Chaotic Sabbat (client) (Rev C)
r31374r31375
55445544            // 2005.08 Avalon no Kagi Ver.2.5 Kagi Seisen
55455545mkartagp        // 2005.12 Mario Kart Arcade Grand Prix
55465546            // 2005.?? Donkey Kong Jungle Fever
5547                // 2006.01.31 Virtua Striker 4 Ver.2006 (export)
5547            // 2006.01.31 Virtua Striker 4 Ver.2006 (export)
55485548vs42006         // 2006.05 Virtua Striker 4 Ver.2006 (Japan) (Rev D)
55495549            // 2006.?? Firmware Update For Compact Flash Box (Rev A)
5550mkartag2      // 2007.03 Mario Kart Arcade Grand Prix 2
5551mkartag2a      // 2007.03 Mario Kart Arcade Grand Prix 2
5550mkartag2        // 2007.03 Mario Kart Arcade Grand Prix 2
5551mkartag2a       // 2007.03 Mario Kart Arcade Grand Prix 2
55525552
55535553// Chihiro (X-Box based)
55545554chihiro         // 2002.?? Chihiro BIOS
r31374r31375
55865586            // 2004.12 Sega Network Taisen Mahjong MJ 2 (Rev D)
55875587            // 2005.02 Sega Network Taisen Mahjong MJ 2 (Rev E)
55885588            // 2005.02 Sega Network Taisen Mahjong MJ 2 (Rev F)
5589mj2            // 2005.02.02 Sega Network Taisen Mahjong MJ 2 (Rev G)
5589mj2             // 2005.02.02 Sega Network Taisen Mahjong MJ 2 (Rev G)
55905590            // 2005.03 Sangokushi Taisen
55915591gundamos        // 2005.03 Gundam Battle Operating Simulator
55925592            // 2005.04 Quest of D Ver.1.20
r31374r31375
56295629            // 2008.?? Sangokushi Taisen 3 Ver.J
56305630            // 2008.?? Sangokushi Taisen 3 War Begins
56315631            // 2008.?? Sangokushi Taisen 3 War Begins Ver.3.59
5632                // 2009.03 Firmware Update For Compact Flash Box
5632            // 2009.03 Firmware Update For Compact Flash Box
56335633ccfboxa         // 2009.03.31 Firmware Update For Compact Flash Box (Rev A)
56345634
56355635hshavoc         // (c) 1993 Data East
r31374r31375
58875887cbusterw        // MAB (c) 1990 Data East Corporation (World)
58885888cbusterj        // MAB (c) 1990 Data East Corporation (Japan)
58895889twocrude        // MAB (c) 1990 Data East USA (US)
5890twocrudea      // MAB (c) 1990 Data East USA (US)
5890twocrudea       // MAB (c) 1990 Data East USA (US)
58915891darkseal        // MAC (c) 1990 Data East Corporation (World)
58925892darkseal1       // MAC (c) 1990 Data East Corporation (World)
58935893darksealj       // MAC (c) 1990 Data East Corporation (Japan)
r31374r31375
61066106stratof         // (c) 1991 Tecmo
61076107raiga           // (c) 1991 Tecmo
61086108drgnbowl        // (c) 1992 Nics
6109drgnbowla      // (c) 1992 Nics
6109drgnbowla       // (c) 1992 Nics
61106110wc90            // (c) 1989 Tecmo
61116111wc90a           // (c) 1989 Tecmo
61126112wc90b           // (c) 1989 Tecmo
r31374r31375
76887688skyadvntu       // Alpha-68K96V  'SA' (c) 1989 SNK of America licensed from Alpha
76897689skyadvntj       // Alpha-68K96V  'SA' (c) 1989 Alpha Denshi Co.
76907690gangwars        // Alpha-68K96V       (c) 1989 Alpha Denshi Co.
7691gangwarsj      // Alpha-68K96V       (c) 1989 Alpha Denshi Co.
7691gangwarsj       // Alpha-68K96V       (c) 1989 Alpha Denshi Co.
76927692gangwarsu       // Alpha-68K96V       (c) 1989 Alpha Denshi Co.
7693gangwarsb      // bootleg
7693gangwarsb       // bootleg
76947694sbasebal        // Alpha-68K96V       (c) 1989 SNK of America licensed from Alpha
76957695tnextspc        // A8003 'NS' (c) 1989 - MASKROM
76967696tnextspc2       // A8003 'NS' (c) 1989 - EPROMs
r31374r31375
83418341rdft            // (c) 1996 Seibu Kaihatsu
83428342rdftu           // (c) 1996 Seibu Kaihatsu (Fabtek license)
83438343rdftau          // (c) 1996 Seibu Kaihatsu
8344rdftauge      // (c) 1996 Seibu Kaihatsu (Tuning license and text display, but Australia region code)
8344rdftauge        // (c) 1996 Seibu Kaihatsu (Tuning license and text display, but Australia region code)
83458345rdftj           // (c) 1996 Seibu Kaihatsu
83468346rdftadi         // (c) 1996 Seibu Kaihatsu (Dream Island license)
83478347rdftam          // (c) 1996 Seibu Kaihatsu (Metrotainment license)
r31374r31375
85898589crshrace2       // (c) 1993 Video System Co.
85908590taotaido        // (c) 1993 Video System Co.
85918591taotaidoa       // (c) 1993 Video System Co.
8592taotaido3      // (c) 1993 Video System Co.
8592taotaido3       // (c) 1993 Video System Co.
85938593gstriker        // (c) [1993] Human
85948594gstrikera       // (c) [1993] Human
85958595gstrikerj       // (c) [1993] Human
r31374r31375
86238623// Semicom games on "Psikyo 68020"-like hardware
86248624baryon          // (c) 1997 SemiCom
86258625dreamwld        // (c) 2000 SemiCom
8626rolcrush      // (c) 1999 Trust
8626rolcrush        // (c) 1999 Trust
86278627
86288628// SH2 board
86298629s1945ii         // (c) 1997
r31374r31375
87868786// Kaneko "AX System" games
87878787berlwall        // (c) 1991 Kaneko
87888788berlwallt       // (c) 1991 Kaneko
8789berlwallk      // (c) 1991 Kaneko (Korea, Inter license)
8789berlwallk       // (c) 1991 Kaneko (Korea, Inter license)
87908790mgcrystl        // (c) 1991 Kaneko (World)
87918791mgcrystlo       // (c) 1991 Kaneko (World)
87928792mgcrystlj       // (c) 1991 Kaneko + distributed by Atlus (Japan)
r31374r31375
91179117pollux          // (c) 1991 Dooyong
91189118polluxa         // (c) 1991 Dooyong
91199119polluxa2        // (c) 1991 Dooyong
9120polluxn         // (c) 1991 NTC
9120polluxn         // (c) 1991 NTC
91219121flytiger        // (c) 1992 Dooyong
91229122flytigera       // (c) 1992 Dooyong
91239123bluehawk        // (c) 1993 Dooyong
r31374r31375
93419341grdnstrmv       // (c) 1998 Apples Industries license
93429342grdnstrmk       // (c) 1998 (Korea)
93439343grdnstrmg       // (c) 1998
9344grdnstrmj      // (c) 1998 (Japan)
9344grdnstrmj       // (c) 1998 (Japan)
93459345redfoxwp2       // (c) 1998 (China)
93469346redfoxwp2a      // (c) 1998 (China)
93479347bubl2000        // (c) 1998 Tuning
93489348hotbubl         // (c) 1998 Pandora
93499349popspops        // (c) 1999
93509350firehawk        // (c) 2001 ESD
9351firehawkv      // (c) 2001 ESD
9351firehawkv       // (c) 2001 ESD
93529352mangchi         // (c) 2000
93539353spec2k          // (c) 2000 Yonatech
9354spec2kh         // (c) 2000 Yonatech
9354spec2kh         // (c) 2000 Yonatech
93559355
93569356// ESD games
93579357// http://www.esdgame.co.kr/english/
r31374r31375
96599659kovsh103        //
96609660kovsh102        //
96619661kovsh101        //
9662kovsh100      //
9662kovsh100        //
96639663kovqhsgs        // bootleg
96649664photoy2k        // (c) 1999 Photo Y2k
96659665photoy2k102     //
r31374r31375
2833728337ac1pstrt    // Pound Stretcher (Pcp)
2833828338ac1primt    // Primetime (Ace)
2833928339ac1taklv    // Take It Or Leave It (Ace)
28340ac1cshtw    // Cash Towers (Ace)
28340ac1cshtw    // Cash Towers (Ace)
2834128341ac1bbclb    // Big Break Club (Ace)
2834228342ac1bbclba   //
2834328343ac1clbsv    // Club Sovereign (Ace)
r31374r31375
3168731687
3168831688amusco     // 1987, Amusco.
3168931689cocoloco   // 198?, Petaco S.A.
31690
trunk/src/mame/audio/cage.h
r31374r31375
1919
2020#define MCFG_ATARI_CAGE_SPEEDUP(_speedup) \
2121   atari_cage_device::static_set_speedup(*device, _speedup);
22     
22
2323class atari_cage_device : public device_t
2424{
2525public:
r31374r31375
3232
3333   // optional information overrides
3434   virtual machine_config_constructor device_mconfig_additions() const;
35   
35
3636   void reset_w(int state);
3737
3838   UINT16 main_r();
3939   void main_w(UINT16 data);
4040
4141   UINT16 control_r();
42   void control_w(UINT16 data);   
43   
42   void control_w(UINT16 data);
43
4444   TIMER_DEVICE_CALLBACK_MEMBER( dma_timer_callback );
4545   void update_dma_state(address_space &space);
4646   TIMER_DEVICE_CALLBACK_MEMBER( cage_timer_callback );
r31374r31375
5858
5959protected:
6060   // device-level overrides
61   virtual void device_start();   
62   
61   virtual void device_start();
62
6363private:
6464   cpu_device *m_cpu;
6565   attotime m_cpu_h1_clock_period;
r31374r31375
8585
8686   UINT32 *m_speedup_ram;
8787   dmadac_sound_device *m_dmadac[4];
88   
88
8989   offs_t m_speedup;
9090};
9191
r31374r31375
9898public:
9999   // construction/destruction
100100   atari_cage_seattle_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
101   
101
102102   // optional information overrides
103103   virtual machine_config_constructor device_mconfig_additions() const;
104     
104
105105};
106106
107107// device type definition
trunk/src/mame/audio/taitosnd.h
r31374r31375
3737   DECLARE_WRITE8_MEMBER( slave_port_w );
3838   DECLARE_READ8_MEMBER( slave_comm_r );
3939   DECLARE_WRITE8_MEMBER( slave_comm_w );
40   
40
4141protected:
4242   // device-level overrides
4343   virtual void device_start();
4444   virtual void device_reset();
45   
45
4646private:
4747   void update_nmi();
4848
trunk/src/mame/audio/cps3.h
r31374r31375
3030public:
3131   cps3_sound_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
3232   ~cps3_sound_device() { }
33   
33
3434   void set_base(INT8* base) { m_base = base; }
3535
3636   DECLARE_WRITE32_MEMBER( cps3_sound_w );
trunk/src/mame/audio/dcs.h
r31374r31375
1818#define MCFG_DCS2_AUDIO_POLLING_OFFSET(_polling_offset) \
1919   dcs_audio_device::static_set_polling_offset(*device, _polling_offset);
2020
21   
21
2222class dcs_audio_device : public device_t
2323{
2424public:
r31374r31375
106106   TIMER_CALLBACK_MEMBER( s2_ack_callback );
107107   int preprocess_stage_2(UINT16 data);
108108   int preprocess_write(UINT16 data);
109   
109
110110protected:
111111   // device-level overrides
112112   virtual void device_start();
113113   virtual void device_reset();
114   
114
115115protected:
116116   struct sdrc_state
117117   {
r31374r31375
181181   UINT8       m_last_output_full;
182182   UINT8       m_last_input_empty;
183183   UINT16      m_progflags;
184   
184
185185   write_line_delegate m_output_full_cb;
186186   write_line_delegate m_input_empty_cb;
187   
187
188188   read16_delegate m_fifo_data_r;
189189   read16_delegate m_fifo_status_r;
190190   write_line_delegate m_fifo_reset_w;
r31374r31375
206206   sdrc_state m_sdrc;
207207   dsio_state m_dsio;
208208   hle_transfer_state m_transfer;
209   
209
210210   int m_dram_in_mb;
211211};
212212
r31374r31375
218218public:
219219   // construction/destruction
220220   dcs_audio_2k_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
221   
221
222222   // optional information overrides
223223   virtual machine_config_constructor device_mconfig_additions() const;
224     
224
225225};
226226
227227// device type definition
r31374r31375
234234public:
235235   // construction/destruction
236236   dcs_audio_2k_uart_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
237   
237
238238   // optional information overrides
239239   virtual machine_config_constructor device_mconfig_additions() const;
240     
240
241241};
242242
243243// device type definition
r31374r31375
250250public:
251251   // construction/destruction
252252   dcs_audio_8k_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
253   
253
254254   // optional information overrides
255255   virtual machine_config_constructor device_mconfig_additions() const;
256     
256
257257};
258258
259259// device type definition
r31374r31375
266266public:
267267   // construction/destruction
268268   dcs_audio_wpc_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
269   
269
270270   // optional information overrides
271271   virtual machine_config_constructor device_mconfig_additions() const;
272272};
r31374r31375
285285
286286protected:
287287   // device-level overrides
288   virtual void device_start();   
288   virtual void device_start();
289289};
290290
291291// dcs2_audio_2115_device
r31374r31375
295295public:
296296   // construction/destruction
297297   dcs2_audio_2115_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
298   
298
299299   // optional information overrides
300300   virtual machine_config_constructor device_mconfig_additions() const;
301     
301
302302};
303303
304304// device type definition
r31374r31375
311311public:
312312   // construction/destruction
313313   dcs2_audio_2104_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
314   
314
315315   // optional information overrides
316316   virtual machine_config_constructor device_mconfig_additions() const;
317     
317
318318};
319319
320320// device type definition
r31374r31375
327327public:
328328   // construction/destruction
329329   dcs2_audio_dsio_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
330   
330
331331   // optional information overrides
332332   virtual machine_config_constructor device_mconfig_additions() const;
333     
333
334334};
335335
336336// device type definition
r31374r31375
343343public:
344344   // construction/destruction
345345   dcs2_audio_denver_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
346   
346
347347   // optional information overrides
348348   virtual machine_config_constructor device_mconfig_additions() const;
349     
349
350350};
351351
352352// device type definition
trunk/src/mame/machine/nmk112.h
r31374r31375
2121   static void set_rom0_tag(device_t &device, const char *tag) { downcast<nmk112_device &>(device).m_tag0 = tag; }
2222   static void set_rom1_tag(device_t &device, const char *tag) { downcast<nmk112_device &>(device).m_tag1 = tag; }
2323   static void set_page_mask(device_t &device, UINT8 mask) { downcast<nmk112_device &>(device).m_page_mask = ~mask; }
24   
24
2525   DECLARE_WRITE8_MEMBER( okibank_w );
2626
2727protected:
trunk/src/mame/machine/ng_memcard.h
r31374r31375
2828// ======================> ng_memcard_device
2929
3030class ng_memcard_device :  public device_t,
31                     public device_image_interface
31                     public device_image_interface
3232{
3333public:
3434   // construction/destruction
3535   ng_memcard_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
36   
36
3737   virtual iodevice_t image_type() const { return IO_MEMCARD; }
3838
3939   virtual bool is_readable()  const { return 1; }
r31374r31375
5151   // device-level overrides
5252   virtual void device_start();
5353   virtual void device_config_complete();
54   
54
5555   DECLARE_READ8_MEMBER(read);
56   DECLARE_WRITE8_MEMBER(write);   
56   DECLARE_WRITE8_MEMBER(write);
5757
5858   /* returns the index of the current memory card, or -1 if none */
59   int present() { return is_loaded() ? 0 : -1; }
59   int present() { return is_loaded() ? 0 : -1; }
6060private:
6161   UINT8 m_memcard_data[0x800];
6262};
trunk/src/mame/machine/konppc.h
r31374r31375
2323
2424   static void static_set_num_boards(device_t &device, int num) { downcast<konppc_device &>(device).num_cgboards = num; }
2525   static void static_set_cbboard_type(device_t &device, int cgtype) { downcast<konppc_device &>(device).cgboard_type = cgtype; }
26   
26
2727   void set_cgboard_id(int board_id);
2828   int get_cgboard_id(void);
2929   void set_cgboard_texture_bank(int board, const char *bank, UINT8 *rom);
30   
3130
31
3232   // read/write
3333   DECLARE_READ32_MEMBER( cgboard_dsp_comm_r_ppc );
3434   DECLARE_WRITE32_MEMBER( cgboard_dsp_comm_w_ppc );
r31374r31375
5858protected:
5959   // device-level overrides
6060   virtual void device_start();
61   
61
6262   UINT32 dsp_comm_sharc_r(int board, int offset);
6363   void dsp_comm_sharc_w(address_space &space, int board, int offset, UINT32 data);
6464   UINT32 dsp_shared_ram_r_sharc(int board, int offset);
r31374r31375
6767   UINT32 nwk_fifo_r(address_space &space, int board);
6868   void nwk_fifo_w(int board, UINT32 data);
6969private:
70   // internal state   
70   // internal state
7171   UINT32 dsp_comm_ppc[MAX_CG_BOARDS][2];
7272   UINT32 dsp_comm_sharc[MAX_CG_BOARDS][2];
7373   UINT8 dsp_shared_ram_bank[MAX_CG_BOARDS];
74   
74
7575   INT32 cgboard_id;
7676   INT32 cgboard_type;
7777   INT32 num_cgboards;
78   
79   UINT32 *dsp_shared_ram[MAX_CG_BOARDS];   
80   
78
79   UINT32 *dsp_shared_ram[MAX_CG_BOARDS];
80
8181   UINT32 dsp_state[MAX_CG_BOARDS];
8282   UINT32 nwk_device_sel[MAX_CG_BOARDS];
8383   const char *texture_bank[MAX_CG_BOARDS];
84   
84
8585   int nwk_fifo_half_full_r;
8686   int nwk_fifo_half_full_w;
8787   int nwk_fifo_full;
8888   int nwk_fifo_mask;
89   
89
9090   UINT32 *nwk_fifo[MAX_CG_BOARDS];
9191   INT32 nwk_fifo_read_ptr[MAX_CG_BOARDS];
9292   INT32 nwk_fifo_write_ptr[MAX_CG_BOARDS];
93   
94   UINT32 *nwk_ram[MAX_CG_BOARDS];   
93
94   UINT32 *nwk_ram[MAX_CG_BOARDS];
9595};
9696
9797
trunk/src/mame/machine/wpc_out.h
r31374r31375
66#ifndef WPC_OUT_H
77#define WPC_OUT_H
88
9#define MCFG_WPC_OUT_ADD( _tag, _count )   \
10   MCFG_DEVICE_ADD( _tag, WPC_OUT, 0 )      \
9#define MCFG_WPC_OUT_ADD( _tag, _count )    \
10   MCFG_DEVICE_ADD( _tag, WPC_OUT, 0 )     \
1111      downcast<wpc_out_device *>(device)->set_gi_count(_count);
1212
1313class wpc_out_device : public device_t
trunk/src/mame/machine/midwayic.h
r31374r31375
2020   // construction/destruction
2121   midway_serial_pic_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
2222   midway_serial_pic_device(const machine_config &mconfig, device_type type, const char *name, const char *tag, device_t *owner, UINT32 clock, const char *shortname, const char *source);
23   
23
2424   static void static_set_upper(device_t &device, int upper) { downcast<midway_serial_pic_device &>(device).m_upper = upper; }
25     
25
2626   DECLARE_READ8_MEMBER( read );
2727   DECLARE_WRITE8_MEMBER( write );
2828   DECLARE_READ8_MEMBER( status_r );
r31374r31375
3030
3131protected:
3232   // device-level overrides
33   virtual void device_start();   
34   
33   virtual void device_start();
34
3535   void generate_serial_data(int upper);
3636   void serial_register_state();
37   
37
3838   UINT8   m_data[16]; // reused by other devices
39   int      m_upper;
39   int     m_upper;
4040private:
4141   UINT8   m_buff;
4242   UINT8   m_idx;
r31374r31375
5151
5252#define MCFG_MIDWAY_SERIAL_PIC_UPPER(_upper) \
5353   midway_serial_pic_device::static_set_upper(*device, _upper);
54   
54
5555/* 2nd generation Midway serial/NVRAM/RTC PIC */
5656
5757// ======================> midway_serial_pic2_device
5858
5959class midway_serial_pic2_device : public midway_serial_pic_device,
60                          public device_nvram_interface
60                           public device_nvram_interface
6161{
6262public:
6363   // construction/destruction
r31374r31375
6565   midway_serial_pic2_device(const machine_config &mconfig, device_type type, const char *name, const char *tag, device_t *owner, UINT32 clock, const char *shortname, const char *source);
6666
6767   static void static_set_yearoffs(device_t &device, int yearoffs) { downcast<midway_serial_pic2_device &>(device).m_yearoffs = yearoffs; }
68   
68
6969   DECLARE_READ8_MEMBER( read );
7070   DECLARE_WRITE8_MEMBER( write );
7171   DECLARE_READ8_MEMBER( status_r );
r31374r31375
8080   virtual void nvram_default();
8181   virtual void nvram_read(emu_file &file);
8282   virtual void nvram_write(emu_file &file);
83     
83
8484private:
8585
8686   void pic_register_state();
8787   TIMER_CALLBACK_MEMBER( reset_timer );
88   
88
8989   UINT16  m_latch;
9090   attotime m_latch_expire_time;
9191   UINT8   m_state;
r31374r31375
106106// device type definition
107107extern const device_type MIDWAY_SERIAL_PIC2;
108108
109#define MCFG_MIDWAY_SERIAL_PIC2_UPPER   MCFG_MIDWAY_SERIAL_PIC_UPPER
109#define MCFG_MIDWAY_SERIAL_PIC2_UPPER   MCFG_MIDWAY_SERIAL_PIC_UPPER
110110
111111#define MCFG_MIDWAY_SERIAL_PIC2_YEAR_OFFS(_yearoffs) \
112112   midway_serial_pic2_device::static_set_yearoffs(*device, _yearoffs);
r31374r31375
124124   static void static_set_shuffle(device_t &device, UINT8 shuffle) { downcast<midway_ioasic_device &>(device).m_shuffle_type = shuffle; }
125125   static void static_set_shuffle_default(device_t &device, UINT8 shuffle) { downcast<midway_ioasic_device &>(device).m_shuffle_default = shuffle; }
126126   static void static_set_auto_ack(device_t &device, UINT8 auto_ack) { downcast<midway_ioasic_device &>(device).m_auto_ack = auto_ack; }
127   template<class _Object> static devcb_base &set_irqhandler_callback(device_t &device, _Object object) { return downcast<midway_ioasic_device &>(device).m_irq_callback.set_callback(object); }   
127   template<class _Object> static devcb_base &set_irqhandler_callback(device_t &device, _Object object) { return downcast<midway_ioasic_device &>(device).m_irq_callback.set_callback(object); }
128128
129129   void set_shuffle_state(int state);
130130   void fifo_w(UINT16 data);
r31374r31375
136136
137137   DECLARE_WRITE_LINE_MEMBER(ioasic_input_empty);
138138   DECLARE_WRITE_LINE_MEMBER(ioasic_output_full);
139   
139
140140   DECLARE_READ32_MEMBER( read );
141141   DECLARE_WRITE32_MEMBER( write );
142142   DECLARE_READ32_MEMBER( packed_r );
143143   DECLARE_WRITE32_MEMBER( packed_w );
144144
145145   DECLARE_WRITE8_MEMBER(cage_irq_handler);
146   
146
147147   void ioasic_reset();
148148
149149protected:
r31374r31375
174174   UINT16  m_fifo_out;
175175   UINT16  m_fifo_bytes;
176176   offs_t  m_fifo_force_buffer_empty_pc;
177   
177
178178   atari_cage_device *m_cage;
179179   dcs_audio_device *m_dcs;
180180};
r31374r31375
183183// device type definition
184184extern const device_type MIDWAY_IOASIC;
185185
186#define MCFG_MIDWAY_IOASIC_UPPER   MCFG_MIDWAY_SERIAL_PIC_UPPER
186#define MCFG_MIDWAY_IOASIC_UPPER    MCFG_MIDWAY_SERIAL_PIC_UPPER
187187
188188#define MCFG_MIDWAY_IOASIC_YEAR_OFFS MCFG_MIDWAY_SERIAL_PIC2_YEAR_OFFS
189189
190190#define MCFG_MIDWAY_IOASIC_SHUFFLE(_shuffle) \
191191   midway_ioasic_device::static_set_shuffle(*device, _shuffle);
192   
192
193193#define MCFG_MIDWAY_IOASIC_SHUFFLE_DEFAULT(_shuffle) \
194194   midway_ioasic_device::static_set_shuffle_default(*device, _shuffle);
195195
r31374r31375
198198
199199#define MCFG_MIDWAY_IOASIC_AUTO_ACK(_ack) \
200200   midway_ioasic_device::static_set_auto_ack(*device, _ack);
201   
202   
201
202
203203enum
204204{
205205   MIDWAY_IOASIC_STANDARD = 0,
r31374r31375
213213   MIDWAY_IOASIC_HYPRDRIV
214214};
215215
216#endif
No newline at end of file
216#endif
trunk/src/mame/machine/c117.h
r31374r31375
1212//**************************************************************************
1313
1414#define MCFG_CUS117_CPUS(_maincpu, _subcpu) \
15        namco_c117_device::set_cpu_tags(*device, _maincpu, _subcpu);
15      namco_c117_device::set_cpu_tags(*device, _maincpu, _subcpu);
1616
1717#define MCFG_CUS117_SUBRES_CB(_devcb) \
18        devcb = &namco_c117_device::set_subres_cb(*device, DEVCB_##_devcb);
18      devcb = &namco_c117_device::set_subres_cb(*device, DEVCB_##_devcb);
1919
2020
2121//***************************************************************************
trunk/src/mame/includes/model3.h
r31374r31375
4141      int intensity;
4242      UINT32 color;
4343   };
44     
44
4545   required_device<cpu_device> m_maincpu;
4646   optional_device<lsi53c810_device> m_lsi53c810;
4747   required_device<cpu_device> m_audiocpu;
trunk/src/mame/includes/toaplan2.h
r31374r31375
159159   UINT8 m_pwrkick_hopper;
160160   DECLARE_CUSTOM_INPUT_MEMBER(pwrkick_hopper_status_r);
161161   DECLARE_WRITE8_MEMBER(pwrkick_coin_w);
162   
162
163163   DECLARE_WRITE_LINE_MEMBER(toaplan2_reset);
164164protected:
165165   virtual void device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr);
trunk/src/mame/includes/chqflag.h
r31374r31375
4747   required_device<k051316_device> m_k051316_1;
4848   required_device<k051316_device> m_k051316_2;
4949   required_device<palette_device> m_palette;
50   
50
5151   DECLARE_WRITE8_MEMBER(chqflag_bankswitch_w);
5252   DECLARE_WRITE8_MEMBER(chqflag_vreg_w);
5353   DECLARE_WRITE8_MEMBER(select_analog_ctrl_w);
trunk/src/mame/includes/atarigt.h
r31374r31375
7272   DECLARE_READ32_MEMBER(colorram_protection_r);
7373   DECLARE_WRITE32_MEMBER(colorram_protection_w);
7474   DECLARE_WRITE32_MEMBER(tmek_pf_w);
75   
75
7676   DECLARE_WRITE8_MEMBER(cage_irq_callback);
77   
77
7878   void atarigt_colorram_w(offs_t address, UINT16 data, UINT16 mem_mask);
7979   UINT16 atarigt_colorram_r(offs_t address);
8080   DECLARE_DRIVER_INIT(primrage);
trunk/src/mame/includes/plygonet.h
r31374r31375
4040   required_device<gfxdecode_device> m_gfxdecode;
4141   required_device<palette_device> m_palette;
4242   required_shared_ptr<UINT32> m_generic_paletteram_32;
43   
43
4444   ioport_port *m_inputs[4];
4545   UINT8 m_sys0;
4646   UINT8 m_sys1;
trunk/src/mame/includes/bfm_sc45.h
r31374r31375
3030#define SC45_BUTTON_MATRIX_7_0 IPT_BUTTON13
3131#define SC45_BUTTON_MATRIX_7_1 IPT_BUTTON14
3232#define SC45_BUTTON_MATRIX_7_2 IPT_BUTTON15
33#define SC45_BUTTON_MATRIX_7_3 IPT_BUTTON16
33#define SC45_BUTTON_MATRIX_7_3 IPT_BUTTON16
3434#define SC45_BUTTON_MATRIX_7_4 IPT_MAHJONG_A // having more buttons would make sense and be cleaner but as a temporary solution (these are meant to be driven more by the clickable layouts anyway).....
3535#define SC45_BUTTON_MATRIX_7_5 IPT_MAHJONG_B
3636
r31374r31375
578578   DECLARE_MACHINE_RESET(sc4);
579579
580580   DECLARE_WRITE_LINE_MEMBER(bfm_sc4_irqhandler);
581   
581
582582   void bfm_sc4_68307_porta_w(address_space &space, bool dedicated, UINT8 data, UINT8 line_mask);
583583   DECLARE_WRITE8_MEMBER( bfm_sc4_reel3_w );
584584   DECLARE_WRITE8_MEMBER( bfm_sc4_reel4_w );
r31374r31375
731731   PORT_DIPSETTING(      0x0000, DEF_STR( Off ) ) \
732732   PORT_DIPSETTING(      0x0010, DEF_STR( On ) ) \
733733   PORT_MODIFY("IN-18") \
734   PORT_DIPNAME( 0x0001, 0x0000, "IN 18-0 (DSW11)" ) /* DIL11 18.0    */ \
734   PORT_DIPNAME( 0x0001, 0x0000, "IN 18-0 (DSW11)" ) /* DIL11 18.0 */ \
735735   PORT_DIPSETTING(      0x0000, DEF_STR( Off ) ) \
736736   PORT_DIPSETTING(      0x0001, DEF_STR( On ) ) \
737737   PORT_DIPNAME( 0x0002, 0x0000, "IN 18-1 (DSW12)" ) /* DIL12 18.1 */ \
trunk/src/mame/includes/amiga.h
r31374r31375
254254#define REG_COLOR29     (0x1BA/2)   /* W    D    Color table 29 */
255255#define REG_COLOR30     (0x1BC/2)   /* W    D    Color table 30 */
256256#define REG_COLOR31     (0x1BE/2)   /* W    D    Color table 31 */
257#define REG_BEAMCON0   (0x1dc/2)   // W  A      Programmable signal generator (ECS Agnus)
257#define REG_BEAMCON0    (0x1dc/2)   // W  A      Programmable signal generator (ECS Agnus)
258258#define REG_DIWHIGH     (0x1E4/2)   /* W  A D    Display window upper bits for start/stop */
259259#define REG_FMODE       (0x1FC/2)   /* W  A D    Fetch mode */
260260
r31374r31375
316316
317317
318318// chipset
319#define IS_OCS(state)   (state->m_denise_id == 0xff)
320#define IS_ECS(state)   (state->m_denise_id == 0xfc)
321#define IS_AGA(state)   (state->m_denise_id == 0xf8)
319#define IS_OCS(state)   (state->m_denise_id == 0xff)
320#define IS_ECS(state)   (state->m_denise_id == 0xfc)
321#define IS_AGA(state)   (state->m_denise_id == 0xf8)
322322
323323
324324class amiga_state : public driver_device
r31374r31375
378378   UINT16 (*m_chip_ram_r)(amiga_state *state, offs_t offset);
379379   void (*m_chip_ram_w)(amiga_state *state, offs_t offset, UINT16 data);
380380
381   
381
382382   /* sprite states */
383383   UINT8 m_sprite_comparitor_enable_mask;
384384   UINT8 m_sprite_dma_reload_mask;
r31374r31375
446446   DECLARE_READ8_MEMBER( cia_1_port_a_read );
447447   DECLARE_WRITE8_MEMBER( cia_1_port_a_write );
448448   DECLARE_WRITE_LINE_MEMBER( cia_1_irq );
449   
449
450450   DECLARE_WRITE_LINE_MEMBER( rs232_rx_w );
451451   DECLARE_WRITE_LINE_MEMBER( rs232_dcd_w );
452452   DECLARE_WRITE_LINE_MEMBER( rs232_dsr_w );
r31374r31375
518518   // denise/lisa chip id
519519   enum
520520   {
521      DENISE    = 0xffff,   // actually this register doesn't exist on ocs
521      DENISE    = 0xffff, // actually this register doesn't exist on ocs
522522      DENISE_HR = 0x00fc,
523523      LISA      = 0x00f8
524524   };
r31374r31375
593593
594594   enum
595595   {
596      VPOSR_LOF = 0x8000   // long frame
596      VPOSR_LOF = 0x8000  // long frame
597597   };
598598
599599   enum
600600   {
601      ADKCON_UARTBRK = 0x800   // send break
601      ADKCON_UARTBRK = 0x800  // send break
602602   };
603603
604604   // serial port flags
605605   enum
606606   {
607      SERDATR_RXD   = 0x0800,   // serial data
608      SERDATR_TSRE  = 0x1000,   // transmit ready
609      SERDATR_TBE   = 0x2000,   // transmit buffer empty
610      SERDATR_RBF   = 0x4000,   // receive buffer full
611      SERDATR_OVRUN = 0x8000   // receive buffer overrun
607      SERDATR_RXD   = 0x0800, // serial data
608      SERDATR_TSRE  = 0x1000, // transmit ready
609      SERDATR_TBE   = 0x2000, // transmit buffer empty
610      SERDATR_RBF   = 0x4000, // receive buffer full
611      SERDATR_OVRUN = 0x8000  // receive buffer overrun
612612   };
613613
614614   enum
615615   {
616      SERPER_LONG = 0x8000   // 9-bit mode
616      SERPER_LONG = 0x8000    // 9-bit mode
617617   };
618618
619619   // pot counters
trunk/src/mame/includes/midzeus.h
r31374r31375
8282   void zeus_draw_quad(int long_fmt, const UINT32 *databuffer, UINT32 texdata, int logit);
8383
8484   void log_fifo_command(const UINT32 *data, int numwords, const char *suffix);
85   void log_waveram(UINT32 length_and_base);   
85   void log_waveram(UINT32 length_and_base);
8686};
8787
8888
r31374r31375
9696   UINT32 screen_update_midzeus2(screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect);
9797   DECLARE_READ32_MEMBER( zeus2_r );
9898   DECLARE_WRITE32_MEMBER( zeus2_w );
99private:   
99private:
100100   void exit_handler2();
101101   void zeus2_register32_w(offs_t offset, UINT32 data, int logit);
102102   void zeus2_register_update(offs_t offset, UINT32 oldval, int logit);
103103   int zeus2_fifo_process(const UINT32 *data, int numwords);
104104   void zeus2_pointer_write(UINT8 which, UINT32 value);
105105   void zeus2_draw_model(UINT32 baseaddr, UINT16 count, int logit);
106   void zeus2_draw_quad(const UINT32 *databuffer, UINT32 texoffs, int logit);   
106   void zeus2_draw_quad(const UINT32 *databuffer, UINT32 texoffs, int logit);
107107   void log_fifo_command(const UINT32 *data, int numwords, const char *suffix);
108108};
trunk/src/mame/includes/spbactn.h
r31374r31375
8282   required_device<tecmo_mix_device> m_mixer;
8383
8484
85   
85
8686};
trunk/src/mame/includes/harddriv.h
r31374r31375
454454   /* DS III/IV board */
455455   TIMER_DEVICE_CALLBACK_MEMBER( ds3sdsp_internal_timer_callback );
456456   TIMER_DEVICE_CALLBACK_MEMBER( ds3xdsp_internal_timer_callback );
457   
457
458458};
459459
460460
trunk/src/mame/includes/neogeo.h
r31374r31375
121121   void set_outputs(  );
122122   void set_output_latch( UINT8 data );
123123   void set_output_data( UINT8 data );
124   
125124
126125
127126
r31374r31375
129128
130129
131130
131
132132   // device overrides
133133   virtual void machine_start();
134134   virtual void machine_reset();
r31374r31375
154154   required_device<screen_device> m_screen;
155155   optional_device<palette_device> m_palette;
156156   optional_device<ng_memcard_device> m_memcard;
157   
157
158158   // configuration
159159   enum {NEOGEO_MVS, NEOGEO_AES, NEOGEO_CD} m_type;
160160
r31374r31375
495495#define ROM_Y_ZOOM \
496496   ROM_REGION( 0x20000, "zoomy", 0 ) \
497497   ROM_LOAD( "000-lo.lo", 0x00000, 0x20000, CRC(5a86cff2) SHA1(5992277debadeb64d1c1c64b0a92d9293eaf7e4a) )
498
499
trunk/src/mame/includes/esd16.h
r31374r31375
5252   required_device<gfxdecode_device> m_gfxdecode;
5353   optional_device<decospr_device> m_sprgen;
5454   optional_device<eeprom_serial_93cxx_device> m_eeprom;
55   
55
5656   DECLARE_WRITE16_MEMBER(esd16_sound_command_w);
5757   DECLARE_WRITE16_MEMBER(hedpanic_platform_w);
5858   DECLARE_READ16_MEMBER(esd_eeprom_r);
trunk/src/mame/includes/boogwing.h
r31374r31375
6363   void mix_boogwing(screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect);
6464   DECLARE_READ16_MEMBER( boogwing_protection_region_0_104_r );
6565   DECLARE_WRITE16_MEMBER( boogwing_protection_region_0_104_w );
66   
66
6767   DECO16IC_BANK_CB_MEMBER(bank_callback);
6868   DECO16IC_BANK_CB_MEMBER(bank_callback2);
6969};
trunk/src/mame/includes/mystwarr.h
r31374r31375
2020   required_device<cpu_device> m_maincpu;
2121   required_device<k053252_device> m_k053252;
2222   required_device<k056832_device> m_k056832;
23   required_device<k055673_device> m_k055673;   
23   required_device<k055673_device> m_k055673;
2424   required_shared_ptr<UINT16> m_gx_workram;
2525   optional_shared_ptr<UINT16> m_spriteram;
2626
trunk/src/mame/includes/konamigx.h
r31374r31375
3434      m_an0(*this, "AN0"),
3535      m_an1(*this, "AN1"),
3636      m_light0_x(*this, "LIGHT0_X"),
37      m_light0_y(*this, "LIGHT0_Y"),   
37      m_light0_y(*this, "LIGHT0_Y"),
3838      m_light1_x(*this, "LIGHT1_X"),
39      m_light1_y(*this, "LIGHT1_Y"),   
39      m_light1_y(*this, "LIGHT1_Y"),
4040      m_eepromout(*this, "EEPROMOUT"),
4141      m_gfxdecode(*this, "gfxdecode"),
4242      m_screen(*this, "screen"),
r31374r31375
162162
163163   void konamigx_mixer_init(screen_device &screen, int objdma);
164164   void konamigx_objdma(void);
165   
165
166166   void fantjour_dma_install();
167167
168168   void konamigx_mixer_primode(int mode);
r31374r31375
225225#define GXSUB_4BPP      0x04    //  16 colors
226226#define GXSUB_5BPP      0x05    //  32 colors
227227#define GXSUB_8BPP      0x08    // 256 colors
228
trunk/src/mame/includes/rpunch.h
r31374r31375
2323   required_device<gfxdecode_device> m_gfxdecode;
2424   required_device<screen_device> m_screen;
2525   required_device<palette_device> m_palette;
26   
26
2727   required_shared_ptr<UINT16> m_videoram;
2828   required_shared_ptr<UINT16> m_bitmapram;
2929   required_shared_ptr<UINT16> m_spriteram;
30   
30
3131   UINT8 m_sound_data;
3232   UINT8 m_sound_busy;
3333   UINT8 m_ym2151_irq;
r31374r31375
5959   TILE_GET_INFO_MEMBER(get_bg1_tile_info);
6060   virtual void machine_start();
6161   virtual void machine_reset();
62   
62
6363   DECLARE_VIDEO_START(rpunch);
6464   DECLARE_VIDEO_START(svolley);
6565
trunk/src/mame/includes/unico.h
r31374r31375
5656   required_device<screen_device> m_screen;
5757   required_device<palette_device> m_palette;
5858   optional_shared_ptr<UINT16> m_generic_paletteram_16;
59   optional_shared_ptr<UINT32> m_generic_paletteram_32;   
59   optional_shared_ptr<UINT32> m_generic_paletteram_32;
6060};
trunk/src/mame/includes/deco32.h
r31374r31375
211211   void screen_eof_dragngun(screen_device &screen, bool state);
212212   void dragngun_draw_sprites( bitmap_rgb32 &bitmap, const rectangle &cliprect, const UINT32 *spritedata);
213213   READ32_MEMBER( dragngun_unk_video_r );
214   
214
215215   DECO16IC_BANK_CB_MEMBER(bank_1_callback);
216216   DECO16IC_BANK_CB_MEMBER(bank_2_callback);
217217
trunk/src/mame/includes/wc90.h
r31374r31375
2828      m_sprgen(*this, "spritegen")
2929   { }
3030
31   
3231
32
3333   required_shared_ptr<UINT8> m_fgvideoram;
3434   required_shared_ptr<UINT8> m_bgvideoram;
3535   required_shared_ptr<UINT8> m_txvideoram;
trunk/src/mame/includes/midtunit.h
r31374r31375
7878   required_device<palette_device> m_palette;
7979   optional_device<dcs_audio_device> m_dcs;
8080   required_shared_ptr<UINT16> m_generic_paletteram_16;
81   
81
8282   void register_state_saving();
8383   void init_tunit_generic(int sound);
8484   void init_nbajam_common(int te_protection);
trunk/src/mame/includes/niyanpai.h
r31374r31375
5454   DECLARE_WRITE8_MEMBER(cpu_portb_w);
5555   DECLARE_WRITE8_MEMBER(cpu_portc_w);
5656   DECLARE_WRITE8_MEMBER(cpu_porte_w);
57   
57
5858   DECLARE_READ16_MEMBER(niyanpai_dipsw_r);
5959   DECLARE_READ16_MEMBER(musobana_inputport_0_r);
6060   DECLARE_WRITE16_MEMBER(musobana_inputport_w);
trunk/src/mame/includes/armedf.h
r31374r31375
2121   required_device<gfxdecode_device> m_gfxdecode;
2222   required_device<palette_device> m_palette;
2323   required_device<buffered_spriteram16_device> m_spriteram;
24   
24
2525   /* memory pointers */
2626   UINT8 *m_text_videoram;
2727   required_shared_ptr<UINT16> m_spr_pal_clut;
trunk/src/mame/includes/megadriv.h
r31374r31375
122122   DECLARE_VIDEO_START( megadriv );
123123   UINT32 screen_update_megadriv(screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect);
124124   void screen_eof_megadriv(screen_device &screen, bool state);
125   
125
126126   DECLARE_WRITE8_MEMBER(megadriv_tas_callback);
127127};
128128
trunk/src/mame/includes/wpc_pin.h
r31374r31375
106106public:
107107   wpc_dcs_state(const machine_config &mconfig, device_type type, const char *tag)
108108      : wpc_flip2_state(mconfig, type, tag),
109        m_dcs(*this, "dcs")
109         m_dcs(*this, "dcs")
110110   { }
111111public:
112112
r31374r31375
115115   DECLARE_WRITE8_MEMBER(wpc_dcs_sound_ctrl_w);
116116   DECLARE_READ8_MEMBER(wpc_dcs_sound_data_r);
117117   DECLARE_WRITE8_MEMBER(wpc_dcs_sound_data_w);
118   
118
119119   required_device<dcs_audio_wpc_device> m_dcs;
120120private:
121121   bool m_send;
trunk/src/mame/includes/atari.h
r31374r31375
3737   TIMER_DEVICE_CALLBACK_MEMBER( a5200_interrupt );
3838
3939   DECLARE_PALETTE_INIT(atari);
40   
40
4141   DECLARE_READ8_MEMBER( atari_gtia_r );
4242   DECLARE_WRITE8_MEMBER( atari_gtia_w );
43   
43
4444   DECLARE_READ8_MEMBER ( atari_antic_r );
4545   DECLARE_WRITE8_MEMBER ( atari_antic_w );
4646
trunk/src/mame/includes/kaneko16.h
r31374r31375
6868   DECLARE_READ16_MEMBER(kaneko16_ay2_YM2149_r);
6969   DECLARE_WRITE16_MEMBER(kaneko16_ay2_YM2149_w);
7070   DECLARE_WRITE16_MEMBER(bakubrkr_oki_bank_sw);
71   
71
7272   DECLARE_READ8_MEMBER(eeprom_r);
7373   DECLARE_WRITE8_MEMBER(eeprom_w);
7474
trunk/src/mame/includes/darkseal.h
r31374r31375
4444   required_device<cpu_device> m_audiocpu;
4545   required_device<palette_device> m_palette;
4646   required_shared_ptr<UINT16> m_generic_paletteram_16;
47   required_shared_ptr<UINT16> m_generic_paletteram2_16;   
47   required_shared_ptr<UINT16> m_generic_paletteram2_16;
4848};
trunk/src/mame/includes/taito_z.h
r31374r31375
6565   optional_device<tc0110pcr_device> m_tc0110pcr;
6666   optional_device<tc0220ioc_device> m_tc0220ioc;
6767   optional_device<tc0510nio_device> m_tc0510nio;
68   optional_device<tc0140syt_device> m_tc0140syt;   // bshark & spacegun miss the CPUs which shall use TC0140
68   optional_device<tc0140syt_device> m_tc0140syt;  // bshark & spacegun miss the CPUs which shall use TC0140
6969   required_device<gfxdecode_device> m_gfxdecode;
7070   required_device<palette_device> m_palette;
7171
trunk/src/mame/includes/gaelco3d.h
r31374r31375
6969      m_serial(*this, "serial"),
7070      m_screen(*this, "screen"),
7171      m_paletteram16(*this, "paletteram"),
72      m_paletteram32(*this, "paletteram")   { }
72      m_paletteram32(*this, "paletteram") { }
7373
7474   required_shared_ptr<UINT32> m_adsp_ram_base;
7575   required_shared_ptr<UINT16> m_m68k_ram_base;
trunk/src/mame/includes/gstriker.h
r31374r31375
5656   DECLARE_READ16_MEMBER(vbl_toggle_r);
5757   DECLARE_WRITE16_MEMBER(vbl_toggle_w);
5858
59   
59
6060   DECLARE_DRIVER_INIT(twrldc94a);
6161   DECLARE_DRIVER_INIT(vgoalsoc);
6262   DECLARE_DRIVER_INIT(twrldc94);
trunk/src/mame/mame.mak
r31374r31375
24372437   $(DRIVERS)/wms.o \
24382438   $(DRIVERS)/xtom3d.o \
24392439   $(DRIVERS)/xyonix.o $(VIDEO)/xyonix.o \
2440   
24412440
2441
24422442#-------------------------------------------------
24432443# layout dependencies
24442444#-------------------------------------------------
r31374r31375
25212521         $(LAYOUT)/sc4_dmd.lh \
25222522         $(LAYOUT)/sc4dnd.lh \
25232523         $(LAYOUT)/sc4dndtp.lh \
2524         $(LAYOUT)/sc4dnddw.lh     
2524         $(LAYOUT)/sc4dnddw.lh
25252525
25262526$(DRIVERS)/bfm_sc5.o:   $(LAYOUT)/bfm_sc5.lh
25272527
trunk/src/mame/video/k054156_k054157_k056832.h
r31374r31375
5353      dev.m_djmain_hack = djmain_hack;
5454      dev.m_k055555_tag = k055555;
5555   }
56   
56
5757   // static configuration
5858   static void static_set_gfxdecode_tag(device_t &device, const char *tag);
5959   static void static_set_palette_tag(device_t &device, const char *tag);
r31374r31375
141141   int                m_bpp;
142142   int                m_big;
143143   int                m_djmain_hack;
144   
144
145145   const char         *m_k055555_tag;    // tbyahhoo uses the k056832 together with a k055555
146   
147146
147
148148   // ROM readback involves reading 2 halves of a word
149149   // from the same location in a row.  Reading the
150150   // RAM window resets this state so you get the first half.
trunk/src/mame/video/k053246_k053247_k055673.h
r31374r31375
7878      dev.m_dx = dx;
7979      dev.m_dy = dy;
8080   }
81   
81
8282   void clear_all();
8383
8484   DECLARE_READ16_MEMBER( k055673_rom_word_r );
trunk/src/mame/video/mb60553.h
r31374r31375
88   mb60553_zooming_tilemap_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
99   static void static_set_gfxdecode_tag(device_t &device, const char *tag);
1010   static void set_gfx_region(device_t &device, int gfxregion);
11   
11
1212   tilemap_t* m_tmap;
1313   UINT16* m_vram;
1414   UINT16 m_regs[8];
trunk/src/mame/video/k051316.h
r31374r31375
3636   DECLARE_GFXDECODE_MEMBER(gfxinfo7);
3737   DECLARE_GFXDECODE_MEMBER(gfxinfo8);
3838   DECLARE_GFXDECODE_MEMBER(gfxinfo4_ram);
39   
39
4040   // static configuration
4141   static void set_k051316_callback(device_t &device, k051316_cb_delegate callback) { downcast<k051316_device &>(device).m_k051316_cb = callback; }
4242   static void set_wrap(device_t &device, int wrap) { downcast<k051316_device &>(device).m_wrap = wrap; }
trunk/src/mame/video/k052109.h
r31374r31375
9595
9696   UINT8 *m_char_rom;
9797   UINT32 m_char_size;
98   
98
9999   k052109_cb_delegate m_k052109_cb;
100100
101101   TILE_GET_INFO_MEMBER(get_tile_info0);
trunk/src/mame/video/excellent_spr.h
r31374r31375
1515
1616protected:
1717   UINT8* m_ram;
18   
18
1919   virtual void device_start();
2020   virtual void device_reset();
2121private:
2222};
2323
2424extern const device_type EXCELLENT_SPRITE;
25
26
trunk/src/mame/video/kan_pand.h
r31374r31375
3030      dev.m_xoffset = x_offset;
3131      dev.m_yoffset = y_offset;
3232   }
33   
33
3434   DECLARE_WRITE8_MEMBER ( spriteram_w );
3535   DECLARE_READ8_MEMBER( spriteram_r );
3636   DECLARE_WRITE16_MEMBER( spriteram_LSB_w );
trunk/src/mame/video/tecmo_mix.h
r31374r31375
77{
88public:
99   tecmo_mix_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
10   
10
1111   void mix_bitmaps(screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect, palette_device* palette, bitmap_ind16* bitmap_bg, bitmap_ind16* bitmap_fg, bitmap_ind16* bitmap_tx, bitmap_ind16* bitmap_sp);
1212   static void set_mixer_shifts(device_t &device, int sprpri_shift, int sprbln_shift, int sprcol_shift);
1313   static void set_blendcols(device_t &device, int bgblend_comp, int fgblend_comp, int txblend_comp, int spblend_comp);
r31374r31375
7070
7171#define MCFG_TECMO_MIXER_BGPEN(_bgpen) \
7272   tecmo_mix_device::set_bgpen(*device, _bgpen);
73
74
trunk/src/mame/video/pc080sn.h
r31374r31375
1919      dev.m_x_offset = x_offset;
2020      dev.m_y_offset = y_offset;
2121   }
22   
22
2323   DECLARE_READ16_MEMBER( word_r );
2424   DECLARE_WRITE16_MEMBER( word_w );
2525   DECLARE_WRITE16_MEMBER( xscroll_word_w );
r31374r31375
6565   int            m_x_offset, m_y_offset;
6666   int            m_y_invert;
6767   int            m_dblwidth;
68   
68
6969   required_device<gfxdecode_device> m_gfxdecode;
7070   required_device<palette_device> m_palette;
7171};
trunk/src/mame/video/tc0480scp.h
r31374r31375
3131      dev.m_flip_xoffs = x_offset;
3232      dev.m_flip_yoffs = y_offset;
3333   }
34   
34
3535   /* When writing a driver, pass zero for the text and flip offsets initially:
3636   then tweak them once you have the 4 bg layer positions correct. Col_base
3737   may be needed when tilemaps use a palette area from sprites. */
r31374r31375
8989   int              m_x_offset, m_y_offset;
9090   int              m_text_xoffs, m_text_yoffs;
9191   int              m_flip_xoffs, m_flip_yoffs;
92   
92
9393   int              m_col_base;
94   
94
9595   required_device<gfxdecode_device> m_gfxdecode;
9696   required_device<palette_device> m_palette;
9797
trunk/src/mame/video/tecmo_spr.h
r31374r31375
1111
1212   // gaiden.c / spbactn.c / tecmo16.c sprites
1313   void gaiden_draw_sprites(screen_device &screen, gfxdecode_device *gfxdecode, const rectangle &cliprect, UINT16* spriteram, int sprite_sizey, int spr_offset_y, int flip_screen, bitmap_ind16 &sprite_bitmap);
14   
14
1515   // tecmo.c sprites
1616   void draw_sprites_8bit(screen_device &screen, bitmap_ind16 &bitmap, gfxdecode_device *gfxdecode, const rectangle &cliprect, UINT8* spriteram, int size, int video_type, int flip_screen);
1717
r31374r31375
4040
4141#define MCFG_TECMO_SPRITE_BOOTLEG(_bootleg) \
4242   tecmo_spr_device::set_bootleg(*device, _bootleg);
43
44
45
trunk/src/mame/video/k001604.h
r31374r31375
1818   static void set_roz_size(device_t &device, int size) { downcast<k001604_device &>(device).m_roz_size = size; }
1919   static void set_txt_mem_offset(device_t &device, int offs) { downcast<k001604_device &>(device).m_txt_mem_offset = offs; }
2020   static void set_roz_mem_offset(device_t &device, int offs) { downcast<k001604_device &>(device).m_roz_mem_offset = offs; }
21   
21
2222   void draw_back_layer( bitmap_rgb32 &bitmap, const rectangle &cliprect );
2323   void draw_front_layer( screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect );
2424   DECLARE_WRITE32_MEMBER( tile_w );
trunk/src/mame/video/k053936.h
r31374r31375
2828      dev.m_xoff = x_offset;
2929      dev.m_yoff = y_offset;
3030   }
31   
31
3232   DECLARE_WRITE16_MEMBER( ctrl_w );
3333   DECLARE_READ16_MEMBER( ctrl_r );
3434   DECLARE_WRITE16_MEMBER( linectrl_w );
trunk/src/mame/video/deco_zoomspr.h
r31374r31375
3636
3737#define MCFG_DECO_ZOOMSPR_GFXDECODE(_gfxtag) \
3838   deco_zoomspr_device::static_set_gfxdecode_tag(*device, "^" _gfxtag);
39
trunk/src/mame/video/tc0080vco.h
r31374r31375
1919      dev.m_bg_yoffs = y_offset;
2020   }
2121   static void set_bgflip_yoffs(device_t &device, int offs) { downcast<tc0080vco_device &>(device).m_bg_flip_yoffs = offs; }
22   
22
2323   DECLARE_READ16_MEMBER( word_r );
2424   DECLARE_WRITE16_MEMBER( word_w );
2525
r31374r31375
6565   tilemap_t      *m_tilemap[3];
6666
6767   INT32          m_flipscreen;
68   
68
6969   int            m_gfxnum;
7070   int            m_txnum;
7171   int            m_bg_xoffs, m_bg_yoffs;
trunk/src/mame/video/k001005.h
r31374r31375
134134   int m_fifo_read_ptr;
135135   int m_fifo_write_ptr;
136136   UINT32 m_reg_far_z;
137   
138137
138
139139   k001005_renderer *m_renderer;
140140};
141141
trunk/src/mame/video/vs920a.h
r31374r31375
4040
4141#define MCFG_VS920A_GFXDECODE(_gfxtag) \
4242   vs920a_text_tilemap_device::static_set_gfxdecode_tag(*device, "^" _gfxtag);
43
44
45
trunk/src/mame/video/pc090oj.h
r31374r31375
1818      dev.m_x_offset = x_offset;
1919      dev.m_y_offset = y_offset;
2020   }
21   
21
2222   DECLARE_READ16_MEMBER( word_r );
2323   DECLARE_WRITE16_MEMBER( word_w );
2424
trunk/src/mame/video/k053244_k053245.h
r31374r31375
1717   k05324x_device::set_offsets(*device, _xoffs, _yoffs);
1818
1919
20class k05324x_device : public device_t,
20class k05324x_device : public device_t,
2121                     public device_gfx_interface
2222{
2323   static const gfx_layout spritelayout;
trunk/src/mame/video/neogeo_spr.h
r31374r31375
2020{
2121public:
2222   neosprite_base_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock,  device_type type);
23//   neosprite_base_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
23//  neosprite_base_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
2424
2525   virtual void optimize_sprite_data();
2626   virtual void set_optimized_sprite_data(UINT8* sprdata, UINT32 mask);
r31374r31375
7070
7171   emu_timer  *m_auto_animation_timer;
7272   emu_timer  *m_sprite_line_timer;
73   
73
7474   TIMER_CALLBACK_MEMBER(auto_animation_timer_callback);
7575   TIMER_CALLBACK_MEMBER(sprite_line_timer_callback);
76   
7776
77
7878   int m_bppshift; // 4 for 4bpp gfx (NeoGeo) 8 for 8bpp gfx (Midas)
7979
8080protected:
r31374r31375
128128{
129129public:
130130   neosprite_midas_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
131   
131
132132   virtual void draw_pixel(int romaddr, UINT32* dst, const pen_t *line_pens);
133133
134134   UINT16* m_videoram_buffer;
r31374r31375
142142};
143143
144144extern const device_type NEOGEO_SPRITE_MIDAS;
145
146
trunk/src/mame/video/tc0100scn.h
r31374r31375
3232      dev.m_flip_text_xoffs = x_offset;
3333      dev.m_flip_text_yoffs = y_offset;
3434   }
35   
35
3636   #define TC0100SCN_SINGLE_VDU    1024
3737
3838   /* Function to set separate color banks for the three tilemapped layers.
r31374r31375
104104   int          m_flip_text_xoffs, m_flip_text_yoffs;
105105   int          m_multiscrn_xoffs;
106106   int          m_multiscrn_hack;
107   
107
108108   required_device<gfxdecode_device> m_gfxdecode;
109109   required_device<palette_device> m_palette;
110110
trunk/src/mame/video/deco16ic.h
r31374r31375
4141   static void set_pf2_col_bank(device_t &device, int bank) { downcast<deco16ic_device &>(device).m_pf2_colour_bank = bank; }
4242   static void set_pf12_8x8_bank(device_t &device, int bank) { downcast<deco16ic_device &>(device).m_pf12_8x8_gfx_bank = bank; }
4343   static void set_pf12_16x16_bank(device_t &device, int bank) { downcast<deco16ic_device &>(device).m_pf12_16x16_gfx_bank = bank; }
44   
4544
45
4646   DECLARE_WRITE16_MEMBER( pf1_data_w );
4747   DECLARE_WRITE16_MEMBER( pf2_data_w );
4848
r31374r31375
144144   int m_pf1_colour_bank, m_pf2_colour_bank;
145145   int m_pf1_colourmask, m_pf2_colourmask;
146146   int m_pf12_8x8_gfx_bank, m_pf12_16x16_gfx_bank;
147   
147
148148   TILEMAP_MAPPER_MEMBER(deco16_scan_rows);
149149   TILE_GET_INFO_MEMBER(get_pf2_tile_info);
150150   TILE_GET_INFO_MEMBER(get_pf1_tile_info);
trunk/src/mame/video/k051960.h
r31374r31375
22#ifndef __K051960_H__
33#define __K051960_H__
44
5enum
5enum
66{
77   K051960_PLANEORDER_BASE = 0,
88   K051960_PLANEORDER_MIA,
r31374r31375
2929   DECLARE_GFXDECODE_MEMBER(gfxinfo);
3030   DECLARE_GFXDECODE_MEMBER(gfxinfo_reverse);
3131   DECLARE_GFXDECODE_MEMBER(gfxinfo_gradius3);
32   
32
3333public:
3434   k051960_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
3535   ~k051960_device() {}
r31374r31375
7373private:
7474   // internal state
7575   UINT8    *m_ram;
76   
76
7777   UINT8 *m_sprite_rom;
7878   UINT32 m_sprite_size;
79   
79
8080   k051960_cb_delegate m_k051960_cb;
81   
81
8282   UINT8    m_spriterombank[3];
8383   int      m_romoffset;
8484   int      m_spriteflip, m_readroms;
trunk/src/osd/sdl/osdsdl.h
r31374r31375
199199   virtual void video_register();
200200   virtual void sound_register();
201201   virtual void debugger_register();
202   
202
203203   virtual bool video_init();
204204   virtual bool input_init();
205205   virtual void input_pause();
trunk/src/osd/sdl/window.h
r31374r31375
9797   int                 resize_height;
9898   osd_ticks_t         last_resize;
9999#else
100   int               screen_width;
101   int             screen_height;
100   int                 screen_width;
101   int                 screen_height;
102102#endif
103103};
104104
trunk/src/osd/osdcomm.h
r31374r31375
6262#define ATTR_MALLOC
6363#define ATTR_PURE
6464#define ATTR_CONST
65#define ATTR_FORCE_INLINE      __forceinline
65#define ATTR_FORCE_INLINE       __forceinline
6666#define ATTR_NONNULL(...)
6767#define ATTR_DEPRECATED         __declspec(deprecated)
6868#define ATTR_HOT
trunk/src/osd/osdepend.h
r31374r31375
2525#define OSDOPTION_LOG                   "log"
2626#define OSDOPTION_VERBOSE               "verbose"
2727#define OSDOPTION_DEBUG                 "debug"
28#define OSDOPTION_DEBUGGER             "debugger"
28#define OSDOPTION_DEBUGGER              "debugger"
2929#define OSDOPTION_OSLOG                 "oslog"
3030#define OSDOPTION_WATCHDOG              "watchdog"
3131
r31374r31375
4949
5050#define OSDOPTION_SWITCHRES             "switchres"
5151
52#define OSDOPTION_SOUND                 "sound"
52#define OSDOPTION_SOUND                 "sound"
5353#define OSDOPTION_AUDIO_LATENCY         "audio_latency"
5454
5555#define OSDOPTVAL_AUTO                  "auto"
r31374r31375
6767   // debugging options
6868   bool verbose() const { return bool_value(OSDOPTION_VERBOSE); }
6969   bool log() const { return bool_value(OSDOPTION_LOG); }
70   bool debug() const { return bool_value(OSDOPTION_DEBUG); }   
71   const char *debugger() const { return value(OSDOPTION_DEBUGGER); }   
70   bool debug() const { return bool_value(OSDOPTION_DEBUG); }
71   const char *debugger() const { return value(OSDOPTION_DEBUGGER); }
7272   bool oslog() const { return bool_value(OSDOPTION_OSLOG); }
7373   int watchdog() const { return int_value(OSDOPTION_WATCHDOG); }
7474
r31374r31375
137137   virtual ~osd_interface();
138138
139139   void register_options(osd_options &options);
140   
140
141141   // getters
142142   running_machine &machine() const { assert(m_machine != NULL); return *m_machine; }
143143
r31374r31375
167167   // video overridables
168168   virtual void *get_slider_list();
169169
170   void init_subsystems();   
171   
170   void init_subsystems();
171
172172   virtual bool video_init();
173173   virtual void video_register();
174   
174
175175   bool sound_init();
176176   virtual void sound_register();
177177   bool no_sound();
178   
178
179179   virtual bool input_init();
180180   virtual void input_pause();
181181   virtual void input_resume();
r31374r31375
183183   virtual bool network_init();
184184   virtual bool midi_init();
185185
186   void exit_subsystems();   
186   void exit_subsystems();
187187   virtual void video_exit();
188188   void sound_exit();
189189   virtual void input_exit();
r31374r31375
192192   virtual void midi_exit();
193193
194194   virtual void osd_exit();
195   
195
196196   void video_options_add(const char *name, void *type);
197197   void sound_options_add(const char *name, osd_sound_type type);
198198   void debugger_options_add(const char *name, osd_debugger_type type);
199199
200200private:
201201   // internal state
202   running_machine *   m_machine;   
203   
202   running_machine *   m_machine;
203
204204   void update_option(osd_options &options, const char * key, dynamic_array<const char *> &values);
205   
206protected:   
205
206protected:
207207   osd_sound_interface* m_sound;
208208   osd_debugger_interface* m_debugger;
209private:   
210   //tagmap_t<osd_video_type>  m_video_options; 
209private:
210   //tagmap_t<osd_video_type>  m_video_options;
211211   dynamic_array<const char *> m_video_names;
212   tagmap_t<osd_sound_type>  m_sound_options; 
212   tagmap_t<osd_sound_type>  m_sound_options;
213213   dynamic_array<const char *> m_sound_names;
214   tagmap_t<osd_debugger_type>  m_debugger_options; 
214   tagmap_t<osd_debugger_type>  m_debugger_options;
215215   dynamic_array<const char *> m_debugger_names;
216216};
217217
r31374r31375
221221   // construction/destruction
222222   osd_sound_interface(const osd_interface &osd);
223223   virtual ~osd_sound_interface();
224   
224
225225   virtual void update_audio_stream(const INT16 *buffer, int samples_this_frame) = 0;
226226   virtual void set_mastervolume(int attenuation) = 0;
227protected:   
227protected:
228228   const osd_interface& m_osd;
229229};
230230
r31374r31375
241241   // construction/destruction
242242   osd_debugger_interface(const osd_interface &osd);
243243   virtual ~osd_debugger_interface();
244   
244
245245   virtual void init_debugger() = 0;
246246   virtual void wait_for_debugger(device_t &device, bool firststop) = 0;
247247   virtual void debugger_update() = 0;
248248   virtual void debugger_exit() = 0;
249249
250protected:   
250protected:
251251   const osd_interface& m_osd;
252252};
253253
trunk/src/osd/modules/sound/direct_sound.h
r31374r31375
2828   // construction/destruction
2929   sound_direct_sound(const osd_interface &osd);
3030   virtual ~sound_direct_sound();
31   
31
3232   virtual void update_audio_stream(const INT16 *buffer, int samples_this_frame);
3333   virtual void set_mastervolume(int attenuation);
3434
r31374r31375
3636   void         dsound_kill();
3737   HRESULT      dsound_create_buffers();
3838   void         dsound_destroy_buffers();
39   void        copy_sample_data(const INT16 *data, int bytes_to_copy);
40private:   
39   void         copy_sample_data(const INT16 *data, int bytes_to_copy);
40private:
4141};
4242
4343extern const osd_sound_type OSD_SOUND_DIRECT_SOUND;
trunk/src/osd/modules/sound/js_sound.h
r31374r31375
2121   // construction/destruction
2222   sound_js(const osd_interface &osd);
2323   virtual ~sound_js() { }
24   
24
2525   virtual void update_audio_stream(const INT16 *buffer, int samples_this_frame);
2626   virtual void set_mastervolume(int attenuation);
2727};
trunk/src/osd/modules/sound/sdl_sound.h
r31374r31375
2121   // construction/destruction
2222   sound_sdl(const osd_interface &osd);
2323   virtual ~sound_sdl();
24   
24
2525   virtual void update_audio_stream(const INT16 *buffer, int samples_this_frame);
2626   virtual void set_mastervolume(int attenuation);
2727};
trunk/src/osd/modules/sound/none.h
r31374r31375
2121   // construction/destruction
2222   sound_none(const osd_interface &osd);
2323   virtual ~sound_none() { }
24   
24
2525   virtual void update_audio_stream(const INT16 *buffer, int samples_this_frame) { }
2626   virtual void set_mastervolume(int attenuation) { }
2727};
trunk/src/osd/modules/debugger/debugqt.h
r31374r31375
2222   // construction/destruction
2323   debugger_qt(const osd_interface &osd);
2424   virtual ~debugger_qt();
25   
25
2626   virtual void init_debugger();
2727   virtual void wait_for_debugger(device_t &device, bool firststop);
2828   virtual void debugger_update();
trunk/src/osd/modules/debugger/none.h
r31374r31375
2121   // construction/destruction
2222   debugger_none(const osd_interface &osd);
2323   virtual ~debugger_none() { }
24   
24
2525   virtual void init_debugger();
2626   virtual void wait_for_debugger(device_t &device, bool firststop);
2727   virtual void debugger_update();
trunk/src/osd/modules/debugger/debugosx.h
r31374r31375
372372   // construction/destruction
373373   debugger_osx(const osd_interface &osd);
374374   virtual ~debugger_osx() { }
375   
375
376376   virtual void init_debugger();
377377   virtual void wait_for_debugger(device_t &device, bool firststop);
378378   virtual void debugger_update();
trunk/src/osd/modules/debugger/debugint.h
r31374r31375
2222   // construction/destruction
2323   debugger_internal(const osd_interface &osd);
2424   virtual ~debugger_internal() { }
25   
25
2626   virtual void init_debugger();
2727   virtual void wait_for_debugger(device_t &device, bool firststop);
2828   virtual void debugger_update();
trunk/src/osd/modules/debugger/debugwin.h
r31374r31375
2020   // construction/destruction
2121   debugger_windows(const osd_interface &osd);
2222   virtual ~debugger_windows() { }
23   
23
2424   virtual void init_debugger();
2525   virtual void wait_for_debugger(device_t &device, bool firststop);
2626   virtual void debugger_update();
trunk/src/osd/windows/winmain.h
r31374r31375
259259   virtual void video_register();
260260   virtual void sound_register();
261261   virtual void debugger_register();
262   
263   virtual bool video_init();   
262
263   virtual bool video_init();
264264   virtual bool input_init();
265265   virtual void input_pause();
266266   virtual void input_resume();
trunk/src/emu/sound/tms36xx.h
r31374r31375
4444   tms36xx_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
4545   ~tms36xx_device() { }
4646
47   static void set_subtype(device_t &device, int type)
48   {
47   static void set_subtype(device_t &device, int type)
48   {
4949      tms36xx_device &dev = downcast<tms36xx_device &>(device);
5050      switch (type)
5151      {
r31374r31375
6363         break;
6464      }
6565   }
66   static void set_tune_speed(device_t &device, double speed)
67   {
68      downcast<tms36xx_device &>(device).m_speed = (speed > 0) ? TMS36XX_VMAX / speed : TMS36XX_VMAX;
66   static void set_tune_speed(device_t &device, double speed)
67   {
68      downcast<tms36xx_device &>(device).m_speed = (speed > 0) ? TMS36XX_VMAX / speed : TMS36XX_VMAX;
6969   }
7070   static void set_decays(device_t &device, double decay_0, double decay_1, double decay_2, double decay_3, double decay_4, double decay_5)
7171   {
r31374r31375
7777      dev.m_decay_time[4] = decay_4;
7878      dev.m_decay_time[5] = decay_5;
7979   }
80   
80
8181protected:
8282   // device-level overrides
8383   virtual void device_start();
trunk/src/emu/sound/discrete.h
r31374r31375
37513751 * add and delete may be slow - the focus is on access!
37523752 */
37533753
3754 // TODO: replace with dynamic_array from utils
3754   // TODO: replace with dynamic_array from utils
37553755template<class _ElementType> struct dynamic_array_t
37563756{
37573757public:
trunk/src/emu/sound/amiga.h
r31374r31375
1818
1919// ======================> amiga_sound_device
2020
21class amiga_sound_device : public device_t,   public device_sound_interface
21class amiga_sound_device : public device_t, public device_sound_interface
2222{
2323public:
2424   amiga_sound_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
trunk/src/emu/sound/segapcm.h
r31374r31375
3838public:
3939   segapcm_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
4040   ~segapcm_device() { }
41   
41
4242   // static configuration
4343   static void set_bank(device_t &device, int bank) { downcast<segapcm_device &>(device).m_bank = bank; }
44   
44
4545   DECLARE_WRITE8_MEMBER( sega_pcm_w );
4646   DECLARE_READ8_MEMBER( sega_pcm_r );
47   
47
4848protected:
4949   // device-level overrides
5050   virtual void device_start();
trunk/src/emu/sound/vrender0.h
r31374r31375
4141protected:
4242   // device-level overrides
4343   virtual void device_start();
44   
44
4545   // sound stream update overrides
4646   virtual void sound_stream_update(sound_stream &stream, stream_sample_t **inputs, stream_sample_t **outputs, int samples);
4747
trunk/src/emu/sound/namco.h
r31374r31375
4040   // static configuration
4141   static void set_voices(device_t &device, int voices) { downcast<namco_audio_device &>(device).m_voices = voices; }
4242   static void set_stereo(device_t &device, int stereo) { downcast<namco_audio_device &>(device).m_stereo = stereo; }
43   
43
4444protected:
4545   // device-level overrides
4646   virtual void device_start();
trunk/src/emu/sound/okim6258.h
r31374r31375
8484   UINT8 m_nibble_shift;     /* nibble select */
8585   sound_stream *m_stream;   /* which stream are we playing on? */
8686
87   UINT8 m_output_bits;      /* D/A precision is 10-bits but 12-bit data can be
88                        output serially to an external DAC */
87   UINT8 m_output_bits;      /* D/A precision is 10-bits but 12-bit data can be
88                               output serially to an external DAC */
8989
9090   INT32 m_signal;
9191   INT32 m_step;
trunk/src/emu/sound/nes_apu.h
r31374r31375
4747public:
4848   nesapu_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
4949   ~nesapu_device() {}
50   
50
5151   static void set_cpu_tag(device_t &device, const char *tag) { downcast<nesapu_device &>(device).m_cpu_tag = tag; }
5252
5353   DECLARE_READ8_MEMBER( read );
trunk/src/emu/sound/rf5c68.h
r31374r31375
6262   ~rf5c68_device() { }
6363
6464   static void set_end_callback(device_t &device, rf5c68_sample_end_cb_delegate callback) { downcast<rf5c68_device &>(device).m_sample_end_cb = callback; }
65   
65
6666protected:
6767   // device-level overrides
6868   virtual void device_start();
trunk/src/emu/sound/pokey.h
r31374r31375
220220   template<class _Object> static devcb_base &set_allpot_r_callback(device_t &device, _Object object) { return downcast<pokey_device &>(device).m_allpot_r_cb.set_callback(object); }
221221   template<class _Object> static devcb_base &set_serin_r_callback(device_t &device, _Object object) { return downcast<pokey_device &>(device).m_serin_r_cb.set_callback(object); }
222222   template<class _Object> static devcb_base &set_serout_w_callback(device_t &device, _Object object) { return downcast<pokey_device &>(device).m_serout_w_cb.set_callback(object); }
223   
223
224224   DECLARE_READ8_MEMBER( read );
225225   DECLARE_WRITE8_MEMBER( write );
226226
trunk/src/emu/sound/ay8910.h
r31374r31375
7070
7171#define MCFG_AY8910_OUTPUT_TYPE(_flag) \
7272   ay8910_device::set_flags(*device, _flag);
73   
73
7474#define MCFG_AY8910_RES_LOADS(_res0, _res1, _res2) \
7575   ay8910_device::set_resistors_load(*device, _res0, _res1, _res2);
7676
r31374r31375
100100   // construction/destruction
101101   ay8910_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
102102   ay8910_device(const machine_config &mconfig, device_type type, const char *name, const char *tag, device_t *owner,
103              UINT32 clock, psg_type_t psg_type, int streams, int ioports, const char *shortname, const char *source);
103               UINT32 clock, psg_type_t psg_type, int streams, int ioports, const char *shortname, const char *source);
104104
105105   // static configuration helpers
106106   static void set_flags(device_t &device, int flags) { downcast<ay8910_device &>(device).m_flags = flags; }
107   static void set_resistors_load(device_t &device, int res_load0, int res_load1, int res_load2) { downcast<ay8910_device &>(device).m_res_load[0] = res_load0; downcast<ay8910_device &>(device).m_res_load[1] = res_load1; downcast<ay8910_device &>(device).m_res_load[2] = res_load2; }
107   static void set_resistors_load(device_t &device, int res_load0, int res_load1, int res_load2) { downcast<ay8910_device &>(device).m_res_load[0] = res_load0; downcast<ay8910_device &>(device).m_res_load[1] = res_load1; downcast<ay8910_device &>(device).m_res_load[2] = res_load2; }
108108   template<class _Object> static devcb_base &set_port_a_read_callback(device_t &device, _Object object) { return downcast<ay8910_device &>(device).m_port_a_read_cb.set_callback(object); }
109109   template<class _Object> static devcb_base &set_port_b_read_callback(device_t &device, _Object object) { return downcast<ay8910_device &>(device).m_port_b_read_cb.set_callback(object); }
110110   template<class _Object> static devcb_base &set_port_a_write_callback(device_t &device, _Object object) { return downcast<ay8910_device &>(device).m_port_a_write_cb.set_callback(object); }
111111   template<class _Object> static devcb_base &set_port_b_write_callback(device_t &device, _Object object) { return downcast<ay8910_device &>(device).m_port_b_write_cb.set_callback(object); }
112   
112
113113   DECLARE_READ8_MEMBER( data_r );
114114   DECLARE_WRITE8_MEMBER( address_w );
115115   DECLARE_WRITE8_MEMBER( data_w );
r31374r31375
125125
126126   void set_volume(int channel,int volume);
127127   void ay_set_clock(int clock);
128   
128
129129   struct ay_ym_param
130130   {
131131      double r_up;
r31374r31375
134134      double res[32];
135135   };
136136
137    struct mosfet_param
138    {
139        double m_Vth;
140        double m_Vg;
141        int    m_count;
142        double m_Kn[32];
143    };
137   struct mosfet_param
138   {
139      double m_Vth;
140      double m_Vg;
141      int    m_count;
142      double m_Kn[32];
143   };
144144
145145   void ay8910_write_ym(int addr, int data);
146146   int ay8910_read_ym();
trunk/src/emu/sound/gaelco.h
r31374r31375
5151      dev.m_banks[2] = offs3;
5252      dev.m_banks[3] = offs4;
5353   }
54   
54
5555protected:
5656   // device-level overrides
5757   virtual void device_start();
trunk/src/emu/sound/es5506.h
r31374r31375
1919
2020#define MCFG_ES5506_REGION1(_region) \
2121   es5506_device::set_region1(*device, _region);
22   
22
2323#define MCFG_ES5506_REGION2(_region) \
2424   es5506_device::set_region2(*device, _region);
25   
25
2626#define MCFG_ES5506_REGION3(_region) \
2727   es5506_device::set_region3(*device, _region);
2828
2929#define MCFG_ES5506_CHANNELS(_chan) \
3030   es5506_device::set_channels(*device, _chan);
31   
31
3232#define MCFG_ES5506_IRQ_CB(_devcb) \
3333   devcb = &es5506_device::set_irq_callback(*device, DEVCB_##_devcb);
3434
3535#define MCFG_ES5506_READ_PORT_CB(_devcb) \
36    devcb = &es5506_device::set_read_port_callback(*device, DEVCB_##_devcb);
36   devcb = &es5506_device::set_read_port_callback(*device, DEVCB_##_devcb);
3737
38   
38
3939#define MCFG_ES5505_REGION0(_region) \
4040   es5505_device::set_region0(*device, _region);
4141
4242#define MCFG_ES5505_REGION1(_region) \
4343   es5505_device::set_region1(*device, _region);
44   
44
4545#define MCFG_ES5505_CHANNELS(_chan) \
4646   es5505_device::set_channels(*device, _chan);
47   
47
4848#define MCFG_ES5505_IRQ_CB(_devcb) \
4949   devcb = &es5505_device::set_irq_callback(*device, DEVCB_##_devcb);
5050
5151#define MCFG_ES5505_READ_PORT_CB(_devcb) \
52    devcb = &es5505_device::set_read_port_callback(*device, DEVCB_##_devcb);
52   devcb = &es5505_device::set_read_port_callback(*device, DEVCB_##_devcb);
5353
5454
5555/* struct describing a single playing voice */
r31374r31375
117117public:
118118   es550x_device(const machine_config &mconfig, device_type type, const char *name, const char *tag, device_t *owner, UINT32 clock, const char *shortname, const char *source);
119119   ~es550x_device() {}
120   
120
121121   static void set_region0(device_t &device, const char *region0) { downcast<es550x_device &>(device).m_region0 = region0; }
122122   static void set_region1(device_t &device, const char *region1) { downcast<es550x_device &>(device).m_region1 = region1; }
123123   static void set_region2(device_t &device, const char *region2) { downcast<es550x_device &>(device).m_region2 = region2; }
r31374r31375
125125   static void set_channels(device_t &device, int channels) { downcast<es550x_device &>(device).m_channels = channels; }
126126   template<class _Object> static devcb_base &set_irq_callback(device_t &device, _Object object) { return downcast<es550x_device &>(device).m_irq_cb.set_callback(object); }
127127   template<class _Object> static devcb_base &set_read_port_callback(device_t &device, _Object object) { return downcast<es550x_device &>(device).m_read_port_cb.set_callback(object); }
128   
129128
129
130130protected:
131131   // device-level overrides
132132   virtual void device_start();
r31374r31375
164164   #endif
165165
166166   FILE *m_eslog;
167   
167
168168   const char * m_region0;                       /* memory region where the sample ROM lives */
169169   const char * m_region1;                       /* memory region where the sample ROM lives */
170170   const char * m_region2;                       /* memory region where the sample ROM lives */
trunk/src/emu/sound/tms5110.h
r31374r31375
8080
8181   void set_variant(int variant);
8282
83   UINT8 m_talk_status;
84   sound_stream *m_stream;
83   UINT8 m_talk_status;
84   sound_stream *m_stream;
8585
8686private:
8787   void new_int_write(UINT8 rc, UINT8 m0, UINT8 m1, UINT8 addr);
r31374r31375
107107   UINT8 m_CTL_pins;
108108   UINT8 m_speaking_now;
109109
110   
110
111111   UINT8 m_state;
112112
113113   /* Rom interface */
r31374r31375
259259   static void set_stop_bit(device_t &device, UINT8 stop_bit) { downcast<tmsprom_device &>(device).m_stop_bit = stop_bit; }
260260   template<class _Object> static devcb_base &set_pdc_callback(device_t &device, _Object object) { return downcast<tmsprom_device &>(device).m_pdc_cb.set_callback(object); }
261261   template<class _Object> static devcb_base &set_ctl_callback(device_t &device, _Object object) { return downcast<tmsprom_device &>(device).m_ctl_cb.set_callback(object); }
262   
262
263263   DECLARE_WRITE_LINE_MEMBER( m0_w );
264264   DECLARE_READ_LINE_MEMBER( data_r );
265265
r31374r31375
314314
315315#define MCFG_TMSPROM_ROM_SIZE(_size) \
316316   tmsprom_device::set_rom_size(*device, _size);
317   
317
318318#define MCFG_TMSPROM_PDC_BIT(_bit) \
319319   tmsprom_device::set_pdc_bit(*device, _bit);
320   
320
321321#define MCFG_TMSPROM_CTL1_BIT(_bit) \
322322   tmsprom_device::set_ctl1_bit(*device, _bit);
323323
324324#define MCFG_TMSPROM_CTL2_BIT(_bit) \
325325   tmsprom_device::set_ctl2_bit(*device, _bit);
326   
326
327327#define MCFG_TMSPROM_CTL4_BIT(_bit) \
328328   tmsprom_device::set_ctl4_bit(*device, _bit);
329   
329
330330#define MCFG_TMSPROM_CTL8_BIT(_bit) \
331331   tmsprom_device::set_ctl8_bit(*device, _bit);
332332
333333#define MCFG_TMSPROM_RESET_BIT(_bit) \
334334   tmsprom_device::set_reset_bit(*device, _bit);
335   
335
336336#define MCFG_TMSPROM_STOP_BIT(_bit) \
337337   tmsprom_device::set_stop_bit(*device, _bit);
338338
r31374r31375
340340   devcb = &tmsprom_device::set_pdc_callback(*device, DEVCB_##_devcb);
341341
342342#define MCFG_TMSPROM_CTL_CB(_devcb) \
343    devcb = &tmsprom_device::set_ctl_callback(*device, DEVCB_##_devcb);
343   devcb = &tmsprom_device::set_ctl_callback(*device, DEVCB_##_devcb);
344344
345345#endif /* __TMS5110_H__ */
trunk/src/emu/addrmap.h
r31374r31375
130130   write16_delegate        m_wproto16;             // 16-bit write proto-delegate
131131   write32_delegate        m_wproto32;             // 32-bit write proto-delegate
132132   write64_delegate        m_wproto64;             // 64-bit write proto-delegate
133   
133
134134   setoffset_delegate       m_soproto;              // set offset proto-delegate
135135   address_map_delegate    m_submap_delegate;
136136   int                     m_submap_bits;
trunk/src/emu/mame.h
r31374r31375
9292   emu_options &options() const { return m_options; }
9393   web_engine *web() { return &m_web; }
9494   lua_engine *lua() { return &m_lua; }
95   
95
9696   running_machine *machine() { return m_machine; }
9797
9898   void set_machine(running_machine *machine) { m_machine = machine; }
99   
99
100100   void update_machine();
101   
101
102102   /* execute as configured by the OPTION_SYSTEMNAME option on the specified options */
103103   int execute();
104104   void schedule_new_driver(const game_driver &driver);
105105private:
106106   osd_interface &         m_osd;                  // reference to OSD system
107107   emu_options &           m_options;              // reference to options
108   
109   web_engine             m_web;
110   lua_engine               m_lua;
111   
112   const game_driver *     m_new_driver_pending;   // pointer to the next pending driver   
113   
114   running_machine *m_machine;   
115   static machine_manager* m_manager;   
108
109   web_engine              m_web;
110   lua_engine              m_lua;
111
112   const game_driver *     m_new_driver_pending;   // pointer to the next pending driver
113
114   running_machine *m_machine;
115   static machine_manager* m_manager;
116116};
117117
118118//**************************************************************************
trunk/src/emu/imagedev/harddriv.h
r31374r31375
7979   MCFG_DEVICE_ADD(_tag, HARDDISK, 0)
8080
8181#define MCFG_HARDDISK_LOAD(_class,_method)                                \
82    harddisk_image_device::static_set_device_load(*device, device_image_load_delegate(&DEVICE_IMAGE_LOAD_NAME(_class,_method), #_class "::device_image_load_" #_method, downcast<_class *>(owner)));
82   harddisk_image_device::static_set_device_load(*device, device_image_load_delegate(&DEVICE_IMAGE_LOAD_NAME(_class,_method), #_class "::device_image_load_" #_method, downcast<_class *>(owner)));
8383
8484#define MCFG_HARDDISK_UNLOAD(_class,_method)                            \
85    harddisk_image_device::static_set_device_unload(*device, device_image_func_delegate(&DEVICE_IMAGE_UNLOAD_NAME(_class,_method), #_class "::device_image_unload_" #_method, downcast<_class *>(owner)));
85   harddisk_image_device::static_set_device_unload(*device, device_image_func_delegate(&DEVICE_IMAGE_UNLOAD_NAME(_class,_method), #_class "::device_image_unload_" #_method, downcast<_class *>(owner)));
8686
8787#define MCFG_HARDDISK_INTERFACE(_interface)                         \
8888   harddisk_image_device::static_set_interface(*device, _interface);
trunk/src/emu/imagedev/midiin.h
r31374r31375
2727   midiin_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
2828
2929   template<class _Object> static devcb_base &set_input_callback(device_t &device, _Object object) { return downcast<midiin_device &>(device).m_input_cb.set_callback(object); }
30   
30
3131   // image-level overrides
3232   virtual bool call_load();
3333   virtual void call_unload();
trunk/src/emu/imagedev/cassette.h
r31374r31375
107107   const struct CassetteFormat*    const *m_formats;
108108   const struct CassetteOptions    *m_create_opts;
109109   cassette_state                  m_default_state;
110   const char *                    m_interface;   
110   const char *                    m_interface;
111111};
112112
113113// device type definition
r31374r31375
124124
125125#define MCFG_CASSETTE_MODIFY(_tag) \
126126   MCFG_DEVICE_MODIFY(_tag)
127   
128#define MCFG_CASSETTE_FORMATS(_formats)   \
127
128#define MCFG_CASSETTE_FORMATS(_formats) \
129129   cassette_image_device::static_set_formats(*device, _formats);
130130
131#define MCFG_CASSETTE_CREATE_OPTS(_create_opts)   \
131#define MCFG_CASSETTE_CREATE_OPTS(_create_opts) \
132132   cassette_image_device::static_set_create_opts(*device, _create_opts);
133133
134#define MCFG_CASSETTE_DEFAULT_STATE(_state)   \
134#define MCFG_CASSETTE_DEFAULT_STATE(_state) \
135135   cassette_image_device::static_set_default_state(*device, (cassette_state) (_state));
136136
137#define MCFG_CASSETTE_INTERFACE(_interface)   \
137#define MCFG_CASSETTE_INTERFACE(_interface) \
138138   cassette_image_device::static_set_interface(*device, _interface);
139139
140140#endif /* CASSETTE_H */
trunk/src/emu/imagedev/flopdrv.h
r31374r31375
9595   ~legacy_floppy_image_device();
9696
9797   template<class _Object> static devcb_base &set_out_idx_func(device_t &device, _Object object) { return downcast<legacy_floppy_image_device &>(device).m_out_idx_func.set_callback(object); }
98   
98
9999   virtual bool call_load();
100100   virtual bool call_softlist_load(software_list_device &swlist, const char *swname, const rom_entry *start_entry) {   return load_software(swlist, swname, start_entry); }
101101   virtual bool call_create(int format_type, option_resolution *format_options);
trunk/src/emu/imagedev/diablo.h
r31374r31375
8484   MCFG_DEVICE_CONFIG(_config)
8585
8686#define MCFG_DIABLO_LOAD(_class,_method)                                \
87    diablo_image_device::static_set_device_load(*device, device_image_load_delegate(&DEVICE_IMAGE_LOAD_NAME(_class,_method), #_class "::device_image_load_" #_method, downcast<_class *>(owner)));
87   diablo_image_device::static_set_device_load(*device, device_image_load_delegate(&DEVICE_IMAGE_LOAD_NAME(_class,_method), #_class "::device_image_load_" #_method, downcast<_class *>(owner)));
8888
8989#define MCFG_DIABLO_UNLOAD(_class,_method)                            \
90    diablo_image_device::static_set_device_unload(*device, device_image_func_delegate(&DEVICE_IMAGE_UNLOAD_NAME(_class,_method), #_class "::device_image_unload_" #_method, downcast<_class *>(owner)));
90   diablo_image_device::static_set_device_unload(*device, device_image_func_delegate(&DEVICE_IMAGE_UNLOAD_NAME(_class,_method), #_class "::device_image_unload_" #_method, downcast<_class *>(owner)));
9191
9292#define MCFG_DIABLO_INTERFACE(_interface)                         \
9393   diablo_image_device::static_set_interface(*device, _interface);
trunk/src/emu/imagedev/cartslot.h
r31374r31375
4242   static void static_set_extensions(device_t &device, const char *_extensions) { downcast<cartslot_image_device &>(device).m_extensions = _extensions; }
4343   static void static_set_interface(device_t &device, const char *_interface) { downcast<cartslot_image_device &>(device).m_interface = _interface; }
4444   static void static_set_must_be_loaded(device_t &device, bool _must_be_loaded) { downcast<cartslot_image_device &>(device).m_must_be_loaded = _must_be_loaded; }
45   
45
4646   // image-level overrides
4747   virtual bool call_load();
4848   virtual void call_unload();
r31374r31375
102102   cartslot_image_device::static_set_must_be_loaded(*device, TRUE);
103103
104104#define MCFG_CARTSLOT_LOAD(_class,_method)                                \
105    cartslot_image_device::static_set_device_load(*device, device_image_load_delegate(&DEVICE_IMAGE_LOAD_NAME(_class,_method), #_class "::device_image_load_" #_method, downcast<_class *>(owner)));
105   cartslot_image_device::static_set_device_load(*device, device_image_load_delegate(&DEVICE_IMAGE_LOAD_NAME(_class,_method), #_class "::device_image_load_" #_method, downcast<_class *>(owner)));
106106
107107#define MCFG_CARTSLOT_UNLOAD(_class,_method)                            \
108    cartslot_image_device::static_set_device_unload(*device, device_image_func_delegate(&DEVICE_IMAGE_UNLOAD_NAME(_class,_method), #_class "::device_image_unload_" #_method, downcast<_class *>(owner)));
108   cartslot_image_device::static_set_device_unload(*device, device_image_func_delegate(&DEVICE_IMAGE_UNLOAD_NAME(_class,_method), #_class "::device_image_unload_" #_method, downcast<_class *>(owner)));
109109
110110#define MCFG_CARTSLOT_PARTIALHASH(_partialhash)                  \
111111   cartslot_image_device::static_set_partialhash(*device, _partialhash);
trunk/src/emu/video.h
r31374r31375
170170   attotime            m_mng_frame_period;         // period of a single movie frame
171171   attotime            m_mng_next_frame_time;      // time of next frame
172172   UINT32              m_mng_frame;                // current movie frame number
173   
173
174174   // movie recording - AVI
175175   avi_file *          m_avi_file;                 // handle to the open movie file
176176   attotime            m_avi_frame_period;         // period of a single movie frame
trunk/src/emu/memory.h
r31374r31375
439439   UINT64 *install_read_handler(offs_t addrstart, offs_t addrend, offs_t addrmask, offs_t addrmirror, read64_delegate rhandler, UINT64 unitmask = 0);
440440   UINT64 *install_write_handler(offs_t addrstart, offs_t addrend, offs_t addrmask, offs_t addrmirror, write64_delegate whandler, UINT64 unitmask = 0);
441441   UINT64 *install_readwrite_handler(offs_t addrstart, offs_t addrend, offs_t addrmask, offs_t addrmirror, read64_delegate rhandler, write64_delegate whandler, UINT64 unitmask = 0);
442   
442
443443   // setup
444444   void prepare_map();
445445   void populate_from_map(address_map *map = NULL);
trunk/src/emu/luaengine.h
r31374r31375
4444      int cb;
4545
4646      hook();
47       void set(lua_State *L, int idx);
47      void set(lua_State *L, int idx);
4848      lua_State *precall();
4949      void call(lua_engine *engine, lua_State *T, int nparam);
5050      bool active() const { return L != NULL; }
5151   };
52   
52
5353   static const char *const tname_ioport;
5454
5555   // internal state
r31374r31375
5858
5959   hook hook_output_cb;
6060   bool output_notifier_set;
61   
61
6262   static lua_engine*  luaThis;
6363
6464   std::map<lua_State *, std::pair<lua_State *, int> > thread_registry;
r31374r31375
9393   static void *checkparam(lua_State *L, int idx, const char *tname);
9494   static void *getparam(lua_State *L, int idx, const char *tname);
9595   static void push(lua_State *L, void *p, const char *tname);
96   
96
9797   int report(int status);
9898   int docall(int narg, int nres);
9999   int incomplete(int status) ;
trunk/src/emu/cpu/m68000/m68kmmu.h
r31374r31375
774774
775775            if (!(ptest))
776776            {
777               page_entry |= 0x8;   // always set the U bit
777               page_entry |= 0x8;  // always set the U bit
778778
779779               // if we're writing, the M bit comes into play
780780               if (!m68k->mmu_tmp_rw)
781781               {
782                  page_entry |= 0x10;   // set Modified
782                  page_entry |= 0x10; // set Modified
783783               }
784784
785785               // if these updates resulted in a change, write the entry back where we found it
r31374r31375
795795               // SR:         B  G U1 U0 S CM CM M 0 W T R
796796               m68k->mmu_tmp_sr |= ((addr_out & ~0xfff) || (page_entry & 0x7f4));
797797            }
798            break;
798            break;
799799
800800         case 2: // shouldn't happen
801801            fatalerror("68040: got indirect final page pointer, shouldn't be possible\n");
trunk/src/emu/cpu/m68000/m68000.h
r31374r31375
252252   const UINT8* cyc_exception;
253253
254254   /* Callbacks to host */
255   device_irq_acknowledge_delegate int_ack_callback;   /* Interrupt Acknowledge */
256   write32_delegate bkpt_ack_callback;               /* Breakpoint Acknowledge */
257   write_line_delegate reset_instr_callback;         /* Called when a RESET instruction is encountered */
258   write32_delegate cmpild_instr_callback;            /* Called when a CMPI.L #v, Dn instruction is encountered */
259   write_line_delegate rte_instr_callback;            /* Called when a RTE instruction is encountered */
260   write8_delegate tas_write_callback;               /* Called instead of normal write8 by the TAS instruction,
261                                             allowing writeback to be disabled globally or selectively
262                                             or other side effects to be implemented */
255   device_irq_acknowledge_delegate int_ack_callback;   /* Interrupt Acknowledge */
256   write32_delegate bkpt_ack_callback;                 /* Breakpoint Acknowledge */
257   write_line_delegate reset_instr_callback;           /* Called when a RESET instruction is encountered */
258   write32_delegate cmpild_instr_callback;             /* Called when a CMPI.L #v, Dn instruction is encountered */
259   write_line_delegate rte_instr_callback;             /* Called when a RTE instruction is encountered */
260   write8_delegate tas_write_callback;                 /* Called instead of normal write8 by the TAS instruction,
261                                                            allowing writeback to be disabled globally or selectively
262                                                            or other side effects to be implemented */
263263
264264   address_space *program;
265265
trunk/src/emu/cpu/mb86233/mb86233.h
r31374r31375
103103   UINT32          m_shift;
104104   UINT32          m_repcnt;
105105   UINT16          m_sr;
106   UINT8          m_fpucontrol;
106   UINT8           m_fpucontrol;
107107
108108   UINT32          m_gpr[16];
109109   UINT32          m_extport[0x30];
trunk/src/emu/cpu/mips/mips3.h
r31374r31375
359359   /* core state */
360360   internal_mips3_state *m_core;
361361
362    /* internal stuff */
362   /* internal stuff */
363363   UINT32      m_ppc;
364364   UINT32      m_nextpc;
365365   UINT32      m_pcbase;
r31374r31375
444444
445445   /* fast RAM */
446446   UINT32              m_fastram_select;
447   struct
447   struct
448448   {
449449      offs_t              start;                      /* start of the RAM block */
450450      offs_t              end;                        /* end of the RAM block */
trunk/src/emu/cpu/upd7725/upd7725.h
r31374r31375
6363
6464#define MCFG_NECDSP_OUT_DRQ_CB(_devcb) \
6565   devcb = &necdsp_device::set_out_drq_callback(*device, DEVCB_##_devcb);
66   
6766
67
6868// ======================> necdsp_device
6969
7070class necdsp_device : public cpu_device
r31374r31375
8686   //template<class _Object> static devcb_base &set_out_so_callback(device_t &device, _Object object) { return downcast<necdsp_device &>(device).m_out_so_cb.set_callback(object); }
8787   //template<class _Object> static devcb_base &set_out_sorq_callback(device_t &device, _Object object) { return downcast<necdsp_device &>(device).m_out_sorq_cb.set_callback(object); }
8888   //template<class _Object> static devcb_base &set_out_drq_callback(device_t &device, _Object object) { return downcast<necdsp_device &>(device).m_out_drq_cb.set_callback(object); }
89   
89
9090   UINT8 snesdsp_read(bool mode);
9191   void snesdsp_write(bool mode, UINT8 data);
9292
trunk/src/emu/cpu/cpu.mak
r31374r31375
17801780endif
17811781
17821782$(CPUOBJ)/upd7810/upd7810_opcodes.o: $(CPUSRC)/upd7810/upd7810_opcodes.c \
1783                                     $(CPUSRC)/upd7810/upd7810_macros.h
1783                              $(CPUSRC)/upd7810/upd7810_macros.h
17841784
17851785$(CPUOBJ)/upd7810/upd7810.o:    $(CPUSRC)/upd7810/upd7810.c \
17861786                        $(CPUSRC)/upd7810/upd7810.h \
trunk/src/emu/cpu/scudsp/scudsp.h
r31374r31375
6161public:
6262   // construction/destruction
6363   scudsp_cpu_device(const machine_config &mconfig, const char *_tag, device_t *_owner, UINT32 _clock);
64   
64
6565   template<class _Object> static devcb_base &set_out_irq_callback(device_t &device, _Object object) { return downcast<scudsp_cpu_device &>(device).m_out_irq_cb.set_callback(object); }
6666   template<class _Object> static devcb_base &set_in_dma_callback(device_t &device, _Object object) { return downcast<scudsp_cpu_device &>(device).m_in_dma_cb.set_callback(object); }
6767   template<class _Object> static devcb_base &set_out_dma_callback(device_t &device, _Object object) { return downcast<scudsp_cpu_device &>(device).m_out_dma_cb.set_callback(object); }
68   
68
6969   /* port 0 */
7070   DECLARE_READ32_MEMBER( program_control_r );
7171   DECLARE_WRITE32_MEMBER( program_control_w );
r31374r31375
104104   devcb_write_line     m_out_irq_cb;
105105   devcb_read16         m_in_dma_cb;
106106   devcb_write16        m_out_dma_cb;
107   
107
108108private:
109109   address_space_config m_program_config;
110110   address_space_config m_data_config;
trunk/src/emu/cpu/g65816/g65816op.h
r31374r31375
19151915
19161916
19171917#if EXECUTION_MODE == EXECUTION_MODE_E
1918#define g65816i_correct_mode()   (FLAG_E == EFLAG_SET)
1918#define g65816i_correct_mode()  (FLAG_E == EFLAG_SET)
19191919#elif EXECUTION_MODE == EXECUTION_MODE_M0X0
1920#define g65816i_correct_mode()   ((FLAG_E == EFLAG_CLEAR) && (FLAG_M == MFLAG_CLEAR) && (FLAG_X == XFLAG_CLEAR))
1920#define g65816i_correct_mode()  ((FLAG_E == EFLAG_CLEAR) && (FLAG_M == MFLAG_CLEAR) && (FLAG_X == XFLAG_CLEAR))
19211921#elif EXECUTION_MODE == EXECUTION_MODE_M0X1
1922#define g65816i_correct_mode()   ((FLAG_E == EFLAG_CLEAR) && (FLAG_M == MFLAG_CLEAR) && (FLAG_X == XFLAG_SET))
1922#define g65816i_correct_mode()  ((FLAG_E == EFLAG_CLEAR) && (FLAG_M == MFLAG_CLEAR) && (FLAG_X == XFLAG_SET))
19231923#elif EXECUTION_MODE == EXECUTION_MODE_M1X0
1924#define g65816i_correct_mode()   ((FLAG_E == EFLAG_CLEAR) && (FLAG_M == MFLAG_SET) && (FLAG_X == XFLAG_CLEAR))
1924#define g65816i_correct_mode()  ((FLAG_E == EFLAG_CLEAR) && (FLAG_M == MFLAG_SET) && (FLAG_X == XFLAG_CLEAR))
19251925#elif EXECUTION_MODE == EXECUTION_MODE_M1X1
1926#define g65816i_correct_mode()   ((FLAG_E == EFLAG_CLEAR) && (FLAG_M == MFLAG_SET) && (FLAG_X == XFLAG_SET))
1926#define g65816i_correct_mode()  ((FLAG_E == EFLAG_CLEAR) && (FLAG_M == MFLAG_SET) && (FLAG_X == XFLAG_SET))
19271927#else
19281928#error Invalid EXECUTION_MODE
19291929#endif
trunk/src/emu/cpu/rsp/rsp.h
r31374r31375
145145
146146#define MCFG_RSP_DP_REG_R_CB(_devcb) \
147147   devcb = &rsp_cpu_device::static_set_dp_reg_r_callback(*device, DEVCB_##_devcb);
148
148
149149#define MCFG_RSP_DP_REG_W_CB(_devcb) \
150150   devcb = &rsp_cpu_device::static_set_dp_reg_w_callback(*device, DEVCB_##_devcb);
151
151
152152#define MCFG_RSP_SP_REG_R_CB(_devcb) \
153153   devcb = &rsp_cpu_device::static_set_sp_reg_r_callback(*device, DEVCB_##_devcb);
154
154
155155#define MCFG_RSP_SP_REG_W_CB(_devcb) \
156156   devcb = &rsp_cpu_device::static_set_sp_reg_w_callback(*device, DEVCB_##_devcb);
157157
r31374r31375
163163protected:
164164   // construction/destruction
165165   rsp_cpu_device(const machine_config &mconfig, device_type type, const char *tag, device_t *owner, UINT32 clock, cpu_get_info_func info);
166   
166
167167public:
168168   void resolve_cb();
169169   template<class _Object> static devcb_base &static_set_dp_reg_r_callback(device_t &device, _Object object) { return downcast<rsp_cpu_device &>(device).dp_reg_r_func.set_callback(object); }
r31374r31375
171171   template<class _Object> static devcb_base &static_set_sp_reg_r_callback(device_t &device, _Object object) { return downcast<rsp_cpu_device &>(device).sp_reg_r_func.set_callback(object); }
172172   template<class _Object> static devcb_base &static_set_sp_reg_w_callback(device_t &device, _Object object) { return downcast<rsp_cpu_device &>(device).sp_reg_w_func.set_callback(object); }
173173   template<class _Object> static devcb_base &static_set_status_callback(device_t &device, _Object object) { return downcast<rsp_cpu_device &>(device).sp_set_status_func.set_callback(object); }
174   
175174
175
176176   devcb_read32 dp_reg_r_func;
177177   devcb_write32 dp_reg_w_func;
178178   devcb_read32 sp_reg_r_func;
179179   devcb_write32 sp_reg_w_func;
180   devcb_write32 sp_set_status_func;   
180   devcb_write32 sp_set_status_func;
181181};
182182
183183
trunk/src/emu/cpu/minx/minxfunc.h
r31374r31375
360360#define AD2_Y8  UINT32 addr2 = ( m_YI << 16 ) | ( m_Y + rdop() )
361361#define AD2_XL  UINT32 addr2 = ( m_XI << 16 ) | ( m_X + ( m_HL & 0x00FF ) )
362362#define AD2_YL  UINT32 addr2 = ( m_YI << 16 ) | ( m_Y + ( m_HL & 0x00FF ) )
363
trunk/src/emu/cpu/minx/minxops.h
r31374r31375
559559   8,  8,  8,  8,  8,  8,  8,  8, 12, 12, 12, 12, 12, 12, 12, 12,
560560   20,  8, 24, 12,  8,  1,  8, 12,  8,  8,  8, 20, 20,  1,  1,  8
561561};
562
trunk/src/emu/cpu/powerpc/ppc.h
r31374r31375
695695//class ppc403_device : public ppc_device
696696//{
697697//public:
698//   ppc403_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
698//  ppc403_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
699699//
700700//protected:
701//   virtual UINT32 execute_input_lines() const { return 8; }
701//  virtual UINT32 execute_input_lines() const { return 8; }
702702//};
703703//
704704//
705705//class ppc405_device : public ppc_device
706706//{
707707//public:
708//   ppc405_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
708//  ppc405_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
709709//
710710//protected:
711//   virtual UINT32 execute_input_lines() const { return 8; }
711//  virtual UINT32 execute_input_lines() const { return 8; }
712712//};
713713
714714
trunk/src/emu/cpu/adsp2100/adsp2100.h
r31374r31375
456456   UINT16              m_mask_table[0x4000];
457457   UINT16              m_reverse_table[0x4000];
458458
459   devcb_read32           m_sport_rx_cb;    // callback for serial receive
460   devcb_write32           m_sport_tx_cb;    // callback for serial transmit
461   devcb_write_line        m_timer_fired_cb;          // callback for timer fired
459   devcb_read32            m_sport_rx_cb;    // callback for serial receive
460   devcb_write32           m_sport_tx_cb;    // callback for serial transmit
461   devcb_write_line        m_timer_fired_cb;          // callback for timer fired
462462
463463   // debugging
464464#if ADSP_TRACK_HOTSPOTS
trunk/src/emu/cpu/sh2/sh2.h
r31374r31375
519519class sh2_frontend : public drc_frontend
520520{
521521public:
522    sh2_frontend(sh2_device *device, UINT32 window_start, UINT32 window_end, UINT32 max_sequence);
522   sh2_frontend(sh2_device *device, UINT32 window_start, UINT32 window_end, UINT32 max_sequence);
523523
524524protected:
525    virtual bool describe(opcode_desc &desc, const opcode_desc *prev);
525   virtual bool describe(opcode_desc &desc, const opcode_desc *prev);
526526
527527private:
528    bool describe_group_0(opcode_desc &desc, const opcode_desc *prev, UINT16 opcode);
529    bool describe_group_2(opcode_desc &desc, const opcode_desc *prev, UINT16 opcode);
530    bool describe_group_3(opcode_desc &desc, const opcode_desc *prev, UINT16 opcode);
531    bool describe_group_4(opcode_desc &desc, const opcode_desc *prev, UINT16 opcode);
532    bool describe_group_6(opcode_desc &desc, const opcode_desc *prev, UINT16 opcode);
533    bool describe_group_8(opcode_desc &desc, const opcode_desc *prev, UINT16 opcode);
534    bool describe_group_12(opcode_desc &desc, const opcode_desc *prev, UINT16 opcode);
528   bool describe_group_0(opcode_desc &desc, const opcode_desc *prev, UINT16 opcode);
529   bool describe_group_2(opcode_desc &desc, const opcode_desc *prev, UINT16 opcode);
530   bool describe_group_3(opcode_desc &desc, const opcode_desc *prev, UINT16 opcode);
531   bool describe_group_4(opcode_desc &desc, const opcode_desc *prev, UINT16 opcode);
532   bool describe_group_6(opcode_desc &desc, const opcode_desc *prev, UINT16 opcode);
533   bool describe_group_8(opcode_desc &desc, const opcode_desc *prev, UINT16 opcode);
534   bool describe_group_12(opcode_desc &desc, const opcode_desc *prev, UINT16 opcode);
535535
536536   sh2_device *m_sh2;
537537};
trunk/src/emu/cpu/sharc/sharcops.inc
r31374r31375
823823               case 0x62:      compute_max(rn, rx, ry); break;
824824               case 0x81:      compute_fadd(rn, rx, ry); break;
825825               case 0x82:      compute_fsub(rn, rx, ry); break;
826               case 0x89:      compute_favg(rn, rx, ry); break;
826               case 0x89:      compute_favg(rn, rx, ry); break;
827827               case 0x8a:      compute_fcomp(rx, ry); break;
828828               case 0x91:      compute_fabs_plus(rn, rx, ry); break;
829829               case 0xa1:      compute_fpass(rn, rx); break;
trunk/src/emu/cpu/tms7000/tms7000.h
r31374r31375
6565   DECLARE_WRITE8_MEMBER(tms7000_pf_w);
6666   DECLARE_READ8_MEMBER(tms7002_pf_r) { return tms7000_pf_r(space, offset + 0x10); }
6767   DECLARE_WRITE8_MEMBER(tms7002_pf_w) { tms7000_pf_w(space, offset + 0x10, data); }
68   
68
6969   bool chip_is_cmos() { return (m_info_flags & TMS7000_CHIP_IS_CMOS) ? true : false; }
7070   UINT32 chip_get_family() { return m_info_flags & TMS7000_CHIP_FAMILY_MASK; }
7171   bool chip_is_family_70x0() { return chip_get_family() == TMS7000_CHIP_FAMILY_70X0; }
r31374r31375
128128
129129   UINT8 m_port_latch[4];
130130   UINT8 m_port_ddr[4];
131   
131
132132   void flag_ext_interrupt(int extline);
133133   void check_interrupts();
134134   void do_interrupt(int irqline);
135   
135
136136   TIMER_CALLBACK_MEMBER(simple_timer_cb);
137137   void timer_run(int tmr);
138138   void timer_reload(int tmr);
139139   void timer_tick_pre(int tmr);
140140   void timer_tick_low(int tmr);
141   
141
142142   // internal read/write
143143   inline UINT8 read_r8(UINT8 address) { return m_program->read_byte(address); }
144144   inline void write_r8(UINT8 address, UINT8 data) { m_program->write_byte(address, data); }
r31374r31375
160160   inline void push8(UINT8 data) { m_program->write_byte(++m_sp, data); }
161161   inline UINT16 pull16() { UINT16 ret = m_program->read_byte(m_sp--); return ret | m_program->read_byte(m_sp--) << 8; }
162162   inline void push16(UINT16 data) { m_program->write_byte(++m_sp, data >> 8 & 0xff); m_program->write_byte(++m_sp, data & 0xff); }
163   
163
164164   // opcode handlers
165165   void br_dir();
166166   void br_inx();
r31374r31375
202202   void stsp();
203203   void trap(UINT8 address);
204204   void illegal(UINT8 op);
205   
205
206206   typedef int (tms7000_device::*op_func)(UINT8, UINT8);
207207   int op_clr(UINT8 param1, UINT8 param2);
208208   int op_dec(UINT8 param1, UINT8 param2);
r31374r31375
214214   int op_rrc(UINT8 param1, UINT8 param2);
215215   int op_swap(UINT8 param1, UINT8 param2);
216216   int op_xchb(UINT8 param1, UINT8 param2);
217   
217
218218   int op_adc(UINT8 param1, UINT8 param2);
219219   int op_add(UINT8 param1, UINT8 param2);
220220   int op_and(UINT8 param1, UINT8 param2);
r31374r31375
227227   int op_sbb(UINT8 param1, UINT8 param2);
228228   int op_sub(UINT8 param1, UINT8 param2);
229229   int op_xor(UINT8 param1, UINT8 param2);
230   
230
231231   inline void shortbranch(bool check);
232232   inline void jmp(bool check);
233233   int op_djnz(UINT8 param1, UINT8 param2);
trunk/src/emu/cpu/tms7000/tms70op.inc
r31374r31375
307307   UINT8 l1 = param1 >> 0 & 0xf;
308308   UINT8 h2 = param2 >> 4 & 0xf;
309309   UINT8 l2 = param2 >> 0 & 0xf;
310   
310
311311   // compute bcd constant
312312   UINT8 d = ((l1 + l2 + c) < 10) ? 0 : 1;
313313   if ((h1 + h2) == 9)
314314      d |= 2;
315315   else if ((h1 + h2) > 9)
316316      d |= 4;
317   
317
318318   UINT8 t = param1 + param2 + c + lut_bcd_out[d];
319319   SET_CNZ(t);
320320   if (d > 2)
321321      m_sr |= SR_C;
322   
322
323323   return t;
324324}
325325
r31374r31375
344344   SET_CNZ(t);
345345   if (d <= 2)
346346      m_sr |= SR_C;
347   
347
348348   return t;
349349}
350350
trunk/src/emu/cpu/z80/tmpz84c015.h
r31374r31375
122122   template<class _Object> static devcb_base &set_out_syncb_callback(device_t &device, _Object object) { return downcast<tmpz84c015_device &>(device).m_out_syncb_cb.set_callback(object); }
123123
124124   template<class _Object> static devcb_base &set_out_rxdrqa_callback(device_t &device, _Object object) { return downcast<tmpz84c015_device &>(device).m_out_rxdrqa_cb.set_callback(object); }
125   template<class _Object> static devcb_base &set_out_txdrqa_callback(device_t &device, _Object object) { return downcast<tmpz84c015_device &>(device).m_out_txdrqa_cb.set_callback(object); }   
125   template<class _Object> static devcb_base &set_out_txdrqa_callback(device_t &device, _Object object) { return downcast<tmpz84c015_device &>(device).m_out_txdrqa_cb.set_callback(object); }
126126   template<class _Object> static devcb_base &set_out_rxdrqb_callback(device_t &device, _Object object) { return downcast<tmpz84c015_device &>(device).m_out_rxdrqb_cb.set_callback(object); }
127   template<class _Object> static devcb_base &set_out_txdrqb_callback(device_t &device, _Object object) { return downcast<tmpz84c015_device &>(device).m_out_txdrqb_cb.set_callback(object); }   
128   
127   template<class _Object> static devcb_base &set_out_txdrqb_callback(device_t &device, _Object object) { return downcast<tmpz84c015_device &>(device).m_out_txdrqb_cb.set_callback(object); }
128
129129   template<class _Object> static devcb_base &set_zc0_callback(device_t &device, _Object object) { return downcast<tmpz84c015_device &>(device).m_zc0_cb.set_callback(object); }
130130   template<class _Object> static devcb_base &set_zc1_callback(device_t &device, _Object object) { return downcast<tmpz84c015_device &>(device).m_zc1_cb.set_callback(object); }
131131   template<class _Object> static devcb_base &set_zc2_callback(device_t &device, _Object object) { return downcast<tmpz84c015_device &>(device).m_zc2_cb.set_callback(object); }
r31374r31375
171171   DECLARE_READ8_MEMBER( pa_r ) { return m_pio->pa_r(space, offset, mem_mask); }
172172   DECLARE_WRITE8_MEMBER( pb_w ) { m_pio->pb_w(space, offset, data, mem_mask); }
173173   DECLARE_READ8_MEMBER( pb_r ) { return m_pio->pb_r(space, offset, mem_mask); }
174   
174
175175   /////////////////////////////////////////////////////////
176176
177177   DECLARE_WRITE8_MEMBER( irq_priority_w );
r31374r31375
204204   DECLARE_READ8_MEMBER( in_pb_cb_trampoline_r ) { return m_in_pb_cb(); }
205205   DECLARE_WRITE8_MEMBER( out_pb_cb_trampoline_w ) { m_out_pb_cb(data); }
206206   DECLARE_WRITE_LINE_MEMBER( out_brdy_cb_trampoline_w ) { m_out_brdy_cb(state); }
207   
207
208208protected:
209209   // device-level overrides
210210   virtual machine_config_constructor device_mconfig_additions() const;
r31374r31375
231231
232232   // internal state
233233   UINT8 m_irq_priority;
234   
234
235235   // callbacks
236236   devcb_write_line m_out_txda_cb;
237237   devcb_write_line m_out_dtra_cb;
238238   devcb_write_line m_out_rtsa_cb;
239239   devcb_write_line m_out_wrdya_cb;
240240   devcb_write_line m_out_synca_cb;
241   
241
242242   devcb_write_line m_out_txdb_cb;
243243   devcb_write_line m_out_dtrb_cb;
244244   devcb_write_line m_out_rtsb_cb;
245245   devcb_write_line m_out_wrdyb_cb;
246246   devcb_write_line m_out_syncb_cb;
247   
247
248248   devcb_write_line m_out_rxdrqa_cb;
249249   devcb_write_line m_out_txdrqa_cb;
250250   devcb_write_line m_out_rxdrqb_cb;
r31374r31375
257257   devcb_read8 m_in_pa_cb;
258258   devcb_write8 m_out_pa_cb;
259259   devcb_write_line m_out_ardy_cb;
260   
260
261261   devcb_read8 m_in_pb_cb;
262262   devcb_write8 m_out_pb_cb;
263263   devcb_write_line m_out_brdy_cb;
trunk/src/emu/cpu/z80/tmpz84c011.h
r31374r31375
9797   DECLARE_WRITE_LINE_MEMBER( trg1 ) { m_ctc->trg1(state); }
9898   DECLARE_WRITE_LINE_MEMBER( trg2 ) { m_ctc->trg2(state); }
9999   DECLARE_WRITE_LINE_MEMBER( trg3 ) { m_ctc->trg3(state); }
100   
100
101101   /////////////////////////////////////////////////////////
102102
103103   DECLARE_READ8_MEMBER( tmpz84c011_pa_r );
trunk/src/emu/machine/74123.h
r31374r31375
6161
6262#define MCFG_TTL74123_RESISTOR_VALUE(_value) \
6363   ttl74123_device::set_resistor_value(*device, _value);
64   
64
6565#define MCFG_TTL74123_CAPACITOR_VALUE(_value) \
6666   ttl74123_device::set_capacitor_value(*device, _value);
6767
6868#define MCFG_TTL74123_A_PIN_VALUE(_value) \
6969   ttl74123_device::set_a_pin_value(*device, _value);
70   
70
7171#define MCFG_TTL74123_B_PIN_VALUE(_value) \
7272   ttl74123_device::set_b_pin_value(*device, _value);
7373
r31374r31375
7575   ttl74123_device::set_clear_pin_value(*device, _value);
7676
7777#define MCFG_TTL74123_OUTPUT_CHANGED_CB(_devcb) \
78    devcb = &ttl74123_device::set_output_changed_callback(*device, DEVCB_##_devcb);
78   devcb = &ttl74123_device::set_output_changed_callback(*device, DEVCB_##_devcb);
7979
8080/* constants for the different ways the cap/res can be connected.
8181   This determines the formula for calculating the pulse width */
r31374r31375
103103   static void set_b_pin_value(device_t &device, int value) { downcast<ttl74123_device &>(device).m_b = value; }
104104   static void set_clear_pin_value(device_t &device, int value) { downcast<ttl74123_device &>(device).m_clear = value; }
105105   template<class _Object> static devcb_base &set_output_changed_callback(device_t &device, _Object object) { return downcast<ttl74123_device &>(device).m_output_changed_cb.set_callback(object); }
106   
106
107107   DECLARE_WRITE8_MEMBER(a_w);
108108   DECLARE_WRITE8_MEMBER(b_w);
109109   DECLARE_WRITE8_MEMBER(clear_w);
trunk/src/emu/machine/mc6854.h
r31374r31375
4747   static void set_out_frame_callback(device_t &device, mc6854_out_frame_delegate callback) { downcast<mc6854_device &>(device).m_out_frame_cb = callback; }
4848   template<class _Object> static devcb_base &set_out_rts_callback(device_t &device, _Object object) { return downcast<mc6854_device &>(device).m_out_rts_cb.set_callback(object); }
4949   template<class _Object> static devcb_base &set_out_dtr_callback(device_t &device, _Object object) { return downcast<mc6854_device &>(device).m_out_dtr_cb.set_callback(object); }
50   
50
5151   /* interface to CPU via address/data bus*/
5252   DECLARE_READ8_MEMBER( read );
5353   DECLARE_WRITE8_MEMBER( write );
r31374r31375
7474private:
7575   // internal state
7676   devcb_write_line  m_out_irq_cb; /* interrupt request */
77   
77
7878   /* low-level, bit-based interface */
7979   devcb_write_line  m_out_txd_cb; /* transmit bit */
80   
81    /* high-level, frame-based interface */
82   mc6854_out_frame_delegate   m_out_frame_cb;
83   
80
81      /* high-level, frame-based interface */
82   mc6854_out_frame_delegate   m_out_frame_cb;
83
8484   /* control lines */
8585   devcb_write_line  m_out_rts_cb; /* 1 = transmitting, 0 = idle */
8686   devcb_write_line  m_out_dtr_cb; /* 1 = data transmit ready, 0 = busy */
trunk/src/emu/machine/upd71071.h
r31374r31375
2626public:
2727   upd71071_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
2828   ~upd71071_device() {}
29   
29
3030   static void static_set_cpu_tag(device_t &device, const char *tag) { downcast<upd71071_device &>(device).m_cpu.set_tag(tag); }
3131   static void set_clock(device_t &device, int clock) { downcast<upd71071_device &>(device).m_upd_clock = clock; }
3232   template<class _Object> static devcb_base &set_out_hreq_callback(device_t &device, _Object object) { return downcast<upd71071_device &>(device).m_out_hreq_cb.set_callback(object); }
r31374r31375
9898
9999#define MCFG_UPD71071_CLOCK(_clk) \
100100   upd71071_device::set_clock(*device, _clk);
101   
101
102102#define MCFG_UPD71071_OUT_HREQ_CB(_devcb) \
103103   devcb = &upd71071_device::set_out_hreq_callback(*device, DEVCB_##_devcb);
104104
trunk/src/emu/machine/z80dma.h
r31374r31375
8383   template<class _Object> static devcb_base &set_out_mreq_callback(device_t &device, _Object object) { return downcast<z80dma_device &>(device).m_out_mreq_cb.set_callback(object); }
8484   template<class _Object> static devcb_base &set_in_iorq_callback(device_t &device, _Object object) { return downcast<z80dma_device &>(device).m_in_iorq_cb.set_callback(object); }
8585   template<class _Object> static devcb_base &set_out_iorq_callback(device_t &device, _Object object) { return downcast<z80dma_device &>(device).m_out_iorq_cb.set_callback(object); }
86   
86
8787   UINT8 read();
8888   void write(UINT8 data);
8989   DECLARE_READ8_MEMBER( read ) { return read(); }
trunk/src/emu/machine/dmac.h
r31374r31375
2323//**************************************************************************
2424
2525#define MCFG_DMAC_ADD(_tag, _clock) \
26   MCFG_DEVICE_ADD(_tag, DMAC, _clock) \
27
26   MCFG_DEVICE_ADD(_tag, DMAC, _clock)
2827#define MCFG_DMAC_CFGOUT_HANDLER(_devcb) \
2928   devcb = &dmac_device::set_cfgout_handler(*device, DEVCB_##_devcb);
3029
r31374r31375
109108   // control register flags
110109   enum
111110   {
112      CNTR_TCEN  = 0x80,   // terminal count enable
113      CNTR_PREST = 0x40,   // peripheral reset
114      CNTR_PDMD  = 0x20,    // peripheral device mode select (1=scsi, 0=xt)
115      CNTR_INTEN = 0x10,   // interrupt enable
116      CNTR_DDIR  = 0x08    // device direction (1=rd host, wr to peripheral)
111      CNTR_TCEN  = 0x80,  // terminal count enable
112      CNTR_PREST = 0x40,  // peripheral reset
113      CNTR_PDMD  = 0x20,  // peripheral device mode select (1=scsi, 0=xt)
114      CNTR_INTEN = 0x10,  // interrupt enable
115      CNTR_DDIR  = 0x08   // device direction (1=rd host, wr to peripheral)
117116   };
118117
119118   // interrupt status register
120119   enum
121120   {
122      ISTR_INTX   = 0x100,   // xt interrupt pending
123      ISTR_INT_F  = 0x080,   // interrupt follow
124      ISTR_INTS   = 0x040,   // scsi peripheral interrupt
125      ISTR_E_INT  = 0x020,   // end-of-process interrupt
126      ISTR_INT_P  = 0x010,   // interrupt pending
127      ISTR_UE_INT = 0x008,   // under-run fifo error interrupt
128      ISTR_OE_INT = 0x004,   // over-run fifo error interrupt
129      ISTR_FF_FLG = 0x002,   // fifo-full flag
130      ISTR_FE_FLG = 0x001      // fifo-empty flag
121      ISTR_INTX   = 0x100,    // xt interrupt pending
122      ISTR_INT_F  = 0x080,    // interrupt follow
123      ISTR_INTS   = 0x040,    // scsi peripheral interrupt
124      ISTR_E_INT  = 0x020,    // end-of-process interrupt
125      ISTR_INT_P  = 0x010,    // interrupt pending
126      ISTR_UE_INT = 0x008,    // under-run fifo error interrupt
127      ISTR_OE_INT = 0x004,    // over-run fifo error interrupt
128      ISTR_FF_FLG = 0x002,    // fifo-full flag
129      ISTR_FE_FLG = 0x001     // fifo-empty flag
131130   };
132131
133132   static const int ISTR_INT_MASK = 0x1fc;
r31374r31375
153152   int m_rst;
154153
155154   // register
156   UINT16 m_cntr;   // control register
157   UINT16 m_istr;   // interrupt status register
158   UINT32 m_wtc;   // word transfer count
159   UINT32 m_acr;   // address control register
155   UINT16 m_cntr;  // control register
156   UINT16 m_istr;  // interrupt status register
157   UINT32 m_wtc;   // word transfer count
158   UINT32 m_acr;   // address control register
160159
161160   bool m_dma_active;
162161
trunk/src/emu/machine/i8271.h
r31374r31375
3131   template<class _Object> static devcb_base &set_irq_wr_callback(device_t &device, _Object object) { return downcast<i8271_device &>(device).m_write_irq.set_callback(object); }
3232   template<class _Object> static devcb_base &set_drq_wr_callback(device_t &device, _Object object) { return downcast<i8271_device &>(device).m_write_drq.set_callback(object); }
3333
34   static void set_floppy_tags(device_t &device, const char *tag1, const char *tag2)
35   {
34   static void set_floppy_tags(device_t &device, const char *tag1, const char *tag2)
35   {
3636      i8271_device &dev = downcast<i8271_device &>(device);
3737      dev.m_floppy_tag1 = tag1;
3838      dev.m_floppy_tag2 = tag2;
trunk/src/emu/machine/i8279.h
r31374r31375
8484   template<class _Object> static devcb_base &set_in_rl_callback(device_t &device, _Object object) { return downcast<i8279_device &>(device).m_in_rl_cb.set_callback(object); }
8585   template<class _Object> static devcb_base &set_in_shift_callback(device_t &device, _Object object) { return downcast<i8279_device &>(device).m_in_shift_cb.set_callback(object); }
8686   template<class _Object> static devcb_base &set_in_ctrl_callback(device_t &device, _Object object) { return downcast<i8279_device &>(device).m_in_ctrl_cb.set_callback(object); }
87   
87
8888   // read & write handlers
8989   DECLARE_READ8_MEMBER(status_r);
9090   DECLARE_READ8_MEMBER(data_r);
r31374r31375
115115   devcb_write8        m_out_sl_cb;        // Scanlines SL0-3
116116   devcb_write8        m_out_disp_cb;      // B0-3,A0-3
117117   devcb_write_line    m_out_bd_cb;        // BD
118   devcb_read8        m_in_rl_cb;        // kbd readlines RL0-7
118   devcb_read8         m_in_rl_cb;         // kbd readlines RL0-7
119119   devcb_read_line     m_in_shift_cb;      // Shift key
120120   devcb_read_line     m_in_ctrl_cb;       // Ctrl-Strobe line
121121
trunk/src/emu/machine/s3c44b0.h
r31374r31375
600600public:
601601   s3c44b0_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
602602   ~s3c44b0_device() {}
603   
603
604604   template<class _Object> static devcb_base &set_gpio_port_r_callback(device_t &device, _Object object) { return downcast<s3c44b0_device &>(device).m_port_r_cb.set_callback(object); }
605605   template<class _Object> static devcb_base &set_gpio_port_w_callback(device_t &device, _Object object) { return downcast<s3c44b0_device &>(device).m_port_w_cb.set_callback(object); }
606606   template<class _Object> static devcb_base &set_i2c_scl_w_callback(device_t &device, _Object object) { return downcast<s3c44b0_device &>(device).m_scl_w_cb.set_callback(object); }
trunk/src/emu/machine/roc10937.h
r31374r31375
11/**********************************************************************
22
3    Rockwell 10937/10957 interface and simlar chips
4   Emulation by J.Wallace
3    Rockwell 10937/10957 interface and simlar chips
4    Emulation by J.Wallace
55    OKI MSC1937 is a clone of this chip, with many others.
66
77**********************************************************************/
r31374r31375
1212
1313#define MCFG_ROC10937_ADD(_tag,_val) \
1414      MCFG_DEVICE_ADD(_tag, ROC10937,60)\
15      MCFG_ROC10937_PORT(_val)
15      MCFG_ROC10937_PORT(_val)
1616
1717#define MCFG_ROC10937_PORT(_val) \
1818   roc10937_t::static_set_value(*device, _val);
r31374r31375
2121
2222#define MCFG_ROC10957_ADD(_tag,_val) \
2323      MCFG_DEVICE_ADD(_tag, ROC10957,60)\
24      MCFG_ROC10957_PORT(_val)
25     
24      MCFG_ROC10957_PORT(_val)
25
2626#define MCFG_ROC10957_PORT(_val) \
2727   roc10957_t::static_set_value(*device, _val);
2828#define MCFG_ROC10957_REMOVE(_tag) \
r31374r31375
3030
3131#define MCFG_MSC1937_ADD(_tag,_val) \
3232      MCFG_DEVICE_ADD(_tag, ROC10937,60)\
33      MCFG_MSC1937_PORT(_val)
34     
33      MCFG_MSC1937_PORT(_val)
34
3535#define MCFG_MSC1937_PORT(_val) \
3636   MCFG_ROC10937_PORT(_val)
3737
r31374r31375
4040
4141#define MCFG_S16LF01_ADD(_tag,_val) \
4242      MCFG_DEVICE_ADD(_tag, S16LF01,60)\
43      MCFG_S16LF01_PORT(_val)
43      MCFG_S16LF01_PORT(_val)
4444
4545#define MCFG_S16LF01_PORT(_val) \
4646   MCFG_ROC10937_PORT(_val)
trunk/src/emu/machine/z80pio.h
r31374r31375
9292   template<class _Object> static devcb_base &set_in_pb_callback(device_t &device, _Object object) { return downcast<z80pio_device &>(device).m_in_pb_cb.set_callback(object); }
9393   template<class _Object> static devcb_base &set_out_pb_callback(device_t &device, _Object object) { return downcast<z80pio_device &>(device).m_out_pb_cb.set_callback(object); }
9494   template<class _Object> static devcb_base &set_out_brdy_callback(device_t &device, _Object object) { return downcast<z80pio_device &>(device).m_out_brdy_cb.set_callback(object); }
95   
95
9696   // I/O line access
9797   int rdy(int which) { return m_port[which].rdy(); }
9898   void strobe(int which, bool state) { m_port[which].strobe(state); }
r31374r31375
206206   devcb_read8         m_in_pa_cb;
207207   devcb_write8        m_out_pa_cb;
208208   devcb_write_line    m_out_ardy_cb;
209   
209
210210   devcb_read8         m_in_pb_cb;
211211   devcb_write8        m_out_pb_cb;
212212   devcb_write_line    m_out_brdy_cb;
trunk/src/emu/machine/ay31015.h
r31374r31375
6868   template<class _Object> static devcb_base &set_read_si_callback(device_t &device, _Object object) { return downcast<ay31015_device &>(device).m_read_si_cb.set_callback(object); }
6969   template<class _Object> static devcb_base &set_write_so_callback(device_t &device, _Object object) { return downcast<ay31015_device &>(device).m_write_so_cb.set_callback(object); }
7070   template<class _Object> static devcb_base &set_status_changed_callback(device_t &device, _Object object) { return downcast<ay31015_device &>(device).m_status_changed_cb.set_callback(object); }
71   
71
7272   /* Set an input pin */
7373   void set_input_pin( ay31015_input_pin_t pin, int data );
7474
r31374r31375
164164
165165#define MCFG_AY31015_TX_CLOCK(_txclk) \
166166   ay31015_device::set_tx_clock(*device, _txclk);
167   
167
168168#define MCFG_AY31015_RX_CLOCK(_rxclk) \
169169   ay31015_device::set_rx_clock(*device, _rxclk);
170170
r31374r31375
175175   devcb = &ay31015_device::set_write_so_callback(*device, DEVCB_##_devcb);
176176
177177#define MCFG_AY31015_STATUS_CHANGED_CB(_devcb) \
178    devcb = &ay31015_device::set_status_changed_callback(*device, DEVCB_##_devcb);
179   
178   devcb = &ay31015_device::set_status_changed_callback(*device, DEVCB_##_devcb);
180179
180
181181#define MCFG_AY51013_TX_CLOCK(_txclk) \
182182   ay51013_device::set_tx_clock(*device, _txclk);
183   
183
184184#define MCFG_AY51013_RX_CLOCK(_rxclk) \
185185   ay51013_device::set_rx_clock(*device, _rxclk);
186186
r31374r31375
191191   devcb = &ay51013_device::set_write_so_callback(*device, DEVCB_##_devcb);
192192
193193#define MCFG_AY51013_STATUS_CHANGED_CB(_devcb) \
194    devcb = &ay51013_device::set_status_changed_callback(*device, DEVCB_##_devcb);
194   devcb = &ay51013_device::set_status_changed_callback(*device, DEVCB_##_devcb);
195195
196196#endif
trunk/src/emu/machine/terminal.h
r31374r31375
2121
2222INPUT_PORTS_EXTERN( generic_terminal );
2323
24class generic_terminal_device :   public device_t
24class generic_terminal_device : public device_t
2525{
2626public:
2727   generic_terminal_device(const machine_config &mconfig, device_type type, const char *name, const char *tag, device_t *owner, UINT32 clock, const char *shortname, const char *source);
2828   generic_terminal_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
29   
29
3030   template<class _Object> static devcb_base &set_keyboard_callback(device_t &device, _Object object) { return downcast<generic_terminal_device &>(device).m_keyboard_cb.set_callback(object); }
31   
31
3232   DECLARE_WRITE8_MEMBER(write) { term_write(data); }
3333   DECLARE_WRITE8_MEMBER(kbd_put);
3434   UINT32 update(screen_device &device, bitmap_rgb32 &bitmap, const rectangle &cliprect);
trunk/src/emu/machine/s3c2410.h
r31374r31375
1919
2020#define MCFG_S3C2410_CORE_PIN_R_CB(_devcb) \
2121   devcb = &s3c2410_device::set_core_pin_r_callback(*device, DEVCB_##_devcb);
22
22
2323#define MCFG_S3C2410_CORE_PIN_W_CB(_devcb) \
2424   devcb = &s3c2410_device::set_core_pin_w_callback(*device, DEVCB_##_devcb);
25   
25
2626#define MCFG_S3C2410_GPIO_PORT_R_CB(_devcb) \
2727   devcb = &s3c2410_device::set_gpio_port_r_callback(*device, DEVCB_##_devcb);
28   
28
2929#define MCFG_S3C2410_GPIO_PORT_W_CB(_devcb) \
3030   devcb = &s3c2410_device::set_gpio_port_w_callback(*device, DEVCB_##_devcb);
31   
31
3232#define MCFG_S3C2410_I2C_SCL_W_CB(_devcb) \
3333   devcb = &s3c2410_device::set_i2c_scl_w_callback(*device, DEVCB_##_devcb);
3434
r31374r31375
4343
4444#define MCFG_S3C2410_I2S_DATA_W_CB(_devcb) \
4545   devcb = &s3c2410_device::set_i2s_data_w_callback(*device, DEVCB_##_devcb);
46   
46
4747#define MCFG_S3C2410_NAND_COMMAND_W_CB(_devcb) \
4848   devcb = &s3c2410_device::set_nand_command_w_callback(*device, DEVCB_##_devcb);
4949
r31374r31375
5555
5656#define MCFG_S3C2410_NAND_DATA_W_CB(_devcb) \
5757   devcb = &s3c2410_device::set_nand_data_w_callback(*device, DEVCB_##_devcb);
58   
58
5959#define MCFG_S3C2410_LCD_FLAGS(_flags) \
6060   s3c2410_device::set_lcd_flags(*device, _flags);
6161
trunk/src/emu/machine/z80sti.h
r31374r31375
9494   template<class _Object> static devcb_base &set_out_tbo_callback(device_t &device, _Object object) { return downcast<z80sti_device &>(device).m_out_tbo_cb.set_callback(object); }
9595   template<class _Object> static devcb_base &set_out_tco_callback(device_t &device, _Object object) { return downcast<z80sti_device &>(device).m_out_tco_cb.set_callback(object); }
9696   template<class _Object> static devcb_base &set_out_tdo_callback(device_t &device, _Object object) { return downcast<z80sti_device &>(device).m_out_tdo_cb.set_callback(object); }
97   
97
9898   static void set_rx_clock(device_t &device, int clock) { downcast<z80sti_device &>(device).m_rx_clock = clock; }
9999   static void set_tx_clock(device_t &device, int clock) { downcast<z80sti_device &>(device).m_tx_clock = clock; }
100100
r31374r31375
201201   void gpip_input(int bit, int state);
202202
203203   // device callbacks
204   devcb_write_line        m_out_int_cb;   // this gets called on each change of the _INT pin (pin 17)
205   devcb_read8             m_in_gpio_cb;   // this is called on each read of the GPIO pins
206   devcb_write8            m_out_gpio_cb;   // this is called on each write of the GPIO pins
207   devcb_write_line        m_out_so_cb;   // this gets called for each change of the SO pin (pin 37)
208   devcb_write_line        m_out_tao_cb;   // this gets called for each change of the TAO pin (pin 1)
209   devcb_write_line        m_out_tbo_cb;   // this gets called for each change of the TBO pin (pin 2)
210   devcb_write_line        m_out_tco_cb;   // this gets called for each change of the TCO pin (pin 3)
211   devcb_write_line        m_out_tdo_cb;   // this gets called for each change of the TDO pin (pin 4)
212   
204   devcb_write_line        m_out_int_cb;   // this gets called on each change of the _INT pin (pin 17)
205   devcb_read8             m_in_gpio_cb;   // this is called on each read of the GPIO pins
206   devcb_write8            m_out_gpio_cb;  // this is called on each write of the GPIO pins
207   devcb_write_line        m_out_so_cb;    // this gets called for each change of the SO pin (pin 37)
208   devcb_write_line        m_out_tao_cb;   // this gets called for each change of the TAO pin (pin 1)
209   devcb_write_line        m_out_tbo_cb;   // this gets called for each change of the TBO pin (pin 2)
210   devcb_write_line        m_out_tco_cb;   // this gets called for each change of the TCO pin (pin 3)
211   devcb_write_line        m_out_tdo_cb;   // this gets called for each change of the TDO pin (pin 4)
212
213213   int m_rx_clock;                     // serial receive clock
214214   int m_tx_clock;                     // serial transmit clock
215215
trunk/src/emu/machine/i8255.h
r31374r31375
7979   template<class _Object> static devcb_base &set_out_pa_callback(device_t &device, _Object object) { return downcast<i8255_device &>(device).m_out_pa_cb.set_callback(object); }
8080   template<class _Object> static devcb_base &set_out_pb_callback(device_t &device, _Object object) { return downcast<i8255_device &>(device).m_out_pb_cb.set_callback(object); }
8181   template<class _Object> static devcb_base &set_out_pc_callback(device_t &device, _Object object) { return downcast<i8255_device &>(device).m_out_pc_cb.set_callback(object); }
82   
82
8383   DECLARE_READ8_MEMBER( read );
8484   DECLARE_WRITE8_MEMBER( write );
8585
r31374r31375
125125   devcb_read8        m_in_pa_cb;
126126   devcb_read8        m_in_pb_cb;
127127   devcb_read8        m_in_pc_cb;
128   
128
129129   devcb_write8       m_out_pa_cb;
130130   devcb_write8       m_out_pb_cb;
131131   devcb_write8       m_out_pc_cb;
trunk/src/emu/machine/6525tpi.h
r31374r31375
4949   template<class _Object> static devcb_base &set_out_pc_callback(device_t &device, _Object object) { return downcast<tpi6525_device &>(device).m_out_pc_cb.set_callback(object); }
5050   template<class _Object> static devcb_base &set_out_ca_callback(device_t &device, _Object object) { return downcast<tpi6525_device &>(device).m_out_ca_cb.set_callback(object); }
5151   template<class _Object> static devcb_base &set_out_cb_callback(device_t &device, _Object object) { return downcast<tpi6525_device &>(device).m_out_cb_cb.set_callback(object); }
52   
52
5353   DECLARE_READ8_MEMBER( read );
5454   DECLARE_WRITE8_MEMBER( write );
5555
trunk/src/emu/machine/8042kbdc.h
r31374r31375
4040   devcb = &kbdc8042_device::set_output_buffer_empty_callback(*device, DEVCB_##_devcb);
4141
4242#define MCFG_KBDC8042_SPEAKER_CB(_devcb) \
43    devcb = &kbdc8042_device::set_speaker_callback(*device, DEVCB_##_devcb);
43   devcb = &kbdc8042_device::set_speaker_callback(*device, DEVCB_##_devcb);
4444
4545//**************************************************************************
4646//  TYPE DEFINITIONS
r31374r31375
5555   kbdc8042_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
5656
5757   virtual machine_config_constructor device_mconfig_additions() const;
58   
58
5959   static void set_keyboard_type(device_t &device, kbdc8042_type_t keybtype) { downcast<kbdc8042_device &>(device).m_keybtype = keybtype; }
6060   template<class _Object> static devcb_base &set_system_reset_callback(device_t &device, _Object object) { return downcast<kbdc8042_device &>(device).m_system_reset_cb.set_callback(object); }
6161   template<class _Object> static devcb_base &set_gate_a20_callback(device_t &device, _Object object) { return downcast<kbdc8042_device &>(device).m_gate_a20_cb.set_callback(object); }
r31374r31375
109109   required_device<at_keyboard_device> m_keyboard_dev;
110110
111111   kbdc8042_type_t     m_keybtype;
112   
112
113113   devcb_write_line    m_system_reset_cb;
114114   devcb_write_line    m_gate_a20_cb;
115115   devcb_write_line    m_input_buffer_full_cb;
trunk/src/emu/machine/53c810.h
r31374r31375
2222   static void set_irq_callback(device_t &device, lsi53c810_irq_delegate callback) { downcast<lsi53c810_device &>(device).m_irq_cb = callback; }
2323   static void set_dma_callback(device_t &device, lsi53c810_dma_delegate callback) { downcast<lsi53c810_device &>(device).m_dma_cb = callback; }
2424   static void set_fetch_callback(device_t &device, lsi53c810_fetch_delegate callback) { downcast<lsi53c810_device &>(device).m_fetch_cb = callback; }
25   
25
2626   void lsi53c810_read_data(int bytes, UINT8 *pData);
2727   void lsi53c810_write_data(int bytes, UINT8 *pData);
2828
trunk/src/emu/machine/ins8250.h
r31374r31375
1818{
1919public:
2020   ins8250_uart_device(const machine_config &mconfig, device_type type, const char* name, const char *tag, device_t *owner, UINT32 clock, const char *shortname);
21   
21
2222   template<class _Object> static devcb_base &set_out_tx_callback(device_t &device, _Object object) { return downcast<ins8250_uart_device &>(device).m_out_tx_cb.set_callback(object); }
2323   template<class _Object> static devcb_base &set_out_dtr_callback(device_t &device, _Object object) { return downcast<ins8250_uart_device &>(device).m_out_dtr_cb.set_callback(object); }
2424   template<class _Object> static devcb_base &set_out_rts_callback(device_t &device, _Object object) { return downcast<ins8250_uart_device &>(device).m_out_rts_cb.set_callback(object); }
2525   template<class _Object> static devcb_base &set_out_int_callback(device_t &device, _Object object) { return downcast<ins8250_uart_device &>(device).m_out_int_cb.set_callback(object); }
2626   template<class _Object> static devcb_base &set_out_out1_callback(device_t &device, _Object object) { return downcast<ins8250_uart_device &>(device).m_out_out1_cb.set_callback(object); }
2727   template<class _Object> static devcb_base &set_out_out2_callback(device_t &device, _Object object) { return downcast<ins8250_uart_device &>(device).m_out_out2_cb.set_callback(object); }
28   
28
2929   DECLARE_WRITE8_MEMBER( ins8250_w );
3030   DECLARE_READ8_MEMBER( ins8250_r );
3131   DECLARE_WRITE_LINE_MEMBER( dcd_w );
trunk/src/emu/machine/wd2010.h
r31374r31375
8787   template<class _Object> static devcb_base &set_in_wf_callback(device_t &device, _Object object) { return downcast<wd2010_device &>(device).m_in_wf_cb.set_callback(object); }
8888   template<class _Object> static devcb_base &set_in_tk000_callback(device_t &device, _Object object) { return downcast<wd2010_device &>(device).m_in_tk000_cb.set_callback(object); }
8989   template<class _Object> static devcb_base &set_in_sc_callback(device_t &device, _Object object) { return downcast<wd2010_device &>(device).m_in_sc_cb.set_callback(object); }
90   
90
9191   DECLARE_READ8_MEMBER( read );
9292   DECLARE_WRITE8_MEMBER( write );
9393
trunk/src/emu/machine/hd63450.h
r31374r31375
100100      dev.m_burst_clock[2] = clk3;
101101      dev.m_burst_clock[3] = clk4;
102102   }
103   
103
104104   DECLARE_READ16_MEMBER( read );
105105   DECLARE_WRITE16_MEMBER( write );
106106   DECLARE_WRITE_LINE_MEMBER(drq0_w);
r31374r31375
133133   const char *m_cpu_tag;
134134   attotime m_our_clock[4];
135135   attotime m_burst_clock[4];
136   
136
137137   // internal state
138138   hd63450_regs m_reg[4];
139139   emu_timer* m_timer[4];  // for timing data reading/writing each channel
trunk/src/emu/machine/corvushd.h
r31374r31375
405405      // Put drive into prep mode command (0x11)
406406      //
407407      struct {
408         UINT8   code;               // Command code
409         UINT8   drive;              // Drive number (starts at 1)
410         UINT8    prep_block[512];    // Machine code payload
408         UINT8   code;               // Command code
409         UINT8   drive;              // Drive number (starts at 1)
410         UINT8   prep_block[512];    // Machine code payload
411411      } prep_mode_command;
412412      //
413413      // Read Firmware command (Prep Mode 0x32)
r31374r31375
439439      //
440440      // Verify Drive command (Prep Mode 0x07)
441441      //
442      // On the real Corvus controller, this is a variable length response.  If the
443      // number of bad sectors is greater than zero, an additional four bytes will
444      // follow for each bad sector.  We don't emulate bad sectors, so we always
442      // On the real Corvus controller, this is a variable length response.  If the
443      // number of bad sectors is greater than zero, an additional four bytes will
444      // follow for each bad sector.  We don't emulate bad sectors, so we always
445445      // return a count of 0.  That makes this a fixed length response of 2 bytes.
446446      //
447447      struct {
448448         UINT8   status;       // Disk access status
449449         UINT8   bad_sectors;  // Number of bad sectors (always zero)
450      } verify_drive_response;     
450      } verify_drive_response;
451451   } m_buffer;
452452
453453   // Structure of Block #1, the Disk Parameter Block
trunk/src/emu/machine/cr511b.h
r31374r31375
11/***************************************************************************
22
3   CR-511-B CD-ROM drive
3    CR-511-B CD-ROM drive
44
55    license: MAME, GPL-2.0+
66    copyright-holders: Dirk Best
77
8   CD-ROM drive with a custom MKE/Panasonic interface as used in the
9   Commodore CDTV and early SoundBlaster cards.
8    CD-ROM drive with a custom MKE/Panasonic interface as used in the
9    Commodore CDTV and early SoundBlaster cards.
1010
11    1 _RESET      2  GND
12    3  EFFK       4  SCCK
13    5  SBCP       6  SCOR
14    7  GND        8  GND
15    9  C16M      10  GND
16   11 _XAEN      12  GND
17   13  EMPASIS   14  D0
18   15  LRCK      16  DSCK
19   17 _MUTE      18  GND
20   19 _BUSY      20 _STCH
21   21 _ENABLE    22  DRQ
22   23 _HWR       24  GND
23   25 _DTEN      26 _HRD
24   27 _STEN      28 _CMD
25   29 _EOP       30  GND
26   31  DB7       32  GND
27   33  DB6       34  DB5
28   35  DB4       36  GND
29   37  DB3       38  DB2
30   39  DB1       40  DB0
11     1 _RESET      2  GND
12     3  EFFK       4  SCCK
13     5  SBCP       6  SCOR
14     7  GND        8  GND
15     9  C16M      10  GND
16    11 _XAEN      12  GND
17    13  EMPASIS   14  D0
18    15  LRCK      16  DSCK
19    17 _MUTE      18  GND
20    19 _BUSY      20 _STCH
21    21 _ENABLE    22  DRQ
22    23 _HWR       24  GND
23    25 _DTEN      26 _HRD
24    27 _STEN      28 _CMD
25    29 _EOP       30  GND
26    31  DB7       32  GND
27    33  DB6       34  DB5
28    35  DB4       36  GND
29    37  DB3       38  DB2
30    39  DB1       40  DB0
3131
3232***************************************************************************/
3333
r31374r31375
4646//**************************************************************************
4747
4848#define MCFG_CR511B_ADD(_tag) \
49   MCFG_DEVICE_ADD(_tag, CR511B, 0) \
50
49   MCFG_DEVICE_ADD(_tag, CR511B, 0)
5150#define MCFG_CR511B_STCH_HANDLER(_devcb) \
5251   devcb = &cr511b_device::set_stch_handler(*device, DEVCB_##_devcb);
5352
trunk/src/emu/machine/wd17xx.h
r31374r31375
11/*********************************************************************
22
3   !!! DEPRECATED, USE src/emu/wd_fdc.h FOR NEW DRIVERS !!!
3    !!! DEPRECATED, USE src/emu/wd_fdc.h FOR NEW DRIVERS !!!
44
55    wd17xx.h
66
r31374r31375
5454   template<class _Object> static devcb_base &set_intrq_wr_callback(device_t &device, _Object object) { return downcast<wd1770_device &>(device).m_out_intrq_func.set_callback(object); }
5555   template<class _Object> static devcb_base &set_drq_wr_callback(device_t &device, _Object object) { return downcast<wd1770_device &>(device).m_out_drq_func.set_callback(object); }
5656   template<class _Object> static devcb_base &set_dden_rd_callback(device_t &device, _Object object) { return downcast<wd1770_device &>(device).m_in_dden_func.set_callback(object); }
57   
57
5858   static void set_drive_tags(device_t &device, const char *tag1, const char *tag2, const char *tag3, const char *tag4)
5959   {
6060      wd1770_device &dev = downcast<wd1770_device &>(device);
r31374r31375
6363      dev.m_floppy_drive_tags[2] = tag3;
6464      dev.m_floppy_drive_tags[3] = tag4;
6565   }
66   
66
6767   /* the following are not strictly part of the wd179x hardware/emulation
6868   but will be put here for now until the flopdrv code has been finalised more */
6969   void set_drive(UINT8);     /* set drive wd179x is accessing */
r31374r31375
130130   devcb_write_line m_out_intrq_func;
131131   devcb_write_line m_out_drq_func;
132132   devcb_read_line m_in_dden_func;
133   
133
134134   const char *m_floppy_drive_tags[4];
135135
136136   /* input lines */
trunk/src/emu/machine/am9517a.h
r31374r31375
7373   template<class _Object> static devcb_base &set_out_dack_1_callback(device_t &device, _Object object) { return downcast<am9517a_device &>(device).m_out_dack_1_cb.set_callback(object); }
7474   template<class _Object> static devcb_base &set_out_dack_2_callback(device_t &device, _Object object) { return downcast<am9517a_device &>(device).m_out_dack_2_cb.set_callback(object); }
7575   template<class _Object> static devcb_base &set_out_dack_3_callback(device_t &device, _Object object) { return downcast<am9517a_device &>(device).m_out_dack_3_cb.set_callback(object); }
76   
76
7777   DECLARE_READ8_MEMBER( read );
7878   DECLARE_WRITE8_MEMBER( write );
7979
trunk/src/emu/machine/6532riot.h
r31374r31375
5050   template<class _Object> static devcb_base &set_in_pb_callback(device_t &device, _Object object) { return downcast<riot6532_device &>(device).m_in_pb_cb.set_callback(object); }
5151   template<class _Object> static devcb_base &set_out_pb_callback(device_t &device, _Object object) { return downcast<riot6532_device &>(device).m_out_pb_cb.set_callback(object); }
5252   template<class _Object> static devcb_base &set_irq_callback(device_t &device, _Object object) { return downcast<riot6532_device &>(device).m_irq_cb.set_callback(object); }
53   
53
5454   DECLARE_READ8_MEMBER( read );
5555   DECLARE_WRITE8_MEMBER( write );
5656
r31374r31375
7575      UINT8                   m_in;
7676      UINT8                   m_out;
7777      UINT8                   m_ddr;
78      devcb_read8            *m_in_cb;
79      devcb_write8           *m_out_cb;
78      devcb_read8             *m_in_cb;
79      devcb_write8            *m_out_cb;
8080   };
8181
8282   // device-level overrides
r31374r31375
100100   devcb_read8         m_in_pb_cb;
101101   devcb_write8        m_out_pb_cb;
102102   devcb_write_line    m_irq_cb;
103   
103
104104   UINT8           m_irqstate;
105105   UINT8           m_irqenable;
106106   int             m_irq;
trunk/src/emu/machine/ym2148.h
r31374r31375
8989
9090
9191#endif
92
trunk/src/emu/machine/z80ctc.h
r31374r31375
6565   template<class _Object> static devcb_base &set_zc0_callback(device_t &device, _Object object) { return downcast<z80ctc_device &>(device).m_zc0_cb.set_callback(object); }
6666   template<class _Object> static devcb_base &set_zc1_callback(device_t &device, _Object object) { return downcast<z80ctc_device &>(device).m_zc1_cb.set_callback(object); }
6767   template<class _Object> static devcb_base &set_zc2_callback(device_t &device, _Object object) { return downcast<z80ctc_device &>(device).m_zc2_cb.set_callback(object); }
68   
68
6969   // read/write handlers
7070   DECLARE_READ8_MEMBER( read );
7171   DECLARE_WRITE8_MEMBER( write );
r31374r31375
124124   devcb_write_line   m_zc1_cb;               // channel 1 zero crossing callbacks
125125   devcb_write_line   m_zc2_cb;               // channel 2 zero crossing callbacks
126126   devcb_write_line   m_zc3_cb;               // channel 3 zero crossing callbacks = NULL ?
127   
127
128128   UINT8               m_vector;               // interrupt vector
129129   attotime            m_period16;             // 16/system clock
130130   attotime            m_period256;            // 256/system clock
trunk/src/emu/machine/at_keybc.h
r31374r31375
5353   template<class _Object> static devcb_base &set_output_buffer_empty_callback(device_t &device, _Object object) { return downcast<at_keyboard_controller_device &>(device).m_output_buffer_empty_cb.set_callback(object); }
5454   template<class _Object> static devcb_base &set_keyboard_clock_callback(device_t &device, _Object object) { return downcast<at_keyboard_controller_device &>(device).m_keyboard_clock_cb.set_callback(object); }
5555   template<class _Object> static devcb_base &set_keyboard_data_callback(device_t &device, _Object object) { return downcast<at_keyboard_controller_device &>(device).m_keyboard_data_cb.set_callback(object); }
56   
56
5757   // internal 8042 interface
5858   DECLARE_READ8_MEMBER( t0_r );
5959   DECLARE_READ8_MEMBER( t1_r );
r31374r31375
7878
7979   virtual const rom_entry *device_rom_region() const;
8080   virtual machine_config_constructor device_mconfig_additions() const;
81   
81
8282private:
8383   // internal state
8484   upi41_cpu_device *m_cpu;
trunk/src/emu/machine/mos6530.h
r31374r31375
7979   // internal state
8080   devcb_read8    m_in_pa_cb;
8181   devcb_write8   m_out_pa_cb;
82   
82
8383   devcb_read8    m_in_pb_cb;
8484   devcb_write8   m_out_pb_cb;
85   
85
8686   mos6530_port    m_port[2];
8787
8888   UINT8           m_irqstate;
trunk/src/emu/machine/mb89363b.h
r31374r31375
113113   devcb_read8        m_in_a_pa_cb;
114114   devcb_read8        m_in_a_pb_cb;
115115   devcb_read8        m_in_a_pc_cb;
116   
116
117117   devcb_write8       m_out_a_pa_cb;
118118   devcb_write8       m_out_a_pb_cb;
119119   devcb_write8       m_out_a_pc_cb;
r31374r31375
121121   devcb_read8        m_in_b_pa_cb;
122122   devcb_read8        m_in_b_pb_cb;
123123   devcb_read8        m_in_b_pc_cb;
124   
124
125125   devcb_write8       m_out_b_pa_cb;
126126   devcb_write8       m_out_b_pb_cb;
127127   devcb_write8       m_out_b_pc_cb;
trunk/src/emu/machine/68307.h
r31374r31375
4545   template<class _Object> static devcb_base &set_b_tx_cb(device_t &device, _Object object) { return downcast<m68307cpu_device &>(device).write_b_tx.set_callback(object); }
4646   template<class _Object> static devcb_base &set_inport_cb(device_t &device, _Object object) { return downcast<m68307cpu_device &>(device).read_inport.set_callback(object); }
4747   template<class _Object> static devcb_base &set_outport_cb(device_t &device, _Object object) { return downcast<m68307cpu_device &>(device).write_outport.set_callback(object); }
48   
48
4949   DECLARE_WRITE_LINE_MEMBER(m68307_duart_irq_handler);
5050   DECLARE_WRITE_LINE_MEMBER(m68307_duart_txa){ write_a_tx(state); }
5151   DECLARE_WRITE_LINE_MEMBER(m68307_duart_txb){ write_b_tx(state);  }
r31374r31375
6969   /* 68307 peripheral modules */
7070   m68307_sim*    m68307SIM;
7171   m68307_mbus*   m68307MBUS;
72//   m68307_serial* m68307SERIAL;
72//  m68307_serial* m68307SERIAL;
7373   m68307_timer*  m68307TIMER;
7474
7575   UINT16 m68307_base;
r31374r31375
9494   /* callbacks for internal ports */
9595   void set_port_callbacks(m68307_porta_read_delegate porta_r, m68307_porta_write_delegate porta_w, m68307_portb_read_delegate portb_r, m68307_portb_write_delegate portb_w);
9696   void set_interrupt(int level, int vector);
97   UINT16 get_cs(offs_t address);   
97   UINT16 get_cs(offs_t address);
9898   void timer0_interrupt();
9999   void timer1_interrupt();
100100   void serial_interrupt(int vector);
trunk/src/emu/machine/mb89352.h
r31374r31375
5050
5151#define MCFG_MB89352A_IRQ_CB(_devcb) \
5252   devcb = &mb89352_device::set_irq_callback(*device, DEVCB_##_devcb);
53   
53
5454#define MCFG_MB89352A_DRQ_CB(_devcb) \
5555   devcb = &mb89352_device::set_drq_callback(*device, DEVCB_##_devcb);
5656
r31374r31375
6262
6363   template<class _Object> static devcb_base &set_irq_callback(device_t &device, _Object object) { return downcast<mb89352_device &>(device).m_irq_cb.set_callback(object); }
6464   template<class _Object> static devcb_base &set_drq_callback(device_t &device, _Object object) { return downcast<mb89352_device &>(device).m_drq_cb.set_callback(object); }
65   
65
6666   // any publically accessible interfaces needed for runtime
6767   DECLARE_READ8_MEMBER( mb89352_r );
6868   DECLARE_WRITE8_MEMBER( mb89352_w );
trunk/src/emu/machine/dp8390.h
r31374r31375
1717
1818#define MCFG_DP8390D_MEM_WRITE_CB(_devcb) \
1919   devcb = &dp8390d_device::set_mem_write_callback(*device, DEVCB_##_devcb);
20   
20
2121#define MCFG_RTL8019A_IRQ_CB(_devcb) \
2222   devcb = &rtl8019a_device::set_irq_callback(*device, DEVCB_##_devcb);
2323
r31374r31375
3737public:
3838   // construction/destruction
3939   dp8390_device(const machine_config &mconfig, device_type type, const char *name, const char *tag, device_t *owner, UINT32 clock, float bandwidth, const char *shortname, const char *source);
40   
40
4141   template<class _Object> static devcb_base &set_irq_callback(device_t &device, _Object object) { return downcast<dp8390_device &>(device).m_irq_cb.set_callback(object); }
4242   template<class _Object> static devcb_base &set_breq_callback(device_t &device, _Object object) { return downcast<dp8390_device &>(device).m_breq_cb.set_callback(object); }
4343   template<class _Object> static devcb_base &set_mem_read_callback(device_t &device, _Object object) { return downcast<dp8390_device &>(device).m_mem_read_cb.set_callback(object); }
trunk/src/emu/machine/z80dart.h
r31374r31375
485485   template<class _Object> static devcb_base &set_out_syncb_callback(device_t &device, _Object object) { return downcast<z80dart_device &>(device).m_out_syncb_cb.set_callback(object); }
486486   template<class _Object> static devcb_base &set_out_int_callback(device_t &device, _Object object) { return downcast<z80dart_device &>(device).m_out_int_cb.set_callback(object); }
487487   template<class _Object> static devcb_base &set_out_rxdrqa_callback(device_t &device, _Object object) { return downcast<z80dart_device &>(device).m_out_rxdrqa_cb.set_callback(object); }
488   template<class _Object> static devcb_base &set_out_txdrqa_callback(device_t &device, _Object object) { return downcast<z80dart_device &>(device).m_out_txdrqa_cb.set_callback(object); }   
488   template<class _Object> static devcb_base &set_out_txdrqa_callback(device_t &device, _Object object) { return downcast<z80dart_device &>(device).m_out_txdrqa_cb.set_callback(object); }
489489   template<class _Object> static devcb_base &set_out_rxdrqb_callback(device_t &device, _Object object) { return downcast<z80dart_device &>(device).m_out_rxdrqb_cb.set_callback(object); }
490   template<class _Object> static devcb_base &set_out_txdrqb_callback(device_t &device, _Object object) { return downcast<z80dart_device &>(device).m_out_txdrqb_cb.set_callback(object); }   
491   
490   template<class _Object> static devcb_base &set_out_txdrqb_callback(device_t &device, _Object object) { return downcast<z80dart_device &>(device).m_out_txdrqb_cb.set_callback(object); }
491
492492   static void configure_channels(device_t &device, int rxa, int txa, int rxb, int txb)
493493   {
494494      z80dart_device &dev = downcast<z80dart_device &>(device);
r31374r31375
497497      dev.m_rxcb = rxb;
498498      dev.m_txcb = txb;
499499   }
500   
500
501501   DECLARE_READ8_MEMBER( cd_ba_r );
502502   DECLARE_WRITE8_MEMBER( cd_ba_w );
503503   DECLARE_READ8_MEMBER( ba_cd_r );
r31374r31375
565565   int m_txca;
566566   int m_rxcb;
567567   int m_txcb;
568   
568
569569   devcb_write_line    m_out_txda_cb;
570570   devcb_write_line    m_out_dtra_cb;
571571   devcb_write_line    m_out_rtsa_cb;
572572   devcb_write_line    m_out_wrdya_cb;
573573   devcb_write_line    m_out_synca_cb;
574   
574
575575   devcb_write_line    m_out_txdb_cb;
576576   devcb_write_line    m_out_dtrb_cb;
577577   devcb_write_line    m_out_rtsb_cb;
578578   devcb_write_line    m_out_wrdyb_cb;
579579   devcb_write_line    m_out_syncb_cb;
580   
580
581581   devcb_write_line    m_out_int_cb;
582582   devcb_write_line    m_out_rxdrqa_cb;
583583   devcb_write_line    m_out_txdrqa_cb;
trunk/src/emu/machine/akiko.h
r31374r31375
11/***************************************************************************
22
3   Akiko
3    Akiko
44
5   Used in the Amiga CD32
5    Used in the Amiga CD32
66
7   - CD-ROM controller
8   - Builtin 1KB NVRAM
9   - Chunky to planar converter
7    - CD-ROM controller
8    - Builtin 1KB NVRAM
9    - Chunky to planar converter
1010
1111***************************************************************************/
1212
r31374r31375
7474   virtual machine_config_constructor device_mconfig_additions() const;
7575
7676private:
77    // 1X CDROM sector time in msec (300KBps)
77   // 1X CDROM sector time in msec (300KBps)
7878   static const int CD_SECTOR_TIME = (1000/((150*1024)/2048));
7979
8080   // internal state
trunk/src/emu/machine/aakart.h
r31374r31375
2020
2121#define MCFG_AAKART_OUT_RX_CB(_devcb) \
2222   devcb = &aakart_device::set_out_rx_callback(*device, DEVCB_##_devcb);
23   
2423
24
2525enum{
2626   STATUS_NORMAL = 0,
2727   STATUS_KEYUP,
r31374r31375
4242public:
4343   // construction/destruction
4444   aakart_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
45   
45
4646   template<class _Object> static devcb_base &set_out_tx_callback(device_t &device, _Object object) { return downcast<aakart_device &>(device).m_out_tx_cb.set_callback(object); }
4747   template<class _Object> static devcb_base &set_out_rx_callback(device_t &device, _Object object) { return downcast<aakart_device &>(device).m_out_rx_cb.set_callback(object); }
4848
4949   // I/O operations
5050   DECLARE_WRITE8_MEMBER( write );
5151   DECLARE_READ8_MEMBER( read );
52    void send_keycode_down(UINT8 row, UINT8 col);
53    void send_keycode_up(UINT8 row, UINT8 col);
52   void send_keycode_down(UINT8 row, UINT8 col);
53   void send_keycode_up(UINT8 row, UINT8 col);
5454protected:
5555   // device-level overrides
5656   virtual void device_validity_check(validity_checker &valid) const;
r31374r31375
7777   UINT8 m_status;
7878   UINT8 m_mouse_enable;
7979   UINT8 m_keyb_enable;
80    UINT8 m_keyb_row;
81    UINT8 m_keyb_col;
82    UINT8 m_keyb_state;
80   UINT8 m_keyb_row;
81   UINT8 m_keyb_col;
82   UINT8 m_keyb_state;
8383
8484};
8585
trunk/src/emu/machine/wd11c00_17.h
r31374r31375
7979   template<class _Object> static devcb_base &set_out_ramwr_callback(device_t &device, _Object object) { return downcast<wd11c00_17_device &>(device).m_out_ramwr_cb.set_callback(object); }
8080   template<class _Object> static devcb_base &set_in_cs1010_callback(device_t &device, _Object object) { return downcast<wd11c00_17_device &>(device).m_in_cs1010_cb.set_callback(object); }
8181   template<class _Object> static devcb_base &set_out_cs1010_callback(device_t &device, _Object object) { return downcast<wd11c00_17_device &>(device).m_out_cs1010_cb.set_callback(object); }
82   
82
8383   DECLARE_READ8_MEMBER( io_r );
8484   DECLARE_WRITE8_MEMBER( io_w );
8585
trunk/src/emu/machine/tms9902.h
r31374r31375
4848{
4949public:
5050   tms9902_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
51   
51
5252   template<class _Object> static devcb_base &set_int_callback(device_t &device, _Object object) { return downcast<tms9902_device &>(device).m_int_cb.set_callback(object); }
5353   template<class _Object> static devcb_base &set_rcv_callback(device_t &device, _Object object) { return downcast<tms9902_device &>(device).m_rcv_cb.set_callback(object); }
5454   template<class _Object> static devcb_base &set_xmit_callback(device_t &device, _Object object) { return downcast<tms9902_device &>(device).m_xmit_cb.set_callback(object); }
5555   template<class _Object> static devcb_base &set_ctrl_callback(device_t &device, _Object object) { return downcast<tms9902_device &>(device).m_ctrl_cb.set_callback(object); }
56   
56
5757   void    set_clock(bool state);
5858
5959   void    rcv_cts(line_state state);
trunk/src/emu/machine/eepromser.h
r31374r31375
5959// X24c44 16 bit ram/eeprom combo
6060#define MCFG_EEPROM_SERIAL_X24C44_ADD(_tag) \
6161   MCFG_DEVICE_ADD(_tag, EEPROM_SERIAL_X24C44_16BIT, 0)
62   
62
6363// optional enable for streaming reads
6464#define MCFG_EEPROM_SERIAL_ENABLE_STREAMING() \
6565   eeprom_serial_base_device::static_enable_streaming(*device);
r31374r31375
144144   virtual void handle_event(eeprom_event event);
145145   virtual void parse_command_and_address() = 0;
146146   virtual void execute_command();
147   
148147
148
149149   // configuration state
150150   UINT8           m_command_address_bits;     // number of address bits in a command
151151   bool            m_streaming_enabled;        // true if streaming is enabled
r31374r31375
219219class eeprom_serial_x24c44_device : public eeprom_serial_base_device
220220{
221221      //async recall not implemented
222      //async store not implemented
222      //async store not implemented
223223protected:
224224   // construction/destruction
225225   eeprom_serial_x24c44_device(const machine_config &mconfig, device_type devtype, const char *name, const char *tag, device_t *owner, const char *shortname, const char *file);
r31374r31375
227227public:
228228   // read handlers
229229   DECLARE_READ_LINE_MEMBER(do_read);          // DO
230   
230
231231   // write handlers
232232   DECLARE_WRITE_LINE_MEMBER(cs_write);        // CS signal (active high)
233233   DECLARE_WRITE_LINE_MEMBER(clk_write);       // CLK signal (active high)
r31374r31375
283283DECLARE_SERIAL_EEPROM_DEVICE(er5911, er5911, ER5911, 8)
284284DECLARE_SERIAL_EEPROM_DEVICE(er5911, er5911, ER5911, 16)
285285
286// X24c44 8 bit 32byte ram/eeprom combo   
286// X24c44 8 bit 32byte ram/eeprom combo
287287DECLARE_SERIAL_EEPROM_DEVICE(x24c44, x24c44, X24C44, 16)
288288#endif
trunk/src/emu/machine/gayle.h
r31374r31375
11/***************************************************************************
22
3   GAYLE
3    GAYLE
44
55    license: MAME, GPL-2.0+
66    copyright-holders: Dirk Best
77
8   Gate array used in the Amiga 600 and Amiga 1200 computers.
8    Gate array used in the Amiga 600 and Amiga 1200 computers.
99
1010***************************************************************************/
1111
r31374r31375
8787private:
8888   enum
8989   {
90      GAYLE_CS = 0,   // interrupt status
91      GAYLE_IRQ,      // interrupt change
92      GAYLE_INTEN,   // interrupt enable register
93      GAYLE_CFG      // config register
90      GAYLE_CS = 0,   // interrupt status
91      GAYLE_IRQ,      // interrupt change
92      GAYLE_INTEN,    // interrupt enable register
93      GAYLE_CFG       // config register
9494   };
9595
9696   devcb_write_line m_int2_w;
trunk/src/emu/machine/s3c2440.h
r31374r31375
1818
1919#define MCFG_S3C2440_CORE_PIN_R_CB(_devcb) \
2020   devcb = &s3c2440_device::set_core_pin_r_callback(*device, DEVCB_##_devcb);
21
21
2222#define MCFG_S3C2440_CORE_PIN_W_CB(_devcb) \
2323   devcb = &s3c2440_device::set_core_pin_w_callback(*device, DEVCB_##_devcb);
24   
24
2525#define MCFG_S3C2440_GPIO_PORT_R_CB(_devcb) \
2626   devcb = &s3c2440_device::set_gpio_port_r_callback(*device, DEVCB_##_devcb);
27   
27
2828#define MCFG_S3C2440_GPIO_PORT_W_CB(_devcb) \
2929   devcb = &s3c2440_device::set_gpio_port_w_callback(*device, DEVCB_##_devcb);
30   
30
3131#define MCFG_S3C2440_I2C_SCL_W_CB(_devcb) \
3232   devcb = &s3c2440_device::set_i2c_scl_w_callback(*device, DEVCB_##_devcb);
3333
r31374r31375
5454
5555#define MCFG_S3C2440_NAND_DATA_W_CB(_devcb) \
5656   devcb = &s3c2440_device::set_nand_data_w_callback(*device, DEVCB_##_devcb);
57   
57
5858#define MCFG_S3C2440_LCD_FLAGS(_flags) \
5959   s3c2440_device::set_lcd_flags(*device, _flags);
6060
trunk/src/emu/machine/adc1038.h
r31374r31375
4949   int m_data_out;
5050   int m_adc_data;
5151   int m_sars;
52   
52
5353   int m_gticlub_hack;
5454   adc1038_input_delegate       m_input_cb;
5555};
trunk/src/emu/machine/ncr539x.h
r31374r31375
1717
1818#define MCFG_NCR539X_OUT_IRQ_CB(_devcb) \
1919   devcb = &ncr539x_device::set_out_irq_callback(*device, DEVCB_##_devcb);
20   
20
2121#define MCFG_NCR539X_OUT_DRQ_CB(_devcb) \
2222   devcb = &ncr539x_device::set_out_drq_callback(*device, DEVCB_##_devcb);
23   
23
2424class ncr539x_device : public legacy_scsi_host_adapter
2525{
2626public:
2727   // construction/destruction
2828   ncr539x_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
29   
29
3030   template<class _Object> static devcb_base &set_out_irq_callback(device_t &device, _Object object) { return downcast<ncr539x_device &>(device).m_out_irq_cb.set_callback(object); }
3131   template<class _Object> static devcb_base &set_out_drq_callback(device_t &device, _Object object) { return downcast<ncr539x_device &>(device).m_out_drq_cb.set_callback(object); }
3232
trunk/src/emu/machine/keyboard.h
r31374r31375
1616
1717INPUT_PORTS_EXTERN( generic_keyboard );
1818
19class generic_keyboard_device :   public device_t
19class generic_keyboard_device : public device_t
2020{
2121public:
2222   generic_keyboard_device(const machine_config &mconfig, device_type type, const char *name, const char *tag, device_t *owner, UINT32 clock, const char *shortname, const char *source);
2323   generic_keyboard_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
24   
24
2525   template<class _Object> static devcb_base &set_keyboard_callback(device_t &device, _Object object) { return downcast<generic_keyboard_device &>(device).m_keyboard_cb.set_callback(object); }
2626
2727   virtual ioport_constructor device_input_ports() const;
trunk/src/emu/machine/s2636.h
r31374r31375
3232      dev.m_x_offset = x_offset;
3333      dev.m_y_offset = y_offset;
3434   }
35   
35
3636   // returns a BITMAP_FORMAT_IND16 bitmap the size of the screen
3737   // D0-D2 of each pixel is the pixel color
3838   // D3 indicates whether the S2636 drew this pixel - 0 = not drawn, 1 = drawn
r31374r31375
6565   int        m_work_ram_size;
6666   int        m_y_offset;
6767   int        m_x_offset;
68   
68
6969   int check_collision( int spriteno1, int spriteno2, const rectangle &cliprect );
7070};
7171
trunk/src/emu/machine/autoconfig.h
r31374r31375
11/***************************************************************************
22
3   Amiga Autoconfig
3    Amiga Autoconfig
44
55***************************************************************************/
66
trunk/src/emu/machine/kb3600.h
r31374r31375
137137   int m_b;                    // output buffer
138138   int m_ako;                  // any key down
139139
140   int m_x_mask[9];         // mask of what keys are down
140   int m_x_mask[9];            // mask of what keys are down
141141
142142   // timers
143143   emu_timer *m_scan_timer;    // keyboard scan timer
trunk/src/emu/machine/adc0808.h
r31374r31375
4949
5050#define MCFG_ADC0808_IN_VREF_POS_CB(_class, _method) \
5151   adc0808_device::set_in_vref_pos_callback(*device, adc0808_analog_read_delegate(&_class::_method, #_class "::" #_method, downcast<_class *>(owner)));
52   
52
5353#define MCFG_ADC0808_IN_VREF_NEG_CB(_class, _method) \
5454   adc0808_device::set_in_vref_neg_callback(*device, adc0808_analog_read_delegate(&_class::_method, #_class "::" #_method, downcast<_class *>(owner)));
55   
55
5656#define MCFG_ADC0808_IN_IN_0_CB(_class, _method) \
5757   adc0808_device::set_in_in_0_callback(*device, adc0808_analog_read_delegate(&_class::_method, #_class "::" #_method, downcast<_class *>(owner)));
58   
58
5959#define MCFG_ADC0808_IN_IN_1_CB(_class, _method) \
6060   adc0808_device::set_in_in_1_callback(*device, adc0808_analog_read_delegate(&_class::_method, #_class "::" #_method, downcast<_class *>(owner)));
61   
61
6262#define MCFG_ADC0808_IN_IN_2_CB(_class, _method) \
6363   adc0808_device::set_in_in_2_callback(*device, adc0808_analog_read_delegate(&_class::_method, #_class "::" #_method, downcast<_class *>(owner)));
64   
64
6565#define MCFG_ADC0808_IN_IN_3_CB(_class, _method) \
6666   adc0808_device::set_in_in_3_callback(*device, adc0808_analog_read_delegate(&_class::_method, #_class "::" #_method, downcast<_class *>(owner)));
67   
67
6868#define MCFG_ADC0808_IN_IN_4_CB(_class, _method) \
6969   adc0808_device::set_in_in_4_callback(*device, adc0808_analog_read_delegate(&_class::_method, #_class "::" #_method, downcast<_class *>(owner)));
70   
70
7171#define MCFG_ADC0808_IN_IN_5_CB(_class, _method) \
7272   adc0808_device::set_in_in_5_callback(*device, adc0808_analog_read_delegate(&_class::_method, #_class "::" #_method, downcast<_class *>(owner)));
7373
7474#define MCFG_ADC0808_IN_IN_6_CB(_class, _method) \
7575   adc0808_device::set_in_in_6_callback(*device, adc0808_analog_read_delegate(&_class::_method, #_class "::" #_method, downcast<_class *>(owner)));
76   
76
7777#define MCFG_ADC0808_IN_IN_7_CB(_class, _method) \
7878   adc0808_device::set_in_in_7_callback(*device, adc0808_analog_read_delegate(&_class::_method, #_class "::" #_method, downcast<_class *>(owner)));
79   
79
8080// ======================> adc0808_device
8181
8282class adc0808_device :  public device_t
r31374r31375
8484public:
8585   // construction/destruction
8686   adc0808_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
87   
87
8888   template<class _Object> static devcb_base &set_out_eoc_callback(device_t &device, _Object object) { return downcast<adc0808_device &>(device).m_out_eoc_cb.set_callback(object); }
8989   static void set_in_vref_pos_callback(device_t &device, adc0808_analog_read_delegate callback) { downcast<adc0808_device &>(device).m_in_vref_pos_cb = callback; }
9090   static void set_in_vref_neg_callback(device_t &device, adc0808_analog_read_delegate callback) { downcast<adc0808_device &>(device).m_in_vref_neg_cb = callback; }
trunk/src/emu/machine/6840ptm.h
r31374r31375
4949   // construction/destruction
5050   ptm6840_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
5151
52   static void set_internal_clock(device_t &device, double clock) { downcast<ptm6840_device &>(device).m_internal_clock = clock; }   
52   static void set_internal_clock(device_t &device, double clock) { downcast<ptm6840_device &>(device).m_internal_clock = clock; }
5353   static void set_external_clocks(device_t &device, double clock0, double clock1, double clock2) { downcast<ptm6840_device &>(device).m_external_clock[0] = clock0; downcast<ptm6840_device &>(device).m_external_clock[1] = clock1; downcast<ptm6840_device &>(device).m_external_clock[2] = clock2; }
5454   template<class _Object> static devcb_base &set_out0_callback(device_t &device, _Object object) { return downcast<ptm6840_device &>(device).m_out0_cb.set_callback(object); }
5555   template<class _Object> static devcb_base &set_out1_callback(device_t &device, _Object object) { return downcast<ptm6840_device &>(device).m_out1_cb.set_callback(object); }
5656   template<class _Object> static devcb_base &set_out2_callback(device_t &device, _Object object) { return downcast<ptm6840_device &>(device).m_out2_cb.set_callback(object); }
5757   template<class _Object> static devcb_base &set_irq_callback(device_t &device, _Object object) { return downcast<ptm6840_device &>(device).m_irq_cb.set_callback(object); }
58   
58
5959   int status(int clock) const { return m_enabled[clock]; } // get whether timer is enabled
6060   int irq_state() const { return m_IRQ; }                 // get IRQ state
6161   UINT16 count(int counter) const { return compute_counter(counter); }    // get counter value
trunk/src/emu/machine/s3c2400.h
r31374r31375
1919
2020#define MCFG_S3C2400_CORE_PIN_R_CB(_devcb) \
2121   devcb = &s3c2400_device::set_core_pin_r_callback(*device, DEVCB_##_devcb);
22
22
2323#define MCFG_S3C2400_CORE_PIN_W_CB(_devcb) \
2424   devcb = &s3c2400_device::set_core_pin_w_callback(*device, DEVCB_##_devcb);
25   
25
2626#define MCFG_S3C2400_GPIO_PORT_R_CB(_devcb) \
2727   devcb = &s3c2400_device::set_gpio_port_r_callback(*device, DEVCB_##_devcb);
28   
28
2929#define MCFG_S3C2400_GPIO_PORT_W_CB(_devcb) \
3030   devcb = &s3c2400_device::set_gpio_port_w_callback(*device, DEVCB_##_devcb);
31   
31
3232#define MCFG_S3C2400_I2C_SCL_W_CB(_devcb) \
3333   devcb = &s3c2400_device::set_i2c_scl_w_callback(*device, DEVCB_##_devcb);
3434
r31374r31375
4343
4444#define MCFG_S3C2400_I2S_DATA_W_CB(_devcb) \
4545   devcb = &s3c2400_device::set_i2s_data_w_callback(*device, DEVCB_##_devcb);
46   
46
4747#define MCFG_S3C2400_LCD_FLAGS(_flags) \
4848   s3c2400_device::set_lcd_flags(*device, _flags);
4949
trunk/src/emu/netlist/nl_time.h
r31374r31375
4040   ATTR_HOT friend inline bool operator<(const netlist_time &left, const netlist_time &right);
4141   ATTR_HOT friend inline bool operator>=(const netlist_time &left, const netlist_time &right);
4242   ATTR_HOT friend inline bool operator<=(const netlist_time &left, const netlist_time &right);
43    ATTR_HOT friend inline bool operator!=(const netlist_time &left, const netlist_time &right);
43   ATTR_HOT friend inline bool operator!=(const netlist_time &left, const netlist_time &right);
4444
4545   ATTR_HOT inline const netlist_time &operator=(const netlist_time &right) { m_time = right.m_time; return *this; }
4646   ATTR_HOT inline const netlist_time &operator=(const double &right) { m_time = (INTERNALTYPE) ( right * (double) RESOLUTION); return *this; }
r31374r31375
114114
115115ATTR_HOT inline bool operator!=(const netlist_time &left, const netlist_time &right)
116116{
117    return (left.m_time != right.m_time);
117   return (left.m_time != right.m_time);
118118}
119119
120120#endif /* NLTIME_H_ */
trunk/src/emu/netlist/nl_lists.h
r31374r31375
7474
7575   ATTR_HOT inline void remove(const _Element elem)
7676   {
77        entry_t * i = m_end - 1;
78        while (i > &m_list[0])
79        {
80            if (i->object() == elem)
81            {
82                m_end--;
83                while (i < m_end)
84                {
85                    *i = *(i+1);
86                    i++;
87                }
88                return;
89            }
90            i--;
91        }
77      entry_t * i = m_end - 1;
78      while (i > &m_list[0])
79      {
80         if (i->object() == elem)
81         {
82            m_end--;
83            while (i < m_end)
84            {
85               *i = *(i+1);
86               i++;
87            }
88            return;
89         }
90         i--;
91      }
9292   }
9393
9494   ATTR_COLD void clear()
trunk/src/emu/netlist/nl_setup.h
r31374r31375
8383   struct link_t
8484   {
8585      link_t() { }
86        link_t(void *) { }
86      link_t(void *) { }
8787      // Copy constructor
8888      link_t(const link_t &from)
8989      {
trunk/src/emu/netlist/devices/nld_log.h
r31374r31375
2828   ~NETLIB_NAME(log)();
2929   netlist_analog_input_t m_I;
3030protected:
31    netlist_state_t<FILE *> m_file;
31   netlist_state_t<FILE *> m_file;
3232);
3333
3434#define LOGD(_name, _I, _I2)                                                 \
trunk/src/emu/netlist/devices/nld_system.h
r31374r31375
3737      NET_REGISTER_DEV(gnd, GND)
3838
3939#define DUMMY_INPUT(_name)                                                     \
40        NET_REGISTER_DEV(dummy_input, _name)
40      NET_REGISTER_DEV(dummy_input, _name)
4141
4242// -----------------------------------------------------------------------------
4343// mainclock
r31374r31375
122122class NETLIB_NAME(dummy_input) : public netlist_device_t
123123{
124124public:
125    ATTR_COLD NETLIB_NAME(dummy_input)()
126            : netlist_device_t(DUMMY) { }
125   ATTR_COLD NETLIB_NAME(dummy_input)()
126         : netlist_device_t(DUMMY) { }
127127
128    ATTR_COLD virtual ~NETLIB_NAME(dummy_input)() {}
128   ATTR_COLD virtual ~NETLIB_NAME(dummy_input)() {}
129129
130130protected:
131131
132    ATTR_COLD void start()
133    {
134        register_input("I", m_I);
135    }
132   ATTR_COLD void start()
133   {
134      register_input("I", m_I);
135   }
136136
137    ATTR_COLD void reset()
138    {
139    }
137   ATTR_COLD void reset()
138   {
139   }
140140
141    ATTR_HOT ATTR_ALIGN void update()
142    {
143    }
141   ATTR_HOT ATTR_ALIGN void update()
142   {
143   }
144144
145145private:
146    netlist_analog_input_t m_I;
146   netlist_analog_input_t m_I;
147147
148148};
149149
r31374r31375
216216      register_input("I", m_I);
217217   }
218218
219    ATTR_COLD virtual const netlist_logic_family_desc_t *logic_family()
220    {
221        return m_logic_family;
222    }
219   ATTR_COLD virtual const netlist_logic_family_desc_t *logic_family()
220   {
221      return m_logic_family;
222   }
223223
224    const netlist_logic_family_desc_t *m_logic_family;
224   const netlist_logic_family_desc_t *m_logic_family;
225225private:
226226};
227227
r31374r31375
266266{
267267public:
268268   ATTR_COLD nld_d_to_a_proxy(netlist_output_t &out_proxied)
269    : nld_base_d_to_a_proxy(out_proxied)
270    , m_RV(TWOTERM)
269   : nld_base_d_to_a_proxy(out_proxied)
270   , m_RV(TWOTERM)
271271   , m_last_state(-1)
272272   {
273273   }
trunk/src/emu/netlist/devices/nld_7474.h
r31374r31375
5757NETLIB_SUBDEVICE(7474sub,
5858   netlist_ttl_input_t m_CLK;
5959
60    netlist_state_t<UINT8> m_nextD;
60   netlist_state_t<UINT8> m_nextD;
6161   netlist_ttl_output_t m_Q;
6262   netlist_ttl_output_t m_QQ;
6363
trunk/src/emu/netlist/devices/nld_74ls629.h
r31374r31375
4141
4242   netlist_time m_inc;
4343   netlist_state_t<netlist_sig_t> m_enableq;
44    netlist_state_t<netlist_sig_t> m_out;
44   netlist_state_t<netlist_sig_t> m_out;
4545);
4646
4747NETLIB_DEVICE_WITH_PARAMS(SN74LS629,
trunk/src/emu/netlist/devices/nld_cmos.h
r31374r31375
1111
1212class nld_vdd_vss : public netlist_device_t
1313{
14    public:
15        nld_vdd_vss ()
16        : netlist_device_t()
17            { }
14   public:
15      nld_vdd_vss ()
16      : netlist_device_t()
17         { }
1818
19        netlist_analog_input_t m_vdd;
20        netlist_analog_input_t m_vss;
19      netlist_analog_input_t m_vdd;
20      netlist_analog_input_t m_vss;
2121
22    protected:
23        ATTR_HOT void update() {};
24        ATTR_HOT void start()  {};
25        ATTR_HOT void reset()  {};
22   protected:
23      ATTR_HOT void update() {};
24      ATTR_HOT void start()  {};
25      ATTR_HOT void reset()  {};
2626
2727public:
28    ATTR_HOT inline double vdd() { return INPANALOG(m_vdd); }
29    ATTR_HOT inline double vss() { return INPANALOG(m_vss); }
28   ATTR_HOT inline double vdd() { return INPANALOG(m_vdd); }
29   ATTR_HOT inline double vss() { return INPANALOG(m_vss); }
3030};
3131
3232#endif /* NLD_CMOS_H_ */
trunk/src/emu/netlist/devices/nld_r2r_dac.h
r31374r31375
5151
5252#define R2R_DAC(_name, _VIN, _R, _N)                                            \
5353      NET_REGISTER_DEV(r2r_dac, _name)                                       \
54        NETDEV_PARAMI(_name, VIN, _VIN)                                        \
55        NETDEV_PARAMI(_name, R,   _R)                                          \
56        NETDEV_PARAMI(_name, N,   _N)
54      NETDEV_PARAMI(_name, VIN, _VIN)                                        \
55      NETDEV_PARAMI(_name, R,   _R)                                          \
56      NETDEV_PARAMI(_name, N,   _N)
5757
5858NETLIB_DEVICE_WITH_PARAMS_DERIVED(r2r_dac, twoterm,
59    netlist_param_double_t m_VIN;
60    netlist_param_double_t m_R;
61    netlist_param_int_t m_num;
62    netlist_param_int_t m_val;
59   netlist_param_double_t m_VIN;
60   netlist_param_double_t m_R;
61   netlist_param_int_t m_num;
62   netlist_param_int_t m_val;
6363);
6464
6565
trunk/src/emu/netlist/devices/nld_truthtable.h
r31374r31375
1111#include "../nl_base.h"
1212
1313#define NETLIB_TRUTHTABLE(_name, _nIN, _nOUT, _state)                               \
14    class NETLIB_NAME(_name) : public nld_truthtable_t<_nIN, _nOUT, _state>         \
15    {                                                                               \
16    public:                                                                         \
17        NETLIB_NAME(_name)()                                                        \
18        : nld_truthtable_t<_nIN, _nOUT, _state>(&m_ttbl, m_desc) { }                \
19    private:                                                                        \
20        static truthtable_t m_ttbl;                                                 \
21        static const char *m_desc[];                                                \
22    }
14   class NETLIB_NAME(_name) : public nld_truthtable_t<_nIN, _nOUT, _state>         \
15   {                                                                               \
16   public:                                                                         \
17      NETLIB_NAME(_name)()                                                        \
18      : nld_truthtable_t<_nIN, _nOUT, _state>(&m_ttbl, m_desc) { }                \
19   private:                                                                        \
20      static truthtable_t m_ttbl;                                                 \
21      static const char *m_desc[];                                                \
22   }
2323
2424
2525template<int m_NI, int m_NO, int has_state>
r31374r31375
2727{
2828public:
2929
30    static const int m_num_bits = m_NI + has_state * (m_NI + m_NO);
31    static const int m_size = (1 << (m_num_bits));
30   static const int m_num_bits = m_NI + has_state * (m_NI + m_NO);
31   static const int m_size = (1 << (m_num_bits));
3232
33    struct truthtable_t
34    {
35        truthtable_t() : m_initialized(false) {}
36        UINT32 m_outs[m_size];
37        UINT8  m_timing[m_size][m_NO];
38        netlist_time m_timing_nt[16];
39        bool m_initialized;
40    };
33   struct truthtable_t
34   {
35      truthtable_t() : m_initialized(false) {}
36      UINT32 m_outs[m_size];
37      UINT8  m_timing[m_size][m_NO];
38      netlist_time m_timing_nt[16];
39      bool m_initialized;
40   };
4141
42    nld_truthtable_t(truthtable_t *ttbl, const char *desc[])
43    : netlist_device_t(), m_last_state(0), m_active(1), m_ttp(ttbl), m_desc(desc)
44    {
45    }
42   nld_truthtable_t(truthtable_t *ttbl, const char *desc[])
43   : netlist_device_t(), m_last_state(0), m_active(1), m_ttp(ttbl), m_desc(desc)
44   {
45   }
4646
47    ATTR_COLD virtual void start()
48    {
49        pstring ttline = pstring(m_desc[0]);
50        {
51            nl_util::pstring_list io = nl_util::split(ttline,"|");
52            // checks
53            assert(io.count() == 2);
54            nl_util::pstring_list inout = nl_util::split(io[0], ",");
55            assert(inout.count() == m_num_bits);
56            nl_util::pstring_list out = nl_util::split(io[1], ",");
57            assert(out.count() == m_NO);
47   ATTR_COLD virtual void start()
48   {
49      pstring ttline = pstring(m_desc[0]);
50      {
51         nl_util::pstring_list io = nl_util::split(ttline,"|");
52         // checks
53         assert(io.count() == 2);
54         nl_util::pstring_list inout = nl_util::split(io[0], ",");
55         assert(inout.count() == m_num_bits);
56         nl_util::pstring_list out = nl_util::split(io[1], ",");
57         assert(out.count() == m_NO);
5858
59            for (int i=0; i < m_NI; i++)
60            {
61                register_input(inout[i], m_i[i]);
62            }
63            for (int i=0; i < m_NO; i++)
64            {
65                register_output(out[i], m_Q[i]);
66            }
67        }
68        setup_tt();
69        // FIXME: save state
70    }
59         for (int i=0; i < m_NI; i++)
60         {
61            register_input(inout[i], m_i[i]);
62         }
63         for (int i=0; i < m_NO; i++)
64         {
65            register_output(out[i], m_Q[i]);
66         }
67      }
68      setup_tt();
69      // FIXME: save state
70   }
7171
72    ATTR_COLD void help(int cur, nl_util::pstring_list list,
73            UINT64 state, UINT64 ignore, UINT16 val, UINT8 timing_index[m_NO])
74    {
75        pstring elem = list[cur];
76        int start = 0;
77        int end = 0;
78        int ign = 0;
72   ATTR_COLD void help(int cur, nl_util::pstring_list list,
73         UINT64 state, UINT64 ignore, UINT16 val, UINT8 timing_index[m_NO])
74   {
75      pstring elem = list[cur];
76      int start = 0;
77      int end = 0;
78      int ign = 0;
7979
80        if (elem.equals("0"))
81        {
82            start = 0;
83            end = 0;
84        }
85        else if (elem.equals("1"))
86        {
87            start = 1;
88            end = 1;
89        }
90        else if (elem.equals("X"))
91        {
92            start = 0;
93            end = 1;
94            ign = 1;
95        }
96        for (int i = start; i <= end; i++)
97        {
98            const UINT64 nstate = state | (i << cur);
99            const UINT64 nignore = ignore | (ign << cur);
80      if (elem.equals("0"))
81      {
82         start = 0;
83         end = 0;
84      }
85      else if (elem.equals("1"))
86      {
87         start = 1;
88         end = 1;
89      }
90      else if (elem.equals("X"))
91      {
92         start = 0;
93         end = 1;
94         ign = 1;
95      }
96      for (int i = start; i <= end; i++)
97      {
98         const UINT64 nstate = state | (i << cur);
99         const UINT64 nignore = ignore | (ign << cur);
100100
101            if (cur < m_num_bits - 1)
102            {
103                help(cur + 1, list, nstate, nignore, val, timing_index);
104            }
105            else
106            {
107                // cutoff previous inputs and outputs for ignore
108                m_ttp->m_outs[nstate] = val | ((nignore & ((1 << m_NI)-1)) << m_NO);
109                for (int j=0; j<m_NO; j++)
110                    m_ttp->m_timing[nstate][j] = timing_index[j];
111            }
112        }
113    }
101         if (cur < m_num_bits - 1)
102         {
103            help(cur + 1, list, nstate, nignore, val, timing_index);
104         }
105         else
106         {
107            // cutoff previous inputs and outputs for ignore
108            m_ttp->m_outs[nstate] = val | ((nignore & ((1 << m_NI)-1)) << m_NO);
109            for (int j=0; j<m_NO; j++)
110               m_ttp->m_timing[nstate][j] = timing_index[j];
111         }
112      }
113   }
114114
115    ATTR_COLD void setup_tt()
116    {
117        if (m_ttp->m_initialized)
118            return;
115   ATTR_COLD void setup_tt()
116   {
117      if (m_ttp->m_initialized)
118         return;
119119
120        const char **truthtable = m_desc;
121        pstring ttline = pstring(truthtable[0]);
122        truthtable++;
123        ttline = pstring(truthtable[0]);
124        truthtable++;
120      const char **truthtable = m_desc;
121      pstring ttline = pstring(truthtable[0]);
122      truthtable++;
123      ttline = pstring(truthtable[0]);
124      truthtable++;
125125
126        for (int j=0; j < m_size; j++)
127            m_ttp->m_outs[j] = -1;
126      for (int j=0; j < m_size; j++)
127         m_ttp->m_outs[j] = -1;
128128
129        for (int j=0; j < 16; j++)
130            m_ttp->m_timing_nt[j] = netlist_time::zero;
129      for (int j=0; j < 16; j++)
130         m_ttp->m_timing_nt[j] = netlist_time::zero;
131131
132        while (!ttline.equals(""))
133        {
134            nl_util::pstring_list io = nl_util::split(ttline,"|");
135            // checks
136            assert(io.count() == 3);
137            nl_util::pstring_list inout = nl_util::split(io[0], ",");
138            assert(inout.count() == m_num_bits);
139            nl_util::pstring_list out = nl_util::split(io[1], ",");
140            assert(out.count() == m_NO);
141            nl_util::pstring_list times = nl_util::split(io[2], ",");
142            assert(times.count() == m_NO);
132      while (!ttline.equals(""))
133      {
134         nl_util::pstring_list io = nl_util::split(ttline,"|");
135         // checks
136         assert(io.count() == 3);
137         nl_util::pstring_list inout = nl_util::split(io[0], ",");
138         assert(inout.count() == m_num_bits);
139         nl_util::pstring_list out = nl_util::split(io[1], ",");
140         assert(out.count() == m_NO);
141         nl_util::pstring_list times = nl_util::split(io[2], ",");
142         assert(times.count() == m_NO);
143143
144            UINT16 val = 0;
145            UINT8 tindex[m_NO];
146            for (int j=0; j<m_NO; j++)
147            {
148                if (out[j].equals("1"))
149                    val = val | (1 << j);
150                netlist_time t = netlist_time::from_nsec(times[j].as_long());
151                int k=0;
152                while (m_ttp->m_timing_nt[k] != netlist_time::zero && m_ttp->m_timing_nt[k] != t)
153                    k++;
154                m_ttp->m_timing_nt[k] = t;
155                tindex[j] = k;
156            }
144         UINT16 val = 0;
145         UINT8 tindex[m_NO];
146         for (int j=0; j<m_NO; j++)
147         {
148            if (out[j].equals("1"))
149               val = val | (1 << j);
150            netlist_time t = netlist_time::from_nsec(times[j].as_long());
151            int k=0;
152            while (m_ttp->m_timing_nt[k] != netlist_time::zero && m_ttp->m_timing_nt[k] != t)
153               k++;
154            m_ttp->m_timing_nt[k] = t;
155            tindex[j] = k;
156         }
157157
158            help(0, inout, 0 , 0 , val, tindex);
159            ttline = pstring(truthtable[0]);
160            truthtable++;
161        }
162        for (int j=0; j < m_size; j++)
163            printf("%05x %04x %04x %04x\n", j, m_ttp->m_outs[j] & ((1 << m_NO)-1),
164                    m_ttp->m_outs[j] >> m_NO, m_ttp->m_timing[j][0]);
165        for (int k=0; m_ttp->m_timing_nt[k] != netlist_time::zero; k++)
166            printf("%d %f\n", k, m_ttp->m_timing_nt[k].as_double() * 1000000.0);
158         help(0, inout, 0 , 0 , val, tindex);
159         ttline = pstring(truthtable[0]);
160         truthtable++;
161      }
162      for (int j=0; j < m_size; j++)
163         printf("%05x %04x %04x %04x\n", j, m_ttp->m_outs[j] & ((1 << m_NO)-1),
164               m_ttp->m_outs[j] >> m_NO, m_ttp->m_timing[j][0]);
165      for (int k=0; m_ttp->m_timing_nt[k] != netlist_time::zero; k++)
166         printf("%d %f\n", k, m_ttp->m_timing_nt[k].as_double() * 1000000.0);
167167
168        m_ttp->m_initialized = true;
168      m_ttp->m_initialized = true;
169169
170    }
170   }
171171
172    ATTR_COLD void reset()
173    {
174        //m_Q.initial(1);
175        m_active = 1;
176        m_last_state = 0;
177    }
172   ATTR_COLD void reset()
173   {
174      //m_Q.initial(1);
175      m_active = 1;
176      m_last_state = 0;
177   }
178178
179    ATTR_HOT ATTR_ALIGN void update()
180    {
181        //const netlist_time times[2] = { NLTIME_FROM_NS(15), NLTIME_FROM_NS(22)};
179   ATTR_HOT ATTR_ALIGN void update()
180   {
181      //const netlist_time times[2] = { NLTIME_FROM_NS(15), NLTIME_FROM_NS(22)};
182182
183        // FIXME: this check is needed because update is called during startup as well
184        if (UNEXPECTED(USE_DEACTIVE_DEVICE && m_active == 0))
185            return;
183      // FIXME: this check is needed because update is called during startup as well
184      if (UNEXPECTED(USE_DEACTIVE_DEVICE && m_active == 0))
185         return;
186186
187        UINT32 state = 0;
188        for (int i=0; i< m_NI; i++)
189        {
190            m_i[i].activate();
191            state = state | (INPLOGIC(m_i[i]) << i);
192        }
187      UINT32 state = 0;
188      for (int i=0; i< m_NI; i++)
189      {
190         m_i[i].activate();
191         state = state | (INPLOGIC(m_i[i]) << i);
192      }
193193
194        const UINT32 nstate = (has_state ? state | (m_last_state << m_NI) : state);
195        const UINT32 out = m_ttp->m_outs[nstate] & ((1 << m_NO) - 1);
196        const UINT32 ign = m_ttp->m_outs[nstate] >> m_NO;
197        if (has_state) m_last_state = (state << m_NO) | out;
194      const UINT32 nstate = (has_state ? state | (m_last_state << m_NI) : state);
195      const UINT32 out = m_ttp->m_outs[nstate] & ((1 << m_NO) - 1);
196      const UINT32 ign = m_ttp->m_outs[nstate] >> m_NO;
197      if (has_state) m_last_state = (state << m_NO) | out;
198198
199        for (int i=0; i< m_NI; i++)
200            if (ign & (1 << i))
201                m_i[i].inactivate();
199      for (int i=0; i< m_NI; i++)
200         if (ign & (1 << i))
201            m_i[i].inactivate();
202202
203        for (int i=0; i<m_NO; i++)
203      for (int i=0; i<m_NO; i++)
204204//            OUTLOGIC(m_Q[i], (out >> i) & 1, times[(out >> i) & 1]);// ? 22000 : 15000);
205            OUTLOGIC(m_Q[i], (out >> i) & 1, m_ttp->m_timing_nt[m_ttp->m_timing[nstate][i]]);// ? 22000 : 15000);
205         OUTLOGIC(m_Q[i], (out >> i) & 1, m_ttp->m_timing_nt[m_ttp->m_timing[nstate][i]]);// ? 22000 : 15000);
206206
207    }
207   }
208208
209209
210210#if (USE_DEACTIVE_DEVICE)
211    ATTR_HOT void inc_active()
212    {
213        if (++m_active == 1)
214        {
215            update();
216        }
217    }
211   ATTR_HOT void inc_active()
212   {
213      if (++m_active == 1)
214      {
215         update();
216      }
217   }
218218
219    ATTR_HOT void dec_active()
220    {
221        if (--m_active == 0)
222        {
223            for (int i = 0; i< m_NI; i++)
224                m_i[i].inactivate();
225        }
226    }
219   ATTR_HOT void dec_active()
220   {
221      if (--m_active == 0)
222      {
223         for (int i = 0; i< m_NI; i++)
224            m_i[i].inactivate();
225      }
226   }
227227#endif
228228
229    netlist_ttl_input_t m_i[m_NI];
230    netlist_ttl_output_t m_Q[m_NO];
229   netlist_ttl_input_t m_i[m_NI];
230   netlist_ttl_output_t m_Q[m_NO];
231231
232232private:
233233
234    UINT32 m_last_state;
235    INT32 m_active;
234   UINT32 m_last_state;
235   INT32 m_active;
236236
237    truthtable_t *m_ttp;
238    const char **m_desc;
237   truthtable_t *m_ttp;
238   const char **m_desc;
239239};
240240
241241#endif /* NLD_TRUTHTABLE_H_ */
trunk/src/emu/netlist/devices/nld_4020.h
r31374r31375
3434      NET_REGISTER_DEV(4020, _name)                                          \
3535      NET_CONNECT(_name, IP, _IP)                                            \
3636      NET_CONNECT(_name, RESET,  _RESET)                                     \
37        NET_CONNECT(_name, VDD,  _VDD)                                         \
38        NET_CONNECT(_name, VSS,  _VSS)
37      NET_CONNECT(_name, VDD,  _VDD)                                         \
38      NET_CONNECT(_name, VSS,  _VSS)
3939
4040#define CD_4020_DIP(_name)                                                     \
4141      NET_REGISTER_DEV(4020_dip, _name)
4242
4343NETLIB_SUBDEVICE(4020_sub,
4444
45    NETLIB_LOGIC_FAMILY(CD4000)
46    ATTR_HOT void update_outputs(const UINT16 cnt);
45   NETLIB_LOGIC_FAMILY(CD4000)
46   ATTR_HOT void update_outputs(const UINT16 cnt);
4747
4848   netlist_ttl_input_t m_IP;
4949
r31374r31375
5353);
5454
5555NETLIB_DEVICE(4020,
56    NETLIB_LOGIC_FAMILY(CD4000)
56   NETLIB_LOGIC_FAMILY(CD4000)
5757   NETLIB_NAME(4020_sub) sub;
58    NETLIB_NAME(vdd_vss) m_supply;
59    netlist_ttl_input_t m_RESET;
58   NETLIB_NAME(vdd_vss) m_supply;
59   netlist_ttl_input_t m_RESET;
6060);
6161
6262NETLIB_DEVICE_DERIVED(4020_dip, 4020,
trunk/src/emu/netlist/devices/nld_4066.h
r31374r31375
3131      NET_REGISTER_DEV(4066_dip, _name)
3232
3333NETLIB_SUBDEVICE(4066,
34    NETLIB_LOGIC_FAMILY(CD4000)
34   NETLIB_LOGIC_FAMILY(CD4000)
3535public:
3636
3737   netlist_analog_input_t m_control;
r31374r31375
4141);
4242
4343NETLIB_DEVICE(4066_dip,
44    NETLIB_LOGIC_FAMILY(CD4000)
44   NETLIB_LOGIC_FAMILY(CD4000)
4545
4646   NETLIB_NAME(4066) m_A;
4747   NETLIB_NAME(4066) m_B;
trunk/src/emu/netlist/devices/nld_7490.h
r31374r31375
8181   netlist_ttl_input_t m_B;
8282
8383   netlist_state_t<UINT8> m_cnt;
84    netlist_state_t<UINT8> m_last_A;
85    netlist_state_t<UINT8> m_last_B;
84   netlist_state_t<UINT8> m_last_A;
85   netlist_state_t<UINT8> m_last_B;
8686
8787   netlist_ttl_output_t m_Q[4];
8888);
trunk/src/emu/netlist/devices/nld_74123.h
r31374r31375
3939   netlist_ttl_input_t m_B;
4040   netlist_ttl_input_t m_CLRQ;
4141   netlist_ttl_output_t m_Q;
42    netlist_ttl_output_t m_QQ;
42   netlist_ttl_output_t m_QQ;
4343
44    netlist_analog_input_t m_CV;
44   netlist_analog_input_t m_CV;
4545
46    netlist_state_t<netlist_sig_t> m_last_trig;
47    netlist_state_t<UINT8>         m_state;
48    netlist_state_t<double>        m_KP;
46   netlist_state_t<netlist_sig_t> m_last_trig;
47   netlist_state_t<UINT8>         m_state;
48   netlist_state_t<double>        m_KP;
4949
50    netlist_param_double_t m_K;
51    netlist_param_double_t m_RI;
50   netlist_param_double_t m_K;
51   netlist_param_double_t m_RI;
5252
5353);
5454
r31374r31375
5757
5858NETLIB_DEVICE(74123_dip,
5959
60    NETLIB_NAME(74123) m_1;
61    NETLIB_NAME(74123) m_2;
60   NETLIB_NAME(74123) m_1;
61   NETLIB_NAME(74123) m_2;
6262
6363);
6464
trunk/src/emu/netlist/pstate.h
r31374r31375
3737
3838template<typename _ItemType> struct nl_datatype
3939{
40    static const pstate_data_type_e type = pstate_data_type_e(NOT_SUPPORTED);
41    static const bool is_ptr = false;
40   static const pstate_data_type_e type = pstate_data_type_e(NOT_SUPPORTED);
41   static const bool is_ptr = false;
4242};
4343
4444template<typename _ItemType> struct nl_datatype<_ItemType *>
4545{
46    static const pstate_data_type_e type = pstate_data_type_e(NOT_SUPPORTED);
47    static const bool is_ptr = true;
46   static const pstate_data_type_e type = pstate_data_type_e(NOT_SUPPORTED);
47   static const bool is_ptr = true;
4848};
4949
5050//template<typename _ItemType> struct type_checker<_ItemType*> { static const bool is_atom = false; static const bool is_pointer = true; };
5151
5252#define NETLIST_SAVE_TYPE(TYPE, TYPEDESC) \
53        template<> struct nl_datatype<TYPE>{ static const pstate_data_type_e type = pstate_data_type_e(TYPEDESC); static const bool is_ptr = false;}; \
54        template<> struct nl_datatype<TYPE *>{ static const pstate_data_type_e type = pstate_data_type_e(TYPEDESC); static const bool is_ptr = true;};
53      template<> struct nl_datatype<TYPE>{ static const pstate_data_type_e type = pstate_data_type_e(TYPEDESC); static const bool is_ptr = false;}; \
54      template<> struct nl_datatype<TYPE *>{ static const pstate_data_type_e type = pstate_data_type_e(TYPEDESC); static const bool is_ptr = true;};
5555
5656NETLIST_SAVE_TYPE(char, DT_INT8);
5757NETLIST_SAVE_TYPE(double, DT_DOUBLE);
r31374r31375
104104   template<typename T>
105105   T *resolved()
106106   {
107       if (m_is_ptr)
108           return *static_cast<T **>(m_ptr);
109       else
110           return static_cast<T *>(m_ptr);
107      if (m_is_ptr)
108         return *static_cast<T **>(m_ptr);
109      else
110         return static_cast<T *>(m_ptr);
111111   }
112112};
113113
trunk/src/emu/netlist/nl_dice_compat.h
r31374r31375
7070   ALIAS(_name.1, _name ## _SW.Q)
7171
7272#define CHIP_INPUT_ACTIVE_HIGH(_name)   \
73    SWITCH2(_name ## _SW) \
74    NET_C(_name ## _SW.2, V5) \
75    NET_CSTR(# _name "_SW.1", "GND") \
76    ALIAS(_name.1, _name ## _SW.Q)
73   SWITCH2(_name ## _SW) \
74   NET_C(_name ## _SW.2, V5) \
75   NET_CSTR(# _name "_SW.1", "GND") \
76   ALIAS(_name.1, _name ## _SW.Q)
7777
7878#define CHIP_LATCH(_name)   \
7979   NETDEV_RSFF(_name) \
trunk/src/emu/netlist/nl_base.h
r31374r31375
244244#define NETLIB_LOGIC_FAMILY(_fam)                                               \
245245ATTR_COLD virtual const netlist_logic_family_desc_t *logic_family()             \
246246{                                                                               \
247    return &netlist_family_ ## _fam;                                            \
247   return &netlist_family_ ## _fam;                                            \
248248}
249249
250250
r31374r31375
298298template< typename X>
299299class netlist_state_t {
300300public:
301  inline netlist_state_t() : m_x(static_cast<X>(0)) {}
302  inline netlist_state_t(const X& x_) : m_x(x_) {}
303  inline const X& get() const { return m_x; }
304  inline X& ref() { return m_x; }
305  inline operator const X&() const { return m_x; }
306  inline operator X&() { return m_x; }
301   inline netlist_state_t() : m_x(static_cast<X>(0)) {}
302   inline netlist_state_t(const X& x_) : m_x(x_) {}
303   inline const X& get() const { return m_x; }
304   inline X& ref() { return m_x; }
305   inline operator const X&() const { return m_x; }
306   inline operator X&() { return m_x; }
307307private:
308  X m_x;
308   X m_x;
309309};
310310
311311// -----------------------------------------------------------------------------
r31374r31375
324324      NET      = 4,
325325      DEVICE   = 5,
326326      NETLIST   = 6,
327        QUEUE   = 7,
327      QUEUE   = 7,
328328   };
329329   enum family_t {
330330      // Terminal families
r31374r31375
336336      RESISTOR,   // Resistor
337337      CAPACITOR,  // Capacitor
338338      DIODE,      // Diode
339        DUMMY,      // DUMMY device without function
340        BJT_EB,     // BJT(Ebers-Moll)
339      DUMMY,      // DUMMY device without function
340      BJT_EB,     // BJT(Ebers-Moll)
341341      BJT_SWITCH, // BJT(Switch)
342342      VCVS,       // Voltage controlled voltage source
343343      VCCS,       // Voltage controlled current source
344        CCCS,       // Current controlled current source
344      CCCS,       // Current controlled current source
345345      GND,        // GND device
346346   };
347347
r31374r31375
356356
357357   PSTATE_INTERFACE_DECL()
358358   template<typename C> ATTR_COLD void save(netlist_state_t<C> &state,
359           const pstring &stname)
359         const pstring &stname)
360360   {
361       save(state.ref(), stname);
361      save(state.ref(), stname);
362362   }
363363
364364   ATTR_HOT inline const type_t type() const { return m_objtype; }
r31374r31375
469469   NETLIST_PREVENT_COPYING(netlist_terminal_t)
470470public:
471471
472    typedef plinearlist_t<netlist_terminal_t * RESTRICT> list_t;
472   typedef plinearlist_t<netlist_terminal_t * RESTRICT> list_t;
473473
474474   ATTR_COLD netlist_terminal_t();
475475
r31374r31375
479479
480480   ATTR_HOT inline void set(const double G)
481481   {
482       set_ptr(m_Idr1, 0);
482      set_ptr(m_Idr1, 0);
483483      set_ptr(m_go1, G);
484484      set_ptr(m_gt1, G);
485485   }
486486
487487   ATTR_HOT inline void set(const double GO, const double GT)
488488   {
489       set_ptr(m_Idr1, 0);
489      set_ptr(m_Idr1, 0);
490490      set_ptr(m_go1, GO);
491491      set_ptr(m_gt1, GT);
492492   }
493493
494494   ATTR_HOT inline void set(const double GO, const double GT, const double I)
495495   {
496       set_ptr(m_Idr1, I);
496      set_ptr(m_Idr1, I);
497497      set_ptr(m_go1, GO);
498498      set_ptr(m_gt1, GT);
499499   }
500500
501    ATTR_HOT void schedule_solve();
502    ATTR_HOT void schedule_after(const netlist_time &after);
501   ATTR_HOT void schedule_solve();
502   ATTR_HOT void schedule_after(const netlist_time &after);
503503
504504   netlist_terminal_t *m_otherterm;
505505
r31374r31375
508508
509509   ATTR_COLD virtual void reset();
510510private:
511    inline void set_ptr(double *ptr, const double val)
512    {
513        if (ptr != NULL)
514            *ptr = val;
515    }
511   inline void set_ptr(double *ptr, const double val)
512   {
513      if (ptr != NULL)
514         *ptr = val;
515   }
516516};
517517
518518
r31374r31375
531531      set_state(STATE_INP_ACTIVE);
532532   }
533533
534    ATTR_HOT inline void inactivate();
535    ATTR_HOT inline void activate();
534   ATTR_HOT inline void inactivate();
535   ATTR_HOT inline void activate();
536536
537537protected:
538538   ATTR_COLD virtual void reset()
r31374r31375
559559   ATTR_HOT inline const netlist_sig_t Q() const;
560560   ATTR_HOT inline const netlist_sig_t last_Q() const;
561561
562    ATTR_HOT inline void activate_hl();
563    ATTR_HOT inline void activate_lh();
562   ATTR_HOT inline void activate_hl();
563   ATTR_HOT inline void activate_lh();
564564
565565};
566566
r31374r31375
610610   ATTR_COLD void merge_net(netlist_net_t *othernet);
611611   ATTR_COLD void register_railterminal(netlist_output_t &mr);
612612
613    ATTR_HOT inline netlist_logic_net_t & RESTRICT as_logic();
614    ATTR_HOT inline const netlist_logic_net_t & RESTRICT as_logic() const;
613   ATTR_HOT inline netlist_logic_net_t & RESTRICT as_logic();
614   ATTR_HOT inline const netlist_logic_net_t & RESTRICT as_logic() const;
615615
616    ATTR_HOT inline netlist_analog_net_t & RESTRICT as_analog();
617    ATTR_HOT inline const netlist_analog_net_t & RESTRICT as_analog() const;
616   ATTR_HOT inline netlist_analog_net_t & RESTRICT as_analog();
617   ATTR_HOT inline const netlist_analog_net_t & RESTRICT as_analog() const;
618618
619619   ATTR_HOT void update_devs();
620620
r31374r31375
625625   ATTR_HOT inline const netlist_core_terminal_t & RESTRICT  railterminal() const { return *m_railterminal; }
626626
627627   ATTR_HOT inline void push_to_queue(const netlist_time delay);
628    ATTR_HOT inline void reschedule_in_queue(const netlist_time delay);
628   ATTR_HOT inline void reschedule_in_queue(const netlist_time delay);
629629   ATTR_HOT bool inline is_queued() const { return m_in_queue == 1; }
630630
631631   ATTR_HOT inline int num_cons() const { return m_core_terms.count(); }
632632
633    ATTR_HOT void inc_active(netlist_core_terminal_t &term);
634    ATTR_HOT void dec_active(netlist_core_terminal_t &term);
633   ATTR_HOT void inc_active(netlist_core_terminal_t &term);
634   ATTR_HOT void dec_active(netlist_core_terminal_t &term);
635635
636    ATTR_COLD void rebuild_list();     /* rebuild m_list after a load */
636   ATTR_COLD void rebuild_list();     /* rebuild m_list after a load */
637637
638    ATTR_COLD void move_connections(netlist_net_t *new_net);
638   ATTR_COLD void move_connections(netlist_net_t *new_net);
639639
640    plinearlist_t<netlist_core_terminal_t *> m_core_terms; // save post-start m_list ...
640   plinearlist_t<netlist_core_terminal_t *> m_core_terms; // save post-start m_list ...
641641
642642protected:  //FIXME: needed by current solver code
643643
644644   ATTR_COLD virtual void save_register();
645645   ATTR_COLD virtual void reset();
646646
647    netlist_sig_t m_new_Q;
648    netlist_sig_t m_cur_Q;
647   netlist_sig_t m_new_Q;
648   netlist_sig_t m_cur_Q;
649649
650650private:
651651
652    netlist_core_terminal_t * RESTRICT m_railterminal;
653    plinkedlist_t<netlist_core_terminal_t> m_list_active;
652   netlist_core_terminal_t * RESTRICT m_railterminal;
653   plinkedlist_t<netlist_core_terminal_t> m_list_active;
654654
655    netlist_time m_time;
656    INT32        m_active;
657    UINT8        m_in_queue;    /* 0: not in queue, 1: in queue, 2: last was taken */
655   netlist_time m_time;
656   INT32        m_active;
657   UINT8        m_in_queue;    /* 0: not in queue, 1: in queue, 2: last was taken */
658658
659659public:
660    // We have to have those on one object. Dividing those does lead
661    // to a significant performance hit
662    // FIXME: Have to fix the public at some time
663    double m_cur_Analog;
660   // We have to have those on one object. Dividing those does lead
661   // to a significant performance hit
662   // FIXME: Have to fix the public at some time
663   double m_cur_Analog;
664664
665665};
666666
667667class netlist_logic_net_t : public netlist_net_t
668668{
669    NETLIST_PREVENT_COPYING(netlist_logic_net_t)
669   NETLIST_PREVENT_COPYING(netlist_logic_net_t)
670670public:
671671
672    typedef plinearlist_t<netlist_logic_net_t *> list_t;
672   typedef plinearlist_t<netlist_logic_net_t *> list_t;
673673
674    ATTR_COLD netlist_logic_net_t();
675    ATTR_COLD virtual ~netlist_logic_net_t() { };
674   ATTR_COLD netlist_logic_net_t();
675   ATTR_COLD virtual ~netlist_logic_net_t() { };
676676
677    ATTR_HOT inline const netlist_sig_t Q() const
678    {
679        return m_cur_Q;
680    }
677   ATTR_HOT inline const netlist_sig_t Q() const
678   {
679      return m_cur_Q;
680   }
681681
682    ATTR_HOT inline const netlist_sig_t new_Q() const
683    {
684        return m_new_Q;
685    }
682   ATTR_HOT inline const netlist_sig_t new_Q() const
683   {
684      return m_new_Q;
685   }
686686
687    ATTR_HOT inline void set_Q(const netlist_sig_t newQ, const netlist_time delay)
688    {
689        if (EXPECTED(newQ !=  m_new_Q))
690        {
691            m_new_Q = newQ;
692            push_to_queue(delay);
693        }
694    }
687   ATTR_HOT inline void set_Q(const netlist_sig_t newQ, const netlist_time delay)
688   {
689      if (EXPECTED(newQ !=  m_new_Q))
690      {
691         m_new_Q = newQ;
692         push_to_queue(delay);
693      }
694   }
695695
696    ATTR_HOT inline void toggle_new_Q()
697    {
698        m_new_Q ^= 1;
699    }
696   ATTR_HOT inline void toggle_new_Q()
697   {
698      m_new_Q ^= 1;
699   }
700700
701    ATTR_COLD void initial(const netlist_sig_t val)
702    {
703        m_cur_Q = val;
704        m_new_Q = val;
705    }
701   ATTR_COLD void initial(const netlist_sig_t val)
702   {
703      m_cur_Q = val;
704      m_new_Q = val;
705   }
706706
707    /* internal state support
708     * FIXME: get rid of this and implement export/import in MAME
709     */
710    ATTR_COLD inline netlist_sig_t &Q_state_ptr()
711    {
712        assert(family() == LOGIC);
713        return m_cur_Q;
714    }
707   /* internal state support
708    * FIXME: get rid of this and implement export/import in MAME
709    */
710   ATTR_COLD inline netlist_sig_t &Q_state_ptr()
711   {
712      assert(family() == LOGIC);
713      return m_cur_Q;
714   }
715715
716716protected:  //FIXME: needed by current solver code
717717
718    ATTR_COLD virtual void save_register();
719    ATTR_COLD virtual void reset();
718   ATTR_COLD virtual void save_register();
719   ATTR_COLD virtual void reset();
720720
721721
722722private:
r31374r31375
727727
728728class netlist_analog_net_t : public netlist_net_t
729729{
730    NETLIST_PREVENT_COPYING(netlist_analog_net_t)
730   NETLIST_PREVENT_COPYING(netlist_analog_net_t)
731731public:
732732
733    typedef plinearlist_t<netlist_analog_net_t *> list_t;
733   typedef plinearlist_t<netlist_analog_net_t *> list_t;
734734
735    ATTR_COLD netlist_analog_net_t();
736    ATTR_COLD virtual ~netlist_analog_net_t() { };
735   ATTR_COLD netlist_analog_net_t();
736   ATTR_COLD virtual ~netlist_analog_net_t() { };
737737
738    ATTR_HOT inline const double Q_Analog() const
739    {
740        //assert(object_type(SIGNAL_MASK) == SIGNAL_ANALOG);
741        assert(family() == ANALOG);
742        return m_cur_Analog;
743    }
738   ATTR_HOT inline const double Q_Analog() const
739   {
740      //assert(object_type(SIGNAL_MASK) == SIGNAL_ANALOG);
741      assert(family() == ANALOG);
742      return m_cur_Analog;
743   }
744744
745    ATTR_COLD inline double &Q_Analog_state_ptr()
746    {
747        //assert(object_type(SIGNAL_MASK) == SIGNAL_ANALOG);
748        assert(family() == ANALOG);
749        return m_cur_Analog;
750    }
745   ATTR_COLD inline double &Q_Analog_state_ptr()
746   {
747      //assert(object_type(SIGNAL_MASK) == SIGNAL_ANALOG);
748      assert(family() == ANALOG);
749      return m_cur_Analog;
750   }
751751
752    ATTR_HOT inline netlist_matrix_solver_t *solver() { return m_solver; }
752   ATTR_HOT inline netlist_matrix_solver_t *solver() { return m_solver; }
753753
754    ATTR_COLD bool already_processed(list_t *groups, int cur_group);
755    ATTR_COLD void process_net(list_t *groups, int &cur_group);
754   ATTR_COLD bool already_processed(list_t *groups, int cur_group);
755   ATTR_COLD void process_net(list_t *groups, int &cur_group);
756756
757757protected:
758758
759    ATTR_COLD virtual void save_register();
760    ATTR_COLD virtual void reset();
759   ATTR_COLD virtual void save_register();
760   ATTR_COLD virtual void reset();
761761
762762
763763private:
764764
765765public:
766    double m_DD_n_m_1;
767    double m_h_n_m_1;
766   double m_DD_n_m_1;
767   double m_h_n_m_1;
768768
769    //FIXME: needed by current solver code
770    netlist_matrix_solver_t *m_solver;
769   //FIXME: needed by current solver code
770   netlist_matrix_solver_t *m_solver;
771771};
772772
773773// -----------------------------------------------------------------------------
r31374r31375
811811   }
812812
813813private:
814    netlist_logic_net_t m_my_net;
814   netlist_logic_net_t m_my_net;
815815   nld_base_d_to_a_proxy *m_proxy;
816816};
817817
r31374r31375
834834
835835   ATTR_HOT inline void set_Q(const double newQ);
836836
837    netlist_analog_net_t *m_proxied_net; // only for proxy nets in analog input logic
837   netlist_analog_net_t *m_proxied_net; // only for proxy nets in analog input logic
838838
839839private:
840    netlist_analog_net_t m_my_net;
840   netlist_analog_net_t m_my_net;
841841};
842842
843843// -----------------------------------------------------------------------------
r31374r31375
10301030   ATTR_COLD virtual void start() { }
10311031   ATTR_COLD virtual const netlist_logic_family_desc_t *logic_family()
10321032   {
1033       return &netlist_family_TTL;
1033      return &netlist_family_TTL;
10341034   }
10351035
10361036private:
r31374r31375
10791079// -----------------------------------------------------------------------------
10801080
10811081class netlist_queue_t : public netlist_timed_queue<netlist_net_t *, netlist_time, 512>,
1082                        public netlist_object_t,
1082                  public netlist_object_t,
10831083                  public pstate_callback_t
10841084{
10851085public:
1086    netlist_queue_t(netlist_base_t &nl);
1086   netlist_queue_t(netlist_base_t &nl);
10871087
10881088protected:
10891089
1090    void reset() {}
1090   void reset() {}
10911091
10921092   void register_state(pstate_manager_t &manager, const pstring &module);
10931093   void on_pre_save();
r31374r31375
11261126      m_queue.push(netlist_queue_t::entry_t(attime, out));
11271127   }
11281128
1129    ATTR_HOT inline void remove_from_queue(netlist_net_t *out)
1130    {
1131        m_queue.remove(out);
1132    }
1129   ATTR_HOT inline void remove_from_queue(netlist_net_t *out)
1130   {
1131      m_queue.remove(out);
1132   }
11331133
11341134   ATTR_HOT void process_queue(const netlist_time delta);
11351135   ATTR_HOT inline void abort_current_queue_slice() { m_stop = netlist_time::zero; }
r31374r31375
11611161   template<class _C>
11621162   _C *get_first_device()
11631163   {
1164       //FIXME:
1165        for (netlist_device_t * const *entry = m_devices.first(); entry != NULL; entry = m_devices.next(entry))
1166        {
1167            _C *dev = dynamic_cast<_C *>(*entry);
1164      //FIXME:
1165      for (netlist_device_t * const *entry = m_devices.first(); entry != NULL; entry = m_devices.next(entry))
1166      {
1167         _C *dev = dynamic_cast<_C *>(*entry);
11681168         if (dev != NULL)
11691169            return dev;
11701170      }
r31374r31375
11751175   _C *get_single_device(const char *classname)
11761176   {
11771177      _C *ret = NULL;
1178        for (netlist_device_t * const *entry = m_devices.first(); entry != NULL; entry = m_devices.next(entry))
1179        {
1180            _C *dev = dynamic_cast<_C *>(*entry);
1178      for (netlist_device_t * const *entry = m_devices.first(); entry != NULL; entry = m_devices.next(entry))
1179      {
1180         _C *dev = dynamic_cast<_C *>(*entry);
11811181         if (dev != NULL)
11821182         {
11831183            if (ret != NULL)
r31374r31375
12611261
12621262ATTR_HOT inline netlist_logic_net_t & RESTRICT netlist_net_t::as_logic()
12631263{
1264    assert(family() == LOGIC);
1265    return static_cast<netlist_logic_net_t &>(*this);
1264   assert(family() == LOGIC);
1265   return static_cast<netlist_logic_net_t &>(*this);
12661266}
12671267
12681268ATTR_HOT inline const netlist_logic_net_t & RESTRICT netlist_net_t::as_logic() const
12691269{
1270    assert(family() == LOGIC);
1271    return static_cast<const netlist_logic_net_t &>(*this);
1270   assert(family() == LOGIC);
1271   return static_cast<const netlist_logic_net_t &>(*this);
12721272}
12731273
12741274ATTR_HOT inline netlist_analog_net_t & RESTRICT netlist_net_t::as_analog()
12751275{
1276    assert(family() == ANALOG);
1277    return static_cast<netlist_analog_net_t &>(*this);
1276   assert(family() == ANALOG);
1277   return static_cast<netlist_analog_net_t &>(*this);
12781278}
12791279
12801280ATTR_HOT inline const netlist_analog_net_t & RESTRICT netlist_net_t::as_analog() const
12811281{
1282    assert(family() == ANALOG);
1283    return static_cast<const netlist_analog_net_t &>(*this);
1282   assert(family() == ANALOG);
1283   return static_cast<const netlist_analog_net_t &>(*this);
12841284}
12851285
12861286
r31374r31375
13371337
13381338ATTR_HOT inline void netlist_net_t::reschedule_in_queue(const netlist_time delay)
13391339{
1340    //if (UNEXPECTED(m_num_cons == 0 || is_queued()))
1341    if (is_queued())
1342        netlist().remove_from_queue(this);
1340   //if (UNEXPECTED(m_num_cons == 0 || is_queued()))
1341   if (is_queued())
1342      netlist().remove_from_queue(this);
13431343
1344    m_time = netlist().time() + delay;
1345    m_in_queue = (m_active > 0);     /* queued ? */
1346    if (EXPECTED(m_in_queue))
1347    {
1348        netlist().push_to_queue(this, m_time);
1349    }
1344   m_time = netlist().time() + delay;
1345   m_in_queue = (m_active > 0);     /* queued ? */
1346   if (EXPECTED(m_in_queue))
1347   {
1348      netlist().push_to_queue(this, m_time);
1349   }
13501350}
13511351
13521352
r31374r31375
13621362
13631363ATTR_HOT inline void netlist_analog_output_t::set_Q(const double newQ)
13641364{
1365    if (newQ != net().as_analog().m_cur_Analog)
1366    {
1367        net().as_analog().m_cur_Analog = newQ;
1368        net().push_to_queue(NLTIME_FROM_NS(1));
1369    }
1365   if (newQ != net().as_analog().m_cur_Analog)
1366   {
1367      net().as_analog().m_cur_Analog = newQ;
1368      net().push_to_queue(NLTIME_FROM_NS(1));
1369   }
13701370}
13711371
13721372
trunk/src/emu/netlist/analog/nld_ms_direct.h
r31374r31375
1313{
1414public:
1515
16    netlist_matrix_solver_direct_t(const netlist_solver_parameters_t &params, int size);
16   netlist_matrix_solver_direct_t(const netlist_solver_parameters_t &params, int size);
1717
18    virtual ~netlist_matrix_solver_direct_t();
18   virtual ~netlist_matrix_solver_direct_t();
1919
20    ATTR_COLD virtual void vsetup(netlist_analog_net_t::list_t &nets);
21    ATTR_COLD virtual void reset() { netlist_matrix_solver_t::reset(); }
20   ATTR_COLD virtual void vsetup(netlist_analog_net_t::list_t &nets);
21   ATTR_COLD virtual void reset() { netlist_matrix_solver_t::reset(); }
2222
23    ATTR_HOT inline const int N() const { if (m_N == 0) return m_dim; else return m_N; }
23   ATTR_HOT inline const int N() const { if (m_N == 0) return m_dim; else return m_N; }
2424
25    ATTR_HOT inline int vsolve_non_dynamic();
25   ATTR_HOT inline int vsolve_non_dynamic();
2626
2727protected:
28    ATTR_COLD virtual void add_term(int net_idx, netlist_terminal_t *term);
28   ATTR_COLD virtual void add_term(int net_idx, netlist_terminal_t *term);
2929
30    ATTR_HOT virtual double vsolve();
30   ATTR_HOT virtual double vsolve();
3131
32    ATTR_HOT int solve_non_dynamic();
33    ATTR_HOT void build_LE();
34    ATTR_HOT void gauss_LE(double (* RESTRICT x));
35    ATTR_HOT double delta(const double (* RESTRICT V));
36    ATTR_HOT void store(const double (* RESTRICT V), const bool store_RHS);
32   ATTR_HOT int solve_non_dynamic();
33   ATTR_HOT void build_LE();
34   ATTR_HOT void gauss_LE(double (* RESTRICT x));
35   ATTR_HOT double delta(const double (* RESTRICT V));
36   ATTR_HOT void store(const double (* RESTRICT V), const bool store_RHS);
3737
38    /* bring the whole system to the current time
39     * Don't schedule a new calculation time. The recalculation has to be
40     * triggered by the caller after the netlist element was changed.
41     */
42    ATTR_HOT double compute_next_timestep();
38   /* bring the whole system to the current time
39    * Don't schedule a new calculation time. The recalculation has to be
40    * triggered by the caller after the netlist element was changed.
41    */
42   ATTR_HOT double compute_next_timestep();
4343
44    double m_A[_storage_N][((_storage_N + 7) / 8) * 8];
45    double m_RHS[_storage_N];
46    double m_last_RHS[_storage_N]; // right hand side - contains currents
47    double m_Vdelta[_storage_N];
48    double m_last_V[_storage_N];
44   double m_A[_storage_N][((_storage_N + 7) / 8) * 8];
45   double m_RHS[_storage_N];
46   double m_last_RHS[_storage_N]; // right hand side - contains currents
47   double m_Vdelta[_storage_N];
48   double m_last_V[_storage_N];
4949
50    terms_t **m_terms;
51    terms_t *m_rails_temp;
50   terms_t **m_terms;
51   terms_t *m_rails_temp;
5252
5353private:
54    vector_ops_t *m_row_ops[_storage_N + 1];
54   vector_ops_t *m_row_ops[_storage_N + 1];
5555
56    int m_dim;
57    double m_lp_fact;
56   int m_dim;
57   double m_lp_fact;
5858};
5959
6060// ----------------------------------------------------------------------------------------
r31374r31375
6464template <int m_N, int _storage_N>
6565netlist_matrix_solver_direct_t<m_N, _storage_N>::~netlist_matrix_solver_direct_t()
6666{
67    for (int k=0; k<_storage_N; k++)
68    {
69        //delete[] m_A[k];
70    }
71    //delete[] m_last_RHS;
72    //delete[] m_RHS;
73    delete[] m_terms;
74    delete[] m_rails_temp;
75    //delete[] m_row_ops;
67   for (int k=0; k<_storage_N; k++)
68   {
69      //delete[] m_A[k];
70   }
71   //delete[] m_last_RHS;
72   //delete[] m_RHS;
73   delete[] m_terms;
74   delete[] m_rails_temp;
75   //delete[] m_row_ops;
7676
7777}
7878
7979template <int m_N, int _storage_N>
8080ATTR_HOT double netlist_matrix_solver_direct_t<m_N, _storage_N>::compute_next_timestep()
8181{
82    double new_solver_timestep = m_params.m_max_timestep;
82   double new_solver_timestep = m_params.m_max_timestep;
8383
84    if (m_params.m_dynamic)
85    {
86        /*
87         * FIXME: We should extend the logic to use either all nets or
88         *        only output nets.
89         */
84   if (m_params.m_dynamic)
85   {
86      /*
87       * FIXME: We should extend the logic to use either all nets or
88       *        only output nets.
89       */
9090#if 0
91        for (netlist_analog_output_t * const *p = m_inps.first(); p != NULL; p = m_inps.next(p))
92        {
93            netlist_analog_net_t *n = (*p)->m_proxied_net;
91      for (netlist_analog_output_t * const *p = m_inps.first(); p != NULL; p = m_inps.next(p))
92      {
93         netlist_analog_net_t *n = (*p)->m_proxied_net;
9494#else
95        for (int k = 0; k < N(); k++)
96        {
97            netlist_analog_net_t *n = m_nets[k];
95      for (int k = 0; k < N(); k++)
96      {
97         netlist_analog_net_t *n = m_nets[k];
9898#endif
99            const double DD_n = (n->m_cur_Analog - m_last_V[k]);
100            const double hn = current_timestep();
99         const double DD_n = (n->m_cur_Analog - m_last_V[k]);
100         const double hn = current_timestep();
101101
102            double DD2 = (DD_n / hn - n->m_DD_n_m_1 / n->m_h_n_m_1) / (hn + n->m_h_n_m_1);
103            double new_net_timestep;
102         double DD2 = (DD_n / hn - n->m_DD_n_m_1 / n->m_h_n_m_1) / (hn + n->m_h_n_m_1);
103         double new_net_timestep;
104104
105            n->m_h_n_m_1 = hn;
106            n->m_DD_n_m_1 = DD_n;
107            if (fabs(DD2) > 1e-50) // avoid div-by-zero
108                new_net_timestep = sqrt(m_params.m_lte / fabs(0.5*DD2));
109            else
110                new_net_timestep = m_params.m_max_timestep;
105         n->m_h_n_m_1 = hn;
106         n->m_DD_n_m_1 = DD_n;
107         if (fabs(DD2) > 1e-50) // avoid div-by-zero
108            new_net_timestep = sqrt(m_params.m_lte / fabs(0.5*DD2));
109         else
110            new_net_timestep = m_params.m_max_timestep;
111111
112            if (new_net_timestep < new_solver_timestep)
113                new_solver_timestep = new_net_timestep;
114        }
115        if (new_solver_timestep < m_params.m_min_timestep)
116            new_solver_timestep = m_params.m_min_timestep;
117    }
118    //if (new_solver_timestep > 10.0 * hn)
119    //    new_solver_timestep = 10.0 * hn;
120    return new_solver_timestep;
112         if (new_net_timestep < new_solver_timestep)
113            new_solver_timestep = new_net_timestep;
114      }
115      if (new_solver_timestep < m_params.m_min_timestep)
116         new_solver_timestep = m_params.m_min_timestep;
117   }
118   //if (new_solver_timestep > 10.0 * hn)
119   //    new_solver_timestep = 10.0 * hn;
120   return new_solver_timestep;
121121}
122122
123123template <int m_N, int _storage_N>
124124ATTR_COLD void netlist_matrix_solver_direct_t<m_N, _storage_N>::add_term(int k, netlist_terminal_t *term)
125125{
126    if (term->m_otherterm->net().isRailNet())
127    {
128        m_rails_temp[k].add(term, -1);
129    }
130    else
131    {
132        int ot = get_net_idx(&term->m_otherterm->net());
133        if (ot>=0)
134        {
135            m_terms[k]->add(term, ot);
136            SOLVER_VERBOSE_OUT(("Net %d Term %s %f %f\n", k, terms[i]->name().cstr(), terms[i]->m_gt, terms[i]->m_go));
137        }
138        /* Should this be allowed ? */
139        else // if (ot<0)
140        {
141           m_rails_temp[k].add(term, ot);
142           netlist().error("found term with missing othernet %s\n", term->name().cstr());
143        }
144    }
126   if (term->m_otherterm->net().isRailNet())
127   {
128      m_rails_temp[k].add(term, -1);
129   }
130   else
131   {
132      int ot = get_net_idx(&term->m_otherterm->net());
133      if (ot>=0)
134      {
135         m_terms[k]->add(term, ot);
136         SOLVER_VERBOSE_OUT(("Net %d Term %s %f %f\n", k, terms[i]->name().cstr(), terms[i]->m_gt, terms[i]->m_go));
137      }
138      /* Should this be allowed ? */
139      else // if (ot<0)
140      {
141         m_rails_temp[k].add(term, ot);
142         netlist().error("found term with missing othernet %s\n", term->name().cstr());
143      }
144   }
145145}
146146
147147
148148template <int m_N, int _storage_N>
149149ATTR_COLD void netlist_matrix_solver_direct_t<m_N, _storage_N>::vsetup(netlist_analog_net_t::list_t &nets)
150150{
151   if (m_dim < nets.count())
152      netlist().error("Dimension %d less than %d", m_dim, nets.count());
151153
152    if (m_dim < nets.count())
153        netlist().error("Dimension %d less than %d", m_dim, nets.count());
154   for (int k = 0; k < N(); k++)
155   {
156      m_terms[k]->clear();
157      m_rails_temp[k].clear();
158   }
154159
155    for (int k = 0; k < N(); k++)
156    {
157        m_terms[k]->clear();
158        m_rails_temp[k].clear();
159    }
160   netlist_matrix_solver_t::setup(nets);
160161
161    netlist_matrix_solver_t::setup(nets);
162   for (int k = 0; k < N(); k++)
163   {
164      m_terms[k]->m_railstart = m_terms[k]->count();
165      for (int i = 0; i < m_rails_temp[k].count(); i++)
166         this->m_terms[k]->add(m_rails_temp[k].terms()[i], m_rails_temp[k].net_other()[i]);
162167
163    for (int k = 0; k < N(); k++)
164    {
165        m_terms[k]->m_railstart = m_terms[k]->count();
166        for (int i = 0; i < m_rails_temp[k].count(); i++)
167            this->m_terms[k]->add(m_rails_temp[k].terms()[i], m_rails_temp[k].net_other()[i]);
168      m_rails_temp[k].clear(); // no longer needed
169      m_terms[k]->set_pointers();
170   }
168171
169        m_rails_temp[k].clear(); // no longer needed
170        m_terms[k]->set_pointers();
171    }
172
173172#if 1
174173
175    /* Sort in descending order by number of connected matrix voltages.
176     * The idea is, that for Gauss-Seidel algo the first voltage computed
177     * depends on the greatest number of previous voltages thus taking into
178     * account the maximum amout of information.
179     *
180     * This actually improves performance on popeye slightly. Average
181     * GS computations reduce from 2.509 to 2.370
182     *
183     * Smallest to largest : 2.613
184     * Unsorted            : 2.509
185     * Largest to smallest : 2.370
186     *
187     * Sorting as a general matrix pre-conditioning is mentioned in
188     * literature but I have found no articles about Gauss Seidel.
189     *
190     */
174   /* Sort in descending order by number of connected matrix voltages.
175    * The idea is, that for Gauss-Seidel algo the first voltage computed
176    * depends on the greatest number of previous voltages thus taking into
177    * account the maximum amout of information.
178    *
179    * This actually improves performance on popeye slightly. Average
180    * GS computations reduce from 2.509 to 2.370
181    *
182    * Smallest to largest : 2.613
183    * Unsorted            : 2.509
184    * Largest to smallest : 2.370
185    *
186    * Sorting as a general matrix pre-conditioning is mentioned in
187    * literature but I have found no articles about Gauss Seidel.
188    *
189    */
191190
192191
193    for (int k = 0; k < N() / 2; k++)
194        for (int i = 0; i < N() - 1; i++)
195        {
196            if (m_terms[i]->m_railstart < m_terms[i+1]->m_railstart)
197            {
198                std::swap(m_terms[i],m_terms[i+1]);
199                m_nets.swap(i, i+1);
200            }
201        }
192   for (int k = 0; k < N() / 2; k++)
193      for (int i = 0; i < N() - 1; i++)
194      {
195         if (m_terms[i]->m_railstart < m_terms[i+1]->m_railstart)
196         {
197            std::swap(m_terms[i],m_terms[i+1]);
198            m_nets.swap(i, i+1);
199         }
200      }
202201
203    for (int k = 0; k < N(); k++)
204    {
205        int *other = m_terms[k]->net_other();
206        for (int i = 0; i < m_terms[k]->count(); i++)
207            if (other[i] != -1)
208                other[i] = get_net_idx(&m_terms[k]->terms()[i]->m_otherterm->net());
209    }
202   for (int k = 0; k < N(); k++)
203   {
204      int *other = m_terms[k]->net_other();
205      for (int i = 0; i < m_terms[k]->count(); i++)
206         if (other[i] != -1)
207            other[i] = get_net_idx(&m_terms[k]->terms()[i]->m_otherterm->net());
208   }
210209
211210#endif
212211
r31374r31375
216215ATTR_HOT void netlist_matrix_solver_direct_t<m_N, _storage_N>::build_LE()
217216{
218217#if 0
219    for (int k=0; k < N(); k++)
220        for (int i=0; i < N(); i++)
221            m_A[k][i] = 0.0;
218   for (int k=0; k < N(); k++)
219      for (int i=0; i < N(); i++)
220         m_A[k][i] = 0.0;
222221#endif
223222
224    for (int k = 0; k < N(); k++)
225    {
226        for (int i=0; i < N(); i++)
227            m_A[k][i] = 0.0;
223   for (int k = 0; k < N(); k++)
224   {
225      for (int i=0; i < N(); i++)
226         m_A[k][i] = 0.0;
228227
229        double rhsk = 0.0;
230        double akk  = 0.0;
231        {
232            const int terms_count = m_terms[k]->count();
233            const double * RESTRICT gt = m_terms[k]->gt();
234            const double * RESTRICT go = m_terms[k]->go();
235            const double * RESTRICT Idr = m_terms[k]->Idr();
228      double rhsk = 0.0;
229      double akk  = 0.0;
230      {
231         const int terms_count = m_terms[k]->count();
232         const double * RESTRICT gt = m_terms[k]->gt();
233         const double * RESTRICT go = m_terms[k]->go();
234         const double * RESTRICT Idr = m_terms[k]->Idr();
236235#if VECTALT
237236
238            for (int i = 0; i < terms_count; i++)
239            {
240                rhsk = rhsk + Idr[i];
241                akk = akk + gt[i];
242            }
237         for (int i = 0; i < terms_count; i++)
238         {
239            rhsk = rhsk + Idr[i];
240            akk = akk + gt[i];
241         }
243242#else
244            m_terms[k]->ops()->sum2(Idr, gt, rhsk, akk);
243         m_terms[k]->ops()->sum2(Idr, gt, rhsk, akk);
245244#endif
246            double * const * RESTRICT other_cur_analog = m_terms[k]->other_curanalog();
247            for (int i = m_terms[k]->m_railstart; i < terms_count; i++)
248            {
249                //rhsk = rhsk + go[i] * terms[i]->m_otherterm->net().as_analog().Q_Analog();
250                rhsk = rhsk + go[i] * *other_cur_analog[i];
251            }
252        }
245         double * const * RESTRICT other_cur_analog = m_terms[k]->other_curanalog();
246         for (int i = m_terms[k]->m_railstart; i < terms_count; i++)
247         {
248            //rhsk = rhsk + go[i] * terms[i]->m_otherterm->net().as_analog().Q_Analog();
249            rhsk = rhsk + go[i] * *other_cur_analog[i];
250         }
251      }
253252#if 0
254        /*
255         * Matrix preconditioning with 1.0 / Akk
256         *
257         * will save a number of calculations during elimination
258         *
259         */
260        akk = 1.0 / akk;
261        m_RHS[k] = rhsk * akk;
262        m_A[k][k] += 1.0;
263        {
264            const int *net_other = m_terms[k]->net_other();
265            const double *go = m_terms[k]->go();
266            const int railstart =  m_terms[k]->m_railstart;
253      /*
254       * Matrix preconditioning with 1.0 / Akk
255       *
256       * will save a number of calculations during elimination
257       *
258       */
259      akk = 1.0 / akk;
260      m_RHS[k] = rhsk * akk;
261      m_A[k][k] += 1.0;
262      {
263         const int *net_other = m_terms[k]->net_other();
264         const double *go = m_terms[k]->go();
265         const int railstart =  m_terms[k]->m_railstart;
267266
268            for (int i = 0; i < railstart; i++)
269            {
270                m_A[k][net_other[i]] += -go[i] * akk;
271            }
272        }
267         for (int i = 0; i < railstart; i++)
268         {
269            m_A[k][net_other[i]] += -go[i] * akk;
270         }
271      }
273272#else
274        m_RHS[k] = rhsk;
275        m_A[k][k] += akk;
276        {
277            const int * RESTRICT net_other = m_terms[k]->net_other();
278            const double * RESTRICT go = m_terms[k]->go();
279            const int railstart =  m_terms[k]->m_railstart;
273      m_RHS[k] = rhsk;
274      m_A[k][k] += akk;
275      {
276         const int * RESTRICT net_other = m_terms[k]->net_other();
277         const double * RESTRICT go = m_terms[k]->go();
278         const int railstart =  m_terms[k]->m_railstart;
280279
281            for (int i = 0; i < railstart; i++)
282            {
283                m_A[k][net_other[i]] += -go[i];
284            }
285        }
280         for (int i = 0; i < railstart; i++)
281         {
282            m_A[k][net_other[i]] += -go[i];
283         }
284      }
286285#endif
287    }
286   }
288287}
289288
290289template <int m_N, int _storage_N>
291290ATTR_HOT void netlist_matrix_solver_direct_t<m_N, _storage_N>::gauss_LE(
292        double (* RESTRICT x))
291      double (* RESTRICT x))
293292{
294293#if 0
295    for (int i = 0; i < N(); i++)
296    {
297        for (int k = 0; k < N(); k++)
298            printf("%f ", m_A[i][k]);
299        printf("| %f = %f \n", x[i], m_RHS[i]);
300    }
301    printf("\n");
294   for (int i = 0; i < N(); i++)
295   {
296      for (int k = 0; k < N(); k++)
297         printf("%f ", m_A[i][k]);
298      printf("| %f = %f \n", x[i], m_RHS[i]);
299   }
300   printf("\n");
302301#endif
303302
304    const int kN = N();
303   const int kN = N();
305304
306    for (int i = 0; i < kN; i++) {
307        // FIXME: use a parameter to enable pivoting?
308        if (USE_PIVOT_SEARCH)
309        {
310            /* Find the row with the largest first value */
311            int maxrow = i;
312            for (int j = i + 1; j < kN; j++)
313            {
314                if (fabs(m_A[j][i]) > fabs(m_A[maxrow][i]))
315                    maxrow = j;
316            }
305   for (int i = 0; i < kN; i++) {
306      // FIXME: use a parameter to enable pivoting?
307      if (USE_PIVOT_SEARCH)
308      {
309         /* Find the row with the largest first value */
310         int maxrow = i;
311         for (int j = i + 1; j < kN; j++)
312         {
313            if (fabs(m_A[j][i]) > fabs(m_A[maxrow][i]))
314               maxrow = j;
315         }
317316
318            if (maxrow != i)
319            {
320                /* Swap the maxrow and ith row */
321                for (int k = i; k < kN; k++) {
322                    std::swap(m_A[i][k], m_A[maxrow][k]);
323                }
324                std::swap(m_RHS[i], m_RHS[maxrow]);
325            }
326        }
317         if (maxrow != i)
318         {
319            /* Swap the maxrow and ith row */
320            for (int k = i; k < kN; k++) {
321               std::swap(m_A[i][k], m_A[maxrow][k]);
322            }
323            std::swap(m_RHS[i], m_RHS[maxrow]);
324         }
325      }
327326
328        /* FIXME: Singular matrix? */
329        const double f = 1.0 / m_A[i][i];
327      /* FIXME: Singular matrix? */
328      const double f = 1.0 / m_A[i][i];
330329
331        /* Eliminate column i from row j */
330      /* Eliminate column i from row j */
332331
333        for (int j = i + 1; j < kN; j++)
334        {
335            const double f1 = - m_A[j][i] * f;
336            if (f1 != 0.0)
337            {
332      for (int j = i + 1; j < kN; j++)
333      {
334         const double f1 = - m_A[j][i] * f;
335         if (f1 != 0.0)
336         {
338337#if 0 && VECTALT
339                for (int k = i + 1; k < kN; k++)
340                    m_A[j][k] += m_A[i][k] * f1;
338            for (int k = i + 1; k < kN; k++)
339               m_A[j][k] += m_A[i][k] * f1;
341340#else
342                // addmult gives some performance increase here...
343                m_row_ops[kN - (i + 1)]->addmult(&m_A[j][i+1], &m_A[i][i+1], f1) ;
341            // addmult gives some performance increase here...
342            m_row_ops[kN - (i + 1)]->addmult(&m_A[j][i+1], &m_A[i][i+1], f1) ;
344343#endif
345                m_RHS[j] += m_RHS[i] * f1;
346            }
347        }
348    }
349    /* back substitution */
350    for (int j = kN - 1; j >= 0; j--)
351    {
352        double tmp = 0;
344            m_RHS[j] += m_RHS[i] * f1;
345         }
346      }
347   }
348   /* back substitution */
349   for (int j = kN - 1; j >= 0; j--)
350   {
351      double tmp = 0;
353352
354        for (int k = j + 1; k < kN; k++)
355            tmp += m_A[j][k] * x[k];
353      for (int k = j + 1; k < kN; k++)
354         tmp += m_A[j][k] * x[k];
356355
357        x[j] = (m_RHS[j] - tmp) / m_A[j][j];
358    }
356      x[j] = (m_RHS[j] - tmp) / m_A[j][j];
357   }
359358#if 0
360    printf("Solution:\n");
361    for (int i = 0; i < N(); i++)
362    {
363        for (int k = 0; k < N(); k++)
364            printf("%f ", m_A[i][k]);
365        printf("| %f = %f \n", x[i], m_RHS[i]);
366    }
367    printf("\n");
359   printf("Solution:\n");
360   for (int i = 0; i < N(); i++)
361   {
362      for (int k = 0; k < N(); k++)
363         printf("%f ", m_A[i][k]);
364      printf("| %f = %f \n", x[i], m_RHS[i]);
365   }
366   printf("\n");
368367#endif
369368
370369}
371370
372371template <int m_N, int _storage_N>
373372ATTR_HOT double netlist_matrix_solver_direct_t<m_N, _storage_N>::delta(
374        const double (* RESTRICT V))
373      const double (* RESTRICT V))
375374{
376    double cerr = 0;
377    double cerr2 = 0;
378    for (int i = 0; i < this->N(); i++)
379    {
380        const double e = (V[i] - this->m_nets[i]->m_cur_Analog);
381        const double e2 = (m_RHS[i] - this->m_last_RHS[i]);
382        cerr = (fabs(e) > cerr ? fabs(e) : cerr);
383        cerr2 = (fabs(e2) > cerr2 ? fabs(e2) : cerr2);
384    }
385    // FIXME: Review
386    return cerr + cerr2*100000.0;
375   double cerr = 0;
376   double cerr2 = 0;
377   for (int i = 0; i < this->N(); i++)
378   {
379      const double e = (V[i] - this->m_nets[i]->m_cur_Analog);
380      const double e2 = (m_RHS[i] - this->m_last_RHS[i]);
381      cerr = (fabs(e) > cerr ? fabs(e) : cerr);
382      cerr2 = (fabs(e2) > cerr2 ? fabs(e2) : cerr2);
383   }
384   // FIXME: Review
385   return cerr + cerr2*100000.0;
387386}
388387
389388template <int m_N, int _storage_N>
390389ATTR_HOT void netlist_matrix_solver_direct_t<m_N, _storage_N>::store(
391        const double (* RESTRICT V), const bool store_RHS)
390      const double (* RESTRICT V), const bool store_RHS)
392391{
393    for (int i = 0; i < this->N(); i++)
394    {
395        this->m_nets[i]->m_cur_Analog = V[i];
396    }
397    if (store_RHS)
398    {
399        for (int i = 0; i < this->N(); i++)
400        {
401            this->m_last_RHS[i] = m_RHS[i];
402        }
403    }
392   for (int i = 0; i < this->N(); i++)
393   {
394      this->m_nets[i]->m_cur_Analog = V[i];
395   }
396   if (store_RHS)
397   {
398      for (int i = 0; i < this->N(); i++)
399      {
400         this->m_last_RHS[i] = m_RHS[i];
401      }
402   }
404403}
405404
406405template <int m_N, int _storage_N>
407406ATTR_HOT double netlist_matrix_solver_direct_t<m_N, _storage_N>::vsolve()
408407{
409    solve_base<netlist_matrix_solver_direct_t>(this);
410    return this->compute_next_timestep();
408   solve_base<netlist_matrix_solver_direct_t>(this);
409   return this->compute_next_timestep();
411410}
412411
413412
414413template <int m_N, int _storage_N>
415414ATTR_HOT int netlist_matrix_solver_direct_t<m_N, _storage_N>::solve_non_dynamic()
416415{
417    double new_v[_storage_N] = { 0.0 };
416   double new_v[_storage_N] = { 0.0 };
418417
419    this->gauss_LE(new_v);
418   this->gauss_LE(new_v);
420419
421    if (this->is_dynamic())
422    {
423        double err = delta(new_v);
420   if (this->is_dynamic())
421   {
422      double err = delta(new_v);
424423
425        store(new_v, true);
424      store(new_v, true);
426425
427        if (err > this->m_params.m_accuracy)
428        {
429            return 2;
430        }
431        return 1;
432    }
433    store(new_v, false);  // ==> No need to store RHS
434    return 1;
426      if (err > this->m_params.m_accuracy)
427      {
428         return 2;
429      }
430      return 1;
431   }
432   store(new_v, false);  // ==> No need to store RHS
433   return 1;
435434}
436435
437436template <int m_N, int _storage_N>
438437ATTR_HOT inline int netlist_matrix_solver_direct_t<m_N, _storage_N>::vsolve_non_dynamic()
439438{
440    this->build_LE();
439   this->build_LE();
441440
442    return this->solve_non_dynamic();
441   return this->solve_non_dynamic();
443442}
444443
445444template <int m_N, int _storage_N>
r31374r31375
448447, m_dim(size)
449448, m_lp_fact(0)
450449{
451    m_terms = new terms_t *[N()];
452    m_rails_temp = new terms_t[N()];
450   m_terms = new terms_t *[N()];
451   m_rails_temp = new terms_t[N()];
453452
454    for (int k = 0; k < N(); k++)
455    {
456        m_terms[k] = new terms_t;
457        m_row_ops[k] = vector_ops_t::create_ops(k);
458    }
459    m_row_ops[N()] = vector_ops_t::create_ops(N());
453   for (int k = 0; k < N(); k++)
454   {
455      m_terms[k] = new terms_t;
456      m_row_ops[k] = vector_ops_t::create_ops(k);
457   }
458   m_row_ops[N()] = vector_ops_t::create_ops(N());
460459}
461460
462461
trunk/src/emu/netlist/analog/nld_solver.h
r31374r31375
4545   bool m_dynamic;
4646   int m_gs_loops;
4747   int m_nr_loops;
48    netlist_time m_nt_sync_delay;
48   netlist_time m_nt_sync_delay;
4949};
5050
5151class vector_ops_t
5252{
5353public:
5454
55    vector_ops_t(int size)
56    : m_dim(size)
57    {
58    }
55   vector_ops_t(int size)
56   : m_dim(size)
57   {
58   }
5959
60    virtual ~vector_ops_t() {}
60   virtual ~vector_ops_t() {}
6161
62    virtual const double sum(const double * v) = 0;
63    virtual void sum2(const double * RESTRICT v1, const double * RESTRICT v2, double & RESTRICT  s1, double & RESTRICT s2) = 0;
64    virtual void addmult(double * RESTRICT v1, const double * RESTRICT v2, const double &mult) = 0;
65    virtual void sum2a(const double * RESTRICT v1, const double * RESTRICT v2, const double * RESTRICT v3abs, double & RESTRICT s1, double & RESTRICT s2, double & RESTRICT s3abs) = 0;
62   virtual const double sum(const double * v) = 0;
63   virtual void sum2(const double * RESTRICT v1, const double * RESTRICT v2, double & RESTRICT  s1, double & RESTRICT s2) = 0;
64   virtual void addmult(double * RESTRICT v1, const double * RESTRICT v2, const double &mult) = 0;
65   virtual void sum2a(const double * RESTRICT v1, const double * RESTRICT v2, const double * RESTRICT v3abs, double & RESTRICT s1, double & RESTRICT s2, double & RESTRICT s3abs) = 0;
6666
67    virtual const double sumabs(const double * v) = 0;
67   virtual const double sumabs(const double * v) = 0;
6868
69    static vector_ops_t *create_ops(const int size);
69   static vector_ops_t *create_ops(const int size);
7070
7171protected:
72    int m_dim;
72   int m_dim;
7373
7474private:
7575
r31374r31375
8080{
8181public:
8282
83    vector_ops_impl_t()
84    : vector_ops_t(m_N)
85    {
86    }
83   vector_ops_impl_t()
84   : vector_ops_t(m_N)
85   {
86   }
8787
88    vector_ops_impl_t(int size)
89    : vector_ops_t(size)
90    {
91        assert(m_N == 0);
92    }
88   vector_ops_impl_t(int size)
89   : vector_ops_t(size)
90   {
91      assert(m_N == 0);
92   }
9393
94    virtual ~vector_ops_impl_t() {}
94   virtual ~vector_ops_impl_t() {}
9595
96    ATTR_HOT inline const int N() const { if (m_N == 0) return m_dim; else return m_N; }
96   ATTR_HOT inline const int N() const { if (m_N == 0) return m_dim; else return m_N; }
9797
98    const double sum(const double * v)
99    {
100        const double *  RESTRICT vl = v;
101        double tmp = 0.0;
102        for (int i=0; i < N(); i++)
103            tmp += vl[i];
104        return tmp;
105    }
98   const double sum(const double * v)
99   {
100      const double *  RESTRICT vl = v;
101      double tmp = 0.0;
102      for (int i=0; i < N(); i++)
103         tmp += vl[i];
104      return tmp;
105   }
106106
107    void sum2(const double * RESTRICT v1, const double * RESTRICT v2, double & RESTRICT s1, double & RESTRICT s2)
108    {
109        const double * RESTRICT v1l = v1;
110        const double * RESTRICT v2l = v2;
111        for (int i=0; i < N(); i++)
112        {
113            s1 += v1l[i];
114            s2 += v2l[i];
115        }
116    }
107   void sum2(const double * RESTRICT v1, const double * RESTRICT v2, double & RESTRICT s1, double & RESTRICT s2)
108   {
109      const double * RESTRICT v1l = v1;
110      const double * RESTRICT v2l = v2;
111      for (int i=0; i < N(); i++)
112      {
113         s1 += v1l[i];
114         s2 += v2l[i];
115      }
116   }
117117
118    void addmult(double * RESTRICT v1, const double * RESTRICT v2, const double &mult)
119    {
120        double * RESTRICT v1l = v1;
121        const double * RESTRICT v2l = v2;
122        for (int i=0; i < N(); i++)
123        {
124            v1l[i] += v2l[i] * mult;
125        }
126    }
118   void addmult(double * RESTRICT v1, const double * RESTRICT v2, const double &mult)
119   {
120      double * RESTRICT v1l = v1;
121      const double * RESTRICT v2l = v2;
122      for (int i=0; i < N(); i++)
123      {
124         v1l[i] += v2l[i] * mult;
125      }
126   }
127127
128    void sum2a(const double * RESTRICT v1, const double * RESTRICT v2, const double * RESTRICT v3abs, double & RESTRICT s1, double & RESTRICT s2, double & RESTRICT s3abs)
129    {
130        const double * RESTRICT v1l = v1;
131        const double * RESTRICT v2l = v2;
132        const double * RESTRICT v3l = v3abs;
133        for (int i=0; i < N(); i++)
134        {
135            s1 += v1l[i];
136            s2 += v2l[i];
137            s3abs += fabs(v3l[i]);
138        }
139    }
128   void sum2a(const double * RESTRICT v1, const double * RESTRICT v2, const double * RESTRICT v3abs, double & RESTRICT s1, double & RESTRICT s2, double & RESTRICT s3abs)
129   {
130      const double * RESTRICT v1l = v1;
131      const double * RESTRICT v2l = v2;
132      const double * RESTRICT v3l = v3abs;
133      for (int i=0; i < N(); i++)
134      {
135         s1 += v1l[i];
136         s2 += v2l[i];
137         s3abs += fabs(v3l[i]);
138      }
139   }
140140
141    const double sumabs(const double * v)
142    {
143        const double * RESTRICT vl = v;
144        double tmp = 0.0;
145        for (int i=0; i < N(); i++)
146            tmp += fabs(vl[i]);
147        return tmp;
148    }
141   const double sumabs(const double * v)
142   {
143      const double * RESTRICT vl = v;
144      double tmp = 0.0;
145      for (int i=0; i < N(); i++)
146         tmp += fabs(vl[i]);
147      return tmp;
148   }
149149
150150private:
151151};
152152
153153class ATTR_ALIGNED(64) terms_t
154154{
155    NETLIST_PREVENT_COPYING(terms_t)
155   NETLIST_PREVENT_COPYING(terms_t)
156156
157    public:
158    ATTR_COLD terms_t() : m_railstart(0), m_ops(NULL)
159    {}
157   public:
158   ATTR_COLD terms_t() : m_railstart(0), m_ops(NULL)
159   {}
160160
161    ATTR_COLD void clear()
162    {
163        m_term.clear();
164        m_net_other.clear();
165        m_gt.clear();
166    }
161   ATTR_COLD void clear()
162   {
163      m_term.clear();
164      m_net_other.clear();
165      m_gt.clear();
166   }
167167
168    ATTR_COLD void add(netlist_terminal_t *term, int net_other);
168   ATTR_COLD void add(netlist_terminal_t *term, int net_other);
169169
170    ATTR_HOT inline int count() { return m_term.count(); }
170   ATTR_HOT inline int count() { return m_term.count(); }
171171
172    ATTR_HOT inline netlist_terminal_t **terms() { return m_term; }
173    ATTR_HOT inline int *net_other() { return m_net_other; }
174    ATTR_HOT inline double *gt() { return m_gt; }
175    ATTR_HOT inline double *go() { return m_go; }
176    ATTR_HOT inline double *Idr() { return m_Idr; }
177    ATTR_HOT inline double **other_curanalog() { return m_other_curanalog; }
178    ATTR_HOT vector_ops_t *ops() { return m_ops; }
172   ATTR_HOT inline netlist_terminal_t **terms() { return m_term; }
173   ATTR_HOT inline int *net_other() { return m_net_other; }
174   ATTR_HOT inline double *gt() { return m_gt; }
175   ATTR_HOT inline double *go() { return m_go; }
176   ATTR_HOT inline double *Idr() { return m_Idr; }
177   ATTR_HOT inline double **other_curanalog() { return m_other_curanalog; }
178   ATTR_HOT vector_ops_t *ops() { return m_ops; }
179179
180    ATTR_COLD void set_pointers();
180   ATTR_COLD void set_pointers();
181181
182    int m_railstart;
182   int m_railstart;
183183
184184private:
185    plinearlist_t<netlist_terminal_t *> m_term;
186    plinearlist_t<int> m_net_other;
187    plinearlist_t<double> m_go;
188    plinearlist_t<double> m_gt;
189    plinearlist_t<double> m_Idr;
190    plinearlist_t<double *> m_other_curanalog;
191    vector_ops_t * m_ops;
185   plinearlist_t<netlist_terminal_t *> m_term;
186   plinearlist_t<int> m_net_other;
187   plinearlist_t<double> m_go;
188   plinearlist_t<double> m_gt;
189   plinearlist_t<double> m_Idr;
190   plinearlist_t<double *> m_other_curanalog;
191   vector_ops_t * m_ops;
192192};
193193
194194class netlist_matrix_solver_t : public netlist_device_t
r31374r31375
200200   ATTR_COLD netlist_matrix_solver_t(const netlist_solver_parameters_t &params);
201201   ATTR_COLD virtual ~netlist_matrix_solver_t();
202202
203    ATTR_COLD virtual void vsetup(netlist_analog_net_t::list_t &nets) = 0;
203   ATTR_COLD virtual void vsetup(netlist_analog_net_t::list_t &nets) = 0;
204204
205    template<class C>
206    void solve_base(C *p);
205   template<class C>
206   void solve_base(C *p);
207207
208208   ATTR_HOT double solve();
209209
210210   ATTR_HOT inline bool is_dynamic() { return m_dynamic_devices.count() > 0; }
211211   ATTR_HOT inline bool is_timestep() { return m_step_devices.count() > 0; }
212212
213    ATTR_HOT void update_forced();
214    ATTR_HOT inline void update_after(const netlist_time after)
215    {
216        m_Q_sync.net().reschedule_in_queue(after);
217    }
213   ATTR_HOT void update_forced();
214   ATTR_HOT inline void update_after(const netlist_time after)
215   {
216      m_Q_sync.net().reschedule_in_queue(after);
217   }
218218
219219   /* netdevice functions */
220220   ATTR_HOT  virtual void update();
221    ATTR_COLD virtual void start();
222    ATTR_COLD virtual void reset();
221   ATTR_COLD virtual void start();
222   ATTR_COLD virtual void reset();
223223
224    ATTR_COLD int get_net_idx(netlist_net_t *net);
224   ATTR_COLD int get_net_idx(netlist_net_t *net);
225225   ATTR_COLD virtual void log_stats() {};
226226
227227protected:
228228
229    ATTR_COLD void setup(netlist_analog_net_t::list_t &nets);
230    ATTR_HOT void update_dynamic();
229   ATTR_COLD void setup(netlist_analog_net_t::list_t &nets);
230   ATTR_HOT void update_dynamic();
231231
232    // should return next time step
233    ATTR_HOT virtual double vsolve() = 0;
232   // should return next time step
233   ATTR_HOT virtual double vsolve() = 0;
234234
235    ATTR_COLD virtual void  add_term(int net_idx, netlist_terminal_t *term) = 0;
235   ATTR_COLD virtual void  add_term(int net_idx, netlist_terminal_t *term) = 0;
236236
237    plinearlist_t<netlist_analog_net_t *> m_nets;
238    plinearlist_t<netlist_analog_output_t *> m_inps;
237   plinearlist_t<netlist_analog_net_t *> m_nets;
238   plinearlist_t<netlist_analog_output_t *> m_inps;
239239
240    int m_calculations;
241    const netlist_solver_parameters_t &m_params;
240   int m_calculations;
241   const netlist_solver_parameters_t &m_params;
242242
243    ATTR_HOT inline const double current_timestep() { return m_cur_ts; }
243   ATTR_HOT inline const double current_timestep() { return m_cur_ts; }
244244private:
245245
246    netlist_time m_last_step;
247    double m_cur_ts;
248    dev_list_t m_step_devices;
249    dev_list_t m_dynamic_devices;
246   netlist_time m_last_step;
247   double m_cur_ts;
248   dev_list_t m_step_devices;
249   dev_list_t m_dynamic_devices;
250250
251    netlist_ttl_input_t m_fb_sync;
252    netlist_ttl_output_t m_Q_sync;
251   netlist_ttl_input_t m_fb_sync;
252   netlist_ttl_output_t m_Q_sync;
253253
254    ATTR_HOT void step(const netlist_time delta);
254   ATTR_HOT void step(const netlist_time delta);
255255
256    ATTR_HOT void update_inputs();
256   ATTR_HOT void update_inputs();
257257
258258};
259259
r31374r31375
262262class ATTR_ALIGNED(64) NETLIB_NAME(solver) : public netlist_device_t
263263{
264264public:
265    NETLIB_NAME(solver)()
266    : netlist_device_t()    { }
265   NETLIB_NAME(solver)()
266   : netlist_device_t()    { }
267267
268    ATTR_COLD virtual ~NETLIB_NAME(solver)();
268   ATTR_COLD virtual ~NETLIB_NAME(solver)();
269269
270    ATTR_COLD void post_start();
270   ATTR_COLD void post_start();
271271
272    ATTR_HOT inline double gmin() { return m_gmin.Value(); }
272   ATTR_HOT inline double gmin() { return m_gmin.Value(); }
273273
274274protected:
275    ATTR_HOT void update();
276    ATTR_HOT void start();
277    ATTR_HOT void reset();
278    ATTR_HOT void update_param();
275   ATTR_HOT void update();
276   ATTR_HOT void start();
277   ATTR_HOT void reset();
278   ATTR_HOT void update_param();
279279
280    netlist_ttl_input_t m_fb_step;
281    netlist_ttl_output_t m_Q_step;
280   netlist_ttl_input_t m_fb_step;
281   netlist_ttl_output_t m_Q_step;
282282
283    netlist_param_double_t m_freq;
284    netlist_param_double_t m_sync_delay;
285    netlist_param_double_t m_accuracy;
286    netlist_param_double_t m_gmin;
287    netlist_param_double_t m_lte;
288    netlist_param_double_t m_sor;
289    netlist_param_logic_t  m_dynamic;
290    netlist_param_double_t m_min_timestep;
283   netlist_param_double_t m_freq;
284   netlist_param_double_t m_sync_delay;
285   netlist_param_double_t m_accuracy;
286   netlist_param_double_t m_gmin;
287   netlist_param_double_t m_lte;
288   netlist_param_double_t m_sor;
289   netlist_param_logic_t  m_dynamic;
290   netlist_param_double_t m_min_timestep;
291291
292    netlist_param_int_t m_nr_loops;
293    netlist_param_int_t m_gs_loops;
294    netlist_param_int_t m_gs_threshold;
295    netlist_param_int_t m_parallel;
292   netlist_param_int_t m_nr_loops;
293   netlist_param_int_t m_gs_loops;
294   netlist_param_int_t m_gs_threshold;
295   netlist_param_int_t m_parallel;
296296
297    netlist_matrix_solver_t::list_t m_mat_solvers;
297   netlist_matrix_solver_t::list_t m_mat_solvers;
298298private:
299299
300    netlist_solver_parameters_t m_params;
300   netlist_solver_parameters_t m_params;
301301
302    template <int m_N, int _storage_N>
303    netlist_matrix_solver_t *create_solver(int size, int gs_threshold, bool use_specific);
302   template <int m_N, int _storage_N>
303   netlist_matrix_solver_t *create_solver(int size, int gs_threshold, bool use_specific);
304304};
305305
306306
trunk/src/emu/netlist/analog/nld_bjt.h
r31374r31375
9898
9999   NETLIB_UPDATE_TERMINALS()
100100   {
101       const double m = (is_qtype( BJT_NPN) ? 1 : -1);
101      const double m = (is_qtype( BJT_NPN) ? 1 : -1);
102102
103103      const int new_state = (m_RB.deltaV() * m > m_V ) ? 1 : 0;
104104      if (m_state_on ^ new_state)
r31374r31375
122122         m_RB.set(gb, v,   0.0);
123123         m_RC.set(gc, 0.0, 0.0);
124124         //m_RB.update_dev();
125            //m_RC.update_dev();
125         //m_RC.update_dev();
126126         m_state_on = new_state;
127127      }
128128   }
r31374r31375
164164      m_D_EB(netlist_object_t::ANALOG),
165165      m_D_EC(netlist_object_t::ANALOG),
166166      m_alpha_f(0),
167       m_alpha_r(0)
167      m_alpha_r(0)
168168      { }
169169
170170   NETLIB_UPDATE_TERMINALS()
trunk/src/emu/netlist/analog/nld_ms_direct1.h
r31374r31375
1313{
1414public:
1515
16    netlist_matrix_solver_direct1_t(const netlist_solver_parameters_t &params)
17      : netlist_matrix_solver_direct_t<1, 1>(params, 1)
18      {}
19    ATTR_HOT inline int vsolve_non_dynamic();
16   netlist_matrix_solver_direct1_t(const netlist_solver_parameters_t &params)
17      : netlist_matrix_solver_direct_t<1, 1>(params, 1)
18      {}
19   ATTR_HOT inline int vsolve_non_dynamic();
2020protected:
21    ATTR_HOT virtual double vsolve();
21   ATTR_HOT virtual double vsolve();
2222private:
2323};
2424
r31374r31375
2828
2929ATTR_HOT double netlist_matrix_solver_direct1_t::vsolve()
3030{
31    solve_base<netlist_matrix_solver_direct1_t>(this);
32    return this->compute_next_timestep();
31   solve_base<netlist_matrix_solver_direct1_t>(this);
32   return this->compute_next_timestep();
3333}
3434
3535ATTR_HOT inline int netlist_matrix_solver_direct1_t::vsolve_non_dynamic()
3636{
37   netlist_analog_net_t *net = m_nets[0];
38   this->build_LE();
39   //NL_VERBOSE_OUT(("%f %f\n", new_val, m_RHS[0] / m_A[0][0]);
3740
38    netlist_analog_net_t *net = m_nets[0];
39    this->build_LE();
40    //NL_VERBOSE_OUT(("%f %f\n", new_val, m_RHS[0] / m_A[0][0]);
41   double new_val =  m_RHS[0] / m_A[0][0];
4142
42    double new_val =  m_RHS[0] / m_A[0][0];
43   double e = (new_val - net->m_cur_Analog);
44   double cerr = fabs(e);
4345
44    double e = (new_val - net->m_cur_Analog);
45    double cerr = fabs(e);
46   net->m_cur_Analog = new_val;
4647
47    net->m_cur_Analog = new_val;
48   if (is_dynamic() && (cerr  > m_params.m_accuracy))
49   {
50      return 2;
51   }
52   else
53      return 1;
4854
49    if (is_dynamic() && (cerr  > m_params.m_accuracy))
50    {
51        return 2;
52    }
53    else
54        return 1;
55
5655}
5756
5857
trunk/src/emu/netlist/analog/nld_ms_direct2.h
r31374r31375
1515{
1616public:
1717
18    netlist_matrix_solver_direct2_t(const netlist_solver_parameters_t &params)
19      : netlist_matrix_solver_direct_t<2, 2>(params, 2)
20      {}
21    ATTR_HOT inline int vsolve_non_dynamic();
18   netlist_matrix_solver_direct2_t(const netlist_solver_parameters_t &params)
19      : netlist_matrix_solver_direct_t<2, 2>(params, 2)
20      {}
21   ATTR_HOT inline int vsolve_non_dynamic();
2222protected:
23    ATTR_HOT virtual double vsolve();
23   ATTR_HOT virtual double vsolve();
2424private:
2525};
2626
r31374r31375
3030
3131ATTR_HOT double netlist_matrix_solver_direct2_t::vsolve()
3232{
33    solve_base<netlist_matrix_solver_direct2_t>(this);
34    return this->compute_next_timestep();
33   solve_base<netlist_matrix_solver_direct2_t>(this);
34   return this->compute_next_timestep();
3535}
3636
3737ATTR_HOT inline int netlist_matrix_solver_direct2_t::vsolve_non_dynamic()
3838{
39   build_LE();
3940
40    build_LE();
41   const double a = m_A[0][0];
42   const double b = m_A[0][1];
43   const double c = m_A[1][0];
44   const double d = m_A[1][1];
4145
42    const double a = m_A[0][0];
43    const double b = m_A[0][1];
44    const double c = m_A[1][0];
45    const double d = m_A[1][1];
46   double new_val[2];
47   new_val[1] = (a * m_RHS[1] - c * m_RHS[0]) / (a * d - b * c);
48   new_val[0] = (m_RHS[0] - b * new_val[1]) / a;
4649
47    double new_val[2];
48    new_val[1] = (a * m_RHS[1] - c * m_RHS[0]) / (a * d - b * c);
49    new_val[0] = (m_RHS[0] - b * new_val[1]) / a;
50
51    if (is_dynamic())
52    {
53        double err = this->delta(new_val);
54        store(new_val, true);
55        if (err > m_params.m_accuracy )
56            return 2;
57        else
58            return 1;
59    }
60    store(new_val, false);
61    return 1;
50   if (is_dynamic())
51   {
52      double err = this->delta(new_val);
53      store(new_val, true);
54      if (err > m_params.m_accuracy )
55         return 2;
56      else
57         return 1;
58   }
59   store(new_val, false);
60   return 1;
6261}
6362
6463
trunk/src/emu/netlist/analog/nld_opamps.h
r31374r31375
1919// ----------------------------------------------------------------------------------------
2020
2121#define LM3900(_name)                                                          \
22    SUBMODEL(_name, opamp_lm3900)
22   SUBMODEL(_name, opamp_lm3900)
2323
2424// ----------------------------------------------------------------------------------------
2525// Devices ...
trunk/src/emu/netlist/analog/nld_twoterm.h
r31374r31375
8888{
8989public:
9090   ATTR_COLD NETLIB_NAME(twoterm)(const family_t afamily);
91    ATTR_COLD NETLIB_NAME(twoterm)();
91   ATTR_COLD NETLIB_NAME(twoterm)();
9292
9393   netlist_terminal_t m_P;
9494   netlist_terminal_t m_N;
r31374r31375
9999
100100   ATTR_HOT inline void set(const double G, const double V, const double I)
101101   {
102       /*      GO, GT, I                */
102      /*      GO, GT, I                */
103103      m_P.set( G,  G, (  V) * G - I);
104104      m_N.set( G,  G, ( -V) * G + I);
105105   }
106106
107107   ATTR_HOT inline double deltaV() const
108108   {
109       return m_P.net().as_analog().Q_Analog() - m_N.net().as_analog().Q_Analog();
109      return m_P.net().as_analog().Q_Analog() - m_N.net().as_analog().Q_Analog();
110110   }
111111
112112   ATTR_HOT void set_mat(double a11, double a12, double a21, double a22, double r1, double r2)
113113   {
114        /*      GO, GT, I                */
115       m_P.set(-a12, a11, -r1);
116       m_N.set(-a21, a22, -r2);
114      /*      GO, GT, I                */
115      m_P.set(-a12, a11, -r1);
116      m_N.set(-a21, a22, -r2);
117117   }
118118
119119protected:
r31374r31375
135135
136136   inline void set_R(const double R)
137137   {
138       set(1.0 / R, 0.0, 0.0);
138      set(1.0 / R, 0.0, 0.0);
139139   }
140140
141141protected:
trunk/src/emu/netlist/analog/nld_fourterm.h
r31374r31375
1818      NET_REGISTER_DEV(VCCS, _name)
1919
2020#define CCCS(_name)                                                                \
21        NET_REGISTER_DEV(CCCS, _name)
21      NET_REGISTER_DEV(CCCS, _name)
2222
2323#define VCVS(_name)                                                                \
2424      NET_REGISTER_DEV(VCVS, _name)
r31374r31375
104104class NETLIB_NAME(CCCS) : public NETLIB_NAME(VCCS)
105105{
106106public:
107    ATTR_COLD NETLIB_NAME(CCCS)()
108    : NETLIB_NAME(VCCS)(CCCS), m_gfac(1.0) {  }
109    //ATTR_COLD NETLIB_NAME(CCCS)(const family_t afamily)
110    //: netlist_device_t(afamily), m_gfac(1.0) {  }
107   ATTR_COLD NETLIB_NAME(CCCS)()
108   : NETLIB_NAME(VCCS)(CCCS), m_gfac(1.0) {  }
109   //ATTR_COLD NETLIB_NAME(CCCS)(const family_t afamily)
110   //: netlist_device_t(afamily), m_gfac(1.0) {  }
111111
112112protected:
113    ATTR_COLD virtual void start();
114    ATTR_COLD virtual void reset();
115    ATTR_COLD virtual void update_param();
116    ATTR_HOT ATTR_ALIGN void update();
113   ATTR_COLD virtual void start();
114   ATTR_COLD virtual void reset();
115   ATTR_COLD virtual void update_param();
116   ATTR_HOT ATTR_ALIGN void update();
117117
118    double m_gfac;
118   double m_gfac;
119119};
120120
121121
trunk/src/emu/netlist/analog/nld_ms_gauss_seidel.h
r31374r31375
1616{
1717public:
1818
19    netlist_matrix_solver_gauss_seidel_t(const netlist_solver_parameters_t &params, int size)
20      : netlist_matrix_solver_direct_t<m_N, _storage_N>(params, size)
21      , m_lp_fact(0)
22      , m_gs_fail(0)
23      , m_gs_total(0)
24      {}
19   netlist_matrix_solver_gauss_seidel_t(const netlist_solver_parameters_t &params, int size)
20      : netlist_matrix_solver_direct_t<m_N, _storage_N>(params, size)
21      , m_lp_fact(0)
22      , m_gs_fail(0)
23      , m_gs_total(0)
24      {}
2525
26    virtual ~netlist_matrix_solver_gauss_seidel_t() {}
26   virtual ~netlist_matrix_solver_gauss_seidel_t() {}
2727
28    ATTR_COLD virtual void log_stats();
28   ATTR_COLD virtual void log_stats();
2929
30    ATTR_HOT inline int vsolve_non_dynamic();
30   ATTR_HOT inline int vsolve_non_dynamic();
3131protected:
32    ATTR_HOT virtual double vsolve();
32   ATTR_HOT virtual double vsolve();
3333
3434private:
35    double m_lp_fact;
36    int m_gs_fail;
37    int m_gs_total;
35   double m_lp_fact;
36   int m_gs_fail;
37   int m_gs_total;
3838
3939};
4040
r31374r31375
4646void netlist_matrix_solver_gauss_seidel_t<m_N, _storage_N>::log_stats()
4747{
4848#if 0
49    if (this->m_calculations == 0)
50        return;
51    printf("==============================================\n");
52    printf("Solver %s\n", this->name().cstr());
53    printf("       ==> %d nets\n", this->N()); //, (*(*groups[i].first())->m_core_terms.first())->name().cstr());
54    printf("       has %s elements\n", this->is_dynamic() ? "dynamic" : "no dynamic");
55    printf("       has %s elements\n", this->is_timestep() ? "timestep" : "no timestep");
56    printf("       %10d invocations (%6d Hz)  %10d gs fails (%6.2f%%) %6.3f average\n",
57            this->m_calculations,
58            this->m_calculations * 10 / (int) (this->netlist().time().as_double() * 10.0),
59            this->m_gs_fail,
60            100.0 * (double) this->m_gs_fail / (double) this->m_calculations,
61            (double) this->m_gs_total / (double) this->m_calculations);
49   if (this->m_calculations == 0)
50      return;
51   printf("==============================================\n");
52   printf("Solver %s\n", this->name().cstr());
53   printf("       ==> %d nets\n", this->N()); //, (*(*groups[i].first())->m_core_terms.first())->name().cstr());
54   printf("       has %s elements\n", this->is_dynamic() ? "dynamic" : "no dynamic");
55   printf("       has %s elements\n", this->is_timestep() ? "timestep" : "no timestep");
56   printf("       %10d invocations (%6d Hz)  %10d gs fails (%6.2f%%) %6.3f average\n",
57         this->m_calculations,
58         this->m_calculations * 10 / (int) (this->netlist().time().as_double() * 10.0),
59         this->m_gs_fail,
60         100.0 * (double) this->m_gs_fail / (double) this->m_calculations,
61         (double) this->m_gs_total / (double) this->m_calculations);
6262#endif
6363}
6464
6565template <int m_N, int _storage_N>
6666ATTR_HOT double netlist_matrix_solver_gauss_seidel_t<m_N, _storage_N>::vsolve()
6767{
68    /*
69     * enable linear prediction on first newton pass
70     */
68   /*
69    * enable linear prediction on first newton pass
70    */
7171
72    if (USE_LINEAR_PREDICTION)
73        for (int k = 0; k < this->N(); k++)
74        {
75            this->m_last_V[k] = this->m_nets[k]->m_cur_Analog;
76            this->m_nets[k]->m_cur_Analog = this->m_nets[k]->m_cur_Analog + this->m_Vdelta[k] * this->current_timestep() * m_lp_fact;
77        }
78    else
79        for (int k = 0; k < this->N(); k++)
80        {
81            this->m_last_V[k] = this->m_nets[k]->m_cur_Analog;
82        }
72   if (USE_LINEAR_PREDICTION)
73      for (int k = 0; k < this->N(); k++)
74      {
75         this->m_last_V[k] = this->m_nets[k]->m_cur_Analog;
76         this->m_nets[k]->m_cur_Analog = this->m_nets[k]->m_cur_Analog + this->m_Vdelta[k] * this->current_timestep() * m_lp_fact;
77      }
78   else
79      for (int k = 0; k < this->N(); k++)
80      {
81         this->m_last_V[k] = this->m_nets[k]->m_cur_Analog;
82      }
8383
84    this->solve_base(this);
84   this->solve_base(this);
8585
86    if (USE_LINEAR_PREDICTION)
87    {
88        double sq = 0;
89        double sqo = 0;
90        const double rez_cts = 1.0 / this->current_timestep();
91        for (int k = 0; k < this->N(); k++)
92        {
93            const netlist_analog_net_t *n = this->m_nets[k];
94            const double nv = (n->m_cur_Analog - this->m_last_V[k]) * rez_cts ;
95            sq += nv * nv;
96            sqo += this->m_Vdelta[k] * this->m_Vdelta[k];
97            this->m_Vdelta[k] = nv;
98        }
99        if (sqo > 1e-90)
100            m_lp_fact = std::min(sqrt(sq/sqo), 2.0);
101        else
102            m_lp_fact = 0.0;
103    }
86   if (USE_LINEAR_PREDICTION)
87   {
88      double sq = 0;
89      double sqo = 0;
90      const double rez_cts = 1.0 / this->current_timestep();
91      for (int k = 0; k < this->N(); k++)
92      {
93         const netlist_analog_net_t *n = this->m_nets[k];
94         const double nv = (n->m_cur_Analog - this->m_last_V[k]) * rez_cts ;
95         sq += nv * nv;
96         sqo += this->m_Vdelta[k] * this->m_Vdelta[k];
97         this->m_Vdelta[k] = nv;
98      }
99      if (sqo > 1e-90)
100         m_lp_fact = std::min(sqrt(sq/sqo), 2.0);
101      else
102         m_lp_fact = 0.0;
103   }
104104
105105
106    return this->compute_next_timestep();
106   return this->compute_next_timestep();
107107}
108108
109109template <int m_N, int _storage_N>
110110ATTR_HOT inline int netlist_matrix_solver_gauss_seidel_t<m_N, _storage_N>::vsolve_non_dynamic()
111111{
112    /* The matrix based code looks a lot nicer but actually is 30% slower than
113     * the optimized code which works directly on the data structures.
114     * Need something like that for gaussian elimination as well.
115     */
112   /* The matrix based code looks a lot nicer but actually is 30% slower than
113    * the optimized code which works directly on the data structures.
114    * Need something like that for gaussian elimination as well.
115    */
116116
117117#if 0 || USE_MATRIX_GS
118    static double ws = 1.0;
119    ATTR_ALIGN double new_v[_storage_N] = { 0.0 };
120    const int iN = this->N();
118   static double ws = 1.0;
119   ATTR_ALIGN double new_v[_storage_N] = { 0.0 };
120   const int iN = this->N();
121121
122    bool resched = false;
122   bool resched = false;
123123
124    int  resched_cnt = 0;
124   int  resched_cnt = 0;
125125
126    this->build_LE();
126   this->build_LE();
127127
128    {
129        double frob;
130        frob = 0;
131        double rmin = 1e99, rmax = -1e99;
132        for (int k = 0; k < iN; k++)
133        {
134            new_v[k] = this->m_nets[k]->m_cur_Analog;
135            double s=0.0;
136            for (int i = 0; i < iN; i++)
137            {
138                frob += this->m_A[k][i] * this->m_A[k][i];
139                s = s + fabs(this->m_A[k][i]);
140            }
128   {
129      double frob;
130      frob = 0;
131      double rmin = 1e99, rmax = -1e99;
132      for (int k = 0; k < iN; k++)
133      {
134         new_v[k] = this->m_nets[k]->m_cur_Analog;
135         double s=0.0;
136         for (int i = 0; i < iN; i++)
137         {
138            frob += this->m_A[k][i] * this->m_A[k][i];
139            s = s + fabs(this->m_A[k][i]);
140         }
141141
142            if (s<rmin)
143                rmin = s;
144            if (s>rmax)
145                rmax = s;
146        }
142         if (s<rmin)
143            rmin = s;
144         if (s>rmax)
145            rmax = s;
146      }
147147#if 0
148        double frobA = sqrt(frob /(iN));
149        if (1 &&frobA < 1.0)
150            //ws = 2.0 / (1.0 + sqrt(1.0-frobA));
151            ws = 2.0 / (2.0 - frobA);
152        else
153            ws = 1.0;
154        ws = 0.9;
148      double frobA = sqrt(frob /(iN));
149      if (1 &&frobA < 1.0)
150         //ws = 2.0 / (1.0 + sqrt(1.0-frobA));
151         ws = 2.0 / (2.0 - frobA);
152      else
153         ws = 1.0;
154      ws = 0.9;
155155#else
156        // calculate an estimate for rho.
157        // This is based on the Perron–Frobenius theorem for positive matrices.
158        // No mathematical proof here. The following estimates the
159        // optimal relaxation parameter pretty well. Unfortunately, the
160        // overhead is bigger than the gain. Consequently the fast GS below
161        // uses a fixed GS. One can however use this here to determine a
162        // suitable parameter.
163        double rm = (rmax + rmin) * 0.5;
164        if (rm < 1.0)
165            ws = 2.0 / (1.0 + sqrt(1.0-rm));
166        else
167            ws = 1.0;
168        if (ws > 1.02 && rmax > 1.001)
169            printf("rmin %f rmax %f ws %f\n", rmin, rmax, ws);
156      // calculate an estimate for rho.
157      // This is based on the Perron???Frobenius theorem for positive matrices.
158      // No mathematical proof here. The following estimates the
159      // optimal relaxation parameter pretty well. Unfortunately, the
160      // overhead is bigger than the gain. Consequently the fast GS below
161      // uses a fixed GS. One can however use this here to determine a
162      // suitable parameter.
163      double rm = (rmax + rmin) * 0.5;
164      if (rm < 1.0)
165         ws = 2.0 / (1.0 + sqrt(1.0-rm));
166      else
167         ws = 1.0;
168      if (ws > 1.02 && rmax > 1.001)
169         printf("rmin %f rmax %f ws %f\n", rmin, rmax, ws);
170170#endif
171    }
171   }
172172
173    // Frobenius norm for (D-L)^(-1)U
174    //double frobU;
175    //double frobL;
176    //double norm;
177    do {
178        resched = false;
179        double cerr = 0.0;
180        //frobU = 0;
181        //frobL = 0;
182        //norm = 0;
173   // Frobenius norm for (D-L)^(-1)U
174   //double frobU;
175   //double frobL;
176   //double norm;
177   do {
178      resched = false;
179      double cerr = 0.0;
180      //frobU = 0;
181      //frobL = 0;
182      //norm = 0;
183183
184        for (int k = 0; k < iN; k++)
185        {
186            double Idrive = 0;
187            //double norm_t = 0;
188            // Reduction loops need -ffast-math
189            for (int i = 0; i < iN; i++)
190                Idrive += this->m_A[k][i] * new_v[i];
184      for (int k = 0; k < iN; k++)
185      {
186         double Idrive = 0;
187         //double norm_t = 0;
188         // Reduction loops need -ffast-math
189         for (int i = 0; i < iN; i++)
190            Idrive += this->m_A[k][i] * new_v[i];
191191
192            for (int i = 0; i < iN; i++)
193            {
194                //if (i < k) frobL += this->m_A[k][i] * this->m_A[k][i] / this->m_A[k][k] /this-> m_A[k][k];
195                //if (i > k) frobU += this->m_A[k][i] * this->m_A[k][i] / this->m_A[k][k] / this->m_A[k][k];
196                //norm_t += fabs(this->m_A[k][i]);
197            }
192         for (int i = 0; i < iN; i++)
193         {
194            //if (i < k) frobL += this->m_A[k][i] * this->m_A[k][i] / this->m_A[k][k] /this-> m_A[k][k];
195            //if (i > k) frobU += this->m_A[k][i] * this->m_A[k][i] / this->m_A[k][k] / this->m_A[k][k];
196            //norm_t += fabs(this->m_A[k][i]);
197         }
198198
199            //if (norm_t > norm) norm = norm_t;
200            const double new_val = (1.0-ws) * new_v[k] + ws * (this->m_RHS[k] - Idrive + this->m_A[k][k] * new_v[k]) / this->m_A[k][k];
199         //if (norm_t > norm) norm = norm_t;
200         const double new_val = (1.0-ws) * new_v[k] + ws * (this->m_RHS[k] - Idrive + this->m_A[k][k] * new_v[k]) / this->m_A[k][k];
201201
202            const double e = fabs(new_val - new_v[k]);
203            cerr = (e > cerr ? e : cerr);
204            new_v[k] = new_val;
205        }
202         const double e = fabs(new_val - new_v[k]);
203         cerr = (e > cerr ? e : cerr);
204         new_v[k] = new_val;
205      }
206206
207        if (cerr > this->m_params.m_accuracy)
208        {
209            resched = true;
210        }
211        resched_cnt++;
212        //ATTR_UNUSED double frobUL = sqrt((frobU + frobL) / (double) (iN) / (double) (iN));
213    } while (resched && (resched_cnt < this->m_params.m_gs_loops));
214    //printf("Frobenius %f %f %f %f %f\n", sqrt(frobU), sqrt(frobL), frobUL, frobA, norm);
215    //printf("Omega Estimate1 %f %f\n", 2.0 / (1.0 + sqrt(1-frobUL)), 2.0 / (1.0 + sqrt(1-frobA)) ); //        printf("Frobenius %f\n", sqrt(frob / (double) (iN * iN) ));
216    //printf("Omega Estimate2 %f %f\n", 2.0 / (2.0 - frobUL), 2.0 / (2.0 - frobA) ); //        printf("Frobenius %f\n", sqrt(frob / (double) (iN * iN) ));
207      if (cerr > this->m_params.m_accuracy)
208      {
209         resched = true;
210      }
211      resched_cnt++;
212      //ATTR_UNUSED double frobUL = sqrt((frobU + frobL) / (double) (iN) / (double) (iN));
213   } while (resched && (resched_cnt < this->m_params.m_gs_loops));
214   //printf("Frobenius %f %f %f %f %f\n", sqrt(frobU), sqrt(frobL), frobUL, frobA, norm);
215   //printf("Omega Estimate1 %f %f\n", 2.0 / (1.0 + sqrt(1-frobUL)), 2.0 / (1.0 + sqrt(1-frobA)) ); //        printf("Frobenius %f\n", sqrt(frob / (double) (iN * iN) ));
216   //printf("Omega Estimate2 %f %f\n", 2.0 / (2.0 - frobUL), 2.0 / (2.0 - frobA) ); //        printf("Frobenius %f\n", sqrt(frob / (double) (iN * iN) ));
217217
218218
219    this->store(new_v, false);
219   this->store(new_v, false);
220220
221    this->m_gs_total += resched_cnt;
222    if (resched)
223    {
224        //this->netlist().warning("Falling back to direct solver .. Consider increasing RESCHED_LOOPS");
225        this->m_gs_fail++;
226        int tmp = netlist_matrix_solver_direct_t<m_N, _storage_N>::solve_non_dynamic();
227        this->m_calculations++;
228        return tmp;
229    }
230    else {
231        this->m_calculations++;
221   this->m_gs_total += resched_cnt;
222   if (resched)
223   {
224      //this->netlist().warning("Falling back to direct solver .. Consider increasing RESCHED_LOOPS");
225      this->m_gs_fail++;
226      int tmp = netlist_matrix_solver_direct_t<m_N, _storage_N>::solve_non_dynamic();
227      this->m_calculations++;
228      return tmp;
229   }
230   else {
231      this->m_calculations++;
232232
233        return resched_cnt;
234    }
233      return resched_cnt;
234   }
235235
236236#else
237    const int iN = this->N();
238    bool resched = false;
239    int  resched_cnt = 0;
237   const int iN = this->N();
238   bool resched = false;
239   int  resched_cnt = 0;
240240
241    /* ideally, we could get an estimate for the spectral radius of
242     * Inv(D - L) * U
243     *
244     * and estimate using
245     *
246     * omega = 2.0 / (1.0 + sqrt(1-rho))
247     */
241   /* ideally, we could get an estimate for the spectral radius of
242    * Inv(D - L) * U
243    *
244    * and estimate using
245    *
246    * omega = 2.0 / (1.0 + sqrt(1-rho))
247    */
248248
249    const double ws = this->m_params.m_sor; //1.045; //2.0 / (1.0 + /*sin*/(3.14159 * 5.5 / (double) (m_nets.count()+1)));
250    //const double ws = 2.0 / (1.0 + sin(3.14159 * 4 / (double) (this->N())));
249   const double ws = this->m_params.m_sor; //1.045; //2.0 / (1.0 + /*sin*/(3.14159 * 5.5 / (double) (m_nets.count()+1)));
250   //const double ws = 2.0 / (1.0 + sin(3.14159 * 4 / (double) (this->N())));
251251
252    ATTR_ALIGN double w[_storage_N];
253    ATTR_ALIGN double one_m_w[_storage_N];
254    ATTR_ALIGN double RHS[_storage_N];
255    ATTR_ALIGN double new_V[_storage_N];
252   ATTR_ALIGN double w[_storage_N];
253   ATTR_ALIGN double one_m_w[_storage_N];
254   ATTR_ALIGN double RHS[_storage_N];
255   ATTR_ALIGN double new_V[_storage_N];
256256
257    for (int k = 0; k < iN; k++)
258    {
259        double gtot_t = 0.0;
260        double gabs_t = 0.0;
261        double RHS_t = 0.0;
257   for (int k = 0; k < iN; k++)
258   {
259      double gtot_t = 0.0;
260      double gabs_t = 0.0;
261      double RHS_t = 0.0;
262262
263        new_V[k] = this->m_nets[k]->m_cur_Analog;
263      new_V[k] = this->m_nets[k]->m_cur_Analog;
264264
265        {
266            const int term_count = this->m_terms[k]->count();
267            const double * const RESTRICT gt = this->m_terms[k]->gt();
268            const double * const RESTRICT go = this->m_terms[k]->go();
269            const double * const RESTRICT Idr = this->m_terms[k]->Idr();
270            const double * const *other_cur_analog = this->m_terms[k]->other_curanalog();
265      {
266         const int term_count = this->m_terms[k]->count();
267         const double * const RESTRICT gt = this->m_terms[k]->gt();
268         const double * const RESTRICT go = this->m_terms[k]->go();
269         const double * const RESTRICT Idr = this->m_terms[k]->Idr();
270         const double * const *other_cur_analog = this->m_terms[k]->other_curanalog();
271271#if VECTALT
272            for (int i = 0; i < term_count; i++)
273            {
274                gtot_t = gtot_t + gt[i];
275                RHS_t = RHS_t + Idr[i];
276            }
277            if (USE_GABS)
278                for (int i = 0; i < term_count; i++)
279                    gabs_t = gabs_t + fabs(go[i]);
272         for (int i = 0; i < term_count; i++)
273         {
274            gtot_t = gtot_t + gt[i];
275            RHS_t = RHS_t + Idr[i];
276         }
277         if (USE_GABS)
278            for (int i = 0; i < term_count; i++)
279               gabs_t = gabs_t + fabs(go[i]);
280280#else
281            if (USE_GABS)
282                this->m_terms[k]->ops()->sum2a(gt, Idr, go, gtot_t, RHS_t, gabs_t);
283            else
284                this->m_terms[k]->ops()->sum2(gt, Idr, gtot_t, RHS_t);
281         if (USE_GABS)
282            this->m_terms[k]->ops()->sum2a(gt, Idr, go, gtot_t, RHS_t, gabs_t);
283         else
284            this->m_terms[k]->ops()->sum2(gt, Idr, gtot_t, RHS_t);
285285#endif
286            for (int i = this->m_terms[k]->m_railstart; i < term_count; i++)
287                RHS_t = RHS_t  + go[i] * *other_cur_analog[i];
288        }
286         for (int i = this->m_terms[k]->m_railstart; i < term_count; i++)
287            RHS_t = RHS_t  + go[i] * *other_cur_analog[i];
288      }
289289
290        RHS[k] = RHS_t;
290      RHS[k] = RHS_t;
291291
292        //if (fabs(gabs_t - fabs(gtot_t)) > 1e-20)
293        //    printf("%d %e abs: %f tot: %f\n",k, gabs_t / gtot_t -1.0, gabs_t, gtot_t);
292      //if (fabs(gabs_t - fabs(gtot_t)) > 1e-20)
293      //    printf("%d %e abs: %f tot: %f\n",k, gabs_t / gtot_t -1.0, gabs_t, gtot_t);
294294
295        gabs_t *= 0.5; // avoid rounding issues
296        if (!USE_GABS || gabs_t <= gtot_t)
297        {
298            w[k] = ws / gtot_t;
299            one_m_w[k] = 1.0 - ws;
300        }
301        else
302        {
303            //printf("abs: %f tot: %f\n", gabs_t, gtot_t);
304            w[k] = 1.0 / (gtot_t + gabs_t);
305            one_m_w[k] = 1.0 - 1.0 * gtot_t / (gtot_t + gabs_t);
306        }
295      gabs_t *= 0.5; // avoid rounding issues
296      if (!USE_GABS || gabs_t <= gtot_t)
297      {
298         w[k] = ws / gtot_t;
299         one_m_w[k] = 1.0 - ws;
300      }
301      else
302      {
303         //printf("abs: %f tot: %f\n", gabs_t, gtot_t);
304         w[k] = 1.0 / (gtot_t + gabs_t);
305         one_m_w[k] = 1.0 - 1.0 * gtot_t / (gtot_t + gabs_t);
306      }
307307
308    }
308   }
309309
310    const double accuracy = this->m_params.m_accuracy;
310   const double accuracy = this->m_params.m_accuracy;
311311
312    do {
313        resched = false;
312   do {
313      resched = false;
314314
315        for (int k = 0; k < iN; k++)
316        {
317            const int * RESTRICT net_other = this->m_terms[k]->net_other();
318            const int railstart = this->m_terms[k]->m_railstart;
319            const double * RESTRICT go = this->m_terms[k]->go();
315      for (int k = 0; k < iN; k++)
316      {
317         const int * RESTRICT net_other = this->m_terms[k]->net_other();
318         const int railstart = this->m_terms[k]->m_railstart;
319         const double * RESTRICT go = this->m_terms[k]->go();
320320
321            double Idrive = 0.0;
322            for (int i = 0; i < railstart; i++)
323                Idrive = Idrive + go[i] * new_V[net_other[i]];
321         double Idrive = 0.0;
322         for (int i = 0; i < railstart; i++)
323            Idrive = Idrive + go[i] * new_V[net_other[i]];
324324
325            //double new_val = (net->m_cur_Analog * gabs[k] + iIdr) / (gtot[k]);
326            const double new_val = new_V[k] * one_m_w[k] + (Idrive + RHS[k]) * w[k];
325         //double new_val = (net->m_cur_Analog * gabs[k] + iIdr) / (gtot[k]);
326         const double new_val = new_V[k] * one_m_w[k] + (Idrive + RHS[k]) * w[k];
327327
328            resched = resched || (std::abs(new_val - new_V[k]) > accuracy);
329            new_V[k] = new_val;
330        }
328         resched = resched || (std::abs(new_val - new_V[k]) > accuracy);
329         new_V[k] = new_val;
330      }
331331
332        resched_cnt++;
333    } while (resched && (resched_cnt < this->m_params.m_gs_loops));
332      resched_cnt++;
333   } while (resched && (resched_cnt < this->m_params.m_gs_loops));
334334
335    for (int k = 0; k < iN; k++)
336        this->m_nets[k]->m_cur_Analog = new_V[k];
335   for (int k = 0; k < iN; k++)
336      this->m_nets[k]->m_cur_Analog = new_V[k];
337337
338    this->m_gs_total += resched_cnt;
339    this->m_calculations++;
338   this->m_gs_total += resched_cnt;
339   this->m_calculations++;
340340
341    if (resched)
342    {
343        //this->netlist().warning("Falling back to direct solver .. Consider increasing RESCHED_LOOPS");
344        this->m_gs_fail++;
345        return netlist_matrix_solver_direct_t<m_N, _storage_N>::vsolve_non_dynamic();
346    }
347    else {
348        return resched_cnt;
349    }
341   if (resched)
342   {
343      //this->netlist().warning("Falling back to direct solver .. Consider increasing RESCHED_LOOPS");
344      this->m_gs_fail++;
345      return netlist_matrix_solver_direct_t<m_N, _storage_N>::vsolve_non_dynamic();
346   }
347   else {
348      return resched_cnt;
349   }
350350#endif
351351}
352352
trunk/src/emu/netlist/plists.h
r31374r31375
2626   {
2727      m_num_elements = numElements;
2828      if (m_num_elements == 0)
29          m_list = NULL;
29         m_list = NULL;
3030      else
31          m_list = new _ListClass[m_num_elements];
31         m_list = new _ListClass[m_num_elements];
3232      m_count = 0;
3333   }
3434
3535   ATTR_COLD plinearlist_t(const plinearlist_t &rhs)
3636   {
3737      m_num_elements = rhs.capacity();
38        if (m_num_elements == 0)
39            m_list = NULL;
40        else
41            m_list = new _ListClass[m_num_elements];
38      if (m_num_elements == 0)
39         m_list = NULL;
40      else
41         m_list = new _ListClass[m_num_elements];
4242      m_count = 0;
4343      for (int i=0; i<rhs.count(); i++)
4444      {
r31374r31375
5959
6060   ATTR_COLD ~plinearlist_t()
6161   {
62       if (m_list != NULL)
63           delete[] m_list;
64       m_list = NULL;
62      if (m_list != NULL)
63         delete[] m_list;
64      m_list = NULL;
6565   }
6666
6767   ATTR_HOT inline operator _ListClass *  () { return m_list; }
68    ATTR_HOT inline operator const _ListClass * () const { return m_list; }
68   ATTR_HOT inline operator const _ListClass * () const { return m_list; }
6969
70    /* using the [] operator will not allow gcc to vectorize code because
71     * basically a pointer is returned.
72     * array works around this.
73     */
70   /* using the [] operator will not allow gcc to vectorize code because
71    * basically a pointer is returned.
72    * array works around this.
73    */
7474
75    ATTR_HOT inline _ListClass *array() { return m_list; }
75   ATTR_HOT inline _ListClass *array() { return m_list; }
7676
77    ATTR_HOT inline _ListClass& operator[](const int index) { return m_list[index]; }
78    ATTR_HOT inline const _ListClass& operator[](const int index) const { return m_list[index]; }
77   ATTR_HOT inline _ListClass& operator[](const int index) { return m_list[index]; }
78   ATTR_HOT inline const _ListClass& operator[](const int index) const { return m_list[index]; }
7979
8080   ATTR_HOT inline void add(const _ListClass &elem)
8181   {
8282      if (m_count >= m_num_elements){
83          int new_size = m_num_elements * 2;
84          if (new_size < 32)
85              new_size = 32;
86            resize(new_size);
83         int new_size = m_num_elements * 2;
84         if (new_size < 32)
85            new_size = 32;
86         resize(new_size);
8787      }
8888
8989      m_list[m_count++] = elem;
r31374r31375
116116      }
117117   }
118118
119    ATTR_HOT inline void swap(const int pos1, const int pos2)
120    {
121        assert((pos1>=0) && (pos1<m_count));
122        assert((pos2>=0) && (pos2<m_count));
123        _ListClass tmp = m_list[pos1];
124        m_list[pos1] = m_list[pos2];
125        m_list[pos2] =tmp;
126    }
119   ATTR_HOT inline void swap(const int pos1, const int pos2)
120   {
121      assert((pos1>=0) && (pos1<m_count));
122      assert((pos2>=0) && (pos2<m_count));
123      _ListClass tmp = m_list[pos1];
124      m_list[pos1] = m_list[pos2];
125      m_list[pos2] =tmp;
126   }
127127
128128   ATTR_HOT inline bool contains(const _ListClass &elem) const
129129   {
r31374r31375
163163   }
164164
165165private:
166    ATTR_HOT inline void resize(const int new_size)
167    {
168        int cnt = count();
169        if (new_size > 0)
170        {
171            _ListClass *m_new = new _ListClass[new_size];
172            _ListClass *pd = m_new;
166   ATTR_HOT inline void resize(const int new_size)
167   {
168      int cnt = count();
169      if (new_size > 0)
170      {
171         _ListClass *m_new = new _ListClass[new_size];
172         _ListClass *pd = m_new;
173173
174            if (cnt > new_size)
175                cnt = new_size;
176            for (_ListClass *ps = m_list; ps < m_list + cnt; ps++, pd++)
177                *pd = *ps;
178            if (m_list != NULL)
179                delete[] m_list;
180            m_list = m_new;
181            m_count = cnt;
182        }
183        else
184        {
185            if (m_list != NULL)
186                delete[] m_list;
187            m_list = NULL;
188            m_count = 0;
189        }
190        m_num_elements = new_size;
191    }
174         if (cnt > new_size)
175            cnt = new_size;
176         for (_ListClass *ps = m_list; ps < m_list + cnt; ps++, pd++)
177            *pd = *ps;
178         if (m_list != NULL)
179            delete[] m_list;
180         m_list = m_new;
181         m_count = cnt;
182      }
183      else
184      {
185         if (m_list != NULL)
186            delete[] m_list;
187         m_list = NULL;
188         m_count = 0;
189      }
190      m_num_elements = new_size;
191   }
192192
193    int m_count;
193   int m_count;
194194   _ListClass * m_list /* ATTR_ALIGN */;
195195   int m_num_elements;
196196};
r31374r31375
203203class pnamedlist_t : public plinearlist_t<_C>
204204{
205205public:
206    _C find(const pstring name) const
207    {
208        for (int i=0; i < this->count(); i++)
209            if (get_name((*this)[i]) == name)
210                return (*this)[i];
211        return _C(NULL);
212    }
206   _C find(const pstring name) const
207   {
208      for (int i=0; i < this->count(); i++)
209         if (get_name((*this)[i]) == name)
210            return (*this)[i];
211      return _C(NULL);
212   }
213213
214    void remove_by_name(const pstring name)
215    {
216        plinearlist_t<_C>::remove(find(name));
217    }
214   void remove_by_name(const pstring name)
215   {
216      plinearlist_t<_C>::remove(find(name));
217   }
218218
219    bool add(_C dev, bool allow_duplicate)
220    {
221        if (allow_duplicate)
222            plinearlist_t<_C>::add(dev);
223        else
224        {
225            if (!(this->find(get_name(dev)) == _C(NULL)))
226                return false;
227            plinearlist_t<_C>::add(dev);
228        }
229        return true;
230    }
219   bool add(_C dev, bool allow_duplicate)
220   {
221      if (allow_duplicate)
222         plinearlist_t<_C>::add(dev);
223      else
224      {
225         if (!(this->find(get_name(dev)) == _C(NULL)))
226            return false;
227         plinearlist_t<_C>::add(dev);
228      }
229      return true;
230   }
231231
232232private:
233    template <typename T> static const pstring get_name(T &elem) { return elem.name(); }
234    template <typename T> static const pstring get_name(T *elem) { return elem->name(); }
233   template <typename T> static const pstring get_name(T &elem) { return elem.name(); }
234   template <typename T> static const pstring get_name(T *elem) { return elem->name(); }
235235
236236};
237237
trunk/src/emu/digfx.h
r31374r31375
107107// use these to declare a gfx_decode_entry array as a member of a device class
108108#define DECLARE_GFXDECODE_MEMBER( name ) static const gfx_decode_entry name[]
109109#define GFXDECODE_MEMBER( name ) const gfx_decode_entry name[] = {
110
111
112110// common gfx_decode_entry macros
113111#define GFXDECODE_ENTRYX(region,offset,layout,start,colors,flags) { region, offset, &layout, start, colors, flags },
114112#define GFXDECODE_ENTRY(region,offset,layout,start,colors) { region, offset, &layout, start, colors, 0 },
trunk/src/emu/video/mc6845.h
r31374r31375
6767#define MC6845_BEGIN_UPDATE(name)  void name(bitmap_rgb32 &bitmap, const rectangle &cliprect)
6868
6969typedef device_delegate<void (bitmap_rgb32 &bitmap, const rectangle &cliprect, UINT16 ma, UINT8 ra,
70                       UINT16 y, UINT8 x_count, INT8 cursor_x, int de, int hbp, int vbp)> mc6845_update_row_delegate;
70                        UINT16 y, UINT8 x_count, INT8 cursor_x, int de, int hbp, int vbp)> mc6845_update_row_delegate;
7171#define MC6845_UPDATE_ROW(name)     void name(bitmap_rgb32 &bitmap, const rectangle &cliprect, UINT16 ma, UINT8 ra, \
7272                                    UINT16 y, UINT8 x_count, INT8 cursor_x, int de, int hbp, int vbp)
7373
r31374r31375
9797   mc6845_device(const machine_config &mconfig, device_type type, const char *name, const char *tag, device_t *owner, UINT32 clock, const char *shortname, const char *source);
9898
9999   static void set_show_border_area(device_t &device, bool show) { downcast<mc6845_device &>(device).m_show_border_area = show; }
100   static void set_visarea_adjust(device_t &device, int min_x, int max_x, int min_y, int max_y)
100   static void set_visarea_adjust(device_t &device, int min_x, int max_x, int min_y, int max_y)
101101   {
102102      mc6845_device &dev = downcast<mc6845_device &>(device);
103103      dev.m_visarea_adjust_min_x = min_x;
r31374r31375
116116   template<class _Object> static devcb_base &set_out_cur_callback(device_t &device, _Object object) { return downcast<mc6845_device &>(device).m_out_cur_cb.set_callback(object); }
117117   template<class _Object> static devcb_base &set_out_hsync_callback(device_t &device, _Object object) { return downcast<mc6845_device &>(device).m_out_hsync_cb.set_callback(object); }
118118   template<class _Object> static devcb_base &set_out_vsync_callback(device_t &device, _Object object) { return downcast<mc6845_device &>(device).m_out_vsync_cb.set_callback(object); }
119   
119
120120   /* select one of the registers for reading or writing */
121121   DECLARE_WRITE8_MEMBER( address_w );
122122
r31374r31375
238238   emu_timer *m_light_pen_latch_timer;
239239   emu_timer *m_upd_adr_timer;
240240   emu_timer *m_upd_trans_timer;
241   
241
242242   /* computed values - do NOT state save these! */
243243   /* These computed are used to define the screen parameters for a driver */
244244   UINT16  m_horiz_pix_total;
r31374r31375
271271   /************************
272272    interface CRTC - driver
273273    ************************/
274   
274
275275   bool m_show_border_area;        /* visible screen area (false) active display (true) active display + blanking */
276   
276
277277   /* visible screen area adjustment */
278278   int m_visarea_adjust_min_x;
279279   int m_visarea_adjust_max_x;
280280   int m_visarea_adjust_min_y;
281281   int m_visarea_adjust_max_y;
282   
282
283283   int m_hpixels_per_column;       /* number of pixels per video memory address */
284284
285285   /* if specified, this gets called before any pixel update,
286286    optionally return a pointer that will be passed to the
287287    update and tear down callbacks */
288288   mc6845_begin_update_delegate m_begin_update_cb;
289   
289
290290   /* this gets called for every row, the driver must output
291291    x_count * hpixels_per_column pixels.
292292    cursor_x indicates the character position where the cursor is, or -1
293293    if there is no cursor on this row */
294294   mc6845_update_row_delegate  m_update_row_cb;
295   
295
296296   /* if specified, this gets called after all row updating is complete */
297297   mc6845_end_update_delegate  m_end_update_cb;
298   
298
299299   /* Called whenever the update address changes
300300    * For vblank/hblank timing strobe indicates the physical update.
301301    * vblank/hblank timing not supported yet! */
302302   mc6845_on_update_addr_changed_delegate m_on_update_addr_changed_cb;
303   
303
304304   /* if specified, this gets called for every change of the disply enable pin (pin 18) */
305305   devcb_write_line            m_out_de_cb;
306   
306
307307   /* if specified, this gets called for every change of the cursor pin (pin 19) */
308308   devcb_write_line            m_out_cur_cb;
309   
309
310310   /* if specified, this gets called for every change of the HSYNC pin (pin 39) */
311311   devcb_write_line            m_out_hsync_cb;
312   
312
313313   /* if specified, this gets called for every change of the VSYNC pin (pin 40) */
314314   devcb_write_line            m_out_vsync_cb;
315315};
trunk/src/emu/video/voodoo.h
r31374r31375
3939***************************************************************************/
4040
4141#define MCFG_VOODOO_FBMEM(_value) \
42   voodoo_device::static_set_fbmem(*device, _value);
42   voodoo_device::static_set_fbmem(*device, _value);
4343
4444#define MCFG_VOODOO_TMUMEM(_value1, _value2) \
45   voodoo_device::static_set_tmumem(*device, _value1, _value2);
45   voodoo_device::static_set_tmumem(*device, _value1, _value2);
4646
4747#define MCFG_VOODOO_SCREEN_TAG(_tag) \
48   voodoo_device::static_set_screen_tag(*device, _tag);
48   voodoo_device::static_set_screen_tag(*device, _tag);
4949
5050#define MCFG_VOODOO_CPU_TAG(_tag) \
51   voodoo_device::static_set_cpu_tag(*device, _tag);
51   voodoo_device::static_set_cpu_tag(*device, _tag);
5252
5353#define MCFG_VOODOO_VBLANK_CB(_devcb) \
5454   devcb = &voodoo_device::static_set_vblank_callback(*device, DEVCB_##_devcb);
55
55
5656#define MCFG_VOODOO_STALL_CB(_devcb) \
5757   devcb = &voodoo_device::static_set_stall_callback(*device, DEVCB_##_devcb);
58 
5958
59
6060/***************************************************************************
6161    FUNCTION PROTOTYPES
6262***************************************************************************/
r31374r31375
8181   static void static_set_cpu_tag(device_t &device, const char *tag) { downcast<voodoo_device &>(device).m_cputag = tag; }
8282   template<class _Object> static devcb_base &static_set_vblank_callback(device_t &device, _Object object) { return downcast<voodoo_device &>(device).m_vblank.set_callback(object); }
8383   template<class _Object> static devcb_base &static_set_stall_callback(device_t &device, _Object object)  { return downcast<voodoo_device &>(device).m_stall.set_callback(object); }
84   
84
8585   DECLARE_READ32_MEMBER( voodoo_r );
8686   DECLARE_WRITE32_MEMBER( voodoo_w );
8787
8888   // access to legacy token
8989   struct voodoo_state *token() const { assert(m_token != NULL); return m_token; }
9090   void common_start_voodoo(UINT8 type);
91   
91
9292   UINT8               m_fbmem;
9393   UINT8               m_tmumem0;
9494   UINT8               m_tmumem1;
r31374r31375
9696   const char *        m_cputag;
9797   devcb_write_line   m_vblank;
9898   devcb_write_line   m_stall;
99   
99
100100protected:
101101   // device-level overrides
102102   virtual void device_config_complete();
trunk/src/emu/video/vic4567.h
r31374r31375
135135   template<class _Object> static devcb_base &set_lightpen_x_callback(device_t &device, _Object object) { return downcast<vic3_device &>(device).m_lightpen_x_cb.set_callback(object); }
136136   template<class _Object> static devcb_base &set_lightpen_y_callback(device_t &device, _Object object) { return downcast<vic3_device &>(device).m_lightpen_y_cb.set_callback(object); }
137137   template<class _Object> static devcb_base &set_c64_mem_r_callback(device_t &device, _Object object) { return downcast<vic3_device &>(device).m_c64_mem_r_cb.set_callback(object); }
138   
138
139139   DECLARE_WRITE8_MEMBER(port_w);
140140   DECLARE_WRITE8_MEMBER(palette_w);
141141   DECLARE_READ8_MEMBER(port_r);
r31374r31375
221221   devcb_read8 m_lightpen_button_cb;
222222   devcb_read8 m_lightpen_x_cb;
223223   devcb_read8 m_lightpen_y_cb;
224   
224
225225   /* C64 memory access */
226226   devcb_read8      m_c64_mem_r_cb;
227227
r31374r31375
239239
240240#define MCFG_VIC3_CPU(_tag) \
241241   vic3_device::static_set_cpu_tag(*device, "^"_tag);
242   
242
243243#define MCFG_VIC3_TYPE(_type) \
244244   vic3_device::set_vic3_type(*device, _type);
245   
245
246246#define MCFG_VIC3_DMA_READ_CB(_devcb) \
247247   devcb = &vic3_device::set_dma_read_callback(*device, DEVCB_##_devcb);
248248
trunk/src/emu/video/t6a04.h
r31374r31375
2929      dev.m_width = w;
3030      dev.m_height = h;
3131   }
32   
32
3333   // device interface
3434   DECLARE_WRITE8_MEMBER(control_write);
3535   DECLARE_READ8_MEMBER(control_read);
trunk/src/emu/video/tms3556.h
r31374r31375
108108
109109   // register interface
110110   int m_reg_access_phase;
111   
111
112112   int m_row_col_written;
113113   int m_bamp_written;
114114   int m_colrow;
115    dma_mode_tt m_vdp_acmpxy_mode;
116    UINT16 m_vdp_acmpxy;
117    UINT16 m_vdp_acmp;
118    int m_init_read;
115   dma_mode_tt m_vdp_acmpxy_mode;
116   UINT16 m_vdp_acmpxy;
117   UINT16 m_vdp_acmp;
118   int m_init_read;
119119
120120   int m_scanline;             // scanline counter
121121   int m_blink, m_blink_count; // blinking
trunk/src/emu/video/ramdac.h
r31374r31375
7373
7474   const address_space_config      m_space_config;
7575   required_device<palette_device> m_palette;
76   
76
7777   UINT8 m_split_read_reg; // read register index is separated, seen in rltennis
7878};
7979
trunk/src/emu/video/mc6847.h
r31374r31375
269269   // callbacks
270270   devcb_write_line   m_write_hsync;
271271   devcb_write_line   m_write_fsync;
272   
272
273273   /* if specified, this reads the external char rom off of the driver state */
274274   // moved here from mc6847_base_device so to be useable in GIME
275275   mc6847_get_char_rom_delegate m_charrom_cb;
276   
276
277277   // incidentals
278278   character_map m_character_map;
279279   artifacter m_artifacter;
r31374r31375
546546   virtual void field_sync_changed(bool line);
547547   virtual void record_body_scanline(UINT16 physical_scanline, UINT16 scanline);
548548   virtual void record_partial_body_scanline(UINT16 physical_scanline, UINT16 logical_scanline, INT32 start_clock, INT32 end_clock);
549   
549
550550   void set_custom_palette(const pixel_t *custom_palette)
551551   {
552552      if ( m_palette != m_bw_palette )
r31374r31375
568568   static const UINT32 s_palette[PALETTE_LENGTH];
569569
570570   // callbacks
571   
571
572572   /* if specified, this gets called whenever reading a byte (offs_t ~0 specifies DA* entering the tristate mode) */
573573   devcb_read8 m_input_cb;
574574
r31374r31375
616616
617617   // setup functions
618618   void setup_fixed_mode();
619   
619
620620   // runtime functions
621621   void record_body_scanline(UINT16 physical_scanline, UINT16 scanline, INT32 start_pos, INT32 end_pos);
622622   pixel_t border_value(UINT8 mode, const pixel_t *palette, bool is_mc6847t1);
r31374r31375
678678{
679679public:
680680   s68047_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
681   
681
682682   void hack_black_becomes_blue(bool flag);
683683
684684private:
r31374r31375
687687
688688class m5c6847p1_device : public mc6847_base_device
689689{
690public:   
690public:
691691   m5c6847p1_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
692692};
693693
trunk/src/emu/video/snes_ppu.h
r31374r31375
5454struct SNES_SCANLINE
5555{
5656   int enable, clip;
57   
57
5858   UINT16 buffer[SNES_SCR_WIDTH];
5959   UINT8  priority[SNES_SCR_WIDTH];
6060   UINT8  layer[SNES_SCR_WIDTH];
r31374r31375
7474   template<class _Object> static devcb_base &static_set_open_bus_callback(device_t &device, _Object object) { return downcast<snes_ppu_device &>(device).m_openbus_cb.set_callback(object); }
7575
7676   UINT8 m_regs[0x40];
77   
77
7878   SNES_SCANLINE m_scanlines[2];
79   
79
8080   struct
8181   {
8282      /* clipmasks */
r31374r31375
8585      UINT8 wlog_mask;
8686      /* color math enabled */
8787      UINT8 color_math;
88     
88
8989      UINT8 charmap;
9090      UINT8 tilemap;
9191      UINT8 tilemap_size;
92     
92
9393      UINT8 tile_size;
9494      UINT8 mosaic_enabled;   // actually used only for layers 0->3!
95     
95
9696      UINT8 main_window_enabled;
9797      UINT8 sub_window_enabled;
9898      UINT8 main_bg_enabled;
9999      UINT8 sub_bg_enabled;
100     
100
101101      UINT16 hoffs;
102102      UINT16 voffs;
103103   } m_layer[6]; // this is for the BG1 - BG2 - BG3 - BG4 - OBJ - color layers
104   
104
105105   struct
106106   {
107107      UINT8 address_low;
r31374r31375
119119      UINT8 flip;
120120      UINT16 write_latch;
121121   } m_oam;
122   
122
123123   struct
124124   {
125125      UINT16 latch_horz;
r31374r31375
129129      UINT8 last_visible_line;
130130      UINT8 interlace_count;
131131   } m_beam;
132   
132
133133   struct
134134   {
135135      UINT8 repeat;
r31374r31375
145145      UINT16 ver_offset;
146146      UINT8 extbg;
147147   } m_mode7;
148   
148
149149   struct OAM
150150   {
151151      UINT16 tile;
r31374r31375
153153      UINT8 size, vflip, hflip, priority_bits, pal;
154154      int height, width;
155155   };
156   
156
157157   struct OAM m_oam_spritelist[SNES_SCR_WIDTH / 2];
158   
158
159159   UINT8 m_oam_itemlist[32];
160   
160
161161   struct TILELIST {
162162      INT16 x;
163163      UINT16 priority, pal, tileaddr;
164164      int hflip;
165165   };
166   
166
167167   struct TILELIST m_oam_tilelist[34];
168   
168
169169#if SNES_LAYER_DEBUG
170170   struct DEBUGOPTS
171171   {
r31374r31375
180180   };
181181   struct DEBUGOPTS m_debug_options;
182182#endif
183   
183
184184   UINT8 m_mosaic_size;
185185   UINT8 m_clip_to_black;
186186   UINT8 m_prevent_color_math;
r31374r31375
188188   UINT8 m_bg3_priority_bit;
189189   UINT8 m_direct_color;
190190   UINT8 m_ppu_last_scroll;      /* as per Anomie's doc and Theme Park, all scroll regs shares (but mode 7 ones) the same
191                           'previous' scroll value */
191                                   'previous' scroll value */
192192   UINT8 m_mode7_last_scroll;    /* as per Anomie's doc mode 7 scroll regs use a different value, shared with mode 7 matrix! */
193   
193
194194   UINT8 m_ppu1_open_bus, m_ppu2_open_bus;
195195   UINT8 m_ppu1_version, m_ppu2_version;
196196   UINT8 m_window1_left, m_window1_right, m_window2_left, m_window2_right;
197   
197
198198   UINT16 m_mosaic_table[16][4096];
199199   UINT8 m_clipmasks[6][SNES_SCR_WIDTH];
200200   UINT8 m_update_windows;
r31374r31375
209209   UINT8 m_color_modes;
210210   UINT8 m_stat77;
211211   UINT8 m_stat78;
212   
212
213213   UINT16                m_htmult;     /* in 512 wide, we run HTOTAL double and halve it on latching */
214214   UINT16                m_cgram_address;  /* CGRAM address */
215215   UINT8                 m_read_ophct;
r31374r31375
221221   UINT16                m_vram_fgr_shift;
222222   UINT16                m_vram_read_buffer;
223223   UINT16                m_vmadd;
224   
224
225225   inline UINT16 get_bgcolor(UINT8 direct_colors, UINT16 palette, UINT8 color);
226226   inline void set_scanline_pixel(int screen, INT16 x, UINT16 color, UINT8 priority, UINT8 layer, int blend);
227227   inline void draw_bgtile_lores(UINT8 layer, INT16 ii, UINT8 colour, UINT16 pal, UINT8 direct_colors, UINT8 priority);
r31374r31375
249249   void update_offsets(void);
250250   inline void draw_blend(UINT16 offset, UINT16 *colour, UINT8 prevent_color_math, UINT8 black_pen_clip, int switch_screens);
251251   void refresh_scanline(running_machine &machine, bitmap_rgb32 &bitmap, UINT16 curline);
252   
252
253253   void latch_counters(running_machine &machine);
254254   void dynamic_res_change(running_machine &machine);
255255   inline UINT32 get_vram_address(running_machine &machine);
256256   UINT8 dbg_video(running_machine &machine, UINT16 curline);
257   
257
258258   UINT8 read(address_space &space, UINT32 offset, UINT8 wrio_bit7);
259259   void write(address_space &space, UINT32 offset, UINT8 data);
260   
260
261261   DECLARE_READ8_MEMBER( oam_read );
262262   DECLARE_WRITE8_MEMBER( oam_write );
263263   DECLARE_READ8_MEMBER( cgram_read );
r31374r31375
271271protected:
272272   // device-level overrides
273273   virtual void device_start();
274   virtual void device_reset() {};   
274   virtual void device_reset() {};
275275
276276private:
277277   devcb_read16  m_openbus_cb;
trunk/src/emu/video/crtc_ega.h
r31374r31375
5959public:
6060   crtc_ega_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
6161
62   template<class _Object> static devcb_base &set_res_out_de_callback(device_t &device, _Object object)
62   template<class _Object> static devcb_base &set_res_out_de_callback(device_t &device, _Object object)
6363                  { return downcast<crtc_ega_device &>(device).m_res_out_de_cb.set_callback(object); }
64   template<class _Object> static devcb_base &set_res_out_hsync_callback(device_t &device, _Object object)
64   template<class _Object> static devcb_base &set_res_out_hsync_callback(device_t &device, _Object object)
6565                  { return downcast<crtc_ega_device &>(device).m_res_out_hsync_cb.set_callback(object); }
66   template<class _Object> static devcb_base &set_res_out_vsync_callback(device_t &device, _Object object)
66   template<class _Object> static devcb_base &set_res_out_vsync_callback(device_t &device, _Object object)
6767                  { return downcast<crtc_ega_device &>(device).m_res_out_vsync_cb.set_callback(object); }
68   template<class _Object> static devcb_base &set_res_out_vblank_callback(device_t &device, _Object object)
68   template<class _Object> static devcb_base &set_res_out_vblank_callback(device_t &device, _Object object)
6969                  { return downcast<crtc_ega_device &>(device).m_res_out_vblank_cb.set_callback(object); }
7070
7171   static void set_begin_update_callback(device_t &device, crtc_ega_begin_update_delegate callback) { downcast<crtc_ega_device &>(device).m_begin_update_cb = callback; }
7272   static void set_row_update_callback(device_t &device, crtc_ega_row_update_delegate callback) { downcast<crtc_ega_device &>(device).m_row_update_cb = callback; }
7373   static void set_end_update_callback(device_t &device, crtc_ega_end_update_delegate callback) { downcast<crtc_ega_device &>(device).m_end_update_cb = callback; }
7474   static void set_hpixels_per_column(device_t &device, int hpixels_per_column) { downcast<crtc_ega_device &>(device).m_hpixels_per_column = hpixels_per_column; }
75   
75
7676   /* select one of the registers for reading or writing */
7777   DECLARE_WRITE8_MEMBER( address_w );
7878
r31374r31375
119119    optionally return a pointer that will be passed to the
120120    update and tear down callbacks */
121121   crtc_ega_begin_update_delegate      m_begin_update_cb;
122   
122
123123   /* this gets called for every row, the driver must output
124124    x_count * hpixels_per_column pixels.
125125    cursor_x indicates the character position where the cursor is, or -1
126126    if there is no cursor on this row */
127127   crtc_ega_row_update_delegate        m_row_update_cb;
128   
128
129129   /* if specified, this gets called after all row updating is complete */
130130   crtc_ega_end_update_delegate        m_end_update_cb;
131   
131
132132   /* ega/vga register file */
133133   UINT8   m_horiz_char_total; /* 0x00 */
134134   UINT8   m_horiz_disp;           /* 0x01 */
trunk/src/emu/video/vooddefs.h
r31374r31375
34003400   /* add clocal or alocal to alpha */                                         \
34013401   if (FBZCP_CCA_ADD_ACLOCAL(FBZCOLORPATH))                                    \
34023402      a += c_local.rgb.a;                                                     \
3403                                                                                \
3403                                                            \
34043404   /* clamp */                                                                 \
34053405   CLAMP(a, 0x00, 0xff);                                                       \
3406                                                                               \
3406                                                            \
34073407   /* invert */                                                                \
34083408   if (FBZCP_CCA_INVERT_OUTPUT(FBZCOLORPATH))                                  \
34093409      a ^= 0xff;                                                              \
trunk/src/emu/video/huc6202.h
r31374r31375
4646#define MCFG_HUC6202_WRITE_1_CB(_devcb) \
4747   devcb = &huc6202_device::set_write_1_callback(*device, DEVCB_##_devcb);
4848
49   
49
5050class huc6202_device : public device_t
5151{
5252public:
5353   // construction/destruction
5454   huc6202_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
55   
55
5656   template<class _Object> static devcb_base &set_next_pixel_0_callback(device_t &device, _Object object) { return downcast<huc6202_device &>(device).m_next_pixel_0_cb.set_callback(object); }
5757   template<class _Object> static devcb_base &set_time_til_next_event_0_callback(device_t &device, _Object object) { return downcast<huc6202_device &>(device).m_time_til_next_event_0_cb.set_callback(object); }
5858   template<class _Object> static devcb_base &set_vsync_changed_0_callback(device_t &device, _Object object) { return downcast<huc6202_device &>(device).m_vsync_changed_0_cb.set_callback(object); }
r31374r31375
6565   template<class _Object> static devcb_base &set_hsync_changed_1_callback(device_t &device, _Object object) { return downcast<huc6202_device &>(device).m_hsync_changed_1_cb.set_callback(object); }
6666   template<class _Object> static devcb_base &set_read_1_callback(device_t &device, _Object object) { return downcast<huc6202_device &>(device).m_read_1_cb.set_callback(object); }
6767   template<class _Object> static devcb_base &set_write_1_callback(device_t &device, _Object object) { return downcast<huc6202_device &>(device).m_write_1_cb.set_callback(object); }
68   
68
6969   DECLARE_READ8_MEMBER( read );
7070   DECLARE_WRITE8_MEMBER( write );
7171   DECLARE_READ8_MEMBER( io_read );
trunk/src/emu/video/tms9928a.h
r31374r31375
3939#define TMS9928A_VERT_DISPLAY_START_PAL     (13 + 51)
4040#define TMS9928A_VERT_DISPLAY_START_NTSC    (13 + 27)
4141
42//   MCFG_DEVICE_ADD(_tag, _variant, XTAL_10_738635MHz / 2 )
42//  MCFG_DEVICE_ADD(_tag, _variant, XTAL_10_738635MHz / 2 )
4343
4444#define MCFG_TMS9928A_VRAM_SIZE(_size) \
4545   tms9928a_device::set_vram_size(*device, _size);
4646
4747#define MCFG_TMS9928A_OUT_INT_LINE_CB(_devcb) \
48   devcb = &tms9928a_device::set_out_int_line_callback(*device, DEVCB_##_devcb);     
48   devcb = &tms9928a_device::set_out_int_line_callback(*device, DEVCB_##_devcb);
4949
5050#define MCFG_TMS9928A_SET_SCREEN MCFG_VIDEO_SET_SCREEN
5151
r31374r31375
8585
8686   static void set_vram_size(device_t &device, int vram_size) { downcast<tms9928a_device &>(device).m_vram_size = vram_size; }
8787   template<class _Object> static devcb_base &set_out_int_line_callback(device_t &device, _Object object) { return downcast<tms9928a_device &>(device).m_out_int_line_cb.set_callback(object); }
88   
88
8989   DECLARE_READ8_MEMBER( vram_read );
9090   DECLARE_WRITE8_MEMBER( vram_write );
9191   DECLARE_READ8_MEMBER( register_read );
r31374r31375
115115   void set_palette();
116116
117117   static const device_timer_id TIMER_LINE = 0;
118   
118
119119   int                 m_vram_size;    /* 4K, 8K, or 16K. This should be replaced by fetching data from an address space? */
120120   devcb_write_line   m_out_int_line_cb; /* Callback is called whenever the state of the INT output changes */
121121
trunk/src/emu/sound.h
r31374r31375
2323//**************************************************************************
2424
2525const int STREAM_SYNC       = -1;       // special rate value indicating a one-sample-at-a-time stream
26                                        // with actual rate defined by its input
26                              // with actual rate defined by its input
2727
2828//**************************************************************************
2929//  MACROS
trunk/src/emu/bus/gameboy/mbc.h
r31374r31375
221221public:
222222   // construction/destruction
223223   gb_rom_licheng_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
224   
224
225225   virtual DECLARE_WRITE8_MEMBER(write_bank);
226226};
227227
trunk/src/emu/bus/tvc/tvc.h
r31374r31375
8989   // construction/destruction
9090   tvcexp_slot_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
9191   virtual ~tvcexp_slot_device();
92   
92
9393   template<class _Object> static devcb_base &set_out_irq_callback(device_t &device, _Object object) { return downcast<tvcexp_slot_device &>(device).m_out_irq_cb.set_callback(object); }
9494   template<class _Object> static devcb_base &set_out_nmi_callback(device_t &device, _Object object) { return downcast<tvcexp_slot_device &>(device).m_out_nmi_cb.set_callback(object); }
9595
r31374r31375
124124
125125#define MCFG_TVCEXP_SLOT_OUT_NMI_CB(_devcb) \
126126   devcb = &tvcexp_slot_device::set_out_nmi_callback(*device, DEVCB_##_devcb);
127   
127
128128#endif /* __TVCEXP_H__ */
trunk/src/emu/bus/x68k/x68kexp.h
r31374r31375
8585
8686#define MCFG_X68K_EXPANSION_SLOT_OUT_RESET_CB(_devcb) \
8787   devcb = &x68k_expansion_slot_device::set_out_reset_callback(*device, DEVCB_##_devcb);
88   
8988
89
9090//**************************************************************************
9191//  TYPE DEFINITIONS
9292//**************************************************************************
r31374r31375
115115   // construction/destruction
116116   x68k_expansion_slot_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
117117   virtual ~x68k_expansion_slot_device();
118   
118
119119   template<class _Object> static devcb_base &set_out_irq2_callback(device_t &device, _Object object) { return downcast<x68k_expansion_slot_device &>(device).m_out_irq2_cb.set_callback(object); }
120120   template<class _Object> static devcb_base &set_out_irq4_callback(device_t &device, _Object object) { return downcast<x68k_expansion_slot_device &>(device).m_out_irq4_cb.set_callback(object); }
121121   template<class _Object> static devcb_base &set_out_nmi_callback(device_t &device, _Object object) { return downcast<x68k_expansion_slot_device &>(device).m_out_nmi_cb.set_callback(object); }
trunk/src/emu/bus/coco/cococart.h
r31374r31375
4646   cococart_line_value         value;
4747   int                         line;
4848   int                         q_count;
49   devcb_write_line          *callback;
49   devcb_write_line        *callback;
5050};
5151
5252// ======================> cococart_base_update_delegate
r31374r31375
5656
5757#define MCFG_COCO_CARTRIDGE_CART_CB(_devcb) \
5858   devcb = &cococart_slot_device::static_set_cart_callback(*device, DEVCB_##_devcb);
59
59
6060#define MCFG_COCO_CARTRIDGE_NMI_CB(_devcb) \
6161   devcb = &cococart_slot_device::static_set_nmi_callback(*device, DEVCB_##_devcb);
62
62
6363#define MCFG_COCO_CARTRIDGE_HALT_CB(_devcb) \
6464   devcb = &cococart_slot_device::static_set_halt_callback(*device, DEVCB_##_devcb);
65 
6665
66
6767// ======================> cococart_slot_device
6868class device_cococart_interface;
6969
r31374r31375
7878   template<class _Object> static devcb_base &static_set_cart_callback(device_t &device, _Object object)  { return downcast<cococart_slot_device &>(device).m_cart_callback.set_callback(object); }
7979   template<class _Object> static devcb_base &static_set_nmi_callback(device_t &device, _Object object)  { return downcast<cococart_slot_device &>(device).m_nmi_callback.set_callback(object); }
8080   template<class _Object> static devcb_base &static_set_halt_callback(device_t &device, _Object object)  { return downcast<cococart_slot_device &>(device).m_halt_callback.set_callback(object); }
81   
81
8282   // device-level overrides
8383   virtual void device_start();
8484   virtual void device_config_complete();
r31374r31375
128128   coco_cartridge_line         m_cart_line;
129129   coco_cartridge_line         m_nmi_line;
130130   coco_cartridge_line         m_halt_line;
131public:   
132   devcb_write_line          m_cart_callback;
133   devcb_write_line           m_nmi_callback;
134   devcb_write_line          m_halt_callback;
131public:
132   devcb_write_line        m_cart_callback;
133   devcb_write_line            m_nmi_callback;
134   devcb_write_line            m_halt_callback;
135135private:
136136   // cartridge
137137   device_cococart_interface   *m_cart;
trunk/src/emu/bus/nubus/nubus.h
r31374r31375
3838
3939#define MCFG_NUBUS_OUT_IRQE_CB(_devcb) \
4040   devcb = &nubus_device::set_out_irqe_callback(*device, DEVCB_##_devcb);
41   
41
4242#define MCFG_NUBUS_SLOT_ADD(_nbtag, _tag, _slot_intf, _def_slot) \
4343   MCFG_DEVICE_ADD(_tag, NUBUS_SLOT, 0) \
4444   MCFG_DEVICE_SLOT_INTERFACE(_slot_intf, _def_slot, false) \
r31374r31375
8888   nubus_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
8989   nubus_device(const machine_config &mconfig, device_type type, const char *name, const char *tag, device_t *owner, UINT32 clock, const char *shortname, const char *source);
9090   ~nubus_device() { m_device_list.detach_all(); }
91   
91
9292   // inline configuration
9393   static void static_set_cputag(device_t &device, const char *tag);
9494   template<class _Object> static devcb_base &set_out_irq9_callback(device_t &device, _Object object) { return downcast<nubus_device &>(device).m_out_irq9_cb.set_callback(object); }
trunk/src/emu/bus/bml3/bml3bus.h
r31374r31375
2121
2222#define MCFG_BML3BUS_CPU(_cputag) \
2323   bml3bus_device::static_set_cputag(*device, _cputag);
24   
24
2525#define MCFG_BML3BUS_OUT_NMI_CB(_devcb) \
2626   devcb = &bml3bus_device::set_out_nmi_callback(*device, DEVCB_##_devcb);
2727
r31374r31375
7979   // construction/destruction
8080   bml3bus_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
8181   bml3bus_device(const machine_config &mconfig, device_type type, const char *name, const char *tag, device_t *owner, UINT32 clock, const char *shortname, const char *source);
82   
82
8383   // inline configuration
8484   static void static_set_cputag(device_t &device, const char *tag);
8585   template<class _Object> static devcb_base &set_out_nmi_callback(device_t &device, _Object object) { return downcast<bml3bus_device &>(device).m_out_nmi_cb.set_callback(object); }
trunk/src/emu/bus/iq151/iq151.h
r31374r31375
7979   // construction/destruction
8080   iq151cart_slot_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
8181   virtual ~iq151cart_slot_device();
82   
82
8383   template<class _Object> static devcb_base &set_out_irq0_callback(device_t &device, _Object object) { return downcast<iq151cart_slot_device &>(device).m_out_irq0_cb.set_callback(object); }
8484   template<class _Object> static devcb_base &set_out_irq1_callback(device_t &device, _Object object) { return downcast<iq151cart_slot_device &>(device).m_out_irq1_cb.set_callback(object); }
8585   template<class _Object> static devcb_base &set_out_irq2_callback(device_t &device, _Object object) { return downcast<iq151cart_slot_device &>(device).m_out_irq2_cb.set_callback(object); }
trunk/src/emu/bus/scsi/scsihle.h
r31374r31375
8888   MCFG_DEVICE_MODIFY(_tag ) \
8989   MCFG_SLOT_OPTION_ADD( _option, _type ) \
9090   MCFG_SLOT_OPTION_DEVICE_INPUT_DEFAULTS( _option, _id ) \
91   MCFG_SLOT_DEFAULT_OPTION( _option ) \
92
91   MCFG_SLOT_DEFAULT_OPTION( _option )
9392#endif
trunk/src/emu/bus/centronics/epson_ex800.h
r31374r31375
2828// ======================> epson_ex800_t
2929
3030class epson_ex800_t :  public device_t,
31                  public device_centronics_peripheral_interface
31                  public device_centronics_peripheral_interface
3232{
3333public:
3434   // construction/destruction
trunk/src/emu/bus/centronics/epson_lx800.h
r31374r31375
2929// ======================> epson_lx800_t
3030
3131class epson_lx800_t :  public device_t,
32                  public device_centronics_peripheral_interface
32                  public device_centronics_peripheral_interface
3333{
3434public:
3535   // construction/destruction
trunk/src/emu/bus/vtech/memexp/memory.h
r31374r31375
11/***************************************************************************
22
3   VTech Laser/VZ Memory Expansions
3    VTech Laser/VZ Memory Expansions
44
55    license: MAME, GPL-2.0+
66    copyright-holders: Dirk Best
trunk/src/emu/bus/vtech/memexp/floppy.h
r31374r31375
11/***************************************************************************
22
3   VTech Laser/VZ Floppy Controller Cartridge
3    VTech Laser/VZ Floppy Controller Cartridge
44
55    license: MAME, GPL-2.0+
66    copyright-holders: Dirk Best
77
8   Laser DD 20
8    Laser DD 20
99    Dick Smith Electronics X-7304
1010
1111***************************************************************************/
trunk/src/emu/bus/vtech/memexp/memexp.h
r31374r31375
11/***************************************************************************
22
3   VTech Laser/VZ Memory Expansion Slot
3    VTech Laser/VZ Memory Expansion Slot
44
55    license: MAME, GPL-2.0+
66    copyright-holders: Dirk Best
77
8   44-pin slot
8    44-pin slot
99
10   22  GND             23  NC
11   21  +5VDC           24  A11
12   20  /IORQ           25  A12
13   19  /RD             26  A13
14   18  /NMI            27  A14
15   17  /WAIT           28  A15
16   16  /MI             29  CLK
17   15  /RFSH           30  D4
18   14  D7              31  D3
19   13  D2              32  D5
20   12  A1              33  D6
21   11  A2              34  NC
22   10  A3              35  A0
23    9  A4              36  D0
24    8  A5              37  D1
25    7  A6              38  /INT
26    6  A7              39  /HALT
27    5  A8              40  /MERQ
28    4  A9              41  /WR
29    3  A10             42  /NC
30    2  /RESET          43  +9VDC
31    1  GND             44  NC
10    22  GND             23  NC
11    21  +5VDC           24  A11
12    20  /IORQ           25  A12
13    19  /RD             26  A13
14    18  /NMI            27  A14
15    17  /WAIT           28  A15
16    16  /MI             29  CLK
17    15  /RFSH           30  D4
18    14  D7              31  D3
19    13  D2              32  D5
20    12  A1              33  D6
21    11  A2              34  NC
22    10  A3              35  A0
23     9  A4              36  D0
24     8  A5              37  D1
25     7  A6              38  /INT
26     6  A7              39  /HALT
27     5  A8              40  /MERQ
28     4  A9              41  /WR
29     3  A10             42  /NC
30     2  /RESET          43  +9VDC
31     1  GND             44  NC
3232
3333***************************************************************************/
3434
trunk/src/emu/bus/vtech/memexp/rs232.h
r31374r31375
11/***************************************************************************
22
3   Dick Smith VZ-200/300 RS-232 Cartridge
3    Dick Smith VZ-200/300 RS-232 Cartridge
44
55    license: MAME, GPL-2.0+
66    copyright-holders: Dirk Best
trunk/src/emu/bus/vtech/memexp/carts.h
r31374r31375
11/***************************************************************************
22
3   VTech Laser/VZ Memory Expansion Slot Devices
3    VTech Laser/VZ Memory Expansion Slot Devices
44
55***************************************************************************/
66
trunk/src/emu/bus/vtech/memexp/wordpro.h
r31374r31375
11/***************************************************************************
22
3   Dick Smith VZ-300 WordPro Cartridge
3    Dick Smith VZ-300 WordPro Cartridge
44
55    license: MAME, GPL-2.0+
66    copyright-holders: Dirk Best
trunk/src/emu/bus/vtech/ioexp/joystick.h
r31374r31375
11/***************************************************************************
22
3   VTech Laser Joystick Interface
3    VTech Laser Joystick Interface
44
55    license: MAME, GPL-2.0+
66    copyright-holders: Dirk Best
trunk/src/emu/bus/vtech/ioexp/printer.h
r31374r31375
11/***************************************************************************
22
3   VTech Laser/VZ Printer Interface
3    VTech Laser/VZ Printer Interface
44
55    license: MAME, GPL-2.0+
66    copyright-holders: Dirk Best
trunk/src/emu/bus/vtech/ioexp/ioexp.h
r31374r31375
11/***************************************************************************
22
3   VTech Laser/VZ I/O Expansion Slot
3    VTech Laser/VZ I/O Expansion Slot
44
55    license: MAME, GPL-2.0+
66    copyright-holders: Dirk Best
77
8   30-pin slot
8    30-pin slot
99
10   15  GND             16  NC
11   14  /WR             17  NC
12   13  A3              18  NC
13   12  A6              19  +5VDC
14   11  A2              20  NC
15   10  A5              21  D4
16    9  D0              22  D5
17    8  D2              23  D7
18    7  D6              24  D1
19    6  D3              25  /RD
20    5  /IORQ           26  A1
21    4  +5VDC           27  A4
22    3  NC              28  A0
23    2  NC              29  A7
24    1  NC              30  NC
10    15  GND             16  NC
11    14  /WR             17  NC
12    13  A3              18  NC
13    12  A6              19  +5VDC
14    11  A2              20  NC
15    10  A5              21  D4
16     9  D0              22  D5
17     8  D2              23  D7
18     7  D6              24  D1
19     6  D3              25  /RD
20     5  /IORQ           26  A1
21     4  +5VDC           27  A4
22     3  NC              28  A0
23     2  NC              29  A7
24     1  NC              30  NC
2525
2626***************************************************************************/
2727
trunk/src/emu/bus/vtech/ioexp/carts.h
r31374r31375
11/***************************************************************************
22
3   VTech Laser/VZ I/O Expansion Slot Devices
3    VTech Laser/VZ I/O Expansion Slot Devices
44
55***************************************************************************/
66
trunk/src/emu/bus/a2bus/a2mcms.h
r31374r31375
106106   virtual bool take_c800() { return false; }
107107
108108private:
109   a2bus_mcms1_device *m_card1;   // card 1 for passthrough
109   a2bus_mcms1_device *m_card1;    // card 1 for passthrough
110110   mcms_device *m_engine;
111111};
112112
trunk/src/emu/bus/a2bus/a2eauxslot.h
r31374r31375
2020
2121#define MCFG_A2EAUXSLOT_CPU(_cputag) \
2222   a2eauxslot_device::static_set_cputag(*device, _cputag);
23   
23
2424#define MCFG_A2EAUXSLOT_OUT_IRQ_CB(_devcb) \
2525   devcb = &a2eauxslot_device::set_out_irq_callback(*device, DEVCB_##_devcb);
2626
2727#define MCFG_A2EAUXSLOT_OUT_NMI_CB(_devcb) \
2828   devcb = &a2eauxslot_device::set_out_nmi_callback(*device, DEVCB_##_devcb);
29   
29
3030#define MCFG_A2EAUXSLOT_SLOT_ADD(_nbtag, _tag, _slot_intf, _def_slot) \
3131   MCFG_DEVICE_ADD(_tag, A2EAUXSLOT_SLOT, 0) \
3232   MCFG_DEVICE_SLOT_INTERFACE(_slot_intf, _def_slot, false) \
r31374r31375
7171   // construction/destruction
7272   a2eauxslot_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
7373   a2eauxslot_device(const machine_config &mconfig, device_type type, const char *name, const char *tag, device_t *owner, UINT32 clock, const char *shortname, const char *source);
74   
74
7575   // inline configuration
7676   static void static_set_cputag(device_t &device, const char *tag);
7777   template<class _Object> static devcb_base &set_out_irq_callback(device_t &device, _Object object) { return downcast<a2eauxslot_device &>(device).m_out_irq_cb.set_callback(object); }
7878   template<class _Object> static devcb_base &set_out_nmi_callback(device_t &device, _Object object) { return downcast<a2eauxslot_device &>(device).m_out_nmi_cb.set_callback(object); }
79   
79
8080   void add_a2eauxslot_card(device_a2eauxslot_card_interface *card);
8181   device_a2eauxslot_card_interface *get_a2eauxslot_card();
8282
trunk/src/emu/bus/a2bus/a2bus.h
r31374r31375
3232
3333#define MCFG_A2BUS_OUT_INH_CB(_devcb) \
3434   devcb = &a2bus_device::set_out_inh_callback(*device, DEVCB_##_devcb);
35   
35
3636#define MCFG_A2BUS_SLOT_ADD(_nbtag, _tag, _slot_intf, _def_slot) \
3737   MCFG_DEVICE_ADD(_tag, A2BUS_SLOT, 0) \
3838   MCFG_DEVICE_SLOT_INTERFACE(_slot_intf, _def_slot, false) \
r31374r31375
8383   // construction/destruction
8484   a2bus_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
8585   a2bus_device(const machine_config &mconfig, device_type type, const char *name, const char *tag, device_t *owner, UINT32 clock, const char *shortname, const char *source);
86   
86
8787   // inline configuration
8888   static void static_set_cputag(device_t &device, const char *tag);
8989   template<class _Object> static devcb_base &set_out_irq_callback(device_t &device, _Object object) { return downcast<a2bus_device &>(device).m_out_irq_cb.set_callback(object); }
r31374r31375
104104   // device-level overrides
105105   virtual void device_start();
106106   virtual void device_reset();
107   
107
108108   // internal state
109109   cpu_device   *m_maincpu;
110110
trunk/src/emu/bus/ql/pcml_qdisk.h
r31374r31375
2525// ======================> pcml_q_disk_interface_t
2626
2727class pcml_q_disk_interface_t : public device_t,
28                           public device_ql_expansion_card_interface
28                        public device_ql_expansion_card_interface
2929{
3030public:
3131   // construction/destruction
trunk/src/emu/bus/ql/exp.h
r31374r31375
6464
6565
6666#define MCFG_QL_EXPANSION_SLOT_IPL0L_CALLBACK(_write) \
67    devcb = &ql_expansion_slot_t::set_ipl0l_wr_callback(*device, DEVCB_##_write);
67   devcb = &ql_expansion_slot_t::set_ipl0l_wr_callback(*device, DEVCB_##_write);
6868
6969#define MCFG_QL_EXPANSION_SLOT_IPL1L_CALLBACK(_write) \
70    devcb = &ql_expansion_slot_t::set_ipl1l_wr_callback(*device, DEVCB_##_write);
70   devcb = &ql_expansion_slot_t::set_ipl1l_wr_callback(*device, DEVCB_##_write);
7171
7272#define MCFG_QL_EXPANSION_SLOT_BERRL_CALLBACK(_write) \
73    devcb = &ql_expansion_slot_t::set_berrl_wr_callback(*device, DEVCB_##_write);
73   devcb = &ql_expansion_slot_t::set_berrl_wr_callback(*device, DEVCB_##_write);
7474
7575#define MCFG_QL_EXPANSION_SLOT_EXTINTL_CALLBACK(_write) \
7676   devcb = &ql_expansion_slot_t::set_extintl_wr_callback(*device, DEVCB_##_write);
r31374r31375
9393   // construction/destruction
9494   device_ql_expansion_card_interface(const machine_config &mconfig, device_t &device);
9595
96    virtual void romoeh_w(int state) { m_romoeh = state; }
97    virtual UINT8 read(address_space &space, offs_t offset, UINT8 data) { return data; }
98    virtual void write(address_space &space, offs_t offset, UINT8 data) { }
96   virtual void romoeh_w(int state) { m_romoeh = state; }
97   virtual UINT8 read(address_space &space, offs_t offset, UINT8 data) { return data; }
98   virtual void write(address_space &space, offs_t offset, UINT8 data) { }
9999
100100protected:
101101   ql_expansion_slot_t  *m_slot;
102102
103    int m_romoeh;
103   int m_romoeh;
104104};
105105
106106
r31374r31375
113113   // construction/destruction
114114   ql_expansion_slot_t(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
115115
116    template<class _Object> static devcb_base &set_ipl0l_wr_callback(device_t &device, _Object object) { return downcast<ql_expansion_slot_t &>(device).m_write_ipl0l.set_callback(object); }
117    template<class _Object> static devcb_base &set_ipl1l_wr_callback(device_t &device, _Object object) { return downcast<ql_expansion_slot_t &>(device).m_write_ipl1l.set_callback(object); }
118    template<class _Object> static devcb_base &set_berrl_wr_callback(device_t &device, _Object object) { return downcast<ql_expansion_slot_t &>(device).m_write_berrl.set_callback(object); }
116   template<class _Object> static devcb_base &set_ipl0l_wr_callback(device_t &device, _Object object) { return downcast<ql_expansion_slot_t &>(device).m_write_ipl0l.set_callback(object); }
117   template<class _Object> static devcb_base &set_ipl1l_wr_callback(device_t &device, _Object object) { return downcast<ql_expansion_slot_t &>(device).m_write_ipl1l.set_callback(object); }
118   template<class _Object> static devcb_base &set_berrl_wr_callback(device_t &device, _Object object) { return downcast<ql_expansion_slot_t &>(device).m_write_berrl.set_callback(object); }
119119   template<class _Object> static devcb_base &set_extintl_wr_callback(device_t &device, _Object object) { return downcast<ql_expansion_slot_t &>(device).m_write_extintl.set_callback(object); }
120120
121    // computer interface
122    UINT8 read(address_space &space, offs_t offset, UINT8 data) { if (m_card) data = m_card->read(space, offset, data); return data; }
123    void write(address_space &space, offs_t offset, UINT8 data) { if (m_card) m_card->write(space, offset, data); }
124    DECLARE_WRITE_LINE_MEMBER( romoeh_w ) { if (m_card) m_card->romoeh_w(state); }
121   // computer interface
122   UINT8 read(address_space &space, offs_t offset, UINT8 data) { if (m_card) data = m_card->read(space, offset, data); return data; }
123   void write(address_space &space, offs_t offset, UINT8 data) { if (m_card) m_card->write(space, offset, data); }
124   DECLARE_WRITE_LINE_MEMBER( romoeh_w ) { if (m_card) m_card->romoeh_w(state); }
125125
126    // card interface
127    DECLARE_WRITE_LINE_MEMBER( ipl0l_w ) { m_write_ipl0l(state); }
128    DECLARE_WRITE_LINE_MEMBER( ipl1l_w ) { m_write_ipl1l(state); }
129    DECLARE_WRITE_LINE_MEMBER( berrl_w ) { m_write_berrl(state); }
126   // card interface
127   DECLARE_WRITE_LINE_MEMBER( ipl0l_w ) { m_write_ipl0l(state); }
128   DECLARE_WRITE_LINE_MEMBER( ipl1l_w ) { m_write_ipl1l(state); }
129   DECLARE_WRITE_LINE_MEMBER( berrl_w ) { m_write_berrl(state); }
130130   DECLARE_WRITE_LINE_MEMBER( extintl_w ) { m_write_extintl(state); }
131131
132132protected:
133133   // device-level overrides
134134   virtual void device_start();
135    virtual void device_reset() { if (get_card_device()) get_card_device()->reset(); }
135   virtual void device_reset() { if (get_card_device()) get_card_device()->reset(); }
136136
137137   devcb_write_line   m_write_ipl0l;
138    devcb_write_line   m_write_ipl1l;
139    devcb_write_line   m_write_berrl;
140    devcb_write_line   m_write_extintl;
138   devcb_write_line   m_write_ipl1l;
139   devcb_write_line   m_write_berrl;
140   devcb_write_line   m_write_extintl;
141141
142142   device_ql_expansion_card_interface *m_card;
143143};
trunk/src/emu/bus/ql/opd_basic_master.h
r31374r31375
2525// ======================> opd_basic_master_t
2626
2727class opd_basic_master_t : public device_t,
28                        public device_ql_expansion_card_interface
28                     public device_ql_expansion_card_interface
2929{
3030public:
3131   // construction/destruction
trunk/src/emu/bus/ql/trumpcard.h
r31374r31375
2727// ======================> ql_trump_card_t
2828
2929class ql_trump_card_t : public device_t,
30                     public device_ql_expansion_card_interface
30                  public device_ql_expansion_card_interface
3131{
3232public:
3333   // construction/destruction
trunk/src/emu/bus/ql/qubide.h
r31374r31375
2626// ======================> qubide_t
2727
2828class qubide_t : public device_t,
29                public device_ql_expansion_card_interface
29               public device_ql_expansion_card_interface
3030{
3131public:
3232   // construction/destruction
trunk/src/emu/bus/ql/cst_qdisc.h
r31374r31375
2525// ======================> cst_ql_disc_interface_t
2626
2727class cst_ql_disc_interface_t : public device_t,
28                           public device_ql_expansion_card_interface
28                        public device_ql_expansion_card_interface
2929{
3030public:
3131   // construction/destruction
trunk/src/emu/bus/ql/sandy_superqboard.h
r31374r31375
2828// ======================> sandy_superqboard_t
2929
3030class sandy_superqboard_t : public device_t,
31                        public device_ql_expansion_card_interface
31                     public device_ql_expansion_card_interface
3232{
3333public:
3434   // construction/destruction
trunk/src/emu/bus/ql/cumana_fdi.h
r31374r31375
22// copyright-holders:Curt Coder
33/**********************************************************************
44
5   Cumana Floppy Disk Interface emulation   
5    Cumana Floppy Disk Interface emulation
66
77    Copyright MESS Team.
88    Visit http://mamedev.org for licensing and usage restrictions.
r31374r31375
2525// ======================> cumana_floppy_disk_interface_t
2626
2727class cumana_floppy_disk_interface_t : public device_t,
28                                 public device_ql_expansion_card_interface
28                              public device_ql_expansion_card_interface
2929{
3030public:
3131   // construction/destruction
trunk/src/emu/bus/ql/miracle_hd.h
r31374r31375
2525// ======================> miracle_hard_disk_t
2626
2727class miracle_hard_disk_t : public device_t,
28                        public device_ql_rom_cartridge_card_interface
28                     public device_ql_rom_cartridge_card_interface
2929{
3030public:
3131   // construction/destruction
trunk/src/emu/bus/ql/rom.h
r31374r31375
6464   device_ql_rom_cartridge_card_interface(const machine_config &mconfig, device_t &device);
6565   virtual ~device_ql_rom_cartridge_card_interface();
6666
67    virtual void romoeh_w(int state) { m_romoeh = state; }
68    virtual UINT8 read(address_space &space, offs_t offset, UINT8 data) { return data; }
69    virtual void write(address_space &space, offs_t offset, UINT8 data) { }
67   virtual void romoeh_w(int state) { m_romoeh = state; }
68   virtual UINT8 read(address_space &space, offs_t offset, UINT8 data) { return data; }
69   virtual void write(address_space &space, offs_t offset, UINT8 data) { }
7070
7171protected:
7272   ql_rom_cartridge_slot_t *m_slot;
7373
7474   optional_shared_ptr<UINT8> m_rom;
7575
76    int m_romoeh;
76   int m_romoeh;
7777};
7878
7979
trunk/src/emu/bus/ql/mp_fdi.h
r31374r31375
2525// ======================> micro_peripherals_floppy_disk_interface_t
2626
2727class micro_peripherals_floppy_disk_interface_t : public device_t,
28                                         public device_ql_expansion_card_interface
28                                       public device_ql_expansion_card_interface
2929{
3030public:
3131   // construction/destruction
trunk/src/emu/bus/ql/cst_q_plus4.h
r31374r31375
2626// ======================> cst_q_plus4_t
2727
2828class cst_q_plus4_t : public device_t,
29                    public device_ql_expansion_card_interface
29                  public device_ql_expansion_card_interface
3030{
3131public:
3232   // construction/destruction
trunk/src/emu/bus/ql/sandy_superdisk.h
r31374r31375
2828// ======================> sandy_super_disk_device
2929
3030class sandy_super_disk_t : public device_t,
31                        public device_ql_expansion_card_interface
31                     public device_ql_expansion_card_interface
3232{
3333public:
3434   // construction/destruction
trunk/src/emu/bus/ql/miracle_gold_card.h
r31374r31375
2525// ======================> miracle_gold_card_t
2626
2727class miracle_gold_card_t : public device_t,
28                        public device_ql_expansion_card_interface
28                     public device_ql_expansion_card_interface
2929{
3030public:
3131   // construction/destruction
trunk/src/emu/bus/ql/kempston_di.h
r31374r31375
2525// ======================> kempston_disk_interface_t
2626
2727class kempston_disk_interface_t : public device_t,
28                                public device_ql_expansion_card_interface
28                           public device_ql_expansion_card_interface
2929{
3030public:
3131   // construction/destruction
trunk/src/emu/bus/pc_kbd/pc_kbdc.h
r31374r31375
2424
2525#define MCFG_PC_KBDC_OUT_DATA_CB(_devcb) \
2626   devcb = &pc_kbdc_device::set_out_data_callback(*device, DEVCB_##_devcb);
27   
27
2828#define MCFG_PC_KBDC_SLOT_ADD(_kbdc_tag, _tag, _slot_intf, _def_slot) \
2929   MCFG_DEVICE_ADD(_tag, PC_KBDC_SLOT, 0 ) \
3030   MCFG_DEVICE_SLOT_INTERFACE(_slot_intf, _def_slot, false) \
r31374r31375
6767
6868   template<class _Object> static devcb_base &set_out_clock_callback(device_t &device, _Object object) { return downcast<pc_kbdc_device &>(device).m_out_clock_cb.set_callback(object); }
6969   template<class _Object> static devcb_base &set_out_data_callback(device_t &device, _Object object) { return downcast<pc_kbdc_device &>(device).m_out_data_cb.set_callback(object); }
70   
70
7171   void set_keyboard(device_pc_kbd_interface *keyboard);
7272
7373   int clock_signal() { return m_clock_state; }
trunk/src/emu/bus/msx_slot/cartridge.h
r31374r31375
8080
8181
8282#endif
83
trunk/src/emu/bus/msx_slot/bunsetsu.h
r31374r31375
1111#define MCFG_MSX_SLOT_BUNSETSU_ADD(_tag, _startpage, _numpages, _region, _offset, _bunsetsu_region_tag) \
1212   MCFG_MSX_INTERNAL_SLOT_ADD(_tag, MSX_SLOT_BUNSETSU, _startpage, _numpages) \
1313   msx_slot_rom_device::set_rom_start(*device, _region, _offset); \
14   msx_slot_bunsetsu_device::set_bunsetsu_region_tag(*device, _bunsetsu_region_tag); \
15
14   msx_slot_bunsetsu_device::set_bunsetsu_region_tag(*device, _bunsetsu_region_tag);
1615class msx_slot_bunsetsu_device : public msx_slot_rom_device
1716{
1817public:
r31374r31375
3534
3635
3736#endif
38
trunk/src/emu/bus/msx_slot/ram_mm.h
r31374r31375
4141extern const device_type MSX_SLOT_RAM_MM;
4242
4343#endif
44
trunk/src/emu/bus/msx_slot/ram.h
r31374r31375
44#include "slot.h"
55
66#define MCFG_MSX_SLOT_RAM_ADD(_tag, _startpage, _numpages) \
7   MCFG_MSX_INTERNAL_SLOT_ADD(_tag, MSX_SLOT_RAM, _startpage, _numpages) \
8
7   MCFG_MSX_INTERNAL_SLOT_ADD(_tag, MSX_SLOT_RAM, _startpage, _numpages)
98class msx_slot_ram_device : public device_t,
109                     public msx_internal_slot_interface
1110{
trunk/src/emu/bus/msx_slot/music.h
r31374r31375
1313#define MCFG_MSX_SLOT_MUSIC_ADD(_tag, _startpage, _numpages, _region, _offset, _ym2413_tag) \
1414   MCFG_MSX_INTERNAL_SLOT_ADD(_tag, MSX_SLOT_MUSIC, _startpage, _numpages) \
1515   msx_slot_rom_device::set_rom_start(*device, _region, _offset); \
16   msx_slot_music_device::set_ym2413_tag(*device, _ym2413_tag); \
17
16   msx_slot_music_device::set_ym2413_tag(*device, _ym2413_tag);
1817class msx_slot_music_device : public msx_slot_rom_device
1918{
2019public:
r31374r31375
3635
3736
3837#endif
39
trunk/src/emu/bus/msx_slot/disk.h
r31374r31375
103103class msx_slot_tc8566_disk_device : public msx_slot_disk_device
104104{
105105public:
106    msx_slot_tc8566_disk_device(const machine_config &mconfig, device_type type, const char *name, const char *tag, device_t *owner, UINT32 clock, const char *shortname, const char *source);
106   msx_slot_tc8566_disk_device(const machine_config &mconfig, device_type type, const char *name, const char *tag, device_t *owner, UINT32 clock, const char *shortname, const char *source);
107107
108    virtual void device_start();
108   virtual void device_start();
109109
110110protected:
111111   tc8566af_device *m_fdc;
r31374r31375
185185   DECLARE_READ8_MEMBER(io_read);
186186   DECLARE_WRITE8_MEMBER(io_write);
187187
188    void post_load();
188   void post_load();
189189
190190private:
191191   UINT8 m_control;
r31374r31375
195195
196196
197197#endif
198
trunk/src/emu/bus/a1bus/a1bus.h
r31374r31375
7575   // construction/destruction
7676   a1bus_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
7777   a1bus_device(const machine_config &mconfig, device_type type, const char *name, const char *tag, device_t *owner, UINT32 clock, const char *shortname, const char *source);
78   
78
7979   // inline configuration
8080   static void static_set_cputag(device_t &device, const char *tag);
8181   template<class _Object> static devcb_base &set_out_irq_callback(device_t &device, _Object object) { return downcast<a1bus_device &>(device).m_out_irq_cb.set_callback(object); }
r31374r31375
9797   // device-level overrides
9898   virtual void device_start();
9999   virtual void device_reset();
100   
100
101101   // internal state
102102   cpu_device   *m_maincpu;
103103
trunk/src/emu/bus/isa/gus.h
r31374r31375
6161
6262#define MCFG_GF1_TIMER2_IRQ_HANDLER(_devcb) \
6363   devcb = &gf1_device::set_timer2_irq_handler(*device, DEVCB_##_devcb);
64   
64
6565#define MCFG_GF1_SB_IRQ_HANDLER(_devcb) \
6666   devcb = &gf1_device::set_sb_irq_handler(*device, DEVCB_##_devcb);
6767
6868#define MCFG_GF1_DMA_IRQ_HANDLER(_devcb) \
6969   devcb = &gf1_device::set_dma_irq_handler(*device, DEVCB_##_devcb);
70   
70
7171#define MCFG_GF1_DRQ1_HANDLER(_devcb) \
7272   devcb = &gf1_device::set_drq1_handler(*device, DEVCB_##_devcb);
73   
73
7474#define MCFG_GF1_DRQ2_HANDLER(_devcb) \
7575   devcb = &gf1_device::set_drq2_handler(*device, DEVCB_##_devcb);
76   
76
7777#define MCFG_GF1_NMI_HANDLER(_devcb) \
7878   devcb = &gf1_device::set_nmi_handler(*device, DEVCB_##_devcb);
79   
79
8080//**************************************************************************
8181//  TYPE DEFINITIONS
8282//**************************************************************************
trunk/src/emu/bus/isa/aga.h
r31374r31375
5757   DECLARE_READ8_MEMBER( pc_aga_videoram_r );
5858
5959   MC6845_UPDATE_ROW( aga_update_row );
60   MC6845_UPDATE_ROW( mda_text_inten_update_row );
60   MC6845_UPDATE_ROW( mda_text_inten_update_row );
6161   MC6845_UPDATE_ROW( mda_text_blink_update_row );
6262   MC6845_UPDATE_ROW( cga_text_inten_update_row );
6363   MC6845_UPDATE_ROW( cga_text_inten_alt_update_row );
trunk/src/emu/bus/isa/isa.h
r31374r31375
9292
9393#define MCFG_ISA_BUS_IOCHCK(_iochck) \
9494   downcast<isa8_device *>(device)->set_iochck_callback(DEVCB_##_iochck);
95   
95
9696#define MCFG_ISA_OUT_IRQ2_CB(_devcb) \
9797   devcb = &isa8_device::set_out_irq2_callback(*device, DEVCB_##_devcb);
9898
r31374r31375
119119
120120#define MCFG_ISA_OUT_DRQ3_CB(_devcb) \
121121   devcb = &isa8_device::set_out_drq3_callback(*device, DEVCB_##_devcb);
122   
123122
123
124124#define MCFG_ISA_OUT_IRQ10_CB(_devcb) \
125125   devcb = &isa16_device::set_out_irq10_callback(*device, DEVCB_##_devcb);
126126
r31374r31375
354354   template<class _Object> static devcb_base &set_out_drq5_callback(device_t &device, _Object object) { return downcast<isa16_device &>(device).m_out_drq5_cb.set_callback(object); }
355355   template<class _Object> static devcb_base &set_out_drq6_callback(device_t &device, _Object object) { return downcast<isa16_device &>(device).m_out_drq6_cb.set_callback(object); }
356356   template<class _Object> static devcb_base &set_out_drq7_callback(device_t &device, _Object object) { return downcast<isa16_device &>(device).m_out_drq7_cb.set_callback(object); }
357   
357
358358   void install16_device(offs_t start, offs_t end, offs_t mask, offs_t mirror, read16_delegate rhandler, write16_delegate whandler);
359359
360360   // for ISA16, put the 16-bit configs in the primary slots and the 8-bit configs in the secondary
trunk/src/emu/bus/oricext/microdisc.h
r31374r31375
4040   floppy_image_device *floppies[4];
4141   UINT8 port_314;
4242   bool intrq_state, drq_state, hld_state;
43   
43
4444   virtual void device_start();
4545   virtual void device_reset();
4646   const rom_entry *device_rom_region() const;
trunk/src/emu/bus/oricext/oricext.h
r31374r31375
1010#include "emu.h"
1111#include "cpu/m6502/m6502.h"
1212
13#define MCFG_ORICEXT_ADD(_tag, _slot_intf, _def_slot, _cputag, _irq)   \
13#define MCFG_ORICEXT_ADD(_tag, _slot_intf, _def_slot, _cputag, _irq)    \
1414   MCFG_DEVICE_ADD(_tag, ORICEXT_CONNECTOR, 0) \
1515   MCFG_DEVICE_SLOT_INTERFACE(_slot_intf, _def_slot, false) \
1616   downcast<oricext_connector *>(device)->set_cputag(_cputag); \
r31374r31375
2020class oricext_device;
2121
2222class oricext_connector: public device_t,
23                  public device_slot_interface
23                     public device_slot_interface
2424{
2525public:
2626   oricext_connector(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
r31374r31375
3838};
3939
4040class oricext_device : public device_t,
41                  public device_slot_card_interface
41                  public device_slot_card_interface
4242{
4343public:
4444   oricext_device(const machine_config &mconfig, device_type type, const char *name, const char *tag, device_t *owner, UINT32 clock, const char *shortname, const char *source);
trunk/src/emu/bus/oricext/jasmin.h
r31374r31375
2828   bool side_sel, fdc_reset, ram_access, rom_access, select[4];
2929   UINT8 *jasmin_rom;
3030   floppy_image_device *cur_floppy, *floppies[4];
31   
31
3232   virtual void device_start();
3333   virtual void device_reset();
3434   const rom_entry *device_rom_region() const;
trunk/src/emu/bus/msx_cart/yamaha.h
r31374r31375
6060};
6161
6262#endif
63
trunk/src/emu/bus/msx_cart/konami.h
r31374r31375
9494
9595
9696class msx_cart_synthesizer : public device_t
97                        , public msx_cart_interface
97                  , public msx_cart_interface
9898{
9999public:
100    msx_cart_synthesizer(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
100   msx_cart_synthesizer(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
101101
102    // device-level overrides
103    virtual void device_start();
102   // device-level overrides
103   virtual void device_start();
104104   virtual machine_config_constructor device_mconfig_additions() const;
105105
106    virtual void initialize_cartridge();
106   virtual void initialize_cartridge();
107107
108    virtual DECLARE_READ8_MEMBER(read_cart);
109    virtual DECLARE_WRITE8_MEMBER(write_cart);
108   virtual DECLARE_READ8_MEMBER(read_cart);
109   virtual DECLARE_WRITE8_MEMBER(write_cart);
110110
111111private:
112    UINT8 *m_bank_base;
112   UINT8 *m_bank_base;
113113   required_device<dac_device> m_dac;
114114};
115115
trunk/src/emu/bus/msx_cart/ascii.h
r31374r31375
113113
114114
115115#endif
116
trunk/src/emu/bus/nes/mmc5.h
r31374r31375
7878
7979   // MMC-5 contains 1K of internal ram
8080   UINT8 m_exram[0x400];
81   
81
8282   UINT8 m_ram_hi_banks[4];
8383
8484   //  int m_nes_vram_sprite[8];
trunk/src/emu/bus/pet/diag.h
r31374r31375
4646   virtual DECLARE_WRITE_LINE_MEMBER( input_d ) { output_4(state); }
4747   virtual DECLARE_WRITE_LINE_MEMBER( input_k ) { output_9(state); }
4848   virtual DECLARE_WRITE_LINE_MEMBER( input_l ) { output_10(state); }
49   
49
5050protected:
5151   // device-level overrides
5252   virtual void device_start();
trunk/src/emu/bus/z88/z88.h
r31374r31375
8585   // construction/destruction
8686   z88cart_slot_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
8787   virtual ~z88cart_slot_device();
88   
88
8989   template<class _Object> static devcb_base &set_out_flp_callback(device_t &device, _Object object) { return downcast<z88cart_slot_device &>(device).m_out_flp_cb.set_callback(object); }
9090
9191   // device-level overrides
r31374r31375
134134
135135#define MCFG_Z88CART_SLOT_OUT_FLP_CB(_devcb) \
136136      devcb = &z88cart_slot_device::set_out_flp_callback(*device, DEVCB_##_devcb);
137   
137
138138#endif /* __Z88CART_H__ */
trunk/src/emu/bus/kc/kc.h
r31374r31375
4949   template<class _Object> static devcb_base &set_out_irq_callback(device_t &device, _Object object) { return downcast<kcexp_slot_device &>(device).m_out_irq_cb.set_callback(object); }
5050   template<class _Object> static devcb_base &set_out_nmi_callback(device_t &device, _Object object) { return downcast<kcexp_slot_device &>(device).m_out_nmi_cb.set_callback(object); }
5151   template<class _Object> static devcb_base &set_out_halt_callback(device_t &device, _Object object) { return downcast<kcexp_slot_device &>(device).m_out_halt_cb.set_callback(object); }
52   
52
5353   // device-level overrides
5454   virtual void device_start();
5555
r31374r31375
127127
128128#define MCFG_KCEXP_SLOT_NEXT_SLOT(_next_slot_tag) \
129129   kcexp_slot_device::static_set_next_slot(*device, _next_slot_tag);
130   
131130
131
132132#define MCFG_KCCART_SLOT_OUT_IRQ_CB(_devcb) \
133133   devcb = &kccart_slot_device::set_out_irq_callback(*device, DEVCB_##_devcb);
134134
r31374r31375
141141#define MCFG_KCCART_SLOT_NEXT_SLOT(_next_slot_tag) \
142142   kccart_slot_device::static_set_next_slot(*device, _next_slot_tag);
143143
144// #define MCFG_KC85_EXPANSION_ADD(_tag,_next_slot_tag,_config,_slot_intf,_def_slot)
145//   MCFG_DEVICE_ADD(_tag, KCEXP_SLOT, 0)
146//   MCFG_DEVICE_SLOT_INTERFACE(_slot_intf, _def_slot, false)
144// #define MCFG_KC85_EXPANSION_ADD(_tag,_next_slot_tag,_config,_slot_intf,_def_slot)
145//  MCFG_DEVICE_ADD(_tag, KCEXP_SLOT, 0)
146//  MCFG_DEVICE_SLOT_INTERFACE(_slot_intf, _def_slot, false)
147147
148148// #define MCFG_KC85_CARTRIDGE_ADD(_tag,_next_slot_tag,_config,_slot_intf,_def_slot)
149//   MCFG_DEVICE_ADD(_tag, KCCART_SLOT, 0)
150//   MCFG_DEVICE_SLOT_INTERFACE(_slot_intf, _def_slot, false)
149//  MCFG_DEVICE_ADD(_tag, KCCART_SLOT, 0)
150//  MCFG_DEVICE_SLOT_INTERFACE(_slot_intf, _def_slot, false)
151151
152152#endif /* __KCEXP_H__ */
trunk/src/emu/bus/cpc/cpcexp.h
r31374r31375
9393   // construction/destruction
9494   cpc_expansion_slot_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
9595   virtual ~cpc_expansion_slot_device();
96   
96
9797   template<class _Object> static devcb_base &set_out_irq_callback(device_t &device, _Object object) { return downcast<cpc_expansion_slot_device &>(device).m_out_irq_cb.set_callback(object); }
9898   template<class _Object> static devcb_base &set_out_nmi_callback(device_t &device, _Object object) { return downcast<cpc_expansion_slot_device &>(device).m_out_nmi_cb.set_callback(object); }
9999   template<class _Object> static devcb_base &set_out_reset_callback(device_t &device, _Object object) { return downcast<cpc_expansion_slot_device &>(device).m_out_reset_cb.set_callback(object); }
trunk/src/emu/bus/cpc/cpc_rs232.h
r31374r31375
1414#include "cpcexp.h"
1515
1616class cpc_rs232_device : public device_t,
17                    public device_cpc_expansion_card_interface
17                     public device_cpc_expansion_card_interface
1818{
1919public:
2020   // construction/destruction
trunk/src/emu/bus/neogeo/mslugx_prot.h
r31374r31375
3737};
3838
3939#endif
40
41
42
trunk/src/emu/bus/neogeo/kof2002_prot.h
r31374r31375
3434};
3535
3636#endif
37
38
39
trunk/src/emu/bus/neogeo/sbp_prot.h
r31374r31375
1616public:
1717   // construction/destruction
1818   sbp_prot_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
19   
2019
20
2121   UINT8* m_mainrom;
2222
2323   void sbp_install_protection(cpu_device* maincpu, UINT8* cpurom, UINT32 cpurom_size);
r31374r31375
3636};
3737
3838#endif
39
40
41
42
trunk/src/emu/bus/neogeo/pvc_prot.h
r31374r31375
4646};
4747
4848#endif
49
50
51
trunk/src/emu/bus/neogeo/bootleg_prot.h
r31374r31375
2222   void neogeo_bootleg_sx_decrypt(UINT8* fixed, UINT32 fixed_size, int value);
2323   void kog_px_decrypt(UINT8* cpurom, UINT32 cpurom_size);
2424   void kof97oro_px_decode(UINT8* cpurom, UINT32 cpurom_size);
25   void kof10thBankswitch(address_space &space, UINT16   nBank);
25   void kof10thBankswitch(address_space &space, UINT16 nBank);
2626   DECLARE_READ16_MEMBER(kof10th_RAM2_r);
2727   DECLARE_READ16_MEMBER(kof10th_RAMB_r);
2828   DECLARE_WRITE16_MEMBER(kof10th_custom_w);
r31374r31375
9595};
9696
9797#endif
98
99
100
trunk/src/emu/bus/neogeo/cmc_prot.h
r31374r31375
8383};
8484
8585#endif
86
87
88
trunk/src/emu/bus/neogeo/sma_prot.h
r31374r31375
5454};
5555
5656#endif
57
58
59
trunk/src/emu/bus/neogeo/neogeo_intf.h
r31374r31375
4949   void ym_alloc(UINT32 size) { if (m_ym == NULL) m_ym.resize(size/sizeof(UINT8)); }
5050   UINT8* get_ym_base() { return m_ym; }
5151   UINT32  get_ym_size() { return m_ym.bytes(); }
52   
52
5353   void ymdelta_alloc(UINT32 size) { if (m_ymdelta == NULL) m_ymdelta.resize(size/sizeof(UINT8)); }
5454   UINT8* get_ymdelta_base() { return m_ymdelta; }
5555   UINT32  get_ymdelta_size() { return m_ymdelta.bytes(); }
r31374r31375
7474};
7575
7676#endif
77
trunk/src/emu/bus/neogeo/banked_cart.h
r31374r31375
4242};
4343
4444#endif
45
46
47
trunk/src/emu/bus/neogeo/kof98_prot.h
r31374r31375
1616public:
1717   // construction/destruction
1818   kof98_prot_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
19   
19
2020   void kof98_decrypt_68k(UINT8* cpurom, UINT32 cpurom_size);
2121   void install_kof98_protection(cpu_device* maincpu);
2222   DECLARE_WRITE16_MEMBER(kof98_prot_w);
r31374r31375
3636};
3737
3838#endif
39
40
41
42
trunk/src/emu/bus/neogeo/pcm2_prot.h
r31374r31375
1616public:
1717   // construction/destruction
1818   pcm2_prot_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
19   
19
2020   void neo_pcm2_snk_1999(UINT8* ymrom, UINT32 ymsize, int value);
2121   void neo_pcm2_swap(UINT8* ymrom, UINT32 ymsize, int value);
2222
r31374r31375
3232};
3333
3434#endif
35
36
37
trunk/src/emu/bus/neogeo/fatfury2_prot.h
r31374r31375
3838};
3939
4040#endif
41
42
43
44
45
trunk/src/emu/bus/amiga/zorro/zorro.h
r31374r31375
11/***************************************************************************
22
3   Amiga Zorro Slots
3    Amiga Zorro Slots
44
55    license: MAME, GPL-2.0+
66    copyright-holders: Dirk Best
77
8   86-pin Expansion Slot (Zorro-I), Zorro-II, Zorro-III
8    86-pin Expansion Slot (Zorro-I), Zorro-II, Zorro-III
99
10   86-pin Expansion Slot
10    86-pin Expansion Slot
1111
12    2  Ground           1  Ground
13    4  Ground           3  Ground
14    6  +5VDC            5  +5VDC
15    8  -5VDC            7  N/C
16   10  +12VDC           9  N/C *1
17   12  CFGIN           11  N/C *2
18   14  /C3 Clock       13  Ground
19   16  /C1 Clock       15  CDAC
20   18  XRDY            17  /OVR
21   20  N/C *3          19  /INT2
22   22  /INT6           21  A5
23   24  A4              23  A6
24   26  A3              25  Ground
25   28  A7              27  A2
26   30  A8              29  A1
27   32  A9              31  FC0
28   34  A10             33  FC1
29   36  A11             35  FC2
30   38  A12             37  Ground
31   40  /IPL0           39  A13
32   42  /IPL1           41  A14
33   44  /IPL2           43  A15
34   46  /BEER           45  A16
35   48  /VPA            47  A17
36   50  E Clock         49  Ground
37   52  A18             51  /VMA
38   54  A19             53  /RST
39   56  A20             55  /HLT
40   58  A21             57  A22
41   60  /BR *4          59  A23
42   62  /BGACK          61  Ground
43   64  /BG *5          63  D15
44   66  /DTACK          65  D14
45   68  R/W             67  D13
46   70  /LDS            69  D12
47   72  /UDS            71  D11
48   74  /AS             73  Ground
49   76  D10             75  D0
50   78  D9              77  D1
51   80  D8              79  D2
52   82  D7              81  D3
53   84  D6              83  D4
54   86  D5              85  Ground
12     2  Ground           1  Ground
13     4  Ground           3  Ground
14     6  +5VDC            5  +5VDC
15     8  -5VDC            7  N/C
16    10  +12VDC           9  N/C *1
17    12  CFGIN           11  N/C *2
18    14  /C3 Clock       13  Ground
19    16  /C1 Clock       15  CDAC
20    18  XRDY            17  /OVR
21    20  N/C *3          19  /INT2
22    22  /INT6           21  A5
23    24  A4              23  A6
24    26  A3              25  Ground
25    28  A7              27  A2
26    30  A8              29  A1
27    32  A9              31  FC0
28    34  A10             33  FC1
29    36  A11             35  FC2
30    38  A12             37  Ground
31    40  /IPL0           39  A13
32    42  /IPL1           41  A14
33    44  /IPL2           43  A15
34    46  /BEER           45  A16
35    48  /VPA            47  A17
36    50  E Clock         49  Ground
37    52  A18             51  /VMA
38    54  A19             53  /RST
39    56  A20             55  /HLT
40    58  A21             57  A22
41    60  /BR *4          59  A23
42    62  /BGACK          61  Ground
43    64  /BG *5          63  D15
44    66  /DTACK          65  D14
45    68  R/W             67  D13
46    70  /LDS            69  D12
47    72  /UDS            71  D11
48    74  /AS             73  Ground
49    76  D10             75  D0
50    78  D9              77  D1
51    80  D8              79  D2
52    82  D7              81  D3
53    84  D6              83  D4
54    86  D5              85  Ground
5555
56   *1  28 MHz Clock on A2000 and B2000
57   *2  /COPCFG on B2000
58   *3  /PALOPE on A1000, /BOSS on B2000
59   *4  /CBR on B2000
60   *5  /CBG on B2000
56    *1  28 MHz Clock on A2000 and B2000
57    *2  /COPCFG on B2000
58    *3  /PALOPE on A1000, /BOSS on B2000
59    *4  /CBR on B2000
60    *5  /CBG on B2000
6161
62   Zorro-II (differences only)
62    Zorro-II (differences only)
6363
64    7  /OWN
65    9  /SLAVEn
66   11  /CFGOUTn
67   12  /CFGINn
68   20  -12VDC
69   40  /EINT7
70   42  /EINT5
71   44  /EINT4
72   60  /BRn
73   64  /BGn
64     7  /OWN
65     9  /SLAVEn
66    11  /CFGOUTn
67    12  /CFGINn
68    20  -12VDC
69    40  /EINT7
70    42  /EINT5
71    44  /EINT4
72    60  /BRn
73    64  /BGn
7474
75   88  Ground          87  Ground
76   90  Ground          89  Ground
77   92  7 MHz           91  Ground
78   94  /BURST          93  DOE
79   96  /EINT1          95  /BG *5
80   98  N/C             97  N/C
75    88  Ground          87  Ground
76    90  Ground          89  Ground
77    92  7 MHz           91  Ground
78    94  /BURST          93  DOE
79    96  /EINT1          95  /BG *5
80    98  N/C             97  N/C
8181   100  Ground          99  Ground
8282
83   *6  /GBG on B2000
83    *6  /GBG on B2000
8484
85   Zorro-III
85    Zorro-III
8686
87   The Zorro-III is a multiplexed Zorro-II bus with address- and
88   data phases. Signals changes as follows:
87    The Zorro-III is a multiplexed Zorro-II bus with address- and
88    data phases. Signals changes as follows:
8989
90   17  /CINH
91   18  /MTCR
92   29  /LOCK
93   30  AD8 (D0)
94   32  AD9 (D1)
95   34  AD10 (D2)
96   36  AD11 (D3)
97   38  AD12 (D4)
98   39  AD13 (D5)
99   40  Reserved
100   41  AD14 (D6)
101   42  Reserved
102   43  AD15 (D7)
103   44  Reserved
104   45  AD16 (D8)
105   47  AD17 (D9)
106   48  /MTACK
107   51  /DS0
108   52  AD18 (D10)
109   54  AD19 (D11)
110   56  AD20 (D12)
111   57  AD22 (D14)
112   58  AD21 (D13)
113   59  AD23 (D15)
114   63  AD31
115   65  AD30
116   67  AD29
117   69  AD28
118   70  /DS2
119   71  AD27
120   72  /DS3
121   74  /CCS
122   75  SD0 (D16)
123   76  AD26
124   77  SD1 (D17)
125   78  AD25
126   79  SD2 (D18)
127   80  AD24
128   81  SD3 (D19)
129   82  SD7 (D23)
130   83  SD4 (D20)
131   84  SD6 (D22)
132   86  SD5 (D21)
133   91  Sense Z3
134   94  /IORST
135   95  /BCLR
136   97  /FCS
137   98  /DS1
90    17  /CINH
91    18  /MTCR
92    29  /LOCK
93    30  AD8 (D0)
94    32  AD9 (D1)
95    34  AD10 (D2)
96    36  AD11 (D3)
97    38  AD12 (D4)
98    39  AD13 (D5)
99    40  Reserved
100    41  AD14 (D6)
101    42  Reserved
102    43  AD15 (D7)
103    44  Reserved
104    45  AD16 (D8)
105    47  AD17 (D9)
106    48  /MTACK
107    51  /DS0
108    52  AD18 (D10)
109    54  AD19 (D11)
110    56  AD20 (D12)
111    57  AD22 (D14)
112    58  AD21 (D13)
113    59  AD23 (D15)
114    63  AD31
115    65  AD30
116    67  AD29
117    69  AD28
118    70  /DS2
119    71  AD27
120    72  /DS3
121    74  /CCS
122    75  SD0 (D16)
123    76  AD26
124    77  SD1 (D17)
125    78  AD25
126    79  SD2 (D18)
127    80  AD24
128    81  SD3 (D19)
129    82  SD7 (D23)
130    83  SD4 (D20)
131    84  SD6 (D22)
132    86  SD5 (D21)
133    91  Sense Z3
134    94  /IORST
135    95  /BCLR
136    97  /FCS
137    98  /DS1
138138
139139
140140***************************************************************************/
trunk/src/emu/bus/amiga/zorro/cards.h
r31374r31375
11/***************************************************************************
22
3   Amiga Zorro Cards
3    Amiga Zorro Cards
44
5   There are different card types and layouts:
5    There are different card types and layouts:
66
7   * 86-pin expansion slot
8     - A1000
9     - A500 (rotated slot)
10     - A2000/B2000 (internal slot)
11   * Zorro-II
12     - A2000
13     - B2000
14   * Zorro-III
15     - A3000, A4000
7    * 86-pin expansion slot
8      - A1000
9      - A500 (rotated slot)
10      - A2000/B2000 (internal slot)
11    * Zorro-II
12      - A2000
13      - B2000
14    * Zorro-III
15      - A3000, A4000
1616
17   For details see zorro.h. Zorro-II cards can be inserted into
18   Zorro-III slots.
17    For details see zorro.h. Zorro-II cards can be inserted into
18    Zorro-III slots.
1919
2020***************************************************************************/
2121
trunk/src/emu/bus/amiga/zorro/a590.h
r31374r31375
11/***************************************************************************
22
3   Commodore A590 / A2091
3    Commodore A590 / A2091
44
55    license: MAME, GPL-2.0+
66    copyright-holders: Dirk Best
77
8   DMAC based SCSI controller for the Amiga 500 and Zorro-II
8    DMAC based SCSI controller for the Amiga 500 and Zorro-II
99
1010***************************************************************************/
1111
trunk/src/emu/bus/amiga/zorro/buddha.h
r31374r31375
11/***************************************************************************
22
3   Buddha
3    Buddha
44
55    license: MAME, GPL-2.0+
66    copyright-holders: Dirk Best
77
8   Zorro-II IDE controller
8    Zorro-II IDE controller
99
1010***************************************************************************/
1111
trunk/src/emu/bus/amiga/zorro/a2052.h
r31374r31375
11/***************************************************************************
22
3   Commodore A2052
3    Commodore A2052
44
55    license: MAME, GPL-2.0+
66    copyright-holders: Dirk Best
77
8   Zorro-II RAM Expansion (0.5, 1 or 2 MB)
8    Zorro-II RAM Expansion (0.5, 1 or 2 MB)
99
1010***************************************************************************/
1111
trunk/src/emu/bus/amiga/zorro/a2232.h
r31374r31375
11/***************************************************************************
22
3   Commodore A2232
3    Commodore A2232
44
55    license: MAME, GPL-2.0+
66    copyright-holders: Dirk Best
77
8   Zorro-II Serial Card
8    Zorro-II Serial Card
99
10   Provides the Amiga with 7 additional RS232 ports.
10    Provides the Amiga with 7 additional RS232 ports.
1111
1212***************************************************************************/
1313
trunk/src/emu/bus/amiga/zorro/action_replay.h
r31374r31375
11/***************************************************************************
22
3   Datel Action Replay
3    Datel Action Replay
44
55    license: MAME, GPL-2.0+
66    copyright-holders: Dirk Best
77
8   Freezer cartridge for Amiga 500 and Amiga 2000
8    Freezer cartridge for Amiga 500 and Amiga 2000
99
1010***************************************************************************/
1111
trunk/src/lib/sqlite3/shell.c
r31374r31375
38483848   }
38493849   sqlite3_free(data.zFreeOnClose);
38503850   return rc;
3851}
3851}
trunk/src/lib/sqlite3/sqlite3.h
r31374r31375
135135** function is provided for use in DLLs since DLL users usually do not have
136136** direct access to string constants within the DLL.  ^The
137137** sqlite3_libversion_number() function returns an integer equal to
138** [SQLITE_VERSION_NUMBER].  ^The sqlite3_sourceid() function returns
139** a pointer to a string constant whose value is the same as the
138** [SQLITE_VERSION_NUMBER].  ^The sqlite3_sourceid() function returns
139** a pointer to a string constant whose value is the same as the
140140** [SQLITE_SOURCE_ID] C preprocessor macro.
141141**
142142** See also: [sqlite_version()] and [sqlite_source_id()].
r31374r31375
149149/*
150150** CAPI3REF: Run-Time Library Compilation Options Diagnostics
151151**
152** ^The sqlite3_compileoption_used() function returns 0 or 1
153** indicating whether the specified option was defined at
154** compile time.  ^The SQLITE_ prefix may be omitted from the
155** option name passed to sqlite3_compileoption_used(). 
152** ^The sqlite3_compileoption_used() function returns 0 or 1
153** indicating whether the specified option was defined at
154** compile time.  ^The SQLITE_ prefix may be omitted from the
155** option name passed to sqlite3_compileoption_used().
156156**
157157** ^The sqlite3_compileoption_get() function allows iterating
158158** over the list of options that were defined at compile time by
159159** returning the N-th compile time option string.  ^If N is out of range,
160** sqlite3_compileoption_get() returns a NULL pointer.  ^The SQLITE_
161** prefix is omitted from any strings returned by
160** sqlite3_compileoption_get() returns a NULL pointer.  ^The SQLITE_
161** prefix is omitted from any strings returned by
162162** sqlite3_compileoption_get().
163163**
164164** ^Support for the diagnostic functions sqlite3_compileoption_used()
165** and sqlite3_compileoption_get() may be omitted by specifying the
165** and sqlite3_compileoption_get() may be omitted by specifying the
166166** [SQLITE_OMIT_COMPILEOPTION_DIAGS] option at compile time.
167167**
168168** See also: SQL functions [sqlite_compileoption_used()] and
r31374r31375
183183** SQLite can be compiled with or without mutexes.  When
184184** the [SQLITE_THREADSAFE] C preprocessor macro is 1 or 2, mutexes
185185** are enabled and SQLite is threadsafe.  When the
186** [SQLITE_THREADSAFE] macro is 0,
186** [SQLITE_THREADSAFE] macro is 0,
187187** the mutexes are omitted.  Without the mutexes, it is not safe
188188** to use SQLite concurrently from more than one thread.
189189**
r31374r31375
240240**
241241** ^The sqlite3_int64 and sqlite_int64 types can store integer values
242242** between -9223372036854775808 and +9223372036854775807 inclusive.  ^The
243** sqlite3_uint64 and sqlite_uint64 types can store integer values
243** sqlite3_uint64 and sqlite_uint64 types can store integer values
244244** between 0 and +18446744073709551615 inclusive.
245245*/
246246#ifdef SQLITE_INT64_TYPE
247  typedef SQLITE_INT64_TYPE sqlite_int64;
248  typedef unsigned SQLITE_INT64_TYPE sqlite_uint64;
247   typedef SQLITE_INT64_TYPE sqlite_int64;
248   typedef unsigned SQLITE_INT64_TYPE sqlite_uint64;
249249#elif defined(_MSC_VER) || defined(__BORLANDC__)
250  typedef __int64 sqlite_int64;
251  typedef unsigned __int64 sqlite_uint64;
250   typedef __int64 sqlite_int64;
251   typedef unsigned __int64 sqlite_uint64;
252252#else
253  typedef long long int sqlite_int64;
254  typedef unsigned long long int sqlite_uint64;
253   typedef long long int sqlite_int64;
254   typedef unsigned long long int sqlite_uint64;
255255#endif
256256typedef sqlite_int64 sqlite3_int64;
257257typedef sqlite_uint64 sqlite3_uint64;
r31374r31375
285285** destructors are called is arbitrary.
286286**
287287** Applications should [sqlite3_finalize | finalize] all [prepared statements],
288** [sqlite3_blob_close | close] all [BLOB handles], and
288** [sqlite3_blob_close | close] all [BLOB handles], and
289289** [sqlite3_backup_finish | finish] all [sqlite3_backup] objects associated
290290** with the [sqlite3] object prior to attempting to close the object.  ^If
291291** sqlite3_close_v2() is called on a [database connection] that still has
r31374r31375
321321** The sqlite3_exec() interface is a convenience wrapper around
322322** [sqlite3_prepare_v2()], [sqlite3_step()], and [sqlite3_finalize()],
323323** that allows an application to run multiple statements of SQL
324** without having to use a lot of C code.
324** without having to use a lot of C code.
325325**
326326** ^The sqlite3_exec() interface runs zero or more UTF-8 encoded,
327327** semicolon-separate SQL statements passed into its 2nd argument,
r31374r31375
361361** from [sqlite3_column_name()].
362362**
363363** ^If the 2nd parameter to sqlite3_exec() is a NULL pointer, a pointer
364** to an empty string, or a pointer that contains only whitespace and/or
364** to an empty string, or a pointer that contains only whitespace and/or
365365** SQL comments, then no SQL statements are evaluated and the database
366366** is not changed.
367367**
r31374r31375
377377** </ul>
378378*/
379379SQLITE_API int sqlite3_exec(
380  sqlite3*,                                  /* An open database */
381  const char *sql,                           /* SQL to be evaluated */
382  int (*callback)(void*,int,char**,char**),  /* Callback function */
383  void *,                                    /* 1st argument to callback */
384  char **errmsg                              /* Error msg written here */
380   sqlite3*,                                  /* An open database */
381   const char *sql,                           /* SQL to be evaluated */
382   int (*callback)(void*,int,char**,char**),  /* Callback function */
383   void *,                                    /* 1st argument to callback */
384   char **errmsg                              /* Error msg written here */
385385);
386386
387387/*
r31374r31375
622622/*
623623** CAPI3REF: OS Interface Open File Handle
624624**
625** An [sqlite3_file] object represents an open file in the
625** An [sqlite3_file] object represents an open file in the
626626** [sqlite3_vfs | OS interface layer].  Individual OS interface
627627** implementations will
628628** want to subclass this object by appending additional fields
r31374r31375
632632*/
633633typedef struct sqlite3_file sqlite3_file;
634634struct sqlite3_file {
635  const struct sqlite3_io_methods *pMethods;  /* Methods for an open file */
635   const struct sqlite3_io_methods *pMethods;  /* Methods for an open file */
636636};
637637
638638/*
r31374r31375
644644** This object defines the methods used to perform various operations
645645** against the open file represented by the [sqlite3_file] object.
646646**
647** If the [sqlite3_vfs.xOpen] method sets the sqlite3_file.pMethods element
647** If the [sqlite3_vfs.xOpen] method sets the sqlite3_file.pMethods element
648648** to a non-NULL pointer, then the sqlite3_io_methods.xClose method
649649** may be invoked even if the [sqlite3_vfs.xOpen] reported that it failed.  The
650650** only way to prevent a call to xClose following a failed [sqlite3_vfs.xOpen]
r31374r31375
727727*/
728728typedef struct sqlite3_io_methods sqlite3_io_methods;
729729struct sqlite3_io_methods {
730  int iVersion;
731  int (*xClose)(sqlite3_file*);
732  int (*xRead)(sqlite3_file*, void*, int iAmt, sqlite3_int64 iOfst);
733  int (*xWrite)(sqlite3_file*, const void*, int iAmt, sqlite3_int64 iOfst);
734  int (*xTruncate)(sqlite3_file*, sqlite3_int64 size);
735  int (*xSync)(sqlite3_file*, int flags);
736  int (*xFileSize)(sqlite3_file*, sqlite3_int64 *pSize);
737  int (*xLock)(sqlite3_file*, int);
738  int (*xUnlock)(sqlite3_file*, int);
739  int (*xCheckReservedLock)(sqlite3_file*, int *pResOut);
740  int (*xFileControl)(sqlite3_file*, int op, void *pArg);
741  int (*xSectorSize)(sqlite3_file*);
742  int (*xDeviceCharacteristics)(sqlite3_file*);
743  /* Methods above are valid for version 1 */
744  int (*xShmMap)(sqlite3_file*, int iPg, int pgsz, int, void volatile**);
745  int (*xShmLock)(sqlite3_file*, int offset, int n, int flags);
746  void (*xShmBarrier)(sqlite3_file*);
747  int (*xShmUnmap)(sqlite3_file*, int deleteFlag);
748  /* Methods above are valid for version 2 */
749  int (*xFetch)(sqlite3_file*, sqlite3_int64 iOfst, int iAmt, void **pp);
750  int (*xUnfetch)(sqlite3_file*, sqlite3_int64 iOfst, void *p);
751  /* Methods above are valid for version 3 */
752  /* Additional methods may be added in future releases */
730   int iVersion;
731   int (*xClose)(sqlite3_file*);
732   int (*xRead)(sqlite3_file*, void*, int iAmt, sqlite3_int64 iOfst);
733   int (*xWrite)(sqlite3_file*, const void*, int iAmt, sqlite3_int64 iOfst);
734   int (*xTruncate)(sqlite3_file*, sqlite3_int64 size);
735   int (*xSync)(sqlite3_file*, int flags);
736   int (*xFileSize)(sqlite3_file*, sqlite3_int64 *pSize);
737   int (*xLock)(sqlite3_file*, int);
738   int (*xUnlock)(sqlite3_file*, int);
739   int (*xCheckReservedLock)(sqlite3_file*, int *pResOut);
740   int (*xFileControl)(sqlite3_file*, int op, void *pArg);
741   int (*xSectorSize)(sqlite3_file*);
742   int (*xDeviceCharacteristics)(sqlite3_file*);
743   /* Methods above are valid for version 1 */
744   int (*xShmMap)(sqlite3_file*, int iPg, int pgsz, int, void volatile**);
745   int (*xShmLock)(sqlite3_file*, int offset, int n, int flags);
746   void (*xShmBarrier)(sqlite3_file*);
747   int (*xShmUnmap)(sqlite3_file*, int deleteFlag);
748   /* Methods above are valid for version 2 */
749   int (*xFetch)(sqlite3_file*, sqlite3_int64 iOfst, int iAmt, void **pp);
750   int (*xUnfetch)(sqlite3_file*, sqlite3_int64 iOfst, void *p);
751   /* Methods above are valid for version 3 */
752   /* Additional methods may be added in future releases */
753753};
754754
755755/*
r31374r31375
778778** <li>[[SQLITE_FCNTL_CHUNK_SIZE]]
779779** The [SQLITE_FCNTL_CHUNK_SIZE] opcode is used to request that the VFS
780780** extends and truncates the database file in chunks of a size specified
781** by the user. The fourth argument to [sqlite3_file_control()] should
781** by the user. The fourth argument to [sqlite3_file_control()] should
782782** point to an integer (type int) containing the new chunk-size to use
783783** for the nominated database. Allocating database file space in large
784784** chunks (say 1MB at a time), may reduce file-system fragmentation and
r31374r31375
796796** <li>[[SQLITE_FCNTL_SYNC]]
797797** The [SQLITE_FCNTL_SYNC] opcode is generated internally by SQLite and
798798** sent to the VFS immediately before the xSync method is invoked on a
799** database file descriptor. Or, if the xSync method is not invoked
800** because the user has configured SQLite with
801** [PRAGMA synchronous | PRAGMA synchronous=OFF] it is invoked in place
799** database file descriptor. Or, if the xSync method is not invoked
800** because the user has configured SQLite with
801** [PRAGMA synchronous | PRAGMA synchronous=OFF] it is invoked in place
802802** of the xSync method. In most cases, the pointer argument passed with
803803** this file-control is NULL. However, if the database file is being synced
804804** as part of a multi-database commit, the argument points to a nul-terminated
805** string containing the transactions master-journal file name. VFSes that
806** do not need this signal should silently ignore this opcode. Applications
807** should not call [sqlite3_file_control()] with this opcode as doing so may
808** disrupt the operation of the specialized VFSes that do require it. 
805** string containing the transactions master-journal file name. VFSes that
806** do not need this signal should silently ignore this opcode. Applications
807** should not call [sqlite3_file_control()] with this opcode as doing so may
808** disrupt the operation of the specialized VFSes that do require it.
809809**
810810** <li>[[SQLITE_FCNTL_COMMIT_PHASETWO]]
811811** The [SQLITE_FCNTL_COMMIT_PHASETWO] opcode is generated internally by SQLite
812812** and sent to the VFS after a transaction has been committed immediately
813813** but before the database is unlocked. VFSes that do not need this signal
814814** should silently ignore this opcode. Applications should not call
815** [sqlite3_file_control()] with this opcode as doing so may disrupt the
816** operation of the specialized VFSes that do require it. 
815** [sqlite3_file_control()] with this opcode as doing so may disrupt the
816** operation of the specialized VFSes that do require it.
817817**
818818** <li>[[SQLITE_FCNTL_WIN32_AV_RETRY]]
819819** ^The [SQLITE_FCNTL_WIN32_AV_RETRY] opcode is used to configure automatic
r31374r31375
860860** <li>[[SQLITE_FCNTL_OVERWRITE]]
861861** ^The [SQLITE_FCNTL_OVERWRITE] opcode is invoked by SQLite after opening
862862** a write transaction to indicate that, unless it is rolled back for some
863** reason, the entire database file will be overwritten by the current
863** reason, the entire database file will be overwritten by the current
864864** transaction. This is used by VACUUM operations.
865865**
866866** <li>[[SQLITE_FCNTL_VFSNAME]]
867867** ^The [SQLITE_FCNTL_VFSNAME] opcode can be used to obtain the names of
868868** all [VFSes] in the VFS stack.  The names are of all VFS shims and the
869** final bottom-level VFS are written into memory obtained from
869** final bottom-level VFS are written into memory obtained from
870870** [sqlite3_malloc()] and the result is stored in the char* variable
871871** that the fourth parameter of [sqlite3_file_control()] points to.
872872** The caller is responsible for freeing the memory when done.  As with
r31374r31375
876876** is intended for diagnostic use only.
877877**
878878** <li>[[SQLITE_FCNTL_PRAGMA]]
879** ^Whenever a [PRAGMA] statement is parsed, an [SQLITE_FCNTL_PRAGMA]
879** ^Whenever a [PRAGMA] statement is parsed, an [SQLITE_FCNTL_PRAGMA]
880880** file control is sent to the open [sqlite3_file] object corresponding
881881** to the database file to which the pragma statement refers. ^The argument
882882** to the [SQLITE_FCNTL_PRAGMA] file control is an array of
r31374r31375
887887** of the char** argument point to a string obtained from [sqlite3_mprintf()]
888888** or the equivalent and that string will become the result of the pragma or
889889** the error message if the pragma fails. ^If the
890** [SQLITE_FCNTL_PRAGMA] file control returns [SQLITE_NOTFOUND], then normal
890** [SQLITE_FCNTL_PRAGMA] file control returns [SQLITE_NOTFOUND], then normal
891891** [PRAGMA] processing continues.  ^If the [SQLITE_FCNTL_PRAGMA]
892892** file control returns [SQLITE_OK], then the parser assumes that the
893893** VFS has handled the PRAGMA itself and the parser generates a no-op
r31374r31375
925925** The argument is a pointer to a value of type sqlite3_int64 that
926926** is an advisory maximum number of bytes in the file to memory map.  The
927927** pointer is overwritten with the old value.  The limit is not changed if
928** the value originally pointed to is negative, and so the current limit
928** the value originally pointed to is negative, and so the current limit
929929** can be queried by passing in a pointer to a negative number.  This
930930** file-control is used internally to implement [PRAGMA mmap_size].
931931**
r31374r31375
10271027** the [sqlite3_file] can safely store a pointer to the
10281028** filename if it needs to remember the filename for some reason.
10291029** If the zFilename parameter to xOpen is a NULL pointer then xOpen
1030** must invent its own temporary name for the file.  ^Whenever the
1030** must invent its own temporary name for the file.  ^Whenever the
10311031** xFilename parameter is NULL it will also be the case that the
10321032** flags parameter will include [SQLITE_OPEN_DELETEONCLOSE].
10331033**
10341034** The flags argument to xOpen() includes all bits set in
10351035** the flags argument to [sqlite3_open_v2()].  Or if [sqlite3_open()]
10361036** or [sqlite3_open16()] is used, then flags includes at least
1037** [SQLITE_OPEN_READWRITE] | [SQLITE_OPEN_CREATE].
1037** [SQLITE_OPEN_READWRITE] | [SQLITE_OPEN_CREATE].
10381038** If xOpen() opens a file read-only then it sets *pOutFlags to
10391039** include [SQLITE_OPEN_READONLY].  Other bits in *pOutFlags may be set.
10401040**
r31374r31375
10761076** ^The [SQLITE_OPEN_EXCLUSIVE] flag is always used in conjunction
10771077** with the [SQLITE_OPEN_CREATE] flag, which are both directly
10781078** analogous to the O_EXCL and O_CREAT flags of the POSIX open()
1079** API.  The SQLITE_OPEN_EXCLUSIVE flag, when paired with the
1079** API.  The SQLITE_OPEN_EXCLUSIVE flag, when paired with the
10801080** SQLITE_OPEN_CREATE, is used to indicate that file should always
10811081** be created, and that it is an error if it already exists.
1082** It is <i>not</i> used to indicate the file should be opened
1082** It is <i>not</i> used to indicate the file should be opened
10831083** for exclusive access.
10841084**
10851085** ^At least szOsFile bytes of memory are allocated by SQLite
r31374r31375
11171117** method returns a Julian Day Number for the current date and time as
11181118** a floating point value.
11191119** ^The xCurrentTimeInt64() method returns, as an integer, the Julian
1120** Day Number multiplied by 86400000 (the number of milliseconds in
1121** a 24-hour day). 
1120** Day Number multiplied by 86400000 (the number of milliseconds in
1121** a 24-hour day).
11221122** ^SQLite will use the xCurrentTimeInt64() method to get the current
1123** date and time if that method is available (if iVersion is 2 or
1123** date and time if that method is available (if iVersion is 2 or
11241124** greater and the function pointer is not NULL) and will fall back
11251125** to xCurrentTime() if xCurrentTimeInt64() is unavailable.
11261126**
11271127** ^The xSetSystemCall(), xGetSystemCall(), and xNestSystemCall() interfaces
11281128** are not used by the SQLite core.  These optional interfaces are provided
1129** by some VFSes to facilitate testing of the VFS code. By overriding
1129** by some VFSes to facilitate testing of the VFS code. By overriding
11301130** system calls with functions under its control, a test program can
11311131** simulate faults and error conditions that would otherwise be difficult
11321132** or impossible to induce.  The set of system calls that can be overridden
r31374r31375
11391139typedef struct sqlite3_vfs sqlite3_vfs;
11401140typedef void (*sqlite3_syscall_ptr)(void);
11411141struct sqlite3_vfs {
1142  int iVersion;            /* Structure version number (currently 3) */
1143  int szOsFile;            /* Size of subclassed sqlite3_file */
1144  int mxPathname;          /* Maximum file pathname length */
1145  sqlite3_vfs *pNext;      /* Next registered VFS */
1146  const char *zName;       /* Name of this virtual file system */
1147  void *pAppData;          /* Pointer to application-specific data */
1148  int (*xOpen)(sqlite3_vfs*, const char *zName, sqlite3_file*,
1149               int flags, int *pOutFlags);
1150  int (*xDelete)(sqlite3_vfs*, const char *zName, int syncDir);
1151  int (*xAccess)(sqlite3_vfs*, const char *zName, int flags, int *pResOut);
1152  int (*xFullPathname)(sqlite3_vfs*, const char *zName, int nOut, char *zOut);
1153  void *(*xDlOpen)(sqlite3_vfs*, const char *zFilename);
1154  void (*xDlError)(sqlite3_vfs*, int nByte, char *zErrMsg);
1155  void (*(*xDlSym)(sqlite3_vfs*,void*, const char *zSymbol))(void);
1156  void (*xDlClose)(sqlite3_vfs*, void*);
1157  int (*xRandomness)(sqlite3_vfs*, int nByte, char *zOut);
1158  int (*xSleep)(sqlite3_vfs*, int microseconds);
1159  int (*xCurrentTime)(sqlite3_vfs*, double*);
1160  int (*xGetLastError)(sqlite3_vfs*, int, char *);
1161  /*
1162  ** The methods above are in version 1 of the sqlite_vfs object
1163  ** definition.  Those that follow are added in version 2 or later
1164  */
1165  int (*xCurrentTimeInt64)(sqlite3_vfs*, sqlite3_int64*);
1166  /*
1167  ** The methods above are in versions 1 and 2 of the sqlite_vfs object.
1168  ** Those below are for version 3 and greater.
1169  */
1170  int (*xSetSystemCall)(sqlite3_vfs*, const char *zName, sqlite3_syscall_ptr);
1171  sqlite3_syscall_ptr (*xGetSystemCall)(sqlite3_vfs*, const char *zName);
1172  const char *(*xNextSystemCall)(sqlite3_vfs*, const char *zName);
1173  /*
1174  ** The methods above are in versions 1 through 3 of the sqlite_vfs object.
1175  ** New fields may be appended in figure versions.  The iVersion
1176  ** value will increment whenever this happens.
1177  */
1142   int iVersion;            /* Structure version number (currently 3) */
1143   int szOsFile;            /* Size of subclassed sqlite3_file */
1144   int mxPathname;          /* Maximum file pathname length */
1145   sqlite3_vfs *pNext;      /* Next registered VFS */
1146   const char *zName;       /* Name of this virtual file system */
1147   void *pAppData;          /* Pointer to application-specific data */
1148   int (*xOpen)(sqlite3_vfs*, const char *zName, sqlite3_file*,
1149            int flags, int *pOutFlags);
1150   int (*xDelete)(sqlite3_vfs*, const char *zName, int syncDir);
1151   int (*xAccess)(sqlite3_vfs*, const char *zName, int flags, int *pResOut);
1152   int (*xFullPathname)(sqlite3_vfs*, const char *zName, int nOut, char *zOut);
1153   void *(*xDlOpen)(sqlite3_vfs*, const char *zFilename);
1154   void (*xDlError)(sqlite3_vfs*, int nByte, char *zErrMsg);
1155   void (*(*xDlSym)(sqlite3_vfs*,void*, const char *zSymbol))(void);
1156   void (*xDlClose)(sqlite3_vfs*, void*);
1157   int (*xRandomness)(sqlite3_vfs*, int nByte, char *zOut);
1158   int (*xSleep)(sqlite3_vfs*, int microseconds);
1159   int (*xCurrentTime)(sqlite3_vfs*, double*);
1160   int (*xGetLastError)(sqlite3_vfs*, int, char *);
1161   /*
1162   ** The methods above are in version 1 of the sqlite_vfs object
1163   ** definition.  Those that follow are added in version 2 or later
1164   */
1165   int (*xCurrentTimeInt64)(sqlite3_vfs*, sqlite3_int64*);
1166   /*
1167   ** The methods above are in versions 1 and 2 of the sqlite_vfs object.
1168   ** Those below are for version 3 and greater.
1169   */
1170   int (*xSetSystemCall)(sqlite3_vfs*, const char *zName, sqlite3_syscall_ptr);
1171   sqlite3_syscall_ptr (*xGetSystemCall)(sqlite3_vfs*, const char *zName);
1172   const char *(*xNextSystemCall)(sqlite3_vfs*, const char *zName);
1173   /*
1174   ** The methods above are in versions 1 through 3 of the sqlite_vfs object.
1175   ** New fields may be appended in figure versions.  The iVersion
1176   ** value will increment whenever this happens.
1177   */
11781178};
11791179
11801180/*
r31374r31375
12171217** </ul>
12181218**
12191219** When unlocking, the same SHARED or EXCLUSIVE flag must be supplied as
1220** was given no the corresponding lock. 
1220** was given no the corresponding lock.
12211221**
12221222** The xShmLock method can transition between unlocked and SHARED or
12231223** between unlocked and EXCLUSIVE.  It cannot transition between SHARED
r31374r31375
13591359** [database connection] (specified in the first argument).
13601360**
13611361** The second argument to sqlite3_db_config(D,V,...)  is the
1362** [SQLITE_DBCONFIG_LOOKASIDE | configuration verb] - an integer code
1362** [SQLITE_DBCONFIG_LOOKASIDE | configuration verb] - an integer code
13631363** that indicates what aspect of the [database connection] is being configured.
13641364** Subsequent arguments vary depending on the configuration verb.
13651365**
r31374r31375
13771377** This object is used in only one place in the SQLite interface.
13781378** A pointer to an instance of this object is the argument to
13791379** [sqlite3_config()] when the configuration option is
1380** [SQLITE_CONFIG_MALLOC] or [SQLITE_CONFIG_GETMALLOC]. 
1380** [SQLITE_CONFIG_MALLOC] or [SQLITE_CONFIG_GETMALLOC].
13811381** By creating an instance of this object
13821382** and passing it to [sqlite3_config]([SQLITE_CONFIG_MALLOC])
13831383** during configuration, an application can specify an alternative
r31374r31375
14071407** allocators round up memory allocations at least to the next multiple
14081408** of 8.  Some allocators round up to a larger multiple or to a power of 2.
14091409** Every memory allocation request coming in through [sqlite3_malloc()]
1410** or [sqlite3_realloc()] first calls xRoundup.  If xRoundup returns 0,
1410** or [sqlite3_realloc()] first calls xRoundup.  If xRoundup returns 0,
14111411** that causes the corresponding memory allocation to fail.
14121412**
14131413** The xInit method initializes the memory allocator.  For example,
r31374r31375
14331433*/
14341434typedef struct sqlite3_mem_methods sqlite3_mem_methods;
14351435struct sqlite3_mem_methods {
1436  void *(*xMalloc)(int);         /* Memory allocation function */
1437  void (*xFree)(void*);          /* Free a prior allocation */
1438  void *(*xRealloc)(void*,int);  /* Resize an allocation */
1439  int (*xSize)(void*);           /* Return the size of an allocation */
1440  int (*xRoundup)(int);          /* Round up request size to allocation size */
1441  int (*xInit)(void*);           /* Initialize the memory allocator */
1442  void (*xShutdown)(void*);      /* Deinitialize the memory allocator */
1443  void *pAppData;                /* Argument to xInit() and xShutdown() */
1436   void *(*xMalloc)(int);         /* Memory allocation function */
1437   void (*xFree)(void*);          /* Free a prior allocation */
1438   void *(*xRealloc)(void*,int);  /* Resize an allocation */
1439   int (*xSize)(void*);           /* Return the size of an allocation */
1440   int (*xRoundup)(int);          /* Round up request size to allocation size */
1441   int (*xInit)(void*);           /* Initialize the memory allocator */
1442   void (*xShutdown)(void*);      /* Deinitialize the memory allocator */
1443   void *pAppData;                /* Argument to xInit() and xShutdown() */
14441444};
14451445
14461446/*
r31374r31375
14651465** by a single thread.   ^If SQLite is compiled with
14661466** the [SQLITE_THREADSAFE | SQLITE_THREADSAFE=0] compile-time option then
14671467** it is not possible to change the [threading mode] from its default
1468** value of Single-thread and so [sqlite3_config()] will return
1468** value of Single-thread and so [sqlite3_config()] will return
14691469** [SQLITE_ERROR] if called with the SQLITE_CONFIG_SINGLETHREAD
14701470** configuration option.</dd>
14711471**
r31374r31375
15161516** tracks memory usage, for example. </dd>
15171517**
15181518** [[SQLITE_CONFIG_MEMSTATUS]] <dt>SQLITE_CONFIG_MEMSTATUS</dt>
1519** <dd> ^This option takes single argument of type int, interpreted as a
1520** boolean, which enables or disables the collection of memory allocation
1521** statistics. ^(When memory allocation statistics are disabled, the
1519** <dd> ^This option takes single argument of type int, interpreted as a
1520** boolean, which enables or disables the collection of memory allocation
1521** statistics. ^(When memory allocation statistics are disabled, the
15221522** following SQLite interfaces become non-operational:
15231523**   <ul>
15241524**   <li> [sqlite3_memory_used()]
r31374r31375
15441544** N should be set to twice the expected maximum number of threads.
15451545** ^SQLite will never require a scratch buffer that is more than 6
15461546** times the database page size. ^If SQLite needs needs additional
1547** scratch memory beyond what is provided by this configuration option, then
1547** scratch memory beyond what is provided by this configuration option, then
15481548** [sqlite3_malloc()] will be used to obtain the memory needed.</dd>
15491549**
15501550** [[SQLITE_CONFIG_PAGECACHE]] <dt>SQLITE_CONFIG_PAGECACHE</dt>
15511551** <dd> ^This option specifies a static memory buffer that SQLite can use for
1552** the database page cache with the default page cache implementation. 
1552** the database page cache with the default page cache implementation.
15531553** This configuration should not be used if an application-define page
15541554** cache implementation is loaded using the SQLITE_CONFIG_PCACHE2 option.
15551555** There are three arguments to this option: A pointer to 8-byte aligned
r31374r31375
16351635** <dd> The SQLITE_CONFIG_LOG option is used to configure the SQLite
16361636** global [error log].
16371637** (^The SQLITE_CONFIG_LOG option takes two arguments: a pointer to a
1638** function with a call signature of void(*)(void*,int,const char*),
1638** function with a call signature of void(*)(void*,int,const char*),
16391639** and a pointer to void. ^If the function pointer is not NULL, it is
16401640** invoked by [sqlite3_log()] to process each logging event.  ^If the
16411641** function pointer is NULL, the [sqlite3_log()] interface becomes a no-op.
r31374r31375
17321732#define SQLITE_CONFIG_MEMSTATUS     9  /* boolean */
17331733#define SQLITE_CONFIG_MUTEX        10  /* sqlite3_mutex_methods* */
17341734#define SQLITE_CONFIG_GETMUTEX     11  /* sqlite3_mutex_methods* */
1735/* previously SQLITE_CONFIG_CHUNKALLOC 12 which is now unused. */
1735/* previously SQLITE_CONFIG_CHUNKALLOC 12 which is now unused. */
17361736#define SQLITE_CONFIG_LOOKASIDE    13  /* int int */
17371737#define SQLITE_CONFIG_PCACHE       14  /* no-op */
17381738#define SQLITE_CONFIG_GETPCACHE    15  /* no-op */
r31374r31375
17601760**
17611761** <dl>
17621762** <dt>SQLITE_DBCONFIG_LOOKASIDE</dt>
1763** <dd> ^This option takes three additional arguments that determine the
1763** <dd> ^This option takes three additional arguments that determine the
17641764** [lookaside memory allocator] configuration for the [database connection].
17651765** ^The first argument (the third parameter to [sqlite3_db_config()] is a
17661766** pointer to a memory buffer to use for lookaside memory.
r31374r31375
17781778** when the "current value" returned by
17791779** [sqlite3_db_status](D,[SQLITE_CONFIG_LOOKASIDE],...) is zero.
17801780** Any attempt to change the lookaside memory configuration when lookaside
1781** memory is in use leaves the configuration unchanged and returns
1781** memory is in use leaves the configuration unchanged and returns
17821782** [SQLITE_BUSY].)^</dd>
17831783**
17841784** <dt>SQLITE_DBCONFIG_ENABLE_FKEY</dt>
r31374r31375
18281828** the table has a column of type [INTEGER PRIMARY KEY] then that column
18291829** is another alias for the rowid.
18301830**
1831** ^The sqlite3_last_insert_rowid(D) interface returns the [rowid] of the
1831** ^The sqlite3_last_insert_rowid(D) interface returns the [rowid] of the
18321832** most recent successful [INSERT] into a rowid table or [virtual table]
18331833** on database connection D.
18341834** ^Inserts into [WITHOUT ROWID] tables are not recorded.
18351835** ^If no successful [INSERT]s into rowid tables
1836** have ever occurred on the database connection D,
1836** have ever occurred on the database connection D,
18371837** then sqlite3_last_insert_rowid(D) returns zero.
18381838**
18391839** ^(If an [INSERT] occurs within a trigger or within a [virtual table]
18401840** method, then this routine will return the [rowid] of the inserted
18411841** row as long as the trigger or virtual table method is running.
1842** But once the trigger or virtual table method ends, the value returned
1842** But once the trigger or virtual table method ends, the value returned
18431843** by this routine reverts to what it was before the trigger or virtual
18441844** table method began.)^
18451845**
r31374r31375
18901890** mechanisms do not count as direct row changes.)^
18911891**
18921892** A "trigger context" is a scope of execution that begins and
1893** ends with the script of a [CREATE TRIGGER | trigger].
1893** ends with the script of a [CREATE TRIGGER | trigger].
18941894** Most SQL statements are
18951895** evaluated outside of any trigger.  This is the "top level"
18961896** trigger context.  If a trigger fires from the top level, a
r31374r31375
19331933** the count does not include changes used to implement [REPLACE] constraints,
19341934** do rollbacks or ABORT processing, or [DROP TABLE] processing.  The
19351935** count does not include rows of views that fire an [INSTEAD OF trigger],
1936** though if the INSTEAD OF trigger makes changes of its own, those changes
1936** though if the INSTEAD OF trigger makes changes of its own, those changes
19371937** are counted.)^
19381938** ^The sqlite3_total_changes() function counts the changes as soon as
19391939** the statement that makes them is completed (when the statement handle
r31374r31375
19731973**
19741974** ^The sqlite3_interrupt(D) call is in effect until all currently running
19751975** SQL statements on [database connection] D complete.  ^Any new SQL statements
1976** that are started after the sqlite3_interrupt() call and before the
1976** that are started after the sqlite3_interrupt() call and before the
19771977** running statements reaches zero are interrupted as if they had been
19781978** running prior to the sqlite3_interrupt() call.  ^New SQL statements
19791979** that are started after the running statement count reaches zero are
r31374r31375
20082008** ^These routines do not parse the SQL statements thus
20092009** will not detect syntactically incorrect SQL.
20102010**
2011** ^(If SQLite has not been initialized using [sqlite3_initialize()] prior
2011** ^(If SQLite has not been initialized using [sqlite3_initialize()] prior
20122012** to invoking sqlite3_complete16() then sqlite3_initialize() is invoked
20132013** automatically by sqlite3_complete16().  If that initialization fails,
20142014** then the return value from sqlite3_complete16() will be non-zero
r31374r31375
20832083** The busy callback should not take any actions which modify the
20842084** database connection that invoked the busy handler.  Any such actions
20852085** result in undefined behavior.
2086**
2086**
20872087** A busy handler must not close the database connection
20882088** or [prepared statement] that invoked the busy handler.
20892089*/
r31374r31375
21822182** [sqlite3_errmsg()].
21832183*/
21842184SQLITE_API int sqlite3_get_table(
2185  sqlite3 *db,          /* An open database */
2186  const char *zSql,     /* SQL to be evaluated */
2187  char ***pazResult,    /* Results of the query */
2188  int *pnRow,           /* Number of result rows written here */
2189  int *pnColumn,        /* Number of result columns written here */
2190  char **pzErrmsg       /* Error msg written here */
2185   sqlite3 *db,          /* An open database */
2186   const char *zSql,     /* SQL to be evaluated */
2187   char ***pazResult,    /* Results of the query */
2188   int *pnRow,           /* Number of result rows written here */
2189   int *pnColumn,        /* Number of result columns written here */
2190   char **pzErrmsg       /* Error msg written here */
21912191);
21922192SQLITE_API void sqlite3_free_table(char **result);
21932193
r31374r31375
24352435** requested is ok.  ^When the callback returns [SQLITE_DENY], the
24362436** [sqlite3_prepare_v2()] or equivalent call that triggered the
24372437** authorizer will fail with an error message explaining that
2438** access is denied.
2438** access is denied.
24392439**
24402440** ^The first parameter to the authorizer callback is a copy of the third
24412441** parameter to the sqlite3_set_authorizer() interface. ^The second parameter
r31374r31375
24822482** database connections for the meaning of "modify" in this paragraph.
24832483**
24842484** ^When [sqlite3_prepare_v2()] is used to prepare a statement, the
2485** statement might be re-prepared during [sqlite3_step()] due to a
2485** statement might be re-prepared during [sqlite3_step()] due to a
24862486** schema change.  Hence, the application should ensure that the
24872487** correct authorizer callback remains in place during the [sqlite3_step()].
24882488**
r31374r31375
24932493** sqlite3_prepare_v2() to reprepare a statement after a schema change.
24942494*/
24952495SQLITE_API int sqlite3_set_authorizer(
2496  sqlite3*,
2497  int (*xAuth)(void*,int,const char*,const char*,const char*,const char*),
2498  void *pUserData
2496   sqlite3*,
2497   int (*xAuth)(void*,int,const char*,const char*,const char*,const char*),
2498   void *pUserData
24992499);
25002500
25012501/*
r31374r31375
25982598*/
25992599SQLITE_API void *sqlite3_trace(sqlite3*, void(*xTrace)(void*,const char*), void*);
26002600SQLITE_API SQLITE_EXPERIMENTAL void *sqlite3_profile(sqlite3*,
2601   void(*xProfile)(void*,const char*,sqlite3_uint64), void*);
2601   void(*xProfile)(void*,const char*,sqlite3_uint64), void*);
26022602
26032603/*
26042604** CAPI3REF: Query Progress Callbacks
r31374r31375
26092609** database connection D.  An example use for this
26102610** interface is to keep a GUI updated during a large query.
26112611**
2612** ^The parameter P is passed through as the only parameter to the
2613** callback function X.  ^The parameter N is the approximate number of
2612** ^The parameter P is passed through as the only parameter to the
2613** callback function X.  ^The parameter N is the approximate number of
26142614** [virtual machine instructions] that are evaluated between successive
26152615** invocations of the callback X.  ^If N is less than one then the progress
26162616** handler is disabled.
r31374r31375
26362636/*
26372637** CAPI3REF: Opening A New Database Connection
26382638**
2639** ^These routines open an SQLite database file as specified by the
2639** ^These routines open an SQLite database file as specified by the
26402640** filename argument. ^The filename argument is interpreted as UTF-8 for
26412641** sqlite3_open() and sqlite3_open_v2() and as UTF-16 in the native byte
26422642** order for sqlite3_open16(). ^(A [database connection] handle is usually
r31374r31375
26612661** except that it accepts two additional parameters for additional control
26622662** over the new database connection.  ^(The flags parameter to
26632663** sqlite3_open_v2() can take one of
2664** the following three values, optionally combined with the
2664** the following three values, optionally combined with the
26652665** [SQLITE_OPEN_NOMUTEX], [SQLITE_OPEN_FULLMUTEX], [SQLITE_OPEN_SHAREDCACHE],
26662666** [SQLITE_OPEN_PRIVATECACHE], and/or [SQLITE_OPEN_URI] flags:)^
26672667**
r31374r31375
27292729** information.
27302730**
27312731** URI filenames are parsed according to RFC 3986. ^If the URI contains an
2732** authority, then it must be either an empty string or the string
2733** "localhost". ^If the authority is not an empty string or "localhost", an
2734** error is returned to the caller. ^The fragment component of a URI, if
2732** authority, then it must be either an empty string or the string
2733** "localhost". ^If the authority is not an empty string or "localhost", an
2734** error is returned to the caller. ^The fragment component of a URI, if
27352735** present, is ignored.
27362736**
27372737** ^SQLite uses the path component of the URI as the name of the disk file
2738** which contains the database. ^If the path begins with a '/' character,
2739** then it is interpreted as an absolute path. ^If the path does not begin
2738** which contains the database. ^If the path begins with a '/' character,
2739** then it is interpreted as an absolute path. ^If the path does not begin
27402740** with a '/' (meaning that the authority section is omitted from the URI)
2741** then the path is interpreted as a relative path.
2742** ^On windows, the first component of an absolute path
2741** then the path is interpreted as a relative path.
2742** ^On windows, the first component of an absolute path
27432743** is a drive specification (e.g. "C:").
27442744**
27452745** [[core URI query parameters]]
r31374r31375
27582758**
27592759**   <li> <b>mode</b>: ^(The mode parameter may be set to either "ro", "rw",
27602760**     "rwc", or "memory". Attempting to set it to any other value is
2761**     an error)^.
2762**     ^If "ro" is specified, then the database is opened for read-only
2763**     access, just as if the [SQLITE_OPEN_READONLY] flag had been set in the
2764**     third argument to sqlite3_open_v2(). ^If the mode option is set to
2765**     "rw", then the database is opened for read-write (but not create)
2766**     access, as if SQLITE_OPEN_READWRITE (but not SQLITE_OPEN_CREATE) had
2767**     been set. ^Value "rwc" is equivalent to setting both
2761**     an error)^.
2762**     ^If "ro" is specified, then the database is opened for read-only
2763**     access, just as if the [SQLITE_OPEN_READONLY] flag had been set in the
2764**     third argument to sqlite3_open_v2(). ^If the mode option is set to
2765**     "rw", then the database is opened for read-write (but not create)
2766**     access, as if SQLITE_OPEN_READWRITE (but not SQLITE_OPEN_CREATE) had
2767**     been set. ^Value "rwc" is equivalent to setting both
27682768**     SQLITE_OPEN_READWRITE and SQLITE_OPEN_CREATE.  ^If the mode option is
27692769**     set to "memory" then a pure [in-memory database] that never reads
27702770**     or writes from disk is used. ^It is an error to specify a value for
r31374r31375
27742774**   <li> <b>cache</b>: ^The cache parameter may be set to either "shared" or
27752775**     "private". ^Setting it to "shared" is equivalent to setting the
27762776**     SQLITE_OPEN_SHAREDCACHE bit in the flags argument passed to
2777**     sqlite3_open_v2(). ^Setting the cache parameter to "private" is
2777**     sqlite3_open_v2(). ^Setting the cache parameter to "private" is
27782778**     equivalent to setting the SQLITE_OPEN_PRIVATECACHE bit.
27792779**     ^If sqlite3_open_v2() is used and the "cache" parameter is present in
27802780**     a URI filename, its value overrides any behavior requested by setting
r31374r31375
27902790**
27912791** <table border="1" align=center cellpadding=5>
27922792** <tr><th> URI filenames <th> Results
2793** <tr><td> file:data.db <td>
2793** <tr><td> file:data.db <td>
27942794**          Open the file "data.db" in the current directory.
27952795** <tr><td> file:/home/fred/data.db<br>
2796**          file:///home/fred/data.db <br>
2797**          file://localhost/home/fred/data.db <br> <td>
2796**          file:///home/fred/data.db <br>
2797**          file://localhost/home/fred/data.db <br> <td>
27982798**          Open the database file "/home/fred/data.db".
2799** <tr><td> file://darkstar/home/fred/data.db <td>
2799** <tr><td> file://darkstar/home/fred/data.db <td>
28002800**          An error. "darkstar" is not a recognized authority.
2801** <tr><td style="white-space:nowrap">
2801** <tr><td style="white-space:nowrap">
28022802**          file:///C:/Documents%20and%20Settings/fred/Desktop/data.db
28032803**     <td> Windows only: Open the file "data.db" on fred's desktop on drive
2804**          C:. Note that the %20 escaping in this example is not strictly
2804**          C:. Note that the %20 escaping in this example is not strictly
28052805**          necessary - space characters can be used literally
28062806**          in URI filenames.
2807** <tr><td> file:data.db?mode=ro&cache=private <td>
2807** <tr><td> file:data.db?mode=ro&cache=private <td>
28082808**          Open file "data.db" in the current directory for read-only access.
28092809**          Regardless of whether or not shared-cache mode is enabled by
28102810**          default, use a private cache.
28112811** <tr><td> file:/home/fred/data.db?vfs=unix-nolock <td>
28122812**          Open file "/home/fred/data.db". Use the special VFS "unix-nolock".
2813** <tr><td> file:data.db?mode=readonly <td>
2813** <tr><td> file:data.db?mode=readonly <td>
28142814**          An error. "readonly" is not a valid option for the "mode" parameter.
28152815** </table>
28162816**
28172817** ^URI hexadecimal escape sequences (%HH) are supported within the path and
28182818** query components of a URI. A hexadecimal escape sequence consists of a
2819** percent sign - "%" - followed by exactly two hexadecimal digits
2819** percent sign - "%" - followed by exactly two hexadecimal digits
28202820** specifying an octet value. ^Before the path or query components of a
2821** URI filename are interpreted, they are encoded using UTF-8 and all
2821** URI filename are interpreted, they are encoded using UTF-8 and all
28222822** hexadecimal escape sequences replaced by a single byte containing the
28232823** corresponding octet. If this process generates an invalid UTF-8 encoding,
28242824** the results are undefined.
r31374r31375
28362836** See also: [sqlite3_temp_directory]
28372837*/
28382838SQLITE_API int sqlite3_open(
2839  const char *filename,   /* Database filename (UTF-8) */
2840  sqlite3 **ppDb          /* OUT: SQLite db handle */
2839   const char *filename,   /* Database filename (UTF-8) */
2840   sqlite3 **ppDb          /* OUT: SQLite db handle */
28412841);
28422842SQLITE_API int sqlite3_open16(
2843  const void *filename,   /* Database filename (UTF-16) */
2844  sqlite3 **ppDb          /* OUT: SQLite db handle */
2843   const void *filename,   /* Database filename (UTF-16) */
2844   sqlite3 **ppDb          /* OUT: SQLite db handle */
28452845);
28462846SQLITE_API int sqlite3_open_v2(
2847  const char *filename,   /* Database filename (UTF-8) */
2848  sqlite3 **ppDb,         /* OUT: SQLite db handle */
2849  int flags,              /* Flags */
2850  const char *zVfs        /* Name of VFS module to use */
2847   const char *filename,   /* Database filename (UTF-8) */
2848   sqlite3 **ppDb,         /* OUT: SQLite db handle */
2849   int flags,              /* Flags */
2850   const char *zVfs        /* Name of VFS module to use */
28512851);
28522852
28532853/*
28542854** CAPI3REF: Obtain Values For URI Parameters
28552855**
28562856** These are utility routines, useful to VFS implementations, that check
2857** to see if a database file was a URI that contained a specific query
2857** to see if a database file was a URI that contained a specific query
28582858** parameter, and if so obtains the value of that query parameter.
28592859**
2860** If F is the database filename pointer passed into the xOpen() method of
2861** a VFS implementation when the flags parameter to xOpen() has one or
2860** If F is the database filename pointer passed into the xOpen() method of
2861** a VFS implementation when the flags parameter to xOpen() has one or
28622862** more of the [SQLITE_OPEN_URI] or [SQLITE_OPEN_MAIN_DB] bits set and
28632863** P is the name of the query parameter, then
28642864** sqlite3_uri_parameter(F,P) returns the value of the P
2865** parameter if it exists or a NULL pointer if P does not appear as a
2865** parameter if it exists or a NULL pointer if P does not appear as a
28662866** query parameter on F.  If P is a query parameter of F
28672867** has no explicit value, then sqlite3_uri_parameter(F,P) returns
28682868** a pointer to an empty string.
r31374r31375
28712871** parameter and returns true (1) or false (0) according to the value
28722872** of P.  The sqlite3_uri_boolean(F,P,B) routine returns true (1) if the
28732873** value of query parameter P is one of "yes", "true", or "on" in any
2874** case or if the value begins with a non-zero number.  The
2874** case or if the value begins with a non-zero number.  The
28752875** sqlite3_uri_boolean(F,P,B) routines returns false (0) if the value of
28762876** query parameter P is one of "no", "false", or "off" in any case or
28772877** if the value begins with a numeric zero.  If P is not a query
r31374r31375
28822882** 64-bit signed integer and returns that integer, or D if P does not
28832883** exist.  If the value of P is something other than an integer, then
28842884** zero is returned.
2885**
2885**
28862886** If F is a NULL pointer, then sqlite3_uri_parameter(F,P) returns NULL and
28872887** sqlite3_uri_boolean(F,P,B) returns B.  If F is not a NULL pointer and
28882888** is not a database file pathname pointer that SQLite passed into the xOpen
r31374r31375
29022902** associated with a [database connection]. If a prior API call failed
29032903** but the most recent API call succeeded, the return value from
29042904** sqlite3_errcode() is undefined.  ^The sqlite3_extended_errcode()
2905** interface is the same except that it always returns the
2905** interface is the same except that it always returns the
29062906** [extended result code] even when extended result codes are
29072907** disabled.
29082908**
r31374r31375
29752975** new limit for that construct.)^
29762976**
29772977** ^If the new limit is a negative number, the limit is unchanged.
2978** ^(For each limit category SQLITE_LIMIT_<i>NAME</i> there is a
2978** ^(For each limit category SQLITE_LIMIT_<i>NAME</i> there is a
29792979** [limits | hard upper bound]
29802980** set at compile-time by a C preprocessor macro called
29812981** [limits | SQLITE_MAX_<i>NAME</i>].
r31374r31375
29832983** ^Attempts to increase a limit above its hard upper bound are
29842984** silently truncated to the hard upper bound.
29852985**
2986** ^Regardless of whether or not the limit was changed, the
2986** ^Regardless of whether or not the limit was changed, the
29872987** [sqlite3_limit()] interface returns the prior value of the limit.
29882988** ^Hence, to find the current value of a limit without changing it,
29892989** simply invoke this interface with the third parameter set to -1.
r31374r31375
31383138** </li>
31393139**
31403140** <li>
3141** ^If the specific value bound to [parameter | host parameter] in the
3141** ^If the specific value bound to [parameter | host parameter] in the
31423142** WHERE clause might influence the choice of query plan for a statement,
3143** then the statement will be automatically recompiled, as if there had been
3143** then the statement will be automatically recompiled, as if there had been
31443144** a schema change, on the first  [sqlite3_step()] call following any change
3145** to the [sqlite3_bind_text | bindings] of that [parameter].
3146** ^The specific value of WHERE-clause [parameter] might influence the
3145** to the [sqlite3_bind_text | bindings] of that [parameter].
3146** ^The specific value of WHERE-clause [parameter] might influence the
31473147** choice of query plan if the parameter is the left-hand side of a [LIKE]
31483148** or [GLOB] operator or if the parameter is compared to an indexed column
31493149** and the [SQLITE_ENABLE_STAT3] compile-time option is enabled.
r31374r31375
31513151** </ol>
31523152*/
31533153SQLITE_API int sqlite3_prepare(
3154  sqlite3 *db,            /* Database handle */
3155  const char *zSql,       /* SQL statement, UTF-8 encoded */
3156  int nByte,              /* Maximum length of zSql in bytes. */
3157  sqlite3_stmt **ppStmt,  /* OUT: Statement handle */
3158  const char **pzTail     /* OUT: Pointer to unused portion of zSql */
3154   sqlite3 *db,            /* Database handle */
3155   const char *zSql,       /* SQL statement, UTF-8 encoded */
3156   int nByte,              /* Maximum length of zSql in bytes. */
3157   sqlite3_stmt **ppStmt,  /* OUT: Statement handle */
3158   const char **pzTail     /* OUT: Pointer to unused portion of zSql */
31593159);
31603160SQLITE_API int sqlite3_prepare_v2(
3161  sqlite3 *db,            /* Database handle */
3162  const char *zSql,       /* SQL statement, UTF-8 encoded */
3163  int nByte,              /* Maximum length of zSql in bytes. */
3164  sqlite3_stmt **ppStmt,  /* OUT: Statement handle */
3165  const char **pzTail     /* OUT: Pointer to unused portion of zSql */
3161   sqlite3 *db,            /* Database handle */
3162   const char *zSql,       /* SQL statement, UTF-8 encoded */
3163   int nByte,              /* Maximum length of zSql in bytes. */
3164   sqlite3_stmt **ppStmt,  /* OUT: Statement handle */
3165   const char **pzTail     /* OUT: Pointer to unused portion of zSql */
31663166);
31673167SQLITE_API int sqlite3_prepare16(
3168  sqlite3 *db,            /* Database handle */
3169  const void *zSql,       /* SQL statement, UTF-16 encoded */
3170  int nByte,              /* Maximum length of zSql in bytes. */
3171  sqlite3_stmt **ppStmt,  /* OUT: Statement handle */
3172  const void **pzTail     /* OUT: Pointer to unused portion of zSql */
3168   sqlite3 *db,            /* Database handle */
3169   const void *zSql,       /* SQL statement, UTF-16 encoded */
3170   int nByte,              /* Maximum length of zSql in bytes. */
3171   sqlite3_stmt **ppStmt,  /* OUT: Statement handle */
3172   const void **pzTail     /* OUT: Pointer to unused portion of zSql */
31733173);
31743174SQLITE_API int sqlite3_prepare16_v2(
3175  sqlite3 *db,            /* Database handle */
3176  const void *zSql,       /* SQL statement, UTF-16 encoded */
3177  int nByte,              /* Maximum length of zSql in bytes. */
3178  sqlite3_stmt **ppStmt,  /* OUT: Statement handle */
3179  const void **pzTail     /* OUT: Pointer to unused portion of zSql */
3175   sqlite3 *db,            /* Database handle */
3176   const void *zSql,       /* SQL statement, UTF-16 encoded */
3177   int nByte,              /* Maximum length of zSql in bytes. */
3178   sqlite3_stmt **ppStmt,  /* OUT: Statement handle */
3179   const void **pzTail     /* OUT: Pointer to unused portion of zSql */
31803180);
31813181
31823182/*
r31374r31375
31963196** the content of the database file.
31973197**
31983198** Note that [application-defined SQL functions] or
3199** [virtual tables] might change the database indirectly as a side effect. 
3200** ^(For example, if an application defines a function "eval()" that
3199** [virtual tables] might change the database indirectly as a side effect.
3200** ^(For example, if an application defines a function "eval()" that
32013201** calls [sqlite3_exec()], then the following SQL statement would
32023202** change the database file through side-effects:
32033203**
r31374r31375
32113211** ^Transaction control statements such as [BEGIN], [COMMIT], [ROLLBACK],
32123212** [SAVEPOINT], and [RELEASE] cause sqlite3_stmt_readonly() to return true,
32133213** since the statements themselves do not actually modify the database but
3214** rather they control the timing of when other statements modify the
3214** rather they control the timing of when other statements modify the
32153215** database.  ^The [ATTACH] and [DETACH] statements also cause
32163216** sqlite3_stmt_readonly() to return true since, while those statements
3217** change the configuration of a database connection, they do not make
3217** change the configuration of a database connection, they do not make
32183218** changes to the content of the database files on disk.
32193219*/
32203220SQLITE_API int sqlite3_stmt_readonly(sqlite3_stmt *pStmt);
r31374r31375
32233223** CAPI3REF: Determine If A Prepared Statement Has Been Reset
32243224**
32253225** ^The sqlite3_stmt_busy(S) interface returns true (non-zero) if the
3226** [prepared statement] S has been stepped at least once using
3227** [sqlite3_step(S)] but has not run to completion and/or has not
3226** [prepared statement] S has been stepped at least once using
3227** [sqlite3_step(S)] but has not run to completion and/or has not
32283228** been reset using [sqlite3_reset(S)].  ^The sqlite3_stmt_busy(S)
3229** interface returns false if S is a NULL pointer.  If S is not a
3229** interface returns false if S is a NULL pointer.  If S is not a
32303230** NULL pointer and is not a pointer to a valid [prepared statement]
32313231** object, then the behavior is undefined and probably undesirable.
32323232**
32333233** This interface can be used in combination [sqlite3_next_stmt()]
3234** to locate all prepared statements associated with a database
3234** to locate all prepared statements associated with a database
32353235** connection that are in need of being reset.  This can be used,
3236** for example, in diagnostic routines to search for prepared
3236** for example, in diagnostic routines to search for prepared
32373237** statements that are holding a transaction open.
32383238*/
32393239SQLITE_API int sqlite3_stmt_busy(sqlite3_stmt*);
r31374r31375
32583258** sqlite3_value object but no mutex is held for an unprotected
32593259** sqlite3_value object.  If SQLite is compiled to be single-threaded
32603260** (with [SQLITE_THREADSAFE=0] and with [sqlite3_threadsafe()] returning 0)
3261** or if SQLite is run in one of reduced mutex modes
3261** or if SQLite is run in one of reduced mutex modes
32623262** [SQLITE_CONFIG_SINGLETHREAD] or [SQLITE_CONFIG_MULTITHREAD]
32633263** then there is no distinction between protected and unprotected
32643264** sqlite3_value objects and they can be used interchangeably.  However,
r31374r31375
33433343** If a non-negative fourth parameter is provided to sqlite3_bind_text()
33443344** or sqlite3_bind_text16() then that parameter must be the byte offset
33453345** where the NUL terminator would occur assuming the string were NUL
3346** terminated.  If any NUL characters occur at byte offsets less than
3346** terminated.  If any NUL characters occur at byte offsets less than
33473347** the value of the fourth parameter then the resulting string value will
33483348** contain embedded NULs.  The result of expressions involving strings
33493349** with embedded NULs is undefined.
r31374r31375
33523352** sqlite3_bind_text16() is a destructor used to dispose of the BLOB or
33533353** string after SQLite has finished with it.  ^The destructor is called
33543354** to dispose of the BLOB or string even if the call to sqlite3_bind_blob(),
3355** sqlite3_bind_text(), or sqlite3_bind_text16() fails. 
3355** sqlite3_bind_text(), or sqlite3_bind_text16() fails.
33563356** ^If the fifth argument is
33573357** the special value [SQLITE_STATIC], then SQLite assumes that the
33583358** information is in static, unmanaged space and does not need to be freed.
r31374r31375
36483648** For all versions of SQLite up to and including 3.6.23.1, a call to
36493649** [sqlite3_reset()] was required after sqlite3_step() returned anything
36503650** other than [SQLITE_ROW] before any subsequent invocation of
3651** sqlite3_step().  Failure to reset the prepared statement using
3651** sqlite3_step().  Failure to reset the prepared statement using
36523652** [sqlite3_reset()] would result in an [SQLITE_MISUSE] return from
36533653** sqlite3_step().  But after version 3.6.23.1, sqlite3_step() began
36543654** calling [sqlite3_reset()] automatically in this circumstance rather
r31374r31375
37783778** the number of bytes in that string.
37793779** ^If the result is NULL, then sqlite3_column_bytes16() returns zero.
37803780**
3781** ^The values returned by [sqlite3_column_bytes()] and
3781** ^The values returned by [sqlite3_column_bytes()] and
37823782** [sqlite3_column_bytes16()] do not include the zero terminators at the end
37833783** of the string.  ^For clarity: the values returned by
37843784** [sqlite3_column_bytes()] and [sqlite3_column_bytes16()] are the number of
r31374r31375
39713971** ^The second parameter is the name of the SQL function to be created or
39723972** redefined.  ^The length of the name is limited to 255 bytes in a UTF-8
39733973** representation, exclusive of the zero-terminator.  ^Note that the name
3974** length limit is in UTF-8 bytes, not characters nor UTF-16 bytes. 
3974** length limit is in UTF-8 bytes, not characters nor UTF-16 bytes.
39753975** ^Any attempt to create a function with a longer name
39763976** will result in [SQLITE_MISUSE] being returned.
39773977**
r31374r31375
39863986** ^The fourth parameter, eTextRep, specifies what
39873987** [SQLITE_UTF8 | text encoding] this SQL function prefers for
39883988** its parameters.  The application should set this parameter to
3989** [SQLITE_UTF16LE] if the function implementation invokes
3989** [SQLITE_UTF16LE] if the function implementation invokes
39903990** [sqlite3_value_text16le()] on an input, or [SQLITE_UTF16BE] if the
39913991** implementation invokes [sqlite3_value_text16be()] on an input, or
39923992** [SQLITE_UTF16] if [sqlite3_value_text16()] is used, or [SQLITE_UTF8]
r31374r31375
40174017** callbacks.
40184018**
40194019** ^(If the ninth parameter to sqlite3_create_function_v2() is not NULL,
4020** then it is destructor for the application data pointer.
4020** then it is destructor for the application data pointer.
40214021** The destructor is invoked when the function is deleted, either by being
40224022** overloaded or when the database connection closes.)^
40234023** ^The destructor is also invoked if the call to
40244024** sqlite3_create_function_v2() fails.
40254025** ^When the destructor callback of the tenth parameter is invoked, it
4026** is passed a single argument which is a copy of the application data
4026** is passed a single argument which is a copy of the application data
40274027** pointer which was the fifth parameter to sqlite3_create_function_v2().
40284028**
40294029** ^It is permitted to register multiple implementations of the same
r31374r31375
40344034** nArg parameter is a better match than a function implementation with
40354035** a negative nArg.  ^A function where the preferred text encoding
40364036** matches the database encoding is a better
4037** match than a function where the encoding is different. 
4037** match than a function where the encoding is different.
40384038** ^A function where the encoding difference is between UTF16le and UTF16be
40394039** is a closer match than a function where the encoding difference is
40404040** between UTF8 and UTF16.
r31374r31375
40474047** statement in which the function is running.
40484048*/
40494049SQLITE_API int sqlite3_create_function(
4050  sqlite3 *db,
4051  const char *zFunctionName,
4052  int nArg,
4053  int eTextRep,
4054  void *pApp,
4055  void (*xFunc)(sqlite3_context*,int,sqlite3_value**),
4056  void (*xStep)(sqlite3_context*,int,sqlite3_value**),
4057  void (*xFinal)(sqlite3_context*)
4050   sqlite3 *db,
4051   const char *zFunctionName,
4052   int nArg,
4053   int eTextRep,
4054   void *pApp,
4055   void (*xFunc)(sqlite3_context*,int,sqlite3_value**),
4056   void (*xStep)(sqlite3_context*,int,sqlite3_value**),
4057   void (*xFinal)(sqlite3_context*)
40584058);
40594059SQLITE_API int sqlite3_create_function16(
4060  sqlite3 *db,
4061  const void *zFunctionName,
4062  int nArg,
4063  int eTextRep,
4064  void *pApp,
4065  void (*xFunc)(sqlite3_context*,int,sqlite3_value**),
4066  void (*xStep)(sqlite3_context*,int,sqlite3_value**),
4067  void (*xFinal)(sqlite3_context*)
4060   sqlite3 *db,
4061   const void *zFunctionName,
4062   int nArg,
4063   int eTextRep,
4064   void *pApp,
4065   void (*xFunc)(sqlite3_context*,int,sqlite3_value**),
4066   void (*xStep)(sqlite3_context*,int,sqlite3_value**),
4067   void (*xFinal)(sqlite3_context*)
40684068);
40694069SQLITE_API int sqlite3_create_function_v2(
4070  sqlite3 *db,
4071  const char *zFunctionName,
4072  int nArg,
4073  int eTextRep,
4074  void *pApp,
4075  void (*xFunc)(sqlite3_context*,int,sqlite3_value**),
4076  void (*xStep)(sqlite3_context*,int,sqlite3_value**),
4077  void (*xFinal)(sqlite3_context*),
4078  void(*xDestroy)(void*)
4070   sqlite3 *db,
4071   const char *zFunctionName,
4072   int nArg,
4073   int eTextRep,
4074   void *pApp,
4075   void (*xFunc)(sqlite3_context*,int,sqlite3_value**),
4076   void (*xStep)(sqlite3_context*,int,sqlite3_value**),
4077   void (*xFinal)(sqlite3_context*),
4078   void(*xDestroy)(void*)
40794079);
40804080
40814081/*
r31374r31375
40944094/*
40954095** CAPI3REF: Function Flags
40964096**
4097** These constants may be ORed together with the
4097** These constants may be ORed together with the
40984098** [SQLITE_UTF8 | preferred text encoding] as the fourth argument
40994099** to [sqlite3_create_function()], [sqlite3_create_function16()], or
41004100** [sqlite3_create_function_v2()].
r31374r31375
41064106** DEPRECATED
41074107**
41084108** These functions are [deprecated].  In order to maintain
4109** backwards compatibility with older code, these functions continue
4109** backwards compatibility with older code, these functions continue
41104110** to be supported.  However, new applications should avoid
41114111** the use of these functions.  To help encourage people to avoid
41124112** using these functions, we are not going to tell you what they do.
r31374r31375
41184118SQLITE_API SQLITE_DEPRECATED int sqlite3_global_recover(void);
41194119SQLITE_API SQLITE_DEPRECATED void sqlite3_thread_cleanup(void);
41204120SQLITE_API SQLITE_DEPRECATED int sqlite3_memory_alarm(void(*)(void*,sqlite3_int64,int),
4121                      void*,sqlite3_int64);
4121                  void*,sqlite3_int64);
41224122#endif
41234123
41244124/*
r31374r31375
41854185** Implementations of aggregate SQL functions use this
41864186** routine to allocate memory for storing their state.
41874187**
4188** ^The first time the sqlite3_aggregate_context(C,N) routine is called
4188** ^The first time the sqlite3_aggregate_context(C,N) routine is called
41894189** for a particular aggregate function, SQLite
41904190** allocates N of memory, zeroes out that memory, and returns a pointer
41914191** to the new memory. ^On second and subsequent calls to
r31374r31375
41984198** In those cases, sqlite3_aggregate_context() might be called for the
41994199** first time from within xFinal().)^
42004200**
4201** ^The sqlite3_aggregate_context(C,N) routine returns a NULL pointer
4201** ^The sqlite3_aggregate_context(C,N) routine returns a NULL pointer
42024202** when first called if N is less than or equal to zero or if a memory
42034203** allocate error occurs.
42044204**
r31374r31375
42074207** value of N in subsequent call to sqlite3_aggregate_context() within
42084208** the same aggregate function instance will not resize the memory
42094209** allocation.)^  Within the xFinal callback, it is customary to set
4210** N=0 in calls to sqlite3_aggregate_context(C,N) so that no
4210** N=0 in calls to sqlite3_aggregate_context(C,N) so that no
42114211** pointless memory allocations occur.
42124212**
4213** ^SQLite automatically frees the memory allocated by
4213** ^SQLite automatically frees the memory allocated by
42144214** sqlite3_aggregate_context() when the aggregate query concludes.
42154215**
42164216** The first parameter must be a copy of the
r31374r31375
42574257** some circumstances the associated metadata may be preserved.  An example
42584258** of where this might be useful is in a regular-expression matching
42594259** function. The compiled version of the regular expression can be stored as
4260** metadata associated with the pattern string. 
4260** metadata associated with the pattern string.
42614261** Then as long as the pattern string remains the same,
42624262** the compiled regular expression can be reused on multiple
42634263** invocations of the same function.
r31374r31375
42814281** <li> when [sqlite3_reset()] or [sqlite3_finalize()] is called for the
42824282**      SQL statement, or
42834283** <li> when sqlite3_set_auxdata() is invoked again on the same parameter, or
4284** <li> during the original sqlite3_set_auxdata() call when a memory
4284** <li> during the original sqlite3_set_auxdata() call when a memory
42854285**      allocation error occurs. </ul>)^
42864286**
4287** Note the last bullet in particular.  The destructor X in
4287** Note the last bullet in particular.  The destructor X in
42884288** sqlite3_set_auxdata(C,N,P,X) might be called immediately, before the
42894289** sqlite3_set_auxdata() interface even returns.  Hence sqlite3_set_auxdata()
42904290** should be called near the end of the function implementation and the
r31374r31375
44854485** deleted.  ^When all collating functions having the same name are deleted,
44864486** that collation is no longer usable.
44874487**
4488** ^The collating function callback is invoked with a copy of the pArg
4488** ^The collating function callback is invoked with a copy of the pArg
44894489** application data pointer and with two strings in the encoding specified
44904490** by the eTextRep argument.  The collating function must return an
44914491** integer that is negative, zero, or positive
r31374r31375
45154515** calls to the collation creation functions or when the
45164516** [database connection] is closed using [sqlite3_close()].
45174517**
4518** ^The xDestroy callback is <u>not</u> called if the
4518** ^The xDestroy callback is <u>not</u> called if the
45194519** sqlite3_create_collation_v2() function fails.  Applications that invoke
4520** sqlite3_create_collation_v2() with a non-NULL xDestroy argument should
4520** sqlite3_create_collation_v2() with a non-NULL xDestroy argument should
45214521** check the return code and dispose of the application data pointer
45224522** themselves rather than expecting SQLite to deal with it for them.
4523** This is different from every other SQLite interface.  The inconsistency
4524** is unfortunate but cannot be changed without breaking backwards
4523** This is different from every other SQLite interface.  The inconsistency
4524** is unfortunate but cannot be changed without breaking backwards
45254525** compatibility.
45264526**
45274527** See also:  [sqlite3_collation_needed()] and [sqlite3_collation_needed16()].
45284528*/
45294529SQLITE_API int sqlite3_create_collation(
4530  sqlite3*,
4531  const char *zName,
4532  int eTextRep,
4533  void *pArg,
4534  int(*xCompare)(void*,int,const void*,int,const void*)
4530   sqlite3*,
4531   const char *zName,
4532   int eTextRep,
4533   void *pArg,
4534   int(*xCompare)(void*,int,const void*,int,const void*)
45354535);
45364536SQLITE_API int sqlite3_create_collation_v2(
4537  sqlite3*,
4538  const char *zName,
4539  int eTextRep,
4540  void *pArg,
4541  int(*xCompare)(void*,int,const void*,int,const void*),
4542  void(*xDestroy)(void*)
4537   sqlite3*,
4538   const char *zName,
4539   int eTextRep,
4540   void *pArg,
4541   int(*xCompare)(void*,int,const void*,int,const void*),
4542   void(*xDestroy)(void*)
45434543);
45444544SQLITE_API int sqlite3_create_collation16(
4545  sqlite3*,
4546  const void *zName,
4547  int eTextRep,
4548  void *pArg,
4549  int(*xCompare)(void*,int,const void*,int,const void*)
4545   sqlite3*,
4546   const void *zName,
4547   int eTextRep,
4548   void *pArg,
4549   int(*xCompare)(void*,int,const void*,int,const void*)
45504550);
45514551
45524552/*
r31374r31375
45764576** [sqlite3_create_collation_v2()].
45774577*/
45784578SQLITE_API int sqlite3_collation_needed(
4579  sqlite3*,
4580  void*,
4581  void(*)(void*,sqlite3*,int eTextRep,const char*)
4579   sqlite3*,
4580   void*,
4581   void(*)(void*,sqlite3*,int eTextRep,const char*)
45824582);
45834583SQLITE_API int sqlite3_collation_needed16(
4584  sqlite3*,
4585  void*,
4586  void(*)(void*,sqlite3*,int eTextRep,const void*)
4584   sqlite3*,
4585   void*,
4586   void(*)(void*,sqlite3*,int eTextRep,const void*)
45874587);
45884588
45894589#ifdef SQLITE_HAS_CODEC
r31374r31375
45954595** of SQLite.
45964596*/
45974597SQLITE_API int sqlite3_key(
4598  sqlite3 *db,                   /* Database to be rekeyed */
4599  const void *pKey, int nKey     /* The key */
4598   sqlite3 *db,                   /* Database to be rekeyed */
4599   const void *pKey, int nKey     /* The key */
46004600);
46014601SQLITE_API int sqlite3_key_v2(
4602  sqlite3 *db,                   /* Database to be rekeyed */
4603  const char *zDbName,           /* Name of the database */
4604  const void *pKey, int nKey     /* The key */
4602   sqlite3 *db,                   /* Database to be rekeyed */
4603   const char *zDbName,           /* Name of the database */
4604   const void *pKey, int nKey     /* The key */
46054605);
46064606
46074607/*
r31374r31375
46134613** of SQLite.
46144614*/
46154615SQLITE_API int sqlite3_rekey(
4616  sqlite3 *db,                   /* Database to be rekeyed */
4617  const void *pKey, int nKey     /* The new key */
4616   sqlite3 *db,                   /* Database to be rekeyed */
4617   const void *pKey, int nKey     /* The new key */
46184618);
46194619SQLITE_API int sqlite3_rekey_v2(
4620  sqlite3 *db,                   /* Database to be rekeyed */
4621  const char *zDbName,           /* Name of the database */
4622  const void *pKey, int nKey     /* The new key */
4620   sqlite3 *db,                   /* Database to be rekeyed */
4621   const char *zDbName,           /* Name of the database */
4622   const void *pKey, int nKey     /* The new key */
46234623);
46244624
46254625/*
4626** Specify the activation key for a SEE database.  Unless
4626** Specify the activation key for a SEE database.  Unless
46274627** activated, none of the SEE routines will work.
46284628*/
46294629SQLITE_API void sqlite3_activate_see(
4630  const char *zPassPhrase        /* Activation phrase */
4630   const char *zPassPhrase        /* Activation phrase */
46314631);
46324632#endif
46334633
46344634#ifdef SQLITE_ENABLE_CEROD
46354635/*
4636** Specify the activation key for a CEROD database.  Unless
4636** Specify the activation key for a CEROD database.  Unless
46374637** activated, none of the CEROD routines will work.
46384638*/
46394639SQLITE_API void sqlite3_activate_cerod(
4640  const char *zPassPhrase        /* Activation phrase */
4640   const char *zPassPhrase        /* Activation phrase */
46414641);
46424642#endif
46434643
r31374r31375
46824682** ^The [temp_store_directory pragma] may modify this variable and cause
46834683** it to point to memory obtained from [sqlite3_malloc].  ^Furthermore,
46844684** the [temp_store_directory pragma] always assumes that any string
4685** that this variable points to is held in memory obtained from
4685** that this variable points to is held in memory obtained from
46864686** [sqlite3_malloc] and the pragma may attempt to free that memory
46874687** using [sqlite3_free].
46884688** Hence, if this variable is modified directly, either it should be
r31374r31375
47344734** ^The [data_store_directory pragma] may modify this variable and cause
47354735** it to point to memory obtained from [sqlite3_malloc].  ^Furthermore,
47364736** the [data_store_directory pragma] always assumes that any string
4737** that this variable points to is held in memory obtained from
4737** that this variable points to is held in memory obtained from
47384738** [sqlite3_malloc] and the pragma may attempt to free that memory
47394739** using [sqlite3_free].
47404740** Hence, if this variable is modified directly, either it should be
r31374r31375
49164916** interfaces.
49174917*/
49184918SQLITE_API void *sqlite3_update_hook(
4919  sqlite3*,
4920  void(*)(void *,int ,char const *,char const *,sqlite3_int64),
4921  void*
4919   sqlite3*,
4920   void(*)(void *,int ,char const *,char const *,sqlite3_int64),
4921   void*
49224922);
49234923
49244924/*
r31374r31375
49914991** as heap memory usages approaches the limit.
49924992** ^The soft heap limit is "soft" because even though SQLite strives to stay
49934993** below the limit, it will exceed the limit rather than generate
4994** an [SQLITE_NOMEM] error.  In other words, the soft heap limit
4994** an [SQLITE_NOMEM] error.  In other words, the soft heap limit
49954995** is advisory only.
49964996**
49974997** ^The return value from sqlite3_soft_heap_limit64() is the size of
r31374r31375
51085108** [SQLITE_ENABLE_COLUMN_METADATA] C-preprocessor symbol defined.
51095109*/
51105110SQLITE_API int sqlite3_table_column_metadata(
5111  sqlite3 *db,                /* Connection handle */
5112  const char *zDbName,        /* Database name or NULL */
5113  const char *zTableName,     /* Table name */
5114  const char *zColumnName,    /* Column name */
5115  char const **pzDataType,    /* OUTPUT: Declared data type */
5116  char const **pzCollSeq,     /* OUTPUT: Collation sequence name */
5117  int *pNotNull,              /* OUTPUT: True if NOT NULL constraint exists */
5118  int *pPrimaryKey,           /* OUTPUT: True if column part of PK */
5119  int *pAutoinc               /* OUTPUT: True if column is auto-increment */
5111   sqlite3 *db,                /* Connection handle */
5112   const char *zDbName,        /* Database name or NULL */
5113   const char *zTableName,     /* Table name */
5114   const char *zColumnName,    /* Column name */
5115   char const **pzDataType,    /* OUTPUT: Declared data type */
5116   char const **pzCollSeq,     /* OUTPUT: Collation sequence name */
5117   int *pNotNull,              /* OUTPUT: True if NOT NULL constraint exists */
5118   int *pPrimaryKey,           /* OUTPUT: True if column part of PK */
5119   int *pAutoinc               /* OUTPUT: True if column is auto-increment */
51205120);
51215121
51225122/*
r31374r31375
51545154** See also the [load_extension() SQL function].
51555155*/
51565156SQLITE_API int sqlite3_load_extension(
5157  sqlite3 *db,          /* Load the extension into this database connection */
5158  const char *zFile,    /* Name of the shared library containing extension */
5159  const char *zProc,    /* Entry point.  Derived from zFile if 0 */
5160  char **pzErrMsg       /* Put error message here if not 0 */
5157   sqlite3 *db,          /* Load the extension into this database connection */
5158   const char *zFile,    /* Name of the shared library containing extension */
5159   const char *zProc,    /* Entry point.  Derived from zFile if 0 */
5160   char **pzErrMsg       /* Put error message here if not 0 */
51615161);
51625162
51635163/*
r31374r31375
52195219** ^The [sqlite3_cancel_auto_extension(X)] interface unregisters the
52205220** initialization routine X that was registered using a prior call to
52215221** [sqlite3_auto_extension(X)].  ^The [sqlite3_cancel_auto_extension(X)]
5222** routine returns 1 if initialization routine X was successfully
5222** routine returns 1 if initialization routine X was successfully
52235223** unregistered and it returns 0 if X was not on the list of initialization
52245224** routines.
52255225*/
r31374r31375
52545254** CAPI3REF: Virtual Table Object
52555255** KEYWORDS: sqlite3_module {virtual table module}
52565256**
5257** This structure, sometimes called a "virtual table module",
5258** defines the implementation of a [virtual tables]. 
5257** This structure, sometimes called a "virtual table module",
5258** defines the implementation of a [virtual tables].
52595259** This structure consists mostly of methods for the module.
52605260**
52615261** ^A virtual table module is created by filling in a persistent
r31374r31375
52675267** any database connection.
52685268*/
52695269struct sqlite3_module {
5270  int iVersion;
5271  int (*xCreate)(sqlite3*, void *pAux,
5272               int argc, const char *const*argv,
5273               sqlite3_vtab **ppVTab, char**);
5274  int (*xConnect)(sqlite3*, void *pAux,
5275               int argc, const char *const*argv,
5276               sqlite3_vtab **ppVTab, char**);
5277  int (*xBestIndex)(sqlite3_vtab *pVTab, sqlite3_index_info*);
5278  int (*xDisconnect)(sqlite3_vtab *pVTab);
5279  int (*xDestroy)(sqlite3_vtab *pVTab);
5280  int (*xOpen)(sqlite3_vtab *pVTab, sqlite3_vtab_cursor **ppCursor);
5281  int (*xClose)(sqlite3_vtab_cursor*);
5282  int (*xFilter)(sqlite3_vtab_cursor*, int idxNum, const char *idxStr,
5283                int argc, sqlite3_value **argv);
5284  int (*xNext)(sqlite3_vtab_cursor*);
5285  int (*xEof)(sqlite3_vtab_cursor*);
5286  int (*xColumn)(sqlite3_vtab_cursor*, sqlite3_context*, int);
5287  int (*xRowid)(sqlite3_vtab_cursor*, sqlite3_int64 *pRowid);
5288  int (*xUpdate)(sqlite3_vtab *, int, sqlite3_value **, sqlite3_int64 *);
5289  int (*xBegin)(sqlite3_vtab *pVTab);
5290  int (*xSync)(sqlite3_vtab *pVTab);
5291  int (*xCommit)(sqlite3_vtab *pVTab);
5292  int (*xRollback)(sqlite3_vtab *pVTab);
5293  int (*xFindFunction)(sqlite3_vtab *pVtab, int nArg, const char *zName,
5294                       void (**pxFunc)(sqlite3_context*,int,sqlite3_value**),
5295                       void **ppArg);
5296  int (*xRename)(sqlite3_vtab *pVtab, const char *zNew);
5297  /* The methods above are in version 1 of the sqlite_module object. Those
5298  ** below are for version 2 and greater. */
5299  int (*xSavepoint)(sqlite3_vtab *pVTab, int);
5300  int (*xRelease)(sqlite3_vtab *pVTab, int);
5301  int (*xRollbackTo)(sqlite3_vtab *pVTab, int);
5270   int iVersion;
5271   int (*xCreate)(sqlite3*, void *pAux,
5272            int argc, const char *const*argv,
5273            sqlite3_vtab **ppVTab, char**);
5274   int (*xConnect)(sqlite3*, void *pAux,
5275            int argc, const char *const*argv,
5276            sqlite3_vtab **ppVTab, char**);
5277   int (*xBestIndex)(sqlite3_vtab *pVTab, sqlite3_index_info*);
5278   int (*xDisconnect)(sqlite3_vtab *pVTab);
5279   int (*xDestroy)(sqlite3_vtab *pVTab);
5280   int (*xOpen)(sqlite3_vtab *pVTab, sqlite3_vtab_cursor **ppCursor);
5281   int (*xClose)(sqlite3_vtab_cursor*);
5282   int (*xFilter)(sqlite3_vtab_cursor*, int idxNum, const char *idxStr,
5283            int argc, sqlite3_value **argv);
5284   int (*xNext)(sqlite3_vtab_cursor*);
5285   int (*xEof)(sqlite3_vtab_cursor*);
5286   int (*xColumn)(sqlite3_vtab_cursor*, sqlite3_context*, int);
5287   int (*xRowid)(sqlite3_vtab_cursor*, sqlite3_int64 *pRowid);
5288   int (*xUpdate)(sqlite3_vtab *, int, sqlite3_value **, sqlite3_int64 *);
5289   int (*xBegin)(sqlite3_vtab *pVTab);
5290   int (*xSync)(sqlite3_vtab *pVTab);
5291   int (*xCommit)(sqlite3_vtab *pVTab);
5292   int (*xRollback)(sqlite3_vtab *pVTab);
5293   int (*xFindFunction)(sqlite3_vtab *pVtab, int nArg, const char *zName,
5294                  void (**pxFunc)(sqlite3_context*,int,sqlite3_value**),
5295                  void **ppArg);
5296   int (*xRename)(sqlite3_vtab *pVtab, const char *zNew);
5297   /* The methods above are in version 1 of the sqlite_module object. Those
5298   ** below are for version 2 and greater. */
5299   int (*xSavepoint)(sqlite3_vtab *pVTab, int);
5300   int (*xRelease)(sqlite3_vtab *pVTab, int);
5301   int (*xRollbackTo)(sqlite3_vtab *pVTab, int);
53025302};
53035303
53045304/*
r31374r31375
53515351**
53525352** ^The estimatedCost value is an estimate of the cost of a particular
53535353** strategy. A cost of N indicates that the cost of the strategy is similar
5354** to a linear scan of an SQLite table with N rows. A cost of log(N)
5354** to a linear scan of an SQLite table with N rows. A cost of log(N)
53555355** indicates that the expense of the operation is similar to that of a
53565356** binary search on a unique indexed field of an SQLite table with N rows.
53575357**
r31374r31375
53605360**
53615361** IMPORTANT: The estimatedRows field was added to the sqlite3_index_info
53625362** structure for SQLite version 3.8.2. If a virtual table extension is
5363** used with an SQLite version earlier than 3.8.2, the results of attempting
5364** to read or write the estimatedRows field are undefined (but are likely
5363** used with an SQLite version earlier than 3.8.2, the results of attempting
5364** to read or write the estimatedRows field are undefined (but are likely
53655365** to included crashing the application). The estimatedRows field should
53665366** therefore only be used if [sqlite3_libversion_number()] returns a
53675367** value greater than or equal to 3008002.
53685368*/
53695369struct sqlite3_index_info {
5370  /* Inputs */
5371  int nConstraint;           /* Number of entries in aConstraint */
5372  struct sqlite3_index_constraint {
5373     int iColumn;              /* Column on left-hand side of constraint */
5374     unsigned char op;         /* Constraint operator */
5375     unsigned char usable;     /* True if this constraint is usable */
5376     int iTermOffset;          /* Used internally - xBestIndex should ignore */
5377  } *aConstraint;            /* Table of WHERE clause constraints */
5378  int nOrderBy;              /* Number of terms in the ORDER BY clause */
5379  struct sqlite3_index_orderby {
5380     int iColumn;              /* Column number */
5381     unsigned char desc;       /* True for DESC.  False for ASC. */
5382  } *aOrderBy;               /* The ORDER BY clause */
5383  /* Outputs */
5384  struct sqlite3_index_constraint_usage {
5385    int argvIndex;           /* if >0, constraint is part of argv to xFilter */
5386    unsigned char omit;      /* Do not code a test for this constraint */
5387  } *aConstraintUsage;
5388  int idxNum;                /* Number used to identify the index */
5389  char *idxStr;              /* String, possibly obtained from sqlite3_malloc */
5390  int needToFreeIdxStr;      /* Free idxStr using sqlite3_free() if true */
5391  int orderByConsumed;       /* True if output is already ordered */
5392  double estimatedCost;           /* Estimated cost of using this index */
5393  /* Fields below are only available in SQLite 3.8.2 and later */
5394  sqlite3_int64 estimatedRows;    /* Estimated number of rows returned */
5370   /* Inputs */
5371   int nConstraint;           /* Number of entries in aConstraint */
5372   struct sqlite3_index_constraint {
5373      int iColumn;              /* Column on left-hand side of constraint */
5374      unsigned char op;         /* Constraint operator */
5375      unsigned char usable;     /* True if this constraint is usable */
5376      int iTermOffset;          /* Used internally - xBestIndex should ignore */
5377   } *aConstraint;            /* Table of WHERE clause constraints */
5378   int nOrderBy;              /* Number of terms in the ORDER BY clause */
5379   struct sqlite3_index_orderby {
5380      int iColumn;              /* Column number */
5381      unsigned char desc;       /* True for DESC.  False for ASC. */
5382   } *aOrderBy;               /* The ORDER BY clause */
5383   /* Outputs */
5384   struct sqlite3_index_constraint_usage {
5385   int argvIndex;           /* if >0, constraint is part of argv to xFilter */
5386   unsigned char omit;      /* Do not code a test for this constraint */
5387   } *aConstraintUsage;
5388   int idxNum;                /* Number used to identify the index */
5389   char *idxStr;              /* String, possibly obtained from sqlite3_malloc */
5390   int needToFreeIdxStr;      /* Free idxStr using sqlite3_free() if true */
5391   int orderByConsumed;       /* True if output is already ordered */
5392   double estimatedCost;           /* Estimated cost of using this index */
5393   /* Fields below are only available in SQLite 3.8.2 and later */
5394   sqlite3_int64 estimatedRows;    /* Estimated number of rows returned */
53955395};
53965396
53975397/*
r31374r31375
54185418** preexisting [virtual table] for the module.
54195419**
54205420** ^The module name is registered on the [database connection] specified
5421** by the first parameter.  ^The name of the module is given by the
5421** by the first parameter.  ^The name of the module is given by the
54225422** second parameter.  ^The third parameter is a pointer to
54235423** the implementation of the [virtual table module].   ^The fourth
54245424** parameter is an arbitrary client data pointer that is passed through
r31374r31375
54355435** destructor.
54365436*/
54375437SQLITE_API int sqlite3_create_module(
5438  sqlite3 *db,               /* SQLite connection to register module with */
5439  const char *zName,         /* Name of the module */
5440  const sqlite3_module *p,   /* Methods for the module */
5441  void *pClientData          /* Client data for xCreate/xConnect */
5438   sqlite3 *db,               /* SQLite connection to register module with */
5439   const char *zName,         /* Name of the module */
5440   const sqlite3_module *p,   /* Methods for the module */
5441   void *pClientData          /* Client data for xCreate/xConnect */
54425442);
54435443SQLITE_API int sqlite3_create_module_v2(
5444  sqlite3 *db,               /* SQLite connection to register module with */
5445  const char *zName,         /* Name of the module */
5446  const sqlite3_module *p,   /* Methods for the module */
5447  void *pClientData,         /* Client data for xCreate/xConnect */
5448  void(*xDestroy)(void*)     /* Module destructor function */
5444   sqlite3 *db,               /* SQLite connection to register module with */
5445   const char *zName,         /* Name of the module */
5446   const sqlite3_module *p,   /* Methods for the module */
5447   void *pClientData,         /* Client data for xCreate/xConnect */
5448   void(*xDestroy)(void*)     /* Module destructor function */
54495449);
54505450
54515451/*
r31374r31375
54675467** freed by sqlite3_free() and the zErrMsg field will be zeroed.
54685468*/
54695469struct sqlite3_vtab {
5470  const sqlite3_module *pModule;  /* The module for this virtual table */
5471  int nRef;                       /* NO LONGER USED */
5472  char *zErrMsg;                  /* Error message from sqlite3_mprintf() */
5473  /* Virtual table implementations will typically add additional fields */
5470   const sqlite3_module *pModule;  /* The module for this virtual table */
5471   int nRef;                       /* NO LONGER USED */
5472   char *zErrMsg;                  /* Error message from sqlite3_mprintf() */
5473   /* Virtual table implementations will typically add additional fields */
54745474};
54755475
54765476/*
r31374r31375
54915491** are common to all implementations.
54925492*/
54935493struct sqlite3_vtab_cursor {
5494  sqlite3_vtab *pVtab;      /* Virtual table of this cursor */
5495  /* Virtual table implementations will typically add additional fields */
5494   sqlite3_vtab *pVtab;      /* Virtual table of this cursor */
5495   /* Virtual table implementations will typically add additional fields */
54965496};
54975497
54985498/*
r31374r31375
55095509** CAPI3REF: Overload A Function For A Virtual Table
55105510**
55115511** ^(Virtual tables can provide alternative implementations of functions
5512** using the [xFindFunction] method of the [virtual table module]. 
5512** using the [xFindFunction] method of the [virtual table module].
55135513** But global versions of those functions
55145514** must exist in order to be overloaded.)^
55155515**
r31374r31375
55605560**
55615561** ^If the flags parameter is non-zero, then the BLOB is opened for read
55625562** and write access. ^If it is zero, the BLOB is opened for read access.
5563** ^It is not possible to open a column that is part of an index or primary
5564** key for writing. ^If [foreign key constraints] are enabled, it is
5563** ^It is not possible to open a column that is part of an index or primary
5564** key for writing. ^If [foreign key constraints] are enabled, it is
55655565** not possible to open a column that is part of a [child key] for writing.
55665566**
55675567** ^Note that the database name is not the filename that contains
r31374r31375
56075607** be released by a call to [sqlite3_blob_close()].
56085608*/
56095609SQLITE_API int sqlite3_blob_open(
5610  sqlite3*,
5611  const char *zDb,
5612  const char *zTable,
5613  const char *zColumn,
5614  sqlite3_int64 iRow,
5615  int flags,
5616  sqlite3_blob **ppBlob
5610   sqlite3*,
5611   const char *zDb,
5612   const char *zTable,
5613   const char *zColumn,
5614   sqlite3_int64 iRow,
5615   int flags,
5616   sqlite3_blob **ppBlob
56175617);
56185618
56195619/*
r31374r31375
56675667/*
56685668** CAPI3REF: Return The Size Of An Open BLOB
56695669**
5670** ^Returns the size in bytes of the BLOB accessible via the
5670** ^Returns the size in bytes of the BLOB accessible via the
56715671** successfully opened [BLOB handle] in its only argument.  ^The
56725672** incremental blob I/O routines can only read or overwriting existing
56735673** blob content; they cannot change the size of a blob.
r31374r31375
59645964*/
59655965typedef struct sqlite3_mutex_methods sqlite3_mutex_methods;
59665966struct sqlite3_mutex_methods {
5967  int (*xMutexInit)(void);
5968  int (*xMutexEnd)(void);
5969  sqlite3_mutex *(*xMutexAlloc)(int);
5970  void (*xMutexFree)(sqlite3_mutex *);
5971  void (*xMutexEnter)(sqlite3_mutex *);
5972  int (*xMutexTry)(sqlite3_mutex *);
5973  void (*xMutexLeave)(sqlite3_mutex *);
5974  int (*xMutexHeld)(sqlite3_mutex *);
5975  int (*xMutexNotheld)(sqlite3_mutex *);
5967   int (*xMutexInit)(void);
5968   int (*xMutexEnd)(void);
5969   sqlite3_mutex *(*xMutexAlloc)(int);
5970   void (*xMutexFree)(sqlite3_mutex *);
5971   void (*xMutexEnter)(sqlite3_mutex *);
5972   int (*xMutexTry)(sqlite3_mutex *);
5973   void (*xMutexLeave)(sqlite3_mutex *);
5974   int (*xMutexHeld)(sqlite3_mutex *);
5975   int (*xMutexNotheld)(sqlite3_mutex *);
59765976};
59775977
59785978/*
r31374r31375
60336033/*
60346034** CAPI3REF: Retrieve the mutex for a database connection
60356035**
6036** ^This interface returns a pointer the [sqlite3_mutex] object that
6036** ^This interface returns a pointer the [sqlite3_mutex] object that
60376037** serializes access to the [database connection] given in the argument
60386038** when the [threading mode] is Serialized.
60396039** ^If the [threading mode] is Single-thread or Multi-thread then this
r31374r31375
61796179** <dd>This parameter records the largest memory allocation request
61806180** handed to [sqlite3_malloc()] or [sqlite3_realloc()] (or their
61816181** internal equivalents).  Only the value returned in the
6182** *pHighwater parameter to [sqlite3_status()] is of interest. 
6182** *pHighwater parameter to [sqlite3_status()] is of interest.
61836183** The value written into the *pCurrent parameter is undefined.</dd>)^
61846184**
61856185** [[SQLITE_STATUS_MALLOC_COUNT]] ^(<dt>SQLITE_STATUS_MALLOC_COUNT</dt>
r31374r31375
61886188**
61896189** [[SQLITE_STATUS_PAGECACHE_USED]] ^(<dt>SQLITE_STATUS_PAGECACHE_USED</dt>
61906190** <dd>This parameter returns the number of pages used out of the
6191** [pagecache memory allocator] that was configured using
6191** [pagecache memory allocator] that was configured using
61926192** [SQLITE_CONFIG_PAGECACHE].  The
61936193** value returned is in pages, not in bytes.</dd>)^
61946194**
6195** [[SQLITE_STATUS_PAGECACHE_OVERFLOW]]
6195** [[SQLITE_STATUS_PAGECACHE_OVERFLOW]]
61966196** ^(<dt>SQLITE_STATUS_PAGECACHE_OVERFLOW</dt>
61976197** <dd>This parameter returns the number of bytes of page cache
61986198** allocation which could not be satisfied by the [SQLITE_CONFIG_PAGECACHE]
r31374r31375
62056205** [[SQLITE_STATUS_PAGECACHE_SIZE]] ^(<dt>SQLITE_STATUS_PAGECACHE_SIZE</dt>
62066206** <dd>This parameter records the largest memory allocation request
62076207** handed to [pagecache memory allocator].  Only the value returned in the
6208** *pHighwater parameter to [sqlite3_status()] is of interest. 
6208** *pHighwater parameter to [sqlite3_status()] is of interest.
62096209** The value written into the *pCurrent parameter is undefined.</dd>)^
62106210**
62116211** [[SQLITE_STATUS_SCRATCH_USED]] ^(<dt>SQLITE_STATUS_SCRATCH_USED</dt>
r31374r31375
62296229** [[SQLITE_STATUS_SCRATCH_SIZE]] ^(<dt>SQLITE_STATUS_SCRATCH_SIZE</dt>
62306230** <dd>This parameter records the largest memory allocation request
62316231** handed to [scratch memory allocator].  Only the value returned in the
6232** *pHighwater parameter to [sqlite3_status()] is of interest. 
6232** *pHighwater parameter to [sqlite3_status()] is of interest.
62336233** The value written into the *pCurrent parameter is undefined.</dd>)^
62346234**
62356235** [[SQLITE_STATUS_PARSER_STACK]] ^(<dt>SQLITE_STATUS_PARSER_STACK</dt>
r31374r31375
62536253/*
62546254** CAPI3REF: Database Connection Status
62556255**
6256** ^This interface is used to retrieve runtime status information
6256** ^This interface is used to retrieve runtime status information
62576257** about a single [database connection].  ^The first argument is the
62586258** database connection object to be interrogated.  ^The second argument
62596259** is an integer constant, taken from the set of
62606260** [SQLITE_DBSTATUS options], that
6261** determines the parameter to interrogate.  The set of
6261** determines the parameter to interrogate.  The set of
62626262** [SQLITE_DBSTATUS options] is likely
62636263** to grow in future releases of SQLite.
62646264**
r31374r31375
62936293** checked out.</dd>)^
62946294**
62956295** [[SQLITE_DBSTATUS_LOOKASIDE_HIT]] ^(<dt>SQLITE_DBSTATUS_LOOKASIDE_HIT</dt>
6296** <dd>This parameter returns the number malloc attempts that were
6296** <dd>This parameter returns the number malloc attempts that were
62976297** satisfied using lookaside memory. Only the high-water value is meaningful;
62986298** the current value is always zero.)^
62996299**
r31374r31375
63216321** [[SQLITE_DBSTATUS_SCHEMA_USED]] ^(<dt>SQLITE_DBSTATUS_SCHEMA_USED</dt>
63226322** <dd>This parameter returns the approximate number of of bytes of heap
63236323** memory used to store the schema for all databases associated
6324** with the connection - main, temp, and any [ATTACH]-ed databases.)^
6324** with the connection - main, temp, and any [ATTACH]-ed databases.)^
63256325** ^The full amount of memory used by the schemas is reported, even if the
63266326** schema memory is shared with other database connections due to
63276327** [shared cache mode] being enabled.
r31374r31375
63366336**
63376337** [[SQLITE_DBSTATUS_CACHE_HIT]] ^(<dt>SQLITE_DBSTATUS_CACHE_HIT</dt>
63386338** <dd>This parameter returns the number of pager cache hits that have
6339** occurred.)^ ^The highwater mark associated with SQLITE_DBSTATUS_CACHE_HIT
6339** occurred.)^ ^The highwater mark associated with SQLITE_DBSTATUS_CACHE_HIT
63406340** is always 0.
63416341** </dd>
63426342**
63436343** [[SQLITE_DBSTATUS_CACHE_MISS]] ^(<dt>SQLITE_DBSTATUS_CACHE_MISS</dt>
63446344** <dd>This parameter returns the number of pager cache misses that have
6345** occurred.)^ ^The highwater mark associated with SQLITE_DBSTATUS_CACHE_MISS
6345** occurred.)^ ^The highwater mark associated with SQLITE_DBSTATUS_CACHE_MISS
63466346** is always 0.
63476347** </dd>
63486348**
r31374r31375
63886388** statements.  For example, if the number of table steps greatly exceeds
63896389** the number of table searches or result rows, that would tend to indicate
63906390** that the prepared statement is using a full table scan rather than
6391** an index. 
6391** an index.
63926392**
63936393** ^(This interface is used to retrieve and reset counter values from
63946394** a [prepared statement].  The first argument is the prepared statement
r31374r31375
64156415** [[SQLITE_STMTSTATUS_FULLSCAN_STEP]] <dt>SQLITE_STMTSTATUS_FULLSCAN_STEP</dt>
64166416** <dd>^This is the number of times that SQLite has stepped forward in
64176417** a table as part of a full table scan.  Large numbers for this counter
6418** may indicate opportunities for performance improvement through
6418** may indicate opportunities for performance improvement through
64196419** careful use of indices.</dd>
64206420**
64216421** [[SQLITE_STMTSTATUS_SORT]] <dt>SQLITE_STMTSTATUS_SORT</dt>
r31374r31375
64336433** [[SQLITE_STMTSTATUS_VM_STEP]] <dt>SQLITE_STMTSTATUS_VM_STEP</dt>
64346434** <dd>^This is the number of virtual machine operations executed
64356435** by the prepared statement if that number is less than or equal
6436** to 2147483647.  The number of virtual machine operations can be
6436** to 2147483647.  The number of virtual machine operations can be
64376437** used as a proxy for the total work done by the prepared statement.
64386438** If the number of virtual machine operations exceeds 2147483647
64396439** then the value returned by this statement status code is undefined.
r31374r31375
64706470*/
64716471typedef struct sqlite3_pcache_page sqlite3_pcache_page;
64726472struct sqlite3_pcache_page {
6473  void *pBuf;        /* The content of the page */
6474  void *pExtra;      /* Extra information associated with the page */
6473   void *pBuf;        /* The content of the page */
6474   void *pExtra;      /* Extra information associated with the page */
64756475};
64766476
64776477/*
r31374r31375
64796479** KEYWORDS: {page cache}
64806480**
64816481** ^(The [sqlite3_config]([SQLITE_CONFIG_PCACHE2], ...) interface can
6482** register an alternative page cache implementation by passing in an
6482** register an alternative page cache implementation by passing in an
64836483** instance of the sqlite3_pcache_methods2 structure.)^
6484** In many applications, most of the heap memory allocated by
6484** In many applications, most of the heap memory allocated by
64856485** SQLite is used for the page cache.
6486** By implementing a
6486** By implementing a
64876487** custom page cache using this API, an application can better control
6488** the amount of memory consumed by SQLite, the way in which
6489** that memory is allocated and released, and the policies used to
6490** determine exactly which parts of a database file are cached and for
6488** the amount of memory consumed by SQLite, the way in which
6489** that memory is allocated and released, and the policies used to
6490** determine exactly which parts of a database file are cached and for
64916491** how long.
64926492**
64936493** The alternative page cache mechanism is an
r31374r31375
65006500** [sqlite3_config()] returns.)^
65016501**
65026502** [[the xInit() page cache method]]
6503** ^(The xInit() method is called once for each effective
6503** ^(The xInit() method is called once for each effective
65046504** call to [sqlite3_initialize()])^
65056505** (usually only once during the lifetime of the process). ^(The xInit()
65066506** method is passed a copy of the sqlite3_pcache_methods2.pArg value.)^
6507** The intent of the xInit() method is to set up global data structures
6508** required by the custom page cache implementation.
6509** ^(If the xInit() method is NULL, then the
6507** The intent of the xInit() method is to set up global data structures
6508** required by the custom page cache implementation.
6509** ^(If the xInit() method is NULL, then the
65106510** built-in default page cache is used instead of the application defined
65116511** page cache.)^
65126512**
65136513** [[the xShutdown() page cache method]]
65146514** ^The xShutdown() method is called by [sqlite3_shutdown()].
6515** It can be used to clean up
6515** It can be used to clean up
65166516** any outstanding resources before process shutdown, if required.
65176517** ^The xShutdown() method may be NULL.
65186518**
r31374r31375
65316531** though this is not guaranteed. ^The
65326532** first parameter, szPage, is the size in bytes of the pages that must
65336533** be allocated by the cache.  ^szPage will always a power of two.  ^The
6534** second parameter szExtra is a number of bytes of extra storage
6534** second parameter szExtra is a number of bytes of extra storage
65356535** associated with each page cache entry.  ^The szExtra parameter will
65366536** a number less than 250.  SQLite will use the
65376537** extra szExtra bytes on each page to store metadata about the underlying
r31374r31375
65446544** it is purely advisory.  ^On a cache where bPurgeable is false, SQLite will
65456545** never invoke xUnpin() except to deliberately delete a page.
65466546** ^In other words, calls to xUnpin() on a cache with bPurgeable set to
6547** false will always have the "discard" flag set to true. 
6547** false will always have the "discard" flag set to true.
65486548** ^Hence, a cache created with bPurgeable false will
65496549** never contain any unpinned pages.
65506550**
r31374r31375
65596559** [[the xPagecount() page cache methods]]
65606560** The xPagecount() method must return the number of pages currently
65616561** stored in the cache, both pinned and unpinned.
6562**
6562**
65636563** [[the xFetch() page cache methods]]
6564** The xFetch() method locates a page in the cache and returns a pointer to
6564** The xFetch() method locates a page in the cache and returns a pointer to
65656565** an sqlite3_pcache_page object associated with that page, or a NULL pointer.
65666566** The pBuf element of the returned sqlite3_pcache_page object will be a
6567** pointer to a buffer of szPage bytes used to store the content of a
6567** pointer to a buffer of szPage bytes used to store the content of a
65686568** single database page.  The pExtra element of sqlite3_pcache_page will be
65696569** a pointer to the szExtra bytes of extra storage that SQLite has requested
65706570** for each entry in the page cache.
r31374r31375
66036603** page cache implementation. ^The page cache implementation
66046604** may choose to evict unpinned pages at any time.
66056605**
6606** The cache must not perform any reference counting. A single
6607** call to xUnpin() unpins the page regardless of the number of prior calls
6606** The cache must not perform any reference counting. A single
6607** call to xUnpin() unpins the page regardless of the number of prior calls
66086608** to xFetch().
66096609**
66106610** [[the xRekey() page cache methods]]
r31374r31375
66356635*/
66366636typedef struct sqlite3_pcache_methods2 sqlite3_pcache_methods2;
66376637struct sqlite3_pcache_methods2 {
6638  int iVersion;
6639  void *pArg;
6640  int (*xInit)(void*);
6641  void (*xShutdown)(void*);
6642  sqlite3_pcache *(*xCreate)(int szPage, int szExtra, int bPurgeable);
6643  void (*xCachesize)(sqlite3_pcache*, int nCachesize);
6644  int (*xPagecount)(sqlite3_pcache*);
6645  sqlite3_pcache_page *(*xFetch)(sqlite3_pcache*, unsigned key, int createFlag);
6646  void (*xUnpin)(sqlite3_pcache*, sqlite3_pcache_page*, int discard);
6647  void (*xRekey)(sqlite3_pcache*, sqlite3_pcache_page*,
6648      unsigned oldKey, unsigned newKey);
6649  void (*xTruncate)(sqlite3_pcache*, unsigned iLimit);
6650  void (*xDestroy)(sqlite3_pcache*);
6651  void (*xShrink)(sqlite3_pcache*);
6638   int iVersion;
6639   void *pArg;
6640   int (*xInit)(void*);
6641   void (*xShutdown)(void*);
6642   sqlite3_pcache *(*xCreate)(int szPage, int szExtra, int bPurgeable);
6643   void (*xCachesize)(sqlite3_pcache*, int nCachesize);
6644   int (*xPagecount)(sqlite3_pcache*);
6645   sqlite3_pcache_page *(*xFetch)(sqlite3_pcache*, unsigned key, int createFlag);
6646   void (*xUnpin)(sqlite3_pcache*, sqlite3_pcache_page*, int discard);
6647   void (*xRekey)(sqlite3_pcache*, sqlite3_pcache_page*,
6648      unsigned oldKey, unsigned newKey);
6649   void (*xTruncate)(sqlite3_pcache*, unsigned iLimit);
6650   void (*xDestroy)(sqlite3_pcache*);
6651   void (*xShrink)(sqlite3_pcache*);
66526652};
66536653
66546654/*
r31374r31375
66586658*/
66596659typedef struct sqlite3_pcache_methods sqlite3_pcache_methods;
66606660struct sqlite3_pcache_methods {
6661  void *pArg;
6662  int (*xInit)(void*);
6663  void (*xShutdown)(void*);
6664  sqlite3_pcache *(*xCreate)(int szPage, int bPurgeable);
6665  void (*xCachesize)(sqlite3_pcache*, int nCachesize);
6666  int (*xPagecount)(sqlite3_pcache*);
6667  void *(*xFetch)(sqlite3_pcache*, unsigned key, int createFlag);
6668  void (*xUnpin)(sqlite3_pcache*, void*, int discard);
6669  void (*xRekey)(sqlite3_pcache*, void*, unsigned oldKey, unsigned newKey);
6670  void (*xTruncate)(sqlite3_pcache*, unsigned iLimit);
6671  void (*xDestroy)(sqlite3_pcache*);
6661   void *pArg;
6662   int (*xInit)(void*);
6663   void (*xShutdown)(void*);
6664   sqlite3_pcache *(*xCreate)(int szPage, int bPurgeable);
6665   void (*xCachesize)(sqlite3_pcache*, int nCachesize);
6666   int (*xPagecount)(sqlite3_pcache*);
6667   void *(*xFetch)(sqlite3_pcache*, unsigned key, int createFlag);
6668   void (*xUnpin)(sqlite3_pcache*, void*, int discard);
6669   void (*xRekey)(sqlite3_pcache*, void*, unsigned oldKey, unsigned newKey);
6670   void (*xTruncate)(sqlite3_pcache*, unsigned iLimit);
6671   void (*xDestroy)(sqlite3_pcache*);
66726672};
66736673
66746674
r31374r31375
66896689**
66906690** The backup API copies the content of one database into another.
66916691** It is useful either for creating backups of databases or
6692** for copying in-memory databases to or from persistent files.
6692** for copying in-memory databases to or from persistent files.
66936693**
66946694** See Also: [Using the SQLite Online Backup API]
66956695**
r31374r31375
67006700** ^Thus, the backup may be performed on a live source database without
67016701** preventing other database connections from
67026702** reading or writing to the source database while the backup is underway.
6703**
6704** ^(To perform a backup operation:
6703**
6704** ^(To perform a backup operation:
67056705**   <ol>
67066706**     <li><b>sqlite3_backup_init()</b> is called once to initialize the
6707**         backup,
6708**     <li><b>sqlite3_backup_step()</b> is called one or more times to transfer
6707**         backup,
6708**     <li><b>sqlite3_backup_step()</b> is called one or more times to transfer
67096709**         the data between the two databases, and finally
6710**     <li><b>sqlite3_backup_finish()</b> is called to release all resources
6711**         associated with the backup operation.
6710**     <li><b>sqlite3_backup_finish()</b> is called to release all resources
6711**         associated with the backup operation.
67126712**   </ol>)^
67136713** There should be exactly one call to sqlite3_backup_finish() for each
67146714** successful call to sqlite3_backup_init().
67156715**
67166716** [[sqlite3_backup_init()]] <b>sqlite3_backup_init()</b>
67176717**
6718** ^The D and N arguments to sqlite3_backup_init(D,N,S,M) are the
6719** [database connection] associated with the destination database
6718** ^The D and N arguments to sqlite3_backup_init(D,N,S,M) are the
6719** [database connection] associated with the destination database
67206720** and the database name, respectively.
67216721** ^The database name is "main" for the main database, "temp" for the
67226722** temporary database, or the name specified after the AS keyword in
67236723** an [ATTACH] statement for an attached database.
6724** ^The S and M arguments passed to
6724** ^The S and M arguments passed to
67256725** sqlite3_backup_init(D,N,S,M) identify the [database connection]
67266726** and database name of the source database, respectively.
67276727** ^The source and destination [database connections] (parameters S and D)
r31374r31375
67376737** ^A successful call to sqlite3_backup_init() returns a pointer to an
67386738** [sqlite3_backup] object.
67396739** ^The [sqlite3_backup] object may be used with the sqlite3_backup_step() and
6740** sqlite3_backup_finish() functions to perform the specified backup
6740** sqlite3_backup_finish() functions to perform the specified backup
67416741** operation.
67426742**
67436743** [[sqlite3_backup_step()]] <b>sqlite3_backup_step()</b>
67446744**
6745** ^Function sqlite3_backup_step(B,N) will copy up to N pages between
6745** ^Function sqlite3_backup_step(B,N) will copy up to N pages between
67466746** the source and destination databases specified by [sqlite3_backup] object B.
6747** ^If N is negative, all remaining source pages are copied.
6747** ^If N is negative, all remaining source pages are copied.
67486748** ^If sqlite3_backup_step(B,N) successfully copies N pages and there
67496749** are still more pages to be copied, then the function returns [SQLITE_OK].
67506750** ^If sqlite3_backup_step(B,N) successfully finishes copying all pages
r31374r31375
67666766**
67676767** ^If sqlite3_backup_step() cannot obtain a required file-system lock, then
67686768** the [sqlite3_busy_handler | busy-handler function]
6769** is invoked (if one is specified). ^If the
6770** busy-handler returns non-zero before the lock is available, then
6769** is invoked (if one is specified). ^If the
6770** busy-handler returns non-zero before the lock is available, then
67716771** [SQLITE_BUSY] is returned to the caller. ^In this case the call to
67726772** sqlite3_backup_step() can be retried later. ^If the source
67736773** [database connection]
r31374r31375
67756775** is called, then [SQLITE_LOCKED] is returned immediately. ^Again, in this
67766776** case the call to sqlite3_backup_step() can be retried later on. ^(If
67776777** [SQLITE_IOERR_ACCESS | SQLITE_IOERR_XXX], [SQLITE_NOMEM], or
6778** [SQLITE_READONLY] is returned, then
6779** there is no point in retrying the call to sqlite3_backup_step(). These
6780** errors are considered fatal.)^  The application must accept
6781** that the backup operation has failed and pass the backup operation handle
6778** [SQLITE_READONLY] is returned, then
6779** there is no point in retrying the call to sqlite3_backup_step(). These
6780** errors are considered fatal.)^  The application must accept
6781** that the backup operation has failed and pass the backup operation handle
67826782** to the sqlite3_backup_finish() to release associated resources.
67836783**
67846784** ^The first call to sqlite3_backup_step() obtains an exclusive lock
6785** on the destination file. ^The exclusive lock is not released until either
6786** sqlite3_backup_finish() is called or the backup operation is complete
6785** on the destination file. ^The exclusive lock is not released until either
6786** sqlite3_backup_finish() is called or the backup operation is complete
67876787** and sqlite3_backup_step() returns [SQLITE_DONE].  ^Every call to
67886788** sqlite3_backup_step() obtains a [shared lock] on the source database that
67896789** lasts for the duration of the sqlite3_backup_step() call.
r31374r31375
67926792** through the backup process.  ^If the source database is modified by an
67936793** external process or via a database connection other than the one being
67946794** used by the backup operation, then the backup will be automatically
6795** restarted by the next call to sqlite3_backup_step(). ^If the source
6795** restarted by the next call to sqlite3_backup_step(). ^If the source
67966796** database is modified by the using the same database connection as is used
67976797** by the backup operation, then the backup database is automatically
67986798** updated at the same time.
67996799**
68006800** [[sqlite3_backup_finish()]] <b>sqlite3_backup_finish()</b>
68016801**
6802** When sqlite3_backup_step() has returned [SQLITE_DONE], or when the
6802** When sqlite3_backup_step() has returned [SQLITE_DONE], or when the
68036803** application wishes to abandon the backup operation, the application
68046804** should destroy the [sqlite3_backup] by passing it to sqlite3_backup_finish().
68056805** ^The sqlite3_backup_finish() interfaces releases all
6806** resources associated with the [sqlite3_backup] object.
6806** resources associated with the [sqlite3_backup] object.
68076807** ^If sqlite3_backup_step() has not yet returned [SQLITE_DONE], then any
68086808** active write-transaction on the destination database is rolled back.
68096809** The [sqlite3_backup] object is invalid
r31374r31375
68436843** connections, then the source database connection may be used concurrently
68446844** from within other threads.
68456845**
6846** However, the application must guarantee that the destination
6847** [database connection] is not passed to any other API (by any thread) after
6846** However, the application must guarantee that the destination
6847** [database connection] is not passed to any other API (by any thread) after
68486848** sqlite3_backup_init() is called and before the corresponding call to
68496849** sqlite3_backup_finish().  SQLite does not currently check to see
68506850** if the application incorrectly accesses the destination [database connection]
r31374r31375
68556855** If running in [shared cache mode], the application must
68566856** guarantee that the shared cache used by the destination database
68576857** is not accessed while the backup is running. In practice this means
6858** that the application must guarantee that the disk file being
6858** that the application must guarantee that the disk file being
68596859** backed up to is not accessed by any connection within the process,
68606860** not just the specific connection that was passed to sqlite3_backup_init().
68616861**
6862** The [sqlite3_backup] object itself is partially threadsafe. Multiple
6862** The [sqlite3_backup] object itself is partially threadsafe. Multiple
68636863** threads may safely make multiple concurrent calls to sqlite3_backup_step().
68646864** However, the sqlite3_backup_remaining() and sqlite3_backup_pagecount()
68656865** APIs are not strictly speaking threadsafe. If they are invoked at the
r31374r31375
68676867** possible that they return invalid values.
68686868*/
68696869SQLITE_API sqlite3_backup *sqlite3_backup_init(
6870  sqlite3 *pDest,                        /* Destination database handle */
6871  const char *zDestName,                 /* Destination database name */
6872  sqlite3 *pSource,                      /* Source database handle */
6873  const char *zSourceName                /* Source database name */
6870   sqlite3 *pDest,                        /* Destination database handle */
6871   const char *zDestName,                 /* Destination database name */
6872   sqlite3 *pSource,                      /* Source database handle */
6873   const char *zSourceName                /* Source database name */
68746874);
68756875SQLITE_API int sqlite3_backup_step(sqlite3_backup *p, int nPage);
68766876SQLITE_API int sqlite3_backup_finish(sqlite3_backup *p);
r31374r31375
68836883** ^When running in shared-cache mode, a database operation may fail with
68846884** an [SQLITE_LOCKED] error if the required locks on the shared-cache or
68856885** individual tables within the shared-cache cannot be obtained. See
6886** [SQLite Shared-Cache Mode] for a description of shared-cache locking.
6887** ^This API may be used to register a callback that SQLite will invoke
6886** [SQLite Shared-Cache Mode] for a description of shared-cache locking.
6887** ^This API may be used to register a callback that SQLite will invoke
68886888** when the connection currently holding the required lock relinquishes it.
68896889** ^This API is only available if the library was compiled with the
68906890** [SQLITE_ENABLE_UNLOCK_NOTIFY] C-preprocessor symbol defined.
r31374r31375
68926892** See Also: [Using the SQLite Unlock Notification Feature].
68936893**
68946894** ^Shared-cache locks are released when a database connection concludes
6895** its current transaction, either by committing it or rolling it back.
6895** its current transaction, either by committing it or rolling it back.
68966896**
68976897** ^When a connection (known as the blocked connection) fails to obtain a
68986898** shared-cache lock and SQLITE_LOCKED is returned to the caller, the
68996899** identity of the database connection (the blocking connection) that
6900** has locked the required resource is stored internally. ^After an
6900** has locked the required resource is stored internally. ^After an
69016901** application receives an SQLITE_LOCKED error, it may call the
6902** sqlite3_unlock_notify() method with the blocked connection handle as
6902** sqlite3_unlock_notify() method with the blocked connection handle as
69036903** the first argument to register for a callback that will be invoked
69046904** when the blocking connections current transaction is concluded. ^The
69056905** callback is invoked from within the [sqlite3_step] or [sqlite3_close]
r31374r31375
69136913**
69146914** ^If the blocked connection is attempting to obtain a write-lock on a
69156915** shared-cache table, and more than one other connection currently holds
6916** a read-lock on the same table, then SQLite arbitrarily selects one of
6916** a read-lock on the same table, then SQLite arbitrarily selects one of
69176917** the other connections to use as the blocking connection.
69186918**
6919** ^(There may be at most one unlock-notify callback registered by a
6919** ^(There may be at most one unlock-notify callback registered by a
69206920** blocked connection. If sqlite3_unlock_notify() is called when the
69216921** blocked connection already has a registered unlock-notify callback,
69226922** then the new callback replaces the old.)^ ^If sqlite3_unlock_notify() is
69236923** called with a NULL pointer as its second argument, then any existing
6924** unlock-notify callback is canceled. ^The blocked connections
6924** unlock-notify callback is canceled. ^The blocked connections
69256925** unlock-notify callback may also be canceled by closing the blocked
69266926** connection using [sqlite3_close()].
69276927**
r31374r31375
69346934**
69356935** <b>Callback Invocation Details</b>
69366936**
6937** When an unlock-notify callback is registered, the application provides a
6937** When an unlock-notify callback is registered, the application provides a
69386938** single void* pointer that is passed to the callback when it is invoked.
69396939** However, the signature of the callback function allows SQLite to pass
69406940** it an array of void* context pointers. The first argument passed to
r31374r31375
69476947** same callback function, then instead of invoking the callback function
69486948** multiple times, it is invoked once with the set of void* context pointers
69496949** specified by the blocked connections bundled together into an array.
6950** This gives the application an opportunity to prioritize any actions
6950** This gives the application an opportunity to prioritize any actions
69516951** related to the set of unblocked database connections.
69526952**
69536953** <b>Deadlock Detection</b>
69546954**
6955** Assuming that after registering for an unlock-notify callback a
6955** Assuming that after registering for an unlock-notify callback a
69566956** database waits for the callback to be issued before taking any further
69576957** action (a reasonable assumption), then using this API may cause the
69586958** application to deadlock. For example, if connection X is waiting for
r31374r31375
69756975**
69766976** <b>The "DROP TABLE" Exception</b>
69776977**
6978** When a call to [sqlite3_step()] returns SQLITE_LOCKED, it is almost
6978** When a call to [sqlite3_step()] returns SQLITE_LOCKED, it is almost
69796979** always appropriate to call sqlite3_unlock_notify(). There is however,
69806980** one exception. When executing a "DROP TABLE" or "DROP INDEX" statement,
69816981** SQLite checks if there are any currently executing SELECT statements
r31374r31375
69886988** One way around this problem is to check the extended error code returned
69896989** by an sqlite3_step() call. ^(If there is a blocking connection, then the
69906990** extended error code is set to SQLITE_LOCKED_SHAREDCACHE. Otherwise, in
6991** the special "DROP TABLE/INDEX" case, the extended error code is just
6991** the special "DROP TABLE/INDEX" case, the extended error code is just
69926992** SQLITE_LOCKED.)^
69936993*/
69946994SQLITE_API int sqlite3_unlock_notify(
6995  sqlite3 *pBlocked,                          /* Waiting connection */
6996  void (*xNotify)(void **apArg, int nArg),    /* Callback function to invoke */
6997  void *pNotifyArg                            /* Argument to pass to xNotify */
6995   sqlite3 *pBlocked,                          /* Waiting connection */
6996   void (*xNotify)(void **apArg, int nArg),    /* Callback function to invoke */
6997   void *pNotifyArg                            /* Argument to pass to xNotify */
69986998);
69996999
70007000
r31374r31375
70537053** ^The [sqlite3_wal_hook()] function is used to register a callback that
70547054** will be invoked each time a database connection commits data to a
70557055** [write-ahead log] (i.e. whenever a transaction is committed in
7056** [journal_mode | journal_mode=WAL mode]).
7056** [journal_mode | journal_mode=WAL mode]).
70577057**
7058** ^The callback is invoked by SQLite after the commit has taken place and
7059** the associated write-lock on the database released, so the implementation
7058** ^The callback is invoked by SQLite after the commit has taken place and
7059** the associated write-lock on the database released, so the implementation
70607060** may read, write or [checkpoint] the database as required.
70617061**
70627062** ^The first parameter passed to the callback function when it is invoked
r31374r31375
70757075** that does not correspond to any valid SQLite error code, the results
70767076** are undefined.
70777077**
7078** A single database handle may have at most a single write-ahead log callback
7078** A single database handle may have at most a single write-ahead log callback
70797079** registered at one time. ^Calling [sqlite3_wal_hook()] replaces any
70807080** previously registered write-ahead log callback. ^Note that the
70817081** [sqlite3_wal_autocheckpoint()] interface and the
r31374r31375
70837083** those overwrite any prior [sqlite3_wal_hook()] settings.
70847084*/
70857085SQLITE_API void *sqlite3_wal_hook(
7086  sqlite3*,
7087  int(*)(void *,sqlite3*,const char*,int),
7088  void*
7086   sqlite3*,
7087   int(*)(void *,sqlite3*,const char*,int),
7088   void*
70897089);
70907090
70917091/*
r31374r31375
70957095** [sqlite3_wal_hook()] that causes any database on [database connection] D
70967096** to automatically [checkpoint]
70977097** after committing a transaction if there are N or
7098** more frames in the [write-ahead log] file.  ^Passing zero or
7098** more frames in the [write-ahead log] file.  ^Passing zero or
70997099** a negative value as the nFrame parameter disables automatic
71007100** checkpoints entirely.
71017101**
r31374r31375
71367136/*
71377137** CAPI3REF: Checkpoint a database
71387138**
7139** Run a checkpoint operation on WAL database zDb attached to database
7140** handle db. The specific operation is determined by the value of the
7139** Run a checkpoint operation on WAL database zDb attached to database
7140** handle db. The specific operation is determined by the value of the
71417141** eMode parameter:
71427142**
71437143** <dl>
71447144** <dt>SQLITE_CHECKPOINT_PASSIVE<dd>
7145**   Checkpoint as many frames as possible without waiting for any database
7145**   Checkpoint as many frames as possible without waiting for any database
71467146**   readers or writers to finish. Sync the db file if all frames in the log
7147**   are checkpointed. This mode is the same as calling
7147**   are checkpointed. This mode is the same as calling
71487148**   sqlite3_wal_checkpoint(). The busy-handler callback is never invoked.
71497149**
71507150** <dt>SQLITE_CHECKPOINT_FULL<dd>
r31374r31375
71557155**   but not database readers.
71567156**
71577157** <dt>SQLITE_CHECKPOINT_RESTART<dd>
7158**   This mode works the same way as SQLITE_CHECKPOINT_FULL, except after
7158**   This mode works the same way as SQLITE_CHECKPOINT_FULL, except after
71597159**   checkpointing the log file it blocks (calls the busy-handler callback)
7160**   until all readers are reading from the database file only. This ensures
7161**   that the next client to write to the database file restarts the log file
7160**   until all readers are reading from the database file only. This ensures
7161**   that the next client to write to the database file restarts the log file
71627162**   from the beginning. This call blocks database writers while it is running,
71637163**   but not database readers.
71647164** </dl>
r31374r31375
71727172** before returning to communicate this to the caller.
71737173**
71747174** All calls obtain an exclusive "checkpoint" lock on the database file. If
7175** any other process is running a checkpoint operation at the same time, the
7176** lock cannot be obtained and SQLITE_BUSY is returned. Even if there is a
7175** any other process is running a checkpoint operation at the same time, the
7176** lock cannot be obtained and SQLITE_BUSY is returned. Even if there is a
71777177** busy-handler configured, it will not be invoked in this case.
71787178**
7179** The SQLITE_CHECKPOINT_FULL and RESTART modes also obtain the exclusive
7179** The SQLITE_CHECKPOINT_FULL and RESTART modes also obtain the exclusive
71807180** "writer" lock on the database file. If the writer lock cannot be obtained
71817181** immediately, and a busy-handler is configured, it is invoked and the writer
71827182** lock retried until either the busy-handler returns 0 or the lock is
71837183** successfully obtained. The busy-handler is also invoked while waiting for
71847184** database readers as described above. If the busy-handler returns 0 before
71857185** the writer lock is obtained or while waiting for database readers, the
7186** checkpoint operation proceeds from that point in the same way as
7187** SQLITE_CHECKPOINT_PASSIVE - checkpointing as many frames as possible
7186** checkpoint operation proceeds from that point in the same way as
7187** SQLITE_CHECKPOINT_PASSIVE - checkpointing as many frames as possible
71887188** without blocking any further. SQLITE_BUSY is returned in this case.
71897189**
71907190** If parameter zDb is NULL or points to a zero length string, then the
71917191** specified operation is attempted on all WAL databases. In this case the
7192** values written to output parameters *pnLog and *pnCkpt are undefined. If
7193** an SQLITE_BUSY error is encountered when processing one or more of the
7194** attached WAL databases, the operation is still attempted on any remaining
7195** attached databases and SQLITE_BUSY is returned to the caller. If any other
7196** error occurs while processing an attached database, processing is abandoned
7197** and the error code returned to the caller immediately. If no error
7198** (SQLITE_BUSY or otherwise) is encountered while processing the attached
7192** values written to output parameters *pnLog and *pnCkpt are undefined. If
7193** an SQLITE_BUSY error is encountered when processing one or more of the
7194** attached WAL databases, the operation is still attempted on any remaining
7195** attached databases and SQLITE_BUSY is returned to the caller. If any other
7196** error occurs while processing an attached database, processing is abandoned
7197** and the error code returned to the caller immediately. If no error
7198** (SQLITE_BUSY or otherwise) is encountered while processing the attached
71997199** databases, SQLITE_OK is returned.
72007200**
72017201** If database zDb is the name of an attached database that is not in WAL
r31374r31375
72047204** attached database, SQLITE_ERROR is returned to the caller.
72057205*/
72067206SQLITE_API int sqlite3_wal_checkpoint_v2(
7207  sqlite3 *db,                    /* Database handle */
7208  const char *zDb,                /* Name of attached database (or NULL) */
7209  int eMode,                      /* SQLITE_CHECKPOINT_* value */
7210  int *pnLog,                     /* OUT: Size of WAL log in frames */
7211  int *pnCkpt                     /* OUT: Total number of frames checkpointed */
7207   sqlite3 *db,                    /* Database handle */
7208   const char *zDb,                /* Name of attached database (or NULL) */
7209   int eMode,                      /* SQLITE_CHECKPOINT_* value */
7210   int *pnLog,                     /* OUT: Size of WAL log in frames */
7211   int *pnCkpt                     /* OUT: Total number of frames checkpointed */
72127212);
72137213
72147214/*
r31374r31375
72617261** If X is non-zero, then the virtual table implementation guarantees
72627262** that if [xUpdate] returns [SQLITE_CONSTRAINT], it will do so before
72637263** any modifications to internal or persistent data structures have been made.
7264** If the [ON CONFLICT] mode is ABORT, FAIL, IGNORE or ROLLBACK, SQLite
7264** If the [ON CONFLICT] mode is ABORT, FAIL, IGNORE or ROLLBACK, SQLite
72657265** is able to roll back a statement or database transaction, and abandon
7266** or continue processing the current SQL statement as appropriate.
7266** or continue processing the current SQL statement as appropriate.
72677267** If the ON CONFLICT mode is REPLACE and the [xUpdate] method returns
72687268** [SQLITE_CONSTRAINT], SQLite handles this as if the ON CONFLICT mode
72697269** had been ABORT.
72707270**
72717271** Virtual table implementations that are required to handle OR REPLACE
7272** must do so within the [xUpdate] method. If a call to the
7273** [sqlite3_vtab_on_conflict()] function indicates that the current ON
7274** CONFLICT policy is REPLACE, the virtual table implementation should
7272** must do so within the [xUpdate] method. If a call to the
7273** [sqlite3_vtab_on_conflict()] function indicates that the current ON
7274** CONFLICT policy is REPLACE, the virtual table implementation should
72757275** silently replace the appropriate rows within the xUpdate callback and
72767276** return SQLITE_OK. Or, if this is not possible, it may return
7277** SQLITE_CONSTRAINT, in which case SQLite falls back to OR ABORT
7277** SQLITE_CONSTRAINT, in which case SQLite falls back to OR ABORT
72787278** constraint handling.
72797279** </dl>
72807280*/
r31374r31375
73547354**   SELECT ... FROM <rtree> WHERE <rtree col> MATCH $zGeom(... params ...)
73557355*/
73567356SQLITE_API int sqlite3_rtree_geometry_callback(
7357  sqlite3 *db,
7358  const char *zGeom,
7357   sqlite3 *db,
7358   const char *zGeom,
73597359#ifdef SQLITE_RTREE_INT_ONLY
7360  int (*xGeom)(sqlite3_rtree_geometry*, int n, sqlite3_int64 *a, int *pRes),
7360   int (*xGeom)(sqlite3_rtree_geometry*, int n, sqlite3_int64 *a, int *pRes),
73617361#else
7362  int (*xGeom)(sqlite3_rtree_geometry*, int n, double *a, int *pRes),
7362   int (*xGeom)(sqlite3_rtree_geometry*, int n, double *a, int *pRes),
73637363#endif
7364  void *pContext
7364   void *pContext
73657365);
73667366
73677367
r31374r31375
73707370** argument to callbacks registered using rtree_geometry_callback().
73717371*/
73727372struct sqlite3_rtree_geometry {
7373  void *pContext;                 /* Copy of pContext passed to s_r_g_c() */
7374  int nParam;                     /* Size of array aParam[] */
7375  double *aParam;                 /* Parameters passed to SQL geom function */
7376  void *pUser;                    /* Callback implementation user data */
7377  void (*xDelUser)(void *);       /* Called by SQLite to clean up pUser */
7373   void *pContext;                 /* Copy of pContext passed to s_r_g_c() */
7374   int nParam;                     /* Size of array aParam[] */
7375   double *aParam;                 /* Parameters passed to SQL geom function */
7376   void *pUser;                    /* Callback implementation user data */
7377   void (*xDelUser)(void *);       /* Called by SQLite to clean up pUser */
73787378};
73797379
73807380
r31374r31375
73837383#endif
73847384
73857385#endif  /* ifndef _SQLITE3RTREE_H_ */
7386
trunk/src/lib/sqlite3/sqlite3ext.h
r31374r31375
1212** This header file defines the SQLite interface for use by
1313** shared libraries that want to be imported as extensions into
1414** an SQLite instance.  Shared libraries that intend to be loaded
15** as extensions by SQLite should #include this file instead of
15** as extensions by SQLite should #include this file instead of
1616** sqlite3.h.
1717*/
1818#ifndef _SQLITE3EXT_H_
r31374r31375
3232** libraries!
3333*/
3434struct sqlite3_api_routines {
35  void * (*aggregate_context)(sqlite3_context*,int nBytes);
36  int  (*aggregate_count)(sqlite3_context*);
37  int  (*bind_blob)(sqlite3_stmt*,int,const void*,int n,void(*)(void*));
38  int  (*bind_double)(sqlite3_stmt*,int,double);
39  int  (*bind_int)(sqlite3_stmt*,int,int);
40  int  (*bind_int64)(sqlite3_stmt*,int,sqlite_int64);
41  int  (*bind_null)(sqlite3_stmt*,int);
42  int  (*bind_parameter_count)(sqlite3_stmt*);
43  int  (*bind_parameter_index)(sqlite3_stmt*,const char*zName);
44  const char * (*bind_parameter_name)(sqlite3_stmt*,int);
45  int  (*bind_text)(sqlite3_stmt*,int,const char*,int n,void(*)(void*));
46  int  (*bind_text16)(sqlite3_stmt*,int,const void*,int,void(*)(void*));
47  int  (*bind_value)(sqlite3_stmt*,int,const sqlite3_value*);
48  int  (*busy_handler)(sqlite3*,int(*)(void*,int),void*);
49  int  (*busy_timeout)(sqlite3*,int ms);
50  int  (*changes)(sqlite3*);
51  int  (*close)(sqlite3*);
52  int  (*collation_needed)(sqlite3*,void*,void(*)(void*,sqlite3*,
53                           int eTextRep,const char*));
54  int  (*collation_needed16)(sqlite3*,void*,void(*)(void*,sqlite3*,
55                             int eTextRep,const void*));
56  const void * (*column_blob)(sqlite3_stmt*,int iCol);
57  int  (*column_bytes)(sqlite3_stmt*,int iCol);
58  int  (*column_bytes16)(sqlite3_stmt*,int iCol);
59  int  (*column_count)(sqlite3_stmt*pStmt);
60  const char * (*column_database_name)(sqlite3_stmt*,int);
61  const void * (*column_database_name16)(sqlite3_stmt*,int);
62  const char * (*column_decltype)(sqlite3_stmt*,int i);
63  const void * (*column_decltype16)(sqlite3_stmt*,int);
64  double  (*column_double)(sqlite3_stmt*,int iCol);
65  int  (*column_int)(sqlite3_stmt*,int iCol);
66  sqlite_int64  (*column_int64)(sqlite3_stmt*,int iCol);
67  const char * (*column_name)(sqlite3_stmt*,int);
68  const void * (*column_name16)(sqlite3_stmt*,int);
69  const char * (*column_origin_name)(sqlite3_stmt*,int);
70  const void * (*column_origin_name16)(sqlite3_stmt*,int);
71  const char * (*column_table_name)(sqlite3_stmt*,int);
72  const void * (*column_table_name16)(sqlite3_stmt*,int);
73  const unsigned char * (*column_text)(sqlite3_stmt*,int iCol);
74  const void * (*column_text16)(sqlite3_stmt*,int iCol);
75  int  (*column_type)(sqlite3_stmt*,int iCol);
76  sqlite3_value* (*column_value)(sqlite3_stmt*,int iCol);
77  void * (*commit_hook)(sqlite3*,int(*)(void*),void*);
78  int  (*complete)(const char*sql);
79  int  (*complete16)(const void*sql);
80  int  (*create_collation)(sqlite3*,const char*,int,void*,
81                           int(*)(void*,int,const void*,int,const void*));
82  int  (*create_collation16)(sqlite3*,const void*,int,void*,
83                             int(*)(void*,int,const void*,int,const void*));
84  int  (*create_function)(sqlite3*,const char*,int,int,void*,
85                          void (*xFunc)(sqlite3_context*,int,sqlite3_value**),
86                          void (*xStep)(sqlite3_context*,int,sqlite3_value**),
87                          void (*xFinal)(sqlite3_context*));
88  int  (*create_function16)(sqlite3*,const void*,int,int,void*,
89                            void (*xFunc)(sqlite3_context*,int,sqlite3_value**),
90                            void (*xStep)(sqlite3_context*,int,sqlite3_value**),
91                            void (*xFinal)(sqlite3_context*));
92  int (*create_module)(sqlite3*,const char*,const sqlite3_module*,void*);
93  int  (*data_count)(sqlite3_stmt*pStmt);
94  sqlite3 * (*db_handle)(sqlite3_stmt*);
95  int (*declare_vtab)(sqlite3*,const char*);
96  int  (*enable_shared_cache)(int);
97  int  (*errcode)(sqlite3*db);
98  const char * (*errmsg)(sqlite3*);
99  const void * (*errmsg16)(sqlite3*);
100  int  (*exec)(sqlite3*,const char*,sqlite3_callback,void*,char**);
101  int  (*expired)(sqlite3_stmt*);
102  int  (*finalize)(sqlite3_stmt*pStmt);
103  void  (*free)(void*);
104  void  (*free_table)(char**result);
105  int  (*get_autocommit)(sqlite3*);
106  void * (*get_auxdata)(sqlite3_context*,int);
107  int  (*get_table)(sqlite3*,const char*,char***,int*,int*,char**);
108  int  (*global_recover)(void);
109  void  (*interruptx)(sqlite3*);
110  sqlite_int64  (*last_insert_rowid)(sqlite3*);
111  const char * (*libversion)(void);
112  int  (*libversion_number)(void);
113  void *(*malloc)(int);
114  char * (*mprintf)(const char*,...);
115  int  (*open)(const char*,sqlite3**);
116  int  (*open16)(const void*,sqlite3**);
117  int  (*prepare)(sqlite3*,const char*,int,sqlite3_stmt**,const char**);
118  int  (*prepare16)(sqlite3*,const void*,int,sqlite3_stmt**,const void**);
119  void * (*profile)(sqlite3*,void(*)(void*,const char*,sqlite_uint64),void*);
120  void  (*progress_handler)(sqlite3*,int,int(*)(void*),void*);
121  void *(*realloc)(void*,int);
122  int  (*reset)(sqlite3_stmt*pStmt);
123  void  (*result_blob)(sqlite3_context*,const void*,int,void(*)(void*));
124  void  (*result_double)(sqlite3_context*,double);
125  void  (*result_error)(sqlite3_context*,const char*,int);
126  void  (*result_error16)(sqlite3_context*,const void*,int);
127  void  (*result_int)(sqlite3_context*,int);
128  void  (*result_int64)(sqlite3_context*,sqlite_int64);
129  void  (*result_null)(sqlite3_context*);
130  void  (*result_text)(sqlite3_context*,const char*,int,void(*)(void*));
131  void  (*result_text16)(sqlite3_context*,const void*,int,void(*)(void*));
132  void  (*result_text16be)(sqlite3_context*,const void*,int,void(*)(void*));
133  void  (*result_text16le)(sqlite3_context*,const void*,int,void(*)(void*));
134  void  (*result_value)(sqlite3_context*,sqlite3_value*);
135  void * (*rollback_hook)(sqlite3*,void(*)(void*),void*);
136  int  (*set_authorizer)(sqlite3*,int(*)(void*,int,const char*,const char*,
137                         const char*,const char*),void*);
138  void  (*set_auxdata)(sqlite3_context*,int,void*,void (*)(void*));
139  char * (*snprintf)(int,char*,const char*,...);
140  int  (*step)(sqlite3_stmt*);
141  int  (*table_column_metadata)(sqlite3*,const char*,const char*,const char*,
142                                char const**,char const**,int*,int*,int*);
143  void  (*thread_cleanup)(void);
144  int  (*total_changes)(sqlite3*);
145  void * (*trace)(sqlite3*,void(*xTrace)(void*,const char*),void*);
146  int  (*transfer_bindings)(sqlite3_stmt*,sqlite3_stmt*);
147  void * (*update_hook)(sqlite3*,void(*)(void*,int ,char const*,char const*,
148                                         sqlite_int64),void*);
149  void * (*user_data)(sqlite3_context*);
150  const void * (*value_blob)(sqlite3_value*);
151  int  (*value_bytes)(sqlite3_value*);
152  int  (*value_bytes16)(sqlite3_value*);
153  double  (*value_double)(sqlite3_value*);
154  int  (*value_int)(sqlite3_value*);
155  sqlite_int64  (*value_int64)(sqlite3_value*);
156  int  (*value_numeric_type)(sqlite3_value*);
157  const unsigned char * (*value_text)(sqlite3_value*);
158  const void * (*value_text16)(sqlite3_value*);
159  const void * (*value_text16be)(sqlite3_value*);
160  const void * (*value_text16le)(sqlite3_value*);
161  int  (*value_type)(sqlite3_value*);
162  char *(*vmprintf)(const char*,va_list);
163  /* Added ??? */
164  int (*overload_function)(sqlite3*, const char *zFuncName, int nArg);
165  /* Added by 3.3.13 */
166  int (*prepare_v2)(sqlite3*,const char*,int,sqlite3_stmt**,const char**);
167  int (*prepare16_v2)(sqlite3*,const void*,int,sqlite3_stmt**,const void**);
168  int (*clear_bindings)(sqlite3_stmt*);
169  /* Added by 3.4.1 */
170  int (*create_module_v2)(sqlite3*,const char*,const sqlite3_module*,void*,
171                          void (*xDestroy)(void *));
172  /* Added by 3.5.0 */
173  int (*bind_zeroblob)(sqlite3_stmt*,int,int);
174  int (*blob_bytes)(sqlite3_blob*);
175  int (*blob_close)(sqlite3_blob*);
176  int (*blob_open)(sqlite3*,const char*,const char*,const char*,sqlite3_int64,
177                   int,sqlite3_blob**);
178  int (*blob_read)(sqlite3_blob*,void*,int,int);
179  int (*blob_write)(sqlite3_blob*,const void*,int,int);
180  int (*create_collation_v2)(sqlite3*,const char*,int,void*,
181                             int(*)(void*,int,const void*,int,const void*),
182                             void(*)(void*));
183  int (*file_control)(sqlite3*,const char*,int,void*);
184  sqlite3_int64 (*memory_highwater)(int);
185  sqlite3_int64 (*memory_used)(void);
186  sqlite3_mutex *(*mutex_alloc)(int);
187  void (*mutex_enter)(sqlite3_mutex*);
188  void (*mutex_free)(sqlite3_mutex*);
189  void (*mutex_leave)(sqlite3_mutex*);
190  int (*mutex_try)(sqlite3_mutex*);
191  int (*open_v2)(const char*,sqlite3**,int,const char*);
192  int (*release_memory)(int);
193  void (*result_error_nomem)(sqlite3_context*);
194  void (*result_error_toobig)(sqlite3_context*);
195  int (*sleep)(int);
196  void (*soft_heap_limit)(int);
197  sqlite3_vfs *(*vfs_find)(const char*);
198  int (*vfs_register)(sqlite3_vfs*,int);
199  int (*vfs_unregister)(sqlite3_vfs*);
200  int (*xthreadsafe)(void);
201  void (*result_zeroblob)(sqlite3_context*,int);
202  void (*result_error_code)(sqlite3_context*,int);
203  int (*test_control)(int, ...);
204  void (*randomness)(int,void*);
205  sqlite3 *(*context_db_handle)(sqlite3_context*);
206  int (*extended_result_codes)(sqlite3*,int);
207  int (*limit)(sqlite3*,int,int);
208  sqlite3_stmt *(*next_stmt)(sqlite3*,sqlite3_stmt*);
209  const char *(*sql)(sqlite3_stmt*);
210  int (*status)(int,int*,int*,int);
211  int (*backup_finish)(sqlite3_backup*);
212  sqlite3_backup *(*backup_init)(sqlite3*,const char*,sqlite3*,const char*);
213  int (*backup_pagecount)(sqlite3_backup*);
214  int (*backup_remaining)(sqlite3_backup*);
215  int (*backup_step)(sqlite3_backup*,int);
216  const char *(*compileoption_get)(int);
217  int (*compileoption_used)(const char*);
218  int (*create_function_v2)(sqlite3*,const char*,int,int,void*,
219                            void (*xFunc)(sqlite3_context*,int,sqlite3_value**),
220                            void (*xStep)(sqlite3_context*,int,sqlite3_value**),
221                            void (*xFinal)(sqlite3_context*),
222                            void(*xDestroy)(void*));
223  int (*db_config)(sqlite3*,int,...);
224  sqlite3_mutex *(*db_mutex)(sqlite3*);
225  int (*db_status)(sqlite3*,int,int*,int*,int);
226  int (*extended_errcode)(sqlite3*);
227  void (*log)(int,const char*,...);
228  sqlite3_int64 (*soft_heap_limit64)(sqlite3_int64);
229  const char *(*sourceid)(void);
230  int (*stmt_status)(sqlite3_stmt*,int,int);
231  int (*strnicmp)(const char*,const char*,int);
232  int (*unlock_notify)(sqlite3*,void(*)(void**,int),void*);
233  int (*wal_autocheckpoint)(sqlite3*,int);
234  int (*wal_checkpoint)(sqlite3*,const char*);
235  void *(*wal_hook)(sqlite3*,int(*)(void*,sqlite3*,const char*,int),void*);
236  int (*blob_reopen)(sqlite3_blob*,sqlite3_int64);
237  int (*vtab_config)(sqlite3*,int op,...);
238  int (*vtab_on_conflict)(sqlite3*);
239  /* Version 3.7.16 and later */
240  int (*close_v2)(sqlite3*);
241  const char *(*db_filename)(sqlite3*,const char*);
242  int (*db_readonly)(sqlite3*,const char*);
243  int (*db_release_memory)(sqlite3*);
244  const char *(*errstr)(int);
245  int (*stmt_busy)(sqlite3_stmt*);
246  int (*stmt_readonly)(sqlite3_stmt*);
247  int (*stricmp)(const char*,const char*);
248  int (*uri_boolean)(const char*,const char*,int);
249  sqlite3_int64 (*uri_int64)(const char*,const char*,sqlite3_int64);
250  const char *(*uri_parameter)(const char*,const char*);
251  char *(*vsnprintf)(int,char*,const char*,va_list);
252  int (*wal_checkpoint_v2)(sqlite3*,const char*,int,int*,int*);
35   void * (*aggregate_context)(sqlite3_context*,int nBytes);
36   int  (*aggregate_count)(sqlite3_context*);
37   int  (*bind_blob)(sqlite3_stmt*,int,const void*,int n,void(*)(void*));
38   int  (*bind_double)(sqlite3_stmt*,int,double);
39   int  (*bind_int)(sqlite3_stmt*,int,int);
40   int  (*bind_int64)(sqlite3_stmt*,int,sqlite_int64);
41   int  (*bind_null)(sqlite3_stmt*,int);
42   int  (*bind_parameter_count)(sqlite3_stmt*);
43   int  (*bind_parameter_index)(sqlite3_stmt*,const char*zName);
44   const char * (*bind_parameter_name)(sqlite3_stmt*,int);
45   int  (*bind_text)(sqlite3_stmt*,int,const char*,int n,void(*)(void*));
46   int  (*bind_text16)(sqlite3_stmt*,int,const void*,int,void(*)(void*));
47   int  (*bind_value)(sqlite3_stmt*,int,const sqlite3_value*);
48   int  (*busy_handler)(sqlite3*,int(*)(void*,int),void*);
49   int  (*busy_timeout)(sqlite3*,int ms);
50   int  (*changes)(sqlite3*);
51   int  (*close)(sqlite3*);
52   int  (*collation_needed)(sqlite3*,void*,void(*)(void*,sqlite3*,
53                     int eTextRep,const char*));
54   int  (*collation_needed16)(sqlite3*,void*,void(*)(void*,sqlite3*,
55                        int eTextRep,const void*));
56   const void * (*column_blob)(sqlite3_stmt*,int iCol);
57   int  (*column_bytes)(sqlite3_stmt*,int iCol);
58   int  (*column_bytes16)(sqlite3_stmt*,int iCol);
59   int  (*column_count)(sqlite3_stmt*pStmt);
60   const char * (*column_database_name)(sqlite3_stmt*,int);
61   const void * (*column_database_name16)(sqlite3_stmt*,int);
62   const char * (*column_decltype)(sqlite3_stmt*,int i);
63   const void * (*column_decltype16)(sqlite3_stmt*,int);
64   double  (*column_double)(sqlite3_stmt*,int iCol);
65   int  (*column_int)(sqlite3_stmt*,int iCol);
66   sqlite_int64  (*column_int64)(sqlite3_stmt*,int iCol);
67   const char * (*column_name)(sqlite3_stmt*,int);
68   const void * (*column_name16)(sqlite3_stmt*,int);
69   const char * (*column_origin_name)(sqlite3_stmt*,int);
70   const void * (*column_origin_name16)(sqlite3_stmt*,int);
71   const char * (*column_table_name)(sqlite3_stmt*,int);
72   const void * (*column_table_name16)(sqlite3_stmt*,int);
73   const unsigned char * (*column_text)(sqlite3_stmt*,int iCol);
74   const void * (*column_text16)(sqlite3_stmt*,int iCol);
75   int  (*column_type)(sqlite3_stmt*,int iCol);
76   sqlite3_value* (*column_value)(sqlite3_stmt*,int iCol);
77   void * (*commit_hook)(sqlite3*,int(*)(void*),void*);
78   int  (*complete)(const char*sql);
79   int  (*complete16)(const void*sql);
80   int  (*create_collation)(sqlite3*,const char*,int,void*,
81                     int(*)(void*,int,const void*,int,const void*));
82   int  (*create_collation16)(sqlite3*,const void*,int,void*,
83                        int(*)(void*,int,const void*,int,const void*));
84   int  (*create_function)(sqlite3*,const char*,int,int,void*,
85                     void (*xFunc)(sqlite3_context*,int,sqlite3_value**),
86                     void (*xStep)(sqlite3_context*,int,sqlite3_value**),
87                     void (*xFinal)(sqlite3_context*));
88   int  (*create_function16)(sqlite3*,const void*,int,int,void*,
89                     void (*xFunc)(sqlite3_context*,int,sqlite3_value**),
90                     void (*xStep)(sqlite3_context*,int,sqlite3_value**),
91                     void (*xFinal)(sqlite3_context*));
92   int (*create_module)(sqlite3*,const char*,const sqlite3_module*,void*);
93   int  (*data_count)(sqlite3_stmt*pStmt);
94   sqlite3 * (*db_handle)(sqlite3_stmt*);
95   int (*declare_vtab)(sqlite3*,const char*);
96   int  (*enable_shared_cache)(int);
97   int  (*errcode)(sqlite3*db);
98   const char * (*errmsg)(sqlite3*);
99   const void * (*errmsg16)(sqlite3*);
100   int  (*exec)(sqlite3*,const char*,sqlite3_callback,void*,char**);
101   int  (*expired)(sqlite3_stmt*);
102   int  (*finalize)(sqlite3_stmt*pStmt);
103   void  (*free)(void*);
104   void  (*free_table)(char**result);
105   int  (*get_autocommit)(sqlite3*);
106   void * (*get_auxdata)(sqlite3_context*,int);
107   int  (*get_table)(sqlite3*,const char*,char***,int*,int*,char**);
108   int  (*global_recover)(void);
109   void  (*interruptx)(sqlite3*);
110   sqlite_int64  (*last_insert_rowid)(sqlite3*);
111   const char * (*libversion)(void);
112   int  (*libversion_number)(void);
113   void *(*malloc)(int);
114   char * (*mprintf)(const char*,...);
115   int  (*open)(const char*,sqlite3**);
116   int  (*open16)(const void*,sqlite3**);
117   int  (*prepare)(sqlite3*,const char*,int,sqlite3_stmt**,const char**);
118   int  (*prepare16)(sqlite3*,const void*,int,sqlite3_stmt**,const void**);
119   void * (*profile)(sqlite3*,void(*)(void*,const char*,sqlite_uint64),void*);
120   void  (*progress_handler)(sqlite3*,int,int(*)(void*),void*);
121   void *(*realloc)(void*,int);
122   int  (*reset)(sqlite3_stmt*pStmt);
123   void  (*result_blob)(sqlite3_context*,const void*,int,void(*)(void*));
124   void  (*result_double)(sqlite3_context*,double);
125   void  (*result_error)(sqlite3_context*,const char*,int);
126   void  (*result_error16)(sqlite3_context*,const void*,int);
127   void  (*result_int)(sqlite3_context*,int);
128   void  (*result_int64)(sqlite3_context*,sqlite_int64);
129   void  (*result_null)(sqlite3_context*);
130   void  (*result_text)(sqlite3_context*,const char*,int,void(*)(void*));
131   void  (*result_text16)(sqlite3_context*,const void*,int,void(*)(void*));
132   void  (*result_text16be)(sqlite3_context*,const void*,int,void(*)(void*));
133   void  (*result_text16le)(sqlite3_context*,const void*,int,void(*)(void*));
134   void  (*result_value)(sqlite3_context*,sqlite3_value*);
135   void * (*rollback_hook)(sqlite3*,void(*)(void*),void*);
136   int  (*set_authorizer)(sqlite3*,int(*)(void*,int,const char*,const char*,
137                     const char*,const char*),void*);
138   void  (*set_auxdata)(sqlite3_context*,int,void*,void (*)(void*));
139   char * (*snprintf)(int,char*,const char*,...);
140   int  (*step)(sqlite3_stmt*);
141   int  (*table_column_metadata)(sqlite3*,const char*,const char*,const char*,
142                        char const**,char const**,int*,int*,int*);
143   void  (*thread_cleanup)(void);
144   int  (*total_changes)(sqlite3*);
145   void * (*trace)(sqlite3*,void(*xTrace)(void*,const char*),void*);
146   int  (*transfer_bindings)(sqlite3_stmt*,sqlite3_stmt*);
147   void * (*update_hook)(sqlite3*,void(*)(void*,int ,char const*,char const*,
148                                 sqlite_int64),void*);
149   void * (*user_data)(sqlite3_context*);
150   const void * (*value_blob)(sqlite3_value*);
151   int  (*value_bytes)(sqlite3_value*);
152   int  (*value_bytes16)(sqlite3_value*);
153   double  (*value_double)(sqlite3_value*);
154   int  (*value_int)(sqlite3_value*);
155   sqlite_int64  (*value_int64)(sqlite3_value*);
156   int  (*value_numeric_type)(sqlite3_value*);
157   const unsigned char * (*value_text)(sqlite3_value*);
158   const void * (*value_text16)(sqlite3_value*);
159   const void * (*value_text16be)(sqlite3_value*);
160   const void * (*value_text16le)(sqlite3_value*);
161   int  (*value_type)(sqlite3_value*);
162   char *(*vmprintf)(const char*,va_list);
163   /* Added ??? */
164   int (*overload_function)(sqlite3*, const char *zFuncName, int nArg);
165   /* Added by 3.3.13 */
166   int (*prepare_v2)(sqlite3*,const char*,int,sqlite3_stmt**,const char**);
167   int (*prepare16_v2)(sqlite3*,const void*,int,sqlite3_stmt**,const void**);
168   int (*clear_bindings)(sqlite3_stmt*);
169   /* Added by 3.4.1 */
170   int (*create_module_v2)(sqlite3*,const char*,const sqlite3_module*,void*,
171                     void (*xDestroy)(void *));
172   /* Added by 3.5.0 */
173   int (*bind_zeroblob)(sqlite3_stmt*,int,int);
174   int (*blob_bytes)(sqlite3_blob*);
175   int (*blob_close)(sqlite3_blob*);
176   int (*blob_open)(sqlite3*,const char*,const char*,const char*,sqlite3_int64,
177               int,sqlite3_blob**);
178   int (*blob_read)(sqlite3_blob*,void*,int,int);
179   int (*blob_write)(sqlite3_blob*,const void*,int,int);
180   int (*create_collation_v2)(sqlite3*,const char*,int,void*,
181                        int(*)(void*,int,const void*,int,const void*),
182                        void(*)(void*));
183   int (*file_control)(sqlite3*,const char*,int,void*);
184   sqlite3_int64 (*memory_highwater)(int);
185   sqlite3_int64 (*memory_used)(void);
186   sqlite3_mutex *(*mutex_alloc)(int);
187   void (*mutex_enter)(sqlite3_mutex*);
188   void (*mutex_free)(sqlite3_mutex*);
189   void (*mutex_leave)(sqlite3_mutex*);
190   int (*mutex_try)(sqlite3_mutex*);
191   int (*open_v2)(const char*,sqlite3**,int,const char*);
192   int (*release_memory)(int);
193   void (*result_error_nomem)(sqlite3_context*);
194   void (*result_error_toobig)(sqlite3_context*);
195   int (*sleep)(int);
196   void (*soft_heap_limit)(int);
197   sqlite3_vfs *(*vfs_find)(const char*);
198   int (*vfs_register)(sqlite3_vfs*,int);
199   int (*vfs_unregister)(sqlite3_vfs*);
200   int (*xthreadsafe)(void);
201   void (*result_zeroblob)(sqlite3_context*,int);
202   void (*result_error_code)(sqlite3_context*,int);
203   int (*test_control)(int, ...);
204   void (*randomness)(int,void*);
205   sqlite3 *(*context_db_handle)(sqlite3_context*);
206   int (*extended_result_codes)(sqlite3*,int);
207   int (*limit)(sqlite3*,int,int);
208   sqlite3_stmt *(*next_stmt)(sqlite3*,sqlite3_stmt*);
209   const char *(*sql)(sqlite3_stmt*);
210   int (*status)(int,int*,int*,int);
211   int (*backup_finish)(sqlite3_backup*);
212   sqlite3_backup *(*backup_init)(sqlite3*,const char*,sqlite3*,const char*);
213   int (*backup_pagecount)(sqlite3_backup*);
214   int (*backup_remaining)(sqlite3_backup*);
215   int (*backup_step)(sqlite3_backup*,int);
216   const char *(*compileoption_get)(int);
217   int (*compileoption_used)(const char*);
218   int (*create_function_v2)(sqlite3*,const char*,int,int,void*,
219                     void (*xFunc)(sqlite3_context*,int,sqlite3_value**),
220                     void (*xStep)(sqlite3_context*,int,sqlite3_value**),
221                     void (*xFinal)(sqlite3_context*),
222                     void(*xDestroy)(void*));
223   int (*db_config)(sqlite3*,int,...);
224   sqlite3_mutex *(*db_mutex)(sqlite3*);
225   int (*db_status)(sqlite3*,int,int*,int*,int);
226   int (*extended_errcode)(sqlite3*);
227   void (*log)(int,const char*,...);
228   sqlite3_int64 (*soft_heap_limit64)(sqlite3_int64);
229   const char *(*sourceid)(void);
230   int (*stmt_status)(sqlite3_stmt*,int,int);
231   int (*strnicmp)(const char*,const char*,int);
232   int (*unlock_notify)(sqlite3*,void(*)(void**,int),void*);
233   int (*wal_autocheckpoint)(sqlite3*,int);
234   int (*wal_checkpoint)(sqlite3*,const char*);
235   void *(*wal_hook)(sqlite3*,int(*)(void*,sqlite3*,const char*,int),void*);
236   int (*blob_reopen)(sqlite3_blob*,sqlite3_int64);
237   int (*vtab_config)(sqlite3*,int op,...);
238   int (*vtab_on_conflict)(sqlite3*);
239   /* Version 3.7.16 and later */
240   int (*close_v2)(sqlite3*);
241   const char *(*db_filename)(sqlite3*,const char*);
242   int (*db_readonly)(sqlite3*,const char*);
243   int (*db_release_memory)(sqlite3*);
244   const char *(*errstr)(int);
245   int (*stmt_busy)(sqlite3_stmt*);
246   int (*stmt_readonly)(sqlite3_stmt*);
247   int (*stricmp)(const char*,const char*);
248   int (*uri_boolean)(const char*,const char*,int);
249   sqlite3_int64 (*uri_int64)(const char*,const char*,sqlite3_int64);
250   const char *(*uri_parameter)(const char*,const char*);
251   char *(*vsnprintf)(int,char*,const char*,va_list);
252   int (*wal_checkpoint_v2)(sqlite3*,const char*,int,int*,int*);
253253};
254254
255255/*
r31374r31375
470470#endif /* SQLITE_CORE */
471471
472472#ifndef SQLITE_CORE
473  /* This case when the file really is being compiled as a loadable
474  ** extension */
473   /* This case when the file really is being compiled as a loadable
474   ** extension */
475475# define SQLITE_EXTENSION_INIT1     const sqlite3_api_routines *sqlite3_api=0;
476476# define SQLITE_EXTENSION_INIT2(v)  sqlite3_api=v;
477477# define SQLITE_EXTENSION_INIT3     \
478    extern const sqlite3_api_routines *sqlite3_api;
478   extern const sqlite3_api_routines *sqlite3_api;
479479#else
480  /* This case when the file is being statically linked into the
481  ** application */
480   /* This case when the file is being statically linked into the
481   ** application */
482482# define SQLITE_EXTENSION_INIT1     /*no-op*/
483483# define SQLITE_EXTENSION_INIT2(v)  (void)v; /* unused parameter */
484484# define SQLITE_EXTENSION_INIT3     /*no-op*/
trunk/src/lib/util/cdrom.h
r31374r31375
5656};
5757
5858#define CD_FLAG_GDROM   0x00000001  // disc is a GD-ROM, all tracks should be stored with GD-ROM metadata
59#define CD_FLAG_GDROMLE 0x00000002   // legacy GD-ROM, with little-endian CDDA data
59#define CD_FLAG_GDROMLE 0x00000002  // legacy GD-ROM, with little-endian CDDA data
6060
6161/***************************************************************************
6262    TYPE DEFINITIONS
trunk/src/lib/web/mongoose.h
r31374r31375
3131
3232// This structure contains information about HTTP request.
3333struct mg_connection {
34  const char *request_method; // "GET", "POST", etc
35  const char *uri;            // URL-decoded URI
36  const char *http_version;   // E.g. "1.0", "1.1"
37  const char *query_string;   // URL part after '?', not including '?', or NULL
34   const char *request_method; // "GET", "POST", etc
35   const char *uri;            // URL-decoded URI
36   const char *http_version;   // E.g. "1.0", "1.1"
37   const char *query_string;   // URL part after '?', not including '?', or NULL
3838
39  char remote_ip[48];         // Max IPv6 string length is 45 characters
40  char local_ip[48];          // Local IP address
41  unsigned short remote_port; // Client's port
42  unsigned short local_port;  // Local port number
39   char remote_ip[48];         // Max IPv6 string length is 45 characters
40   char local_ip[48];          // Local IP address
41   unsigned short remote_port; // Client's port
42   unsigned short local_port;  // Local port number
4343
44  int num_headers;            // Number of HTTP headers
45  struct mg_header {
46    const char *name;         // HTTP header name
47    const char *value;        // HTTP header value
48  } http_headers[30];
44   int num_headers;            // Number of HTTP headers
45   struct mg_header {
46   const char *name;         // HTTP header name
47   const char *value;        // HTTP header value
48   } http_headers[30];
4949
50  char *content;              // POST (or websocket message) data, or NULL
51  size_t content_len;         // Data length
50   char *content;              // POST (or websocket message) data, or NULL
51   size_t content_len;         // Data length
5252
53  int is_websocket;           // Connection is a websocket connection
54  int status_code;            // HTTP status code for HTTP error handler
55  int wsbits;                 // First byte of the websocket frame
56  void *server_param;         // Parameter passed to mg_add_uri_handler()
57  void *connection_param;     // Placeholder for connection-specific data
58  void *callback_param;       // Needed by mg_iterate_over_connections()
53   int is_websocket;           // Connection is a websocket connection
54   int status_code;            // HTTP status code for HTTP error handler
55   int wsbits;                 // First byte of the websocket frame
56   void *server_param;         // Parameter passed to mg_add_uri_handler()
57   void *connection_param;     // Placeholder for connection-specific data
58   void *callback_param;       // Needed by mg_iterate_over_connections()
5959};
6060
6161struct mg_server; // Opaque structure describing server instance
6262enum mg_result { MG_FALSE, MG_TRUE, MG_MORE };
6363enum mg_event {
64  MG_POLL = 100,  // Callback return value is ignored
65  MG_CONNECT,     // If callback returns MG_FALSE, connect fails
66  MG_AUTH,        // If callback returns MG_FALSE, authentication fails
67  MG_REQUEST,     // If callback returns MG_FALSE, Mongoose continues with req
68  MG_REPLY,       // If callback returns MG_FALSE, Mongoose closes connection
69  MG_CLOSE,       // Connection is closed, callback return value is ignored
70  MG_WS_HANDSHAKE,  // New websocket connection, handshake request
71  MG_WS_CONNECT,  // New websocket connection established
72  MG_HTTP_ERROR   // If callback returns MG_FALSE, Mongoose continues with err
64   MG_POLL = 100,  // Callback return value is ignored
65   MG_CONNECT,     // If callback returns MG_FALSE, connect fails
66   MG_AUTH,        // If callback returns MG_FALSE, authentication fails
67   MG_REQUEST,     // If callback returns MG_FALSE, Mongoose continues with req
68   MG_REPLY,       // If callback returns MG_FALSE, Mongoose closes connection
69   MG_CLOSE,       // Connection is closed, callback return value is ignored
70   MG_WS_HANDSHAKE,  // New websocket connection, handshake request
71   MG_WS_CONNECT,  // New websocket connection established
72   MG_HTTP_ERROR   // If callback returns MG_FALSE, Mongoose continues with err
7373};
7474typedef int (*mg_handler_t)(struct mg_connection *, enum mg_event);
7575
7676// Websocket opcodes, from http://tools.ietf.org/html/rfc6455
7777enum {
78  WEBSOCKET_OPCODE_CONTINUATION = 0x0,
79  WEBSOCKET_OPCODE_TEXT = 0x1,
80  WEBSOCKET_OPCODE_BINARY = 0x2,
81  WEBSOCKET_OPCODE_CONNECTION_CLOSE = 0x8,
82  WEBSOCKET_OPCODE_PING = 0x9,
83  WEBSOCKET_OPCODE_PONG = 0xa
78   WEBSOCKET_OPCODE_CONTINUATION = 0x0,
79   WEBSOCKET_OPCODE_TEXT = 0x1,
80   WEBSOCKET_OPCODE_BINARY = 0x2,
81   WEBSOCKET_OPCODE_CONNECTION_CLOSE = 0x8,
82   WEBSOCKET_OPCODE_PING = 0x9,
83   WEBSOCKET_OPCODE_PONG = 0xa
8484};
8585
8686// Server management functions
r31374r31375
107107size_t mg_printf(struct mg_connection *conn, const char *fmt, ...);
108108
109109size_t mg_websocket_write(struct mg_connection *, int opcode,
110                          const char *data, size_t data_len);
110                     const char *data, size_t data_len);
111111size_t mg_websocket_printf(struct mg_connection* conn, int opcode,
112                           const char *fmt, ...);
113                           
112                     const char *fmt, ...);
113
114114void mg_send_file(struct mg_connection *, const char *path);
115115
116116const char *mg_get_header(const struct mg_connection *, const char *name);
117117const char *mg_get_mime_type(const char *name, const char *default_mime_type);
118118int mg_get_var(const struct mg_connection *conn, const char *var_name,
119               char *buf, size_t buf_len);
119            char *buf, size_t buf_len);
120120int mg_parse_header(const char *hdr, const char *var_name, char *buf, size_t);
121121int mg_parse_multipart(const char *buf, int buf_len,
122                       char *var_name, int var_name_len,
123                       char *file_name, int file_name_len,
124                       const char **data, int *data_len);
122                  char *var_name, int var_name_len,
123                  char *file_name, int file_name_len,
124                  const char **data, int *data_len);
125125
126126// Utility functions
127127void *mg_start_thread(void *(*func)(void *), void *param);
r31374r31375
132132
133133// Templates support
134134struct mg_expansion {
135  const char *keyword;
136  void (*handler)(struct mg_connection *);
135   const char *keyword;
136   void (*handler)(struct mg_connection *);
137137};
138138void mg_template(struct mg_connection *, const char *text,
139                 struct mg_expansion *expansions);
139               struct mg_expansion *expansions);
140140
141141
142142#ifdef __cplusplus
trunk/src/lib/lua/lgc.h
r31374r31375
2929/* how much to allocate before next GC step */
3030#if !defined(GCSTEPSIZE)
3131/* ~100 small strings */
32#define GCSTEPSIZE   (cast_int(100 * sizeof(TString)))
32#define GCSTEPSIZE  (cast_int(100 * sizeof(TString)))
3333#endif
3434
3535
3636/*
3737** Possible states of the Garbage Collector
3838*/
39#define GCSpropagate   0
40#define GCSatomic   1
41#define GCSsweepstring   2
42#define GCSsweepudata   3
43#define GCSsweep   4
44#define GCSpause   5
39#define GCSpropagate    0
40#define GCSatomic   1
41#define GCSsweepstring  2
42#define GCSsweepudata   3
43#define GCSsweep    4
44#define GCSpause    5
4545
4646
4747#define issweepphase(g)  \
4848   (GCSsweepstring <= (g)->gcstate && (g)->gcstate <= GCSsweep)
4949
50#define isgenerational(g)   ((g)->gckind == KGC_GEN)
50#define isgenerational(g)   ((g)->gckind == KGC_GEN)
5151
5252/*
5353** macros to tell when main invariant (white objects cannot point to black
r31374r31375
5858** invariant must be kept all times.
5959*/
6060
61#define keepinvariant(g)   (isgenerational(g) || g->gcstate <= GCSatomic)
61#define keepinvariant(g)    (isgenerational(g) || g->gcstate <= GCSatomic)
6262
6363
6464/*
r31374r31375
6666** 'propagate', so 'keepinvariant' is always true.
6767*/
6868#define keepinvariantout(g)  \
69  check_exp(g->gcstate == GCSpropagate || !isgenerational(g),  \
70            g->gcstate <= GCSatomic)
69   check_exp(g->gcstate == GCSpropagate || !isgenerational(g),  \
70         g->gcstate <= GCSatomic)
7171
7272
7373/*
7474** some useful bit tricks
7575*/
76#define resetbits(x,m)      ((x) &= cast(lu_byte, ~(m)))
77#define setbits(x,m)      ((x) |= (m))
78#define testbits(x,m)      ((x) & (m))
79#define bitmask(b)      (1<<(b))
80#define bit2mask(b1,b2)      (bitmask(b1) | bitmask(b2))
81#define l_setbit(x,b)      setbits(x, bitmask(b))
82#define resetbit(x,b)      resetbits(x, bitmask(b))
83#define testbit(x,b)      testbits(x, bitmask(b))
76#define resetbits(x,m)      ((x) &= cast(lu_byte, ~(m)))
77#define setbits(x,m)        ((x) |= (m))
78#define testbits(x,m)       ((x) & (m))
79#define bitmask(b)      (1<<(b))
80#define bit2mask(b1,b2)     (bitmask(b1) | bitmask(b2))
81#define l_setbit(x,b)       setbits(x, bitmask(b))
82#define resetbit(x,b)       resetbits(x, bitmask(b))
83#define testbit(x,b)        testbits(x, bitmask(b))
8484
8585
8686/* Layout for bit use in `marked' field: */
87#define WHITE0BIT   0  /* object is white (type 0) */
88#define WHITE1BIT   1  /* object is white (type 1) */
89#define BLACKBIT   2  /* object is black */
90#define FINALIZEDBIT   3  /* object has been separated for finalization */
91#define SEPARATED   4  /* object is in 'finobj' list or in 'tobefnz' */
92#define FIXEDBIT   5  /* object is fixed (should not be collected) */
93#define OLDBIT      6  /* object is old (only in generational mode) */
87#define WHITE0BIT   0  /* object is white (type 0) */
88#define WHITE1BIT   1  /* object is white (type 1) */
89#define BLACKBIT    2  /* object is black */
90#define FINALIZEDBIT    3  /* object has been separated for finalization */
91#define SEPARATED   4  /* object is in 'finobj' list or in 'tobefnz' */
92#define FIXEDBIT    5  /* object is fixed (should not be collected) */
93#define OLDBIT      6  /* object is old (only in generational mode) */
9494/* bit 7 is currently used by tests (luaL_checkmemory) */
9595
96#define WHITEBITS   bit2mask(WHITE0BIT, WHITE1BIT)
96#define WHITEBITS   bit2mask(WHITE0BIT, WHITE1BIT)
9797
9898
9999#define iswhite(x)      testbits((x)->gch.marked, WHITEBITS)
r31374r31375
101101#define isgray(x)  /* neither white nor black */  \
102102   (!testbits((x)->gch.marked, WHITEBITS | bitmask(BLACKBIT)))
103103
104#define isold(x)   testbit((x)->gch.marked, OLDBIT)
104#define isold(x)    testbit((x)->gch.marked, OLDBIT)
105105
106106/* MOVE OLD rule: whenever an object is moved to the beginning of
107107   a GC list, its old bit must be cleared */
108#define resetoldbit(o)   resetbit((o)->gch.marked, OLDBIT)
108#define resetoldbit(o)  resetbit((o)->gch.marked, OLDBIT)
109109
110#define otherwhite(g)   (g->currentwhite ^ WHITEBITS)
111#define isdeadm(ow,m)   (!(((m) ^ WHITEBITS) & (ow)))
112#define isdead(g,v)   isdeadm(otherwhite(g), (v)->gch.marked)
110#define otherwhite(g)   (g->currentwhite ^ WHITEBITS)
111#define isdeadm(ow,m)   (!(((m) ^ WHITEBITS) & (ow)))
112#define isdead(g,v) isdeadm(otherwhite(g), (v)->gch.marked)
113113
114#define changewhite(x)   ((x)->gch.marked ^= WHITEBITS)
115#define gray2black(x)   l_setbit((x)->gch.marked, BLACKBIT)
114#define changewhite(x)  ((x)->gch.marked ^= WHITEBITS)
115#define gray2black(x)   l_setbit((x)->gch.marked, BLACKBIT)
116116
117#define valiswhite(x)   (iscollectable(x) && iswhite(gcvalue(x)))
117#define valiswhite(x)   (iscollectable(x) && iswhite(gcvalue(x)))
118118
119#define luaC_white(g)   cast(lu_byte, (g)->currentwhite & WHITEBITS)
119#define luaC_white(g)   cast(lu_byte, (g)->currentwhite & WHITEBITS)
120120
121121
122122#define luaC_condGC(L,c) \
123123   {if (G(L)->GCdebt > 0) {c;}; condchangemem(L);}
124#define luaC_checkGC(L)      luaC_condGC(L, luaC_step(L);)
124#define luaC_checkGC(L)     luaC_condGC(L, luaC_step(L);)
125125
126126
127127#define luaC_barrier(L,p,v) { if (valiswhite(v) && isblack(obj2gco(p)))  \
r31374r31375
135135      luaC_barrier_(L,obj2gco(p),obj2gco(o)); }
136136
137137#define luaC_objbarrierback(L,p,o)  \
138   { if (iswhite(obj2gco(o)) && isblack(obj2gco(p))) luaC_barrierback_(L,p); }
138   { if (iswhite(obj2gco(o)) && isblack(obj2gco(p))) luaC_barrierback_(L,p); }
139139
140140#define luaC_barrierproto(L,p,c) \
141   { if (isblack(obj2gco(p))) luaC_barrierproto_(L,p,c); }
141   { if (isblack(obj2gco(p))) luaC_barrierproto_(L,p,c); }
142142
143143LUAI_FUNC void luaC_freeallobjects (lua_State *L);
144144LUAI_FUNC void luaC_step (lua_State *L);
r31374r31375
146146LUAI_FUNC void luaC_runtilstate (lua_State *L, int statesmask);
147147LUAI_FUNC void luaC_fullgc (lua_State *L, int isemergency);
148148LUAI_FUNC GCObject *luaC_newobj (lua_State *L, int tt, size_t sz,
149                                 GCObject **list, int offset);
149                           GCObject **list, int offset);
150150LUAI_FUNC void luaC_barrier_ (lua_State *L, GCObject *o, GCObject *v);
151151LUAI_FUNC void luaC_barrierback_ (lua_State *L, GCObject *o);
152152LUAI_FUNC void luaC_barrierproto_ (lua_State *L, Proto *p, Closure *c);
trunk/src/lib/lua/lfunc.h
r31374r31375
1111#include "lobject.h"
1212
1313
14#define sizeCclosure(n)   (cast(int, sizeof(CClosure)) + \
15                         cast(int, sizeof(TValue)*((n)-1)))
14#define sizeCclosure(n) (cast(int, sizeof(CClosure)) + \
15                     cast(int, sizeof(TValue)*((n)-1)))
1616
17#define sizeLclosure(n)   (cast(int, sizeof(LClosure)) + \
18                         cast(int, sizeof(TValue *)*((n)-1)))
17#define sizeLclosure(n) (cast(int, sizeof(LClosure)) + \
18                     cast(int, sizeof(TValue *)*((n)-1)))
1919
2020
2121LUAI_FUNC Proto *luaF_newproto (lua_State *L);
r31374r31375
2727LUAI_FUNC void luaF_freeproto (lua_State *L, Proto *f);
2828LUAI_FUNC void luaF_freeupval (lua_State *L, UpVal *uv);
2929LUAI_FUNC const char *luaF_getlocalname (const Proto *func, int local_number,
30                                         int pc);
30                                 int pc);
3131
3232
3333#endif
trunk/src/lib/lua/lualib.h
r31374r31375
1414
1515LUAMOD_API int (luaopen_base) (lua_State *L);
1616
17#define LUA_COLIBNAME   "coroutine"
17#define LUA_COLIBNAME   "coroutine"
1818LUAMOD_API int (luaopen_coroutine) (lua_State *L);
1919
20#define LUA_TABLIBNAME   "table"
20#define LUA_TABLIBNAME  "table"
2121LUAMOD_API int (luaopen_table) (lua_State *L);
2222
23#define LUA_IOLIBNAME   "io"
23#define LUA_IOLIBNAME   "io"
2424LUAMOD_API int (luaopen_io) (lua_State *L);
2525
26#define LUA_OSLIBNAME   "os"
26#define LUA_OSLIBNAME   "os"
2727LUAMOD_API int (luaopen_os) (lua_State *L);
2828
29#define LUA_STRLIBNAME   "string"
29#define LUA_STRLIBNAME  "string"
3030LUAMOD_API int (luaopen_string) (lua_State *L);
3131
32#define LUA_BITLIBNAME   "bit32"
32#define LUA_BITLIBNAME  "bit32"
3333LUAMOD_API int (luaopen_bit32) (lua_State *L);
3434
35#define LUA_MATHLIBNAME   "math"
35#define LUA_MATHLIBNAME "math"
3636LUAMOD_API int (luaopen_math) (lua_State *L);
3737
38#define LUA_DBLIBNAME   "debug"
38#define LUA_DBLIBNAME   "debug"
3939LUAMOD_API int (luaopen_debug) (lua_State *L);
4040
41#define LUA_LOADLIBNAME   "package"
41#define LUA_LOADLIBNAME "package"
4242LUAMOD_API int (luaopen_package) (lua_State *L);
4343
4444
r31374r31375
4848
4949
5050#if !defined(lua_assert)
51#define lua_assert(x)   ((void)0)
51#define lua_assert(x)   ((void)0)
5252#endif
5353
5454
trunk/src/lib/lua/lparser.h
r31374r31375
1717*/
1818
1919typedef enum {
20  VVOID,   /* no value */
21  VNIL,
22  VTRUE,
23  VFALSE,
24  VK,      /* info = index of constant in `k' */
25  VKNUM,   /* nval = numerical value */
26  VNONRELOC,   /* info = result register */
27  VLOCAL,   /* info = local register */
28  VUPVAL,       /* info = index of upvalue in 'upvalues' */
29  VINDEXED,   /* t = table register/upvalue; idx = index R/K */
30  VJMP,      /* info = instruction pc */
31  VRELOCABLE,   /* info = instruction pc */
32  VCALL,   /* info = instruction pc */
33  VVARARG   /* info = instruction pc */
20   VVOID,  /* no value */
21   VNIL,
22   VTRUE,
23   VFALSE,
24   VK,     /* info = index of constant in `k' */
25   VKNUM,  /* nval = numerical value */
26   VNONRELOC,  /* info = result register */
27   VLOCAL, /* info = local register */
28   VUPVAL,       /* info = index of upvalue in 'upvalues' */
29   VINDEXED,   /* t = table register/upvalue; idx = index R/K */
30   VJMP,       /* info = instruction pc */
31   VRELOCABLE, /* info = instruction pc */
32   VCALL,  /* info = instruction pc */
33   VVARARG /* info = instruction pc */
3434} expkind;
3535
3636
37#define vkisvar(k)   (VLOCAL <= (k) && (k) <= VINDEXED)
38#define vkisinreg(k)   ((k) == VNONRELOC || (k) == VLOCAL)
37#define vkisvar(k)  (VLOCAL <= (k) && (k) <= VINDEXED)
38#define vkisinreg(k)    ((k) == VNONRELOC || (k) == VLOCAL)
3939
4040typedef struct expdesc {
41  expkind k;
42  union {
43    struct {  /* for indexed variables (VINDEXED) */
44      short idx;  /* index (R/K) */
45      lu_byte t;  /* table (register or upvalue) */
46      lu_byte vt;  /* whether 't' is register (VLOCAL) or upvalue (VUPVAL) */
47    } ind;
48    int info;  /* for generic use */
49    lua_Number nval;  /* for VKNUM */
50  } u;
51  int t;  /* patch list of `exit when true' */
52  int f;  /* patch list of `exit when false' */
41   expkind k;
42   union {
43   struct {  /* for indexed variables (VINDEXED) */
44      short idx;  /* index (R/K) */
45      lu_byte t;  /* table (register or upvalue) */
46      lu_byte vt;  /* whether 't' is register (VLOCAL) or upvalue (VUPVAL) */
47   } ind;
48   int info;  /* for generic use */
49   lua_Number nval;  /* for VKNUM */
50   } u;
51   int t;  /* patch list of `exit when true' */
52   int f;  /* patch list of `exit when false' */
5353} expdesc;
5454
5555
5656/* description of active local variable */
5757typedef struct Vardesc {
58  short idx;  /* variable index in stack */
58   short idx;  /* variable index in stack */
5959} Vardesc;
6060
6161
6262/* description of pending goto statements and label statements */
6363typedef struct Labeldesc {
64  TString *name;  /* label identifier */
65  int pc;  /* position in code */
66  int line;  /* line where it appeared */
67  lu_byte nactvar;  /* local level where it appears in current block */
64   TString *name;  /* label identifier */
65   int pc;  /* position in code */
66   int line;  /* line where it appeared */
67   lu_byte nactvar;  /* local level where it appears in current block */
6868} Labeldesc;
6969
7070
7171/* list of labels or gotos */
7272typedef struct Labellist {
73  Labeldesc *arr;  /* array */
74  int n;  /* number of entries in use */
75  int size;  /* array size */
73   Labeldesc *arr;  /* array */
74   int n;  /* number of entries in use */
75   int size;  /* array size */
7676} Labellist;
7777
7878
7979/* dynamic structures used by the parser */
8080typedef struct Dyndata {
81  struct {  /* list of active local variables */
82    Vardesc *arr;
83    int n;
84    int size;
85  } actvar;
86  Labellist gt;  /* list of pending gotos */
87  Labellist label;   /* list of active labels */
81   struct {  /* list of active local variables */
82   Vardesc *arr;
83   int n;
84   int size;
85   } actvar;
86   Labellist gt;  /* list of pending gotos */
87   Labellist label;   /* list of active labels */
8888} Dyndata;
8989
9090
r31374r31375
9494
9595/* state needed to generate code for a given function */
9696typedef struct FuncState {
97  Proto *f;  /* current function header */
98  Table *h;  /* table to find (and reuse) elements in `k' */
99  struct FuncState *prev;  /* enclosing function */
100  struct LexState *ls;  /* lexical state */
101  struct BlockCnt *bl;  /* chain of current blocks */
102  int pc;  /* next position to code (equivalent to `ncode') */
103  int lasttarget;   /* 'label' of last 'jump label' */
104  int jpc;  /* list of pending jumps to `pc' */
105  int nk;  /* number of elements in `k' */
106  int np;  /* number of elements in `p' */
107  int firstlocal;  /* index of first local var (in Dyndata array) */
108  short nlocvars;  /* number of elements in 'f->locvars' */
109  lu_byte nactvar;  /* number of active local variables */
110  lu_byte nups;  /* number of upvalues */
111  lu_byte freereg;  /* first free register */
97   Proto *f;  /* current function header */
98   Table *h;  /* table to find (and reuse) elements in `k' */
99   struct FuncState *prev;  /* enclosing function */
100   struct LexState *ls;  /* lexical state */
101   struct BlockCnt *bl;  /* chain of current blocks */
102   int pc;  /* next position to code (equivalent to `ncode') */
103   int lasttarget;   /* 'label' of last 'jump label' */
104   int jpc;  /* list of pending jumps to `pc' */
105   int nk;  /* number of elements in `k' */
106   int np;  /* number of elements in `p' */
107   int firstlocal;  /* index of first local var (in Dyndata array) */
108   short nlocvars;  /* number of elements in 'f->locvars' */
109   lu_byte nactvar;  /* number of active local variables */
110   lu_byte nups;  /* number of upvalues */
111   lu_byte freereg;  /* first free register */
112112} FuncState;
113113
114114
115115LUAI_FUNC Closure *luaY_parser (lua_State *L, ZIO *z, Mbuffer *buff,
116                                Dyndata *dyd, const char *name, int firstchar);
116                        Dyndata *dyd, const char *name, int firstchar);
117117
118118
119119#endif
trunk/src/lib/lua/llimits.h
r31374r31375
2727typedef unsigned char lu_byte;
2828
2929
30#define MAX_SIZET   ((size_t)(~(size_t)0)-2)
30#define MAX_SIZET   ((size_t)(~(size_t)0)-2)
3131
32#define MAX_LUMEM   ((lu_mem)(~(lu_mem)0)-2)
32#define MAX_LUMEM   ((lu_mem)(~(lu_mem)0)-2)
3333
34#define MAX_LMEM   ((l_mem) ((MAX_LUMEM >> 1) - 2))
34#define MAX_LMEM    ((l_mem) ((MAX_LUMEM >> 1) - 2))
3535
3636
3737#define MAX_INT (INT_MAX-2)  /* maximum value of an int (-2 for safety) */
r31374r31375
4747
4848/* type to ensure maximum alignment */
4949#if !defined(LUAI_USER_ALIGNMENT_T)
50#define LUAI_USER_ALIGNMENT_T   union { double u; void *s; long l; }
50#define LUAI_USER_ALIGNMENT_T   union { double u; void *s; long l; }
5151#endif
5252
5353typedef LUAI_USER_ALIGNMENT_T L_Umaxalign;
r31374r31375
5959
6060/* internal assertions for in-house debugging */
6161#if defined(lua_assert)
62#define check_exp(c,e)      (lua_assert(c), (e))
62#define check_exp(c,e)      (lua_assert(c), (e))
6363/* to avoid problems with conditions too long */
64#define lua_longassert(c)   { if (!(c)) lua_assert(0); }
64#define lua_longassert(c)   { if (!(c)) lua_assert(0); }
6565#else
66#define lua_assert(c)      ((void)0)
67#define check_exp(c,e)      (e)
68#define lua_longassert(c)   ((void)0)
66#define lua_assert(c)       ((void)0)
67#define check_exp(c,e)      (e)
68#define lua_longassert(c)   ((void)0)
6969#endif
7070
7171/*
r31374r31375
7575
7676#if defined(LUA_USE_APICHECK)
7777#include <assert.h>
78#define luai_apicheck(L,e)   assert(e)
78#define luai_apicheck(L,e)  assert(e)
7979#else
80#define luai_apicheck(L,e)   lua_assert(e)
80#define luai_apicheck(L,e)  lua_assert(e)
8181#endif
8282
8383#endif
8484
85#define api_check(l,e,msg)   luai_apicheck(l,(e) && msg)
85#define api_check(l,e,msg)  luai_apicheck(l,(e) && msg)
8686
8787
8888#if !defined(UNUSED)
89#define UNUSED(x)   ((void)(x))   /* to avoid warnings */
89#define UNUSED(x)   ((void)(x)) /* to avoid warnings */
9090#endif
9191
9292
93#define cast(t, exp)   ((t)(exp))
93#define cast(t, exp)    ((t)(exp))
9494
95#define cast_byte(i)   cast(lu_byte, (i))
96#define cast_num(i)   cast(lua_Number, (i))
97#define cast_int(i)   cast(int, (i))
98#define cast_uchar(i)   cast(unsigned char, (i))
95#define cast_byte(i)    cast(lu_byte, (i))
96#define cast_num(i) cast(lua_Number, (i))
97#define cast_int(i) cast(int, (i))
98#define cast_uchar(i)   cast(unsigned char, (i))
9999
100100
101101/*
102102** non-return type
103103*/
104104#if defined(__GNUC__)
105#define l_noret      void __attribute__((noreturn))
105#define l_noret     void __attribute__((noreturn))
106106#elif defined(_MSC_VER)
107#define l_noret      void __declspec(noreturn)
107#define l_noret     void __declspec(noreturn)
108108#else
109#define l_noret      void
109#define l_noret     void
110110#endif
111111
112112
r31374r31375
116116** in a program. (Value must fit in an unsigned short int.)
117117*/
118118#if !defined(LUAI_MAXCCALLS)
119#define LUAI_MAXCCALLS      200
119#define LUAI_MAXCCALLS      200
120120#endif
121121
122122/*
123123** maximum number of upvalues in a closure (both C and Lua). (Value
124124** must fit in an unsigned char.)
125125*/
126#define MAXUPVAL   UCHAR_MAX
126#define MAXUPVAL    UCHAR_MAX
127127
128128
129129/*
r31374r31375
135135
136136
137137/* maximum stack for a Lua function */
138#define MAXSTACK   250
138#define MAXSTACK    250
139139
140140
141141
142142/* minimum size for the string table (must be power of 2) */
143143#if !defined(MINSTRTABSIZE)
144#define MINSTRTABSIZE   32
144#define MINSTRTABSIZE   32
145145#endif
146146
147147
148148/* minimum size for string buffer */
149149#if !defined(LUA_MINBUFFER)
150#define LUA_MINBUFFER   32
150#define LUA_MINBUFFER   32
151151#endif
152152
153153
r31374r31375
167167** created/deleted/resumed/yielded.
168168*/
169169#if !defined(luai_userstateopen)
170#define luai_userstateopen(L)      ((void)L)
170#define luai_userstateopen(L)       ((void)L)
171171#endif
172172
173173#if !defined(luai_userstateclose)
174#define luai_userstateclose(L)      ((void)L)
174#define luai_userstateclose(L)      ((void)L)
175175#endif
176176
177177#if !defined(luai_userstatethread)
178#define luai_userstatethread(L,L1)   ((void)L)
178#define luai_userstatethread(L,L1)  ((void)L)
179179#endif
180180
181181#if !defined(luai_userstatefree)
182#define luai_userstatefree(L,L1)   ((void)L)
182#define luai_userstatefree(L,L1)    ((void)L)
183183#endif
184184
185185#if !defined(luai_userstateresume)
r31374r31375
200200** both small and large values (outside the range of integers).
201201*/
202202
203#if defined(MS_ASMTRICK) || defined(LUA_MSASMTRICK)   /* { */
203#if defined(MS_ASMTRICK) || defined(LUA_MSASMTRICK) /* { */
204204/* trick with Microsoft assembler for X86 */
205205
206206#define lua_number2int(i,n)  __asm {__asm fld n   __asm fistp i}
207#define lua_number2integer(i,n)      lua_number2int(i, n)
207#define lua_number2integer(i,n)     lua_number2int(i, n)
208208#define lua_number2unsigned(i,n)  \
209  {__int64 l; __asm {__asm fld n   __asm fistp l} i = (unsigned int)l;}
209   {__int64 l; __asm {__asm fld n   __asm fistp l} i = (unsigned int)l;}
210210
211211
212#elif defined(LUA_IEEE754TRICK)      /* }{ */
212#elif defined(LUA_IEEE754TRICK)     /* }{ */
213213/* the next trick should work on any machine using IEEE754 with
214214   a 32-bit int type */
215215
216216union luai_Cast { double l_d; LUA_INT32 l_p[2]; };
217217
218#if !defined(LUA_IEEEENDIAN)   /* { */
219#define LUAI_EXTRAIEEE   \
220  static const union luai_Cast ieeeendian = {-(33.0 + 6755399441055744.0)};
221#define LUA_IEEEENDIANLOC   (ieeeendian.l_p[1] == 33)
218#if !defined(LUA_IEEEENDIAN)    /* { */
219#define LUAI_EXTRAIEEE  \
220   static const union luai_Cast ieeeendian = {-(33.0 + 6755399441055744.0)};
221#define LUA_IEEEENDIANLOC   (ieeeendian.l_p[1] == 33)
222222#else
223#define LUA_IEEEENDIANLOC   LUA_IEEEENDIAN
224#define LUAI_EXTRAIEEE      /* empty */
225#endif            /* } */
223#define LUA_IEEEENDIANLOC   LUA_IEEEENDIAN
224#define LUAI_EXTRAIEEE      /* empty */
225#endif              /* } */
226226
227227#define lua_number2int32(i,n,t) \
228  { LUAI_EXTRAIEEE \
229    volatile union luai_Cast u; u.l_d = (n) + 6755399441055744.0; \
230    (i) = (t)u.l_p[LUA_IEEEENDIANLOC]; }
228   { LUAI_EXTRAIEEE \
229   volatile union luai_Cast u; u.l_d = (n) + 6755399441055744.0; \
230   (i) = (t)u.l_p[LUA_IEEEENDIANLOC]; }
231231
232232#define luai_hashnum(i,n)  \
233  { volatile union luai_Cast u; u.l_d = (n) + 1.0;  /* avoid -0 */ \
234    (i) = u.l_p[0]; (i) += u.l_p[1]; }  /* add double bits for his hash */
233   { volatile union luai_Cast u; u.l_d = (n) + 1.0;  /* avoid -0 */ \
234   (i) = u.l_p[0]; (i) += u.l_p[1]; }  /* add double bits for his hash */
235235
236#define lua_number2int(i,n)      lua_number2int32(i, n, int)
237#define lua_number2unsigned(i,n)   lua_number2int32(i, n, lua_Unsigned)
236#define lua_number2int(i,n)     lua_number2int32(i, n, int)
237#define lua_number2unsigned(i,n)    lua_number2int32(i, n, lua_Unsigned)
238238
239239/* the trick can be expanded to lua_Integer when it is a 32-bit value */
240240#if defined(LUA_IEEELL)
241#define lua_number2integer(i,n)      lua_number2int32(i, n, lua_Integer)
241#define lua_number2integer(i,n)     lua_number2int32(i, n, lua_Integer)
242242#endif
243243
244#endif            /* } */
244#endif              /* } */
245245
246246
247247/* the following definitions always work, but may be slow */
248248
249249#if !defined(lua_number2int)
250#define lua_number2int(i,n)   ((i)=(int)(n))
250#define lua_number2int(i,n) ((i)=(int)(n))
251251#endif
252252
253253#if !defined(lua_number2integer)
254#define lua_number2integer(i,n)   ((i)=(lua_Integer)(n))
254#define lua_number2integer(i,n) ((i)=(lua_Integer)(n))
255255#endif
256256
257#if !defined(lua_number2unsigned)   /* { */
257#if !defined(lua_number2unsigned)   /* { */
258258/* the following definition assures proper modulo behavior */
259259#if defined(LUA_NUMBER_DOUBLE) || defined(LUA_NUMBER_FLOAT)
260260#include <math.h>
261#define SUPUNSIGNED   ((lua_Number)(~(lua_Unsigned)0) + 1)
261#define SUPUNSIGNED ((lua_Number)(~(lua_Unsigned)0) + 1)
262262#define lua_number2unsigned(i,n)  \
263263   ((i)=(lua_Unsigned)((n) - floor((n)/SUPUNSIGNED)*SUPUNSIGNED))
264264#else
265#define lua_number2unsigned(i,n)   ((i)=(lua_Unsigned)(n))
265#define lua_number2unsigned(i,n)    ((i)=(lua_Unsigned)(n))
266266#endif
267#endif            /* } */
267#endif              /* } */
268268
269269
270270#if !defined(lua_unsigned2number)
271271/* on several machines, coercion from unsigned to double is slow,
272272   so it may be worth to avoid */
273273#define lua_unsigned2number(u)  \
274    (((u) <= (lua_Unsigned)INT_MAX) ? (lua_Number)(int)(u) : (lua_Number)(u))
274   (((u) <= (lua_Unsigned)INT_MAX) ? (lua_Number)(int)(u) : (lua_Number)(u))
275275#endif
276276
277277
r31374r31375
282282#include <math.h>
283283
284284#define luai_hashnum(i,n) { int e;  \
285  n = l_mathop(frexp)(n, &e) * (lua_Number)(INT_MAX - DBL_MAX_EXP);  \
286  lua_number2int(i, n); i += e; }
285   n = l_mathop(frexp)(n, &e) * (lua_Number)(INT_MAX - DBL_MAX_EXP);  \
286   lua_number2int(i, n); i += e; }
287287
288288#endif
289289
r31374r31375
293293** macro to control inclusion of some hard tests on stack reallocation
294294*/
295295#if !defined(HARDSTACKTESTS)
296#define condmovestack(L)   ((void)0)
296#define condmovestack(L)    ((void)0)
297297#else
298298/* realloc stack keeping its size */
299#define condmovestack(L)   luaD_reallocstack((L), (L)->stacksize)
299#define condmovestack(L)    luaD_reallocstack((L), (L)->stacksize)
300300#endif
301301
302302#if !defined(HARDMEMTESTS)
303#define condchangemem(L)   condmovestack(L)
303#define condchangemem(L)    condmovestack(L)
304304#else
305305#define condchangemem(L)  \
306306   ((void)(!(G(L)->gcrunning) || (luaC_fullgc(L, 0), 1)))
trunk/src/lib/lua/lua.h
r31374r31375
1616#include "luaconf.h"
1717
1818
19#define LUA_VERSION_MAJOR   "5"
20#define LUA_VERSION_MINOR   "2"
21#define LUA_VERSION_NUM      502
22#define LUA_VERSION_RELEASE   "3"
19#define LUA_VERSION_MAJOR   "5"
20#define LUA_VERSION_MINOR   "2"
21#define LUA_VERSION_NUM     502
22#define LUA_VERSION_RELEASE "3"
2323
24#define LUA_VERSION   "Lua " LUA_VERSION_MAJOR "." LUA_VERSION_MINOR
25#define LUA_RELEASE   LUA_VERSION "." LUA_VERSION_RELEASE
26#define LUA_COPYRIGHT   LUA_RELEASE "  Copyright (C) 1994-2013 Lua.org, PUC-Rio"
27#define LUA_AUTHORS   "R. Ierusalimschy, L. H. de Figueiredo, W. Celes"
24#define LUA_VERSION "Lua " LUA_VERSION_MAJOR "." LUA_VERSION_MINOR
25#define LUA_RELEASE LUA_VERSION "." LUA_VERSION_RELEASE
26#define LUA_COPYRIGHT   LUA_RELEASE "  Copyright (C) 1994-2013 Lua.org, PUC-Rio"
27#define LUA_AUTHORS "R. Ierusalimschy, L. H. de Figueiredo, W. Celes"
2828
2929
3030/* mark for precompiled code ('<esc>Lua') */
31#define LUA_SIGNATURE   "\033Lua"
31#define LUA_SIGNATURE   "\033Lua"
3232
3333/* option for multiple returns in 'lua_pcall' and 'lua_call' */
34#define LUA_MULTRET   (-1)
34#define LUA_MULTRET (-1)
3535
3636
3737/*
3838** pseudo-indices
3939*/
40#define LUA_REGISTRYINDEX   LUAI_FIRSTPSEUDOIDX
41#define lua_upvalueindex(i)   (LUA_REGISTRYINDEX - (i))
40#define LUA_REGISTRYINDEX   LUAI_FIRSTPSEUDOIDX
41#define lua_upvalueindex(i) (LUA_REGISTRYINDEX - (i))
4242
4343
4444/* thread status */
45#define LUA_OK      0
46#define LUA_YIELD   1
47#define LUA_ERRRUN   2
48#define LUA_ERRSYNTAX   3
49#define LUA_ERRMEM   4
50#define LUA_ERRGCMM   5
51#define LUA_ERRERR   6
45#define LUA_OK      0
46#define LUA_YIELD   1
47#define LUA_ERRRUN  2
48#define LUA_ERRSYNTAX   3
49#define LUA_ERRMEM  4
50#define LUA_ERRGCMM 5
51#define LUA_ERRERR  6
5252
5353
5454typedef struct lua_State lua_State;
r31374r31375
7373/*
7474** basic types
7575*/
76#define LUA_TNONE      (-1)
76#define LUA_TNONE       (-1)
7777
78#define LUA_TNIL      0
79#define LUA_TBOOLEAN      1
80#define LUA_TLIGHTUSERDATA   2
81#define LUA_TNUMBER      3
82#define LUA_TSTRING      4
83#define LUA_TTABLE      5
84#define LUA_TFUNCTION      6
85#define LUA_TUSERDATA      7
86#define LUA_TTHREAD      8
78#define LUA_TNIL        0
79#define LUA_TBOOLEAN        1
80#define LUA_TLIGHTUSERDATA  2
81#define LUA_TNUMBER     3
82#define LUA_TSTRING     4
83#define LUA_TTABLE      5
84#define LUA_TFUNCTION       6
85#define LUA_TUSERDATA       7
86#define LUA_TTHREAD     8
8787
88#define LUA_NUMTAGS      9
88#define LUA_NUMTAGS     9
8989
9090
9191
9292/* minimum Lua stack available to a C function */
93#define LUA_MINSTACK   20
93#define LUA_MINSTACK    20
9494
9595
9696/* predefined values in the registry */
97#define LUA_RIDX_MAINTHREAD   1
98#define LUA_RIDX_GLOBALS   2
99#define LUA_RIDX_LAST      LUA_RIDX_GLOBALS
97#define LUA_RIDX_MAINTHREAD 1
98#define LUA_RIDX_GLOBALS    2
99#define LUA_RIDX_LAST       LUA_RIDX_GLOBALS
100100
101101
102102/* type of numbers in Lua */
r31374r31375
172172LUA_API const char     *(lua_tolstring) (lua_State *L, int idx, size_t *len);
173173LUA_API size_t          (lua_rawlen) (lua_State *L, int idx);
174174LUA_API lua_CFunction   (lua_tocfunction) (lua_State *L, int idx);
175LUA_API void          *(lua_touserdata) (lua_State *L, int idx);
175LUA_API void           *(lua_touserdata) (lua_State *L, int idx);
176176LUA_API lua_State      *(lua_tothread) (lua_State *L, int idx);
177177LUA_API const void     *(lua_topointer) (lua_State *L, int idx);
178178
r31374r31375
181181** Comparison and arithmetic functions
182182*/
183183
184#define LUA_OPADD   0   /* ORDER TM */
185#define LUA_OPSUB   1
186#define LUA_OPMUL   2
187#define LUA_OPDIV   3
188#define LUA_OPMOD   4
189#define LUA_OPPOW   5
190#define LUA_OPUNM   6
184#define LUA_OPADD   0   /* ORDER TM */
185#define LUA_OPSUB   1
186#define LUA_OPMUL   2
187#define LUA_OPDIV   3
188#define LUA_OPMOD   4
189#define LUA_OPPOW   5
190#define LUA_OPUNM   6
191191
192192LUA_API void  (lua_arith) (lua_State *L, int op);
193193
194#define LUA_OPEQ   0
195#define LUA_OPLT   1
196#define LUA_OPLE   2
194#define LUA_OPEQ    0
195#define LUA_OPLT    1
196#define LUA_OPLE    2
197197
198198LUA_API int   (lua_rawequal) (lua_State *L, int idx1, int idx2);
199199LUA_API int   (lua_compare) (lua_State *L, int idx1, int idx2, int op);
r31374r31375
209209LUA_API const char *(lua_pushlstring) (lua_State *L, const char *s, size_t l);
210210LUA_API const char *(lua_pushstring) (lua_State *L, const char *s);
211211LUA_API const char *(lua_pushvfstring) (lua_State *L, const char *fmt,
212                                                      va_list argp);
212                                          va_list argp);
213213LUA_API const char *(lua_pushfstring) (lua_State *L, const char *fmt, ...);
214214LUA_API void  (lua_pushcclosure) (lua_State *L, lua_CFunction fn, int n);
215215LUA_API void  (lua_pushboolean) (lua_State *L, int b);
r31374r31375
249249** 'load' and 'call' functions (load and run Lua code)
250250*/
251251LUA_API void  (lua_callk) (lua_State *L, int nargs, int nresults, int ctx,
252                           lua_CFunction k);
253#define lua_call(L,n,r)      lua_callk(L, (n), (r), 0, NULL)
252                     lua_CFunction k);
253#define lua_call(L,n,r)     lua_callk(L, (n), (r), 0, NULL)
254254
255255LUA_API int   (lua_getctx) (lua_State *L, int *ctx);
256256
257257LUA_API int   (lua_pcallk) (lua_State *L, int nargs, int nresults, int errfunc,
258                            int ctx, lua_CFunction k);
259#define lua_pcall(L,n,r,f)   lua_pcallk(L, (n), (r), (f), 0, NULL)
258                     int ctx, lua_CFunction k);
259#define lua_pcall(L,n,r,f)  lua_pcallk(L, (n), (r), (f), 0, NULL)
260260
261261LUA_API int   (lua_load) (lua_State *L, lua_Reader reader, void *dt,
262                                        const char *chunkname,
263                                        const char *mode);
262                              const char *chunkname,
263                              const char *mode);
264264
265265LUA_API int (lua_dump) (lua_State *L, lua_Writer writer, void *data);
266266
r31374r31375
269269** coroutine functions
270270*/
271271LUA_API int  (lua_yieldk) (lua_State *L, int nresults, int ctx,
272                           lua_CFunction k);
273#define lua_yield(L,n)      lua_yieldk(L, (n), 0, NULL)
272                     lua_CFunction k);
273#define lua_yield(L,n)      lua_yieldk(L, (n), 0, NULL)
274274LUA_API int  (lua_resume) (lua_State *L, lua_State *from, int narg);
275275LUA_API int  (lua_status) (lua_State *L);
276276
r31374r31375
278278** garbage-collection function and options
279279*/
280280
281#define LUA_GCSTOP      0
282#define LUA_GCRESTART      1
283#define LUA_GCCOLLECT      2
284#define LUA_GCCOUNT      3
285#define LUA_GCCOUNTB      4
286#define LUA_GCSTEP      5
287#define LUA_GCSETPAUSE      6
288#define LUA_GCSETSTEPMUL   7
289#define LUA_GCSETMAJORINC   8
290#define LUA_GCISRUNNING      9
291#define LUA_GCGEN      10
292#define LUA_GCINC      11
281#define LUA_GCSTOP      0
282#define LUA_GCRESTART       1
283#define LUA_GCCOLLECT       2
284#define LUA_GCCOUNT     3
285#define LUA_GCCOUNTB        4
286#define LUA_GCSTEP      5
287#define LUA_GCSETPAUSE      6
288#define LUA_GCSETSTEPMUL    7
289#define LUA_GCSETMAJORINC   8
290#define LUA_GCISRUNNING     9
291#define LUA_GCGEN       10
292#define LUA_GCINC       11
293293
294294LUA_API int (lua_gc) (lua_State *L, int what, int data);
295295
r31374r31375
316316** ===============================================================
317317*/
318318
319#define lua_tonumber(L,i)   lua_tonumberx(L,i,NULL)
320#define lua_tointeger(L,i)   lua_tointegerx(L,i,NULL)
321#define lua_tounsigned(L,i)   lua_tounsignedx(L,i,NULL)
319#define lua_tonumber(L,i)   lua_tonumberx(L,i,NULL)
320#define lua_tointeger(L,i)  lua_tointegerx(L,i,NULL)
321#define lua_tounsigned(L,i) lua_tounsignedx(L,i,NULL)
322322
323#define lua_pop(L,n)      lua_settop(L, -(n)-1)
323#define lua_pop(L,n)        lua_settop(L, -(n)-1)
324324
325#define lua_newtable(L)      lua_createtable(L, 0, 0)
325#define lua_newtable(L)     lua_createtable(L, 0, 0)
326326
327327#define lua_register(L,n,f) (lua_pushcfunction(L, (f)), lua_setglobal(L, (n)))
328328
329#define lua_pushcfunction(L,f)   lua_pushcclosure(L, (f), 0)
329#define lua_pushcfunction(L,f)  lua_pushcclosure(L, (f), 0)
330330
331#define lua_isfunction(L,n)   (lua_type(L, (n)) == LUA_TFUNCTION)
332#define lua_istable(L,n)   (lua_type(L, (n)) == LUA_TTABLE)
333#define lua_islightuserdata(L,n)   (lua_type(L, (n)) == LUA_TLIGHTUSERDATA)
334#define lua_isnil(L,n)      (lua_type(L, (n)) == LUA_TNIL)
335#define lua_isboolean(L,n)   (lua_type(L, (n)) == LUA_TBOOLEAN)
336#define lua_isthread(L,n)   (lua_type(L, (n)) == LUA_TTHREAD)
337#define lua_isnone(L,n)      (lua_type(L, (n)) == LUA_TNONE)
338#define lua_isnoneornil(L, n)   (lua_type(L, (n)) <= 0)
331#define lua_isfunction(L,n) (lua_type(L, (n)) == LUA_TFUNCTION)
332#define lua_istable(L,n)    (lua_type(L, (n)) == LUA_TTABLE)
333#define lua_islightuserdata(L,n)    (lua_type(L, (n)) == LUA_TLIGHTUSERDATA)
334#define lua_isnil(L,n)      (lua_type(L, (n)) == LUA_TNIL)
335#define lua_isboolean(L,n)  (lua_type(L, (n)) == LUA_TBOOLEAN)
336#define lua_isthread(L,n)   (lua_type(L, (n)) == LUA_TTHREAD)
337#define lua_isnone(L,n)     (lua_type(L, (n)) == LUA_TNONE)
338#define lua_isnoneornil(L, n)   (lua_type(L, (n)) <= 0)
339339
340#define lua_pushliteral(L, s)   \
340#define lua_pushliteral(L, s)   \
341341   lua_pushlstring(L, "" s, (sizeof(s)/sizeof(char))-1)
342342
343343#define lua_pushglobaltable(L)  \
344344   lua_rawgeti(L, LUA_REGISTRYINDEX, LUA_RIDX_GLOBALS)
345345
346#define lua_tostring(L,i)   lua_tolstring(L, (i), NULL)
346#define lua_tostring(L,i)   lua_tolstring(L, (i), NULL)
347347
348348
349349
r31374r31375
357357/*
358358** Event codes
359359*/
360#define LUA_HOOKCALL   0
361#define LUA_HOOKRET   1
362#define LUA_HOOKLINE   2
363#define LUA_HOOKCOUNT   3
360#define LUA_HOOKCALL    0
361#define LUA_HOOKRET 1
362#define LUA_HOOKLINE    2
363#define LUA_HOOKCOUNT   3
364364#define LUA_HOOKTAILCALL 4
365365
366366
367367/*
368368** Event masks
369369*/
370#define LUA_MASKCALL   (1 << LUA_HOOKCALL)
371#define LUA_MASKRET   (1 << LUA_HOOKRET)
372#define LUA_MASKLINE   (1 << LUA_HOOKLINE)
373#define LUA_MASKCOUNT   (1 << LUA_HOOKCOUNT)
370#define LUA_MASKCALL    (1 << LUA_HOOKCALL)
371#define LUA_MASKRET (1 << LUA_HOOKRET)
372#define LUA_MASKLINE    (1 << LUA_HOOKLINE)
373#define LUA_MASKCOUNT   (1 << LUA_HOOKCOUNT)
374374
375375typedef struct lua_Debug lua_Debug;  /* activation record */
376376
r31374r31375
388388
389389LUA_API void *(lua_upvalueid) (lua_State *L, int fidx, int n);
390390LUA_API void  (lua_upvaluejoin) (lua_State *L, int fidx1, int n1,
391                                               int fidx2, int n2);
391                                    int fidx2, int n2);
392392
393393LUA_API int (lua_sethook) (lua_State *L, lua_Hook func, int mask, int count);
394394LUA_API lua_Hook (lua_gethook) (lua_State *L);
r31374r31375
397397
398398
399399struct lua_Debug {
400  int event;
401  const char *name;   /* (n) */
402  const char *namewhat;   /* (n) 'global', 'local', 'field', 'method' */
403  const char *what;   /* (S) 'Lua', 'C', 'main', 'tail' */
404  const char *source;   /* (S) */
405  int currentline;   /* (l) */
406  int linedefined;   /* (S) */
407  int lastlinedefined;   /* (S) */
408  unsigned char nups;   /* (u) number of upvalues */
409  unsigned char nparams;/* (u) number of parameters */
410  char isvararg;        /* (u) */
411  char istailcall;   /* (t) */
412  char short_src[LUA_IDSIZE]; /* (S) */
413  /* private part */
414  struct CallInfo *i_ci;  /* active function */
400   int event;
401   const char *name;   /* (n) */
402   const char *namewhat;   /* (n) 'global', 'local', 'field', 'method' */
403   const char *what;   /* (S) 'Lua', 'C', 'main', 'tail' */
404   const char *source; /* (S) */
405   int currentline;    /* (l) */
406   int linedefined;    /* (S) */
407   int lastlinedefined;    /* (S) */
408   unsigned char nups; /* (u) number of upvalues */
409   unsigned char nparams;/* (u) number of parameters */
410   char isvararg;        /* (u) */
411   char istailcall;    /* (t) */
412   char short_src[LUA_IDSIZE]; /* (S) */
413   /* private part */
414   struct CallInfo *i_ci;  /* active function */
415415};
416416
417417/* }====================================================================== */
trunk/src/lib/lua/lobject.h
r31374r31375
1919/*
2020** Extra tags for non-values
2121*/
22#define LUA_TPROTO   LUA_NUMTAGS
23#define LUA_TUPVAL   (LUA_NUMTAGS+1)
24#define LUA_TDEADKEY   (LUA_NUMTAGS+2)
22#define LUA_TPROTO  LUA_NUMTAGS
23#define LUA_TUPVAL  (LUA_NUMTAGS+1)
24#define LUA_TDEADKEY    (LUA_NUMTAGS+2)
2525
2626/*
2727** number of all possible tags (including LUA_TNONE but excluding DEADKEY)
2828*/
29#define LUA_TOTALTAGS   (LUA_TUPVAL+2)
29#define LUA_TOTALTAGS   (LUA_TUPVAL+2)
3030
3131
3232/*
r31374r31375
3636** bit 6: whether value is collectable
3737*/
3838
39#define VARBITS      (3 << 4)
39#define VARBITS     (3 << 4)
4040
4141
4242/*
r31374r31375
4747*/
4848
4949/* Variant tags for functions */
50#define LUA_TLCL   (LUA_TFUNCTION | (0 << 4))  /* Lua closure */
51#define LUA_TLCF   (LUA_TFUNCTION | (1 << 4))  /* light C function */
52#define LUA_TCCL   (LUA_TFUNCTION | (2 << 4))  /* C closure */
50#define LUA_TLCL    (LUA_TFUNCTION | (0 << 4))  /* Lua closure */
51#define LUA_TLCF    (LUA_TFUNCTION | (1 << 4))  /* light C function */
52#define LUA_TCCL    (LUA_TFUNCTION | (2 << 4))  /* C closure */
5353
5454
5555/* Variant tags for strings */
56#define LUA_TSHRSTR   (LUA_TSTRING | (0 << 4))  /* short strings */
57#define LUA_TLNGSTR   (LUA_TSTRING | (1 << 4))  /* long strings */
56#define LUA_TSHRSTR (LUA_TSTRING | (0 << 4))  /* short strings */
57#define LUA_TLNGSTR (LUA_TSTRING | (1 << 4))  /* long strings */
5858
5959
6060/* Bit mark for collectable types */
61#define BIT_ISCOLLECTABLE   (1 << 6)
61#define BIT_ISCOLLECTABLE   (1 << 6)
6262
6363/* mark a tag as collectable */
64#define ctb(t)         ((t) | BIT_ISCOLLECTABLE)
64#define ctb(t)          ((t) | BIT_ISCOLLECTABLE)
6565
6666
6767/*
r31374r31375
7474** Common Header for all collectable objects (in macro form, to be
7575** included in other objects)
7676*/
77#define CommonHeader   GCObject *next; lu_byte tt; lu_byte marked
77#define CommonHeader    GCObject *next; lu_byte tt; lu_byte marked
7878
7979
8080/*
8181** Common header in struct form
8282*/
8383typedef struct GCheader {
84  CommonHeader;
84   CommonHeader;
8585} GCheader;
8686
8787
r31374r31375
9292typedef union Value Value;
9393
9494
95#define numfield   lua_Number n;    /* numbers */
95#define numfield    lua_Number n;    /* numbers */
9696
9797
9898
r31374r31375
101101** an actual value plus a tag with its type.
102102*/
103103
104#define TValuefields   Value value_; int tt_
104#define TValuefields    Value value_; int tt_
105105
106106typedef struct lua_TValue TValue;
107107
108108
109109/* macro defining a nil value */
110#define NILCONSTANT   {NULL}, LUA_TNIL
110#define NILCONSTANT {NULL}, LUA_TNIL
111111
112112
113#define val_(o)      ((o)->value_)
114#define num_(o)      (val_(o).n)
113#define val_(o)     ((o)->value_)
114#define num_(o)     (val_(o).n)
115115
116116
117117/* raw type tag of a TValue */
118#define rttype(o)   ((o)->tt_)
118#define rttype(o)   ((o)->tt_)
119119
120120/* tag with no variants (bits 0-3) */
121#define novariant(x)   ((x) & 0x0F)
121#define novariant(x)    ((x) & 0x0F)
122122
123123/* type tag of a TValue (bits 0-3 for tags + variant bits 4-5) */
124#define ttype(o)   (rttype(o) & 0x3F)
124#define ttype(o)    (rttype(o) & 0x3F)
125125
126126/* type tag of a TValue with no variants (bits 0-3) */
127#define ttypenv(o)   (novariant(rttype(o)))
127#define ttypenv(o)  (novariant(rttype(o)))
128128
129129
130130/* Macros to test type */
131#define checktag(o,t)      (rttype(o) == (t))
132#define checktype(o,t)      (ttypenv(o) == (t))
133#define ttisnumber(o)      checktag((o), LUA_TNUMBER)
134#define ttisnil(o)      checktag((o), LUA_TNIL)
135#define ttisboolean(o)      checktag((o), LUA_TBOOLEAN)
136#define ttislightuserdata(o)   checktag((o), LUA_TLIGHTUSERDATA)
137#define ttisstring(o)      checktype((o), LUA_TSTRING)
138#define ttisshrstring(o)   checktag((o), ctb(LUA_TSHRSTR))
139#define ttislngstring(o)   checktag((o), ctb(LUA_TLNGSTR))
140#define ttistable(o)      checktag((o), ctb(LUA_TTABLE))
141#define ttisfunction(o)      checktype(o, LUA_TFUNCTION)
142#define ttisclosure(o)      ((rttype(o) & 0x1F) == LUA_TFUNCTION)
143#define ttisCclosure(o)      checktag((o), ctb(LUA_TCCL))
144#define ttisLclosure(o)      checktag((o), ctb(LUA_TLCL))
145#define ttislcf(o)      checktag((o), LUA_TLCF)
146#define ttisuserdata(o)      checktag((o), ctb(LUA_TUSERDATA))
147#define ttisthread(o)      checktag((o), ctb(LUA_TTHREAD))
148#define ttisdeadkey(o)      checktag((o), LUA_TDEADKEY)
131#define checktag(o,t)       (rttype(o) == (t))
132#define checktype(o,t)      (ttypenv(o) == (t))
133#define ttisnumber(o)       checktag((o), LUA_TNUMBER)
134#define ttisnil(o)      checktag((o), LUA_TNIL)
135#define ttisboolean(o)      checktag((o), LUA_TBOOLEAN)
136#define ttislightuserdata(o)    checktag((o), LUA_TLIGHTUSERDATA)
137#define ttisstring(o)       checktype((o), LUA_TSTRING)
138#define ttisshrstring(o)    checktag((o), ctb(LUA_TSHRSTR))
139#define ttislngstring(o)    checktag((o), ctb(LUA_TLNGSTR))
140#define ttistable(o)        checktag((o), ctb(LUA_TTABLE))
141#define ttisfunction(o)     checktype(o, LUA_TFUNCTION)
142#define ttisclosure(o)      ((rttype(o) & 0x1F) == LUA_TFUNCTION)
143#define ttisCclosure(o)     checktag((o), ctb(LUA_TCCL))
144#define ttisLclosure(o)     checktag((o), ctb(LUA_TLCL))
145#define ttislcf(o)      checktag((o), LUA_TLCF)
146#define ttisuserdata(o)     checktag((o), ctb(LUA_TUSERDATA))
147#define ttisthread(o)       checktag((o), ctb(LUA_TTHREAD))
148#define ttisdeadkey(o)      checktag((o), LUA_TDEADKEY)
149149
150#define ttisequal(o1,o2)   (rttype(o1) == rttype(o2))
150#define ttisequal(o1,o2)    (rttype(o1) == rttype(o2))
151151
152152/* Macros to access values */
153#define nvalue(o)   check_exp(ttisnumber(o), num_(o))
154#define gcvalue(o)   check_exp(iscollectable(o), val_(o).gc)
155#define pvalue(o)   check_exp(ttislightuserdata(o), val_(o).p)
156#define rawtsvalue(o)   check_exp(ttisstring(o), &val_(o).gc->ts)
157#define tsvalue(o)   (&rawtsvalue(o)->tsv)
158#define rawuvalue(o)   check_exp(ttisuserdata(o), &val_(o).gc->u)
159#define uvalue(o)   (&rawuvalue(o)->uv)
160#define clvalue(o)   check_exp(ttisclosure(o), &val_(o).gc->cl)
161#define clLvalue(o)   check_exp(ttisLclosure(o), &val_(o).gc->cl.l)
162#define clCvalue(o)   check_exp(ttisCclosure(o), &val_(o).gc->cl.c)
163#define fvalue(o)   check_exp(ttislcf(o), val_(o).f)
164#define hvalue(o)   check_exp(ttistable(o), &val_(o).gc->h)
165#define bvalue(o)   check_exp(ttisboolean(o), val_(o).b)
166#define thvalue(o)   check_exp(ttisthread(o), &val_(o).gc->th)
153#define nvalue(o)   check_exp(ttisnumber(o), num_(o))
154#define gcvalue(o)  check_exp(iscollectable(o), val_(o).gc)
155#define pvalue(o)   check_exp(ttislightuserdata(o), val_(o).p)
156#define rawtsvalue(o)   check_exp(ttisstring(o), &val_(o).gc->ts)
157#define tsvalue(o)  (&rawtsvalue(o)->tsv)
158#define rawuvalue(o)    check_exp(ttisuserdata(o), &val_(o).gc->u)
159#define uvalue(o)   (&rawuvalue(o)->uv)
160#define clvalue(o)  check_exp(ttisclosure(o), &val_(o).gc->cl)
161#define clLvalue(o) check_exp(ttisLclosure(o), &val_(o).gc->cl.l)
162#define clCvalue(o) check_exp(ttisCclosure(o), &val_(o).gc->cl.c)
163#define fvalue(o)   check_exp(ttislcf(o), val_(o).f)
164#define hvalue(o)   check_exp(ttistable(o), &val_(o).gc->h)
165#define bvalue(o)   check_exp(ttisboolean(o), val_(o).b)
166#define thvalue(o)  check_exp(ttisthread(o), &val_(o).gc->th)
167167/* a dead value may get the 'gc' field, but cannot access its contents */
168#define deadvalue(o)   check_exp(ttisdeadkey(o), cast(void *, val_(o).gc))
168#define deadvalue(o)    check_exp(ttisdeadkey(o), cast(void *, val_(o).gc))
169169
170#define l_isfalse(o)   (ttisnil(o) || (ttisboolean(o) && bvalue(o) == 0))
170#define l_isfalse(o)    (ttisnil(o) || (ttisboolean(o) && bvalue(o) == 0))
171171
172172
173#define iscollectable(o)   (rttype(o) & BIT_ISCOLLECTABLE)
173#define iscollectable(o)    (rttype(o) & BIT_ISCOLLECTABLE)
174174
175175
176176/* Macros for internal tests */
177#define righttt(obj)      (ttype(obj) == gcvalue(obj)->gch.tt)
177#define righttt(obj)        (ttype(obj) == gcvalue(obj)->gch.tt)
178178
179179#define checkliveness(g,obj) \
180180   lua_longassert(!iscollectable(obj) || \
r31374r31375
182182
183183
184184/* Macros to set values */
185#define settt_(o,t)   ((o)->tt_=(t))
185#define settt_(o,t) ((o)->tt_=(t))
186186
187187#define setnvalue(obj,x) \
188  { TValue *io=(obj); num_(io)=(x); settt_(io, LUA_TNUMBER); }
188   { TValue *io=(obj); num_(io)=(x); settt_(io, LUA_TNUMBER); }
189189
190190#define setnilvalue(obj) settt_(obj, LUA_TNIL)
191191
192192#define setfvalue(obj,x) \
193  { TValue *io=(obj); val_(io).f=(x); settt_(io, LUA_TLCF); }
193   { TValue *io=(obj); val_(io).f=(x); settt_(io, LUA_TLCF); }
194194
195195#define setpvalue(obj,x) \
196  { TValue *io=(obj); val_(io).p=(x); settt_(io, LUA_TLIGHTUSERDATA); }
196   { TValue *io=(obj); val_(io).p=(x); settt_(io, LUA_TLIGHTUSERDATA); }
197197
198198#define setbvalue(obj,x) \
199  { TValue *io=(obj); val_(io).b=(x); settt_(io, LUA_TBOOLEAN); }
199   { TValue *io=(obj); val_(io).b=(x); settt_(io, LUA_TBOOLEAN); }
200200
201201#define setgcovalue(L,obj,x) \
202  { TValue *io=(obj); GCObject *i_g=(x); \
203    val_(io).gc=i_g; settt_(io, ctb(gch(i_g)->tt)); }
202   { TValue *io=(obj); GCObject *i_g=(x); \
203   val_(io).gc=i_g; settt_(io, ctb(gch(i_g)->tt)); }
204204
205205#define setsvalue(L,obj,x) \
206  { TValue *io=(obj); \
207    TString *x_ = (x); \
208    val_(io).gc=cast(GCObject *, x_); settt_(io, ctb(x_->tsv.tt)); \
209    checkliveness(G(L),io); }
206   { TValue *io=(obj); \
207   TString *x_ = (x); \
208   val_(io).gc=cast(GCObject *, x_); settt_(io, ctb(x_->tsv.tt)); \
209   checkliveness(G(L),io); }
210210
211211#define setuvalue(L,obj,x) \
212  { TValue *io=(obj); \
213    val_(io).gc=cast(GCObject *, (x)); settt_(io, ctb(LUA_TUSERDATA)); \
214    checkliveness(G(L),io); }
212   { TValue *io=(obj); \
213   val_(io).gc=cast(GCObject *, (x)); settt_(io, ctb(LUA_TUSERDATA)); \
214   checkliveness(G(L),io); }
215215
216216#define setthvalue(L,obj,x) \
217  { TValue *io=(obj); \
218    val_(io).gc=cast(GCObject *, (x)); settt_(io, ctb(LUA_TTHREAD)); \
219    checkliveness(G(L),io); }
217   { TValue *io=(obj); \
218   val_(io).gc=cast(GCObject *, (x)); settt_(io, ctb(LUA_TTHREAD)); \
219   checkliveness(G(L),io); }
220220
221221#define setclLvalue(L,obj,x) \
222  { TValue *io=(obj); \
223    val_(io).gc=cast(GCObject *, (x)); settt_(io, ctb(LUA_TLCL)); \
224    checkliveness(G(L),io); }
222   { TValue *io=(obj); \
223   val_(io).gc=cast(GCObject *, (x)); settt_(io, ctb(LUA_TLCL)); \
224   checkliveness(G(L),io); }
225225
226226#define setclCvalue(L,obj,x) \
227  { TValue *io=(obj); \
228    val_(io).gc=cast(GCObject *, (x)); settt_(io, ctb(LUA_TCCL)); \
229    checkliveness(G(L),io); }
227   { TValue *io=(obj); \
228   val_(io).gc=cast(GCObject *, (x)); settt_(io, ctb(LUA_TCCL)); \
229   checkliveness(G(L),io); }
230230
231231#define sethvalue(L,obj,x) \
232  { TValue *io=(obj); \
233    val_(io).gc=cast(GCObject *, (x)); settt_(io, ctb(LUA_TTABLE)); \
234    checkliveness(G(L),io); }
232   { TValue *io=(obj); \
233   val_(io).gc=cast(GCObject *, (x)); settt_(io, ctb(LUA_TTABLE)); \
234   checkliveness(G(L),io); }
235235
236#define setdeadvalue(obj)   settt_(obj, LUA_TDEADKEY)
236#define setdeadvalue(obj)   settt_(obj, LUA_TDEADKEY)
237237
238238
239239
240240#define setobj(L,obj1,obj2) \
241241   { const TValue *io2=(obj2); TValue *io1=(obj1); \
242     io1->value_ = io2->value_; io1->tt_ = io2->tt_; \
243     checkliveness(G(L),io1); }
242      io1->value_ = io2->value_; io1->tt_ = io2->tt_; \
243      checkliveness(G(L),io1); }
244244
245245
246246/*
r31374r31375
248248*/
249249
250250/* from stack to (same) stack */
251#define setobjs2s   setobj
251#define setobjs2s   setobj
252252/* to stack (not from same stack) */
253#define setobj2s   setobj
254#define setsvalue2s   setsvalue
255#define sethvalue2s   sethvalue
256#define setptvalue2s   setptvalue
253#define setobj2s    setobj
254#define setsvalue2s setsvalue
255#define sethvalue2s sethvalue
256#define setptvalue2s    setptvalue
257257/* from table to same table */
258#define setobjt2t   setobj
258#define setobjt2t   setobj
259259/* to table */
260#define setobj2t   setobj
260#define setobj2t    setobj
261261/* to new object */
262#define setobj2n   setobj
263#define setsvalue2n   setsvalue
262#define setobj2n    setobj
263#define setsvalue2n setsvalue
264264
265265
266266/* check whether a number is valid (useful only for NaN trick) */
267#define luai_checknum(L,o,c)   { /* empty */ }
267#define luai_checknum(L,o,c)    { /* empty */ }
268268
269269
270270/*
r31374r31375
282282*/
283283
284284/* allows for external implementation for part of the trick */
285#if !defined(NNMARK)   /* { */
285#if !defined(NNMARK)    /* { */
286286
287287
288288#if !defined(LUA_IEEEENDIAN)
r31374r31375
290290#endif
291291
292292
293#define NNMARK      0x7FF7A500
294#define NNMASK      0x7FFFFF00
293#define NNMARK      0x7FF7A500
294#define NNMASK      0x7FFFFF00
295295
296296#undef TValuefields
297297#undef NILCONSTANT
298298
299#if (LUA_IEEEENDIAN == 0)   /* { */
299#if (LUA_IEEEENDIAN == 0)   /* { */
300300
301301/* little endian */
302302#define TValuefields  \
303303   union { struct { Value v__; int tt__; } i; double d__; } u
304#define NILCONSTANT   {{{NULL}, tag2tt(LUA_TNIL)}}
304#define NILCONSTANT {{{NULL}, tag2tt(LUA_TNIL)}}
305305/* field-access macros */
306#define v_(o)      ((o)->u.i.v__)
307#define d_(o)      ((o)->u.d__)
308#define tt_(o)      ((o)->u.i.tt__)
306#define v_(o)       ((o)->u.i.v__)
307#define d_(o)       ((o)->u.d__)
308#define tt_(o)      ((o)->u.i.tt__)
309309
310#else            /* }{ */
310#else               /* }{ */
311311
312312/* big endian */
313313#define TValuefields  \
314314   union { struct { int tt__; Value v__; } i; double d__; } u
315#define NILCONSTANT   {{tag2tt(LUA_TNIL), {NULL}}}
315#define NILCONSTANT {{tag2tt(LUA_TNIL), {NULL}}}
316316/* field-access macros */
317#define v_(o)      ((o)->u.i.v__)
318#define d_(o)      ((o)->u.d__)
319#define tt_(o)      ((o)->u.i.tt__)
317#define v_(o)       ((o)->u.i.v__)
318#define d_(o)       ((o)->u.d__)
319#define tt_(o)      ((o)->u.i.tt__)
320320
321#endif            /* } */
321#endif              /* } */
322322
323#endif         /* } */
323#endif          /* } */
324324
325325
326326/* correspondence with standard representation */
327327#undef val_
328#define val_(o)      v_(o)
328#define val_(o)     v_(o)
329329#undef num_
330#define num_(o)      d_(o)
330#define num_(o)     d_(o)
331331
332332
333333#undef numfield
334#define numfield   /* no such field; numbers are the entire struct */
334#define numfield    /* no such field; numbers are the entire struct */
335335
336336/* basic check to distinguish numbers from non-numbers */
337337#undef ttisnumber
338#define ttisnumber(o)   ((tt_(o) & NNMASK) != NNMARK)
338#define ttisnumber(o)   ((tt_(o) & NNMASK) != NNMARK)
339339
340#define tag2tt(t)   (NNMARK | (t))
340#define tag2tt(t)   (NNMARK | (t))
341341
342342#undef rttype
343#define rttype(o)   (ttisnumber(o) ? LUA_TNUMBER : tt_(o) & 0xff)
343#define rttype(o)   (ttisnumber(o) ? LUA_TNUMBER : tt_(o) & 0xff)
344344
345345#undef settt_
346#define settt_(o,t)   (tt_(o) = tag2tt(t))
346#define settt_(o,t) (tt_(o) = tag2tt(t))
347347
348348#undef setnvalue
349349#define setnvalue(obj,x) \
r31374r31375
352352#undef setobj
353353#define setobj(L,obj1,obj2) \
354354   { const TValue *o2_=(obj2); TValue *o1_=(obj1); \
355     o1_->u = o2_->u; \
356     checkliveness(G(L),o1_); }
355      o1_->u = o2_->u; \
356      checkliveness(G(L),o1_); }
357357
358358
359359/*
r31374r31375
362362
363363#undef checktag
364364#undef checktype
365#define checktag(o,t)   (tt_(o) == tag2tt(t))
366#define checktype(o,t)   (ctb(tt_(o) | VARBITS) == ctb(tag2tt(t) | VARBITS))
365#define checktag(o,t)   (tt_(o) == tag2tt(t))
366#define checktype(o,t)  (ctb(tt_(o) | VARBITS) == ctb(tag2tt(t) | VARBITS))
367367
368368#undef ttisequal
369369#define ttisequal(o1,o2)  \
r31374r31375
371371
372372
373373#undef luai_checknum
374#define luai_checknum(L,o,c)   { if (!ttisnumber(o)) c; }
374#define luai_checknum(L,o,c)    { if (!ttisnumber(o)) c; }
375375
376376#endif
377377/* }====================================================== */
r31374r31375
386386
387387
388388union Value {
389  GCObject *gc;    /* collectable objects */
390  void *p;         /* light userdata */
391  int b;           /* booleans */
392  lua_CFunction f; /* light C functions */
393  numfield         /* numbers */
389   GCObject *gc;    /* collectable objects */
390   void *p;         /* light userdata */
391   int b;           /* booleans */
392   lua_CFunction f; /* light C functions */
393   numfield         /* numbers */
394394};
395395
396396
397397struct lua_TValue {
398  TValuefields;
398   TValuefields;
399399};
400400
401401
r31374r31375
408408** Header for string value; string bytes follow the end of this structure
409409*/
410410typedef union TString {
411  L_Umaxalign dummy;  /* ensures maximum alignment for strings */
412  struct {
413    CommonHeader;
414    lu_byte extra;  /* reserved words for short strings; "has hash" for longs */
415    unsigned int hash;
416    size_t len;  /* number of characters in string */
417  } tsv;
411   L_Umaxalign dummy;  /* ensures maximum alignment for strings */
412   struct {
413   CommonHeader;
414   lu_byte extra;  /* reserved words for short strings; "has hash" for longs */
415   unsigned int hash;
416   size_t len;  /* number of characters in string */
417   } tsv;
418418} TString;
419419
420420
421421/* get the actual string (array of bytes) from a TString */
422#define getstr(ts)   cast(const char *, (ts) + 1)
422#define getstr(ts)  cast(const char *, (ts) + 1)
423423
424424/* get the actual string (array of bytes) from a Lua value */
425425#define svalue(o)       getstr(rawtsvalue(o))
r31374r31375
429429** Header for userdata; memory area follows the end of this structure
430430*/
431431typedef union Udata {
432  L_Umaxalign dummy;  /* ensures maximum alignment for `local' udata */
433  struct {
434    CommonHeader;
435    struct Table *metatable;
436    struct Table *env;
437    size_t len;  /* number of bytes */
438  } uv;
432   L_Umaxalign dummy;  /* ensures maximum alignment for `local' udata */
433   struct {
434   CommonHeader;
435   struct Table *metatable;
436   struct Table *env;
437   size_t len;  /* number of bytes */
438   } uv;
439439} Udata;
440440
441441
r31374r31375
444444** Description of an upvalue for function prototypes
445445*/
446446typedef struct Upvaldesc {
447  TString *name;  /* upvalue name (for debug information) */
448  lu_byte instack;  /* whether it is in stack */
449  lu_byte idx;  /* index of upvalue (in stack or in outer function's list) */
447   TString *name;  /* upvalue name (for debug information) */
448   lu_byte instack;  /* whether it is in stack */
449   lu_byte idx;  /* index of upvalue (in stack or in outer function's list) */
450450} Upvaldesc;
451451
452452
r31374r31375
455455** (used for debug information)
456456*/
457457typedef struct LocVar {
458  TString *varname;
459  int startpc;  /* first point where variable is active */
460  int endpc;    /* first point where variable is dead */
458   TString *varname;
459   int startpc;  /* first point where variable is active */
460   int endpc;    /* first point where variable is dead */
461461} LocVar;
462462
463463
r31374r31375
465465** Function Prototypes
466466*/
467467typedef struct Proto {
468  CommonHeader;
469  TValue *k;  /* constants used by the function */
470  Instruction *code;
471  struct Proto **p;  /* functions defined inside the function */
472  int *lineinfo;  /* map from opcodes to source lines (debug information) */
473  LocVar *locvars;  /* information about local variables (debug information) */
474  Upvaldesc *upvalues;  /* upvalue information */
475  union Closure *cache;  /* last created closure with this prototype */
476  TString  *source;  /* used for debug information */
477  int sizeupvalues;  /* size of 'upvalues' */
478  int sizek;  /* size of `k' */
479  int sizecode;
480  int sizelineinfo;
481  int sizep;  /* size of `p' */
482  int sizelocvars;
483  int linedefined;
484  int lastlinedefined;
485  GCObject *gclist;
486  lu_byte numparams;  /* number of fixed parameters */
487  lu_byte is_vararg;
488  lu_byte maxstacksize;  /* maximum stack used by this function */
468   CommonHeader;
469   TValue *k;  /* constants used by the function */
470   Instruction *code;
471   struct Proto **p;  /* functions defined inside the function */
472   int *lineinfo;  /* map from opcodes to source lines (debug information) */
473   LocVar *locvars;  /* information about local variables (debug information) */
474   Upvaldesc *upvalues;  /* upvalue information */
475   union Closure *cache;  /* last created closure with this prototype */
476   TString  *source;  /* used for debug information */
477   int sizeupvalues;  /* size of 'upvalues' */
478   int sizek;  /* size of `k' */
479   int sizecode;
480   int sizelineinfo;
481   int sizep;  /* size of `p' */
482   int sizelocvars;
483   int linedefined;
484   int lastlinedefined;
485   GCObject *gclist;
486   lu_byte numparams;  /* number of fixed parameters */
487   lu_byte is_vararg;
488   lu_byte maxstacksize;  /* maximum stack used by this function */
489489} Proto;
490490
491491
r31374r31375
494494** Lua Upvalues
495495*/
496496typedef struct UpVal {
497  CommonHeader;
498  TValue *v;  /* points to stack or to its own value */
499  union {
500    TValue value;  /* the value (when closed) */
501    struct {  /* double linked list (when open) */
502      struct UpVal *prev;
503      struct UpVal *next;
504    } l;
505  } u;
497   CommonHeader;
498   TValue *v;  /* points to stack or to its own value */
499   union {
500   TValue value;  /* the value (when closed) */
501   struct {  /* double linked list (when open) */
502      struct UpVal *prev;
503      struct UpVal *next;
504   } l;
505   } u;
506506} UpVal;
507507
508508
r31374r31375
514514   CommonHeader; lu_byte nupvalues; GCObject *gclist
515515
516516typedef struct CClosure {
517  ClosureHeader;
518  lua_CFunction f;
519  TValue upvalue[1];  /* list of upvalues */
517   ClosureHeader;
518   lua_CFunction f;
519   TValue upvalue[1];  /* list of upvalues */
520520} CClosure;
521521
522522
523523typedef struct LClosure {
524  ClosureHeader;
525  struct Proto *p;
526  UpVal *upvals[1];  /* list of upvalues */
524   ClosureHeader;
525   struct Proto *p;
526   UpVal *upvals[1];  /* list of upvalues */
527527} LClosure;
528528
529529
530530typedef union Closure {
531  CClosure c;
532  LClosure l;
531   CClosure c;
532   LClosure l;
533533} Closure;
534534
535535
536#define isLfunction(o)   ttisLclosure(o)
536#define isLfunction(o)  ttisLclosure(o)
537537
538#define getproto(o)   (clLvalue(o)->p)
538#define getproto(o) (clLvalue(o)->p)
539539
540540
541541/*
r31374r31375
543543*/
544544
545545typedef union TKey {
546  struct {
547    TValuefields;
548    struct Node *next;  /* for chaining */
549  } nk;
550  TValue tvk;
546   struct {
547   TValuefields;
548   struct Node *next;  /* for chaining */
549   } nk;
550   TValue tvk;
551551} TKey;
552552
553553
554554typedef struct Node {
555  TValue i_val;
556  TKey i_key;
555   TValue i_val;
556   TKey i_key;
557557} Node;
558558
559559
560560typedef struct Table {
561  CommonHeader;
562  lu_byte flags;  /* 1<<p means tagmethod(p) is not present */
563  lu_byte lsizenode;  /* log2 of size of `node' array */
564  struct Table *metatable;
565  TValue *array;  /* array part */
566  Node *node;
567  Node *lastfree;  /* any free position is before this position */
568  GCObject *gclist;
569  int sizearray;  /* size of `array' array */
561   CommonHeader;
562   lu_byte flags;  /* 1<<p means tagmethod(p) is not present */
563   lu_byte lsizenode;  /* log2 of size of `node' array */
564   struct Table *metatable;
565   TValue *array;  /* array part */
566   Node *node;
567   Node *lastfree;  /* any free position is before this position */
568   GCObject *gclist;
569   int sizearray;  /* size of `array' array */
570570} Table;
571571
572572
r31374r31375
578578   (check_exp((size&(size-1))==0, (cast(int, (s) & ((size)-1)))))
579579
580580
581#define twoto(x)   (1<<(x))
582#define sizenode(t)   (twoto((t)->lsizenode))
581#define twoto(x)    (1<<(x))
582#define sizenode(t) (twoto((t)->lsizenode))
583583
584584
585585/*
586586** (address of) a fixed nil value
587587*/
588#define luaO_nilobject      (&luaO_nilobject_)
588#define luaO_nilobject      (&luaO_nilobject_)
589589
590590
591591LUAI_DDEC const TValue luaO_nilobject_;
r31374r31375
598598LUAI_FUNC int luaO_str2d (const char *s, size_t len, lua_Number *result);
599599LUAI_FUNC int luaO_hexavalue (int c);
600600LUAI_FUNC const char *luaO_pushvfstring (lua_State *L, const char *fmt,
601                                                       va_list argp);
601                                          va_list argp);
602602LUAI_FUNC const char *luaO_pushfstring (lua_State *L, const char *fmt, ...);
603603LUAI_FUNC void luaO_chunkid (char *out, const char *source, size_t len);
604604
605605
606606#endif
607
trunk/src/lib/lua/lstring.h
r31374r31375
1212#include "lstate.h"
1313
1414
15#define sizestring(s)   (sizeof(union TString)+((s)->len+1)*sizeof(char))
15#define sizestring(s)   (sizeof(union TString)+((s)->len+1)*sizeof(char))
1616
17#define sizeudata(u)   (sizeof(union Udata)+(u)->len)
17#define sizeudata(u)    (sizeof(union Udata)+(u)->len)
1818
19#define luaS_newliteral(L, s)   (luaS_newlstr(L, "" s, \
20                                 (sizeof(s)/sizeof(char))-1))
19#define luaS_newliteral(L, s)   (luaS_newlstr(L, "" s, \
20                           (sizeof(s)/sizeof(char))-1))
2121
22#define luaS_fix(s)   l_setbit((s)->tsv.marked, FIXEDBIT)
22#define luaS_fix(s) l_setbit((s)->tsv.marked, FIXEDBIT)
2323
2424
2525/*
2626** test whether a string is a reserved word
2727*/
28#define isreserved(s)   ((s)->tsv.tt == LUA_TSHRSTR && (s)->tsv.extra > 0)
28#define isreserved(s)   ((s)->tsv.tt == LUA_TSHRSTR && (s)->tsv.extra > 0)
2929
3030
3131/*
3232** equality for short strings, which are always internalized
3333*/
34#define eqshrstr(a,b)   check_exp((a)->tsv.tt == LUA_TSHRSTR, (a) == (b))
34#define eqshrstr(a,b)   check_exp((a)->tsv.tt == LUA_TSHRSTR, (a) == (b))
3535
3636
3737LUAI_FUNC unsigned int luaS_hash (const char *str, size_t l, unsigned int seed);
trunk/src/lib/lua/lcode.h
r31374r31375
2424** grep "ORDER OPR" if you change these enums  (ORDER OP)
2525*/
2626typedef enum BinOpr {
27  OPR_ADD, OPR_SUB, OPR_MUL, OPR_DIV, OPR_MOD, OPR_POW,
28  OPR_CONCAT,
29  OPR_EQ, OPR_LT, OPR_LE,
30  OPR_NE, OPR_GT, OPR_GE,
31  OPR_AND, OPR_OR,
32  OPR_NOBINOPR
27   OPR_ADD, OPR_SUB, OPR_MUL, OPR_DIV, OPR_MOD, OPR_POW,
28   OPR_CONCAT,
29   OPR_EQ, OPR_LT, OPR_LE,
30   OPR_NE, OPR_GT, OPR_GE,
31   OPR_AND, OPR_OR,
32   OPR_NOBINOPR
3333} BinOpr;
3434
3535
3636typedef enum UnOpr { OPR_MINUS, OPR_NOT, OPR_LEN, OPR_NOUNOPR } UnOpr;
3737
3838
39#define getcode(fs,e)   ((fs)->f->code[(e)->u.info])
39#define getcode(fs,e)   ((fs)->f->code[(e)->u.info])
4040
41#define luaK_codeAsBx(fs,o,A,sBx)   luaK_codeABx(fs,o,A,(sBx)+MAXARG_sBx)
41#define luaK_codeAsBx(fs,o,A,sBx)   luaK_codeABx(fs,o,A,(sBx)+MAXARG_sBx)
4242
43#define luaK_setmultret(fs,e)   luaK_setreturns(fs, e, LUA_MULTRET)
43#define luaK_setmultret(fs,e)   luaK_setreturns(fs, e, LUA_MULTRET)
4444
45#define luaK_jumpto(fs,t)   luaK_patchlist(fs, luaK_jump(fs), t)
45#define luaK_jumpto(fs,t)   luaK_patchlist(fs, luaK_jump(fs), t)
4646
4747LUAI_FUNC int luaK_codeABx (FuncState *fs, OpCode o, int A, unsigned int Bx);
4848LUAI_FUNC int luaK_codeABC (FuncState *fs, OpCode o, int A, int B, int C);
r31374r31375
7676LUAI_FUNC void luaK_prefix (FuncState *fs, UnOpr op, expdesc *v, int line);
7777LUAI_FUNC void luaK_infix (FuncState *fs, BinOpr op, expdesc *v);
7878LUAI_FUNC void luaK_posfix (FuncState *fs, BinOpr op, expdesc *v1,
79                            expdesc *v2, int line);
79                     expdesc *v2, int line);
8080LUAI_FUNC void luaK_setlist (FuncState *fs, int base, int nelems, int tostore);
8181
8282
trunk/src/lib/lua/luaconf.h
r31374r31375
3030
3131
3232#if !defined(LUA_ANSI) && defined(_WIN32) && !defined(_WIN32_WCE)
33#define LUA_WIN      /* enable goodies for regular Windows platforms */
33#define LUA_WIN     /* enable goodies for regular Windows platforms */
3434#endif
3535
3636#if defined(LUA_WIN)
3737#define LUA_DL_DLL
38#define LUA_USE_AFORMAT      /* assume 'printf' handles 'aA' specifiers */
38#define LUA_USE_AFORMAT     /* assume 'printf' handles 'aA' specifiers */
3939#endif
4040
4141
4242
4343#if defined(LUA_USE_LINUX)
4444#define LUA_USE_POSIX
45#define LUA_USE_DLOPEN      /* needs an extra library: -ldl */
46#define LUA_USE_READLINE   /* needs some extra libraries */
47#define LUA_USE_STRTODHEX   /* assume 'strtod' handles hex formats */
48#define LUA_USE_AFORMAT      /* assume 'printf' handles 'aA' specifiers */
49#define LUA_USE_LONGLONG   /* assume support for long long */
45#define LUA_USE_DLOPEN      /* needs an extra library: -ldl */
46#define LUA_USE_READLINE    /* needs some extra libraries */
47#define LUA_USE_STRTODHEX   /* assume 'strtod' handles hex formats */
48#define LUA_USE_AFORMAT     /* assume 'printf' handles 'aA' specifiers */
49#define LUA_USE_LONGLONG    /* assume support for long long */
5050#endif
5151
5252#if defined(LUA_USE_MACOSX)
5353#define LUA_USE_POSIX
54#define LUA_USE_DLOPEN      /* does not need -ldl */
55#define LUA_USE_READLINE   /* needs an extra library: -lreadline */
56#define LUA_USE_STRTODHEX   /* assume 'strtod' handles hex formats */
57#define LUA_USE_AFORMAT      /* assume 'printf' handles 'aA' specifiers */
58#define LUA_USE_LONGLONG   /* assume support for long long */
54#define LUA_USE_DLOPEN      /* does not need -ldl */
55#define LUA_USE_READLINE    /* needs an extra library: -lreadline */
56#define LUA_USE_STRTODHEX   /* assume 'strtod' handles hex formats */
57#define LUA_USE_AFORMAT     /* assume 'printf' handles 'aA' specifiers */
58#define LUA_USE_LONGLONG    /* assume support for long long */
5959#endif
6060
6161
r31374r31375
8484** hierarchy or if you want to install your libraries in
8585** non-conventional directories.
8686*/
87#if defined(_WIN32)   /* { */
87#if defined(_WIN32) /* { */
8888/*
8989** In Windows, any exclamation mark ('!') in the path is replaced by the
9090** path of the directory of the executable file of the current process.
9191*/
92#define LUA_LDIR   "!\\lua\\"
93#define LUA_CDIR   "!\\"
92#define LUA_LDIR    "!\\lua\\"
93#define LUA_CDIR    "!\\"
9494#define LUA_PATH_DEFAULT  \
9595      LUA_LDIR"?.lua;"  LUA_LDIR"?\\init.lua;" \
9696      LUA_CDIR"?.lua;"  LUA_CDIR"?\\init.lua;" ".\\?.lua"
9797#define LUA_CPATH_DEFAULT \
9898      LUA_CDIR"?.dll;" LUA_CDIR"loadall.dll;" ".\\?.dll"
9999
100#else         /* }{ */
100#else           /* }{ */
101101
102#define LUA_VDIR   LUA_VERSION_MAJOR "." LUA_VERSION_MINOR "/"
103#define LUA_ROOT   "/usr/local/"
104#define LUA_LDIR   LUA_ROOT "share/lua/" LUA_VDIR
105#define LUA_CDIR   LUA_ROOT "lib/lua/" LUA_VDIR
102#define LUA_VDIR    LUA_VERSION_MAJOR "." LUA_VERSION_MINOR "/"
103#define LUA_ROOT    "/usr/local/"
104#define LUA_LDIR    LUA_ROOT "share/lua/" LUA_VDIR
105#define LUA_CDIR    LUA_ROOT "lib/lua/" LUA_VDIR
106106#define LUA_PATH_DEFAULT  \
107107      LUA_LDIR"?.lua;"  LUA_LDIR"?/init.lua;" \
108108      LUA_CDIR"?.lua;"  LUA_CDIR"?/init.lua;" "./?.lua"
109109#define LUA_CPATH_DEFAULT \
110110      LUA_CDIR"?.so;" LUA_CDIR"loadall.so;" "./?.so"
111#endif         /* } */
111#endif          /* } */
112112
113113
114114/*
r31374r31375
117117** and is not Windows. (On Windows Lua automatically uses "\".)
118118*/
119119#if defined(_WIN32)
120#define LUA_DIRSEP   "\\"
120#define LUA_DIRSEP  "\\"
121121#else
122#define LUA_DIRSEP   "/"
122#define LUA_DIRSEP  "/"
123123#endif
124124
125125
r31374r31375
128128@@ environment, used to access global names.
129129** CHANGE it if you do not like this name.
130130*/
131#define LUA_ENV      "_ENV"
131#define LUA_ENV     "_ENV"
132132
133133
134134/*
r31374r31375
140140** the libraries, you may want to use the following definition (define
141141** LUA_BUILD_AS_DLL to get it).
142142*/
143#if defined(LUA_BUILD_AS_DLL)   /* { */
143#if defined(LUA_BUILD_AS_DLL)   /* { */
144144
145#if defined(LUA_CORE) || defined(LUA_LIB)   /* { */
145#if defined(LUA_CORE) || defined(LUA_LIB)   /* { */
146146#define LUA_API __declspec(dllexport)
147#else                  /* }{ */
147#else                       /* }{ */
148148#define LUA_API __declspec(dllimport)
149#endif                  /* } */
149#endif                      /* } */
150150
151#else            /* }{ */
151#else               /* }{ */
152152
153#define LUA_API      extern
153#define LUA_API     extern
154154
155#endif            /* } */
155#endif              /* } */
156156
157157
158158/* more often than not the libs go together with the core */
159#define LUALIB_API   LUA_API
160#define LUAMOD_API   LUALIB_API
159#define LUALIB_API  LUA_API
160#define LUAMOD_API  LUALIB_API
161161
162162
163163/*
r31374r31375
175175** default definition.
176176*/
177177#if defined(__GNUC__) && ((__GNUC__*100 + __GNUC_MINOR__) >= 302) && \
178    defined(__ELF__)      /* { */
179#define LUAI_FUNC   __attribute__((visibility("hidden"))) extern
180#define LUAI_DDEC   LUAI_FUNC
181#define LUAI_DDEF   /* empty */
178   defined(__ELF__)        /* { */
179#define LUAI_FUNC   __attribute__((visibility("hidden"))) extern
180#define LUAI_DDEC   LUAI_FUNC
181#define LUAI_DDEF   /* empty */
182182
183#else            /* }{ */
184#define LUAI_FUNC   extern
185#define LUAI_DDEC   extern
186#define LUAI_DDEF   /* empty */
187#endif            /* } */
183#else               /* }{ */
184#define LUAI_FUNC   extern
185#define LUAI_DDEC   extern
186#define LUAI_DDEF   /* empty */
187#endif              /* } */
188188
189189
190190
r31374r31375
192192@@ LUA_QL describes how error messages quote program elements.
193193** CHANGE it if you want a different appearance.
194194*/
195#define LUA_QL(x)   "'" x "'"
196#define LUA_QS      LUA_QL("%s")
195#define LUA_QL(x)   "'" x "'"
196#define LUA_QS      LUA_QL("%s")
197197
198198
199199/*
r31374r31375
201201@* of a function in debug information.
202202** CHANGE it if you want a different size.
203203*/
204#define LUA_IDSIZE   60
204#define LUA_IDSIZE  60
205205
206206
207207/*
r31374r31375
211211*/
212212#if defined(LUA_LIB) || defined(lua_c)
213213#include <stdio.h>
214#define luai_writestring(s,l)   fwrite((s), sizeof(char), (l), stdout)
215#define luai_writeline()   (luai_writestring("\n", 1), fflush(stdout))
214#define luai_writestring(s,l)   fwrite((s), sizeof(char), (l), stdout)
215#define luai_writeline()    (luai_writestring("\n", 1), fflush(stdout))
216216#endif
217217
218218/*
r31374r31375
244244** You can define it to get all options, or change specific options
245245** to fit your specific needs.
246246*/
247#if defined(LUA_COMPAT_ALL)   /* { */
247#if defined(LUA_COMPAT_ALL) /* { */
248248
249249/*
250250@@ LUA_COMPAT_UNPACK controls the presence of global 'unpack'.
r31374r31375
264264*/
265265#define lua_cpcall(L,f,u)  \
266266   (lua_pushcfunction(L, (f)), \
267    lua_pushlightuserdata(L,(u)), \
268    lua_pcall(L,1,0,0))
267      lua_pushlightuserdata(L,(u)), \
268      lua_pcall(L,1,0,0))
269269
270270
271271/*
r31374r31375
290290** changes in the API. The macros themselves document how to
291291** change your code to avoid using them.
292292*/
293#define lua_strlen(L,i)      lua_rawlen(L, (i))
293#define lua_strlen(L,i)     lua_rawlen(L, (i))
294294
295#define lua_objlen(L,i)      lua_rawlen(L, (i))
295#define lua_objlen(L,i)     lua_rawlen(L, (i))
296296
297#define lua_equal(L,idx1,idx2)      lua_compare(L,(idx1),(idx2),LUA_OPEQ)
298#define lua_lessthan(L,idx1,idx2)   lua_compare(L,(idx1),(idx2),LUA_OPLT)
297#define lua_equal(L,idx1,idx2)      lua_compare(L,(idx1),(idx2),LUA_OPEQ)
298#define lua_lessthan(L,idx1,idx2)   lua_compare(L,(idx1),(idx2),LUA_OPLT)
299299
300300/*
301301@@ LUA_COMPAT_MODULE controls compatibility with previous
r31374r31375
303303*/
304304#define LUA_COMPAT_MODULE
305305
306#endif            /* } */
306#endif              /* } */
307307
308308/* }================================================================== */
309309
r31374r31375
315315** your machine. Probably you do not need to change this.
316316*/
317317/* avoid overflows in comparison */
318#if INT_MAX-20 < 32760      /* { */
319#define LUAI_BITSINT   16
320#elif INT_MAX > 2147483640L   /* }{ */
318#if INT_MAX-20 < 32760      /* { */
319#define LUAI_BITSINT    16
320#elif INT_MAX > 2147483640L /* }{ */
321321/* int has at least 32 bits */
322#define LUAI_BITSINT   32
323#else            /* }{ */
322#define LUAI_BITSINT    32
323#else               /* }{ */
324324#error "you must define LUA_BITSINT with number of bits in an integer"
325#endif            /* } */
325#endif              /* } */
326326
327327
328328/*
r31374r31375
335335** good enough for your machine. Probably you do not need to change
336336** this.
337337*/
338#if LUAI_BITSINT >= 32      /* { */
339#define LUA_INT32   int
340#define LUAI_UMEM   size_t
341#define LUAI_MEM   ptrdiff_t
342#else            /* }{ */
338#if LUAI_BITSINT >= 32      /* { */
339#define LUA_INT32   int
340#define LUAI_UMEM   size_t
341#define LUAI_MEM    ptrdiff_t
342#else               /* }{ */
343343/* 16-bit ints */
344#define LUA_INT32   long
345#define LUAI_UMEM   unsigned long
346#define LUAI_MEM   long
347#endif            /* } */
344#define LUA_INT32   long
345#define LUAI_UMEM   unsigned long
346#define LUAI_MEM    long
347#endif              /* } */
348348
349349
350350/*
r31374r31375
354354** space (and to reserve some numbers for pseudo-indices).
355355*/
356356#if LUAI_BITSINT >= 32
357#define LUAI_MAXSTACK      1000000
357#define LUAI_MAXSTACK       1000000
358358#else
359#define LUAI_MAXSTACK      15000
359#define LUAI_MAXSTACK       15000
360360#endif
361361
362362/* reserve some space for error handling */
363#define LUAI_FIRSTPSEUDOIDX   (-LUAI_MAXSTACK - 1000)
363#define LUAI_FIRSTPSEUDOIDX (-LUAI_MAXSTACK - 1000)
364364
365365
366366
r31374r31375
369369@@ LUAL_BUFFERSIZE is the buffer size used by the lauxlib buffer system.
370370** CHANGE it if it uses too much C-stack space.
371371*/
372#define LUAL_BUFFERSIZE      BUFSIZ
372#define LUAL_BUFFERSIZE     BUFSIZ
373373
374374
375375
r31374r31375
384384*/
385385
386386#define LUA_NUMBER_DOUBLE
387#define LUA_NUMBER   double
387#define LUA_NUMBER  double
388388
389389/*
390390@@ LUAI_UACNUMBER is the result of an 'usual argument conversion'
391391@* over a number.
392392*/
393#define LUAI_UACNUMBER   double
393#define LUAI_UACNUMBER  double
394394
395395
396396/*
r31374r31375
399399@@ lua_number2str converts a number to a string.
400400@@ LUAI_MAXNUMBER2STR is maximum size of previous conversion.
401401*/
402#define LUA_NUMBER_SCAN      "%lf"
403#define LUA_NUMBER_FMT      "%.14g"
404#define lua_number2str(s,n)   sprintf((s), LUA_NUMBER_FMT, (n))
405#define LUAI_MAXNUMBER2STR   32 /* 16 digits, sign, point, and \0 */
402#define LUA_NUMBER_SCAN     "%lf"
403#define LUA_NUMBER_FMT      "%.14g"
404#define lua_number2str(s,n) sprintf((s), LUA_NUMBER_FMT, (n))
405#define LUAI_MAXNUMBER2STR  32 /* 16 digits, sign, point, and \0 */
406406
407407
408408/*
409409@@ l_mathop allows the addition of an 'l' or 'f' to all math operations
410410*/
411#define l_mathop(x)      (x)
411#define l_mathop(x)     (x)
412412
413413
414414/*
r31374r31375
419419** systems, you can leave 'lua_strx2number' undefined and Lua will
420420** provide its own implementation.
421421*/
422#define lua_str2number(s,p)   strtod((s), (p))
422#define lua_str2number(s,p) strtod((s), (p))
423423
424424#if defined(LUA_USE_STRTODHEX)
425#define lua_strx2number(s,p)   strtod((s), (p))
425#define lua_strx2number(s,p)    strtod((s), (p))
426426#endif
427427
428428
r31374r31375
433433/* the following operations need the math library */
434434#if defined(lobject_c) || defined(lvm_c)
435435#include <math.h>
436#define luai_nummod(L,a,b)   ((a) - l_mathop(floor)((a)/(b))*(b))
437#define luai_numpow(L,a,b)   (l_mathop(pow)(a,b))
436#define luai_nummod(L,a,b)  ((a) - l_mathop(floor)((a)/(b))*(b))
437#define luai_numpow(L,a,b)  (l_mathop(pow)(a,b))
438438#endif
439439
440440/* these are quite standard operations */
441441#if defined(LUA_CORE)
442#define luai_numadd(L,a,b)   ((a)+(b))
443#define luai_numsub(L,a,b)   ((a)-(b))
444#define luai_nummul(L,a,b)   ((a)*(b))
445#define luai_numdiv(L,a,b)   ((a)/(b))
446#define luai_numunm(L,a)   (-(a))
447#define luai_numeq(a,b)      ((a)==(b))
448#define luai_numlt(L,a,b)   ((a)<(b))
449#define luai_numle(L,a,b)   ((a)<=(b))
450#define luai_numisnan(L,a)   (!luai_numeq((a), (a)))
442#define luai_numadd(L,a,b)  ((a)+(b))
443#define luai_numsub(L,a,b)  ((a)-(b))
444#define luai_nummul(L,a,b)  ((a)*(b))
445#define luai_numdiv(L,a,b)  ((a)/(b))
446#define luai_numunm(L,a)    (-(a))
447#define luai_numeq(a,b)     ((a)==(b))
448#define luai_numlt(L,a,b)   ((a)<(b))
449#define luai_numle(L,a,b)   ((a)<=(b))
450#define luai_numisnan(L,a)  (!luai_numeq((a), (a)))
451451#endif
452452
453453
r31374r31375
457457** CHANGE that if ptrdiff_t is not adequate on your machine. (On most
458458** machines, ptrdiff_t gives a good choice between int or long.)
459459*/
460#define LUA_INTEGER   ptrdiff_t
460#define LUA_INTEGER ptrdiff_t
461461
462462/*
463463@@ LUA_UNSIGNED is the integral type used by lua_pushunsigned/lua_tounsigned.
464464** It must have at least 32 bits.
465465*/
466#define LUA_UNSIGNED   unsigned LUA_INT32
466#define LUA_UNSIGNED    unsigned LUA_INT32
467467
468468
469469
r31374r31375
471471** Some tricks with doubles
472472*/
473473
474#if defined(LUA_NUMBER_DOUBLE) && !defined(LUA_ANSI)   /* { */
474#if defined(LUA_NUMBER_DOUBLE) && !defined(LUA_ANSI)    /* { */
475475/*
476476** The next definitions activate some tricks to speed up the
477477** conversion from doubles to integer types, mainly to LUA_UNSIGNED.
r31374r31375
498498*/
499499
500500/* Microsoft compiler on a Pentium (32 bit) ? */
501#if defined(LUA_WIN) && defined(_MSC_VER) && defined(_M_IX86)   /* { */
501#if defined(LUA_WIN) && defined(_MSC_VER) && defined(_M_IX86)   /* { */
502502
503503#define LUA_MSASMTRICK
504#define LUA_IEEEENDIAN      0
504#define LUA_IEEEENDIAN      0
505505#define LUA_NANTRICK
506506
507507
r31374r31375
510510
511511#define LUA_IEEE754TRICK
512512#define LUA_IEEELL
513#define LUA_IEEEENDIAN      0
513#define LUA_IEEEENDIAN      0
514514#define LUA_NANTRICK
515515
516516/* pentium 64 bits? */
517#elif defined(__x86_64)                  /* }{ */
517#elif defined(__x86_64)                     /* }{ */
518518
519519#define LUA_IEEE754TRICK
520#define LUA_IEEEENDIAN      0
520#define LUA_IEEEENDIAN      0
521521
522#elif defined(__POWERPC__) || defined(__ppc__)         /* }{ */
522#elif defined(__POWERPC__) || defined(__ppc__)          /* }{ */
523523
524524#define LUA_IEEE754TRICK
525#define LUA_IEEEENDIAN      1
525#define LUA_IEEEENDIAN      1
526526
527#else                        /* }{ */
527#else                               /* }{ */
528528
529529/* assume IEEE754 and a 32-bit integer type */
530530#define LUA_IEEE754TRICK
531531
532#endif                        /* } */
532#endif                              /* } */
533533
534#endif                     /* } */
534#endif                          /* } */
535535
536536/* }================================================================== */
537537
r31374r31375
548548
549549
550550#endif
551
trunk/src/lib/lua/lmem.h
r31374r31375
2222** cast to 'void' avoids warnings of "value unused".
2323*/
2424#define luaM_reallocv(L,b,on,n,e) \
25  (cast(void, \
26     (cast(size_t, (n)+1) > MAX_SIZET/(e)) ? (luaM_toobig(L), 0) : 0), \
27   luaM_realloc_(L, (b), (on)*(e), (n)*(e)))
25   (cast(void, \
26      (cast(size_t, (n)+1) > MAX_SIZET/(e)) ? (luaM_toobig(L), 0) : 0), \
27   luaM_realloc_(L, (b), (on)*(e), (n)*(e)))
2828
29#define luaM_freemem(L, b, s)   luaM_realloc_(L, (b), (s), 0)
30#define luaM_free(L, b)      luaM_realloc_(L, (b), sizeof(*(b)), 0)
29#define luaM_freemem(L, b, s)   luaM_realloc_(L, (b), (s), 0)
30#define luaM_free(L, b)     luaM_realloc_(L, (b), sizeof(*(b)), 0)
3131#define luaM_freearray(L, b, n)   luaM_reallocv(L, (b), n, 0, sizeof((b)[0]))
3232
33#define luaM_malloc(L,s)   luaM_realloc_(L, NULL, 0, (s))
34#define luaM_new(L,t)      cast(t *, luaM_malloc(L, sizeof(t)))
33#define luaM_malloc(L,s)    luaM_realloc_(L, NULL, 0, (s))
34#define luaM_new(L,t)       cast(t *, luaM_malloc(L, sizeof(t)))
3535#define luaM_newvector(L,n,t) \
3636      cast(t *, luaM_reallocv(L, NULL, 0, n, sizeof(t)))
3737
38#define luaM_newobject(L,tag,s)   luaM_realloc_(L, NULL, tag, (s))
38#define luaM_newobject(L,tag,s) luaM_realloc_(L, NULL, tag, (s))
3939
4040#define luaM_growvector(L,v,nelems,size,t,limit,e) \
41          if ((nelems)+1 > (size)) \
42            ((v)=cast(t *, luaM_growaux_(L,v,&(size),sizeof(t),limit,e)))
41         if ((nelems)+1 > (size)) \
42         ((v)=cast(t *, luaM_growaux_(L,v,&(size),sizeof(t),limit,e)))
4343
4444#define luaM_reallocvector(L, v,oldn,n,t) \
45   ((v)=cast(t *, luaM_reallocv(L, v, oldn, n, sizeof(t))))
45   ((v)=cast(t *, luaM_reallocv(L, v, oldn, n, sizeof(t))))
4646
4747LUAI_FUNC l_noret luaM_toobig (lua_State *L);
4848
4949/* not to be called directly */
5050LUAI_FUNC void *luaM_realloc_ (lua_State *L, void *block, size_t oldsize,
51                                                          size_t size);
51                                             size_t size);
5252LUAI_FUNC void *luaM_growaux_ (lua_State *L, void *block, int *size,
53                               size_t size_elem, int limit,
54                               const char *what);
53                        size_t size_elem, int limit,
54                        const char *what);
5555
5656#endif
57
trunk/src/lib/lua/lstate.h
r31374r31375
5151
5252
5353/* kinds of Garbage Collection */
54#define KGC_NORMAL   0
55#define KGC_EMERGENCY   1   /* gc was forced by an allocation failure */
56#define KGC_GEN      2   /* generational collection */
54#define KGC_NORMAL  0
55#define KGC_EMERGENCY   1   /* gc was forced by an allocation failure */
56#define KGC_GEN     2   /* generational collection */
5757
5858
5959typedef struct stringtable {
60  GCObject **hash;
61  lu_int32 nuse;  /* number of elements */
62  int size;
60   GCObject **hash;
61   lu_int32 nuse;  /* number of elements */
62   int size;
6363} stringtable;
6464
6565
r31374r31375
6767** information about a call
6868*/
6969typedef struct CallInfo {
70  StkId func;  /* function index in the stack */
71  StkId   top;  /* top for this function */
72  struct CallInfo *previous, *next;  /* dynamic call link */
73  short nresults;  /* expected number of results from this function */
74  lu_byte callstatus;
75  ptrdiff_t extra;
76  union {
77    struct {  /* only for Lua functions */
78      StkId base;  /* base for this function */
79      const Instruction *savedpc;
80    } l;
81    struct {  /* only for C functions */
82      int ctx;  /* context info. in case of yields */
83      lua_CFunction k;  /* continuation in case of yields */
84      ptrdiff_t old_errfunc;
85      lu_byte old_allowhook;
86      lu_byte status;
87    } c;
88  } u;
70   StkId func;  /* function index in the stack */
71   StkId   top;  /* top for this function */
72   struct CallInfo *previous, *next;  /* dynamic call link */
73   short nresults;  /* expected number of results from this function */
74   lu_byte callstatus;
75   ptrdiff_t extra;
76   union {
77   struct {  /* only for Lua functions */
78      StkId base;  /* base for this function */
79      const Instruction *savedpc;
80   } l;
81   struct {  /* only for C functions */
82      int ctx;  /* context info. in case of yields */
83      lua_CFunction k;  /* continuation in case of yields */
84      ptrdiff_t old_errfunc;
85      lu_byte old_allowhook;
86      lu_byte status;
87   } c;
88   } u;
8989} CallInfo;
9090
9191
9292/*
9393** Bits in CallInfo status
9494*/
95#define CIST_LUA   (1<<0)   /* call is running a Lua function */
96#define CIST_HOOKED   (1<<1)   /* call is running a debug hook */
97#define CIST_REENTRY   (1<<2)   /* call is running on same invocation of
95#define CIST_LUA    (1<<0)  /* call is running a Lua function */
96#define CIST_HOOKED (1<<1)  /* call is running a debug hook */
97#define CIST_REENTRY    (1<<2)  /* call is running on same invocation of
9898                                   luaV_execute of previous call */
99#define CIST_YIELDED   (1<<3)   /* call reentered after suspension */
100#define CIST_YPCALL   (1<<4)   /* call is a yieldable protected call */
101#define CIST_STAT   (1<<5)   /* call has an error status (pcall) */
102#define CIST_TAIL   (1<<6)   /* call was tail called */
103#define CIST_HOOKYIELD   (1<<7)   /* last hook called yielded */
99#define CIST_YIELDED    (1<<3)  /* call reentered after suspension */
100#define CIST_YPCALL (1<<4)  /* call is a yieldable protected call */
101#define CIST_STAT   (1<<5)  /* call has an error status (pcall) */
102#define CIST_TAIL   (1<<6)  /* call was tail called */
103#define CIST_HOOKYIELD  (1<<7)  /* last hook called yielded */
104104
105105
106#define isLua(ci)   ((ci)->callstatus & CIST_LUA)
106#define isLua(ci)   ((ci)->callstatus & CIST_LUA)
107107
108108
109109/*
110110** `global state', shared by all threads of this state
111111*/
112112typedef struct global_State {
113  lua_Alloc frealloc;  /* function to reallocate memory */
114  void *ud;         /* auxiliary data to `frealloc' */
115  lu_mem totalbytes;  /* number of bytes currently allocated - GCdebt */
116  l_mem GCdebt;  /* bytes allocated not yet compensated by the collector */
117  lu_mem GCmemtrav;  /* memory traversed by the GC */
118  lu_mem GCestimate;  /* an estimate of the non-garbage memory in use */
119  stringtable strt;  /* hash table for strings */
120  TValue l_registry;
121  unsigned int seed;  /* randomized seed for hashes */
122  lu_byte currentwhite;
123  lu_byte gcstate;  /* state of garbage collector */
124  lu_byte gckind;  /* kind of GC running */
125  lu_byte gcrunning;  /* true if GC is running */
126  int sweepstrgc;  /* position of sweep in `strt' */
127  GCObject *allgc;  /* list of all collectable objects */
128  GCObject *finobj;  /* list of collectable objects with finalizers */
129  GCObject **sweepgc;  /* current position of sweep in list 'allgc' */
130  GCObject **sweepfin;  /* current position of sweep in list 'finobj' */
131  GCObject *gray;  /* list of gray objects */
132  GCObject *grayagain;  /* list of objects to be traversed atomically */
133  GCObject *weak;  /* list of tables with weak values */
134  GCObject *ephemeron;  /* list of ephemeron tables (weak keys) */
135  GCObject *allweak;  /* list of all-weak tables */
136  GCObject *tobefnz;  /* list of userdata to be GC */
137  UpVal uvhead;  /* head of double-linked list of all open upvalues */
138  Mbuffer buff;  /* temporary buffer for string concatenation */
139  int gcpause;  /* size of pause between successive GCs */
140  int gcmajorinc;  /* pause between major collections (only in gen. mode) */
141  int gcstepmul;  /* GC `granularity' */
142  lua_CFunction panic;  /* to be called in unprotected errors */
143  struct lua_State *mainthread;
144  const lua_Number *version;  /* pointer to version number */
145  TString *memerrmsg;  /* memory-error message */
146  TString *tmname[TM_N];  /* array with tag-method names */
147  struct Table *mt[LUA_NUMTAGS];  /* metatables for basic types */
113   lua_Alloc frealloc;  /* function to reallocate memory */
114   void *ud;         /* auxiliary data to `frealloc' */
115   lu_mem totalbytes;  /* number of bytes currently allocated - GCdebt */
116   l_mem GCdebt;  /* bytes allocated not yet compensated by the collector */
117   lu_mem GCmemtrav;  /* memory traversed by the GC */
118   lu_mem GCestimate;  /* an estimate of the non-garbage memory in use */
119   stringtable strt;  /* hash table for strings */
120   TValue l_registry;
121   unsigned int seed;  /* randomized seed for hashes */
122   lu_byte currentwhite;
123   lu_byte gcstate;  /* state of garbage collector */
124   lu_byte gckind;  /* kind of GC running */
125   lu_byte gcrunning;  /* true if GC is running */
126   int sweepstrgc;  /* position of sweep in `strt' */
127   GCObject *allgc;  /* list of all collectable objects */
128   GCObject *finobj;  /* list of collectable objects with finalizers */
129   GCObject **sweepgc;  /* current position of sweep in list 'allgc' */
130   GCObject **sweepfin;  /* current position of sweep in list 'finobj' */
131   GCObject *gray;  /* list of gray objects */
132   GCObject *grayagain;  /* list of objects to be traversed atomically */
133   GCObject *weak;  /* list of tables with weak values */
134   GCObject *ephemeron;  /* list of ephemeron tables (weak keys) */
135   GCObject *allweak;  /* list of all-weak tables */
136   GCObject *tobefnz;  /* list of userdata to be GC */
137   UpVal uvhead;  /* head of double-linked list of all open upvalues */
138   Mbuffer buff;  /* temporary buffer for string concatenation */
139   int gcpause;  /* size of pause between successive GCs */
140   int gcmajorinc;  /* pause between major collections (only in gen. mode) */
141   int gcstepmul;  /* GC `granularity' */
142   lua_CFunction panic;  /* to be called in unprotected errors */
143   struct lua_State *mainthread;
144   const lua_Number *version;  /* pointer to version number */
145   TString *memerrmsg;  /* memory-error message */
146   TString *tmname[TM_N];  /* array with tag-method names */
147   struct Table *mt[LUA_NUMTAGS];  /* metatables for basic types */
148148} global_State;
149149
150150
r31374r31375
152152** `per thread' state
153153*/
154154struct lua_State {
155  CommonHeader;
156  lu_byte status;
157  StkId top;  /* first free slot in the stack */
158  global_State *l_G;
159  CallInfo *ci;  /* call info for current function */
160  const Instruction *oldpc;  /* last pc traced */
161  StkId stack_last;  /* last free slot in the stack */
162  StkId stack;  /* stack base */
163  int stacksize;
164  unsigned short nny;  /* number of non-yieldable calls in stack */
165  unsigned short nCcalls;  /* number of nested C calls */
166  lu_byte hookmask;
167  lu_byte allowhook;
168  int basehookcount;
169  int hookcount;
170  lua_Hook hook;
171  GCObject *openupval;  /* list of open upvalues in this stack */
172  GCObject *gclist;
173  struct lua_longjmp *errorJmp;  /* current error recover point */
174  ptrdiff_t errfunc;  /* current error handling function (stack index) */
175  CallInfo base_ci;  /* CallInfo for first level (C calling Lua) */
155   CommonHeader;
156   lu_byte status;
157   StkId top;  /* first free slot in the stack */
158   global_State *l_G;
159   CallInfo *ci;  /* call info for current function */
160   const Instruction *oldpc;  /* last pc traced */
161   StkId stack_last;  /* last free slot in the stack */
162   StkId stack;  /* stack base */
163   int stacksize;
164   unsigned short nny;  /* number of non-yieldable calls in stack */
165   unsigned short nCcalls;  /* number of nested C calls */
166   lu_byte hookmask;
167   lu_byte allowhook;
168   int basehookcount;
169   int hookcount;
170   lua_Hook hook;
171   GCObject *openupval;  /* list of open upvalues in this stack */
172   GCObject *gclist;
173   struct lua_longjmp *errorJmp;  /* current error recover point */
174   ptrdiff_t errfunc;  /* current error handling function (stack index) */
175   CallInfo base_ci;  /* CallInfo for first level (C calling Lua) */
176176};
177177
178178
179#define G(L)   (L->l_G)
179#define G(L)    (L->l_G)
180180
181181
182182/*
183183** Union of all collectable objects
184184*/
185185union GCObject {
186  GCheader gch;  /* common header */
187  union TString ts;
188  union Udata u;
189  union Closure cl;
190  struct Table h;
191  struct Proto p;
192  struct UpVal uv;
193  struct lua_State th;  /* thread */
186   GCheader gch;  /* common header */
187   union TString ts;
188   union Udata u;
189   union Closure cl;
190   struct Table h;
191   struct Proto p;
192   struct UpVal uv;
193   struct lua_State th;  /* thread */
194194};
195195
196196
197#define gch(o)      (&(o)->gch)
197#define gch(o)      (&(o)->gch)
198198
199199/* macros to convert a GCObject into a specific value */
200200#define rawgco2ts(o)  \
201201   check_exp(novariant((o)->gch.tt) == LUA_TSTRING, &((o)->ts))
202#define gco2ts(o)   (&rawgco2ts(o)->tsv)
203#define rawgco2u(o)   check_exp((o)->gch.tt == LUA_TUSERDATA, &((o)->u))
204#define gco2u(o)   (&rawgco2u(o)->uv)
205#define gco2lcl(o)   check_exp((o)->gch.tt == LUA_TLCL, &((o)->cl.l))
206#define gco2ccl(o)   check_exp((o)->gch.tt == LUA_TCCL, &((o)->cl.c))
202#define gco2ts(o)   (&rawgco2ts(o)->tsv)
203#define rawgco2u(o) check_exp((o)->gch.tt == LUA_TUSERDATA, &((o)->u))
204#define gco2u(o)    (&rawgco2u(o)->uv)
205#define gco2lcl(o)  check_exp((o)->gch.tt == LUA_TLCL, &((o)->cl.l))
206#define gco2ccl(o)  check_exp((o)->gch.tt == LUA_TCCL, &((o)->cl.c))
207207#define gco2cl(o)  \
208208   check_exp(novariant((o)->gch.tt) == LUA_TFUNCTION, &((o)->cl))
209#define gco2t(o)   check_exp((o)->gch.tt == LUA_TTABLE, &((o)->h))
210#define gco2p(o)   check_exp((o)->gch.tt == LUA_TPROTO, &((o)->p))
211#define gco2uv(o)   check_exp((o)->gch.tt == LUA_TUPVAL, &((o)->uv))
212#define gco2th(o)   check_exp((o)->gch.tt == LUA_TTHREAD, &((o)->th))
209#define gco2t(o)    check_exp((o)->gch.tt == LUA_TTABLE, &((o)->h))
210#define gco2p(o)    check_exp((o)->gch.tt == LUA_TPROTO, &((o)->p))
211#define gco2uv(o)   check_exp((o)->gch.tt == LUA_TUPVAL, &((o)->uv))
212#define gco2th(o)   check_exp((o)->gch.tt == LUA_TTHREAD, &((o)->th))
213213
214214/* macro to convert any Lua object into a GCObject */
215#define obj2gco(v)   (cast(GCObject *, (v)))
215#define obj2gco(v)  (cast(GCObject *, (v)))
216216
217217
218218/* actual number of total bytes allocated */
219#define gettotalbytes(g)   ((g)->totalbytes + (g)->GCdebt)
219#define gettotalbytes(g)    ((g)->totalbytes + (g)->GCdebt)
220220
221221LUAI_FUNC void luaE_setdebt (global_State *g, l_mem debt);
222222LUAI_FUNC void luaE_freethread (lua_State *L, lua_State *L1);
r31374r31375
225225
226226
227227#endif
228
trunk/src/lib/lua/lctype.h
r31374r31375
2020
2121#if 'A' == 65 && '0' == 48
2222/* ASCII case: can use its own tables; faster and fixed */
23#define LUA_USE_CTYPE   0
23#define LUA_USE_CTYPE   0
2424#else
2525/* must use standard C ctype */
26#define LUA_USE_CTYPE   1
26#define LUA_USE_CTYPE   1
2727#endif
2828
2929#endif
3030
3131
32#if !LUA_USE_CTYPE   /* { */
32#if !LUA_USE_CTYPE  /* { */
3333
3434#include <limits.h>
3535
3636#include "llimits.h"
3737
3838
39#define ALPHABIT   0
40#define DIGITBIT   1
41#define PRINTBIT   2
42#define SPACEBIT   3
43#define XDIGITBIT   4
39#define ALPHABIT    0
40#define DIGITBIT    1
41#define PRINTBIT    2
42#define SPACEBIT    3
43#define XDIGITBIT   4
4444
4545
46#define MASK(B)      (1 << (B))
46#define MASK(B)     (1 << (B))
4747
4848
4949/*
5050** add 1 to char to allow index -1 (EOZ)
5151*/
52#define testprop(c,p)   (luai_ctype_[(c)+1] & (p))
52#define testprop(c,p)   (luai_ctype_[(c)+1] & (p))
5353
5454/*
5555** 'lalpha' (Lua alphabetic) and 'lalnum' (Lua alphanumeric) both include '_'
5656*/
57#define lislalpha(c)   testprop(c, MASK(ALPHABIT))
58#define lislalnum(c)   testprop(c, (MASK(ALPHABIT) | MASK(DIGITBIT)))
59#define lisdigit(c)   testprop(c, MASK(DIGITBIT))
60#define lisspace(c)   testprop(c, MASK(SPACEBIT))
61#define lisprint(c)   testprop(c, MASK(PRINTBIT))
62#define lisxdigit(c)   testprop(c, MASK(XDIGITBIT))
57#define lislalpha(c)    testprop(c, MASK(ALPHABIT))
58#define lislalnum(c)    testprop(c, (MASK(ALPHABIT) | MASK(DIGITBIT)))
59#define lisdigit(c) testprop(c, MASK(DIGITBIT))
60#define lisspace(c) testprop(c, MASK(SPACEBIT))
61#define lisprint(c) testprop(c, MASK(PRINTBIT))
62#define lisxdigit(c)    testprop(c, MASK(XDIGITBIT))
6363
6464/*
6565** this 'ltolower' only works for alphabetic characters
6666*/
67#define ltolower(c)   ((c) | ('A' ^ 'a'))
67#define ltolower(c) ((c) | ('A' ^ 'a'))
6868
6969
7070/* two more entries for 0 and -1 (EOZ) */
7171LUAI_DDEC const lu_byte luai_ctype_[UCHAR_MAX + 2];
7272
7373
74#else         /* }{ */
74#else           /* }{ */
7575
7676/*
7777** use standard C ctypes
r31374r31375
8080#include <ctype.h>
8181
8282
83#define lislalpha(c)   (isalpha(c) || (c) == '_')
84#define lislalnum(c)   (isalnum(c) || (c) == '_')
85#define lisdigit(c)   (isdigit(c))
86#define lisspace(c)   (isspace(c))
87#define lisprint(c)   (isprint(c))
88#define lisxdigit(c)   (isxdigit(c))
83#define lislalpha(c)    (isalpha(c) || (c) == '_')
84#define lislalnum(c)    (isalnum(c) || (c) == '_')
85#define lisdigit(c) (isdigit(c))
86#define lisspace(c) (isspace(c))
87#define lisprint(c) (isprint(c))
88#define lisxdigit(c)    (isxdigit(c))
8989
90#define ltolower(c)   (tolower(c))
90#define ltolower(c) (tolower(c))
9191
92#endif         /* } */
92#endif          /* } */
9393
9494#endif
95
trunk/src/lib/lua/lauxlib.h
r31374r31375
2121
2222
2323typedef struct luaL_Reg {
24  const char *name;
25  lua_CFunction func;
24   const char *name;
25   lua_CFunction func;
2626} luaL_Reg;
2727
2828
2929LUALIB_API void (luaL_checkversion_) (lua_State *L, lua_Number ver);
30#define luaL_checkversion(L)   luaL_checkversion_(L, LUA_VERSION_NUM)
30#define luaL_checkversion(L)    luaL_checkversion_(L, LUA_VERSION_NUM)
3131
3232LUALIB_API int (luaL_getmetafield) (lua_State *L, int obj, const char *e);
3333LUALIB_API int (luaL_callmeta) (lua_State *L, int obj, const char *e);
3434LUALIB_API const char *(luaL_tolstring) (lua_State *L, int idx, size_t *len);
3535LUALIB_API int (luaL_argerror) (lua_State *L, int numarg, const char *extramsg);
3636LUALIB_API const char *(luaL_checklstring) (lua_State *L, int numArg,
37                                                          size_t *l);
37                                             size_t *l);
3838LUALIB_API const char *(luaL_optlstring) (lua_State *L, int numArg,
39                                          const char *def, size_t *l);
39                                 const char *def, size_t *l);
4040LUALIB_API lua_Number (luaL_checknumber) (lua_State *L, int numArg);
4141LUALIB_API lua_Number (luaL_optnumber) (lua_State *L, int nArg, lua_Number def);
4242
4343LUALIB_API lua_Integer (luaL_checkinteger) (lua_State *L, int numArg);
4444LUALIB_API lua_Integer (luaL_optinteger) (lua_State *L, int nArg,
45                                          lua_Integer def);
45                                 lua_Integer def);
4646LUALIB_API lua_Unsigned (luaL_checkunsigned) (lua_State *L, int numArg);
4747LUALIB_API lua_Unsigned (luaL_optunsigned) (lua_State *L, int numArg,
48                                            lua_Unsigned def);
48                                 lua_Unsigned def);
4949
5050LUALIB_API void (luaL_checkstack) (lua_State *L, int sz, const char *msg);
5151LUALIB_API void (luaL_checktype) (lua_State *L, int narg, int t);
r31374r31375
6060LUALIB_API int (luaL_error) (lua_State *L, const char *fmt, ...);
6161
6262LUALIB_API int (luaL_checkoption) (lua_State *L, int narg, const char *def,
63                                   const char *const lst[]);
63                           const char *const lst[]);
6464
6565LUALIB_API int (luaL_fileresult) (lua_State *L, int stat, const char *fname);
6666LUALIB_API int (luaL_execresult) (lua_State *L, int stat);
r31374r31375
7373LUALIB_API void (luaL_unref) (lua_State *L, int t, int ref);
7474
7575LUALIB_API int (luaL_loadfilex) (lua_State *L, const char *filename,
76                                               const char *mode);
76                                    const char *mode);
7777
78#define luaL_loadfile(L,f)   luaL_loadfilex(L,f,NULL)
78#define luaL_loadfile(L,f)  luaL_loadfilex(L,f,NULL)
7979
8080LUALIB_API int (luaL_loadbufferx) (lua_State *L, const char *buff, size_t sz,
81                                   const char *name, const char *mode);
81                           const char *name, const char *mode);
8282LUALIB_API int (luaL_loadstring) (lua_State *L, const char *s);
8383
8484LUALIB_API lua_State *(luaL_newstate) (void);
r31374r31375
8686LUALIB_API int (luaL_len) (lua_State *L, int idx);
8787
8888LUALIB_API const char *(luaL_gsub) (lua_State *L, const char *s, const char *p,
89                                                  const char *r);
89                                       const char *r);
9090
9191LUALIB_API void (luaL_setfuncs) (lua_State *L, const luaL_Reg *l, int nup);
9292
9393LUALIB_API int (luaL_getsubtable) (lua_State *L, int idx, const char *fname);
9494
9595LUALIB_API void (luaL_traceback) (lua_State *L, lua_State *L1,
96                                  const char *msg, int level);
96                           const char *msg, int level);
9797
9898LUALIB_API void (luaL_requiref) (lua_State *L, const char *modname,
99                                 lua_CFunction openf, int glb);
99                           lua_CFunction openf, int glb);
100100
101101/*
102102** ===============================================================
r31374r31375
105105*/
106106
107107
108#define luaL_newlibtable(L,l)   \
109  lua_createtable(L, 0, sizeof(l)/sizeof((l)[0]) - 1)
108#define luaL_newlibtable(L,l)   \
109   lua_createtable(L, 0, sizeof(l)/sizeof((l)[0]) - 1)
110110
111#define luaL_newlib(L,l)   (luaL_newlibtable(L,l), luaL_setfuncs(L,l,0))
111#define luaL_newlib(L,l)    (luaL_newlibtable(L,l), luaL_setfuncs(L,l,0))
112112
113#define luaL_argcheck(L, cond,numarg,extramsg)   \
113#define luaL_argcheck(L, cond,numarg,extramsg)  \
114114      ((void)((cond) || luaL_argerror(L, (numarg), (extramsg))))
115#define luaL_checkstring(L,n)   (luaL_checklstring(L, (n), NULL))
116#define luaL_optstring(L,n,d)   (luaL_optlstring(L, (n), (d), NULL))
117#define luaL_checkint(L,n)   ((int)luaL_checkinteger(L, (n)))
118#define luaL_optint(L,n,d)   ((int)luaL_optinteger(L, (n), (d)))
119#define luaL_checklong(L,n)   ((long)luaL_checkinteger(L, (n)))
120#define luaL_optlong(L,n,d)   ((long)luaL_optinteger(L, (n), (d)))
115#define luaL_checkstring(L,n)   (luaL_checklstring(L, (n), NULL))
116#define luaL_optstring(L,n,d)   (luaL_optlstring(L, (n), (d), NULL))
117#define luaL_checkint(L,n)  ((int)luaL_checkinteger(L, (n)))
118#define luaL_optint(L,n,d)  ((int)luaL_optinteger(L, (n), (d)))
119#define luaL_checklong(L,n) ((long)luaL_checkinteger(L, (n)))
120#define luaL_optlong(L,n,d) ((long)luaL_optinteger(L, (n), (d)))
121121
122#define luaL_typename(L,i)   lua_typename(L, lua_type(L,(i)))
122#define luaL_typename(L,i)  lua_typename(L, lua_type(L,(i)))
123123
124124#define luaL_dofile(L, fn) \
125125   (luaL_loadfile(L, fn) || lua_pcall(L, 0, LUA_MULTRET, 0))
r31374r31375
127127#define luaL_dostring(L, s) \
128128   (luaL_loadstring(L, s) || lua_pcall(L, 0, LUA_MULTRET, 0))
129129
130#define luaL_getmetatable(L,n)   (lua_getfield(L, LUA_REGISTRYINDEX, (n)))
130#define luaL_getmetatable(L,n)  (lua_getfield(L, LUA_REGISTRYINDEX, (n)))
131131
132#define luaL_opt(L,f,n,d)   (lua_isnoneornil(L,(n)) ? (d) : f(L,(n)))
132#define luaL_opt(L,f,n,d)   (lua_isnoneornil(L,(n)) ? (d) : f(L,(n)))
133133
134#define luaL_loadbuffer(L,s,sz,n)   luaL_loadbufferx(L,s,sz,n,NULL)
134#define luaL_loadbuffer(L,s,sz,n)   luaL_loadbufferx(L,s,sz,n,NULL)
135135
136136
137137/*
r31374r31375
141141*/
142142
143143typedef struct luaL_Buffer {
144  char *b;  /* buffer address */
145  size_t size;  /* buffer size */
146  size_t n;  /* number of characters in buffer */
147  lua_State *L;
148  char initb[LUAL_BUFFERSIZE];  /* initial buffer */
144   char *b;  /* buffer address */
145   size_t size;  /* buffer size */
146   size_t n;  /* number of characters in buffer */
147   lua_State *L;
148   char initb[LUAL_BUFFERSIZE];  /* initial buffer */
149149} luaL_Buffer;
150150
151151
152152#define luaL_addchar(B,c) \
153  ((void)((B)->n < (B)->size || luaL_prepbuffsize((B), 1)), \
154   ((B)->b[(B)->n++] = (c)))
153   ((void)((B)->n < (B)->size || luaL_prepbuffsize((B), 1)), \
154   ((B)->b[(B)->n++] = (c)))
155155
156#define luaL_addsize(B,s)   ((B)->n += (s))
156#define luaL_addsize(B,s)   ((B)->n += (s))
157157
158158LUALIB_API void (luaL_buffinit) (lua_State *L, luaL_Buffer *B);
159159LUALIB_API char *(luaL_prepbuffsize) (luaL_Buffer *B, size_t sz);
r31374r31375
164164LUALIB_API void (luaL_pushresultsize) (luaL_Buffer *B, size_t sz);
165165LUALIB_API char *(luaL_buffinitsize) (lua_State *L, luaL_Buffer *B, size_t sz);
166166
167#define luaL_prepbuffer(B)   luaL_prepbuffsize(B, LUAL_BUFFERSIZE)
167#define luaL_prepbuffer(B)  luaL_prepbuffsize(B, LUAL_BUFFERSIZE)
168168
169169/* }====================================================== */
170170
r31374r31375
186186
187187
188188typedef struct luaL_Stream {
189  FILE *f;  /* stream (NULL for incompletely created streams) */
190  lua_CFunction closef;  /* to close stream (NULL for closed streams) */
189   FILE *f;  /* stream (NULL for incompletely created streams) */
190   lua_CFunction closef;  /* to close stream (NULL for closed streams) */
191191} luaL_Stream;
192192
193193/* }====================================================== */
r31374r31375
198198#if defined(LUA_COMPAT_MODULE)
199199
200200LUALIB_API void (luaL_pushmodule) (lua_State *L, const char *modname,
201                                   int sizehint);
201                           int sizehint);
202202LUALIB_API void (luaL_openlib) (lua_State *L, const char *libname,
203                                const luaL_Reg *l, int nup);
203                        const luaL_Reg *l, int nup);
204204
205#define luaL_register(L,n,l)   (luaL_openlib(L,(n),(l),0))
205#define luaL_register(L,n,l)    (luaL_openlib(L,(n),(l),0))
206206
207207#endif
208208
209209
210210#endif
211
212
trunk/src/lib/lua/ltable.h
r31374r31375
1010#include "lobject.h"
1111
1212
13#define gnode(t,i)   (&(t)->node[i])
14#define gkey(n)      (&(n)->i_key.tvk)
15#define gval(n)      (&(n)->i_val)
16#define gnext(n)   ((n)->i_key.nk.next)
13#define gnode(t,i)  (&(t)->node[i])
14#define gkey(n)     (&(n)->i_key.tvk)
15#define gval(n)     (&(n)->i_val)
16#define gnext(n)    ((n)->i_key.nk.next)
1717
18#define invalidateTMcache(t)   ((t)->flags = 0)
18#define invalidateTMcache(t)    ((t)->flags = 0)
1919
2020/* returns the key, given the value of a table entry */
2121#define keyfromval(v) \
22  (gkey(cast(Node *, cast(char *, (v)) - offsetof(Node, i_val))))
22   (gkey(cast(Node *, cast(char *, (v)) - offsetof(Node, i_val))))
2323
2424
2525LUAI_FUNC const TValue *luaH_getint (Table *t, int key);
trunk/src/lib/lua/llex.h
r31374r31375
1111#include "lzio.h"
1212
1313
14#define FIRST_RESERVED   257
14#define FIRST_RESERVED  257
1515
1616
1717
r31374r31375
2020* grep "ORDER RESERVED"
2121*/
2222enum RESERVED {
23  /* terminal symbols denoted by reserved words */
24  TK_AND = FIRST_RESERVED, TK_BREAK,
25  TK_DO, TK_ELSE, TK_ELSEIF, TK_END, TK_FALSE, TK_FOR, TK_FUNCTION,
26  TK_GOTO, TK_IF, TK_IN, TK_LOCAL, TK_NIL, TK_NOT, TK_OR, TK_REPEAT,
27  TK_RETURN, TK_THEN, TK_TRUE, TK_UNTIL, TK_WHILE,
28  /* other terminal symbols */
29  TK_CONCAT, TK_DOTS, TK_EQ, TK_GE, TK_LE, TK_NE, TK_DBCOLON, TK_EOS,
30  TK_NUMBER, TK_NAME, TK_STRING
23   /* terminal symbols denoted by reserved words */
24   TK_AND = FIRST_RESERVED, TK_BREAK,
25   TK_DO, TK_ELSE, TK_ELSEIF, TK_END, TK_FALSE, TK_FOR, TK_FUNCTION,
26   TK_GOTO, TK_IF, TK_IN, TK_LOCAL, TK_NIL, TK_NOT, TK_OR, TK_REPEAT,
27   TK_RETURN, TK_THEN, TK_TRUE, TK_UNTIL, TK_WHILE,
28   /* other terminal symbols */
29   TK_CONCAT, TK_DOTS, TK_EQ, TK_GE, TK_LE, TK_NE, TK_DBCOLON, TK_EOS,
30   TK_NUMBER, TK_NAME, TK_STRING
3131};
3232
3333/* number of reserved words */
34#define NUM_RESERVED   (cast(int, TK_WHILE-FIRST_RESERVED+1))
34#define NUM_RESERVED    (cast(int, TK_WHILE-FIRST_RESERVED+1))
3535
3636
3737typedef union {
38  lua_Number r;
39  TString *ts;
38   lua_Number r;
39   TString *ts;
4040} SemInfo;  /* semantics information */
4141
4242
4343typedef struct Token {
44  int token;
45  SemInfo seminfo;
44   int token;
45   SemInfo seminfo;
4646} Token;
4747
4848
4949/* state of the lexer plus state of the parser when shared by all
5050   functions */
5151typedef struct LexState {
52  int current;  /* current character (charint) */
53  int linenumber;  /* input line counter */
54  int lastline;  /* line of last token `consumed' */
55  Token t;  /* current token */
56  Token lookahead;  /* look ahead token */
57  struct FuncState *fs;  /* current function (parser) */
58  struct lua_State *L;
59  ZIO *z;  /* input stream */
60  Mbuffer *buff;  /* buffer for tokens */
61  struct Dyndata *dyd;  /* dynamic structures used by the parser */
62  TString *source;  /* current source name */
63  TString *envn;  /* environment variable name */
64  char decpoint;  /* locale decimal point */
52   int current;  /* current character (charint) */
53   int linenumber;  /* input line counter */
54   int lastline;  /* line of last token `consumed' */
55   Token t;  /* current token */
56   Token lookahead;  /* look ahead token */
57   struct FuncState *fs;  /* current function (parser) */
58   struct lua_State *L;
59   ZIO *z;  /* input stream */
60   Mbuffer *buff;  /* buffer for tokens */
61   struct Dyndata *dyd;  /* dynamic structures used by the parser */
62   TString *source;  /* current source name */
63   TString *envn;  /* environment variable name */
64   char decpoint;  /* locale decimal point */
6565} LexState;
6666
6767
6868LUAI_FUNC void luaX_init (lua_State *L);
6969LUAI_FUNC void luaX_setinput (lua_State *L, LexState *ls, ZIO *z,
70                              TString *source, int firstchar);
70                        TString *source, int firstchar);
7171LUAI_FUNC TString *luaX_newstring (LexState *ls, const char *str, size_t l);
7272LUAI_FUNC void luaX_next (LexState *ls);
7373LUAI_FUNC int luaX_lookahead (LexState *ls);
trunk/src/lib/lua/bridge/detail/LuaHelpers.h
r31374r31375
11//------------------------------------------------------------------------------
22/*
33  https://github.com/vinniefalco/LuaBridge
4 
4
55  Copyright 2012, Vinnie Falco <vinnie.falco@gmail.com>
66  Copyright 2007, Nathan Reed
77
r31374r31375
3232#if LUA_VERSION_NUM < 502
3333inline int lua_absindex (lua_State* L, int idx)
3434{
35  if (idx > LUA_REGISTRYINDEX && idx < 0)
36    return lua_gettop (L) + idx + 1;
37  else
38    return idx;
35   if (idx > LUA_REGISTRYINDEX && idx < 0)
36   return lua_gettop (L) + idx + 1;
37   else
38   return idx;
3939}
4040
4141inline void lua_rawgetp (lua_State* L, int idx, void const* p)
4242{
43  idx = lua_absindex (L, idx);
44  lua_pushlightuserdata (L, const_cast <void*> (p));
45  lua_rawget (L,idx);
43   idx = lua_absindex (L, idx);
44   lua_pushlightuserdata (L, const_cast <void*> (p));
45   lua_rawget (L,idx);
4646}
4747
4848inline void lua_rawsetp (lua_State* L, int idx, void const* p)
4949{
50  idx = lua_absindex (L, idx);
51  lua_pushlightuserdata (L, const_cast <void*> (p));
52  // put key behind value
53  lua_insert (L, -2);
54  lua_rawset (L, idx);
50   idx = lua_absindex (L, idx);
51   lua_pushlightuserdata (L, const_cast <void*> (p));
52   // put key behind value
53   lua_insert (L, -2);
54   lua_rawset (L, idx);
5555}
5656
5757#define LUA_OPEQ 1
r31374r31375
6060
6161inline int lua_compare (lua_State* L, int idx1, int idx2, int op)
6262{
63  switch (op)
64  {
65  case LUA_OPEQ:
66    return lua_equal (L, idx1, idx2);
67    break;
63   switch (op)
64   {
65   case LUA_OPEQ:
66   return lua_equal (L, idx1, idx2);
67   break;
6868
69  case LUA_OPLT:
70    return lua_lessthan (L, idx1, idx2);
71    break;
69   case LUA_OPLT:
70   return lua_lessthan (L, idx1, idx2);
71   break;
7272
73  case LUA_OPLE:
74    return lua_equal (L, idx1, idx2) || lua_lessthan (L, idx1, idx2);
75    break;
73   case LUA_OPLE:
74   return lua_equal (L, idx1, idx2) || lua_lessthan (L, idx1, idx2);
75   break;
7676
77  default:
78    return 0;
79  };
77   default:
78   return 0;
79   };
8080}
8181
8282inline int get_length (lua_State* L, int idx)
8383{
84  return int (lua_objlen (L, idx));
84   return int (lua_objlen (L, idx));
8585}
8686
8787#else
8888inline int get_length (lua_State* L, int idx)
8989{
90  lua_len (L, idx);
91  int len = int (luaL_checknumber (L, -1));
92  lua_pop (L, 1);
93  return len;
90   lua_len (L, idx);
91   int len = int (luaL_checknumber (L, -1));
92   lua_pop (L, 1);
93   return len;
9494}
9595
9696#endif
r31374r31375
102102#endif
103103
104104/** Get a table value, bypassing metamethods.
105*/ 
105*/
106106inline void rawgetfield (lua_State* L, int index, char const* key)
107107{
108  assert (lua_istable (L, index));
109  index = lua_absindex (L, index);
110  lua_pushstring (L, key);
111  lua_rawget (L, index);
108   assert (lua_istable (L, index));
109   index = lua_absindex (L, index);
110   lua_pushstring (L, key);
111   lua_rawget (L, index);
112112}
113113
114114/** Set a table value, bypassing metamethods.
115*/ 
115*/
116116inline void rawsetfield (lua_State* L, int index, char const* key)
117117{
118  assert (lua_istable (L, index));
119  index = lua_absindex (L, index);
120  lua_pushstring (L, key);
121  lua_insert (L, -2);
122  lua_rawset (L, index);
118   assert (lua_istable (L, index));
119   index = lua_absindex (L, index);
120   lua_pushstring (L, key);
121   lua_insert (L, -2);
122   lua_rawset (L, index);
123123}
124124
125125/** Returns true if the value is a full userdata (not light).
126126*/
127127inline bool isfulluserdata (lua_State* L, int index)
128128{
129  return lua_isuserdata (L, index) && !lua_islightuserdata (L, index);
129   return lua_isuserdata (L, index) && !lua_islightuserdata (L, index);
130130}
131131
132132/** Test lua_State objects for global equality.
r31374r31375
138138*/
139139inline bool equalstates (lua_State* L1, lua_State* L2)
140140{
141  return lua_topointer (L1, LUA_REGISTRYINDEX) ==
142         lua_topointer (L2, LUA_REGISTRYINDEX);
141   return lua_topointer (L1, LUA_REGISTRYINDEX) ==
142         lua_topointer (L2, LUA_REGISTRYINDEX);
143143}
trunk/src/lib/lua/bridge/detail/Constructor.h
r31374r31375
11//------------------------------------------------------------------------------
22/*
33  https://github.com/vinniefalco/LuaBridge
4 
4
55  Copyright 2012, Vinnie Falco <vinnie.falco@gmail.com>
66  Copyright 2007, Nathan Reed
77
r31374r31375
4949template <class T>
5050struct Constructor <T, None>
5151{
52  static T* call (TypeListValues <None> const&)
53  {
54    return new T;
55  }
56  static T* call (void* mem, TypeListValues <None> const&)
57  {
58    return new (mem) T;
59  }
52   static T* call (TypeListValues <None> const&)
53   {
54   return new T;
55   }
56   static T* call (void* mem, TypeListValues <None> const&)
57   {
58   return new (mem) T;
59   }
6060};
6161
6262template <class T, class P1>
6363struct Constructor <T, TypeList <P1> >
6464{
65  static T* call (const TypeListValues<TypeList <P1> > &tvl)
66  {
67    return new T(tvl.hd);
68  }
69  static T* call (void* mem, const TypeListValues<TypeList <P1> > &tvl)
70  {
71    return new (mem) T(tvl.hd);
72  }
65   static T* call (const TypeListValues<TypeList <P1> > &tvl)
66   {
67   return new T(tvl.hd);
68   }
69   static T* call (void* mem, const TypeListValues<TypeList <P1> > &tvl)
70   {
71   return new (mem) T(tvl.hd);
72   }
7373};
7474
7575template <class T, class P1, class P2>
7676struct Constructor <T, TypeList <P1, TypeList <P2> > >
7777{
78  static T* call (const TypeListValues<TypeList <P1, TypeList <P2> > > &tvl)
79  {
80    return new T(tvl.hd, tvl.tl.hd);
81  }
82  static T* call (void* mem, const TypeListValues<TypeList <P1, TypeList <P2> > > &tvl)
83  {
84    return new (mem) T(tvl.hd, tvl.tl.hd);
85  }
78   static T* call (const TypeListValues<TypeList <P1, TypeList <P2> > > &tvl)
79   {
80   return new T(tvl.hd, tvl.tl.hd);
81   }
82   static T* call (void* mem, const TypeListValues<TypeList <P1, TypeList <P2> > > &tvl)
83   {
84   return new (mem) T(tvl.hd, tvl.tl.hd);
85   }
8686};
8787
8888template <class T, class P1, class P2, class P3>
8989struct Constructor <T, TypeList <P1, TypeList <P2, TypeList <P3> > > >
9090{
91  static T* call (const TypeListValues<TypeList <P1, TypeList <P2,
92    TypeList <P3> > > > &tvl)
93  {
94    return new T(tvl.hd, tvl.tl.hd, tvl.tl.tl.hd);
95  }
96  static T* call (void* mem, const TypeListValues<TypeList <P1, TypeList <P2,
97    TypeList <P3> > > > &tvl)
98  {
99    return new (mem) T(tvl.hd, tvl.tl.hd, tvl.tl.tl.hd);
100  }
91   static T* call (const TypeListValues<TypeList <P1, TypeList <P2,
92   TypeList <P3> > > > &tvl)
93   {
94   return new T(tvl.hd, tvl.tl.hd, tvl.tl.tl.hd);
95   }
96   static T* call (void* mem, const TypeListValues<TypeList <P1, TypeList <P2,
97   TypeList <P3> > > > &tvl)
98   {
99   return new (mem) T(tvl.hd, tvl.tl.hd, tvl.tl.tl.hd);
100   }
101101};
102102
103103template <class T, class P1, class P2, class P3, class P4>
104104struct Constructor <T, TypeList <P1, TypeList <P2, TypeList <P3,
105  TypeList <P4> > > > >
105   TypeList <P4> > > > >
106106{
107  static T* call (const TypeListValues<TypeList <P1, TypeList <P2,
108    TypeList <P3, TypeList <P4> > > > > &tvl)
109  {
110    return new T(tvl.hd, tvl.tl.hd, tvl.tl.tl.hd, tvl.tl.tl.tl.hd);
111  }
112  static T* call (void* mem, const TypeListValues<TypeList <P1, TypeList <P2,
113    TypeList <P3, TypeList <P4> > > > > &tvl)
114  {
115    return new (mem) T(tvl.hd, tvl.tl.hd, tvl.tl.tl.hd, tvl.tl.tl.tl.hd);
116  }
107   static T* call (const TypeListValues<TypeList <P1, TypeList <P2,
108   TypeList <P3, TypeList <P4> > > > > &tvl)
109   {
110   return new T(tvl.hd, tvl.tl.hd, tvl.tl.tl.hd, tvl.tl.tl.tl.hd);
111   }
112   static T* call (void* mem, const TypeListValues<TypeList <P1, TypeList <P2,
113   TypeList <P3, TypeList <P4> > > > > &tvl)
114   {
115   return new (mem) T(tvl.hd, tvl.tl.hd, tvl.tl.tl.hd, tvl.tl.tl.tl.hd);
116   }
117117};
118118
119119template <class T, class P1, class P2, class P3, class P4,
120  class P5>
120   class P5>
121121struct Constructor <T, TypeList <P1, TypeList <P2, TypeList <P3,
122  TypeList <P4, TypeList <P5> > > > > >
122   TypeList <P4, TypeList <P5> > > > > >
123123{
124  static T* call (const TypeListValues<TypeList <P1, TypeList <P2,
125    TypeList <P3, TypeList <P4, TypeList <P5> > > > > > &tvl)
126  {
127    return new T(tvl.hd, tvl.tl.hd, tvl.tl.tl.hd, tvl.tl.tl.tl.hd,
128      tvl.tl.tl.tl.tl.hd);
129  }
130  static T* call (void* mem, const TypeListValues<TypeList <P1, TypeList <P2,
131    TypeList <P3, TypeList <P4, TypeList <P5> > > > > > &tvl)
132  {
133    return new (mem) T(tvl.hd, tvl.tl.hd, tvl.tl.tl.hd, tvl.tl.tl.tl.hd,
134      tvl.tl.tl.tl.tl.hd);
135  }
124   static T* call (const TypeListValues<TypeList <P1, TypeList <P2,
125   TypeList <P3, TypeList <P4, TypeList <P5> > > > > > &tvl)
126   {
127   return new T(tvl.hd, tvl.tl.hd, tvl.tl.tl.hd, tvl.tl.tl.tl.hd,
128      tvl.tl.tl.tl.tl.hd);
129   }
130   static T* call (void* mem, const TypeListValues<TypeList <P1, TypeList <P2,
131   TypeList <P3, TypeList <P4, TypeList <P5> > > > > > &tvl)
132   {
133   return new (mem) T(tvl.hd, tvl.tl.hd, tvl.tl.tl.hd, tvl.tl.tl.tl.hd,
134      tvl.tl.tl.tl.tl.hd);
135   }
136136};
137137
138138template <class T, class P1, class P2, class P3, class P4,
139  class P5, class P6>
139   class P5, class P6>
140140struct Constructor <T, TypeList <P1, TypeList <P2, TypeList <P3,
141  TypeList <P4, TypeList <P5, TypeList <P6> > > > > > >
141   TypeList <P4, TypeList <P5, TypeList <P6> > > > > > >
142142{
143  static T* call (const TypeListValues<TypeList <P1, TypeList <P2,
144    TypeList <P3, TypeList <P4, TypeList <P5, TypeList <P6> > > > > > > &tvl)
145  {
146    return new T(tvl.hd, tvl.tl.hd, tvl.tl.tl.hd, tvl.tl.tl.tl.hd,
147      tvl.tl.tl.tl.tl.hd, tvl.tl.tl.tl.tl.tl.hd);
148  }
149  static T* call (void* mem, const TypeListValues<TypeList <P1, TypeList <P2,
150    TypeList <P3, TypeList <P4, TypeList <P5, TypeList <P6> > > > > > > &tvl)
151  {
152    return new (mem) T(tvl.hd, tvl.tl.hd, tvl.tl.tl.hd, tvl.tl.tl.tl.hd,
153      tvl.tl.tl.tl.tl.hd, tvl.tl.tl.tl.tl.tl.hd);
154  }
143   static T* call (const TypeListValues<TypeList <P1, TypeList <P2,
144   TypeList <P3, TypeList <P4, TypeList <P5, TypeList <P6> > > > > > > &tvl)
145   {
146   return new T(tvl.hd, tvl.tl.hd, tvl.tl.tl.hd, tvl.tl.tl.tl.hd,
147      tvl.tl.tl.tl.tl.hd, tvl.tl.tl.tl.tl.tl.hd);
148   }
149   static T* call (void* mem, const TypeListValues<TypeList <P1, TypeList <P2,
150   TypeList <P3, TypeList <P4, TypeList <P5, TypeList <P6> > > > > > > &tvl)
151   {
152   return new (mem) T(tvl.hd, tvl.tl.hd, tvl.tl.tl.hd, tvl.tl.tl.tl.hd,
153      tvl.tl.tl.tl.tl.hd, tvl.tl.tl.tl.tl.tl.hd);
154   }
155155};
156156
157157template <class T, class P1, class P2, class P3, class P4,
158  class P5, class P6, class P7>
158   class P5, class P6, class P7>
159159struct Constructor <T, TypeList <P1, TypeList <P2, TypeList <P3,
160  TypeList <P4, TypeList <P5, TypeList <P6, TypeList <P7> > > > > > > >
160   TypeList <P4, TypeList <P5, TypeList <P6, TypeList <P7> > > > > > > >
161161{
162  static T* call (const TypeListValues<TypeList <P1, TypeList <P2,
163    TypeList <P3, TypeList <P4, TypeList <P5, TypeList <P6,
164    TypeList <P7> > > > > > > > &tvl)
165  {
166    return new T(tvl.hd, tvl.tl.hd, tvl.tl.tl.hd, tvl.tl.tl.tl.hd,
167      tvl.tl.tl.tl.tl.hd, tvl.tl.tl.tl.tl.tl.hd,
168      tvl.tl.tl.tl.tl.tl.tl.hd);
169  }
170  static T* call (void* mem, const TypeListValues<TypeList <P1, TypeList <P2,
171    TypeList <P3, TypeList <P4, TypeList <P5, TypeList <P6,
172    TypeList <P7> > > > > > > > &tvl)
173  {
174    return new (mem) T(tvl.hd, tvl.tl.hd, tvl.tl.tl.hd, tvl.tl.tl.tl.hd,
175      tvl.tl.tl.tl.tl.hd, tvl.tl.tl.tl.tl.tl.hd,
176      tvl.tl.tl.tl.tl.tl.tl.hd);
177  }
162   static T* call (const TypeListValues<TypeList <P1, TypeList <P2,
163   TypeList <P3, TypeList <P4, TypeList <P5, TypeList <P6,
164   TypeList <P7> > > > > > > > &tvl)
165   {
166   return new T(tvl.hd, tvl.tl.hd, tvl.tl.tl.hd, tvl.tl.tl.tl.hd,
167      tvl.tl.tl.tl.tl.hd, tvl.tl.tl.tl.tl.tl.hd,
168      tvl.tl.tl.tl.tl.tl.tl.hd);
169   }
170   static T* call (void* mem, const TypeListValues<TypeList <P1, TypeList <P2,
171   TypeList <P3, TypeList <P4, TypeList <P5, TypeList <P6,
172   TypeList <P7> > > > > > > > &tvl)
173   {
174   return new (mem) T(tvl.hd, tvl.tl.hd, tvl.tl.tl.hd, tvl.tl.tl.tl.hd,
175      tvl.tl.tl.tl.tl.hd, tvl.tl.tl.tl.tl.tl.hd,
176      tvl.tl.tl.tl.tl.tl.tl.hd);
177   }
178178};
179179
180180template <class T, class P1, class P2, class P3, class P4,
181  class P5, class P6, class P7, class P8>
181   class P5, class P6, class P7, class P8>
182182struct Constructor <T, TypeList <P1, TypeList <P2, TypeList <P3,
183  TypeList <P4, TypeList <P5, TypeList <P6, TypeList <P7,
184  TypeList <P8> > > > > > > > >
183   TypeList <P4, TypeList <P5, TypeList <P6, TypeList <P7,
184   TypeList <P8> > > > > > > > >
185185{
186  static T* call (const TypeListValues<TypeList <P1, TypeList <P2,
187    TypeList <P3, TypeList <P4, TypeList <P5, TypeList <P6,
188    TypeList <P7, TypeList <P8> > > > > > > > > &tvl)
189  {
190    return new T(tvl.hd, tvl.tl.hd, tvl.tl.tl.hd, tvl.tl.tl.tl.hd,
191      tvl.tl.tl.tl.tl.hd, tvl.tl.tl.tl.tl.tl.hd,
192      tvl.tl.tl.tl.tl.tl.tl.hd, tvl.tl.tl.tl.tl.tl.tl.tl.hd);
193  }
194  static T* call (void* mem, const TypeListValues<TypeList <P1, TypeList <P2,
195    TypeList <P3, TypeList <P4, TypeList <P5, TypeList <P6,
196    TypeList <P7, TypeList <P8> > > > > > > > > &tvl)
197  {
198    return new (mem) T(tvl.hd, tvl.tl.hd, tvl.tl.tl.hd, tvl.tl.tl.tl.hd,
199      tvl.tl.tl.tl.tl.hd, tvl.tl.tl.tl.tl.tl.hd,
200      tvl.tl.tl.tl.tl.tl.tl.hd, tvl.tl.tl.tl.tl.tl.tl.tl.hd);
201  }
186   static T* call (const TypeListValues<TypeList <P1, TypeList <P2,
187   TypeList <P3, TypeList <P4, TypeList <P5, TypeList <P6,
188   TypeList <P7, TypeList <P8> > > > > > > > > &tvl)
189   {
190   return new T(tvl.hd, tvl.tl.hd, tvl.tl.tl.hd, tvl.tl.tl.tl.hd,
191      tvl.tl.tl.tl.tl.hd, tvl.tl.tl.tl.tl.tl.hd,
192      tvl.tl.tl.tl.tl.tl.tl.hd, tvl.tl.tl.tl.tl.tl.tl.tl.hd);
193   }
194   static T* call (void* mem, const TypeListValues<TypeList <P1, TypeList <P2,
195   TypeList <P3, TypeList <P4, TypeList <P5, TypeList <P6,
196   TypeList <P7, TypeList <P8> > > > > > > > > &tvl)
197   {
198   return new (mem) T(tvl.hd, tvl.tl.hd, tvl.tl.tl.hd, tvl.tl.tl.tl.hd,
199      tvl.tl.tl.tl.tl.hd, tvl.tl.tl.tl.tl.tl.hd,
200      tvl.tl.tl.tl.tl.tl.tl.hd, tvl.tl.tl.tl.tl.tl.tl.tl.hd);
201   }
202202};
203203
204204#endif
trunk/src/lib/lua/bridge/detail/Stack.h
r31374r31375
3434template <>
3535struct Stack <lua_State*>
3636{
37  static lua_State* get (lua_State* L, int)
38  {
39    return L;
40  }
37   static lua_State* get (lua_State* L, int)
38   {
39   return L;
40   }
4141};
4242
4343//------------------------------------------------------------------------------
r31374r31375
4747template <>
4848struct Stack <lua_CFunction>
4949{
50  static void push (lua_State* L, lua_CFunction f)
51  {
52    lua_pushcfunction (L, f);
53  }
50   static void push (lua_State* L, lua_CFunction f)
51   {
52   lua_pushcfunction (L, f);
53   }
5454
55  static lua_CFunction get (lua_State* L, int index)
56  {
57    return lua_tocfunction (L, index);
58  }
55   static lua_CFunction get (lua_State* L, int index)
56   {
57   return lua_tocfunction (L, index);
58   }
5959};
6060
6161//------------------------------------------------------------------------------
r31374r31375
6565template <>
6666struct Stack <int>
6767{
68  static inline void push (lua_State* L, int value)
69  {
70    lua_pushinteger (L, static_cast <lua_Integer> (value));
71  }
72 
73  static inline int get (lua_State* L, int index)
74  {
75    return static_cast <int> (luaL_checkinteger (L, index));
76  }
68   static inline void push (lua_State* L, int value)
69   {
70   lua_pushinteger (L, static_cast <lua_Integer> (value));
71   }
72
73   static inline int get (lua_State* L, int index)
74   {
75   return static_cast <int> (luaL_checkinteger (L, index));
76   }
7777};
7878
7979template <>
8080struct Stack <int const&>
8181{
82  static inline void push (lua_State* L, int value)
83  {
84    lua_pushnumber (L, static_cast <lua_Number> (value));
85  }
86 
87  static inline int get (lua_State* L, int index)
88  {
89    return static_cast <int > (luaL_checknumber (L, index));
90  }
82   static inline void push (lua_State* L, int value)
83   {
84   lua_pushnumber (L, static_cast <lua_Number> (value));
85   }
86
87   static inline int get (lua_State* L, int index)
88   {
89   return static_cast <int > (luaL_checknumber (L, index));
90   }
9191};
9292//------------------------------------------------------------------------------
9393/**
r31374r31375
9696template <>
9797struct Stack <unsigned int>
9898{
99  static inline void push (lua_State* L, unsigned int value)
100  {
101    lua_pushinteger (L, static_cast <lua_Integer> (value));
102  }
103 
104  static inline unsigned int get (lua_State* L, int index)
105  {
106    return static_cast <unsigned int> (luaL_checkinteger (L, index));
107  }
99   static inline void push (lua_State* L, unsigned int value)
100   {
101   lua_pushinteger (L, static_cast <lua_Integer> (value));
102   }
103
104   static inline unsigned int get (lua_State* L, int index)
105   {
106   return static_cast <unsigned int> (luaL_checkinteger (L, index));
107   }
108108};
109109
110110template <>
111111struct Stack <unsigned int const&>
112112{
113  static inline void push (lua_State* L, unsigned int value)
114  {
115    lua_pushnumber (L, static_cast <lua_Number> (value));
116  }
117 
118  static inline unsigned int get (lua_State* L, int index)
119  {
120    return static_cast <unsigned int > (luaL_checknumber (L, index));
121  }
113   static inline void push (lua_State* L, unsigned int value)
114   {
115   lua_pushnumber (L, static_cast <lua_Number> (value));
116   }
117
118   static inline unsigned int get (lua_State* L, int index)
119   {
120   return static_cast <unsigned int > (luaL_checknumber (L, index));
121   }
122122};
123123
124124//------------------------------------------------------------------------------
r31374r31375
128128template <>
129129struct Stack <unsigned char>
130130{
131  static inline void push (lua_State* L, unsigned char value)
132  {
133    lua_pushinteger (L, static_cast <lua_Integer> (value));
134  }
135 
136  static inline unsigned char get (lua_State* L, int index)
137  {
138    return static_cast <unsigned char> (luaL_checkinteger (L, index));
139  }
131   static inline void push (lua_State* L, unsigned char value)
132   {
133   lua_pushinteger (L, static_cast <lua_Integer> (value));
134   }
135
136   static inline unsigned char get (lua_State* L, int index)
137   {
138   return static_cast <unsigned char> (luaL_checkinteger (L, index));
139   }
140140};
141141
142142template <>
143143struct Stack <unsigned char const&>
144144{
145  static inline void push (lua_State* L, unsigned char value)
146  {
147    lua_pushnumber (L, static_cast <lua_Number> (value));
148  }
149 
150  static inline unsigned char get (lua_State* L, int index)
151  {
152    return static_cast <unsigned char> (luaL_checknumber (L, index));
153  }
145   static inline void push (lua_State* L, unsigned char value)
146   {
147   lua_pushnumber (L, static_cast <lua_Number> (value));
148   }
149
150   static inline unsigned char get (lua_State* L, int index)
151   {
152   return static_cast <unsigned char> (luaL_checknumber (L, index));
153   }
154154};
155155
156156//------------------------------------------------------------------------------
r31374r31375
160160template <>
161161struct Stack <short>
162162{
163  static inline void push (lua_State* L, short value)
164  {
165    lua_pushinteger (L, static_cast <lua_Integer> (value));
166  }
167 
168  static inline short get (lua_State* L, int index)
169  {
170    return static_cast <short> (luaL_checkinteger (L, index));
171  }
163   static inline void push (lua_State* L, short value)
164   {
165   lua_pushinteger (L, static_cast <lua_Integer> (value));
166   }
167
168   static inline short get (lua_State* L, int index)
169   {
170   return static_cast <short> (luaL_checkinteger (L, index));
171   }
172172};
173173
174174template <>
175175struct Stack <short const&>
176176{
177  static inline void push (lua_State* L, short value)
178  {
179    lua_pushnumber (L, static_cast <lua_Number> (value));
180  }
181 
182  static inline short get (lua_State* L, int index)
183  {
184    return static_cast <short> (luaL_checknumber (L, index));
185  }
177   static inline void push (lua_State* L, short value)
178   {
179   lua_pushnumber (L, static_cast <lua_Number> (value));
180   }
181
182   static inline short get (lua_State* L, int index)
183   {
184   return static_cast <short> (luaL_checknumber (L, index));
185   }
186186};
187187
188188//------------------------------------------------------------------------------
r31374r31375
192192template <>
193193struct Stack <unsigned short>
194194{
195  static inline void push (lua_State* L, unsigned short value)
196  {
197    lua_pushinteger (L, static_cast <lua_Integer> (value));
198  }
199 
200  static inline unsigned short get (lua_State* L, int index)
201  {
202    return static_cast <unsigned short> (luaL_checkinteger (L, index));
203  }
195   static inline void push (lua_State* L, unsigned short value)
196   {
197   lua_pushinteger (L, static_cast <lua_Integer> (value));
198   }
199
200   static inline unsigned short get (lua_State* L, int index)
201   {
202   return static_cast <unsigned short> (luaL_checkinteger (L, index));
203   }
204204};
205205
206206template <>
207207struct Stack <unsigned short const&>
208208{
209  static inline void push (lua_State* L, unsigned short value)
210  {
211    lua_pushnumber (L, static_cast <lua_Number> (value));
212  }
213 
214  static inline unsigned short get (lua_State* L, int index)
215  {
216    return static_cast <unsigned short> (luaL_checknumber (L, index));
217  }
209   static inline void push (lua_State* L, unsigned short value)
210   {
211   lua_pushnumber (L, static_cast <lua_Number> (value));
212   }
213
214   static inline unsigned short get (lua_State* L, int index)
215   {
216   return static_cast <unsigned short> (luaL_checknumber (L, index));
217   }
218218};
219219
220220//------------------------------------------------------------------------------
r31374r31375
224224template <>
225225struct Stack <long>
226226{
227  static inline void push (lua_State* L, long value)
228  {
229    lua_pushinteger (L, static_cast <lua_Integer> (value));
230  }
231 
232  static inline long get (lua_State* L, int index)
233  {
234    return static_cast <long> (luaL_checkinteger (L, index));
235  }
227   static inline void push (lua_State* L, long value)
228   {
229   lua_pushinteger (L, static_cast <lua_Integer> (value));
230   }
231
232   static inline long get (lua_State* L, int index)
233   {
234   return static_cast <long> (luaL_checkinteger (L, index));
235   }
236236};
237237
238238template <>
239239struct Stack <long const&>
240240{
241  static inline void push (lua_State* L, long value)
242  {
243    lua_pushnumber (L, static_cast <lua_Number> (value));
244  }
245 
246  static inline long get (lua_State* L, int index)
247  {
248    return static_cast <long> (luaL_checknumber (L, index));
249  }
241   static inline void push (lua_State* L, long value)
242   {
243   lua_pushnumber (L, static_cast <lua_Number> (value));
244   }
245
246   static inline long get (lua_State* L, int index)
247   {
248   return static_cast <long> (luaL_checknumber (L, index));
249   }
250250};
251251
252252//------------------------------------------------------------------------------
r31374r31375
256256template <>
257257struct Stack <unsigned long>
258258{
259  static inline void push (lua_State* L, unsigned long value)
260  {
261    lua_pushinteger (L, static_cast <lua_Integer> (value));
262  }
263 
264  static inline unsigned long get (lua_State* L, int index)
265  {
266    return static_cast <unsigned long> (luaL_checkinteger (L, index));
267  }
259   static inline void push (lua_State* L, unsigned long value)
260   {
261   lua_pushinteger (L, static_cast <lua_Integer> (value));
262   }
263
264   static inline unsigned long get (lua_State* L, int index)
265   {
266   return static_cast <unsigned long> (luaL_checkinteger (L, index));
267   }
268268};
269269
270270template <>
271271struct Stack <unsigned long const&>
272272{
273  static inline void push (lua_State* L, unsigned long value)
274  {
275    lua_pushnumber (L, static_cast <lua_Number> (value));
276  }
277 
278  static inline unsigned long get (lua_State* L, int index)
279  {
280    return static_cast <unsigned long> (luaL_checknumber (L, index));
281  }
273   static inline void push (lua_State* L, unsigned long value)
274   {
275   lua_pushnumber (L, static_cast <lua_Number> (value));
276   }
277
278   static inline unsigned long get (lua_State* L, int index)
279   {
280   return static_cast <unsigned long> (luaL_checknumber (L, index));
281   }
282282};
283283
284284//------------------------------------------------------------------------------
r31374r31375
288288template <>
289289struct Stack <float>
290290{
291  static inline void push (lua_State* L, float value)
292  {
293    lua_pushnumber (L, static_cast <lua_Number> (value));
294  }
295 
296  static inline float get (lua_State* L, int index)
297  {
298    return static_cast <float> (luaL_checknumber (L, index));
299  }
291   static inline void push (lua_State* L, float value)
292   {
293   lua_pushnumber (L, static_cast <lua_Number> (value));
294   }
295
296   static inline float get (lua_State* L, int index)
297   {
298   return static_cast <float> (luaL_checknumber (L, index));
299   }
300300};
301301
302302template <>
303303struct Stack <float const&>
304304{
305  static inline void push (lua_State* L, float value)
306  {
307    lua_pushnumber (L, static_cast <lua_Number> (value));
308  }
309 
310  static inline float get (lua_State* L, int index)
311  {
312    return static_cast <float> (luaL_checknumber (L, index));
313  }
305   static inline void push (lua_State* L, float value)
306   {
307   lua_pushnumber (L, static_cast <lua_Number> (value));
308   }
309
310   static inline float get (lua_State* L, int index)
311   {
312   return static_cast <float> (luaL_checknumber (L, index));
313   }
314314};
315315
316316//------------------------------------------------------------------------------
r31374r31375
319319*/
320320template <> struct Stack <double>
321321{
322  static inline void push (lua_State* L, double value)
323  {
324    lua_pushnumber (L, static_cast <lua_Number> (value));
325  }
326 
327  static inline double get (lua_State* L, int index)
328  {
329    return static_cast <double> (luaL_checknumber (L, index));
330  }
322   static inline void push (lua_State* L, double value)
323   {
324   lua_pushnumber (L, static_cast <lua_Number> (value));
325   }
326
327   static inline double get (lua_State* L, int index)
328   {
329   return static_cast <double> (luaL_checknumber (L, index));
330   }
331331};
332332
333333template <> struct Stack <double const&>
334334{
335  static inline void push (lua_State* L, double value)
336  {
337    lua_pushnumber (L, static_cast <lua_Number> (value));
338  }
339 
340  static inline double get (lua_State* L, int index)
341  {
342    return static_cast <double> (luaL_checknumber (L, index));
343  }
335   static inline void push (lua_State* L, double value)
336   {
337   lua_pushnumber (L, static_cast <lua_Number> (value));
338   }
339
340   static inline double get (lua_State* L, int index)
341   {
342   return static_cast <double> (luaL_checknumber (L, index));
343   }
344344};
345345
346346//------------------------------------------------------------------------------
r31374r31375
349349*/
350350template <>
351351struct Stack <bool> {
352  static inline void push (lua_State* L, bool value)
353  {
354    lua_pushboolean (L, value ? 1 : 0);
355  }
356 
357  static inline bool get (lua_State* L, int index)
358  {
359    return lua_toboolean (L, index) ? true : false;
360  }
352   static inline void push (lua_State* L, bool value)
353   {
354   lua_pushboolean (L, value ? 1 : 0);
355   }
356
357   static inline bool get (lua_State* L, int index)
358   {
359   return lua_toboolean (L, index) ? true : false;
360   }
361361};
362362
363363template <>
364364struct Stack <bool const&> {
365  static inline void push (lua_State* L, bool value)
366  {
367    lua_pushboolean (L, value ? 1 : 0);
368  }
369 
370  static inline bool get (lua_State* L, int index)
371  {
372    return lua_toboolean (L, index) ? true : false;
373  }
365   static inline void push (lua_State* L, bool value)
366   {
367   lua_pushboolean (L, value ? 1 : 0);
368   }
369
370   static inline bool get (lua_State* L, int index)
371   {
372   return lua_toboolean (L, index) ? true : false;
373   }
374374};
375375
376376//------------------------------------------------------------------------------
r31374r31375
380380template <>
381381struct Stack <char>
382382{
383  static inline void push (lua_State* L, char value)
384  {
385    char str [2] = { value, 0 };
386    lua_pushstring (L, str);
387  }
388 
389  static inline char get (lua_State* L, int index)
390  {
391    return luaL_checkstring (L, index) [0];
392  }
383   static inline void push (lua_State* L, char value)
384   {
385   char str [2] = { value, 0 };
386   lua_pushstring (L, str);
387   }
388
389   static inline char get (lua_State* L, int index)
390   {
391   return luaL_checkstring (L, index) [0];
392   }
393393};
394394
395395template <>
396396struct Stack <char const&>
397397{
398  static inline void push (lua_State* L, char value)
399  {
400    char str [2] = { value, 0 };
401    lua_pushstring (L, str);
402  }
403 
404  static inline char get (lua_State* L, int index)
405  {
406    return luaL_checkstring (L, index) [0];
407  }
398   static inline void push (lua_State* L, char value)
399   {
400   char str [2] = { value, 0 };
401   lua_pushstring (L, str);
402   }
403
404   static inline char get (lua_State* L, int index)
405   {
406   return luaL_checkstring (L, index) [0];
407   }
408408};
409409
410410//------------------------------------------------------------------------------
r31374r31375
414414template <>
415415struct Stack <char const*>
416416{
417  static inline void push (lua_State* L, char const* str)
418  {
419    if (str != 0)
420      lua_pushstring (L, str);
421    else
422      lua_pushnil (L);
423  }
417   static inline void push (lua_State* L, char const* str)
418   {
419   if (str != 0)
420      lua_pushstring (L, str);
421   else
422      lua_pushnil (L);
423   }
424424
425  static inline char const* get (lua_State* L, int index)
426  {
427    return lua_isnil (L, index) ? 0 : luaL_checkstring (L, index);
428  }
425   static inline char const* get (lua_State* L, int index)
426   {
427   return lua_isnil (L, index) ? 0 : luaL_checkstring (L, index);
428   }
429429};
430430
431431//------------------------------------------------------------------------------
r31374r31375
435435template <>
436436struct Stack <std::string>
437437{
438  static inline void push (lua_State* L, std::string const& str)
439  {
440    lua_pushlstring (L, str.c_str (), str.size());
441  }
438   static inline void push (lua_State* L, std::string const& str)
439   {
440   lua_pushlstring (L, str.c_str (), str.size());
441   }
442442
443  static inline std::string get (lua_State* L, int index)
444  {
445    size_t len;
446    const char *str = luaL_checklstring(L, index, &len);
447    return std::string (str, len);
448  }
443   static inline std::string get (lua_State* L, int index)
444   {
445   size_t len;
446   const char *str = luaL_checklstring(L, index, &len);
447   return std::string (str, len);
448   }
449449};
450450
451451//------------------------------------------------------------------------------
r31374r31375
455455template <>
456456struct Stack <std::string const&>
457457{
458  static inline void push (lua_State* L, std::string const& str)
459  {
460    lua_pushstring (L, str.c_str());
461  }
458   static inline void push (lua_State* L, std::string const& str)
459   {
460   lua_pushstring (L, str.c_str());
461   }
462462
463  static inline std::string get (lua_State* L, int index)
464  {
465    size_t len;
466    const char *str = luaL_checklstring(L, index, &len);
467    return std::string (str, len);
468  }
463   static inline std::string get (lua_State* L, int index)
464   {
465   size_t len;
466   const char *str = luaL_checklstring(L, index, &len);
467   return std::string (str, len);
468   }
469469};
trunk/src/lib/lua/bridge/detail/dump.h
r31374r31375
1313         ostr << "  " << i << ": '" << lua_tostring(L, i) << "'\n";
1414         break;
1515      case LUA_TBOOLEAN:
16         ostr << "  " << i << ": " <<
16         ostr << "  " << i << ": " <<
1717               (lua_toboolean(L, i) ? "true" : "false") << "\n";
1818         break;
1919      case LUA_TNUMBER:
trunk/src/lib/lua/bridge/detail/TypeTraits.h
r31374r31375
11//------------------------------------------------------------------------------
22/*
33  https://github.com/vinniefalco/LuaBridge
4 
4
55  Copyright 2012, Vinnie Falco <vinnie.falco@gmail.com>
66
77  License: The MIT License (http://www.opensource.org/licenses/mit-license.php)
r31374r31375
5656template <class T>
5757struct ContainerTraits
5858{
59  typedef bool isNotContainer;
59   typedef bool isNotContainer;
6060};
6161
6262//------------------------------------------------------------------------------
r31374r31375
6767*/
6868struct TypeTraits
6969{
70  /** Determine if type T is a container.
70   /** Determine if type T is a container.
7171
72      To be considered a container, there must be a specialization of
73      ContainerTraits with the required fields.
74  */
75  template <typename T>
76  class isContainer
77  {
78  private:
79    typedef char yes[1]; // sizeof (yes) == 1
80    typedef char no [2]; // sizeof (no)  == 2
72     To be considered a container, there must be a specialization of
73     ContainerTraits with the required fields.
74   */
75   template <typename T>
76   class isContainer
77   {
78   private:
79   typedef char yes[1]; // sizeof (yes) == 1
80   typedef char no [2]; // sizeof (no)  == 2
8181
82    template <typename C>
83    static no& test (typename C::isNotContainer*);
84 
85    template <typename>
86    static yes& test (...);
87 
88  public:
89    static const bool value = sizeof (test <ContainerTraits <T> >(0)) == sizeof (yes);
90  };
82   template <typename C>
83   static no& test (typename C::isNotContainer*);
9184
92  /** Determine if T is const qualified.
93  */
94  /** @{ */
95  template <class T>
96  struct isConst
97  {
98    static bool const value = false;
99  };
85   template <typename>
86   static yes& test (...);
10087
101  template <class T>
102  struct isConst <T const>
103  {
104    static bool const value = true;
105  };
106  /** @} */
88   public:
89   static const bool value = sizeof (test <ContainerTraits <T> >(0)) == sizeof (yes);
90   };
10791
108  /** Remove the const qualifier from T.
109  */
110  /** @{ */
111  template <class T>
112  struct removeConst
113  {
114    typedef T Type;
115  };
92   /** Determine if T is const qualified.
93   */
94   /** @{ */
95   template <class T>
96   struct isConst
97   {
98   static bool const value = false;
99   };
116100
117  template <class T>
118  struct removeConst <T const>
119  {
120    typedef T Type;
121  };
122  /**@}*/
101   template <class T>
102   struct isConst <T const>
103   {
104   static bool const value = true;
105   };
106   /** @} */
107
108   /** Remove the const qualifier from T.
109   */
110   /** @{ */
111   template <class T>
112   struct removeConst
113   {
114   typedef T Type;
115   };
116
117   template <class T>
118   struct removeConst <T const>
119   {
120   typedef T Type;
121   };
122   /**@}*/
123123};
124124
125125#endif
trunk/src/lib/lua/bridge/detail/Userdata.h
r31374r31375
11//------------------------------------------------------------------------------
22/*
33  https://github.com/vinniefalco/LuaBridge
4 
4
55  Copyright 2012, Vinnie Falco <vinnie.falco@gmail.com>
66
77  License: The MIT License (http://www.opensource.org/licenses/mit-license.php)
r31374r31375
5252*/
5353inline void* getIdentityKey ()
5454{
55  static char value;
56  return &value;
55   static char value;
56   return &value;
5757}
5858
5959/**
r31374r31375
6262class Userdata
6363{
6464protected:
65  void* m_p; // subclasses must set this
65   void* m_p; // subclasses must set this
6666
67  //--------------------------------------------------------------------------
68  /**
69    Get an untyped pointer to the contained class.
70  */
71  inline void* const getPointer ()
72  {
73    return m_p;
74  }
67   //--------------------------------------------------------------------------
68   /**
69   Get an untyped pointer to the contained class.
70   */
71   inline void* const getPointer ()
72   {
73   return m_p;
74   }
7575
7676private:
77  //--------------------------------------------------------------------------
78  /**
79    Validate and retrieve a Userdata on the stack.
77   //--------------------------------------------------------------------------
78   /**
79   Validate and retrieve a Userdata on the stack.
8080
81    The Userdata must exactly match the corresponding class table or
82    const table, or else a Lua error is raised. This is used for the
83    __gc metamethod.
84  */
85  static Userdata* getExactClass (lua_State* L,
86                                  int narg,
87                                  void const* classKey)
88  {
89    Userdata* ud = 0;
90    int const index = lua_absindex (L, narg);
81   The Userdata must exactly match the corresponding class table or
82   const table, or else a Lua error is raised. This is used for the
83   __gc metamethod.
84   */
85   static Userdata* getExactClass (lua_State* L,
86                           int narg,
87                           void const* classKey)
88   {
89   Userdata* ud = 0;
90   int const index = lua_absindex (L, narg);
9191
92    bool mismatch = false;
93    char const* got = 0;
92   bool mismatch = false;
93   char const* got = 0;
9494
95    lua_rawgetp (L, LUA_REGISTRYINDEX, classKey);
96    assert (lua_istable (L, -1));
95   lua_rawgetp (L, LUA_REGISTRYINDEX, classKey);
96   assert (lua_istable (L, -1));
9797
98    // Make sure we have a userdata.
99    if (!lua_isuserdata (L, index))
100      mismatch = true;
98   // Make sure we have a userdata.
99   if (!lua_isuserdata (L, index))
100      mismatch = true;
101101
102    // Make sure it's metatable is ours.
103    if (!mismatch)
104    {
105      lua_getmetatable (L, index);
106      lua_rawgetp (L, -1, getIdentityKey ());
107      if (lua_isboolean (L, -1))
108      {
109        lua_pop (L, 1);
110      }
111      else
112      {
113        lua_pop (L, 2);
114        mismatch = true;
115      }     
116    }
102   // Make sure it's metatable is ours.
103   if (!mismatch)
104   {
105      lua_getmetatable (L, index);
106      lua_rawgetp (L, -1, getIdentityKey ());
107      if (lua_isboolean (L, -1))
108      {
109      lua_pop (L, 1);
110      }
111      else
112      {
113      lua_pop (L, 2);
114      mismatch = true;
115      }
116   }
117117
118    if (!mismatch)
119    {
120      if (lua_rawequal (L, -1, -2))
121      {
122        // Matches class table.
123        lua_pop (L, 2);
124        ud = static_cast <Userdata*> (lua_touserdata (L, index));
125      }
126      else
127      {
128        rawgetfield (L, -2, "__const");
129        if (lua_rawequal (L, -1, -2))
130        {
131          // Matches const table
132          lua_pop (L, 3);
133          ud = static_cast <Userdata*> (lua_touserdata (L, index));
134        }
135        else
136        {
137          // Mismatch, but its one of ours so get a type name.
138          rawgetfield (L, -2, "__type");
139          lua_insert (L, -4);
140          lua_pop (L, 2);
141          got = lua_tostring (L, -2);
142          mismatch = true;
143        }
144      }
145    }
118   if (!mismatch)
119   {
120      if (lua_rawequal (L, -1, -2))
121      {
122      // Matches class table.
123      lua_pop (L, 2);
124      ud = static_cast <Userdata*> (lua_touserdata (L, index));
125      }
126      else
127      {
128      rawgetfield (L, -2, "__const");
129      if (lua_rawequal (L, -1, -2))
130      {
131         // Matches const table
132         lua_pop (L, 3);
133         ud = static_cast <Userdata*> (lua_touserdata (L, index));
134      }
135      else
136      {
137         // Mismatch, but its one of ours so get a type name.
138         rawgetfield (L, -2, "__type");
139         lua_insert (L, -4);
140         lua_pop (L, 2);
141         got = lua_tostring (L, -2);
142         mismatch = true;
143      }
144      }
145   }
146146
147    if (mismatch)
148    {
149      rawgetfield (L, -1, "__type");
150      assert (lua_type (L, -1) == LUA_TSTRING);
151      char const* const expected = lua_tostring (L, -1);
147   if (mismatch)
148   {
149      rawgetfield (L, -1, "__type");
150      assert (lua_type (L, -1) == LUA_TSTRING);
151      char const* const expected = lua_tostring (L, -1);
152152
153      if (got == 0)
154        got = lua_typename (L, lua_type (L, index));
153      if (got == 0)
154      got = lua_typename (L, lua_type (L, index));
155155
156      char const* const msg = lua_pushfstring (
157        L, "%s expected, got %s", expected, got);
156      char const* const msg = lua_pushfstring (
157      L, "%s expected, got %s", expected, got);
158158
159      if (narg > 0)
160        luaL_argerror (L, narg, msg);
161      else
162        lua_error (L);
163    }
159      if (narg > 0)
160      luaL_argerror (L, narg, msg);
161      else
162      lua_error (L);
163   }
164164
165    return ud;
166  }
165   return ud;
166   }
167167
168  //--------------------------------------------------------------------------
169  /**
170    Validate and retrieve a Userdata on the stack.
168   //--------------------------------------------------------------------------
169   /**
170   Validate and retrieve a Userdata on the stack.
171171
172    The Userdata must be derived from or the same as the given base class,
173    identified by the key. If canBeConst is false, generates an error if
174    the resulting Userdata represents to a const object. We do the type check
175    first so that the error message is informative.
176  */
177  static Userdata* getClass (lua_State* L,
178                             int index,
179                             void const* baseClassKey,
180                             bool canBeConst)
181  {
182    assert (index > 0);
183    Userdata* ud = 0;
172   The Userdata must be derived from or the same as the given base class,
173   identified by the key. If canBeConst is false, generates an error if
174   the resulting Userdata represents to a const object. We do the type check
175   first so that the error message is informative.
176   */
177   static Userdata* getClass (lua_State* L,
178                        int index,
179                        void const* baseClassKey,
180                        bool canBeConst)
181   {
182   assert (index > 0);
183   Userdata* ud = 0;
184184
185    bool mismatch = false;
186    char const* got = 0;
185   bool mismatch = false;
186   char const* got = 0;
187187
188    lua_rawgetp (L, LUA_REGISTRYINDEX, baseClassKey);
189    assert (lua_istable (L, -1));
188   lua_rawgetp (L, LUA_REGISTRYINDEX, baseClassKey);
189   assert (lua_istable (L, -1));
190190
191    // Make sure we have a userdata.
192    if (lua_isuserdata (L, index))
193    {
194      // Make sure it's metatable is ours.
195      lua_getmetatable (L, index);
196      lua_rawgetp (L, -1, getIdentityKey ());
197      if (lua_isboolean (L, -1))
198      {
199        lua_pop (L, 1);
191   // Make sure we have a userdata.
192   if (lua_isuserdata (L, index))
193   {
194      // Make sure it's metatable is ours.
195      lua_getmetatable (L, index);
196      lua_rawgetp (L, -1, getIdentityKey ());
197      if (lua_isboolean (L, -1))
198      {
199      lua_pop (L, 1);
200200
201        // If __const is present, object is NOT const.
202        rawgetfield (L, -1, "__const");
203        assert (lua_istable (L, -1) || lua_isnil (L, -1));
204        bool const isConst = lua_isnil (L, -1);
205        lua_pop (L, 1);
201      // If __const is present, object is NOT const.
202      rawgetfield (L, -1, "__const");
203      assert (lua_istable (L, -1) || lua_isnil (L, -1));
204      bool const isConst = lua_isnil (L, -1);
205      lua_pop (L, 1);
206206
207        // Replace the class table with the const table if needed.
208        if (isConst)
209        {
210          rawgetfield (L, -2, "__const");
211          assert (lua_istable (L, -1));
212          lua_replace (L, -3);
213        }
207      // Replace the class table with the const table if needed.
208      if (isConst)
209      {
210         rawgetfield (L, -2, "__const");
211         assert (lua_istable (L, -1));
212         lua_replace (L, -3);
213      }
214214
215        for (;;)
216        {
217          if (lua_rawequal (L, -1, -2))
218          {
219            lua_pop (L, 2);
215      for (;;)
216      {
217         if (lua_rawequal (L, -1, -2))
218         {
219         lua_pop (L, 2);
220220
221            // Match, now check const-ness.
222            if (isConst && !canBeConst)
223            {
224              luaL_argerror (L, index, "cannot be const");
225            }
226            else
227            {
228              ud = static_cast <Userdata*> (lua_touserdata (L, index));
229              break;
230            }
231          }
232          else
233          {
234            // Replace current metatable with it's base class.
235            rawgetfield (L, -1, "__parent");
221         // Match, now check const-ness.
222         if (isConst && !canBeConst)
223         {
224            luaL_argerror (L, index, "cannot be const");
225         }
226         else
227         {
228            ud = static_cast <Userdata*> (lua_touserdata (L, index));
229            break;
230         }
231         }
232         else
233         {
234         // Replace current metatable with it's base class.
235         rawgetfield (L, -1, "__parent");
236236/*
237237ud
238238class metatable
r31374r31375
240240ud __parent (nil)
241241*/
242242
243            if (lua_isnil (L, -1))
244            {
245              lua_remove (L, -1);
246              // Mismatch, but its one of ours so get a type name.
247              rawgetfield (L, -1, "__type");
248              lua_insert (L, -3);
249              lua_pop (L, 1);
250              got = lua_tostring (L, -2);
251              mismatch = true;
252              break;
253            }
254            else
255            {
256              lua_remove (L, -2);
257            }
258          }
259        }
260      }
261      else
262      {
263        lua_pop (L, 2);
264        mismatch = true;
265      }     
266    }
267    else
268    {
269      mismatch = true;
270    }
243         if (lua_isnil (L, -1))
244         {
245            lua_remove (L, -1);
246            // Mismatch, but its one of ours so get a type name.
247            rawgetfield (L, -1, "__type");
248            lua_insert (L, -3);
249            lua_pop (L, 1);
250            got = lua_tostring (L, -2);
251            mismatch = true;
252            break;
253         }
254         else
255         {
256            lua_remove (L, -2);
257         }
258         }
259      }
260      }
261      else
262      {
263      lua_pop (L, 2);
264      mismatch = true;
265      }
266   }
267   else
268   {
269      mismatch = true;
270   }
271271
272    if (mismatch)
273    {
274      assert (lua_type (L, -1) == LUA_TTABLE);
275      rawgetfield (L, -1, "__type");
276      assert (lua_type (L, -1) == LUA_TSTRING);
277      char const* const expected = lua_tostring (L, -1);
272   if (mismatch)
273   {
274      assert (lua_type (L, -1) == LUA_TTABLE);
275      rawgetfield (L, -1, "__type");
276      assert (lua_type (L, -1) == LUA_TSTRING);
277      char const* const expected = lua_tostring (L, -1);
278278
279      if (got == 0)
280        got = lua_typename (L, lua_type (L, index));
279      if (got == 0)
280      got = lua_typename (L, lua_type (L, index));
281281
282      char const* const msg = lua_pushfstring (
283        L, "%s expected, got %s", expected, got);
282      char const* const msg = lua_pushfstring (
283      L, "%s expected, got %s", expected, got);
284284
285      luaL_argerror (L, index, msg);
286    }
285      luaL_argerror (L, index, msg);
286   }
287287
288    return ud;
289  }
288   return ud;
289   }
290290
291291public:
292  virtual ~Userdata () { }
292   virtual ~Userdata () { }
293293
294  //--------------------------------------------------------------------------
295  /**
296    Returns the Userdata* if the class on the Lua stack matches.
294   //--------------------------------------------------------------------------
295   /**
296   Returns the Userdata* if the class on the Lua stack matches.
297297
298    If the class does not match, a Lua error is raised.
299  */
300  template <class T>
301  static inline Userdata* getExact (lua_State* L, int index)
302  {
303    return getExactClass (L, index, ClassInfo <T>::getClassKey ());
304  }
298   If the class does not match, a Lua error is raised.
299   */
300   template <class T>
301   static inline Userdata* getExact (lua_State* L, int index)
302   {
303   return getExactClass (L, index, ClassInfo <T>::getClassKey ());
304   }
305305
306  //--------------------------------------------------------------------------
307  /**
308    Get a pointer to the class from the Lua stack.
306   //--------------------------------------------------------------------------
307   /**
308   Get a pointer to the class from the Lua stack.
309309
310    If the object is not the class or a subclass, or it violates the
311    const-ness, a Lua error is raised.
312  */
313  template <class T>
314  static inline T* get (lua_State* L, int index, bool canBeConst)
315  {
316    if (lua_isnil (L, index))
317      return 0;
318    else
319      return static_cast <T*> (getClass (L, index,
320        ClassInfo <T>::getClassKey (), canBeConst)->getPointer ());
321  }
310   If the object is not the class or a subclass, or it violates the
311   const-ness, a Lua error is raised.
312   */
313   template <class T>
314   static inline T* get (lua_State* L, int index, bool canBeConst)
315   {
316   if (lua_isnil (L, index))
317      return 0;
318   else
319      return static_cast <T*> (getClass (L, index,
320      ClassInfo <T>::getClassKey (), canBeConst)->getPointer ());
321   }
322322};
323323
324324//----------------------------------------------------------------------------
r31374r31375
332332class UserdataValue : public Userdata
333333{
334334private:
335  UserdataValue <T> (UserdataValue <T> const&);
336  UserdataValue <T> operator= (UserdataValue <T> const&);
335   UserdataValue <T> (UserdataValue <T> const&);
336   UserdataValue <T> operator= (UserdataValue <T> const&);
337337
338  char m_storage [sizeof (T)];
338   char m_storage [sizeof (T)];
339339
340  inline T* getObject ()
341  {
342    // If this fails to compile it means you forgot to provide
343    // a Container specialization for your container!
344    //
345    return reinterpret_cast <T*> (&m_storage [0]);
346  }
340   inline T* getObject ()
341   {
342   // If this fails to compile it means you forgot to provide
343   // a Container specialization for your container!
344   //
345   return reinterpret_cast <T*> (&m_storage [0]);
346   }
347347
348348private:
349  /**
350    Used for placement construction.
351  */
352  UserdataValue ()
353  {
354    m_p = getObject ();
355  }
349   /**
350   Used for placement construction.
351   */
352   UserdataValue ()
353   {
354   m_p = getObject ();
355   }
356356
357  ~UserdataValue ()
358  {
359    getObject ()->~T ();
360  }
357   ~UserdataValue ()
358   {
359   getObject ()->~T ();
360   }
361361
362362public:
363  /**
364    Push a T via placement new.
363   /**
364   Push a T via placement new.
365365
366    The caller is responsible for calling placement new using the
367    returned uninitialized storage.
368  */
369  static void* place (lua_State* const L)
370  {
371    UserdataValue <T>* const ud = new (
372      lua_newuserdata (L, sizeof (UserdataValue <T>))) UserdataValue <T> ();
373    lua_rawgetp (L, LUA_REGISTRYINDEX, ClassInfo <T>::getClassKey ());
374    // If this goes off it means you forgot to register the class!
375    assert (lua_istable (L, -1));
376    lua_setmetatable (L, -2);
377    return ud->getPointer ();
378  }
366   The caller is responsible for calling placement new using the
367   returned uninitialized storage.
368   */
369   static void* place (lua_State* const L)
370   {
371   UserdataValue <T>* const ud = new (
372      lua_newuserdata (L, sizeof (UserdataValue <T>))) UserdataValue <T> ();
373   lua_rawgetp (L, LUA_REGISTRYINDEX, ClassInfo <T>::getClassKey ());
374   // If this goes off it means you forgot to register the class!
375   assert (lua_istable (L, -1));
376   lua_setmetatable (L, -2);
377   return ud->getPointer ();
378   }
379379
380  /**
381    Push T via copy construction from U.
382  */
383  template <class U>
384  static inline void push (lua_State* const L, U const& u)
385  {
386    new (place (L)) U (u);
387  }
380   /**
381   Push T via copy construction from U.
382   */
383   template <class U>
384   static inline void push (lua_State* const L, U const& u)
385   {
386   new (place (L)) U (u);
387   }
388388};
389389
390390//----------------------------------------------------------------------------
r31374r31375
396396class UserdataPtr : public Userdata
397397{
398398private:
399  UserdataPtr (UserdataPtr const&);
400  UserdataPtr operator= (UserdataPtr const&);
399   UserdataPtr (UserdataPtr const&);
400   UserdataPtr operator= (UserdataPtr const&);
401401
402402private:
403  /** Push non-const pointer to object using metatable key.
404  */
405  static void push (lua_State* L, void* const p, void const* const key)
406  {
407    if (p)
408    {
409      new (lua_newuserdata (L, sizeof (UserdataPtr))) UserdataPtr (p);
410      lua_rawgetp (L, LUA_REGISTRYINDEX, key);
411      // If this goes off it means you forgot to register the class!
412      assert (lua_istable (L, -1));
413      lua_setmetatable (L, -2);
414    }
415    else
416    {
417      lua_pushnil (L);
418    }
419  }
403   /** Push non-const pointer to object using metatable key.
404   */
405   static void push (lua_State* L, void* const p, void const* const key)
406   {
407   if (p)
408   {
409      new (lua_newuserdata (L, sizeof (UserdataPtr))) UserdataPtr (p);
410      lua_rawgetp (L, LUA_REGISTRYINDEX, key);
411      // If this goes off it means you forgot to register the class!
412      assert (lua_istable (L, -1));
413      lua_setmetatable (L, -2);
414   }
415   else
416   {
417      lua_pushnil (L);
418   }
419   }
420420
421  /** Push const pointer to object using metatable key.
422  */
423  static void push (lua_State* L, void const* const p, void const* const key)
424  {
425    if (p)
426    {
427      new (lua_newuserdata (L, sizeof (UserdataPtr)))
428        UserdataPtr (const_cast <void*> (p));
429      lua_rawgetp (L, LUA_REGISTRYINDEX, key);
430      // If this goes off it means you forgot to register the class!
431      assert (lua_istable (L, -1));
432      lua_setmetatable (L, -2);
433    }
434    else
435    {
436      lua_pushnil (L);
437    }
438  }
421   /** Push const pointer to object using metatable key.
422   */
423   static void push (lua_State* L, void const* const p, void const* const key)
424   {
425   if (p)
426   {
427      new (lua_newuserdata (L, sizeof (UserdataPtr)))
428      UserdataPtr (const_cast <void*> (p));
429      lua_rawgetp (L, LUA_REGISTRYINDEX, key);
430      // If this goes off it means you forgot to register the class!
431      assert (lua_istable (L, -1));
432      lua_setmetatable (L, -2);
433   }
434   else
435   {
436      lua_pushnil (L);
437   }
438   }
439439
440  explicit UserdataPtr (void* const p)
441  {
442    m_p = p;
440   explicit UserdataPtr (void* const p)
441   {
442   m_p = p;
443443
444    // Can't construct with a null pointer!
445    //
446    assert (m_p != 0);
447  }
444   // Can't construct with a null pointer!
445   //
446   assert (m_p != 0);
447   }
448448
449449public:
450  /** Push non-const pointer to object.
451  */
452  template <class T>
453  static inline void push (lua_State* const L, T* const p)
454  {
455    if (p)
456      push (L, p, ClassInfo <T>::getClassKey ());
457    else
458      lua_pushnil (L);
459  }
450   /** Push non-const pointer to object.
451   */
452   template <class T>
453   static inline void push (lua_State* const L, T* const p)
454   {
455   if (p)
456      push (L, p, ClassInfo <T>::getClassKey ());
457   else
458      lua_pushnil (L);
459   }
460460
461  /** Push const pointer to object.
462  */
463  template <class T>
464  static inline void push (lua_State* const L, T const* const p)
465  {
466    if (p)
467      push (L, p, ClassInfo <T>::getConstKey ());
468    else
469      lua_pushnil (L);
470  }
461   /** Push const pointer to object.
462   */
463   template <class T>
464   static inline void push (lua_State* const L, T const* const p)
465   {
466   if (p)
467      push (L, p, ClassInfo <T>::getConstKey ());
468   else
469      lua_pushnil (L);
470   }
471471};
472472
473473//============================================================================
r31374r31375
481481class UserdataShared : public Userdata
482482{
483483private:
484  UserdataShared (UserdataShared <C> const&);
485  UserdataShared <C>& operator= (UserdataShared <C> const&);
484   UserdataShared (UserdataShared <C> const&);
485   UserdataShared <C>& operator= (UserdataShared <C> const&);
486486
487  typedef typename TypeTraits::removeConst <
488    typename ContainerTraits <C>::Type>::Type T;
487   typedef typename TypeTraits::removeConst <
488   typename ContainerTraits <C>::Type>::Type T;
489489
490  C m_c;
490   C m_c;
491491
492492private:
493  ~UserdataShared ()
494  {
495  }
493   ~UserdataShared ()
494   {
495   }
496496
497497public:
498  /**
499    Construct from a container to the class or a derived class.
500  */
501  template <class U>
502  explicit UserdataShared (U const& u) : m_c (u)
503  {
504    m_p = const_cast <void*> (reinterpret_cast <void const*> (
505        (ContainerTraits <C>::get (m_c))));
506  }
498   /**
499   Construct from a container to the class or a derived class.
500   */
501   template <class U>
502   explicit UserdataShared (U const& u) : m_c (u)
503   {
504   m_p = const_cast <void*> (reinterpret_cast <void const*> (
505      (ContainerTraits <C>::get (m_c))));
506   }
507507
508  /**
509    Construct from a pointer to the class or a derived class.
510  */
511  template <class U>
512  explicit UserdataShared (U* u) : m_c (u)
513  {
514    m_p = const_cast <void*> (reinterpret_cast <void const*> (
515        (ContainerTraits <C>::get (m_c))));
516  }
508   /**
509   Construct from a pointer to the class or a derived class.
510   */
511   template <class U>
512   explicit UserdataShared (U* u) : m_c (u)
513   {
514   m_p = const_cast <void*> (reinterpret_cast <void const*> (
515      (ContainerTraits <C>::get (m_c))));
516   }
517517};
518518
519519//----------------------------------------------------------------------------
r31374r31375
525525template <class C, bool makeObjectConst>
526526struct UserdataSharedHelper
527527{
528  typedef typename TypeTraits::removeConst <
529    typename ContainerTraits <C>::Type>::Type T;
528   typedef typename TypeTraits::removeConst <
529   typename ContainerTraits <C>::Type>::Type T;
530530
531  static void push (lua_State* L, C const& c)
532  {
533    if (ContainerTraits <C>::get (c) != 0)
534    {
535      new (lua_newuserdata (L, sizeof (UserdataShared <C>))) UserdataShared <C> (c);
536      lua_rawgetp (L, LUA_REGISTRYINDEX, ClassInfo <T>::getClassKey ());
537      // If this goes off it means the class T is unregistered!
538      assert (lua_istable (L, -1));
539      lua_setmetatable (L, -2);
540    }
541    else
542    {
543      lua_pushnil (L);
544    }
545  }
531   static void push (lua_State* L, C const& c)
532   {
533   if (ContainerTraits <C>::get (c) != 0)
534   {
535      new (lua_newuserdata (L, sizeof (UserdataShared <C>))) UserdataShared <C> (c);
536      lua_rawgetp (L, LUA_REGISTRYINDEX, ClassInfo <T>::getClassKey ());
537      // If this goes off it means the class T is unregistered!
538      assert (lua_istable (L, -1));
539      lua_setmetatable (L, -2);
540   }
541   else
542   {
543      lua_pushnil (L);
544   }
545   }
546546
547  static void push (lua_State* L, T* const t)
548  {
549    if (t)
550    {
551      new (lua_newuserdata (L, sizeof (UserdataShared <C>))) UserdataShared <C> (t);
552      lua_rawgetp (L, LUA_REGISTRYINDEX, ClassInfo <T>::getClassKey ());
553      // If this goes off it means the class T is unregistered!
554      assert (lua_istable (L, -1));
555      lua_setmetatable (L, -2);
556    }
557    else
558    {
559      lua_pushnil (L);
560    }
561  }
547   static void push (lua_State* L, T* const t)
548   {
549   if (t)
550   {
551      new (lua_newuserdata (L, sizeof (UserdataShared <C>))) UserdataShared <C> (t);
552      lua_rawgetp (L, LUA_REGISTRYINDEX, ClassInfo <T>::getClassKey ());
553      // If this goes off it means the class T is unregistered!
554      assert (lua_istable (L, -1));
555      lua_setmetatable (L, -2);
556   }
557   else
558   {
559      lua_pushnil (L);
560   }
561   }
562562};
563563
564564// const objects
565565template <class C>
566566struct UserdataSharedHelper <C, true>
567567{
568  typedef typename TypeTraits::removeConst <
569    typename ContainerTraits <C>::Type>::Type T;
568   typedef typename TypeTraits::removeConst <
569   typename ContainerTraits <C>::Type>::Type T;
570570
571  static void push (lua_State* L, C const& c)
572  {
573    if (ContainerTraits <C>::get (c) != 0)
574    {
575      new (lua_newuserdata (L, sizeof (UserdataShared <C>))) UserdataShared <C> (c);
576      lua_rawgetp (L, LUA_REGISTRYINDEX, ClassInfo <T>::getConstKey ());
577      // If this goes off it means the class T is unregistered!
578      assert (lua_istable (L, -1));
579      lua_setmetatable (L, -2);
580    }
581    else
582    {
583      lua_pushnil (L);
584    }
585  }
571   static void push (lua_State* L, C const& c)
572   {
573   if (ContainerTraits <C>::get (c) != 0)
574   {
575      new (lua_newuserdata (L, sizeof (UserdataShared <C>))) UserdataShared <C> (c);
576      lua_rawgetp (L, LUA_REGISTRYINDEX, ClassInfo <T>::getConstKey ());
577      // If this goes off it means the class T is unregistered!
578      assert (lua_istable (L, -1));
579      lua_setmetatable (L, -2);
580   }
581   else
582   {
583      lua_pushnil (L);
584   }
585   }
586586
587  static void push (lua_State* L, T* const t)
588  {
589    if (t)
590    {
591      new (lua_newuserdata (L, sizeof (UserdataShared <C>))) UserdataShared <C> (t);
592      lua_rawgetp (L, LUA_REGISTRYINDEX, ClassInfo <T>::getConstKey ());
593      // If this goes off it means the class T is unregistered!
594      assert (lua_istable (L, -1));
595      lua_setmetatable (L, -2);
596    }
597    else
598    {
599      lua_pushnil (L);
600    }
601  }
587   static void push (lua_State* L, T* const t)
588   {
589   if (t)
590   {
591      new (lua_newuserdata (L, sizeof (UserdataShared <C>))) UserdataShared <C> (t);
592      lua_rawgetp (L, LUA_REGISTRYINDEX, ClassInfo <T>::getConstKey ());
593      // If this goes off it means the class T is unregistered!
594      assert (lua_istable (L, -1));
595      lua_setmetatable (L, -2);
596   }
597   else
598   {
599      lua_pushnil (L);
600   }
601   }
602602};
603603
604604/**
r31374r31375
613613template <class C, bool byContainer>
614614struct StackHelper
615615{
616  static inline void push (lua_State* L, C const& c)
617  {
618    UserdataSharedHelper <C,
619      TypeTraits::isConst <typename ContainerTraits <C>::Type>::value>::push (L, c);
620  }
616   static inline void push (lua_State* L, C const& c)
617   {
618   UserdataSharedHelper <C,
619      TypeTraits::isConst <typename ContainerTraits <C>::Type>::value>::push (L, c);
620   }
621621
622  typedef typename TypeTraits::removeConst <
623    typename ContainerTraits <C>::Type>::Type T;
622   typedef typename TypeTraits::removeConst <
623   typename ContainerTraits <C>::Type>::Type T;
624624
625  static inline C get (lua_State* L, int index)
626  {
627    return Userdata::get <T> (L, index, true);
628  }
625   static inline C get (lua_State* L, int index)
626   {
627   return Userdata::get <T> (L, index, true);
628   }
629629};
630630
631631/**
r31374r31375
638638template <class T>
639639struct StackHelper <T, false>
640640{
641  static inline void push (lua_State* L, T const& t)
642  {
643    UserdataValue <T>::push (L, t);
644  }
641   static inline void push (lua_State* L, T const& t)
642   {
643   UserdataValue <T>::push (L, t);
644   }
645645
646  static inline T const& get (lua_State* L, int index)
647  {
648    return *Userdata::get <T> (L, index, true);
649  }
646   static inline T const& get (lua_State* L, int index)
647   {
648   return *Userdata::get <T> (L, index, true);
649   }
650650};
651651
652652//==============================================================================
r31374r31375
658658struct Stack
659659{
660660public:
661  static inline void push (lua_State* L, T const& t)
662  {
663    StackHelper <T,
664      TypeTraits::isContainer <T>::value>::push (L, t);
665  }
661   static inline void push (lua_State* L, T const& t)
662   {
663   StackHelper <T,
664      TypeTraits::isContainer <T>::value>::push (L, t);
665   }
666666
667  static inline T get (lua_State* L, int index)
668  {
669    return StackHelper <T,
670      TypeTraits::isContainer <T>::value>::get (L, index);
671  }
667   static inline T get (lua_State* L, int index)
668   {
669   return StackHelper <T,
670      TypeTraits::isContainer <T>::value>::get (L, index);
671   }
672672};
673673
674674//------------------------------------------------------------------------------
r31374r31375
684684template <class T>
685685struct Stack <T*>
686686{
687  static inline void push (lua_State* L, T* const p)
688  {
689    UserdataPtr::push (L, p);
690  }
687   static inline void push (lua_State* L, T* const p)
688   {
689   UserdataPtr::push (L, p);
690   }
691691
692  static inline T* const get (lua_State* L, int index)
693  {
694    return Userdata::get <T> (L, index, false);
695  }
692   static inline T* const get (lua_State* L, int index)
693   {
694   return Userdata::get <T> (L, index, false);
695   }
696696};
697697
698698// Strips the const off the right side of *
699699template <class T>
700700struct Stack <T* const>
701701{
702  static inline void push (lua_State* L, T* const p)
703  {
704    UserdataPtr::push (L, p);
705  }
702   static inline void push (lua_State* L, T* const p)
703   {
704   UserdataPtr::push (L, p);
705   }
706706
707  static inline T* const get (lua_State* L, int index)
708  {
709    return Userdata::get <T> (L, index, false);
710  }
707   static inline T* const get (lua_State* L, int index)
708   {
709   return Userdata::get <T> (L, index, false);
710   }
711711};
712712
713713// pointer to const
714714template <class T>
715715struct Stack <T const*>
716716{
717  static inline void push (lua_State* L, T const* const p)
718  {
719    UserdataPtr::push (L, p);
720  }
717   static inline void push (lua_State* L, T const* const p)
718   {
719   UserdataPtr::push (L, p);
720   }
721721
722  static inline T const* const get (lua_State* L, int index)
723  {
724    return Userdata::get <T> (L, index, true);
725  }
722   static inline T const* const get (lua_State* L, int index)
723   {
724   return Userdata::get <T> (L, index, true);
725   }
726726};
727727
728728// Strips the const off the right side of *
729729template <class T>
730730struct Stack <T const* const>
731731{
732  static inline void push (lua_State* L, T const* const p)
733  {
734    UserdataPtr::push (L, p);
735  }
732   static inline void push (lua_State* L, T const* const p)
733   {
734   UserdataPtr::push (L, p);
735   }
736736
737  static inline T const* const get (lua_State* L, int index)
738  {
739    return Userdata::get <T> (L, index, true);
740  }
737   static inline T const* const get (lua_State* L, int index)
738   {
739   return Userdata::get <T> (L, index, true);
740   }
741741};
742742
743743// reference
744744template <class T>
745745struct Stack <T&>
746746{
747  static inline void push (lua_State* L, T& t)
748  {
749    UserdataPtr::push (L, &t);
750  }
747   static inline void push (lua_State* L, T& t)
748   {
749   UserdataPtr::push (L, &t);
750   }
751751
752  static T& get (lua_State* L, int index)
753  {
754    T* const t = Userdata::get <T> (L, index, false);
755    if (!t)
756      luaL_error (L, "nil passed to reference");
757    return *t;
758  }
752   static T& get (lua_State* L, int index)
753   {
754   T* const t = Userdata::get <T> (L, index, false);
755   if (!t)
756      luaL_error (L, "nil passed to reference");
757   return *t;
758   }
759759};
760760
761761template <class C, bool byContainer>
762762struct RefStackHelper
763763{
764  typedef C return_type; 
765   
766  static inline void push (lua_State* L, C const& t)
767  {
768    UserdataSharedHelper <C,
769      TypeTraits::isConst <typename ContainerTraits <C>::Type>::value>::push (L, t);
770  }
764   typedef C return_type;
771765
772  typedef typename TypeTraits::removeConst <
773    typename ContainerTraits <C>::Type>::Type T;
766   static inline void push (lua_State* L, C const& t)
767   {
768   UserdataSharedHelper <C,
769      TypeTraits::isConst <typename ContainerTraits <C>::Type>::value>::push (L, t);
770   }
774771
775  static return_type get (lua_State* L, int index)
776  {
777    return Userdata::get <T> (L, index, true);
778  }
772   typedef typename TypeTraits::removeConst <
773   typename ContainerTraits <C>::Type>::Type T;
774
775   static return_type get (lua_State* L, int index)
776   {
777   return Userdata::get <T> (L, index, true);
778   }
779779};
780780
781781template <class T>
782782struct RefStackHelper <T, false>
783783{
784  typedef T const& return_type; 
785   
784   typedef T const& return_type;
785
786786   static inline void push (lua_State* L, T const& t)
787787   {
788     UserdataPtr::push (L, &t);
788      UserdataPtr::push (L, &t);
789789   }
790790
791  static return_type get (lua_State* L, int index)
792  {
793    T const* const t = Userdata::get <T> (L, index, true);
791   static return_type get (lua_State* L, int index)
792   {
793   T const* const t = Userdata::get <T> (L, index, true);
794794
795    if (!t)
796      luaL_error (L, "nil passed to reference");
797    return *t;
798  }
799   
795   if (!t)
796      luaL_error (L, "nil passed to reference");
797   return *t;
798   }
799
800800};
801801
802802// reference to const
803803template <class T>
804804struct Stack <T const&>
805805{
806  typedef RefStackHelper <T, TypeTraits::isContainer <T>::value> helper_t;
807 
808  static inline void push (lua_State* L, T const& t)
809  {
810    helper_t::push (L, t);
811  }
806   typedef RefStackHelper <T, TypeTraits::isContainer <T>::value> helper_t;
812807
813  static typename helper_t::return_type get (lua_State* L, int index)
814  {
815    return helper_t::get (L, index);
816  }
808   static inline void push (lua_State* L, T const& t)
809   {
810   helper_t::push (L, t);
811   }
812
813   static typename helper_t::return_type get (lua_State* L, int index)
814   {
815   return helper_t::get (L, index);
816   }
817817};
trunk/src/lib/lua/bridge/detail/Iterator.h
r31374r31375
11//------------------------------------------------------------------------------
22/*
33  https://github.com/vinniefalco/LuaBridge
4 
4
55  Copyright 2012, Vinnie Falco <vinnie.falco@gmail.com>
66
77  License: The MIT License (http://www.opensource.org/licenses/mit-license.php)
r31374r31375
3131class Iterator
3232{
3333private:
34  lua_State* m_L;
35  LuaRef m_table;
36  LuaRef m_key;
37  LuaRef m_value;
34   lua_State* m_L;
35   LuaRef m_table;
36   LuaRef m_key;
37   LuaRef m_value;
3838
39  void next ()
40  {
41    m_table.push(m_L);
42    m_key.push (m_L);
43    if (lua_next (m_L, -2))
44    {
45      m_value.pop (m_L);
46      m_key.pop (m_L);
47    }
48    else
49    {
50      m_key = Nil();
51      m_value = Nil();
52    }
53    lua_pop(m_L, 1);
54  }
39   void next ()
40   {
41   m_table.push(m_L);
42   m_key.push (m_L);
43   if (lua_next (m_L, -2))
44   {
45      m_value.pop (m_L);
46      m_key.pop (m_L);
47   }
48   else
49   {
50      m_key = Nil();
51      m_value = Nil();
52   }
53   lua_pop(m_L, 1);
54   }
5555
5656public:
57  explicit Iterator (LuaRef table)
58    : m_L (table.state ())
59    , m_table (table)
60    , m_key (table.state ()) // m_key is nil
61    , m_value (table.state ()) // m_value is nil
62  {
63    next (); // get the first (key, value) pair from table
64  }
57   explicit Iterator (LuaRef table)
58   : m_L (table.state ())
59   , m_table (table)
60   , m_key (table.state ()) // m_key is nil
61   , m_value (table.state ()) // m_value is nil
62   {
63   next (); // get the first (key, value) pair from table
64   }
6565
66  lua_State* state () const
67  {
68    return m_L;
69  }
66   lua_State* state () const
67   {
68   return m_L;
69   }
7070
71  LuaRef operator* () const
72  {
73    return m_value;
74  }
71   LuaRef operator* () const
72   {
73   return m_value;
74   }
7575
76  LuaRef operator-> () const
77  {
78    return m_value;
79  }
76   LuaRef operator-> () const
77   {
78   return m_value;
79   }
8080
81  Iterator& operator++ ()
82  {
83    if (isNil())
84    {
85      // if the iterator reaches the end, do nothing
86      return *this;
87    }
88    else
89    {
90      next();
91      return *this;
92    }
93  }
81   Iterator& operator++ ()
82   {
83   if (isNil())
84   {
85      // if the iterator reaches the end, do nothing
86      return *this;
87   }
88   else
89   {
90      next();
91      return *this;
92   }
93   }
9494
95  inline bool isNil () const
96  {
97    return m_key.isNil ();
98  }
95   inline bool isNil () const
96   {
97   return m_key.isNil ();
98   }
9999
100  inline LuaRef key () const
101  {
102    return m_key;
103  }
100   inline LuaRef key () const
101   {
102   return m_key;
103   }
104104
105  inline LuaRef value () const
106  {
107    return m_value;
108  }
105   inline LuaRef value () const
106   {
107   return m_value;
108   }
109109
110110private:
111  // Don't use postfix increment, it is less efficient
112  Iterator operator++ (int);
111   // Don't use postfix increment, it is less efficient
112   Iterator operator++ (int);
113113};
114
trunk/src/lib/lua/bridge/detail/CFunctions.h
r31374r31375
11//------------------------------------------------------------------------------
22/*
33  https://github.com/vinniefalco/LuaBridge
4 
4
55  Copyright 2012, Vinnie Falco <vinnie.falco@gmail.com>
66
77  License: The MIT License (http://www.opensource.org/licenses/mit-license.php)
r31374r31375
3030//
3131struct CFunc
3232{
33  //----------------------------------------------------------------------------
34  /**
35      __index metamethod for a namespace or class static members.
33   //----------------------------------------------------------------------------
34   /**
35     __index metamethod for a namespace or class static members.
3636
37      This handles:
38        Retrieving functions and class static methods, stored in the metatable.
39        Reading global and class static data, stored in the __propget table.
40        Reading global and class properties, stored in the __propget table.
41  */
42  static int indexMetaMethod (lua_State* L)
43  {
44    int result = 0;
45    lua_getmetatable (L, 1);                // push metatable of arg1
46    for (;;)
47    {
48      lua_pushvalue (L, 2);                 // push key arg2
49      lua_rawget (L, -2);                   // lookup key in metatable
50      if (lua_isnil (L, -1))                // not found
51      {
52        lua_pop (L, 1);                     // discard nil
53        rawgetfield (L, -1, "__propget");   // lookup __propget in metatable
54        lua_pushvalue (L, 2);               // push key arg2
55        lua_rawget (L, -2);                 // lookup key in __propget
56        lua_remove (L, -2);                 // discard __propget
57        if (lua_iscfunction (L, -1))
58        {
59          lua_remove (L, -2);               // discard metatable
60          lua_pushvalue (L, 1);             // push arg1
61          lua_call (L, 1, 1);               // call cfunction
62          result = 1;
63          break;
64        }
65        else
66        {
67          assert (lua_isnil (L, -1));
68          lua_pop (L, 1);                   // discard nil and fall through
69        }
70      }
71      else
72      {
73        assert (lua_istable (L, -1) || lua_iscfunction (L, -1));
74        lua_remove (L, -2);
75        result = 1;
76        break;
77      }
37     This handles:
38       Retrieving functions and class static methods, stored in the metatable.
39       Reading global and class static data, stored in the __propget table.
40       Reading global and class properties, stored in the __propget table.
41   */
42   static int indexMetaMethod (lua_State* L)
43   {
44   int result = 0;
45   lua_getmetatable (L, 1);                // push metatable of arg1
46   for (;;)
47   {
48      lua_pushvalue (L, 2);                 // push key arg2
49      lua_rawget (L, -2);                   // lookup key in metatable
50      if (lua_isnil (L, -1))                // not found
51      {
52      lua_pop (L, 1);                     // discard nil
53      rawgetfield (L, -1, "__propget");   // lookup __propget in metatable
54      lua_pushvalue (L, 2);               // push key arg2
55      lua_rawget (L, -2);                 // lookup key in __propget
56      lua_remove (L, -2);                 // discard __propget
57      if (lua_iscfunction (L, -1))
58      {
59         lua_remove (L, -2);               // discard metatable
60         lua_pushvalue (L, 1);             // push arg1
61         lua_call (L, 1, 1);               // call cfunction
62         result = 1;
63         break;
64      }
65      else
66      {
67         assert (lua_isnil (L, -1));
68         lua_pop (L, 1);                   // discard nil and fall through
69      }
70      }
71      else
72      {
73      assert (lua_istable (L, -1) || lua_iscfunction (L, -1));
74      lua_remove (L, -2);
75      result = 1;
76      break;
77      }
7878
79      rawgetfield (L, -1, "__parent");
80      if (lua_istable (L, -1))
81      {
82        // Remove metatable and repeat the search in __parent.
83        lua_remove (L, -2);
84      }
85      else
86      {
87        // Discard metatable and return nil.
88        assert (lua_isnil (L, -1));
89        lua_remove (L, -2);
90        result = 1;
91        break;
92      }
93    }
79      rawgetfield (L, -1, "__parent");
80      if (lua_istable (L, -1))
81      {
82      // Remove metatable and repeat the search in __parent.
83      lua_remove (L, -2);
84      }
85      else
86      {
87      // Discard metatable and return nil.
88      assert (lua_isnil (L, -1));
89      lua_remove (L, -2);
90      result = 1;
91      break;
92      }
93   }
9494
95    return result;
96  }
95   return result;
96   }
9797
98  //----------------------------------------------------------------------------
99  /**
100      __newindex metamethod for a namespace or class static members.
98   //----------------------------------------------------------------------------
99   /**
100     __newindex metamethod for a namespace or class static members.
101101
102      The __propset table stores proxy functions for assignment to:
103        Global and class static data.
104        Global and class properties.
105  */
106  static int newindexMetaMethod (lua_State* L)
107  {
108    int result = 0;
109    lua_getmetatable (L, 1);                // push metatable of arg1
110    for (;;)
111    {
112      rawgetfield (L, -1, "__propset");     // lookup __propset in metatable
113      assert (lua_istable (L, -1));
114      lua_pushvalue (L, 2);                 // push key arg2
115      lua_rawget (L, -2);                   // lookup key in __propset
116      lua_remove (L, -2);                   // discard __propset
117      if (lua_iscfunction (L, -1))          // ensure value is a cfunction
118      {
119        lua_remove (L, -2);                 // discard metatable
120        lua_pushvalue (L, 3);               // push new value arg3
121        lua_call (L, 1, 0);                 // call cfunction
122        result = 0;
123        break;
124      }
125      else
126      {
127        assert (lua_isnil (L, -1));
128        lua_pop (L, 1);
129      }
102     The __propset table stores proxy functions for assignment to:
103       Global and class static data.
104       Global and class properties.
105   */
106   static int newindexMetaMethod (lua_State* L)
107   {
108   int result = 0;
109   lua_getmetatable (L, 1);                // push metatable of arg1
110   for (;;)
111   {
112      rawgetfield (L, -1, "__propset");     // lookup __propset in metatable
113      assert (lua_istable (L, -1));
114      lua_pushvalue (L, 2);                 // push key arg2
115      lua_rawget (L, -2);                   // lookup key in __propset
116      lua_remove (L, -2);                   // discard __propset
117      if (lua_iscfunction (L, -1))          // ensure value is a cfunction
118      {
119      lua_remove (L, -2);                 // discard metatable
120      lua_pushvalue (L, 3);               // push new value arg3
121      lua_call (L, 1, 0);                 // call cfunction
122      result = 0;
123      break;
124      }
125      else
126      {
127      assert (lua_isnil (L, -1));
128      lua_pop (L, 1);
129      }
130130
131      rawgetfield (L, -1, "__parent");
132      if (lua_istable (L, -1))
133      {
134        // Remove metatable and repeat the search in __parent.
135        lua_remove (L, -2);
136      }
137      else
138      {
139        assert (lua_isnil (L, -1));
140        lua_pop (L, 2);
141        result = luaL_error (L,"no writable variable '%s'", lua_tostring (L, 2));
142      }
143    }
131      rawgetfield (L, -1, "__parent");
132      if (lua_istable (L, -1))
133      {
134      // Remove metatable and repeat the search in __parent.
135      lua_remove (L, -2);
136      }
137      else
138      {
139      assert (lua_isnil (L, -1));
140      lua_pop (L, 2);
141      result = luaL_error (L,"no writable variable '%s'", lua_tostring (L, 2));
142      }
143   }
144144
145    return result;
146  }
145   return result;
146   }
147147
148  //----------------------------------------------------------------------------
149  /**
150      lua_CFunction to report an error writing to a read-only value.
148   //----------------------------------------------------------------------------
149   /**
150     lua_CFunction to report an error writing to a read-only value.
151151
152      The name of the variable is in the first upvalue.
153  */
154  static int readOnlyError (lua_State* L)
155  {
156    std::string s;
157   
158    s = s + "'" + lua_tostring (L, lua_upvalueindex (1)) + "' is read-only";
152     The name of the variable is in the first upvalue.
153   */
154   static int readOnlyError (lua_State* L)
155   {
156   std::string s;
159157
160    return luaL_error (L, s.c_str ());
161  }
162 
163  //----------------------------------------------------------------------------
164  /**
165      lua_CFunction to get a variable.
158   s = s + "'" + lua_tostring (L, lua_upvalueindex (1)) + "' is read-only";
166159
167      This is used for global variables or class static data members.
160   return luaL_error (L, s.c_str ());
161   }
168162
169      The pointer to the data is in the first upvalue.
170  */
171  template <class T>
172  static int getVariable (lua_State* L)
173  {
174    assert (lua_islightuserdata (L, lua_upvalueindex (1)));
175    T const* ptr = static_cast <T const*> (lua_touserdata (L, lua_upvalueindex (1)));
176    assert (ptr != 0);
177    Stack <T>::push (L, *ptr);
178    return 1;
179  }
163   //----------------------------------------------------------------------------
164   /**
165     lua_CFunction to get a variable.
180166
181  //----------------------------------------------------------------------------
182  /**
183      lua_CFunction to set a variable.
167     This is used for global variables or class static data members.
184168
185      This is used for global variables or class static data members.
169     The pointer to the data is in the first upvalue.
170   */
171   template <class T>
172   static int getVariable (lua_State* L)
173   {
174   assert (lua_islightuserdata (L, lua_upvalueindex (1)));
175   T const* ptr = static_cast <T const*> (lua_touserdata (L, lua_upvalueindex (1)));
176   assert (ptr != 0);
177   Stack <T>::push (L, *ptr);
178   return 1;
179   }
186180
187      The pointer to the data is in the first upvalue.
188  */
189  template <class T>
190  static int setVariable (lua_State* L)
191  {
192    assert (lua_islightuserdata (L, lua_upvalueindex (1)));
193    T* ptr = static_cast <T*> (lua_touserdata (L, lua_upvalueindex (1)));
194    assert (ptr != 0);
195    *ptr = Stack <T>::get (L, 1);
196    return 0;
197  }
181   //----------------------------------------------------------------------------
182   /**
183     lua_CFunction to set a variable.
198184
199  //----------------------------------------------------------------------------
200  /**
201      lua_CFunction to call a function with a return value.
185     This is used for global variables or class static data members.
202186
203      This is used for global functions, global properties, class static methods,
204      and class static properties.
187     The pointer to the data is in the first upvalue.
188   */
189   template <class T>
190   static int setVariable (lua_State* L)
191   {
192   assert (lua_islightuserdata (L, lua_upvalueindex (1)));
193   T* ptr = static_cast <T*> (lua_touserdata (L, lua_upvalueindex (1)));
194   assert (ptr != 0);
195   *ptr = Stack <T>::get (L, 1);
196   return 0;
197   }
205198
206      The function pointer is in the first upvalue.
207  */
208  template <class FnPtr,
209            class ReturnType = typename FuncTraits <FnPtr>::ReturnType>
210  struct Call
211  {
212    typedef typename FuncTraits <FnPtr>::Params Params;
213    static int f (lua_State* L)
214    {
215      assert (isfulluserdata (L, lua_upvalueindex (1)));
216      FnPtr const& fnptr = *static_cast <FnPtr const*> (lua_touserdata (L, lua_upvalueindex (1)));
217      assert (fnptr != 0);
218      ArgList <Params> args (L);
219      Stack <typename FuncTraits <FnPtr>::ReturnType>::push (L, FuncTraits <FnPtr>::call (fnptr, args));
220      return 1;
221    }
222  };
199   //----------------------------------------------------------------------------
200   /**
201     lua_CFunction to call a function with a return value.
223202
224  //----------------------------------------------------------------------------
225  /**
226      lua_CFunction to call a function with no return value.
203     This is used for global functions, global properties, class static methods,
204     and class static properties.
227205
228      This is used for global functions, global properties, class static methods,
229      and class static properties.
206     The function pointer is in the first upvalue.
207   */
208   template <class FnPtr,
209         class ReturnType = typename FuncTraits <FnPtr>::ReturnType>
210   struct Call
211   {
212   typedef typename FuncTraits <FnPtr>::Params Params;
213   static int f (lua_State* L)
214   {
215      assert (isfulluserdata (L, lua_upvalueindex (1)));
216      FnPtr const& fnptr = *static_cast <FnPtr const*> (lua_touserdata (L, lua_upvalueindex (1)));
217      assert (fnptr != 0);
218      ArgList <Params> args (L);
219      Stack <typename FuncTraits <FnPtr>::ReturnType>::push (L, FuncTraits <FnPtr>::call (fnptr, args));
220      return 1;
221   }
222   };
230223
231      The function pointer is in the first upvalue.
232  */
233  template <class FnPtr>
234  struct Call <FnPtr, void>
235  {
236    typedef typename FuncTraits <FnPtr>::Params Params;
237    static int f (lua_State* L)
238    {
239      assert (isfulluserdata (L, lua_upvalueindex (1)));
240      FnPtr const& fnptr = *static_cast <FnPtr const*> (lua_touserdata (L, lua_upvalueindex (1)));
241      assert (fnptr != 0);
242      ArgList <Params> args (L);
243      FuncTraits <FnPtr>::call (fnptr, args);
244      return 0;
245    }
246  };
224   //----------------------------------------------------------------------------
225   /**
226     lua_CFunction to call a function with no return value.
247227
248  //----------------------------------------------------------------------------
249  /**
250      lua_CFunction to call a class member function with a return value.
228     This is used for global functions, global properties, class static methods,
229     and class static properties.
251230
252      The member function pointer is in the first upvalue.
253      The class userdata object is at the top of the Lua stack.
254  */
255  template <class MemFnPtr,
256            class ReturnType = typename FuncTraits <MemFnPtr>::ReturnType>
257  struct CallMember
258  {
259    typedef typename FuncTraits <MemFnPtr>::ClassType T;
260    typedef typename FuncTraits <MemFnPtr>::Params Params;
231     The function pointer is in the first upvalue.
232   */
233   template <class FnPtr>
234   struct Call <FnPtr, void>
235   {
236   typedef typename FuncTraits <FnPtr>::Params Params;
237   static int f (lua_State* L)
238   {
239      assert (isfulluserdata (L, lua_upvalueindex (1)));
240      FnPtr const& fnptr = *static_cast <FnPtr const*> (lua_touserdata (L, lua_upvalueindex (1)));
241      assert (fnptr != 0);
242      ArgList <Params> args (L);
243      FuncTraits <FnPtr>::call (fnptr, args);
244      return 0;
245   }
246   };
261247
262    static int f (lua_State* L)
263    {
264      assert (isfulluserdata (L, lua_upvalueindex (1)));
265      T* const t = Userdata::get <T> (L, 1, false);
266      MemFnPtr const& fnptr = *static_cast <MemFnPtr const*> (lua_touserdata (L, lua_upvalueindex (1)));
267      assert (fnptr != 0);
268      ArgList <Params, 2> args (L);
269      Stack <ReturnType>::push (L, FuncTraits <MemFnPtr>::call (t, fnptr, args));
270      return 1;
271    }
272  };
248   //----------------------------------------------------------------------------
249   /**
250     lua_CFunction to call a class member function with a return value.
273251
274  template <class MemFnPtr,
275            class ReturnType = typename FuncTraits <MemFnPtr>::ReturnType>
276  struct CallConstMember
277  {
278    typedef typename FuncTraits <MemFnPtr>::ClassType T;
279    typedef typename FuncTraits <MemFnPtr>::Params Params;
252     The member function pointer is in the first upvalue.
253     The class userdata object is at the top of the Lua stack.
254   */
255   template <class MemFnPtr,
256         class ReturnType = typename FuncTraits <MemFnPtr>::ReturnType>
257   struct CallMember
258   {
259   typedef typename FuncTraits <MemFnPtr>::ClassType T;
260   typedef typename FuncTraits <MemFnPtr>::Params Params;
280261
281    static int f (lua_State* L)
282    {
283      assert (isfulluserdata (L, lua_upvalueindex (1)));
284      T const* const t = Userdata::get <T> (L, 1, true);
285      MemFnPtr const& fnptr = *static_cast <MemFnPtr const*> (lua_touserdata (L, lua_upvalueindex (1)));
286      assert (fnptr != 0);
287      ArgList <Params, 2> args(L);
288      Stack <ReturnType>::push (L, FuncTraits <MemFnPtr>::call (t, fnptr, args));
289      return 1;
290    }
291  };
262   static int f (lua_State* L)
263   {
264      assert (isfulluserdata (L, lua_upvalueindex (1)));
265      T* const t = Userdata::get <T> (L, 1, false);
266      MemFnPtr const& fnptr = *static_cast <MemFnPtr const*> (lua_touserdata (L, lua_upvalueindex (1)));
267      assert (fnptr != 0);
268      ArgList <Params, 2> args (L);
269      Stack <ReturnType>::push (L, FuncTraits <MemFnPtr>::call (t, fnptr, args));
270      return 1;
271   }
272   };
292273
293  //----------------------------------------------------------------------------
294  /**
295      lua_CFunction to call a class member function with no return value.
274   template <class MemFnPtr,
275         class ReturnType = typename FuncTraits <MemFnPtr>::ReturnType>
276   struct CallConstMember
277   {
278   typedef typename FuncTraits <MemFnPtr>::ClassType T;
279   typedef typename FuncTraits <MemFnPtr>::Params Params;
296280
297      The member function pointer is in the first upvalue.
298      The class userdata object is at the top of the Lua stack.
299  */
300  template <class MemFnPtr>
301  struct CallMember <MemFnPtr, void>
302  {
303    typedef typename FuncTraits <MemFnPtr>::ClassType T;
304    typedef typename FuncTraits <MemFnPtr>::Params Params;
281   static int f (lua_State* L)
282   {
283      assert (isfulluserdata (L, lua_upvalueindex (1)));
284      T const* const t = Userdata::get <T> (L, 1, true);
285      MemFnPtr const& fnptr = *static_cast <MemFnPtr const*> (lua_touserdata (L, lua_upvalueindex (1)));
286      assert (fnptr != 0);
287      ArgList <Params, 2> args(L);
288      Stack <ReturnType>::push (L, FuncTraits <MemFnPtr>::call (t, fnptr, args));
289      return 1;
290   }
291   };
305292
306    static int f (lua_State* L)
307    {
308      assert (isfulluserdata (L, lua_upvalueindex (1)));
309      T* const t = Userdata::get <T> (L, 1, false);
310      MemFnPtr const& fnptr = *static_cast <MemFnPtr const*> (lua_touserdata (L, lua_upvalueindex (1)));
311      assert (fnptr != 0);
312      ArgList <Params, 2> args (L);
313      FuncTraits <MemFnPtr>::call (t, fnptr, args);
314      return 0;
315    }
316  };
293   //----------------------------------------------------------------------------
294   /**
295     lua_CFunction to call a class member function with no return value.
317296
318  template <class MemFnPtr>
319  struct CallConstMember <MemFnPtr, void>
320  {
321    typedef typename FuncTraits <MemFnPtr>::ClassType T;
322    typedef typename FuncTraits <MemFnPtr>::Params Params;
297     The member function pointer is in the first upvalue.
298     The class userdata object is at the top of the Lua stack.
299   */
300   template <class MemFnPtr>
301   struct CallMember <MemFnPtr, void>
302   {
303   typedef typename FuncTraits <MemFnPtr>::ClassType T;
304   typedef typename FuncTraits <MemFnPtr>::Params Params;
323305
324    static int f (lua_State* L)
325    {
326      assert (isfulluserdata (L, lua_upvalueindex (1)));
327      T const* const t = Userdata::get <T> (L, 1, true);
328      MemFnPtr const& fnptr = *static_cast <MemFnPtr const*> (lua_touserdata (L, lua_upvalueindex (1)));
329      assert (fnptr != 0);
330      ArgList <Params, 2> args (L);
331      FuncTraits <MemFnPtr>::call (t, fnptr, args);
332      return 0;
333    }
334  };
306   static int f (lua_State* L)
307   {
308      assert (isfulluserdata (L, lua_upvalueindex (1)));
309      T* const t = Userdata::get <T> (L, 1, false);
310      MemFnPtr const& fnptr = *static_cast <MemFnPtr const*> (lua_touserdata (L, lua_upvalueindex (1)));
311      assert (fnptr != 0);
312      ArgList <Params, 2> args (L);
313      FuncTraits <MemFnPtr>::call (t, fnptr, args);
314      return 0;
315   }
316   };
335317
336  //--------------------------------------------------------------------------
337  /**
338      lua_CFunction to call a class member lua_CFunction.
318   template <class MemFnPtr>
319   struct CallConstMember <MemFnPtr, void>
320   {
321   typedef typename FuncTraits <MemFnPtr>::ClassType T;
322   typedef typename FuncTraits <MemFnPtr>::Params Params;
339323
340      The member function pointer is in the first upvalue.
341      The class userdata object is at the top of the Lua stack.
342  */
343  template <class T>
344  struct CallMemberCFunction
345  {
346    static int f (lua_State* L)
347    {
348      assert (isfulluserdata (L, lua_upvalueindex (1)));
349      typedef int (T::*MFP)(lua_State* L);
350      T* const t = Userdata::get <T> (L, 1, false);
351      MFP const& fnptr = *static_cast <MFP const*> (lua_touserdata (L, lua_upvalueindex (1)));
352      assert (fnptr != 0);
353      return (t->*fnptr) (L);
354    }
355  };
324   static int f (lua_State* L)
325   {
326      assert (isfulluserdata (L, lua_upvalueindex (1)));
327      T const* const t = Userdata::get <T> (L, 1, true);
328      MemFnPtr const& fnptr = *static_cast <MemFnPtr const*> (lua_touserdata (L, lua_upvalueindex (1)));
329      assert (fnptr != 0);
330      ArgList <Params, 2> args (L);
331      FuncTraits <MemFnPtr>::call (t, fnptr, args);
332      return 0;
333   }
334   };
356335
357  template <class T>
358  struct CallConstMemberCFunction
359  {
360    static int f (lua_State* L)
361    {
362      assert (isfulluserdata (L, lua_upvalueindex (1)));
363      typedef int (T::*MFP)(lua_State* L);
364      T const* const t = Userdata::get <T> (L, 1, true);
365      MFP const& fnptr = *static_cast <MFP const*> (lua_touserdata (L, lua_upvalueindex (1)));
366      assert (fnptr != 0);
367      return (t->*fnptr) (L);
368    }
369  };
336   //--------------------------------------------------------------------------
337   /**
338     lua_CFunction to call a class member lua_CFunction.
370339
371  //--------------------------------------------------------------------------
340     The member function pointer is in the first upvalue.
341     The class userdata object is at the top of the Lua stack.
342   */
343   template <class T>
344   struct CallMemberCFunction
345   {
346   static int f (lua_State* L)
347   {
348      assert (isfulluserdata (L, lua_upvalueindex (1)));
349      typedef int (T::*MFP)(lua_State* L);
350      T* const t = Userdata::get <T> (L, 1, false);
351      MFP const& fnptr = *static_cast <MFP const*> (lua_touserdata (L, lua_upvalueindex (1)));
352      assert (fnptr != 0);
353      return (t->*fnptr) (L);
354   }
355   };
372356
373  // SFINAE Helpers
357   template <class T>
358   struct CallConstMemberCFunction
359   {
360   static int f (lua_State* L)
361   {
362      assert (isfulluserdata (L, lua_upvalueindex (1)));
363      typedef int (T::*MFP)(lua_State* L);
364      T const* const t = Userdata::get <T> (L, 1, true);
365      MFP const& fnptr = *static_cast <MFP const*> (lua_touserdata (L, lua_upvalueindex (1)));
366      assert (fnptr != 0);
367      return (t->*fnptr) (L);
368   }
369   };
374370
375  template <class MemFnPtr, bool isConst>
376  struct CallMemberFunctionHelper
377  {
378    static void add (lua_State* L, char const* name, MemFnPtr mf)
379    {
380      new (lua_newuserdata (L, sizeof (MemFnPtr))) MemFnPtr (mf);
381      lua_pushcclosure (L, &CallConstMember <MemFnPtr>::f, 1);
382      lua_pushvalue (L, -1);
383      rawsetfield (L, -5, name); // const table
384      rawsetfield (L, -3, name); // class table
385    }
386  };
371   //--------------------------------------------------------------------------
387372
388  template <class MemFnPtr>
389  struct CallMemberFunctionHelper <MemFnPtr, false>
390  {
391    static void add (lua_State* L, char const* name, MemFnPtr mf)
392    {
393      new (lua_newuserdata (L, sizeof (MemFnPtr))) MemFnPtr (mf);
394      lua_pushcclosure (L, &CallMember <MemFnPtr>::f, 1);
395      rawsetfield (L, -3, name); // class table
396    }
397  };
373   // SFINAE Helpers
398374
399  //--------------------------------------------------------------------------
400  /**
401      __gc metamethod for a class.
402  */
403  template <class C>
404  static int gcMetaMethod (lua_State* L)
405  {
406    Userdata* const ud = Userdata::getExact <C> (L, 1);
407    ud->~Userdata ();
408    return 0;
409  }
375   template <class MemFnPtr, bool isConst>
376   struct CallMemberFunctionHelper
377   {
378   static void add (lua_State* L, char const* name, MemFnPtr mf)
379   {
380      new (lua_newuserdata (L, sizeof (MemFnPtr))) MemFnPtr (mf);
381      lua_pushcclosure (L, &CallConstMember <MemFnPtr>::f, 1);
382      lua_pushvalue (L, -1);
383      rawsetfield (L, -5, name); // const table
384      rawsetfield (L, -3, name); // class table
385   }
386   };
410387
411  //--------------------------------------------------------------------------
412  /**
413      lua_CFunction to get a class data member.
388   template <class MemFnPtr>
389   struct CallMemberFunctionHelper <MemFnPtr, false>
390   {
391   static void add (lua_State* L, char const* name, MemFnPtr mf)
392   {
393      new (lua_newuserdata (L, sizeof (MemFnPtr))) MemFnPtr (mf);
394      lua_pushcclosure (L, &CallMember <MemFnPtr>::f, 1);
395      rawsetfield (L, -3, name); // class table
396   }
397   };
414398
415      The pointer-to-member is in the first upvalue.
416      The class userdata object is at the top of the Lua stack.
417  */
418  template <class C, typename T>
419  static int getProperty (lua_State* L)
420  {
421    C const* const c = Userdata::get <C> (L, 1, true);
422    T C::** mp = static_cast <T C::**> (lua_touserdata (L, lua_upvalueindex (1)));
423    Stack <T>::push (L, c->**mp);
424    return 1;
425  }
399   //--------------------------------------------------------------------------
400   /**
401     __gc metamethod for a class.
402   */
403   template <class C>
404   static int gcMetaMethod (lua_State* L)
405   {
406   Userdata* const ud = Userdata::getExact <C> (L, 1);
407   ud->~Userdata ();
408   return 0;
409   }
426410
427  //--------------------------------------------------------------------------
428  /**
429      lua_CFunction to set a class data member.
411   //--------------------------------------------------------------------------
412   /**
413     lua_CFunction to get a class data member.
430414
431      The pointer-to-member is in the first upvalue.
432      The class userdata object is at the top of the Lua stack.
433  */
434  template <class C, typename T>
435  static int setProperty (lua_State* L)
436  {
437    C* const c = Userdata::get <C> (L, 1, false);
438    T C::** mp = static_cast <T C::**> (lua_touserdata (L, lua_upvalueindex (1)));
439    c->**mp = Stack <T>::get (L, 2);
440    return 0;
441  }
415     The pointer-to-member is in the first upvalue.
416     The class userdata object is at the top of the Lua stack.
417   */
418   template <class C, typename T>
419   static int getProperty (lua_State* L)
420   {
421   C const* const c = Userdata::get <C> (L, 1, true);
422   T C::** mp = static_cast <T C::**> (lua_touserdata (L, lua_upvalueindex (1)));
423   Stack <T>::push (L, c->**mp);
424   return 1;
425   }
426
427   //--------------------------------------------------------------------------
428   /**
429     lua_CFunction to set a class data member.
430
431     The pointer-to-member is in the first upvalue.
432     The class userdata object is at the top of the Lua stack.
433   */
434   template <class C, typename T>
435   static int setProperty (lua_State* L)
436   {
437   C* const c = Userdata::get <C> (L, 1, false);
438   T C::** mp = static_cast <T C::**> (lua_touserdata (L, lua_upvalueindex (1)));
439   c->**mp = Stack <T>::get (L, 2);
440   return 0;
441   }
442442};
trunk/src/lib/lua/bridge/detail/Namespace.h
r31374r31375
11//------------------------------------------------------------------------------
22/*
33  https://github.com/vinniefalco/LuaBridge
4 
4
55  Copyright 2012, Vinnie Falco <vinnie.falco@gmail.com>
66  Copyright 2007, Nathan Reed
77
r31374r31375
3535class Namespace
3636{
3737private:
38  Namespace& operator= (Namespace const& other);
38   Namespace& operator= (Namespace const& other);
3939
40  lua_State* const L;
41  int mutable m_stackSize;
40   lua_State* const L;
41   int mutable m_stackSize;
4242
4343private:
44  //============================================================================
45  /**
46    Error reporting.
44   //============================================================================
45   /**
46   Error reporting.
4747
48    VF: This function looks handy, why aren't we using it?
49  */
48   VF: This function looks handy, why aren't we using it?
49   */
5050#if 0
51  static int luaError (lua_State* L, std::string message)
52  {
53    assert (lua_isstring (L, lua_upvalueindex (1)));
54    std::string s;
51   static int luaError (lua_State* L, std::string message)
52   {
53   assert (lua_isstring (L, lua_upvalueindex (1)));
54   std::string s;
5555
56    // Get information on the caller's caller to format the message,
57    // so the error appears to originate from the Lua source.
58    lua_Debug ar;
59    int result = lua_getstack (L, 2, &ar);
60    if (result != 0)
61    {
62      lua_getinfo (L, "Sl", &ar);
63      s = ar.short_src;
64      if (ar.currentline != -1)
65      {
66        // poor mans int to string to avoid <strstrream>.
67        lua_pushnumber (L, ar.currentline);
68        s = s + ":" + lua_tostring (L, -1) + ": ";
69        lua_pop (L, 1);
70      }
71    }
56   // Get information on the caller's caller to format the message,
57   // so the error appears to originate from the Lua source.
58   lua_Debug ar;
59   int result = lua_getstack (L, 2, &ar);
60   if (result != 0)
61   {
62      lua_getinfo (L, "Sl", &ar);
63      s = ar.short_src;
64      if (ar.currentline != -1)
65      {
66      // poor mans int to string to avoid <strstrream>.
67      lua_pushnumber (L, ar.currentline);
68      s = s + ":" + lua_tostring (L, -1) + ": ";
69      lua_pop (L, 1);
70      }
71   }
7272
73    s = s + message;
73   s = s + message;
7474
75    return luaL_error (L, s.c_str ());
76  }
75   return luaL_error (L, s.c_str ());
76   }
7777#endif
7878
79  //----------------------------------------------------------------------------
80  /**
81    Pop the Lua stack.
82  */
83  void pop (int n) const
84  {
85    if (m_stackSize >= n && lua_gettop (L) >= n)
86    {
87      lua_pop (L, n);
88      m_stackSize -= n;
89    }
90    else
91    {
92      throw std::logic_error ("invalid stack");
93    }
94  }
79   //----------------------------------------------------------------------------
80   /**
81   Pop the Lua stack.
82   */
83   void pop (int n) const
84   {
85   if (m_stackSize >= n && lua_gettop (L) >= n)
86   {
87      lua_pop (L, n);
88      m_stackSize -= n;
89   }
90   else
91   {
92      throw std::logic_error ("invalid stack");
93   }
94   }
9595
9696private:
97  /**
98    Factored base to reduce template instantiations.
99  */
100  class ClassBase
101  {
102  private:
103    ClassBase& operator= (ClassBase const& other);
97   /**
98   Factored base to reduce template instantiations.
99   */
100   class ClassBase
101   {
102   private:
103   ClassBase& operator= (ClassBase const& other);
104104
105  protected:
106    friend class Namespace;
105   protected:
106   friend class Namespace;
107107
108    lua_State* const L;
109    int mutable m_stackSize;
108   lua_State* const L;
109   int mutable m_stackSize;
110110
111  protected:
112    //--------------------------------------------------------------------------
113    /**
114      __index metamethod for a class.
111   protected:
112   //--------------------------------------------------------------------------
113   /**
114     __index metamethod for a class.
115115
116      This implements member functions, data members, and property members.
117      Functions are stored in the metatable and const metatable. Data members
118      and property members are in the __propget table.
116     This implements member functions, data members, and property members.
117     Functions are stored in the metatable and const metatable. Data members
118     and property members are in the __propget table.
119119
120      If the key is not found, the search proceeds up the hierarchy of base
121      classes.
122    */
123    static int indexMetaMethod (lua_State* L)
124    {
125      int result = 0;
120     If the key is not found, the search proceeds up the hierarchy of base
121     classes.
122   */
123   static int indexMetaMethod (lua_State* L)
124   {
125      int result = 0;
126126
127      assert (lua_isuserdata (L, 1));               // warn on security bypass
128      lua_getmetatable (L, 1);                      // get metatable for object
129      for (;;)
130      {
131        lua_pushvalue (L, 2);                       // push key arg2
132        lua_rawget (L, -2);                         // lookup key in metatable
133        if (lua_iscfunction (L, -1))                // ensure its a cfunction
134        {
135          lua_remove (L, -2);                       // remove metatable
136          result = 1;
137          break;
138        }
139        else if (lua_isnil (L, -1))
140        {
141          lua_pop (L, 1);
142        }
143        else
144        {
145          lua_pop (L, 2);
146          throw std::logic_error ("not a cfunction");
147        }
127      assert (lua_isuserdata (L, 1));               // warn on security bypass
128      lua_getmetatable (L, 1);                      // get metatable for object
129      for (;;)
130      {
131      lua_pushvalue (L, 2);                       // push key arg2
132      lua_rawget (L, -2);                         // lookup key in metatable
133      if (lua_iscfunction (L, -1))                // ensure its a cfunction
134      {
135         lua_remove (L, -2);                       // remove metatable
136         result = 1;
137         break;
138      }
139      else if (lua_isnil (L, -1))
140      {
141         lua_pop (L, 1);
142      }
143      else
144      {
145         lua_pop (L, 2);
146         throw std::logic_error ("not a cfunction");
147      }
148148
149        rawgetfield (L, -1, "__propget");           // get __propget table
150        if (lua_istable (L, -1))                    // ensure it is a table
151        {
152          lua_pushvalue (L, 2);                     // push key arg2
153          lua_rawget (L, -2);                       // lookup key in __propget
154          lua_remove (L, -2);                       // remove __propget
155          if (lua_iscfunction (L, -1))              // ensure its a cfunction
156          {
157            lua_remove (L, -2);                     // remove metatable
158            lua_pushvalue (L, 1);                   // push class arg1
159            lua_call (L, 1, 1);
160            result = 1;
161            break;
162          }
163          else if (lua_isnil (L, -1))
164          {
165            lua_pop (L, 1);
166          }
167          else
168          {
169            lua_pop (L, 2);
149      rawgetfield (L, -1, "__propget");           // get __propget table
150      if (lua_istable (L, -1))                    // ensure it is a table
151      {
152         lua_pushvalue (L, 2);                     // push key arg2
153         lua_rawget (L, -2);                       // lookup key in __propget
154         lua_remove (L, -2);                       // remove __propget
155         if (lua_iscfunction (L, -1))              // ensure its a cfunction
156         {
157         lua_remove (L, -2);                     // remove metatable
158         lua_pushvalue (L, 1);                   // push class arg1
159         lua_call (L, 1, 1);
160         result = 1;
161         break;
162         }
163         else if (lua_isnil (L, -1))
164         {
165         lua_pop (L, 1);
166         }
167         else
168         {
169         lua_pop (L, 2);
170170
171            // We only put cfunctions into __propget.
172            throw std::logic_error ("not a cfunction");
173          }
174        }
175        else
176        {
177          lua_pop (L, 2);
171         // We only put cfunctions into __propget.
172         throw std::logic_error ("not a cfunction");
173         }
174      }
175      else
176      {
177         lua_pop (L, 2);
178178
179          // __propget is missing, or not a table.
180          throw std::logic_error ("missing __propget table");
181        }
179         // __propget is missing, or not a table.
180         throw std::logic_error ("missing __propget table");
181      }
182182
183        // Repeat the lookup in the __parent metafield,
184        // or return nil if the field doesn't exist.
185        rawgetfield (L, -1, "__parent");
186        if (lua_istable (L, -1))
187        {
188          // Remove metatable and repeat the search in __parent.
189          lua_remove (L, -2);
190        }
191        else if (lua_isnil (L, -1))
192        {
193          result = 1;
194          break;
195        }
196        else
197        {
198          lua_pop (L, 2);
183      // Repeat the lookup in the __parent metafield,
184      // or return nil if the field doesn't exist.
185      rawgetfield (L, -1, "__parent");
186      if (lua_istable (L, -1))
187      {
188         // Remove metatable and repeat the search in __parent.
189         lua_remove (L, -2);
190      }
191      else if (lua_isnil (L, -1))
192      {
193         result = 1;
194         break;
195      }
196      else
197      {
198         lua_pop (L, 2);
199199
200          throw std::logic_error ("__parent is not a table");
201        }
202      }
200         throw std::logic_error ("__parent is not a table");
201      }
202      }
203203
204      return result;
205    }
204      return result;
205   }
206206
207    //--------------------------------------------------------------------------
208    /**
209      __newindex metamethod for classes.
207   //--------------------------------------------------------------------------
208   /**
209     __newindex metamethod for classes.
210210
211      This supports writable variables and properties on class objects. The
212      corresponding object is passed in the first parameter to the set function.
213    */
214    static int newindexMetaMethod (lua_State* L)
215    {
216      int result = 0;
211     This supports writable variables and properties on class objects. The
212     corresponding object is passed in the first parameter to the set function.
213   */
214   static int newindexMetaMethod (lua_State* L)
215   {
216      int result = 0;
217217
218      lua_getmetatable (L, 1);
218      lua_getmetatable (L, 1);
219219
220      for (;;)
221      {
222        // Check __propset
223        rawgetfield (L, -1, "__propset");
224        if (!lua_isnil (L, -1))
225        {
226          lua_pushvalue (L, 2);
227          lua_rawget (L, -2);
228          if (!lua_isnil (L, -1))
229          {
230            // found it, call the setFunction.
231            assert (lua_isfunction (L, -1));
232            lua_pushvalue (L, 1);
233            lua_pushvalue (L, 3);
234            lua_call (L, 2, 0);
235            result = 0;
236            break;
237          }
238          lua_pop (L, 1);
239        }
240        lua_pop (L, 1);
220      for (;;)
221      {
222      // Check __propset
223      rawgetfield (L, -1, "__propset");
224      if (!lua_isnil (L, -1))
225      {
226         lua_pushvalue (L, 2);
227         lua_rawget (L, -2);
228         if (!lua_isnil (L, -1))
229         {
230         // found it, call the setFunction.
231         assert (lua_isfunction (L, -1));
232         lua_pushvalue (L, 1);
233         lua_pushvalue (L, 3);
234         lua_call (L, 2, 0);
235         result = 0;
236         break;
237         }
238         lua_pop (L, 1);
239      }
240      lua_pop (L, 1);
241241
242        // Repeat the lookup in the __parent metafield.
243        rawgetfield (L, -1, "__parent");
244        if (lua_isnil (L, -1))
245        {
246          // Either the property or __parent must exist.
247          result = luaL_error (L,
248            "no member named '%s'", lua_tostring (L, 2));
249        }
250        lua_remove (L, -2);
251      }
242      // Repeat the lookup in the __parent metafield.
243      rawgetfield (L, -1, "__parent");
244      if (lua_isnil (L, -1))
245      {
246         // Either the property or __parent must exist.
247         result = luaL_error (L,
248         "no member named '%s'", lua_tostring (L, 2));
249      }
250      lua_remove (L, -2);
251      }
252252
253      return result;
254    }
253      return result;
254   }
255255
256    //--------------------------------------------------------------------------
257    /**
258      Create the const table.
259    */
260    void createConstTable (char const* name)
261    {
262      lua_newtable (L);
263      lua_pushvalue (L, -1);
264      lua_setmetatable (L, -2);
265      lua_pushboolean (L, 1);
266      lua_rawsetp (L, -2, getIdentityKey ());
267      lua_pushstring (L, (std::string ("const ") + name).c_str ());
268      rawsetfield (L, -2, "__type");
269      lua_pushcfunction (L, &indexMetaMethod);
270      rawsetfield (L, -2, "__index");
271      lua_pushcfunction (L, &newindexMetaMethod);
272      rawsetfield (L, -2, "__newindex");
273      lua_newtable (L);
274      rawsetfield (L, -2, "__propget");
275     
276      if (Security::hideMetatables ())
277      {
278        lua_pushnil (L);
279        rawsetfield (L, -2, "__metatable");
280      }
281    }
256   //--------------------------------------------------------------------------
257   /**
258     Create the const table.
259   */
260   void createConstTable (char const* name)
261   {
262      lua_newtable (L);
263      lua_pushvalue (L, -1);
264      lua_setmetatable (L, -2);
265      lua_pushboolean (L, 1);
266      lua_rawsetp (L, -2, getIdentityKey ());
267      lua_pushstring (L, (std::string ("const ") + name).c_str ());
268      rawsetfield (L, -2, "__type");
269      lua_pushcfunction (L, &indexMetaMethod);
270      rawsetfield (L, -2, "__index");
271      lua_pushcfunction (L, &newindexMetaMethod);
272      rawsetfield (L, -2, "__newindex");
273      lua_newtable (L);
274      rawsetfield (L, -2, "__propget");
282275
283    //--------------------------------------------------------------------------
284    /**
285      Create the class table.
276      if (Security::hideMetatables ())
277      {
278      lua_pushnil (L);
279      rawsetfield (L, -2, "__metatable");
280      }
281   }
286282
287      The Lua stack should have the const table on top.
288    */
289    void createClassTable (char const* name)
290    {
291      lua_newtable (L);
292      lua_pushvalue (L, -1);
293      lua_setmetatable (L, -2);
294      lua_pushboolean (L, 1);
295      lua_rawsetp (L, -2, getIdentityKey ());
296      lua_pushstring (L, name);
297      rawsetfield (L, -2, "__type");
298      lua_pushcfunction (L, &indexMetaMethod);
299      rawsetfield (L, -2, "__index");
300      lua_pushcfunction (L, &newindexMetaMethod);
301      rawsetfield (L, -2, "__newindex");
302      lua_newtable (L);
303      rawsetfield (L, -2, "__propget");
304      lua_newtable (L);
305      rawsetfield (L, -2, "__propset");
283   //--------------------------------------------------------------------------
284   /**
285     Create the class table.
306286
307      lua_pushvalue (L, -2);
308      rawsetfield (L, -2, "__const"); // point to const table
287     The Lua stack should have the const table on top.
288   */
289   void createClassTable (char const* name)
290   {
291      lua_newtable (L);
292      lua_pushvalue (L, -1);
293      lua_setmetatable (L, -2);
294      lua_pushboolean (L, 1);
295      lua_rawsetp (L, -2, getIdentityKey ());
296      lua_pushstring (L, name);
297      rawsetfield (L, -2, "__type");
298      lua_pushcfunction (L, &indexMetaMethod);
299      rawsetfield (L, -2, "__index");
300      lua_pushcfunction (L, &newindexMetaMethod);
301      rawsetfield (L, -2, "__newindex");
302      lua_newtable (L);
303      rawsetfield (L, -2, "__propget");
304      lua_newtable (L);
305      rawsetfield (L, -2, "__propset");
309306
310      lua_pushvalue (L, -1);
311      rawsetfield (L, -3, "__class"); // point const table to class table
307      lua_pushvalue (L, -2);
308      rawsetfield (L, -2, "__const"); // point to const table
312309
313      if (Security::hideMetatables ())
314      {
315        lua_pushnil (L);
316        rawsetfield (L, -2, "__metatable");
317      }
318    }
310      lua_pushvalue (L, -1);
311      rawsetfield (L, -3, "__class"); // point const table to class table
319312
320    //--------------------------------------------------------------------------
321    /**
322      Create the static table.
313      if (Security::hideMetatables ())
314      {
315      lua_pushnil (L);
316      rawsetfield (L, -2, "__metatable");
317      }
318   }
323319
324      The Lua stack should have:
325        -1 class table
326        -2 const table
327        -3 enclosing namespace
328    */
329    void createStaticTable (char const* name)
330    {
331      lua_newtable (L);
332      lua_newtable (L);
333      lua_pushvalue (L, -1);
334      lua_setmetatable (L, -3);
335      lua_insert (L, -2);
336      rawsetfield (L, -5, name);
320   //--------------------------------------------------------------------------
321   /**
322     Create the static table.
337323
324     The Lua stack should have:
325       -1 class table
326       -2 const table
327       -3 enclosing namespace
328   */
329   void createStaticTable (char const* name)
330   {
331      lua_newtable (L);
332      lua_newtable (L);
333      lua_pushvalue (L, -1);
334      lua_setmetatable (L, -3);
335      lua_insert (L, -2);
336      rawsetfield (L, -5, name);
337
338338#if 0
339      lua_pushlightuserdata (L, this);
340      lua_pushcclosure (L, &tostringMetaMethod, 1);
341      rawsetfield (L, -2, "__tostring");
339      lua_pushlightuserdata (L, this);
340      lua_pushcclosure (L, &tostringMetaMethod, 1);
341      rawsetfield (L, -2, "__tostring");
342342#endif
343      lua_pushcfunction (L, &CFunc::indexMetaMethod);
344      rawsetfield (L, -2, "__index");
345      lua_pushcfunction (L, &CFunc::newindexMetaMethod);
346      rawsetfield (L, -2, "__newindex");
347      lua_newtable (L);
348      rawsetfield (L, -2, "__propget");
349      lua_newtable (L);
350      rawsetfield (L, -2, "__propset");
343      lua_pushcfunction (L, &CFunc::indexMetaMethod);
344      rawsetfield (L, -2, "__index");
345      lua_pushcfunction (L, &CFunc::newindexMetaMethod);
346      rawsetfield (L, -2, "__newindex");
347      lua_newtable (L);
348      rawsetfield (L, -2, "__propget");
349      lua_newtable (L);
350      rawsetfield (L, -2, "__propset");
351351
352      lua_pushvalue (L, -2);
353      rawsetfield (L, -2, "__class"); // point to class table
352      lua_pushvalue (L, -2);
353      rawsetfield (L, -2, "__class"); // point to class table
354354
355      if (Security::hideMetatables ())
356      {
357        lua_pushnil (L);
358        rawsetfield (L, -2, "__metatable");
359      }
360    }
355      if (Security::hideMetatables ())
356      {
357      lua_pushnil (L);
358      rawsetfield (L, -2, "__metatable");
359      }
360   }
361361
362    //==========================================================================
363    /**
364      lua_CFunction to construct a class object wrapped in a container.
365    */
366    template <class Params, class C>
367    static int ctorContainerProxy (lua_State* L)
368    {
369      typedef typename ContainerTraits <C>::Type T;
370      ArgList <Params, 2> args (L);
371      T* const p = Constructor <T, Params>::call (args);
372      UserdataSharedHelper <C, false>::push (L, p);
373      return 1;
374    }
362   //==========================================================================
363   /**
364     lua_CFunction to construct a class object wrapped in a container.
365   */
366   template <class Params, class C>
367   static int ctorContainerProxy (lua_State* L)
368   {
369      typedef typename ContainerTraits <C>::Type T;
370      ArgList <Params, 2> args (L);
371      T* const p = Constructor <T, Params>::call (args);
372      UserdataSharedHelper <C, false>::push (L, p);
373      return 1;
374   }
375375
376    //--------------------------------------------------------------------------
377    /**
378      lua_CFunction to construct a class object in-place in the userdata.
379    */
380    template <class Params, class T>
381    static int ctorPlacementProxy (lua_State* L)
382    {
383      ArgList <Params, 2> args (L);
384      Constructor <T, Params>::call (UserdataValue <T>::place (L), args);
385      return 1;
386    }
376   //--------------------------------------------------------------------------
377   /**
378     lua_CFunction to construct a class object in-place in the userdata.
379   */
380   template <class Params, class T>
381   static int ctorPlacementProxy (lua_State* L)
382   {
383      ArgList <Params, 2> args (L);
384      Constructor <T, Params>::call (UserdataValue <T>::place (L), args);
385      return 1;
386   }
387387
388    //--------------------------------------------------------------------------
389    /**
390      Pop the Lua stack.
391    */
392    void pop (int n) const
393    {
394      if (m_stackSize >= n && lua_gettop (L) >= n)
395      {
396        lua_pop (L, n);
397        m_stackSize -= n;
398      }
399      else
400      {
401        throw std::logic_error ("invalid stack");
402      }
403    }
388   //--------------------------------------------------------------------------
389   /**
390     Pop the Lua stack.
391   */
392   void pop (int n) const
393   {
394      if (m_stackSize >= n && lua_gettop (L) >= n)
395      {
396      lua_pop (L, n);
397      m_stackSize -= n;
398      }
399      else
400      {
401      throw std::logic_error ("invalid stack");
402      }
403   }
404404
405  public:
406    //--------------------------------------------------------------------------
407    explicit ClassBase (lua_State* L_)
408      : L (L_)
409      , m_stackSize (0)
410    {
411    }
405   public:
406   //--------------------------------------------------------------------------
407   explicit ClassBase (lua_State* L_)
408      : L (L_)
409      , m_stackSize (0)
410   {
411   }
412412
413    //--------------------------------------------------------------------------
414    /**
415      Copy Constructor.
416    */
417    ClassBase (ClassBase const& other)
418      : L (other.L)
419      , m_stackSize (0)
420    {
421      m_stackSize = other.m_stackSize;
422      other.m_stackSize = 0;
423    }
413   //--------------------------------------------------------------------------
414   /**
415     Copy Constructor.
416   */
417   ClassBase (ClassBase const& other)
418      : L (other.L)
419      , m_stackSize (0)
420   {
421      m_stackSize = other.m_stackSize;
422      other.m_stackSize = 0;
423   }
424424
425    ~ClassBase ()
426    {
427      pop (m_stackSize);
428    }
429  };
425   ~ClassBase ()
426   {
427      pop (m_stackSize);
428   }
429   };
430430
431  //============================================================================
432  //
433  // Class
434  //
435  //============================================================================
436  /**
437    Provides a class registration in a lua_State.
431   //============================================================================
432   //
433   // Class
434   //
435   //============================================================================
436   /**
437   Provides a class registration in a lua_State.
438438
439    After contstruction the Lua stack holds these objects:
440      -1 static table
441      -2 class table
442      -3 const table
443      -4 (enclosing namespace)
444  */
445  template <class T>
446  class Class : public ClassBase
447  {
448  public:
449    //==========================================================================
450    /**
451      Register a new class or add to an existing class registration.
452    */
453    Class (char const* name, Namespace const* parent) : ClassBase (parent->L)
454    {
455      m_stackSize = parent->m_stackSize + 3;
456      parent->m_stackSize = 0;
439   After contstruction the Lua stack holds these objects:
440     -1 static table
441     -2 class table
442     -3 const table
443     -4 (enclosing namespace)
444   */
445   template <class T>
446   class Class : public ClassBase
447   {
448   public:
449   //==========================================================================
450   /**
451     Register a new class or add to an existing class registration.
452   */
453   Class (char const* name, Namespace const* parent) : ClassBase (parent->L)
454   {
455      m_stackSize = parent->m_stackSize + 3;
456      parent->m_stackSize = 0;
457457
458      assert (lua_istable (L, -1));
459      rawgetfield (L, -1, name);
460     
461      if (lua_isnil (L, -1))
462      {
463        lua_pop (L, 1);
458      assert (lua_istable (L, -1));
459      rawgetfield (L, -1, name);
464460
465        createConstTable (name);
466        lua_pushcfunction (L, &CFunc::gcMetaMethod <T>);
467        rawsetfield (L, -2, "__gc");
461      if (lua_isnil (L, -1))
462      {
463      lua_pop (L, 1);
468464
469        createClassTable (name);
470        lua_pushcfunction (L, &CFunc::gcMetaMethod <T>);
471        rawsetfield (L, -2, "__gc");
465      createConstTable (name);
466      lua_pushcfunction (L, &CFunc::gcMetaMethod <T>);
467      rawsetfield (L, -2, "__gc");
472468
473        createStaticTable (name);
469      createClassTable (name);
470      lua_pushcfunction (L, &CFunc::gcMetaMethod <T>);
471      rawsetfield (L, -2, "__gc");
474472
475        // Map T back to its tables.
476        lua_pushvalue (L, -1);
477        lua_rawsetp (L, LUA_REGISTRYINDEX, ClassInfo <T>::getStaticKey ());
478        lua_pushvalue (L, -2);
479        lua_rawsetp (L, LUA_REGISTRYINDEX, ClassInfo <T>::getClassKey ());
480        lua_pushvalue (L, -3);
481        lua_rawsetp (L, LUA_REGISTRYINDEX, ClassInfo <T>::getConstKey ());
482      }
483      else
484      {
485        rawgetfield (L, -1, "__class");
486        rawgetfield (L, -1, "__const");
473      createStaticTable (name);
487474
488        // Reverse the top 3 stack elements
489        lua_insert (L, -3);
490        lua_insert (L, -2);
491      }
492    }
475      // Map T back to its tables.
476      lua_pushvalue (L, -1);
477      lua_rawsetp (L, LUA_REGISTRYINDEX, ClassInfo <T>::getStaticKey ());
478      lua_pushvalue (L, -2);
479      lua_rawsetp (L, LUA_REGISTRYINDEX, ClassInfo <T>::getClassKey ());
480      lua_pushvalue (L, -3);
481      lua_rawsetp (L, LUA_REGISTRYINDEX, ClassInfo <T>::getConstKey ());
482      }
483      else
484      {
485      rawgetfield (L, -1, "__class");
486      rawgetfield (L, -1, "__const");
493487
494    //==========================================================================
495    /**
496      Derive a new class.
497    */
498    Class (char const* name, Namespace const* parent, void const* const staticKey)
499      : ClassBase (parent->L)
500    {
501      m_stackSize = parent->m_stackSize + 3;
502      parent->m_stackSize = 0;
488      // Reverse the top 3 stack elements
489      lua_insert (L, -3);
490      lua_insert (L, -2);
491      }
492   }
503493
504      assert (lua_istable (L, -1));
494   //==========================================================================
495   /**
496     Derive a new class.
497   */
498   Class (char const* name, Namespace const* parent, void const* const staticKey)
499      : ClassBase (parent->L)
500   {
501      m_stackSize = parent->m_stackSize + 3;
502      parent->m_stackSize = 0;
505503
506      createConstTable (name);
507      lua_pushcfunction (L, &CFunc::gcMetaMethod <T>);
508      rawsetfield (L, -2, "__gc");
504      assert (lua_istable (L, -1));
509505
510      createClassTable (name);
511      lua_pushcfunction (L, &CFunc::gcMetaMethod <T>);
512      rawsetfield (L, -2, "__gc");
506      createConstTable (name);
507      lua_pushcfunction (L, &CFunc::gcMetaMethod <T>);
508      rawsetfield (L, -2, "__gc");
513509
514      createStaticTable (name);
510      createClassTable (name);
511      lua_pushcfunction (L, &CFunc::gcMetaMethod <T>);
512      rawsetfield (L, -2, "__gc");
515513
516      lua_rawgetp (L, LUA_REGISTRYINDEX, staticKey);
517      assert (lua_istable (L, -1));
518      rawgetfield (L, -1, "__class");
519      assert (lua_istable (L, -1));
520      rawgetfield (L, -1, "__const");
521      assert (lua_istable (L, -1));
514      createStaticTable (name);
522515
523      rawsetfield (L, -6, "__parent");
524      rawsetfield (L, -4, "__parent");
525      rawsetfield (L, -2, "__parent");
516      lua_rawgetp (L, LUA_REGISTRYINDEX, staticKey);
517      assert (lua_istable (L, -1));
518      rawgetfield (L, -1, "__class");
519      assert (lua_istable (L, -1));
520      rawgetfield (L, -1, "__const");
521      assert (lua_istable (L, -1));
526522
527      lua_pushvalue (L, -1);
528      lua_rawsetp (L, LUA_REGISTRYINDEX, ClassInfo <T>::getStaticKey ());
529      lua_pushvalue (L, -2);
530      lua_rawsetp (L, LUA_REGISTRYINDEX, ClassInfo <T>::getClassKey ());
531      lua_pushvalue (L, -3);
532      lua_rawsetp (L, LUA_REGISTRYINDEX, ClassInfo <T>::getConstKey ());
533    }
523      rawsetfield (L, -6, "__parent");
524      rawsetfield (L, -4, "__parent");
525      rawsetfield (L, -2, "__parent");
534526
535    //--------------------------------------------------------------------------
536    /**
537      Continue registration in the enclosing namespace.
538    */
539    Namespace endClass ()
540    {
541      return Namespace (this);
542    }
527      lua_pushvalue (L, -1);
528      lua_rawsetp (L, LUA_REGISTRYINDEX, ClassInfo <T>::getStaticKey ());
529      lua_pushvalue (L, -2);
530      lua_rawsetp (L, LUA_REGISTRYINDEX, ClassInfo <T>::getClassKey ());
531      lua_pushvalue (L, -3);
532      lua_rawsetp (L, LUA_REGISTRYINDEX, ClassInfo <T>::getConstKey ());
533   }
543534
544    //--------------------------------------------------------------------------
545    /**
546      Add or replace a static data member.
547    */
548    template <class U>
549    Class <T>& addStaticData (char const* name, U* pu, bool isWritable = true)
550    {
551      assert (lua_istable (L, -1));
535   //--------------------------------------------------------------------------
536   /**
537     Continue registration in the enclosing namespace.
538   */
539   Namespace endClass ()
540   {
541      return Namespace (this);
542   }
552543
553      rawgetfield (L, -1, "__propget");
554      assert (lua_istable (L, -1));
555      lua_pushlightuserdata (L, pu);
556      lua_pushcclosure (L, &CFunc::getVariable <U>, 1);
557      rawsetfield (L, -2, name);
558      lua_pop (L, 1);
544   //--------------------------------------------------------------------------
545   /**
546     Add or replace a static data member.
547   */
548   template <class U>
549   Class <T>& addStaticData (char const* name, U* pu, bool isWritable = true)
550   {
551      assert (lua_istable (L, -1));
559552
560      rawgetfield (L, -1, "__propset");
561      assert (lua_istable (L, -1));
562      if (isWritable)
563      {
564        lua_pushlightuserdata (L, pu);
565        lua_pushcclosure (L, &CFunc::setVariable <U>, 1);
566      }
567      else
568      {
569        lua_pushstring (L, name);
570        lua_pushcclosure (L, &CFunc::readOnlyError, 1);
571      }
572      rawsetfield (L, -2, name);
573      lua_pop (L, 1);
553      rawgetfield (L, -1, "__propget");
554      assert (lua_istable (L, -1));
555      lua_pushlightuserdata (L, pu);
556      lua_pushcclosure (L, &CFunc::getVariable <U>, 1);
557      rawsetfield (L, -2, name);
558      lua_pop (L, 1);
574559
575      return *this;
576    }
560      rawgetfield (L, -1, "__propset");
561      assert (lua_istable (L, -1));
562      if (isWritable)
563      {
564      lua_pushlightuserdata (L, pu);
565      lua_pushcclosure (L, &CFunc::setVariable <U>, 1);
566      }
567      else
568      {
569      lua_pushstring (L, name);
570      lua_pushcclosure (L, &CFunc::readOnlyError, 1);
571      }
572      rawsetfield (L, -2, name);
573      lua_pop (L, 1);
577574
578    //--------------------------------------------------------------------------
579    /**
580      Add or replace a static property member.
575      return *this;
576   }
581577
582      If the set function is null, the property is read-only.
583    */
584    template <class U>
585    Class <T>& addStaticProperty (char const* name, U (*get)(), void (*set)(U) = 0)
586    {
587      typedef U (*get_t)();
588      typedef void (*set_t)(U);
589     
590      assert (lua_istable (L, -1));
578   //--------------------------------------------------------------------------
579   /**
580     Add or replace a static property member.
591581
592      rawgetfield (L, -1, "__propget");
593      assert (lua_istable (L, -1));
594      new (lua_newuserdata (L, sizeof (get))) get_t (get);
595      lua_pushcclosure (L, &CFunc::Call <U (*) (void)>::f, 1);
596      rawsetfield (L, -2, name);
597      lua_pop (L, 1);
582     If the set function is null, the property is read-only.
583   */
584   template <class U>
585   Class <T>& addStaticProperty (char const* name, U (*get)(), void (*set)(U) = 0)
586   {
587      typedef U (*get_t)();
588      typedef void (*set_t)(U);
598589
599      rawgetfield (L, -1, "__propset");
600      assert (lua_istable (L, -1));
601      if (set != 0)
602      {
603        new (lua_newuserdata (L, sizeof (set))) set_t (set);
604        lua_pushcclosure (L, &CFunc::Call <void (*) (U)>::f, 1);
605      }
606      else
607      {
608        lua_pushstring (L, name);
609        lua_pushcclosure (L, &CFunc::readOnlyError, 1);
610      }
611      rawsetfield (L, -2, name);
612      lua_pop (L, 1);
590      assert (lua_istable (L, -1));
613591
614      return *this;
615    }
592      rawgetfield (L, -1, "__propget");
593      assert (lua_istable (L, -1));
594      new (lua_newuserdata (L, sizeof (get))) get_t (get);
595      lua_pushcclosure (L, &CFunc::Call <U (*) (void)>::f, 1);
596      rawsetfield (L, -2, name);
597      lua_pop (L, 1);
616598
617    //--------------------------------------------------------------------------
618    /**
619      Add or replace a static member function.
620    */
621    template <class FP>
622    Class <T>& addStaticFunction (char const* name, FP const fp)
623    {
624      new (lua_newuserdata (L, sizeof (fp))) FP (fp);
625      lua_pushcclosure (L, &CFunc::Call <FP>::f, 1);
626      rawsetfield (L, -2, name);
599      rawgetfield (L, -1, "__propset");
600      assert (lua_istable (L, -1));
601      if (set != 0)
602      {
603      new (lua_newuserdata (L, sizeof (set))) set_t (set);
604      lua_pushcclosure (L, &CFunc::Call <void (*) (U)>::f, 1);
605      }
606      else
607      {
608      lua_pushstring (L, name);
609      lua_pushcclosure (L, &CFunc::readOnlyError, 1);
610      }
611      rawsetfield (L, -2, name);
612      lua_pop (L, 1);
627613
628      return *this;
629    }
614      return *this;
615   }
630616
631    //--------------------------------------------------------------------------
632    /**
633      Add or replace a lua_CFunction.
634    */
635    Class <T>& addStaticCFunction (char const* name, int (*const fp)(lua_State*))
636    {
637      lua_pushcfunction (L, fp);
638      rawsetfield (L, -2, name);
639      return *this;
640    }
617   //--------------------------------------------------------------------------
618   /**
619     Add or replace a static member function.
620   */
621   template <class FP>
622   Class <T>& addStaticFunction (char const* name, FP const fp)
623   {
624      new (lua_newuserdata (L, sizeof (fp))) FP (fp);
625      lua_pushcclosure (L, &CFunc::Call <FP>::f, 1);
626      rawsetfield (L, -2, name);
641627
642    //--------------------------------------------------------------------------
643    /**
644      Add or replace a data member.
645    */
646    template <class U>
647    Class <T>& addData (char const* name, const U T::* mp, bool isWritable = true)
648    {
649      typedef const U T::*mp_t;
628      return *this;
629   }
650630
651      // Add to __propget in class and const tables.
652      {
653        rawgetfield (L, -2, "__propget");
654        rawgetfield (L, -4, "__propget");
655        new (lua_newuserdata (L, sizeof (mp_t))) mp_t (mp);
656        lua_pushcclosure (L, &CFunc::getProperty <T,U>, 1);
657        lua_pushvalue (L, -1);
658        rawsetfield (L, -4, name);
659        rawsetfield (L, -2, name);
660        lua_pop (L, 2);
661      }
631   //--------------------------------------------------------------------------
632   /**
633     Add or replace a lua_CFunction.
634   */
635   Class <T>& addStaticCFunction (char const* name, int (*const fp)(lua_State*))
636   {
637      lua_pushcfunction (L, fp);
638      rawsetfield (L, -2, name);
639      return *this;
640   }
662641
663      if (isWritable)
664      {
665        // Add to __propset in class table.
666        rawgetfield (L, -2, "__propset");
667        assert (lua_istable (L, -1));
668        new (lua_newuserdata (L, sizeof (mp_t))) mp_t (mp);
669        lua_pushcclosure (L, &CFunc::setProperty <T,U>, 1);
670        rawsetfield (L, -2, name);
671        lua_pop (L, 1);
672      }
642   //--------------------------------------------------------------------------
643   /**
644     Add or replace a data member.
645   */
646   template <class U>
647   Class <T>& addData (char const* name, const U T::* mp, bool isWritable = true)
648   {
649      typedef const U T::*mp_t;
673650
674      return *this;
675    }
651      // Add to __propget in class and const tables.
652      {
653      rawgetfield (L, -2, "__propget");
654      rawgetfield (L, -4, "__propget");
655      new (lua_newuserdata (L, sizeof (mp_t))) mp_t (mp);
656      lua_pushcclosure (L, &CFunc::getProperty <T,U>, 1);
657      lua_pushvalue (L, -1);
658      rawsetfield (L, -4, name);
659      rawsetfield (L, -2, name);
660      lua_pop (L, 2);
661      }
676662
677    //--------------------------------------------------------------------------
678    /**
679      Add or replace a property member.
680    */
681    template <class TG, class TS>
682    Class <T>& addProperty (char const* name, TG (T::* get) () const, void (T::* set) (TS))
683    {
684      // Add to __propget in class and const tables.
685      {
686        rawgetfield (L, -2, "__propget");
687        rawgetfield (L, -4, "__propget");
688        typedef TG (T::*get_t) () const;
689        new (lua_newuserdata (L, sizeof (get_t))) get_t (get);
690        lua_pushcclosure (L, &CFunc::CallConstMember <get_t>::f, 1);
691        lua_pushvalue (L, -1);
692        rawsetfield (L, -4, name);
693        rawsetfield (L, -2, name);
694        lua_pop (L, 2);
695      }
663      if (isWritable)
664      {
665      // Add to __propset in class table.
666      rawgetfield (L, -2, "__propset");
667      assert (lua_istable (L, -1));
668      new (lua_newuserdata (L, sizeof (mp_t))) mp_t (mp);
669      lua_pushcclosure (L, &CFunc::setProperty <T,U>, 1);
670      rawsetfield (L, -2, name);
671      lua_pop (L, 1);
672      }
696673
697      {
698        // Add to __propset in class table.
699        rawgetfield (L, -2, "__propset");
700        assert (lua_istable (L, -1));
701        typedef void (T::* set_t) (TS);
702        new (lua_newuserdata (L, sizeof (set_t))) set_t (set);
703        lua_pushcclosure (L, &CFunc::CallMember <set_t>::f, 1);
704        rawsetfield (L, -2, name);
705        lua_pop (L, 1);
706      }
674      return *this;
675   }
707676
708      return *this;
709    }
677   //--------------------------------------------------------------------------
678   /**
679     Add or replace a property member.
680   */
681   template <class TG, class TS>
682   Class <T>& addProperty (char const* name, TG (T::* get) () const, void (T::* set) (TS))
683   {
684      // Add to __propget in class and const tables.
685      {
686      rawgetfield (L, -2, "__propget");
687      rawgetfield (L, -4, "__propget");
688      typedef TG (T::*get_t) () const;
689      new (lua_newuserdata (L, sizeof (get_t))) get_t (get);
690      lua_pushcclosure (L, &CFunc::CallConstMember <get_t>::f, 1);
691      lua_pushvalue (L, -1);
692      rawsetfield (L, -4, name);
693      rawsetfield (L, -2, name);
694      lua_pop (L, 2);
695      }
710696
711    // read-only
712    template <class TG>
713    Class <T>& addProperty (char const* name, TG (T::* get) () const)
714    {
715      // Add to __propget in class and const tables.
716      rawgetfield (L, -2, "__propget");
717      rawgetfield (L, -4, "__propget");
718      typedef TG (T::*get_t) () const;
719      new (lua_newuserdata (L, sizeof (get_t))) get_t (get);
720      lua_pushcclosure (L, &CFunc::CallConstMember <get_t>::f, 1);
721      lua_pushvalue (L, -1);
722      rawsetfield (L, -4, name);
723      rawsetfield (L, -2, name);
724      lua_pop (L, 2);
697      {
698      // Add to __propset in class table.
699      rawgetfield (L, -2, "__propset");
700      assert (lua_istable (L, -1));
701      typedef void (T::* set_t) (TS);
702      new (lua_newuserdata (L, sizeof (set_t))) set_t (set);
703      lua_pushcclosure (L, &CFunc::CallMember <set_t>::f, 1);
704      rawsetfield (L, -2, name);
705      lua_pop (L, 1);
706      }
725707
726      return *this;
727    }
708      return *this;
709   }
728710
729    //--------------------------------------------------------------------------
730    /**
731      Add or replace a property member, by proxy.
711   // read-only
712   template <class TG>
713   Class <T>& addProperty (char const* name, TG (T::* get) () const)
714   {
715      // Add to __propget in class and const tables.
716      rawgetfield (L, -2, "__propget");
717      rawgetfield (L, -4, "__propget");
718      typedef TG (T::*get_t) () const;
719      new (lua_newuserdata (L, sizeof (get_t))) get_t (get);
720      lua_pushcclosure (L, &CFunc::CallConstMember <get_t>::f, 1);
721      lua_pushvalue (L, -1);
722      rawsetfield (L, -4, name);
723      rawsetfield (L, -2, name);
724      lua_pop (L, 2);
732725
733      When a class is closed for modification and does not provide (or cannot
734      provide) the function signatures necessary to implement get or set for
735      a property, this will allow non-member functions act as proxies.
726      return *this;
727   }
736728
737      Both the get and the set functions require a T const* and T* in the first
738      argument respectively.
739    */
740    template <class TG, class TS>
741    Class <T>& addProperty (char const* name, TG (*get) (T const*), void (*set) (T*, TS))
742    {
743      // Add to __propget in class and const tables.
744      {
745        rawgetfield (L, -2, "__propget");
746        rawgetfield (L, -4, "__propget");
747        typedef TG (*get_t) (T const*);
748        new (lua_newuserdata (L, sizeof (get_t))) get_t (get);
749        lua_pushcclosure (L, &CFunc::Call <get_t>::f, 1);
750        lua_pushvalue (L, -1);
751        rawsetfield (L, -4, name);
752        rawsetfield (L, -2, name);
753        lua_pop (L, 2);
754      }
729   //--------------------------------------------------------------------------
730   /**
731     Add or replace a property member, by proxy.
755732
756      if (set != 0)
757      {
758        // Add to __propset in class table.
759        rawgetfield (L, -2, "__propset");
760        assert (lua_istable (L, -1));
761        typedef void (*set_t) (T*, TS);
762        new (lua_newuserdata (L, sizeof (set_t))) set_t (set);
763        lua_pushcclosure (L, &CFunc::Call <set_t>::f, 1);
764        rawsetfield (L, -2, name);
765        lua_pop (L, 1);
766      }
733     When a class is closed for modification and does not provide (or cannot
734     provide) the function signatures necessary to implement get or set for
735     a property, this will allow non-member functions act as proxies.
767736
768      return *this;
769    }
737     Both the get and the set functions require a T const* and T* in the first
738     argument respectively.
739   */
740   template <class TG, class TS>
741   Class <T>& addProperty (char const* name, TG (*get) (T const*), void (*set) (T*, TS))
742   {
743      // Add to __propget in class and const tables.
744      {
745      rawgetfield (L, -2, "__propget");
746      rawgetfield (L, -4, "__propget");
747      typedef TG (*get_t) (T const*);
748      new (lua_newuserdata (L, sizeof (get_t))) get_t (get);
749      lua_pushcclosure (L, &CFunc::Call <get_t>::f, 1);
750      lua_pushvalue (L, -1);
751      rawsetfield (L, -4, name);
752      rawsetfield (L, -2, name);
753      lua_pop (L, 2);
754      }
770755
771    // read-only
772    template <class TG, class TS>
773    Class <T>& addProperty (char const* name, TG (*get) (T const*))
774    {
775      // Add to __propget in class and const tables.
776      rawgetfield (L, -2, "__propget");
777      rawgetfield (L, -4, "__propget");
778      typedef TG (*get_t) (T const*);
779      new (lua_newuserdata (L, sizeof (get_t))) get_t (get);
780      lua_pushcclosure (L, &CFunc::Call <get_t>::f, 1);
781      lua_pushvalue (L, -1);
782      rawsetfield (L, -4, name);
783      rawsetfield (L, -2, name);
784      lua_pop (L, 2);
756      if (set != 0)
757      {
758      // Add to __propset in class table.
759      rawgetfield (L, -2, "__propset");
760      assert (lua_istable (L, -1));
761      typedef void (*set_t) (T*, TS);
762      new (lua_newuserdata (L, sizeof (set_t))) set_t (set);
763      lua_pushcclosure (L, &CFunc::Call <set_t>::f, 1);
764      rawsetfield (L, -2, name);
765      lua_pop (L, 1);
766      }
785767
786      return *this;
787    }
768      return *this;
769   }
788770
789    //--------------------------------------------------------------------------
790    /**
791        Add or replace a member function.
792    */
793    template <class MemFn>
794    Class <T>& addFunction (char const* name, MemFn mf)
795    {
796      CFunc::CallMemberFunctionHelper <MemFn, FuncTraits <MemFn>::isConstMemberFunction>::add (L, name, mf);
797      return *this;
798    }
771   // read-only
772   template <class TG, class TS>
773   Class <T>& addProperty (char const* name, TG (*get) (T const*))
774   {
775      // Add to __propget in class and const tables.
776      rawgetfield (L, -2, "__propget");
777      rawgetfield (L, -4, "__propget");
778      typedef TG (*get_t) (T const*);
779      new (lua_newuserdata (L, sizeof (get_t))) get_t (get);
780      lua_pushcclosure (L, &CFunc::Call <get_t>::f, 1);
781      lua_pushvalue (L, -1);
782      rawsetfield (L, -4, name);
783      rawsetfield (L, -2, name);
784      lua_pop (L, 2);
799785
800    //--------------------------------------------------------------------------
801    /**
802        Add or replace a member lua_CFunction.
803    */
804    Class <T>& addCFunction (char const* name, int (T::*mfp)(lua_State*))
805    {
806      typedef int (T::*MFP)(lua_State*);
807      assert (lua_istable (L, -1));
808      new (lua_newuserdata (L, sizeof (mfp))) MFP (mfp);
809      lua_pushcclosure (L, &CFunc::CallMemberCFunction <T>::f, 1);
810      rawsetfield (L, -3, name); // class table
786      return *this;
787   }
811788
812      return *this;
813    }
789   //--------------------------------------------------------------------------
790   /**
791       Add or replace a member function.
792   */
793   template <class MemFn>
794   Class <T>& addFunction (char const* name, MemFn mf)
795   {
796      CFunc::CallMemberFunctionHelper <MemFn, FuncTraits <MemFn>::isConstMemberFunction>::add (L, name, mf);
797      return *this;
798   }
814799
815    //--------------------------------------------------------------------------
816    /**
817        Add or replace a const member lua_CFunction.
818    */
819    Class <T>& addCFunction (char const* name, int (T::*mfp)(lua_State*) const)
820    {
821      typedef int (T::*MFP)(lua_State*) const;
822      assert (lua_istable (L, -1));
823      new (lua_newuserdata (L, sizeof (mfp))) MFP (mfp);
824      lua_pushcclosure (L, &CFunc::CallConstMemberCFunction <T>::f, 1);
825      lua_pushvalue (L, -1);
826      rawsetfield (L, -5, name); // const table
827      rawsetfield (L, -3, name); // class table
800   //--------------------------------------------------------------------------
801   /**
802       Add or replace a member lua_CFunction.
803   */
804   Class <T>& addCFunction (char const* name, int (T::*mfp)(lua_State*))
805   {
806      typedef int (T::*MFP)(lua_State*);
807      assert (lua_istable (L, -1));
808      new (lua_newuserdata (L, sizeof (mfp))) MFP (mfp);
809      lua_pushcclosure (L, &CFunc::CallMemberCFunction <T>::f, 1);
810      rawsetfield (L, -3, name); // class table
828811
829      return *this;
830    }
812      return *this;
813   }
831814
832    //--------------------------------------------------------------------------
833    /**
834      Add or replace a primary Constructor.
815   //--------------------------------------------------------------------------
816   /**
817       Add or replace a const member lua_CFunction.
818   */
819   Class <T>& addCFunction (char const* name, int (T::*mfp)(lua_State*) const)
820   {
821      typedef int (T::*MFP)(lua_State*) const;
822      assert (lua_istable (L, -1));
823      new (lua_newuserdata (L, sizeof (mfp))) MFP (mfp);
824      lua_pushcclosure (L, &CFunc::CallConstMemberCFunction <T>::f, 1);
825      lua_pushvalue (L, -1);
826      rawsetfield (L, -5, name); // const table
827      rawsetfield (L, -3, name); // class table
835828
836      The primary Constructor is invoked when calling the class type table
837      like a function.
829      return *this;
830   }
838831
839      The template parameter should be a function pointer type that matches
840      the desired Constructor (since you can't take the address of a Constructor
841      and pass it as an argument).
842    */
843    template <class MemFn, class C>
844    Class <T>& addConstructor ()
845    {
846      lua_pushcclosure (L,
847        &ctorContainerProxy <typename FuncTraits <MemFn>::Params, C>, 0);
848      rawsetfield(L, -2, "__call");
832   //--------------------------------------------------------------------------
833   /**
834     Add or replace a primary Constructor.
849835
850      return *this;
851    }
836     The primary Constructor is invoked when calling the class type table
837     like a function.
852838
853    template <class MemFn>
854    Class <T>& addConstructor ()
855    {
856      lua_pushcclosure (L,
857        &ctorPlacementProxy <typename FuncTraits <MemFn>::Params, T>, 0);
858      rawsetfield(L, -2, "__call");
839     The template parameter should be a function pointer type that matches
840     the desired Constructor (since you can't take the address of a Constructor
841     and pass it as an argument).
842   */
843   template <class MemFn, class C>
844   Class <T>& addConstructor ()
845   {
846      lua_pushcclosure (L,
847      &ctorContainerProxy <typename FuncTraits <MemFn>::Params, C>, 0);
848      rawsetfield(L, -2, "__call");
859849
860      return *this;
861    }
862  };
850      return *this;
851   }
863852
853   template <class MemFn>
854   Class <T>& addConstructor ()
855   {
856      lua_pushcclosure (L,
857      &ctorPlacementProxy <typename FuncTraits <MemFn>::Params, T>, 0);
858      rawsetfield(L, -2, "__call");
859
860      return *this;
861   }
862   };
863
864864private:
865  //----------------------------------------------------------------------------
866  /**
867      Open the global namespace for registrations.
868  */
869  explicit Namespace (lua_State* L_)
870    : L (L_)
871    , m_stackSize (0)
872  {
873    lua_getglobal (L, "_G");
874    ++m_stackSize;
875  }
865   //----------------------------------------------------------------------------
866   /**
867     Open the global namespace for registrations.
868   */
869   explicit Namespace (lua_State* L_)
870   : L (L_)
871   , m_stackSize (0)
872   {
873   lua_getglobal (L, "_G");
874   ++m_stackSize;
875   }
876876
877  //----------------------------------------------------------------------------
878  /**
879      Open a namespace for registrations.
877   //----------------------------------------------------------------------------
878   /**
879     Open a namespace for registrations.
880880
881      The namespace is created if it doesn't already exist.
882      The parent namespace is at the top of the Lua stack.
883  */
884  Namespace (char const* name, Namespace const* parent)
885    : L (parent->L)
886    , m_stackSize (0)
887  {
888    m_stackSize = parent->m_stackSize + 1;
889    parent->m_stackSize = 0;
881     The namespace is created if it doesn't already exist.
882     The parent namespace is at the top of the Lua stack.
883   */
884   Namespace (char const* name, Namespace const* parent)
885   : L (parent->L)
886   , m_stackSize (0)
887   {
888   m_stackSize = parent->m_stackSize + 1;
889   parent->m_stackSize = 0;
890890
891    assert (lua_istable (L, -1));
892    rawgetfield (L, -1, name);
893    if (lua_isnil (L, -1))
894    {
895      lua_pop (L, 1);
891   assert (lua_istable (L, -1));
892   rawgetfield (L, -1, name);
893   if (lua_isnil (L, -1))
894   {
895      lua_pop (L, 1);
896896
897      lua_newtable (L);
898      lua_pushvalue (L, -1);
899      lua_setmetatable (L, -2);
900      lua_pushcfunction (L, &CFunc::indexMetaMethod);
901      rawsetfield (L, -2, "__index");
902      lua_pushcfunction (L, &CFunc::newindexMetaMethod);
903      rawsetfield (L, -2, "__newindex");
904      lua_newtable (L);
905      rawsetfield (L, -2, "__propget");
906      lua_newtable (L);
907      rawsetfield (L, -2, "__propset");
908      lua_pushvalue (L, -1);
909      rawsetfield (L, -3, name);
897      lua_newtable (L);
898      lua_pushvalue (L, -1);
899      lua_setmetatable (L, -2);
900      lua_pushcfunction (L, &CFunc::indexMetaMethod);
901      rawsetfield (L, -2, "__index");
902      lua_pushcfunction (L, &CFunc::newindexMetaMethod);
903      rawsetfield (L, -2, "__newindex");
904      lua_newtable (L);
905      rawsetfield (L, -2, "__propget");
906      lua_newtable (L);
907      rawsetfield (L, -2, "__propset");
908      lua_pushvalue (L, -1);
909      rawsetfield (L, -3, name);
910910#if 0
911      lua_pushcfunction (L, &tostringMetaMethod);
912      rawsetfield (L, -2, "__tostring");
911      lua_pushcfunction (L, &tostringMetaMethod);
912      rawsetfield (L, -2, "__tostring");
913913#endif
914    }
915  }
914   }
915   }
916916
917  //----------------------------------------------------------------------------
918  /**
919      Creates a continued registration from a child namespace.
920  */
921  explicit Namespace (Namespace const* child)
922    : L (child->L)
923    , m_stackSize (0)
924  {
925    m_stackSize = child->m_stackSize - 1;
926    child->m_stackSize = 1;
927    child->pop (1);
917   //----------------------------------------------------------------------------
918   /**
919     Creates a continued registration from a child namespace.
920   */
921   explicit Namespace (Namespace const* child)
922   : L (child->L)
923   , m_stackSize (0)
924   {
925   m_stackSize = child->m_stackSize - 1;
926   child->m_stackSize = 1;
927   child->pop (1);
928928
929    // It is not necessary or valid to call
930    // endNamespace() for the global namespace!
931    //
932    assert (m_stackSize != 0);
933  }
929   // It is not necessary or valid to call
930   // endNamespace() for the global namespace!
931   //
932   assert (m_stackSize != 0);
933   }
934934
935  //----------------------------------------------------------------------------
936  /**
937      Creates a continued registration from a child class.
938  */
939  explicit Namespace (ClassBase const* child)
940    : L (child->L)
941    , m_stackSize (0)
942  {
943    m_stackSize = child->m_stackSize - 3;
944    child->m_stackSize = 3;
945    child->pop (3);
946  }
935   //----------------------------------------------------------------------------
936   /**
937     Creates a continued registration from a child class.
938   */
939   explicit Namespace (ClassBase const* child)
940   : L (child->L)
941   , m_stackSize (0)
942   {
943   m_stackSize = child->m_stackSize - 3;
944   child->m_stackSize = 3;
945   child->pop (3);
946   }
947947
948948public:
949  //----------------------------------------------------------------------------
950  /**
951      Copy Constructor.
949   //----------------------------------------------------------------------------
950   /**
951     Copy Constructor.
952952
953      Ownership of the stack is transferred to the new object. This happens
954      when the compiler emits temporaries to hold these objects while chaining
955      registrations across namespaces.
956  */
957  Namespace (Namespace const& other) : L (other.L)
958  {
959    m_stackSize = other.m_stackSize;
960    other.m_stackSize = 0;
961  }
953     Ownership of the stack is transferred to the new object. This happens
954     when the compiler emits temporaries to hold these objects while chaining
955     registrations across namespaces.
956   */
957   Namespace (Namespace const& other) : L (other.L)
958   {
959   m_stackSize = other.m_stackSize;
960   other.m_stackSize = 0;
961   }
962962
963  //----------------------------------------------------------------------------
964  /**
965      Closes this namespace registration.
966  */
967  ~Namespace ()
968  {
969    pop (m_stackSize);
970  }
963   //----------------------------------------------------------------------------
964   /**
965     Closes this namespace registration.
966   */
967   ~Namespace ()
968   {
969   pop (m_stackSize);
970   }
971971
972  //----------------------------------------------------------------------------
973  /**
974      Open the global namespace.
975  */
976  static Namespace getGlobalNamespace (lua_State* L)
977  {
978    return Namespace (L);
979  }
972   //----------------------------------------------------------------------------
973   /**
974     Open the global namespace.
975   */
976   static Namespace getGlobalNamespace (lua_State* L)
977   {
978   return Namespace (L);
979   }
980980
981  //----------------------------------------------------------------------------
982  /**
983      Open a new or existing namespace for registrations.
984  */
985  Namespace beginNamespace (char const* name)
986  {
987    return Namespace (name, this);
988  }
981   //----------------------------------------------------------------------------
982   /**
983     Open a new or existing namespace for registrations.
984   */
985   Namespace beginNamespace (char const* name)
986   {
987   return Namespace (name, this);
988   }
989989
990  //----------------------------------------------------------------------------
991  /**
992      Continue namespace registration in the parent.
990   //----------------------------------------------------------------------------
991   /**
992     Continue namespace registration in the parent.
993993
994      Do not use this on the global namespace.
995  */
996  Namespace endNamespace ()
997  {
998    return Namespace (this);
999  }
994     Do not use this on the global namespace.
995   */
996   Namespace endNamespace ()
997   {
998   return Namespace (this);
999   }
10001000
1001  //----------------------------------------------------------------------------
1002  /**
1003      Add or replace a variable.
1004  */
1005  template <class T>
1006  Namespace& addVariable (char const* name, T* pt, bool isWritable = true)
1007  {
1008    assert (lua_istable (L, -1));
1001   //----------------------------------------------------------------------------
1002   /**
1003     Add or replace a variable.
1004   */
1005   template <class T>
1006   Namespace& addVariable (char const* name, T* pt, bool isWritable = true)
1007   {
1008   assert (lua_istable (L, -1));
10091009
1010    rawgetfield (L, -1, "__propget");
1011    assert (lua_istable (L, -1));
1012    lua_pushlightuserdata (L, pt);
1013    lua_pushcclosure (L, &CFunc::getVariable <T>, 1);
1014    rawsetfield (L, -2, name);
1015    lua_pop (L, 1);
1010   rawgetfield (L, -1, "__propget");
1011   assert (lua_istable (L, -1));
1012   lua_pushlightuserdata (L, pt);
1013   lua_pushcclosure (L, &CFunc::getVariable <T>, 1);
1014   rawsetfield (L, -2, name);
1015   lua_pop (L, 1);
10161016
1017    rawgetfield (L, -1, "__propset");
1018    assert (lua_istable (L, -1));
1019    if (isWritable)
1020    {
1021      lua_pushlightuserdata (L, pt);
1022      lua_pushcclosure (L, &CFunc::setVariable <T>, 1);
1023    }
1024    else
1025    {
1026      lua_pushstring (L, name);
1027      lua_pushcclosure (L, &CFunc::readOnlyError, 1);
1028    }
1029    rawsetfield (L, -2, name);
1030    lua_pop (L, 1);
1017   rawgetfield (L, -1, "__propset");
1018   assert (lua_istable (L, -1));
1019   if (isWritable)
1020   {
1021      lua_pushlightuserdata (L, pt);
1022      lua_pushcclosure (L, &CFunc::setVariable <T>, 1);
1023   }
1024   else
1025   {
1026      lua_pushstring (L, name);
1027      lua_pushcclosure (L, &CFunc::readOnlyError, 1);
1028   }
1029   rawsetfield (L, -2, name);
1030   lua_pop (L, 1);
10311031
1032    return *this;
1033  }
1034 
1035  //----------------------------------------------------------------------------
1036  /**
1037      Add or replace a property.
1032   return *this;
1033   }
10381034
1039      If the set function is omitted or null, the property is read-only.
1040  */
1041  template <class TG, class TS>
1042  Namespace& addProperty (char const* name, TG (*get) (), void (*set)(TS) = 0)
1043  {
1044    assert (lua_istable (L, -1));
1035   //----------------------------------------------------------------------------
1036   /**
1037     Add or replace a property.
10451038
1046    rawgetfield (L, -1, "__propget");
1047    assert (lua_istable (L, -1));
1048    typedef TG (*get_t) ();
1049    new (lua_newuserdata (L, sizeof (get_t))) get_t (get);
1050    lua_pushcclosure (L, &CFunc::Call <TG (*) (void)>::f, 1);
1051    rawsetfield (L, -2, name);
1052    lua_pop (L, 1);
1039     If the set function is omitted or null, the property is read-only.
1040   */
1041   template <class TG, class TS>
1042   Namespace& addProperty (char const* name, TG (*get) (), void (*set)(TS) = 0)
1043   {
1044   assert (lua_istable (L, -1));
10531045
1054    rawgetfield (L, -1, "__propset");
1055    assert (lua_istable (L, -1));
1056    if (set != 0)
1057    {
1058      typedef void (*set_t) (TS);
1059      new (lua_newuserdata (L, sizeof (set_t))) set_t (set);
1060      lua_pushcclosure (L, &CFunc::Call <void (*) (TS)>::f, 1);
1061    }
1062    else
1063    {
1064      lua_pushstring (L, name);
1065      lua_pushcclosure (L, &CFunc::readOnlyError, 1);
1066    }
1067    rawsetfield (L, -2, name);
1068    lua_pop (L, 1);
1046   rawgetfield (L, -1, "__propget");
1047   assert (lua_istable (L, -1));
1048   typedef TG (*get_t) ();
1049   new (lua_newuserdata (L, sizeof (get_t))) get_t (get);
1050   lua_pushcclosure (L, &CFunc::Call <TG (*) (void)>::f, 1);
1051   rawsetfield (L, -2, name);
1052   lua_pop (L, 1);
10691053
1070    return *this;
1071  }
1054   rawgetfield (L, -1, "__propset");
1055   assert (lua_istable (L, -1));
1056   if (set != 0)
1057   {
1058      typedef void (*set_t) (TS);
1059      new (lua_newuserdata (L, sizeof (set_t))) set_t (set);
1060      lua_pushcclosure (L, &CFunc::Call <void (*) (TS)>::f, 1);
1061   }
1062   else
1063   {
1064      lua_pushstring (L, name);
1065      lua_pushcclosure (L, &CFunc::readOnlyError, 1);
1066   }
1067   rawsetfield (L, -2, name);
1068   lua_pop (L, 1);
10721069
1073  //----------------------------------------------------------------------------
1074  /**
1075      Add or replace a free function.
1076  */
1077  template <class FP>
1078  Namespace& addFunction (char const* name, FP const fp)
1079  {
1080    assert (lua_istable (L, -1));
1070   return *this;
1071   }
10811072
1082    new (lua_newuserdata (L, sizeof (fp))) FP (fp);
1083    lua_pushcclosure (L, &CFunc::Call <FP>::f, 1);
1084    rawsetfield (L, -2, name);
1073   //----------------------------------------------------------------------------
1074   /**
1075     Add or replace a free function.
1076   */
1077   template <class FP>
1078   Namespace& addFunction (char const* name, FP const fp)
1079   {
1080   assert (lua_istable (L, -1));
10851081
1086    return *this;
1087  }
1082   new (lua_newuserdata (L, sizeof (fp))) FP (fp);
1083   lua_pushcclosure (L, &CFunc::Call <FP>::f, 1);
1084   rawsetfield (L, -2, name);
10881085
1089  //----------------------------------------------------------------------------
1090  /**
1091      Add or replace a lua_CFunction.
1092  */
1093  Namespace& addCFunction (char const* name, int (*const fp)(lua_State*))
1094  {
1095    lua_pushcfunction (L, fp);
1096    rawsetfield (L, -2, name);
1086   return *this;
1087   }
10971088
1098    return *this;
1099  }
1089   //----------------------------------------------------------------------------
1090   /**
1091     Add or replace a lua_CFunction.
1092   */
1093   Namespace& addCFunction (char const* name, int (*const fp)(lua_State*))
1094   {
1095   lua_pushcfunction (L, fp);
1096   rawsetfield (L, -2, name);
11001097
1101  //----------------------------------------------------------------------------
1102  /**
1103      Open a new or existing class for registrations.
1104  */
1105  template <class T>
1106  Class <T> beginClass (char const* name)
1107  {
1108    return Class <T> (name, this);
1109  }
1098   return *this;
1099   }
11101100
1111  //----------------------------------------------------------------------------
1112  /**
1113      Derive a new class for registrations.
1101   //----------------------------------------------------------------------------
1102   /**
1103     Open a new or existing class for registrations.
1104   */
1105   template <class T>
1106   Class <T> beginClass (char const* name)
1107   {
1108   return Class <T> (name, this);
1109   }
11141110
1115      To continue registrations for the class later, use beginClass().
1116      Do not call deriveClass() again.
1117  */
1118  template <class T, class U>
1119  Class <T> deriveClass (char const* name)
1120  {
1121    return Class <T> (name, this, ClassInfo <U>::getStaticKey ());
1122  }
1111   //----------------------------------------------------------------------------
1112   /**
1113     Derive a new class for registrations.
1114
1115     To continue registrations for the class later, use beginClass().
1116     Do not call deriveClass() again.
1117   */
1118   template <class T, class U>
1119   Class <T> deriveClass (char const* name)
1120   {
1121   return Class <T> (name, this, ClassInfo <U>::getStaticKey ());
1122   }
11231123};
11241124
11251125//------------------------------------------------------------------------------
r31374r31375
11321132*/
11331133inline Namespace getGlobalNamespace (lua_State* L)
11341134{
1135  return Namespace::getGlobalNamespace (L);
1135   return Namespace::getGlobalNamespace (L);
11361136}
trunk/src/lib/lua/bridge/detail/TypeList.h
r31374r31375
11//------------------------------------------------------------------------------
22/*
33  https://github.com/vinniefalco/LuaBridge
4 
4
55  Copyright 2012, Vinnie Falco <vinnie.falco@gmail.com>
66  Copyright 2007, Nathan Reed
77
r31374r31375
2626  SOFTWARE.
2727
2828  This file incorporates work covered by the following copyright and
29  permission notice: 
29  permission notice:
3030
3131    The Loki Library
3232    Copyright (c) 2001 by Andrei Alexandrescu
3333    This code accompanies the book:
34    Alexandrescu, Andrei. "Modern C++ Design: Generic Programming and Design
34    Alexandrescu, Andrei. "Modern C++ Design: Generic Programming and Design
3535        Patterns Applied". Copyright (c) 2001. Addison-Wesley.
36    Permission to use, copy, modify, distribute and sell this software for any
37        purpose is hereby granted without fee, provided that the above copyright
38        notice appear in all copies and that both that copyright notice and this
36    Permission to use, copy, modify, distribute and sell this software for any
37        purpose is hereby granted without fee, provided that the above copyright
38        notice appear in all copies and that both that copyright notice and this
3939        permission notice appear in supporting documentation.
40    The author or Addison-Welsey Longman make no representations about the
41        suitability of this software for any purpose. It is provided "as is"
40    The author or Addison-Welsey Longman make no representations about the
41        suitability of this software for any purpose. It is provided "as is"
4242        without express or implied warranty.
4343*/
4444//==============================================================================
r31374r31375
5959template <typename List>
6060struct TypeListValues
6161{
62  static std::string const tostring (bool)
63  {
64    return "";
65  }
62   static std::string const tostring (bool)
63   {
64   return "";
65   }
6666};
6767
6868/**
r31374r31375
7171template <typename Head, typename Tail>
7272struct TypeListValues <TypeList <Head, Tail> >
7373{
74  Head hd;
75  TypeListValues <Tail> tl;
74   Head hd;
75   TypeListValues <Tail> tl;
7676
77  TypeListValues (Head hd_, TypeListValues <Tail> const& tl_)
78    : hd (hd_), tl (tl_)
79  {
80  }
77   TypeListValues (Head hd_, TypeListValues <Tail> const& tl_)
78   : hd (hd_), tl (tl_)
79   {
80   }
8181
82  static std::string const tostring (bool comma = false)
83  {
84    std::string s;
82   static std::string const tostring (bool comma = false)
83   {
84   std::string s;
8585
86    if (comma)
87      s = ", ";
86   if (comma)
87      s = ", ";
8888
89    s = s + typeid (Head).name ();
89   s = s + typeid (Head).name ();
9090
91    return s + TypeListValues <Tail>::tostring (true);
92  }
91   return s + TypeListValues <Tail>::tostring (true);
92   }
9393};
9494
9595// Specializations of type/value list for head types that are references and
r31374r31375
9999template <typename Head, typename Tail>
100100struct TypeListValues <TypeList <Head&, Tail> >
101101{
102  Head hd;
103  TypeListValues <Tail> tl;
102   Head hd;
103   TypeListValues <Tail> tl;
104104
105  TypeListValues (Head& hd_, TypeListValues <Tail> const& tl_)
106    : hd (hd_), tl (tl_)
107  {
108  }
105   TypeListValues (Head& hd_, TypeListValues <Tail> const& tl_)
106   : hd (hd_), tl (tl_)
107   {
108   }
109109
110  static std::string const tostring (bool comma = false)
111  {
112    std::string s;
110   static std::string const tostring (bool comma = false)
111   {
112   std::string s;
113113
114    if (comma)
115      s = ", ";
114   if (comma)
115      s = ", ";
116116
117    s = s + typeid (Head).name () + "&";
117   s = s + typeid (Head).name () + "&";
118118
119    return s + TypeListValues <Tail>::tostring (true);
120  }
119   return s + TypeListValues <Tail>::tostring (true);
120   }
121121};
122122
123123template <typename Head, typename Tail>
124124struct TypeListValues <TypeList <Head const&, Tail> >
125125{
126  Head hd;
127  TypeListValues <Tail> tl;
126   Head hd;
127   TypeListValues <Tail> tl;
128128
129  TypeListValues (Head const& hd_, const TypeListValues <Tail>& tl_)
130    : hd (hd_), tl (tl_)
131  {
132  }
129   TypeListValues (Head const& hd_, const TypeListValues <Tail>& tl_)
130   : hd (hd_), tl (tl_)
131   {
132   }
133133
134  static std::string const tostring (bool comma = false)
135  {
136    std::string s;
134   static std::string const tostring (bool comma = false)
135   {
136   std::string s;
137137
138    if (comma)
139      s = ", ";
138   if (comma)
139      s = ", ";
140140
141    s = s + typeid (Head).name () + " const&";
141   s = s + typeid (Head).name () + " const&";
142142
143    return s + TypeListValues <Tail>::tostring (true);
144  }
143   return s + TypeListValues <Tail>::tostring (true);
144   }
145145};
146146
147147//==============================================================================
r31374r31375
157157template <int Start>
158158struct ArgList <None, Start> : public TypeListValues <None>
159159{
160  ArgList (lua_State*)
161  {
162  }
160   ArgList (lua_State*)
161   {
162   }
163163};
164164
165165template <typename Head, typename Tail, int Start>
166166struct ArgList <TypeList <Head, Tail>, Start>
167  : public TypeListValues <TypeList <Head, Tail> >
167   : public TypeListValues <TypeList <Head, Tail> >
168168{
169  ArgList (lua_State* L)
170    : TypeListValues <TypeList <Head, Tail> > (Stack <Head>::get (L, Start),
171                                            ArgList <Tail, Start + 1> (L))
172  {
173  }
169   ArgList (lua_State* L)
170   : TypeListValues <TypeList <Head, Tail> > (Stack <Head>::get (L, Start),
171                                 ArgList <Tail, Start + 1> (L))
172   {
173   }
174174};
trunk/src/lib/lua/bridge/detail/LuaRef.h
r31374r31375
11//------------------------------------------------------------------------------
22/*
33  https://github.com/vinniefalco/LuaBridge
4 
4
55  Copyright 2012, Vinnie Falco <vinnie.falco@gmail.com>
66  Copyright 2008, Nigel Atkinson <suprapilot+LuaCode@gmail.com>
77
r31374r31375
5151class LuaRef
5252{
5353private:
54  class Proxy;
55  friend struct Stack <Proxy>;
54   class Proxy;
55   friend struct Stack <Proxy>;
5656
57  //----------------------------------------------------------------------------
58  /**
59      Pop the Lua stack.
57   //----------------------------------------------------------------------------
58   /**
59     Pop the Lua stack.
6060
61      Pops the specified number of stack items on destruction. We use this
62      when returning objects, to avoid an explicit temporary variable, since
63      the destructor executes after the return statement. For example:
61     Pops the specified number of stack items on destruction. We use this
62     when returning objects, to avoid an explicit temporary variable, since
63     the destructor executes after the return statement. For example:
6464
65          template <class U>
66          U cast (lua_State* L)
67          {
68            StackPop p (L, 1);
69            ...
70            return U (); // dtor called after this line
71          }
65         template <class U>
66         U cast (lua_State* L)
67         {
68           StackPop p (L, 1);
69           ...
70           return U (); // dtor called after this line
71         }
7272
73      @note The `StackPop` object must always be a named local variable.
74  */
75  class StackPop
76  {
77  public:
78    /** Create a StackPop object.
73     @note The `StackPop` object must always be a named local variable.
74   */
75   class StackPop
76   {
77   public:
78   /** Create a StackPop object.
7979
80        @param count The number of stack entries to pop on destruction.
81    */
82    StackPop (lua_State* L, int count)
83      : m_L (L)
84      , m_count (count)
85    {
86    }
80       @param count The number of stack entries to pop on destruction.
81   */
82   StackPop (lua_State* L, int count)
83      : m_L (L)
84      , m_count (count)
85   {
86   }
8787
88    ~StackPop ()
89    {
90      lua_pop (m_L, m_count);
91    }
88   ~StackPop ()
89   {
90      lua_pop (m_L, m_count);
91   }
9292
93  private:
94    lua_State* m_L;
95    int m_count;
96  };
93   private:
94   lua_State* m_L;
95   int m_count;
96   };
9797
98  //----------------------------------------------------------------------------
99  /**
100      A proxy for representing table values.
101  */
102  class Proxy
103  {
104  private:
105    lua_State* m_L;
106    int m_tableRef;
107    int m_keyRef;
98   //----------------------------------------------------------------------------
99   /**
100     A proxy for representing table values.
101   */
102   class Proxy
103   {
104   private:
105   lua_State* m_L;
106   int m_tableRef;
107   int m_keyRef;
108108
109  public:
110    //--------------------------------------------------------------------------
111    /**
112        Construct a Proxy from a table value.
109   public:
110   //--------------------------------------------------------------------------
111   /**
112       Construct a Proxy from a table value.
113113
114        The table is in the registry, and the key is at the top of the stack.
115        The key is popped off the stack.
116    */
117    Proxy (lua_State* L, int tableRef)
118      : m_L (L)
119      , m_tableRef (tableRef)
120      , m_keyRef (luaL_ref (L, LUA_REGISTRYINDEX))
121    {
122    }
114       The table is in the registry, and the key is at the top of the stack.
115       The key is popped off the stack.
116   */
117   Proxy (lua_State* L, int tableRef)
118      : m_L (L)
119      , m_tableRef (tableRef)
120      , m_keyRef (luaL_ref (L, LUA_REGISTRYINDEX))
121   {
122   }
123123
124    //--------------------------------------------------------------------------
125    /**
126        Create a Proxy via copy constructor.
124   //--------------------------------------------------------------------------
125   /**
126       Create a Proxy via copy constructor.
127127
128        It is best to avoid code paths that invoke this, because it creates
129        an extra temporary Lua reference. Typically this is done by passing
130        the Proxy parameter as a `const` reference.
131    */
132    Proxy (Proxy const& other)
133      : m_L (other.m_L)
134      , m_tableRef (other.m_tableRef)
135    {
136      // If this assert goes off it means code is taking this path,
137      // which is better avoided.
138      //
139      assert (0);
128       It is best to avoid code paths that invoke this, because it creates
129       an extra temporary Lua reference. Typically this is done by passing
130       the Proxy parameter as a `const` reference.
131   */
132   Proxy (Proxy const& other)
133      : m_L (other.m_L)
134      , m_tableRef (other.m_tableRef)
135   {
136      // If this assert goes off it means code is taking this path,
137      // which is better avoided.
138      //
139      assert (0);
140140
141      lua_rawgeti (m_L, LUA_REGISTRYINDEX, other.m_keyRef);
142      m_keyRef = luaL_ref (m_L, LUA_REGISTRYINDEX);
143    }
141      lua_rawgeti (m_L, LUA_REGISTRYINDEX, other.m_keyRef);
142      m_keyRef = luaL_ref (m_L, LUA_REGISTRYINDEX);
143   }
144144
145    //--------------------------------------------------------------------------
146    /**
147        Destroy the proxy.
145   //--------------------------------------------------------------------------
146   /**
147       Destroy the proxy.
148148
149        This does not destroy the table value.
150    */
151    ~Proxy ()
152    {
153      luaL_unref (m_L, LUA_REGISTRYINDEX, m_keyRef);
154    }
149       This does not destroy the table value.
150   */
151   ~Proxy ()
152   {
153      luaL_unref (m_L, LUA_REGISTRYINDEX, m_keyRef);
154   }
155155
156    //--------------------------------------------------------------------------
157    /**
158        Return a reference to the table value.
159    */
160    int createRef () const
161    {
162      push (m_L);
163      return luaL_ref (m_L, LUA_REGISTRYINDEX);
164    }
156   //--------------------------------------------------------------------------
157   /**
158       Return a reference to the table value.
159   */
160   int createRef () const
161   {
162      push (m_L);
163      return luaL_ref (m_L, LUA_REGISTRYINDEX);
164   }
165165
166    //--------------------------------------------------------------------------
167    /**
168        Assign a new value to this table key.
166   //--------------------------------------------------------------------------
167   /**
168       Assign a new value to this table key.
169169
170        This may invoke metamethods.
171    */
172    template <class T>
173    Proxy& operator= (T v)
174    {
175      StackPop p (m_L, 1);
176      lua_rawgeti (m_L, LUA_REGISTRYINDEX, m_tableRef);
177      lua_rawgeti (m_L, LUA_REGISTRYINDEX, m_keyRef);
178      Stack <T>::push (m_L, v);
179      lua_rawset (m_L, -3);
180      return *this;
181    }
170       This may invoke metamethods.
171   */
172   template <class T>
173   Proxy& operator= (T v)
174   {
175      StackPop p (m_L, 1);
176      lua_rawgeti (m_L, LUA_REGISTRYINDEX, m_tableRef);
177      lua_rawgeti (m_L, LUA_REGISTRYINDEX, m_keyRef);
178      Stack <T>::push (m_L, v);
179      lua_rawset (m_L, -3);
180      return *this;
181   }
182182
183    //--------------------------------------------------------------------------
184    /**
185        Assign a new value to this table key.
183   //--------------------------------------------------------------------------
184   /**
185       Assign a new value to this table key.
186186
187        The assignment is raw, no metamethods are invoked.
188    */
189    template <class T>
190    Proxy& rawset (T v)
191    {
192      StackPop p (m_L, 1);
193      lua_rawgeti (m_L, LUA_REGISTRYINDEX, m_tableRef);
194      lua_rawgeti (m_L, LUA_REGISTRYINDEX, m_keyRef);
195      Stack <T>::push (m_L, v);
196      lua_settable (m_L, -3);
197      return *this;
198    }
187       The assignment is raw, no metamethods are invoked.
188   */
189   template <class T>
190   Proxy& rawset (T v)
191   {
192      StackPop p (m_L, 1);
193      lua_rawgeti (m_L, LUA_REGISTRYINDEX, m_tableRef);
194      lua_rawgeti (m_L, LUA_REGISTRYINDEX, m_keyRef);
195      Stack <T>::push (m_L, v);
196      lua_settable (m_L, -3);
197      return *this;
198   }
199199
200    //==========================================================================
201    //
202    // This group of member functions mirrors the member functions in LuaRef.
200   //==========================================================================
201   //
202   // This group of member functions mirrors the member functions in LuaRef.
203203
204    /** Retrieve the lua_State associated with the table value.
205    */
206    lua_State* state () const
207    {
208      return m_L;
209    }
204   /** Retrieve the lua_State associated with the table value.
205   */
206   lua_State* state () const
207   {
208      return m_L;
209   }
210210
211    //--------------------------------------------------------------------------
212    /**
213        Push the value onto the Lua stack.
214    */
215    void push (lua_State* L) const
216    {
217      assert (equalstates (L, m_L));
218      lua_rawgeti (L, LUA_REGISTRYINDEX, m_tableRef);
219      lua_rawgeti (L, LUA_REGISTRYINDEX, m_keyRef);
220      lua_gettable (L, -2);
221      lua_remove (L, -2); // remove the table
222    }
211   //--------------------------------------------------------------------------
212   /**
213       Push the value onto the Lua stack.
214   */
215   void push (lua_State* L) const
216   {
217      assert (equalstates (L, m_L));
218      lua_rawgeti (L, LUA_REGISTRYINDEX, m_tableRef);
219      lua_rawgeti (L, LUA_REGISTRYINDEX, m_keyRef);
220      lua_gettable (L, -2);
221      lua_remove (L, -2); // remove the table
222   }
223223
224    //--------------------------------------------------------------------------
225    /**
226        Determine the object type.
224   //--------------------------------------------------------------------------
225   /**
226       Determine the object type.
227227
228        The return values are the same as for `lua_type`.
229    */
230    int type () const
231    {
232      int result;
233      push (m_L);
234      result = lua_type (m_L, -1);
235      lua_pop (m_L, 1);
236      return result;
237    }
228       The return values are the same as for `lua_type`.
229   */
230   int type () const
231   {
232      int result;
233      push (m_L);
234      result = lua_type (m_L, -1);
235      lua_pop (m_L, 1);
236      return result;
237   }
238238
239    inline bool isNil () const { return type () == LUA_TNIL; }
240    inline bool isNumber () const { return type () == LUA_TNUMBER; }
241    inline bool isString () const { return type () == LUA_TSTRING; }
242    inline bool isTable () const { return type () == LUA_TTABLE; }
243    inline bool isFunction () const { return type () == LUA_TFUNCTION; }
244    inline bool isUserdata () const { return type () == LUA_TUSERDATA; }
245    inline bool isThread () const { return type () == LUA_TTHREAD; }
246    inline bool isLightUserdata () const { return type () == LUA_TLIGHTUSERDATA; }
239   inline bool isNil () const { return type () == LUA_TNIL; }
240   inline bool isNumber () const { return type () == LUA_TNUMBER; }
241   inline bool isString () const { return type () == LUA_TSTRING; }
242   inline bool isTable () const { return type () == LUA_TTABLE; }
243   inline bool isFunction () const { return type () == LUA_TFUNCTION; }
244   inline bool isUserdata () const { return type () == LUA_TUSERDATA; }
245   inline bool isThread () const { return type () == LUA_TTHREAD; }
246   inline bool isLightUserdata () const { return type () == LUA_TLIGHTUSERDATA; }
247247
248    //--------------------------------------------------------------------------
249    /**
250        Perform an explicit conversion.
251    */
252    template <class T>
253    T cast () const
254    {
255      StackPop p (m_L, 1);
256      push (m_L);
248   //--------------------------------------------------------------------------
249   /**
250       Perform an explicit conversion.
251   */
252   template <class T>
253   T cast () const
254   {
255      StackPop p (m_L, 1);
256      push (m_L);
257257
258      // lua_gettop is used because Userdata::getClass() doesn't handle
259      // negative stack indexes.
260      //
261      return Stack <T>::get (m_L, lua_gettop (m_L));
262    }
258      // lua_gettop is used because Userdata::getClass() doesn't handle
259      // negative stack indexes.
260      //
261      return Stack <T>::get (m_L, lua_gettop (m_L));
262   }
263263
264    //--------------------------------------------------------------------------
265    /**
266        Universal implicit conversion operator.
264   //--------------------------------------------------------------------------
265   /**
266       Universal implicit conversion operator.
267267
268        NOTE: Visual Studio 2010 and 2012 have a bug where this function
269              is not used. See:
268       NOTE: Visual Studio 2010 and 2012 have a bug where this function
269             is not used. See:
270270
271        http://social.msdn.microsoft.com/Forums/en-US/vcgeneral/thread/e30b2664-a92d-445c-9db2-e8e0fbde2014
272        https://connect.microsoft.com/VisualStudio/feedback/details/771509/correct-code-doesnt-compile
271       http://social.msdn.microsoft.com/Forums/en-US/vcgeneral/thread/e30b2664-a92d-445c-9db2-e8e0fbde2014
272       https://connect.microsoft.com/VisualStudio/feedback/details/771509/correct-code-doesnt-compile
273273
274            // This code snippet fails to compile in vs2010,vs2012
275            struct S {
276              template <class T> inline operator T () const { return T (); }
277            };
278            int main () {
279              S () || false;
280              return 0;
281            }
282    */
283    template <class T>
284    inline operator T () const
285    {
286      return cast <T> ();
287    }
274           // This code snippet fails to compile in vs2010,vs2012
275           struct S {
276             template <class T> inline operator T () const { return T (); }
277           };
278           int main () {
279             S () || false;
280             return 0;
281           }
282   */
283   template <class T>
284   inline operator T () const
285   {
286      return cast <T> ();
287   }
288288
289    //--------------------------------------------------------------------------
290    /**
291        Universal comparison operators.
292    */
293    /** @{ */
294    template <class T>
295    bool operator== (T rhs) const
296    {
297      StackPop p (m_L, 2);
298      push (m_L);
299      Stack <T>::push (m_L, rhs);
300      return lua_compare (m_L, -2, -1, LUA_OPEQ) == 1;
301    }
289   //--------------------------------------------------------------------------
290   /**
291       Universal comparison operators.
292   */
293   /** @{ */
294   template <class T>
295   bool operator== (T rhs) const
296   {
297      StackPop p (m_L, 2);
298      push (m_L);
299      Stack <T>::push (m_L, rhs);
300      return lua_compare (m_L, -2, -1, LUA_OPEQ) == 1;
301   }
302302
303    template <class T>
304    bool operator< (T rhs) const
305    {
306      StackPop p (m_L, 2);
307      push (m_L);
308      Stack <T>::push (m_L, rhs);
309      return lua_compare (m_L, -2, -1, LUA_OPLT) == 1;
310    }
303   template <class T>
304   bool operator< (T rhs) const
305   {
306      StackPop p (m_L, 2);
307      push (m_L);
308      Stack <T>::push (m_L, rhs);
309      return lua_compare (m_L, -2, -1, LUA_OPLT) == 1;
310   }
311311
312    template <class T>
313    bool operator<= (T rhs) const
314    {
315      StackPop p (m_L, 2);
316      push (m_L);
317      Stack <T>::push (m_L, rhs);
318      return lua_compare (m_L, -2, -1, LUA_OPLE) == 1;
319    }
312   template <class T>
313   bool operator<= (T rhs) const
314   {
315      StackPop p (m_L, 2);
316      push (m_L);
317      Stack <T>::push (m_L, rhs);
318      return lua_compare (m_L, -2, -1, LUA_OPLE) == 1;
319   }
320320
321    template <class T>
322    bool operator> (T rhs) const
323    {
324      StackPop p (m_L, 2);
325      push (m_L);
326      Stack <T>::push (m_L, rhs);
327      return lua_compare (m_L, -1, -2, LUA_OPLT) == 1;
328    }
321   template <class T>
322   bool operator> (T rhs) const
323   {
324      StackPop p (m_L, 2);
325      push (m_L);
326      Stack <T>::push (m_L, rhs);
327      return lua_compare (m_L, -1, -2, LUA_OPLT) == 1;
328   }
329329
330    template <class T>
331    bool operator>= (T rhs) const
332    {
333      StackPop p (m_L, 2);
334      push (m_L);
335      Stack <T>::push (m_L, rhs);
336      return lua_compare (m_L, -1, -2, LUA_OPLE) == 1;
337    }
330   template <class T>
331   bool operator>= (T rhs) const
332   {
333      StackPop p (m_L, 2);
334      push (m_L);
335      Stack <T>::push (m_L, rhs);
336      return lua_compare (m_L, -1, -2, LUA_OPLE) == 1;
337   }
338338
339    template <class T>
340    bool rawequal (T rhs) const
341    {
342      StackPop p (m_L, 2);
343      push (m_L);
344      Stack <T>::push (m_L, rhs);
345      return lua_rawequal (m_L, -1, -2) == 1;
346    }
347    /** @} */
339   template <class T>
340   bool rawequal (T rhs) const
341   {
342      StackPop p (m_L, 2);
343      push (m_L);
344      Stack <T>::push (m_L, rhs);
345      return lua_rawequal (m_L, -1, -2) == 1;
346   }
347   /** @} */
348348
349    //--------------------------------------------------------------------------
350    /**
351        Access a table value using a key.
349   //--------------------------------------------------------------------------
350   /**
351       Access a table value using a key.
352352
353        This invokes metamethods.
354    */
355    template <class T>
356    Proxy operator[] (T key) const
357    {
358      return LuaRef (*this) [key];
359    }
353       This invokes metamethods.
354   */
355   template <class T>
356   Proxy operator[] (T key) const
357   {
358      return LuaRef (*this) [key];
359   }
360360
361    //--------------------------------------------------------------------------
362    /**
363        Access a table value using a key.
361   //--------------------------------------------------------------------------
362   /**
363       Access a table value using a key.
364364
365        The operation is raw, metamethods are not invoked. The result is
366        passed by value and may not be modified.
367    */
368    template <class T>
369    LuaRef rawget (T key) const
370    {
371      StackPop (m_L, 1);
372      push (m_L);
373      Stack <T>::push (m_L, key);
374      lua_rawget (m_L, -2);
375      return LuaRef (m_L, FromStack ());
376    }
365       The operation is raw, metamethods are not invoked. The result is
366       passed by value and may not be modified.
367   */
368   template <class T>
369   LuaRef rawget (T key) const
370   {
371      StackPop (m_L, 1);
372      push (m_L);
373      Stack <T>::push (m_L, key);
374      lua_rawget (m_L, -2);
375      return LuaRef (m_L, FromStack ());
376   }
377377
378    //--------------------------------------------------------------------------
379    /**
380        Append a value to the table.
378   //--------------------------------------------------------------------------
379   /**
380       Append a value to the table.
381381
382        If the table is a sequence this will add another element to it.
383    */
384    template <class T>
385    void append (T v) const
386    {
387      push (m_L);
388      Stack <T>::push (m_L, v);
389      luaL_ref (m_L, -2);
390      lua_pop (m_L, 1);
391    }
382       If the table is a sequence this will add another element to it.
383   */
384   template <class T>
385   void append (T v) const
386   {
387      push (m_L);
388      Stack <T>::push (m_L, v);
389      luaL_ref (m_L, -2);
390      lua_pop (m_L, 1);
391   }
392392
393    //--------------------------------------------------------------------------
394    /**
395        Call the length operator.
393   //--------------------------------------------------------------------------
394   /**
395       Call the length operator.
396396
397        This is identical to applying the Lua # operator.
398    */
399    int length () const
400    {
401      StackPop p (m_L, 1);
402      push (m_L);
403      return get_length (m_L, -1);
404    }
397       This is identical to applying the Lua # operator.
398   */
399   int length () const
400   {
401      StackPop p (m_L, 1);
402      push (m_L);
403      return get_length (m_L, -1);
404   }
405405
406    //--------------------------------------------------------------------------
407    /**
408        Call Lua code.
406   //--------------------------------------------------------------------------
407   /**
408       Call Lua code.
409409
410        These overloads allow Lua code to be called with up to 8 parameters.
411        The return value is provided as a LuaRef (which may be LUA_REFNIL).
412        If an error occurs, a LuaException is thrown.
413    */
414    /** @{ */
415    LuaRef const operator() () const
416    {
417      push (m_L);
418      LuaException::pcall (m_L, 0, 1);
419      return LuaRef (m_L, FromStack ());
420    }
410       These overloads allow Lua code to be called with up to 8 parameters.
411       The return value is provided as a LuaRef (which may be LUA_REFNIL).
412       If an error occurs, a LuaException is thrown.
413   */
414   /** @{ */
415   LuaRef const operator() () const
416   {
417      push (m_L);
418      LuaException::pcall (m_L, 0, 1);
419      return LuaRef (m_L, FromStack ());
420   }
421421
422    template <class P1>
423    LuaRef const operator() (P1 p1) const
424    {
425      push (m_L);
426      Stack <P1>::push (m_L, p1);
427      LuaException::pcall (m_L, 1, 1);
428      return LuaRef (m_L, FromStack ());
429    }
422   template <class P1>
423   LuaRef const operator() (P1 p1) const
424   {
425      push (m_L);
426      Stack <P1>::push (m_L, p1);
427      LuaException::pcall (m_L, 1, 1);
428      return LuaRef (m_L, FromStack ());
429   }
430430
431    template <class P1, class P2>
432    LuaRef const operator() (P1 p1, P2 p2) const
433    {
434      push (m_L);
435      Stack <P1>::push (m_L, p1);
436      Stack <P2>::push (m_L, p2);
437      LuaException::pcall (m_L, 2, 1);
438      return LuaRef (m_L, FromStack ());
439    }
431   template <class P1, class P2>
432   LuaRef const operator() (P1 p1, P2 p2) const
433   {
434      push (m_L);
435      Stack <P1>::push (m_L, p1);
436      Stack <P2>::push (m_L, p2);
437      LuaException::pcall (m_L, 2, 1);
438      return LuaRef (m_L, FromStack ());
439   }
440440
441    template <class P1, class P2, class P3>
442    LuaRef const operator() (P1 p1, P2 p2, P3 p3) const
443    {
444      push (m_L);
445      Stack <P1>::push (m_L, p1);
446      Stack <P2>::push (m_L, p2);
447      Stack <P3>::push (m_L, p3);
448      LuaException::pcall (m_L, 3, 1);
449      return LuaRef (m_L, FromStack ());
450    }
441   template <class P1, class P2, class P3>
442   LuaRef const operator() (P1 p1, P2 p2, P3 p3) const
443   {
444      push (m_L);
445      Stack <P1>::push (m_L, p1);
446      Stack <P2>::push (m_L, p2);
447      Stack <P3>::push (m_L, p3);
448      LuaException::pcall (m_L, 3, 1);
449      return LuaRef (m_L, FromStack ());
450   }
451451
452    template <class P1, class P2, class P3, class P4>
453    LuaRef const operator() (P1 p1, P2 p2, P3 p3, P4 p4) const
454    {
455      push (m_L);
456      Stack <P1>::push (m_L, p1);
457      Stack <P2>::push (m_L, p2);
458      Stack <P3>::push (m_L, p3);
459      Stack <P4>::push (m_L, p4);
460      LuaException::pcall (m_L, 4, 1);
461      return LuaRef (m_L, FromStack ());
462    }
452   template <class P1, class P2, class P3, class P4>
453   LuaRef const operator() (P1 p1, P2 p2, P3 p3, P4 p4) const
454   {
455      push (m_L);
456      Stack <P1>::push (m_L, p1);
457      Stack <P2>::push (m_L, p2);
458      Stack <P3>::push (m_L, p3);
459      Stack <P4>::push (m_L, p4);
460      LuaException::pcall (m_L, 4, 1);
461      return LuaRef (m_L, FromStack ());
462   }
463463
464    template <class P1, class P2, class P3, class P4, class P5>
465    LuaRef const operator() (P1 p1, P2 p2, P3 p3, P4 p4, P5 p5) const
466    {
467      push (m_L);
468      Stack <P1>::push (m_L, p1);
469      Stack <P2>::push (m_L, p2);
470      Stack <P3>::push (m_L, p3);
471      Stack <P4>::push (m_L, p4);
472      Stack <P5>::push (m_L, p5);
473      LuaException::pcall (m_L, 5, 1);
474      return LuaRef (m_L, FromStack ());
475    }
464   template <class P1, class P2, class P3, class P4, class P5>
465   LuaRef const operator() (P1 p1, P2 p2, P3 p3, P4 p4, P5 p5) const
466   {
467      push (m_L);
468      Stack <P1>::push (m_L, p1);
469      Stack <P2>::push (m_L, p2);
470      Stack <P3>::push (m_L, p3);
471      Stack <P4>::push (m_L, p4);
472      Stack <P5>::push (m_L, p5);
473      LuaException::pcall (m_L, 5, 1);
474      return LuaRef (m_L, FromStack ());
475   }
476476
477    template <class P1, class P2, class P3, class P4, class P5, class P6>
478    LuaRef const operator() (P1 p1, P2 p2, P3 p3, P4 p4, P5 p5, P6 p6) const
479    {
480      push (m_L);
481      Stack <P1>::push (m_L, p1);
482      Stack <P2>::push (m_L, p2);
483      Stack <P3>::push (m_L, p3);
484      Stack <P4>::push (m_L, p4);
485      Stack <P5>::push (m_L, p5);
486      Stack <P6>::push (m_L, p6);
487      LuaException::pcall (m_L, 6, 1);
488      return LuaRef (m_L, FromStack ());
489    }
477   template <class P1, class P2, class P3, class P4, class P5, class P6>
478   LuaRef const operator() (P1 p1, P2 p2, P3 p3, P4 p4, P5 p5, P6 p6) const
479   {
480      push (m_L);
481      Stack <P1>::push (m_L, p1);
482      Stack <P2>::push (m_L, p2);
483      Stack <P3>::push (m_L, p3);
484      Stack <P4>::push (m_L, p4);
485      Stack <P5>::push (m_L, p5);
486      Stack <P6>::push (m_L, p6);
487      LuaException::pcall (m_L, 6, 1);
488      return LuaRef (m_L, FromStack ());
489   }
490490
491    template <class P1, class P2, class P3, class P4, class P5, class P6, class P7>
492    LuaRef const operator() (P1 p1, P2 p2, P3 p3, P4 p4, P5 p5, P6 p6, P7 p7) const
493    {
494      push (m_L);
495      Stack <P1>::push (m_L, p1);
496      Stack <P2>::push (m_L, p2);
497      Stack <P3>::push (m_L, p3);
498      Stack <P4>::push (m_L, p4);
499      Stack <P5>::push (m_L, p5);
500      Stack <P6>::push (m_L, p6);
501      Stack <P7>::push (m_L, p7);
502      LuaException::pcall (m_L, 7, 1);
503      return LuaRef (m_L, FromStack ());
504    }
491   template <class P1, class P2, class P3, class P4, class P5, class P6, class P7>
492   LuaRef const operator() (P1 p1, P2 p2, P3 p3, P4 p4, P5 p5, P6 p6, P7 p7) const
493   {
494      push (m_L);
495      Stack <P1>::push (m_L, p1);
496      Stack <P2>::push (m_L, p2);
497      Stack <P3>::push (m_L, p3);
498      Stack <P4>::push (m_L, p4);
499      Stack <P5>::push (m_L, p5);
500      Stack <P6>::push (m_L, p6);
501      Stack <P7>::push (m_L, p7);
502      LuaException::pcall (m_L, 7, 1);
503      return LuaRef (m_L, FromStack ());
504   }
505505
506    template <class P1, class P2, class P3, class P4, class P5, class P6, class P7, class P8>
507    LuaRef const operator() (P1 p1, P2 p2, P3 p3, P4 p4, P5 p5, P6 p6, P7 p7, P8 p8) const
508    {
509      push (m_L);
510      Stack <P1>::push (m_L, p1);
511      Stack <P2>::push (m_L, p2);
512      Stack <P3>::push (m_L, p3);
513      Stack <P4>::push (m_L, p4);
514      Stack <P5>::push (m_L, p5);
515      Stack <P6>::push (m_L, p6);
516      Stack <P7>::push (m_L, p7);
517      Stack <P8>::push (m_L, p8);
518      LuaException::pcall (m_L, 8, 1);
519      return LuaRef (m_L, FromStack ());
520    }
521    /** @} */
506   template <class P1, class P2, class P3, class P4, class P5, class P6, class P7, class P8>
507   LuaRef const operator() (P1 p1, P2 p2, P3 p3, P4 p4, P5 p5, P6 p6, P7 p7, P8 p8) const
508   {
509      push (m_L);
510      Stack <P1>::push (m_L, p1);
511      Stack <P2>::push (m_L, p2);
512      Stack <P3>::push (m_L, p3);
513      Stack <P4>::push (m_L, p4);
514      Stack <P5>::push (m_L, p5);
515      Stack <P6>::push (m_L, p6);
516      Stack <P7>::push (m_L, p7);
517      Stack <P8>::push (m_L, p8);
518      LuaException::pcall (m_L, 8, 1);
519      return LuaRef (m_L, FromStack ());
520   }
521   /** @} */
522522
523    //==========================================================================
524  };
523   //==========================================================================
524   };
525525
526526private:
527  friend struct Stack <LuaRef>;
527   friend struct Stack <LuaRef>;
528528
529  //----------------------------------------------------------------------------
530  /**
531      Type tag for stack construction.
532  */
533  struct FromStack { };
529   //----------------------------------------------------------------------------
530   /**
531     Type tag for stack construction.
532   */
533   struct FromStack { };
534534
535  //----------------------------------------------------------------------------
536  /**
537      Create a reference to an object at the top of the Lua stack and pop it.
535   //----------------------------------------------------------------------------
536   /**
537     Create a reference to an object at the top of the Lua stack and pop it.
538538
539      This constructor is private and not invoked directly.
540      Instead, use the `fromStack` function.
539     This constructor is private and not invoked directly.
540     Instead, use the `fromStack` function.
541541
542      @note The object is popped.
543  */
544  LuaRef (lua_State* L, FromStack)
545    : m_L (L)
546  {
547    m_ref = luaL_ref (m_L, LUA_REGISTRYINDEX);
548  }
542     @note The object is popped.
543   */
544   LuaRef (lua_State* L, FromStack)
545   : m_L (L)
546   {
547   m_ref = luaL_ref (m_L, LUA_REGISTRYINDEX);
548   }
549549
550  //----------------------------------------------------------------------------
551  /**
552      Create a reference to an object on the Lua stack.
550   //----------------------------------------------------------------------------
551   /**
552     Create a reference to an object on the Lua stack.
553553
554      This constructor is private and not invoked directly.
555      Instead, use the `fromStack` function.
554     This constructor is private and not invoked directly.
555     Instead, use the `fromStack` function.
556556
557      @note The object is not popped.
558  */
559  LuaRef (lua_State* L, int index, FromStack)
560    : m_L (L)
561  {
562    lua_pushvalue (m_L, index);
563    m_ref = luaL_ref (m_L, LUA_REGISTRYINDEX);
564  }
557     @note The object is not popped.
558   */
559   LuaRef (lua_State* L, int index, FromStack)
560   : m_L (L)
561   {
562   lua_pushvalue (m_L, index);
563   m_ref = luaL_ref (m_L, LUA_REGISTRYINDEX);
564   }
565565
566  //----------------------------------------------------------------------------
566   //----------------------------------------------------------------------------
567567
568  // This type of construction is disallowed, since we don't have a `lua_State`.
569  //
570  template <class T>
571  LuaRef (T)
572  {
573  }
568   // This type of construction is disallowed, since we don't have a `lua_State`.
569   //
570   template <class T>
571   LuaRef (T)
572   {
573   }
574574
575  //----------------------------------------------------------------------------
576  /**
577      Create a reference to this ref.
575   //----------------------------------------------------------------------------
576   /**
577     Create a reference to this ref.
578578
579      This is used internally.
580  */
581  int createRef () const
582  {
583    if (m_ref != LUA_REFNIL)
584    {
585      push (m_L);
586      return luaL_ref (m_L, LUA_REGISTRYINDEX);
587    }
588    else
589    {
590      return LUA_REFNIL;
591    }
592  }
579     This is used internally.
580   */
581   int createRef () const
582   {
583   if (m_ref != LUA_REFNIL)
584   {
585      push (m_L);
586      return luaL_ref (m_L, LUA_REGISTRYINDEX);
587   }
588   else
589   {
590      return LUA_REFNIL;
591   }
592   }
593593
594594public:
595  //----------------------------------------------------------------------------
596  /**
597      Create a nil reference.
595   //----------------------------------------------------------------------------
596   /**
597     Create a nil reference.
598598
599      The LuaRef may be assigned later.
600  */
601  LuaRef (lua_State* L)
602    : m_L (L)
603    , m_ref (LUA_REFNIL)
604  {
605  }
599     The LuaRef may be assigned later.
600   */
601   LuaRef (lua_State* L)
602   : m_L (L)
603   , m_ref (LUA_REFNIL)
604   {
605   }
606606
607  //----------------------------------------------------------------------------
608  /**
609      Create a reference to a value.
610  */
611  template <class T>
612  LuaRef (lua_State* L, T v)
613    : m_L (L)
614  {
615    Stack <T>::push (m_L, v);
616    m_ref = luaL_ref (m_L, LUA_REGISTRYINDEX);
617  }
607   //----------------------------------------------------------------------------
608   /**
609     Create a reference to a value.
610   */
611   template <class T>
612   LuaRef (lua_State* L, T v)
613   : m_L (L)
614   {
615   Stack <T>::push (m_L, v);
616   m_ref = luaL_ref (m_L, LUA_REGISTRYINDEX);
617   }
618618
619  //----------------------------------------------------------------------------
620  /**
621      Create a reference to a table value.
622  */
623  LuaRef (Proxy const& v)
624    : m_L (v.state ())
625    , m_ref (v.createRef ())
626  {
627  }
619   //----------------------------------------------------------------------------
620   /**
621     Create a reference to a table value.
622   */
623   LuaRef (Proxy const& v)
624   : m_L (v.state ())
625   , m_ref (v.createRef ())
626   {
627   }
628628
629  //----------------------------------------------------------------------------
630  /**
631      Create a new reference to an existing reference.
632  */
633  LuaRef (LuaRef const& other)
634    : m_L (other.m_L)
635    , m_ref (other.createRef ())
636  {
637  }
629   //----------------------------------------------------------------------------
630   /**
631     Create a new reference to an existing reference.
632   */
633   LuaRef (LuaRef const& other)
634   : m_L (other.m_L)
635   , m_ref (other.createRef ())
636   {
637   }
638638
639  //----------------------------------------------------------------------------
640  /**
641      Destroy a reference.
639   //----------------------------------------------------------------------------
640   /**
641     Destroy a reference.
642642
643      The corresponding Lua registry reference will be released.
643     The corresponding Lua registry reference will be released.
644644
645      @note If the state refers to a thread, it is the responsibility of the
646            caller to ensure that the thread still exists when the LuaRef
647            is destroyed.
648  */
649  ~LuaRef ()
650  {
651    luaL_unref (m_L, LUA_REGISTRYINDEX, m_ref);
652  }
645     @note If the state refers to a thread, it is the responsibility of the
646           caller to ensure that the thread still exists when the LuaRef
647           is destroyed.
648   */
649   ~LuaRef ()
650   {
651   luaL_unref (m_L, LUA_REGISTRYINDEX, m_ref);
652   }
653653
654  //----------------------------------------------------------------------------
655  /**
656      Return a LuaRef from a stack item.
654   //----------------------------------------------------------------------------
655   /**
656     Return a LuaRef from a stack item.
657657
658      The stack item is not popped.
659  */
660  static LuaRef fromStack (lua_State* L, int index)
661  {
662    lua_pushvalue (L, index);
663    return LuaRef (L, FromStack ());
664  }
658     The stack item is not popped.
659   */
660   static LuaRef fromStack (lua_State* L, int index)
661   {
662   lua_pushvalue (L, index);
663   return LuaRef (L, FromStack ());
664   }
665665
666  //----------------------------------------------------------------------------
667  /**
668      Create a new empty table and return a reference to it.
666   //----------------------------------------------------------------------------
667   /**
668     Create a new empty table and return a reference to it.
669669
670      It is also possible to use the free function `newTable`.
670     It is also possible to use the free function `newTable`.
671671
672      @see ::getGlobal
673  */
674  static LuaRef newTable (lua_State* L)
675  {
676    lua_newtable (L);
677    return LuaRef (L, FromStack ());
678  }
672     @see ::getGlobal
673   */
674   static LuaRef newTable (lua_State* L)
675   {
676   lua_newtable (L);
677   return LuaRef (L, FromStack ());
678   }
679679
680  //----------------------------------------------------------------------------
681  /**
682      Return a reference to a named global.
680   //----------------------------------------------------------------------------
681   /**
682     Return a reference to a named global.
683683
684      It is also possible to use the free function `getGlobal`.
684     It is also possible to use the free function `getGlobal`.
685685
686      @see ::getGlobal
687  */
688  static LuaRef getGlobal (lua_State *L, char const* name)
689  {
690    lua_getglobal (L, name);
691    return LuaRef (L, FromStack ());
692  }
686     @see ::getGlobal
687   */
688   static LuaRef getGlobal (lua_State *L, char const* name)
689   {
690   lua_getglobal (L, name);
691   return LuaRef (L, FromStack ());
692   }
693693
694  //----------------------------------------------------------------------------
695  /**
696      Assign a different value to this LuaRef.
697  */
698  template <class T>
699  LuaRef& operator= (T rhs)
700  {
701    luaL_unref (m_L, LUA_REGISTRYINDEX, m_ref);
702    Stack <T>::push (m_L, rhs);
703    m_ref = luaL_ref (m_L, LUA_REGISTRYINDEX);
704    return *this;
705  }
694   //----------------------------------------------------------------------------
695   /**
696     Assign a different value to this LuaRef.
697   */
698   template <class T>
699   LuaRef& operator= (T rhs)
700   {
701   luaL_unref (m_L, LUA_REGISTRYINDEX, m_ref);
702   Stack <T>::push (m_L, rhs);
703   m_ref = luaL_ref (m_L, LUA_REGISTRYINDEX);
704   return *this;
705   }
706706
707  //----------------------------------------------------------------------------
708  /**
709      Assign another LuaRef to this LuaRef.
710  */
711  LuaRef& operator= (LuaRef const& rhs)
712  {
713    luaL_unref (m_L, LUA_REGISTRYINDEX, m_ref);
714    rhs.push (m_L);
715    m_L = rhs.state ();
716    m_ref = luaL_ref (m_L, LUA_REGISTRYINDEX);
717    return *this;
718  }
707   //----------------------------------------------------------------------------
708   /**
709     Assign another LuaRef to this LuaRef.
710   */
711   LuaRef& operator= (LuaRef const& rhs)
712   {
713   luaL_unref (m_L, LUA_REGISTRYINDEX, m_ref);
714   rhs.push (m_L);
715   m_L = rhs.state ();
716   m_ref = luaL_ref (m_L, LUA_REGISTRYINDEX);
717   return *this;
718   }
719719
720  //----------------------------------------------------------------------------
721  /**
722      converts to a string using luas tostring function
723  */
724  std::string tostring() const
725  {
726    lua_getglobal (m_L, "tostring");
727    push (m_L);
728    lua_call (m_L, 1, 1);
729    const char* str = lua_tostring(m_L, 1);
730    lua_pop(m_L, 1);
731    return std::string(str);
732  }
720   //----------------------------------------------------------------------------
721   /**
722     converts to a string using luas tostring function
723   */
724   std::string tostring() const
725   {
726   lua_getglobal (m_L, "tostring");
727   push (m_L);
728   lua_call (m_L, 1, 1);
729   const char* str = lua_tostring(m_L, 1);
730   lua_pop(m_L, 1);
731   return std::string(str);
732   }
733733
734  //----------------------------------------------------------------------------
735  /**
736      Print a text description of the value to a stream.
734   //----------------------------------------------------------------------------
735   /**
736     Print a text description of the value to a stream.
737737
738      This is used for diagnostics.
739  */
740  void print (std::ostream& os) const
741  {
742    switch (type ())
743    {
744    case LUA_TNIL:
745      os << "nil";
746      break;
738     This is used for diagnostics.
739   */
740   void print (std::ostream& os) const
741   {
742   switch (type ())
743   {
744   case LUA_TNIL:
745      os << "nil";
746      break;
747747
748    case LUA_TNUMBER:
749      os << cast <lua_Number> ();
750      break;
748   case LUA_TNUMBER:
749      os << cast <lua_Number> ();
750      break;
751751
752    case LUA_TBOOLEAN:
753      os << (cast <bool> () ? "true" : "false");
754      break;
752   case LUA_TBOOLEAN:
753      os << (cast <bool> () ? "true" : "false");
754      break;
755755
756    case LUA_TSTRING:
757      os << '"' << cast <std::string> () << '"';
758      break;
756   case LUA_TSTRING:
757      os << '"' << cast <std::string> () << '"';
758      break;
759759
760    case LUA_TTABLE:
761      os << "table: " << tostring();
762      break;
760   case LUA_TTABLE:
761      os << "table: " << tostring();
762      break;
763763
764    case LUA_TFUNCTION:
765      os << "function: " << tostring();
766      break;
764   case LUA_TFUNCTION:
765      os << "function: " << tostring();
766      break;
767767
768    case LUA_TUSERDATA:
769      os << "userdata: " << tostring();
770      break;
768   case LUA_TUSERDATA:
769      os << "userdata: " << tostring();
770      break;
771771
772    case LUA_TTHREAD:
773      os << "thread: " << tostring();
774      break;
772   case LUA_TTHREAD:
773      os << "thread: " << tostring();
774      break;
775775
776    case LUA_TLIGHTUSERDATA:
777      os << "lightuserdata: " << tostring();
778      break;
776   case LUA_TLIGHTUSERDATA:
777      os << "lightuserdata: " << tostring();
778      break;
779779
780    default:
781      os << "unknown";
782      break;
783    }
784  }
780   default:
781      os << "unknown";
782      break;
783   }
784   }
785785
786  //============================================================================
787  //
788  // This group of member functions is mirrored in Proxy
789  //
786   //============================================================================
787   //
788   // This group of member functions is mirrored in Proxy
789   //
790790
791  /** Retrieve the lua_State associated with the reference.
792  */
793  lua_State* state () const
794  {
795    return m_L;
796  }
791   /** Retrieve the lua_State associated with the reference.
792   */
793   lua_State* state () const
794   {
795   return m_L;
796   }
797797
798  //----------------------------------------------------------------------------
799  /**
800      Place the object onto the Lua stack.
801  */
802  void push (lua_State* L) const
803  {
804    assert (equalstates (L, m_L));
805    lua_rawgeti (L, LUA_REGISTRYINDEX, m_ref);
806  }
798   //----------------------------------------------------------------------------
799   /**
800     Place the object onto the Lua stack.
801   */
802   void push (lua_State* L) const
803   {
804   assert (equalstates (L, m_L));
805   lua_rawgeti (L, LUA_REGISTRYINDEX, m_ref);
806   }
807807
808  //----------------------------------------------------------------------------
809  /**
810      Pop the top of Lua stack and assign the ref to m_ref
811  */
812  void pop (lua_State* L)
813  {
814    assert (equalstates (L, m_L));
815    luaL_unref (m_L, LUA_REGISTRYINDEX, m_ref);
816    m_ref = luaL_ref (m_L, LUA_REGISTRYINDEX);
817  }
808   //----------------------------------------------------------------------------
809   /**
810     Pop the top of Lua stack and assign the ref to m_ref
811   */
812   void pop (lua_State* L)
813   {
814   assert (equalstates (L, m_L));
815   luaL_unref (m_L, LUA_REGISTRYINDEX, m_ref);
816   m_ref = luaL_ref (m_L, LUA_REGISTRYINDEX);
817   }
818818
819  //----------------------------------------------------------------------------
820  /**
821      Determine the object type.
819   //----------------------------------------------------------------------------
820   /**
821     Determine the object type.
822822
823      The return values are the same as for `lua_type`.
824  */
825  /** @{ */
826  int type () const
827  {
828    int result;
829    if (m_ref != LUA_REFNIL)
830    {
831      push (m_L);
832      result = lua_type (m_L, -1);
833      lua_pop (m_L, 1);
834    }
835    else
836    {
837      result = LUA_TNIL;
838    }
823     The return values are the same as for `lua_type`.
824   */
825   /** @{ */
826   int type () const
827   {
828   int result;
829   if (m_ref != LUA_REFNIL)
830   {
831      push (m_L);
832      result = lua_type (m_L, -1);
833      lua_pop (m_L, 1);
834   }
835   else
836   {
837      result = LUA_TNIL;
838   }
839839
840    return result;
841  }
840   return result;
841   }
842842
843  // should never happen
844  //inline bool isNone () const { return m_ref == LUA_NOREF; }
843   // should never happen
844   //inline bool isNone () const { return m_ref == LUA_NOREF; }
845845
846  inline bool isNil () const { return type () == LUA_TNIL; }
847  inline bool isNumber () const { return type () == LUA_TNUMBER; }
848  inline bool isString () const { return type () == LUA_TSTRING; }
849  inline bool isTable () const { return type () == LUA_TTABLE; }
850  inline bool isFunction () const { return type () == LUA_TFUNCTION; }
851  inline bool isUserdata () const { return type () == LUA_TUSERDATA; }
852  inline bool isThread () const { return type () == LUA_TTHREAD; }
853  inline bool isLightUserdata () const { return type () == LUA_TLIGHTUSERDATA; }
854  /** @} */
846   inline bool isNil () const { return type () == LUA_TNIL; }
847   inline bool isNumber () const { return type () == LUA_TNUMBER; }
848   inline bool isString () const { return type () == LUA_TSTRING; }
849   inline bool isTable () const { return type () == LUA_TTABLE; }
850   inline bool isFunction () const { return type () == LUA_TFUNCTION; }
851   inline bool isUserdata () const { return type () == LUA_TUSERDATA; }
852   inline bool isThread () const { return type () == LUA_TTHREAD; }
853   inline bool isLightUserdata () const { return type () == LUA_TLIGHTUSERDATA; }
854   /** @} */
855855
856  //----------------------------------------------------------------------------
857  /**
858      Perform an explicit conversion.
859  */
860  template <class T>
861  T cast () const
862  {
863    StackPop p (m_L, 1);
864    push (m_L);
856   //----------------------------------------------------------------------------
857   /**
858     Perform an explicit conversion.
859   */
860   template <class T>
861   T cast () const
862   {
863   StackPop p (m_L, 1);
864   push (m_L);
865865
866    // lua_gettop is used because Userdata::getClass() doesn't handle
867    // negative stack indexes.
868    //
869    return Stack <T>::get (m_L, lua_gettop (m_L));
870  }
866   // lua_gettop is used because Userdata::getClass() doesn't handle
867   // negative stack indexes.
868   //
869   return Stack <T>::get (m_L, lua_gettop (m_L));
870   }
871871
872  //----------------------------------------------------------------------------
873  /**
874      Universal implicit conversion operator.
872   //----------------------------------------------------------------------------
873   /**
874     Universal implicit conversion operator.
875875
876      NOTE: Visual Studio 2010 and 2012 have a bug where this function
877            is not used. See:
876     NOTE: Visual Studio 2010 and 2012 have a bug where this function
877           is not used. See:
878878
879      http://social.msdn.microsoft.com/Forums/en-US/vcgeneral/thread/e30b2664-a92d-445c-9db2-e8e0fbde2014
880      https://connect.microsoft.com/VisualStudio/feedback/details/771509/correct-code-doesnt-compile
879     http://social.msdn.microsoft.com/Forums/en-US/vcgeneral/thread/e30b2664-a92d-445c-9db2-e8e0fbde2014
880     https://connect.microsoft.com/VisualStudio/feedback/details/771509/correct-code-doesnt-compile
881881
882          // This code snippet fails to compile in vs2010,vs2012
883          struct S {
884            template <class T> inline operator T () const { return T (); }
885          };
886          int main () {
887            S () || false;
888            return 0;
889          }
890  */
891  template <class T>
892  inline operator T () const
893  {
894    return cast <T> ();
895  }
882         // This code snippet fails to compile in vs2010,vs2012
883         struct S {
884           template <class T> inline operator T () const { return T (); }
885         };
886         int main () {
887           S () || false;
888           return 0;
889         }
890   */
891   template <class T>
892   inline operator T () const
893   {
894   return cast <T> ();
895   }
896896
897  //----------------------------------------------------------------------------
898  /**
899      Universal comparison operators.
900  */
901  /** @{ */
902  template <class T>
903  bool operator== (T rhs) const
904  {
905    StackPop p (m_L, 2);
906    push (m_L);
907    Stack <T>::push (m_L, rhs);
908    return lua_compare (m_L, -2, -1, LUA_OPEQ) == 1;
909  }
897   //----------------------------------------------------------------------------
898   /**
899     Universal comparison operators.
900   */
901   /** @{ */
902   template <class T>
903   bool operator== (T rhs) const
904   {
905   StackPop p (m_L, 2);
906   push (m_L);
907   Stack <T>::push (m_L, rhs);
908   return lua_compare (m_L, -2, -1, LUA_OPEQ) == 1;
909   }
910910
911  template <class T>
912  bool operator< (T rhs) const
913  {
914    StackPop p (m_L, 2);
915    push (m_L);
916    Stack <T>::push (m_L, rhs);
917    return lua_compare (m_L, -2, -1, LUA_OPLT) == 1;
918  }
911   template <class T>
912   bool operator< (T rhs) const
913   {
914   StackPop p (m_L, 2);
915   push (m_L);
916   Stack <T>::push (m_L, rhs);
917   return lua_compare (m_L, -2, -1, LUA_OPLT) == 1;
918   }
919919
920  template <class T>
921  bool operator<= (T rhs) const
922  {
923    StackPop p (m_L, 2);
924    push (m_L);
925    Stack <T>::push (m_L, rhs);
926    return lua_compare (m_L, -2, -1, LUA_OPLE) == 1;
927  }
920   template <class T>
921   bool operator<= (T rhs) const
922   {
923   StackPop p (m_L, 2);
924   push (m_L);
925   Stack <T>::push (m_L, rhs);
926   return lua_compare (m_L, -2, -1, LUA_OPLE) == 1;
927   }
928928
929  template <class T>
930  bool operator> (T rhs) const
931  {
932    StackPop p (m_L, 2);
933    push (m_L);
934    Stack <T>::push (m_L, rhs);
935    return lua_compare (m_L, -1, -2, LUA_OPLT) == 1;
936  }
929   template <class T>
930   bool operator> (T rhs) const
931   {
932   StackPop p (m_L, 2);
933   push (m_L);
934   Stack <T>::push (m_L, rhs);
935   return lua_compare (m_L, -1, -2, LUA_OPLT) == 1;
936   }
937937
938  template <class T>
939  bool operator>= (T rhs) const
940  {
941    StackPop p (m_L, 2);
942    push (m_L);
943    Stack <T>::push (m_L, rhs);
944    return lua_compare (m_L, -1, -2, LUA_OPLE) == 1;
945  }
938   template <class T>
939   bool operator>= (T rhs) const
940   {
941   StackPop p (m_L, 2);
942   push (m_L);
943   Stack <T>::push (m_L, rhs);
944   return lua_compare (m_L, -1, -2, LUA_OPLE) == 1;
945   }
946946
947  template <class T>
948  bool rawequal (T rhs) const
949  {
950    StackPop p (m_L, 2);
951    push (m_L);
952    Stack <T>::push (m_L, rhs);
953    return lua_rawequal (m_L, -1, -2) == 1;
954  }
955  /** @} */
947   template <class T>
948   bool rawequal (T rhs) const
949   {
950   StackPop p (m_L, 2);
951   push (m_L);
952   Stack <T>::push (m_L, rhs);
953   return lua_rawequal (m_L, -1, -2) == 1;
954   }
955   /** @} */
956956
957  //----------------------------------------------------------------------------
958  /**
959      Append a value to the table.
957   //----------------------------------------------------------------------------
958   /**
959     Append a value to the table.
960960
961      If the table is a sequence this will add another element to it.
962  */
963  template <class T>
964  void append (T v) const
965  {
966    push (m_L);
967    Stack <T>::push (m_L, v);
968    luaL_ref (m_L, -2);
969    lua_pop (m_L, 1);
970  }
961     If the table is a sequence this will add another element to it.
962   */
963   template <class T>
964   void append (T v) const
965   {
966   push (m_L);
967   Stack <T>::push (m_L, v);
968   luaL_ref (m_L, -2);
969   lua_pop (m_L, 1);
970   }
971971
972  //----------------------------------------------------------------------------
973  /**
974      Call the length operator.
972   //----------------------------------------------------------------------------
973   /**
974     Call the length operator.
975975
976      This is identical to applying the Lua # operator.
977  */
978  int length () const
979  {
980    StackPop p (m_L, 1);
981    push (m_L);
982    return get_length (m_L, -1);
983  }
976     This is identical to applying the Lua # operator.
977   */
978   int length () const
979   {
980   StackPop p (m_L, 1);
981   push (m_L);
982   return get_length (m_L, -1);
983   }
984984
985  //----------------------------------------------------------------------------
986  /**
987      Access a table value using a key.
985   //----------------------------------------------------------------------------
986   /**
987     Access a table value using a key.
988988
989      This invokes metamethods.
990  */
991  template <class T>
992  Proxy operator[] (T key) const
993  {
994    Stack <T>::push (m_L, key);
995    return Proxy (m_L, m_ref);
996  }
989     This invokes metamethods.
990   */
991   template <class T>
992   Proxy operator[] (T key) const
993   {
994   Stack <T>::push (m_L, key);
995   return Proxy (m_L, m_ref);
996   }
997997
998  //----------------------------------------------------------------------------
999  /**
1000      Call Lua code.
998   //----------------------------------------------------------------------------
999   /**
1000     Call Lua code.
10011001
1002      These overloads allow Lua code to be called with up to 8 parameters.
1003      The return value is provided as a LuaRef (which may be LUA_REFNIL).
1004      If an error occurs, a LuaException is thrown.
1005  */
1006  /** @{ */
1007  LuaRef const operator() () const
1008  {
1009    push (m_L);
1010    LuaException::pcall (m_L, 0, 1);
1011    return LuaRef (m_L, FromStack ());
1012  }
1002     These overloads allow Lua code to be called with up to 8 parameters.
1003     The return value is provided as a LuaRef (which may be LUA_REFNIL).
1004     If an error occurs, a LuaException is thrown.
1005   */
1006   /** @{ */
1007   LuaRef const operator() () const
1008   {
1009   push (m_L);
1010   LuaException::pcall (m_L, 0, 1);
1011   return LuaRef (m_L, FromStack ());
1012   }
10131013
1014  template <class P1>
1015  LuaRef const operator() (P1 p1) const
1016  {
1017    push (m_L);
1018    Stack <P1>::push (m_L, p1);
1019    LuaException::pcall (m_L, 1, 1);
1020    return LuaRef (m_L, FromStack ());
1021  }
1014   template <class P1>
1015   LuaRef const operator() (P1 p1) const
1016   {
1017   push (m_L);
1018   Stack <P1>::push (m_L, p1);
1019   LuaException::pcall (m_L, 1, 1);
1020   return LuaRef (m_L, FromStack ());
1021   }
10221022
1023  template <class P1, class P2>
1024  LuaRef const operator() (P1 p1, P2 p2) const
1025  {
1026    push (m_L);
1027    Stack <P1>::push (m_L, p1);
1028    Stack <P2>::push (m_L, p2);
1029    LuaException::pcall (m_L, 2, 1);
1030    return LuaRef (m_L, FromStack ());
1031  }
1023   template <class P1, class P2>
1024   LuaRef const operator() (P1 p1, P2 p2) const
1025   {
1026   push (m_L);
1027   Stack <P1>::push (m_L, p1);
1028   Stack <P2>::push (m_L, p2);
1029   LuaException::pcall (m_L, 2, 1);
1030   return LuaRef (m_L, FromStack ());
1031   }
10321032
1033  template <class P1, class P2, class P3>
1034  LuaRef const operator() (P1 p1, P2 p2, P3 p3) const
1035  {
1036    push (m_L);
1037    Stack <P1>::push (m_L, p1);
1038    Stack <P2>::push (m_L, p2);
1039    Stack <P3>::push (m_L, p3);
1040    LuaException::pcall (m_L, 3, 1);
1041    return LuaRef (m_L, FromStack ());
1042  }
1033   template <class P1, class P2, class P3>
1034   LuaRef const operator() (P1 p1, P2 p2, P3 p3) const
1035   {
1036   push (m_L);
1037   Stack <P1>::push (m_L, p1);
1038   Stack <P2>::push (m_L, p2);
1039   Stack <P3>::push (m_L, p3);
1040   LuaException::pcall (m_L, 3, 1);
1041   return LuaRef (m_L, FromStack ());
1042   }
10431043
1044  template <class P1, class P2, class P3, class P4>
1045  LuaRef const operator() (P1 p1, P2 p2, P3 p3, P4 p4) const
1046  {
1047    push (m_L);
1048    Stack <P1>::push (m_L, p1);
1049    Stack <P2>::push (m_L, p2);
1050    Stack <P3>::push (m_L, p3);
1051    Stack <P4>::push (m_L, p4);
1052    LuaException::pcall (m_L, 4, 1);
1053    return LuaRef (m_L, FromStack ());
1054  }
1044   template <class P1, class P2, class P3, class P4>
1045   LuaRef const operator() (P1 p1, P2 p2, P3 p3, P4 p4) const
1046   {
1047   push (m_L);
1048   Stack <P1>::push (m_L, p1);
1049   Stack <P2>::push (m_L, p2);
1050   Stack <P3>::push (m_L, p3);
1051   Stack <P4>::push (m_L, p4);
1052   LuaException::pcall (m_L, 4, 1);
1053   return LuaRef (m_L, FromStack ());
1054   }
10551055
1056  template <class P1, class P2, class P3, class P4, class P5>
1057  LuaRef const operator() (P1 p1, P2 p2, P3 p3, P4 p4, P5 p5) const
1058  {
1059    push (m_L);
1060    Stack <P1>::push (m_L, p1);
1061    Stack <P2>::push (m_L, p2);
1062    Stack <P3>::push (m_L, p3);
1063    Stack <P4>::push (m_L, p4);
1064    Stack <P5>::push (m_L, p5);
1065    LuaException::pcall (m_L, 5, 1);
1066    return LuaRef (m_L, FromStack ());
1067  }
1056   template <class P1, class P2, class P3, class P4, class P5>
1057   LuaRef const operator() (P1 p1, P2 p2, P3 p3, P4 p4, P5 p5) const
1058   {
1059   push (m_L);
1060   Stack <P1>::push (m_L, p1);
1061   Stack <P2>::push (m_L, p2);
1062   Stack <P3>::push (m_L, p3);
1063   Stack <P4>::push (m_L, p4);
1064   Stack <P5>::push (m_L, p5);
1065   LuaException::pcall (m_L, 5, 1);
1066   return LuaRef (m_L, FromStack ());
1067   }
10681068
1069  template <class P1, class P2, class P3, class P4, class P5, class P6>
1070  LuaRef const operator() (P1 p1, P2 p2, P3 p3, P4 p4, P5 p5, P6 p6) const
1071  {
1072    push (m_L);
1073    Stack <P1>::push (m_L, p1);
1074    Stack <P2>::push (m_L, p2);
1075    Stack <P3>::push (m_L, p3);
1076    Stack <P4>::push (m_L, p4);
1077    Stack <P5>::push (m_L, p5);
1078    Stack <P6>::push (m_L, p6);
1079    LuaException::pcall (m_L, 6, 1);
1080    return LuaRef (m_L, FromStack ());
1081  }
1069   template <class P1, class P2, class P3, class P4, class P5, class P6>
1070   LuaRef const operator() (P1 p1, P2 p2, P3 p3, P4 p4, P5 p5, P6 p6) const
1071   {
1072   push (m_L);
1073   Stack <P1>::push (m_L, p1);
1074   Stack <P2>::push (m_L, p2);
1075   Stack <P3>::push (m_L, p3);
1076   Stack <P4>::push (m_L, p4);
1077   Stack <P5>::push (m_L, p5);
1078   Stack <P6>::push (m_L, p6);
1079   LuaException::pcall (m_L, 6, 1);
1080   return LuaRef (m_L, FromStack ());
1081   }
10821082
1083  template <class P1, class P2, class P3, class P4, class P5, class P6, class P7>
1084  LuaRef const operator() (P1 p1, P2 p2, P3 p3, P4 p4, P5 p5, P6 p6, P7 p7) const
1085  {
1086    push (m_L);
1087    Stack <P1>::push (m_L, p1);
1088    Stack <P2>::push (m_L, p2);
1089    Stack <P3>::push (m_L, p3);
1090    Stack <P4>::push (m_L, p4);
1091    Stack <P5>::push (m_L, p5);
1092    Stack <P6>::push (m_L, p6);
1093    Stack <P7>::push (m_L, p7);
1094    LuaException::pcall (m_L, 7, 1);
1095    return LuaRef (m_L, FromStack ());
1096  }
1083   template <class P1, class P2, class P3, class P4, class P5, class P6, class P7>
1084   LuaRef const operator() (P1 p1, P2 p2, P3 p3, P4 p4, P5 p5, P6 p6, P7 p7) const
1085   {
1086   push (m_L);
1087   Stack <P1>::push (m_L, p1);
1088   Stack <P2>::push (m_L, p2);
1089   Stack <P3>::push (m_L, p3);
1090   Stack <P4>::push (m_L, p4);
1091   Stack <P5>::push (m_L, p5);
1092   Stack <P6>::push (m_L, p6);
1093   Stack <P7>::push (m_L, p7);
1094   LuaException::pcall (m_L, 7, 1);
1095   return LuaRef (m_L, FromStack ());
1096   }
10971097
1098  template <class P1, class P2, class P3, class P4, class P5, class P6, class P7, class P8>
1099  LuaRef const operator() (P1 p1, P2 p2, P3 p3, P4 p4, P5 p5, P6 p6, P7 p7, P8 p8) const
1100  {
1101    push (m_L);
1102    Stack <P1>::push (m_L, p1);
1103    Stack <P2>::push (m_L, p2);
1104    Stack <P3>::push (m_L, p3);
1105    Stack <P4>::push (m_L, p4);
1106    Stack <P5>::push (m_L, p5);
1107    Stack <P6>::push (m_L, p6);
1108    Stack <P7>::push (m_L, p7);
1109    Stack <P8>::push (m_L, p8);
1110    LuaException::pcall (m_L, 8, 1);
1111    return LuaRef (m_L, FromStack ());
1112  }
1113  /** @} */
1098   template <class P1, class P2, class P3, class P4, class P5, class P6, class P7, class P8>
1099   LuaRef const operator() (P1 p1, P2 p2, P3 p3, P4 p4, P5 p5, P6 p6, P7 p7, P8 p8) const
1100   {
1101   push (m_L);
1102   Stack <P1>::push (m_L, p1);
1103   Stack <P2>::push (m_L, p2);
1104   Stack <P3>::push (m_L, p3);
1105   Stack <P4>::push (m_L, p4);
1106   Stack <P5>::push (m_L, p5);
1107   Stack <P6>::push (m_L, p6);
1108   Stack <P7>::push (m_L, p7);
1109   Stack <P8>::push (m_L, p8);
1110   LuaException::pcall (m_L, 8, 1);
1111   return LuaRef (m_L, FromStack ());
1112   }
1113   /** @} */
11141114
1115  //============================================================================
1115   //============================================================================
11161116
11171117private:
1118  lua_State* m_L;
1119  int m_ref;
1118   lua_State* m_L;
1119   int m_ref;
11201120};
11211121
11221122//------------------------------------------------------------------------------
r31374r31375
11271127struct Stack <Nil>
11281128{
11291129public:
1130  static inline void push (lua_State* L, Nil)
1131  {
1132    lua_pushnil (L);
1133  }
1130   static inline void push (lua_State* L, Nil)
1131   {
1132   lua_pushnil (L);
1133   }
11341134};
11351135
11361136//------------------------------------------------------------------------------
r31374r31375
11411141struct Stack <LuaRef>
11421142{
11431143public:
1144  // The value is const& to prevent a copy construction.
1145  //
1146  static inline void push (lua_State* L, LuaRef const& v)
1147  {
1148    v.push (L);
1149  }
1144   // The value is const& to prevent a copy construction.
1145   //
1146   static inline void push (lua_State* L, LuaRef const& v)
1147   {
1148   v.push (L);
1149   }
11501150
1151  static inline LuaRef get (lua_State* L, int index)
1152  {
1153    return LuaRef (L, index, LuaRef::FromStack ());
1154  }
1151   static inline LuaRef get (lua_State* L, int index)
1152   {
1153   return LuaRef (L, index, LuaRef::FromStack ());
1154   }
11551155};
11561156
11571157//------------------------------------------------------------------------------
r31374r31375
11621162struct Stack <LuaRef::Proxy>
11631163{
11641164public:
1165  // The value is const& to prevent a copy construction.
1166  //
1167  static inline void push (lua_State* L, LuaRef::Proxy const& v)
1168  {
1169    v.push (L);
1170  }
1165   // The value is const& to prevent a copy construction.
1166   //
1167   static inline void push (lua_State* L, LuaRef::Proxy const& v)
1168   {
1169   v.push (L);
1170   }
11711171};
11721172
11731173//------------------------------------------------------------------------------
r31374r31375
11781178*/
11791179inline LuaRef newTable (lua_State* L)
11801180{
1181  return LuaRef::newTable (L);
1181   return LuaRef::newTable (L);
11821182}
11831183
11841184//------------------------------------------------------------------------------
r31374r31375
11891189*/
11901190inline LuaRef getGlobal (lua_State *L, char const* name)
11911191{
1192  return LuaRef::getGlobal (L, name);
1192   return LuaRef::getGlobal (L, name);
11931193}
11941194
11951195//------------------------------------------------------------------------------
r31374r31375
12001200*/
12011201inline std::ostream& operator<< (std::ostream& os, LuaRef const& ref)
12021202{
1203  ref.print (os);
1204  return os;
1203   ref.print (os);
1204   return os;
12051205}
12061206
12071207//------------------------------------------------------------------------------
r31374r31375
12111211template<class T>
12121212inline T LuaRef_cast(LuaRef const& lr)
12131213{
1214  return lr.cast<T>();
1214   return lr.cast<T>();
12151215}
trunk/src/lib/lua/bridge/detail/LuaException.h
r31374r31375
11//------------------------------------------------------------------------------
22/*
33  https://github.com/vinniefalco/LuaBridge
4 
4
55  Copyright 2012, Vinnie Falco <vinnie.falco@gmail.com>
66  Copyright 2008, Nigel Atkinson <suprapilot+LuaCode@gmail.com>
77
r31374r31375
2727*/
2828//==============================================================================
2929
30class LuaException : public std::exception
30class LuaException : public std::exception
3131{
3232private:
33  lua_State* m_L;
34  std::string m_what;
33   lua_State* m_L;
34   std::string m_what;
3535
3636public:
37  //----------------------------------------------------------------------------
38  /**
39      Construct a LuaException after a lua_pcall().
40  */
41  LuaException (lua_State* L, int /*code*/)
42    : m_L (L)
43  {
44    whatFromStack ();
45  }
37   //----------------------------------------------------------------------------
38   /**
39     Construct a LuaException after a lua_pcall().
40   */
41   LuaException (lua_State* L, int /*code*/)
42   : m_L (L)
43   {
44   whatFromStack ();
45   }
4646
47  //----------------------------------------------------------------------------
47   //----------------------------------------------------------------------------
4848
49  LuaException (lua_State *L,
50                char const*,
51                char const*,
52                long)
53    : m_L (L)
54  {
55    whatFromStack ();
56  }
49   LuaException (lua_State *L,
50            char const*,
51            char const*,
52            long)
53   : m_L (L)
54   {
55   whatFromStack ();
56   }
5757
58  //----------------------------------------------------------------------------
58   //----------------------------------------------------------------------------
5959
60  ~LuaException() throw ()
61  {
62  }
60   ~LuaException() throw ()
61   {
62   }
6363
64  //----------------------------------------------------------------------------
64   //----------------------------------------------------------------------------
6565
66  char const* what() const throw ()
67  {
68    return m_what.c_str();
69  }
66   char const* what() const throw ()
67   {
68   return m_what.c_str();
69   }
7070
71  //============================================================================
72  /**
73      Throw an exception.
71   //============================================================================
72   /**
73     Throw an exception.
7474
75      This centralizes all the exceptions thrown, so that we can set
76      breakpoints before the stack is unwound, or otherwise customize the
77      behavior.
78  */
79  template <class Exception>
80  static void Throw (Exception e)
81  {
82    throw e;
83  }
75     This centralizes all the exceptions thrown, so that we can set
76     breakpoints before the stack is unwound, or otherwise customize the
77     behavior.
78   */
79   template <class Exception>
80   static void Throw (Exception e)
81   {
82   throw e;
83   }
8484
85  //----------------------------------------------------------------------------
86  /**
87      Wrapper for lua_pcall that throws.
88  */
89  static void pcall (lua_State* L, int nargs = 0, int nresults = 0, int msgh = 0)
90  {
91    int code = lua_pcall (L, nargs, nresults, msgh);
85   //----------------------------------------------------------------------------
86   /**
87     Wrapper for lua_pcall that throws.
88   */
89   static void pcall (lua_State* L, int nargs = 0, int nresults = 0, int msgh = 0)
90   {
91   int code = lua_pcall (L, nargs, nresults, msgh);
9292
93    if (code != LUABRIDGE_LUA_OK)
94      Throw (LuaException (L, code));
95  }
93   if (code != LUABRIDGE_LUA_OK)
94      Throw (LuaException (L, code));
95   }
9696
97  //----------------------------------------------------------------------------
97   //----------------------------------------------------------------------------
9898
9999protected:
100  void whatFromStack ()
101  {
102    if (lua_gettop (m_L) > 0)
103    {
104      char const* s = lua_tostring (m_L, -1);
105      m_what = s ? s : "";
106    }
107    else
108    {
109      // stack is empty
110      m_what = "missing error";
111    }
112  }
100   void whatFromStack ()
101   {
102   if (lua_gettop (m_L) > 0)
103   {
104      char const* s = lua_tostring (m_L, -1);
105      m_what = s ? s : "";
106   }
107   else
108   {
109      // stack is empty
110      m_what = "missing error";
111   }
112   }
113113};
trunk/src/lib/lua/bridge/detail/ClassInfo.h
r31374r31375
11//------------------------------------------------------------------------------
22/*
33  https://github.com/vinniefalco/LuaBridge
4 
4
55  Copyright 2012, Vinnie Falco <vinnie.falco@gmail.com>
66
77  License: The MIT License (http://www.opensource.org/licenses/mit-license.php)
r31374r31375
3636class ClassInfo
3737{
3838public:
39  /** Get the key for the static table.
39   /** Get the key for the static table.
4040
41      The static table holds the static data members, static properties, and
42      static member functions for a class.
43  */
44  static void const* getStaticKey ()
45  {
46    static char value;
47    return &value;
48  }
41     The static table holds the static data members, static properties, and
42     static member functions for a class.
43   */
44   static void const* getStaticKey ()
45   {
46   static char value;
47   return &value;
48   }
4949
50  /** Get the key for the class table.
50   /** Get the key for the class table.
5151
52      The class table holds the data members, properties, and member functions
53      of a class. Read-only data and properties, and const member functions are
54      also placed here (to save a lookup in the const table).
55  */
56  static void const* getClassKey ()
57  {
58    static char value;
59    return &value;
60  }
52     The class table holds the data members, properties, and member functions
53     of a class. Read-only data and properties, and const member functions are
54     also placed here (to save a lookup in the const table).
55   */
56   static void const* getClassKey ()
57   {
58   static char value;
59   return &value;
60   }
6161
62  /** Get the key for the const table.
62   /** Get the key for the const table.
6363
64      The const table holds read-only data members and properties, and const
65      member functions of a class.
66  */
67  static void const* getConstKey ()
68  {
69    static char value;
70    return &value;
71  }
64     The const table holds read-only data members and properties, and const
65     member functions of a class.
66   */
67   static void const* getConstKey ()
68   {
69   static char value;
70   return &value;
71   }
7272};
73
trunk/src/lib/lua/bridge/detail/FuncTraits.h
r31374r31375
11//------------------------------------------------------------------------------
22/*
33  https://github.com/vinniefalco/LuaBridge
4 
4
55  Copyright 2012, Vinnie Falco <vinnie.falco@gmail.com>
66
77  License: The MIT License (http://www.opensource.org/licenses/mit-license.php)
r31374r31375
3333  'noexcept' (if C++11 is available) to distinguish the functions.
3434*/
3535#if defined (__APPLE_CPP__) || defined(__APPLE_CC__) || defined(__clang__) || defined(__GNUC__) || \
36    (defined (_MSC_VER) && (_MSC_VER >= 1700))
36   (defined (_MSC_VER) && (_MSC_VER >= 1700))
3737// Do not define LUABRIDGE_THROWSPEC since the Xcode and gcc  compilers do not
3838// distinguish the throw specification in the function signature.
3939#else
r31374r31375
6464template <class R, class D>
6565struct FuncTraits <R (*) (), D>
6666{
67  static bool const isMemberFunction = false;
68  typedef D DeclType;
69  typedef R ReturnType;
70  typedef None Params;
71  static R call (D fp, TypeListValues <Params>)
72  {
73    return fp ();
74  }
67   static bool const isMemberFunction = false;
68   typedef D DeclType;
69   typedef R ReturnType;
70   typedef None Params;
71   static R call (D fp, TypeListValues <Params>)
72   {
73   return fp ();
74   }
7575};
7676
7777template <class R, class P1, class D>
7878struct FuncTraits <R (*) (P1), D>
7979{
80  static bool const isMemberFunction = false;
81  typedef D DeclType;
82  typedef R ReturnType;
83  typedef TypeList <P1> Params;
84  static R call (D fp, TypeListValues <Params> tvl)
85  {
86    return fp (tvl.hd);
87  }
80   static bool const isMemberFunction = false;
81   typedef D DeclType;
82   typedef R ReturnType;
83   typedef TypeList <P1> Params;
84   static R call (D fp, TypeListValues <Params> tvl)
85   {
86   return fp (tvl.hd);
87   }
8888};
8989
9090template <class R, class P1, class P2, class D>
9191struct FuncTraits <R (*) (P1, P2), D>
9292{
93  static bool const isMemberFunction = false;
94  typedef D DeclType;
95  typedef R ReturnType;
96  typedef TypeList <P1, TypeList <P2> > Params;
97  static R call (D fp, TypeListValues <Params> tvl)
98  {
99    return fp (tvl.hd, tvl.tl.hd);
100  }
93   static bool const isMemberFunction = false;
94   typedef D DeclType;
95   typedef R ReturnType;
96   typedef TypeList <P1, TypeList <P2> > Params;
97   static R call (D fp, TypeListValues <Params> tvl)
98   {
99   return fp (tvl.hd, tvl.tl.hd);
100   }
101101};
102102
103103template <class R, class P1, class P2, class P3, class D>
104104struct FuncTraits <R (*) (P1, P2, P3), D>
105105{
106  static bool const isMemberFunction = false;
107  typedef D DeclType;
108  typedef R ReturnType;
109  typedef TypeList <P1, TypeList <P2, TypeList <P3> > > Params;
110  static R call (D fp, TypeListValues <Params> tvl)
111  {
112    return fp (tvl.hd, tvl.tl.hd, tvl.tl.tl.hd);
113  }
106   static bool const isMemberFunction = false;
107   typedef D DeclType;
108   typedef R ReturnType;
109   typedef TypeList <P1, TypeList <P2, TypeList <P3> > > Params;
110   static R call (D fp, TypeListValues <Params> tvl)
111   {
112   return fp (tvl.hd, tvl.tl.hd, tvl.tl.tl.hd);
113   }
114114};
115115
116116template <class R, class P1, class P2, class P3, class P4, class D>
117117struct FuncTraits <R (*) (P1, P2, P3, P4), D>
118118{
119  static bool const isMemberFunction = false;
120  typedef D DeclType;
121  typedef R ReturnType;
122  typedef TypeList <P1, TypeList <P2, TypeList <P3, TypeList <P4> > > > Params;
123  static R call (D fp, TypeListValues <Params> tvl)
124  {
125    return fp (tvl.hd, tvl.tl.hd, tvl.tl.tl.hd, tvl.tl.tl.tl.hd);
126  }
119   static bool const isMemberFunction = false;
120   typedef D DeclType;
121   typedef R ReturnType;
122   typedef TypeList <P1, TypeList <P2, TypeList <P3, TypeList <P4> > > > Params;
123   static R call (D fp, TypeListValues <Params> tvl)
124   {
125   return fp (tvl.hd, tvl.tl.hd, tvl.tl.tl.hd, tvl.tl.tl.tl.hd);
126   }
127127};
128128
129129template <class R, class P1, class P2, class P3, class P4, class P5, class D>
130130struct FuncTraits <R (*) (P1, P2, P3, P4, P5), D>
131131{
132  static bool const isMemberFunction = false;
133  typedef D DeclType;
134  typedef R ReturnType;
135  typedef TypeList <P1, TypeList <P2, TypeList <P3, TypeList <P4, TypeList <P5> > > > > Params;
136  static R call (D fp, TypeListValues <Params> tvl)
137  {
138    return fp (tvl.hd, tvl.tl.hd, tvl.tl.tl.hd, tvl.tl.tl.tl.hd, tvl.tl.tl.tl.tl.hd);
139  }
132   static bool const isMemberFunction = false;
133   typedef D DeclType;
134   typedef R ReturnType;
135   typedef TypeList <P1, TypeList <P2, TypeList <P3, TypeList <P4, TypeList <P5> > > > > Params;
136   static R call (D fp, TypeListValues <Params> tvl)
137   {
138   return fp (tvl.hd, tvl.tl.hd, tvl.tl.tl.hd, tvl.tl.tl.tl.hd, tvl.tl.tl.tl.tl.hd);
139   }
140140};
141141
142142template <class R, class P1, class P2, class P3, class P4, class P5, class P6, class D>
143143struct FuncTraits <R (*) (P1, P2, P3, P4, P5, P6), D>
144144{
145  static bool const isMemberFunction = false;
146  typedef D DeclType;
147  typedef R ReturnType;
148  typedef TypeList <P1, TypeList <P2, TypeList <P3, TypeList <P4, TypeList <P5,  TypeList <P6> > > > > > Params;
149  static R call (D fp, TypeListValues <Params> tvl)
150  {
151    return fp (tvl.hd, tvl.tl.hd, tvl.tl.tl.hd, tvl.tl.tl.tl.hd, tvl.tl.tl.tl.tl.hd, tvl.tl.tl.tl.tl.tl.hd);
152  }
145   static bool const isMemberFunction = false;
146   typedef D DeclType;
147   typedef R ReturnType;
148   typedef TypeList <P1, TypeList <P2, TypeList <P3, TypeList <P4, TypeList <P5,  TypeList <P6> > > > > > Params;
149   static R call (D fp, TypeListValues <Params> tvl)
150   {
151   return fp (tvl.hd, tvl.tl.hd, tvl.tl.tl.hd, tvl.tl.tl.tl.hd, tvl.tl.tl.tl.tl.hd, tvl.tl.tl.tl.tl.tl.hd);
152   }
153153};
154154
155155template <class R, class P1, class P2, class P3, class P4, class P5, class P6, class P7, class D>
156156struct FuncTraits <R (*) (P1, P2, P3, P4, P5, P6, P7), D>
157157{
158  static bool const isMemberFunction = false;
159  typedef D DeclType;
160  typedef R ReturnType;
161  typedef TypeList <P1, TypeList <P2, TypeList <P3, TypeList <P4, TypeList <P5, TypeList <P6, TypeList <P7> > > > > > > Params;
162  static R call (D fp, TypeListValues <Params> tvl)
163  {
164    return fp (tvl.hd, tvl.tl.hd, tvl.tl.tl.hd, tvl.tl.tl.tl.hd, tvl.tl.tl.tl.tl.hd, tvl.tl.tl.tl.tl.tl.hd, tvl.tl.tl.tl.tl.tl.tl.hd);
165  }
158   static bool const isMemberFunction = false;
159   typedef D DeclType;
160   typedef R ReturnType;
161   typedef TypeList <P1, TypeList <P2, TypeList <P3, TypeList <P4, TypeList <P5, TypeList <P6, TypeList <P7> > > > > > > Params;
162   static R call (D fp, TypeListValues <Params> tvl)
163   {
164   return fp (tvl.hd, tvl.tl.hd, tvl.tl.tl.hd, tvl.tl.tl.tl.hd, tvl.tl.tl.tl.tl.hd, tvl.tl.tl.tl.tl.tl.hd, tvl.tl.tl.tl.tl.tl.tl.hd);
165   }
166166};
167167
168168template <class R, class P1, class P2, class P3, class P4, class P5, class P6, class P7, class P8, class D>
169169struct FuncTraits <R (*) (P1, P2, P3, P4, P5, P6, P7, P8), D>
170170{
171  static bool const isMemberFunction = false;
172  typedef D DeclType;
173  typedef R ReturnType;
174  typedef TypeList <P1, TypeList <P2, TypeList <P3, TypeList <P4, TypeList <P5, TypeList <P6, TypeList <P7, TypeList <P8> > > > > > > > Params;
175  static R call (D fp, TypeListValues <Params> tvl)
176  {
177    return fp (tvl.hd, tvl.tl.hd, tvl.tl.tl.hd, tvl.tl.tl.tl.hd, tvl.tl.tl.tl.tl.hd, tvl.tl.tl.tl.tl.tl.hd, tvl.tl.tl.tl.tl.tl.tl.hd, tvl.tl.tl.tl.tl.tl.tl.tl.hd);
178  }
171   static bool const isMemberFunction = false;
172   typedef D DeclType;
173   typedef R ReturnType;
174   typedef TypeList <P1, TypeList <P2, TypeList <P3, TypeList <P4, TypeList <P5, TypeList <P6, TypeList <P7, TypeList <P8> > > > > > > > Params;
175   static R call (D fp, TypeListValues <Params> tvl)
176   {
177   return fp (tvl.hd, tvl.tl.hd, tvl.tl.tl.hd, tvl.tl.tl.tl.hd, tvl.tl.tl.tl.tl.hd, tvl.tl.tl.tl.tl.tl.hd, tvl.tl.tl.tl.tl.tl.tl.hd, tvl.tl.tl.tl.tl.tl.tl.tl.hd);
178   }
179179};
180180
181181/* Non-const member function pointers. */
r31374r31375
183183template <class T, class R, class D>
184184struct FuncTraits <R (T::*) (), D>
185185{
186  static bool const isMemberFunction = true;
187  static bool const isConstMemberFunction = false;
188  typedef D DeclType;
189  typedef T ClassType;
190  typedef R ReturnType;
191  typedef None Params;
192  static R call (T* obj, D fp, TypeListValues <Params>)
193  {
194    return (obj->*fp)();
195  }
186   static bool const isMemberFunction = true;
187   static bool const isConstMemberFunction = false;
188   typedef D DeclType;
189   typedef T ClassType;
190   typedef R ReturnType;
191   typedef None Params;
192   static R call (T* obj, D fp, TypeListValues <Params>)
193   {
194   return (obj->*fp)();
195   }
196196};
197197
198198template <class T, class R, class P1, class D>
199199struct FuncTraits <R (T::*) (P1), D>
200200{
201  static bool const isMemberFunction = true;
202  static bool const isConstMemberFunction = false;
203  typedef D DeclType;
204  typedef T ClassType;
205  typedef R ReturnType;
206  typedef TypeList <P1> Params;
207  static R call (T* obj, D fp, TypeListValues <Params> tvl)
208  {
209    return (obj->*fp)(tvl.hd);
210  }
201   static bool const isMemberFunction = true;
202   static bool const isConstMemberFunction = false;
203   typedef D DeclType;
204   typedef T ClassType;
205   typedef R ReturnType;
206   typedef TypeList <P1> Params;
207   static R call (T* obj, D fp, TypeListValues <Params> tvl)
208   {
209   return (obj->*fp)(tvl.hd);
210   }
211211};
212212
213213template <class T, class R, class P1, class P2, class D>
214214struct FuncTraits <R (T::*) (P1, P2), D>
215215{
216  static bool const isMemberFunction = true;
217  static bool const isConstMemberFunction = false;
218  typedef D DeclType;
219  typedef T ClassType;
220  typedef R ReturnType;
221  typedef TypeList <P1, TypeList <P2> > Params;
222  static R call (T* obj, D fp, TypeListValues <Params> tvl)
223  {
224    return (obj->*fp)(tvl.hd, tvl.tl.hd);
225  }
216   static bool const isMemberFunction = true;
217   static bool const isConstMemberFunction = false;
218   typedef D DeclType;
219   typedef T ClassType;
220   typedef R ReturnType;
221   typedef TypeList <P1, TypeList <P2> > Params;
222   static R call (T* obj, D fp, TypeListValues <Params> tvl)
223   {
224   return (obj->*fp)(tvl.hd, tvl.tl.hd);
225   }
226226};
227227
228228template <class T, class R, class P1, class P2, class P3, class D>
229229struct FuncTraits <R (T::*) (P1, P2, P3), D>
230230{
231  static bool const isMemberFunction = true;
232  static bool const isConstMemberFunction = false;
233  typedef D DeclType;
234  typedef T ClassType;
235  typedef R ReturnType;
236  typedef TypeList <P1, TypeList <P2, TypeList <P3> > > Params;
237  static R call (T* obj, D fp, TypeListValues <Params> tvl)
238  {
239    return (obj->*fp)(tvl.hd, tvl.tl.hd, tvl.tl.tl.hd);
240  }
231   static bool const isMemberFunction = true;
232   static bool const isConstMemberFunction = false;
233   typedef D DeclType;
234   typedef T ClassType;
235   typedef R ReturnType;
236   typedef TypeList <P1, TypeList <P2, TypeList <P3> > > Params;
237   static R call (T* obj, D fp, TypeListValues <Params> tvl)
238   {
239   return (obj->*fp)(tvl.hd, tvl.tl.hd, tvl.tl.tl.hd);
240   }
241241};
242242
243243template <class T, class R, class P1, class P2, class P3, class P4, class D>
244244struct FuncTraits <R (T::*) (P1, P2, P3, P4), D>
245245{
246  static bool const isMemberFunction = true;
247  static bool const isConstMemberFunction = false;
248  typedef D DeclType;
249  typedef T ClassType;
250  typedef R ReturnType;
251  typedef TypeList <P1, TypeList <P2, TypeList <P3, TypeList <P4> > > > Params;
252  static R call (T* obj, D fp, TypeListValues <Params> tvl)
253  {
254    return (obj->*fp)(tvl.hd, tvl.tl.hd, tvl.tl.tl.hd, tvl.tl.tl.tl.hd);
255  }
246   static bool const isMemberFunction = true;
247   static bool const isConstMemberFunction = false;
248   typedef D DeclType;
249   typedef T ClassType;
250   typedef R ReturnType;
251   typedef TypeList <P1, TypeList <P2, TypeList <P3, TypeList <P4> > > > Params;
252   static R call (T* obj, D fp, TypeListValues <Params> tvl)
253   {
254   return (obj->*fp)(tvl.hd, tvl.tl.hd, tvl.tl.tl.hd, tvl.tl.tl.tl.hd);
255   }
256256};
257257
258258template <class T, class R, class P1, class P2, class P3, class P4, class P5, class D>
259259struct FuncTraits <R (T::*) (P1, P2, P3, P4, P5), D>
260260{
261  static bool const isMemberFunction = true;
262  static bool const isConstMemberFunction = false;
263  typedef D DeclType;
264  typedef T ClassType;
265  typedef R ReturnType;
266  typedef TypeList <P1, TypeList <P2, TypeList <P3, TypeList <P4, TypeList <P5> > > > > Params;
267  static R call (T* obj, D fp, TypeListValues <Params> tvl)
268  {
269    return (obj->*fp)(tvl.hd, tvl.tl.hd, tvl.tl.tl.hd, tvl.tl.tl.tl.hd, tvl.tl.tl.tl.tl.hd);
270  }
261   static bool const isMemberFunction = true;
262   static bool const isConstMemberFunction = false;
263   typedef D DeclType;
264   typedef T ClassType;
265   typedef R ReturnType;
266   typedef TypeList <P1, TypeList <P2, TypeList <P3, TypeList <P4, TypeList <P5> > > > > Params;
267   static R call (T* obj, D fp, TypeListValues <Params> tvl)
268   {
269   return (obj->*fp)(tvl.hd, tvl.tl.hd, tvl.tl.tl.hd, tvl.tl.tl.tl.hd, tvl.tl.tl.tl.tl.hd);
270   }
271271};
272272
273273template <class T, class R, class P1, class P2, class P3, class P4, class P5, class P6, class D>
274274struct FuncTraits <R (T::*) (P1, P2, P3, P4, P5, P6), D>
275275{
276  static bool const isMemberFunction = true;
277  static bool const isConstMemberFunction = false;
278  typedef D DeclType;
279  typedef T ClassType;
280  typedef R ReturnType;
281  typedef TypeList <P1, TypeList <P2, TypeList <P3, TypeList <P4, TypeList <P5, TypeList <P6> > > > > > Params;
282  static R call (T* obj, D fp, TypeListValues <Params> tvl)
283  {
284    return (obj->*fp)(tvl.hd, tvl.tl.hd, tvl.tl.tl.hd, tvl.tl.tl.tl.hd, tvl.tl.tl.tl.tl.hd, tvl.tl.tl.tl.tl.tl.hd);
285  }
276   static bool const isMemberFunction = true;
277   static bool const isConstMemberFunction = false;
278   typedef D DeclType;
279   typedef T ClassType;
280   typedef R ReturnType;
281   typedef TypeList <P1, TypeList <P2, TypeList <P3, TypeList <P4, TypeList <P5, TypeList <P6> > > > > > Params;
282   static R call (T* obj, D fp, TypeListValues <Params> tvl)
283   {
284   return (obj->*fp)(tvl.hd, tvl.tl.hd, tvl.tl.tl.hd, tvl.tl.tl.tl.hd, tvl.tl.tl.tl.tl.hd, tvl.tl.tl.tl.tl.tl.hd);
285   }
286286};
287287
288288template <class T, class R, class P1, class P2, class P3, class P4, class P5, class P6, class P7, class D>
289289struct FuncTraits <R (T::*) (P1, P2, P3, P4, P5, P6, P7), D>
290290{
291  static bool const isMemberFunction = true;
292  static bool const isConstMemberFunction = false;
293  typedef D DeclType;
294  typedef T ClassType;
295  typedef R ReturnType;
296  typedef TypeList <P1, TypeList <P2, TypeList <P3, TypeList <P4, TypeList <P5, TypeList <P6, TypeList <P7> > > > > > > Params;
297  static R call (T* obj, D fp, TypeListValues <Params> tvl)
298  {
299    return (obj->*fp)(tvl.hd, tvl.tl.hd, tvl.tl.tl.hd, tvl.tl.tl.tl.hd, tvl.tl.tl.tl.tl.hd, tvl.tl.tl.tl.tl.tl.hd, tvl.tl.tl.tl.tl.tl.tl.hd);
300  }
291   static bool const isMemberFunction = true;
292   static bool const isConstMemberFunction = false;
293   typedef D DeclType;
294   typedef T ClassType;
295   typedef R ReturnType;
296   typedef TypeList <P1, TypeList <P2, TypeList <P3, TypeList <P4, TypeList <P5, TypeList <P6, TypeList <P7> > > > > > > Params;
297   static R call (T* obj, D fp, TypeListValues <Params> tvl)
298   {
299   return (obj->*fp)(tvl.hd, tvl.tl.hd, tvl.tl.tl.hd, tvl.tl.tl.tl.hd, tvl.tl.tl.tl.tl.hd, tvl.tl.tl.tl.tl.tl.hd, tvl.tl.tl.tl.tl.tl.tl.hd);
300   }
301301};
302302
303303template <class T, class R, class P1, class P2, class P3, class P4, class P5, class P6, class P7, class P8, class D>
304304struct FuncTraits <R (T::*) (P1, P2, P3, P4, P5, P6, P7, P8), D>
305305{
306  static bool const isMemberFunction = true;
307  static bool const isConstMemberFunction = false;
308  typedef D DeclType;
309  typedef T ClassType;
310  typedef R ReturnType;
311  typedef TypeList <P1, TypeList <P2, TypeList <P3, TypeList <P4, TypeList <P5, TypeList <P6, TypeList <P7, TypeList <P8> > > > > > > > Params;
312  static R call (T* obj, D fp, TypeListValues <Params> tvl)
313  {
314    return (obj->*fp)(tvl.hd, tvl.tl.hd, tvl.tl.tl.hd, tvl.tl.tl.tl.hd, tvl.tl.tl.tl.tl.hd, tvl.tl.tl.tl.tl.tl.hd, tvl.tl.tl.tl.tl.tl.tl.hd, tvl.tl.tl.tl.tl.tl.tl.tl.hd);
315  }
306   static bool const isMemberFunction = true;
307   static bool const isConstMemberFunction = false;
308   typedef D DeclType;
309   typedef T ClassType;
310   typedef R ReturnType;
311   typedef TypeList <P1, TypeList <P2, TypeList <P3, TypeList <P4, TypeList <P5, TypeList <P6, TypeList <P7, TypeList <P8> > > > > > > > Params;
312   static R call (T* obj, D fp, TypeListValues <Params> tvl)
313   {
314   return (obj->*fp)(tvl.hd, tvl.tl.hd, tvl.tl.tl.hd, tvl.tl.tl.tl.hd, tvl.tl.tl.tl.tl.hd, tvl.tl.tl.tl.tl.tl.hd, tvl.tl.tl.tl.tl.tl.tl.hd, tvl.tl.tl.tl.tl.tl.tl.tl.hd);
315   }
316316};
317317
318318/* Const member function pointers. */
r31374r31375
320320template <class T, class R, class D>
321321struct FuncTraits <R (T::*) () const, D>
322322{
323  static bool const isMemberFunction = true;
324  static bool const isConstMemberFunction = true;
325  typedef D DeclType;
326  typedef T ClassType;
327  typedef R ReturnType;
328  typedef None Params;
329  static R call (T const* obj, D fp, TypeListValues <Params>)
330  {
331    return (obj->*fp)();
332  }
323   static bool const isMemberFunction = true;
324   static bool const isConstMemberFunction = true;
325   typedef D DeclType;
326   typedef T ClassType;
327   typedef R ReturnType;
328   typedef None Params;
329   static R call (T const* obj, D fp, TypeListValues <Params>)
330   {
331   return (obj->*fp)();
332   }
333333};
334334
335335template <class T, class R, class P1, class D>
336336struct FuncTraits <R (T::*) (P1) const, D>
337337{
338  static bool const isMemberFunction = true;
339  static bool const isConstMemberFunction = true;
340  typedef D DeclType;
341  typedef T ClassType;
342  typedef R ReturnType;
343  typedef TypeList <P1> Params;
344  static R call (T const* obj, D fp, TypeListValues <Params> tvl)
345  {
346    return (obj->*fp)(tvl.hd);
347  }
338   static bool const isMemberFunction = true;
339   static bool const isConstMemberFunction = true;
340   typedef D DeclType;
341   typedef T ClassType;
342   typedef R ReturnType;
343   typedef TypeList <P1> Params;
344   static R call (T const* obj, D fp, TypeListValues <Params> tvl)
345   {
346   return (obj->*fp)(tvl.hd);
347   }
348348};
349349
350350template <class T, class R, class P1, class P2, class D>
351351struct FuncTraits <R (T::*) (P1, P2) const, D>
352352{
353  static bool const isMemberFunction = true;
354  static bool const isConstMemberFunction = true;
355  typedef D DeclType;
356  typedef T ClassType;
357  typedef R ReturnType;
358  typedef TypeList <P1, TypeList <P2> > Params;
359  static R call (T const* obj, R (T::*fp) (P1, P2) const,
360    TypeListValues <Params> tvl)
361  {
362    return (obj->*fp)(tvl.hd, tvl.tl.hd);
363  }
353   static bool const isMemberFunction = true;
354   static bool const isConstMemberFunction = true;
355   typedef D DeclType;
356   typedef T ClassType;
357   typedef R ReturnType;
358   typedef TypeList <P1, TypeList <P2> > Params;
359   static R call (T const* obj, R (T::*fp) (P1, P2) const,
360   TypeListValues <Params> tvl)
361   {
362   return (obj->*fp)(tvl.hd, tvl.tl.hd);
363   }
364364};
365365
366366template <class T, class R, class P1, class P2, class P3, class D>
367367struct FuncTraits <R (T::*) (P1, P2, P3) const, D>
368368{
369  static bool const isMemberFunction = true;
370  static bool const isConstMemberFunction = true;
371  typedef D DeclType;
372  typedef T ClassType;
373  typedef R ReturnType;
374  typedef TypeList <P1, TypeList <P2, TypeList <P3> > > Params;
375  static R call (T const* obj, D fp, TypeListValues <Params> tvl)
376  {
377    return (obj->*fp)(tvl.hd, tvl.tl.hd, tvl.tl.tl.hd);
378  }
369   static bool const isMemberFunction = true;
370   static bool const isConstMemberFunction = true;
371   typedef D DeclType;
372   typedef T ClassType;
373   typedef R ReturnType;
374   typedef TypeList <P1, TypeList <P2, TypeList <P3> > > Params;
375   static R call (T const* obj, D fp, TypeListValues <Params> tvl)
376   {
377   return (obj->*fp)(tvl.hd, tvl.tl.hd, tvl.tl.tl.hd);
378   }
379379};
380380
381381template <class T, class R, class P1, class P2, class P3, class P4, class D>
382382struct FuncTraits <R (T::*) (P1, P2, P3, P4) const, D>
383383{
384  static bool const isMemberFunction = true;
385  static bool const isConstMemberFunction = true;
386  typedef D DeclType;
387  typedef T ClassType;
388  typedef R ReturnType;
389  typedef TypeList <P1, TypeList <P2, TypeList <P3, TypeList <P4> > > > Params;
390  static R call (T const* obj, D fp, TypeListValues <Params> tvl)
391  {
392    return (obj->*fp)(tvl.hd, tvl.tl.hd, tvl.tl.tl.hd, tvl.tl.tl.tl.hd);
393  }
384   static bool const isMemberFunction = true;
385   static bool const isConstMemberFunction = true;
386   typedef D DeclType;
387   typedef T ClassType;
388   typedef R ReturnType;
389   typedef TypeList <P1, TypeList <P2, TypeList <P3, TypeList <P4> > > > Params;
390   static R call (T const* obj, D fp, TypeListValues <Params> tvl)
391   {
392   return (obj->*fp)(tvl.hd, tvl.tl.hd, tvl.tl.tl.hd, tvl.tl.tl.tl.hd);
393   }
394394};
395395
396396template <class T, class R, class P1, class P2, class P3, class P4, class P5, class D>
397397struct FuncTraits <R (T::*) (P1, P2, P3, P4, P5) const, D>
398398{
399  static bool const isMemberFunction = true;
400  static bool const isConstMemberFunction = true;
401  typedef D DeclType;
402  typedef T ClassType;
403  typedef R ReturnType;
404  typedef TypeList <P1, TypeList <P2, TypeList <P3, TypeList <P4, TypeList <P5> > > > > Params;
405  static R call (T const* obj, D fp, TypeListValues <Params> tvl)
406  {
407    return (obj->*fp)(tvl.hd, tvl.tl.hd, tvl.tl.tl.hd, tvl.tl.tl.tl.hd, tvl.tl.tl.tl.tl.hd);
408  }
399   static bool const isMemberFunction = true;
400   static bool const isConstMemberFunction = true;
401   typedef D DeclType;
402   typedef T ClassType;
403   typedef R ReturnType;
404   typedef TypeList <P1, TypeList <P2, TypeList <P3, TypeList <P4, TypeList <P5> > > > > Params;
405   static R call (T const* obj, D fp, TypeListValues <Params> tvl)
406   {
407   return (obj->*fp)(tvl.hd, tvl.tl.hd, tvl.tl.tl.hd, tvl.tl.tl.tl.hd, tvl.tl.tl.tl.tl.hd);
408   }
409409};
410410
411411template <class T, class R, class P1, class P2, class P3, class P4, class P5, class P6, class D>
412412struct FuncTraits <R (T::*) (P1, P2, P3, P4, P5, P6) const, D>
413413{
414  static bool const isMemberFunction = true;
415  static bool const isConstMemberFunction = true;
416  typedef D DeclType;
417  typedef T ClassType;
418  typedef R ReturnType;
419  typedef TypeList <P1, TypeList <P2, TypeList <P3, TypeList <P4, TypeList <P5, TypeList <P6> > > > > > Params;
420  static R call (T const* obj, D fp, TypeListValues <Params> tvl)
421  {
422    return (obj->*fp)(tvl.hd, tvl.tl.hd, tvl.tl.tl.hd, tvl.tl.tl.tl.hd, tvl.tl.tl.tl.tl.hd, tvl.tl.tl.tl.tl.tl.hd);
423  }
414   static bool const isMemberFunction = true;
415   static bool const isConstMemberFunction = true;
416   typedef D DeclType;
417   typedef T ClassType;
418   typedef R ReturnType;
419   typedef TypeList <P1, TypeList <P2, TypeList <P3, TypeList <P4, TypeList <P5, TypeList <P6> > > > > > Params;
420   static R call (T const* obj, D fp, TypeListValues <Params> tvl)
421   {
422   return (obj->*fp)(tvl.hd, tvl.tl.hd, tvl.tl.tl.hd, tvl.tl.tl.tl.hd, tvl.tl.tl.tl.tl.hd, tvl.tl.tl.tl.tl.tl.hd);
423   }
424424};
425425
426426template <class T, class R, class P1, class P2, class P3, class P4, class P5, class P6, class P7, class D>
427427struct FuncTraits <R (T::*) (P1, P2, P3, P4, P5, P6, P7) const, D>
428428{
429  static bool const isMemberFunction = true;
430  static bool const isConstMemberFunction = true;
431  typedef D DeclType;
432  typedef T ClassType;
433  typedef R ReturnType;
434  typedef TypeList <P1, TypeList <P2, TypeList <P3, TypeList <P4, TypeList <P5, TypeList <P6, TypeList <P7> > > > > > > Params;
435  static R call (T const* obj, D fp, TypeListValues <Params> tvl)
436  {
437    return (obj->*fp)(tvl.hd, tvl.tl.hd, tvl.tl.tl.hd, tvl.tl.tl.tl.hd, tvl.tl.tl.tl.tl.hd, tvl.tl.tl.tl.tl.tl.hd, tvl.tl.tl.tl.tl.tl.tl.hd);
438  }
429   static bool const isMemberFunction = true;
430   static bool const isConstMemberFunction = true;
431   typedef D DeclType;
432   typedef T ClassType;
433   typedef R ReturnType;
434   typedef TypeList <P1, TypeList <P2, TypeList <P3, TypeList <P4, TypeList <P5, TypeList <P6, TypeList <P7> > > > > > > Params;
435   static R call (T const* obj, D fp, TypeListValues <Params> tvl)
436   {
437   return (obj->*fp)(tvl.hd, tvl.tl.hd, tvl.tl.tl.hd, tvl.tl.tl.tl.hd, tvl.tl.tl.tl.tl.hd, tvl.tl.tl.tl.tl.tl.hd, tvl.tl.tl.tl.tl.tl.tl.hd);
438   }
439439};
440440
441441template <class T, class R, class P1, class P2, class P3, class P4, class P5, class P6, class P7, class P8, class D>
442442struct FuncTraits <R (T::*) (P1, P2, P3, P4, P5, P6, P7, P8) const, D>
443443{
444  static bool const isMemberFunction = true;
445  static bool const isConstMemberFunction = true;
446  typedef D DeclType;
447  typedef T ClassType;
448  typedef R ReturnType;
449  typedef TypeList <P1, TypeList <P2, TypeList <P3, TypeList <P4, TypeList <P5, TypeList <P6, TypeList <P7, TypeList <P8> > > > > > > > Params;
450  static R call (T const* obj, D fp, TypeListValues <Params> tvl)
451  {
452    return (obj->*fp)(tvl.hd, tvl.tl.hd, tvl.tl.tl.hd, tvl.tl.tl.tl.hd, tvl.tl.tl.tl.tl.hd, tvl.tl.tl.tl.tl.tl.hd, tvl.tl.tl.tl.tl.tl.tl.hd, tvl.tl.tl.tl.tl.tl.tl.tl.hd);
453  }
444   static bool const isMemberFunction = true;
445   static bool const isConstMemberFunction = true;
446   typedef D DeclType;
447   typedef T ClassType;
448   typedef R ReturnType;
449   typedef TypeList <P1, TypeList <P2, TypeList <P3, TypeList <P4, TypeList <P5, TypeList <P6, TypeList <P7, TypeList <P8> > > > > > > > Params;
450   static R call (T const* obj, D fp, TypeListValues <Params> tvl)
451   {
452   return (obj->*fp)(tvl.hd, tvl.tl.hd, tvl.tl.tl.hd, tvl.tl.tl.tl.hd, tvl.tl.tl.tl.tl.hd, tvl.tl.tl.tl.tl.tl.hd, tvl.tl.tl.tl.tl.tl.tl.hd, tvl.tl.tl.tl.tl.tl.tl.tl.hd);
453   }
454454};
455455
456456#if defined (LUABRIDGE_THROWSPEC)
r31374r31375
460460template <class R, class D>
461461struct FuncTraits <R (*) () LUABRIDGE_THROWSPEC, D>
462462{
463  static bool const isMemberFunction = false;
464  typedef D DeclType;
465  typedef R ReturnType;
466  typedef None Params;
467  static R call (D fp, TypeListValues <Params> const&)
468  {
469    return fp ();
470  }
463   static bool const isMemberFunction = false;
464   typedef D DeclType;
465   typedef R ReturnType;
466   typedef None Params;
467   static R call (D fp, TypeListValues <Params> const&)
468   {
469   return fp ();
470   }
471471};
472472
473473template <class R, class P1, class D>
474474struct FuncTraits <R (*) (P1) LUABRIDGE_THROWSPEC, D>
475475{
476  static bool const isMemberFunction = false;
477  typedef D DeclType;
478  typedef R ReturnType;
479  typedef TypeList <P1> Params;
480  static R call (D fp, TypeListValues <Params> tvl)
481  {
482    return fp (tvl.hd);
483  }
476   static bool const isMemberFunction = false;
477   typedef D DeclType;
478   typedef R ReturnType;
479   typedef TypeList <P1> Params;
480   static R call (D fp, TypeListValues <Params> tvl)
481   {
482   return fp (tvl.hd);
483   }
484484};
485485
486486template <class R, class P1, class P2, class D>
487487struct FuncTraits <R (*) (P1, P2) LUABRIDGE_THROWSPEC, D>
488488{
489  static bool const isMemberFunction = false;
490  typedef D DeclType;
491  typedef R ReturnType;
492  typedef TypeList <P1, TypeList <P2> > Params;
493  static R call (D fp, TypeListValues <Params> tvl)
494  {
495    return fp (tvl.hd, tvl.tl.hd);
496  }
489   static bool const isMemberFunction = false;
490   typedef D DeclType;
491   typedef R ReturnType;
492   typedef TypeList <P1, TypeList <P2> > Params;
493   static R call (D fp, TypeListValues <Params> tvl)
494   {
495   return fp (tvl.hd, tvl.tl.hd);
496   }
497497};
498498
499499template <class R, class P1, class P2, class P3, class D>
500500struct FuncTraits <R (*) (P1, P2, P3) LUABRIDGE_THROWSPEC, D>
501501{
502  static bool const isMemberFunction = false;
503  typedef D DeclType;
504  typedef R ReturnType;
505  typedef TypeList <P1, TypeList <P2, TypeList <P3> > > Params;
506  static R call (D fp, TypeListValues <Params> tvl)
507  {
508    return fp (tvl.hd, tvl.tl.hd, tvl.tl.tl.hd);
509  }
502   static bool const isMemberFunction = false;
503   typedef D DeclType;
504   typedef R ReturnType;
505   typedef TypeList <P1, TypeList <P2, TypeList <P3> > > Params;
506   static R call (D fp, TypeListValues <Params> tvl)
507   {
508   return fp (tvl.hd, tvl.tl.hd, tvl.tl.tl.hd);
509   }
510510};
511511
512512template <class R, class P1, class P2, class P3, class P4, class D>
513513struct FuncTraits <R (*) (P1, P2, P3, P4) LUABRIDGE_THROWSPEC, D>
514514{
515  static bool const isMemberFunction = false;
516  typedef D DeclType;
517  typedef R ReturnType;
518  typedef TypeList <P1, TypeList <P2, TypeList <P3, TypeList <P4> > > > Params;
519  static R call (D fp, TypeListValues <Params> tvl)
520  {
521    return fp (tvl.hd, tvl.tl.hd, tvl.tl.tl.hd, tvl.tl.tl.tl.hd);
522  }
515   static bool const isMemberFunction = false;
516   typedef D DeclType;
517   typedef R ReturnType;
518   typedef TypeList <P1, TypeList <P2, TypeList <P3, TypeList <P4> > > > Params;
519   static R call (D fp, TypeListValues <Params> tvl)
520   {
521   return fp (tvl.hd, tvl.tl.hd, tvl.tl.tl.hd, tvl.tl.tl.tl.hd);
522   }
523523};
524524
525525template <class R, class P1, class P2, class P3, class P4, class P5, class D>
526526struct FuncTraits <R (*) (P1, P2, P3, P4, P5) LUABRIDGE_THROWSPEC, D>
527527{
528  static bool const isMemberFunction = false;
529  typedef D DeclType;
530  typedef R ReturnType;
531  typedef TypeList <P1, TypeList <P2, TypeList <P3, TypeList <P4, TypeList <P5> > > > > Params;
532  static R call (D fp, TypeListValues <Params> tvl)
533  {
534    return fp (tvl.hd, tvl.tl.hd, tvl.tl.tl.hd, tvl.tl.tl.tl.hd, tvl.tl.tl.tl.tl.hd);
535  }
528   static bool const isMemberFunction = false;
529   typedef D DeclType;
530   typedef R ReturnType;
531   typedef TypeList <P1, TypeList <P2, TypeList <P3, TypeList <P4, TypeList <P5> > > > > Params;
532   static R call (D fp, TypeListValues <Params> tvl)
533   {
534   return fp (tvl.hd, tvl.tl.hd, tvl.tl.tl.hd, tvl.tl.tl.tl.hd, tvl.tl.tl.tl.tl.hd);
535   }
536536};
537537
538538template <class R, class P1, class P2, class P3, class P4, class P5, class P6, class D>
539539struct FuncTraits <R (*) (P1, P2, P3, P4, P5, P6) LUABRIDGE_THROWSPEC, D>
540540{
541  static bool const isMemberFunction = false;
542  typedef D DeclType;
543  typedef R ReturnType;
544  typedef TypeList <P1, TypeList <P2, TypeList <P3, TypeList <P4, TypeList <P5,  TypeList <P6> > > > > > Params;
545  static R call (D fp, TypeListValues <Params> tvl)
546  {
547    return fp (tvl.hd, tvl.tl.hd, tvl.tl.tl.hd, tvl.tl.tl.tl.hd, tvl.tl.tl.tl.tl.hd, tvl.tl.tl.tl.tl.tl.hd);
548  }
541   static bool const isMemberFunction = false;
542   typedef D DeclType;
543   typedef R ReturnType;
544   typedef TypeList <P1, TypeList <P2, TypeList <P3, TypeList <P4, TypeList <P5,  TypeList <P6> > > > > > Params;
545   static R call (D fp, TypeListValues <Params> tvl)
546   {
547   return fp (tvl.hd, tvl.tl.hd, tvl.tl.tl.hd, tvl.tl.tl.tl.hd, tvl.tl.tl.tl.tl.hd, tvl.tl.tl.tl.tl.tl.hd);
548   }
549549};
550550
551551template <class R, class P1, class P2, class P3, class P4, class P5, class P6, class P7, class D>
552552struct FuncTraits <R (*) (P1, P2, P3, P4, P5, P6, P7) LUABRIDGE_THROWSPEC, D>
553553{
554  static bool const isMemberFunction = false;
555  typedef D DeclType;
556  typedef R ReturnType;
557  typedef TypeList <P1, TypeList <P2, TypeList <P3, TypeList <P4, TypeList <P5, TypeList <P6, TypeList <P7> > > > > > > Params;
558  static R call (D fp, TypeListValues <Params> tvl)
559  {
560    return fp (tvl.hd, tvl.tl.hd, tvl.tl.tl.hd, tvl.tl.tl.tl.hd, tvl.tl.tl.tl.tl.hd, tvl.tl.tl.tl.tl.tl.hd, tvl.tl.tl.tl.tl.tl.tl.hd);
561  }
554   static bool const isMemberFunction = false;
555   typedef D DeclType;
556   typedef R ReturnType;
557   typedef TypeList <P1, TypeList <P2, TypeList <P3, TypeList <P4, TypeList <P5, TypeList <P6, TypeList <P7> > > > > > > Params;
558   static R call (D fp, TypeListValues <Params> tvl)
559   {
560   return fp (tvl.hd, tvl.tl.hd, tvl.tl.tl.hd, tvl.tl.tl.tl.hd, tvl.tl.tl.tl.tl.hd, tvl.tl.tl.tl.tl.tl.hd, tvl.tl.tl.tl.tl.tl.tl.hd);
561   }
562562};
563563
564564template <class R, class P1, class P2, class P3, class P4, class P5, class P6, class P7, class P8, class D>
565565struct FuncTraits <R (*) (P1, P2, P3, P4, P5, P6, P7, P8) LUABRIDGE_THROWSPEC, D>
566566{
567  static bool const isMemberFunction = false;
568  typedef D DeclType;
569  typedef R ReturnType;
570  typedef TypeList <P1, TypeList <P2, TypeList <P3, TypeList <P4, TypeList <P5, TypeList <P6, TypeList <P7, TypeList <P8> > > > > > > > Params;
571  static R call (D fp, TypeListValues <Params> tvl)
572  {
573    return fp (tvl.hd, tvl.tl.hd, tvl.tl.tl.hd, tvl.tl.tl.tl.hd, tvl.tl.tl.tl.tl.hd, tvl.tl.tl.tl.tl.tl.hd, tvl.tl.tl.tl.tl.tl.tl.hd, tvl.tl.tl.tl.tl.tl.tl.tl.hd);
574  }
567   static bool const isMemberFunction = false;
568   typedef D DeclType;
569   typedef R ReturnType;
570   typedef TypeList <P1, TypeList <P2, TypeList <P3, TypeList <P4, TypeList <P5, TypeList <P6, TypeList <P7, TypeList <P8> > > > > > > > Params;
571   static R call (D fp, TypeListValues <Params> tvl)
572   {
573   return fp (tvl.hd, tvl.tl.hd, tvl.tl.tl.hd, tvl.tl.tl.tl.hd, tvl.tl.tl.tl.tl.hd, tvl.tl.tl.tl.tl.tl.hd, tvl.tl.tl.tl.tl.tl.tl.hd, tvl.tl.tl.tl.tl.tl.tl.tl.hd);
574   }
575575};
576576
577577/* Non-const member function pointers with THROWSPEC. */
r31374r31375
579579template <class T, class R, class D>
580580struct FuncTraits <R (T::*) () LUABRIDGE_THROWSPEC, D>
581581{
582  static bool const isMemberFunction = true;
583  static bool const isConstMemberFunction = false;
584  typedef D DeclType;
585  typedef T ClassType;
586  typedef R ReturnType;
587  typedef None Params;
588  static R call (T* obj, D fp, TypeListValues <Params> const&)
589  {
590    return (obj->*fp)();
591  }
582   static bool const isMemberFunction = true;
583   static bool const isConstMemberFunction = false;
584   typedef D DeclType;
585   typedef T ClassType;
586   typedef R ReturnType;
587   typedef None Params;
588   static R call (T* obj, D fp, TypeListValues <Params> const&)
589   {
590   return (obj->*fp)();
591   }
592592};
593593
594594template <class T, class R, class P1, class D>
595595struct FuncTraits <R (T::*) (P1) LUABRIDGE_THROWSPEC, D>
596596{
597  static bool const isMemberFunction = true;
598  static bool const isConstMemberFunction = false;
599  typedef D DeclType;
600  typedef T ClassType;
601  typedef R ReturnType;
602  typedef TypeList <P1> Params;
603  static R call (T* obj, D fp, TypeListValues <Params> tvl)
604  {
605    return (obj->*fp)(tvl.hd);
606  }
597   static bool const isMemberFunction = true;
598   static bool const isConstMemberFunction = false;
599   typedef D DeclType;
600   typedef T ClassType;
601   typedef R ReturnType;
602   typedef TypeList <P1> Params;
603   static R call (T* obj, D fp, TypeListValues <Params> tvl)
604   {
605   return (obj->*fp)(tvl.hd);
606   }
607607};
608608
609609template <class T, class R, class P1, class P2, class D>
610610struct FuncTraits <R (T::*) (P1, P2) LUABRIDGE_THROWSPEC, D>
611611{
612  static bool const isMemberFunction = true;
613  static bool const isConstMemberFunction = false;
614  typedef D DeclType;
615  typedef T ClassType;
616  typedef R ReturnType;
617  typedef TypeList <P1, TypeList <P2> > Params;
618  static R call (T* obj, D fp, TypeListValues <Params> tvl)
619  {
620    return (obj->*fp)(tvl.hd, tvl.tl.hd);
621  }
612   static bool const isMemberFunction = true;
613   static bool const isConstMemberFunction = false;
614   typedef D DeclType;
615   typedef T ClassType;
616   typedef R ReturnType;
617   typedef TypeList <P1, TypeList <P2> > Params;
618   static R call (T* obj, D fp, TypeListValues <Params> tvl)
619   {
620   return (obj->*fp)(tvl.hd, tvl.tl.hd);
621   }
622622};
623623
624624template <class T, class R, class P1, class P2, class P3, class D>
625625struct FuncTraits <R (T::*) (P1, P2, P3) LUABRIDGE_THROWSPEC, D>
626626{
627  static bool const isMemberFunction = true;
628  static bool const isConstMemberFunction = false;
629  typedef D DeclType;
630  typedef T ClassType;
631  typedef R ReturnType;
632  typedef TypeList <P1, TypeList <P2, TypeList <P3> > > Params;
633  static R call (T* obj, D fp, TypeListValues <Params> tvl)
634  {
635    return (obj->*fp)(tvl.hd, tvl.tl.hd, tvl.tl.tl.hd);
636  }
627   static bool const isMemberFunction = true;
628   static bool const isConstMemberFunction = false;
629   typedef D DeclType;
630   typedef T ClassType;
631   typedef R ReturnType;
632   typedef TypeList <P1, TypeList <P2, TypeList <P3> > > Params;
633   static R call (T* obj, D fp, TypeListValues <Params> tvl)
634   {
635   return (obj->*fp)(tvl.hd, tvl.tl.hd, tvl.tl.tl.hd);
636   }
637637};
638638
639639template <class T, class R, class P1, class P2, class P3, class P4, class D>
640640struct FuncTraits <R (T::*) (P1, P2, P3, P4) LUABRIDGE_THROWSPEC, D>
641641{
642  static bool const isMemberFunction = true;
643  static bool const isConstMemberFunction = false;
644  typedef D DeclType;
645  typedef T ClassType;
646  typedef R ReturnType;
647  typedef TypeList <P1, TypeList <P2, TypeList <P3, TypeList <P4> > > > Params;
648  static R call (T* obj, D fp, TypeListValues <Params> tvl)
649  {
650    return (obj->*fp)(tvl.hd, tvl.tl.hd, tvl.tl.tl.hd, tvl.tl.tl.tl.hd);
651  }
642   static bool const isMemberFunction = true;
643   static bool const isConstMemberFunction = false;
644   typedef D DeclType;
645   typedef T ClassType;
646   typedef R ReturnType;
647   typedef TypeList <P1, TypeList <P2, TypeList <P3, TypeList <P4> > > > Params;
648   static R call (T* obj, D fp, TypeListValues <Params> tvl)
649   {
650   return (obj->*fp)(tvl.hd, tvl.tl.hd, tvl.tl.tl.hd, tvl.tl.tl.tl.hd);
651   }
652652};
653653
654654template <class T, class R, class P1, class P2, class P3, class P4, class P5, class D>
655655struct FuncTraits <R (T::*) (P1, P2, P3, P4, P5) LUABRIDGE_THROWSPEC, D>
656656{
657  static bool const isMemberFunction = true;
658  static bool const isConstMemberFunction = false;
659  typedef D DeclType;
660  typedef T ClassType;
661  typedef R ReturnType;
662  typedef TypeList <P1, TypeList <P2, TypeList <P3, TypeList <P4, TypeList <P5> > > > > Params;
663  static R call (T* obj, D fp, TypeListValues <Params> tvl)
664  {
665    return (obj->*fp)(tvl.hd, tvl.tl.hd, tvl.tl.tl.hd, tvl.tl.tl.tl.hd, tvl.tl.tl.tl.tl.hd);
666  }
657   static bool const isMemberFunction = true;
658   static bool const isConstMemberFunction = false;
659   typedef D DeclType;
660   typedef T ClassType;
661   typedef R ReturnType;
662   typedef TypeList <P1, TypeList <P2, TypeList <P3, TypeList <P4, TypeList <P5> > > > > Params;
663   static R call (T* obj, D fp, TypeListValues <Params> tvl)
664   {
665   return (obj->*fp)(tvl.hd, tvl.tl.hd, tvl.tl.tl.hd, tvl.tl.tl.tl.hd, tvl.tl.tl.tl.tl.hd);
666   }
667667};
668668
669669template <class T, class R, class P1, class P2, class P3, class P4, class P5, class P6, class D>
670670struct FuncTraits <R (T::*) (P1, P2, P3, P4, P5, P6) LUABRIDGE_THROWSPEC, D>
671671{
672  static bool const isMemberFunction = true;
673  static bool const isConstMemberFunction = false;
674  typedef D DeclType;
675  typedef T ClassType;
676  typedef R ReturnType;
677  typedef TypeList <P1, TypeList <P2, TypeList <P3, TypeList <P4, TypeList <P5, TypeList <P6> > > > > > Params;
678  static R call (T* obj, D fp, TypeListValues <Params> tvl)
679  {
680    return (obj->*fp)(tvl.hd, tvl.tl.hd, tvl.tl.tl.hd, tvl.tl.tl.tl.hd, tvl.tl.tl.tl.tl.hd, tvl.tl.tl.tl.tl.tl.hd);
681  }
672   static bool const isMemberFunction = true;
673   static bool const isConstMemberFunction = false;
674   typedef D DeclType;
675   typedef T ClassType;
676   typedef R ReturnType;
677   typedef TypeList <P1, TypeList <P2, TypeList <P3, TypeList <P4, TypeList <P5, TypeList <P6> > > > > > Params;
678   static R call (T* obj, D fp, TypeListValues <Params> tvl)
679   {
680   return (obj->*fp)(tvl.hd, tvl.tl.hd, tvl.tl.tl.hd, tvl.tl.tl.tl.hd, tvl.tl.tl.tl.tl.hd, tvl.tl.tl.tl.tl.tl.hd);
681   }
682682};
683683
684684template <class T, class R, class P1, class P2, class P3, class P4, class P5, class P6, class P7, class D>
685685struct FuncTraits <R (T::*) (P1, P2, P3, P4, P5, P6, P7) LUABRIDGE_THROWSPEC, D>
686686{
687  static bool const isMemberFunction = true;
688  static bool const isConstMemberFunction = false;
689  typedef D DeclType;
690  typedef T ClassType;
691  typedef R ReturnType;
692  typedef TypeList <P1, TypeList <P2, TypeList <P3, TypeList <P4, TypeList <P5, TypeList <P6, TypeList <P7> > > > > > > Params;
693  static R call (T* obj, D fp, TypeListValues <Params> tvl)
694  {
695    return (obj->*fp)(tvl.hd, tvl.tl.hd, tvl.tl.tl.hd, tvl.tl.tl.tl.hd, tvl.tl.tl.tl.tl.hd, tvl.tl.tl.tl.tl.tl.hd, tvl.tl.tl.tl.tl.tl.tl.hd);
696  }
687   static bool const isMemberFunction = true;
688   static bool const isConstMemberFunction = false;
689   typedef D DeclType;
690   typedef T ClassType;
691   typedef R ReturnType;
692   typedef TypeList <P1, TypeList <P2, TypeList <P3, TypeList <P4, TypeList <P5, TypeList <P6, TypeList <P7> > > > > > > Params;
693   static R call (T* obj, D fp, TypeListValues <Params> tvl)
694   {
695   return (obj->*fp)(tvl.hd, tvl.tl.hd, tvl.tl.tl.hd, tvl.tl.tl.tl.hd, tvl.tl.tl.tl.tl.hd, tvl.tl.tl.tl.tl.tl.hd, tvl.tl.tl.tl.tl.tl.tl.hd);
696   }
697697};
698698
699699template <class T, class R, class P1, class P2, class P3, class P4, class P5, class P6, class P7, class P8, class D>
700700struct FuncTraits <R (T::*) (P1, P2, P3, P4, P5, P6, P7, P8) LUABRIDGE_THROWSPEC, D>
701701{
702  static bool const isMemberFunction = true;
703  static bool const isConstMemberFunction = false;
704  typedef D DeclType;
705  typedef T ClassType;
706  typedef R ReturnType;
707  typedef TypeList <P1, TypeList <P2, TypeList <P3, TypeList <P4, TypeList <P5, TypeList <P6, TypeList <P7, TypeList <P8> > > > > > > > Params;
708  static R call (T* obj, D fp, TypeListValues <Params> tvl)
709  {
710    return (obj->*fp)(tvl.hd, tvl.tl.hd, tvl.tl.tl.hd, tvl.tl.tl.tl.hd, tvl.tl.tl.tl.tl.hd, tvl.tl.tl.tl.tl.tl.hd, tvl.tl.tl.tl.tl.tl.tl.hd, tvl.tl.tl.tl.tl.tl.tl.tl.hd);
711  }
702   static bool const isMemberFunction = true;
703   static bool const isConstMemberFunction = false;
704   typedef D DeclType;
705   typedef T ClassType;
706   typedef R ReturnType;
707   typedef TypeList <P1, TypeList <P2, TypeList <P3, TypeList <P4, TypeList <P5, TypeList <P6, TypeList <P7, TypeList <P8> > > > > > > > Params;
708   static R call (T* obj, D fp, TypeListValues <Params> tvl)
709   {
710   return (obj->*fp)(tvl.hd, tvl.tl.hd, tvl.tl.tl.hd, tvl.tl.tl.tl.hd, tvl.tl.tl.tl.tl.hd, tvl.tl.tl.tl.tl.tl.hd, tvl.tl.tl.tl.tl.tl.tl.hd, tvl.tl.tl.tl.tl.tl.tl.tl.hd);
711   }
712712};
713713
714714/* Const member function pointers with THROWSPEC. */
r31374r31375
716716template <class T, class R, class D>
717717struct FuncTraits <R (T::*) () const LUABRIDGE_THROWSPEC, D>
718718{
719  static bool const isMemberFunction = true;
720  static bool const isConstMemberFunction = true;
721  typedef D DeclType;
722  typedef T ClassType;
723  typedef R ReturnType;
724  typedef None Params;
725  static R call (T const* obj, D fp, TypeListValues <Params>)
726  {
727    return (obj->*fp)();
728  }
719   static bool const isMemberFunction = true;
720   static bool const isConstMemberFunction = true;
721   typedef D DeclType;
722   typedef T ClassType;
723   typedef R ReturnType;
724   typedef None Params;
725   static R call (T const* obj, D fp, TypeListValues <Params>)
726   {
727   return (obj->*fp)();
728   }
729729};
730730
731731template <class T, class R, class P1, class D>
732732struct FuncTraits <R (T::*) (P1) const LUABRIDGE_THROWSPEC, D>
733733{
734  static bool const isMemberFunction = true;
735  static bool const isConstMemberFunction = true;
736  typedef D DeclType;
737  typedef T ClassType;
738  typedef R ReturnType;
739  typedef TypeList <P1> Params;
740  static R call (T const* obj, D fp, TypeListValues <Params> tvl)
741  {
742    return (obj->*fp)(tvl.hd);
743  }
734   static bool const isMemberFunction = true;
735   static bool const isConstMemberFunction = true;
736   typedef D DeclType;
737   typedef T ClassType;
738   typedef R ReturnType;
739   typedef TypeList <P1> Params;
740   static R call (T const* obj, D fp, TypeListValues <Params> tvl)
741   {
742   return (obj->*fp)(tvl.hd);
743   }
744744};
745745
746746template <class T, class R, class P1, class P2, class D>
747747struct FuncTraits <R (T::*) (P1, P2) const LUABRIDGE_THROWSPEC, D>
748748{
749  static bool const isMemberFunction = true;
750  static bool const isConstMemberFunction = true;
751  typedef D DeclType;
752  typedef T ClassType;
753  typedef R ReturnType;
754  typedef TypeList <P1, TypeList <P2> > Params;
755  static R call (T const* obj, D fp, TypeListValues <Params> tvl)
756  {
757    return (obj->*fp)(tvl.hd, tvl.tl.hd);
758  }
749   static bool const isMemberFunction = true;
750   static bool const isConstMemberFunction = true;
751   typedef D DeclType;
752   typedef T ClassType;
753   typedef R ReturnType;
754   typedef TypeList <P1, TypeList <P2> > Params;
755   static R call (T const* obj, D fp, TypeListValues <Params> tvl)
756   {
757   return (obj->*fp)(tvl.hd, tvl.tl.hd);
758   }
759759};
760760
761761template <class T, class R, class P1, class P2, class P3, class D>
762762struct FuncTraits <R (T::*) (P1, P2, P3) const LUABRIDGE_THROWSPEC, D>
763763{
764  static bool const isMemberFunction = true;
765  static bool const isConstMemberFunction = true;
766  typedef D DeclType;
767  typedef T ClassType;
768  typedef R ReturnType;
769  typedef TypeList <P1, TypeList <P2, TypeList <P3> > > Params;
770  static R call (T const* obj, D fp, TypeListValues <Params> tvl)
771  {
772    return (obj->*fp)(tvl.hd, tvl.tl.hd, tvl.tl.tl.hd);
773  }
764   static bool const isMemberFunction = true;
765   static bool const isConstMemberFunction = true;
766   typedef D DeclType;
767   typedef T ClassType;
768   typedef R ReturnType;
769   typedef TypeList <P1, TypeList <P2, TypeList <P3> > > Params;
770   static R call (T const* obj, D fp, TypeListValues <Params> tvl)
771   {
772   return (obj->*fp)(tvl.hd, tvl.tl.hd, tvl.tl.tl.hd);
773   }
774774};
775775
776776template <class T, class R, class P1, class P2, class P3, class P4, class D>
777777struct FuncTraits <R (T::*) (P1, P2, P3, P4) const LUABRIDGE_THROWSPEC, D>
778778{
779  static bool const isMemberFunction = true;
780  static bool const isConstMemberFunction = true;
781  typedef D DeclType;
782  typedef T ClassType;
783  typedef R ReturnType;
784  typedef TypeList <P1, TypeList <P2, TypeList <P3, TypeList <P4> > > > Params;
785  static R call (T const* obj, D fp, TypeListValues <Params> tvl)
786  {
787    return (obj->*fp)(tvl.hd, tvl.tl.hd, tvl.tl.tl.hd, tvl.tl.tl.tl.hd);
788  }
779   static bool const isMemberFunction = true;
780   static bool const isConstMemberFunction = true;
781   typedef D DeclType;
782   typedef T ClassType;
783   typedef R ReturnType;
784   typedef TypeList <P1, TypeList <P2, TypeList <P3, TypeList <P4> > > > Params;
785   static R call (T const* obj, D fp, TypeListValues <Params> tvl)
786   {
787   return (obj->*fp)(tvl.hd, tvl.tl.hd, tvl.tl.tl.hd, tvl.tl.tl.tl.hd);
788   }
789789};
790790
791791template <class T, class R, class P1, class P2, class P3, class P4, class P5, class D>
792792struct FuncTraits <R (T::*) (P1, P2, P3, P4, P5) const LUABRIDGE_THROWSPEC, D>
793793{
794  static bool const isMemberFunction = true;
795  static bool const isConstMemberFunction = true;
796  typedef D DeclType;
797  typedef T ClassType;
798  typedef R ReturnType;
799  typedef TypeList <P1, TypeList <P2, TypeList <P3, TypeList <P4, TypeList <P5> > > > > Params;
800  static R call (T const* obj, D fp, TypeListValues <Params> tvl)
801  {
802    return (obj->*fp)(tvl.hd, tvl.tl.hd, tvl.tl.tl.hd, tvl.tl.tl.tl.hd,
803      tvl.tl.tl.tl.tl.hd);
804  }
794   static bool const isMemberFunction = true;
795   static bool const isConstMemberFunction = true;
796   typedef D DeclType;
797   typedef T ClassType;
798   typedef R ReturnType;
799   typedef TypeList <P1, TypeList <P2, TypeList <P3, TypeList <P4, TypeList <P5> > > > > Params;
800   static R call (T const* obj, D fp, TypeListValues <Params> tvl)
801   {
802   return (obj->*fp)(tvl.hd, tvl.tl.hd, tvl.tl.tl.hd, tvl.tl.tl.tl.hd,
803      tvl.tl.tl.tl.tl.hd);
804   }
805805};
806806
807807template <class T, class R, class P1, class P2, class P3, class P4, class P5, class P6, class D>
808808struct FuncTraits <R (T::*) (P1, P2, P3, P4, P5, P6) const LUABRIDGE_THROWSPEC, D>
809809{
810  static bool const isMemberFunction = true;
811  static bool const isConstMemberFunction = true;
812  typedef D DeclType;
813  typedef T ClassType;
814  typedef R ReturnType;
815  typedef TypeList <P1, TypeList <P2, TypeList <P3, TypeList <P4, TypeList <P5, TypeList <P6> > > > > > Params;
816  static R call (T const* obj, D fp, TypeListValues <Params> tvl)
817  {
818    return (obj->*fp)(tvl.hd, tvl.tl.hd, tvl.tl.tl.hd, tvl.tl.tl.tl.hd, tvl.tl.tl.tl.tl.hd, tvl.tl.tl.tl.tl.tl.hd);
819  }
810   static bool const isMemberFunction = true;
811   static bool const isConstMemberFunction = true;
812   typedef D DeclType;
813   typedef T ClassType;
814   typedef R ReturnType;
815   typedef TypeList <P1, TypeList <P2, TypeList <P3, TypeList <P4, TypeList <P5, TypeList <P6> > > > > > Params;
816   static R call (T const* obj, D fp, TypeListValues <Params> tvl)
817   {
818   return (obj->*fp)(tvl.hd, tvl.tl.hd, tvl.tl.tl.hd, tvl.tl.tl.tl.hd, tvl.tl.tl.tl.tl.hd, tvl.tl.tl.tl.tl.tl.hd);
819   }
820820};
821821
822822template <class T, class R, class P1, class P2, class P3, class P4, class P5, class P6, class P7, class D>
823823struct FuncTraits <R (T::*) (P1, P2, P3, P4, P5, P6, P7) const LUABRIDGE_THROWSPEC, D>
824824{
825  static bool const isMemberFunction = true;
826  static bool const isConstMemberFunction = true;
827  typedef D DeclType;
828  typedef T ClassType;
829  typedef R ReturnType;
830  typedef TypeList <P1, TypeList <P2, TypeList <P3, TypeList <P4, TypeList <P5, TypeList <P6, TypeList <P7> > > > > > > Params;
831  static R call (T const* obj, D fp, TypeListValues <Params> tvl)
832  {
833    return (obj->*fp)(tvl.hd, tvl.tl.hd, tvl.tl.tl.hd, tvl.tl.tl.tl.hd, tvl.tl.tl.tl.tl.hd, tvl.tl.tl.tl.tl.tl.hd, tvl.tl.tl.tl.tl.tl.tl.hd);
834  }
825   static bool const isMemberFunction = true;
826   static bool const isConstMemberFunction = true;
827   typedef D DeclType;
828   typedef T ClassType;
829   typedef R ReturnType;
830   typedef TypeList <P1, TypeList <P2, TypeList <P3, TypeList <P4, TypeList <P5, TypeList <P6, TypeList <P7> > > > > > > Params;
831   static R call (T const* obj, D fp, TypeListValues <Params> tvl)
832   {
833   return (obj->*fp)(tvl.hd, tvl.tl.hd, tvl.tl.tl.hd, tvl.tl.tl.tl.hd, tvl.tl.tl.tl.tl.hd, tvl.tl.tl.tl.tl.tl.hd, tvl.tl.tl.tl.tl.tl.tl.hd);
834   }
835835};
836836
837837template <class T, class R, class P1, class P2, class P3, class P4, class P5, class P6, class P7, class P8, class D>
838838struct FuncTraits <R (T::*) (P1, P2, P3, P4, P5, P6, P7, P8) const LUABRIDGE_THROWSPEC, D>
839839{
840  static bool const isMemberFunction = true;
841  static bool const isConstMemberFunction = true;
842  typedef D DeclType;
843  typedef T ClassType;
844  typedef R ReturnType;
845  typedef TypeList <P1, TypeList <P2, TypeList <P3, TypeList <P4, TypeList <P5, TypeList <P6, TypeList <P7, TypeList <P8> > > > > > > > Params;
846  static R call (T const* obj, D fp, TypeListValues <Params> tvl)
847  {
848    return (obj->*fp)(tvl.hd, tvl.tl.hd, tvl.tl.tl.hd, tvl.tl.tl.tl.hd, tvl.tl.tl.tl.tl.hd, tvl.tl.tl.tl.tl.tl.hd, tvl.tl.tl.tl.tl.tl.tl.hd, tvl.tl.tl.tl.tl.tl.tl.tl.hd);
849  }
840   static bool const isMemberFunction = true;
841   static bool const isConstMemberFunction = true;
842   typedef D DeclType;
843   typedef T ClassType;
844   typedef R ReturnType;
845   typedef TypeList <P1, TypeList <P2, TypeList <P3, TypeList <P4, TypeList <P5, TypeList <P6, TypeList <P7, TypeList <P8> > > > > > > > Params;
846   static R call (T const* obj, D fp, TypeListValues <Params> tvl)
847   {
848   return (obj->*fp)(tvl.hd, tvl.tl.hd, tvl.tl.tl.hd, tvl.tl.tl.tl.hd, tvl.tl.tl.tl.tl.hd, tvl.tl.tl.tl.tl.tl.hd, tvl.tl.tl.tl.tl.tl.tl.hd, tvl.tl.tl.tl.tl.tl.tl.tl.hd);
849   }
850850};
851851
852852#endif
trunk/src/lib/lua/bridge/LuaBridge.h
r31374r31375
11//------------------------------------------------------------------------------
22/*
33  https://github.com/vinniefalco/LuaBridge
4 
4
55  Copyright 2012, Vinnie Falco <vinnie.falco@gmail.com>
66  Copyright 2007, Nathan Reed
77
r31374r31375
4545
4646namespace luabridge
4747{
48
4948// Forward declaration
5049//
5150template <class T>
r31374r31375
7372class Security
7473{
7574public:
76  static bool hideMetatables ()
77  {
78    return getSettings().hideMetatables;
79  }
75   static bool hideMetatables ()
76   {
77   return getSettings().hideMetatables;
78   }
8079
81  static void setHideMetatables (bool shouldHide)
82  {
83    getSettings().hideMetatables = shouldHide;
84  }
80   static void setHideMetatables (bool shouldHide)
81   {
82   getSettings().hideMetatables = shouldHide;
83   }
8584
8685private:
87  struct Settings
88  {
89    Settings () : hideMetatables (true)
90    {
91    }
86   struct Settings
87   {
88   Settings () : hideMetatables (true)
89   {
90   }
9291
93    bool hideMetatables;
94  };
92   bool hideMetatables;
93   };
9594
96  static Settings& getSettings ()
97  {
98    static Settings settings;
99    return settings;
100  }
95   static Settings& getSettings ()
96   {
97   static Settings settings;
98   return settings;
99   }
101100};
102101
103102#include "detail/Userdata.h"
r31374r31375
111110template <class T>
112111inline void push (lua_State* L, T t)
113112{
114  Stack <T>::push (L, t);
113   Stack <T>::push (L, t);
115114}
116115
117116//------------------------------------------------------------------------------
r31374r31375
124123template <class T>
125124inline void setGlobal (lua_State* L, T t, char const* name)
126125{
127  push (L, t);
128  lua_setglobal (L, name);
126   push (L, t);
127   lua_setglobal (L, name);
129128}
130129
131130//------------------------------------------------------------------------------
r31374r31375
134133*/
135134inline void setHideMetatables (bool shouldHide)
136135{
137  Security::setHideMetatables (shouldHide);
136   Security::setHideMetatables (shouldHide);
138137}
139138
140139}
trunk/src/lib/lua/lopcodes.h
r31374r31375
1414  We assume that instructions are unsigned numbers.
1515  All instructions have an opcode in the first 6 bits.
1616  Instructions can have the following fields:
17   `A' : 8 bits
18   `B' : 9 bits
19   `C' : 9 bits
20   'Ax' : 26 bits ('A', 'B', and 'C' together)
21   `Bx' : 18 bits (`B' and `C' together)
22   `sBx' : signed Bx
17    `A' : 8 bits
18    `B' : 9 bits
19    `C' : 9 bits
20    'Ax' : 26 bits ('A', 'B', and 'C' together)
21    `Bx' : 18 bits (`B' and `C' together)
22    `sBx' : signed Bx
2323
2424  A signed argument is represented in excess K; that is, the number
2525  value is the unsigned value minus K. K is exactly the maximum value
r31374r31375
3535/*
3636** size and position of opcode arguments.
3737*/
38#define SIZE_C      9
39#define SIZE_B      9
40#define SIZE_Bx      (SIZE_C + SIZE_B)
41#define SIZE_A      8
42#define SIZE_Ax      (SIZE_C + SIZE_B + SIZE_A)
38#define SIZE_C      9
39#define SIZE_B      9
40#define SIZE_Bx     (SIZE_C + SIZE_B)
41#define SIZE_A      8
42#define SIZE_Ax     (SIZE_C + SIZE_B + SIZE_A)
4343
44#define SIZE_OP      6
44#define SIZE_OP     6
4545
46#define POS_OP      0
47#define POS_A      (POS_OP + SIZE_OP)
48#define POS_C      (POS_A + SIZE_A)
49#define POS_B      (POS_C + SIZE_C)
50#define POS_Bx      POS_C
51#define POS_Ax      POS_A
46#define POS_OP      0
47#define POS_A       (POS_OP + SIZE_OP)
48#define POS_C       (POS_A + SIZE_A)
49#define POS_B       (POS_C + SIZE_C)
50#define POS_Bx      POS_C
51#define POS_Ax      POS_A
5252
5353
5454/*
r31374r31375
6565#endif
6666
6767#if SIZE_Ax < LUAI_BITSINT-1
68#define MAXARG_Ax   ((1<<SIZE_Ax)-1)
68#define MAXARG_Ax   ((1<<SIZE_Ax)-1)
6969#else
70#define MAXARG_Ax   MAX_INT
70#define MAXARG_Ax   MAX_INT
7171#endif
7272
7373
r31374r31375
7777
7878
7979/* creates a mask with `n' 1 bits at position `p' */
80#define MASK1(n,p)   ((~((~(Instruction)0)<<(n)))<<(p))
80#define MASK1(n,p)  ((~((~(Instruction)0)<<(n)))<<(p))
8181
8282/* creates a mask with `n' 0 bits at position `p' */
83#define MASK0(n,p)   (~MASK1(n,p))
83#define MASK0(n,p)  (~MASK1(n,p))
8484
8585/*
8686** the following macros help to manipulate instructions
8787*/
8888
89#define GET_OPCODE(i)   (cast(OpCode, ((i)>>POS_OP) & MASK1(SIZE_OP,0)))
90#define SET_OPCODE(i,o)   ((i) = (((i)&MASK0(SIZE_OP,POS_OP)) | \
89#define GET_OPCODE(i)   (cast(OpCode, ((i)>>POS_OP) & MASK1(SIZE_OP,0)))
90#define SET_OPCODE(i,o) ((i) = (((i)&MASK0(SIZE_OP,POS_OP)) | \
9191      ((cast(Instruction, o)<<POS_OP)&MASK1(SIZE_OP,POS_OP))))
9292
93#define getarg(i,pos,size)   (cast(int, ((i)>>pos) & MASK1(size,0)))
94#define setarg(i,v,pos,size)   ((i) = (((i)&MASK0(size,pos)) | \
95                ((cast(Instruction, v)<<pos)&MASK1(size,pos))))
93#define getarg(i,pos,size)  (cast(int, ((i)>>pos) & MASK1(size,0)))
94#define setarg(i,v,pos,size)    ((i) = (((i)&MASK0(size,pos)) | \
95            ((cast(Instruction, v)<<pos)&MASK1(size,pos))))
9696
97#define GETARG_A(i)   getarg(i, POS_A, SIZE_A)
98#define SETARG_A(i,v)   setarg(i, v, POS_A, SIZE_A)
97#define GETARG_A(i) getarg(i, POS_A, SIZE_A)
98#define SETARG_A(i,v)   setarg(i, v, POS_A, SIZE_A)
9999
100#define GETARG_B(i)   getarg(i, POS_B, SIZE_B)
101#define SETARG_B(i,v)   setarg(i, v, POS_B, SIZE_B)
100#define GETARG_B(i) getarg(i, POS_B, SIZE_B)
101#define SETARG_B(i,v)   setarg(i, v, POS_B, SIZE_B)
102102
103#define GETARG_C(i)   getarg(i, POS_C, SIZE_C)
104#define SETARG_C(i,v)   setarg(i, v, POS_C, SIZE_C)
103#define GETARG_C(i) getarg(i, POS_C, SIZE_C)
104#define SETARG_C(i,v)   setarg(i, v, POS_C, SIZE_C)
105105
106#define GETARG_Bx(i)   getarg(i, POS_Bx, SIZE_Bx)
107#define SETARG_Bx(i,v)   setarg(i, v, POS_Bx, SIZE_Bx)
106#define GETARG_Bx(i)    getarg(i, POS_Bx, SIZE_Bx)
107#define SETARG_Bx(i,v)  setarg(i, v, POS_Bx, SIZE_Bx)
108108
109#define GETARG_Ax(i)   getarg(i, POS_Ax, SIZE_Ax)
110#define SETARG_Ax(i,v)   setarg(i, v, POS_Ax, SIZE_Ax)
109#define GETARG_Ax(i)    getarg(i, POS_Ax, SIZE_Ax)
110#define SETARG_Ax(i,v)  setarg(i, v, POS_Ax, SIZE_Ax)
111111
112#define GETARG_sBx(i)   (GETARG_Bx(i)-MAXARG_sBx)
113#define SETARG_sBx(i,b)   SETARG_Bx((i),cast(unsigned int, (b)+MAXARG_sBx))
112#define GETARG_sBx(i)   (GETARG_Bx(i)-MAXARG_sBx)
113#define SETARG_sBx(i,b) SETARG_Bx((i),cast(unsigned int, (b)+MAXARG_sBx))
114114
115115
116#define CREATE_ABC(o,a,b,c)   ((cast(Instruction, o)<<POS_OP) \
116#define CREATE_ABC(o,a,b,c) ((cast(Instruction, o)<<POS_OP) \
117117         | (cast(Instruction, a)<<POS_A) \
118118         | (cast(Instruction, b)<<POS_B) \
119119         | (cast(Instruction, c)<<POS_C))
120120
121#define CREATE_ABx(o,a,bc)   ((cast(Instruction, o)<<POS_OP) \
121#define CREATE_ABx(o,a,bc)  ((cast(Instruction, o)<<POS_OP) \
122122         | (cast(Instruction, a)<<POS_A) \
123123         | (cast(Instruction, bc)<<POS_Bx))
124124
125#define CREATE_Ax(o,a)      ((cast(Instruction, o)<<POS_OP) \
125#define CREATE_Ax(o,a)      ((cast(Instruction, o)<<POS_OP) \
126126         | (cast(Instruction, a)<<POS_Ax))
127127
128128
r31374r31375
131131*/
132132
133133/* this bit 1 means constant (0 means register) */
134#define BITRK      (1 << (SIZE_B - 1))
134#define BITRK       (1 << (SIZE_B - 1))
135135
136136/* test whether value is a constant */
137#define ISK(x)      ((x) & BITRK)
137#define ISK(x)      ((x) & BITRK)
138138
139139/* gets the index of the constant */
140#define INDEXK(r)   ((int)(r) & ~BITRK)
140#define INDEXK(r)   ((int)(r) & ~BITRK)
141141
142#define MAXINDEXRK   (BITRK - 1)
142#define MAXINDEXRK  (BITRK - 1)
143143
144144/* code a constant index as a RK value */
145#define RKASK(x)   ((x) | BITRK)
145#define RKASK(x)    ((x) | BITRK)
146146
147147
148148/*
149149** invalid register that fits in 8 bits
150150*/
151#define NO_REG      MAXARG_A
151#define NO_REG      MAXARG_A
152152
153153
154154/*
r31374r31375
164164
165165typedef enum {
166166/*----------------------------------------------------------------------
167name      args   description
167name        args    description
168168------------------------------------------------------------------------*/
169OP_MOVE,/*   A B   R(A) := R(B)               */
170OP_LOADK,/*   A Bx   R(A) := Kst(Bx)               */
171OP_LOADKX,/*   A    R(A) := Kst(extra arg)            */
172OP_LOADBOOL,/*   A B C   R(A) := (Bool)B; if (C) pc++         */
173OP_LOADNIL,/*   A B   R(A), R(A+1), ..., R(A+B) := nil      */
174OP_GETUPVAL,/*   A B   R(A) := UpValue[B]            */
169OP_MOVE,/*  A B R(A) := R(B)                    */
170OP_LOADK,/* A Bx    R(A) := Kst(Bx)                 */
171OP_LOADKX,/*    A   R(A) := Kst(extra arg)              */
172OP_LOADBOOL,/*  A B C   R(A) := (Bool)B; if (C) pc++            */
173OP_LOADNIL,/*   A B R(A), R(A+1), ..., R(A+B) := nil        */
174OP_GETUPVAL,/*  A B R(A) := UpValue[B]              */
175175
176OP_GETTABUP,/*   A B C   R(A) := UpValue[B][RK(C)]         */
177OP_GETTABLE,/*   A B C   R(A) := R(B)[RK(C)]            */
176OP_GETTABUP,/*  A B C   R(A) := UpValue[B][RK(C)]           */
177OP_GETTABLE,/*  A B C   R(A) := R(B)[RK(C)]             */
178178
179OP_SETTABUP,/*   A B C   UpValue[A][RK(B)] := RK(C)         */
180OP_SETUPVAL,/*   A B   UpValue[B] := R(A)            */
181OP_SETTABLE,/*   A B C   R(A)[RK(B)] := RK(C)            */
179OP_SETTABUP,/*  A B C   UpValue[A][RK(B)] := RK(C)          */
180OP_SETUPVAL,/*  A B UpValue[B] := R(A)              */
181OP_SETTABLE,/*  A B C   R(A)[RK(B)] := RK(C)                */
182182
183OP_NEWTABLE,/*   A B C   R(A) := {} (size = B,C)            */
183OP_NEWTABLE,/*  A B C   R(A) := {} (size = B,C)             */
184184
185OP_SELF,/*   A B C   R(A+1) := R(B); R(A) := R(B)[RK(C)]      */
185OP_SELF,/*  A B C   R(A+1) := R(B); R(A) := R(B)[RK(C)]     */
186186
187OP_ADD,/*   A B C   R(A) := RK(B) + RK(C)            */
188OP_SUB,/*   A B C   R(A) := RK(B) - RK(C)            */
189OP_MUL,/*   A B C   R(A) := RK(B) * RK(C)            */
190OP_DIV,/*   A B C   R(A) := RK(B) / RK(C)            */
191OP_MOD,/*   A B C   R(A) := RK(B) % RK(C)            */
192OP_POW,/*   A B C   R(A) := RK(B) ^ RK(C)            */
193OP_UNM,/*   A B   R(A) := -R(B)               */
194OP_NOT,/*   A B   R(A) := not R(B)            */
195OP_LEN,/*   A B   R(A) := length of R(B)            */
187OP_ADD,/*   A B C   R(A) := RK(B) + RK(C)               */
188OP_SUB,/*   A B C   R(A) := RK(B) - RK(C)               */
189OP_MUL,/*   A B C   R(A) := RK(B) * RK(C)               */
190OP_DIV,/*   A B C   R(A) := RK(B) / RK(C)               */
191OP_MOD,/*   A B C   R(A) := RK(B) % RK(C)               */
192OP_POW,/*   A B C   R(A) := RK(B) ^ RK(C)               */
193OP_UNM,/*   A B R(A) := -R(B)                   */
194OP_NOT,/*   A B R(A) := not R(B)                */
195OP_LEN,/*   A B R(A) := length of R(B)              */
196196
197OP_CONCAT,/*   A B C   R(A) := R(B).. ... ..R(C)         */
197OP_CONCAT,/*    A B C   R(A) := R(B).. ... ..R(C)           */
198198
199OP_JMP,/*   A sBx   pc+=sBx; if (A) close all upvalues >= R(A) + 1   */
200OP_EQ,/*   A B C   if ((RK(B) == RK(C)) ~= A) then pc++      */
201OP_LT,/*   A B C   if ((RK(B) <  RK(C)) ~= A) then pc++      */
202OP_LE,/*   A B C   if ((RK(B) <= RK(C)) ~= A) then pc++      */
199OP_JMP,/*   A sBx   pc+=sBx; if (A) close all upvalues >= R(A) + 1  */
200OP_EQ,/*    A B C   if ((RK(B) == RK(C)) ~= A) then pc++        */
201OP_LT,/*    A B C   if ((RK(B) <  RK(C)) ~= A) then pc++        */
202OP_LE,/*    A B C   if ((RK(B) <= RK(C)) ~= A) then pc++        */
203203
204OP_TEST,/*   A C   if not (R(A) <=> C) then pc++         */
205OP_TESTSET,/*   A B C   if (R(B) <=> C) then R(A) := R(B) else pc++   */
204OP_TEST,/*  A C if not (R(A) <=> C) then pc++           */
205OP_TESTSET,/*   A B C   if (R(B) <=> C) then R(A) := R(B) else pc++ */
206206
207OP_CALL,/*   A B C   R(A), ... ,R(A+C-2) := R(A)(R(A+1), ... ,R(A+B-1)) */
208OP_TAILCALL,/*   A B C   return R(A)(R(A+1), ... ,R(A+B-1))      */
209OP_RETURN,/*   A B   return R(A), ... ,R(A+B-2)   (see note)   */
207OP_CALL,/*  A B C   R(A), ... ,R(A+C-2) := R(A)(R(A+1), ... ,R(A+B-1)) */
208OP_TAILCALL,/*  A B C   return R(A)(R(A+1), ... ,R(A+B-1))      */
209OP_RETURN,/*    A B return R(A), ... ,R(A+B-2)  (see note)  */
210210
211OP_FORLOOP,/*   A sBx   R(A)+=R(A+2);
212         if R(A) <?= R(A+1) then { pc+=sBx; R(A+3)=R(A) }*/
213OP_FORPREP,/*   A sBx   R(A)-=R(A+2); pc+=sBx            */
211OP_FORLOOP,/*   A sBx   R(A)+=R(A+2);
212            if R(A) <?= R(A+1) then { pc+=sBx; R(A+3)=R(A) }*/
213OP_FORPREP,/*   A sBx   R(A)-=R(A+2); pc+=sBx               */
214214
215OP_TFORCALL,/*   A C   R(A+3), ... ,R(A+2+C) := R(A)(R(A+1), R(A+2));   */
216OP_TFORLOOP,/*   A sBx   if R(A+1) ~= nil then { R(A)=R(A+1); pc += sBx }*/
215OP_TFORCALL,/*  A C R(A+3), ... ,R(A+2+C) := R(A)(R(A+1), R(A+2));  */
216OP_TFORLOOP,/*  A sBx   if R(A+1) ~= nil then { R(A)=R(A+1); pc += sBx }*/
217217
218OP_SETLIST,/*   A B C   R(A)[(C-1)*FPF+i] := R(A+i), 1 <= i <= B   */
218OP_SETLIST,/*   A B C   R(A)[(C-1)*FPF+i] := R(A+i), 1 <= i <= B    */
219219
220OP_CLOSURE,/*   A Bx   R(A) := closure(KPROTO[Bx])         */
220OP_CLOSURE,/*   A Bx    R(A) := closure(KPROTO[Bx])         */
221221
222OP_VARARG,/*   A B   R(A), R(A+1), ..., R(A+B-2) = vararg      */
222OP_VARARG,/*    A B R(A), R(A+1), ..., R(A+B-2) = vararg        */
223223
224OP_EXTRAARG/*   Ax   extra (larger) argument for previous opcode   */
224OP_EXTRAARG/*   Ax  extra (larger) argument for previous opcode */
225225} OpCode;
226226
227227
228#define NUM_OPCODES   (cast(int, OP_EXTRAARG) + 1)
228#define NUM_OPCODES (cast(int, OP_EXTRAARG) + 1)
229229
230230
231231
r31374r31375
263263*/
264264
265265enum OpArgMask {
266  OpArgN,  /* argument is not used */
267  OpArgU,  /* argument is used */
268  OpArgR,  /* argument is a register or a jump offset */
269  OpArgK   /* argument is a constant or register/constant */
266   OpArgN,  /* argument is not used */
267   OpArgU,  /* argument is used */
268   OpArgR,  /* argument is a register or a jump offset */
269   OpArgK   /* argument is a constant or register/constant */
270270};
271271
272272LUAI_DDEC const lu_byte luaP_opmodes[NUM_OPCODES];
273273
274#define getOpMode(m)   (cast(enum OpMode, luaP_opmodes[m] & 3))
275#define getBMode(m)   (cast(enum OpArgMask, (luaP_opmodes[m] >> 4) & 3))
276#define getCMode(m)   (cast(enum OpArgMask, (luaP_opmodes[m] >> 2) & 3))
277#define testAMode(m)   (luaP_opmodes[m] & (1 << 6))
278#define testTMode(m)   (luaP_opmodes[m] & (1 << 7))
274#define getOpMode(m)    (cast(enum OpMode, luaP_opmodes[m] & 3))
275#define getBMode(m) (cast(enum OpArgMask, (luaP_opmodes[m] >> 4) & 3))
276#define getCMode(m) (cast(enum OpArgMask, (luaP_opmodes[m] >> 2) & 3))
277#define testAMode(m)    (luaP_opmodes[m] & (1 << 6))
278#define testTMode(m)    (luaP_opmodes[m] & (1 << 7))
279279
280280
281281LUAI_DDEC const char *const luaP_opnames[NUM_OPCODES+1];  /* opcode names */
282282
283283
284284/* number of list items to accumulate before a SETLIST instruction */
285#define LFIELDS_PER_FLUSH   50
285#define LFIELDS_PER_FLUSH   50
286286
287287
288288#endif
trunk/src/lib/lua/lzio.h
r31374r31375
1313#include "lmem.h"
1414
1515
16#define EOZ   (-1)         /* end of stream */
16#define EOZ (-1)            /* end of stream */
1717
1818typedef struct Zio ZIO;
1919
r31374r31375
2121
2222
2323typedef struct Mbuffer {
24  char *buffer;
25  size_t n;
26  size_t buffsize;
24   char *buffer;
25   size_t n;
26   size_t buffsize;
2727} Mbuffer;
2828
2929#define luaZ_initbuffer(L, buff) ((buff)->buffer = NULL, (buff)->buffsize = 0)
3030
31#define luaZ_buffer(buff)   ((buff)->buffer)
32#define luaZ_sizebuffer(buff)   ((buff)->buffsize)
33#define luaZ_bufflen(buff)   ((buff)->n)
31#define luaZ_buffer(buff)   ((buff)->buffer)
32#define luaZ_sizebuffer(buff)   ((buff)->buffsize)
33#define luaZ_bufflen(buff)  ((buff)->n)
3434
3535#define luaZ_resetbuffer(buff) ((buff)->n = 0)
3636
r31374r31375
3939   (luaM_reallocvector(L, (buff)->buffer, (buff)->buffsize, size, char), \
4040   (buff)->buffsize = size)
4141
42#define luaZ_freebuffer(L, buff)   luaZ_resizebuffer(L, buff, 0)
42#define luaZ_freebuffer(L, buff)    luaZ_resizebuffer(L, buff, 0)
4343
4444
4545LUAI_FUNC char *luaZ_openspace (lua_State *L, Mbuffer *buff, size_t n);
4646LUAI_FUNC void luaZ_init (lua_State *L, ZIO *z, lua_Reader reader,
47                                        void *data);
48LUAI_FUNC size_t luaZ_read (ZIO* z, void* b, size_t n);   /* read next n bytes */
47                              void *data);
48LUAI_FUNC size_t luaZ_read (ZIO* z, void* b, size_t n); /* read next n bytes */
4949
5050
5151
5252/* --------- Private Part ------------------ */
5353
5454struct Zio {
55  size_t n;         /* bytes still unread */
56  const char *p;      /* current position in buffer */
57  lua_Reader reader;      /* reader function */
58  void* data;         /* additional data */
59  lua_State *L;         /* Lua state (for reader) */
55   size_t n;           /* bytes still unread */
56   const char *p;      /* current position in buffer */
57   lua_Reader reader;      /* reader function */
58   void* data;         /* additional data */
59   lua_State *L;           /* Lua state (for reader) */
6060};
6161
6262
trunk/src/lib/lua/ldo.h
r31374r31375
1313#include "lzio.h"
1414
1515
16#define luaD_checkstack(L,n)   if (L->stack_last - L->top <= (n)) \
17                luaD_growstack(L, n); else condmovestack(L);
16#define luaD_checkstack(L,n)    if (L->stack_last - L->top <= (n)) \
17               luaD_growstack(L, n); else condmovestack(L);
1818
1919
2020#define incr_top(L) {L->top++; luaD_checkstack(L,0);}
2121
22#define savestack(L,p)      ((char *)(p) - (char *)L->stack)
23#define restorestack(L,n)   ((TValue *)((char *)L->stack + (n)))
22#define savestack(L,p)      ((char *)(p) - (char *)L->stack)
23#define restorestack(L,n)   ((TValue *)((char *)L->stack + (n)))
2424
2525
2626/* type of protected functions, to be ran by `runprotected' */
2727typedef void (*Pfunc) (lua_State *L, void *ud);
2828
2929LUAI_FUNC int luaD_protectedparser (lua_State *L, ZIO *z, const char *name,
30                                                  const char *mode);
30                                       const char *mode);
3131LUAI_FUNC void luaD_hook (lua_State *L, int event, int line);
3232LUAI_FUNC int luaD_precall (lua_State *L, StkId func, int nresults);
3333LUAI_FUNC void luaD_call (lua_State *L, StkId func, int nResults,
34                                        int allowyield);
34                              int allowyield);
3535LUAI_FUNC int luaD_pcall (lua_State *L, Pfunc func, void *u,
36                                        ptrdiff_t oldtop, ptrdiff_t ef);
36                              ptrdiff_t oldtop, ptrdiff_t ef);
3737LUAI_FUNC int luaD_poscall (lua_State *L, StkId firstResult);
3838LUAI_FUNC void luaD_reallocstack (lua_State *L, int newsize);
3939LUAI_FUNC void luaD_growstack (lua_State *L, int n);
r31374r31375
4343LUAI_FUNC int luaD_rawrunprotected (lua_State *L, Pfunc f, void *ud);
4444
4545#endif
46
trunk/src/lib/lua/lundump.h
r31374r31375
2020LUAI_FUNC int luaU_dump (lua_State* L, const Proto* f, lua_Writer w, void* data, int strip);
2121
2222/* data to catch conversion errors */
23#define LUAC_TAIL      "\x19\x93\r\n\x1a\n"
23#define LUAC_TAIL       "\x19\x93\r\n\x1a\n"
2424
2525/* size in bytes of header of binary files */
26#define LUAC_HEADERSIZE      (sizeof(LUA_SIGNATURE)-sizeof(char)+2+6+sizeof(LUAC_TAIL)-sizeof(char))
26#define LUAC_HEADERSIZE     (sizeof(LUA_SIGNATURE)-sizeof(char)+2+6+sizeof(LUAC_TAIL)-sizeof(char))
2727
2828#endif
trunk/src/lib/lua/lapi.h
r31374r31375
1515            "stack overflow");}
1616
1717#define adjustresults(L,nres) \
18    { if ((nres) == LUA_MULTRET && L->ci->top < L->top) L->ci->top = L->top; }
18   { if ((nres) == LUA_MULTRET && L->ci->top < L->top) L->ci->top = L->top; }
1919
20#define api_checknelems(L,n)   api_check(L, (n) < (L->top - L->ci->func), \
21              "not enough elements in the stack")
20#define api_checknelems(L,n)    api_check(L, (n) < (L->top - L->ci->func), \
21               "not enough elements in the stack")
2222
2323
2424#endif
trunk/src/lib/lua/ltm.h
r31374r31375
1616* grep "ORDER TM"
1717*/
1818typedef enum {
19  TM_INDEX,
20  TM_NEWINDEX,
21  TM_GC,
22  TM_MODE,
23  TM_LEN,
24  TM_EQ,  /* last tag method with `fast' access */
25  TM_ADD,
26  TM_SUB,
27  TM_MUL,
28  TM_DIV,
29  TM_MOD,
30  TM_POW,
31  TM_UNM,
32  TM_LT,
33  TM_LE,
34  TM_CONCAT,
35  TM_CALL,
36  TM_N      /* number of elements in the enum */
19   TM_INDEX,
20   TM_NEWINDEX,
21   TM_GC,
22   TM_MODE,
23   TM_LEN,
24   TM_EQ,  /* last tag method with `fast' access */
25   TM_ADD,
26   TM_SUB,
27   TM_MUL,
28   TM_DIV,
29   TM_MOD,
30   TM_POW,
31   TM_UNM,
32   TM_LT,
33   TM_LE,
34   TM_CONCAT,
35   TM_CALL,
36   TM_N        /* number of elements in the enum */
3737} TMS;
3838
3939
4040
4141#define gfasttm(g,et,e) ((et) == NULL ? NULL : \
42  ((et)->flags & (1u<<(e))) ? NULL : luaT_gettm(et, e, (g)->tmname[e]))
42   ((et)->flags & (1u<<(e))) ? NULL : luaT_gettm(et, e, (g)->tmname[e]))
4343
44#define fasttm(l,et,e)   gfasttm(G(l), et, e)
44#define fasttm(l,et,e)  gfasttm(G(l), et, e)
4545
46#define ttypename(x)   luaT_typenames_[(x) + 1]
47#define objtypename(x)   ttypename(ttypenv(x))
46#define ttypename(x)    luaT_typenames_[(x) + 1]
47#define objtypename(x)  ttypename(ttypenv(x))
4848
4949LUAI_DDEC const char *const luaT_typenames_[LUA_TOTALTAGS];
5050
5151
5252LUAI_FUNC const TValue *luaT_gettm (Table *events, TMS event, TString *ename);
5353LUAI_FUNC const TValue *luaT_gettmbyobj (lua_State *L, const TValue *o,
54                                                       TMS event);
54                                          TMS event);
5555LUAI_FUNC void luaT_init (lua_State *L);
5656
5757#endif
trunk/src/lib/lua/lvm.h
r31374r31375
1515
1616#define tostring(L,o) (ttisstring(o) || (luaV_tostring(L, o)))
1717
18#define tonumber(o,n)   (ttisnumber(o) || (((o) = luaV_tonumber(o,n)) != NULL))
18#define tonumber(o,n)   (ttisnumber(o) || (((o) = luaV_tonumber(o,n)) != NULL))
1919
2020#define equalobj(L,o1,o2)  (ttisequal(o1, o2) && luaV_equalobj_(L, o1, o2))
2121
22#define luaV_rawequalobj(o1,o2)      equalobj(NULL,o1,o2)
22#define luaV_rawequalobj(o1,o2)     equalobj(NULL,o1,o2)
2323
2424
2525/* not to called directly */
r31374r31375
3131LUAI_FUNC const TValue *luaV_tonumber (const TValue *obj, TValue *n);
3232LUAI_FUNC int luaV_tostring (lua_State *L, StkId obj);
3333LUAI_FUNC void luaV_gettable (lua_State *L, const TValue *t, TValue *key,
34                                            StkId val);
34                                 StkId val);
3535LUAI_FUNC void luaV_settable (lua_State *L, const TValue *t, TValue *key,
36                                            StkId val);
36                                 StkId val);
3737LUAI_FUNC void luaV_finishOp (lua_State *L);
3838LUAI_FUNC void luaV_execute (lua_State *L);
3939LUAI_FUNC void luaV_concat (lua_State *L, int total);
4040LUAI_FUNC void luaV_arith (lua_State *L, StkId ra, const TValue *rb,
41                           const TValue *rc, TMS op);
41                     const TValue *rc, TMS op);
4242LUAI_FUNC void luaV_objlen (lua_State *L, StkId ra, const TValue *rb);
4343
4444#endif
trunk/src/lib/lua/ldebug.h
r31374r31375
1111#include "lstate.h"
1212
1313
14#define pcRel(pc, p)   (cast(int, (pc) - (p)->code) - 1)
14#define pcRel(pc, p)    (cast(int, (pc) - (p)->code) - 1)
1515
16#define getfuncline(f,pc)   (((f)->lineinfo) ? (f)->lineinfo[pc] : 0)
16#define getfuncline(f,pc)   (((f)->lineinfo) ? (f)->lineinfo[pc] : 0)
1717
18#define resethookcount(L)   (L->hookcount = L->basehookcount)
18#define resethookcount(L)   (L->hookcount = L->basehookcount)
1919
2020/* Active Lua function (given call info) */
21#define ci_func(ci)      (clLvalue((ci)->func))
21#define ci_func(ci)     (clLvalue((ci)->func))
2222
2323
2424LUAI_FUNC l_noret luaG_typeerror (lua_State *L, const TValue *o,
25                                                const char *opname);
25                                    const char *opname);
2626LUAI_FUNC l_noret luaG_concaterror (lua_State *L, StkId p1, StkId p2);
2727LUAI_FUNC l_noret luaG_aritherror (lua_State *L, const TValue *p1,
28                                                 const TValue *p2);
28                                       const TValue *p2);
2929LUAI_FUNC l_noret luaG_ordererror (lua_State *L, const TValue *p1,
30                                                 const TValue *p2);
30                                       const TValue *p2);
3131LUAI_FUNC l_noret luaG_runerror (lua_State *L, const char *fmt, ...);
3232LUAI_FUNC l_noret luaG_errormsg (lua_State *L);
3333
trunk/src/mess/machine/micropolis.h
r31374r31375
5454      dev.m_floppy_drive_tags[2] = tag3;
5555      dev.m_floppy_drive_tags[3] = tag4;
5656   }
57   
57
5858   void set_drive(UINT8 drive); // set current drive (0-3)
5959
6060   DECLARE_READ8_MEMBER( status_r );
trunk/src/mess/machine/msx_systemflags.h
r31374r31375
3535};
3636
3737#endif
38
trunk/src/mess/machine/smartmed.h
r31374r31375
4343// "Sequential Row Read is available only on K9F5608U0D_Y,P,V,F or K9F5608D0D_Y,P"
4444enum
4545{
46   NAND_CHIP_K9F5608U0D = 0,   // K9F5608U0D
47   NAND_CHIP_K9F5608U0D_J,      // K9F5608U0D-Jxxx
48   NAND_CHIP_K9F5608U0B,      // K9F5608U0B
49   NAND_CHIP_K9F1G08U0B,      // K9F1G08U0B
50   NAND_CHIP_K9LAG08U0M      // K9LAG08U0M
46   NAND_CHIP_K9F5608U0D = 0,   // K9F5608U0D
47   NAND_CHIP_K9F5608U0D_J,     // K9F5608U0D-Jxxx
48   NAND_CHIP_K9F5608U0B,       // K9F5608U0B
49   NAND_CHIP_K9F1G08U0B,       // K9F1G08U0B
50   NAND_CHIP_K9LAG08U0M        // K9LAG08U0M
5151};
5252
5353// ======================> nand_device
r31374r31375
133133            break;
134134      }
135135   }
136   
136
137137   int is_present();
138138   int is_protected();
139139   int is_busy();
r31374r31375
186186   int m_col_address_cycles;
187187   int m_row_address_cycles;
188188   int m_sequential_row_read;
189   
189
190190   devcb_write_line m_write_rnb;
191191
192192   #ifdef SMARTMEDIA_IMAGE_SAVE
trunk/src/mess/machine/msx_matsushita.h
r31374r31375
4444};
4545
4646#endif
47
trunk/src/mess/machine/msx_s1985.h
r31374r31375
2929};
3030
3131#endif
32
trunk/src/mess/machine/mega32x.h
r31374r31375
205205   int m_current_fifo_read_pos;
206206   int m_fifo_block_a_full;
207207   int m_fifo_block_b_full;
208   
208
209209   required_device<palette_device> m_palette;
210210};
211211
trunk/src/mess/machine/ti99/videowrp.h
r31374r31375
143143   MCFG_DEVICE_ADD(_tag, TI99VIDEO, 0)                                     \
144144   MCFG_DEVICE_ADD( VDP_TAG, _chip, XTAL_10_738635MHz / 2 ) \
145145   MCFG_TMS9928A_VRAM_SIZE(_vsize) \
146   MCFG_TMS9928A_OUT_INT_LINE_CB(WRITELINE(_class,_int))   \
146   MCFG_TMS9928A_OUT_INT_LINE_CB(WRITELINE(_class,_int))   \
147147   MCFG_TMS9928A_SCREEN_ADD_PAL( SCREEN_TAG )                              \
148148   MCFG_SCREEN_UPDATE_DEVICE( VDP_TAG, tms9928a_device, screen_update )
149149
r31374r31375
174174   MCFG_SCREEN_SIZE(_x, _y)                                                \
175175   MCFG_SCREEN_VISIBLE_AREA(0, _x - 1, 0, _y - 1)                          \
176176   MCFG_SCREEN_PALETTE(VDP_TAG ":palette")
177   
177
178178#define MCFG_TI_SOUND_94624_ADD(_tag)            \
179179   MCFG_DEVICE_ADD(_tag, TISOUND_94624, 0)
180180
trunk/src/mess/machine/ie15_kbd.h
r31374r31375
4242public:
4343   ie15_keyboard_device(const machine_config &mconfig, device_type type, const char *name, const char *tag, device_t *owner, UINT32 clock, const char *shortname, const char *source);
4444   ie15_keyboard_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
45   
45
4646   template<class _Object> static devcb_base &set_keyboard_callback(device_t &device, _Object object) { return downcast<ie15_keyboard_device &>(device).m_keyboard_cb.set_callback(object); }
4747
4848   virtual ioport_constructor device_input_ports() const;
trunk/src/mess/includes/apollo.h
r31374r31375
330330   virtual void device_reset();
331331
332332private:
333    UINT8 m_csrb;
334    UINT8 m_ip6;
333      UINT8 m_csrb;
334      UINT8 m_ip6;
335335};
336336
337337extern const device_type APOLLO_SIO;
trunk/src/mess/includes/p2000t.h
r31374r31375
2323         m_gfxdecode(*this, "gfxdecode"),
2424         m_palette(*this, "palette"),
2525         m_videoram(*this, "videoram"),
26         m_keyboard(*this, "KEY")   { }
26         m_keyboard(*this, "KEY")    { }
2727
2828   required_device<cpu_device> m_maincpu;
2929   required_device<speaker_sound_device> m_speaker;
trunk/src/mess/includes/thomson.h
r31374r31375
314314
315315   int m_centronics_busy;
316316   int m_centronics_perror;
317   
317
318318   MC6854_OUT_FRAME_CB(to7_network_got_frame);
319319
320320protected:
trunk/src/mess/includes/bebox.h
r31374r31375
110110   LSI53C810_DMA_CB(scsi_dma_callback);
111111
112112   void bebox_set_irq_bit(unsigned int interrupt_bit, int val);
113   void bebox_update_interrupts();   
113   void bebox_update_interrupts();
114114
115115protected:
116116   virtual void device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr);
trunk/src/mess/includes/hec2hrp.h
r31374r31375
9191   optional_shared_ptr<UINT8> m_videoram;
9292   optional_shared_ptr<UINT8> m_hector_videoram;
9393   required_ioport_array<9> m_keyboard;
94   
94
9595   UINT8 m_hector_flag_hr;
9696   UINT8 m_hector_flag_80c;
9797   UINT8 m_hector_color[4];
trunk/src/mess/includes/cybiko.h
r31374r31375
8989   required_device<pcf8593_device> m_rtc;
9090   required_device<ram_device> m_ram;
9191   optional_device<at45db041_device> m_flash1;
92   required_device<nvram_device>    m_nvram;
92   required_device<nvram_device>   m_nvram;
9393   DECLARE_DRIVER_INIT(cybikoxt);
9494   DECLARE_DRIVER_INIT(cybiko);
9595   virtual void machine_start();
trunk/src/mess/includes/apple2.h
r31374r31375
7777   APPLE_II,           // Apple II/II+
7878   APPLE_IIE,          // Apple IIe with aux slots
7979   APPLE_IIGS,         // Apple IIgs
80   APPLE_IIC,         // Apple IIc
81   APPLE_IICPLUS,      // Apple IIc+
80   APPLE_IIC,          // Apple IIc
81   APPLE_IICPLUS,      // Apple IIc+
8282   TK2000,             // Microdigital TK2000
8383   LASER128,           // Laser 128/128EX/128EX2
8484   SPACE84,            // "Space 84" with flipped text mode
trunk/src/mess/includes/hp48.h
r31374r31375
182182
183183   static void set_port_config(device_t &device, int port, int module, int max_size)
184184   {
185      downcast<hp48_port_image_device &>(device).m_port = port;
185      downcast<hp48_port_image_device &>(device).m_port = port;
186186      downcast<hp48_port_image_device &>(device).m_module = module;
187187      downcast<hp48_port_image_device &>(device).m_max_size = max_size;
188188   }
189   
189
190190   // image-level overrides
191191   virtual iodevice_t image_type() const { return IO_MEMCARD; }
192192
trunk/src/mess/includes/newbrain.h
r31374r31375
251251   ADC0808_ANALOG_READ_CB(adc_vref_pos_r);
252252   ADC0808_ANALOG_READ_CB(adc_vref_neg_r);
253253   ADC0808_ANALOG_READ_CB(adc_input_r);
254   
254
255255   TIMER_DEVICE_CALLBACK_MEMBER(ctc_c2_tick);
256256
257257   void bankswitch();
trunk/src/mess/includes/msx.h
r31374r31375
7373
7474#define MCFG_MSX_LAYOUT_DISK2(_tag, _prim, _sec, _page, _numpages, _region, _offset) \
7575   MCFG_MSX_SLOT_DISK2_ADD(_tag, _page, _numpages, _region, _offset, "fdc", "fdc:0", "fdc:1") \
76   msx_state::install_slot_pages(*owner, _prim, _sec, _page, _numpages + 1, device);   /* Memory mapped FDC registers are also accessible through page 2 */
76   msx_state::install_slot_pages(*owner, _prim, _sec, _page, _numpages + 1, device);   /* Memory mapped FDC registers are also accessible through page 2 */
7777
7878#define MCFG_MSX_LAYOUT_DISK3(_tag, _prim, _sec, _page, _numpages, _region, _offset) \
7979   MCFG_MSX_SLOT_DISK3_ADD(_tag, _page, _numpages, _region, _offset, "fdc", "fdc:0", "fdc:1") \
r31374r31375
163163   }
164164
165165   // static configuration helpers
166   static void install_slot_pages(device_t &owner, UINT8 prim, UINT8 sec, UINT8 page, UINT8 numpages, device_t *device);
166   static void install_slot_pages(device_t &owner, UINT8 prim, UINT8 sec, UINT8 page, UINT8 numpages, device_t *device);
167167
168168   DECLARE_ADDRESS_MAP(switched_device_map, 8);
169169   DECLARE_WRITE8_MEMBER(msx_sec_slot_w);
trunk/src/mess/includes/coco.h
r31374r31375
130130
131131   // floating bus
132132   DECLARE_READ8_MEMBER( floating_bus_read )   { return floating_bus_read(); }
133   
133
134134   DECLARE_WRITE_LINE_MEMBER( cart_w ) { cart_w((bool) state); }
135135protected:
136136   // device-level overrides
trunk/src/mess/includes/ql.h
r31374r31375
2727#define ZX8302_TAG  "ic23"
2828#define RS232_A_TAG "ser1"
2929#define RS232_B_TAG "ser2"
30#define QIMI_TAG   "qimi"
30#define QIMI_TAG    "qimi"
3131
3232#define X1 XTAL_15MHz
3333#define X2 XTAL_32_768kHz
trunk/src/mess/includes/dgnalpha.h
r31374r31375
5252   DECLARE_WRITE8_MEMBER( pia2_pa_w );
5353   DECLARE_WRITE_LINE_MEMBER( pia2_firq_a );
5454   DECLARE_WRITE_LINE_MEMBER( pia2_firq_b );
55   
55
5656   /* psg */
5757   DECLARE_READ8_MEMBER( psg_porta_read );
5858   DECLARE_WRITE8_MEMBER( psg_porta_write );
trunk/src/mess/includes/x68k.h
r31374r31375
6363         m_screen(*this, "screen"),
6464         m_upd72065(*this, "upd72065"),
6565         m_options(*this, "options"),
66         m_mouse1(*this, "mouse1"),
67         m_mouse2(*this, "mouse2"),
66         m_mouse1(*this, "mouse1"),
67         m_mouse2(*this, "mouse2"),
6868         m_mouse3(*this, "mouse3"),
6969         m_xpd1lr(*this, "xpd1lr"),
7070         m_ctrltype(*this, "ctrltype"),
trunk/src/mess/video/vtvideo.h
r31374r31375
7171
7272   const char *m_char_rom_tag; /* character rom region */
7373   required_device<palette_device> m_palette;
74   
74
7575   bool m_notify_vblank;
7676   int m_last_scroll;
7777
trunk/src/mess/video/gime.h
r31374r31375
203203   const char *m_maincpu_tag;  /* tag of main CPU */
204204   const char *m_ram_tag;      /* tag of RAM device */
205205   const char *m_ext_tag;      /* tag of expansion device */
206   
206
207207   // timer constants
208208   static const device_timer_id TIMER_FRAME = 0;
209209   static const device_timer_id TIMER_HSYNC_OFF = 1;
trunk/src/mess/video/crt.h
r31374r31375
6060      dev.m_window_width = width;
6161      dev.m_window_height = height;
6262   }
63   
63
6464   void plot(int x, int y);
6565   void eof();
6666   void update(bitmap_ind16 &bitmap);
67   
67
6868protected:
6969   // device-level overrides
7070   virtual void device_start();
trunk/src/mess/mess.lst
r31374r31375
704704c128dcr_se
705705c128d81
706706
707a1000      // Commodore Amiga 1000
707a1000       // Commodore Amiga 1000
708708a1000n
709a2000      // Commodore Amiga 2000
709a2000       // Commodore Amiga 2000
710710a2000n
711a500       // Commodore Amiga 500
711a500        // Commodore Amiga 500
712712a500n
713cdtv      // Commodore CDTV
713cdtv        // Commodore CDTV
714714cdtvn
715a3000      // Commodore Amiga 3000
715a3000       // Commodore Amiga 3000
716716a3000n
717a500p      // Commodore Amiga 500 Plus
717a500p       // Commodore Amiga 500 Plus
718718a500pn
719a600      // Commodore Amiga 600
719a600        // Commodore Amiga 600
720720a600n
721a1200      // Commodore Amiga 1200
721a1200       // Commodore Amiga 1200
722722a1200n
723a4000      // Commodore Amiga 4000/040
723a4000       // Commodore Amiga 4000/040
724724a4000n
725a400030      // Commodore Amiga 4000/030
725a400030     // Commodore Amiga 4000/030
726726a400030n
727cd32      // Commodore Amiga CD32
727cd32        // Commodore Amiga CD32
728728cd32n
729a4000t      // Commodore Amiga 4000T
729a4000t      // Commodore Amiga 4000T
730730a4000tn
731731
732732c65    // 1991 C65 / C64DX (Prototype, NTSC)
r31374r31375
860860aprpand
861861aprfte
862862megapc // 1992 Amstrad plc
863megapcpl
863megapcpl
864864megapcpla // AMI BIOS version with Winbond WINBUS chipset
865865ec1849
866866t2000sx
r31374r31375
19151915fmtownssj  // FM-Towns II SJ
19161916fmtownshr  // 1992 FM-Towns II HR
19171917fmtownsmx  // FM-Towns II MX
1918fmtownsftv  // 1994 FM-Towns II FreshTV
1918fmtownsftv  // 1994 FM-Towns II FreshTV
19191919fmtmarty  // 1993 Fujitsu FM-Towns Marty
19201920fmtmarty2  // 1993 Fujitsu FM-Towns Marty 2
19211921carmarty  // Fujitsu FM-Towns Car Marty
trunk/src/mess/layout/fb01.lay
r31374r31375
7575   </element>
7676
7777<!--
78  System   Inst      Data Entry   Data Entry
79   Setup   Select    -1/No        +1/Yes
78   System   Inst      Data Entry   Data Entry
79   Setup   Select    -1/No        +1/Yes
8080
81  Inst     Inst      Voice        Voice
82  Assign   Function  Function     Select
81   Inst     Inst      Voice        Voice
82   Assign   Function  Function     Select
8383
8484-->
8585

Previous 199869 Revisions Next


© 1997-2024 The MAME Team