| 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 |
| r31374 | r31375 | |
|---|---|---|
| 63 | 63 | <description>Kundregister</description> |
| 64 | 64 | <year>19??</year> |
| 65 | 65 | <publisher><unknown></publisher> |
| 66 | ||
| 66 | ||
| 67 | 67 | <part name="flop1" interface="floppy_5_25"> |
| 68 | 68 | <dataarea name="flop" size="79143"> |
| 69 | 69 | <rom name="fd2_bifak.imd" size="79143" crc="a741ad5d" sha1="a0cb8cc31a30fcbea258dd5249845819930e60c2" offset="0" /> |
| r31374 | r31375 | |
|---|---|---|
| 836 | 836 | <info name="alt_title" value="ミケランジェロⅡ" /> |
| 837 | 837 | <part name="cart" interface="msx_cart"> |
| 838 | 838 | <feature name="pcb" value="1M-8KB" /> |
| 839 | ||
| 839 | <feature name="slot" value="ascii8" /> | |
| 840 | 840 | <feature name="mapper" value="NEOS MR6401" /> |
| 841 | 841 | <dataarea name="rom" size="131072"> |
| 842 | 842 | <rom name="rp231024d" size="131072" crc="" sha1="" offset="0" /> |
| r31374 | r31375 | |
| 3167 | 3167 | </part> |
| 3168 | 3168 | </software> |
| 3169 | 3169 | |
| 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 | |
| 3171 | 3171 | combined in one software description including the Sound cartridge and the floppies. |
| 3172 | 3172 | This sound cartridge can _not_ be used with the MSX Game Collections from Konami. |
| 3173 | 3173 | --> |
| r31374 | r31375 | |
| 3177 | 3177 | <publisher>Konami</publisher> |
| 3178 | 3178 | <part name="cart" interface="msx_cart"> |
| 3179 | 3179 | <feature name="slot" value="sound_sdsnatch" /> |
| 3180 | <dataarea name="ram" size="65536"> | |
| 3180 | <dataarea name="ram" size="65536"> | |
| 3181 | 3181 | </dataarea> |
| 3182 | 3182 | </part> |
| 3183 | 3183 | </software> |
| r31374 | r31375 | |
|---|---|---|
| 13 | 13 | </dataarea> |
| 14 | 14 | </part> |
| 15 | 15 | </software> |
| 16 | ||
| 16 | ||
| 17 | 17 | </softwarelist> |
| r31374 | r31375 | |
|---|---|---|
| 2 | 2 | <!DOCTYPE softwarelist SYSTEM "softwarelist.dtd"> |
| 3 | 3 | |
| 4 | 4 | <softwarelist name="hp9845a_rom" description="HP 9845A/S Option ROMs"> |
| 5 | ||
| 5 | ||
| 6 | 6 | <software name="mass"> |
| 7 | 7 | <description>Mass Storage</description> |
| 8 | 8 | <year>198?</year> |
| r31374 | r31375 | |
| 15 | 15 | </dataarea> |
| 16 | 16 | </part> |
| 17 | 17 | </software> |
| 18 | ||
| 18 | ||
| 19 | 19 | <software name="iolpu"> |
| 20 | 20 | <description>I/O LPU</description> |
| 21 | 21 | <year>198?</year> |
| r31374 | r31375 | |
| 28 | 28 | </dataarea> |
| 29 | 29 | </part> |
| 30 | 30 | </software> |
| 31 | ||
| 31 | ||
| 32 | 32 | <software name="ioppu"> |
| 33 | 33 | <description>I/O PPU</description> |
| 34 | 34 | <year>198?</year> |
| r31374 | r31375 | |
| 41 | 41 | </dataarea> |
| 42 | 42 | </part> |
| 43 | 43 | </software> |
| 44 | ||
| 44 | ||
| 45 | 45 | <software name="graphics"> |
| 46 | 46 | <description>Graphics</description> |
| 47 | 47 | <year>198?</year> |
| r31374 | r31375 | |
| 54 | 54 | </dataarea> |
| 55 | 55 | </part> |
| 56 | 56 | </software> |
| 57 | ||
| 57 | ||
| 58 | 58 | <software name="pdr45"> |
| 59 | 59 | <description>PDR-45</description> |
| 60 | 60 | <year>198?</year> |
| r31374 | r31375 | |
| 68 | 68 | </dataarea> |
| 69 | 69 | </part> |
| 70 | 70 | </software> |
| 71 | ||
| 71 | ||
| 72 | 72 | <software name="progtkit"> |
| 73 | 73 | <description>Programmer's Toolkit</description> |
| 74 | 74 | <year>198?</year> |
| r31374 | r31375 | |
| 82 | 82 | </dataarea> |
| 83 | 83 | </part> |
| 84 | 84 | </software> |
| 85 | ||
| 85 | ||
| 86 | 86 | <software name="cfmms"> |
| 87 | 87 | <description>HP 9845B Command File/Memory Mass Storage ROM (Rev A)</description> |
| 88 | 88 | <year>198?</year> |
| r31374 | r31375 | |
| 95 | 95 | </dataarea> |
| 96 | 96 | </part> |
| 97 | 97 | </software> |
| 98 | ||
| 98 | ||
| 99 | 99 | <software name="cfmmsb" cloneof="cfmms"> |
| 100 | 100 | <description>HP 9845B Command File/Memory Mass Storage ROM (Rev B)</description> |
| 101 | 101 | <year>198?</year> |
| r31374 | r31375 | |
|---|---|---|
| 1038 | 1038 | <info name="alt_title" value="スーパーレイドック(THE LINKS NETWORK VERSION)" /> |
| 1039 | 1039 | <part name="cart" interface="msx_cart"> |
| 1040 | 1040 | <feature name="pcb" value="TA6228" /> |
| 1041 | ||
| 1041 | <feature name="slot" value="ascii8" /> | |
| 1042 | 1042 | <feature name="mapper" value="M60002-0125SP" /> |
| 1043 | 1043 | <dataarea name="rom" size="262144"> |
| 1044 | 1044 | <rom name="lh532045" size="262144" crc="" sha1="" offset="0" /> |
| r31374 | r31375 | |
| 1071 | 1071 | <info name="alt_title" value="シンセサウルス" /> |
| 1072 | 1072 | <part name="cart" interface="msx_cart"> |
| 1073 | 1073 | <feature name="pcb" value="TAS-1M-008S" /> |
| 1074 | ||
| 1074 | <feature name="slot" value="ascii8" /> | |
| 1075 | 1075 | <feature name="mapper" value="LZ93A13" /> |
| 1076 | 1076 | <dataarea name="rom" size="131072"> |
| 1077 | 1077 | <rom name="m5m27512p" size="131072" crc="" sha1="" offset="0" /> |
| r31374 | r31375 | |
| 1088 | 1088 | <info name="alt_title" value="シンセサウルス" /> |
| 1089 | 1089 | <part name="cart" interface="msx_cart"> |
| 1090 | 1090 | <feature name="pcb" value="TAS-2M008-E2M" /> |
| 1091 | ||
| 1091 | <feature name="slot" value="ascii8" /> | |
| 1092 | 1092 | <feature name="mapper" value="LZ93A13" /> |
| 1093 | 1093 | <dataarea name="rom" size="262144"> |
| 1094 | 1094 | <rom name="m5m27512p" size="131072" crc="" sha1="" offset="0" /> |
| r31374 | r31375 | |
| 14568 | 14568 | <!-- |
| 14569 | 14569 | This memory is currently declared as a memory region inside the nms1205 implementation otherwise the |
| 14570 | 14570 | legacy FM implementations cannot find it. |
| 14571 | <dataarea name="ram" size="32768"> | |
| 14572 | </dataarea> | |
| 14571 | <dataarea name="ram" size="32768"> | |
| 14572 | </dataarea> | |
| 14573 | 14573 | --> |
| 14574 | 14574 | </part> |
| 14575 | 14575 | </software> |
| 14576 | 14576 | |
| 14577 | 14577 | <!-- |
| 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> | |
| 14588 | 14588 | <!- - |
| 14589 | 14589 | This memory is currently declared as a memory region inside the nms1205 implementation otherwise the |
| 14590 | 14590 | legacy FM implementations cannot find it. |
| 14591 | <dataarea name="ram" size="32768"> | |
| 14592 | </dataarea> | |
| 14591 | <dataarea name="ram" size="32768"> | |
| 14592 | </dataarea> | |
| 14593 | 14593 | - -> |
| 14594 | </part> | |
| 14595 | </software> | |
| 14594 | </part> | |
| 14595 | </software> | |
| 14596 | 14596 | --> |
| 14597 | 14597 | |
| 14598 | 14598 | <!-- Dictionary ROMs? --> |
| r31374 | r31375 | |
|---|---|---|
| 297 | 297 | </software> |
| 298 | 298 | |
| 299 | 299 | <!-- |
| 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> | |
| 310 | 310 | --> |
| 311 | 311 | |
| 312 | 312 | <software name="arc"> |
| r31374 | r31375 | |
|---|---|---|
| 3262 | 3262 | </software> |
| 3263 | 3263 | |
| 3264 | 3264 | <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 | |
| 3266 | 3266 | the rom was overdumped to 4MiB likely due to header based dumping tools, the right size "should be" 1MiB --> |
| 3267 | 3267 | <description>Contra IV - The Alien Wars (USA, Prototype)</description> |
| 3268 | 3268 | <year>1992</year> |
| r31374 | r31375 | |
|---|---|---|
| 21 | 21 | |
| 22 | 22 | <softwarelist name="neogeo" description="SNK Neo-Geo cartridges"> |
| 23 | 23 | |
| 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 | ***************************************--> | |
| 31 | 31 | |
| 32 | 32 | <software name="nam1975"> |
| 33 | 33 | <!-- MVS AND AES VERSION --> |
| r31374 | r31375 | |
| 80 | 80 | </part> |
| 81 | 81 | </software> |
| 82 | 82 | |
| 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 | |
| 89 | 89 | ***************************************--> |
| 90 | 90 | |
| 91 | 91 | |
| r31374 | r31375 | |
| 191 | 191 | </part> |
| 192 | 192 | </software> |
| 193 | 193 | |
| 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 | |
| 200 | 200 | ***************************************--> |
| 201 | 201 | |
| 202 | 202 | <software name="tpgolf"> |
| r31374 | r31375 | |
| 258 | 258 | </part> |
| 259 | 259 | </software> |
| 260 | 260 | |
| 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 | |
| 267 | 267 | ***************************************--> |
| 268 | 268 | |
| 269 | 269 | <software name="mahretsu"> |
| r31374 | r31375 | |
| 313 | 313 | </part> |
| 314 | 314 | </software> |
| 315 | 315 | |
| 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 | |
| 322 | 322 | ***************************************--> |
| 323 | 323 | |
| 324 | 324 | <software name="maglord"> |
| r31374 | r31375 | |
| 415 | 415 | </part> |
| 416 | 416 | </software> |
| 417 | 417 | |
| 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 | |
| 424 | 424 | ***************************************--> |
| 425 | 425 | |
| 426 | 426 | <software name="ridhero"> |
| r31374 | r31375 | |
| 528 | 528 | </part> |
| 529 | 529 | </software> |
| 530 | 530 | |
| 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 | |
| 537 | 537 | ***************************************--> |
| 538 | 538 | |
| 539 | 539 | <software name="alpham2"> |
| r31374 | r31375 | |
| 616 | 616 | </part> |
| 617 | 617 | </software> |
| 618 | 618 | |
| 619 | <!--*************************************** | |
| 620 | ID-0008 | |
| 621 | Sunshine (prototype) 1990 SNK | |
| 619 | <!--*************************************** | |
| 620 | ID-0008 | |
| 621 | Sunshine (prototype) 1990 SNK | |
| 622 | 622 | ***************************************--> |
| 623 | 623 | |
| 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 | |
| 630 | 630 | ***************************************--> |
| 631 | 631 | |
| 632 | 632 | <software name="ncombat"> |
| r31374 | r31375 | |
| 727 | 727 | </part> |
| 728 | 728 | </software> |
| 729 | 729 | |
| 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 | |
| 735 | 735 | ***************************************--> |
| 736 | 736 | |
| 737 | 737 | <software name="cyberlip"> |
| r31374 | r31375 | |
| 785 | 785 | </part> |
| 786 | 786 | </software> |
| 787 | 787 | |
| 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 | |
| 794 | 794 | ***************************************--> |
| 795 | 795 | |
| 796 | 796 | <software name="superspy"> |
| r31374 | r31375 | |
| 838 | 838 | </part> |
| 839 | 839 | </software> |
| 840 | 840 | |
| 841 | <!--*************************************** | |
| 842 | ID-0012 | |
| 843 | unknown | |
| 841 | <!--*************************************** | |
| 842 | ID-0012 | |
| 843 | unknown | |
| 844 | 844 | ***************************************--> |
| 845 | 845 | |
| 846 | <!--*************************************** | |
| 847 | ID-0013 | |
| 848 | unknown | |
| 846 | <!--*************************************** | |
| 847 | ID-0013 | |
| 848 | unknown | |
| 849 | 849 | ***************************************--> |
| 850 | 850 | |
| 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 | |
| 857 | 857 | ***************************************--> |
| 858 | 858 | |
| 859 | 859 | <software name="mutnat"> |
| r31374 | r31375 | |
| 895 | 895 | </part> |
| 896 | 896 | </software> |
| 897 | 897 | |
| 898 | <!--*************************************** | |
| 899 | ID-0015 | |
| 900 | unknown | |
| 898 | <!--*************************************** | |
| 899 | ID-0015 | |
| 900 | unknown | |
| 901 | 901 | ***************************************--> |
| 902 | 902 | |
| 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 | |
| 910 | 910 | ***************************************--> |
| 911 | 911 | |
| 912 | 912 | <software name="kotm"> |
| r31374 | r31375 | |
| 991 | 991 | </part> |
| 992 | 992 | </software> |
| 993 | 993 | |
| 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 | |
| 1000 | 1000 | ***************************************--> |
| 1001 | 1001 | |
| 1002 | 1002 | <software name="sengoku"> |
| r31374 | r31375 | |
| 1081 | 1081 | </part> |
| 1082 | 1082 | </software> |
| 1083 | 1083 | |
| 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 | |
| 1092 | 1092 | ***************************************--> |
| 1093 | 1093 | |
| 1094 | 1094 | <software name="burningf"> |
| r31374 | r31375 | |
| 1208 | 1208 | </part> |
| 1209 | 1209 | </software> |
| 1210 | 1210 | |
| 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 | |
| 1217 | 1217 | ***************************************--> |
| 1218 | 1218 | |
| 1219 | 1219 | <software name="lbowling"> |
| r31374 | r31375 | |
| 1259 | 1259 | </part> |
| 1260 | 1260 | </software> |
| 1261 | 1261 | |
| 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 | |
| 1268 | 1268 | ***************************************--> |
| 1269 | 1269 | |
| 1270 | 1270 | <software name="gpilots"> |
| r31374 | r31375 | |
| 1357 | 1357 | </part> |
| 1358 | 1358 | </software> |
| 1359 | 1359 | |
| 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 | |
| 1366 | 1366 | ***************************************--> |
| 1367 | 1367 | |
| 1368 | 1368 | <software name="joyjoy"> |
| r31374 | r31375 | |
| 1402 | 1402 | </part> |
| 1403 | 1403 | </software> |
| 1404 | 1404 | |
| 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 | |
| 1411 | 1411 | ***************************************--> |
| 1412 | 1412 | |
| 1413 | 1413 | <software name="bjourney"> |
| r31374 | r31375 | |
| 1449 | 1449 | </part> |
| 1450 | 1450 | </software> |
| 1451 | 1451 | |
| 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 | |
| 1458 | 1458 | ***************************************--> |
| 1459 | 1459 | |
| 1460 | 1460 | <software name="quizdais"> |
| r31374 | r31375 | |
| 1518 | 1518 | </part> |
| 1519 | 1519 | </software> |
| 1520 | 1520 | |
| 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 | |
| 1526 | 1526 | ***************************************--> |
| 1527 | 1527 | |
| 1528 | 1528 | <software name="lresort"> |
| r31374 | r31375 | |
| 1563 | 1563 | </part> |
| 1564 | 1564 | </software> |
| 1565 | 1565 | |
| 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 | |
| 1572 | 1572 | ***************************************--> |
| 1573 | 1573 | |
| 1574 | 1574 | <software name="eightman"> |
| r31374 | r31375 | |
| 1610 | 1610 | </part> |
| 1611 | 1611 | </software> |
| 1612 | 1612 | |
| 1613 | <!--*************************************** | |
| 1614 | ID-0026 | |
| 1615 | Fun Fun Brothers (prototype) 1991 Alpha | |
| 1613 | <!--*************************************** | |
| 1614 | ID-0026 | |
| 1615 | Fun Fun Brothers (prototype) 1991 Alpha | |
| 1616 | 1616 | ***************************************--> |
| 1617 | 1617 | |
| 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 | |
| 1624 | 1624 | ***************************************--> |
| 1625 | 1625 | |
| 1626 | 1626 | <software name="minasan"> |
| r31374 | r31375 | |
| 1664 | 1664 | </part> |
| 1665 | 1665 | </software> |
| 1666 | 1666 | |
| 1667 | <!--*************************************** | |
| 1668 | ID-0028 | |
| 1669 | Dunk Star (prototype) Sammy | |
| 1667 | <!--*************************************** | |
| 1668 | ID-0028 | |
| 1669 | Dunk Star (prototype) Sammy | |
| 1670 | 1670 | ***************************************--> |
| 1671 | 1671 | |
| 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 | |
| 1677 | 1677 | ***************************************--> |
| 1678 | 1678 | |
| 1679 | 1679 | <software name="legendos"> |
| r31374 | r31375 | |
| 1712 | 1712 | </part> |
| 1713 | 1713 | </software> |
| 1714 | 1714 | |
| 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 | |
| 1721 | 1721 | ***************************************--> |
| 1722 | 1722 | |
| 1723 | 1723 | <software name="2020bb"> |
| r31374 | r31375 | |
| 1835 | 1835 | </part> |
| 1836 | 1836 | </software> |
| 1837 | 1837 | |
| 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 | |
| 1844 | 1844 | ***************************************--> |
| 1845 | 1845 | |
| 1846 | 1846 | <software name="socbrawl"> |
| r31374 | r31375 | |
| 1921 | 1921 | </part> |
| 1922 | 1922 | </software> |
| 1923 | 1923 | |
| 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 | |
| 1930 | 1930 | ***************************************--> |
| 1931 | 1931 | |
| 1932 | 1932 | <software name="roboarmy"> |
| r31374 | r31375 | |
| 1968 | 1968 | </software> |
| 1969 | 1969 | |
| 1970 | 1970 | |
| 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 | |
| 1977 | 1977 | ***************************************--> |
| 1978 | 1978 | |
| 1979 | 1979 | <software name="fatfury1"> |
| r31374 | r31375 | |
| 2019 | 2019 | </part> |
| 2020 | 2020 | </software> |
| 2021 | 2021 | |
| 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 | |
| 2028 | 2028 | ***************************************--> |
| 2029 | 2029 | |
| 2030 | 2030 | <software name="fbfrenzy"> |
| r31374 | r31375 | |
| 2066 | 2066 | </part> |
| 2067 | 2067 | </software> |
| 2068 | 2068 | |
| 2069 | <!--*************************************** | |
| 2070 | ID-0035 | |
| 2071 | Mystic Wand (prototype) 1991 Alpha | |
| 2069 | <!--*************************************** | |
| 2070 | ID-0035 | |
| 2071 | Mystic Wand (prototype) 1991 Alpha | |
| 2072 | 2072 | ***************************************--> |
| 2073 | 2073 | |
| 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 | |
| 2080 | 2080 | ***************************************--> |
| 2081 | 2081 | |
| 2082 | 2082 | <software name="bakatono"> |
| r31374 | r31375 | |
| 2118 | 2118 | </part> |
| 2119 | 2119 | </software> |
| 2120 | 2120 | |
| 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 | |
| 2127 | 2127 | ***************************************--> |
| 2128 | 2128 | |
| 2129 | 2129 | <software name="crsword"> |
| r31374 | r31375 | |
| 2163 | 2163 | </part> |
| 2164 | 2164 | </software> |
| 2165 | 2165 | |
| 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 | |
| 2172 | 2172 | ***************************************--> |
| 2173 | 2173 | |
| 2174 | 2174 | <software name="trally"> |
| r31374 | r31375 | |
| 2216 | 2216 | </part> |
| 2217 | 2217 | </software> |
| 2218 | 2218 | |
| 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 | |
| 2225 | 2225 | ***************************************--> |
| 2226 | 2226 | |
| 2227 | 2227 | <software name="kotm2"> |
| r31374 | r31375 | |
| 2309 | 2309 | </part> |
| 2310 | 2310 | </software> |
| 2311 | 2311 | |
| 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 | |
| 2317 | 2317 | ***************************************--> |
| 2318 | 2318 | |
| 2319 | 2319 | <software name="sengoku2"> |
| r31374 | r31375 | |
| 2348 | 2348 | </part> |
| 2349 | 2349 | </software> |
| 2350 | 2350 | |
| 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 | |
| 2356 | 2356 | ***************************************--> |
| 2357 | 2357 | |
| 2358 | 2358 | <software name="bstars2"> |
| r31374 | r31375 | |
| 2395 | 2395 | </part> |
| 2396 | 2396 | </software> |
| 2397 | 2397 | |
| 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 | |
| 2404 | 2404 | ***************************************--> |
| 2405 | 2405 | |
| 2406 | 2406 | <software name="quizdai2"> |
| r31374 | r31375 | |
| 2442 | 2442 | </part> |
| 2443 | 2443 | </software> |
| 2444 | 2444 | |
| 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 | |
| 2451 | 2451 | ***************************************--> |
| 2452 | 2452 | |
| 2453 | 2453 | <software name="3countb"> |
| r31374 | r31375 | |
| 2494 | 2494 | </part> |
| 2495 | 2495 | </software> |
| 2496 | 2496 | |
| 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 | |
| 2503 | 2503 | ***************************************--> |
| 2504 | 2504 | |
| 2505 | 2505 | <software name="aof"> |
| r31374 | r31375 | |
| 2545 | 2545 | </part> |
| 2546 | 2546 | </software> |
| 2547 | 2547 | |
| 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 | |
| 2554 | 2554 | ***************************************--> |
| 2555 | 2555 | |
| 2556 | 2556 | <software name="samsho"> |
| r31374 | r31375 | |
| 2643 | 2643 | </part> |
| 2644 | 2644 | </software> |
| 2645 | 2645 | |
| 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] | |
| 2652 | 2652 | ***************************************--> |
| 2653 | 2653 | |
| 2654 | 2654 | <software name="tophuntr"> |
| r31374 | r31375 | |
| 2757 | 2757 | </part> |
| 2758 | 2758 | </software> |
| 2759 | 2759 | |
| 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 | |
| 2766 | 2766 | ***************************************--> |
| 2767 | 2767 | |
| 2768 | 2768 | <software name="fatfury2"> |
| r31374 | r31375 | |
| 2810 | 2810 | </part> |
| 2811 | 2811 | </software> |
| 2812 | 2812 | |
| 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 | |
| 2817 | 2817 | ***************************************--> |
| 2818 | 2818 | |
| 2819 | 2819 | <software name="janshin"> |
| r31374 | r31375 | |
| 2849 | 2849 | </part> |
| 2850 | 2850 | </software> |
| 2851 | 2851 | |
| 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 | |
| 2858 | 2858 | ***************************************--> |
| 2859 | 2859 | |
| 2860 | 2860 | <software name="androdun"> |
| r31374 | r31375 | |
| 2892 | 2892 | </part> |
| 2893 | 2893 | </software> |
| 2894 | 2894 | |
| 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 | |
| 2900 | 2900 | ***************************************--> |
| 2901 | 2901 | |
| 2902 | 2902 | <software name="ncommand"> |
| r31374 | r31375 | |
| 2937 | 2937 | </part> |
| 2938 | 2938 | </software> |
| 2939 | 2939 | |
| 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 | |
| 2945 | 2945 | ***************************************--> |
| 2946 | 2946 | |
| 2947 | 2947 | <software name="viewpoin"> |
| r31374 | r31375 | |
| 2981 | 2981 | </part> |
| 2982 | 2982 | </software> |
| 2983 | 2983 | |
| 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 | |
| 2989 | 2989 | ***************************************--> |
| 2990 | 2990 | |
| 2991 | 2991 | <software name="ssideki"> |
| r31374 | r31375 | |
| 3023 | 3023 | </part> |
| 3024 | 3024 | </software> |
| 3025 | 3025 | |
| 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 | |
| 3032 | 3032 | ***************************************--> |
| 3033 | 3033 | |
| 3034 | 3034 | <software name="wh1"> |
| r31374 | r31375 | |
| 3159 | 3159 | </part> |
| 3160 | 3160 | </software> |
| 3161 | 3161 | |
| 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) | |
| 3165 | 3165 | ***************************************--> |
| 3166 | 3166 | |
| 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 | |
| 3173 | 3173 | ***************************************--> |
| 3174 | 3174 | |
| 3175 | 3175 | <software name="kof94"> |
| r31374 | r31375 | |
| 3222 | 3222 | </part> |
| 3223 | 3223 | </software> |
| 3224 | 3224 | |
| 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] | |
| 3231 | 3231 | ***************************************--> |
| 3232 | 3232 | |
| 3233 | 3233 | <software name="aof2"> |
| r31374 | r31375 | |
| 3333 | 3333 | </part> |
| 3334 | 3334 | </software> |
| 3335 | 3335 | |
| 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 | |
| 3342 | 3342 | ***************************************--> |
| 3343 | 3343 | |
| 3344 | 3344 | <software name="wh2"> |
| r31374 | r31375 | |
| 3385 | 3385 | </part> |
| 3386 | 3386 | </software> |
| 3387 | 3387 | |
| 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 | |
| 3394 | 3394 | ***************************************--> |
| 3395 | 3395 | |
| 3396 | 3396 | <software name="fatfursp"> |
| r31374 | r31375 | |
| 3491 | 3491 | </part> |
| 3492 | 3492 | </software> |
| 3493 | 3493 | |
| 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 | |
| 3499 | 3499 | ***************************************--> |
| 3500 | 3500 | |
| 3501 | 3501 | <software name="savagere"> |
| r31374 | r31375 | |
| 3547 | 3547 | </part> |
| 3548 | 3548 | </software> |
| 3549 | 3549 | |
| 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 | |
| 3554 | 3554 | ***************************************--> |
| 3555 | 3555 | |
| 3556 | 3556 | <software name="fightfev"> |
| r31374 | r31375 | |
| 3634 | 3634 | </part> |
| 3635 | 3635 | </software> |
| 3636 | 3636 | |
| 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] | |
| 3643 | 3643 | ***************************************--> |
| 3644 | 3644 | |
| 3645 | 3645 | <software name="ssideki2"> |
| r31374 | r31375 | |
| 3682 | 3682 | </part> |
| 3683 | 3683 | </software> |
| 3684 | 3684 | |
| 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 | |
| 3690 | 3690 | ***************************************--> |
| 3691 | 3691 | |
| 3692 | 3692 | <software name="spinmast"> |
| r31374 | r31375 | |
| 3735 | 3735 | </part> |
| 3736 | 3736 | </software> |
| 3737 | 3737 | |
| 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 | |
| 3744 | 3744 | ***************************************--> |
| 3745 | 3745 | |
| 3746 | 3746 | <software name="samsho2"> |
| r31374 | r31375 | |
| 3851 | 3851 | </part> |
| 3852 | 3852 | </software> |
| 3853 | 3853 | |
| 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 | |
| 3860 | 3860 | ***************************************--> |
| 3861 | 3861 | |
| 3862 | 3862 | <software name="wh2j"> |
| r31374 | r31375 | |
| 3907 | 3907 | </part> |
| 3908 | 3908 | </software> |
| 3909 | 3909 | |
| 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 | |
| 3915 | 3915 | ***************************************--> |
| 3916 | 3916 | |
| 3917 | 3917 | <software name="wjammers"> |
| r31374 | r31375 | |
| 3956 | 3956 | </part> |
| 3957 | 3957 | </software> |
| 3958 | 3958 | |
| 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 | |
| 3964 | 3964 | ***************************************--> |
| 3965 | 3965 | |
| 3966 | 3966 | <software name="karnovr"> |
| r31374 | r31375 | |
| 4003 | 4003 | </part> |
| 4004 | 4004 | </software> |
| 4005 | 4005 | |
| 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 | |
| 4010 | 4010 | ***************************************--> |
| 4011 | 4011 | |
| 4012 | 4012 | <software name="gururin"> |
| r31374 | r31375 | |
| 4042 | 4042 | </part> |
| 4043 | 4043 | </software> |
| 4044 | 4044 | |
| 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 | |
| 4049 | 4049 | ***************************************--> |
| 4050 | 4050 | |
| 4051 | 4051 | <software name="pspikes2"> |
| r31374 | r31375 | |
| 4093 | 4093 | </part> |
| 4094 | 4094 | </software> |
| 4095 | 4095 | |
| 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 | |
| 4100 | 4100 | . NGH-069 |
| 4101 | ||
| 4101 | NEO-AEG PROGBK1Y / NEO-AEG CHA256RY | |
| 4102 | 4102 | ***************************************--> |
| 4103 | 4103 | |
| 4104 | 4104 | <software name="fatfury3"> |
| r31374 | r31375 | |
| 4148 | 4148 | </part> |
| 4149 | 4149 | </software> |
| 4150 | 4150 | |
| 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) | |
| 4155 | 4155 | ***************************************--> |
| 4156 | 4156 | |
| 4157 | 4157 | <software name="zupapa"> |
| r31374 | r31375 | |
| 4191 | 4191 | </part> |
| 4192 | 4192 | </software> |
| 4193 | 4193 | |
| 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) | |
| 4198 | 4198 | |
| 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 | ***************************************--> | |
| 4206 | 4206 | |
| 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 | ***************************************--> | |
| 4212 | 4212 | |
| 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 | |
| 4217 | 4217 | ***************************************--> |
| 4218 | 4218 | |
| 4219 | 4219 | <software name="panicbom"> |
| r31374 | r31375 | |
| 4251 | 4251 | </part> |
| 4252 | 4252 | </software> |
| 4253 | 4253 | |
| 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 | |
| 4260 | 4260 | ***************************************--> |
| 4261 | 4261 | |
| 4262 | 4262 | <software name="aodk"> |
| r31374 | r31375 | |
| 4307 | 4307 | </part> |
| 4308 | 4308 | </software> |
| 4309 | 4309 | |
| 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 | |
| 4315 | 4315 | ***************************************--> |
| 4316 | 4316 | |
| 4317 | 4317 | <software name="sonicwi2"> |
| r31374 | r31375 | |
| 4353 | 4353 | </part> |
| 4354 | 4354 | </software> |
| 4355 | 4355 | |
| 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 | |
| 4360 | 4360 | ***************************************--> |
| 4361 | 4361 | |
| 4362 | 4362 | <software name="zedblade"> |
| r31374 | r31375 | |
| 4400 | 4400 | </part> |
| 4401 | 4401 | </software> |
| 4402 | 4402 | |
| 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 | |
| 4406 | 4406 | ***************************************--> |
| 4407 | 4407 | |
| 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 | |
| 4413 | 4413 | ***************************************--> |
| 4414 | 4414 | |
| 4415 | 4415 | <software name="galaxyfg"> |
| r31374 | r31375 | |
| 4461 | 4461 | </part> |
| 4462 | 4462 | </software> |
| 4463 | 4463 | |
| 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 | |
| 4470 | 4470 | ***************************************--> |
| 4471 | 4471 | |
| 4472 | 4472 | <software name="strhoop"> |
| r31374 | r31375 | |
| 4509 | 4509 | </part> |
| 4510 | 4510 | </software> |
| 4511 | 4511 | |
| 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 | |
| 4518 | 4518 | ***************************************--> |
| 4519 | 4519 | |
| 4520 | 4520 | <software name="quizkof"> |
| r31374 | r31375 | |
| 4593 | 4593 | </part> |
| 4594 | 4594 | </software> |
| 4595 | 4595 | |
| 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 | |
| 4602 | 4602 | ***************************************--> |
| 4603 | 4603 | |
| 4604 | 4604 | <software name="ssideki3"> |
| r31374 | r31375 | |
| 4646 | 4646 | </part> |
| 4647 | 4647 | </software> |
| 4648 | 4648 | |
| 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 | |
| 4656 | 4656 | ***************************************--> |
| 4657 | 4657 | |
| 4658 | 4658 | <software name="doubledr"> |
| r31374 | r31375 | |
| 4702 | 4702 | </part> |
| 4703 | 4703 | </software> |
| 4704 | 4704 | |
| 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 | |
| 4709 | 4709 | ***************************************--> |
| 4710 | 4710 | |
| 4711 | 4711 | <software name="pbobblen"> |
| r31374 | r31375 | |
| 4716 | 4716 | <sharedfeat name="compatibility" value="MVS,AES" /> |
| 4717 | 4717 | <part name="cart" interface="neo_cart"> |
| 4718 | 4718 | <!-- MVS ONLY RELEASE --> |
| 4719 | ||
| 4719 | <!-- This set uses CHA and PROG board from Power Spikes II. Six Power Spikes II prom's are replaced with | |
| 4720 | 4720 | Puzzle Bobble prom's. Confirmed on several original carts. Do other layouts also exist? --> |
| 4721 | 4721 | <dataarea name="maincpu" width="16" endianness="big" size="0x100000"> |
| 4722 | 4722 | <rom loadflag="load16_word_swap" name="d96-07.ep1" offset="0x000000" size="0x080000" crc="6102ca14" sha1="328429d11de5b327a0654ae0548da4d0025a2ae6" /> |
| r31374 | r31375 | |
| 4763 | 4763 | </part> |
| 4764 | 4764 | </software> |
| 4765 | 4765 | |
| 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 | |
| 4773 | 4773 | ***************************************--> |
| 4774 | 4774 | |
| 4775 | 4775 | <software name="kof95"> |
| r31374 | r31375 | |
| 4877 | 4877 | </part> |
| 4878 | 4878 | </software> |
| 4879 | 4879 | |
| 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) | |
| 4883 | 4883 | ***************************************--> |
| 4884 | 4884 | |
| 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 | |
| 4889 | 4889 | ***************************************--> |
| 4890 | 4890 | |
| 4891 | 4891 | <software name="tws96"> |
| r31374 | r31375 | |
| 4927 | 4927 | </part> |
| 4928 | 4928 | </software> |
| 4929 | 4929 | |
| 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 | |
| 4936 | 4936 | ***************************************--> |
| 4937 | 4937 | |
| 4938 | 4938 | <software name="samsho3"> |
| r31374 | r31375 | |
| 5089 | 5089 | </part> |
| 5090 | 5090 | </software> |
| 5091 | 5091 | |
| 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 | |
| 5097 | 5097 | ***************************************--> |
| 5098 | 5098 | |
| 5099 | 5099 | <software name="stakwin"> |
| r31374 | r31375 | |
| 5133 | 5133 | </part> |
| 5134 | 5134 | </software> |
| 5135 | 5135 | |
| 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 | |
| 5141 | 5141 | ***************************************--> |
| 5142 | 5142 | |
| 5143 | 5143 | <software name="pulstar"> |
| r31374 | r31375 | |
| 5188 | 5188 | </part> |
| 5189 | 5189 | </software> |
| 5190 | 5190 | |
| 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 | |
| 5196 | 5196 | ***************************************--> |
| 5197 | 5197 | |
| 5198 | 5198 | <software name="whp"> |
| r31374 | r31375 | |
| 5246 | 5246 | </part> |
| 5247 | 5247 | </software> |
| 5248 | 5248 | |
| 5249 | <!--*************************************** | |
| 5250 | ID-0091 | |
| 5251 | unknown | |
| 5249 | <!--*************************************** | |
| 5250 | ID-0091 | |
| 5251 | unknown | |
| 5252 | 5252 | ***************************************--> |
| 5253 | 5253 | |
| 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 | |
| 5259 | 5259 | ***************************************--> |
| 5260 | 5260 | |
| 5261 | 5261 | <software name="kabukikl"> |
| r31374 | r31375 | |
| 5301 | 5301 | </part> |
| 5302 | 5302 | </software> |
| 5303 | 5303 | |
| 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 | |
| 5308 | 5308 | ***************************************--> |
| 5309 | 5309 | |
| 5310 | 5310 | <software name="neobombe"> |
| r31374 | r31375 | |
| 5346 | 5346 | </part> |
| 5347 | 5347 | </software> |
| 5348 | 5348 | |
| 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 | |
| 5354 | 5354 | ***************************************--> |
| 5355 | 5355 | |
| 5356 | 5356 | <software name="gowcaizr"> |
| r31374 | r31375 | |
| 5402 | 5402 | </part> |
| 5403 | 5403 | </software> |
| 5404 | 5404 | |
| 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 | |
| 5411 | 5411 | ***************************************--> |
| 5412 | 5412 | |
| 5413 | 5413 | <software name="rbff1"> |
| r31374 | r31375 | |
| 5518 | 5518 | </part> |
| 5519 | 5519 | </software> |
| 5520 | 5520 | |
| 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 | |
| 5526 | 5526 | ***************************************--> |
| 5527 | 5527 | |
| 5528 | 5528 | <software name="aof3"> |
| r31374 | r31375 | |
| 5626 | 5626 | </part> |
| 5627 | 5627 | </software> |
| 5628 | 5628 | |
| 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 | |
| 5634 | 5634 | ***************************************--> |
| 5635 | 5635 | |
| 5636 | 5636 | <software name="sonicwi3"> |
| r31374 | r31375 | |
| 5672 | 5672 | </part> |
| 5673 | 5673 | </software> |
| 5674 | 5674 | |
| 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) | |
| 5678 | 5678 | ***************************************--> |
| 5679 | 5679 | |
| 5680 | <!--*************************************** | |
| 5681 | ID-0099 | |
| 5682 | Neo Pool Masters | |
| 5680 | <!--*************************************** | |
| 5681 | ID-0099 | |
| 5682 | Neo Pool Masters | |
| 5683 | 5683 | ***************************************--> |
| 5684 | 5684 | |
| 5685 | 5685 | |
| 5686 | 5686 | <!-- ID range from 100 - 199 is used for Korean (some) and Neo Print carts --> |
| 5687 | 5687 | |
| 5688 | ||
| 5688 | <!-- | |
| 5689 | 5689 | The following ID's are used by Korean releases: |
| 5690 | 5690 | |
| 5691 | 5691 | ID-0122 - Pae Wang Jeon Seol / Legend of a Warrior (Korean censored Samurai Shodown IV) |
| r31374 | r31375 | |
| 5700 | 5700 | --> |
| 5701 | 5701 | |
| 5702 | 5702 | |
| 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 | |
| 5708 | 5708 | ***************************************--> |
| 5709 | 5709 | |
| 5710 | 5710 | <software name="turfmast"> |
| r31374 | r31375 | |
| 5746 | 5746 | </part> |
| 5747 | 5747 | </software> |
| 5748 | 5748 | |
| 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 | |
| 5754 | 5754 | ***************************************--> |
| 5755 | 5755 | |
| 5756 | 5756 | <software name="mslug"> |
| r31374 | r31375 | |
| 5792 | 5792 | </part> |
| 5793 | 5793 | </software> |
| 5794 | 5794 | |
| 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 | |
| 5799 | 5799 | ***************************************--> |
| 5800 | 5800 | |
| 5801 | 5801 | <software name="puzzledp"> |
| r31374 | r31375 | |
| 5831 | 5831 | </part> |
| 5832 | 5832 | </software> |
| 5833 | 5833 | |
| 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 | |
| 5839 | 5839 | ***************************************--> |
| 5840 | 5840 | |
| 5841 | 5841 | <software name="mosyougi"> |
| r31374 | r31375 | |
| 5870 | 5870 | </part> |
| 5871 | 5871 | </software> |
| 5872 | 5872 | |
| 5873 | <!--*************************************** | |
| 5874 | ID-0204 | |
| 5875 | QP (prototype) | |
| 5873 | <!--*************************************** | |
| 5874 | ID-0204 | |
| 5875 | QP (prototype) | |
| 5876 | 5876 | ***************************************--> |
| 5877 | 5877 | |
| 5878 | <!--*************************************** | |
| 5879 | ID-0205 | |
| 5880 | Neo-Geo CD Special (CD only) | |
| 5878 | <!--*************************************** | |
| 5879 | ID-0205 | |
| 5880 | Neo-Geo CD Special (CD only) | |
| 5881 | 5881 | ***************************************--> |
| 5882 | 5882 | |
| 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 | |
| 5888 | 5888 | ***************************************--> |
| 5889 | 5889 | |
| 5890 | 5890 | <software name="marukodq"> |
| r31374 | r31375 | |
| 5925 | 5925 | </part> |
| 5926 | 5926 | </software> |
| 5927 | 5927 | |
| 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 | |
| 5932 | 5932 | ***************************************--> |
| 5933 | 5933 | |
| 5934 | 5934 | <software name="neomrdo"> |
| r31374 | r31375 | |
| 5964 | 5964 | </part> |
| 5965 | 5965 | </software> |
| 5966 | 5966 | |
| 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 | |
| 5971 | 5971 | ***************************************--> |
| 5972 | 5972 | |
| 5973 | 5973 | <software name="sdodgeb"> |
| r31374 | r31375 | |
| 6008 | 6008 | </part> |
| 6009 | 6009 | </software> |
| 6010 | 6010 | |
| 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 | |
| 6015 | 6015 | ***************************************--> |
| 6016 | 6016 | |
| 6017 | 6017 | <software name="goalx3"> |
| r31374 | r31375 | |
| 6052 | 6052 | </part> |
| 6053 | 6053 | </software> |
| 6054 | 6054 | |
| 6055 | <!--*************************************** | |
| 6056 | ID-0210 | |
| 6057 | Karate Ninja Sho (prototype) 1995 Yumekobo | |
| 6055 | <!--*************************************** | |
| 6056 | ID-0210 | |
| 6057 | Karate Ninja Sho (prototype) 1995 Yumekobo | |
| 6058 | 6058 | ***************************************--> |
| 6059 | 6059 | |
| 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 | |
| 6063 | 6063 | ***************************************--> |
| 6064 | 6064 | |
| 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 | |
| 6070 | 6070 | ***************************************--> |
| 6071 | 6071 | |
| 6072 | 6072 | <software name="overtop"> |
| r31374 | r31375 | |
| 6110 | 6110 | </part> |
| 6111 | 6111 | </software> |
| 6112 | 6112 | |
| 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 | |
| 6117 | 6117 | ***************************************--> |
| 6118 | 6118 | |
| 6119 | 6119 | <software name="neodrift"> |
| r31374 | r31375 | |
| 6152 | 6152 | </part> |
| 6153 | 6153 | </software> |
| 6154 | 6154 | |
| 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 | |
| 6160 | 6160 | ***************************************--> |
| 6161 | 6161 | |
| 6162 | 6162 | <software name="kof96"> |
| r31374 | r31375 | |
| 6259 | 6259 | </part> |
| 6260 | 6260 | </software> |
| 6261 | 6261 | |
| 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 | |
| 6267 | 6267 | ***************************************--> |
| 6268 | 6268 | |
| 6269 | 6269 | <software name="ssideki4"> |
| r31374 | r31375 | |
| 6309 | 6309 | </part> |
| 6310 | 6310 | </software> |
| 6311 | 6311 | |
| 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 | |
| 6317 | 6317 | ***************************************--> |
| 6318 | 6318 | |
| 6319 | 6319 | <software name="kizuna"> |
| r31374 | r31375 | |
| 6369 | 6369 | </part> |
| 6370 | 6370 | </software> |
| 6371 | 6371 | |
| 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 | |
| 6377 | 6377 | ***************************************--> |
| 6378 | 6378 | |
| 6379 | 6379 | <software name="ninjamas"> |
| r31374 | r31375 | |
| 6424 | 6424 | </part> |
| 6425 | 6425 | </software> |
| 6426 | 6426 | |
| 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 | |
| 6432 | 6432 | ***************************************--> |
| 6433 | 6433 | |
| 6434 | 6434 | <software name="ragnagrd"> |
| r31374 | r31375 | |
| 6478 | 6478 | </part> |
| 6479 | 6479 | </software> |
| 6480 | 6480 | |
| 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 | |
| 6485 | 6485 | ***************************************--> |
| 6486 | 6486 | |
| 6487 | 6487 | <software name="pgoal"> |
| r31374 | r31375 | |
| 6522 | 6522 | </part> |
| 6523 | 6523 | </software> |
| 6524 | 6524 | |
| 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 | |
| 6528 | 6528 | ***************************************--> |
| 6529 | 6529 | |
| 6530 | 6530 | <software name="ironclad"> |
| r31374 | r31375 | |
| 6587 | 6587 | </part> |
| 6588 | 6588 | </software> |
| 6589 | 6589 | |
| 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 | |
| 6595 | 6595 | ***************************************--> |
| 6596 | 6596 | |
| 6597 | 6597 | <software name="magdrop2"> |
| r31374 | r31375 | |
| 6626 | 6626 | </part> |
| 6627 | 6627 | </software> |
| 6628 | 6628 | |
| 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 | |
| 6635 | 6635 | ***************************************--> |
| 6636 | 6636 | |
| 6637 | 6637 | <software name="samsho4"> |
| r31374 | r31375 | |
| 6735 | 6735 | </part> |
| 6736 | 6736 | </software> |
| 6737 | 6737 | |
| 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 | |
| 6743 | 6743 | ***************************************--> |
| 6744 | 6744 | |
| 6745 | 6745 | <software name="rbffspec"> |
| r31374 | r31375 | |
| 6844 | 6844 | </part> |
| 6845 | 6845 | </software> |
| 6846 | 6846 | |
| 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 | |
| 6852 | 6852 | ***************************************--> |
| 6853 | 6853 | |
| 6854 | 6854 | <software name="twinspri"> |
| r31374 | r31375 | |
| 6890 | 6890 | </part> |
| 6891 | 6891 | </software> |
| 6892 | 6892 | |
| 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 | |
| 6898 | 6898 | ***************************************--> |
| 6899 | 6899 | |
| 6900 | 6900 | <software name="wakuwak7"> |
| r31374 | r31375 | |
| 6941 | 6941 | </part> |
| 6942 | 6942 | </software> |
| 6943 | 6943 | |
| 6944 | <!--*************************************** | |
| 6945 | ID-0226 | |
| 6946 | Pair Pair Wars (prototype) 1996 Sunsoft? | |
| 6944 | <!--*************************************** | |
| 6945 | ID-0226 | |
| 6946 | Pair Pair Wars (prototype) 1996 Sunsoft? | |
| 6947 | 6947 | ***************************************--> |
| 6948 | 6948 | |
| 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 | |
| 6954 | 6954 | ***************************************--> |
| 6955 | 6955 | |
| 6956 | 6956 | <software name="stakwin2"> |
| r31374 | r31375 | |
| 6992 | 6992 | </part> |
| 6993 | 6993 | </software> |
| 6994 | 6994 | |
| 6995 | <!--*************************************** | |
| 6996 | ID-0228 | |
| 6997 | Ghostlop (prototype) 1996 Data East Corp. | |
| 6995 | <!--*************************************** | |
| 6996 | ID-0228 | |
| 6997 | Ghostlop (prototype) 1996 Data East Corp. | |
| 6998 | 6998 | ***************************************--> |
| 6999 | 6999 | |
| 7000 | 7000 | <software name="ghostlop"> |
| r31374 | r31375 | |
| 7024 | 7024 | </part> |
| 7025 | 7025 | </software> |
| 7026 | 7026 | |
| 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) | |
| 7030 | 7030 | ***************************************--> |
| 7031 | 7031 | |
| 7032 | 7032 | |
| 7033 | 7033 | <!-- With ID-0230 the product ID code changed from xxM-xxx / xxH-xxx to xxM-xxx0 / xxH-xxx0 --> |
| 7034 | 7034 | |
| 7035 | 7035 | |
| 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 | |
| 7041 | 7041 | ***************************************--> |
| 7042 | 7042 | |
| 7043 | 7043 | <software name="breakers"> |
| r31374 | r31375 | |
| 7079 | 7079 | </part> |
| 7080 | 7080 | </software> |
| 7081 | 7081 | |
| 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 | |
| 7086 | 7086 | ***************************************--> |
| 7087 | 7087 | |
| 7088 | 7088 | <software name="miexchng"> |
| r31374 | r31375 | |
| 7122 | 7122 | </part> |
| 7123 | 7123 | </software> |
| 7124 | 7124 | |
| 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 | |
| 7131 | 7131 | ***************************************--> |
| 7132 | 7132 | |
| 7133 | 7133 | <software name="kof97"> |
| r31374 | r31375 | |
| 7271 | 7271 | </part> |
| 7272 | 7272 | </software> |
| 7273 | 7273 | |
| 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 | |
| 7279 | 7279 | ***************************************--> |
| 7280 | 7280 | |
| 7281 | 7281 | <software name="magdrop3"> |
| r31374 | r31375 | |
| 7316 | 7316 | </part> |
| 7317 | 7317 | </software> |
| 7318 | 7318 | |
| 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 | |
| 7325 | 7325 | ***************************************--> |
| 7326 | 7326 | |
| 7327 | 7327 | <software name="lastblad"> |
| r31374 | r31375 | |
| 7472 | 7472 | </part> |
| 7473 | 7473 | </software> |
| 7474 | 7474 | |
| 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 | |
| 7479 | 7479 | ***************************************--> |
| 7480 | 7480 | |
| 7481 | 7481 | <software name="puzzldpr" cloneof="puzzledp"> |
| r31374 | r31375 | |
| 7509 | 7509 | </part> |
| 7510 | 7510 | </software> |
| 7511 | 7511 | |
| 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 | |
| 7516 | 7516 | ***************************************--> |
| 7517 | 7517 | |
| 7518 | 7518 | <!-- Irritating Maze requires a Custom BIOS and is still loaded in neodrvr.c --> |
| 7519 | 7519 | |
| 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 | |
| 7524 | 7524 | ***************************************--> |
| 7525 | 7525 | |
| 7526 | 7526 | <software name="popbounc"> |
| r31374 | r31375 | |
| 7556 | 7556 | </part> |
| 7557 | 7557 | </software> |
| 7558 | 7558 | |
| 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 | |
| 7563 | 7563 | ***************************************--> |
| 7564 | 7564 | |
| 7565 | 7565 | <software name="shocktro"> |
| r31374 | r31375 | |
| 7659 | 7659 | </part> |
| 7660 | 7660 | </software> |
| 7661 | 7661 | |
| 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 | |
| 7667 | 7667 | ***************************************--> |
| 7668 | 7668 | |
| 7669 | 7669 | <software name="blazstar"> |
| r31374 | r31375 | |
| 7714 | 7714 | </part> |
| 7715 | 7715 | </software> |
| 7716 | 7716 | |
| 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 | |
| 7723 | 7723 | ***************************************--> |
| 7724 | 7724 | |
| 7725 | 7725 | <software name="rbff2"> |
| r31374 | r31375 | |
| 7870 | 7870 | </part> |
| 7871 | 7871 | </software> |
| 7872 | 7872 | |
| 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 | |
| 7879 | 7879 | ***************************************--> |
| 7880 | 7880 | |
| 7881 | 7881 | <software name="mslug2"> |
| r31374 | r31375 | |
| 7918 | 7918 | </part> |
| 7919 | 7919 | </software> |
| 7920 | 7920 | |
| 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 | |
| 7928 | 7928 | ***************************************--> |
| 7929 | 7929 | |
| 7930 | 7930 | <software name="kof98"> |
| r31374 | r31375 | |
| 8149 | 8149 | </part> |
| 8150 | 8150 | </software> |
| 8151 | 8151 | |
| 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 | |
| 8158 | 8158 | ***************************************--> |
| 8159 | 8159 | |
| 8160 | 8160 | <software name="lastbld2"> |
| r31374 | r31375 | |
| 8207 | 8207 | </part> |
| 8208 | 8208 | </software> |
| 8209 | 8209 | |
| 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 | |
| 8215 | 8215 | ***************************************--> |
| 8216 | 8216 | |
| 8217 | 8217 | <software name="neocup98"> |
| r31374 | r31375 | |
| 8249 | 8249 | </part> |
| 8250 | 8250 | </software> |
| 8251 | 8251 | |
| 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 | |
| 8256 | 8256 | ***************************************--> |
| 8257 | 8257 | |
| 8258 | 8258 | <software name="breakrev"> |
| r31374 | r31375 | |
| 8300 | 8300 | </part> |
| 8301 | 8301 | </software> |
| 8302 | 8302 | |
| 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 | |
| 8308 | 8308 | ***************************************--> |
| 8309 | 8309 | |
| 8310 | 8310 | <software name="shocktr2"> |
| r31374 | r31375 | |
| 8353 | 8353 | </part> |
| 8354 | 8354 | </software> |
| 8355 | 8355 | |
| 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 | |
| 8360 | 8360 | ***************************************--> |
| 8361 | 8361 | |
| 8362 | 8362 | <software name="flipshot"> |
| r31374 | r31375 | |
| 8392 | 8392 | </part> |
| 8393 | 8393 | </software> |
| 8394 | 8394 | |
| 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 | |
| 8399 | 8399 | ***************************************--> |
| 8400 | 8400 | |
| 8401 | 8401 | <software name="pbobbl2n"> |
| r31374 | r31375 | |
| 8492 | 8492 | </part> |
| 8493 | 8493 | </software> |
| 8494 | 8494 | |
| 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 | |
| 8500 | 8500 | ***************************************--> |
| 8501 | 8501 | |
| 8502 | 8502 | <software name="ctomaday"> |
| r31374 | r31375 | |
| 8535 | 8535 | </part> |
| 8536 | 8536 | </software> |
| 8537 | 8537 | |
| 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 | |
| 8544 | 8544 | ***************************************--> |
| 8545 | 8545 | |
| 8546 | 8546 | <software name="mslugx"> |
| r31374 | r31375 | |
| 8590 | 8590 | </part> |
| 8591 | 8591 | </software> |
| 8592 | 8592 | |
| 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) | |
| 8602 | 8602 | ***************************************--> |
| 8603 | 8603 | |
| 8604 | 8604 | <software name="kof99"> |
| r31374 | r31375 | |
| 8875 | 8875 | </part> |
| 8876 | 8876 | </software> |
| 8877 | 8877 | |
| 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) | |
| 8882 | 8882 | ***************************************--> |
| 8883 | 8883 | |
| 8884 | 8884 | <software name="ganryu"> |
| r31374 | r31375 | |
| 8913 | 8913 | </part> |
| 8914 | 8914 | </software> |
| 8915 | 8915 | |
| 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) | |
| 8922 | 8922 | ***************************************--> |
| 8923 | 8923 | |
| 8924 | 8924 | <software name="garou"> |
| r31374 | r31375 | |
| 9078 | 9078 | </part> |
| 9079 | 9079 | </software> |
| 9080 | 9080 | |
| 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) | |
| 9085 | 9085 | ***************************************--> |
| 9086 | 9086 | |
| 9087 | 9087 | <software name="s1945p"> |
| r31374 | r31375 | |
| 9124 | 9124 | </part> |
| 9125 | 9125 | </software> |
| 9126 | 9126 | |
| 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) | |
| 9131 | 9131 | ***************************************--> |
| 9132 | 9132 | |
| 9133 | 9133 | <software name="preisle2"> |
| r31374 | r31375 | |
| 9167 | 9167 | </part> |
| 9168 | 9168 | </software> |
| 9169 | 9169 | |
| 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 | |
| 9178 | 9178 | ***************************************--> |
| 9179 | 9179 | |
| 9180 | 9180 | <software name="mslug3"> |
| r31374 | r31375 | |
| 9292 | 9292 | </part> |
| 9293 | 9293 | </software> |
| 9294 | 9294 | |
| 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) | |
| 9304 | 9304 | ***************************************--> |
| 9305 | 9305 | |
| 9306 | 9306 | <software name="kof2000"> |
| r31374 | r31375 | |
| 9416 | 9416 | </part> |
| 9417 | 9417 | </software> |
| 9418 | 9418 | |
| 9419 | <!--*************************************** | |
| 9420 | ID-0258 | |
| 9421 | SNK vs. Capcom? | |
| 9419 | <!--*************************************** | |
| 9420 | ID-0258 | |
| 9421 | SNK vs. Capcom? | |
| 9422 | 9422 | ***************************************--> |
| 9423 | 9423 | |
| 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) | |
| 9428 | 9428 | ***************************************--> |
| 9429 | 9429 | |
| 9430 | 9430 | <software name="bangbead"> |
| r31374 | r31375 | |
| 9461 | 9461 | </software> |
| 9462 | 9462 | |
| 9463 | 9463 | |
| 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) | |
| 9468 | 9468 | ***************************************--> |
| 9469 | 9469 | |
| 9470 | 9470 | <software name="nitd"> |
| r31374 | r31375 | |
| 9498 | 9498 | </part> |
| 9499 | 9499 | </software> |
| 9500 | 9500 | |
| 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 | |
| 9506 | 9506 | ***************************************--> |
| 9507 | 9507 | |
| 9508 | 9508 | <software name="sengoku3"> |
| r31374 | r31375 | |
| 9550 | 9550 | </part> |
| 9551 | 9551 | </software> |
| 9552 | 9552 | |
| 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 | |
| 9560 | 9560 | ***************************************--> |
| 9561 | 9561 | |
| 9562 | 9562 | <software name="kof2001"> |
| r31374 | r31375 | |
| 9673 | 9673 | </part> |
| 9674 | 9674 | </software> |
| 9675 | 9675 | |
| 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) | |
| 9682 | 9682 | ***************************************--> |
| 9683 | 9683 | |
| 9684 | 9684 | <software name="mslug4"> |
| r31374 | r31375 | |
| 9782 | 9782 | </part> |
| 9783 | 9783 | </software> |
| 9784 | 9784 | |
| 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 | |
| 9792 | 9792 | ***************************************--> |
| 9793 | 9793 | |
| 9794 | 9794 | <software name="rotd"> |
| r31374 | r31375 | |
| 9843 | 9843 | </part> |
| 9844 | 9844 | </software> |
| 9845 | 9845 | |
| 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) | |
| 9852 | 9852 | ***************************************--> |
| 9853 | 9853 | |
| 9854 | 9854 | <software name="kof2002"> |
| r31374 | r31375 | |
| 9905 | 9905 | </part> |
| 9906 | 9906 | </software> |
| 9907 | 9907 | |
| 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) | |
| 9914 | 9914 | ***************************************--> |
| 9915 | 9915 | |
| 9916 | 9916 | <software name="matrim"> |
| r31374 | r31375 | |
| 9967 | 9967 | </part> |
| 9968 | 9968 | </software> |
| 9969 | 9969 | |
| 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) | |
| 9974 | 9974 | ***************************************--> |
| 9975 | 9975 | |
| 9976 | 9976 | <software name="pnyaa"> |
| r31374 | r31375 | |
| 10011 | 10011 | </part> |
| 10012 | 10012 | </software> |
| 10013 | 10013 | |
| 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 | |
| 10019 | 10019 | ***************************************--> |
| 10020 | 10020 | |
| 10021 | 10021 | <software name="mslug5"> |
| r31374 | r31375 | |
| 10124 | 10124 | </part> |
| 10125 | 10125 | </software> |
| 10126 | 10126 | |
| 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) | |
| 10133 | 10133 | ***************************************--> |
| 10134 | 10134 | |
| 10135 | 10135 | <software name="svc"> |
| r31374 | r31375 | |
| 10186 | 10186 | </part> |
| 10187 | 10187 | </software> |
| 10188 | 10188 | |
| 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) | |
| 10195 | 10195 | ***************************************--> |
| 10196 | 10196 | |
| 10197 | 10197 | <software name="samsho5"> |
| r31374 | r31375 | |
| 10303 | 10303 | </part> |
| 10304 | 10304 | </software> |
| 10305 | 10305 | |
| 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) | |
| 10312 | 10312 | ***************************************--> |
| 10313 | 10313 | |
| 10314 | 10314 | <software name="kof2003"> |
| r31374 | r31375 | |
| 10424 | 10424 | </part> |
| 10425 | 10425 | </software> |
| 10426 | 10426 | |
| 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 | |
| 10432 | 10432 | ***************************************--> |
| 10433 | 10433 | |
| 10434 | 10434 | <software name="samsh5sp"> |
| r31374 | r31375 | |
| 10562 | 10562 | <!-- BrezzaSoft games, licensed? --> |
| 10563 | 10563 | |
| 10564 | 10564 | |
| 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) | |
| 10569 | 10569 | ***************************************--> |
| 10570 | 10570 | |
| 10571 | 10571 | <!-- jockeygp requires very specific hardware and is loaded in neodrvr.c --> |
| 10572 | 10572 | |
| 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) | |
| 10577 | 10577 | ***************************************--> |
| 10578 | 10578 | |
| 10579 | 10579 | <!-- vliner requires very specific hardware and is loaded in neodrvr.c --> |
| r31374 | r31375 | |
| 10582 | 10582 | <!-- Jamma PCB sets --> |
| 10583 | 10583 | |
| 10584 | 10584 | |
| 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 | |
| 10589 | 10589 | ***************************************--> |
| 10590 | 10590 | |
| 10591 | 10591 | <!-- ms5pcb is not an MVS cart and is loaded in neodrvr.c --> |
| 10592 | 10592 | |
| 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 | |
| 10597 | 10597 | ***************************************--> |
| 10598 | 10598 | |
| 10599 | 10599 | <!-- svcpcb is not an MVS cart and is loaded in neodrvr.c --> |
| 10600 | 10600 | |
| 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 | |
| 10605 | 10605 | ***************************************--> |
| 10606 | 10606 | |
| 10607 | 10607 | <!-- svcpcba is not an MVS cart and is loaded in neodrvr.c --> |
| 10608 | 10608 | |
| 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 | |
| 10613 | 10613 | ***************************************--> |
| 10614 | 10614 | |
| 10615 | 10615 | <!-- kof2003pcb is not an MVS cart and is loaded in neodrvr.c --> |
| r31374 | r31375 | |
| 10619 | 10619 | |
| 10620 | 10620 | <!-- Bootleg sets --> |
| 10621 | 10621 | |
| 10622 | ||
| 10622 | <!-- | |
| 10623 | 10623 | About supported sets: |
| 10624 | 10624 | |
| 10625 | 10625 | For many bootleg sets, only P's (program rom), M1 (sound driver) and S1 (text layer) roms were dumped. |
| r31374 | r31375 | |
| 10631 | 10631 | |
| 10632 | 10632 | <!-- Zintrick bootleg --> |
| 10633 | 10633 | |
| 10634 | ||
| 10634 | <!-- This Zintrick set appears to be a bootleg made from the CD version, not a genuine | |
| 10635 | 10635 | prototype the code is based on that of the NeoCD version with some minor patches, |
| 10636 | 10636 | for example the ADK SAMPLE TEST text that appears on the screen is actually a hacked |
| 10637 | 10637 | PROG LOAD ERROR message. The set is supported in order to distinguish the hacks from |
| r31374 | r31375 | |
|---|---|---|
| 2 | 2 | <!DOCTYPE softwarelist SYSTEM "softwarelist.dtd"> |
| 3 | 3 | |
| 4 | 4 | <softwarelist name="hp9835a_rom" description="HP 9835A/B Option ROMs"> |
| 5 | ||
| 5 | ||
| 6 | 6 | <software name="mass"> |
| 7 | 7 | <description>Mass Storage</description> |
| 8 | 8 | <year>198?</year> |
| r31374 | r31375 | |
| 16 | 16 | </dataarea> |
| 17 | 17 | </part> |
| 18 | 18 | </software> |
| 19 | ||
| 19 | ||
| 20 | 20 | <software name="io"> |
| 21 | 21 | <description>I/O</description> |
| 22 | 22 | <year>198?</year> |
| r31374 | r31375 | |
| 32 | 32 | </dataarea> |
| 33 | 33 | </part> |
| 34 | 34 | </software> |
| 35 | ||
| 35 | ||
| 36 | 36 | <software name="asmexec"> |
| 37 | 37 | <description>Assembly Execution</description> |
| 38 | 38 | <year>198?</year> |
| r31374 | r31375 | |
| 45 | 45 | </dataarea> |
| 46 | 46 | </part> |
| 47 | 47 | </software> |
| 48 | ||
| 48 | ||
| 49 | 49 | <software name="asmdev"> |
| 50 | 50 | <description>Assembly Language Development & Execution</description> |
| 51 | 51 | <year>198?</year> |
| r31374 | r31375 | |
|---|---|---|
| 5 | 5 | |
| 6 | 6 | <!-- |
| 7 | 7 | |
| 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 | |
| 16 | 11 | |
| 12 | Also, not sure if these exist, probably canceled: | |
| 13 | - Business Graphics | |
| 14 | - Games II | |
| 15 | - Perspective Drawing | |
| 16 | ||
| 17 | 17 | --> |
| 18 | 18 | |
| 19 | 19 | <software name="aee"> |
| r31374 | r31375 | |
|---|---|---|
| 4 | 4 | |
| 5 | 5 | <!-- |
| 6 | 6 | |
| 7 | | |
| 7 | Undumped and most wanted: | |
| 8 | 8 | |
| 9 | | |
| 9 | #700-2611 Driver disk for Windows 1.03 | |
| 10 | 10 | |
| 11 | 11 | --> |
| 12 | 12 |
| r31374 | r31375 | |
|---|---|---|
| 2 | 2 | <!DOCTYPE softwarelist SYSTEM "softwarelist.dtd"> |
| 3 | 3 | |
| 4 | 4 | <softwarelist name="hp9845b_rom" description="HP 9845B/T/C Option ROMs"> |
| 5 | ||
| 5 | ||
| 6 | 6 | <software name="mass"> |
| 7 | 7 | <description>Mass Storage (Rev B)</description> |
| 8 | 8 | <year>198?</year> |
| r31374 | r31375 | |
| 16 | 16 | </dataarea> |
| 17 | 17 | </part> |
| 18 | 18 | </software> |
| 19 | ||
| 19 | ||
| 20 | 20 | <software name="massc" cloneof="mass"> |
| 21 | 21 | <description>Mass Storage (Rev C)</description> |
| 22 | 22 | <year>198?</year> |
| r31374 | r31375 | |
| 30 | 30 | </dataarea> |
| 31 | 31 | </part> |
| 32 | 32 | </software> |
| 33 | ||
| 33 | ||
| 34 | 34 | <software name="massd" cloneof="mass"> |
| 35 | 35 | <description>Mass Storage (Rev D)</description> |
| 36 | 36 | <year>198?</year> |
| r31374 | r31375 | |
| 45 | 45 | </dataarea> |
| 46 | 46 | </part> |
| 47 | 47 | </software> |
| 48 | ||
| 48 | ||
| 49 | 49 | <software name="graphics"> |
| 50 | 50 | <description>Graphics</description> |
| 51 | 51 | <year>198?</year> |
| r31374 | r31375 | |
| 59 | 59 | </dataarea> |
| 60 | 60 | </part> |
| 61 | 61 | </software> |
| 62 | ||
| 62 | ||
| 63 | 63 | <software name="iolpu"> |
| 64 | 64 | <description>I/O LPU (Rev A)</description> |
| 65 | 65 | <year>198?</year> |
| r31374 | r31375 | |
| 73 | 73 | </dataarea> |
| 74 | 74 | </part> |
| 75 | 75 | </software> |
| 76 | ||
| 76 | ||
| 77 | 77 | <software name="iolpub" cloneof="iolpu"> |
| 78 | 78 | <description>I/O LPU (Rev B)</description> |
| 79 | 79 | <year>198?</year> |
| r31374 | r31375 | |
| 87 | 87 | </dataarea> |
| 88 | 88 | </part> |
| 89 | 89 | </software> |
| 90 | ||
| 90 | ||
| 91 | 91 | <software name="ioppu"> |
| 92 | 92 | <description>I/O PPU (Rev B)</description> |
| 93 | 93 | <year>198?</year> |
| r31374 | r31375 | |
| 101 | 101 | </dataarea> |
| 102 | 102 | </part> |
| 103 | 103 | </software> |
| 104 | ||
| 104 | ||
| 105 | 105 | <software name="ioppuc" cloneof="ioppu"> |
| 106 | 106 | <description>I/O PPU (Rev C)</description> |
| 107 | 107 | <year>198?</year> |
| r31374 | r31375 | |
| 115 | 115 | </dataarea> |
| 116 | 116 | </part> |
| 117 | 117 | </software> |
| 118 | ||
| 118 | ||
| 119 | 119 | <software name="advprog"> |
| 120 | 120 | <description>Advanced Programming</description> |
| 121 | 121 | <year>198?</year> |
| r31374 | r31375 | |
| 128 | 128 | </dataarea> |
| 129 | 129 | </part> |
| 130 | 130 | </software> |
| 131 | ||
| 131 | ||
| 132 | 132 | <software name="asmexec"> |
| 133 | 133 | <description>Assembly Execution</description> |
| 134 | 134 | <year>198?</year> |
| r31374 | r31375 | |
| 142 | 142 | </dataarea> |
| 143 | 143 | </part> |
| 144 | 144 | </software> |
| 145 | ||
| 145 | ||
| 146 | 146 | <software name="asmdev"> |
| 147 | 147 | <description>Assembly Development & Execution</description> |
| 148 | 148 | <year>198?</year> |
| r31374 | r31375 | |
| 158 | 158 | </dataarea> |
| 159 | 159 | </part> |
| 160 | 160 | </software> |
| 161 | ||
| 161 | ||
| 162 | 162 | <software name="image45"> |
| 163 | 163 | <description>IMAGE/45 Database Manager (Rev B)</description> |
| 164 | 164 | <year>198?</year> |
| r31374 | r31375 | |
| 178 | 178 | </dataarea> |
| 179 | 179 | </part> |
| 180 | 180 | </software> |
| 181 | ||
| 181 | ||
| 182 | 182 | <software name="image45c" cloneof="image45"> |
| 183 | 183 | <description>IMAGE/45 Database Manager (Rev C)</description> |
| 184 | 184 | <year>198?</year> |
| r31374 | r31375 | |
| 198 | 198 | </dataarea> |
| 199 | 199 | </part> |
| 200 | 200 | </software> |
| 201 | ||
| 201 | ||
| 202 | 202 | <software name="strucprg"> |
| 203 | 203 | <description>Structured Programming</description> |
| 204 | 204 | <year>198?</year> |
| r31374 | r31375 | |
| 211 | 211 | </dataarea> |
| 212 | 212 | </part> |
| 213 | 213 | </software> |
| 214 | ||
| 214 | ||
| 215 | 215 | <software name="resmgmt"> |
| 216 | 216 | <description>Resource Management</description> |
| 217 | 217 | <year>198?</year> |
| r31374 | r31375 | |
| 229 | 229 | </dataarea> |
| 230 | 230 | </part> |
| 231 | 231 | </software> |
| 232 | ||
| 232 | ||
| 233 | 233 | <software name="test"> |
| 234 | 234 | <description>Test ROM</description> |
| 235 | 235 | <year>198?</year> |
| r31374 | r31375 | |
| 243 | 243 | </dataarea> |
| 244 | 244 | </part> |
| 245 | 245 | </software> |
| 246 | ||
| 246 | ||
| 247 | 247 | <software name="datacomm"> |
| 248 | 248 | <description>BASIC Datacomm</description> |
| 249 | 249 | <year>198?</year> |
| r31374 | r31375 | |
| 259 | 259 | </dataarea> |
| 260 | 260 | </part> |
| 261 | 261 | </software> |
| 262 | ||
| 262 | ||
| 263 | 263 | <software name="bisync"> |
| 264 | 264 | <description>RJE Bisync</description> |
| 265 | 265 | <year>198?</year> |
| r31374 | r31375 | |
| 273 | 273 | </dataarea> |
| 274 | 274 | </part> |
| 275 | 275 | </software> |
| 276 | ||
| 276 | ||
| 277 | 277 | <software name="colorgfx"> |
| 278 | 278 | <description>Color Graphics</description> |
| 279 | 279 | <year>198?</year> |
| r31374 | r31375 | |
| 289 | 289 | </dataarea> |
| 290 | 290 | </part> |
| 291 | 291 | </software> |
| 292 | ||
| 292 | ||
| 293 | 293 | <software name="enhgfx"> |
| 294 | 294 | <description>Enhanced Graphics (Rev A)</description> |
| 295 | 295 | <year>198?</year> |
| r31374 | r31375 | |
| 306 | 306 | </dataarea> |
| 307 | 307 | </part> |
| 308 | 308 | </software> |
| 309 | ||
| 309 | ||
| 310 | 310 | <software name="enhgfxb" cloneof="enhgfx"> |
| 311 | 311 | <description>Enhanced Graphics (Rev B)</description> |
| 312 | 312 | <year>198?</year> |
| r31374 | r31375 | |
|---|---|---|
| 8428 | 8428 | <feature name="mmc1_type" value="MMC1B2" /> |
| 8429 | 8429 | <feature name="pcb_model" value="HVC-SXROM-01" /> |
| 8430 | 8430 | <feature name="u1" value="U1 PRG-ROM" /> |
| 8431 | <feature name="u2" value="U2 CHR-RAM" /> | |
| 8431 | <feature name="u2" value="U2 CHR-RAM" /> <!-- LH5168FB-10L --> | |
| 8432 | 8432 | <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 --> | |
| 8435 | 8435 | <dataarea name="prg" size="131072"> |
| 8436 | 8436 | <rom name="ath-87-0 prg.u1" size="131072" crc="d1e50064" sha1="bd442a386741ee63c0dcbbd46b3f53fb60a6d45d" offset="00000" /> |
| 8437 | 8437 | </dataarea> |
| r31374 | r31375 | |
|---|---|---|
| 9 | 9 | <color red="1.0" green="0.25" blue="0.0" /> |
| 10 | 10 | </led7seg> |
| 11 | 11 | </element> |
| 12 | ||
| 12 | ||
| 13 | 13 | <element name="red_led"> |
| 14 | 14 | <rect> |
| 15 | 15 | <color red="1.0" green="0.0" blue="0.0" /> |
| r31374 | r31375 | |
| 22 | 22 | <color red="0.0" green="0.0" blue="0.0" /> |
| 23 | 23 | </rect> |
| 24 | 24 | </element> |
| 25 | ||
| 25 | ||
| 26 | 26 | <element name="P0"><text string="Score"><color red="1.0" green="1.0" blue="1.0" /></text></element> |
| 27 | 27 | <element name="P1"><text string="Ball"><color red="1.0" green="1.0" blue="1.0" /></text></element> |
| 28 | 28 | <element name="P2"><text string="On board"><color red="1.0" green="1.0" blue="1.0" /></text></element> |
| r31374 | r31375 | |
| 38 | 38 | <element name="P11"><text string="Shot Valve"><color red="1.0" green="1.0" blue="1.0" /></text></element> |
| 39 | 39 | <element name="P12"><text string="Feed Back Valve"><color red="1.0" green="1.0" blue="1.0" /></text></element> |
| 40 | 40 | <element name="P13"><text string="Return Valve"><color red="1.0" green="1.0" blue="1.0" /></text></element> |
| 41 | ||
| 42 | ||
| 41 | ||
| 42 | ||
| 43 | 43 | <view name="Default Layout"> |
| 44 | 44 | |
| 45 | 45 | <!-- Background --> |
| r31374 | r31375 | |
| 75 | 75 | <bezel name="digit7" element="digit"> |
| 76 | 76 | <bounds left="330" top="65" right="350" bottom="84" /> |
| 77 | 77 | </bezel> |
| 78 | ||
| 78 | ||
| 79 | 79 | <!-- Game Lamp --> |
| 80 | 80 | <bezel name="Hopper1" element="red_led"> |
| 81 | 81 | <bounds x="10" y="110" width="30" height="5" /> |
| 82 | 82 | </bezel> |
| 83 | ||
| 83 | ||
| 84 | 84 | <bezel name="Hopper2" element="red_led"> |
| 85 | 85 | <bounds x="50" y="110" width="30" height="5" /> |
| 86 | 86 | </bezel> |
| 87 | ||
| 87 | ||
| 88 | 88 | <bezel name="Hopper3" element="red_led"> |
| 89 | 89 | <bounds x="90" y="110" width="30" height="5" /> |
| 90 | </bezel> | |
| 90 | </bezel> | |
| 91 | 91 | |
| 92 | 92 | <bezel name="Title" element="red_led"> |
| 93 | 93 | <bounds x="10" y="140" width="30" height="5" /> |
| 94 | </bezel> | |
| 94 | </bezel> | |
| 95 | 95 | |
| 96 | 96 | <bezel name="GameOver" element="red_led"> |
| 97 | 97 | <bounds x="50" y="140" width="30" height="5" /> |
| 98 | 98 | </bezel> |
| 99 | ||
| 99 | ||
| 100 | 100 | <bezel name="Credit" element="red_led"> |
| 101 | 101 | <bounds x="90" y="140" width="30" height="5" /> |
| 102 | </bezel> | |
| 103 | ||
| 102 | </bezel> | |
| 103 | ||
| 104 | 104 | <bezel name="SS" element="red_led"> |
| 105 | 105 | <bounds x="130" y="140" width="30" height="5" /> |
| 106 | </bezel> | |
| 107 | ||
| 106 | </bezel> | |
| 107 | ||
| 108 | 108 | <bezel name="C_LOCK" element="red_led"> |
| 109 | 109 | <bounds x="170" y="140" width="30" height="5" /> |
| 110 | </bezel> | |
| 111 | ||
| 110 | </bezel> | |
| 111 | ||
| 112 | 112 | <bezel name="SV" element="red_led"> |
| 113 | 113 | <bounds x="210" y="140" width="30" height="5" /> |
| 114 | 114 | </bezel> |
| 115 | ||
| 115 | ||
| 116 | 116 | <bezel name="FBV" element="red_led"> |
| 117 | 117 | <bounds x="250" y="140" width="30" height="5" /> |
| 118 | 118 | </bezel> |
| 119 | ||
| 119 | ||
| 120 | 120 | <bezel name="RV" element="red_led"> |
| 121 | 121 | <bounds x="290" y="140" width="30" height="5" /> |
| 122 | 122 | </bezel> |
| 123 | ||
| 123 | ||
| 124 | 124 | <bezel element="P0"><bounds left="71" right="115" top="30" bottom="42" /></bezel> |
| 125 | 125 | <bezel element="P1"><bounds left="247" right="288" top="30" bottom="42" /></bezel> |
| 126 | 126 | <bezel element="P2"><bounds left="330" right="350" top="50" bottom="62" /></bezel> |
| r31374 | r31375 | |
| 131 | 131 | |
| 132 | 132 | <bezel element="P6"><bounds left="10" right="40" top="120" bottom="134" /></bezel> |
| 133 | 133 | <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 | ||
| 137 | 137 | <bezel element="P10"><bounds left="170" right="200" top="120" bottom="134" /></bezel> |
| 138 | 138 | <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> | |
| 140 | 140 | <bezel element="P13"><bounds left="290" right="320" top="120" bottom="134" /></bezel> |
| 141 | ||
| 141 | ||
| 142 | 142 | </view> |
| 143 | 143 | </mamelayout> |
| r31374 | r31375 | |
|---|---|---|
| 20 | 20 | </rect> |
| 21 | 21 | </element> |
| 22 | 22 | |
| 23 | ||
| 23 | <element name="startbutton" defstate="0"> | |
| 24 | 24 | <disk state = "0"> |
| 25 | 25 | <color red="0.7" green="0.7" blue="0.7" /> |
| 26 | 26 | </disk> |
| 27 | 27 | <disk state = "1"> |
| 28 | 28 | <color red="1.0" green="1.0" blue="1.0" /> |
| 29 | 29 | </disk> |
| 30 | </element> | |
| 30 | </element> | |
| 31 | 31 | |
| 32 | 32 | <element name="text_level_l"> |
| 33 | 33 | <rect><color red="0" green="0.13333" blue="0.86666" /></rect> |
| r31374 | r31375 | |
| 50 | 50 | <text string="Start"><color red="0.3" green="0.3" blue="0.3" /></text> |
| 51 | 51 | </element> |
| 52 | 52 | |
| 53 | ||
| 53 | <element name="mole_sim_red" defstate="0"> | |
| 54 | 54 | <disk state = "0"><color blue="0.05" green="0.05" red="0.20" /></disk> |
| 55 | 55 | <disk state = "1"><color blue="0.05" green="0.05" red="0.21" /></disk> |
| 56 | 56 | <disk state = "2"><color blue="0.05" green="0.05" red="0.22" /></disk> |
| r31374 | r31375 | |
| 61 | 61 | <disk state = "7"><color blue="0.05" green="0.05" red="0.27" /></disk> |
| 62 | 62 | <disk state = "8"><color blue="0.05" green="0.05" red="0.28" /></disk> |
| 63 | 63 | <disk state = "9"><color blue="0.05" green="0.05" red="0.29" /></disk> |
| 64 | ||
| 64 | <disk state ="10"><color blue="0.05" green="0.05" red="0.30" /></disk> | |
| 65 | 65 | <disk state ="11"><color blue="0.05" green="0.05" red="0.31" /></disk> |
| 66 | 66 | <disk state ="12"><color blue="0.05" green="0.05" red="0.32" /></disk> |
| 67 | 67 | <disk state ="13"><color blue="0.05" green="0.05" red="0.33" /></disk> |
| r31374 | r31375 | |
| 71 | 71 | <disk state ="17"><color blue="0.05" green="0.05" red="0.37" /></disk> |
| 72 | 72 | <disk state ="18"><color blue="0.05" green="0.05" red="0.38" /></disk> |
| 73 | 73 | <disk state ="19"><color blue="0.05" green="0.05" red="0.39" /></disk> |
| 74 | ||
| 74 | <disk state ="20"><color blue="0.05" green="0.05" red="0.40" /></disk> | |
| 75 | 75 | <disk state ="21"><color blue="0.05" green="0.05" red="0.41" /></disk> |
| 76 | 76 | <disk state ="22"><color blue="0.05" green="0.05" red="0.42" /></disk> |
| 77 | 77 | <disk state ="23"><color blue="0.05" green="0.05" red="0.43" /></disk> |
| r31374 | r31375 | |
| 81 | 81 | <disk state ="27"><color blue="0.06" green="0.06" red="0.47" /></disk> |
| 82 | 82 | <disk state ="28"><color blue="0.07" green="0.07" red="0.48" /></disk> |
| 83 | 83 | <disk state ="29"><color blue="0.07" green="0.07" red="0.49" /></disk> |
| 84 | ||
| 84 | <disk state ="30"><color blue="0.07" green="0.07" red="0.50" /></disk> | |
| 85 | 85 | <disk state ="31"><color blue="0.07" green="0.07" red="0.51" /></disk> |
| 86 | 86 | <disk state ="32"><color blue="0.08" green="0.08" red="0.52" /></disk> |
| 87 | 87 | <disk state ="33"><color blue="0.08" green="0.08" red="0.53" /></disk> |
| r31374 | r31375 | |
| 91 | 91 | <disk state ="37"><color blue="0.09" green="0.09" red="0.57" /></disk> |
| 92 | 92 | <disk state ="38"><color blue="0.09" green="0.09" red="0.58" /></disk> |
| 93 | 93 | <disk state ="39"><color blue="0.09" green="0.09" red="0.59" /></disk> |
| 94 | ||
| 94 | <disk state ="40"><color blue="0.10" green="0.10" red="0.60" /></disk> | |
| 95 | 95 | <disk state ="41"><color blue="0.10" green="0.10" red="0.61" /></disk> |
| 96 | 96 | <disk state ="42"><color blue="0.10" green="0.10" red="0.62" /></disk> |
| 97 | 97 | <disk state ="43"><color blue="0.10" green="0.10" red="0.63" /></disk> |
| r31374 | r31375 | |
| 121 | 121 | <disk state ="67"><color blue="0.16" green="0.16" red="0.87" /></disk> |
| 122 | 122 | <disk state ="68"><color blue="0.17" green="0.17" red="0.88" /></disk> |
| 123 | 123 | <disk state ="69"><color blue="0.17" green="0.17" red="0.89" /></disk> |
| 124 | ||
| 124 | <disk state ="70"><color blue="0.17" green="0.17" red="0.90" /></disk> | |
| 125 | 125 | <disk state ="71"><color blue="0.17" green="0.17" red="0.91" /></disk> |
| 126 | 126 | <disk state ="72"><color blue="0.18" green="0.18" red="0.92" /></disk> |
| 127 | 127 | <disk state ="73"><color blue="0.18" green="0.18" red="0.93" /></disk> |
| r31374 | r31375 | |
| 131 | 131 | <disk state ="77"><color blue="0.19" green="0.19" red="0.97" /></disk> |
| 132 | 132 | <disk state ="78"><color blue="0.19" green="0.19" red="0.98" /></disk> |
| 133 | 133 | <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> | |
| 135 | 135 | </element> |
| 136 | 136 | |
| 137 | ||
| 137 | <element name="mole_sim_blu" defstate="0"> | |
| 138 | 138 | <disk state = "0"><color red="0.05" green="0.05" blue="0.20" /></disk> |
| 139 | 139 | <disk state = "1"><color red="0.05" green="0.05" blue="0.21" /></disk> |
| 140 | 140 | <disk state = "2"><color red="0.05" green="0.05" blue="0.22" /></disk> |
| r31374 | r31375 | |
| 145 | 145 | <disk state = "7"><color red="0.05" green="0.05" blue="0.27" /></disk> |
| 146 | 146 | <disk state = "8"><color red="0.05" green="0.05" blue="0.28" /></disk> |
| 147 | 147 | <disk state = "9"><color red="0.05" green="0.05" blue="0.29" /></disk> |
| 148 | ||
| 148 | <disk state ="10"><color red="0.05" green="0.05" blue="0.30" /></disk> | |
| 149 | 149 | <disk state ="11"><color red="0.05" green="0.05" blue="0.31" /></disk> |
| 150 | 150 | <disk state ="12"><color red="0.05" green="0.05" blue="0.32" /></disk> |
| 151 | 151 | <disk state ="13"><color red="0.05" green="0.05" blue="0.33" /></disk> |
| r31374 | r31375 | |
| 155 | 155 | <disk state ="17"><color red="0.05" green="0.05" blue="0.37" /></disk> |
| 156 | 156 | <disk state ="18"><color red="0.05" green="0.05" blue="0.38" /></disk> |
| 157 | 157 | <disk state ="19"><color red="0.05" green="0.05" blue="0.39" /></disk> |
| 158 | ||
| 158 | <disk state ="20"><color red="0.05" green="0.05" blue="0.40" /></disk> | |
| 159 | 159 | <disk state ="21"><color red="0.05" green="0.05" blue="0.41" /></disk> |
| 160 | 160 | <disk state ="22"><color red="0.05" green="0.05" blue="0.42" /></disk> |
| 161 | 161 | <disk state ="23"><color red="0.05" green="0.05" blue="0.43" /></disk> |
| r31374 | r31375 | |
| 165 | 165 | <disk state ="27"><color red="0.06" green="0.06" blue="0.47" /></disk> |
| 166 | 166 | <disk state ="28"><color red="0.07" green="0.07" blue="0.48" /></disk> |
| 167 | 167 | <disk state ="29"><color red="0.07" green="0.07" blue="0.49" /></disk> |
| 168 | ||
| 168 | <disk state ="30"><color red="0.07" green="0.07" blue="0.50" /></disk> | |
| 169 | 169 | <disk state ="31"><color red="0.07" green="0.07" blue="0.51" /></disk> |
| 170 | 170 | <disk state ="32"><color red="0.08" green="0.08" blue="0.52" /></disk> |
| 171 | 171 | <disk state ="33"><color red="0.08" green="0.08" blue="0.53" /></disk> |
| r31374 | r31375 | |
| 175 | 175 | <disk state ="37"><color red="0.09" green="0.09" blue="0.57" /></disk> |
| 176 | 176 | <disk state ="38"><color red="0.09" green="0.09" blue="0.58" /></disk> |
| 177 | 177 | <disk state ="39"><color red="0.09" green="0.09" blue="0.59" /></disk> |
| 178 | ||
| 178 | <disk state ="40"><color red="0.10" green="0.10" blue="0.60" /></disk> | |
| 179 | 179 | <disk state ="41"><color red="0.10" green="0.10" blue="0.61" /></disk> |
| 180 | 180 | <disk state ="42"><color red="0.10" green="0.10" blue="0.62" /></disk> |
| 181 | 181 | <disk state ="43"><color red="0.10" green="0.10" blue="0.63" /></disk> |
| r31374 | r31375 | |
| 205 | 205 | <disk state ="67"><color red="0.16" green="0.16" blue="0.87" /></disk> |
| 206 | 206 | <disk state ="68"><color red="0.17" green="0.17" blue="0.88" /></disk> |
| 207 | 207 | <disk state ="69"><color red="0.17" green="0.17" blue="0.89" /></disk> |
| 208 | ||
| 208 | <disk state ="70"><color red="0.17" green="0.17" blue="0.90" /></disk> | |
| 209 | 209 | <disk state ="71"><color red="0.17" green="0.17" blue="0.91" /></disk> |
| 210 | 210 | <disk state ="72"><color red="0.18" green="0.18" blue="0.92" /></disk> |
| 211 | 211 | <disk state ="73"><color red="0.18" green="0.18" blue="0.93" /></disk> |
| r31374 | r31375 | |
| 215 | 215 | <disk state ="77"><color red="0.19" green="0.19" blue="0.97" /></disk> |
| 216 | 216 | <disk state ="78"><color red="0.19" green="0.19" blue="0.98" /></disk> |
| 217 | 217 | <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> | |
| 219 | 219 | </element> |
| 220 | 220 | |
| 221 | 221 | |
| r31374 | r31375 | |
| 357 | 357 | <bezel element="text_ryu"> |
| 358 | 358 | <bounds x="118" y="254" width="24" height="6"/> |
| 359 | 359 | </bezel> |
| 360 | ||
| 360 | <bezel element="text_start"> | |
| 361 | 361 | <bounds x="118" y="261" width="24" height="6"/> |
| 362 | 362 | </bezel> |
| 363 | 363 | |
| r31374 | r31375 | |
| 371 | 371 | <bezel element="text_chunli"> |
| 372 | 372 | <bounds x="180" y="254" width="24" height="6"/> |
| 373 | 373 | </bezel> |
| 374 | ||
| 374 | <bezel element="text_start"> | |
| 375 | 375 | <bounds x="180" y="261" width="24" height="6"/> |
| 376 | </bezel> | |
| 376 | </bezel> | |
| 377 | 377 | |
| 378 | 378 | <bezel element="disk_black"> |
| 379 | 379 | <bounds x="163" y="251" width="19" height="19" /> |
| r31374 | r31375 | |
|---|---|---|
| 2 | 2 | |
| 3 | 3 | void bfm_sc45_layout_helper(running_machine &machine); |
| 4 | 4 | int find_project_string(running_machine &machine, int addrxor, int mode); |
| 5 |
| r31374 | r31375 | |
|---|---|---|
| 100 | 100 | mspacmat // hack |
| 101 | 101 | msheartb // hack |
| 102 | 102 | mspacmanbg // bootleg |
| 103 | mspacmanbgd | |
| 103 | mspacmanbgd // bootleg | |
| 104 | 104 | woodpeck // (c) 1981 Amenip (Palcom Queen River) |
| 105 | 105 | woodpeca // (c) 1981 Amenip Nova Games Ltd. |
| 106 | 106 | mspacmab // bootleg |
| r31374 | r31375 | |
| 175 | 175 | galturbo // hack |
| 176 | 176 | swarm // hack |
| 177 | 177 | zerotime // hack |
| 178 | zerotimed | |
| 178 | zerotimed // hack | |
| 179 | 179 | starfght // hack |
| 180 | 180 | galaxbsf // hack |
| 181 | 181 | galaxianbl // bootleg |
| r31374 | r31375 | |
| 324 | 324 | ckongs // bootleg |
| 325 | 325 | froggers // bootleg |
| 326 | 326 | frogf // bootleg |
| 327 | quaak | |
| 327 | quaak // bootleg | |
| 328 | 328 | amidars // GX337 (c) 1982 Konami |
| 329 | 329 | triplep // (c) 1982 KKI / made by Sanritsu? |
| 330 | 330 | triplepa // (c) 1982 KKI / made by Sanritsu? |
| r31374 | r31375 | |
| 701 | 701 | pleiadsb2 // bootleg |
| 702 | 702 | pleiadbl // bootleg |
| 703 | 703 | pleiadce // (c) 1981 Centuri + Tehkan |
| 704 | pleiadsi // bootleg? | |
| 705 | pleiadss // bootleg | |
| 704 | pleiadsi // bootleg? | |
| 705 | pleiadss // bootleg | |
| 706 | 706 | capitol // bootleg? |
| 707 | 707 | survival // (c) 1982 Rock-ola |
| 708 | 708 | naughtyb // (c) 1982 Jaleco |
| r31374 | r31375 | |
| 866 | 866 | pacmania // (c) 1987 |
| 867 | 867 | pacmaniaj // (c) 1987 (Japan) |
| 868 | 868 | galaga88 // (c) 1987 |
| 869 | galaga88a | |
| 869 | galaga88a // (c) 1987 | |
| 870 | 870 | galaga88j // (c) 1987 (Japan) |
| 871 | 871 | ws // (c) 1988 (Japan) |
| 872 | 872 | berabohm // (c) 1988 (Japan, Rev C) |
| r31374 | r31375 | |
| 1463 | 1463 | invasionb // bootleg |
| 1464 | 1464 | invasionrz // bootleg |
| 1465 | 1465 | invasionrza // bootleg |
| 1466 | invadersem | |
| 1466 | invadersem // Electromar | |
| 1467 | 1467 | sstrangr // (c) 1978 Yachiyo Electronics, Ltd. |
| 1468 | 1468 | sstrangr2 // (c) 1979 Yachiyo Electronics, Ltd. |
| 1469 | 1469 | sinvemag // Zenitone-Microsec Ltd. |
| r31374 | r31375 | |
| 2994 | 2994 | blktigera // 8/1987 (c) 1987 (US) |
| 2995 | 2995 | blktigerb1 // bootleg |
| 2996 | 2996 | blktigerb2 // bootleg |
| 2997 | blktigerb3 | |
| 2997 | blktigerb3 // bootleg? | |
| 2998 | 2998 | blkdrgon // 8/1987 (c) 1987 (Japan) |
| 2999 | 2999 | blkdrgonb // bootleg, hacked to say Black Tiger |
| 3000 | 3000 | sf // 8/1987 (c) 1987 (World) |
| r31374 | r31375 | |
| 3087 | 3087 | cawingbl // bootleg |
| 3088 | 3088 | cawingb2 // bootleg |
| 3089 | 3089 | nemo // 30/11/1990 (c) 1990 (World) |
| 3090 | nemor1 | |
| 3090 | nemor1 // 09/11/1990 (c) 1990 (World) | |
| 3091 | 3091 | nemoj // 20/11/1990 (c) 1990 (Japan) |
| 3092 | 3092 | sf2 // 22/05/1991 (c) 1991 (World) |
| 3093 | 3093 | sf2eb // 14/02/1991 (c) 1991 (World) |
| r31374 | r31375 | |
| 4552 | 4552 | passsht // (c) 1988 (FD1094, decrypted) |
| 4553 | 4553 | passshta // (c) 1988 (FD1094, decrypted) |
| 4554 | 4554 | passshtj // (c) 1988 (FD1094, decrypted) |
| 4555 | cencourt | |
| 4555 | cencourt // (c) 1988 (MC-8123B) | |
| 4556 | 4556 | riotcity // (c) 1991 Sega / Westone (Unprotected) |
| 4557 | 4557 | ryukyu // (c) 1990 (FD1094, decrypted) |
| 4558 | 4558 | sdib // (c) 1987 (FD1089A, decrypted) |
| r31374 | r31375 | |
| 5077 | 5077 | |
| 5078 | 5078 | // System C-2 games |
| 5079 | 5079 | borench // (c) 1990 Sega |
| 5080 | borencha | |
| 5080 | borencha // (c) 1990 Sega | |
| 5081 | 5081 | tfrceac // (c) 1990 Sega / Technosoft |
| 5082 | 5082 | tfrceacj // (c) 1990 Sega / Technosoft |
| 5083 | 5083 | tfrceacb // bootleg |
| r31374 | r31375 | |
| 5401 | 5401 | pokasuka // 2007.07 Pokasuka Ghost! |
| 5402 | 5402 | sl2007 // 2007.07 Shooting Love |
| 5403 | 5403 | asndynmt // 2007.07 Dynamite Deka EX - Asian dynamite |
| 5404 | rhytngk | |
| 5404 | rhytngk // 2007.09 Rhythm Tengoku | |
| 5405 | 5405 | ausfache // 2008.02 Akatsuki Denkou Senki Ausf.Achse |
| 5406 | 5406 | illvelo // 2008.06 Illvelo (Illmatic Envelope) |
| 5407 | 5407 | mamonoro // 2008.07 Mamoru-kun wa Norowarete Shimatta! |
| r31374 | r31375 | |
| 5435 | 5435 | vf4b // 2001.08.20 Virtua Fighter 4 (Rev B) (cartridge) |
| 5436 | 5436 | vf4c // 2002.01.31 Virtua Fighter 4 (Rev C) (cartridge) |
| 5437 | 5437 | kingrt66 // 2002.02 The King of Route 66 (Rev A) |
| 5438 | ||
| 5438 | // 2002.02.14 Initial D Arcade Stage (Japan) | |
| 5439 | 5439 | initd // 2002.03 Initial D Arcade Stage (Japan) (Rev B) |
| 5440 | 5440 | // 2002.06 World Club Champion Football Serie A 2001-2002 |
| 5441 | 5441 | soulsurf // 2002.07 Soul Surfer |
| r31374 | r31375 | |
| 5451 | 5451 | initdexpo // 2002.?? Initial D Arcade Stage (Export) |
| 5452 | 5452 | // 2002.?? Sega Driving Simulator |
| 5453 | 5453 | // 2003.03 World Club Champion Football Serie A 2001-2002 Ver.2 |
| 5454 | ||
| 5454 | // 2003.05 Initial D Arcade Stage Ver. 2 (Japan) (Rev A) | |
| 5455 | 5455 | initdv2j // 2003.05.27 Initial D Arcade Stage Ver. 2 (Japan) (Rev B) |
| 5456 | 5456 | // 2003.09 World Club Champion Football Serie A 2002-2003 |
| 5457 | 5457 | // 2003.?? Club Kart Cycraft Edition |
| r31374 | r31375 | |
| 5528 | 5528 | triforce // 2002.?? Triforce BIOS |
| 5529 | 5529 | vs2002ex // 2002.07.30 Virtua Striker 2002 (Export) |
| 5530 | 5530 | vs2002j // 2002.10 Virtua Striker 2002 (Japan) |
| 5531 | fzeroaxc | |
| 5531 | fzeroaxc // 2003.06.11 F-Zero AX (Rev. C) | |
| 5532 | 5532 | avalons // 2003.07 The Key Of Avalon: The Wizard Master (server) (Rev C) |
| 5533 | 5533 | // 2003.10 The Key Of Avalon 1.01 |
| 5534 | 5534 | gekpurya // 2003.10 Gekitou Pro Yakyuu Mizushima Shinji All Stars vs. Pro Yakyuu (Rev C) |
| 5535 | fzeroax | |
| 5535 | fzeroax // 2003.12 F-Zero AX (Rev. E) | |
| 5536 | 5536 | // 2003.12 The Key Of Avalon 1.10 |
| 5537 | 5537 | // 2004.04 The Key Of Avalon 1.20 - Summon The New Monsters |
| 5538 | 5538 | avalon13 // 2004.06.08 The Key Of Avalon 1.30 - Chaotic Sabbat (client) (Rev C) |
| r31374 | r31375 | |
| 5544 | 5544 | // 2005.08 Avalon no Kagi Ver.2.5 Kagi Seisen |
| 5545 | 5545 | mkartagp // 2005.12 Mario Kart Arcade Grand Prix |
| 5546 | 5546 | // 2005.?? Donkey Kong Jungle Fever |
| 5547 | ||
| 5547 | // 2006.01.31 Virtua Striker 4 Ver.2006 (export) | |
| 5548 | 5548 | vs42006 // 2006.05 Virtua Striker 4 Ver.2006 (Japan) (Rev D) |
| 5549 | 5549 | // 2006.?? Firmware Update For Compact Flash Box (Rev A) |
| 5550 | mkartag2 // 2007.03 Mario Kart Arcade Grand Prix 2 | |
| 5551 | mkartag2a // 2007.03 Mario Kart Arcade Grand Prix 2 | |
| 5550 | mkartag2 // 2007.03 Mario Kart Arcade Grand Prix 2 | |
| 5551 | mkartag2a // 2007.03 Mario Kart Arcade Grand Prix 2 | |
| 5552 | 5552 | |
| 5553 | 5553 | // Chihiro (X-Box based) |
| 5554 | 5554 | chihiro // 2002.?? Chihiro BIOS |
| r31374 | r31375 | |
| 5586 | 5586 | // 2004.12 Sega Network Taisen Mahjong MJ 2 (Rev D) |
| 5587 | 5587 | // 2005.02 Sega Network Taisen Mahjong MJ 2 (Rev E) |
| 5588 | 5588 | // 2005.02 Sega Network Taisen Mahjong MJ 2 (Rev F) |
| 5589 | mj2 | |
| 5589 | mj2 // 2005.02.02 Sega Network Taisen Mahjong MJ 2 (Rev G) | |
| 5590 | 5590 | // 2005.03 Sangokushi Taisen |
| 5591 | 5591 | gundamos // 2005.03 Gundam Battle Operating Simulator |
| 5592 | 5592 | // 2005.04 Quest of D Ver.1.20 |
| r31374 | r31375 | |
| 5629 | 5629 | // 2008.?? Sangokushi Taisen 3 Ver.J |
| 5630 | 5630 | // 2008.?? Sangokushi Taisen 3 War Begins |
| 5631 | 5631 | // 2008.?? Sangokushi Taisen 3 War Begins Ver.3.59 |
| 5632 | ||
| 5632 | // 2009.03 Firmware Update For Compact Flash Box | |
| 5633 | 5633 | ccfboxa // 2009.03.31 Firmware Update For Compact Flash Box (Rev A) |
| 5634 | 5634 | |
| 5635 | 5635 | hshavoc // (c) 1993 Data East |
| r31374 | r31375 | |
| 5887 | 5887 | cbusterw // MAB (c) 1990 Data East Corporation (World) |
| 5888 | 5888 | cbusterj // MAB (c) 1990 Data East Corporation (Japan) |
| 5889 | 5889 | twocrude // MAB (c) 1990 Data East USA (US) |
| 5890 | twocrudea | |
| 5890 | twocrudea // MAB (c) 1990 Data East USA (US) | |
| 5891 | 5891 | darkseal // MAC (c) 1990 Data East Corporation (World) |
| 5892 | 5892 | darkseal1 // MAC (c) 1990 Data East Corporation (World) |
| 5893 | 5893 | darksealj // MAC (c) 1990 Data East Corporation (Japan) |
| r31374 | r31375 | |
| 6106 | 6106 | stratof // (c) 1991 Tecmo |
| 6107 | 6107 | raiga // (c) 1991 Tecmo |
| 6108 | 6108 | drgnbowl // (c) 1992 Nics |
| 6109 | drgnbowla | |
| 6109 | drgnbowla // (c) 1992 Nics | |
| 6110 | 6110 | wc90 // (c) 1989 Tecmo |
| 6111 | 6111 | wc90a // (c) 1989 Tecmo |
| 6112 | 6112 | wc90b // (c) 1989 Tecmo |
| r31374 | r31375 | |
| 7688 | 7688 | skyadvntu // Alpha-68K96V 'SA' (c) 1989 SNK of America licensed from Alpha |
| 7689 | 7689 | skyadvntj // Alpha-68K96V 'SA' (c) 1989 Alpha Denshi Co. |
| 7690 | 7690 | gangwars // Alpha-68K96V (c) 1989 Alpha Denshi Co. |
| 7691 | gangwarsj | |
| 7691 | gangwarsj // Alpha-68K96V (c) 1989 Alpha Denshi Co. | |
| 7692 | 7692 | gangwarsu // Alpha-68K96V (c) 1989 Alpha Denshi Co. |
| 7693 | gangwarsb | |
| 7693 | gangwarsb // bootleg | |
| 7694 | 7694 | sbasebal // Alpha-68K96V (c) 1989 SNK of America licensed from Alpha |
| 7695 | 7695 | tnextspc // A8003 'NS' (c) 1989 - MASKROM |
| 7696 | 7696 | tnextspc2 // A8003 'NS' (c) 1989 - EPROMs |
| r31374 | r31375 | |
| 8341 | 8341 | rdft // (c) 1996 Seibu Kaihatsu |
| 8342 | 8342 | rdftu // (c) 1996 Seibu Kaihatsu (Fabtek license) |
| 8343 | 8343 | rdftau // (c) 1996 Seibu Kaihatsu |
| 8344 | rdftauge | |
| 8344 | rdftauge // (c) 1996 Seibu Kaihatsu (Tuning license and text display, but Australia region code) | |
| 8345 | 8345 | rdftj // (c) 1996 Seibu Kaihatsu |
| 8346 | 8346 | rdftadi // (c) 1996 Seibu Kaihatsu (Dream Island license) |
| 8347 | 8347 | rdftam // (c) 1996 Seibu Kaihatsu (Metrotainment license) |
| r31374 | r31375 | |
| 8589 | 8589 | crshrace2 // (c) 1993 Video System Co. |
| 8590 | 8590 | taotaido // (c) 1993 Video System Co. |
| 8591 | 8591 | taotaidoa // (c) 1993 Video System Co. |
| 8592 | taotaido3 | |
| 8592 | taotaido3 // (c) 1993 Video System Co. | |
| 8593 | 8593 | gstriker // (c) [1993] Human |
| 8594 | 8594 | gstrikera // (c) [1993] Human |
| 8595 | 8595 | gstrikerj // (c) [1993] Human |
| r31374 | r31375 | |
| 8623 | 8623 | // Semicom games on "Psikyo 68020"-like hardware |
| 8624 | 8624 | baryon // (c) 1997 SemiCom |
| 8625 | 8625 | dreamwld // (c) 2000 SemiCom |
| 8626 | rolcrush | |
| 8626 | rolcrush // (c) 1999 Trust | |
| 8627 | 8627 | |
| 8628 | 8628 | // SH2 board |
| 8629 | 8629 | s1945ii // (c) 1997 |
| r31374 | r31375 | |
| 8786 | 8786 | // Kaneko "AX System" games |
| 8787 | 8787 | berlwall // (c) 1991 Kaneko |
| 8788 | 8788 | berlwallt // (c) 1991 Kaneko |
| 8789 | berlwallk | |
| 8789 | berlwallk // (c) 1991 Kaneko (Korea, Inter license) | |
| 8790 | 8790 | mgcrystl // (c) 1991 Kaneko (World) |
| 8791 | 8791 | mgcrystlo // (c) 1991 Kaneko (World) |
| 8792 | 8792 | mgcrystlj // (c) 1991 Kaneko + distributed by Atlus (Japan) |
| r31374 | r31375 | |
| 9117 | 9117 | pollux // (c) 1991 Dooyong |
| 9118 | 9118 | polluxa // (c) 1991 Dooyong |
| 9119 | 9119 | polluxa2 // (c) 1991 Dooyong |
| 9120 | polluxn | |
| 9120 | polluxn // (c) 1991 NTC | |
| 9121 | 9121 | flytiger // (c) 1992 Dooyong |
| 9122 | 9122 | flytigera // (c) 1992 Dooyong |
| 9123 | 9123 | bluehawk // (c) 1993 Dooyong |
| r31374 | r31375 | |
| 9341 | 9341 | grdnstrmv // (c) 1998 Apples Industries license |
| 9342 | 9342 | grdnstrmk // (c) 1998 (Korea) |
| 9343 | 9343 | grdnstrmg // (c) 1998 |
| 9344 | grdnstrmj | |
| 9344 | grdnstrmj // (c) 1998 (Japan) | |
| 9345 | 9345 | redfoxwp2 // (c) 1998 (China) |
| 9346 | 9346 | redfoxwp2a // (c) 1998 (China) |
| 9347 | 9347 | bubl2000 // (c) 1998 Tuning |
| 9348 | 9348 | hotbubl // (c) 1998 Pandora |
| 9349 | 9349 | popspops // (c) 1999 |
| 9350 | 9350 | firehawk // (c) 2001 ESD |
| 9351 | firehawkv | |
| 9351 | firehawkv // (c) 2001 ESD | |
| 9352 | 9352 | mangchi // (c) 2000 |
| 9353 | 9353 | spec2k // (c) 2000 Yonatech |
| 9354 | spec2kh | |
| 9354 | spec2kh // (c) 2000 Yonatech | |
| 9355 | 9355 | |
| 9356 | 9356 | // ESD games |
| 9357 | 9357 | // http://www.esdgame.co.kr/english/ |
| r31374 | r31375 | |
| 9659 | 9659 | kovsh103 // |
| 9660 | 9660 | kovsh102 // |
| 9661 | 9661 | kovsh101 // |
| 9662 | kovsh100 | |
| 9662 | kovsh100 // | |
| 9663 | 9663 | kovqhsgs // bootleg |
| 9664 | 9664 | photoy2k // (c) 1999 Photo Y2k |
| 9665 | 9665 | photoy2k102 // |
| r31374 | r31375 | |
| 28337 | 28337 | ac1pstrt // Pound Stretcher (Pcp) |
| 28338 | 28338 | ac1primt // Primetime (Ace) |
| 28339 | 28339 | ac1taklv // Take It Or Leave It (Ace) |
| 28340 | ac1cshtw // Cash Towers (Ace) | |
| 28340 | ac1cshtw // Cash Towers (Ace) | |
| 28341 | 28341 | ac1bbclb // Big Break Club (Ace) |
| 28342 | 28342 | ac1bbclba // |
| 28343 | 28343 | ac1clbsv // Club Sovereign (Ace) |
| r31374 | r31375 | |
| 31687 | 31687 | |
| 31688 | 31688 | amusco // 1987, Amusco. |
| 31689 | 31689 | cocoloco // 198?, Petaco S.A. |
| 31690 |
| r31374 | r31375 | |
|---|---|---|
| 19 | 19 | |
| 20 | 20 | #define MCFG_ATARI_CAGE_SPEEDUP(_speedup) \ |
| 21 | 21 | atari_cage_device::static_set_speedup(*device, _speedup); |
| 22 | ||
| 22 | ||
| 23 | 23 | class atari_cage_device : public device_t |
| 24 | 24 | { |
| 25 | 25 | public: |
| r31374 | r31375 | |
| 32 | 32 | |
| 33 | 33 | // optional information overrides |
| 34 | 34 | virtual machine_config_constructor device_mconfig_additions() const; |
| 35 | ||
| 35 | ||
| 36 | 36 | void reset_w(int state); |
| 37 | 37 | |
| 38 | 38 | UINT16 main_r(); |
| 39 | 39 | void main_w(UINT16 data); |
| 40 | 40 | |
| 41 | 41 | UINT16 control_r(); |
| 42 | void control_w(UINT16 data); | |
| 43 | ||
| 42 | void control_w(UINT16 data); | |
| 43 | ||
| 44 | 44 | TIMER_DEVICE_CALLBACK_MEMBER( dma_timer_callback ); |
| 45 | 45 | void update_dma_state(address_space &space); |
| 46 | 46 | TIMER_DEVICE_CALLBACK_MEMBER( cage_timer_callback ); |
| r31374 | r31375 | |
| 58 | 58 | |
| 59 | 59 | protected: |
| 60 | 60 | // device-level overrides |
| 61 | virtual void device_start(); | |
| 62 | ||
| 61 | virtual void device_start(); | |
| 62 | ||
| 63 | 63 | private: |
| 64 | 64 | cpu_device *m_cpu; |
| 65 | 65 | attotime m_cpu_h1_clock_period; |
| r31374 | r31375 | |
| 85 | 85 | |
| 86 | 86 | UINT32 *m_speedup_ram; |
| 87 | 87 | dmadac_sound_device *m_dmadac[4]; |
| 88 | ||
| 88 | ||
| 89 | 89 | offs_t m_speedup; |
| 90 | 90 | }; |
| 91 | 91 | |
| r31374 | r31375 | |
| 98 | 98 | public: |
| 99 | 99 | // construction/destruction |
| 100 | 100 | atari_cage_seattle_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock); |
| 101 | ||
| 101 | ||
| 102 | 102 | // optional information overrides |
| 103 | 103 | virtual machine_config_constructor device_mconfig_additions() const; |
| 104 | ||
| 104 | ||
| 105 | 105 | }; |
| 106 | 106 | |
| 107 | 107 | // device type definition |
| r31374 | r31375 | |
|---|---|---|
| 37 | 37 | DECLARE_WRITE8_MEMBER( slave_port_w ); |
| 38 | 38 | DECLARE_READ8_MEMBER( slave_comm_r ); |
| 39 | 39 | DECLARE_WRITE8_MEMBER( slave_comm_w ); |
| 40 | ||
| 40 | ||
| 41 | 41 | protected: |
| 42 | 42 | // device-level overrides |
| 43 | 43 | virtual void device_start(); |
| 44 | 44 | virtual void device_reset(); |
| 45 | ||
| 45 | ||
| 46 | 46 | private: |
| 47 | 47 | void update_nmi(); |
| 48 | 48 |
| r31374 | r31375 | |
|---|---|---|
| 30 | 30 | public: |
| 31 | 31 | cps3_sound_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock); |
| 32 | 32 | ~cps3_sound_device() { } |
| 33 | ||
| 33 | ||
| 34 | 34 | void set_base(INT8* base) { m_base = base; } |
| 35 | 35 | |
| 36 | 36 | DECLARE_WRITE32_MEMBER( cps3_sound_w ); |
| r31374 | r31375 | |
|---|---|---|
| 18 | 18 | #define MCFG_DCS2_AUDIO_POLLING_OFFSET(_polling_offset) \ |
| 19 | 19 | dcs_audio_device::static_set_polling_offset(*device, _polling_offset); |
| 20 | 20 | |
| 21 | ||
| 21 | ||
| 22 | 22 | class dcs_audio_device : public device_t |
| 23 | 23 | { |
| 24 | 24 | public: |
| r31374 | r31375 | |
| 106 | 106 | TIMER_CALLBACK_MEMBER( s2_ack_callback ); |
| 107 | 107 | int preprocess_stage_2(UINT16 data); |
| 108 | 108 | int preprocess_write(UINT16 data); |
| 109 | ||
| 109 | ||
| 110 | 110 | protected: |
| 111 | 111 | // device-level overrides |
| 112 | 112 | virtual void device_start(); |
| 113 | 113 | virtual void device_reset(); |
| 114 | ||
| 114 | ||
| 115 | 115 | protected: |
| 116 | 116 | struct sdrc_state |
| 117 | 117 | { |
| r31374 | r31375 | |
| 181 | 181 | UINT8 m_last_output_full; |
| 182 | 182 | UINT8 m_last_input_empty; |
| 183 | 183 | UINT16 m_progflags; |
| 184 | ||
| 184 | ||
| 185 | 185 | write_line_delegate m_output_full_cb; |
| 186 | 186 | write_line_delegate m_input_empty_cb; |
| 187 | ||
| 187 | ||
| 188 | 188 | read16_delegate m_fifo_data_r; |
| 189 | 189 | read16_delegate m_fifo_status_r; |
| 190 | 190 | write_line_delegate m_fifo_reset_w; |
| r31374 | r31375 | |
| 206 | 206 | sdrc_state m_sdrc; |
| 207 | 207 | dsio_state m_dsio; |
| 208 | 208 | hle_transfer_state m_transfer; |
| 209 | ||
| 209 | ||
| 210 | 210 | int m_dram_in_mb; |
| 211 | 211 | }; |
| 212 | 212 | |
| r31374 | r31375 | |
| 218 | 218 | public: |
| 219 | 219 | // construction/destruction |
| 220 | 220 | dcs_audio_2k_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock); |
| 221 | ||
| 221 | ||
| 222 | 222 | // optional information overrides |
| 223 | 223 | virtual machine_config_constructor device_mconfig_additions() const; |
| 224 | ||
| 224 | ||
| 225 | 225 | }; |
| 226 | 226 | |
| 227 | 227 | // device type definition |
| r31374 | r31375 | |
| 234 | 234 | public: |
| 235 | 235 | // construction/destruction |
| 236 | 236 | dcs_audio_2k_uart_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock); |
| 237 | ||
| 237 | ||
| 238 | 238 | // optional information overrides |
| 239 | 239 | virtual machine_config_constructor device_mconfig_additions() const; |
| 240 | ||
| 240 | ||
| 241 | 241 | }; |
| 242 | 242 | |
| 243 | 243 | // device type definition |
| r31374 | r31375 | |
| 250 | 250 | public: |
| 251 | 251 | // construction/destruction |
| 252 | 252 | dcs_audio_8k_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock); |
| 253 | ||
| 253 | ||
| 254 | 254 | // optional information overrides |
| 255 | 255 | virtual machine_config_constructor device_mconfig_additions() const; |
| 256 | ||
| 256 | ||
| 257 | 257 | }; |
| 258 | 258 | |
| 259 | 259 | // device type definition |
| r31374 | r31375 | |
| 266 | 266 | public: |
| 267 | 267 | // construction/destruction |
| 268 | 268 | dcs_audio_wpc_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock); |
| 269 | ||
| 269 | ||
| 270 | 270 | // optional information overrides |
| 271 | 271 | virtual machine_config_constructor device_mconfig_additions() const; |
| 272 | 272 | }; |
| r31374 | r31375 | |
| 285 | 285 | |
| 286 | 286 | protected: |
| 287 | 287 | // device-level overrides |
| 288 | virtual void device_start(); | |
| 288 | virtual void device_start(); | |
| 289 | 289 | }; |
| 290 | 290 | |
| 291 | 291 | // dcs2_audio_2115_device |
| r31374 | r31375 | |
| 295 | 295 | public: |
| 296 | 296 | // construction/destruction |
| 297 | 297 | dcs2_audio_2115_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock); |
| 298 | ||
| 298 | ||
| 299 | 299 | // optional information overrides |
| 300 | 300 | virtual machine_config_constructor device_mconfig_additions() const; |
| 301 | ||
| 301 | ||
| 302 | 302 | }; |
| 303 | 303 | |
| 304 | 304 | // device type definition |
| r31374 | r31375 | |
| 311 | 311 | public: |
| 312 | 312 | // construction/destruction |
| 313 | 313 | dcs2_audio_2104_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock); |
| 314 | ||
| 314 | ||
| 315 | 315 | // optional information overrides |
| 316 | 316 | virtual machine_config_constructor device_mconfig_additions() const; |
| 317 | ||
| 317 | ||
| 318 | 318 | }; |
| 319 | 319 | |
| 320 | 320 | // device type definition |
| r31374 | r31375 | |
| 327 | 327 | public: |
| 328 | 328 | // construction/destruction |
| 329 | 329 | dcs2_audio_dsio_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock); |
| 330 | ||
| 330 | ||
| 331 | 331 | // optional information overrides |
| 332 | 332 | virtual machine_config_constructor device_mconfig_additions() const; |
| 333 | ||
| 333 | ||
| 334 | 334 | }; |
| 335 | 335 | |
| 336 | 336 | // device type definition |
| r31374 | r31375 | |
| 343 | 343 | public: |
| 344 | 344 | // construction/destruction |
| 345 | 345 | dcs2_audio_denver_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock); |
| 346 | ||
| 346 | ||
| 347 | 347 | // optional information overrides |
| 348 | 348 | virtual machine_config_constructor device_mconfig_additions() const; |
| 349 | ||
| 349 | ||
| 350 | 350 | }; |
| 351 | 351 | |
| 352 | 352 | // device type definition |
| r31374 | r31375 | |
|---|---|---|
| 21 | 21 | static void set_rom0_tag(device_t &device, const char *tag) { downcast<nmk112_device &>(device).m_tag0 = tag; } |
| 22 | 22 | static void set_rom1_tag(device_t &device, const char *tag) { downcast<nmk112_device &>(device).m_tag1 = tag; } |
| 23 | 23 | static void set_page_mask(device_t &device, UINT8 mask) { downcast<nmk112_device &>(device).m_page_mask = ~mask; } |
| 24 | ||
| 24 | ||
| 25 | 25 | DECLARE_WRITE8_MEMBER( okibank_w ); |
| 26 | 26 | |
| 27 | 27 | protected: |
| r31374 | r31375 | |
|---|---|---|
| 28 | 28 | // ======================> ng_memcard_device |
| 29 | 29 | |
| 30 | 30 | class ng_memcard_device : public device_t, |
| 31 | | |
| 31 | public device_image_interface | |
| 32 | 32 | { |
| 33 | 33 | public: |
| 34 | 34 | // construction/destruction |
| 35 | 35 | ng_memcard_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock); |
| 36 | ||
| 36 | ||
| 37 | 37 | virtual iodevice_t image_type() const { return IO_MEMCARD; } |
| 38 | 38 | |
| 39 | 39 | virtual bool is_readable() const { return 1; } |
| r31374 | r31375 | |
| 51 | 51 | // device-level overrides |
| 52 | 52 | virtual void device_start(); |
| 53 | 53 | virtual void device_config_complete(); |
| 54 | ||
| 54 | ||
| 55 | 55 | DECLARE_READ8_MEMBER(read); |
| 56 | DECLARE_WRITE8_MEMBER(write); | |
| 56 | DECLARE_WRITE8_MEMBER(write); | |
| 57 | 57 | |
| 58 | 58 | /* 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; } | |
| 60 | 60 | private: |
| 61 | 61 | UINT8 m_memcard_data[0x800]; |
| 62 | 62 | }; |
| r31374 | r31375 | |
|---|---|---|
| 23 | 23 | |
| 24 | 24 | static void static_set_num_boards(device_t &device, int num) { downcast<konppc_device &>(device).num_cgboards = num; } |
| 25 | 25 | static void static_set_cbboard_type(device_t &device, int cgtype) { downcast<konppc_device &>(device).cgboard_type = cgtype; } |
| 26 | ||
| 26 | ||
| 27 | 27 | void set_cgboard_id(int board_id); |
| 28 | 28 | int get_cgboard_id(void); |
| 29 | 29 | void set_cgboard_texture_bank(int board, const char *bank, UINT8 *rom); |
| 30 | ||
| 31 | 30 | |
| 31 | ||
| 32 | 32 | // read/write |
| 33 | 33 | DECLARE_READ32_MEMBER( cgboard_dsp_comm_r_ppc ); |
| 34 | 34 | DECLARE_WRITE32_MEMBER( cgboard_dsp_comm_w_ppc ); |
| r31374 | r31375 | |
| 58 | 58 | protected: |
| 59 | 59 | // device-level overrides |
| 60 | 60 | virtual void device_start(); |
| 61 | ||
| 61 | ||
| 62 | 62 | UINT32 dsp_comm_sharc_r(int board, int offset); |
| 63 | 63 | void dsp_comm_sharc_w(address_space &space, int board, int offset, UINT32 data); |
| 64 | 64 | UINT32 dsp_shared_ram_r_sharc(int board, int offset); |
| r31374 | r31375 | |
| 67 | 67 | UINT32 nwk_fifo_r(address_space &space, int board); |
| 68 | 68 | void nwk_fifo_w(int board, UINT32 data); |
| 69 | 69 | private: |
| 70 | // internal state | |
| 70 | // internal state | |
| 71 | 71 | UINT32 dsp_comm_ppc[MAX_CG_BOARDS][2]; |
| 72 | 72 | UINT32 dsp_comm_sharc[MAX_CG_BOARDS][2]; |
| 73 | 73 | UINT8 dsp_shared_ram_bank[MAX_CG_BOARDS]; |
| 74 | ||
| 74 | ||
| 75 | 75 | INT32 cgboard_id; |
| 76 | 76 | INT32 cgboard_type; |
| 77 | 77 | INT32 num_cgboards; |
| 78 | ||
| 79 | UINT32 *dsp_shared_ram[MAX_CG_BOARDS]; | |
| 80 | ||
| 78 | ||
| 79 | UINT32 *dsp_shared_ram[MAX_CG_BOARDS]; | |
| 80 | ||
| 81 | 81 | UINT32 dsp_state[MAX_CG_BOARDS]; |
| 82 | 82 | UINT32 nwk_device_sel[MAX_CG_BOARDS]; |
| 83 | 83 | const char *texture_bank[MAX_CG_BOARDS]; |
| 84 | ||
| 84 | ||
| 85 | 85 | int nwk_fifo_half_full_r; |
| 86 | 86 | int nwk_fifo_half_full_w; |
| 87 | 87 | int nwk_fifo_full; |
| 88 | 88 | int nwk_fifo_mask; |
| 89 | ||
| 89 | ||
| 90 | 90 | UINT32 *nwk_fifo[MAX_CG_BOARDS]; |
| 91 | 91 | INT32 nwk_fifo_read_ptr[MAX_CG_BOARDS]; |
| 92 | 92 | INT32 nwk_fifo_write_ptr[MAX_CG_BOARDS]; |
| 93 | ||
| 94 | UINT32 *nwk_ram[MAX_CG_BOARDS]; | |
| 93 | ||
| 94 | UINT32 *nwk_ram[MAX_CG_BOARDS]; | |
| 95 | 95 | }; |
| 96 | 96 | |
| 97 | 97 |
| r31374 | r31375 | |
|---|---|---|
| 6 | 6 | #ifndef WPC_OUT_H |
| 7 | 7 | #define WPC_OUT_H |
| 8 | 8 | |
| 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 ) \ | |
| 11 | 11 | downcast<wpc_out_device *>(device)->set_gi_count(_count); |
| 12 | 12 | |
| 13 | 13 | class wpc_out_device : public device_t |
| r31374 | r31375 | |
|---|---|---|
| 20 | 20 | // construction/destruction |
| 21 | 21 | midway_serial_pic_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock); |
| 22 | 22 | 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 | ||
| 24 | 24 | static void static_set_upper(device_t &device, int upper) { downcast<midway_serial_pic_device &>(device).m_upper = upper; } |
| 25 | ||
| 25 | ||
| 26 | 26 | DECLARE_READ8_MEMBER( read ); |
| 27 | 27 | DECLARE_WRITE8_MEMBER( write ); |
| 28 | 28 | DECLARE_READ8_MEMBER( status_r ); |
| r31374 | r31375 | |
| 30 | 30 | |
| 31 | 31 | protected: |
| 32 | 32 | // device-level overrides |
| 33 | virtual void device_start(); | |
| 34 | ||
| 33 | virtual void device_start(); | |
| 34 | ||
| 35 | 35 | void generate_serial_data(int upper); |
| 36 | 36 | void serial_register_state(); |
| 37 | ||
| 37 | ||
| 38 | 38 | UINT8 m_data[16]; // reused by other devices |
| 39 | int | |
| 39 | int m_upper; | |
| 40 | 40 | private: |
| 41 | 41 | UINT8 m_buff; |
| 42 | 42 | UINT8 m_idx; |
| r31374 | r31375 | |
| 51 | 51 | |
| 52 | 52 | #define MCFG_MIDWAY_SERIAL_PIC_UPPER(_upper) \ |
| 53 | 53 | midway_serial_pic_device::static_set_upper(*device, _upper); |
| 54 | ||
| 54 | ||
| 55 | 55 | /* 2nd generation Midway serial/NVRAM/RTC PIC */ |
| 56 | 56 | |
| 57 | 57 | // ======================> midway_serial_pic2_device |
| 58 | 58 | |
| 59 | 59 | class midway_serial_pic2_device : public midway_serial_pic_device, |
| 60 | | |
| 60 | public device_nvram_interface | |
| 61 | 61 | { |
| 62 | 62 | public: |
| 63 | 63 | // construction/destruction |
| r31374 | r31375 | |
| 65 | 65 | 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); |
| 66 | 66 | |
| 67 | 67 | static void static_set_yearoffs(device_t &device, int yearoffs) { downcast<midway_serial_pic2_device &>(device).m_yearoffs = yearoffs; } |
| 68 | ||
| 68 | ||
| 69 | 69 | DECLARE_READ8_MEMBER( read ); |
| 70 | 70 | DECLARE_WRITE8_MEMBER( write ); |
| 71 | 71 | DECLARE_READ8_MEMBER( status_r ); |
| r31374 | r31375 | |
| 80 | 80 | virtual void nvram_default(); |
| 81 | 81 | virtual void nvram_read(emu_file &file); |
| 82 | 82 | virtual void nvram_write(emu_file &file); |
| 83 | ||
| 83 | ||
| 84 | 84 | private: |
| 85 | 85 | |
| 86 | 86 | void pic_register_state(); |
| 87 | 87 | TIMER_CALLBACK_MEMBER( reset_timer ); |
| 88 | ||
| 88 | ||
| 89 | 89 | UINT16 m_latch; |
| 90 | 90 | attotime m_latch_expire_time; |
| 91 | 91 | UINT8 m_state; |
| r31374 | r31375 | |
| 106 | 106 | // device type definition |
| 107 | 107 | extern const device_type MIDWAY_SERIAL_PIC2; |
| 108 | 108 | |
| 109 | #define MCFG_MIDWAY_SERIAL_PIC2_UPPER | |
| 109 | #define MCFG_MIDWAY_SERIAL_PIC2_UPPER MCFG_MIDWAY_SERIAL_PIC_UPPER | |
| 110 | 110 | |
| 111 | 111 | #define MCFG_MIDWAY_SERIAL_PIC2_YEAR_OFFS(_yearoffs) \ |
| 112 | 112 | midway_serial_pic2_device::static_set_yearoffs(*device, _yearoffs); |
| r31374 | r31375 | |
| 124 | 124 | static void static_set_shuffle(device_t &device, UINT8 shuffle) { downcast<midway_ioasic_device &>(device).m_shuffle_type = shuffle; } |
| 125 | 125 | static void static_set_shuffle_default(device_t &device, UINT8 shuffle) { downcast<midway_ioasic_device &>(device).m_shuffle_default = shuffle; } |
| 126 | 126 | 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); } | |
| 128 | 128 | |
| 129 | 129 | void set_shuffle_state(int state); |
| 130 | 130 | void fifo_w(UINT16 data); |
| r31374 | r31375 | |
| 136 | 136 | |
| 137 | 137 | DECLARE_WRITE_LINE_MEMBER(ioasic_input_empty); |
| 138 | 138 | DECLARE_WRITE_LINE_MEMBER(ioasic_output_full); |
| 139 | ||
| 139 | ||
| 140 | 140 | DECLARE_READ32_MEMBER( read ); |
| 141 | 141 | DECLARE_WRITE32_MEMBER( write ); |
| 142 | 142 | DECLARE_READ32_MEMBER( packed_r ); |
| 143 | 143 | DECLARE_WRITE32_MEMBER( packed_w ); |
| 144 | 144 | |
| 145 | 145 | DECLARE_WRITE8_MEMBER(cage_irq_handler); |
| 146 | ||
| 146 | ||
| 147 | 147 | void ioasic_reset(); |
| 148 | 148 | |
| 149 | 149 | protected: |
| r31374 | r31375 | |
| 174 | 174 | UINT16 m_fifo_out; |
| 175 | 175 | UINT16 m_fifo_bytes; |
| 176 | 176 | offs_t m_fifo_force_buffer_empty_pc; |
| 177 | ||
| 177 | ||
| 178 | 178 | atari_cage_device *m_cage; |
| 179 | 179 | dcs_audio_device *m_dcs; |
| 180 | 180 | }; |
| r31374 | r31375 | |
| 183 | 183 | // device type definition |
| 184 | 184 | extern const device_type MIDWAY_IOASIC; |
| 185 | 185 | |
| 186 | #define MCFG_MIDWAY_IOASIC_UPPER | |
| 186 | #define MCFG_MIDWAY_IOASIC_UPPER MCFG_MIDWAY_SERIAL_PIC_UPPER | |
| 187 | 187 | |
| 188 | 188 | #define MCFG_MIDWAY_IOASIC_YEAR_OFFS MCFG_MIDWAY_SERIAL_PIC2_YEAR_OFFS |
| 189 | 189 | |
| 190 | 190 | #define MCFG_MIDWAY_IOASIC_SHUFFLE(_shuffle) \ |
| 191 | 191 | midway_ioasic_device::static_set_shuffle(*device, _shuffle); |
| 192 | ||
| 192 | ||
| 193 | 193 | #define MCFG_MIDWAY_IOASIC_SHUFFLE_DEFAULT(_shuffle) \ |
| 194 | 194 | midway_ioasic_device::static_set_shuffle_default(*device, _shuffle); |
| 195 | 195 | |
| r31374 | r31375 | |
| 198 | 198 | |
| 199 | 199 | #define MCFG_MIDWAY_IOASIC_AUTO_ACK(_ack) \ |
| 200 | 200 | midway_ioasic_device::static_set_auto_ack(*device, _ack); |
| 201 | ||
| 202 | ||
| 201 | ||
| 202 | ||
| 203 | 203 | enum |
| 204 | 204 | { |
| 205 | 205 | MIDWAY_IOASIC_STANDARD = 0, |
| r31374 | r31375 | |
| 213 | 213 | MIDWAY_IOASIC_HYPRDRIV |
| 214 | 214 | }; |
| 215 | 215 | |
| 216 | #endif | |
| No newline at end of file | ||
| 216 | #endif |
| r31374 | r31375 | |
|---|---|---|
| 12 | 12 | //************************************************************************** |
| 13 | 13 | |
| 14 | 14 | #define MCFG_CUS117_CPUS(_maincpu, _subcpu) \ |
| 15 | ||
| 15 | namco_c117_device::set_cpu_tags(*device, _maincpu, _subcpu); | |
| 16 | 16 | |
| 17 | 17 | #define MCFG_CUS117_SUBRES_CB(_devcb) \ |
| 18 | ||
| 18 | devcb = &namco_c117_device::set_subres_cb(*device, DEVCB_##_devcb); | |
| 19 | 19 | |
| 20 | 20 | |
| 21 | 21 | //*************************************************************************** |
| r31374 | r31375 | |
|---|---|---|
| 41 | 41 | int intensity; |
| 42 | 42 | UINT32 color; |
| 43 | 43 | }; |
| 44 | ||
| 44 | ||
| 45 | 45 | required_device<cpu_device> m_maincpu; |
| 46 | 46 | optional_device<lsi53c810_device> m_lsi53c810; |
| 47 | 47 | required_device<cpu_device> m_audiocpu; |
| r31374 | r31375 | |
|---|---|---|
| 159 | 159 | UINT8 m_pwrkick_hopper; |
| 160 | 160 | DECLARE_CUSTOM_INPUT_MEMBER(pwrkick_hopper_status_r); |
| 161 | 161 | DECLARE_WRITE8_MEMBER(pwrkick_coin_w); |
| 162 | ||
| 162 | ||
| 163 | 163 | DECLARE_WRITE_LINE_MEMBER(toaplan2_reset); |
| 164 | 164 | protected: |
| 165 | 165 | virtual void device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr); |
| r31374 | r31375 | |
|---|---|---|
| 47 | 47 | required_device<k051316_device> m_k051316_1; |
| 48 | 48 | required_device<k051316_device> m_k051316_2; |
| 49 | 49 | required_device<palette_device> m_palette; |
| 50 | ||
| 50 | ||
| 51 | 51 | DECLARE_WRITE8_MEMBER(chqflag_bankswitch_w); |
| 52 | 52 | DECLARE_WRITE8_MEMBER(chqflag_vreg_w); |
| 53 | 53 | DECLARE_WRITE8_MEMBER(select_analog_ctrl_w); |
| r31374 | r31375 | |
|---|---|---|
| 72 | 72 | DECLARE_READ32_MEMBER(colorram_protection_r); |
| 73 | 73 | DECLARE_WRITE32_MEMBER(colorram_protection_w); |
| 74 | 74 | DECLARE_WRITE32_MEMBER(tmek_pf_w); |
| 75 | ||
| 75 | ||
| 76 | 76 | DECLARE_WRITE8_MEMBER(cage_irq_callback); |
| 77 | ||
| 77 | ||
| 78 | 78 | void atarigt_colorram_w(offs_t address, UINT16 data, UINT16 mem_mask); |
| 79 | 79 | UINT16 atarigt_colorram_r(offs_t address); |
| 80 | 80 | DECLARE_DRIVER_INIT(primrage); |
| r31374 | r31375 | |
|---|---|---|
| 40 | 40 | required_device<gfxdecode_device> m_gfxdecode; |
| 41 | 41 | required_device<palette_device> m_palette; |
| 42 | 42 | required_shared_ptr<UINT32> m_generic_paletteram_32; |
| 43 | ||
| 43 | ||
| 44 | 44 | ioport_port *m_inputs[4]; |
| 45 | 45 | UINT8 m_sys0; |
| 46 | 46 | UINT8 m_sys1; |
| r31374 | r31375 | |
|---|---|---|
| 30 | 30 | #define SC45_BUTTON_MATRIX_7_0 IPT_BUTTON13 |
| 31 | 31 | #define SC45_BUTTON_MATRIX_7_1 IPT_BUTTON14 |
| 32 | 32 | #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 | |
| 34 | 34 | #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)..... |
| 35 | 35 | #define SC45_BUTTON_MATRIX_7_5 IPT_MAHJONG_B |
| 36 | 36 | |
| r31374 | r31375 | |
| 578 | 578 | DECLARE_MACHINE_RESET(sc4); |
| 579 | 579 | |
| 580 | 580 | DECLARE_WRITE_LINE_MEMBER(bfm_sc4_irqhandler); |
| 581 | ||
| 581 | ||
| 582 | 582 | void bfm_sc4_68307_porta_w(address_space &space, bool dedicated, UINT8 data, UINT8 line_mask); |
| 583 | 583 | DECLARE_WRITE8_MEMBER( bfm_sc4_reel3_w ); |
| 584 | 584 | DECLARE_WRITE8_MEMBER( bfm_sc4_reel4_w ); |
| r31374 | r31375 | |
| 731 | 731 | PORT_DIPSETTING( 0x0000, DEF_STR( Off ) ) \ |
| 732 | 732 | PORT_DIPSETTING( 0x0010, DEF_STR( On ) ) \ |
| 733 | 733 | 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 */ \ | |
| 735 | 735 | PORT_DIPSETTING( 0x0000, DEF_STR( Off ) ) \ |
| 736 | 736 | PORT_DIPSETTING( 0x0001, DEF_STR( On ) ) \ |
| 737 | 737 | PORT_DIPNAME( 0x0002, 0x0000, "IN 18-1 (DSW12)" ) /* DIL12 18.1 */ \ |
| r31374 | r31375 | |
|---|---|---|
| 254 | 254 | #define REG_COLOR29 (0x1BA/2) /* W D Color table 29 */ |
| 255 | 255 | #define REG_COLOR30 (0x1BC/2) /* W D Color table 30 */ |
| 256 | 256 | #define REG_COLOR31 (0x1BE/2) /* W D Color table 31 */ |
| 257 | #define REG_BEAMCON0 | |
| 257 | #define REG_BEAMCON0 (0x1dc/2) // W A Programmable signal generator (ECS Agnus) | |
| 258 | 258 | #define REG_DIWHIGH (0x1E4/2) /* W A D Display window upper bits for start/stop */ |
| 259 | 259 | #define REG_FMODE (0x1FC/2) /* W A D Fetch mode */ |
| 260 | 260 | |
| r31374 | r31375 | |
| 316 | 316 | |
| 317 | 317 | |
| 318 | 318 | // 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) | |
| 322 | 322 | |
| 323 | 323 | |
| 324 | 324 | class amiga_state : public driver_device |
| r31374 | r31375 | |
| 378 | 378 | UINT16 (*m_chip_ram_r)(amiga_state *state, offs_t offset); |
| 379 | 379 | void (*m_chip_ram_w)(amiga_state *state, offs_t offset, UINT16 data); |
| 380 | 380 | |
| 381 | ||
| 381 | ||
| 382 | 382 | /* sprite states */ |
| 383 | 383 | UINT8 m_sprite_comparitor_enable_mask; |
| 384 | 384 | UINT8 m_sprite_dma_reload_mask; |
| r31374 | r31375 | |
| 446 | 446 | DECLARE_READ8_MEMBER( cia_1_port_a_read ); |
| 447 | 447 | DECLARE_WRITE8_MEMBER( cia_1_port_a_write ); |
| 448 | 448 | DECLARE_WRITE_LINE_MEMBER( cia_1_irq ); |
| 449 | ||
| 449 | ||
| 450 | 450 | DECLARE_WRITE_LINE_MEMBER( rs232_rx_w ); |
| 451 | 451 | DECLARE_WRITE_LINE_MEMBER( rs232_dcd_w ); |
| 452 | 452 | DECLARE_WRITE_LINE_MEMBER( rs232_dsr_w ); |
| r31374 | r31375 | |
| 518 | 518 | // denise/lisa chip id |
| 519 | 519 | enum |
| 520 | 520 | { |
| 521 | DENISE = 0xffff, | |
| 521 | DENISE = 0xffff, // actually this register doesn't exist on ocs | |
| 522 | 522 | DENISE_HR = 0x00fc, |
| 523 | 523 | LISA = 0x00f8 |
| 524 | 524 | }; |
| r31374 | r31375 | |
| 593 | 593 | |
| 594 | 594 | enum |
| 595 | 595 | { |
| 596 | VPOSR_LOF = 0x8000 | |
| 596 | VPOSR_LOF = 0x8000 // long frame | |
| 597 | 597 | }; |
| 598 | 598 | |
| 599 | 599 | enum |
| 600 | 600 | { |
| 601 | ADKCON_UARTBRK = 0x800 | |
| 601 | ADKCON_UARTBRK = 0x800 // send break | |
| 602 | 602 | }; |
| 603 | 603 | |
| 604 | 604 | // serial port flags |
| 605 | 605 | enum |
| 606 | 606 | { |
| 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 | |
| 612 | 612 | }; |
| 613 | 613 | |
| 614 | 614 | enum |
| 615 | 615 | { |
| 616 | SERPER_LONG = 0x8000 | |
| 616 | SERPER_LONG = 0x8000 // 9-bit mode | |
| 617 | 617 | }; |
| 618 | 618 | |
| 619 | 619 | // pot counters |
| r31374 | r31375 | |
|---|---|---|
| 82 | 82 | void zeus_draw_quad(int long_fmt, const UINT32 *databuffer, UINT32 texdata, int logit); |
| 83 | 83 | |
| 84 | 84 | 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); | |
| 86 | 86 | }; |
| 87 | 87 | |
| 88 | 88 | |
| r31374 | r31375 | |
| 96 | 96 | UINT32 screen_update_midzeus2(screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect); |
| 97 | 97 | DECLARE_READ32_MEMBER( zeus2_r ); |
| 98 | 98 | DECLARE_WRITE32_MEMBER( zeus2_w ); |
| 99 | private: | |
| 99 | private: | |
| 100 | 100 | void exit_handler2(); |
| 101 | 101 | void zeus2_register32_w(offs_t offset, UINT32 data, int logit); |
| 102 | 102 | void zeus2_register_update(offs_t offset, UINT32 oldval, int logit); |
| 103 | 103 | int zeus2_fifo_process(const UINT32 *data, int numwords); |
| 104 | 104 | void zeus2_pointer_write(UINT8 which, UINT32 value); |
| 105 | 105 | 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); | |
| 107 | 107 | void log_fifo_command(const UINT32 *data, int numwords, const char *suffix); |
| 108 | 108 | }; |
| r31374 | r31375 | |
|---|---|---|
| 82 | 82 | required_device<tecmo_mix_device> m_mixer; |
| 83 | 83 | |
| 84 | 84 | |
| 85 | ||
| 85 | ||
| 86 | 86 | }; |
| r31374 | r31375 | |
|---|---|---|
| 454 | 454 | /* DS III/IV board */ |
| 455 | 455 | TIMER_DEVICE_CALLBACK_MEMBER( ds3sdsp_internal_timer_callback ); |
| 456 | 456 | TIMER_DEVICE_CALLBACK_MEMBER( ds3xdsp_internal_timer_callback ); |
| 457 | ||
| 457 | ||
| 458 | 458 | }; |
| 459 | 459 | |
| 460 | 460 |
| r31374 | r31375 | |
|---|---|---|
| 121 | 121 | void set_outputs( ); |
| 122 | 122 | void set_output_latch( UINT8 data ); |
| 123 | 123 | void set_output_data( UINT8 data ); |
| 124 | ||
| 125 | 124 | |
| 126 | 125 | |
| 127 | 126 | |
| r31374 | r31375 | |
| 129 | 128 | |
| 130 | 129 | |
| 131 | 130 | |
| 131 | ||
| 132 | 132 | // device overrides |
| 133 | 133 | virtual void machine_start(); |
| 134 | 134 | virtual void machine_reset(); |
| r31374 | r31375 | |
| 154 | 154 | required_device<screen_device> m_screen; |
| 155 | 155 | optional_device<palette_device> m_palette; |
| 156 | 156 | optional_device<ng_memcard_device> m_memcard; |
| 157 | ||
| 157 | ||
| 158 | 158 | // configuration |
| 159 | 159 | enum {NEOGEO_MVS, NEOGEO_AES, NEOGEO_CD} m_type; |
| 160 | 160 | |
| r31374 | r31375 | |
| 495 | 495 | #define ROM_Y_ZOOM \ |
| 496 | 496 | ROM_REGION( 0x20000, "zoomy", 0 ) \ |
| 497 | 497 | ROM_LOAD( "000-lo.lo", 0x00000, 0x20000, CRC(5a86cff2) SHA1(5992277debadeb64d1c1c64b0a92d9293eaf7e4a) ) |
| 498 | ||
| 499 |
| r31374 | r31375 | |
|---|---|---|
| 52 | 52 | required_device<gfxdecode_device> m_gfxdecode; |
| 53 | 53 | optional_device<decospr_device> m_sprgen; |
| 54 | 54 | optional_device<eeprom_serial_93cxx_device> m_eeprom; |
| 55 | ||
| 55 | ||
| 56 | 56 | DECLARE_WRITE16_MEMBER(esd16_sound_command_w); |
| 57 | 57 | DECLARE_WRITE16_MEMBER(hedpanic_platform_w); |
| 58 | 58 | DECLARE_READ16_MEMBER(esd_eeprom_r); |
| r31374 | r31375 | |
|---|---|---|
| 63 | 63 | void mix_boogwing(screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect); |
| 64 | 64 | DECLARE_READ16_MEMBER( boogwing_protection_region_0_104_r ); |
| 65 | 65 | DECLARE_WRITE16_MEMBER( boogwing_protection_region_0_104_w ); |
| 66 | ||
| 66 | ||
| 67 | 67 | DECO16IC_BANK_CB_MEMBER(bank_callback); |
| 68 | 68 | DECO16IC_BANK_CB_MEMBER(bank_callback2); |
| 69 | 69 | }; |
| r31374 | r31375 | |
|---|---|---|
| 20 | 20 | required_device<cpu_device> m_maincpu; |
| 21 | 21 | required_device<k053252_device> m_k053252; |
| 22 | 22 | required_device<k056832_device> m_k056832; |
| 23 | required_device<k055673_device> m_k055673; | |
| 23 | required_device<k055673_device> m_k055673; | |
| 24 | 24 | required_shared_ptr<UINT16> m_gx_workram; |
| 25 | 25 | optional_shared_ptr<UINT16> m_spriteram; |
| 26 | 26 |
| r31374 | r31375 | |
|---|---|---|
| 34 | 34 | m_an0(*this, "AN0"), |
| 35 | 35 | m_an1(*this, "AN1"), |
| 36 | 36 | m_light0_x(*this, "LIGHT0_X"), |
| 37 | m_light0_y(*this, "LIGHT0_Y"), | |
| 37 | m_light0_y(*this, "LIGHT0_Y"), | |
| 38 | 38 | m_light1_x(*this, "LIGHT1_X"), |
| 39 | m_light1_y(*this, "LIGHT1_Y"), | |
| 39 | m_light1_y(*this, "LIGHT1_Y"), | |
| 40 | 40 | m_eepromout(*this, "EEPROMOUT"), |
| 41 | 41 | m_gfxdecode(*this, "gfxdecode"), |
| 42 | 42 | m_screen(*this, "screen"), |
| r31374 | r31375 | |
| 162 | 162 | |
| 163 | 163 | void konamigx_mixer_init(screen_device &screen, int objdma); |
| 164 | 164 | void konamigx_objdma(void); |
| 165 | ||
| 165 | ||
| 166 | 166 | void fantjour_dma_install(); |
| 167 | 167 | |
| 168 | 168 | void konamigx_mixer_primode(int mode); |
| r31374 | r31375 | |
| 225 | 225 | #define GXSUB_4BPP 0x04 // 16 colors |
| 226 | 226 | #define GXSUB_5BPP 0x05 // 32 colors |
| 227 | 227 | #define GXSUB_8BPP 0x08 // 256 colors |
| 228 |
| r31374 | r31375 | |
|---|---|---|
| 23 | 23 | required_device<gfxdecode_device> m_gfxdecode; |
| 24 | 24 | required_device<screen_device> m_screen; |
| 25 | 25 | required_device<palette_device> m_palette; |
| 26 | ||
| 26 | ||
| 27 | 27 | required_shared_ptr<UINT16> m_videoram; |
| 28 | 28 | required_shared_ptr<UINT16> m_bitmapram; |
| 29 | 29 | required_shared_ptr<UINT16> m_spriteram; |
| 30 | ||
| 30 | ||
| 31 | 31 | UINT8 m_sound_data; |
| 32 | 32 | UINT8 m_sound_busy; |
| 33 | 33 | UINT8 m_ym2151_irq; |
| r31374 | r31375 | |
| 59 | 59 | TILE_GET_INFO_MEMBER(get_bg1_tile_info); |
| 60 | 60 | virtual void machine_start(); |
| 61 | 61 | virtual void machine_reset(); |
| 62 | ||
| 62 | ||
| 63 | 63 | DECLARE_VIDEO_START(rpunch); |
| 64 | 64 | DECLARE_VIDEO_START(svolley); |
| 65 | 65 |
| r31374 | r31375 | |
|---|---|---|
| 56 | 56 | required_device<screen_device> m_screen; |
| 57 | 57 | required_device<palette_device> m_palette; |
| 58 | 58 | 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; | |
| 60 | 60 | }; |
| r31374 | r31375 | |
|---|---|---|
| 211 | 211 | void screen_eof_dragngun(screen_device &screen, bool state); |
| 212 | 212 | void dragngun_draw_sprites( bitmap_rgb32 &bitmap, const rectangle &cliprect, const UINT32 *spritedata); |
| 213 | 213 | READ32_MEMBER( dragngun_unk_video_r ); |
| 214 | ||
| 214 | ||
| 215 | 215 | DECO16IC_BANK_CB_MEMBER(bank_1_callback); |
| 216 | 216 | DECO16IC_BANK_CB_MEMBER(bank_2_callback); |
| 217 | 217 |
| r31374 | r31375 | |
|---|---|---|
| 28 | 28 | m_sprgen(*this, "spritegen") |
| 29 | 29 | { } |
| 30 | 30 | |
| 31 | ||
| 32 | 31 | |
| 32 | ||
| 33 | 33 | required_shared_ptr<UINT8> m_fgvideoram; |
| 34 | 34 | required_shared_ptr<UINT8> m_bgvideoram; |
| 35 | 35 | required_shared_ptr<UINT8> m_txvideoram; |
| r31374 | r31375 | |
|---|---|---|
| 78 | 78 | required_device<palette_device> m_palette; |
| 79 | 79 | optional_device<dcs_audio_device> m_dcs; |
| 80 | 80 | required_shared_ptr<UINT16> m_generic_paletteram_16; |
| 81 | ||
| 81 | ||
| 82 | 82 | void register_state_saving(); |
| 83 | 83 | void init_tunit_generic(int sound); |
| 84 | 84 | void init_nbajam_common(int te_protection); |
| r31374 | r31375 | |
|---|---|---|
| 54 | 54 | DECLARE_WRITE8_MEMBER(cpu_portb_w); |
| 55 | 55 | DECLARE_WRITE8_MEMBER(cpu_portc_w); |
| 56 | 56 | DECLARE_WRITE8_MEMBER(cpu_porte_w); |
| 57 | ||
| 57 | ||
| 58 | 58 | DECLARE_READ16_MEMBER(niyanpai_dipsw_r); |
| 59 | 59 | DECLARE_READ16_MEMBER(musobana_inputport_0_r); |
| 60 | 60 | DECLARE_WRITE16_MEMBER(musobana_inputport_w); |
| r31374 | r31375 | |
|---|---|---|
| 21 | 21 | required_device<gfxdecode_device> m_gfxdecode; |
| 22 | 22 | required_device<palette_device> m_palette; |
| 23 | 23 | required_device<buffered_spriteram16_device> m_spriteram; |
| 24 | ||
| 24 | ||
| 25 | 25 | /* memory pointers */ |
| 26 | 26 | UINT8 *m_text_videoram; |
| 27 | 27 | required_shared_ptr<UINT16> m_spr_pal_clut; |
| r31374 | r31375 | |
|---|---|---|
| 122 | 122 | DECLARE_VIDEO_START( megadriv ); |
| 123 | 123 | UINT32 screen_update_megadriv(screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect); |
| 124 | 124 | void screen_eof_megadriv(screen_device &screen, bool state); |
| 125 | ||
| 125 | ||
| 126 | 126 | DECLARE_WRITE8_MEMBER(megadriv_tas_callback); |
| 127 | 127 | }; |
| 128 | 128 |
| r31374 | r31375 | |
|---|---|---|
| 106 | 106 | public: |
| 107 | 107 | wpc_dcs_state(const machine_config &mconfig, device_type type, const char *tag) |
| 108 | 108 | : wpc_flip2_state(mconfig, type, tag), |
| 109 | | |
| 109 | m_dcs(*this, "dcs") | |
| 110 | 110 | { } |
| 111 | 111 | public: |
| 112 | 112 | |
| r31374 | r31375 | |
| 115 | 115 | DECLARE_WRITE8_MEMBER(wpc_dcs_sound_ctrl_w); |
| 116 | 116 | DECLARE_READ8_MEMBER(wpc_dcs_sound_data_r); |
| 117 | 117 | DECLARE_WRITE8_MEMBER(wpc_dcs_sound_data_w); |
| 118 | ||
| 118 | ||
| 119 | 119 | required_device<dcs_audio_wpc_device> m_dcs; |
| 120 | 120 | private: |
| 121 | 121 | bool m_send; |
| r31374 | r31375 | |
|---|---|---|
| 37 | 37 | TIMER_DEVICE_CALLBACK_MEMBER( a5200_interrupt ); |
| 38 | 38 | |
| 39 | 39 | DECLARE_PALETTE_INIT(atari); |
| 40 | ||
| 40 | ||
| 41 | 41 | DECLARE_READ8_MEMBER( atari_gtia_r ); |
| 42 | 42 | DECLARE_WRITE8_MEMBER( atari_gtia_w ); |
| 43 | ||
| 43 | ||
| 44 | 44 | DECLARE_READ8_MEMBER ( atari_antic_r ); |
| 45 | 45 | DECLARE_WRITE8_MEMBER ( atari_antic_w ); |
| 46 | 46 |
| r31374 | r31375 | |
|---|---|---|
| 68 | 68 | DECLARE_READ16_MEMBER(kaneko16_ay2_YM2149_r); |
| 69 | 69 | DECLARE_WRITE16_MEMBER(kaneko16_ay2_YM2149_w); |
| 70 | 70 | DECLARE_WRITE16_MEMBER(bakubrkr_oki_bank_sw); |
| 71 | ||
| 71 | ||
| 72 | 72 | DECLARE_READ8_MEMBER(eeprom_r); |
| 73 | 73 | DECLARE_WRITE8_MEMBER(eeprom_w); |
| 74 | 74 |
| r31374 | r31375 | |
|---|---|---|
| 44 | 44 | required_device<cpu_device> m_audiocpu; |
| 45 | 45 | required_device<palette_device> m_palette; |
| 46 | 46 | 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; | |
| 48 | 48 | }; |
| r31374 | r31375 | |
|---|---|---|
| 65 | 65 | optional_device<tc0110pcr_device> m_tc0110pcr; |
| 66 | 66 | optional_device<tc0220ioc_device> m_tc0220ioc; |
| 67 | 67 | optional_device<tc0510nio_device> m_tc0510nio; |
| 68 | optional_device<tc0140syt_device> m_tc0140syt; | |
| 68 | optional_device<tc0140syt_device> m_tc0140syt; // bshark & spacegun miss the CPUs which shall use TC0140 | |
| 69 | 69 | required_device<gfxdecode_device> m_gfxdecode; |
| 70 | 70 | required_device<palette_device> m_palette; |
| 71 | 71 |
| r31374 | r31375 | |
|---|---|---|
| 69 | 69 | m_serial(*this, "serial"), |
| 70 | 70 | m_screen(*this, "screen"), |
| 71 | 71 | m_paletteram16(*this, "paletteram"), |
| 72 | m_paletteram32(*this, "paletteram") | |
| 72 | m_paletteram32(*this, "paletteram") { } | |
| 73 | 73 | |
| 74 | 74 | required_shared_ptr<UINT32> m_adsp_ram_base; |
| 75 | 75 | required_shared_ptr<UINT16> m_m68k_ram_base; |
| r31374 | r31375 | |
|---|---|---|
| 56 | 56 | DECLARE_READ16_MEMBER(vbl_toggle_r); |
| 57 | 57 | DECLARE_WRITE16_MEMBER(vbl_toggle_w); |
| 58 | 58 | |
| 59 | ||
| 59 | ||
| 60 | 60 | DECLARE_DRIVER_INIT(twrldc94a); |
| 61 | 61 | DECLARE_DRIVER_INIT(vgoalsoc); |
| 62 | 62 | DECLARE_DRIVER_INIT(twrldc94); |
| r31374 | r31375 | |
|---|---|---|
| 2437 | 2437 | $(DRIVERS)/wms.o \ |
| 2438 | 2438 | $(DRIVERS)/xtom3d.o \ |
| 2439 | 2439 | $(DRIVERS)/xyonix.o $(VIDEO)/xyonix.o \ |
| 2440 | ||
| 2441 | 2440 | |
| 2441 | ||
| 2442 | 2442 | #------------------------------------------------- |
| 2443 | 2443 | # layout dependencies |
| 2444 | 2444 | #------------------------------------------------- |
| r31374 | r31375 | |
| 2521 | 2521 | $(LAYOUT)/sc4_dmd.lh \ |
| 2522 | 2522 | $(LAYOUT)/sc4dnd.lh \ |
| 2523 | 2523 | $(LAYOUT)/sc4dndtp.lh \ |
| 2524 | $(LAYOUT)/sc4dnddw.lh | |
| 2524 | $(LAYOUT)/sc4dnddw.lh | |
| 2525 | 2525 | |
| 2526 | 2526 | $(DRIVERS)/bfm_sc5.o: $(LAYOUT)/bfm_sc5.lh |
| 2527 | 2527 |
| r31374 | r31375 | |
|---|---|---|
| 53 | 53 | dev.m_djmain_hack = djmain_hack; |
| 54 | 54 | dev.m_k055555_tag = k055555; |
| 55 | 55 | } |
| 56 | ||
| 56 | ||
| 57 | 57 | // static configuration |
| 58 | 58 | static void static_set_gfxdecode_tag(device_t &device, const char *tag); |
| 59 | 59 | static void static_set_palette_tag(device_t &device, const char *tag); |
| r31374 | r31375 | |
| 141 | 141 | int m_bpp; |
| 142 | 142 | int m_big; |
| 143 | 143 | int m_djmain_hack; |
| 144 | ||
| 144 | ||
| 145 | 145 | const char *m_k055555_tag; // tbyahhoo uses the k056832 together with a k055555 |
| 146 | ||
| 147 | 146 | |
| 147 | ||
| 148 | 148 | // ROM readback involves reading 2 halves of a word |
| 149 | 149 | // from the same location in a row. Reading the |
| 150 | 150 | // RAM window resets this state so you get the first half. |
| r31374 | r31375 | |
|---|---|---|
| 78 | 78 | dev.m_dx = dx; |
| 79 | 79 | dev.m_dy = dy; |
| 80 | 80 | } |
| 81 | ||
| 81 | ||
| 82 | 82 | void clear_all(); |
| 83 | 83 | |
| 84 | 84 | DECLARE_READ16_MEMBER( k055673_rom_word_r ); |
| r31374 | r31375 | |
|---|---|---|
| 8 | 8 | mb60553_zooming_tilemap_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock); |
| 9 | 9 | static void static_set_gfxdecode_tag(device_t &device, const char *tag); |
| 10 | 10 | static void set_gfx_region(device_t &device, int gfxregion); |
| 11 | ||
| 11 | ||
| 12 | 12 | tilemap_t* m_tmap; |
| 13 | 13 | UINT16* m_vram; |
| 14 | 14 | UINT16 m_regs[8]; |
| r31374 | r31375 | |
|---|---|---|
| 36 | 36 | DECLARE_GFXDECODE_MEMBER(gfxinfo7); |
| 37 | 37 | DECLARE_GFXDECODE_MEMBER(gfxinfo8); |
| 38 | 38 | DECLARE_GFXDECODE_MEMBER(gfxinfo4_ram); |
| 39 | ||
| 39 | ||
| 40 | 40 | // static configuration |
| 41 | 41 | static void set_k051316_callback(device_t &device, k051316_cb_delegate callback) { downcast<k051316_device &>(device).m_k051316_cb = callback; } |
| 42 | 42 | static void set_wrap(device_t &device, int wrap) { downcast<k051316_device &>(device).m_wrap = wrap; } |
| r31374 | r31375 | |
|---|---|---|
| 95 | 95 | |
| 96 | 96 | UINT8 *m_char_rom; |
| 97 | 97 | UINT32 m_char_size; |
| 98 | ||
| 98 | ||
| 99 | 99 | k052109_cb_delegate m_k052109_cb; |
| 100 | 100 | |
| 101 | 101 | TILE_GET_INFO_MEMBER(get_tile_info0); |
| r31374 | r31375 | |
|---|---|---|
| 15 | 15 | |
| 16 | 16 | protected: |
| 17 | 17 | UINT8* m_ram; |
| 18 | ||
| 18 | ||
| 19 | 19 | virtual void device_start(); |
| 20 | 20 | virtual void device_reset(); |
| 21 | 21 | private: |
| 22 | 22 | }; |
| 23 | 23 | |
| 24 | 24 | extern const device_type EXCELLENT_SPRITE; |
| 25 | ||
| 26 |
| r31374 | r31375 | |
|---|---|---|
| 30 | 30 | dev.m_xoffset = x_offset; |
| 31 | 31 | dev.m_yoffset = y_offset; |
| 32 | 32 | } |
| 33 | ||
| 33 | ||
| 34 | 34 | DECLARE_WRITE8_MEMBER ( spriteram_w ); |
| 35 | 35 | DECLARE_READ8_MEMBER( spriteram_r ); |
| 36 | 36 | DECLARE_WRITE16_MEMBER( spriteram_LSB_w ); |
| r31374 | r31375 | |
|---|---|---|
| 7 | 7 | { |
| 8 | 8 | public: |
| 9 | 9 | tecmo_mix_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock); |
| 10 | ||
| 10 | ||
| 11 | 11 | 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); |
| 12 | 12 | static void set_mixer_shifts(device_t &device, int sprpri_shift, int sprbln_shift, int sprcol_shift); |
| 13 | 13 | static void set_blendcols(device_t &device, int bgblend_comp, int fgblend_comp, int txblend_comp, int spblend_comp); |
| r31374 | r31375 | |
| 70 | 70 | |
| 71 | 71 | #define MCFG_TECMO_MIXER_BGPEN(_bgpen) \ |
| 72 | 72 | tecmo_mix_device::set_bgpen(*device, _bgpen); |
| 73 | ||
| 74 |
| r31374 | r31375 | |
|---|---|---|
| 19 | 19 | dev.m_x_offset = x_offset; |
| 20 | 20 | dev.m_y_offset = y_offset; |
| 21 | 21 | } |
| 22 | ||
| 22 | ||
| 23 | 23 | DECLARE_READ16_MEMBER( word_r ); |
| 24 | 24 | DECLARE_WRITE16_MEMBER( word_w ); |
| 25 | 25 | DECLARE_WRITE16_MEMBER( xscroll_word_w ); |
| r31374 | r31375 | |
| 65 | 65 | int m_x_offset, m_y_offset; |
| 66 | 66 | int m_y_invert; |
| 67 | 67 | int m_dblwidth; |
| 68 | ||
| 68 | ||
| 69 | 69 | required_device<gfxdecode_device> m_gfxdecode; |
| 70 | 70 | required_device<palette_device> m_palette; |
| 71 | 71 | }; |
| r31374 | r31375 | |
|---|---|---|
| 31 | 31 | dev.m_flip_xoffs = x_offset; |
| 32 | 32 | dev.m_flip_yoffs = y_offset; |
| 33 | 33 | } |
| 34 | ||
| 34 | ||
| 35 | 35 | /* When writing a driver, pass zero for the text and flip offsets initially: |
| 36 | 36 | then tweak them once you have the 4 bg layer positions correct. Col_base |
| 37 | 37 | may be needed when tilemaps use a palette area from sprites. */ |
| r31374 | r31375 | |
| 89 | 89 | int m_x_offset, m_y_offset; |
| 90 | 90 | int m_text_xoffs, m_text_yoffs; |
| 91 | 91 | int m_flip_xoffs, m_flip_yoffs; |
| 92 | ||
| 92 | ||
| 93 | 93 | int m_col_base; |
| 94 | ||
| 94 | ||
| 95 | 95 | required_device<gfxdecode_device> m_gfxdecode; |
| 96 | 96 | required_device<palette_device> m_palette; |
| 97 | 97 |
| r31374 | r31375 | |
|---|---|---|
| 11 | 11 | |
| 12 | 12 | // gaiden.c / spbactn.c / tecmo16.c sprites |
| 13 | 13 | 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 | ||
| 15 | 15 | // tecmo.c sprites |
| 16 | 16 | 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); |
| 17 | 17 | |
| r31374 | r31375 | |
| 40 | 40 | |
| 41 | 41 | #define MCFG_TECMO_SPRITE_BOOTLEG(_bootleg) \ |
| 42 | 42 | tecmo_spr_device::set_bootleg(*device, _bootleg); |
| 43 | ||
| 44 | ||
| 45 |
| r31374 | r31375 | |
|---|---|---|
| 18 | 18 | static void set_roz_size(device_t &device, int size) { downcast<k001604_device &>(device).m_roz_size = size; } |
| 19 | 19 | static void set_txt_mem_offset(device_t &device, int offs) { downcast<k001604_device &>(device).m_txt_mem_offset = offs; } |
| 20 | 20 | static void set_roz_mem_offset(device_t &device, int offs) { downcast<k001604_device &>(device).m_roz_mem_offset = offs; } |
| 21 | ||
| 21 | ||
| 22 | 22 | void draw_back_layer( bitmap_rgb32 &bitmap, const rectangle &cliprect ); |
| 23 | 23 | void draw_front_layer( screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect ); |
| 24 | 24 | DECLARE_WRITE32_MEMBER( tile_w ); |
| r31374 | r31375 | |
|---|---|---|
| 28 | 28 | dev.m_xoff = x_offset; |
| 29 | 29 | dev.m_yoff = y_offset; |
| 30 | 30 | } |
| 31 | ||
| 31 | ||
| 32 | 32 | DECLARE_WRITE16_MEMBER( ctrl_w ); |
| 33 | 33 | DECLARE_READ16_MEMBER( ctrl_r ); |
| 34 | 34 | DECLARE_WRITE16_MEMBER( linectrl_w ); |
| r31374 | r31375 | |
|---|---|---|
| 36 | 36 | |
| 37 | 37 | #define MCFG_DECO_ZOOMSPR_GFXDECODE(_gfxtag) \ |
| 38 | 38 | deco_zoomspr_device::static_set_gfxdecode_tag(*device, "^" _gfxtag); |
| 39 |
| r31374 | r31375 | |
|---|---|---|
| 19 | 19 | dev.m_bg_yoffs = y_offset; |
| 20 | 20 | } |
| 21 | 21 | static void set_bgflip_yoffs(device_t &device, int offs) { downcast<tc0080vco_device &>(device).m_bg_flip_yoffs = offs; } |
| 22 | ||
| 22 | ||
| 23 | 23 | DECLARE_READ16_MEMBER( word_r ); |
| 24 | 24 | DECLARE_WRITE16_MEMBER( word_w ); |
| 25 | 25 | |
| r31374 | r31375 | |
| 65 | 65 | tilemap_t *m_tilemap[3]; |
| 66 | 66 | |
| 67 | 67 | INT32 m_flipscreen; |
| 68 | ||
| 68 | ||
| 69 | 69 | int m_gfxnum; |
| 70 | 70 | int m_txnum; |
| 71 | 71 | int m_bg_xoffs, m_bg_yoffs; |
| r31374 | r31375 | |
|---|---|---|
| 134 | 134 | int m_fifo_read_ptr; |
| 135 | 135 | int m_fifo_write_ptr; |
| 136 | 136 | UINT32 m_reg_far_z; |
| 137 | ||
| 138 | 137 | |
| 138 | ||
| 139 | 139 | k001005_renderer *m_renderer; |
| 140 | 140 | }; |
| 141 | 141 |
| r31374 | r31375 | |
|---|---|---|
| 40 | 40 | |
| 41 | 41 | #define MCFG_VS920A_GFXDECODE(_gfxtag) \ |
| 42 | 42 | vs920a_text_tilemap_device::static_set_gfxdecode_tag(*device, "^" _gfxtag); |
| 43 | ||
| 44 | ||
| 45 |
| r31374 | r31375 | |
|---|---|---|
| 18 | 18 | dev.m_x_offset = x_offset; |
| 19 | 19 | dev.m_y_offset = y_offset; |
| 20 | 20 | } |
| 21 | ||
| 21 | ||
| 22 | 22 | DECLARE_READ16_MEMBER( word_r ); |
| 23 | 23 | DECLARE_WRITE16_MEMBER( word_w ); |
| 24 | 24 |
| r31374 | r31375 | |
|---|---|---|
| 17 | 17 | k05324x_device::set_offsets(*device, _xoffs, _yoffs); |
| 18 | 18 | |
| 19 | 19 | |
| 20 | class k05324x_device : public device_t, | |
| 20 | class k05324x_device : public device_t, | |
| 21 | 21 | public device_gfx_interface |
| 22 | 22 | { |
| 23 | 23 | static const gfx_layout spritelayout; |
| r31374 | r31375 | |
|---|---|---|
| 20 | 20 | { |
| 21 | 21 | public: |
| 22 | 22 | neosprite_base_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock, device_type type); |
| 23 | // | |
| 23 | // neosprite_base_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock); | |
| 24 | 24 | |
| 25 | 25 | virtual void optimize_sprite_data(); |
| 26 | 26 | virtual void set_optimized_sprite_data(UINT8* sprdata, UINT32 mask); |
| r31374 | r31375 | |
| 70 | 70 | |
| 71 | 71 | emu_timer *m_auto_animation_timer; |
| 72 | 72 | emu_timer *m_sprite_line_timer; |
| 73 | ||
| 73 | ||
| 74 | 74 | TIMER_CALLBACK_MEMBER(auto_animation_timer_callback); |
| 75 | 75 | TIMER_CALLBACK_MEMBER(sprite_line_timer_callback); |
| 76 | ||
| 77 | 76 | |
| 77 | ||
| 78 | 78 | int m_bppshift; // 4 for 4bpp gfx (NeoGeo) 8 for 8bpp gfx (Midas) |
| 79 | 79 | |
| 80 | 80 | protected: |
| r31374 | r31375 | |
| 128 | 128 | { |
| 129 | 129 | public: |
| 130 | 130 | neosprite_midas_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock); |
| 131 | ||
| 131 | ||
| 132 | 132 | virtual void draw_pixel(int romaddr, UINT32* dst, const pen_t *line_pens); |
| 133 | 133 | |
| 134 | 134 | UINT16* m_videoram_buffer; |
| r31374 | r31375 | |
| 142 | 142 | }; |
| 143 | 143 | |
| 144 | 144 | extern const device_type NEOGEO_SPRITE_MIDAS; |
| 145 | ||
| 146 |
| r31374 | r31375 | |
|---|---|---|
| 32 | 32 | dev.m_flip_text_xoffs = x_offset; |
| 33 | 33 | dev.m_flip_text_yoffs = y_offset; |
| 34 | 34 | } |
| 35 | ||
| 35 | ||
| 36 | 36 | #define TC0100SCN_SINGLE_VDU 1024 |
| 37 | 37 | |
| 38 | 38 | /* Function to set separate color banks for the three tilemapped layers. |
| r31374 | r31375 | |
| 104 | 104 | int m_flip_text_xoffs, m_flip_text_yoffs; |
| 105 | 105 | int m_multiscrn_xoffs; |
| 106 | 106 | int m_multiscrn_hack; |
| 107 | ||
| 107 | ||
| 108 | 108 | required_device<gfxdecode_device> m_gfxdecode; |
| 109 | 109 | required_device<palette_device> m_palette; |
| 110 | 110 |
| r31374 | r31375 | |
|---|---|---|
| 41 | 41 | static void set_pf2_col_bank(device_t &device, int bank) { downcast<deco16ic_device &>(device).m_pf2_colour_bank = bank; } |
| 42 | 42 | static void set_pf12_8x8_bank(device_t &device, int bank) { downcast<deco16ic_device &>(device).m_pf12_8x8_gfx_bank = bank; } |
| 43 | 43 | static void set_pf12_16x16_bank(device_t &device, int bank) { downcast<deco16ic_device &>(device).m_pf12_16x16_gfx_bank = bank; } |
| 44 | ||
| 45 | 44 | |
| 45 | ||
| 46 | 46 | DECLARE_WRITE16_MEMBER( pf1_data_w ); |
| 47 | 47 | DECLARE_WRITE16_MEMBER( pf2_data_w ); |
| 48 | 48 | |
| r31374 | r31375 | |
| 144 | 144 | int m_pf1_colour_bank, m_pf2_colour_bank; |
| 145 | 145 | int m_pf1_colourmask, m_pf2_colourmask; |
| 146 | 146 | int m_pf12_8x8_gfx_bank, m_pf12_16x16_gfx_bank; |
| 147 | ||
| 147 | ||
| 148 | 148 | TILEMAP_MAPPER_MEMBER(deco16_scan_rows); |
| 149 | 149 | TILE_GET_INFO_MEMBER(get_pf2_tile_info); |
| 150 | 150 | TILE_GET_INFO_MEMBER(get_pf1_tile_info); |
| r31374 | r31375 | |
|---|---|---|
| 2 | 2 | #ifndef __K051960_H__ |
| 3 | 3 | #define __K051960_H__ |
| 4 | 4 | |
| 5 | enum | |
| 5 | enum | |
| 6 | 6 | { |
| 7 | 7 | K051960_PLANEORDER_BASE = 0, |
| 8 | 8 | K051960_PLANEORDER_MIA, |
| r31374 | r31375 | |
| 29 | 29 | DECLARE_GFXDECODE_MEMBER(gfxinfo); |
| 30 | 30 | DECLARE_GFXDECODE_MEMBER(gfxinfo_reverse); |
| 31 | 31 | DECLARE_GFXDECODE_MEMBER(gfxinfo_gradius3); |
| 32 | ||
| 32 | ||
| 33 | 33 | public: |
| 34 | 34 | k051960_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock); |
| 35 | 35 | ~k051960_device() {} |
| r31374 | r31375 | |
| 73 | 73 | private: |
| 74 | 74 | // internal state |
| 75 | 75 | UINT8 *m_ram; |
| 76 | ||
| 76 | ||
| 77 | 77 | UINT8 *m_sprite_rom; |
| 78 | 78 | UINT32 m_sprite_size; |
| 79 | ||
| 79 | ||
| 80 | 80 | k051960_cb_delegate m_k051960_cb; |
| 81 | ||
| 81 | ||
| 82 | 82 | UINT8 m_spriterombank[3]; |
| 83 | 83 | int m_romoffset; |
| 84 | 84 | int m_spriteflip, m_readroms; |
| r31374 | r31375 | |
|---|---|---|
| 199 | 199 | virtual void video_register(); |
| 200 | 200 | virtual void sound_register(); |
| 201 | 201 | virtual void debugger_register(); |
| 202 | ||
| 202 | ||
| 203 | 203 | virtual bool video_init(); |
| 204 | 204 | virtual bool input_init(); |
| 205 | 205 | virtual void input_pause(); |
| r31374 | r31375 | |
|---|---|---|
| 97 | 97 | int resize_height; |
| 98 | 98 | osd_ticks_t last_resize; |
| 99 | 99 | #else |
| 100 | int screen_width; | |
| 101 | int screen_height; | |
| 100 | int screen_width; | |
| 101 | int screen_height; | |
| 102 | 102 | #endif |
| 103 | 103 | }; |
| 104 | 104 |
| r31374 | r31375 | |
|---|---|---|
| 62 | 62 | #define ATTR_MALLOC |
| 63 | 63 | #define ATTR_PURE |
| 64 | 64 | #define ATTR_CONST |
| 65 | #define ATTR_FORCE_INLINE | |
| 65 | #define ATTR_FORCE_INLINE __forceinline | |
| 66 | 66 | #define ATTR_NONNULL(...) |
| 67 | 67 | #define ATTR_DEPRECATED __declspec(deprecated) |
| 68 | 68 | #define ATTR_HOT |
| r31374 | r31375 | |
|---|---|---|
| 25 | 25 | #define OSDOPTION_LOG "log" |
| 26 | 26 | #define OSDOPTION_VERBOSE "verbose" |
| 27 | 27 | #define OSDOPTION_DEBUG "debug" |
| 28 | #define OSDOPTION_DEBUGGER | |
| 28 | #define OSDOPTION_DEBUGGER "debugger" | |
| 29 | 29 | #define OSDOPTION_OSLOG "oslog" |
| 30 | 30 | #define OSDOPTION_WATCHDOG "watchdog" |
| 31 | 31 | |
| r31374 | r31375 | |
| 49 | 49 | |
| 50 | 50 | #define OSDOPTION_SWITCHRES "switchres" |
| 51 | 51 | |
| 52 | #define OSDOPTION_SOUND | |
| 52 | #define OSDOPTION_SOUND "sound" | |
| 53 | 53 | #define OSDOPTION_AUDIO_LATENCY "audio_latency" |
| 54 | 54 | |
| 55 | 55 | #define OSDOPTVAL_AUTO "auto" |
| r31374 | r31375 | |
| 67 | 67 | // debugging options |
| 68 | 68 | bool verbose() const { return bool_value(OSDOPTION_VERBOSE); } |
| 69 | 69 | 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); } | |
| 72 | 72 | bool oslog() const { return bool_value(OSDOPTION_OSLOG); } |
| 73 | 73 | int watchdog() const { return int_value(OSDOPTION_WATCHDOG); } |
| 74 | 74 | |
| r31374 | r31375 | |
| 137 | 137 | virtual ~osd_interface(); |
| 138 | 138 | |
| 139 | 139 | void register_options(osd_options &options); |
| 140 | ||
| 140 | ||
| 141 | 141 | // getters |
| 142 | 142 | running_machine &machine() const { assert(m_machine != NULL); return *m_machine; } |
| 143 | 143 | |
| r31374 | r31375 | |
| 167 | 167 | // video overridables |
| 168 | 168 | virtual void *get_slider_list(); |
| 169 | 169 | |
| 170 | void init_subsystems(); | |
| 171 | ||
| 170 | void init_subsystems(); | |
| 171 | ||
| 172 | 172 | virtual bool video_init(); |
| 173 | 173 | virtual void video_register(); |
| 174 | ||
| 174 | ||
| 175 | 175 | bool sound_init(); |
| 176 | 176 | virtual void sound_register(); |
| 177 | 177 | bool no_sound(); |
| 178 | ||
| 178 | ||
| 179 | 179 | virtual bool input_init(); |
| 180 | 180 | virtual void input_pause(); |
| 181 | 181 | virtual void input_resume(); |
| r31374 | r31375 | |
| 183 | 183 | virtual bool network_init(); |
| 184 | 184 | virtual bool midi_init(); |
| 185 | 185 | |
| 186 | void exit_subsystems(); | |
| 186 | void exit_subsystems(); | |
| 187 | 187 | virtual void video_exit(); |
| 188 | 188 | void sound_exit(); |
| 189 | 189 | virtual void input_exit(); |
| r31374 | r31375 | |
| 192 | 192 | virtual void midi_exit(); |
| 193 | 193 | |
| 194 | 194 | virtual void osd_exit(); |
| 195 | ||
| 195 | ||
| 196 | 196 | void video_options_add(const char *name, void *type); |
| 197 | 197 | void sound_options_add(const char *name, osd_sound_type type); |
| 198 | 198 | void debugger_options_add(const char *name, osd_debugger_type type); |
| 199 | 199 | |
| 200 | 200 | private: |
| 201 | 201 | // internal state |
| 202 | running_machine * m_machine; | |
| 203 | ||
| 202 | running_machine * m_machine; | |
| 203 | ||
| 204 | 204 | void update_option(osd_options &options, const char * key, dynamic_array<const char *> &values); |
| 205 | ||
| 206 | protected: | |
| 205 | ||
| 206 | protected: | |
| 207 | 207 | osd_sound_interface* m_sound; |
| 208 | 208 | osd_debugger_interface* m_debugger; |
| 209 | private: | |
| 210 | //tagmap_t<osd_video_type> m_video_options; | |
| 209 | private: | |
| 210 | //tagmap_t<osd_video_type> m_video_options; | |
| 211 | 211 | 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; | |
| 213 | 213 | 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; | |
| 215 | 215 | dynamic_array<const char *> m_debugger_names; |
| 216 | 216 | }; |
| 217 | 217 | |
| r31374 | r31375 | |
| 221 | 221 | // construction/destruction |
| 222 | 222 | osd_sound_interface(const osd_interface &osd); |
| 223 | 223 | virtual ~osd_sound_interface(); |
| 224 | ||
| 224 | ||
| 225 | 225 | virtual void update_audio_stream(const INT16 *buffer, int samples_this_frame) = 0; |
| 226 | 226 | virtual void set_mastervolume(int attenuation) = 0; |
| 227 | protected: | |
| 227 | protected: | |
| 228 | 228 | const osd_interface& m_osd; |
| 229 | 229 | }; |
| 230 | 230 | |
| r31374 | r31375 | |
| 241 | 241 | // construction/destruction |
| 242 | 242 | osd_debugger_interface(const osd_interface &osd); |
| 243 | 243 | virtual ~osd_debugger_interface(); |
| 244 | ||
| 244 | ||
| 245 | 245 | virtual void init_debugger() = 0; |
| 246 | 246 | virtual void wait_for_debugger(device_t &device, bool firststop) = 0; |
| 247 | 247 | virtual void debugger_update() = 0; |
| 248 | 248 | virtual void debugger_exit() = 0; |
| 249 | 249 | |
| 250 | protected: | |
| 250 | protected: | |
| 251 | 251 | const osd_interface& m_osd; |
| 252 | 252 | }; |
| 253 | 253 |
| r31374 | r31375 | |
|---|---|---|
| 28 | 28 | // construction/destruction |
| 29 | 29 | sound_direct_sound(const osd_interface &osd); |
| 30 | 30 | virtual ~sound_direct_sound(); |
| 31 | ||
| 31 | ||
| 32 | 32 | virtual void update_audio_stream(const INT16 *buffer, int samples_this_frame); |
| 33 | 33 | virtual void set_mastervolume(int attenuation); |
| 34 | 34 | |
| r31374 | r31375 | |
| 36 | 36 | void dsound_kill(); |
| 37 | 37 | HRESULT dsound_create_buffers(); |
| 38 | 38 | void dsound_destroy_buffers(); |
| 39 | void copy_sample_data(const INT16 *data, int bytes_to_copy); | |
| 40 | private: | |
| 39 | void copy_sample_data(const INT16 *data, int bytes_to_copy); | |
| 40 | private: | |
| 41 | 41 | }; |
| 42 | 42 | |
| 43 | 43 | extern const osd_sound_type OSD_SOUND_DIRECT_SOUND; |
| r31374 | r31375 | |
|---|---|---|
| 21 | 21 | // construction/destruction |
| 22 | 22 | sound_js(const osd_interface &osd); |
| 23 | 23 | virtual ~sound_js() { } |
| 24 | ||
| 24 | ||
| 25 | 25 | virtual void update_audio_stream(const INT16 *buffer, int samples_this_frame); |
| 26 | 26 | virtual void set_mastervolume(int attenuation); |
| 27 | 27 | }; |
| r31374 | r31375 | |
|---|---|---|
| 21 | 21 | // construction/destruction |
| 22 | 22 | sound_sdl(const osd_interface &osd); |
| 23 | 23 | virtual ~sound_sdl(); |
| 24 | ||
| 24 | ||
| 25 | 25 | virtual void update_audio_stream(const INT16 *buffer, int samples_this_frame); |
| 26 | 26 | virtual void set_mastervolume(int attenuation); |
| 27 | 27 | }; |
| r31374 | r31375 | |
|---|---|---|
| 21 | 21 | // construction/destruction |
| 22 | 22 | sound_none(const osd_interface &osd); |
| 23 | 23 | virtual ~sound_none() { } |
| 24 | ||
| 24 | ||
| 25 | 25 | virtual void update_audio_stream(const INT16 *buffer, int samples_this_frame) { } |
| 26 | 26 | virtual void set_mastervolume(int attenuation) { } |
| 27 | 27 | }; |
| r31374 | r31375 | |
|---|---|---|
| 22 | 22 | // construction/destruction |
| 23 | 23 | debugger_qt(const osd_interface &osd); |
| 24 | 24 | virtual ~debugger_qt(); |
| 25 | ||
| 25 | ||
| 26 | 26 | virtual void init_debugger(); |
| 27 | 27 | virtual void wait_for_debugger(device_t &device, bool firststop); |
| 28 | 28 | virtual void debugger_update(); |
| r31374 | r31375 | |
|---|---|---|
| 21 | 21 | // construction/destruction |
| 22 | 22 | debugger_none(const osd_interface &osd); |
| 23 | 23 | virtual ~debugger_none() { } |
| 24 | ||
| 24 | ||
| 25 | 25 | virtual void init_debugger(); |
| 26 | 26 | virtual void wait_for_debugger(device_t &device, bool firststop); |
| 27 | 27 | virtual void debugger_update(); |
| r31374 | r31375 | |
|---|---|---|
| 372 | 372 | // construction/destruction |
| 373 | 373 | debugger_osx(const osd_interface &osd); |
| 374 | 374 | virtual ~debugger_osx() { } |
| 375 | ||
| 375 | ||
| 376 | 376 | virtual void init_debugger(); |
| 377 | 377 | virtual void wait_for_debugger(device_t &device, bool firststop); |
| 378 | 378 | virtual void debugger_update(); |
| r31374 | r31375 | |
|---|---|---|
| 22 | 22 | // construction/destruction |
| 23 | 23 | debugger_internal(const osd_interface &osd); |
| 24 | 24 | virtual ~debugger_internal() { } |
| 25 | ||
| 25 | ||
| 26 | 26 | virtual void init_debugger(); |
| 27 | 27 | virtual void wait_for_debugger(device_t &device, bool firststop); |
| 28 | 28 | virtual void debugger_update(); |
| r31374 | r31375 | |
|---|---|---|
| 20 | 20 | // construction/destruction |
| 21 | 21 | debugger_windows(const osd_interface &osd); |
| 22 | 22 | virtual ~debugger_windows() { } |
| 23 | ||
| 23 | ||
| 24 | 24 | virtual void init_debugger(); |
| 25 | 25 | virtual void wait_for_debugger(device_t &device, bool firststop); |
| 26 | 26 | virtual void debugger_update(); |
| r31374 | r31375 | |
|---|---|---|
| 259 | 259 | virtual void video_register(); |
| 260 | 260 | virtual void sound_register(); |
| 261 | 261 | virtual void debugger_register(); |
| 262 | ||
| 263 | virtual bool video_init(); | |
| 262 | ||
| 263 | virtual bool video_init(); | |
| 264 | 264 | virtual bool input_init(); |
| 265 | 265 | virtual void input_pause(); |
| 266 | 266 | virtual void input_resume(); |
| r31374 | r31375 | |
|---|---|---|
| 44 | 44 | tms36xx_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock); |
| 45 | 45 | ~tms36xx_device() { } |
| 46 | 46 | |
| 47 | static void set_subtype(device_t &device, int type) | |
| 48 | { | |
| 47 | static void set_subtype(device_t &device, int type) | |
| 48 | { | |
| 49 | 49 | tms36xx_device &dev = downcast<tms36xx_device &>(device); |
| 50 | 50 | switch (type) |
| 51 | 51 | { |
| r31374 | r31375 | |
| 63 | 63 | break; |
| 64 | 64 | } |
| 65 | 65 | } |
| 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; | |
| 69 | 69 | } |
| 70 | 70 | 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) |
| 71 | 71 | { |
| r31374 | r31375 | |
| 77 | 77 | dev.m_decay_time[4] = decay_4; |
| 78 | 78 | dev.m_decay_time[5] = decay_5; |
| 79 | 79 | } |
| 80 | ||
| 80 | ||
| 81 | 81 | protected: |
| 82 | 82 | // device-level overrides |
| 83 | 83 | virtual void device_start(); |
| r31374 | r31375 | |
|---|---|---|
| 3751 | 3751 | * add and delete may be slow - the focus is on access! |
| 3752 | 3752 | */ |
| 3753 | 3753 | |
| 3754 | ||
| 3754 | // TODO: replace with dynamic_array from utils | |
| 3755 | 3755 | template<class _ElementType> struct dynamic_array_t |
| 3756 | 3756 | { |
| 3757 | 3757 | public: |
| r31374 | r31375 | |
|---|---|---|
| 18 | 18 | |
| 19 | 19 | // ======================> amiga_sound_device |
| 20 | 20 | |
| 21 | class amiga_sound_device : public device_t, | |
| 21 | class amiga_sound_device : public device_t, public device_sound_interface | |
| 22 | 22 | { |
| 23 | 23 | public: |
| 24 | 24 | amiga_sound_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock); |
| r31374 | r31375 | |
|---|---|---|
| 38 | 38 | public: |
| 39 | 39 | segapcm_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock); |
| 40 | 40 | ~segapcm_device() { } |
| 41 | ||
| 41 | ||
| 42 | 42 | // static configuration |
| 43 | 43 | static void set_bank(device_t &device, int bank) { downcast<segapcm_device &>(device).m_bank = bank; } |
| 44 | ||
| 44 | ||
| 45 | 45 | DECLARE_WRITE8_MEMBER( sega_pcm_w ); |
| 46 | 46 | DECLARE_READ8_MEMBER( sega_pcm_r ); |
| 47 | ||
| 47 | ||
| 48 | 48 | protected: |
| 49 | 49 | // device-level overrides |
| 50 | 50 | virtual void device_start(); |
| r31374 | r31375 | |
|---|---|---|
| 41 | 41 | protected: |
| 42 | 42 | // device-level overrides |
| 43 | 43 | virtual void device_start(); |
| 44 | ||
| 44 | ||
| 45 | 45 | // sound stream update overrides |
| 46 | 46 | virtual void sound_stream_update(sound_stream &stream, stream_sample_t **inputs, stream_sample_t **outputs, int samples); |
| 47 | 47 |
| r31374 | r31375 | |
|---|---|---|
| 40 | 40 | // static configuration |
| 41 | 41 | static void set_voices(device_t &device, int voices) { downcast<namco_audio_device &>(device).m_voices = voices; } |
| 42 | 42 | static void set_stereo(device_t &device, int stereo) { downcast<namco_audio_device &>(device).m_stereo = stereo; } |
| 43 | ||
| 43 | ||
| 44 | 44 | protected: |
| 45 | 45 | // device-level overrides |
| 46 | 46 | virtual void device_start(); |
| r31374 | r31375 | |
|---|---|---|
| 84 | 84 | UINT8 m_nibble_shift; /* nibble select */ |
| 85 | 85 | sound_stream *m_stream; /* which stream are we playing on? */ |
| 86 | 86 | |
| 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 */ | |
| 89 | 89 | |
| 90 | 90 | INT32 m_signal; |
| 91 | 91 | INT32 m_step; |
| r31374 | r31375 | |
|---|---|---|
| 47 | 47 | public: |
| 48 | 48 | nesapu_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock); |
| 49 | 49 | ~nesapu_device() {} |
| 50 | ||
| 50 | ||
| 51 | 51 | static void set_cpu_tag(device_t &device, const char *tag) { downcast<nesapu_device &>(device).m_cpu_tag = tag; } |
| 52 | 52 | |
| 53 | 53 | DECLARE_READ8_MEMBER( read ); |
| r31374 | r31375 | |
|---|---|---|
| 62 | 62 | ~rf5c68_device() { } |
| 63 | 63 | |
| 64 | 64 | 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 | ||
| 66 | 66 | protected: |
| 67 | 67 | // device-level overrides |
| 68 | 68 | virtual void device_start(); |
| r31374 | r31375 | |
|---|---|---|
| 220 | 220 | 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); } |
| 221 | 221 | 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); } |
| 222 | 222 | 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 | ||
| 224 | 224 | DECLARE_READ8_MEMBER( read ); |
| 225 | 225 | DECLARE_WRITE8_MEMBER( write ); |
| 226 | 226 |
| r31374 | r31375 | |
|---|---|---|
| 70 | 70 | |
| 71 | 71 | #define MCFG_AY8910_OUTPUT_TYPE(_flag) \ |
| 72 | 72 | ay8910_device::set_flags(*device, _flag); |
| 73 | ||
| 73 | ||
| 74 | 74 | #define MCFG_AY8910_RES_LOADS(_res0, _res1, _res2) \ |
| 75 | 75 | ay8910_device::set_resistors_load(*device, _res0, _res1, _res2); |
| 76 | 76 | |
| r31374 | r31375 | |
| 100 | 100 | // construction/destruction |
| 101 | 101 | ay8910_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock); |
| 102 | 102 | ay8910_device(const machine_config &mconfig, device_type type, const char *name, const char *tag, device_t *owner, |
| 103 | | |
| 103 | UINT32 clock, psg_type_t psg_type, int streams, int ioports, const char *shortname, const char *source); | |
| 104 | 104 | |
| 105 | 105 | // static configuration helpers |
| 106 | 106 | 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; } | |
| 108 | 108 | 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); } |
| 109 | 109 | 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); } |
| 110 | 110 | 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); } |
| 111 | 111 | 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 | ||
| 113 | 113 | DECLARE_READ8_MEMBER( data_r ); |
| 114 | 114 | DECLARE_WRITE8_MEMBER( address_w ); |
| 115 | 115 | DECLARE_WRITE8_MEMBER( data_w ); |
| r31374 | r31375 | |
| 125 | 125 | |
| 126 | 126 | void set_volume(int channel,int volume); |
| 127 | 127 | void ay_set_clock(int clock); |
| 128 | ||
| 128 | ||
| 129 | 129 | struct ay_ym_param |
| 130 | 130 | { |
| 131 | 131 | double r_up; |
| r31374 | r31375 | |
| 134 | 134 | double res[32]; |
| 135 | 135 | }; |
| 136 | 136 | |
| 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 | }; | |
| 144 | 144 | |
| 145 | 145 | void ay8910_write_ym(int addr, int data); |
| 146 | 146 | int ay8910_read_ym(); |
| r31374 | r31375 | |
|---|---|---|
| 51 | 51 | dev.m_banks[2] = offs3; |
| 52 | 52 | dev.m_banks[3] = offs4; |
| 53 | 53 | } |
| 54 | ||
| 54 | ||
| 55 | 55 | protected: |
| 56 | 56 | // device-level overrides |
| 57 | 57 | virtual void device_start(); |
| r31374 | r31375 | |
|---|---|---|
| 19 | 19 | |
| 20 | 20 | #define MCFG_ES5506_REGION1(_region) \ |
| 21 | 21 | es5506_device::set_region1(*device, _region); |
| 22 | ||
| 22 | ||
| 23 | 23 | #define MCFG_ES5506_REGION2(_region) \ |
| 24 | 24 | es5506_device::set_region2(*device, _region); |
| 25 | ||
| 25 | ||
| 26 | 26 | #define MCFG_ES5506_REGION3(_region) \ |
| 27 | 27 | es5506_device::set_region3(*device, _region); |
| 28 | 28 | |
| 29 | 29 | #define MCFG_ES5506_CHANNELS(_chan) \ |
| 30 | 30 | es5506_device::set_channels(*device, _chan); |
| 31 | ||
| 31 | ||
| 32 | 32 | #define MCFG_ES5506_IRQ_CB(_devcb) \ |
| 33 | 33 | devcb = &es5506_device::set_irq_callback(*device, DEVCB_##_devcb); |
| 34 | 34 | |
| 35 | 35 | #define MCFG_ES5506_READ_PORT_CB(_devcb) \ |
| 36 | ||
| 36 | devcb = &es5506_device::set_read_port_callback(*device, DEVCB_##_devcb); | |
| 37 | 37 | |
| 38 | ||
| 38 | ||
| 39 | 39 | #define MCFG_ES5505_REGION0(_region) \ |
| 40 | 40 | es5505_device::set_region0(*device, _region); |
| 41 | 41 | |
| 42 | 42 | #define MCFG_ES5505_REGION1(_region) \ |
| 43 | 43 | es5505_device::set_region1(*device, _region); |
| 44 | ||
| 44 | ||
| 45 | 45 | #define MCFG_ES5505_CHANNELS(_chan) \ |
| 46 | 46 | es5505_device::set_channels(*device, _chan); |
| 47 | ||
| 47 | ||
| 48 | 48 | #define MCFG_ES5505_IRQ_CB(_devcb) \ |
| 49 | 49 | devcb = &es5505_device::set_irq_callback(*device, DEVCB_##_devcb); |
| 50 | 50 | |
| 51 | 51 | #define MCFG_ES5505_READ_PORT_CB(_devcb) \ |
| 52 | ||
| 52 | devcb = &es5505_device::set_read_port_callback(*device, DEVCB_##_devcb); | |
| 53 | 53 | |
| 54 | 54 | |
| 55 | 55 | /* struct describing a single playing voice */ |
| r31374 | r31375 | |
| 117 | 117 | public: |
| 118 | 118 | 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); |
| 119 | 119 | ~es550x_device() {} |
| 120 | ||
| 120 | ||
| 121 | 121 | static void set_region0(device_t &device, const char *region0) { downcast<es550x_device &>(device).m_region0 = region0; } |
| 122 | 122 | static void set_region1(device_t &device, const char *region1) { downcast<es550x_device &>(device).m_region1 = region1; } |
| 123 | 123 | static void set_region2(device_t &device, const char *region2) { downcast<es550x_device &>(device).m_region2 = region2; } |
| r31374 | r31375 | |
| 125 | 125 | static void set_channels(device_t &device, int channels) { downcast<es550x_device &>(device).m_channels = channels; } |
| 126 | 126 | 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); } |
| 127 | 127 | 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 | ||
| 129 | 128 | |
| 129 | ||
| 130 | 130 | protected: |
| 131 | 131 | // device-level overrides |
| 132 | 132 | virtual void device_start(); |
| r31374 | r31375 | |
| 164 | 164 | #endif |
| 165 | 165 | |
| 166 | 166 | FILE *m_eslog; |
| 167 | ||
| 167 | ||
| 168 | 168 | const char * m_region0; /* memory region where the sample ROM lives */ |
| 169 | 169 | const char * m_region1; /* memory region where the sample ROM lives */ |
| 170 | 170 | const char * m_region2; /* memory region where the sample ROM lives */ |
| r31374 | r31375 | |
|---|---|---|
| 80 | 80 | |
| 81 | 81 | void set_variant(int variant); |
| 82 | 82 | |
| 83 | UINT8 m_talk_status; | |
| 84 | sound_stream *m_stream; | |
| 83 | UINT8 m_talk_status; | |
| 84 | sound_stream *m_stream; | |
| 85 | 85 | |
| 86 | 86 | private: |
| 87 | 87 | void new_int_write(UINT8 rc, UINT8 m0, UINT8 m1, UINT8 addr); |
| r31374 | r31375 | |
| 107 | 107 | UINT8 m_CTL_pins; |
| 108 | 108 | UINT8 m_speaking_now; |
| 109 | 109 | |
| 110 | ||
| 110 | ||
| 111 | 111 | UINT8 m_state; |
| 112 | 112 | |
| 113 | 113 | /* Rom interface */ |
| r31374 | r31375 | |
| 259 | 259 | static void set_stop_bit(device_t &device, UINT8 stop_bit) { downcast<tmsprom_device &>(device).m_stop_bit = stop_bit; } |
| 260 | 260 | 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); } |
| 261 | 261 | 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 | ||
| 263 | 263 | DECLARE_WRITE_LINE_MEMBER( m0_w ); |
| 264 | 264 | DECLARE_READ_LINE_MEMBER( data_r ); |
| 265 | 265 | |
| r31374 | r31375 | |
| 314 | 314 | |
| 315 | 315 | #define MCFG_TMSPROM_ROM_SIZE(_size) \ |
| 316 | 316 | tmsprom_device::set_rom_size(*device, _size); |
| 317 | ||
| 317 | ||
| 318 | 318 | #define MCFG_TMSPROM_PDC_BIT(_bit) \ |
| 319 | 319 | tmsprom_device::set_pdc_bit(*device, _bit); |
| 320 | ||
| 320 | ||
| 321 | 321 | #define MCFG_TMSPROM_CTL1_BIT(_bit) \ |
| 322 | 322 | tmsprom_device::set_ctl1_bit(*device, _bit); |
| 323 | 323 | |
| 324 | 324 | #define MCFG_TMSPROM_CTL2_BIT(_bit) \ |
| 325 | 325 | tmsprom_device::set_ctl2_bit(*device, _bit); |
| 326 | ||
| 326 | ||
| 327 | 327 | #define MCFG_TMSPROM_CTL4_BIT(_bit) \ |
| 328 | 328 | tmsprom_device::set_ctl4_bit(*device, _bit); |
| 329 | ||
| 329 | ||
| 330 | 330 | #define MCFG_TMSPROM_CTL8_BIT(_bit) \ |
| 331 | 331 | tmsprom_device::set_ctl8_bit(*device, _bit); |
| 332 | 332 | |
| 333 | 333 | #define MCFG_TMSPROM_RESET_BIT(_bit) \ |
| 334 | 334 | tmsprom_device::set_reset_bit(*device, _bit); |
| 335 | ||
| 335 | ||
| 336 | 336 | #define MCFG_TMSPROM_STOP_BIT(_bit) \ |
| 337 | 337 | tmsprom_device::set_stop_bit(*device, _bit); |
| 338 | 338 | |
| r31374 | r31375 | |
| 340 | 340 | devcb = &tmsprom_device::set_pdc_callback(*device, DEVCB_##_devcb); |
| 341 | 341 | |
| 342 | 342 | #define MCFG_TMSPROM_CTL_CB(_devcb) \ |
| 343 | ||
| 343 | devcb = &tmsprom_device::set_ctl_callback(*device, DEVCB_##_devcb); | |
| 344 | 344 | |
| 345 | 345 | #endif /* __TMS5110_H__ */ |
| r31374 | r31375 | |
|---|---|---|
| 130 | 130 | write16_delegate m_wproto16; // 16-bit write proto-delegate |
| 131 | 131 | write32_delegate m_wproto32; // 32-bit write proto-delegate |
| 132 | 132 | write64_delegate m_wproto64; // 64-bit write proto-delegate |
| 133 | ||
| 133 | ||
| 134 | 134 | setoffset_delegate m_soproto; // set offset proto-delegate |
| 135 | 135 | address_map_delegate m_submap_delegate; |
| 136 | 136 | int m_submap_bits; |
| r31374 | r31375 | |
|---|---|---|
| 92 | 92 | emu_options &options() const { return m_options; } |
| 93 | 93 | web_engine *web() { return &m_web; } |
| 94 | 94 | lua_engine *lua() { return &m_lua; } |
| 95 | ||
| 95 | ||
| 96 | 96 | running_machine *machine() { return m_machine; } |
| 97 | 97 | |
| 98 | 98 | void set_machine(running_machine *machine) { m_machine = machine; } |
| 99 | ||
| 99 | ||
| 100 | 100 | void update_machine(); |
| 101 | ||
| 101 | ||
| 102 | 102 | /* execute as configured by the OPTION_SYSTEMNAME option on the specified options */ |
| 103 | 103 | int execute(); |
| 104 | 104 | void schedule_new_driver(const game_driver &driver); |
| 105 | 105 | private: |
| 106 | 106 | osd_interface & m_osd; // reference to OSD system |
| 107 | 107 | 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; | |
| 116 | 116 | }; |
| 117 | 117 | |
| 118 | 118 | //************************************************************************** |
| r31374 | r31375 | |
|---|---|---|
| 79 | 79 | MCFG_DEVICE_ADD(_tag, HARDDISK, 0) |
| 80 | 80 | |
| 81 | 81 | #define MCFG_HARDDISK_LOAD(_class,_method) \ |
| 82 | ||
| 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))); | |
| 83 | 83 | |
| 84 | 84 | #define MCFG_HARDDISK_UNLOAD(_class,_method) \ |
| 85 | ||
| 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))); | |
| 86 | 86 | |
| 87 | 87 | #define MCFG_HARDDISK_INTERFACE(_interface) \ |
| 88 | 88 | harddisk_image_device::static_set_interface(*device, _interface); |
| r31374 | r31375 | |
|---|---|---|
| 27 | 27 | midiin_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock); |
| 28 | 28 | |
| 29 | 29 | 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 | ||
| 31 | 31 | // image-level overrides |
| 32 | 32 | virtual bool call_load(); |
| 33 | 33 | virtual void call_unload(); |
| r31374 | r31375 | |
|---|---|---|
| 107 | 107 | const struct CassetteFormat* const *m_formats; |
| 108 | 108 | const struct CassetteOptions *m_create_opts; |
| 109 | 109 | cassette_state m_default_state; |
| 110 | const char * m_interface; | |
| 110 | const char * m_interface; | |
| 111 | 111 | }; |
| 112 | 112 | |
| 113 | 113 | // device type definition |
| r31374 | r31375 | |
| 124 | 124 | |
| 125 | 125 | #define MCFG_CASSETTE_MODIFY(_tag) \ |
| 126 | 126 | MCFG_DEVICE_MODIFY(_tag) |
| 127 | ||
| 128 | #define MCFG_CASSETTE_FORMATS(_formats) \ | |
| 127 | ||
| 128 | #define MCFG_CASSETTE_FORMATS(_formats) \ | |
| 129 | 129 | cassette_image_device::static_set_formats(*device, _formats); |
| 130 | 130 | |
| 131 | #define MCFG_CASSETTE_CREATE_OPTS(_create_opts) | |
| 131 | #define MCFG_CASSETTE_CREATE_OPTS(_create_opts) \ | |
| 132 | 132 | cassette_image_device::static_set_create_opts(*device, _create_opts); |
| 133 | 133 | |
| 134 | #define MCFG_CASSETTE_DEFAULT_STATE(_state) | |
| 134 | #define MCFG_CASSETTE_DEFAULT_STATE(_state) \ | |
| 135 | 135 | cassette_image_device::static_set_default_state(*device, (cassette_state) (_state)); |
| 136 | 136 | |
| 137 | #define MCFG_CASSETTE_INTERFACE(_interface) | |
| 137 | #define MCFG_CASSETTE_INTERFACE(_interface) \ | |
| 138 | 138 | cassette_image_device::static_set_interface(*device, _interface); |
| 139 | 139 | |
| 140 | 140 | #endif /* CASSETTE_H */ |
| r31374 | r31375 | |
|---|---|---|
| 95 | 95 | ~legacy_floppy_image_device(); |
| 96 | 96 | |
| 97 | 97 | 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 | ||
| 99 | 99 | virtual bool call_load(); |
| 100 | 100 | virtual bool call_softlist_load(software_list_device &swlist, const char *swname, const rom_entry *start_entry) { return load_software(swlist, swname, start_entry); } |
| 101 | 101 | virtual bool call_create(int format_type, option_resolution *format_options); |
| r31374 | r31375 | |
|---|---|---|
| 84 | 84 | MCFG_DEVICE_CONFIG(_config) |
| 85 | 85 | |
| 86 | 86 | #define MCFG_DIABLO_LOAD(_class,_method) \ |
| 87 | ||
| 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))); | |
| 88 | 88 | |
| 89 | 89 | #define MCFG_DIABLO_UNLOAD(_class,_method) \ |
| 90 | ||
| 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))); | |
| 91 | 91 | |
| 92 | 92 | #define MCFG_DIABLO_INTERFACE(_interface) \ |
| 93 | 93 | diablo_image_device::static_set_interface(*device, _interface); |
| r31374 | r31375 | |
|---|---|---|
| 42 | 42 | static void static_set_extensions(device_t &device, const char *_extensions) { downcast<cartslot_image_device &>(device).m_extensions = _extensions; } |
| 43 | 43 | static void static_set_interface(device_t &device, const char *_interface) { downcast<cartslot_image_device &>(device).m_interface = _interface; } |
| 44 | 44 | 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 | ||
| 46 | 46 | // image-level overrides |
| 47 | 47 | virtual bool call_load(); |
| 48 | 48 | virtual void call_unload(); |
| r31374 | r31375 | |
| 102 | 102 | cartslot_image_device::static_set_must_be_loaded(*device, TRUE); |
| 103 | 103 | |
| 104 | 104 | #define MCFG_CARTSLOT_LOAD(_class,_method) \ |
| 105 | ||
| 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))); | |
| 106 | 106 | |
| 107 | 107 | #define MCFG_CARTSLOT_UNLOAD(_class,_method) \ |
| 108 | ||
| 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))); | |
| 109 | 109 | |
| 110 | 110 | #define MCFG_CARTSLOT_PARTIALHASH(_partialhash) \ |
| 111 | 111 | cartslot_image_device::static_set_partialhash(*device, _partialhash); |
| r31374 | r31375 | |
|---|---|---|
| 170 | 170 | attotime m_mng_frame_period; // period of a single movie frame |
| 171 | 171 | attotime m_mng_next_frame_time; // time of next frame |
| 172 | 172 | UINT32 m_mng_frame; // current movie frame number |
| 173 | ||
| 173 | ||
| 174 | 174 | // movie recording - AVI |
| 175 | 175 | avi_file * m_avi_file; // handle to the open movie file |
| 176 | 176 | attotime m_avi_frame_period; // period of a single movie frame |
| r31374 | r31375 | |
|---|---|---|
| 439 | 439 | UINT64 *install_read_handler(offs_t addrstart, offs_t addrend, offs_t addrmask, offs_t addrmirror, read64_delegate rhandler, UINT64 unitmask = 0); |
| 440 | 440 | UINT64 *install_write_handler(offs_t addrstart, offs_t addrend, offs_t addrmask, offs_t addrmirror, write64_delegate whandler, UINT64 unitmask = 0); |
| 441 | 441 | 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 | ||
| 443 | 443 | // setup |
| 444 | 444 | void prepare_map(); |
| 445 | 445 | void populate_from_map(address_map *map = NULL); |
| r31374 | r31375 | |
|---|---|---|
| 44 | 44 | int cb; |
| 45 | 45 | |
| 46 | 46 | hook(); |
| 47 | | |
| 47 | void set(lua_State *L, int idx); | |
| 48 | 48 | lua_State *precall(); |
| 49 | 49 | void call(lua_engine *engine, lua_State *T, int nparam); |
| 50 | 50 | bool active() const { return L != NULL; } |
| 51 | 51 | }; |
| 52 | ||
| 52 | ||
| 53 | 53 | static const char *const tname_ioport; |
| 54 | 54 | |
| 55 | 55 | // internal state |
| r31374 | r31375 | |
| 58 | 58 | |
| 59 | 59 | hook hook_output_cb; |
| 60 | 60 | bool output_notifier_set; |
| 61 | ||
| 61 | ||
| 62 | 62 | static lua_engine* luaThis; |
| 63 | 63 | |
| 64 | 64 | std::map<lua_State *, std::pair<lua_State *, int> > thread_registry; |
| r31374 | r31375 | |
| 93 | 93 | static void *checkparam(lua_State *L, int idx, const char *tname); |
| 94 | 94 | static void *getparam(lua_State *L, int idx, const char *tname); |
| 95 | 95 | static void push(lua_State *L, void *p, const char *tname); |
| 96 | ||
| 96 | ||
| 97 | 97 | int report(int status); |
| 98 | 98 | int docall(int narg, int nres); |
| 99 | 99 | int incomplete(int status) ; |
| r31374 | r31375 | |
|---|---|---|
| 774 | 774 | |
| 775 | 775 | if (!(ptest)) |
| 776 | 776 | { |
| 777 | page_entry |= 0x8; | |
| 777 | page_entry |= 0x8; // always set the U bit | |
| 778 | 778 | |
| 779 | 779 | // if we're writing, the M bit comes into play |
| 780 | 780 | if (!m68k->mmu_tmp_rw) |
| 781 | 781 | { |
| 782 | page_entry |= 0x10; | |
| 782 | page_entry |= 0x10; // set Modified | |
| 783 | 783 | } |
| 784 | 784 | |
| 785 | 785 | // if these updates resulted in a change, write the entry back where we found it |
| r31374 | r31375 | |
| 795 | 795 | // SR: B G U1 U0 S CM CM M 0 W T R |
| 796 | 796 | m68k->mmu_tmp_sr |= ((addr_out & ~0xfff) || (page_entry & 0x7f4)); |
| 797 | 797 | } |
| 798 | break; | |
| 798 | break; | |
| 799 | 799 | |
| 800 | 800 | case 2: // shouldn't happen |
| 801 | 801 | fatalerror("68040: got indirect final page pointer, shouldn't be possible\n"); |
| r31374 | r31375 | |
|---|---|---|
| 252 | 252 | const UINT8* cyc_exception; |
| 253 | 253 | |
| 254 | 254 | /* 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 */ | |
| 263 | 263 | |
| 264 | 264 | address_space *program; |
| 265 | 265 |
| r31374 | r31375 | |
|---|---|---|
| 103 | 103 | UINT32 m_shift; |
| 104 | 104 | UINT32 m_repcnt; |
| 105 | 105 | UINT16 m_sr; |
| 106 | UINT8 | |
| 106 | UINT8 m_fpucontrol; | |
| 107 | 107 | |
| 108 | 108 | UINT32 m_gpr[16]; |
| 109 | 109 | UINT32 m_extport[0x30]; |
| r31374 | r31375 | |
|---|---|---|
| 359 | 359 | /* core state */ |
| 360 | 360 | internal_mips3_state *m_core; |
| 361 | 361 | |
| 362 | ||
| 362 | /* internal stuff */ | |
| 363 | 363 | UINT32 m_ppc; |
| 364 | 364 | UINT32 m_nextpc; |
| 365 | 365 | UINT32 m_pcbase; |
| r31374 | r31375 | |
| 444 | 444 | |
| 445 | 445 | /* fast RAM */ |
| 446 | 446 | UINT32 m_fastram_select; |
| 447 | struct | |
| 447 | struct | |
| 448 | 448 | { |
| 449 | 449 | offs_t start; /* start of the RAM block */ |
| 450 | 450 | offs_t end; /* end of the RAM block */ |
| r31374 | r31375 | |
|---|---|---|
| 63 | 63 | |
| 64 | 64 | #define MCFG_NECDSP_OUT_DRQ_CB(_devcb) \ |
| 65 | 65 | devcb = &necdsp_device::set_out_drq_callback(*device, DEVCB_##_devcb); |
| 66 | ||
| 67 | 66 | |
| 67 | ||
| 68 | 68 | // ======================> necdsp_device |
| 69 | 69 | |
| 70 | 70 | class necdsp_device : public cpu_device |
| r31374 | r31375 | |
| 86 | 86 | //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); } |
| 87 | 87 | //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); } |
| 88 | 88 | //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 | ||
| 90 | 90 | UINT8 snesdsp_read(bool mode); |
| 91 | 91 | void snesdsp_write(bool mode, UINT8 data); |
| 92 | 92 |
| r31374 | r31375 | |
|---|---|---|
| 1780 | 1780 | endif |
| 1781 | 1781 | |
| 1782 | 1782 | $(CPUOBJ)/upd7810/upd7810_opcodes.o: $(CPUSRC)/upd7810/upd7810_opcodes.c \ |
| 1783 | ||
| 1783 | $(CPUSRC)/upd7810/upd7810_macros.h | |
| 1784 | 1784 | |
| 1785 | 1785 | $(CPUOBJ)/upd7810/upd7810.o: $(CPUSRC)/upd7810/upd7810.c \ |
| 1786 | 1786 | $(CPUSRC)/upd7810/upd7810.h \ |
| r31374 | r31375 | |
|---|---|---|
| 61 | 61 | public: |
| 62 | 62 | // construction/destruction |
| 63 | 63 | scudsp_cpu_device(const machine_config &mconfig, const char *_tag, device_t *_owner, UINT32 _clock); |
| 64 | ||
| 64 | ||
| 65 | 65 | 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); } |
| 66 | 66 | 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); } |
| 67 | 67 | 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 | ||
| 69 | 69 | /* port 0 */ |
| 70 | 70 | DECLARE_READ32_MEMBER( program_control_r ); |
| 71 | 71 | DECLARE_WRITE32_MEMBER( program_control_w ); |
| r31374 | r31375 | |
| 104 | 104 | devcb_write_line m_out_irq_cb; |
| 105 | 105 | devcb_read16 m_in_dma_cb; |
| 106 | 106 | devcb_write16 m_out_dma_cb; |
| 107 | ||
| 107 | ||
| 108 | 108 | private: |
| 109 | 109 | address_space_config m_program_config; |
| 110 | 110 | address_space_config m_data_config; |
| r31374 | r31375 | |
|---|---|---|
| 1915 | 1915 | |
| 1916 | 1916 | |
| 1917 | 1917 | #if EXECUTION_MODE == EXECUTION_MODE_E |
| 1918 | #define g65816i_correct_mode() | |
| 1918 | #define g65816i_correct_mode() (FLAG_E == EFLAG_SET) | |
| 1919 | 1919 | #elif EXECUTION_MODE == EXECUTION_MODE_M0X0 |
| 1920 | #define g65816i_correct_mode() | |
| 1920 | #define g65816i_correct_mode() ((FLAG_E == EFLAG_CLEAR) && (FLAG_M == MFLAG_CLEAR) && (FLAG_X == XFLAG_CLEAR)) | |
| 1921 | 1921 | #elif EXECUTION_MODE == EXECUTION_MODE_M0X1 |
| 1922 | #define g65816i_correct_mode() | |
| 1922 | #define g65816i_correct_mode() ((FLAG_E == EFLAG_CLEAR) && (FLAG_M == MFLAG_CLEAR) && (FLAG_X == XFLAG_SET)) | |
| 1923 | 1923 | #elif EXECUTION_MODE == EXECUTION_MODE_M1X0 |
| 1924 | #define g65816i_correct_mode() | |
| 1924 | #define g65816i_correct_mode() ((FLAG_E == EFLAG_CLEAR) && (FLAG_M == MFLAG_SET) && (FLAG_X == XFLAG_CLEAR)) | |
| 1925 | 1925 | #elif EXECUTION_MODE == EXECUTION_MODE_M1X1 |
| 1926 | #define g65816i_correct_mode() | |
| 1926 | #define g65816i_correct_mode() ((FLAG_E == EFLAG_CLEAR) && (FLAG_M == MFLAG_SET) && (FLAG_X == XFLAG_SET)) | |
| 1927 | 1927 | #else |
| 1928 | 1928 | #error Invalid EXECUTION_MODE |
| 1929 | 1929 | #endif |
| r31374 | r31375 | |
|---|---|---|
| 145 | 145 | |
| 146 | 146 | #define MCFG_RSP_DP_REG_R_CB(_devcb) \ |
| 147 | 147 | devcb = &rsp_cpu_device::static_set_dp_reg_r_callback(*device, DEVCB_##_devcb); |
| 148 | ||
| 148 | ||
| 149 | 149 | #define MCFG_RSP_DP_REG_W_CB(_devcb) \ |
| 150 | 150 | devcb = &rsp_cpu_device::static_set_dp_reg_w_callback(*device, DEVCB_##_devcb); |
| 151 | ||
| 151 | ||
| 152 | 152 | #define MCFG_RSP_SP_REG_R_CB(_devcb) \ |
| 153 | 153 | devcb = &rsp_cpu_device::static_set_sp_reg_r_callback(*device, DEVCB_##_devcb); |
| 154 | ||
| 154 | ||
| 155 | 155 | #define MCFG_RSP_SP_REG_W_CB(_devcb) \ |
| 156 | 156 | devcb = &rsp_cpu_device::static_set_sp_reg_w_callback(*device, DEVCB_##_devcb); |
| 157 | 157 | |
| r31374 | r31375 | |
| 163 | 163 | protected: |
| 164 | 164 | // construction/destruction |
| 165 | 165 | 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 | ||
| 167 | 167 | public: |
| 168 | 168 | void resolve_cb(); |
| 169 | 169 | 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); } |
| r31374 | r31375 | |
| 171 | 171 | 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); } |
| 172 | 172 | 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); } |
| 173 | 173 | 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 | ||
| 175 | 174 | |
| 175 | ||
| 176 | 176 | devcb_read32 dp_reg_r_func; |
| 177 | 177 | devcb_write32 dp_reg_w_func; |
| 178 | 178 | devcb_read32 sp_reg_r_func; |
| 179 | 179 | devcb_write32 sp_reg_w_func; |
| 180 | devcb_write32 sp_set_status_func; | |
| 180 | devcb_write32 sp_set_status_func; | |
| 181 | 181 | }; |
| 182 | 182 | |
| 183 | 183 |
| r31374 | r31375 | |
|---|---|---|
| 360 | 360 | #define AD2_Y8 UINT32 addr2 = ( m_YI << 16 ) | ( m_Y + rdop() ) |
| 361 | 361 | #define AD2_XL UINT32 addr2 = ( m_XI << 16 ) | ( m_X + ( m_HL & 0x00FF ) ) |
| 362 | 362 | #define AD2_YL UINT32 addr2 = ( m_YI << 16 ) | ( m_Y + ( m_HL & 0x00FF ) ) |
| 363 |
| r31374 | r31375 | |
|---|---|---|
| 559 | 559 | 8, 8, 8, 8, 8, 8, 8, 8, 12, 12, 12, 12, 12, 12, 12, 12, |
| 560 | 560 | 20, 8, 24, 12, 8, 1, 8, 12, 8, 8, 8, 20, 20, 1, 1, 8 |
| 561 | 561 | }; |
| 562 |
| r31374 | r31375 | |
|---|---|---|
| 695 | 695 | //class ppc403_device : public ppc_device |
| 696 | 696 | //{ |
| 697 | 697 | //public: |
| 698 | // | |
| 698 | // ppc403_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock); | |
| 699 | 699 | // |
| 700 | 700 | //protected: |
| 701 | // | |
| 701 | // virtual UINT32 execute_input_lines() const { return 8; } | |
| 702 | 702 | //}; |
| 703 | 703 | // |
| 704 | 704 | // |
| 705 | 705 | //class ppc405_device : public ppc_device |
| 706 | 706 | //{ |
| 707 | 707 | //public: |
| 708 | // | |
| 708 | // ppc405_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock); | |
| 709 | 709 | // |
| 710 | 710 | //protected: |
| 711 | // | |
| 711 | // virtual UINT32 execute_input_lines() const { return 8; } | |
| 712 | 712 | //}; |
| 713 | 713 | |
| 714 | 714 |
| r31374 | r31375 | |
|---|---|---|
| 456 | 456 | UINT16 m_mask_table[0x4000]; |
| 457 | 457 | UINT16 m_reverse_table[0x4000]; |
| 458 | 458 | |
| 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 | |
| 462 | 462 | |
| 463 | 463 | // debugging |
| 464 | 464 | #if ADSP_TRACK_HOTSPOTS |
| r31374 | r31375 | |
|---|---|---|
| 519 | 519 | class sh2_frontend : public drc_frontend |
| 520 | 520 | { |
| 521 | 521 | public: |
| 522 | ||
| 522 | sh2_frontend(sh2_device *device, UINT32 window_start, UINT32 window_end, UINT32 max_sequence); | |
| 523 | 523 | |
| 524 | 524 | protected: |
| 525 | ||
| 525 | virtual bool describe(opcode_desc &desc, const opcode_desc *prev); | |
| 526 | 526 | |
| 527 | 527 | private: |
| 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); | |
| 535 | 535 | |
| 536 | 536 | sh2_device *m_sh2; |
| 537 | 537 | }; |
| r31374 | r31375 | |
|---|---|---|
| 823 | 823 | case 0x62: compute_max(rn, rx, ry); break; |
| 824 | 824 | case 0x81: compute_fadd(rn, rx, ry); break; |
| 825 | 825 | case 0x82: compute_fsub(rn, rx, ry); break; |
| 826 | case 0x89: | |
| 826 | case 0x89: compute_favg(rn, rx, ry); break; | |
| 827 | 827 | case 0x8a: compute_fcomp(rx, ry); break; |
| 828 | 828 | case 0x91: compute_fabs_plus(rn, rx, ry); break; |
| 829 | 829 | case 0xa1: compute_fpass(rn, rx); break; |
| r31374 | r31375 | |
|---|---|---|
| 65 | 65 | DECLARE_WRITE8_MEMBER(tms7000_pf_w); |
| 66 | 66 | DECLARE_READ8_MEMBER(tms7002_pf_r) { return tms7000_pf_r(space, offset + 0x10); } |
| 67 | 67 | DECLARE_WRITE8_MEMBER(tms7002_pf_w) { tms7000_pf_w(space, offset + 0x10, data); } |
| 68 | ||
| 68 | ||
| 69 | 69 | bool chip_is_cmos() { return (m_info_flags & TMS7000_CHIP_IS_CMOS) ? true : false; } |
| 70 | 70 | UINT32 chip_get_family() { return m_info_flags & TMS7000_CHIP_FAMILY_MASK; } |
| 71 | 71 | bool chip_is_family_70x0() { return chip_get_family() == TMS7000_CHIP_FAMILY_70X0; } |
| r31374 | r31375 | |
| 128 | 128 | |
| 129 | 129 | UINT8 m_port_latch[4]; |
| 130 | 130 | UINT8 m_port_ddr[4]; |
| 131 | ||
| 131 | ||
| 132 | 132 | void flag_ext_interrupt(int extline); |
| 133 | 133 | void check_interrupts(); |
| 134 | 134 | void do_interrupt(int irqline); |
| 135 | ||
| 135 | ||
| 136 | 136 | TIMER_CALLBACK_MEMBER(simple_timer_cb); |
| 137 | 137 | void timer_run(int tmr); |
| 138 | 138 | void timer_reload(int tmr); |
| 139 | 139 | void timer_tick_pre(int tmr); |
| 140 | 140 | void timer_tick_low(int tmr); |
| 141 | ||
| 141 | ||
| 142 | 142 | // internal read/write |
| 143 | 143 | inline UINT8 read_r8(UINT8 address) { return m_program->read_byte(address); } |
| 144 | 144 | inline void write_r8(UINT8 address, UINT8 data) { m_program->write_byte(address, data); } |
| r31374 | r31375 | |
| 160 | 160 | inline void push8(UINT8 data) { m_program->write_byte(++m_sp, data); } |
| 161 | 161 | inline UINT16 pull16() { UINT16 ret = m_program->read_byte(m_sp--); return ret | m_program->read_byte(m_sp--) << 8; } |
| 162 | 162 | inline void push16(UINT16 data) { m_program->write_byte(++m_sp, data >> 8 & 0xff); m_program->write_byte(++m_sp, data & 0xff); } |
| 163 | ||
| 163 | ||
| 164 | 164 | // opcode handlers |
| 165 | 165 | void br_dir(); |
| 166 | 166 | void br_inx(); |
| r31374 | r31375 | |
| 202 | 202 | void stsp(); |
| 203 | 203 | void trap(UINT8 address); |
| 204 | 204 | void illegal(UINT8 op); |
| 205 | ||
| 205 | ||
| 206 | 206 | typedef int (tms7000_device::*op_func)(UINT8, UINT8); |
| 207 | 207 | int op_clr(UINT8 param1, UINT8 param2); |
| 208 | 208 | int op_dec(UINT8 param1, UINT8 param2); |
| r31374 | r31375 | |
| 214 | 214 | int op_rrc(UINT8 param1, UINT8 param2); |
| 215 | 215 | int op_swap(UINT8 param1, UINT8 param2); |
| 216 | 216 | int op_xchb(UINT8 param1, UINT8 param2); |
| 217 | ||
| 217 | ||
| 218 | 218 | int op_adc(UINT8 param1, UINT8 param2); |
| 219 | 219 | int op_add(UINT8 param1, UINT8 param2); |
| 220 | 220 | int op_and(UINT8 param1, UINT8 param2); |
| r31374 | r31375 | |
| 227 | 227 | int op_sbb(UINT8 param1, UINT8 param2); |
| 228 | 228 | int op_sub(UINT8 param1, UINT8 param2); |
| 229 | 229 | int op_xor(UINT8 param1, UINT8 param2); |
| 230 | ||
| 230 | ||
| 231 | 231 | inline void shortbranch(bool check); |
| 232 | 232 | inline void jmp(bool check); |
| 233 | 233 | int op_djnz(UINT8 param1, UINT8 param2); |
| r31374 | r31375 | |
|---|---|---|
| 307 | 307 | UINT8 l1 = param1 >> 0 & 0xf; |
| 308 | 308 | UINT8 h2 = param2 >> 4 & 0xf; |
| 309 | 309 | UINT8 l2 = param2 >> 0 & 0xf; |
| 310 | ||
| 310 | ||
| 311 | 311 | // compute bcd constant |
| 312 | 312 | UINT8 d = ((l1 + l2 + c) < 10) ? 0 : 1; |
| 313 | 313 | if ((h1 + h2) == 9) |
| 314 | 314 | d |= 2; |
| 315 | 315 | else if ((h1 + h2) > 9) |
| 316 | 316 | d |= 4; |
| 317 | ||
| 317 | ||
| 318 | 318 | UINT8 t = param1 + param2 + c + lut_bcd_out[d]; |
| 319 | 319 | SET_CNZ(t); |
| 320 | 320 | if (d > 2) |
| 321 | 321 | m_sr |= SR_C; |
| 322 | ||
| 322 | ||
| 323 | 323 | return t; |
| 324 | 324 | } |
| 325 | 325 | |
| r31374 | r31375 | |
| 344 | 344 | SET_CNZ(t); |
| 345 | 345 | if (d <= 2) |
| 346 | 346 | m_sr |= SR_C; |
| 347 | ||
| 347 | ||
| 348 | 348 | return t; |
| 349 | 349 | } |
| 350 | 350 |
| r31374 | r31375 | |
|---|---|---|
| 122 | 122 | 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); } |
| 123 | 123 | |
| 124 | 124 | 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); } | |
| 126 | 126 | 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 | ||
| 129 | 129 | 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); } |
| 130 | 130 | 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); } |
| 131 | 131 | 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); } |
| r31374 | r31375 | |
| 171 | 171 | DECLARE_READ8_MEMBER( pa_r ) { return m_pio->pa_r(space, offset, mem_mask); } |
| 172 | 172 | DECLARE_WRITE8_MEMBER( pb_w ) { m_pio->pb_w(space, offset, data, mem_mask); } |
| 173 | 173 | DECLARE_READ8_MEMBER( pb_r ) { return m_pio->pb_r(space, offset, mem_mask); } |
| 174 | ||
| 174 | ||
| 175 | 175 | ///////////////////////////////////////////////////////// |
| 176 | 176 | |
| 177 | 177 | DECLARE_WRITE8_MEMBER( irq_priority_w ); |
| r31374 | r31375 | |
| 204 | 204 | DECLARE_READ8_MEMBER( in_pb_cb_trampoline_r ) { return m_in_pb_cb(); } |
| 205 | 205 | DECLARE_WRITE8_MEMBER( out_pb_cb_trampoline_w ) { m_out_pb_cb(data); } |
| 206 | 206 | DECLARE_WRITE_LINE_MEMBER( out_brdy_cb_trampoline_w ) { m_out_brdy_cb(state); } |
| 207 | ||
| 207 | ||
| 208 | 208 | protected: |
| 209 | 209 | // device-level overrides |
| 210 | 210 | virtual machine_config_constructor device_mconfig_additions() const; |
| r31374 | r31375 | |
| 231 | 231 | |
| 232 | 232 | // internal state |
| 233 | 233 | UINT8 m_irq_priority; |
| 234 | ||
| 234 | ||
| 235 | 235 | // callbacks |
| 236 | 236 | devcb_write_line m_out_txda_cb; |
| 237 | 237 | devcb_write_line m_out_dtra_cb; |
| 238 | 238 | devcb_write_line m_out_rtsa_cb; |
| 239 | 239 | devcb_write_line m_out_wrdya_cb; |
| 240 | 240 | devcb_write_line m_out_synca_cb; |
| 241 | ||
| 241 | ||
| 242 | 242 | devcb_write_line m_out_txdb_cb; |
| 243 | 243 | devcb_write_line m_out_dtrb_cb; |
| 244 | 244 | devcb_write_line m_out_rtsb_cb; |
| 245 | 245 | devcb_write_line m_out_wrdyb_cb; |
| 246 | 246 | devcb_write_line m_out_syncb_cb; |
| 247 | ||
| 247 | ||
| 248 | 248 | devcb_write_line m_out_rxdrqa_cb; |
| 249 | 249 | devcb_write_line m_out_txdrqa_cb; |
| 250 | 250 | devcb_write_line m_out_rxdrqb_cb; |
| r31374 | r31375 | |
| 257 | 257 | devcb_read8 m_in_pa_cb; |
| 258 | 258 | devcb_write8 m_out_pa_cb; |
| 259 | 259 | devcb_write_line m_out_ardy_cb; |
| 260 | ||
| 260 | ||
| 261 | 261 | devcb_read8 m_in_pb_cb; |
| 262 | 262 | devcb_write8 m_out_pb_cb; |
| 263 | 263 | devcb_write_line m_out_brdy_cb; |
| r31374 | r31375 | |
|---|---|---|
| 97 | 97 | DECLARE_WRITE_LINE_MEMBER( trg1 ) { m_ctc->trg1(state); } |
| 98 | 98 | DECLARE_WRITE_LINE_MEMBER( trg2 ) { m_ctc->trg2(state); } |
| 99 | 99 | DECLARE_WRITE_LINE_MEMBER( trg3 ) { m_ctc->trg3(state); } |
| 100 | ||
| 100 | ||
| 101 | 101 | ///////////////////////////////////////////////////////// |
| 102 | 102 | |
| 103 | 103 | DECLARE_READ8_MEMBER( tmpz84c011_pa_r ); |
| r31374 | r31375 | |
|---|---|---|
| 61 | 61 | |
| 62 | 62 | #define MCFG_TTL74123_RESISTOR_VALUE(_value) \ |
| 63 | 63 | ttl74123_device::set_resistor_value(*device, _value); |
| 64 | ||
| 64 | ||
| 65 | 65 | #define MCFG_TTL74123_CAPACITOR_VALUE(_value) \ |
| 66 | 66 | ttl74123_device::set_capacitor_value(*device, _value); |
| 67 | 67 | |
| 68 | 68 | #define MCFG_TTL74123_A_PIN_VALUE(_value) \ |
| 69 | 69 | ttl74123_device::set_a_pin_value(*device, _value); |
| 70 | ||
| 70 | ||
| 71 | 71 | #define MCFG_TTL74123_B_PIN_VALUE(_value) \ |
| 72 | 72 | ttl74123_device::set_b_pin_value(*device, _value); |
| 73 | 73 | |
| r31374 | r31375 | |
| 75 | 75 | ttl74123_device::set_clear_pin_value(*device, _value); |
| 76 | 76 | |
| 77 | 77 | #define MCFG_TTL74123_OUTPUT_CHANGED_CB(_devcb) \ |
| 78 | ||
| 78 | devcb = &ttl74123_device::set_output_changed_callback(*device, DEVCB_##_devcb); | |
| 79 | 79 | |
| 80 | 80 | /* constants for the different ways the cap/res can be connected. |
| 81 | 81 | This determines the formula for calculating the pulse width */ |
| r31374 | r31375 | |
| 103 | 103 | static void set_b_pin_value(device_t &device, int value) { downcast<ttl74123_device &>(device).m_b = value; } |
| 104 | 104 | static void set_clear_pin_value(device_t &device, int value) { downcast<ttl74123_device &>(device).m_clear = value; } |
| 105 | 105 | 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 | ||
| 107 | 107 | DECLARE_WRITE8_MEMBER(a_w); |
| 108 | 108 | DECLARE_WRITE8_MEMBER(b_w); |
| 109 | 109 | DECLARE_WRITE8_MEMBER(clear_w); |
| r31374 | r31375 | |
|---|---|---|
| 47 | 47 | static void set_out_frame_callback(device_t &device, mc6854_out_frame_delegate callback) { downcast<mc6854_device &>(device).m_out_frame_cb = callback; } |
| 48 | 48 | 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); } |
| 49 | 49 | 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 | ||
| 51 | 51 | /* interface to CPU via address/data bus*/ |
| 52 | 52 | DECLARE_READ8_MEMBER( read ); |
| 53 | 53 | DECLARE_WRITE8_MEMBER( write ); |
| r31374 | r31375 | |
| 74 | 74 | private: |
| 75 | 75 | // internal state |
| 76 | 76 | devcb_write_line m_out_irq_cb; /* interrupt request */ |
| 77 | ||
| 77 | ||
| 78 | 78 | /* low-level, bit-based interface */ |
| 79 | 79 | 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 | ||
| 84 | 84 | /* control lines */ |
| 85 | 85 | devcb_write_line m_out_rts_cb; /* 1 = transmitting, 0 = idle */ |
| 86 | 86 | devcb_write_line m_out_dtr_cb; /* 1 = data transmit ready, 0 = busy */ |
| r31374 | r31375 | |
|---|---|---|
| 26 | 26 | public: |
| 27 | 27 | upd71071_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock); |
| 28 | 28 | ~upd71071_device() {} |
| 29 | ||
| 29 | ||
| 30 | 30 | static void static_set_cpu_tag(device_t &device, const char *tag) { downcast<upd71071_device &>(device).m_cpu.set_tag(tag); } |
| 31 | 31 | static void set_clock(device_t &device, int clock) { downcast<upd71071_device &>(device).m_upd_clock = clock; } |
| 32 | 32 | 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); } |
| r31374 | r31375 | |
| 98 | 98 | |
| 99 | 99 | #define MCFG_UPD71071_CLOCK(_clk) \ |
| 100 | 100 | upd71071_device::set_clock(*device, _clk); |
| 101 | ||
| 101 | ||
| 102 | 102 | #define MCFG_UPD71071_OUT_HREQ_CB(_devcb) \ |
| 103 | 103 | devcb = &upd71071_device::set_out_hreq_callback(*device, DEVCB_##_devcb); |
| 104 | 104 |
| r31374 | r31375 | |
|---|---|---|
| 83 | 83 | 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); } |
| 84 | 84 | 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); } |
| 85 | 85 | 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 | ||
| 87 | 87 | UINT8 read(); |
| 88 | 88 | void write(UINT8 data); |
| 89 | 89 | DECLARE_READ8_MEMBER( read ) { return read(); } |
| r31374 | r31375 | |
|---|---|---|
| 23 | 23 | //************************************************************************** |
| 24 | 24 | |
| 25 | 25 | #define MCFG_DMAC_ADD(_tag, _clock) \ |
| 26 | MCFG_DEVICE_ADD(_tag, DMAC, _clock) \ | |
| 27 | ||
| 26 | MCFG_DEVICE_ADD(_tag, DMAC, _clock) | |
| 28 | 27 | #define MCFG_DMAC_CFGOUT_HANDLER(_devcb) \ |
| 29 | 28 | devcb = &dmac_device::set_cfgout_handler(*device, DEVCB_##_devcb); |
| 30 | 29 | |
| r31374 | r31375 | |
| 109 | 108 | // control register flags |
| 110 | 109 | enum |
| 111 | 110 | { |
| 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) | |
| 117 | 116 | }; |
| 118 | 117 | |
| 119 | 118 | // interrupt status register |
| 120 | 119 | enum |
| 121 | 120 | { |
| 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 | |
| 131 | 130 | }; |
| 132 | 131 | |
| 133 | 132 | static const int ISTR_INT_MASK = 0x1fc; |
| r31374 | r31375 | |
| 153 | 152 | int m_rst; |
| 154 | 153 | |
| 155 | 154 | // 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 | |
| 160 | 159 | |
| 161 | 160 | bool m_dma_active; |
| 162 | 161 |
| r31374 | r31375 | |
|---|---|---|
| 31 | 31 | 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); } |
| 32 | 32 | 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); } |
| 33 | 33 | |
| 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 | { | |
| 36 | 36 | i8271_device &dev = downcast<i8271_device &>(device); |
| 37 | 37 | dev.m_floppy_tag1 = tag1; |
| 38 | 38 | dev.m_floppy_tag2 = tag2; |
| r31374 | r31375 | |
|---|---|---|
| 84 | 84 | 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); } |
| 85 | 85 | 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); } |
| 86 | 86 | 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 | ||
| 88 | 88 | // read & write handlers |
| 89 | 89 | DECLARE_READ8_MEMBER(status_r); |
| 90 | 90 | DECLARE_READ8_MEMBER(data_r); |
| r31374 | r31375 | |
| 115 | 115 | devcb_write8 m_out_sl_cb; // Scanlines SL0-3 |
| 116 | 116 | devcb_write8 m_out_disp_cb; // B0-3,A0-3 |
| 117 | 117 | devcb_write_line m_out_bd_cb; // BD |
| 118 | devcb_read8 | |
| 118 | devcb_read8 m_in_rl_cb; // kbd readlines RL0-7 | |
| 119 | 119 | devcb_read_line m_in_shift_cb; // Shift key |
| 120 | 120 | devcb_read_line m_in_ctrl_cb; // Ctrl-Strobe line |
| 121 | 121 |
| r31374 | r31375 | |
|---|---|---|
| 600 | 600 | public: |
| 601 | 601 | s3c44b0_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock); |
| 602 | 602 | ~s3c44b0_device() {} |
| 603 | ||
| 603 | ||
| 604 | 604 | 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); } |
| 605 | 605 | 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); } |
| 606 | 606 | 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); } |
| r31374 | r31375 | |
|---|---|---|
| 1 | 1 | /********************************************************************** |
| 2 | 2 | |
| 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 | |
| 5 | 5 | OKI MSC1937 is a clone of this chip, with many others. |
| 6 | 6 | |
| 7 | 7 | **********************************************************************/ |
| r31374 | r31375 | |
| 12 | 12 | |
| 13 | 13 | #define MCFG_ROC10937_ADD(_tag,_val) \ |
| 14 | 14 | MCFG_DEVICE_ADD(_tag, ROC10937,60)\ |
| 15 | MCFG_ROC10937_PORT(_val) | |
| 15 | MCFG_ROC10937_PORT(_val) | |
| 16 | 16 | |
| 17 | 17 | #define MCFG_ROC10937_PORT(_val) \ |
| 18 | 18 | roc10937_t::static_set_value(*device, _val); |
| r31374 | r31375 | |
| 21 | 21 | |
| 22 | 22 | #define MCFG_ROC10957_ADD(_tag,_val) \ |
| 23 | 23 | MCFG_DEVICE_ADD(_tag, ROC10957,60)\ |
| 24 | MCFG_ROC10957_PORT(_val) | |
| 25 | ||
| 24 | MCFG_ROC10957_PORT(_val) | |
| 25 | ||
| 26 | 26 | #define MCFG_ROC10957_PORT(_val) \ |
| 27 | 27 | roc10957_t::static_set_value(*device, _val); |
| 28 | 28 | #define MCFG_ROC10957_REMOVE(_tag) \ |
| r31374 | r31375 | |
| 30 | 30 | |
| 31 | 31 | #define MCFG_MSC1937_ADD(_tag,_val) \ |
| 32 | 32 | MCFG_DEVICE_ADD(_tag, ROC10937,60)\ |
| 33 | MCFG_MSC1937_PORT(_val) | |
| 34 | ||
| 33 | MCFG_MSC1937_PORT(_val) | |
| 34 | ||
| 35 | 35 | #define MCFG_MSC1937_PORT(_val) \ |
| 36 | 36 | MCFG_ROC10937_PORT(_val) |
| 37 | 37 | |
| r31374 | r31375 | |
| 40 | 40 | |
| 41 | 41 | #define MCFG_S16LF01_ADD(_tag,_val) \ |
| 42 | 42 | MCFG_DEVICE_ADD(_tag, S16LF01,60)\ |
| 43 | MCFG_S16LF01_PORT(_val) | |
| 43 | MCFG_S16LF01_PORT(_val) | |
| 44 | 44 | |
| 45 | 45 | #define MCFG_S16LF01_PORT(_val) \ |
| 46 | 46 | MCFG_ROC10937_PORT(_val) |
| r31374 | r31375 | |
|---|---|---|
| 92 | 92 | 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); } |
| 93 | 93 | 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); } |
| 94 | 94 | 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 | ||
| 96 | 96 | // I/O line access |
| 97 | 97 | int rdy(int which) { return m_port[which].rdy(); } |
| 98 | 98 | void strobe(int which, bool state) { m_port[which].strobe(state); } |
| r31374 | r31375 | |
| 206 | 206 | devcb_read8 m_in_pa_cb; |
| 207 | 207 | devcb_write8 m_out_pa_cb; |
| 208 | 208 | devcb_write_line m_out_ardy_cb; |
| 209 | ||
| 209 | ||
| 210 | 210 | devcb_read8 m_in_pb_cb; |
| 211 | 211 | devcb_write8 m_out_pb_cb; |
| 212 | 212 | devcb_write_line m_out_brdy_cb; |
| r31374 | r31375 | |
|---|---|---|
| 68 | 68 | 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); } |
| 69 | 69 | 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); } |
| 70 | 70 | 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 | ||
| 72 | 72 | /* Set an input pin */ |
| 73 | 73 | void set_input_pin( ay31015_input_pin_t pin, int data ); |
| 74 | 74 | |
| r31374 | r31375 | |
| 164 | 164 | |
| 165 | 165 | #define MCFG_AY31015_TX_CLOCK(_txclk) \ |
| 166 | 166 | ay31015_device::set_tx_clock(*device, _txclk); |
| 167 | ||
| 167 | ||
| 168 | 168 | #define MCFG_AY31015_RX_CLOCK(_rxclk) \ |
| 169 | 169 | ay31015_device::set_rx_clock(*device, _rxclk); |
| 170 | 170 | |
| r31374 | r31375 | |
| 175 | 175 | devcb = &ay31015_device::set_write_so_callback(*device, DEVCB_##_devcb); |
| 176 | 176 | |
| 177 | 177 | #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); | |
| 180 | 179 | |
| 180 | ||
| 181 | 181 | #define MCFG_AY51013_TX_CLOCK(_txclk) \ |
| 182 | 182 | ay51013_device::set_tx_clock(*device, _txclk); |
| 183 | ||
| 183 | ||
| 184 | 184 | #define MCFG_AY51013_RX_CLOCK(_rxclk) \ |
| 185 | 185 | ay51013_device::set_rx_clock(*device, _rxclk); |
| 186 | 186 | |
| r31374 | r31375 | |
| 191 | 191 | devcb = &ay51013_device::set_write_so_callback(*device, DEVCB_##_devcb); |
| 192 | 192 | |
| 193 | 193 | #define MCFG_AY51013_STATUS_CHANGED_CB(_devcb) \ |
| 194 | ||
| 194 | devcb = &ay51013_device::set_status_changed_callback(*device, DEVCB_##_devcb); | |
| 195 | 195 | |
| 196 | 196 | #endif |
| r31374 | r31375 | |
|---|---|---|
| 21 | 21 | |
| 22 | 22 | INPUT_PORTS_EXTERN( generic_terminal ); |
| 23 | 23 | |
| 24 | class generic_terminal_device : | |
| 24 | class generic_terminal_device : public device_t | |
| 25 | 25 | { |
| 26 | 26 | public: |
| 27 | 27 | 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); |
| 28 | 28 | generic_terminal_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock); |
| 29 | ||
| 29 | ||
| 30 | 30 | 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 | ||
| 32 | 32 | DECLARE_WRITE8_MEMBER(write) { term_write(data); } |
| 33 | 33 | DECLARE_WRITE8_MEMBER(kbd_put); |
| 34 | 34 | UINT32 update(screen_device &device, bitmap_rgb32 &bitmap, const rectangle &cliprect); |
| r31374 | r31375 | |
|---|---|---|
| 19 | 19 | |
| 20 | 20 | #define MCFG_S3C2410_CORE_PIN_R_CB(_devcb) \ |
| 21 | 21 | devcb = &s3c2410_device::set_core_pin_r_callback(*device, DEVCB_##_devcb); |
| 22 | ||
| 22 | ||
| 23 | 23 | #define MCFG_S3C2410_CORE_PIN_W_CB(_devcb) \ |
| 24 | 24 | devcb = &s3c2410_device::set_core_pin_w_callback(*device, DEVCB_##_devcb); |
| 25 | ||
| 25 | ||
| 26 | 26 | #define MCFG_S3C2410_GPIO_PORT_R_CB(_devcb) \ |
| 27 | 27 | devcb = &s3c2410_device::set_gpio_port_r_callback(*device, DEVCB_##_devcb); |
| 28 | ||
| 28 | ||
| 29 | 29 | #define MCFG_S3C2410_GPIO_PORT_W_CB(_devcb) \ |
| 30 | 30 | devcb = &s3c2410_device::set_gpio_port_w_callback(*device, DEVCB_##_devcb); |
| 31 | ||
| 31 | ||
| 32 | 32 | #define MCFG_S3C2410_I2C_SCL_W_CB(_devcb) \ |
| 33 | 33 | devcb = &s3c2410_device::set_i2c_scl_w_callback(*device, DEVCB_##_devcb); |
| 34 | 34 | |
| r31374 | r31375 | |
| 43 | 43 | |
| 44 | 44 | #define MCFG_S3C2410_I2S_DATA_W_CB(_devcb) \ |
| 45 | 45 | devcb = &s3c2410_device::set_i2s_data_w_callback(*device, DEVCB_##_devcb); |
| 46 | ||
| 46 | ||
| 47 | 47 | #define MCFG_S3C2410_NAND_COMMAND_W_CB(_devcb) \ |
| 48 | 48 | devcb = &s3c2410_device::set_nand_command_w_callback(*device, DEVCB_##_devcb); |
| 49 | 49 | |
| r31374 | r31375 | |
| 55 | 55 | |
| 56 | 56 | #define MCFG_S3C2410_NAND_DATA_W_CB(_devcb) \ |
| 57 | 57 | devcb = &s3c2410_device::set_nand_data_w_callback(*device, DEVCB_##_devcb); |
| 58 | ||
| 58 | ||
| 59 | 59 | #define MCFG_S3C2410_LCD_FLAGS(_flags) \ |
| 60 | 60 | s3c2410_device::set_lcd_flags(*device, _flags); |
| 61 | 61 |
| r31374 | r31375 | |
|---|---|---|
| 94 | 94 | 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); } |
| 95 | 95 | 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); } |
| 96 | 96 | 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 | ||
| 98 | 98 | static void set_rx_clock(device_t &device, int clock) { downcast<z80sti_device &>(device).m_rx_clock = clock; } |
| 99 | 99 | static void set_tx_clock(device_t &device, int clock) { downcast<z80sti_device &>(device).m_tx_clock = clock; } |
| 100 | 100 | |
| r31374 | r31375 | |
| 201 | 201 | void gpip_input(int bit, int state); |
| 202 | 202 | |
| 203 | 203 | // 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 | ||
| 213 | 213 | int m_rx_clock; // serial receive clock |
| 214 | 214 | int m_tx_clock; // serial transmit clock |
| 215 | 215 |
| r31374 | r31375 | |
|---|---|---|
| 79 | 79 | 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); } |
| 80 | 80 | 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); } |
| 81 | 81 | 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 | ||
| 83 | 83 | DECLARE_READ8_MEMBER( read ); |
| 84 | 84 | DECLARE_WRITE8_MEMBER( write ); |
| 85 | 85 | |
| r31374 | r31375 | |
| 125 | 125 | devcb_read8 m_in_pa_cb; |
| 126 | 126 | devcb_read8 m_in_pb_cb; |
| 127 | 127 | devcb_read8 m_in_pc_cb; |
| 128 | ||
| 128 | ||
| 129 | 129 | devcb_write8 m_out_pa_cb; |
| 130 | 130 | devcb_write8 m_out_pb_cb; |
| 131 | 131 | devcb_write8 m_out_pc_cb; |
| r31374 | r31375 | |
|---|---|---|
| 49 | 49 | 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); } |
| 50 | 50 | 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); } |
| 51 | 51 | 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 | ||
| 53 | 53 | DECLARE_READ8_MEMBER( read ); |
| 54 | 54 | DECLARE_WRITE8_MEMBER( write ); |
| 55 | 55 |
| r31374 | r31375 | |
|---|---|---|
| 40 | 40 | devcb = &kbdc8042_device::set_output_buffer_empty_callback(*device, DEVCB_##_devcb); |
| 41 | 41 | |
| 42 | 42 | #define MCFG_KBDC8042_SPEAKER_CB(_devcb) \ |
| 43 | ||
| 43 | devcb = &kbdc8042_device::set_speaker_callback(*device, DEVCB_##_devcb); | |
| 44 | 44 | |
| 45 | 45 | //************************************************************************** |
| 46 | 46 | // TYPE DEFINITIONS |
| r31374 | r31375 | |
| 55 | 55 | kbdc8042_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock); |
| 56 | 56 | |
| 57 | 57 | virtual machine_config_constructor device_mconfig_additions() const; |
| 58 | ||
| 58 | ||
| 59 | 59 | static void set_keyboard_type(device_t &device, kbdc8042_type_t keybtype) { downcast<kbdc8042_device &>(device).m_keybtype = keybtype; } |
| 60 | 60 | 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); } |
| 61 | 61 | 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); } |
| r31374 | r31375 | |
| 109 | 109 | required_device<at_keyboard_device> m_keyboard_dev; |
| 110 | 110 | |
| 111 | 111 | kbdc8042_type_t m_keybtype; |
| 112 | ||
| 112 | ||
| 113 | 113 | devcb_write_line m_system_reset_cb; |
| 114 | 114 | devcb_write_line m_gate_a20_cb; |
| 115 | 115 | devcb_write_line m_input_buffer_full_cb; |
| r31374 | r31375 | |
|---|---|---|
| 22 | 22 | static void set_irq_callback(device_t &device, lsi53c810_irq_delegate callback) { downcast<lsi53c810_device &>(device).m_irq_cb = callback; } |
| 23 | 23 | static void set_dma_callback(device_t &device, lsi53c810_dma_delegate callback) { downcast<lsi53c810_device &>(device).m_dma_cb = callback; } |
| 24 | 24 | static void set_fetch_callback(device_t &device, lsi53c810_fetch_delegate callback) { downcast<lsi53c810_device &>(device).m_fetch_cb = callback; } |
| 25 | ||
| 25 | ||
| 26 | 26 | void lsi53c810_read_data(int bytes, UINT8 *pData); |
| 27 | 27 | void lsi53c810_write_data(int bytes, UINT8 *pData); |
| 28 | 28 |
| r31374 | r31375 | |
|---|---|---|
| 18 | 18 | { |
| 19 | 19 | public: |
| 20 | 20 | 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 | ||
| 22 | 22 | 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); } |
| 23 | 23 | 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); } |
| 24 | 24 | 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); } |
| 25 | 25 | 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); } |
| 26 | 26 | 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); } |
| 27 | 27 | 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 | ||
| 29 | 29 | DECLARE_WRITE8_MEMBER( ins8250_w ); |
| 30 | 30 | DECLARE_READ8_MEMBER( ins8250_r ); |
| 31 | 31 | DECLARE_WRITE_LINE_MEMBER( dcd_w ); |
| r31374 | r31375 | |
|---|---|---|
| 87 | 87 | 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); } |
| 88 | 88 | 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); } |
| 89 | 89 | 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 | ||
| 91 | 91 | DECLARE_READ8_MEMBER( read ); |
| 92 | 92 | DECLARE_WRITE8_MEMBER( write ); |
| 93 | 93 |
| r31374 | r31375 | |
|---|---|---|
| 100 | 100 | dev.m_burst_clock[2] = clk3; |
| 101 | 101 | dev.m_burst_clock[3] = clk4; |
| 102 | 102 | } |
| 103 | ||
| 103 | ||
| 104 | 104 | DECLARE_READ16_MEMBER( read ); |
| 105 | 105 | DECLARE_WRITE16_MEMBER( write ); |
| 106 | 106 | DECLARE_WRITE_LINE_MEMBER(drq0_w); |
| r31374 | r31375 | |
| 133 | 133 | const char *m_cpu_tag; |
| 134 | 134 | attotime m_our_clock[4]; |
| 135 | 135 | attotime m_burst_clock[4]; |
| 136 | ||
| 136 | ||
| 137 | 137 | // internal state |
| 138 | 138 | hd63450_regs m_reg[4]; |
| 139 | 139 | emu_timer* m_timer[4]; // for timing data reading/writing each channel |
| r31374 | r31375 | |
|---|---|---|
| 405 | 405 | // Put drive into prep mode command (0x11) |
| 406 | 406 | // |
| 407 | 407 | 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 | |
| 411 | 411 | } prep_mode_command; |
| 412 | 412 | // |
| 413 | 413 | // Read Firmware command (Prep Mode 0x32) |
| r31374 | r31375 | |
| 439 | 439 | // |
| 440 | 440 | // Verify Drive command (Prep Mode 0x07) |
| 441 | 441 | // |
| 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 | |
| 445 | 445 | // return a count of 0. That makes this a fixed length response of 2 bytes. |
| 446 | 446 | // |
| 447 | 447 | struct { |
| 448 | 448 | UINT8 status; // Disk access status |
| 449 | 449 | UINT8 bad_sectors; // Number of bad sectors (always zero) |
| 450 | } verify_drive_response; | |
| 450 | } verify_drive_response; | |
| 451 | 451 | } m_buffer; |
| 452 | 452 | |
| 453 | 453 | // Structure of Block #1, the Disk Parameter Block |
| r31374 | r31375 | |
|---|---|---|
| 1 | 1 | /*************************************************************************** |
| 2 | 2 | |
| 3 | ||
| 3 | CR-511-B CD-ROM drive | |
| 4 | 4 | |
| 5 | 5 | license: MAME, GPL-2.0+ |
| 6 | 6 | copyright-holders: Dirk Best |
| 7 | 7 | |
| 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. | |
| 10 | 10 | |
| 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 | |
| 31 | 31 | |
| 32 | 32 | ***************************************************************************/ |
| 33 | 33 | |
| r31374 | r31375 | |
| 46 | 46 | //************************************************************************** |
| 47 | 47 | |
| 48 | 48 | #define MCFG_CR511B_ADD(_tag) \ |
| 49 | MCFG_DEVICE_ADD(_tag, CR511B, 0) \ | |
| 50 | ||
| 49 | MCFG_DEVICE_ADD(_tag, CR511B, 0) | |
| 51 | 50 | #define MCFG_CR511B_STCH_HANDLER(_devcb) \ |
| 52 | 51 | devcb = &cr511b_device::set_stch_handler(*device, DEVCB_##_devcb); |
| 53 | 52 |
| r31374 | r31375 | |
|---|---|---|
| 1 | 1 | /********************************************************************* |
| 2 | 2 | |
| 3 | ||
| 3 | !!! DEPRECATED, USE src/emu/wd_fdc.h FOR NEW DRIVERS !!! | |
| 4 | 4 | |
| 5 | 5 | wd17xx.h |
| 6 | 6 | |
| r31374 | r31375 | |
| 54 | 54 | 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); } |
| 55 | 55 | 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); } |
| 56 | 56 | 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 | ||
| 58 | 58 | static void set_drive_tags(device_t &device, const char *tag1, const char *tag2, const char *tag3, const char *tag4) |
| 59 | 59 | { |
| 60 | 60 | wd1770_device &dev = downcast<wd1770_device &>(device); |
| r31374 | r31375 | |
| 63 | 63 | dev.m_floppy_drive_tags[2] = tag3; |
| 64 | 64 | dev.m_floppy_drive_tags[3] = tag4; |
| 65 | 65 | } |
| 66 | ||
| 66 | ||
| 67 | 67 | /* the following are not strictly part of the wd179x hardware/emulation |
| 68 | 68 | but will be put here for now until the flopdrv code has been finalised more */ |
| 69 | 69 | void set_drive(UINT8); /* set drive wd179x is accessing */ |
| r31374 | r31375 | |
| 130 | 130 | devcb_write_line m_out_intrq_func; |
| 131 | 131 | devcb_write_line m_out_drq_func; |
| 132 | 132 | devcb_read_line m_in_dden_func; |
| 133 | ||
| 133 | ||
| 134 | 134 | const char *m_floppy_drive_tags[4]; |
| 135 | 135 | |
| 136 | 136 | /* input lines */ |
| r31374 | r31375 | |
|---|---|---|
| 73 | 73 | 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); } |
| 74 | 74 | 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); } |
| 75 | 75 | 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 | ||
| 77 | 77 | DECLARE_READ8_MEMBER( read ); |
| 78 | 78 | DECLARE_WRITE8_MEMBER( write ); |
| 79 | 79 |
| r31374 | r31375 | |
|---|---|---|
| 50 | 50 | 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); } |
| 51 | 51 | 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); } |
| 52 | 52 | 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 | ||
| 54 | 54 | DECLARE_READ8_MEMBER( read ); |
| 55 | 55 | DECLARE_WRITE8_MEMBER( write ); |
| 56 | 56 | |
| r31374 | r31375 | |
| 75 | 75 | UINT8 m_in; |
| 76 | 76 | UINT8 m_out; |
| 77 | 77 | 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; | |
| 80 | 80 | }; |
| 81 | 81 | |
| 82 | 82 | // device-level overrides |
| r31374 | r31375 | |
| 100 | 100 | devcb_read8 m_in_pb_cb; |
| 101 | 101 | devcb_write8 m_out_pb_cb; |
| 102 | 102 | devcb_write_line m_irq_cb; |
| 103 | ||
| 103 | ||
| 104 | 104 | UINT8 m_irqstate; |
| 105 | 105 | UINT8 m_irqenable; |
| 106 | 106 | int m_irq; |
| r31374 | r31375 | |
|---|---|---|
| 89 | 89 | |
| 90 | 90 | |
| 91 | 91 | #endif |
| 92 |
| r31374 | r31375 | |
|---|---|---|
| 65 | 65 | 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); } |
| 66 | 66 | 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); } |
| 67 | 67 | 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 | ||
| 69 | 69 | // read/write handlers |
| 70 | 70 | DECLARE_READ8_MEMBER( read ); |
| 71 | 71 | DECLARE_WRITE8_MEMBER( write ); |
| r31374 | r31375 | |
| 124 | 124 | devcb_write_line m_zc1_cb; // channel 1 zero crossing callbacks |
| 125 | 125 | devcb_write_line m_zc2_cb; // channel 2 zero crossing callbacks |
| 126 | 126 | devcb_write_line m_zc3_cb; // channel 3 zero crossing callbacks = NULL ? |
| 127 | ||
| 127 | ||
| 128 | 128 | UINT8 m_vector; // interrupt vector |
| 129 | 129 | attotime m_period16; // 16/system clock |
| 130 | 130 | attotime m_period256; // 256/system clock |
| r31374 | r31375 | |
|---|---|---|
| 53 | 53 | 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); } |
| 54 | 54 | 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); } |
| 55 | 55 | 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 | ||
| 57 | 57 | // internal 8042 interface |
| 58 | 58 | DECLARE_READ8_MEMBER( t0_r ); |
| 59 | 59 | DECLARE_READ8_MEMBER( t1_r ); |
| r31374 | r31375 | |
| 78 | 78 | |
| 79 | 79 | virtual const rom_entry *device_rom_region() const; |
| 80 | 80 | virtual machine_config_constructor device_mconfig_additions() const; |
| 81 | ||
| 81 | ||
| 82 | 82 | private: |
| 83 | 83 | // internal state |
| 84 | 84 | upi41_cpu_device *m_cpu; |
| r31374 | r31375 | |
|---|---|---|
| 79 | 79 | // internal state |
| 80 | 80 | devcb_read8 m_in_pa_cb; |
| 81 | 81 | devcb_write8 m_out_pa_cb; |
| 82 | ||
| 82 | ||
| 83 | 83 | devcb_read8 m_in_pb_cb; |
| 84 | 84 | devcb_write8 m_out_pb_cb; |
| 85 | ||
| 85 | ||
| 86 | 86 | mos6530_port m_port[2]; |
| 87 | 87 | |
| 88 | 88 | UINT8 m_irqstate; |
| r31374 | r31375 | |
|---|---|---|
| 113 | 113 | devcb_read8 m_in_a_pa_cb; |
| 114 | 114 | devcb_read8 m_in_a_pb_cb; |
| 115 | 115 | devcb_read8 m_in_a_pc_cb; |
| 116 | ||
| 116 | ||
| 117 | 117 | devcb_write8 m_out_a_pa_cb; |
| 118 | 118 | devcb_write8 m_out_a_pb_cb; |
| 119 | 119 | devcb_write8 m_out_a_pc_cb; |
| r31374 | r31375 | |
| 121 | 121 | devcb_read8 m_in_b_pa_cb; |
| 122 | 122 | devcb_read8 m_in_b_pb_cb; |
| 123 | 123 | devcb_read8 m_in_b_pc_cb; |
| 124 | ||
| 124 | ||
| 125 | 125 | devcb_write8 m_out_b_pa_cb; |
| 126 | 126 | devcb_write8 m_out_b_pb_cb; |
| 127 | 127 | devcb_write8 m_out_b_pc_cb; |
| r31374 | r31375 | |
|---|---|---|
| 45 | 45 | 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); } |
| 46 | 46 | template<class _Object> static devcb_base &set_inport_cb(device_t &device, _Object object) { return downcast<m68307cpu_device &>(device).read_inport.set_callback(object); } |
| 47 | 47 | 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 | ||
| 49 | 49 | DECLARE_WRITE_LINE_MEMBER(m68307_duart_irq_handler); |
| 50 | 50 | DECLARE_WRITE_LINE_MEMBER(m68307_duart_txa){ write_a_tx(state); } |
| 51 | 51 | DECLARE_WRITE_LINE_MEMBER(m68307_duart_txb){ write_b_tx(state); } |
| r31374 | r31375 | |
| 69 | 69 | /* 68307 peripheral modules */ |
| 70 | 70 | m68307_sim* m68307SIM; |
| 71 | 71 | m68307_mbus* m68307MBUS; |
| 72 | // | |
| 72 | // m68307_serial* m68307SERIAL; | |
| 73 | 73 | m68307_timer* m68307TIMER; |
| 74 | 74 | |
| 75 | 75 | UINT16 m68307_base; |
| r31374 | r31375 | |
| 94 | 94 | /* callbacks for internal ports */ |
| 95 | 95 | 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); |
| 96 | 96 | void set_interrupt(int level, int vector); |
| 97 | UINT16 get_cs(offs_t address); | |
| 97 | UINT16 get_cs(offs_t address); | |
| 98 | 98 | void timer0_interrupt(); |
| 99 | 99 | void timer1_interrupt(); |
| 100 | 100 | void serial_interrupt(int vector); |
| r31374 | r31375 | |
|---|---|---|
| 50 | 50 | |
| 51 | 51 | #define MCFG_MB89352A_IRQ_CB(_devcb) \ |
| 52 | 52 | devcb = &mb89352_device::set_irq_callback(*device, DEVCB_##_devcb); |
| 53 | ||
| 53 | ||
| 54 | 54 | #define MCFG_MB89352A_DRQ_CB(_devcb) \ |
| 55 | 55 | devcb = &mb89352_device::set_drq_callback(*device, DEVCB_##_devcb); |
| 56 | 56 | |
| r31374 | r31375 | |
| 62 | 62 | |
| 63 | 63 | 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); } |
| 64 | 64 | 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 | ||
| 66 | 66 | // any publically accessible interfaces needed for runtime |
| 67 | 67 | DECLARE_READ8_MEMBER( mb89352_r ); |
| 68 | 68 | DECLARE_WRITE8_MEMBER( mb89352_w ); |
| r31374 | r31375 | |
|---|---|---|
| 17 | 17 | |
| 18 | 18 | #define MCFG_DP8390D_MEM_WRITE_CB(_devcb) \ |
| 19 | 19 | devcb = &dp8390d_device::set_mem_write_callback(*device, DEVCB_##_devcb); |
| 20 | ||
| 20 | ||
| 21 | 21 | #define MCFG_RTL8019A_IRQ_CB(_devcb) \ |
| 22 | 22 | devcb = &rtl8019a_device::set_irq_callback(*device, DEVCB_##_devcb); |
| 23 | 23 | |
| r31374 | r31375 | |
| 37 | 37 | public: |
| 38 | 38 | // construction/destruction |
| 39 | 39 | 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 | ||
| 41 | 41 | 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); } |
| 42 | 42 | 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); } |
| 43 | 43 | 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); } |
| r31374 | r31375 | |
|---|---|---|
| 485 | 485 | 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); } |
| 486 | 486 | 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); } |
| 487 | 487 | 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); } | |
| 489 | 489 | 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 | ||
| 492 | 492 | static void configure_channels(device_t &device, int rxa, int txa, int rxb, int txb) |
| 493 | 493 | { |
| 494 | 494 | z80dart_device &dev = downcast<z80dart_device &>(device); |
| r31374 | r31375 | |
| 497 | 497 | dev.m_rxcb = rxb; |
| 498 | 498 | dev.m_txcb = txb; |
| 499 | 499 | } |
| 500 | ||
| 500 | ||
| 501 | 501 | DECLARE_READ8_MEMBER( cd_ba_r ); |
| 502 | 502 | DECLARE_WRITE8_MEMBER( cd_ba_w ); |
| 503 | 503 | DECLARE_READ8_MEMBER( ba_cd_r ); |
| r31374 | r31375 | |
| 565 | 565 | int m_txca; |
| 566 | 566 | int m_rxcb; |
| 567 | 567 | int m_txcb; |
| 568 | ||
| 568 | ||
| 569 | 569 | devcb_write_line m_out_txda_cb; |
| 570 | 570 | devcb_write_line m_out_dtra_cb; |
| 571 | 571 | devcb_write_line m_out_rtsa_cb; |
| 572 | 572 | devcb_write_line m_out_wrdya_cb; |
| 573 | 573 | devcb_write_line m_out_synca_cb; |
| 574 | ||
| 574 | ||
| 575 | 575 | devcb_write_line m_out_txdb_cb; |
| 576 | 576 | devcb_write_line m_out_dtrb_cb; |
| 577 | 577 | devcb_write_line m_out_rtsb_cb; |
| 578 | 578 | devcb_write_line m_out_wrdyb_cb; |
| 579 | 579 | devcb_write_line m_out_syncb_cb; |
| 580 | ||
| 580 | ||
| 581 | 581 | devcb_write_line m_out_int_cb; |
| 582 | 582 | devcb_write_line m_out_rxdrqa_cb; |
| 583 | 583 | devcb_write_line m_out_txdrqa_cb; |
| r31374 | r31375 | |
|---|---|---|
| 1 | 1 | /*************************************************************************** |
| 2 | 2 | |
| 3 | ||
| 3 | Akiko | |
| 4 | 4 | |
| 5 | ||
| 5 | Used in the Amiga CD32 | |
| 6 | 6 | |
| 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 | |
| 10 | 10 | |
| 11 | 11 | ***************************************************************************/ |
| 12 | 12 | |
| r31374 | r31375 | |
| 74 | 74 | virtual machine_config_constructor device_mconfig_additions() const; |
| 75 | 75 | |
| 76 | 76 | private: |
| 77 | ||
| 77 | // 1X CDROM sector time in msec (300KBps) | |
| 78 | 78 | static const int CD_SECTOR_TIME = (1000/((150*1024)/2048)); |
| 79 | 79 | |
| 80 | 80 | // internal state |
| r31374 | r31375 | |
|---|---|---|
| 20 | 20 | |
| 21 | 21 | #define MCFG_AAKART_OUT_RX_CB(_devcb) \ |
| 22 | 22 | devcb = &aakart_device::set_out_rx_callback(*device, DEVCB_##_devcb); |
| 23 | ||
| 24 | 23 | |
| 24 | ||
| 25 | 25 | enum{ |
| 26 | 26 | STATUS_NORMAL = 0, |
| 27 | 27 | STATUS_KEYUP, |
| r31374 | r31375 | |
| 42 | 42 | public: |
| 43 | 43 | // construction/destruction |
| 44 | 44 | aakart_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock); |
| 45 | ||
| 45 | ||
| 46 | 46 | 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); } |
| 47 | 47 | 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); } |
| 48 | 48 | |
| 49 | 49 | // I/O operations |
| 50 | 50 | DECLARE_WRITE8_MEMBER( write ); |
| 51 | 51 | 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); | |
| 54 | 54 | protected: |
| 55 | 55 | // device-level overrides |
| 56 | 56 | virtual void device_validity_check(validity_checker &valid) const; |
| r31374 | r31375 | |
| 77 | 77 | UINT8 m_status; |
| 78 | 78 | UINT8 m_mouse_enable; |
| 79 | 79 | 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; | |
| 83 | 83 | |
| 84 | 84 | }; |
| 85 | 85 |
| r31374 | r31375 | |
|---|---|---|
| 79 | 79 | 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); } |
| 80 | 80 | 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); } |
| 81 | 81 | 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 | ||
| 83 | 83 | DECLARE_READ8_MEMBER( io_r ); |
| 84 | 84 | DECLARE_WRITE8_MEMBER( io_w ); |
| 85 | 85 |
| r31374 | r31375 | |
|---|---|---|
| 48 | 48 | { |
| 49 | 49 | public: |
| 50 | 50 | tms9902_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock); |
| 51 | ||
| 51 | ||
| 52 | 52 | 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); } |
| 53 | 53 | 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); } |
| 54 | 54 | 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); } |
| 55 | 55 | 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 | ||
| 57 | 57 | void set_clock(bool state); |
| 58 | 58 | |
| 59 | 59 | void rcv_cts(line_state state); |
| r31374 | r31375 | |
|---|---|---|
| 59 | 59 | // X24c44 16 bit ram/eeprom combo |
| 60 | 60 | #define MCFG_EEPROM_SERIAL_X24C44_ADD(_tag) \ |
| 61 | 61 | MCFG_DEVICE_ADD(_tag, EEPROM_SERIAL_X24C44_16BIT, 0) |
| 62 | ||
| 62 | ||
| 63 | 63 | // optional enable for streaming reads |
| 64 | 64 | #define MCFG_EEPROM_SERIAL_ENABLE_STREAMING() \ |
| 65 | 65 | eeprom_serial_base_device::static_enable_streaming(*device); |
| r31374 | r31375 | |
| 144 | 144 | virtual void handle_event(eeprom_event event); |
| 145 | 145 | virtual void parse_command_and_address() = 0; |
| 146 | 146 | virtual void execute_command(); |
| 147 | ||
| 148 | 147 | |
| 148 | ||
| 149 | 149 | // configuration state |
| 150 | 150 | UINT8 m_command_address_bits; // number of address bits in a command |
| 151 | 151 | bool m_streaming_enabled; // true if streaming is enabled |
| r31374 | r31375 | |
| 219 | 219 | class eeprom_serial_x24c44_device : public eeprom_serial_base_device |
| 220 | 220 | { |
| 221 | 221 | //async recall not implemented |
| 222 | //async store not implemented | |
| 222 | //async store not implemented | |
| 223 | 223 | protected: |
| 224 | 224 | // construction/destruction |
| 225 | 225 | 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); |
| r31374 | r31375 | |
| 227 | 227 | public: |
| 228 | 228 | // read handlers |
| 229 | 229 | DECLARE_READ_LINE_MEMBER(do_read); // DO |
| 230 | ||
| 230 | ||
| 231 | 231 | // write handlers |
| 232 | 232 | DECLARE_WRITE_LINE_MEMBER(cs_write); // CS signal (active high) |
| 233 | 233 | DECLARE_WRITE_LINE_MEMBER(clk_write); // CLK signal (active high) |
| r31374 | r31375 | |
| 283 | 283 | DECLARE_SERIAL_EEPROM_DEVICE(er5911, er5911, ER5911, 8) |
| 284 | 284 | DECLARE_SERIAL_EEPROM_DEVICE(er5911, er5911, ER5911, 16) |
| 285 | 285 | |
| 286 | // X24c44 8 bit 32byte ram/eeprom combo | |
| 286 | // X24c44 8 bit 32byte ram/eeprom combo | |
| 287 | 287 | DECLARE_SERIAL_EEPROM_DEVICE(x24c44, x24c44, X24C44, 16) |
| 288 | 288 | #endif |
| r31374 | r31375 | |
|---|---|---|
| 1 | 1 | /*************************************************************************** |
| 2 | 2 | |
| 3 | ||
| 3 | GAYLE | |
| 4 | 4 | |
| 5 | 5 | license: MAME, GPL-2.0+ |
| 6 | 6 | copyright-holders: Dirk Best |
| 7 | 7 | |
| 8 | ||
| 8 | Gate array used in the Amiga 600 and Amiga 1200 computers. | |
| 9 | 9 | |
| 10 | 10 | ***************************************************************************/ |
| 11 | 11 | |
| r31374 | r31375 | |
| 87 | 87 | private: |
| 88 | 88 | enum |
| 89 | 89 | { |
| 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 | |
| 94 | 94 | }; |
| 95 | 95 | |
| 96 | 96 | devcb_write_line m_int2_w; |
| r31374 | r31375 | |
|---|---|---|
| 18 | 18 | |
| 19 | 19 | #define MCFG_S3C2440_CORE_PIN_R_CB(_devcb) \ |
| 20 | 20 | devcb = &s3c2440_device::set_core_pin_r_callback(*device, DEVCB_##_devcb); |
| 21 | ||
| 21 | ||
| 22 | 22 | #define MCFG_S3C2440_CORE_PIN_W_CB(_devcb) \ |
| 23 | 23 | devcb = &s3c2440_device::set_core_pin_w_callback(*device, DEVCB_##_devcb); |
| 24 | ||
| 24 | ||
| 25 | 25 | #define MCFG_S3C2440_GPIO_PORT_R_CB(_devcb) \ |
| 26 | 26 | devcb = &s3c2440_device::set_gpio_port_r_callback(*device, DEVCB_##_devcb); |
| 27 | ||
| 27 | ||
| 28 | 28 | #define MCFG_S3C2440_GPIO_PORT_W_CB(_devcb) \ |
| 29 | 29 | devcb = &s3c2440_device::set_gpio_port_w_callback(*device, DEVCB_##_devcb); |
| 30 | ||
| 30 | ||
| 31 | 31 | #define MCFG_S3C2440_I2C_SCL_W_CB(_devcb) \ |
| 32 | 32 | devcb = &s3c2440_device::set_i2c_scl_w_callback(*device, DEVCB_##_devcb); |
| 33 | 33 | |
| r31374 | r31375 | |
| 54 | 54 | |
| 55 | 55 | #define MCFG_S3C2440_NAND_DATA_W_CB(_devcb) \ |
| 56 | 56 | devcb = &s3c2440_device::set_nand_data_w_callback(*device, DEVCB_##_devcb); |
| 57 | ||
| 57 | ||
| 58 | 58 | #define MCFG_S3C2440_LCD_FLAGS(_flags) \ |
| 59 | 59 | s3c2440_device::set_lcd_flags(*device, _flags); |
| 60 | 60 |
| r31374 | r31375 | |
|---|---|---|
| 49 | 49 | int m_data_out; |
| 50 | 50 | int m_adc_data; |
| 51 | 51 | int m_sars; |
| 52 | ||
| 52 | ||
| 53 | 53 | int m_gticlub_hack; |
| 54 | 54 | adc1038_input_delegate m_input_cb; |
| 55 | 55 | }; |
| r31374 | r31375 | |
|---|---|---|
| 17 | 17 | |
| 18 | 18 | #define MCFG_NCR539X_OUT_IRQ_CB(_devcb) \ |
| 19 | 19 | devcb = &ncr539x_device::set_out_irq_callback(*device, DEVCB_##_devcb); |
| 20 | ||
| 20 | ||
| 21 | 21 | #define MCFG_NCR539X_OUT_DRQ_CB(_devcb) \ |
| 22 | 22 | devcb = &ncr539x_device::set_out_drq_callback(*device, DEVCB_##_devcb); |
| 23 | ||
| 23 | ||
| 24 | 24 | class ncr539x_device : public legacy_scsi_host_adapter |
| 25 | 25 | { |
| 26 | 26 | public: |
| 27 | 27 | // construction/destruction |
| 28 | 28 | ncr539x_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock); |
| 29 | ||
| 29 | ||
| 30 | 30 | 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); } |
| 31 | 31 | 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); } |
| 32 | 32 |
| r31374 | r31375 | |
|---|---|---|
| 16 | 16 | |
| 17 | 17 | INPUT_PORTS_EXTERN( generic_keyboard ); |
| 18 | 18 | |
| 19 | class generic_keyboard_device : | |
| 19 | class generic_keyboard_device : public device_t | |
| 20 | 20 | { |
| 21 | 21 | public: |
| 22 | 22 | 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); |
| 23 | 23 | generic_keyboard_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock); |
| 24 | ||
| 24 | ||
| 25 | 25 | 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); } |
| 26 | 26 | |
| 27 | 27 | virtual ioport_constructor device_input_ports() const; |
| r31374 | r31375 | |
|---|---|---|
| 32 | 32 | dev.m_x_offset = x_offset; |
| 33 | 33 | dev.m_y_offset = y_offset; |
| 34 | 34 | } |
| 35 | ||
| 35 | ||
| 36 | 36 | // returns a BITMAP_FORMAT_IND16 bitmap the size of the screen |
| 37 | 37 | // D0-D2 of each pixel is the pixel color |
| 38 | 38 | // D3 indicates whether the S2636 drew this pixel - 0 = not drawn, 1 = drawn |
| r31374 | r31375 | |
| 65 | 65 | int m_work_ram_size; |
| 66 | 66 | int m_y_offset; |
| 67 | 67 | int m_x_offset; |
| 68 | ||
| 68 | ||
| 69 | 69 | int check_collision( int spriteno1, int spriteno2, const rectangle &cliprect ); |
| 70 | 70 | }; |
| 71 | 71 |
| r31374 | r31375 | |
|---|---|---|
| 1 | 1 | /*************************************************************************** |
| 2 | 2 | |
| 3 | ||
| 3 | Amiga Autoconfig | |
| 4 | 4 | |
| 5 | 5 | ***************************************************************************/ |
| 6 | 6 |
| r31374 | r31375 | |
|---|---|---|
| 137 | 137 | int m_b; // output buffer |
| 138 | 138 | int m_ako; // any key down |
| 139 | 139 | |
| 140 | int m_x_mask[9]; | |
| 140 | int m_x_mask[9]; // mask of what keys are down | |
| 141 | 141 | |
| 142 | 142 | // timers |
| 143 | 143 | emu_timer *m_scan_timer; // keyboard scan timer |
| r31374 | r31375 | |
|---|---|---|
| 49 | 49 | |
| 50 | 50 | #define MCFG_ADC0808_IN_VREF_POS_CB(_class, _method) \ |
| 51 | 51 | adc0808_device::set_in_vref_pos_callback(*device, adc0808_analog_read_delegate(&_class::_method, #_class "::" #_method, downcast<_class *>(owner))); |
| 52 | ||
| 52 | ||
| 53 | 53 | #define MCFG_ADC0808_IN_VREF_NEG_CB(_class, _method) \ |
| 54 | 54 | adc0808_device::set_in_vref_neg_callback(*device, adc0808_analog_read_delegate(&_class::_method, #_class "::" #_method, downcast<_class *>(owner))); |
| 55 | ||
| 55 | ||
| 56 | 56 | #define MCFG_ADC0808_IN_IN_0_CB(_class, _method) \ |
| 57 | 57 | adc0808_device::set_in_in_0_callback(*device, adc0808_analog_read_delegate(&_class::_method, #_class "::" #_method, downcast<_class *>(owner))); |
| 58 | ||
| 58 | ||
| 59 | 59 | #define MCFG_ADC0808_IN_IN_1_CB(_class, _method) \ |
| 60 | 60 | adc0808_device::set_in_in_1_callback(*device, adc0808_analog_read_delegate(&_class::_method, #_class "::" #_method, downcast<_class *>(owner))); |
| 61 | ||
| 61 | ||
| 62 | 62 | #define MCFG_ADC0808_IN_IN_2_CB(_class, _method) \ |
| 63 | 63 | adc0808_device::set_in_in_2_callback(*device, adc0808_analog_read_delegate(&_class::_method, #_class "::" #_method, downcast<_class *>(owner))); |
| 64 | ||
| 64 | ||
| 65 | 65 | #define MCFG_ADC0808_IN_IN_3_CB(_class, _method) \ |
| 66 | 66 | adc0808_device::set_in_in_3_callback(*device, adc0808_analog_read_delegate(&_class::_method, #_class "::" #_method, downcast<_class *>(owner))); |
| 67 | ||
| 67 | ||
| 68 | 68 | #define MCFG_ADC0808_IN_IN_4_CB(_class, _method) \ |
| 69 | 69 | adc0808_device::set_in_in_4_callback(*device, adc0808_analog_read_delegate(&_class::_method, #_class "::" #_method, downcast<_class *>(owner))); |
| 70 | ||
| 70 | ||
| 71 | 71 | #define MCFG_ADC0808_IN_IN_5_CB(_class, _method) \ |
| 72 | 72 | adc0808_device::set_in_in_5_callback(*device, adc0808_analog_read_delegate(&_class::_method, #_class "::" #_method, downcast<_class *>(owner))); |
| 73 | 73 | |
| 74 | 74 | #define MCFG_ADC0808_IN_IN_6_CB(_class, _method) \ |
| 75 | 75 | adc0808_device::set_in_in_6_callback(*device, adc0808_analog_read_delegate(&_class::_method, #_class "::" #_method, downcast<_class *>(owner))); |
| 76 | ||
| 76 | ||
| 77 | 77 | #define MCFG_ADC0808_IN_IN_7_CB(_class, _method) \ |
| 78 | 78 | adc0808_device::set_in_in_7_callback(*device, adc0808_analog_read_delegate(&_class::_method, #_class "::" #_method, downcast<_class *>(owner))); |
| 79 | ||
| 79 | ||
| 80 | 80 | // ======================> adc0808_device |
| 81 | 81 | |
| 82 | 82 | class adc0808_device : public device_t |
| r31374 | r31375 | |
| 84 | 84 | public: |
| 85 | 85 | // construction/destruction |
| 86 | 86 | adc0808_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock); |
| 87 | ||
| 87 | ||
| 88 | 88 | 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); } |
| 89 | 89 | 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; } |
| 90 | 90 | 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; } |
| r31374 | r31375 | |
|---|---|---|
| 49 | 49 | // construction/destruction |
| 50 | 50 | ptm6840_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock); |
| 51 | 51 | |
| 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; } | |
| 53 | 53 | 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; } |
| 54 | 54 | 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); } |
| 55 | 55 | 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); } |
| 56 | 56 | 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); } |
| 57 | 57 | 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 | ||
| 59 | 59 | int status(int clock) const { return m_enabled[clock]; } // get whether timer is enabled |
| 60 | 60 | int irq_state() const { return m_IRQ; } // get IRQ state |
| 61 | 61 | UINT16 count(int counter) const { return compute_counter(counter); } // get counter value |
| r31374 | r31375 | |
|---|---|---|
| 19 | 19 | |
| 20 | 20 | #define MCFG_S3C2400_CORE_PIN_R_CB(_devcb) \ |
| 21 | 21 | devcb = &s3c2400_device::set_core_pin_r_callback(*device, DEVCB_##_devcb); |
| 22 | ||
| 22 | ||
| 23 | 23 | #define MCFG_S3C2400_CORE_PIN_W_CB(_devcb) \ |
| 24 | 24 | devcb = &s3c2400_device::set_core_pin_w_callback(*device, DEVCB_##_devcb); |
| 25 | ||
| 25 | ||
| 26 | 26 | #define MCFG_S3C2400_GPIO_PORT_R_CB(_devcb) \ |
| 27 | 27 | devcb = &s3c2400_device::set_gpio_port_r_callback(*device, DEVCB_##_devcb); |
| 28 | ||
| 28 | ||
| 29 | 29 | #define MCFG_S3C2400_GPIO_PORT_W_CB(_devcb) \ |
| 30 | 30 | devcb = &s3c2400_device::set_gpio_port_w_callback(*device, DEVCB_##_devcb); |
| 31 | ||
| 31 | ||
| 32 | 32 | #define MCFG_S3C2400_I2C_SCL_W_CB(_devcb) \ |
| 33 | 33 | devcb = &s3c2400_device::set_i2c_scl_w_callback(*device, DEVCB_##_devcb); |
| 34 | 34 | |
| r31374 | r31375 | |
| 43 | 43 | |
| 44 | 44 | #define MCFG_S3C2400_I2S_DATA_W_CB(_devcb) \ |
| 45 | 45 | devcb = &s3c2400_device::set_i2s_data_w_callback(*device, DEVCB_##_devcb); |
| 46 | ||
| 46 | ||
| 47 | 47 | #define MCFG_S3C2400_LCD_FLAGS(_flags) \ |
| 48 | 48 | s3c2400_device::set_lcd_flags(*device, _flags); |
| 49 | 49 |
| r31374 | r31375 | |
|---|---|---|
| 40 | 40 | ATTR_HOT friend inline bool operator<(const netlist_time &left, const netlist_time &right); |
| 41 | 41 | ATTR_HOT friend inline bool operator>=(const netlist_time &left, const netlist_time &right); |
| 42 | 42 | ATTR_HOT friend inline bool operator<=(const netlist_time &left, const netlist_time &right); |
| 43 | ||
| 43 | ATTR_HOT friend inline bool operator!=(const netlist_time &left, const netlist_time &right); | |
| 44 | 44 | |
| 45 | 45 | ATTR_HOT inline const netlist_time &operator=(const netlist_time &right) { m_time = right.m_time; return *this; } |
| 46 | 46 | ATTR_HOT inline const netlist_time &operator=(const double &right) { m_time = (INTERNALTYPE) ( right * (double) RESOLUTION); return *this; } |
| r31374 | r31375 | |
| 114 | 114 | |
| 115 | 115 | ATTR_HOT inline bool operator!=(const netlist_time &left, const netlist_time &right) |
| 116 | 116 | { |
| 117 | ||
| 117 | return (left.m_time != right.m_time); | |
| 118 | 118 | } |
| 119 | 119 | |
| 120 | 120 | #endif /* NLTIME_H_ */ |
| r31374 | r31375 | |
|---|---|---|
| 74 | 74 | |
| 75 | 75 | ATTR_HOT inline void remove(const _Element elem) |
| 76 | 76 | { |
| 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 | } | |
| 92 | 92 | } |
| 93 | 93 | |
| 94 | 94 | ATTR_COLD void clear() |
| r31374 | r31375 | |
|---|---|---|
| 83 | 83 | struct link_t |
| 84 | 84 | { |
| 85 | 85 | link_t() { } |
| 86 | ||
| 86 | link_t(void *) { } | |
| 87 | 87 | // Copy constructor |
| 88 | 88 | link_t(const link_t &from) |
| 89 | 89 | { |
| r31374 | r31375 | |
|---|---|---|
| 28 | 28 | ~NETLIB_NAME(log)(); |
| 29 | 29 | netlist_analog_input_t m_I; |
| 30 | 30 | protected: |
| 31 | ||
| 31 | netlist_state_t<FILE *> m_file; | |
| 32 | 32 | ); |
| 33 | 33 | |
| 34 | 34 | #define LOGD(_name, _I, _I2) \ |
| r31374 | r31375 | |
|---|---|---|
| 37 | 37 | NET_REGISTER_DEV(gnd, GND) |
| 38 | 38 | |
| 39 | 39 | #define DUMMY_INPUT(_name) \ |
| 40 | ||
| 40 | NET_REGISTER_DEV(dummy_input, _name) | |
| 41 | 41 | |
| 42 | 42 | // ----------------------------------------------------------------------------- |
| 43 | 43 | // mainclock |
| r31374 | r31375 | |
| 122 | 122 | class NETLIB_NAME(dummy_input) : public netlist_device_t |
| 123 | 123 | { |
| 124 | 124 | public: |
| 125 | ATTR_COLD NETLIB_NAME(dummy_input)() | |
| 126 | : netlist_device_t(DUMMY) { } | |
| 125 | ATTR_COLD NETLIB_NAME(dummy_input)() | |
| 126 | : netlist_device_t(DUMMY) { } | |
| 127 | 127 | |
| 128 | ||
| 128 | ATTR_COLD virtual ~NETLIB_NAME(dummy_input)() {} | |
| 129 | 129 | |
| 130 | 130 | protected: |
| 131 | 131 | |
| 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 | } | |
| 136 | 136 | |
| 137 | ATTR_COLD void reset() | |
| 138 | { | |
| 139 | } | |
| 137 | ATTR_COLD void reset() | |
| 138 | { | |
| 139 | } | |
| 140 | 140 | |
| 141 | ATTR_HOT ATTR_ALIGN void update() | |
| 142 | { | |
| 143 | } | |
| 141 | ATTR_HOT ATTR_ALIGN void update() | |
| 142 | { | |
| 143 | } | |
| 144 | 144 | |
| 145 | 145 | private: |
| 146 | ||
| 146 | netlist_analog_input_t m_I; | |
| 147 | 147 | |
| 148 | 148 | }; |
| 149 | 149 | |
| r31374 | r31375 | |
| 216 | 216 | register_input("I", m_I); |
| 217 | 217 | } |
| 218 | 218 | |
| 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 | } | |
| 223 | 223 | |
| 224 | ||
| 224 | const netlist_logic_family_desc_t *m_logic_family; | |
| 225 | 225 | private: |
| 226 | 226 | }; |
| 227 | 227 | |
| r31374 | r31375 | |
| 266 | 266 | { |
| 267 | 267 | public: |
| 268 | 268 | 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) | |
| 271 | 271 | , m_last_state(-1) |
| 272 | 272 | { |
| 273 | 273 | } |
| r31374 | r31375 | |
|---|---|---|
| 57 | 57 | NETLIB_SUBDEVICE(7474sub, |
| 58 | 58 | netlist_ttl_input_t m_CLK; |
| 59 | 59 | |
| 60 | ||
| 60 | netlist_state_t<UINT8> m_nextD; | |
| 61 | 61 | netlist_ttl_output_t m_Q; |
| 62 | 62 | netlist_ttl_output_t m_QQ; |
| 63 | 63 |
| r31374 | r31375 | |
|---|---|---|
| 41 | 41 | |
| 42 | 42 | netlist_time m_inc; |
| 43 | 43 | netlist_state_t<netlist_sig_t> m_enableq; |
| 44 | ||
| 44 | netlist_state_t<netlist_sig_t> m_out; | |
| 45 | 45 | ); |
| 46 | 46 | |
| 47 | 47 | NETLIB_DEVICE_WITH_PARAMS(SN74LS629, |
| r31374 | r31375 | |
|---|---|---|
| 11 | 11 | |
| 12 | 12 | class nld_vdd_vss : public netlist_device_t |
| 13 | 13 | { |
| 14 | public: | |
| 15 | nld_vdd_vss () | |
| 16 | : netlist_device_t() | |
| 17 | { } | |
| 14 | public: | |
| 15 | nld_vdd_vss () | |
| 16 | : netlist_device_t() | |
| 17 | { } | |
| 18 | 18 | |
| 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; | |
| 21 | 21 | |
| 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() {}; | |
| 26 | 26 | |
| 27 | 27 | public: |
| 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); } | |
| 30 | 30 | }; |
| 31 | 31 | |
| 32 | 32 | #endif /* NLD_CMOS_H_ */ |
| r31374 | r31375 | |
|---|---|---|
| 51 | 51 | |
| 52 | 52 | #define R2R_DAC(_name, _VIN, _R, _N) \ |
| 53 | 53 | 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) | |
| 57 | 57 | |
| 58 | 58 | NETLIB_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; | |
| 63 | 63 | ); |
| 64 | 64 | |
| 65 | 65 |
| r31374 | r31375 | |
|---|---|---|
| 11 | 11 | #include "../nl_base.h" |
| 12 | 12 | |
| 13 | 13 | #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 | } | |
| 23 | 23 | |
| 24 | 24 | |
| 25 | 25 | template<int m_NI, int m_NO, int has_state> |
| r31374 | r31375 | |
| 27 | 27 | { |
| 28 | 28 | public: |
| 29 | 29 | |
| 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)); | |
| 32 | 32 | |
| 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 | }; | |
| 41 | 41 | |
| 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 | } | |
| 46 | 46 | |
| 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); | |
| 58 | 58 | |
| 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 | } | |
| 71 | 71 | |
| 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; | |
| 79 | 79 | |
| 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); | |
| 100 | 100 | |
| 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 | } | |
| 114 | 114 | |
| 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; | |
| 119 | 119 | |
| 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++; | |
| 125 | 125 | |
| 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; | |
| 128 | 128 | |
| 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; | |
| 131 | 131 | |
| 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); | |
| 143 | 143 | |
| 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 | } | |
| 157 | 157 | |
| 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); | |
| 167 | 167 | |
| 168 | ||
| 168 | m_ttp->m_initialized = true; | |
| 169 | 169 | |
| 170 | ||
| 170 | } | |
| 171 | 171 | |
| 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 | } | |
| 178 | 178 | |
| 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)}; | |
| 182 | 182 | |
| 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; | |
| 186 | 186 | |
| 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 | } | |
| 193 | 193 | |
| 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; | |
| 198 | 198 | |
| 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(); | |
| 202 | 202 | |
| 203 | ||
| 203 | for (int i=0; i<m_NO; i++) | |
| 204 | 204 | // OUTLOGIC(m_Q[i], (out >> i) & 1, times[(out >> i) & 1]);// ? 22000 : 15000); |
| 205 | ||
| 205 | OUTLOGIC(m_Q[i], (out >> i) & 1, m_ttp->m_timing_nt[m_ttp->m_timing[nstate][i]]);// ? 22000 : 15000); | |
| 206 | 206 | |
| 207 | ||
| 207 | } | |
| 208 | 208 | |
| 209 | 209 | |
| 210 | 210 | #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 | } | |
| 218 | 218 | |
| 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 | } | |
| 227 | 227 | #endif |
| 228 | 228 | |
| 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]; | |
| 231 | 231 | |
| 232 | 232 | private: |
| 233 | 233 | |
| 234 | UINT32 m_last_state; | |
| 235 | INT32 m_active; | |
| 234 | UINT32 m_last_state; | |
| 235 | INT32 m_active; | |
| 236 | 236 | |
| 237 | truthtable_t *m_ttp; | |
| 238 | const char **m_desc; | |
| 237 | truthtable_t *m_ttp; | |
| 238 | const char **m_desc; | |
| 239 | 239 | }; |
| 240 | 240 | |
| 241 | 241 | #endif /* NLD_TRUTHTABLE_H_ */ |
| r31374 | r31375 | |
|---|---|---|
| 34 | 34 | NET_REGISTER_DEV(4020, _name) \ |
| 35 | 35 | NET_CONNECT(_name, IP, _IP) \ |
| 36 | 36 | 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) | |
| 39 | 39 | |
| 40 | 40 | #define CD_4020_DIP(_name) \ |
| 41 | 41 | NET_REGISTER_DEV(4020_dip, _name) |
| 42 | 42 | |
| 43 | 43 | NETLIB_SUBDEVICE(4020_sub, |
| 44 | 44 | |
| 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); | |
| 47 | 47 | |
| 48 | 48 | netlist_ttl_input_t m_IP; |
| 49 | 49 | |
| r31374 | r31375 | |
| 53 | 53 | ); |
| 54 | 54 | |
| 55 | 55 | NETLIB_DEVICE(4020, |
| 56 | ||
| 56 | NETLIB_LOGIC_FAMILY(CD4000) | |
| 57 | 57 | 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; | |
| 60 | 60 | ); |
| 61 | 61 | |
| 62 | 62 | NETLIB_DEVICE_DERIVED(4020_dip, 4020, |
| r31374 | r31375 | |
|---|---|---|
| 31 | 31 | NET_REGISTER_DEV(4066_dip, _name) |
| 32 | 32 | |
| 33 | 33 | NETLIB_SUBDEVICE(4066, |
| 34 | ||
| 34 | NETLIB_LOGIC_FAMILY(CD4000) | |
| 35 | 35 | public: |
| 36 | 36 | |
| 37 | 37 | netlist_analog_input_t m_control; |
| r31374 | r31375 | |
| 41 | 41 | ); |
| 42 | 42 | |
| 43 | 43 | NETLIB_DEVICE(4066_dip, |
| 44 | ||
| 44 | NETLIB_LOGIC_FAMILY(CD4000) | |
| 45 | 45 | |
| 46 | 46 | NETLIB_NAME(4066) m_A; |
| 47 | 47 | NETLIB_NAME(4066) m_B; |
| r31374 | r31375 | |
|---|---|---|
| 81 | 81 | netlist_ttl_input_t m_B; |
| 82 | 82 | |
| 83 | 83 | 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; | |
| 86 | 86 | |
| 87 | 87 | netlist_ttl_output_t m_Q[4]; |
| 88 | 88 | ); |
| r31374 | r31375 | |
|---|---|---|
| 39 | 39 | netlist_ttl_input_t m_B; |
| 40 | 40 | netlist_ttl_input_t m_CLRQ; |
| 41 | 41 | netlist_ttl_output_t m_Q; |
| 42 | ||
| 42 | netlist_ttl_output_t m_QQ; | |
| 43 | 43 | |
| 44 | ||
| 44 | netlist_analog_input_t m_CV; | |
| 45 | 45 | |
| 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; | |
| 49 | 49 | |
| 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; | |
| 52 | 52 | |
| 53 | 53 | ); |
| 54 | 54 | |
| r31374 | r31375 | |
| 57 | 57 | |
| 58 | 58 | NETLIB_DEVICE(74123_dip, |
| 59 | 59 | |
| 60 | NETLIB_NAME(74123) m_1; | |
| 61 | NETLIB_NAME(74123) m_2; | |
| 60 | NETLIB_NAME(74123) m_1; | |
| 61 | NETLIB_NAME(74123) m_2; | |
| 62 | 62 | |
| 63 | 63 | ); |
| 64 | 64 |
| r31374 | r31375 | |
|---|---|---|
| 37 | 37 | |
| 38 | 38 | template<typename _ItemType> struct nl_datatype |
| 39 | 39 | { |
| 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; | |
| 42 | 42 | }; |
| 43 | 43 | |
| 44 | 44 | template<typename _ItemType> struct nl_datatype<_ItemType *> |
| 45 | 45 | { |
| 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; | |
| 48 | 48 | }; |
| 49 | 49 | |
| 50 | 50 | //template<typename _ItemType> struct type_checker<_ItemType*> { static const bool is_atom = false; static const bool is_pointer = true; }; |
| 51 | 51 | |
| 52 | 52 | #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;}; | |
| 55 | 55 | |
| 56 | 56 | NETLIST_SAVE_TYPE(char, DT_INT8); |
| 57 | 57 | NETLIST_SAVE_TYPE(double, DT_DOUBLE); |
| r31374 | r31375 | |
| 104 | 104 | template<typename T> |
| 105 | 105 | T *resolved() |
| 106 | 106 | { |
| 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); | |
| 111 | 111 | } |
| 112 | 112 | }; |
| 113 | 113 |
| r31374 | r31375 | |
|---|---|---|
| 70 | 70 | ALIAS(_name.1, _name ## _SW.Q) |
| 71 | 71 | |
| 72 | 72 | #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) | |
| 77 | 77 | |
| 78 | 78 | #define CHIP_LATCH(_name) \ |
| 79 | 79 | NETDEV_RSFF(_name) \ |
| r31374 | r31375 | |
|---|---|---|
| 244 | 244 | #define NETLIB_LOGIC_FAMILY(_fam) \ |
| 245 | 245 | ATTR_COLD virtual const netlist_logic_family_desc_t *logic_family() \ |
| 246 | 246 | { \ |
| 247 | ||
| 247 | return &netlist_family_ ## _fam; \ | |
| 248 | 248 | } |
| 249 | 249 | |
| 250 | 250 | |
| r31374 | r31375 | |
| 298 | 298 | template< typename X> |
| 299 | 299 | class netlist_state_t { |
| 300 | 300 | public: |
| 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; } | |
| 307 | 307 | private: |
| 308 | ||
| 308 | X m_x; | |
| 309 | 309 | }; |
| 310 | 310 | |
| 311 | 311 | // ----------------------------------------------------------------------------- |
| r31374 | r31375 | |
| 324 | 324 | NET = 4, |
| 325 | 325 | DEVICE = 5, |
| 326 | 326 | NETLIST = 6, |
| 327 | ||
| 327 | QUEUE = 7, | |
| 328 | 328 | }; |
| 329 | 329 | enum family_t { |
| 330 | 330 | // Terminal families |
| r31374 | r31375 | |
| 336 | 336 | RESISTOR, // Resistor |
| 337 | 337 | CAPACITOR, // Capacitor |
| 338 | 338 | 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) | |
| 341 | 341 | BJT_SWITCH, // BJT(Switch) |
| 342 | 342 | VCVS, // Voltage controlled voltage source |
| 343 | 343 | VCCS, // Voltage controlled current source |
| 344 | ||
| 344 | CCCS, // Current controlled current source | |
| 345 | 345 | GND, // GND device |
| 346 | 346 | }; |
| 347 | 347 | |
| r31374 | r31375 | |
| 356 | 356 | |
| 357 | 357 | PSTATE_INTERFACE_DECL() |
| 358 | 358 | template<typename C> ATTR_COLD void save(netlist_state_t<C> &state, |
| 359 | | |
| 359 | const pstring &stname) | |
| 360 | 360 | { |
| 361 | | |
| 361 | save(state.ref(), stname); | |
| 362 | 362 | } |
| 363 | 363 | |
| 364 | 364 | ATTR_HOT inline const type_t type() const { return m_objtype; } |
| r31374 | r31375 | |
| 469 | 469 | NETLIST_PREVENT_COPYING(netlist_terminal_t) |
| 470 | 470 | public: |
| 471 | 471 | |
| 472 | ||
| 472 | typedef plinearlist_t<netlist_terminal_t * RESTRICT> list_t; | |
| 473 | 473 | |
| 474 | 474 | ATTR_COLD netlist_terminal_t(); |
| 475 | 475 | |
| r31374 | r31375 | |
| 479 | 479 | |
| 480 | 480 | ATTR_HOT inline void set(const double G) |
| 481 | 481 | { |
| 482 | | |
| 482 | set_ptr(m_Idr1, 0); | |
| 483 | 483 | set_ptr(m_go1, G); |
| 484 | 484 | set_ptr(m_gt1, G); |
| 485 | 485 | } |
| 486 | 486 | |
| 487 | 487 | ATTR_HOT inline void set(const double GO, const double GT) |
| 488 | 488 | { |
| 489 | | |
| 489 | set_ptr(m_Idr1, 0); | |
| 490 | 490 | set_ptr(m_go1, GO); |
| 491 | 491 | set_ptr(m_gt1, GT); |
| 492 | 492 | } |
| 493 | 493 | |
| 494 | 494 | ATTR_HOT inline void set(const double GO, const double GT, const double I) |
| 495 | 495 | { |
| 496 | | |
| 496 | set_ptr(m_Idr1, I); | |
| 497 | 497 | set_ptr(m_go1, GO); |
| 498 | 498 | set_ptr(m_gt1, GT); |
| 499 | 499 | } |
| 500 | 500 | |
| 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); | |
| 503 | 503 | |
| 504 | 504 | netlist_terminal_t *m_otherterm; |
| 505 | 505 | |
| r31374 | r31375 | |
| 508 | 508 | |
| 509 | 509 | ATTR_COLD virtual void reset(); |
| 510 | 510 | private: |
| 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 | } | |
| 516 | 516 | }; |
| 517 | 517 | |
| 518 | 518 | |
| r31374 | r31375 | |
| 531 | 531 | set_state(STATE_INP_ACTIVE); |
| 532 | 532 | } |
| 533 | 533 | |
| 534 | ATTR_HOT inline void inactivate(); | |
| 535 | ATTR_HOT inline void activate(); | |
| 534 | ATTR_HOT inline void inactivate(); | |
| 535 | ATTR_HOT inline void activate(); | |
| 536 | 536 | |
| 537 | 537 | protected: |
| 538 | 538 | ATTR_COLD virtual void reset() |
| r31374 | r31375 | |
| 559 | 559 | ATTR_HOT inline const netlist_sig_t Q() const; |
| 560 | 560 | ATTR_HOT inline const netlist_sig_t last_Q() const; |
| 561 | 561 | |
| 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(); | |
| 564 | 564 | |
| 565 | 565 | }; |
| 566 | 566 | |
| r31374 | r31375 | |
| 610 | 610 | ATTR_COLD void merge_net(netlist_net_t *othernet); |
| 611 | 611 | ATTR_COLD void register_railterminal(netlist_output_t &mr); |
| 612 | 612 | |
| 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; | |
| 615 | 615 | |
| 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; | |
| 618 | 618 | |
| 619 | 619 | ATTR_HOT void update_devs(); |
| 620 | 620 | |
| r31374 | r31375 | |
| 625 | 625 | ATTR_HOT inline const netlist_core_terminal_t & RESTRICT railterminal() const { return *m_railterminal; } |
| 626 | 626 | |
| 627 | 627 | ATTR_HOT inline void push_to_queue(const netlist_time delay); |
| 628 | ||
| 628 | ATTR_HOT inline void reschedule_in_queue(const netlist_time delay); | |
| 629 | 629 | ATTR_HOT bool inline is_queued() const { return m_in_queue == 1; } |
| 630 | 630 | |
| 631 | 631 | ATTR_HOT inline int num_cons() const { return m_core_terms.count(); } |
| 632 | 632 | |
| 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); | |
| 635 | 635 | |
| 636 | ||
| 636 | ATTR_COLD void rebuild_list(); /* rebuild m_list after a load */ | |
| 637 | 637 | |
| 638 | ||
| 638 | ATTR_COLD void move_connections(netlist_net_t *new_net); | |
| 639 | 639 | |
| 640 | ||
| 640 | plinearlist_t<netlist_core_terminal_t *> m_core_terms; // save post-start m_list ... | |
| 641 | 641 | |
| 642 | 642 | protected: //FIXME: needed by current solver code |
| 643 | 643 | |
| 644 | 644 | ATTR_COLD virtual void save_register(); |
| 645 | 645 | ATTR_COLD virtual void reset(); |
| 646 | 646 | |
| 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; | |
| 649 | 649 | |
| 650 | 650 | private: |
| 651 | 651 | |
| 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; | |
| 654 | 654 | |
| 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 */ | |
| 658 | 658 | |
| 659 | 659 | public: |
| 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; | |
| 664 | 664 | |
| 665 | 665 | }; |
| 666 | 666 | |
| 667 | 667 | class netlist_logic_net_t : public netlist_net_t |
| 668 | 668 | { |
| 669 | ||
| 669 | NETLIST_PREVENT_COPYING(netlist_logic_net_t) | |
| 670 | 670 | public: |
| 671 | 671 | |
| 672 | ||
| 672 | typedef plinearlist_t<netlist_logic_net_t *> list_t; | |
| 673 | 673 | |
| 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() { }; | |
| 676 | 676 | |
| 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 | } | |
| 681 | 681 | |
| 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 | } | |
| 686 | 686 | |
| 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 | } | |
| 695 | 695 | |
| 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 | } | |
| 700 | 700 | |
| 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 | } | |
| 706 | 706 | |
| 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 | } | |
| 715 | 715 | |
| 716 | 716 | protected: //FIXME: needed by current solver code |
| 717 | 717 | |
| 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(); | |
| 720 | 720 | |
| 721 | 721 | |
| 722 | 722 | private: |
| r31374 | r31375 | |
| 727 | 727 | |
| 728 | 728 | class netlist_analog_net_t : public netlist_net_t |
| 729 | 729 | { |
| 730 | ||
| 730 | NETLIST_PREVENT_COPYING(netlist_analog_net_t) | |
| 731 | 731 | public: |
| 732 | 732 | |
| 733 | ||
| 733 | typedef plinearlist_t<netlist_analog_net_t *> list_t; | |
| 734 | 734 | |
| 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() { }; | |
| 737 | 737 | |
| 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 | } | |
| 744 | 744 | |
| 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 | } | |
| 751 | 751 | |
| 752 | ||
| 752 | ATTR_HOT inline netlist_matrix_solver_t *solver() { return m_solver; } | |
| 753 | 753 | |
| 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); | |
| 756 | 756 | |
| 757 | 757 | protected: |
| 758 | 758 | |
| 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(); | |
| 761 | 761 | |
| 762 | 762 | |
| 763 | 763 | private: |
| 764 | 764 | |
| 765 | 765 | public: |
| 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; | |
| 768 | 768 | |
| 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; | |
| 771 | 771 | }; |
| 772 | 772 | |
| 773 | 773 | // ----------------------------------------------------------------------------- |
| r31374 | r31375 | |
| 811 | 811 | } |
| 812 | 812 | |
| 813 | 813 | private: |
| 814 | ||
| 814 | netlist_logic_net_t m_my_net; | |
| 815 | 815 | nld_base_d_to_a_proxy *m_proxy; |
| 816 | 816 | }; |
| 817 | 817 | |
| r31374 | r31375 | |
| 834 | 834 | |
| 835 | 835 | ATTR_HOT inline void set_Q(const double newQ); |
| 836 | 836 | |
| 837 | ||
| 837 | netlist_analog_net_t *m_proxied_net; // only for proxy nets in analog input logic | |
| 838 | 838 | |
| 839 | 839 | private: |
| 840 | ||
| 840 | netlist_analog_net_t m_my_net; | |
| 841 | 841 | }; |
| 842 | 842 | |
| 843 | 843 | // ----------------------------------------------------------------------------- |
| r31374 | r31375 | |
| 1030 | 1030 | ATTR_COLD virtual void start() { } |
| 1031 | 1031 | ATTR_COLD virtual const netlist_logic_family_desc_t *logic_family() |
| 1032 | 1032 | { |
| 1033 | | |
| 1033 | return &netlist_family_TTL; | |
| 1034 | 1034 | } |
| 1035 | 1035 | |
| 1036 | 1036 | private: |
| r31374 | r31375 | |
| 1079 | 1079 | // ----------------------------------------------------------------------------- |
| 1080 | 1080 | |
| 1081 | 1081 | class netlist_queue_t : public netlist_timed_queue<netlist_net_t *, netlist_time, 512>, |
| 1082 | ||
| 1082 | public netlist_object_t, | |
| 1083 | 1083 | public pstate_callback_t |
| 1084 | 1084 | { |
| 1085 | 1085 | public: |
| 1086 | ||
| 1086 | netlist_queue_t(netlist_base_t &nl); | |
| 1087 | 1087 | |
| 1088 | 1088 | protected: |
| 1089 | 1089 | |
| 1090 | ||
| 1090 | void reset() {} | |
| 1091 | 1091 | |
| 1092 | 1092 | void register_state(pstate_manager_t &manager, const pstring &module); |
| 1093 | 1093 | void on_pre_save(); |
| r31374 | r31375 | |
| 1126 | 1126 | m_queue.push(netlist_queue_t::entry_t(attime, out)); |
| 1127 | 1127 | } |
| 1128 | 1128 | |
| 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 | } | |
| 1133 | 1133 | |
| 1134 | 1134 | ATTR_HOT void process_queue(const netlist_time delta); |
| 1135 | 1135 | ATTR_HOT inline void abort_current_queue_slice() { m_stop = netlist_time::zero; } |
| r31374 | r31375 | |
| 1161 | 1161 | template<class _C> |
| 1162 | 1162 | _C *get_first_device() |
| 1163 | 1163 | { |
| 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); | |
| 1168 | 1168 | if (dev != NULL) |
| 1169 | 1169 | return dev; |
| 1170 | 1170 | } |
| r31374 | r31375 | |
| 1175 | 1175 | _C *get_single_device(const char *classname) |
| 1176 | 1176 | { |
| 1177 | 1177 | _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); | |
| 1181 | 1181 | if (dev != NULL) |
| 1182 | 1182 | { |
| 1183 | 1183 | if (ret != NULL) |
| r31374 | r31375 | |
| 1261 | 1261 | |
| 1262 | 1262 | ATTR_HOT inline netlist_logic_net_t & RESTRICT netlist_net_t::as_logic() |
| 1263 | 1263 | { |
| 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); | |
| 1266 | 1266 | } |
| 1267 | 1267 | |
| 1268 | 1268 | ATTR_HOT inline const netlist_logic_net_t & RESTRICT netlist_net_t::as_logic() const |
| 1269 | 1269 | { |
| 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); | |
| 1272 | 1272 | } |
| 1273 | 1273 | |
| 1274 | 1274 | ATTR_HOT inline netlist_analog_net_t & RESTRICT netlist_net_t::as_analog() |
| 1275 | 1275 | { |
| 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); | |
| 1278 | 1278 | } |
| 1279 | 1279 | |
| 1280 | 1280 | ATTR_HOT inline const netlist_analog_net_t & RESTRICT netlist_net_t::as_analog() const |
| 1281 | 1281 | { |
| 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); | |
| 1284 | 1284 | } |
| 1285 | 1285 | |
| 1286 | 1286 | |
| r31374 | r31375 | |
| 1337 | 1337 | |
| 1338 | 1338 | ATTR_HOT inline void netlist_net_t::reschedule_in_queue(const netlist_time delay) |
| 1339 | 1339 | { |
| 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); | |
| 1343 | 1343 | |
| 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 | } | |
| 1350 | 1350 | } |
| 1351 | 1351 | |
| 1352 | 1352 | |
| r31374 | r31375 | |
| 1362 | 1362 | |
| 1363 | 1363 | ATTR_HOT inline void netlist_analog_output_t::set_Q(const double newQ) |
| 1364 | 1364 | { |
| 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 | } | |
| 1370 | 1370 | } |
| 1371 | 1371 | |
| 1372 | 1372 |
| r31374 | r31375 | |
|---|---|---|
| 13 | 13 | { |
| 14 | 14 | public: |
| 15 | 15 | |
| 16 | ||
| 16 | netlist_matrix_solver_direct_t(const netlist_solver_parameters_t ¶ms, int size); | |
| 17 | 17 | |
| 18 | ||
| 18 | virtual ~netlist_matrix_solver_direct_t(); | |
| 19 | 19 | |
| 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(); } | |
| 22 | 22 | |
| 23 | ||
| 23 | ATTR_HOT inline const int N() const { if (m_N == 0) return m_dim; else return m_N; } | |
| 24 | 24 | |
| 25 | ||
| 25 | ATTR_HOT inline int vsolve_non_dynamic(); | |
| 26 | 26 | |
| 27 | 27 | protected: |
| 28 | ||
| 28 | ATTR_COLD virtual void add_term(int net_idx, netlist_terminal_t *term); | |
| 29 | 29 | |
| 30 | ||
| 30 | ATTR_HOT virtual double vsolve(); | |
| 31 | 31 | |
| 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); | |
| 37 | 37 | |
| 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(); | |
| 43 | 43 | |
| 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]; | |
| 49 | 49 | |
| 50 | terms_t **m_terms; | |
| 51 | terms_t *m_rails_temp; | |
| 50 | terms_t **m_terms; | |
| 51 | terms_t *m_rails_temp; | |
| 52 | 52 | |
| 53 | 53 | private: |
| 54 | ||
| 54 | vector_ops_t *m_row_ops[_storage_N + 1]; | |
| 55 | 55 | |
| 56 | int m_dim; | |
| 57 | double m_lp_fact; | |
| 56 | int m_dim; | |
| 57 | double m_lp_fact; | |
| 58 | 58 | }; |
| 59 | 59 | |
| 60 | 60 | // ---------------------------------------------------------------------------------------- |
| r31374 | r31375 | |
| 64 | 64 | template <int m_N, int _storage_N> |
| 65 | 65 | netlist_matrix_solver_direct_t<m_N, _storage_N>::~netlist_matrix_solver_direct_t() |
| 66 | 66 | { |
| 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; | |
| 76 | 76 | |
| 77 | 77 | } |
| 78 | 78 | |
| 79 | 79 | template <int m_N, int _storage_N> |
| 80 | 80 | ATTR_HOT double netlist_matrix_solver_direct_t<m_N, _storage_N>::compute_next_timestep() |
| 81 | 81 | { |
| 82 | ||
| 82 | double new_solver_timestep = m_params.m_max_timestep; | |
| 83 | 83 | |
| 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 | */ | |
| 90 | 90 | #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; | |
| 94 | 94 | #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]; | |
| 98 | 98 | #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(); | |
| 101 | 101 | |
| 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; | |
| 104 | 104 | |
| 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; | |
| 111 | 111 | |
| 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; | |
| 121 | 121 | } |
| 122 | 122 | |
| 123 | 123 | template <int m_N, int _storage_N> |
| 124 | 124 | ATTR_COLD void netlist_matrix_solver_direct_t<m_N, _storage_N>::add_term(int k, netlist_terminal_t *term) |
| 125 | 125 | { |
| 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 | } | |
| 145 | 145 | } |
| 146 | 146 | |
| 147 | 147 | |
| 148 | 148 | template <int m_N, int _storage_N> |
| 149 | 149 | ATTR_COLD void netlist_matrix_solver_direct_t<m_N, _storage_N>::vsetup(netlist_analog_net_t::list_t &nets) |
| 150 | 150 | { |
| 151 | if (m_dim < nets.count()) | |
| 152 | netlist().error("Dimension %d less than %d", m_dim, nets.count()); | |
| 151 | 153 | |
| 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 | } | |
| 154 | 159 | |
| 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); | |
| 160 | 161 | |
| 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]); | |
| 162 | 167 | |
| 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 | } | |
| 168 | 171 | |
| 169 | m_rails_temp[k].clear(); // no longer needed | |
| 170 | m_terms[k]->set_pointers(); | |
| 171 | } | |
| 172 | ||
| 173 | 172 | #if 1 |
| 174 | 173 | |
| 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 | */ | |
| 191 | 190 | |
| 192 | 191 | |
| 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 | } | |
| 202 | 201 | |
| 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 | } | |
| 210 | 209 | |
| 211 | 210 | #endif |
| 212 | 211 | |
| r31374 | r31375 | |
| 216 | 215 | ATTR_HOT void netlist_matrix_solver_direct_t<m_N, _storage_N>::build_LE() |
| 217 | 216 | { |
| 218 | 217 | #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; | |
| 222 | 221 | #endif |
| 223 | 222 | |
| 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; | |
| 228 | 227 | |
| 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(); | |
| 236 | 235 | #if VECTALT |
| 237 | 236 | |
| 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 | } | |
| 243 | 242 | #else |
| 244 | ||
| 243 | m_terms[k]->ops()->sum2(Idr, gt, rhsk, akk); | |
| 245 | 244 | #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 | } | |
| 253 | 252 | #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; | |
| 267 | 266 | |
| 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 | } | |
| 273 | 272 | #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; | |
| 280 | 279 | |
| 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 | } | |
| 286 | 285 | #endif |
| 287 | ||
| 286 | } | |
| 288 | 287 | } |
| 289 | 288 | |
| 290 | 289 | template <int m_N, int _storage_N> |
| 291 | 290 | ATTR_HOT void netlist_matrix_solver_direct_t<m_N, _storage_N>::gauss_LE( |
| 292 | ||
| 291 | double (* RESTRICT x)) | |
| 293 | 292 | { |
| 294 | 293 | #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"); | |
| 302 | 301 | #endif |
| 303 | 302 | |
| 304 | ||
| 303 | const int kN = N(); | |
| 305 | 304 | |
| 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 | } | |
| 317 | 316 | |
| 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 | } | |
| 327 | 326 | |
| 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]; | |
| 330 | 329 | |
| 331 | ||
| 330 | /* Eliminate column i from row j */ | |
| 332 | 331 | |
| 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 | { | |
| 338 | 337 | #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; | |
| 341 | 340 | #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) ; | |
| 344 | 343 | #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; | |
| 353 | 352 | |
| 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]; | |
| 356 | 355 | |
| 357 | x[j] = (m_RHS[j] - tmp) / m_A[j][j]; | |
| 358 | } | |
| 356 | x[j] = (m_RHS[j] - tmp) / m_A[j][j]; | |
| 357 | } | |
| 359 | 358 | #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"); | |
| 368 | 367 | #endif |
| 369 | 368 | |
| 370 | 369 | } |
| 371 | 370 | |
| 372 | 371 | template <int m_N, int _storage_N> |
| 373 | 372 | ATTR_HOT double netlist_matrix_solver_direct_t<m_N, _storage_N>::delta( |
| 374 | ||
| 373 | const double (* RESTRICT V)) | |
| 375 | 374 | { |
| 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; | |
| 387 | 386 | } |
| 388 | 387 | |
| 389 | 388 | template <int m_N, int _storage_N> |
| 390 | 389 | ATTR_HOT void netlist_matrix_solver_direct_t<m_N, _storage_N>::store( |
| 391 | ||
| 390 | const double (* RESTRICT V), const bool store_RHS) | |
| 392 | 391 | { |
| 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 | } | |
| 404 | 403 | } |
| 405 | 404 | |
| 406 | 405 | template <int m_N, int _storage_N> |
| 407 | 406 | ATTR_HOT double netlist_matrix_solver_direct_t<m_N, _storage_N>::vsolve() |
| 408 | 407 | { |
| 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(); | |
| 411 | 410 | } |
| 412 | 411 | |
| 413 | 412 | |
| 414 | 413 | template <int m_N, int _storage_N> |
| 415 | 414 | ATTR_HOT int netlist_matrix_solver_direct_t<m_N, _storage_N>::solve_non_dynamic() |
| 416 | 415 | { |
| 417 | ||
| 416 | double new_v[_storage_N] = { 0.0 }; | |
| 418 | 417 | |
| 419 | ||
| 418 | this->gauss_LE(new_v); | |
| 420 | 419 | |
| 421 | if (this->is_dynamic()) | |
| 422 | { | |
| 423 | double err = delta(new_v); | |
| 420 | if (this->is_dynamic()) | |
| 421 | { | |
| 422 | double err = delta(new_v); | |
| 424 | 423 | |
| 425 | ||
| 424 | store(new_v, true); | |
| 426 | 425 | |
| 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; | |
| 435 | 434 | } |
| 436 | 435 | |
| 437 | 436 | template <int m_N, int _storage_N> |
| 438 | 437 | ATTR_HOT inline int netlist_matrix_solver_direct_t<m_N, _storage_N>::vsolve_non_dynamic() |
| 439 | 438 | { |
| 440 | ||
| 439 | this->build_LE(); | |
| 441 | 440 | |
| 442 | ||
| 441 | return this->solve_non_dynamic(); | |
| 443 | 442 | } |
| 444 | 443 | |
| 445 | 444 | template <int m_N, int _storage_N> |
| r31374 | r31375 | |
| 448 | 447 | , m_dim(size) |
| 449 | 448 | , m_lp_fact(0) |
| 450 | 449 | { |
| 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()]; | |
| 453 | 452 | |
| 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()); | |
| 460 | 459 | } |
| 461 | 460 | |
| 462 | 461 |
| r31374 | r31375 | |
|---|---|---|
| 45 | 45 | bool m_dynamic; |
| 46 | 46 | int m_gs_loops; |
| 47 | 47 | int m_nr_loops; |
| 48 | ||
| 48 | netlist_time m_nt_sync_delay; | |
| 49 | 49 | }; |
| 50 | 50 | |
| 51 | 51 | class vector_ops_t |
| 52 | 52 | { |
| 53 | 53 | public: |
| 54 | 54 | |
| 55 | vector_ops_t(int size) | |
| 56 | : m_dim(size) | |
| 57 | { | |
| 58 | } | |
| 55 | vector_ops_t(int size) | |
| 56 | : m_dim(size) | |
| 57 | { | |
| 58 | } | |
| 59 | 59 | |
| 60 | ||
| 60 | virtual ~vector_ops_t() {} | |
| 61 | 61 | |
| 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; | |
| 66 | 66 | |
| 67 | ||
| 67 | virtual const double sumabs(const double * v) = 0; | |
| 68 | 68 | |
| 69 | ||
| 69 | static vector_ops_t *create_ops(const int size); | |
| 70 | 70 | |
| 71 | 71 | protected: |
| 72 | ||
| 72 | int m_dim; | |
| 73 | 73 | |
| 74 | 74 | private: |
| 75 | 75 | |
| r31374 | r31375 | |
| 80 | 80 | { |
| 81 | 81 | public: |
| 82 | 82 | |
| 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 | } | |
| 87 | 87 | |
| 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 | } | |
| 93 | 93 | |
| 94 | ||
| 94 | virtual ~vector_ops_impl_t() {} | |
| 95 | 95 | |
| 96 | ||
| 96 | ATTR_HOT inline const int N() const { if (m_N == 0) return m_dim; else return m_N; } | |
| 97 | 97 | |
| 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 | } | |
| 106 | 106 | |
| 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 | } | |
| 117 | 117 | |
| 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 | } | |
| 127 | 127 | |
| 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 | } | |
| 140 | 140 | |
| 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 | } | |
| 149 | 149 | |
| 150 | 150 | private: |
| 151 | 151 | }; |
| 152 | 152 | |
| 153 | 153 | class ATTR_ALIGNED(64) terms_t |
| 154 | 154 | { |
| 155 | ||
| 155 | NETLIST_PREVENT_COPYING(terms_t) | |
| 156 | 156 | |
| 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 | {} | |
| 160 | 160 | |
| 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 | } | |
| 167 | 167 | |
| 168 | ||
| 168 | ATTR_COLD void add(netlist_terminal_t *term, int net_other); | |
| 169 | 169 | |
| 170 | ||
| 170 | ATTR_HOT inline int count() { return m_term.count(); } | |
| 171 | 171 | |
| 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; } | |
| 179 | 179 | |
| 180 | ||
| 180 | ATTR_COLD void set_pointers(); | |
| 181 | 181 | |
| 182 | ||
| 182 | int m_railstart; | |
| 183 | 183 | |
| 184 | 184 | private: |
| 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; | |
| 192 | 192 | }; |
| 193 | 193 | |
| 194 | 194 | class netlist_matrix_solver_t : public netlist_device_t |
| r31374 | r31375 | |
| 200 | 200 | ATTR_COLD netlist_matrix_solver_t(const netlist_solver_parameters_t ¶ms); |
| 201 | 201 | ATTR_COLD virtual ~netlist_matrix_solver_t(); |
| 202 | 202 | |
| 203 | ||
| 203 | ATTR_COLD virtual void vsetup(netlist_analog_net_t::list_t &nets) = 0; | |
| 204 | 204 | |
| 205 | template<class C> | |
| 206 | void solve_base(C *p); | |
| 205 | template<class C> | |
| 206 | void solve_base(C *p); | |
| 207 | 207 | |
| 208 | 208 | ATTR_HOT double solve(); |
| 209 | 209 | |
| 210 | 210 | ATTR_HOT inline bool is_dynamic() { return m_dynamic_devices.count() > 0; } |
| 211 | 211 | ATTR_HOT inline bool is_timestep() { return m_step_devices.count() > 0; } |
| 212 | 212 | |
| 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 | } | |
| 218 | 218 | |
| 219 | 219 | /* netdevice functions */ |
| 220 | 220 | 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(); | |
| 223 | 223 | |
| 224 | ||
| 224 | ATTR_COLD int get_net_idx(netlist_net_t *net); | |
| 225 | 225 | ATTR_COLD virtual void log_stats() {}; |
| 226 | 226 | |
| 227 | 227 | protected: |
| 228 | 228 | |
| 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(); | |
| 231 | 231 | |
| 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; | |
| 234 | 234 | |
| 235 | ||
| 235 | ATTR_COLD virtual void add_term(int net_idx, netlist_terminal_t *term) = 0; | |
| 236 | 236 | |
| 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; | |
| 239 | 239 | |
| 240 | int m_calculations; | |
| 241 | const netlist_solver_parameters_t &m_params; | |
| 240 | int m_calculations; | |
| 241 | const netlist_solver_parameters_t &m_params; | |
| 242 | 242 | |
| 243 | ||
| 243 | ATTR_HOT inline const double current_timestep() { return m_cur_ts; } | |
| 244 | 244 | private: |
| 245 | 245 | |
| 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; | |
| 250 | 250 | |
| 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; | |
| 253 | 253 | |
| 254 | ||
| 254 | ATTR_HOT void step(const netlist_time delta); | |
| 255 | 255 | |
| 256 | ||
| 256 | ATTR_HOT void update_inputs(); | |
| 257 | 257 | |
| 258 | 258 | }; |
| 259 | 259 | |
| r31374 | r31375 | |
| 262 | 262 | class ATTR_ALIGNED(64) NETLIB_NAME(solver) : public netlist_device_t |
| 263 | 263 | { |
| 264 | 264 | public: |
| 265 | NETLIB_NAME(solver)() | |
| 266 | : netlist_device_t() { } | |
| 265 | NETLIB_NAME(solver)() | |
| 266 | : netlist_device_t() { } | |
| 267 | 267 | |
| 268 | ||
| 268 | ATTR_COLD virtual ~NETLIB_NAME(solver)(); | |
| 269 | 269 | |
| 270 | ||
| 270 | ATTR_COLD void post_start(); | |
| 271 | 271 | |
| 272 | ||
| 272 | ATTR_HOT inline double gmin() { return m_gmin.Value(); } | |
| 273 | 273 | |
| 274 | 274 | protected: |
| 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(); | |
| 279 | 279 | |
| 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; | |
| 282 | 282 | |
| 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; | |
| 291 | 291 | |
| 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; | |
| 296 | 296 | |
| 297 | ||
| 297 | netlist_matrix_solver_t::list_t m_mat_solvers; | |
| 298 | 298 | private: |
| 299 | 299 | |
| 300 | ||
| 300 | netlist_solver_parameters_t m_params; | |
| 301 | 301 | |
| 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); | |
| 304 | 304 | }; |
| 305 | 305 | |
| 306 | 306 |
| r31374 | r31375 | |
|---|---|---|
| 98 | 98 | |
| 99 | 99 | NETLIB_UPDATE_TERMINALS() |
| 100 | 100 | { |
| 101 | | |
| 101 | const double m = (is_qtype( BJT_NPN) ? 1 : -1); | |
| 102 | 102 | |
| 103 | 103 | const int new_state = (m_RB.deltaV() * m > m_V ) ? 1 : 0; |
| 104 | 104 | if (m_state_on ^ new_state) |
| r31374 | r31375 | |
| 122 | 122 | m_RB.set(gb, v, 0.0); |
| 123 | 123 | m_RC.set(gc, 0.0, 0.0); |
| 124 | 124 | //m_RB.update_dev(); |
| 125 | ||
| 125 | //m_RC.update_dev(); | |
| 126 | 126 | m_state_on = new_state; |
| 127 | 127 | } |
| 128 | 128 | } |
| r31374 | r31375 | |
| 164 | 164 | m_D_EB(netlist_object_t::ANALOG), |
| 165 | 165 | m_D_EC(netlist_object_t::ANALOG), |
| 166 | 166 | m_alpha_f(0), |
| 167 | | |
| 167 | m_alpha_r(0) | |
| 168 | 168 | { } |
| 169 | 169 | |
| 170 | 170 | NETLIB_UPDATE_TERMINALS() |
| r31374 | r31375 | |
|---|---|---|
| 13 | 13 | { |
| 14 | 14 | public: |
| 15 | 15 | |
| 16 | netlist_matrix_solver_direct1_t(const netlist_solver_parameters_t ¶ms) | |
| 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 ¶ms) | |
| 17 | : netlist_matrix_solver_direct_t<1, 1>(params, 1) | |
| 18 | {} | |
| 19 | ATTR_HOT inline int vsolve_non_dynamic(); | |
| 20 | 20 | protected: |
| 21 | ||
| 21 | ATTR_HOT virtual double vsolve(); | |
| 22 | 22 | private: |
| 23 | 23 | }; |
| 24 | 24 | |
| r31374 | r31375 | |
| 28 | 28 | |
| 29 | 29 | ATTR_HOT double netlist_matrix_solver_direct1_t::vsolve() |
| 30 | 30 | { |
| 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(); | |
| 33 | 33 | } |
| 34 | 34 | |
| 35 | 35 | ATTR_HOT inline int netlist_matrix_solver_direct1_t::vsolve_non_dynamic() |
| 36 | 36 | { |
| 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]); | |
| 37 | 40 | |
| 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]; | |
| 41 | 42 | |
| 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); | |
| 43 | 45 | |
| 44 | double e = (new_val - net->m_cur_Analog); | |
| 45 | double cerr = fabs(e); | |
| 46 | net->m_cur_Analog = new_val; | |
| 46 | 47 | |
| 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; | |
| 48 | 54 | |
| 49 | if (is_dynamic() && (cerr > m_params.m_accuracy)) | |
| 50 | { | |
| 51 | return 2; | |
| 52 | } | |
| 53 | else | |
| 54 | return 1; | |
| 55 | ||
| 56 | 55 | } |
| 57 | 56 | |
| 58 | 57 |
| r31374 | r31375 | |
|---|---|---|
| 15 | 15 | { |
| 16 | 16 | public: |
| 17 | 17 | |
| 18 | netlist_matrix_solver_direct2_t(const netlist_solver_parameters_t ¶ms) | |
| 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 ¶ms) | |
| 19 | : netlist_matrix_solver_direct_t<2, 2>(params, 2) | |
| 20 | {} | |
| 21 | ATTR_HOT inline int vsolve_non_dynamic(); | |
| 22 | 22 | protected: |
| 23 | ||
| 23 | ATTR_HOT virtual double vsolve(); | |
| 24 | 24 | private: |
| 25 | 25 | }; |
| 26 | 26 | |
| r31374 | r31375 | |
| 30 | 30 | |
| 31 | 31 | ATTR_HOT double netlist_matrix_solver_direct2_t::vsolve() |
| 32 | 32 | { |
| 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(); | |
| 35 | 35 | } |
| 36 | 36 | |
| 37 | 37 | ATTR_HOT inline int netlist_matrix_solver_direct2_t::vsolve_non_dynamic() |
| 38 | 38 | { |
| 39 | build_LE(); | |
| 39 | 40 | |
| 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]; | |
| 41 | 45 | |
| 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; | |
| 46 | 49 | |
| 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; | |
| 62 | 61 | } |
| 63 | 62 | |
| 64 | 63 |
| r31374 | r31375 | |
|---|---|---|
| 19 | 19 | // ---------------------------------------------------------------------------------------- |
| 20 | 20 | |
| 21 | 21 | #define LM3900(_name) \ |
| 22 | ||
| 22 | SUBMODEL(_name, opamp_lm3900) | |
| 23 | 23 | |
| 24 | 24 | // ---------------------------------------------------------------------------------------- |
| 25 | 25 | // Devices ... |
| r31374 | r31375 | |
|---|---|---|
| 88 | 88 | { |
| 89 | 89 | public: |
| 90 | 90 | ATTR_COLD NETLIB_NAME(twoterm)(const family_t afamily); |
| 91 | ||
| 91 | ATTR_COLD NETLIB_NAME(twoterm)(); | |
| 92 | 92 | |
| 93 | 93 | netlist_terminal_t m_P; |
| 94 | 94 | netlist_terminal_t m_N; |
| r31374 | r31375 | |
| 99 | 99 | |
| 100 | 100 | ATTR_HOT inline void set(const double G, const double V, const double I) |
| 101 | 101 | { |
| 102 | | |
| 102 | /* GO, GT, I */ | |
| 103 | 103 | m_P.set( G, G, ( V) * G - I); |
| 104 | 104 | m_N.set( G, G, ( -V) * G + I); |
| 105 | 105 | } |
| 106 | 106 | |
| 107 | 107 | ATTR_HOT inline double deltaV() const |
| 108 | 108 | { |
| 109 | | |
| 109 | return m_P.net().as_analog().Q_Analog() - m_N.net().as_analog().Q_Analog(); | |
| 110 | 110 | } |
| 111 | 111 | |
| 112 | 112 | ATTR_HOT void set_mat(double a11, double a12, double a21, double a22, double r1, double r2) |
| 113 | 113 | { |
| 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); | |
| 117 | 117 | } |
| 118 | 118 | |
| 119 | 119 | protected: |
| r31374 | r31375 | |
| 135 | 135 | |
| 136 | 136 | inline void set_R(const double R) |
| 137 | 137 | { |
| 138 | | |
| 138 | set(1.0 / R, 0.0, 0.0); | |
| 139 | 139 | } |
| 140 | 140 | |
| 141 | 141 | protected: |
| r31374 | r31375 | |
|---|---|---|
| 18 | 18 | NET_REGISTER_DEV(VCCS, _name) |
| 19 | 19 | |
| 20 | 20 | #define CCCS(_name) \ |
| 21 | ||
| 21 | NET_REGISTER_DEV(CCCS, _name) | |
| 22 | 22 | |
| 23 | 23 | #define VCVS(_name) \ |
| 24 | 24 | NET_REGISTER_DEV(VCVS, _name) |
| r31374 | r31375 | |
| 104 | 104 | class NETLIB_NAME(CCCS) : public NETLIB_NAME(VCCS) |
| 105 | 105 | { |
| 106 | 106 | public: |
| 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) { } | |
| 111 | 111 | |
| 112 | 112 | protected: |
| 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(); | |
| 117 | 117 | |
| 118 | ||
| 118 | double m_gfac; | |
| 119 | 119 | }; |
| 120 | 120 | |
| 121 | 121 |
| r31374 | r31375 | |
|---|---|---|
| 16 | 16 | { |
| 17 | 17 | public: |
| 18 | 18 | |
| 19 | netlist_matrix_solver_gauss_seidel_t(const netlist_solver_parameters_t ¶ms, 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 ¶ms, 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 | {} | |
| 25 | 25 | |
| 26 | ||
| 26 | virtual ~netlist_matrix_solver_gauss_seidel_t() {} | |
| 27 | 27 | |
| 28 | ||
| 28 | ATTR_COLD virtual void log_stats(); | |
| 29 | 29 | |
| 30 | ||
| 30 | ATTR_HOT inline int vsolve_non_dynamic(); | |
| 31 | 31 | protected: |
| 32 | ||
| 32 | ATTR_HOT virtual double vsolve(); | |
| 33 | 33 | |
| 34 | 34 | private: |
| 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; | |
| 38 | 38 | |
| 39 | 39 | }; |
| 40 | 40 | |
| r31374 | r31375 | |
| 46 | 46 | void netlist_matrix_solver_gauss_seidel_t<m_N, _storage_N>::log_stats() |
| 47 | 47 | { |
| 48 | 48 | #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); | |
| 62 | 62 | #endif |
| 63 | 63 | } |
| 64 | 64 | |
| 65 | 65 | template <int m_N, int _storage_N> |
| 66 | 66 | ATTR_HOT double netlist_matrix_solver_gauss_seidel_t<m_N, _storage_N>::vsolve() |
| 67 | 67 | { |
| 68 | /* | |
| 69 | * enable linear prediction on first newton pass | |
| 70 | */ | |
| 68 | /* | |
| 69 | * enable linear prediction on first newton pass | |
| 70 | */ | |
| 71 | 71 | |
| 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 | } | |
| 83 | 83 | |
| 84 | ||
| 84 | this->solve_base(this); | |
| 85 | 85 | |
| 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 | } | |
| 104 | 104 | |
| 105 | 105 | |
| 106 | ||
| 106 | return this->compute_next_timestep(); | |
| 107 | 107 | } |
| 108 | 108 | |
| 109 | 109 | template <int m_N, int _storage_N> |
| 110 | 110 | ATTR_HOT inline int netlist_matrix_solver_gauss_seidel_t<m_N, _storage_N>::vsolve_non_dynamic() |
| 111 | 111 | { |
| 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 | */ | |
| 116 | 116 | |
| 117 | 117 | #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(); | |
| 121 | 121 | |
| 122 | ||
| 122 | bool resched = false; | |
| 123 | 123 | |
| 124 | ||
| 124 | int resched_cnt = 0; | |
| 125 | 125 | |
| 126 | ||
| 126 | this->build_LE(); | |
| 127 | 127 | |
| 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 | } | |
| 141 | 141 | |
| 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 | } | |
| 147 | 147 | #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; | |
| 155 | 155 | #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); | |
| 170 | 170 | #endif |
| 171 | ||
| 171 | } | |
| 172 | 172 | |
| 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; | |
| 183 | 183 | |
| 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]; | |
| 191 | 191 | |
| 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 | } | |
| 198 | 198 | |
| 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]; | |
| 201 | 201 | |
| 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 | } | |
| 206 | 206 | |
| 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) )); | |
| 217 | 217 | |
| 218 | 218 | |
| 219 | ||
| 219 | this->store(new_v, false); | |
| 220 | 220 | |
| 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++; | |
| 232 | 232 | |
| 233 | return resched_cnt; | |
| 234 | } | |
| 233 | return resched_cnt; | |
| 234 | } | |
| 235 | 235 | |
| 236 | 236 | #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; | |
| 240 | 240 | |
| 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 | */ | |
| 248 | 248 | |
| 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()))); | |
| 251 | 251 | |
| 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]; | |
| 256 | 256 | |
| 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; | |
| 262 | 262 | |
| 263 | ||
| 263 | new_V[k] = this->m_nets[k]->m_cur_Analog; | |
| 264 | 264 | |
| 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(); | |
| 271 | 271 | #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]); | |
| 280 | 280 | #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); | |
| 285 | 285 | #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 | } | |
| 289 | 289 | |
| 290 | ||
| 290 | RHS[k] = RHS_t; | |
| 291 | 291 | |
| 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); | |
| 294 | 294 | |
| 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 | } | |
| 307 | 307 | |
| 308 | ||
| 308 | } | |
| 309 | 309 | |
| 310 | ||
| 310 | const double accuracy = this->m_params.m_accuracy; | |
| 311 | 311 | |
| 312 | do { | |
| 313 | resched = false; | |
| 312 | do { | |
| 313 | resched = false; | |
| 314 | 314 | |
| 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(); | |
| 320 | 320 | |
| 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]]; | |
| 324 | 324 | |
| 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]; | |
| 327 | 327 | |
| 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 | } | |
| 331 | 331 | |
| 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)); | |
| 334 | 334 | |
| 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]; | |
| 337 | 337 | |
| 338 | this->m_gs_total += resched_cnt; | |
| 339 | this->m_calculations++; | |
| 338 | this->m_gs_total += resched_cnt; | |
| 339 | this->m_calculations++; | |
| 340 | 340 | |
| 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 | } | |
| 350 | 350 | #endif |
| 351 | 351 | } |
| 352 | 352 |
| r31374 | r31375 | |
|---|---|---|
| 26 | 26 | { |
| 27 | 27 | m_num_elements = numElements; |
| 28 | 28 | if (m_num_elements == 0) |
| 29 | | |
| 29 | m_list = NULL; | |
| 30 | 30 | else |
| 31 | | |
| 31 | m_list = new _ListClass[m_num_elements]; | |
| 32 | 32 | m_count = 0; |
| 33 | 33 | } |
| 34 | 34 | |
| 35 | 35 | ATTR_COLD plinearlist_t(const plinearlist_t &rhs) |
| 36 | 36 | { |
| 37 | 37 | 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]; | |
| 42 | 42 | m_count = 0; |
| 43 | 43 | for (int i=0; i<rhs.count(); i++) |
| 44 | 44 | { |
| r31374 | r31375 | |
| 59 | 59 | |
| 60 | 60 | ATTR_COLD ~plinearlist_t() |
| 61 | 61 | { |
| 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; | |
| 65 | 65 | } |
| 66 | 66 | |
| 67 | 67 | ATTR_HOT inline operator _ListClass * () { return m_list; } |
| 68 | ||
| 68 | ATTR_HOT inline operator const _ListClass * () const { return m_list; } | |
| 69 | 69 | |
| 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 | */ | |
| 74 | 74 | |
| 75 | ||
| 75 | ATTR_HOT inline _ListClass *array() { return m_list; } | |
| 76 | 76 | |
| 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]; } | |
| 79 | 79 | |
| 80 | 80 | ATTR_HOT inline void add(const _ListClass &elem) |
| 81 | 81 | { |
| 82 | 82 | 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); | |
| 87 | 87 | } |
| 88 | 88 | |
| 89 | 89 | m_list[m_count++] = elem; |
| r31374 | r31375 | |
| 116 | 116 | } |
| 117 | 117 | } |
| 118 | 118 | |
| 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 | } | |
| 127 | 127 | |
| 128 | 128 | ATTR_HOT inline bool contains(const _ListClass &elem) const |
| 129 | 129 | { |
| r31374 | r31375 | |
| 163 | 163 | } |
| 164 | 164 | |
| 165 | 165 | private: |
| 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; | |
| 173 | 173 | |
| 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 | } | |
| 192 | 192 | |
| 193 | ||
| 193 | int m_count; | |
| 194 | 194 | _ListClass * m_list /* ATTR_ALIGN */; |
| 195 | 195 | int m_num_elements; |
| 196 | 196 | }; |
| r31374 | r31375 | |
| 203 | 203 | class pnamedlist_t : public plinearlist_t<_C> |
| 204 | 204 | { |
| 205 | 205 | public: |
| 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 | } | |
| 213 | 213 | |
| 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 | } | |
| 218 | 218 | |
| 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 | } | |
| 231 | 231 | |
| 232 | 232 | private: |
| 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(); } | |
| 235 | 235 | |
| 236 | 236 | }; |
| 237 | 237 |
| r31374 | r31375 | |
|---|---|---|
| 107 | 107 | // use these to declare a gfx_decode_entry array as a member of a device class |
| 108 | 108 | #define DECLARE_GFXDECODE_MEMBER( name ) static const gfx_decode_entry name[] |
| 109 | 109 | #define GFXDECODE_MEMBER( name ) const gfx_decode_entry name[] = { |
| 110 | ||
| 111 | ||
| 112 | 110 | // common gfx_decode_entry macros |
| 113 | 111 | #define GFXDECODE_ENTRYX(region,offset,layout,start,colors,flags) { region, offset, &layout, start, colors, flags }, |
| 114 | 112 | #define GFXDECODE_ENTRY(region,offset,layout,start,colors) { region, offset, &layout, start, colors, 0 }, |
| r31374 | r31375 | |
|---|---|---|
| 67 | 67 | #define MC6845_BEGIN_UPDATE(name) void name(bitmap_rgb32 &bitmap, const rectangle &cliprect) |
| 68 | 68 | |
| 69 | 69 | typedef device_delegate<void (bitmap_rgb32 &bitmap, const rectangle &cliprect, UINT16 ma, UINT8 ra, |
| 70 | | |
| 70 | UINT16 y, UINT8 x_count, INT8 cursor_x, int de, int hbp, int vbp)> mc6845_update_row_delegate; | |
| 71 | 71 | #define MC6845_UPDATE_ROW(name) void name(bitmap_rgb32 &bitmap, const rectangle &cliprect, UINT16 ma, UINT8 ra, \ |
| 72 | 72 | UINT16 y, UINT8 x_count, INT8 cursor_x, int de, int hbp, int vbp) |
| 73 | 73 | |
| r31374 | r31375 | |
| 97 | 97 | 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); |
| 98 | 98 | |
| 99 | 99 | 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) | |
| 101 | 101 | { |
| 102 | 102 | mc6845_device &dev = downcast<mc6845_device &>(device); |
| 103 | 103 | dev.m_visarea_adjust_min_x = min_x; |
| r31374 | r31375 | |
| 116 | 116 | 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); } |
| 117 | 117 | 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); } |
| 118 | 118 | 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 | ||
| 120 | 120 | /* select one of the registers for reading or writing */ |
| 121 | 121 | DECLARE_WRITE8_MEMBER( address_w ); |
| 122 | 122 | |
| r31374 | r31375 | |
| 238 | 238 | emu_timer *m_light_pen_latch_timer; |
| 239 | 239 | emu_timer *m_upd_adr_timer; |
| 240 | 240 | emu_timer *m_upd_trans_timer; |
| 241 | ||
| 241 | ||
| 242 | 242 | /* computed values - do NOT state save these! */ |
| 243 | 243 | /* These computed are used to define the screen parameters for a driver */ |
| 244 | 244 | UINT16 m_horiz_pix_total; |
| r31374 | r31375 | |
| 271 | 271 | /************************ |
| 272 | 272 | interface CRTC - driver |
| 273 | 273 | ************************/ |
| 274 | ||
| 274 | ||
| 275 | 275 | bool m_show_border_area; /* visible screen area (false) active display (true) active display + blanking */ |
| 276 | ||
| 276 | ||
| 277 | 277 | /* visible screen area adjustment */ |
| 278 | 278 | int m_visarea_adjust_min_x; |
| 279 | 279 | int m_visarea_adjust_max_x; |
| 280 | 280 | int m_visarea_adjust_min_y; |
| 281 | 281 | int m_visarea_adjust_max_y; |
| 282 | ||
| 282 | ||
| 283 | 283 | int m_hpixels_per_column; /* number of pixels per video memory address */ |
| 284 | 284 | |
| 285 | 285 | /* if specified, this gets called before any pixel update, |
| 286 | 286 | optionally return a pointer that will be passed to the |
| 287 | 287 | update and tear down callbacks */ |
| 288 | 288 | mc6845_begin_update_delegate m_begin_update_cb; |
| 289 | ||
| 289 | ||
| 290 | 290 | /* this gets called for every row, the driver must output |
| 291 | 291 | x_count * hpixels_per_column pixels. |
| 292 | 292 | cursor_x indicates the character position where the cursor is, or -1 |
| 293 | 293 | if there is no cursor on this row */ |
| 294 | 294 | mc6845_update_row_delegate m_update_row_cb; |
| 295 | ||
| 295 | ||
| 296 | 296 | /* if specified, this gets called after all row updating is complete */ |
| 297 | 297 | mc6845_end_update_delegate m_end_update_cb; |
| 298 | ||
| 298 | ||
| 299 | 299 | /* Called whenever the update address changes |
| 300 | 300 | * For vblank/hblank timing strobe indicates the physical update. |
| 301 | 301 | * vblank/hblank timing not supported yet! */ |
| 302 | 302 | mc6845_on_update_addr_changed_delegate m_on_update_addr_changed_cb; |
| 303 | ||
| 303 | ||
| 304 | 304 | /* if specified, this gets called for every change of the disply enable pin (pin 18) */ |
| 305 | 305 | devcb_write_line m_out_de_cb; |
| 306 | ||
| 306 | ||
| 307 | 307 | /* if specified, this gets called for every change of the cursor pin (pin 19) */ |
| 308 | 308 | devcb_write_line m_out_cur_cb; |
| 309 | ||
| 309 | ||
| 310 | 310 | /* if specified, this gets called for every change of the HSYNC pin (pin 39) */ |
| 311 | 311 | devcb_write_line m_out_hsync_cb; |
| 312 | ||
| 312 | ||
| 313 | 313 | /* if specified, this gets called for every change of the VSYNC pin (pin 40) */ |
| 314 | 314 | devcb_write_line m_out_vsync_cb; |
| 315 | 315 | }; |
| r31374 | r31375 | |
|---|---|---|
| 39 | 39 | ***************************************************************************/ |
| 40 | 40 | |
| 41 | 41 | #define MCFG_VOODOO_FBMEM(_value) \ |
| 42 | voodoo_device::static_set_fbmem(*device, _value); | |
| 42 | voodoo_device::static_set_fbmem(*device, _value); | |
| 43 | 43 | |
| 44 | 44 | #define MCFG_VOODOO_TMUMEM(_value1, _value2) \ |
| 45 | voodoo_device::static_set_tmumem(*device, _value1, _value2); | |
| 45 | voodoo_device::static_set_tmumem(*device, _value1, _value2); | |
| 46 | 46 | |
| 47 | 47 | #define MCFG_VOODOO_SCREEN_TAG(_tag) \ |
| 48 | voodoo_device::static_set_screen_tag(*device, _tag); | |
| 48 | voodoo_device::static_set_screen_tag(*device, _tag); | |
| 49 | 49 | |
| 50 | 50 | #define MCFG_VOODOO_CPU_TAG(_tag) \ |
| 51 | voodoo_device::static_set_cpu_tag(*device, _tag); | |
| 51 | voodoo_device::static_set_cpu_tag(*device, _tag); | |
| 52 | 52 | |
| 53 | 53 | #define MCFG_VOODOO_VBLANK_CB(_devcb) \ |
| 54 | 54 | devcb = &voodoo_device::static_set_vblank_callback(*device, DEVCB_##_devcb); |
| 55 | ||
| 55 | ||
| 56 | 56 | #define MCFG_VOODOO_STALL_CB(_devcb) \ |
| 57 | 57 | devcb = &voodoo_device::static_set_stall_callback(*device, DEVCB_##_devcb); |
| 58 | ||
| 59 | 58 | |
| 59 | ||
| 60 | 60 | /*************************************************************************** |
| 61 | 61 | FUNCTION PROTOTYPES |
| 62 | 62 | ***************************************************************************/ |
| r31374 | r31375 | |
| 81 | 81 | static void static_set_cpu_tag(device_t &device, const char *tag) { downcast<voodoo_device &>(device).m_cputag = tag; } |
| 82 | 82 | 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); } |
| 83 | 83 | 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 | ||
| 85 | 85 | DECLARE_READ32_MEMBER( voodoo_r ); |
| 86 | 86 | DECLARE_WRITE32_MEMBER( voodoo_w ); |
| 87 | 87 | |
| 88 | 88 | // access to legacy token |
| 89 | 89 | struct voodoo_state *token() const { assert(m_token != NULL); return m_token; } |
| 90 | 90 | void common_start_voodoo(UINT8 type); |
| 91 | ||
| 91 | ||
| 92 | 92 | UINT8 m_fbmem; |
| 93 | 93 | UINT8 m_tmumem0; |
| 94 | 94 | UINT8 m_tmumem1; |
| r31374 | r31375 | |
| 96 | 96 | const char * m_cputag; |
| 97 | 97 | devcb_write_line m_vblank; |
| 98 | 98 | devcb_write_line m_stall; |
| 99 | ||
| 99 | ||
| 100 | 100 | protected: |
| 101 | 101 | // device-level overrides |
| 102 | 102 | virtual void device_config_complete(); |
| r31374 | r31375 | |
|---|---|---|
| 135 | 135 | 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); } |
| 136 | 136 | 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); } |
| 137 | 137 | 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 | ||
| 139 | 139 | DECLARE_WRITE8_MEMBER(port_w); |
| 140 | 140 | DECLARE_WRITE8_MEMBER(palette_w); |
| 141 | 141 | DECLARE_READ8_MEMBER(port_r); |
| r31374 | r31375 | |
| 221 | 221 | devcb_read8 m_lightpen_button_cb; |
| 222 | 222 | devcb_read8 m_lightpen_x_cb; |
| 223 | 223 | devcb_read8 m_lightpen_y_cb; |
| 224 | ||
| 224 | ||
| 225 | 225 | /* C64 memory access */ |
| 226 | 226 | devcb_read8 m_c64_mem_r_cb; |
| 227 | 227 | |
| r31374 | r31375 | |
| 239 | 239 | |
| 240 | 240 | #define MCFG_VIC3_CPU(_tag) \ |
| 241 | 241 | vic3_device::static_set_cpu_tag(*device, "^"_tag); |
| 242 | ||
| 242 | ||
| 243 | 243 | #define MCFG_VIC3_TYPE(_type) \ |
| 244 | 244 | vic3_device::set_vic3_type(*device, _type); |
| 245 | ||
| 245 | ||
| 246 | 246 | #define MCFG_VIC3_DMA_READ_CB(_devcb) \ |
| 247 | 247 | devcb = &vic3_device::set_dma_read_callback(*device, DEVCB_##_devcb); |
| 248 | 248 |
| r31374 | r31375 | |
|---|---|---|
| 29 | 29 | dev.m_width = w; |
| 30 | 30 | dev.m_height = h; |
| 31 | 31 | } |
| 32 | ||
| 32 | ||
| 33 | 33 | // device interface |
| 34 | 34 | DECLARE_WRITE8_MEMBER(control_write); |
| 35 | 35 | DECLARE_READ8_MEMBER(control_read); |
| r31374 | r31375 | |
|---|---|---|
| 108 | 108 | |
| 109 | 109 | // register interface |
| 110 | 110 | int m_reg_access_phase; |
| 111 | ||
| 111 | ||
| 112 | 112 | int m_row_col_written; |
| 113 | 113 | int m_bamp_written; |
| 114 | 114 | 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; | |
| 119 | 119 | |
| 120 | 120 | int m_scanline; // scanline counter |
| 121 | 121 | int m_blink, m_blink_count; // blinking |
| r31374 | r31375 | |
|---|---|---|
| 73 | 73 | |
| 74 | 74 | const address_space_config m_space_config; |
| 75 | 75 | required_device<palette_device> m_palette; |
| 76 | ||
| 76 | ||
| 77 | 77 | UINT8 m_split_read_reg; // read register index is separated, seen in rltennis |
| 78 | 78 | }; |
| 79 | 79 |
| r31374 | r31375 | |
|---|---|---|
| 269 | 269 | // callbacks |
| 270 | 270 | devcb_write_line m_write_hsync; |
| 271 | 271 | devcb_write_line m_write_fsync; |
| 272 | ||
| 272 | ||
| 273 | 273 | /* if specified, this reads the external char rom off of the driver state */ |
| 274 | 274 | // moved here from mc6847_base_device so to be useable in GIME |
| 275 | 275 | mc6847_get_char_rom_delegate m_charrom_cb; |
| 276 | ||
| 276 | ||
| 277 | 277 | // incidentals |
| 278 | 278 | character_map m_character_map; |
| 279 | 279 | artifacter m_artifacter; |
| r31374 | r31375 | |
| 546 | 546 | virtual void field_sync_changed(bool line); |
| 547 | 547 | virtual void record_body_scanline(UINT16 physical_scanline, UINT16 scanline); |
| 548 | 548 | virtual void record_partial_body_scanline(UINT16 physical_scanline, UINT16 logical_scanline, INT32 start_clock, INT32 end_clock); |
| 549 | ||
| 549 | ||
| 550 | 550 | void set_custom_palette(const pixel_t *custom_palette) |
| 551 | 551 | { |
| 552 | 552 | if ( m_palette != m_bw_palette ) |
| r31374 | r31375 | |
| 568 | 568 | static const UINT32 s_palette[PALETTE_LENGTH]; |
| 569 | 569 | |
| 570 | 570 | // callbacks |
| 571 | ||
| 571 | ||
| 572 | 572 | /* if specified, this gets called whenever reading a byte (offs_t ~0 specifies DA* entering the tristate mode) */ |
| 573 | 573 | devcb_read8 m_input_cb; |
| 574 | 574 | |
| r31374 | r31375 | |
| 616 | 616 | |
| 617 | 617 | // setup functions |
| 618 | 618 | void setup_fixed_mode(); |
| 619 | ||
| 619 | ||
| 620 | 620 | // runtime functions |
| 621 | 621 | void record_body_scanline(UINT16 physical_scanline, UINT16 scanline, INT32 start_pos, INT32 end_pos); |
| 622 | 622 | pixel_t border_value(UINT8 mode, const pixel_t *palette, bool is_mc6847t1); |
| r31374 | r31375 | |
| 678 | 678 | { |
| 679 | 679 | public: |
| 680 | 680 | s68047_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock); |
| 681 | ||
| 681 | ||
| 682 | 682 | void hack_black_becomes_blue(bool flag); |
| 683 | 683 | |
| 684 | 684 | private: |
| r31374 | r31375 | |
| 687 | 687 | |
| 688 | 688 | class m5c6847p1_device : public mc6847_base_device |
| 689 | 689 | { |
| 690 | public: | |
| 690 | public: | |
| 691 | 691 | m5c6847p1_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock); |
| 692 | 692 | }; |
| 693 | 693 |
| r31374 | r31375 | |
|---|---|---|
| 54 | 54 | struct SNES_SCANLINE |
| 55 | 55 | { |
| 56 | 56 | int enable, clip; |
| 57 | ||
| 57 | ||
| 58 | 58 | UINT16 buffer[SNES_SCR_WIDTH]; |
| 59 | 59 | UINT8 priority[SNES_SCR_WIDTH]; |
| 60 | 60 | UINT8 layer[SNES_SCR_WIDTH]; |
| r31374 | r31375 | |
| 74 | 74 | 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); } |
| 75 | 75 | |
| 76 | 76 | UINT8 m_regs[0x40]; |
| 77 | ||
| 77 | ||
| 78 | 78 | SNES_SCANLINE m_scanlines[2]; |
| 79 | ||
| 79 | ||
| 80 | 80 | struct |
| 81 | 81 | { |
| 82 | 82 | /* clipmasks */ |
| r31374 | r31375 | |
| 85 | 85 | UINT8 wlog_mask; |
| 86 | 86 | /* color math enabled */ |
| 87 | 87 | UINT8 color_math; |
| 88 | ||
| 88 | ||
| 89 | 89 | UINT8 charmap; |
| 90 | 90 | UINT8 tilemap; |
| 91 | 91 | UINT8 tilemap_size; |
| 92 | ||
| 92 | ||
| 93 | 93 | UINT8 tile_size; |
| 94 | 94 | UINT8 mosaic_enabled; // actually used only for layers 0->3! |
| 95 | ||
| 95 | ||
| 96 | 96 | UINT8 main_window_enabled; |
| 97 | 97 | UINT8 sub_window_enabled; |
| 98 | 98 | UINT8 main_bg_enabled; |
| 99 | 99 | UINT8 sub_bg_enabled; |
| 100 | ||
| 100 | ||
| 101 | 101 | UINT16 hoffs; |
| 102 | 102 | UINT16 voffs; |
| 103 | 103 | } m_layer[6]; // this is for the BG1 - BG2 - BG3 - BG4 - OBJ - color layers |
| 104 | ||
| 104 | ||
| 105 | 105 | struct |
| 106 | 106 | { |
| 107 | 107 | UINT8 address_low; |
| r31374 | r31375 | |
| 119 | 119 | UINT8 flip; |
| 120 | 120 | UINT16 write_latch; |
| 121 | 121 | } m_oam; |
| 122 | ||
| 122 | ||
| 123 | 123 | struct |
| 124 | 124 | { |
| 125 | 125 | UINT16 latch_horz; |
| r31374 | r31375 | |
| 129 | 129 | UINT8 last_visible_line; |
| 130 | 130 | UINT8 interlace_count; |
| 131 | 131 | } m_beam; |
| 132 | ||
| 132 | ||
| 133 | 133 | struct |
| 134 | 134 | { |
| 135 | 135 | UINT8 repeat; |
| r31374 | r31375 | |
| 145 | 145 | UINT16 ver_offset; |
| 146 | 146 | UINT8 extbg; |
| 147 | 147 | } m_mode7; |
| 148 | ||
| 148 | ||
| 149 | 149 | struct OAM |
| 150 | 150 | { |
| 151 | 151 | UINT16 tile; |
| r31374 | r31375 | |
| 153 | 153 | UINT8 size, vflip, hflip, priority_bits, pal; |
| 154 | 154 | int height, width; |
| 155 | 155 | }; |
| 156 | ||
| 156 | ||
| 157 | 157 | struct OAM m_oam_spritelist[SNES_SCR_WIDTH / 2]; |
| 158 | ||
| 158 | ||
| 159 | 159 | UINT8 m_oam_itemlist[32]; |
| 160 | ||
| 160 | ||
| 161 | 161 | struct TILELIST { |
| 162 | 162 | INT16 x; |
| 163 | 163 | UINT16 priority, pal, tileaddr; |
| 164 | 164 | int hflip; |
| 165 | 165 | }; |
| 166 | ||
| 166 | ||
| 167 | 167 | struct TILELIST m_oam_tilelist[34]; |
| 168 | ||
| 168 | ||
| 169 | 169 | #if SNES_LAYER_DEBUG |
| 170 | 170 | struct DEBUGOPTS |
| 171 | 171 | { |
| r31374 | r31375 | |
| 180 | 180 | }; |
| 181 | 181 | struct DEBUGOPTS m_debug_options; |
| 182 | 182 | #endif |
| 183 | ||
| 183 | ||
| 184 | 184 | UINT8 m_mosaic_size; |
| 185 | 185 | UINT8 m_clip_to_black; |
| 186 | 186 | UINT8 m_prevent_color_math; |
| r31374 | r31375 | |
| 188 | 188 | UINT8 m_bg3_priority_bit; |
| 189 | 189 | UINT8 m_direct_color; |
| 190 | 190 | UINT8 m_ppu_last_scroll; /* as per Anomie's doc and Theme Park, all scroll regs shares (but mode 7 ones) the same |
| 191 | ||
| 191 | 'previous' scroll value */ | |
| 192 | 192 | 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 | ||
| 194 | 194 | UINT8 m_ppu1_open_bus, m_ppu2_open_bus; |
| 195 | 195 | UINT8 m_ppu1_version, m_ppu2_version; |
| 196 | 196 | UINT8 m_window1_left, m_window1_right, m_window2_left, m_window2_right; |
| 197 | ||
| 197 | ||
| 198 | 198 | UINT16 m_mosaic_table[16][4096]; |
| 199 | 199 | UINT8 m_clipmasks[6][SNES_SCR_WIDTH]; |
| 200 | 200 | UINT8 m_update_windows; |
| r31374 | r31375 | |
| 209 | 209 | UINT8 m_color_modes; |
| 210 | 210 | UINT8 m_stat77; |
| 211 | 211 | UINT8 m_stat78; |
| 212 | ||
| 212 | ||
| 213 | 213 | UINT16 m_htmult; /* in 512 wide, we run HTOTAL double and halve it on latching */ |
| 214 | 214 | UINT16 m_cgram_address; /* CGRAM address */ |
| 215 | 215 | UINT8 m_read_ophct; |
| r31374 | r31375 | |
| 221 | 221 | UINT16 m_vram_fgr_shift; |
| 222 | 222 | UINT16 m_vram_read_buffer; |
| 223 | 223 | UINT16 m_vmadd; |
| 224 | ||
| 224 | ||
| 225 | 225 | inline UINT16 get_bgcolor(UINT8 direct_colors, UINT16 palette, UINT8 color); |
| 226 | 226 | inline void set_scanline_pixel(int screen, INT16 x, UINT16 color, UINT8 priority, UINT8 layer, int blend); |
| 227 | 227 | inline void draw_bgtile_lores(UINT8 layer, INT16 ii, UINT8 colour, UINT16 pal, UINT8 direct_colors, UINT8 priority); |
| r31374 | r31375 | |
| 249 | 249 | void update_offsets(void); |
| 250 | 250 | inline void draw_blend(UINT16 offset, UINT16 *colour, UINT8 prevent_color_math, UINT8 black_pen_clip, int switch_screens); |
| 251 | 251 | void refresh_scanline(running_machine &machine, bitmap_rgb32 &bitmap, UINT16 curline); |
| 252 | ||
| 252 | ||
| 253 | 253 | void latch_counters(running_machine &machine); |
| 254 | 254 | void dynamic_res_change(running_machine &machine); |
| 255 | 255 | inline UINT32 get_vram_address(running_machine &machine); |
| 256 | 256 | UINT8 dbg_video(running_machine &machine, UINT16 curline); |
| 257 | ||
| 257 | ||
| 258 | 258 | UINT8 read(address_space &space, UINT32 offset, UINT8 wrio_bit7); |
| 259 | 259 | void write(address_space &space, UINT32 offset, UINT8 data); |
| 260 | ||
| 260 | ||
| 261 | 261 | DECLARE_READ8_MEMBER( oam_read ); |
| 262 | 262 | DECLARE_WRITE8_MEMBER( oam_write ); |
| 263 | 263 | DECLARE_READ8_MEMBER( cgram_read ); |
| r31374 | r31375 | |
| 271 | 271 | protected: |
| 272 | 272 | // device-level overrides |
| 273 | 273 | virtual void device_start(); |
| 274 | virtual void device_reset() {}; | |
| 274 | virtual void device_reset() {}; | |
| 275 | 275 | |
| 276 | 276 | private: |
| 277 | 277 | devcb_read16 m_openbus_cb; |
| r31374 | r31375 | |
|---|---|---|
| 59 | 59 | public: |
| 60 | 60 | crtc_ega_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock); |
| 61 | 61 | |
| 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) | |
| 63 | 63 | { 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) | |
| 65 | 65 | { 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) | |
| 67 | 67 | { 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) | |
| 69 | 69 | { return downcast<crtc_ega_device &>(device).m_res_out_vblank_cb.set_callback(object); } |
| 70 | 70 | |
| 71 | 71 | 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; } |
| 72 | 72 | 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; } |
| 73 | 73 | 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; } |
| 74 | 74 | 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 | ||
| 76 | 76 | /* select one of the registers for reading or writing */ |
| 77 | 77 | DECLARE_WRITE8_MEMBER( address_w ); |
| 78 | 78 | |
| r31374 | r31375 | |
| 119 | 119 | optionally return a pointer that will be passed to the |
| 120 | 120 | update and tear down callbacks */ |
| 121 | 121 | crtc_ega_begin_update_delegate m_begin_update_cb; |
| 122 | ||
| 122 | ||
| 123 | 123 | /* this gets called for every row, the driver must output |
| 124 | 124 | x_count * hpixels_per_column pixels. |
| 125 | 125 | cursor_x indicates the character position where the cursor is, or -1 |
| 126 | 126 | if there is no cursor on this row */ |
| 127 | 127 | crtc_ega_row_update_delegate m_row_update_cb; |
| 128 | ||
| 128 | ||
| 129 | 129 | /* if specified, this gets called after all row updating is complete */ |
| 130 | 130 | crtc_ega_end_update_delegate m_end_update_cb; |
| 131 | ||
| 131 | ||
| 132 | 132 | /* ega/vga register file */ |
| 133 | 133 | UINT8 m_horiz_char_total; /* 0x00 */ |
| 134 | 134 | UINT8 m_horiz_disp; /* 0x01 */ |
| r31374 | r31375 | |
|---|---|---|
| 3400 | 3400 | /* add clocal or alocal to alpha */ \ |
| 3401 | 3401 | if (FBZCP_CCA_ADD_ACLOCAL(FBZCOLORPATH)) \ |
| 3402 | 3402 | a += c_local.rgb.a; \ |
| 3403 | ||
| 3403 | \ | |
| 3404 | 3404 | /* clamp */ \ |
| 3405 | 3405 | CLAMP(a, 0x00, 0xff); \ |
| 3406 | | |
| 3406 | \ | |
| 3407 | 3407 | /* invert */ \ |
| 3408 | 3408 | if (FBZCP_CCA_INVERT_OUTPUT(FBZCOLORPATH)) \ |
| 3409 | 3409 | a ^= 0xff; \ |
| r31374 | r31375 | |
|---|---|---|
| 46 | 46 | #define MCFG_HUC6202_WRITE_1_CB(_devcb) \ |
| 47 | 47 | devcb = &huc6202_device::set_write_1_callback(*device, DEVCB_##_devcb); |
| 48 | 48 | |
| 49 | ||
| 49 | ||
| 50 | 50 | class huc6202_device : public device_t |
| 51 | 51 | { |
| 52 | 52 | public: |
| 53 | 53 | // construction/destruction |
| 54 | 54 | huc6202_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock); |
| 55 | ||
| 55 | ||
| 56 | 56 | 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); } |
| 57 | 57 | 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); } |
| 58 | 58 | 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); } |
| r31374 | r31375 | |
| 65 | 65 | 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); } |
| 66 | 66 | 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); } |
| 67 | 67 | 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 | ||
| 69 | 69 | DECLARE_READ8_MEMBER( read ); |
| 70 | 70 | DECLARE_WRITE8_MEMBER( write ); |
| 71 | 71 | DECLARE_READ8_MEMBER( io_read ); |
| r31374 | r31375 | |
|---|---|---|
| 39 | 39 | #define TMS9928A_VERT_DISPLAY_START_PAL (13 + 51) |
| 40 | 40 | #define TMS9928A_VERT_DISPLAY_START_NTSC (13 + 27) |
| 41 | 41 | |
| 42 | // | |
| 42 | // MCFG_DEVICE_ADD(_tag, _variant, XTAL_10_738635MHz / 2 ) | |
| 43 | 43 | |
| 44 | 44 | #define MCFG_TMS9928A_VRAM_SIZE(_size) \ |
| 45 | 45 | tms9928a_device::set_vram_size(*device, _size); |
| 46 | 46 | |
| 47 | 47 | #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); | |
| 49 | 49 | |
| 50 | 50 | #define MCFG_TMS9928A_SET_SCREEN MCFG_VIDEO_SET_SCREEN |
| 51 | 51 | |
| r31374 | r31375 | |
| 85 | 85 | |
| 86 | 86 | static void set_vram_size(device_t &device, int vram_size) { downcast<tms9928a_device &>(device).m_vram_size = vram_size; } |
| 87 | 87 | 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 | ||
| 89 | 89 | DECLARE_READ8_MEMBER( vram_read ); |
| 90 | 90 | DECLARE_WRITE8_MEMBER( vram_write ); |
| 91 | 91 | DECLARE_READ8_MEMBER( register_read ); |
| r31374 | r31375 | |
| 115 | 115 | void set_palette(); |
| 116 | 116 | |
| 117 | 117 | static const device_timer_id TIMER_LINE = 0; |
| 118 | ||
| 118 | ||
| 119 | 119 | int m_vram_size; /* 4K, 8K, or 16K. This should be replaced by fetching data from an address space? */ |
| 120 | 120 | devcb_write_line m_out_int_line_cb; /* Callback is called whenever the state of the INT output changes */ |
| 121 | 121 |
| r31374 | r31375 | |
|---|---|---|
| 23 | 23 | //************************************************************************** |
| 24 | 24 | |
| 25 | 25 | const int STREAM_SYNC = -1; // special rate value indicating a one-sample-at-a-time stream |
| 26 | ||
| 26 | // with actual rate defined by its input | |
| 27 | 27 | |
| 28 | 28 | //************************************************************************** |
| 29 | 29 | // MACROS |
| r31374 | r31375 | |
|---|---|---|
| 221 | 221 | public: |
| 222 | 222 | // construction/destruction |
| 223 | 223 | gb_rom_licheng_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock); |
| 224 | ||
| 224 | ||
| 225 | 225 | virtual DECLARE_WRITE8_MEMBER(write_bank); |
| 226 | 226 | }; |
| 227 | 227 |
| r31374 | r31375 | |
|---|---|---|
| 89 | 89 | // construction/destruction |
| 90 | 90 | tvcexp_slot_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock); |
| 91 | 91 | virtual ~tvcexp_slot_device(); |
| 92 | ||
| 92 | ||
| 93 | 93 | 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); } |
| 94 | 94 | 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); } |
| 95 | 95 | |
| r31374 | r31375 | |
| 124 | 124 | |
| 125 | 125 | #define MCFG_TVCEXP_SLOT_OUT_NMI_CB(_devcb) \ |
| 126 | 126 | devcb = &tvcexp_slot_device::set_out_nmi_callback(*device, DEVCB_##_devcb); |
| 127 | ||
| 127 | ||
| 128 | 128 | #endif /* __TVCEXP_H__ */ |
| r31374 | r31375 | |
|---|---|---|
| 85 | 85 | |
| 86 | 86 | #define MCFG_X68K_EXPANSION_SLOT_OUT_RESET_CB(_devcb) \ |
| 87 | 87 | devcb = &x68k_expansion_slot_device::set_out_reset_callback(*device, DEVCB_##_devcb); |
| 88 | ||
| 89 | 88 | |
| 89 | ||
| 90 | 90 | //************************************************************************** |
| 91 | 91 | // TYPE DEFINITIONS |
| 92 | 92 | //************************************************************************** |
| r31374 | r31375 | |
| 115 | 115 | // construction/destruction |
| 116 | 116 | x68k_expansion_slot_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock); |
| 117 | 117 | virtual ~x68k_expansion_slot_device(); |
| 118 | ||
| 118 | ||
| 119 | 119 | 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); } |
| 120 | 120 | 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); } |
| 121 | 121 | 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); } |
| r31374 | r31375 | |
|---|---|---|
| 46 | 46 | cococart_line_value value; |
| 47 | 47 | int line; |
| 48 | 48 | int q_count; |
| 49 | devcb_write_line | |
| 49 | devcb_write_line *callback; | |
| 50 | 50 | }; |
| 51 | 51 | |
| 52 | 52 | // ======================> cococart_base_update_delegate |
| r31374 | r31375 | |
| 56 | 56 | |
| 57 | 57 | #define MCFG_COCO_CARTRIDGE_CART_CB(_devcb) \ |
| 58 | 58 | devcb = &cococart_slot_device::static_set_cart_callback(*device, DEVCB_##_devcb); |
| 59 | ||
| 59 | ||
| 60 | 60 | #define MCFG_COCO_CARTRIDGE_NMI_CB(_devcb) \ |
| 61 | 61 | devcb = &cococart_slot_device::static_set_nmi_callback(*device, DEVCB_##_devcb); |
| 62 | ||
| 62 | ||
| 63 | 63 | #define MCFG_COCO_CARTRIDGE_HALT_CB(_devcb) \ |
| 64 | 64 | devcb = &cococart_slot_device::static_set_halt_callback(*device, DEVCB_##_devcb); |
| 65 | ||
| 66 | 65 | |
| 66 | ||
| 67 | 67 | // ======================> cococart_slot_device |
| 68 | 68 | class device_cococart_interface; |
| 69 | 69 | |
| r31374 | r31375 | |
| 78 | 78 | 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); } |
| 79 | 79 | 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); } |
| 80 | 80 | 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 | ||
| 82 | 82 | // device-level overrides |
| 83 | 83 | virtual void device_start(); |
| 84 | 84 | virtual void device_config_complete(); |
| r31374 | r31375 | |
| 128 | 128 | coco_cartridge_line m_cart_line; |
| 129 | 129 | coco_cartridge_line m_nmi_line; |
| 130 | 130 | coco_cartridge_line m_halt_line; |
| 131 | public: | |
| 132 | devcb_write_line m_cart_callback; | |
| 133 | devcb_write_line m_nmi_callback; | |
| 134 | devcb_write_line m_halt_callback; | |
| 131 | public: | |
| 132 | devcb_write_line m_cart_callback; | |
| 133 | devcb_write_line m_nmi_callback; | |
| 134 | devcb_write_line m_halt_callback; | |
| 135 | 135 | private: |
| 136 | 136 | // cartridge |
| 137 | 137 | device_cococart_interface *m_cart; |
| r31374 | r31375 | |
|---|---|---|
| 38 | 38 | |
| 39 | 39 | #define MCFG_NUBUS_OUT_IRQE_CB(_devcb) \ |
| 40 | 40 | devcb = &nubus_device::set_out_irqe_callback(*device, DEVCB_##_devcb); |
| 41 | ||
| 41 | ||
| 42 | 42 | #define MCFG_NUBUS_SLOT_ADD(_nbtag, _tag, _slot_intf, _def_slot) \ |
| 43 | 43 | MCFG_DEVICE_ADD(_tag, NUBUS_SLOT, 0) \ |
| 44 | 44 | MCFG_DEVICE_SLOT_INTERFACE(_slot_intf, _def_slot, false) \ |
| r31374 | r31375 | |
| 88 | 88 | nubus_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock); |
| 89 | 89 | 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); |
| 90 | 90 | ~nubus_device() { m_device_list.detach_all(); } |
| 91 | ||
| 91 | ||
| 92 | 92 | // inline configuration |
| 93 | 93 | static void static_set_cputag(device_t &device, const char *tag); |
| 94 | 94 | 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); } |
| r31374 | r31375 | |
|---|---|---|
| 21 | 21 | |
| 22 | 22 | #define MCFG_BML3BUS_CPU(_cputag) \ |
| 23 | 23 | bml3bus_device::static_set_cputag(*device, _cputag); |
| 24 | ||
| 24 | ||
| 25 | 25 | #define MCFG_BML3BUS_OUT_NMI_CB(_devcb) \ |
| 26 | 26 | devcb = &bml3bus_device::set_out_nmi_callback(*device, DEVCB_##_devcb); |
| 27 | 27 | |
| r31374 | r31375 | |
| 79 | 79 | // construction/destruction |
| 80 | 80 | bml3bus_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock); |
| 81 | 81 | 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 | ||
| 83 | 83 | // inline configuration |
| 84 | 84 | static void static_set_cputag(device_t &device, const char *tag); |
| 85 | 85 | 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); } |
| r31374 | r31375 | |
|---|---|---|
| 79 | 79 | // construction/destruction |
| 80 | 80 | iq151cart_slot_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock); |
| 81 | 81 | virtual ~iq151cart_slot_device(); |
| 82 | ||
| 82 | ||
| 83 | 83 | 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); } |
| 84 | 84 | 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); } |
| 85 | 85 | 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); } |
| r31374 | r31375 | |
|---|---|---|
| 88 | 88 | MCFG_DEVICE_MODIFY(_tag ) \ |
| 89 | 89 | MCFG_SLOT_OPTION_ADD( _option, _type ) \ |
| 90 | 90 | MCFG_SLOT_OPTION_DEVICE_INPUT_DEFAULTS( _option, _id ) \ |
| 91 | MCFG_SLOT_DEFAULT_OPTION( _option ) \ | |
| 92 | ||
| 91 | MCFG_SLOT_DEFAULT_OPTION( _option ) | |
| 93 | 92 | #endif |
| r31374 | r31375 | |
|---|---|---|
| 28 | 28 | // ======================> epson_ex800_t |
| 29 | 29 | |
| 30 | 30 | class epson_ex800_t : public device_t, |
| 31 | | |
| 31 | public device_centronics_peripheral_interface | |
| 32 | 32 | { |
| 33 | 33 | public: |
| 34 | 34 | // construction/destruction |
| r31374 | r31375 | |
|---|---|---|
| 29 | 29 | // ======================> epson_lx800_t |
| 30 | 30 | |
| 31 | 31 | class epson_lx800_t : public device_t, |
| 32 | | |
| 32 | public device_centronics_peripheral_interface | |
| 33 | 33 | { |
| 34 | 34 | public: |
| 35 | 35 | // construction/destruction |
| r31374 | r31375 | |
|---|---|---|
| 1 | 1 | /*************************************************************************** |
| 2 | 2 | |
| 3 | ||
| 3 | VTech Laser/VZ Memory Expansions | |
| 4 | 4 | |
| 5 | 5 | license: MAME, GPL-2.0+ |
| 6 | 6 | copyright-holders: Dirk Best |
| r31374 | r31375 | |
|---|---|---|
| 1 | 1 | /*************************************************************************** |
| 2 | 2 | |
| 3 | ||
| 3 | VTech Laser/VZ Floppy Controller Cartridge | |
| 4 | 4 | |
| 5 | 5 | license: MAME, GPL-2.0+ |
| 6 | 6 | copyright-holders: Dirk Best |
| 7 | 7 | |
| 8 | ||
| 8 | Laser DD 20 | |
| 9 | 9 | Dick Smith Electronics X-7304 |
| 10 | 10 | |
| 11 | 11 | ***************************************************************************/ |
| r31374 | r31375 | |
|---|---|---|
| 1 | 1 | /*************************************************************************** |
| 2 | 2 | |
| 3 | ||
| 3 | VTech Laser/VZ Memory Expansion Slot | |
| 4 | 4 | |
| 5 | 5 | license: MAME, GPL-2.0+ |
| 6 | 6 | copyright-holders: Dirk Best |
| 7 | 7 | |
| 8 | ||
| 8 | 44-pin slot | |
| 9 | 9 | |
| 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 | |
| 32 | 32 | |
| 33 | 33 | ***************************************************************************/ |
| 34 | 34 |
| r31374 | r31375 | |
|---|---|---|
| 1 | 1 | /*************************************************************************** |
| 2 | 2 | |
| 3 | ||
| 3 | Dick Smith VZ-200/300 RS-232 Cartridge | |
| 4 | 4 | |
| 5 | 5 | license: MAME, GPL-2.0+ |
| 6 | 6 | copyright-holders: Dirk Best |
| r31374 | r31375 | |
|---|---|---|
| 1 | 1 | /*************************************************************************** |
| 2 | 2 | |
| 3 | ||
| 3 | VTech Laser/VZ Memory Expansion Slot Devices | |
| 4 | 4 | |
| 5 | 5 | ***************************************************************************/ |
| 6 | 6 |
| r31374 | r31375 | |
|---|---|---|
| 1 | 1 | /*************************************************************************** |
| 2 | 2 | |
| 3 | ||
| 3 | Dick Smith VZ-300 WordPro Cartridge | |
| 4 | 4 | |
| 5 | 5 | license: MAME, GPL-2.0+ |
| 6 | 6 | copyright-holders: Dirk Best |
| r31374 | r31375 | |
|---|---|---|
| 1 | 1 | /*************************************************************************** |
| 2 | 2 | |
| 3 | ||
| 3 | VTech Laser Joystick Interface | |
| 4 | 4 | |
| 5 | 5 | license: MAME, GPL-2.0+ |
| 6 | 6 | copyright-holders: Dirk Best |
| r31374 | r31375 | |
|---|---|---|
| 1 | 1 | /*************************************************************************** |
| 2 | 2 | |
| 3 | ||
| 3 | VTech Laser/VZ Printer Interface | |
| 4 | 4 | |
| 5 | 5 | license: MAME, GPL-2.0+ |
| 6 | 6 | copyright-holders: Dirk Best |
| r31374 | r31375 | |
|---|---|---|
| 1 | 1 | /*************************************************************************** |
| 2 | 2 | |
| 3 | ||
| 3 | VTech Laser/VZ I/O Expansion Slot | |
| 4 | 4 | |
| 5 | 5 | license: MAME, GPL-2.0+ |
| 6 | 6 | copyright-holders: Dirk Best |
| 7 | 7 | |
| 8 | ||
| 8 | 30-pin slot | |
| 9 | 9 | |
| 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 | |
| 25 | 25 | |
| 26 | 26 | ***************************************************************************/ |
| 27 | 27 |
| r31374 | r31375 | |
|---|---|---|
| 1 | 1 | /*************************************************************************** |
| 2 | 2 | |
| 3 | ||
| 3 | VTech Laser/VZ I/O Expansion Slot Devices | |
| 4 | 4 | |
| 5 | 5 | ***************************************************************************/ |
| 6 | 6 |
| r31374 | r31375 | |
|---|---|---|
| 106 | 106 | virtual bool take_c800() { return false; } |
| 107 | 107 | |
| 108 | 108 | private: |
| 109 | a2bus_mcms1_device *m_card1; | |
| 109 | a2bus_mcms1_device *m_card1; // card 1 for passthrough | |
| 110 | 110 | mcms_device *m_engine; |
| 111 | 111 | }; |
| 112 | 112 |
| r31374 | r31375 | |
|---|---|---|
| 20 | 20 | |
| 21 | 21 | #define MCFG_A2EAUXSLOT_CPU(_cputag) \ |
| 22 | 22 | a2eauxslot_device::static_set_cputag(*device, _cputag); |
| 23 | ||
| 23 | ||
| 24 | 24 | #define MCFG_A2EAUXSLOT_OUT_IRQ_CB(_devcb) \ |
| 25 | 25 | devcb = &a2eauxslot_device::set_out_irq_callback(*device, DEVCB_##_devcb); |
| 26 | 26 | |
| 27 | 27 | #define MCFG_A2EAUXSLOT_OUT_NMI_CB(_devcb) \ |
| 28 | 28 | devcb = &a2eauxslot_device::set_out_nmi_callback(*device, DEVCB_##_devcb); |
| 29 | ||
| 29 | ||
| 30 | 30 | #define MCFG_A2EAUXSLOT_SLOT_ADD(_nbtag, _tag, _slot_intf, _def_slot) \ |
| 31 | 31 | MCFG_DEVICE_ADD(_tag, A2EAUXSLOT_SLOT, 0) \ |
| 32 | 32 | MCFG_DEVICE_SLOT_INTERFACE(_slot_intf, _def_slot, false) \ |
| r31374 | r31375 | |
| 71 | 71 | // construction/destruction |
| 72 | 72 | a2eauxslot_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock); |
| 73 | 73 | 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 | ||
| 75 | 75 | // inline configuration |
| 76 | 76 | static void static_set_cputag(device_t &device, const char *tag); |
| 77 | 77 | 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); } |
| 78 | 78 | 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 | ||
| 80 | 80 | void add_a2eauxslot_card(device_a2eauxslot_card_interface *card); |
| 81 | 81 | device_a2eauxslot_card_interface *get_a2eauxslot_card(); |
| 82 | 82 |
| r31374 | r31375 | |
|---|---|---|
| 32 | 32 | |
| 33 | 33 | #define MCFG_A2BUS_OUT_INH_CB(_devcb) \ |
| 34 | 34 | devcb = &a2bus_device::set_out_inh_callback(*device, DEVCB_##_devcb); |
| 35 | ||
| 35 | ||
| 36 | 36 | #define MCFG_A2BUS_SLOT_ADD(_nbtag, _tag, _slot_intf, _def_slot) \ |
| 37 | 37 | MCFG_DEVICE_ADD(_tag, A2BUS_SLOT, 0) \ |
| 38 | 38 | MCFG_DEVICE_SLOT_INTERFACE(_slot_intf, _def_slot, false) \ |
| r31374 | r31375 | |
| 83 | 83 | // construction/destruction |
| 84 | 84 | a2bus_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock); |
| 85 | 85 | 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 | ||
| 87 | 87 | // inline configuration |
| 88 | 88 | static void static_set_cputag(device_t &device, const char *tag); |
| 89 | 89 | 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); } |
| r31374 | r31375 | |
| 104 | 104 | // device-level overrides |
| 105 | 105 | virtual void device_start(); |
| 106 | 106 | virtual void device_reset(); |
| 107 | ||
| 107 | ||
| 108 | 108 | // internal state |
| 109 | 109 | cpu_device *m_maincpu; |
| 110 | 110 |
| r31374 | r31375 | |
|---|---|---|
| 25 | 25 | // ======================> pcml_q_disk_interface_t |
| 26 | 26 | |
| 27 | 27 | class pcml_q_disk_interface_t : public device_t, |
| 28 | | |
| 28 | public device_ql_expansion_card_interface | |
| 29 | 29 | { |
| 30 | 30 | public: |
| 31 | 31 | // construction/destruction |
| r31374 | r31375 | |
|---|---|---|
| 64 | 64 | |
| 65 | 65 | |
| 66 | 66 | #define MCFG_QL_EXPANSION_SLOT_IPL0L_CALLBACK(_write) \ |
| 67 | ||
| 67 | devcb = &ql_expansion_slot_t::set_ipl0l_wr_callback(*device, DEVCB_##_write); | |
| 68 | 68 | |
| 69 | 69 | #define MCFG_QL_EXPANSION_SLOT_IPL1L_CALLBACK(_write) \ |
| 70 | ||
| 70 | devcb = &ql_expansion_slot_t::set_ipl1l_wr_callback(*device, DEVCB_##_write); | |
| 71 | 71 | |
| 72 | 72 | #define MCFG_QL_EXPANSION_SLOT_BERRL_CALLBACK(_write) \ |
| 73 | ||
| 73 | devcb = &ql_expansion_slot_t::set_berrl_wr_callback(*device, DEVCB_##_write); | |
| 74 | 74 | |
| 75 | 75 | #define MCFG_QL_EXPANSION_SLOT_EXTINTL_CALLBACK(_write) \ |
| 76 | 76 | devcb = &ql_expansion_slot_t::set_extintl_wr_callback(*device, DEVCB_##_write); |
| r31374 | r31375 | |
| 93 | 93 | // construction/destruction |
| 94 | 94 | device_ql_expansion_card_interface(const machine_config &mconfig, device_t &device); |
| 95 | 95 | |
| 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) { } | |
| 99 | 99 | |
| 100 | 100 | protected: |
| 101 | 101 | ql_expansion_slot_t *m_slot; |
| 102 | 102 | |
| 103 | ||
| 103 | int m_romoeh; | |
| 104 | 104 | }; |
| 105 | 105 | |
| 106 | 106 | |
| r31374 | r31375 | |
| 113 | 113 | // construction/destruction |
| 114 | 114 | ql_expansion_slot_t(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock); |
| 115 | 115 | |
| 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); } | |
| 119 | 119 | 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); } |
| 120 | 120 | |
| 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); } | |
| 125 | 125 | |
| 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); } | |
| 130 | 130 | DECLARE_WRITE_LINE_MEMBER( extintl_w ) { m_write_extintl(state); } |
| 131 | 131 | |
| 132 | 132 | protected: |
| 133 | 133 | // device-level overrides |
| 134 | 134 | virtual void device_start(); |
| 135 | ||
| 135 | virtual void device_reset() { if (get_card_device()) get_card_device()->reset(); } | |
| 136 | 136 | |
| 137 | 137 | 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; | |
| 141 | 141 | |
| 142 | 142 | device_ql_expansion_card_interface *m_card; |
| 143 | 143 | }; |
| r31374 | r31375 | |
|---|---|---|
| 25 | 25 | // ======================> opd_basic_master_t |
| 26 | 26 | |
| 27 | 27 | class opd_basic_master_t : public device_t, |
| 28 | | |
| 28 | public device_ql_expansion_card_interface | |
| 29 | 29 | { |
| 30 | 30 | public: |
| 31 | 31 | // construction/destruction |
| r31374 | r31375 | |
|---|---|---|
| 27 | 27 | // ======================> ql_trump_card_t |
| 28 | 28 | |
| 29 | 29 | class ql_trump_card_t : public device_t, |
| 30 | | |
| 30 | public device_ql_expansion_card_interface | |
| 31 | 31 | { |
| 32 | 32 | public: |
| 33 | 33 | // construction/destruction |
| r31374 | r31375 | |
|---|---|---|
| 26 | 26 | // ======================> qubide_t |
| 27 | 27 | |
| 28 | 28 | class qubide_t : public device_t, |
| 29 | | |
| 29 | public device_ql_expansion_card_interface | |
| 30 | 30 | { |
| 31 | 31 | public: |
| 32 | 32 | // construction/destruction |
| r31374 | r31375 | |
|---|---|---|
| 25 | 25 | // ======================> cst_ql_disc_interface_t |
| 26 | 26 | |
| 27 | 27 | class cst_ql_disc_interface_t : public device_t, |
| 28 | | |
| 28 | public device_ql_expansion_card_interface | |
| 29 | 29 | { |
| 30 | 30 | public: |
| 31 | 31 | // construction/destruction |
| r31374 | r31375 | |
|---|---|---|
| 28 | 28 | // ======================> sandy_superqboard_t |
| 29 | 29 | |
| 30 | 30 | class sandy_superqboard_t : public device_t, |
| 31 | | |
| 31 | public device_ql_expansion_card_interface | |
| 32 | 32 | { |
| 33 | 33 | public: |
| 34 | 34 | // construction/destruction |
| r31374 | r31375 | |
|---|---|---|
| 2 | 2 | // copyright-holders:Curt Coder |
| 3 | 3 | /********************************************************************** |
| 4 | 4 | |
| 5 | ||
| 5 | Cumana Floppy Disk Interface emulation | |
| 6 | 6 | |
| 7 | 7 | Copyright MESS Team. |
| 8 | 8 | Visit http://mamedev.org for licensing and usage restrictions. |
| r31374 | r31375 | |
| 25 | 25 | // ======================> cumana_floppy_disk_interface_t |
| 26 | 26 | |
| 27 | 27 | class cumana_floppy_disk_interface_t : public device_t, |
| 28 | | |
| 28 | public device_ql_expansion_card_interface | |
| 29 | 29 | { |
| 30 | 30 | public: |
| 31 | 31 | // construction/destruction |
| r31374 | r31375 | |
|---|---|---|
| 25 | 25 | // ======================> miracle_hard_disk_t |
| 26 | 26 | |
| 27 | 27 | class miracle_hard_disk_t : public device_t, |
| 28 | | |
| 28 | public device_ql_rom_cartridge_card_interface | |
| 29 | 29 | { |
| 30 | 30 | public: |
| 31 | 31 | // construction/destruction |
| r31374 | r31375 | |
|---|---|---|
| 64 | 64 | device_ql_rom_cartridge_card_interface(const machine_config &mconfig, device_t &device); |
| 65 | 65 | virtual ~device_ql_rom_cartridge_card_interface(); |
| 66 | 66 | |
| 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) { } | |
| 70 | 70 | |
| 71 | 71 | protected: |
| 72 | 72 | ql_rom_cartridge_slot_t *m_slot; |
| 73 | 73 | |
| 74 | 74 | optional_shared_ptr<UINT8> m_rom; |
| 75 | 75 | |
| 76 | ||
| 76 | int m_romoeh; | |
| 77 | 77 | }; |
| 78 | 78 | |
| 79 | 79 |
| r31374 | r31375 | |
|---|---|---|
| 25 | 25 | // ======================> micro_peripherals_floppy_disk_interface_t |
| 26 | 26 | |
| 27 | 27 | class micro_peripherals_floppy_disk_interface_t : public device_t, |
| 28 | | |
| 28 | public device_ql_expansion_card_interface | |
| 29 | 29 | { |
| 30 | 30 | public: |
| 31 | 31 | // construction/destruction |
| r31374 | r31375 | |
|---|---|---|
| 26 | 26 | // ======================> cst_q_plus4_t |
| 27 | 27 | |
| 28 | 28 | class cst_q_plus4_t : public device_t, |
| 29 | | |
| 29 | public device_ql_expansion_card_interface | |
| 30 | 30 | { |
| 31 | 31 | public: |
| 32 | 32 | // construction/destruction |
| r31374 | r31375 | |
|---|---|---|
| 28 | 28 | // ======================> sandy_super_disk_device |
| 29 | 29 | |
| 30 | 30 | class sandy_super_disk_t : public device_t, |
| 31 | | |
| 31 | public device_ql_expansion_card_interface | |
| 32 | 32 | { |
| 33 | 33 | public: |
| 34 | 34 | // construction/destruction |
| r31374 | r31375 | |
|---|---|---|
| 25 | 25 | // ======================> miracle_gold_card_t |
| 26 | 26 | |
| 27 | 27 | class miracle_gold_card_t : public device_t, |
| 28 | | |
| 28 | public device_ql_expansion_card_interface | |
| 29 | 29 | { |
| 30 | 30 | public: |
| 31 | 31 | // construction/destruction |
| r31374 | r31375 | |
|---|---|---|
| 25 | 25 | // ======================> kempston_disk_interface_t |
| 26 | 26 | |
| 27 | 27 | class kempston_disk_interface_t : public device_t, |
| 28 | | |
| 28 | public device_ql_expansion_card_interface | |
| 29 | 29 | { |
| 30 | 30 | public: |
| 31 | 31 | // construction/destruction |
| r31374 | r31375 | |
|---|---|---|
| 24 | 24 | |
| 25 | 25 | #define MCFG_PC_KBDC_OUT_DATA_CB(_devcb) \ |
| 26 | 26 | devcb = &pc_kbdc_device::set_out_data_callback(*device, DEVCB_##_devcb); |
| 27 | ||
| 27 | ||
| 28 | 28 | #define MCFG_PC_KBDC_SLOT_ADD(_kbdc_tag, _tag, _slot_intf, _def_slot) \ |
| 29 | 29 | MCFG_DEVICE_ADD(_tag, PC_KBDC_SLOT, 0 ) \ |
| 30 | 30 | MCFG_DEVICE_SLOT_INTERFACE(_slot_intf, _def_slot, false) \ |
| r31374 | r31375 | |
| 67 | 67 | |
| 68 | 68 | 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); } |
| 69 | 69 | 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 | ||
| 71 | 71 | void set_keyboard(device_pc_kbd_interface *keyboard); |
| 72 | 72 | |
| 73 | 73 | int clock_signal() { return m_clock_state; } |
| r31374 | r31375 | |
|---|---|---|
| 80 | 80 | |
| 81 | 81 | |
| 82 | 82 | #endif |
| 83 |
| r31374 | r31375 | |
|---|---|---|
| 11 | 11 | #define MCFG_MSX_SLOT_BUNSETSU_ADD(_tag, _startpage, _numpages, _region, _offset, _bunsetsu_region_tag) \ |
| 12 | 12 | MCFG_MSX_INTERNAL_SLOT_ADD(_tag, MSX_SLOT_BUNSETSU, _startpage, _numpages) \ |
| 13 | 13 | 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); | |
| 16 | 15 | class msx_slot_bunsetsu_device : public msx_slot_rom_device |
| 17 | 16 | { |
| 18 | 17 | public: |
| r31374 | r31375 | |
| 35 | 34 | |
| 36 | 35 | |
| 37 | 36 | #endif |
| 38 |
| r31374 | r31375 | |
|---|---|---|
| 41 | 41 | extern const device_type MSX_SLOT_RAM_MM; |
| 42 | 42 | |
| 43 | 43 | #endif |
| 44 |
| r31374 | r31375 | |
|---|---|---|
| 4 | 4 | #include "slot.h" |
| 5 | 5 | |
| 6 | 6 | #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) | |
| 9 | 8 | class msx_slot_ram_device : public device_t, |
| 10 | 9 | public msx_internal_slot_interface |
| 11 | 10 | { |
| r31374 | r31375 | |
|---|---|---|
| 13 | 13 | #define MCFG_MSX_SLOT_MUSIC_ADD(_tag, _startpage, _numpages, _region, _offset, _ym2413_tag) \ |
| 14 | 14 | MCFG_MSX_INTERNAL_SLOT_ADD(_tag, MSX_SLOT_MUSIC, _startpage, _numpages) \ |
| 15 | 15 | 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); | |
| 18 | 17 | class msx_slot_music_device : public msx_slot_rom_device |
| 19 | 18 | { |
| 20 | 19 | public: |
| r31374 | r31375 | |
| 36 | 35 | |
| 37 | 36 | |
| 38 | 37 | #endif |
| 39 |
| r31374 | r31375 | |
|---|---|---|
| 103 | 103 | class msx_slot_tc8566_disk_device : public msx_slot_disk_device |
| 104 | 104 | { |
| 105 | 105 | public: |
| 106 | ||
| 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); | |
| 107 | 107 | |
| 108 | ||
| 108 | virtual void device_start(); | |
| 109 | 109 | |
| 110 | 110 | protected: |
| 111 | 111 | tc8566af_device *m_fdc; |
| r31374 | r31375 | |
| 185 | 185 | DECLARE_READ8_MEMBER(io_read); |
| 186 | 186 | DECLARE_WRITE8_MEMBER(io_write); |
| 187 | 187 | |
| 188 | ||
| 188 | void post_load(); | |
| 189 | 189 | |
| 190 | 190 | private: |
| 191 | 191 | UINT8 m_control; |
| r31374 | r31375 | |
| 195 | 195 | |
| 196 | 196 | |
| 197 | 197 | #endif |
| 198 |
| r31374 | r31375 | |
|---|---|---|
| 75 | 75 | // construction/destruction |
| 76 | 76 | a1bus_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock); |
| 77 | 77 | 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 | ||
| 79 | 79 | // inline configuration |
| 80 | 80 | static void static_set_cputag(device_t &device, const char *tag); |
| 81 | 81 | 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); } |
| r31374 | r31375 | |
| 97 | 97 | // device-level overrides |
| 98 | 98 | virtual void device_start(); |
| 99 | 99 | virtual void device_reset(); |
| 100 | ||
| 100 | ||
| 101 | 101 | // internal state |
| 102 | 102 | cpu_device *m_maincpu; |
| 103 | 103 |
| r31374 | r31375 | |
|---|---|---|
| 61 | 61 | |
| 62 | 62 | #define MCFG_GF1_TIMER2_IRQ_HANDLER(_devcb) \ |
| 63 | 63 | devcb = &gf1_device::set_timer2_irq_handler(*device, DEVCB_##_devcb); |
| 64 | ||
| 64 | ||
| 65 | 65 | #define MCFG_GF1_SB_IRQ_HANDLER(_devcb) \ |
| 66 | 66 | devcb = &gf1_device::set_sb_irq_handler(*device, DEVCB_##_devcb); |
| 67 | 67 | |
| 68 | 68 | #define MCFG_GF1_DMA_IRQ_HANDLER(_devcb) \ |
| 69 | 69 | devcb = &gf1_device::set_dma_irq_handler(*device, DEVCB_##_devcb); |
| 70 | ||
| 70 | ||
| 71 | 71 | #define MCFG_GF1_DRQ1_HANDLER(_devcb) \ |
| 72 | 72 | devcb = &gf1_device::set_drq1_handler(*device, DEVCB_##_devcb); |
| 73 | ||
| 73 | ||
| 74 | 74 | #define MCFG_GF1_DRQ2_HANDLER(_devcb) \ |
| 75 | 75 | devcb = &gf1_device::set_drq2_handler(*device, DEVCB_##_devcb); |
| 76 | ||
| 76 | ||
| 77 | 77 | #define MCFG_GF1_NMI_HANDLER(_devcb) \ |
| 78 | 78 | devcb = &gf1_device::set_nmi_handler(*device, DEVCB_##_devcb); |
| 79 | ||
| 79 | ||
| 80 | 80 | //************************************************************************** |
| 81 | 81 | // TYPE DEFINITIONS |
| 82 | 82 | //************************************************************************** |
| r31374 | r31375 | |
|---|---|---|
| 57 | 57 | DECLARE_READ8_MEMBER( pc_aga_videoram_r ); |
| 58 | 58 | |
| 59 | 59 | MC6845_UPDATE_ROW( aga_update_row ); |
| 60 | MC6845_UPDATE_ROW( mda_text_inten_update_row ); | |
| 60 | MC6845_UPDATE_ROW( mda_text_inten_update_row ); | |
| 61 | 61 | MC6845_UPDATE_ROW( mda_text_blink_update_row ); |
| 62 | 62 | MC6845_UPDATE_ROW( cga_text_inten_update_row ); |
| 63 | 63 | MC6845_UPDATE_ROW( cga_text_inten_alt_update_row ); |
| r31374 | r31375 | |
|---|---|---|
| 92 | 92 | |
| 93 | 93 | #define MCFG_ISA_BUS_IOCHCK(_iochck) \ |
| 94 | 94 | downcast<isa8_device *>(device)->set_iochck_callback(DEVCB_##_iochck); |
| 95 | ||
| 95 | ||
| 96 | 96 | #define MCFG_ISA_OUT_IRQ2_CB(_devcb) \ |
| 97 | 97 | devcb = &isa8_device::set_out_irq2_callback(*device, DEVCB_##_devcb); |
| 98 | 98 | |
| r31374 | r31375 | |
| 119 | 119 | |
| 120 | 120 | #define MCFG_ISA_OUT_DRQ3_CB(_devcb) \ |
| 121 | 121 | devcb = &isa8_device::set_out_drq3_callback(*device, DEVCB_##_devcb); |
| 122 | ||
| 123 | 122 | |
| 123 | ||
| 124 | 124 | #define MCFG_ISA_OUT_IRQ10_CB(_devcb) \ |
| 125 | 125 | devcb = &isa16_device::set_out_irq10_callback(*device, DEVCB_##_devcb); |
| 126 | 126 | |
| r31374 | r31375 | |
| 354 | 354 | 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); } |
| 355 | 355 | 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); } |
| 356 | 356 | 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 | ||
| 358 | 358 | void install16_device(offs_t start, offs_t end, offs_t mask, offs_t mirror, read16_delegate rhandler, write16_delegate whandler); |
| 359 | 359 | |
| 360 | 360 | // for ISA16, put the 16-bit configs in the primary slots and the 8-bit configs in the secondary |
| r31374 | r31375 | |
|---|---|---|
| 40 | 40 | floppy_image_device *floppies[4]; |
| 41 | 41 | UINT8 port_314; |
| 42 | 42 | bool intrq_state, drq_state, hld_state; |
| 43 | ||
| 43 | ||
| 44 | 44 | virtual void device_start(); |
| 45 | 45 | virtual void device_reset(); |
| 46 | 46 | const rom_entry *device_rom_region() const; |
| r31374 | r31375 | |
|---|---|---|
| 10 | 10 | #include "emu.h" |
| 11 | 11 | #include "cpu/m6502/m6502.h" |
| 12 | 12 | |
| 13 | #define MCFG_ORICEXT_ADD(_tag, _slot_intf, _def_slot, _cputag, _irq) | |
| 13 | #define MCFG_ORICEXT_ADD(_tag, _slot_intf, _def_slot, _cputag, _irq) \ | |
| 14 | 14 | MCFG_DEVICE_ADD(_tag, ORICEXT_CONNECTOR, 0) \ |
| 15 | 15 | MCFG_DEVICE_SLOT_INTERFACE(_slot_intf, _def_slot, false) \ |
| 16 | 16 | downcast<oricext_connector *>(device)->set_cputag(_cputag); \ |
| r31374 | r31375 | |
| 20 | 20 | class oricext_device; |
| 21 | 21 | |
| 22 | 22 | class oricext_connector: public device_t, |
| 23 | | |
| 23 | public device_slot_interface | |
| 24 | 24 | { |
| 25 | 25 | public: |
| 26 | 26 | oricext_connector(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock); |
| r31374 | r31375 | |
| 38 | 38 | }; |
| 39 | 39 | |
| 40 | 40 | class oricext_device : public device_t, |
| 41 | | |
| 41 | public device_slot_card_interface | |
| 42 | 42 | { |
| 43 | 43 | public: |
| 44 | 44 | 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); |
| r31374 | r31375 | |
|---|---|---|
| 28 | 28 | bool side_sel, fdc_reset, ram_access, rom_access, select[4]; |
| 29 | 29 | UINT8 *jasmin_rom; |
| 30 | 30 | floppy_image_device *cur_floppy, *floppies[4]; |
| 31 | ||
| 31 | ||
| 32 | 32 | virtual void device_start(); |
| 33 | 33 | virtual void device_reset(); |
| 34 | 34 | const rom_entry *device_rom_region() const; |
| r31374 | r31375 | |
|---|---|---|
| 60 | 60 | }; |
| 61 | 61 | |
| 62 | 62 | #endif |
| 63 |
| r31374 | r31375 | |
|---|---|---|
| 94 | 94 | |
| 95 | 95 | |
| 96 | 96 | class msx_cart_synthesizer : public device_t |
| 97 | ||
| 97 | , public msx_cart_interface | |
| 98 | 98 | { |
| 99 | 99 | public: |
| 100 | ||
| 100 | msx_cart_synthesizer(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock); | |
| 101 | 101 | |
| 102 | // device-level overrides | |
| 103 | virtual void device_start(); | |
| 102 | // device-level overrides | |
| 103 | virtual void device_start(); | |
| 104 | 104 | virtual machine_config_constructor device_mconfig_additions() const; |
| 105 | 105 | |
| 106 | ||
| 106 | virtual void initialize_cartridge(); | |
| 107 | 107 | |
| 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); | |
| 110 | 110 | |
| 111 | 111 | private: |
| 112 | ||
| 112 | UINT8 *m_bank_base; | |
| 113 | 113 | required_device<dac_device> m_dac; |
| 114 | 114 | }; |
| 115 | 115 |
| r31374 | r31375 | |
|---|---|---|
| 113 | 113 | |
| 114 | 114 | |
| 115 | 115 | #endif |
| 116 |
| r31374 | r31375 | |
|---|---|---|
| 78 | 78 | |
| 79 | 79 | // MMC-5 contains 1K of internal ram |
| 80 | 80 | UINT8 m_exram[0x400]; |
| 81 | ||
| 81 | ||
| 82 | 82 | UINT8 m_ram_hi_banks[4]; |
| 83 | 83 | |
| 84 | 84 | // int m_nes_vram_sprite[8]; |
| r31374 | r31375 | |
|---|---|---|
| 46 | 46 | virtual DECLARE_WRITE_LINE_MEMBER( input_d ) { output_4(state); } |
| 47 | 47 | virtual DECLARE_WRITE_LINE_MEMBER( input_k ) { output_9(state); } |
| 48 | 48 | virtual DECLARE_WRITE_LINE_MEMBER( input_l ) { output_10(state); } |
| 49 | ||
| 49 | ||
| 50 | 50 | protected: |
| 51 | 51 | // device-level overrides |
| 52 | 52 | virtual void device_start(); |
| r31374 | r31375 | |
|---|---|---|
| 85 | 85 | // construction/destruction |
| 86 | 86 | z88cart_slot_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock); |
| 87 | 87 | virtual ~z88cart_slot_device(); |
| 88 | ||
| 88 | ||
| 89 | 89 | 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); } |
| 90 | 90 | |
| 91 | 91 | // device-level overrides |
| r31374 | r31375 | |
| 134 | 134 | |
| 135 | 135 | #define MCFG_Z88CART_SLOT_OUT_FLP_CB(_devcb) \ |
| 136 | 136 | devcb = &z88cart_slot_device::set_out_flp_callback(*device, DEVCB_##_devcb); |
| 137 | ||
| 137 | ||
| 138 | 138 | #endif /* __Z88CART_H__ */ |
| r31374 | r31375 | |
|---|---|---|
| 49 | 49 | 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); } |
| 50 | 50 | 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); } |
| 51 | 51 | 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 | ||
| 53 | 53 | // device-level overrides |
| 54 | 54 | virtual void device_start(); |
| 55 | 55 | |
| r31374 | r31375 | |
| 127 | 127 | |
| 128 | 128 | #define MCFG_KCEXP_SLOT_NEXT_SLOT(_next_slot_tag) \ |
| 129 | 129 | kcexp_slot_device::static_set_next_slot(*device, _next_slot_tag); |
| 130 | ||
| 131 | 130 | |
| 131 | ||
| 132 | 132 | #define MCFG_KCCART_SLOT_OUT_IRQ_CB(_devcb) \ |
| 133 | 133 | devcb = &kccart_slot_device::set_out_irq_callback(*device, DEVCB_##_devcb); |
| 134 | 134 | |
| r31374 | r31375 | |
| 141 | 141 | #define MCFG_KCCART_SLOT_NEXT_SLOT(_next_slot_tag) \ |
| 142 | 142 | kccart_slot_device::static_set_next_slot(*device, _next_slot_tag); |
| 143 | 143 | |
| 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) | |
| 147 | 147 | |
| 148 | 148 | // #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) | |
| 151 | 151 | |
| 152 | 152 | #endif /* __KCEXP_H__ */ |
| r31374 | r31375 | |
|---|---|---|
| 93 | 93 | // construction/destruction |
| 94 | 94 | cpc_expansion_slot_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock); |
| 95 | 95 | virtual ~cpc_expansion_slot_device(); |
| 96 | ||
| 96 | ||
| 97 | 97 | 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); } |
| 98 | 98 | 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); } |
| 99 | 99 | 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); } |
| r31374 | r31375 | |
|---|---|---|
| 14 | 14 | #include "cpcexp.h" |
| 15 | 15 | |
| 16 | 16 | class cpc_rs232_device : public device_t, |
| 17 | | |
| 17 | public device_cpc_expansion_card_interface | |
| 18 | 18 | { |
| 19 | 19 | public: |
| 20 | 20 | // construction/destruction |
| r31374 | r31375 | |
|---|---|---|
| 37 | 37 | }; |
| 38 | 38 | |
| 39 | 39 | #endif |
| 40 | ||
| 41 | ||
| 42 |
| r31374 | r31375 | |
|---|---|---|
| 34 | 34 | }; |
| 35 | 35 | |
| 36 | 36 | #endif |
| 37 | ||
| 38 | ||
| 39 |
| r31374 | r31375 | |
|---|---|---|
| 16 | 16 | public: |
| 17 | 17 | // construction/destruction |
| 18 | 18 | sbp_prot_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock); |
| 19 | ||
| 20 | 19 | |
| 20 | ||
| 21 | 21 | UINT8* m_mainrom; |
| 22 | 22 | |
| 23 | 23 | void sbp_install_protection(cpu_device* maincpu, UINT8* cpurom, UINT32 cpurom_size); |
| r31374 | r31375 | |
| 36 | 36 | }; |
| 37 | 37 | |
| 38 | 38 | #endif |
| 39 | ||
| 40 | ||
| 41 | ||
| 42 |
| r31374 | r31375 | |
|---|---|---|
| 46 | 46 | }; |
| 47 | 47 | |
| 48 | 48 | #endif |
| 49 | ||
| 50 | ||
| 51 |
| r31374 | r31375 | |
|---|---|---|
| 22 | 22 | void neogeo_bootleg_sx_decrypt(UINT8* fixed, UINT32 fixed_size, int value); |
| 23 | 23 | void kog_px_decrypt(UINT8* cpurom, UINT32 cpurom_size); |
| 24 | 24 | void kof97oro_px_decode(UINT8* cpurom, UINT32 cpurom_size); |
| 25 | void kof10thBankswitch(address_space &space, UINT16 | |
| 25 | void kof10thBankswitch(address_space &space, UINT16 nBank); | |
| 26 | 26 | DECLARE_READ16_MEMBER(kof10th_RAM2_r); |
| 27 | 27 | DECLARE_READ16_MEMBER(kof10th_RAMB_r); |
| 28 | 28 | DECLARE_WRITE16_MEMBER(kof10th_custom_w); |
| r31374 | r31375 | |
| 95 | 95 | }; |
| 96 | 96 | |
| 97 | 97 | #endif |
| 98 | ||
| 99 | ||
| 100 |
| r31374 | r31375 | |
|---|---|---|
| 83 | 83 | }; |
| 84 | 84 | |
| 85 | 85 | #endif |
| 86 | ||
| 87 | ||
| 88 |
| r31374 | r31375 | |
|---|---|---|
| 54 | 54 | }; |
| 55 | 55 | |
| 56 | 56 | #endif |
| 57 | ||
| 58 | ||
| 59 |
| r31374 | r31375 | |
|---|---|---|
| 49 | 49 | void ym_alloc(UINT32 size) { if (m_ym == NULL) m_ym.resize(size/sizeof(UINT8)); } |
| 50 | 50 | UINT8* get_ym_base() { return m_ym; } |
| 51 | 51 | UINT32 get_ym_size() { return m_ym.bytes(); } |
| 52 | ||
| 52 | ||
| 53 | 53 | void ymdelta_alloc(UINT32 size) { if (m_ymdelta == NULL) m_ymdelta.resize(size/sizeof(UINT8)); } |
| 54 | 54 | UINT8* get_ymdelta_base() { return m_ymdelta; } |
| 55 | 55 | UINT32 get_ymdelta_size() { return m_ymdelta.bytes(); } |
| r31374 | r31375 | |
| 74 | 74 | }; |
| 75 | 75 | |
| 76 | 76 | #endif |
| 77 |
| r31374 | r31375 | |
|---|---|---|
| 42 | 42 | }; |
| 43 | 43 | |
| 44 | 44 | #endif |
| 45 | ||
| 46 | ||
| 47 |
| r31374 | r31375 | |
|---|---|---|
| 16 | 16 | public: |
| 17 | 17 | // construction/destruction |
| 18 | 18 | kof98_prot_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock); |
| 19 | ||
| 19 | ||
| 20 | 20 | void kof98_decrypt_68k(UINT8* cpurom, UINT32 cpurom_size); |
| 21 | 21 | void install_kof98_protection(cpu_device* maincpu); |
| 22 | 22 | DECLARE_WRITE16_MEMBER(kof98_prot_w); |
| r31374 | r31375 | |
| 36 | 36 | }; |
| 37 | 37 | |
| 38 | 38 | #endif |
| 39 | ||
| 40 | ||
| 41 | ||
| 42 |
| r31374 | r31375 | |
|---|---|---|
| 16 | 16 | public: |
| 17 | 17 | // construction/destruction |
| 18 | 18 | pcm2_prot_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock); |
| 19 | ||
| 19 | ||
| 20 | 20 | void neo_pcm2_snk_1999(UINT8* ymrom, UINT32 ymsize, int value); |
| 21 | 21 | void neo_pcm2_swap(UINT8* ymrom, UINT32 ymsize, int value); |
| 22 | 22 | |
| r31374 | r31375 | |
| 32 | 32 | }; |
| 33 | 33 | |
| 34 | 34 | #endif |
| 35 | ||
| 36 | ||
| 37 |
| r31374 | r31375 | |
|---|---|---|
| 38 | 38 | }; |
| 39 | 39 | |
| 40 | 40 | #endif |
| 41 | ||
| 42 | ||
| 43 | ||
| 44 | ||
| 45 |
| r31374 | r31375 | |
|---|---|---|
| 1 | 1 | /*************************************************************************** |
| 2 | 2 | |
| 3 | ||
| 3 | Amiga Zorro Slots | |
| 4 | 4 | |
| 5 | 5 | license: MAME, GPL-2.0+ |
| 6 | 6 | copyright-holders: Dirk Best |
| 7 | 7 | |
| 8 | ||
| 8 | 86-pin Expansion Slot (Zorro-I), Zorro-II, Zorro-III | |
| 9 | 9 | |
| 10 | ||
| 10 | 86-pin Expansion Slot | |
| 11 | 11 | |
| 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 | |
| 55 | 55 | |
| 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 | |
| 61 | 61 | |
| 62 | ||
| 62 | Zorro-II (differences only) | |
| 63 | 63 | |
| 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 | |
| 74 | 74 | |
| 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 | |
| 81 | 81 | 100 Ground 99 Ground |
| 82 | 82 | |
| 83 | ||
| 83 | *6 /GBG on B2000 | |
| 84 | 84 | |
| 85 | ||
| 85 | Zorro-III | |
| 86 | 86 | |
| 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: | |
| 89 | 89 | |
| 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 | |
| 138 | 138 | |
| 139 | 139 | |
| 140 | 140 | ***************************************************************************/ |
| r31374 | r31375 | |
|---|---|---|
| 1 | 1 | /*************************************************************************** |
| 2 | 2 | |
| 3 | ||
| 3 | Amiga Zorro Cards | |
| 4 | 4 | |
| 5 | ||
| 5 | There are different card types and layouts: | |
| 6 | 6 | |
| 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 | |
| 16 | 16 | |
| 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. | |
| 19 | 19 | |
| 20 | 20 | ***************************************************************************/ |
| 21 | 21 |
| r31374 | r31375 | |
|---|---|---|
| 1 | 1 | /*************************************************************************** |
| 2 | 2 | |
| 3 | ||
| 3 | Commodore A590 / A2091 | |
| 4 | 4 | |
| 5 | 5 | license: MAME, GPL-2.0+ |
| 6 | 6 | copyright-holders: Dirk Best |
| 7 | 7 | |
| 8 | ||
| 8 | DMAC based SCSI controller for the Amiga 500 and Zorro-II | |
| 9 | 9 | |
| 10 | 10 | ***************************************************************************/ |
| 11 | 11 |
| r31374 | r31375 | |
|---|---|---|
| 1 | 1 | /*************************************************************************** |
| 2 | 2 | |
| 3 | ||
| 3 | Buddha | |
| 4 | 4 | |
| 5 | 5 | license: MAME, GPL-2.0+ |
| 6 | 6 | copyright-holders: Dirk Best |
| 7 | 7 | |
| 8 | ||
| 8 | Zorro-II IDE controller | |
| 9 | 9 | |
| 10 | 10 | ***************************************************************************/ |
| 11 | 11 |
| r31374 | r31375 | |
|---|---|---|
| 1 | 1 | /*************************************************************************** |
| 2 | 2 | |
| 3 | ||
| 3 | Commodore A2052 | |
| 4 | 4 | |
| 5 | 5 | license: MAME, GPL-2.0+ |
| 6 | 6 | copyright-holders: Dirk Best |
| 7 | 7 | |
| 8 | ||
| 8 | Zorro-II RAM Expansion (0.5, 1 or 2 MB) | |
| 9 | 9 | |
| 10 | 10 | ***************************************************************************/ |
| 11 | 11 |
| r31374 | r31375 | |
|---|---|---|
| 1 | 1 | /*************************************************************************** |
| 2 | 2 | |
| 3 | ||
| 3 | Commodore A2232 | |
| 4 | 4 | |
| 5 | 5 | license: MAME, GPL-2.0+ |
| 6 | 6 | copyright-holders: Dirk Best |
| 7 | 7 | |
| 8 | ||
| 8 | Zorro-II Serial Card | |
| 9 | 9 | |
| 10 | ||
| 10 | Provides the Amiga with 7 additional RS232 ports. | |
| 11 | 11 | |
| 12 | 12 | ***************************************************************************/ |
| 13 | 13 |
| r31374 | r31375 | |
|---|---|---|
| 1 | 1 | /*************************************************************************** |
| 2 | 2 | |
| 3 | ||
| 3 | Datel Action Replay | |
| 4 | 4 | |
| 5 | 5 | license: MAME, GPL-2.0+ |
| 6 | 6 | copyright-holders: Dirk Best |
| 7 | 7 | |
| 8 | ||
| 8 | Freezer cartridge for Amiga 500 and Amiga 2000 | |
| 9 | 9 | |
| 10 | 10 | ***************************************************************************/ |
| 11 | 11 |
| r31374 | r31375 | |
|---|---|---|
| 3848 | 3848 | } |
| 3849 | 3849 | sqlite3_free(data.zFreeOnClose); |
| 3850 | 3850 | return rc; |
| 3851 | } | |
| 3851 | } |
| r31374 | r31375 | |
|---|---|---|
| 135 | 135 | ** function is provided for use in DLLs since DLL users usually do not have |
| 136 | 136 | ** direct access to string constants within the DLL. ^The |
| 137 | 137 | ** 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 | |
| 140 | 140 | ** [SQLITE_SOURCE_ID] C preprocessor macro. |
| 141 | 141 | ** |
| 142 | 142 | ** See also: [sqlite_version()] and [sqlite_source_id()]. |
| r31374 | r31375 | |
| 149 | 149 | /* |
| 150 | 150 | ** CAPI3REF: Run-Time Library Compilation Options Diagnostics |
| 151 | 151 | ** |
| 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(). | |
| 156 | 156 | ** |
| 157 | 157 | ** ^The sqlite3_compileoption_get() function allows iterating |
| 158 | 158 | ** over the list of options that were defined at compile time by |
| 159 | 159 | ** 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 | |
| 162 | 162 | ** sqlite3_compileoption_get(). |
| 163 | 163 | ** |
| 164 | 164 | ** ^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 | |
| 166 | 166 | ** [SQLITE_OMIT_COMPILEOPTION_DIAGS] option at compile time. |
| 167 | 167 | ** |
| 168 | 168 | ** See also: SQL functions [sqlite_compileoption_used()] and |
| r31374 | r31375 | |
| 183 | 183 | ** SQLite can be compiled with or without mutexes. When |
| 184 | 184 | ** the [SQLITE_THREADSAFE] C preprocessor macro is 1 or 2, mutexes |
| 185 | 185 | ** are enabled and SQLite is threadsafe. When the |
| 186 | ** [SQLITE_THREADSAFE] macro is 0, | |
| 186 | ** [SQLITE_THREADSAFE] macro is 0, | |
| 187 | 187 | ** the mutexes are omitted. Without the mutexes, it is not safe |
| 188 | 188 | ** to use SQLite concurrently from more than one thread. |
| 189 | 189 | ** |
| r31374 | r31375 | |
| 240 | 240 | ** |
| 241 | 241 | ** ^The sqlite3_int64 and sqlite_int64 types can store integer values |
| 242 | 242 | ** 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 | |
| 244 | 244 | ** between 0 and +18446744073709551615 inclusive. |
| 245 | 245 | */ |
| 246 | 246 | #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; | |
| 249 | 249 | #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; | |
| 252 | 252 | #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; | |
| 255 | 255 | #endif |
| 256 | 256 | typedef sqlite_int64 sqlite3_int64; |
| 257 | 257 | typedef sqlite_uint64 sqlite3_uint64; |
| r31374 | r31375 | |
| 285 | 285 | ** destructors are called is arbitrary. |
| 286 | 286 | ** |
| 287 | 287 | ** 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 | |
| 289 | 289 | ** [sqlite3_backup_finish | finish] all [sqlite3_backup] objects associated |
| 290 | 290 | ** with the [sqlite3] object prior to attempting to close the object. ^If |
| 291 | 291 | ** sqlite3_close_v2() is called on a [database connection] that still has |
| r31374 | r31375 | |
| 321 | 321 | ** The sqlite3_exec() interface is a convenience wrapper around |
| 322 | 322 | ** [sqlite3_prepare_v2()], [sqlite3_step()], and [sqlite3_finalize()], |
| 323 | 323 | ** 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. | |
| 325 | 325 | ** |
| 326 | 326 | ** ^The sqlite3_exec() interface runs zero or more UTF-8 encoded, |
| 327 | 327 | ** semicolon-separate SQL statements passed into its 2nd argument, |
| r31374 | r31375 | |
| 361 | 361 | ** from [sqlite3_column_name()]. |
| 362 | 362 | ** |
| 363 | 363 | ** ^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 | |
| 365 | 365 | ** SQL comments, then no SQL statements are evaluated and the database |
| 366 | 366 | ** is not changed. |
| 367 | 367 | ** |
| r31374 | r31375 | |
| 377 | 377 | ** </ul> |
| 378 | 378 | */ |
| 379 | 379 | SQLITE_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 */ | |
| 385 | 385 | ); |
| 386 | 386 | |
| 387 | 387 | /* |
| r31374 | r31375 | |
| 622 | 622 | /* |
| 623 | 623 | ** CAPI3REF: OS Interface Open File Handle |
| 624 | 624 | ** |
| 625 | ** An [sqlite3_file] object represents an open file in the | |
| 625 | ** An [sqlite3_file] object represents an open file in the | |
| 626 | 626 | ** [sqlite3_vfs | OS interface layer]. Individual OS interface |
| 627 | 627 | ** implementations will |
| 628 | 628 | ** want to subclass this object by appending additional fields |
| r31374 | r31375 | |
| 632 | 632 | */ |
| 633 | 633 | typedef struct sqlite3_file sqlite3_file; |
| 634 | 634 | struct sqlite3_file { |
| 635 | ||
| 635 | const struct sqlite3_io_methods *pMethods; /* Methods for an open file */ | |
| 636 | 636 | }; |
| 637 | 637 | |
| 638 | 638 | /* |
| r31374 | r31375 | |
| 644 | 644 | ** This object defines the methods used to perform various operations |
| 645 | 645 | ** against the open file represented by the [sqlite3_file] object. |
| 646 | 646 | ** |
| 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 | |
| 648 | 648 | ** to a non-NULL pointer, then the sqlite3_io_methods.xClose method |
| 649 | 649 | ** may be invoked even if the [sqlite3_vfs.xOpen] reported that it failed. The |
| 650 | 650 | ** only way to prevent a call to xClose following a failed [sqlite3_vfs.xOpen] |
| r31374 | r31375 | |
| 727 | 727 | */ |
| 728 | 728 | typedef struct sqlite3_io_methods sqlite3_io_methods; |
| 729 | 729 | struct 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 */ | |
| 753 | 753 | }; |
| 754 | 754 | |
| 755 | 755 | /* |
| r31374 | r31375 | |
| 778 | 778 | ** <li>[[SQLITE_FCNTL_CHUNK_SIZE]] |
| 779 | 779 | ** The [SQLITE_FCNTL_CHUNK_SIZE] opcode is used to request that the VFS |
| 780 | 780 | ** 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 | |
| 782 | 782 | ** point to an integer (type int) containing the new chunk-size to use |
| 783 | 783 | ** for the nominated database. Allocating database file space in large |
| 784 | 784 | ** chunks (say 1MB at a time), may reduce file-system fragmentation and |
| r31374 | r31375 | |
| 796 | 796 | ** <li>[[SQLITE_FCNTL_SYNC]] |
| 797 | 797 | ** The [SQLITE_FCNTL_SYNC] opcode is generated internally by SQLite and |
| 798 | 798 | ** 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 | |
| 802 | 802 | ** of the xSync method. In most cases, the pointer argument passed with |
| 803 | 803 | ** this file-control is NULL. However, if the database file is being synced |
| 804 | 804 | ** 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. | |
| 809 | 809 | ** |
| 810 | 810 | ** <li>[[SQLITE_FCNTL_COMMIT_PHASETWO]] |
| 811 | 811 | ** The [SQLITE_FCNTL_COMMIT_PHASETWO] opcode is generated internally by SQLite |
| 812 | 812 | ** and sent to the VFS after a transaction has been committed immediately |
| 813 | 813 | ** but before the database is unlocked. VFSes that do not need this signal |
| 814 | 814 | ** 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. | |
| 817 | 817 | ** |
| 818 | 818 | ** <li>[[SQLITE_FCNTL_WIN32_AV_RETRY]] |
| 819 | 819 | ** ^The [SQLITE_FCNTL_WIN32_AV_RETRY] opcode is used to configure automatic |
| r31374 | r31375 | |
| 860 | 860 | ** <li>[[SQLITE_FCNTL_OVERWRITE]] |
| 861 | 861 | ** ^The [SQLITE_FCNTL_OVERWRITE] opcode is invoked by SQLite after opening |
| 862 | 862 | ** 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 | |
| 864 | 864 | ** transaction. This is used by VACUUM operations. |
| 865 | 865 | ** |
| 866 | 866 | ** <li>[[SQLITE_FCNTL_VFSNAME]] |
| 867 | 867 | ** ^The [SQLITE_FCNTL_VFSNAME] opcode can be used to obtain the names of |
| 868 | 868 | ** 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 | |
| 870 | 870 | ** [sqlite3_malloc()] and the result is stored in the char* variable |
| 871 | 871 | ** that the fourth parameter of [sqlite3_file_control()] points to. |
| 872 | 872 | ** The caller is responsible for freeing the memory when done. As with |
| r31374 | r31375 | |
| 876 | 876 | ** is intended for diagnostic use only. |
| 877 | 877 | ** |
| 878 | 878 | ** <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] | |
| 880 | 880 | ** file control is sent to the open [sqlite3_file] object corresponding |
| 881 | 881 | ** to the database file to which the pragma statement refers. ^The argument |
| 882 | 882 | ** to the [SQLITE_FCNTL_PRAGMA] file control is an array of |
| r31374 | r31375 | |
| 887 | 887 | ** of the char** argument point to a string obtained from [sqlite3_mprintf()] |
| 888 | 888 | ** or the equivalent and that string will become the result of the pragma or |
| 889 | 889 | ** 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 | |
| 891 | 891 | ** [PRAGMA] processing continues. ^If the [SQLITE_FCNTL_PRAGMA] |
| 892 | 892 | ** file control returns [SQLITE_OK], then the parser assumes that the |
| 893 | 893 | ** VFS has handled the PRAGMA itself and the parser generates a no-op |
| r31374 | r31375 | |
| 925 | 925 | ** The argument is a pointer to a value of type sqlite3_int64 that |
| 926 | 926 | ** is an advisory maximum number of bytes in the file to memory map. The |
| 927 | 927 | ** 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 | |
| 929 | 929 | ** can be queried by passing in a pointer to a negative number. This |
| 930 | 930 | ** file-control is used internally to implement [PRAGMA mmap_size]. |
| 931 | 931 | ** |
| r31374 | r31375 | |
| 1027 | 1027 | ** the [sqlite3_file] can safely store a pointer to the |
| 1028 | 1028 | ** filename if it needs to remember the filename for some reason. |
| 1029 | 1029 | ** 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 | |
| 1031 | 1031 | ** xFilename parameter is NULL it will also be the case that the |
| 1032 | 1032 | ** flags parameter will include [SQLITE_OPEN_DELETEONCLOSE]. |
| 1033 | 1033 | ** |
| 1034 | 1034 | ** The flags argument to xOpen() includes all bits set in |
| 1035 | 1035 | ** the flags argument to [sqlite3_open_v2()]. Or if [sqlite3_open()] |
| 1036 | 1036 | ** or [sqlite3_open16()] is used, then flags includes at least |
| 1037 | ** [SQLITE_OPEN_READWRITE] | [SQLITE_OPEN_CREATE]. | |
| 1037 | ** [SQLITE_OPEN_READWRITE] | [SQLITE_OPEN_CREATE]. | |
| 1038 | 1038 | ** If xOpen() opens a file read-only then it sets *pOutFlags to |
| 1039 | 1039 | ** include [SQLITE_OPEN_READONLY]. Other bits in *pOutFlags may be set. |
| 1040 | 1040 | ** |
| r31374 | r31375 | |
| 1076 | 1076 | ** ^The [SQLITE_OPEN_EXCLUSIVE] flag is always used in conjunction |
| 1077 | 1077 | ** with the [SQLITE_OPEN_CREATE] flag, which are both directly |
| 1078 | 1078 | ** 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 | |
| 1080 | 1080 | ** SQLITE_OPEN_CREATE, is used to indicate that file should always |
| 1081 | 1081 | ** 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 | |
| 1083 | 1083 | ** for exclusive access. |
| 1084 | 1084 | ** |
| 1085 | 1085 | ** ^At least szOsFile bytes of memory are allocated by SQLite |
| r31374 | r31375 | |
| 1117 | 1117 | ** method returns a Julian Day Number for the current date and time as |
| 1118 | 1118 | ** a floating point value. |
| 1119 | 1119 | ** ^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). | |
| 1122 | 1122 | ** ^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 | |
| 1124 | 1124 | ** greater and the function pointer is not NULL) and will fall back |
| 1125 | 1125 | ** to xCurrentTime() if xCurrentTimeInt64() is unavailable. |
| 1126 | 1126 | ** |
| 1127 | 1127 | ** ^The xSetSystemCall(), xGetSystemCall(), and xNestSystemCall() interfaces |
| 1128 | 1128 | ** 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 | |
| 1130 | 1130 | ** system calls with functions under its control, a test program can |
| 1131 | 1131 | ** simulate faults and error conditions that would otherwise be difficult |
| 1132 | 1132 | ** or impossible to induce. The set of system calls that can be overridden |
| r31374 | r31375 | |
| 1139 | 1139 | typedef struct sqlite3_vfs sqlite3_vfs; |
| 1140 | 1140 | typedef void (*sqlite3_syscall_ptr)(void); |
| 1141 | 1141 | struct 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 | */ | |
| 1178 | 1178 | }; |
| 1179 | 1179 | |
| 1180 | 1180 | /* |
| r31374 | r31375 | |
| 1217 | 1217 | ** </ul> |
| 1218 | 1218 | ** |
| 1219 | 1219 | ** 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. | |
| 1221 | 1221 | ** |
| 1222 | 1222 | ** The xShmLock method can transition between unlocked and SHARED or |
| 1223 | 1223 | ** between unlocked and EXCLUSIVE. It cannot transition between SHARED |
| r31374 | r31375 | |
| 1359 | 1359 | ** [database connection] (specified in the first argument). |
| 1360 | 1360 | ** |
| 1361 | 1361 | ** 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 | |
| 1363 | 1363 | ** that indicates what aspect of the [database connection] is being configured. |
| 1364 | 1364 | ** Subsequent arguments vary depending on the configuration verb. |
| 1365 | 1365 | ** |
| r31374 | r31375 | |
| 1377 | 1377 | ** This object is used in only one place in the SQLite interface. |
| 1378 | 1378 | ** A pointer to an instance of this object is the argument to |
| 1379 | 1379 | ** [sqlite3_config()] when the configuration option is |
| 1380 | ** [SQLITE_CONFIG_MALLOC] or [SQLITE_CONFIG_GETMALLOC]. | |
| 1380 | ** [SQLITE_CONFIG_MALLOC] or [SQLITE_CONFIG_GETMALLOC]. | |
| 1381 | 1381 | ** By creating an instance of this object |
| 1382 | 1382 | ** and passing it to [sqlite3_config]([SQLITE_CONFIG_MALLOC]) |
| 1383 | 1383 | ** during configuration, an application can specify an alternative |
| r31374 | r31375 | |
| 1407 | 1407 | ** allocators round up memory allocations at least to the next multiple |
| 1408 | 1408 | ** of 8. Some allocators round up to a larger multiple or to a power of 2. |
| 1409 | 1409 | ** 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, | |
| 1411 | 1411 | ** that causes the corresponding memory allocation to fail. |
| 1412 | 1412 | ** |
| 1413 | 1413 | ** The xInit method initializes the memory allocator. For example, |
| r31374 | r31375 | |
| 1433 | 1433 | */ |
| 1434 | 1434 | typedef struct sqlite3_mem_methods sqlite3_mem_methods; |
| 1435 | 1435 | struct 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() */ | |
| 1444 | 1444 | }; |
| 1445 | 1445 | |
| 1446 | 1446 | /* |
| r31374 | r31375 | |
| 1465 | 1465 | ** by a single thread. ^If SQLite is compiled with |
| 1466 | 1466 | ** the [SQLITE_THREADSAFE | SQLITE_THREADSAFE=0] compile-time option then |
| 1467 | 1467 | ** 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 | |
| 1469 | 1469 | ** [SQLITE_ERROR] if called with the SQLITE_CONFIG_SINGLETHREAD |
| 1470 | 1470 | ** configuration option.</dd> |
| 1471 | 1471 | ** |
| r31374 | r31375 | |
| 1516 | 1516 | ** tracks memory usage, for example. </dd> |
| 1517 | 1517 | ** |
| 1518 | 1518 | ** [[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 | |
| 1522 | 1522 | ** following SQLite interfaces become non-operational: |
| 1523 | 1523 | ** <ul> |
| 1524 | 1524 | ** <li> [sqlite3_memory_used()] |
| r31374 | r31375 | |
| 1544 | 1544 | ** N should be set to twice the expected maximum number of threads. |
| 1545 | 1545 | ** ^SQLite will never require a scratch buffer that is more than 6 |
| 1546 | 1546 | ** 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 | |
| 1548 | 1548 | ** [sqlite3_malloc()] will be used to obtain the memory needed.</dd> |
| 1549 | 1549 | ** |
| 1550 | 1550 | ** [[SQLITE_CONFIG_PAGECACHE]] <dt>SQLITE_CONFIG_PAGECACHE</dt> |
| 1551 | 1551 | ** <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. | |
| 1553 | 1553 | ** This configuration should not be used if an application-define page |
| 1554 | 1554 | ** cache implementation is loaded using the SQLITE_CONFIG_PCACHE2 option. |
| 1555 | 1555 | ** There are three arguments to this option: A pointer to 8-byte aligned |
| r31374 | r31375 | |
| 1635 | 1635 | ** <dd> The SQLITE_CONFIG_LOG option is used to configure the SQLite |
| 1636 | 1636 | ** global [error log]. |
| 1637 | 1637 | ** (^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*), | |
| 1639 | 1639 | ** and a pointer to void. ^If the function pointer is not NULL, it is |
| 1640 | 1640 | ** invoked by [sqlite3_log()] to process each logging event. ^If the |
| 1641 | 1641 | ** function pointer is NULL, the [sqlite3_log()] interface becomes a no-op. |
| r31374 | r31375 | |
| 1732 | 1732 | #define SQLITE_CONFIG_MEMSTATUS 9 /* boolean */ |
| 1733 | 1733 | #define SQLITE_CONFIG_MUTEX 10 /* sqlite3_mutex_methods* */ |
| 1734 | 1734 | #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. */ | |
| 1736 | 1736 | #define SQLITE_CONFIG_LOOKASIDE 13 /* int int */ |
| 1737 | 1737 | #define SQLITE_CONFIG_PCACHE 14 /* no-op */ |
| 1738 | 1738 | #define SQLITE_CONFIG_GETPCACHE 15 /* no-op */ |
| r31374 | r31375 | |
| 1760 | 1760 | ** |
| 1761 | 1761 | ** <dl> |
| 1762 | 1762 | ** <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 | |
| 1764 | 1764 | ** [lookaside memory allocator] configuration for the [database connection]. |
| 1765 | 1765 | ** ^The first argument (the third parameter to [sqlite3_db_config()] is a |
| 1766 | 1766 | ** pointer to a memory buffer to use for lookaside memory. |
| r31374 | r31375 | |
| 1778 | 1778 | ** when the "current value" returned by |
| 1779 | 1779 | ** [sqlite3_db_status](D,[SQLITE_CONFIG_LOOKASIDE],...) is zero. |
| 1780 | 1780 | ** 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 | |
| 1782 | 1782 | ** [SQLITE_BUSY].)^</dd> |
| 1783 | 1783 | ** |
| 1784 | 1784 | ** <dt>SQLITE_DBCONFIG_ENABLE_FKEY</dt> |
| r31374 | r31375 | |
| 1828 | 1828 | ** the table has a column of type [INTEGER PRIMARY KEY] then that column |
| 1829 | 1829 | ** is another alias for the rowid. |
| 1830 | 1830 | ** |
| 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 | |
| 1832 | 1832 | ** most recent successful [INSERT] into a rowid table or [virtual table] |
| 1833 | 1833 | ** on database connection D. |
| 1834 | 1834 | ** ^Inserts into [WITHOUT ROWID] tables are not recorded. |
| 1835 | 1835 | ** ^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, | |
| 1837 | 1837 | ** then sqlite3_last_insert_rowid(D) returns zero. |
| 1838 | 1838 | ** |
| 1839 | 1839 | ** ^(If an [INSERT] occurs within a trigger or within a [virtual table] |
| 1840 | 1840 | ** method, then this routine will return the [rowid] of the inserted |
| 1841 | 1841 | ** 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 | |
| 1843 | 1843 | ** by this routine reverts to what it was before the trigger or virtual |
| 1844 | 1844 | ** table method began.)^ |
| 1845 | 1845 | ** |
| r31374 | r31375 | |
| 1890 | 1890 | ** mechanisms do not count as direct row changes.)^ |
| 1891 | 1891 | ** |
| 1892 | 1892 | ** 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]. | |
| 1894 | 1894 | ** Most SQL statements are |
| 1895 | 1895 | ** evaluated outside of any trigger. This is the "top level" |
| 1896 | 1896 | ** trigger context. If a trigger fires from the top level, a |
| r31374 | r31375 | |
| 1933 | 1933 | ** the count does not include changes used to implement [REPLACE] constraints, |
| 1934 | 1934 | ** do rollbacks or ABORT processing, or [DROP TABLE] processing. The |
| 1935 | 1935 | ** 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 | |
| 1937 | 1937 | ** are counted.)^ |
| 1938 | 1938 | ** ^The sqlite3_total_changes() function counts the changes as soon as |
| 1939 | 1939 | ** the statement that makes them is completed (when the statement handle |
| r31374 | r31375 | |
| 1973 | 1973 | ** |
| 1974 | 1974 | ** ^The sqlite3_interrupt(D) call is in effect until all currently running |
| 1975 | 1975 | ** 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 | |
| 1977 | 1977 | ** running statements reaches zero are interrupted as if they had been |
| 1978 | 1978 | ** running prior to the sqlite3_interrupt() call. ^New SQL statements |
| 1979 | 1979 | ** that are started after the running statement count reaches zero are |
| r31374 | r31375 | |
| 2008 | 2008 | ** ^These routines do not parse the SQL statements thus |
| 2009 | 2009 | ** will not detect syntactically incorrect SQL. |
| 2010 | 2010 | ** |
| 2011 | ** ^(If SQLite has not been initialized using [sqlite3_initialize()] prior | |
| 2011 | ** ^(If SQLite has not been initialized using [sqlite3_initialize()] prior | |
| 2012 | 2012 | ** to invoking sqlite3_complete16() then sqlite3_initialize() is invoked |
| 2013 | 2013 | ** automatically by sqlite3_complete16(). If that initialization fails, |
| 2014 | 2014 | ** then the return value from sqlite3_complete16() will be non-zero |
| r31374 | r31375 | |
| 2083 | 2083 | ** The busy callback should not take any actions which modify the |
| 2084 | 2084 | ** database connection that invoked the busy handler. Any such actions |
| 2085 | 2085 | ** result in undefined behavior. |
| 2086 | ** | |
| 2086 | ** | |
| 2087 | 2087 | ** A busy handler must not close the database connection |
| 2088 | 2088 | ** or [prepared statement] that invoked the busy handler. |
| 2089 | 2089 | */ |
| r31374 | r31375 | |
| 2182 | 2182 | ** [sqlite3_errmsg()]. |
| 2183 | 2183 | */ |
| 2184 | 2184 | SQLITE_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 */ | |
| 2191 | 2191 | ); |
| 2192 | 2192 | SQLITE_API void sqlite3_free_table(char **result); |
| 2193 | 2193 | |
| r31374 | r31375 | |
| 2435 | 2435 | ** requested is ok. ^When the callback returns [SQLITE_DENY], the |
| 2436 | 2436 | ** [sqlite3_prepare_v2()] or equivalent call that triggered the |
| 2437 | 2437 | ** authorizer will fail with an error message explaining that |
| 2438 | ** access is denied. | |
| 2438 | ** access is denied. | |
| 2439 | 2439 | ** |
| 2440 | 2440 | ** ^The first parameter to the authorizer callback is a copy of the third |
| 2441 | 2441 | ** parameter to the sqlite3_set_authorizer() interface. ^The second parameter |
| r31374 | r31375 | |
| 2482 | 2482 | ** database connections for the meaning of "modify" in this paragraph. |
| 2483 | 2483 | ** |
| 2484 | 2484 | ** ^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 | |
| 2486 | 2486 | ** schema change. Hence, the application should ensure that the |
| 2487 | 2487 | ** correct authorizer callback remains in place during the [sqlite3_step()]. |
| 2488 | 2488 | ** |
| r31374 | r31375 | |
| 2493 | 2493 | ** sqlite3_prepare_v2() to reprepare a statement after a schema change. |
| 2494 | 2494 | */ |
| 2495 | 2495 | SQLITE_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 | |
| 2499 | 2499 | ); |
| 2500 | 2500 | |
| 2501 | 2501 | /* |
| r31374 | r31375 | |
| 2598 | 2598 | */ |
| 2599 | 2599 | SQLITE_API void *sqlite3_trace(sqlite3*, void(*xTrace)(void*,const char*), void*); |
| 2600 | 2600 | SQLITE_API SQLITE_EXPERIMENTAL void *sqlite3_profile(sqlite3*, |
| 2601 | ||
| 2601 | void(*xProfile)(void*,const char*,sqlite3_uint64), void*); | |
| 2602 | 2602 | |
| 2603 | 2603 | /* |
| 2604 | 2604 | ** CAPI3REF: Query Progress Callbacks |
| r31374 | r31375 | |
| 2609 | 2609 | ** database connection D. An example use for this |
| 2610 | 2610 | ** interface is to keep a GUI updated during a large query. |
| 2611 | 2611 | ** |
| 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 | |
| 2614 | 2614 | ** [virtual machine instructions] that are evaluated between successive |
| 2615 | 2615 | ** invocations of the callback X. ^If N is less than one then the progress |
| 2616 | 2616 | ** handler is disabled. |
| r31374 | r31375 | |
| 2636 | 2636 | /* |
| 2637 | 2637 | ** CAPI3REF: Opening A New Database Connection |
| 2638 | 2638 | ** |
| 2639 | ** ^These routines open an SQLite database file as specified by the | |
| 2639 | ** ^These routines open an SQLite database file as specified by the | |
| 2640 | 2640 | ** filename argument. ^The filename argument is interpreted as UTF-8 for |
| 2641 | 2641 | ** sqlite3_open() and sqlite3_open_v2() and as UTF-16 in the native byte |
| 2642 | 2642 | ** order for sqlite3_open16(). ^(A [database connection] handle is usually |
| r31374 | r31375 | |
| 2661 | 2661 | ** except that it accepts two additional parameters for additional control |
| 2662 | 2662 | ** over the new database connection. ^(The flags parameter to |
| 2663 | 2663 | ** 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 | |
| 2665 | 2665 | ** [SQLITE_OPEN_NOMUTEX], [SQLITE_OPEN_FULLMUTEX], [SQLITE_OPEN_SHAREDCACHE], |
| 2666 | 2666 | ** [SQLITE_OPEN_PRIVATECACHE], and/or [SQLITE_OPEN_URI] flags:)^ |
| 2667 | 2667 | ** |
| r31374 | r31375 | |
| 2729 | 2729 | ** information. |
| 2730 | 2730 | ** |
| 2731 | 2731 | ** 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 | |
| 2735 | 2735 | ** present, is ignored. |
| 2736 | 2736 | ** |
| 2737 | 2737 | ** ^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 | |
| 2740 | 2740 | ** 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 | |
| 2743 | 2743 | ** is a drive specification (e.g. "C:"). |
| 2744 | 2744 | ** |
| 2745 | 2745 | ** [[core URI query parameters]] |
| r31374 | r31375 | |
| 2758 | 2758 | ** |
| 2759 | 2759 | ** <li> <b>mode</b>: ^(The mode parameter may be set to either "ro", "rw", |
| 2760 | 2760 | ** "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 | |
| 2768 | 2768 | ** SQLITE_OPEN_READWRITE and SQLITE_OPEN_CREATE. ^If the mode option is |
| 2769 | 2769 | ** set to "memory" then a pure [in-memory database] that never reads |
| 2770 | 2770 | ** or writes from disk is used. ^It is an error to specify a value for |
| r31374 | r31375 | |
| 2774 | 2774 | ** <li> <b>cache</b>: ^The cache parameter may be set to either "shared" or |
| 2775 | 2775 | ** "private". ^Setting it to "shared" is equivalent to setting the |
| 2776 | 2776 | ** 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 | |
| 2778 | 2778 | ** equivalent to setting the SQLITE_OPEN_PRIVATECACHE bit. |
| 2779 | 2779 | ** ^If sqlite3_open_v2() is used and the "cache" parameter is present in |
| 2780 | 2780 | ** a URI filename, its value overrides any behavior requested by setting |
| r31374 | r31375 | |
| 2790 | 2790 | ** |
| 2791 | 2791 | ** <table border="1" align=center cellpadding=5> |
| 2792 | 2792 | ** <tr><th> URI filenames <th> Results |
| 2793 | ** <tr><td> file:data.db <td> | |
| 2793 | ** <tr><td> file:data.db <td> | |
| 2794 | 2794 | ** Open the file "data.db" in the current directory. |
| 2795 | 2795 | ** <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> | |
| 2798 | 2798 | ** 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> | |
| 2800 | 2800 | ** An error. "darkstar" is not a recognized authority. |
| 2801 | ** <tr><td style="white-space:nowrap"> | |
| 2801 | ** <tr><td style="white-space:nowrap"> | |
| 2802 | 2802 | ** file:///C:/Documents%20and%20Settings/fred/Desktop/data.db |
| 2803 | 2803 | ** <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 | |
| 2805 | 2805 | ** necessary - space characters can be used literally |
| 2806 | 2806 | ** 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> | |
| 2808 | 2808 | ** Open file "data.db" in the current directory for read-only access. |
| 2809 | 2809 | ** Regardless of whether or not shared-cache mode is enabled by |
| 2810 | 2810 | ** default, use a private cache. |
| 2811 | 2811 | ** <tr><td> file:/home/fred/data.db?vfs=unix-nolock <td> |
| 2812 | 2812 | ** 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> | |
| 2814 | 2814 | ** An error. "readonly" is not a valid option for the "mode" parameter. |
| 2815 | 2815 | ** </table> |
| 2816 | 2816 | ** |
| 2817 | 2817 | ** ^URI hexadecimal escape sequences (%HH) are supported within the path and |
| 2818 | 2818 | ** 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 | |
| 2820 | 2820 | ** 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 | |
| 2822 | 2822 | ** hexadecimal escape sequences replaced by a single byte containing the |
| 2823 | 2823 | ** corresponding octet. If this process generates an invalid UTF-8 encoding, |
| 2824 | 2824 | ** the results are undefined. |
| r31374 | r31375 | |
| 2836 | 2836 | ** See also: [sqlite3_temp_directory] |
| 2837 | 2837 | */ |
| 2838 | 2838 | SQLITE_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 */ | |
| 2841 | 2841 | ); |
| 2842 | 2842 | SQLITE_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 */ | |
| 2845 | 2845 | ); |
| 2846 | 2846 | SQLITE_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 */ | |
| 2851 | 2851 | ); |
| 2852 | 2852 | |
| 2853 | 2853 | /* |
| 2854 | 2854 | ** CAPI3REF: Obtain Values For URI Parameters |
| 2855 | 2855 | ** |
| 2856 | 2856 | ** 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 | |
| 2858 | 2858 | ** parameter, and if so obtains the value of that query parameter. |
| 2859 | 2859 | ** |
| 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 | |
| 2862 | 2862 | ** more of the [SQLITE_OPEN_URI] or [SQLITE_OPEN_MAIN_DB] bits set and |
| 2863 | 2863 | ** P is the name of the query parameter, then |
| 2864 | 2864 | ** 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 | |
| 2866 | 2866 | ** query parameter on F. If P is a query parameter of F |
| 2867 | 2867 | ** has no explicit value, then sqlite3_uri_parameter(F,P) returns |
| 2868 | 2868 | ** a pointer to an empty string. |
| r31374 | r31375 | |
| 2871 | 2871 | ** parameter and returns true (1) or false (0) according to the value |
| 2872 | 2872 | ** of P. The sqlite3_uri_boolean(F,P,B) routine returns true (1) if the |
| 2873 | 2873 | ** 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 | |
| 2875 | 2875 | ** sqlite3_uri_boolean(F,P,B) routines returns false (0) if the value of |
| 2876 | 2876 | ** query parameter P is one of "no", "false", or "off" in any case or |
| 2877 | 2877 | ** if the value begins with a numeric zero. If P is not a query |
| r31374 | r31375 | |
| 2882 | 2882 | ** 64-bit signed integer and returns that integer, or D if P does not |
| 2883 | 2883 | ** exist. If the value of P is something other than an integer, then |
| 2884 | 2884 | ** zero is returned. |
| 2885 | ** | |
| 2885 | ** | |
| 2886 | 2886 | ** If F is a NULL pointer, then sqlite3_uri_parameter(F,P) returns NULL and |
| 2887 | 2887 | ** sqlite3_uri_boolean(F,P,B) returns B. If F is not a NULL pointer and |
| 2888 | 2888 | ** is not a database file pathname pointer that SQLite passed into the xOpen |
| r31374 | r31375 | |
| 2902 | 2902 | ** associated with a [database connection]. If a prior API call failed |
| 2903 | 2903 | ** but the most recent API call succeeded, the return value from |
| 2904 | 2904 | ** 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 | |
| 2906 | 2906 | ** [extended result code] even when extended result codes are |
| 2907 | 2907 | ** disabled. |
| 2908 | 2908 | ** |
| r31374 | r31375 | |
| 2975 | 2975 | ** new limit for that construct.)^ |
| 2976 | 2976 | ** |
| 2977 | 2977 | ** ^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 | |
| 2979 | 2979 | ** [limits | hard upper bound] |
| 2980 | 2980 | ** set at compile-time by a C preprocessor macro called |
| 2981 | 2981 | ** [limits | SQLITE_MAX_<i>NAME</i>]. |
| r31374 | r31375 | |
| 2983 | 2983 | ** ^Attempts to increase a limit above its hard upper bound are |
| 2984 | 2984 | ** silently truncated to the hard upper bound. |
| 2985 | 2985 | ** |
| 2986 | ** ^Regardless of whether or not the limit was changed, the | |
| 2986 | ** ^Regardless of whether or not the limit was changed, the | |
| 2987 | 2987 | ** [sqlite3_limit()] interface returns the prior value of the limit. |
| 2988 | 2988 | ** ^Hence, to find the current value of a limit without changing it, |
| 2989 | 2989 | ** simply invoke this interface with the third parameter set to -1. |
| r31374 | r31375 | |
| 3138 | 3138 | ** </li> |
| 3139 | 3139 | ** |
| 3140 | 3140 | ** <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 | |
| 3142 | 3142 | ** 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 | |
| 3144 | 3144 | ** 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 | |
| 3147 | 3147 | ** choice of query plan if the parameter is the left-hand side of a [LIKE] |
| 3148 | 3148 | ** or [GLOB] operator or if the parameter is compared to an indexed column |
| 3149 | 3149 | ** and the [SQLITE_ENABLE_STAT3] compile-time option is enabled. |
| r31374 | r31375 | |
| 3151 | 3151 | ** </ol> |
| 3152 | 3152 | */ |
| 3153 | 3153 | SQLITE_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 */ | |
| 3159 | 3159 | ); |
| 3160 | 3160 | SQLITE_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 */ | |
| 3166 | 3166 | ); |
| 3167 | 3167 | SQLITE_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 */ | |
| 3173 | 3173 | ); |
| 3174 | 3174 | SQLITE_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 */ | |
| 3180 | 3180 | ); |
| 3181 | 3181 | |
| 3182 | 3182 | /* |
| r31374 | r31375 | |
| 3196 | 3196 | ** the content of the database file. |
| 3197 | 3197 | ** |
| 3198 | 3198 | ** 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 | |
| 3201 | 3201 | ** calls [sqlite3_exec()], then the following SQL statement would |
| 3202 | 3202 | ** change the database file through side-effects: |
| 3203 | 3203 | ** |
| r31374 | r31375 | |
| 3211 | 3211 | ** ^Transaction control statements such as [BEGIN], [COMMIT], [ROLLBACK], |
| 3212 | 3212 | ** [SAVEPOINT], and [RELEASE] cause sqlite3_stmt_readonly() to return true, |
| 3213 | 3213 | ** 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 | |
| 3215 | 3215 | ** database. ^The [ATTACH] and [DETACH] statements also cause |
| 3216 | 3216 | ** 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 | |
| 3218 | 3218 | ** changes to the content of the database files on disk. |
| 3219 | 3219 | */ |
| 3220 | 3220 | SQLITE_API int sqlite3_stmt_readonly(sqlite3_stmt *pStmt); |
| r31374 | r31375 | |
| 3223 | 3223 | ** CAPI3REF: Determine If A Prepared Statement Has Been Reset |
| 3224 | 3224 | ** |
| 3225 | 3225 | ** ^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 | |
| 3228 | 3228 | ** 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 | |
| 3230 | 3230 | ** NULL pointer and is not a pointer to a valid [prepared statement] |
| 3231 | 3231 | ** object, then the behavior is undefined and probably undesirable. |
| 3232 | 3232 | ** |
| 3233 | 3233 | ** 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 | |
| 3235 | 3235 | ** 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 | |
| 3237 | 3237 | ** statements that are holding a transaction open. |
| 3238 | 3238 | */ |
| 3239 | 3239 | SQLITE_API int sqlite3_stmt_busy(sqlite3_stmt*); |
| r31374 | r31375 | |
| 3258 | 3258 | ** sqlite3_value object but no mutex is held for an unprotected |
| 3259 | 3259 | ** sqlite3_value object. If SQLite is compiled to be single-threaded |
| 3260 | 3260 | ** (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 | |
| 3262 | 3262 | ** [SQLITE_CONFIG_SINGLETHREAD] or [SQLITE_CONFIG_MULTITHREAD] |
| 3263 | 3263 | ** then there is no distinction between protected and unprotected |
| 3264 | 3264 | ** sqlite3_value objects and they can be used interchangeably. However, |
| r31374 | r31375 | |
| 3343 | 3343 | ** If a non-negative fourth parameter is provided to sqlite3_bind_text() |
| 3344 | 3344 | ** or sqlite3_bind_text16() then that parameter must be the byte offset |
| 3345 | 3345 | ** 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 | |
| 3347 | 3347 | ** the value of the fourth parameter then the resulting string value will |
| 3348 | 3348 | ** contain embedded NULs. The result of expressions involving strings |
| 3349 | 3349 | ** with embedded NULs is undefined. |
| r31374 | r31375 | |
| 3352 | 3352 | ** sqlite3_bind_text16() is a destructor used to dispose of the BLOB or |
| 3353 | 3353 | ** string after SQLite has finished with it. ^The destructor is called |
| 3354 | 3354 | ** 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. | |
| 3356 | 3356 | ** ^If the fifth argument is |
| 3357 | 3357 | ** the special value [SQLITE_STATIC], then SQLite assumes that the |
| 3358 | 3358 | ** information is in static, unmanaged space and does not need to be freed. |
| r31374 | r31375 | |
| 3648 | 3648 | ** For all versions of SQLite up to and including 3.6.23.1, a call to |
| 3649 | 3649 | ** [sqlite3_reset()] was required after sqlite3_step() returned anything |
| 3650 | 3650 | ** 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 | |
| 3652 | 3652 | ** [sqlite3_reset()] would result in an [SQLITE_MISUSE] return from |
| 3653 | 3653 | ** sqlite3_step(). But after version 3.6.23.1, sqlite3_step() began |
| 3654 | 3654 | ** calling [sqlite3_reset()] automatically in this circumstance rather |
| r31374 | r31375 | |
| 3778 | 3778 | ** the number of bytes in that string. |
| 3779 | 3779 | ** ^If the result is NULL, then sqlite3_column_bytes16() returns zero. |
| 3780 | 3780 | ** |
| 3781 | ** ^The values returned by [sqlite3_column_bytes()] and | |
| 3781 | ** ^The values returned by [sqlite3_column_bytes()] and | |
| 3782 | 3782 | ** [sqlite3_column_bytes16()] do not include the zero terminators at the end |
| 3783 | 3783 | ** of the string. ^For clarity: the values returned by |
| 3784 | 3784 | ** [sqlite3_column_bytes()] and [sqlite3_column_bytes16()] are the number of |
| r31374 | r31375 | |
| 3971 | 3971 | ** ^The second parameter is the name of the SQL function to be created or |
| 3972 | 3972 | ** redefined. ^The length of the name is limited to 255 bytes in a UTF-8 |
| 3973 | 3973 | ** 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. | |
| 3975 | 3975 | ** ^Any attempt to create a function with a longer name |
| 3976 | 3976 | ** will result in [SQLITE_MISUSE] being returned. |
| 3977 | 3977 | ** |
| r31374 | r31375 | |
| 3986 | 3986 | ** ^The fourth parameter, eTextRep, specifies what |
| 3987 | 3987 | ** [SQLITE_UTF8 | text encoding] this SQL function prefers for |
| 3988 | 3988 | ** 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 | |
| 3990 | 3990 | ** [sqlite3_value_text16le()] on an input, or [SQLITE_UTF16BE] if the |
| 3991 | 3991 | ** implementation invokes [sqlite3_value_text16be()] on an input, or |
| 3992 | 3992 | ** [SQLITE_UTF16] if [sqlite3_value_text16()] is used, or [SQLITE_UTF8] |
| r31374 | r31375 | |
| 4017 | 4017 | ** callbacks. |
| 4018 | 4018 | ** |
| 4019 | 4019 | ** ^(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. | |
| 4021 | 4021 | ** The destructor is invoked when the function is deleted, either by being |
| 4022 | 4022 | ** overloaded or when the database connection closes.)^ |
| 4023 | 4023 | ** ^The destructor is also invoked if the call to |
| 4024 | 4024 | ** sqlite3_create_function_v2() fails. |
| 4025 | 4025 | ** ^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 | |
| 4027 | 4027 | ** pointer which was the fifth parameter to sqlite3_create_function_v2(). |
| 4028 | 4028 | ** |
| 4029 | 4029 | ** ^It is permitted to register multiple implementations of the same |
| r31374 | r31375 | |
| 4034 | 4034 | ** nArg parameter is a better match than a function implementation with |
| 4035 | 4035 | ** a negative nArg. ^A function where the preferred text encoding |
| 4036 | 4036 | ** 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. | |
| 4038 | 4038 | ** ^A function where the encoding difference is between UTF16le and UTF16be |
| 4039 | 4039 | ** is a closer match than a function where the encoding difference is |
| 4040 | 4040 | ** between UTF8 and UTF16. |
| r31374 | r31375 | |
| 4047 | 4047 | ** statement in which the function is running. |
| 4048 | 4048 | */ |
| 4049 | 4049 | SQLITE_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*) | |
| 4058 | 4058 | ); |
| 4059 | 4059 | SQLITE_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*) | |
| 4068 | 4068 | ); |
| 4069 | 4069 | SQLITE_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*) | |
| 4079 | 4079 | ); |
| 4080 | 4080 | |
| 4081 | 4081 | /* |
| r31374 | r31375 | |
| 4094 | 4094 | /* |
| 4095 | 4095 | ** CAPI3REF: Function Flags |
| 4096 | 4096 | ** |
| 4097 | ** These constants may be ORed together with the | |
| 4097 | ** These constants may be ORed together with the | |
| 4098 | 4098 | ** [SQLITE_UTF8 | preferred text encoding] as the fourth argument |
| 4099 | 4099 | ** to [sqlite3_create_function()], [sqlite3_create_function16()], or |
| 4100 | 4100 | ** [sqlite3_create_function_v2()]. |
| r31374 | r31375 | |
| 4106 | 4106 | ** DEPRECATED |
| 4107 | 4107 | ** |
| 4108 | 4108 | ** 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 | |
| 4110 | 4110 | ** to be supported. However, new applications should avoid |
| 4111 | 4111 | ** the use of these functions. To help encourage people to avoid |
| 4112 | 4112 | ** using these functions, we are not going to tell you what they do. |
| r31374 | r31375 | |
| 4118 | 4118 | SQLITE_API SQLITE_DEPRECATED int sqlite3_global_recover(void); |
| 4119 | 4119 | SQLITE_API SQLITE_DEPRECATED void sqlite3_thread_cleanup(void); |
| 4120 | 4120 | SQLITE_API SQLITE_DEPRECATED int sqlite3_memory_alarm(void(*)(void*,sqlite3_int64,int), |
| 4121 | ||
| 4121 | void*,sqlite3_int64); | |
| 4122 | 4122 | #endif |
| 4123 | 4123 | |
| 4124 | 4124 | /* |
| r31374 | r31375 | |
| 4185 | 4185 | ** Implementations of aggregate SQL functions use this |
| 4186 | 4186 | ** routine to allocate memory for storing their state. |
| 4187 | 4187 | ** |
| 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 | |
| 4189 | 4189 | ** for a particular aggregate function, SQLite |
| 4190 | 4190 | ** allocates N of memory, zeroes out that memory, and returns a pointer |
| 4191 | 4191 | ** to the new memory. ^On second and subsequent calls to |
| r31374 | r31375 | |
| 4198 | 4198 | ** In those cases, sqlite3_aggregate_context() might be called for the |
| 4199 | 4199 | ** first time from within xFinal().)^ |
| 4200 | 4200 | ** |
| 4201 | ** ^The sqlite3_aggregate_context(C,N) routine returns a NULL pointer | |
| 4201 | ** ^The sqlite3_aggregate_context(C,N) routine returns a NULL pointer | |
| 4202 | 4202 | ** when first called if N is less than or equal to zero or if a memory |
| 4203 | 4203 | ** allocate error occurs. |
| 4204 | 4204 | ** |
| r31374 | r31375 | |
| 4207 | 4207 | ** value of N in subsequent call to sqlite3_aggregate_context() within |
| 4208 | 4208 | ** the same aggregate function instance will not resize the memory |
| 4209 | 4209 | ** 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 | |
| 4211 | 4211 | ** pointless memory allocations occur. |
| 4212 | 4212 | ** |
| 4213 | ** ^SQLite automatically frees the memory allocated by | |
| 4213 | ** ^SQLite automatically frees the memory allocated by | |
| 4214 | 4214 | ** sqlite3_aggregate_context() when the aggregate query concludes. |
| 4215 | 4215 | ** |
| 4216 | 4216 | ** The first parameter must be a copy of the |
| r31374 | r31375 | |
| 4257 | 4257 | ** some circumstances the associated metadata may be preserved. An example |
| 4258 | 4258 | ** of where this might be useful is in a regular-expression matching |
| 4259 | 4259 | ** 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. | |
| 4261 | 4261 | ** Then as long as the pattern string remains the same, |
| 4262 | 4262 | ** the compiled regular expression can be reused on multiple |
| 4263 | 4263 | ** invocations of the same function. |
| r31374 | r31375 | |
| 4281 | 4281 | ** <li> when [sqlite3_reset()] or [sqlite3_finalize()] is called for the |
| 4282 | 4282 | ** SQL statement, or |
| 4283 | 4283 | ** <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 | |
| 4285 | 4285 | ** allocation error occurs. </ul>)^ |
| 4286 | 4286 | ** |
| 4287 | ** Note the last bullet in particular. The destructor X in | |
| 4287 | ** Note the last bullet in particular. The destructor X in | |
| 4288 | 4288 | ** sqlite3_set_auxdata(C,N,P,X) might be called immediately, before the |
| 4289 | 4289 | ** sqlite3_set_auxdata() interface even returns. Hence sqlite3_set_auxdata() |
| 4290 | 4290 | ** should be called near the end of the function implementation and the |
| r31374 | r31375 | |
| 4485 | 4485 | ** deleted. ^When all collating functions having the same name are deleted, |
| 4486 | 4486 | ** that collation is no longer usable. |
| 4487 | 4487 | ** |
| 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 | |
| 4489 | 4489 | ** application data pointer and with two strings in the encoding specified |
| 4490 | 4490 | ** by the eTextRep argument. The collating function must return an |
| 4491 | 4491 | ** integer that is negative, zero, or positive |
| r31374 | r31375 | |
| 4515 | 4515 | ** calls to the collation creation functions or when the |
| 4516 | 4516 | ** [database connection] is closed using [sqlite3_close()]. |
| 4517 | 4517 | ** |
| 4518 | ** ^The xDestroy callback is <u>not</u> called if the | |
| 4518 | ** ^The xDestroy callback is <u>not</u> called if the | |
| 4519 | 4519 | ** 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 | |
| 4521 | 4521 | ** check the return code and dispose of the application data pointer |
| 4522 | 4522 | ** 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 | |
| 4525 | 4525 | ** compatibility. |
| 4526 | 4526 | ** |
| 4527 | 4527 | ** See also: [sqlite3_collation_needed()] and [sqlite3_collation_needed16()]. |
| 4528 | 4528 | */ |
| 4529 | 4529 | SQLITE_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*) | |
| 4535 | 4535 | ); |
| 4536 | 4536 | SQLITE_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*) | |
| 4543 | 4543 | ); |
| 4544 | 4544 | SQLITE_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*) | |
| 4550 | 4550 | ); |
| 4551 | 4551 | |
| 4552 | 4552 | /* |
| r31374 | r31375 | |
| 4576 | 4576 | ** [sqlite3_create_collation_v2()]. |
| 4577 | 4577 | */ |
| 4578 | 4578 | SQLITE_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*) | |
| 4582 | 4582 | ); |
| 4583 | 4583 | SQLITE_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*) | |
| 4587 | 4587 | ); |
| 4588 | 4588 | |
| 4589 | 4589 | #ifdef SQLITE_HAS_CODEC |
| r31374 | r31375 | |
| 4595 | 4595 | ** of SQLite. |
| 4596 | 4596 | */ |
| 4597 | 4597 | SQLITE_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 */ | |
| 4600 | 4600 | ); |
| 4601 | 4601 | SQLITE_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 */ | |
| 4605 | 4605 | ); |
| 4606 | 4606 | |
| 4607 | 4607 | /* |
| r31374 | r31375 | |
| 4613 | 4613 | ** of SQLite. |
| 4614 | 4614 | */ |
| 4615 | 4615 | SQLITE_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 */ | |
| 4618 | 4618 | ); |
| 4619 | 4619 | SQLITE_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 */ | |
| 4623 | 4623 | ); |
| 4624 | 4624 | |
| 4625 | 4625 | /* |
| 4626 | ** Specify the activation key for a SEE database. Unless | |
| 4626 | ** Specify the activation key for a SEE database. Unless | |
| 4627 | 4627 | ** activated, none of the SEE routines will work. |
| 4628 | 4628 | */ |
| 4629 | 4629 | SQLITE_API void sqlite3_activate_see( |
| 4630 | ||
| 4630 | const char *zPassPhrase /* Activation phrase */ | |
| 4631 | 4631 | ); |
| 4632 | 4632 | #endif |
| 4633 | 4633 | |
| 4634 | 4634 | #ifdef SQLITE_ENABLE_CEROD |
| 4635 | 4635 | /* |
| 4636 | ** Specify the activation key for a CEROD database. Unless | |
| 4636 | ** Specify the activation key for a CEROD database. Unless | |
| 4637 | 4637 | ** activated, none of the CEROD routines will work. |
| 4638 | 4638 | */ |
| 4639 | 4639 | SQLITE_API void sqlite3_activate_cerod( |
| 4640 | ||
| 4640 | const char *zPassPhrase /* Activation phrase */ | |
| 4641 | 4641 | ); |
| 4642 | 4642 | #endif |
| 4643 | 4643 | |
| r31374 | r31375 | |
| 4682 | 4682 | ** ^The [temp_store_directory pragma] may modify this variable and cause |
| 4683 | 4683 | ** it to point to memory obtained from [sqlite3_malloc]. ^Furthermore, |
| 4684 | 4684 | ** 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 | |
| 4686 | 4686 | ** [sqlite3_malloc] and the pragma may attempt to free that memory |
| 4687 | 4687 | ** using [sqlite3_free]. |
| 4688 | 4688 | ** Hence, if this variable is modified directly, either it should be |
| r31374 | r31375 | |
| 4734 | 4734 | ** ^The [data_store_directory pragma] may modify this variable and cause |
| 4735 | 4735 | ** it to point to memory obtained from [sqlite3_malloc]. ^Furthermore, |
| 4736 | 4736 | ** 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 | |
| 4738 | 4738 | ** [sqlite3_malloc] and the pragma may attempt to free that memory |
| 4739 | 4739 | ** using [sqlite3_free]. |
| 4740 | 4740 | ** Hence, if this variable is modified directly, either it should be |
| r31374 | r31375 | |
| 4916 | 4916 | ** interfaces. |
| 4917 | 4917 | */ |
| 4918 | 4918 | SQLITE_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* | |
| 4922 | 4922 | ); |
| 4923 | 4923 | |
| 4924 | 4924 | /* |
| r31374 | r31375 | |
| 4991 | 4991 | ** as heap memory usages approaches the limit. |
| 4992 | 4992 | ** ^The soft heap limit is "soft" because even though SQLite strives to stay |
| 4993 | 4993 | ** 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 | |
| 4995 | 4995 | ** is advisory only. |
| 4996 | 4996 | ** |
| 4997 | 4997 | ** ^The return value from sqlite3_soft_heap_limit64() is the size of |
| r31374 | r31375 | |
| 5108 | 5108 | ** [SQLITE_ENABLE_COLUMN_METADATA] C-preprocessor symbol defined. |
| 5109 | 5109 | */ |
| 5110 | 5110 | SQLITE_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 */ | |
| 5120 | 5120 | ); |
| 5121 | 5121 | |
| 5122 | 5122 | /* |
| r31374 | r31375 | |
| 5154 | 5154 | ** See also the [load_extension() SQL function]. |
| 5155 | 5155 | */ |
| 5156 | 5156 | SQLITE_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 */ | |
| 5161 | 5161 | ); |
| 5162 | 5162 | |
| 5163 | 5163 | /* |
| r31374 | r31375 | |
| 5219 | 5219 | ** ^The [sqlite3_cancel_auto_extension(X)] interface unregisters the |
| 5220 | 5220 | ** initialization routine X that was registered using a prior call to |
| 5221 | 5221 | ** [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 | |
| 5223 | 5223 | ** unregistered and it returns 0 if X was not on the list of initialization |
| 5224 | 5224 | ** routines. |
| 5225 | 5225 | */ |
| r31374 | r31375 | |
| 5254 | 5254 | ** CAPI3REF: Virtual Table Object |
| 5255 | 5255 | ** KEYWORDS: sqlite3_module {virtual table module} |
| 5256 | 5256 | ** |
| 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]. | |
| 5259 | 5259 | ** This structure consists mostly of methods for the module. |
| 5260 | 5260 | ** |
| 5261 | 5261 | ** ^A virtual table module is created by filling in a persistent |
| r31374 | r31375 | |
| 5267 | 5267 | ** any database connection. |
| 5268 | 5268 | */ |
| 5269 | 5269 | struct 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); | |
| 5302 | 5302 | }; |
| 5303 | 5303 | |
| 5304 | 5304 | /* |
| r31374 | r31375 | |
| 5351 | 5351 | ** |
| 5352 | 5352 | ** ^The estimatedCost value is an estimate of the cost of a particular |
| 5353 | 5353 | ** 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) | |
| 5355 | 5355 | ** indicates that the expense of the operation is similar to that of a |
| 5356 | 5356 | ** binary search on a unique indexed field of an SQLite table with N rows. |
| 5357 | 5357 | ** |
| r31374 | r31375 | |
| 5360 | 5360 | ** |
| 5361 | 5361 | ** IMPORTANT: The estimatedRows field was added to the sqlite3_index_info |
| 5362 | 5362 | ** 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 | |
| 5365 | 5365 | ** to included crashing the application). The estimatedRows field should |
| 5366 | 5366 | ** therefore only be used if [sqlite3_libversion_number()] returns a |
| 5367 | 5367 | ** value greater than or equal to 3008002. |
| 5368 | 5368 | */ |
| 5369 | 5369 | struct 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 */ | |
| 5395 | 5395 | }; |
| 5396 | 5396 | |
| 5397 | 5397 | /* |
| r31374 | r31375 | |
| 5418 | 5418 | ** preexisting [virtual table] for the module. |
| 5419 | 5419 | ** |
| 5420 | 5420 | ** ^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 | |
| 5422 | 5422 | ** second parameter. ^The third parameter is a pointer to |
| 5423 | 5423 | ** the implementation of the [virtual table module]. ^The fourth |
| 5424 | 5424 | ** parameter is an arbitrary client data pointer that is passed through |
| r31374 | r31375 | |
| 5435 | 5435 | ** destructor. |
| 5436 | 5436 | */ |
| 5437 | 5437 | SQLITE_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 */ | |
| 5442 | 5442 | ); |
| 5443 | 5443 | SQLITE_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 */ | |
| 5449 | 5449 | ); |
| 5450 | 5450 | |
| 5451 | 5451 | /* |
| r31374 | r31375 | |
| 5467 | 5467 | ** freed by sqlite3_free() and the zErrMsg field will be zeroed. |
| 5468 | 5468 | */ |
| 5469 | 5469 | struct 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 */ | |
| 5474 | 5474 | }; |
| 5475 | 5475 | |
| 5476 | 5476 | /* |
| r31374 | r31375 | |
| 5491 | 5491 | ** are common to all implementations. |
| 5492 | 5492 | */ |
| 5493 | 5493 | struct 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 */ | |
| 5496 | 5496 | }; |
| 5497 | 5497 | |
| 5498 | 5498 | /* |
| r31374 | r31375 | |
| 5509 | 5509 | ** CAPI3REF: Overload A Function For A Virtual Table |
| 5510 | 5510 | ** |
| 5511 | 5511 | ** ^(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]. | |
| 5513 | 5513 | ** But global versions of those functions |
| 5514 | 5514 | ** must exist in order to be overloaded.)^ |
| 5515 | 5515 | ** |
| r31374 | r31375 | |
| 5560 | 5560 | ** |
| 5561 | 5561 | ** ^If the flags parameter is non-zero, then the BLOB is opened for read |
| 5562 | 5562 | ** 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 | |
| 5565 | 5565 | ** not possible to open a column that is part of a [child key] for writing. |
| 5566 | 5566 | ** |
| 5567 | 5567 | ** ^Note that the database name is not the filename that contains |
| r31374 | r31375 | |
| 5607 | 5607 | ** be released by a call to [sqlite3_blob_close()]. |
| 5608 | 5608 | */ |
| 5609 | 5609 | SQLITE_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 | |
| 5617 | 5617 | ); |
| 5618 | 5618 | |
| 5619 | 5619 | /* |
| r31374 | r31375 | |
| 5667 | 5667 | /* |
| 5668 | 5668 | ** CAPI3REF: Return The Size Of An Open BLOB |
| 5669 | 5669 | ** |
| 5670 | ** ^Returns the size in bytes of the BLOB accessible via the | |
| 5670 | ** ^Returns the size in bytes of the BLOB accessible via the | |
| 5671 | 5671 | ** successfully opened [BLOB handle] in its only argument. ^The |
| 5672 | 5672 | ** incremental blob I/O routines can only read or overwriting existing |
| 5673 | 5673 | ** blob content; they cannot change the size of a blob. |
| r31374 | r31375 | |
| 5964 | 5964 | */ |
| 5965 | 5965 | typedef struct sqlite3_mutex_methods sqlite3_mutex_methods; |
| 5966 | 5966 | struct 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 *); | |
| 5976 | 5976 | }; |
| 5977 | 5977 | |
| 5978 | 5978 | /* |
| r31374 | r31375 | |
| 6033 | 6033 | /* |
| 6034 | 6034 | ** CAPI3REF: Retrieve the mutex for a database connection |
| 6035 | 6035 | ** |
| 6036 | ** ^This interface returns a pointer the [sqlite3_mutex] object that | |
| 6036 | ** ^This interface returns a pointer the [sqlite3_mutex] object that | |
| 6037 | 6037 | ** serializes access to the [database connection] given in the argument |
| 6038 | 6038 | ** when the [threading mode] is Serialized. |
| 6039 | 6039 | ** ^If the [threading mode] is Single-thread or Multi-thread then this |
| r31374 | r31375 | |
| 6179 | 6179 | ** <dd>This parameter records the largest memory allocation request |
| 6180 | 6180 | ** handed to [sqlite3_malloc()] or [sqlite3_realloc()] (or their |
| 6181 | 6181 | ** 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. | |
| 6183 | 6183 | ** The value written into the *pCurrent parameter is undefined.</dd>)^ |
| 6184 | 6184 | ** |
| 6185 | 6185 | ** [[SQLITE_STATUS_MALLOC_COUNT]] ^(<dt>SQLITE_STATUS_MALLOC_COUNT</dt> |
| r31374 | r31375 | |
| 6188 | 6188 | ** |
| 6189 | 6189 | ** [[SQLITE_STATUS_PAGECACHE_USED]] ^(<dt>SQLITE_STATUS_PAGECACHE_USED</dt> |
| 6190 | 6190 | ** <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 | |
| 6192 | 6192 | ** [SQLITE_CONFIG_PAGECACHE]. The |
| 6193 | 6193 | ** value returned is in pages, not in bytes.</dd>)^ |
| 6194 | 6194 | ** |
| 6195 | ** [[SQLITE_STATUS_PAGECACHE_OVERFLOW]] | |
| 6195 | ** [[SQLITE_STATUS_PAGECACHE_OVERFLOW]] | |
| 6196 | 6196 | ** ^(<dt>SQLITE_STATUS_PAGECACHE_OVERFLOW</dt> |
| 6197 | 6197 | ** <dd>This parameter returns the number of bytes of page cache |
| 6198 | 6198 | ** allocation which could not be satisfied by the [SQLITE_CONFIG_PAGECACHE] |
| r31374 | r31375 | |
| 6205 | 6205 | ** [[SQLITE_STATUS_PAGECACHE_SIZE]] ^(<dt>SQLITE_STATUS_PAGECACHE_SIZE</dt> |
| 6206 | 6206 | ** <dd>This parameter records the largest memory allocation request |
| 6207 | 6207 | ** 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. | |
| 6209 | 6209 | ** The value written into the *pCurrent parameter is undefined.</dd>)^ |
| 6210 | 6210 | ** |
| 6211 | 6211 | ** [[SQLITE_STATUS_SCRATCH_USED]] ^(<dt>SQLITE_STATUS_SCRATCH_USED</dt> |
| r31374 | r31375 | |
| 6229 | 6229 | ** [[SQLITE_STATUS_SCRATCH_SIZE]] ^(<dt>SQLITE_STATUS_SCRATCH_SIZE</dt> |
| 6230 | 6230 | ** <dd>This parameter records the largest memory allocation request |
| 6231 | 6231 | ** 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. | |
| 6233 | 6233 | ** The value written into the *pCurrent parameter is undefined.</dd>)^ |
| 6234 | 6234 | ** |
| 6235 | 6235 | ** [[SQLITE_STATUS_PARSER_STACK]] ^(<dt>SQLITE_STATUS_PARSER_STACK</dt> |
| r31374 | r31375 | |
| 6253 | 6253 | /* |
| 6254 | 6254 | ** CAPI3REF: Database Connection Status |
| 6255 | 6255 | ** |
| 6256 | ** ^This interface is used to retrieve runtime status information | |
| 6256 | ** ^This interface is used to retrieve runtime status information | |
| 6257 | 6257 | ** about a single [database connection]. ^The first argument is the |
| 6258 | 6258 | ** database connection object to be interrogated. ^The second argument |
| 6259 | 6259 | ** is an integer constant, taken from the set of |
| 6260 | 6260 | ** [SQLITE_DBSTATUS options], that |
| 6261 | ** determines the parameter to interrogate. The set of | |
| 6261 | ** determines the parameter to interrogate. The set of | |
| 6262 | 6262 | ** [SQLITE_DBSTATUS options] is likely |
| 6263 | 6263 | ** to grow in future releases of SQLite. |
| 6264 | 6264 | ** |
| r31374 | r31375 | |
| 6293 | 6293 | ** checked out.</dd>)^ |
| 6294 | 6294 | ** |
| 6295 | 6295 | ** [[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 | |
| 6297 | 6297 | ** satisfied using lookaside memory. Only the high-water value is meaningful; |
| 6298 | 6298 | ** the current value is always zero.)^ |
| 6299 | 6299 | ** |
| r31374 | r31375 | |
| 6321 | 6321 | ** [[SQLITE_DBSTATUS_SCHEMA_USED]] ^(<dt>SQLITE_DBSTATUS_SCHEMA_USED</dt> |
| 6322 | 6322 | ** <dd>This parameter returns the approximate number of of bytes of heap |
| 6323 | 6323 | ** 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.)^ | |
| 6325 | 6325 | ** ^The full amount of memory used by the schemas is reported, even if the |
| 6326 | 6326 | ** schema memory is shared with other database connections due to |
| 6327 | 6327 | ** [shared cache mode] being enabled. |
| r31374 | r31375 | |
| 6336 | 6336 | ** |
| 6337 | 6337 | ** [[SQLITE_DBSTATUS_CACHE_HIT]] ^(<dt>SQLITE_DBSTATUS_CACHE_HIT</dt> |
| 6338 | 6338 | ** <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 | |
| 6340 | 6340 | ** is always 0. |
| 6341 | 6341 | ** </dd> |
| 6342 | 6342 | ** |
| 6343 | 6343 | ** [[SQLITE_DBSTATUS_CACHE_MISS]] ^(<dt>SQLITE_DBSTATUS_CACHE_MISS</dt> |
| 6344 | 6344 | ** <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 | |
| 6346 | 6346 | ** is always 0. |
| 6347 | 6347 | ** </dd> |
| 6348 | 6348 | ** |
| r31374 | r31375 | |
| 6388 | 6388 | ** statements. For example, if the number of table steps greatly exceeds |
| 6389 | 6389 | ** the number of table searches or result rows, that would tend to indicate |
| 6390 | 6390 | ** that the prepared statement is using a full table scan rather than |
| 6391 | ** an index. | |
| 6391 | ** an index. | |
| 6392 | 6392 | ** |
| 6393 | 6393 | ** ^(This interface is used to retrieve and reset counter values from |
| 6394 | 6394 | ** a [prepared statement]. The first argument is the prepared statement |
| r31374 | r31375 | |
| 6415 | 6415 | ** [[SQLITE_STMTSTATUS_FULLSCAN_STEP]] <dt>SQLITE_STMTSTATUS_FULLSCAN_STEP</dt> |
| 6416 | 6416 | ** <dd>^This is the number of times that SQLite has stepped forward in |
| 6417 | 6417 | ** 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 | |
| 6419 | 6419 | ** careful use of indices.</dd> |
| 6420 | 6420 | ** |
| 6421 | 6421 | ** [[SQLITE_STMTSTATUS_SORT]] <dt>SQLITE_STMTSTATUS_SORT</dt> |
| r31374 | r31375 | |
| 6433 | 6433 | ** [[SQLITE_STMTSTATUS_VM_STEP]] <dt>SQLITE_STMTSTATUS_VM_STEP</dt> |
| 6434 | 6434 | ** <dd>^This is the number of virtual machine operations executed |
| 6435 | 6435 | ** 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 | |
| 6437 | 6437 | ** used as a proxy for the total work done by the prepared statement. |
| 6438 | 6438 | ** If the number of virtual machine operations exceeds 2147483647 |
| 6439 | 6439 | ** then the value returned by this statement status code is undefined. |
| r31374 | r31375 | |
| 6470 | 6470 | */ |
| 6471 | 6471 | typedef struct sqlite3_pcache_page sqlite3_pcache_page; |
| 6472 | 6472 | struct 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 */ | |
| 6475 | 6475 | }; |
| 6476 | 6476 | |
| 6477 | 6477 | /* |
| r31374 | r31375 | |
| 6479 | 6479 | ** KEYWORDS: {page cache} |
| 6480 | 6480 | ** |
| 6481 | 6481 | ** ^(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 | |
| 6483 | 6483 | ** 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 | |
| 6485 | 6485 | ** SQLite is used for the page cache. |
| 6486 | ** By implementing a | |
| 6486 | ** By implementing a | |
| 6487 | 6487 | ** 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 | |
| 6491 | 6491 | ** how long. |
| 6492 | 6492 | ** |
| 6493 | 6493 | ** The alternative page cache mechanism is an |
| r31374 | r31375 | |
| 6500 | 6500 | ** [sqlite3_config()] returns.)^ |
| 6501 | 6501 | ** |
| 6502 | 6502 | ** [[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 | |
| 6504 | 6504 | ** call to [sqlite3_initialize()])^ |
| 6505 | 6505 | ** (usually only once during the lifetime of the process). ^(The xInit() |
| 6506 | 6506 | ** 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 | |
| 6510 | 6510 | ** built-in default page cache is used instead of the application defined |
| 6511 | 6511 | ** page cache.)^ |
| 6512 | 6512 | ** |
| 6513 | 6513 | ** [[the xShutdown() page cache method]] |
| 6514 | 6514 | ** ^The xShutdown() method is called by [sqlite3_shutdown()]. |
| 6515 | ** It can be used to clean up | |
| 6515 | ** It can be used to clean up | |
| 6516 | 6516 | ** any outstanding resources before process shutdown, if required. |
| 6517 | 6517 | ** ^The xShutdown() method may be NULL. |
| 6518 | 6518 | ** |
| r31374 | r31375 | |
| 6531 | 6531 | ** though this is not guaranteed. ^The |
| 6532 | 6532 | ** first parameter, szPage, is the size in bytes of the pages that must |
| 6533 | 6533 | ** 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 | |
| 6535 | 6535 | ** associated with each page cache entry. ^The szExtra parameter will |
| 6536 | 6536 | ** a number less than 250. SQLite will use the |
| 6537 | 6537 | ** extra szExtra bytes on each page to store metadata about the underlying |
| r31374 | r31375 | |
| 6544 | 6544 | ** it is purely advisory. ^On a cache where bPurgeable is false, SQLite will |
| 6545 | 6545 | ** never invoke xUnpin() except to deliberately delete a page. |
| 6546 | 6546 | ** ^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. | |
| 6548 | 6548 | ** ^Hence, a cache created with bPurgeable false will |
| 6549 | 6549 | ** never contain any unpinned pages. |
| 6550 | 6550 | ** |
| r31374 | r31375 | |
| 6559 | 6559 | ** [[the xPagecount() page cache methods]] |
| 6560 | 6560 | ** The xPagecount() method must return the number of pages currently |
| 6561 | 6561 | ** stored in the cache, both pinned and unpinned. |
| 6562 | ** | |
| 6562 | ** | |
| 6563 | 6563 | ** [[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 | |
| 6565 | 6565 | ** an sqlite3_pcache_page object associated with that page, or a NULL pointer. |
| 6566 | 6566 | ** 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 | |
| 6568 | 6568 | ** single database page. The pExtra element of sqlite3_pcache_page will be |
| 6569 | 6569 | ** a pointer to the szExtra bytes of extra storage that SQLite has requested |
| 6570 | 6570 | ** for each entry in the page cache. |
| r31374 | r31375 | |
| 6603 | 6603 | ** page cache implementation. ^The page cache implementation |
| 6604 | 6604 | ** may choose to evict unpinned pages at any time. |
| 6605 | 6605 | ** |
| 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 | |
| 6608 | 6608 | ** to xFetch(). |
| 6609 | 6609 | ** |
| 6610 | 6610 | ** [[the xRekey() page cache methods]] |
| r31374 | r31375 | |
| 6635 | 6635 | */ |
| 6636 | 6636 | typedef struct sqlite3_pcache_methods2 sqlite3_pcache_methods2; |
| 6637 | 6637 | struct 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*); | |
| 6652 | 6652 | }; |
| 6653 | 6653 | |
| 6654 | 6654 | /* |
| r31374 | r31375 | |
| 6658 | 6658 | */ |
| 6659 | 6659 | typedef struct sqlite3_pcache_methods sqlite3_pcache_methods; |
| 6660 | 6660 | struct 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*); | |
| 6672 | 6672 | }; |
| 6673 | 6673 | |
| 6674 | 6674 | |
| r31374 | r31375 | |
| 6689 | 6689 | ** |
| 6690 | 6690 | ** The backup API copies the content of one database into another. |
| 6691 | 6691 | ** 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. | |
| 6693 | 6693 | ** |
| 6694 | 6694 | ** See Also: [Using the SQLite Online Backup API] |
| 6695 | 6695 | ** |
| r31374 | r31375 | |
| 6700 | 6700 | ** ^Thus, the backup may be performed on a live source database without |
| 6701 | 6701 | ** preventing other database connections from |
| 6702 | 6702 | ** 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: | |
| 6705 | 6705 | ** <ol> |
| 6706 | 6706 | ** <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 | |
| 6709 | 6709 | ** 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. | |
| 6712 | 6712 | ** </ol>)^ |
| 6713 | 6713 | ** There should be exactly one call to sqlite3_backup_finish() for each |
| 6714 | 6714 | ** successful call to sqlite3_backup_init(). |
| 6715 | 6715 | ** |
| 6716 | 6716 | ** [[sqlite3_backup_init()]] <b>sqlite3_backup_init()</b> |
| 6717 | 6717 | ** |
| 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 | |
| 6720 | 6720 | ** and the database name, respectively. |
| 6721 | 6721 | ** ^The database name is "main" for the main database, "temp" for the |
| 6722 | 6722 | ** temporary database, or the name specified after the AS keyword in |
| 6723 | 6723 | ** an [ATTACH] statement for an attached database. |
| 6724 | ** ^The S and M arguments passed to | |
| 6724 | ** ^The S and M arguments passed to | |
| 6725 | 6725 | ** sqlite3_backup_init(D,N,S,M) identify the [database connection] |
| 6726 | 6726 | ** and database name of the source database, respectively. |
| 6727 | 6727 | ** ^The source and destination [database connections] (parameters S and D) |
| r31374 | r31375 | |
| 6737 | 6737 | ** ^A successful call to sqlite3_backup_init() returns a pointer to an |
| 6738 | 6738 | ** [sqlite3_backup] object. |
| 6739 | 6739 | ** ^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 | |
| 6741 | 6741 | ** operation. |
| 6742 | 6742 | ** |
| 6743 | 6743 | ** [[sqlite3_backup_step()]] <b>sqlite3_backup_step()</b> |
| 6744 | 6744 | ** |
| 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 | |
| 6746 | 6746 | ** 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. | |
| 6748 | 6748 | ** ^If sqlite3_backup_step(B,N) successfully copies N pages and there |
| 6749 | 6749 | ** are still more pages to be copied, then the function returns [SQLITE_OK]. |
| 6750 | 6750 | ** ^If sqlite3_backup_step(B,N) successfully finishes copying all pages |
| r31374 | r31375 | |
| 6766 | 6766 | ** |
| 6767 | 6767 | ** ^If sqlite3_backup_step() cannot obtain a required file-system lock, then |
| 6768 | 6768 | ** 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 | |
| 6771 | 6771 | ** [SQLITE_BUSY] is returned to the caller. ^In this case the call to |
| 6772 | 6772 | ** sqlite3_backup_step() can be retried later. ^If the source |
| 6773 | 6773 | ** [database connection] |
| r31374 | r31375 | |
| 6775 | 6775 | ** is called, then [SQLITE_LOCKED] is returned immediately. ^Again, in this |
| 6776 | 6776 | ** case the call to sqlite3_backup_step() can be retried later on. ^(If |
| 6777 | 6777 | ** [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 | |
| 6782 | 6782 | ** to the sqlite3_backup_finish() to release associated resources. |
| 6783 | 6783 | ** |
| 6784 | 6784 | ** ^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 | |
| 6787 | 6787 | ** and sqlite3_backup_step() returns [SQLITE_DONE]. ^Every call to |
| 6788 | 6788 | ** sqlite3_backup_step() obtains a [shared lock] on the source database that |
| 6789 | 6789 | ** lasts for the duration of the sqlite3_backup_step() call. |
| r31374 | r31375 | |
| 6792 | 6792 | ** through the backup process. ^If the source database is modified by an |
| 6793 | 6793 | ** external process or via a database connection other than the one being |
| 6794 | 6794 | ** 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 | |
| 6796 | 6796 | ** database is modified by the using the same database connection as is used |
| 6797 | 6797 | ** by the backup operation, then the backup database is automatically |
| 6798 | 6798 | ** updated at the same time. |
| 6799 | 6799 | ** |
| 6800 | 6800 | ** [[sqlite3_backup_finish()]] <b>sqlite3_backup_finish()</b> |
| 6801 | 6801 | ** |
| 6802 | ** When sqlite3_backup_step() has returned [SQLITE_DONE], or when the | |
| 6802 | ** When sqlite3_backup_step() has returned [SQLITE_DONE], or when the | |
| 6803 | 6803 | ** application wishes to abandon the backup operation, the application |
| 6804 | 6804 | ** should destroy the [sqlite3_backup] by passing it to sqlite3_backup_finish(). |
| 6805 | 6805 | ** ^The sqlite3_backup_finish() interfaces releases all |
| 6806 | ** resources associated with the [sqlite3_backup] object. | |
| 6806 | ** resources associated with the [sqlite3_backup] object. | |
| 6807 | 6807 | ** ^If sqlite3_backup_step() has not yet returned [SQLITE_DONE], then any |
| 6808 | 6808 | ** active write-transaction on the destination database is rolled back. |
| 6809 | 6809 | ** The [sqlite3_backup] object is invalid |
| r31374 | r31375 | |
| 6843 | 6843 | ** connections, then the source database connection may be used concurrently |
| 6844 | 6844 | ** from within other threads. |
| 6845 | 6845 | ** |
| 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 | |
| 6848 | 6848 | ** sqlite3_backup_init() is called and before the corresponding call to |
| 6849 | 6849 | ** sqlite3_backup_finish(). SQLite does not currently check to see |
| 6850 | 6850 | ** if the application incorrectly accesses the destination [database connection] |
| r31374 | r31375 | |
| 6855 | 6855 | ** If running in [shared cache mode], the application must |
| 6856 | 6856 | ** guarantee that the shared cache used by the destination database |
| 6857 | 6857 | ** 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 | |
| 6859 | 6859 | ** backed up to is not accessed by any connection within the process, |
| 6860 | 6860 | ** not just the specific connection that was passed to sqlite3_backup_init(). |
| 6861 | 6861 | ** |
| 6862 | ** The [sqlite3_backup] object itself is partially threadsafe. Multiple | |
| 6862 | ** The [sqlite3_backup] object itself is partially threadsafe. Multiple | |
| 6863 | 6863 | ** threads may safely make multiple concurrent calls to sqlite3_backup_step(). |
| 6864 | 6864 | ** However, the sqlite3_backup_remaining() and sqlite3_backup_pagecount() |
| 6865 | 6865 | ** APIs are not strictly speaking threadsafe. If they are invoked at the |
| r31374 | r31375 | |
| 6867 | 6867 | ** possible that they return invalid values. |
| 6868 | 6868 | */ |
| 6869 | 6869 | SQLITE_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 */ | |
| 6874 | 6874 | ); |
| 6875 | 6875 | SQLITE_API int sqlite3_backup_step(sqlite3_backup *p, int nPage); |
| 6876 | 6876 | SQLITE_API int sqlite3_backup_finish(sqlite3_backup *p); |
| r31374 | r31375 | |
| 6883 | 6883 | ** ^When running in shared-cache mode, a database operation may fail with |
| 6884 | 6884 | ** an [SQLITE_LOCKED] error if the required locks on the shared-cache or |
| 6885 | 6885 | ** 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 | |
| 6888 | 6888 | ** when the connection currently holding the required lock relinquishes it. |
| 6889 | 6889 | ** ^This API is only available if the library was compiled with the |
| 6890 | 6890 | ** [SQLITE_ENABLE_UNLOCK_NOTIFY] C-preprocessor symbol defined. |
| r31374 | r31375 | |
| 6892 | 6892 | ** See Also: [Using the SQLite Unlock Notification Feature]. |
| 6893 | 6893 | ** |
| 6894 | 6894 | ** ^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. | |
| 6896 | 6896 | ** |
| 6897 | 6897 | ** ^When a connection (known as the blocked connection) fails to obtain a |
| 6898 | 6898 | ** shared-cache lock and SQLITE_LOCKED is returned to the caller, the |
| 6899 | 6899 | ** 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 | |
| 6901 | 6901 | ** 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 | |
| 6903 | 6903 | ** the first argument to register for a callback that will be invoked |
| 6904 | 6904 | ** when the blocking connections current transaction is concluded. ^The |
| 6905 | 6905 | ** callback is invoked from within the [sqlite3_step] or [sqlite3_close] |
| r31374 | r31375 | |
| 6913 | 6913 | ** |
| 6914 | 6914 | ** ^If the blocked connection is attempting to obtain a write-lock on a |
| 6915 | 6915 | ** 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 | |
| 6917 | 6917 | ** the other connections to use as the blocking connection. |
| 6918 | 6918 | ** |
| 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 | |
| 6920 | 6920 | ** blocked connection. If sqlite3_unlock_notify() is called when the |
| 6921 | 6921 | ** blocked connection already has a registered unlock-notify callback, |
| 6922 | 6922 | ** then the new callback replaces the old.)^ ^If sqlite3_unlock_notify() is |
| 6923 | 6923 | ** 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 | |
| 6925 | 6925 | ** unlock-notify callback may also be canceled by closing the blocked |
| 6926 | 6926 | ** connection using [sqlite3_close()]. |
| 6927 | 6927 | ** |
| r31374 | r31375 | |
| 6934 | 6934 | ** |
| 6935 | 6935 | ** <b>Callback Invocation Details</b> |
| 6936 | 6936 | ** |
| 6937 | ** When an unlock-notify callback is registered, the application provides a | |
| 6937 | ** When an unlock-notify callback is registered, the application provides a | |
| 6938 | 6938 | ** single void* pointer that is passed to the callback when it is invoked. |
| 6939 | 6939 | ** However, the signature of the callback function allows SQLite to pass |
| 6940 | 6940 | ** it an array of void* context pointers. The first argument passed to |
| r31374 | r31375 | |
| 6947 | 6947 | ** same callback function, then instead of invoking the callback function |
| 6948 | 6948 | ** multiple times, it is invoked once with the set of void* context pointers |
| 6949 | 6949 | ** 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 | |
| 6951 | 6951 | ** related to the set of unblocked database connections. |
| 6952 | 6952 | ** |
| 6953 | 6953 | ** <b>Deadlock Detection</b> |
| 6954 | 6954 | ** |
| 6955 | ** Assuming that after registering for an unlock-notify callback a | |
| 6955 | ** Assuming that after registering for an unlock-notify callback a | |
| 6956 | 6956 | ** database waits for the callback to be issued before taking any further |
| 6957 | 6957 | ** action (a reasonable assumption), then using this API may cause the |
| 6958 | 6958 | ** application to deadlock. For example, if connection X is waiting for |
| r31374 | r31375 | |
| 6975 | 6975 | ** |
| 6976 | 6976 | ** <b>The "DROP TABLE" Exception</b> |
| 6977 | 6977 | ** |
| 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 | |
| 6979 | 6979 | ** always appropriate to call sqlite3_unlock_notify(). There is however, |
| 6980 | 6980 | ** one exception. When executing a "DROP TABLE" or "DROP INDEX" statement, |
| 6981 | 6981 | ** SQLite checks if there are any currently executing SELECT statements |
| r31374 | r31375 | |
| 6988 | 6988 | ** One way around this problem is to check the extended error code returned |
| 6989 | 6989 | ** by an sqlite3_step() call. ^(If there is a blocking connection, then the |
| 6990 | 6990 | ** 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 | |
| 6992 | 6992 | ** SQLITE_LOCKED.)^ |
| 6993 | 6993 | */ |
| 6994 | 6994 | SQLITE_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 */ | |
| 6998 | 6998 | ); |
| 6999 | 6999 | |
| 7000 | 7000 | |
| r31374 | r31375 | |
| 7053 | 7053 | ** ^The [sqlite3_wal_hook()] function is used to register a callback that |
| 7054 | 7054 | ** will be invoked each time a database connection commits data to a |
| 7055 | 7055 | ** [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]). | |
| 7057 | 7057 | ** |
| 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 | |
| 7060 | 7060 | ** may read, write or [checkpoint] the database as required. |
| 7061 | 7061 | ** |
| 7062 | 7062 | ** ^The first parameter passed to the callback function when it is invoked |
| r31374 | r31375 | |
| 7075 | 7075 | ** that does not correspond to any valid SQLite error code, the results |
| 7076 | 7076 | ** are undefined. |
| 7077 | 7077 | ** |
| 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 | |
| 7079 | 7079 | ** registered at one time. ^Calling [sqlite3_wal_hook()] replaces any |
| 7080 | 7080 | ** previously registered write-ahead log callback. ^Note that the |
| 7081 | 7081 | ** [sqlite3_wal_autocheckpoint()] interface and the |
| r31374 | r31375 | |
| 7083 | 7083 | ** those overwrite any prior [sqlite3_wal_hook()] settings. |
| 7084 | 7084 | */ |
| 7085 | 7085 | SQLITE_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* | |
| 7089 | 7089 | ); |
| 7090 | 7090 | |
| 7091 | 7091 | /* |
| r31374 | r31375 | |
| 7095 | 7095 | ** [sqlite3_wal_hook()] that causes any database on [database connection] D |
| 7096 | 7096 | ** to automatically [checkpoint] |
| 7097 | 7097 | ** 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 | |
| 7099 | 7099 | ** a negative value as the nFrame parameter disables automatic |
| 7100 | 7100 | ** checkpoints entirely. |
| 7101 | 7101 | ** |
| r31374 | r31375 | |
| 7136 | 7136 | /* |
| 7137 | 7137 | ** CAPI3REF: Checkpoint a database |
| 7138 | 7138 | ** |
| 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 | |
| 7141 | 7141 | ** eMode parameter: |
| 7142 | 7142 | ** |
| 7143 | 7143 | ** <dl> |
| 7144 | 7144 | ** <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 | |
| 7146 | 7146 | ** 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 | |
| 7148 | 7148 | ** sqlite3_wal_checkpoint(). The busy-handler callback is never invoked. |
| 7149 | 7149 | ** |
| 7150 | 7150 | ** <dt>SQLITE_CHECKPOINT_FULL<dd> |
| r31374 | r31375 | |
| 7155 | 7155 | ** but not database readers. |
| 7156 | 7156 | ** |
| 7157 | 7157 | ** <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 | |
| 7159 | 7159 | ** 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 | |
| 7162 | 7162 | ** from the beginning. This call blocks database writers while it is running, |
| 7163 | 7163 | ** but not database readers. |
| 7164 | 7164 | ** </dl> |
| r31374 | r31375 | |
| 7172 | 7172 | ** before returning to communicate this to the caller. |
| 7173 | 7173 | ** |
| 7174 | 7174 | ** 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 | |
| 7177 | 7177 | ** busy-handler configured, it will not be invoked in this case. |
| 7178 | 7178 | ** |
| 7179 | ** The SQLITE_CHECKPOINT_FULL and RESTART modes also obtain the exclusive | |
| 7179 | ** The SQLITE_CHECKPOINT_FULL and RESTART modes also obtain the exclusive | |
| 7180 | 7180 | ** "writer" lock on the database file. If the writer lock cannot be obtained |
| 7181 | 7181 | ** immediately, and a busy-handler is configured, it is invoked and the writer |
| 7182 | 7182 | ** lock retried until either the busy-handler returns 0 or the lock is |
| 7183 | 7183 | ** successfully obtained. The busy-handler is also invoked while waiting for |
| 7184 | 7184 | ** database readers as described above. If the busy-handler returns 0 before |
| 7185 | 7185 | ** 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 | |
| 7188 | 7188 | ** without blocking any further. SQLITE_BUSY is returned in this case. |
| 7189 | 7189 | ** |
| 7190 | 7190 | ** If parameter zDb is NULL or points to a zero length string, then the |
| 7191 | 7191 | ** 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 | |
| 7199 | 7199 | ** databases, SQLITE_OK is returned. |
| 7200 | 7200 | ** |
| 7201 | 7201 | ** If database zDb is the name of an attached database that is not in WAL |
| r31374 | r31375 | |
| 7204 | 7204 | ** attached database, SQLITE_ERROR is returned to the caller. |
| 7205 | 7205 | */ |
| 7206 | 7206 | SQLITE_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 */ | |
| 7212 | 7212 | ); |
| 7213 | 7213 | |
| 7214 | 7214 | /* |
| r31374 | r31375 | |
| 7261 | 7261 | ** If X is non-zero, then the virtual table implementation guarantees |
| 7262 | 7262 | ** that if [xUpdate] returns [SQLITE_CONSTRAINT], it will do so before |
| 7263 | 7263 | ** 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 | |
| 7265 | 7265 | ** 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. | |
| 7267 | 7267 | ** If the ON CONFLICT mode is REPLACE and the [xUpdate] method returns |
| 7268 | 7268 | ** [SQLITE_CONSTRAINT], SQLite handles this as if the ON CONFLICT mode |
| 7269 | 7269 | ** had been ABORT. |
| 7270 | 7270 | ** |
| 7271 | 7271 | ** 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 | |
| 7275 | 7275 | ** silently replace the appropriate rows within the xUpdate callback and |
| 7276 | 7276 | ** 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 | |
| 7278 | 7278 | ** constraint handling. |
| 7279 | 7279 | ** </dl> |
| 7280 | 7280 | */ |
| r31374 | r31375 | |
| 7354 | 7354 | ** SELECT ... FROM <rtree> WHERE <rtree col> MATCH $zGeom(... params ...) |
| 7355 | 7355 | */ |
| 7356 | 7356 | SQLITE_API int sqlite3_rtree_geometry_callback( |
| 7357 | sqlite3 *db, | |
| 7358 | const char *zGeom, | |
| 7357 | sqlite3 *db, | |
| 7358 | const char *zGeom, | |
| 7359 | 7359 | #ifdef SQLITE_RTREE_INT_ONLY |
| 7360 | ||
| 7360 | int (*xGeom)(sqlite3_rtree_geometry*, int n, sqlite3_int64 *a, int *pRes), | |
| 7361 | 7361 | #else |
| 7362 | ||
| 7362 | int (*xGeom)(sqlite3_rtree_geometry*, int n, double *a, int *pRes), | |
| 7363 | 7363 | #endif |
| 7364 | ||
| 7364 | void *pContext | |
| 7365 | 7365 | ); |
| 7366 | 7366 | |
| 7367 | 7367 | |
| r31374 | r31375 | |
| 7370 | 7370 | ** argument to callbacks registered using rtree_geometry_callback(). |
| 7371 | 7371 | */ |
| 7372 | 7372 | struct 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 */ | |
| 7378 | 7378 | }; |
| 7379 | 7379 | |
| 7380 | 7380 | |
| r31374 | r31375 | |
| 7383 | 7383 | #endif |
| 7384 | 7384 | |
| 7385 | 7385 | #endif /* ifndef _SQLITE3RTREE_H_ */ |
| 7386 |
| r31374 | r31375 | |
|---|---|---|
| 12 | 12 | ** This header file defines the SQLite interface for use by |
| 13 | 13 | ** shared libraries that want to be imported as extensions into |
| 14 | 14 | ** 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 | |
| 16 | 16 | ** sqlite3.h. |
| 17 | 17 | */ |
| 18 | 18 | #ifndef _SQLITE3EXT_H_ |
| r31374 | r31375 | |
| 32 | 32 | ** libraries! |
| 33 | 33 | */ |
| 34 | 34 | struct 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*); | |
| 253 | 253 | }; |
| 254 | 254 | |
| 255 | 255 | /* |
| r31374 | r31375 | |
| 470 | 470 | #endif /* SQLITE_CORE */ |
| 471 | 471 | |
| 472 | 472 | #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 */ | |
| 475 | 475 | # define SQLITE_EXTENSION_INIT1 const sqlite3_api_routines *sqlite3_api=0; |
| 476 | 476 | # define SQLITE_EXTENSION_INIT2(v) sqlite3_api=v; |
| 477 | 477 | # define SQLITE_EXTENSION_INIT3 \ |
| 478 | ||
| 478 | extern const sqlite3_api_routines *sqlite3_api; | |
| 479 | 479 | #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 */ | |
| 482 | 482 | # define SQLITE_EXTENSION_INIT1 /*no-op*/ |
| 483 | 483 | # define SQLITE_EXTENSION_INIT2(v) (void)v; /* unused parameter */ |
| 484 | 484 | # define SQLITE_EXTENSION_INIT3 /*no-op*/ |
| r31374 | r31375 | |
|---|---|---|
| 56 | 56 | }; |
| 57 | 57 | |
| 58 | 58 | #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 | |
| 59 | #define CD_FLAG_GDROMLE 0x00000002 // legacy GD-ROM, with little-endian CDDA data | |
| 60 | 60 | |
| 61 | 61 | /*************************************************************************** |
| 62 | 62 | TYPE DEFINITIONS |
| r31374 | r31375 | |
|---|---|---|
| 31 | 31 | |
| 32 | 32 | // This structure contains information about HTTP request. |
| 33 | 33 | struct 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 | |
| 38 | 38 | |
| 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 | |
| 43 | 43 | |
| 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]; | |
| 49 | 49 | |
| 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 | |
| 52 | 52 | |
| 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() | |
| 59 | 59 | }; |
| 60 | 60 | |
| 61 | 61 | struct mg_server; // Opaque structure describing server instance |
| 62 | 62 | enum mg_result { MG_FALSE, MG_TRUE, MG_MORE }; |
| 63 | 63 | enum 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 | |
| 73 | 73 | }; |
| 74 | 74 | typedef int (*mg_handler_t)(struct mg_connection *, enum mg_event); |
| 75 | 75 | |
| 76 | 76 | // Websocket opcodes, from http://tools.ietf.org/html/rfc6455 |
| 77 | 77 | enum { |
| 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 | |
| 84 | 84 | }; |
| 85 | 85 | |
| 86 | 86 | // Server management functions |
| r31374 | r31375 | |
| 107 | 107 | size_t mg_printf(struct mg_connection *conn, const char *fmt, ...); |
| 108 | 108 | |
| 109 | 109 | size_t mg_websocket_write(struct mg_connection *, int opcode, |
| 110 | ||
| 110 | const char *data, size_t data_len); | |
| 111 | 111 | size_t mg_websocket_printf(struct mg_connection* conn, int opcode, |
| 112 | const char *fmt, ...); | |
| 113 | ||
| 112 | const char *fmt, ...); | |
| 113 | ||
| 114 | 114 | void mg_send_file(struct mg_connection *, const char *path); |
| 115 | 115 | |
| 116 | 116 | const char *mg_get_header(const struct mg_connection *, const char *name); |
| 117 | 117 | const char *mg_get_mime_type(const char *name, const char *default_mime_type); |
| 118 | 118 | int mg_get_var(const struct mg_connection *conn, const char *var_name, |
| 119 | ||
| 119 | char *buf, size_t buf_len); | |
| 120 | 120 | int mg_parse_header(const char *hdr, const char *var_name, char *buf, size_t); |
| 121 | 121 | int 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); | |
| 125 | 125 | |
| 126 | 126 | // Utility functions |
| 127 | 127 | void *mg_start_thread(void *(*func)(void *), void *param); |
| r31374 | r31375 | |
| 132 | 132 | |
| 133 | 133 | // Templates support |
| 134 | 134 | struct mg_expansion { |
| 135 | const char *keyword; | |
| 136 | void (*handler)(struct mg_connection *); | |
| 135 | const char *keyword; | |
| 136 | void (*handler)(struct mg_connection *); | |
| 137 | 137 | }; |
| 138 | 138 | void mg_template(struct mg_connection *, const char *text, |
| 139 | ||
| 139 | struct mg_expansion *expansions); | |
| 140 | 140 | |
| 141 | 141 | |
| 142 | 142 | #ifdef __cplusplus |
| r31374 | r31375 | |
|---|---|---|
| 29 | 29 | /* how much to allocate before next GC step */ |
| 30 | 30 | #if !defined(GCSTEPSIZE) |
| 31 | 31 | /* ~100 small strings */ |
| 32 | #define GCSTEPSIZE | |
| 32 | #define GCSTEPSIZE (cast_int(100 * sizeof(TString))) | |
| 33 | 33 | #endif |
| 34 | 34 | |
| 35 | 35 | |
| 36 | 36 | /* |
| 37 | 37 | ** Possible states of the Garbage Collector |
| 38 | 38 | */ |
| 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 | |
| 45 | 45 | |
| 46 | 46 | |
| 47 | 47 | #define issweepphase(g) \ |
| 48 | 48 | (GCSsweepstring <= (g)->gcstate && (g)->gcstate <= GCSsweep) |
| 49 | 49 | |
| 50 | #define isgenerational(g) | |
| 50 | #define isgenerational(g) ((g)->gckind == KGC_GEN) | |
| 51 | 51 | |
| 52 | 52 | /* |
| 53 | 53 | ** macros to tell when main invariant (white objects cannot point to black |
| r31374 | r31375 | |
| 58 | 58 | ** invariant must be kept all times. |
| 59 | 59 | */ |
| 60 | 60 | |
| 61 | #define keepinvariant(g) | |
| 61 | #define keepinvariant(g) (isgenerational(g) || g->gcstate <= GCSatomic) | |
| 62 | 62 | |
| 63 | 63 | |
| 64 | 64 | /* |
| r31374 | r31375 | |
| 66 | 66 | ** 'propagate', so 'keepinvariant' is always true. |
| 67 | 67 | */ |
| 68 | 68 | #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) | |
| 71 | 71 | |
| 72 | 72 | |
| 73 | 73 | /* |
| 74 | 74 | ** some useful bit tricks |
| 75 | 75 | */ |
| 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)) | |
| 84 | 84 | |
| 85 | 85 | |
| 86 | 86 | /* 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) */ | |
| 94 | 94 | /* bit 7 is currently used by tests (luaL_checkmemory) */ |
| 95 | 95 | |
| 96 | #define WHITEBITS | |
| 96 | #define WHITEBITS bit2mask(WHITE0BIT, WHITE1BIT) | |
| 97 | 97 | |
| 98 | 98 | |
| 99 | 99 | #define iswhite(x) testbits((x)->gch.marked, WHITEBITS) |
| r31374 | r31375 | |
| 101 | 101 | #define isgray(x) /* neither white nor black */ \ |
| 102 | 102 | (!testbits((x)->gch.marked, WHITEBITS | bitmask(BLACKBIT))) |
| 103 | 103 | |
| 104 | #define isold(x) | |
| 104 | #define isold(x) testbit((x)->gch.marked, OLDBIT) | |
| 105 | 105 | |
| 106 | 106 | /* MOVE OLD rule: whenever an object is moved to the beginning of |
| 107 | 107 | a GC list, its old bit must be cleared */ |
| 108 | #define resetoldbit(o) | |
| 108 | #define resetoldbit(o) resetbit((o)->gch.marked, OLDBIT) | |
| 109 | 109 | |
| 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) | |
| 113 | 113 | |
| 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) | |
| 116 | 116 | |
| 117 | #define valiswhite(x) | |
| 117 | #define valiswhite(x) (iscollectable(x) && iswhite(gcvalue(x))) | |
| 118 | 118 | |
| 119 | #define luaC_white(g) | |
| 119 | #define luaC_white(g) cast(lu_byte, (g)->currentwhite & WHITEBITS) | |
| 120 | 120 | |
| 121 | 121 | |
| 122 | 122 | #define luaC_condGC(L,c) \ |
| 123 | 123 | {if (G(L)->GCdebt > 0) {c;}; condchangemem(L);} |
| 124 | #define luaC_checkGC(L) | |
| 124 | #define luaC_checkGC(L) luaC_condGC(L, luaC_step(L);) | |
| 125 | 125 | |
| 126 | 126 | |
| 127 | 127 | #define luaC_barrier(L,p,v) { if (valiswhite(v) && isblack(obj2gco(p))) \ |
| r31374 | r31375 | |
| 135 | 135 | luaC_barrier_(L,obj2gco(p),obj2gco(o)); } |
| 136 | 136 | |
| 137 | 137 | #define luaC_objbarrierback(L,p,o) \ |
| 138 | ||
| 138 | { if (iswhite(obj2gco(o)) && isblack(obj2gco(p))) luaC_barrierback_(L,p); } | |
| 139 | 139 | |
| 140 | 140 | #define luaC_barrierproto(L,p,c) \ |
| 141 | ||
| 141 | { if (isblack(obj2gco(p))) luaC_barrierproto_(L,p,c); } | |
| 142 | 142 | |
| 143 | 143 | LUAI_FUNC void luaC_freeallobjects (lua_State *L); |
| 144 | 144 | LUAI_FUNC void luaC_step (lua_State *L); |
| r31374 | r31375 | |
| 146 | 146 | LUAI_FUNC void luaC_runtilstate (lua_State *L, int statesmask); |
| 147 | 147 | LUAI_FUNC void luaC_fullgc (lua_State *L, int isemergency); |
| 148 | 148 | LUAI_FUNC GCObject *luaC_newobj (lua_State *L, int tt, size_t sz, |
| 149 | ||
| 149 | GCObject **list, int offset); | |
| 150 | 150 | LUAI_FUNC void luaC_barrier_ (lua_State *L, GCObject *o, GCObject *v); |
| 151 | 151 | LUAI_FUNC void luaC_barrierback_ (lua_State *L, GCObject *o); |
| 152 | 152 | LUAI_FUNC void luaC_barrierproto_ (lua_State *L, Proto *p, Closure *c); |
| r31374 | r31375 | |
|---|---|---|
| 11 | 11 | #include "lobject.h" |
| 12 | 12 | |
| 13 | 13 | |
| 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))) | |
| 16 | 16 | |
| 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))) | |
| 19 | 19 | |
| 20 | 20 | |
| 21 | 21 | LUAI_FUNC Proto *luaF_newproto (lua_State *L); |
| r31374 | r31375 | |
| 27 | 27 | LUAI_FUNC void luaF_freeproto (lua_State *L, Proto *f); |
| 28 | 28 | LUAI_FUNC void luaF_freeupval (lua_State *L, UpVal *uv); |
| 29 | 29 | LUAI_FUNC const char *luaF_getlocalname (const Proto *func, int local_number, |
| 30 | ||
| 30 | int pc); | |
| 31 | 31 | |
| 32 | 32 | |
| 33 | 33 | #endif |
| r31374 | r31375 | |
|---|---|---|
| 14 | 14 | |
| 15 | 15 | LUAMOD_API int (luaopen_base) (lua_State *L); |
| 16 | 16 | |
| 17 | #define LUA_COLIBNAME | |
| 17 | #define LUA_COLIBNAME "coroutine" | |
| 18 | 18 | LUAMOD_API int (luaopen_coroutine) (lua_State *L); |
| 19 | 19 | |
| 20 | #define LUA_TABLIBNAME | |
| 20 | #define LUA_TABLIBNAME "table" | |
| 21 | 21 | LUAMOD_API int (luaopen_table) (lua_State *L); |
| 22 | 22 | |
| 23 | #define LUA_IOLIBNAME | |
| 23 | #define LUA_IOLIBNAME "io" | |
| 24 | 24 | LUAMOD_API int (luaopen_io) (lua_State *L); |
| 25 | 25 | |
| 26 | #define LUA_OSLIBNAME | |
| 26 | #define LUA_OSLIBNAME "os" | |
| 27 | 27 | LUAMOD_API int (luaopen_os) (lua_State *L); |
| 28 | 28 | |
| 29 | #define LUA_STRLIBNAME | |
| 29 | #define LUA_STRLIBNAME "string" | |
| 30 | 30 | LUAMOD_API int (luaopen_string) (lua_State *L); |
| 31 | 31 | |
| 32 | #define LUA_BITLIBNAME | |
| 32 | #define LUA_BITLIBNAME "bit32" | |
| 33 | 33 | LUAMOD_API int (luaopen_bit32) (lua_State *L); |
| 34 | 34 | |
| 35 | #define LUA_MATHLIBNAME | |
| 35 | #define LUA_MATHLIBNAME "math" | |
| 36 | 36 | LUAMOD_API int (luaopen_math) (lua_State *L); |
| 37 | 37 | |
| 38 | #define LUA_DBLIBNAME | |
| 38 | #define LUA_DBLIBNAME "debug" | |
| 39 | 39 | LUAMOD_API int (luaopen_debug) (lua_State *L); |
| 40 | 40 | |
| 41 | #define LUA_LOADLIBNAME | |
| 41 | #define LUA_LOADLIBNAME "package" | |
| 42 | 42 | LUAMOD_API int (luaopen_package) (lua_State *L); |
| 43 | 43 | |
| 44 | 44 | |
| r31374 | r31375 | |
| 48 | 48 | |
| 49 | 49 | |
| 50 | 50 | #if !defined(lua_assert) |
| 51 | #define lua_assert(x) | |
| 51 | #define lua_assert(x) ((void)0) | |
| 52 | 52 | #endif |
| 53 | 53 | |
| 54 | 54 |
| r31374 | r31375 | |
|---|---|---|
| 17 | 17 | */ |
| 18 | 18 | |
| 19 | 19 | typedef 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 */ | |
| 34 | 34 | } expkind; |
| 35 | 35 | |
| 36 | 36 | |
| 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) | |
| 39 | 39 | |
| 40 | 40 | typedef 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' */ | |
| 53 | 53 | } expdesc; |
| 54 | 54 | |
| 55 | 55 | |
| 56 | 56 | /* description of active local variable */ |
| 57 | 57 | typedef struct Vardesc { |
| 58 | ||
| 58 | short idx; /* variable index in stack */ | |
| 59 | 59 | } Vardesc; |
| 60 | 60 | |
| 61 | 61 | |
| 62 | 62 | /* description of pending goto statements and label statements */ |
| 63 | 63 | typedef 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 */ | |
| 68 | 68 | } Labeldesc; |
| 69 | 69 | |
| 70 | 70 | |
| 71 | 71 | /* list of labels or gotos */ |
| 72 | 72 | typedef 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 */ | |
| 76 | 76 | } Labellist; |
| 77 | 77 | |
| 78 | 78 | |
| 79 | 79 | /* dynamic structures used by the parser */ |
| 80 | 80 | typedef 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 */ | |
| 88 | 88 | } Dyndata; |
| 89 | 89 | |
| 90 | 90 | |
| r31374 | r31375 | |
| 94 | 94 | |
| 95 | 95 | /* state needed to generate code for a given function */ |
| 96 | 96 | typedef 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 */ | |
| 112 | 112 | } FuncState; |
| 113 | 113 | |
| 114 | 114 | |
| 115 | 115 | LUAI_FUNC Closure *luaY_parser (lua_State *L, ZIO *z, Mbuffer *buff, |
| 116 | ||
| 116 | Dyndata *dyd, const char *name, int firstchar); | |
| 117 | 117 | |
| 118 | 118 | |
| 119 | 119 | #endif |
| r31374 | r31375 | |
|---|---|---|
| 27 | 27 | typedef unsigned char lu_byte; |
| 28 | 28 | |
| 29 | 29 | |
| 30 | #define MAX_SIZET | |
| 30 | #define MAX_SIZET ((size_t)(~(size_t)0)-2) | |
| 31 | 31 | |
| 32 | #define MAX_LUMEM | |
| 32 | #define MAX_LUMEM ((lu_mem)(~(lu_mem)0)-2) | |
| 33 | 33 | |
| 34 | #define MAX_LMEM | |
| 34 | #define MAX_LMEM ((l_mem) ((MAX_LUMEM >> 1) - 2)) | |
| 35 | 35 | |
| 36 | 36 | |
| 37 | 37 | #define MAX_INT (INT_MAX-2) /* maximum value of an int (-2 for safety) */ |
| r31374 | r31375 | |
| 47 | 47 | |
| 48 | 48 | /* type to ensure maximum alignment */ |
| 49 | 49 | #if !defined(LUAI_USER_ALIGNMENT_T) |
| 50 | #define LUAI_USER_ALIGNMENT_T | |
| 50 | #define LUAI_USER_ALIGNMENT_T union { double u; void *s; long l; } | |
| 51 | 51 | #endif |
| 52 | 52 | |
| 53 | 53 | typedef LUAI_USER_ALIGNMENT_T L_Umaxalign; |
| r31374 | r31375 | |
| 59 | 59 | |
| 60 | 60 | /* internal assertions for in-house debugging */ |
| 61 | 61 | #if defined(lua_assert) |
| 62 | #define check_exp(c,e) | |
| 62 | #define check_exp(c,e) (lua_assert(c), (e)) | |
| 63 | 63 | /* to avoid problems with conditions too long */ |
| 64 | #define lua_longassert(c) | |
| 64 | #define lua_longassert(c) { if (!(c)) lua_assert(0); } | |
| 65 | 65 | #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) | |
| 69 | 69 | #endif |
| 70 | 70 | |
| 71 | 71 | /* |
| r31374 | r31375 | |
| 75 | 75 | |
| 76 | 76 | #if defined(LUA_USE_APICHECK) |
| 77 | 77 | #include <assert.h> |
| 78 | #define luai_apicheck(L,e) | |
| 78 | #define luai_apicheck(L,e) assert(e) | |
| 79 | 79 | #else |
| 80 | #define luai_apicheck(L,e) | |
| 80 | #define luai_apicheck(L,e) lua_assert(e) | |
| 81 | 81 | #endif |
| 82 | 82 | |
| 83 | 83 | #endif |
| 84 | 84 | |
| 85 | #define api_check(l,e,msg) | |
| 85 | #define api_check(l,e,msg) luai_apicheck(l,(e) && msg) | |
| 86 | 86 | |
| 87 | 87 | |
| 88 | 88 | #if !defined(UNUSED) |
| 89 | #define UNUSED(x) | |
| 89 | #define UNUSED(x) ((void)(x)) /* to avoid warnings */ | |
| 90 | 90 | #endif |
| 91 | 91 | |
| 92 | 92 | |
| 93 | #define cast(t, exp) | |
| 93 | #define cast(t, exp) ((t)(exp)) | |
| 94 | 94 | |
| 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)) | |
| 99 | 99 | |
| 100 | 100 | |
| 101 | 101 | /* |
| 102 | 102 | ** non-return type |
| 103 | 103 | */ |
| 104 | 104 | #if defined(__GNUC__) |
| 105 | #define l_noret | |
| 105 | #define l_noret void __attribute__((noreturn)) | |
| 106 | 106 | #elif defined(_MSC_VER) |
| 107 | #define l_noret | |
| 107 | #define l_noret void __declspec(noreturn) | |
| 108 | 108 | #else |
| 109 | #define l_noret | |
| 109 | #define l_noret void | |
| 110 | 110 | #endif |
| 111 | 111 | |
| 112 | 112 | |
| r31374 | r31375 | |
| 116 | 116 | ** in a program. (Value must fit in an unsigned short int.) |
| 117 | 117 | */ |
| 118 | 118 | #if !defined(LUAI_MAXCCALLS) |
| 119 | #define LUAI_MAXCCALLS | |
| 119 | #define LUAI_MAXCCALLS 200 | |
| 120 | 120 | #endif |
| 121 | 121 | |
| 122 | 122 | /* |
| 123 | 123 | ** maximum number of upvalues in a closure (both C and Lua). (Value |
| 124 | 124 | ** must fit in an unsigned char.) |
| 125 | 125 | */ |
| 126 | #define MAXUPVAL | |
| 126 | #define MAXUPVAL UCHAR_MAX | |
| 127 | 127 | |
| 128 | 128 | |
| 129 | 129 | /* |
| r31374 | r31375 | |
| 135 | 135 | |
| 136 | 136 | |
| 137 | 137 | /* maximum stack for a Lua function */ |
| 138 | #define MAXSTACK | |
| 138 | #define MAXSTACK 250 | |
| 139 | 139 | |
| 140 | 140 | |
| 141 | 141 | |
| 142 | 142 | /* minimum size for the string table (must be power of 2) */ |
| 143 | 143 | #if !defined(MINSTRTABSIZE) |
| 144 | #define MINSTRTABSIZE | |
| 144 | #define MINSTRTABSIZE 32 | |
| 145 | 145 | #endif |
| 146 | 146 | |
| 147 | 147 | |
| 148 | 148 | /* minimum size for string buffer */ |
| 149 | 149 | #if !defined(LUA_MINBUFFER) |
| 150 | #define LUA_MINBUFFER | |
| 150 | #define LUA_MINBUFFER 32 | |
| 151 | 151 | #endif |
| 152 | 152 | |
| 153 | 153 | |
| r31374 | r31375 | |
| 167 | 167 | ** created/deleted/resumed/yielded. |
| 168 | 168 | */ |
| 169 | 169 | #if !defined(luai_userstateopen) |
| 170 | #define luai_userstateopen(L) | |
| 170 | #define luai_userstateopen(L) ((void)L) | |
| 171 | 171 | #endif |
| 172 | 172 | |
| 173 | 173 | #if !defined(luai_userstateclose) |
| 174 | #define luai_userstateclose(L) | |
| 174 | #define luai_userstateclose(L) ((void)L) | |
| 175 | 175 | #endif |
| 176 | 176 | |
| 177 | 177 | #if !defined(luai_userstatethread) |
| 178 | #define luai_userstatethread(L,L1) | |
| 178 | #define luai_userstatethread(L,L1) ((void)L) | |
| 179 | 179 | #endif |
| 180 | 180 | |
| 181 | 181 | #if !defined(luai_userstatefree) |
| 182 | #define luai_userstatefree(L,L1) | |
| 182 | #define luai_userstatefree(L,L1) ((void)L) | |
| 183 | 183 | #endif |
| 184 | 184 | |
| 185 | 185 | #if !defined(luai_userstateresume) |
| r31374 | r31375 | |
| 200 | 200 | ** both small and large values (outside the range of integers). |
| 201 | 201 | */ |
| 202 | 202 | |
| 203 | #if defined(MS_ASMTRICK) || defined(LUA_MSASMTRICK) | |
| 203 | #if defined(MS_ASMTRICK) || defined(LUA_MSASMTRICK) /* { */ | |
| 204 | 204 | /* trick with Microsoft assembler for X86 */ |
| 205 | 205 | |
| 206 | 206 | #define lua_number2int(i,n) __asm {__asm fld n __asm fistp i} |
| 207 | #define lua_number2integer(i,n) | |
| 207 | #define lua_number2integer(i,n) lua_number2int(i, n) | |
| 208 | 208 | #define lua_number2unsigned(i,n) \ |
| 209 | ||
| 209 | {__int64 l; __asm {__asm fld n __asm fistp l} i = (unsigned int)l;} | |
| 210 | 210 | |
| 211 | 211 | |
| 212 | #elif defined(LUA_IEEE754TRICK) | |
| 212 | #elif defined(LUA_IEEE754TRICK) /* }{ */ | |
| 213 | 213 | /* the next trick should work on any machine using IEEE754 with |
| 214 | 214 | a 32-bit int type */ |
| 215 | 215 | |
| 216 | 216 | union luai_Cast { double l_d; LUA_INT32 l_p[2]; }; |
| 217 | 217 | |
| 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) | |
| 222 | 222 | #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 /* } */ | |
| 226 | 226 | |
| 227 | 227 | #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]; } | |
| 231 | 231 | |
| 232 | 232 | #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 */ | |
| 235 | 235 | |
| 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) | |
| 238 | 238 | |
| 239 | 239 | /* the trick can be expanded to lua_Integer when it is a 32-bit value */ |
| 240 | 240 | #if defined(LUA_IEEELL) |
| 241 | #define lua_number2integer(i,n) | |
| 241 | #define lua_number2integer(i,n) lua_number2int32(i, n, lua_Integer) | |
| 242 | 242 | #endif |
| 243 | 243 | |
| 244 | #endif | |
| 244 | #endif /* } */ | |
| 245 | 245 | |
| 246 | 246 | |
| 247 | 247 | /* the following definitions always work, but may be slow */ |
| 248 | 248 | |
| 249 | 249 | #if !defined(lua_number2int) |
| 250 | #define lua_number2int(i,n) | |
| 250 | #define lua_number2int(i,n) ((i)=(int)(n)) | |
| 251 | 251 | #endif |
| 252 | 252 | |
| 253 | 253 | #if !defined(lua_number2integer) |
| 254 | #define lua_number2integer(i,n) | |
| 254 | #define lua_number2integer(i,n) ((i)=(lua_Integer)(n)) | |
| 255 | 255 | #endif |
| 256 | 256 | |
| 257 | #if !defined(lua_number2unsigned) | |
| 257 | #if !defined(lua_number2unsigned) /* { */ | |
| 258 | 258 | /* the following definition assures proper modulo behavior */ |
| 259 | 259 | #if defined(LUA_NUMBER_DOUBLE) || defined(LUA_NUMBER_FLOAT) |
| 260 | 260 | #include <math.h> |
| 261 | #define SUPUNSIGNED | |
| 261 | #define SUPUNSIGNED ((lua_Number)(~(lua_Unsigned)0) + 1) | |
| 262 | 262 | #define lua_number2unsigned(i,n) \ |
| 263 | 263 | ((i)=(lua_Unsigned)((n) - floor((n)/SUPUNSIGNED)*SUPUNSIGNED)) |
| 264 | 264 | #else |
| 265 | #define lua_number2unsigned(i,n) | |
| 265 | #define lua_number2unsigned(i,n) ((i)=(lua_Unsigned)(n)) | |
| 266 | 266 | #endif |
| 267 | #endif | |
| 267 | #endif /* } */ | |
| 268 | 268 | |
| 269 | 269 | |
| 270 | 270 | #if !defined(lua_unsigned2number) |
| 271 | 271 | /* on several machines, coercion from unsigned to double is slow, |
| 272 | 272 | so it may be worth to avoid */ |
| 273 | 273 | #define lua_unsigned2number(u) \ |
| 274 | ||
| 274 | (((u) <= (lua_Unsigned)INT_MAX) ? (lua_Number)(int)(u) : (lua_Number)(u)) | |
| 275 | 275 | #endif |
| 276 | 276 | |
| 277 | 277 | |
| r31374 | r31375 | |
| 282 | 282 | #include <math.h> |
| 283 | 283 | |
| 284 | 284 | #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; } | |
| 287 | 287 | |
| 288 | 288 | #endif |
| 289 | 289 | |
| r31374 | r31375 | |
| 293 | 293 | ** macro to control inclusion of some hard tests on stack reallocation |
| 294 | 294 | */ |
| 295 | 295 | #if !defined(HARDSTACKTESTS) |
| 296 | #define condmovestack(L) | |
| 296 | #define condmovestack(L) ((void)0) | |
| 297 | 297 | #else |
| 298 | 298 | /* realloc stack keeping its size */ |
| 299 | #define condmovestack(L) | |
| 299 | #define condmovestack(L) luaD_reallocstack((L), (L)->stacksize) | |
| 300 | 300 | #endif |
| 301 | 301 | |
| 302 | 302 | #if !defined(HARDMEMTESTS) |
| 303 | #define condchangemem(L) | |
| 303 | #define condchangemem(L) condmovestack(L) | |
| 304 | 304 | #else |
| 305 | 305 | #define condchangemem(L) \ |
| 306 | 306 | ((void)(!(G(L)->gcrunning) || (luaC_fullgc(L, 0), 1))) |
| r31374 | r31375 | |
|---|---|---|
| 16 | 16 | #include "luaconf.h" |
| 17 | 17 | |
| 18 | 18 | |
| 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" | |
| 23 | 23 | |
| 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" | |
| 28 | 28 | |
| 29 | 29 | |
| 30 | 30 | /* mark for precompiled code ('<esc>Lua') */ |
| 31 | #define LUA_SIGNATURE | |
| 31 | #define LUA_SIGNATURE "\033Lua" | |
| 32 | 32 | |
| 33 | 33 | /* option for multiple returns in 'lua_pcall' and 'lua_call' */ |
| 34 | #define LUA_MULTRET | |
| 34 | #define LUA_MULTRET (-1) | |
| 35 | 35 | |
| 36 | 36 | |
| 37 | 37 | /* |
| 38 | 38 | ** pseudo-indices |
| 39 | 39 | */ |
| 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)) | |
| 42 | 42 | |
| 43 | 43 | |
| 44 | 44 | /* 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 | |
| 52 | 52 | |
| 53 | 53 | |
| 54 | 54 | typedef struct lua_State lua_State; |
| r31374 | r31375 | |
| 73 | 73 | /* |
| 74 | 74 | ** basic types |
| 75 | 75 | */ |
| 76 | #define LUA_TNONE | |
| 76 | #define LUA_TNONE (-1) | |
| 77 | 77 | |
| 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 | |
| 87 | 87 | |
| 88 | #define LUA_NUMTAGS | |
| 88 | #define LUA_NUMTAGS 9 | |
| 89 | 89 | |
| 90 | 90 | |
| 91 | 91 | |
| 92 | 92 | /* minimum Lua stack available to a C function */ |
| 93 | #define LUA_MINSTACK | |
| 93 | #define LUA_MINSTACK 20 | |
| 94 | 94 | |
| 95 | 95 | |
| 96 | 96 | /* 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 | |
| 100 | 100 | |
| 101 | 101 | |
| 102 | 102 | /* type of numbers in Lua */ |
| r31374 | r31375 | |
| 172 | 172 | LUA_API const char *(lua_tolstring) (lua_State *L, int idx, size_t *len); |
| 173 | 173 | LUA_API size_t (lua_rawlen) (lua_State *L, int idx); |
| 174 | 174 | LUA_API lua_CFunction (lua_tocfunction) (lua_State *L, int idx); |
| 175 | LUA_API void | |
| 175 | LUA_API void *(lua_touserdata) (lua_State *L, int idx); | |
| 176 | 176 | LUA_API lua_State *(lua_tothread) (lua_State *L, int idx); |
| 177 | 177 | LUA_API const void *(lua_topointer) (lua_State *L, int idx); |
| 178 | 178 | |
| r31374 | r31375 | |
| 181 | 181 | ** Comparison and arithmetic functions |
| 182 | 182 | */ |
| 183 | 183 | |
| 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 | |
| 191 | 191 | |
| 192 | 192 | LUA_API void (lua_arith) (lua_State *L, int op); |
| 193 | 193 | |
| 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 | |
| 197 | 197 | |
| 198 | 198 | LUA_API int (lua_rawequal) (lua_State *L, int idx1, int idx2); |
| 199 | 199 | LUA_API int (lua_compare) (lua_State *L, int idx1, int idx2, int op); |
| r31374 | r31375 | |
| 209 | 209 | LUA_API const char *(lua_pushlstring) (lua_State *L, const char *s, size_t l); |
| 210 | 210 | LUA_API const char *(lua_pushstring) (lua_State *L, const char *s); |
| 211 | 211 | LUA_API const char *(lua_pushvfstring) (lua_State *L, const char *fmt, |
| 212 | ||
| 212 | va_list argp); | |
| 213 | 213 | LUA_API const char *(lua_pushfstring) (lua_State *L, const char *fmt, ...); |
| 214 | 214 | LUA_API void (lua_pushcclosure) (lua_State *L, lua_CFunction fn, int n); |
| 215 | 215 | LUA_API void (lua_pushboolean) (lua_State *L, int b); |
| r31374 | r31375 | |
| 249 | 249 | ** 'load' and 'call' functions (load and run Lua code) |
| 250 | 250 | */ |
| 251 | 251 | LUA_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) | |
| 254 | 254 | |
| 255 | 255 | LUA_API int (lua_getctx) (lua_State *L, int *ctx); |
| 256 | 256 | |
| 257 | 257 | LUA_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) | |
| 260 | 260 | |
| 261 | 261 | LUA_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); | |
| 264 | 264 | |
| 265 | 265 | LUA_API int (lua_dump) (lua_State *L, lua_Writer writer, void *data); |
| 266 | 266 | |
| r31374 | r31375 | |
| 269 | 269 | ** coroutine functions |
| 270 | 270 | */ |
| 271 | 271 | LUA_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) | |
| 274 | 274 | LUA_API int (lua_resume) (lua_State *L, lua_State *from, int narg); |
| 275 | 275 | LUA_API int (lua_status) (lua_State *L); |
| 276 | 276 | |
| r31374 | r31375 | |
| 278 | 278 | ** garbage-collection function and options |
| 279 | 279 | */ |
| 280 | 280 | |
| 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 | |
| 293 | 293 | |
| 294 | 294 | LUA_API int (lua_gc) (lua_State *L, int what, int data); |
| 295 | 295 | |
| r31374 | r31375 | |
| 316 | 316 | ** =============================================================== |
| 317 | 317 | */ |
| 318 | 318 | |
| 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) | |
| 322 | 322 | |
| 323 | #define lua_pop(L,n) | |
| 323 | #define lua_pop(L,n) lua_settop(L, -(n)-1) | |
| 324 | 324 | |
| 325 | #define lua_newtable(L) | |
| 325 | #define lua_newtable(L) lua_createtable(L, 0, 0) | |
| 326 | 326 | |
| 327 | 327 | #define lua_register(L,n,f) (lua_pushcfunction(L, (f)), lua_setglobal(L, (n))) |
| 328 | 328 | |
| 329 | #define lua_pushcfunction(L,f) | |
| 329 | #define lua_pushcfunction(L,f) lua_pushcclosure(L, (f), 0) | |
| 330 | 330 | |
| 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) | |
| 339 | 339 | |
| 340 | #define lua_pushliteral(L, s) | |
| 340 | #define lua_pushliteral(L, s) \ | |
| 341 | 341 | lua_pushlstring(L, "" s, (sizeof(s)/sizeof(char))-1) |
| 342 | 342 | |
| 343 | 343 | #define lua_pushglobaltable(L) \ |
| 344 | 344 | lua_rawgeti(L, LUA_REGISTRYINDEX, LUA_RIDX_GLOBALS) |
| 345 | 345 | |
| 346 | #define lua_tostring(L,i) | |
| 346 | #define lua_tostring(L,i) lua_tolstring(L, (i), NULL) | |
| 347 | 347 | |
| 348 | 348 | |
| 349 | 349 | |
| r31374 | r31375 | |
| 357 | 357 | /* |
| 358 | 358 | ** Event codes |
| 359 | 359 | */ |
| 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 | |
| 364 | 364 | #define LUA_HOOKTAILCALL 4 |
| 365 | 365 | |
| 366 | 366 | |
| 367 | 367 | /* |
| 368 | 368 | ** Event masks |
| 369 | 369 | */ |
| 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) | |
| 374 | 374 | |
| 375 | 375 | typedef struct lua_Debug lua_Debug; /* activation record */ |
| 376 | 376 | |
| r31374 | r31375 | |
| 388 | 388 | |
| 389 | 389 | LUA_API void *(lua_upvalueid) (lua_State *L, int fidx, int n); |
| 390 | 390 | LUA_API void (lua_upvaluejoin) (lua_State *L, int fidx1, int n1, |
| 391 | ||
| 391 | int fidx2, int n2); | |
| 392 | 392 | |
| 393 | 393 | LUA_API int (lua_sethook) (lua_State *L, lua_Hook func, int mask, int count); |
| 394 | 394 | LUA_API lua_Hook (lua_gethook) (lua_State *L); |
| r31374 | r31375 | |
| 397 | 397 | |
| 398 | 398 | |
| 399 | 399 | struct 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 */ | |
| 415 | 415 | }; |
| 416 | 416 | |
| 417 | 417 | /* }====================================================================== */ |
| r31374 | r31375 | |
|---|---|---|
| 19 | 19 | /* |
| 20 | 20 | ** Extra tags for non-values |
| 21 | 21 | */ |
| 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) | |
| 25 | 25 | |
| 26 | 26 | /* |
| 27 | 27 | ** number of all possible tags (including LUA_TNONE but excluding DEADKEY) |
| 28 | 28 | */ |
| 29 | #define LUA_TOTALTAGS | |
| 29 | #define LUA_TOTALTAGS (LUA_TUPVAL+2) | |
| 30 | 30 | |
| 31 | 31 | |
| 32 | 32 | /* |
| r31374 | r31375 | |
| 36 | 36 | ** bit 6: whether value is collectable |
| 37 | 37 | */ |
| 38 | 38 | |
| 39 | #define VARBITS | |
| 39 | #define VARBITS (3 << 4) | |
| 40 | 40 | |
| 41 | 41 | |
| 42 | 42 | /* |
| r31374 | r31375 | |
| 47 | 47 | */ |
| 48 | 48 | |
| 49 | 49 | /* 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 */ | |
| 53 | 53 | |
| 54 | 54 | |
| 55 | 55 | /* 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 */ | |
| 58 | 58 | |
| 59 | 59 | |
| 60 | 60 | /* Bit mark for collectable types */ |
| 61 | #define BIT_ISCOLLECTABLE | |
| 61 | #define BIT_ISCOLLECTABLE (1 << 6) | |
| 62 | 62 | |
| 63 | 63 | /* mark a tag as collectable */ |
| 64 | #define ctb(t) | |
| 64 | #define ctb(t) ((t) | BIT_ISCOLLECTABLE) | |
| 65 | 65 | |
| 66 | 66 | |
| 67 | 67 | /* |
| r31374 | r31375 | |
| 74 | 74 | ** Common Header for all collectable objects (in macro form, to be |
| 75 | 75 | ** included in other objects) |
| 76 | 76 | */ |
| 77 | #define CommonHeader | |
| 77 | #define CommonHeader GCObject *next; lu_byte tt; lu_byte marked | |
| 78 | 78 | |
| 79 | 79 | |
| 80 | 80 | /* |
| 81 | 81 | ** Common header in struct form |
| 82 | 82 | */ |
| 83 | 83 | typedef struct GCheader { |
| 84 | ||
| 84 | CommonHeader; | |
| 85 | 85 | } GCheader; |
| 86 | 86 | |
| 87 | 87 | |
| r31374 | r31375 | |
| 92 | 92 | typedef union Value Value; |
| 93 | 93 | |
| 94 | 94 | |
| 95 | #define numfield | |
| 95 | #define numfield lua_Number n; /* numbers */ | |
| 96 | 96 | |
| 97 | 97 | |
| 98 | 98 | |
| r31374 | r31375 | |
| 101 | 101 | ** an actual value plus a tag with its type. |
| 102 | 102 | */ |
| 103 | 103 | |
| 104 | #define TValuefields | |
| 104 | #define TValuefields Value value_; int tt_ | |
| 105 | 105 | |
| 106 | 106 | typedef struct lua_TValue TValue; |
| 107 | 107 | |
| 108 | 108 | |
| 109 | 109 | /* macro defining a nil value */ |
| 110 | #define NILCONSTANT | |
| 110 | #define NILCONSTANT {NULL}, LUA_TNIL | |
| 111 | 111 | |
| 112 | 112 | |
| 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) | |
| 115 | 115 | |
| 116 | 116 | |
| 117 | 117 | /* raw type tag of a TValue */ |
| 118 | #define rttype(o) | |
| 118 | #define rttype(o) ((o)->tt_) | |
| 119 | 119 | |
| 120 | 120 | /* tag with no variants (bits 0-3) */ |
| 121 | #define novariant(x) | |
| 121 | #define novariant(x) ((x) & 0x0F) | |
| 122 | 122 | |
| 123 | 123 | /* type tag of a TValue (bits 0-3 for tags + variant bits 4-5) */ |
| 124 | #define ttype(o) | |
| 124 | #define ttype(o) (rttype(o) & 0x3F) | |
| 125 | 125 | |
| 126 | 126 | /* type tag of a TValue with no variants (bits 0-3) */ |
| 127 | #define ttypenv(o) | |
| 127 | #define ttypenv(o) (novariant(rttype(o))) | |
| 128 | 128 | |
| 129 | 129 | |
| 130 | 130 | /* 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) | |
| 149 | 149 | |
| 150 | #define ttisequal(o1,o2) | |
| 150 | #define ttisequal(o1,o2) (rttype(o1) == rttype(o2)) | |
| 151 | 151 | |
| 152 | 152 | /* 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) | |
| 167 | 167 | /* a dead value may get the 'gc' field, but cannot access its contents */ |
| 168 | #define deadvalue(o) | |
| 168 | #define deadvalue(o) check_exp(ttisdeadkey(o), cast(void *, val_(o).gc)) | |
| 169 | 169 | |
| 170 | #define l_isfalse(o) | |
| 170 | #define l_isfalse(o) (ttisnil(o) || (ttisboolean(o) && bvalue(o) == 0)) | |
| 171 | 171 | |
| 172 | 172 | |
| 173 | #define iscollectable(o) | |
| 173 | #define iscollectable(o) (rttype(o) & BIT_ISCOLLECTABLE) | |
| 174 | 174 | |
| 175 | 175 | |
| 176 | 176 | /* Macros for internal tests */ |
| 177 | #define righttt(obj) | |
| 177 | #define righttt(obj) (ttype(obj) == gcvalue(obj)->gch.tt) | |
| 178 | 178 | |
| 179 | 179 | #define checkliveness(g,obj) \ |
| 180 | 180 | lua_longassert(!iscollectable(obj) || \ |
| r31374 | r31375 | |
| 182 | 182 | |
| 183 | 183 | |
| 184 | 184 | /* Macros to set values */ |
| 185 | #define settt_(o,t) | |
| 185 | #define settt_(o,t) ((o)->tt_=(t)) | |
| 186 | 186 | |
| 187 | 187 | #define setnvalue(obj,x) \ |
| 188 | ||
| 188 | { TValue *io=(obj); num_(io)=(x); settt_(io, LUA_TNUMBER); } | |
| 189 | 189 | |
| 190 | 190 | #define setnilvalue(obj) settt_(obj, LUA_TNIL) |
| 191 | 191 | |
| 192 | 192 | #define setfvalue(obj,x) \ |
| 193 | ||
| 193 | { TValue *io=(obj); val_(io).f=(x); settt_(io, LUA_TLCF); } | |
| 194 | 194 | |
| 195 | 195 | #define setpvalue(obj,x) \ |
| 196 | ||
| 196 | { TValue *io=(obj); val_(io).p=(x); settt_(io, LUA_TLIGHTUSERDATA); } | |
| 197 | 197 | |
| 198 | 198 | #define setbvalue(obj,x) \ |
| 199 | ||
| 199 | { TValue *io=(obj); val_(io).b=(x); settt_(io, LUA_TBOOLEAN); } | |
| 200 | 200 | |
| 201 | 201 | #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)); } | |
| 204 | 204 | |
| 205 | 205 | #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); } | |
| 210 | 210 | |
| 211 | 211 | #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); } | |
| 215 | 215 | |
| 216 | 216 | #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); } | |
| 220 | 220 | |
| 221 | 221 | #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); } | |
| 225 | 225 | |
| 226 | 226 | #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); } | |
| 230 | 230 | |
| 231 | 231 | #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); } | |
| 235 | 235 | |
| 236 | #define setdeadvalue(obj) | |
| 236 | #define setdeadvalue(obj) settt_(obj, LUA_TDEADKEY) | |
| 237 | 237 | |
| 238 | 238 | |
| 239 | 239 | |
| 240 | 240 | #define setobj(L,obj1,obj2) \ |
| 241 | 241 | { 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); } | |
| 244 | 244 | |
| 245 | 245 | |
| 246 | 246 | /* |
| r31374 | r31375 | |
| 248 | 248 | */ |
| 249 | 249 | |
| 250 | 250 | /* from stack to (same) stack */ |
| 251 | #define setobjs2s | |
| 251 | #define setobjs2s setobj | |
| 252 | 252 | /* 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 | |
| 257 | 257 | /* from table to same table */ |
| 258 | #define setobjt2t | |
| 258 | #define setobjt2t setobj | |
| 259 | 259 | /* to table */ |
| 260 | #define setobj2t | |
| 260 | #define setobj2t setobj | |
| 261 | 261 | /* to new object */ |
| 262 | #define setobj2n setobj | |
| 263 | #define setsvalue2n setsvalue | |
| 262 | #define setobj2n setobj | |
| 263 | #define setsvalue2n setsvalue | |
| 264 | 264 | |
| 265 | 265 | |
| 266 | 266 | /* check whether a number is valid (useful only for NaN trick) */ |
| 267 | #define luai_checknum(L,o,c) | |
| 267 | #define luai_checknum(L,o,c) { /* empty */ } | |
| 268 | 268 | |
| 269 | 269 | |
| 270 | 270 | /* |
| r31374 | r31375 | |
| 282 | 282 | */ |
| 283 | 283 | |
| 284 | 284 | /* allows for external implementation for part of the trick */ |
| 285 | #if !defined(NNMARK) | |
| 285 | #if !defined(NNMARK) /* { */ | |
| 286 | 286 | |
| 287 | 287 | |
| 288 | 288 | #if !defined(LUA_IEEEENDIAN) |
| r31374 | r31375 | |
| 290 | 290 | #endif |
| 291 | 291 | |
| 292 | 292 | |
| 293 | #define NNMARK 0x7FF7A500 | |
| 294 | #define NNMASK 0x7FFFFF00 | |
| 293 | #define NNMARK 0x7FF7A500 | |
| 294 | #define NNMASK 0x7FFFFF00 | |
| 295 | 295 | |
| 296 | 296 | #undef TValuefields |
| 297 | 297 | #undef NILCONSTANT |
| 298 | 298 | |
| 299 | #if (LUA_IEEEENDIAN == 0) | |
| 299 | #if (LUA_IEEEENDIAN == 0) /* { */ | |
| 300 | 300 | |
| 301 | 301 | /* little endian */ |
| 302 | 302 | #define TValuefields \ |
| 303 | 303 | union { struct { Value v__; int tt__; } i; double d__; } u |
| 304 | #define NILCONSTANT | |
| 304 | #define NILCONSTANT {{{NULL}, tag2tt(LUA_TNIL)}} | |
| 305 | 305 | /* 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__) | |
| 309 | 309 | |
| 310 | #else | |
| 310 | #else /* }{ */ | |
| 311 | 311 | |
| 312 | 312 | /* big endian */ |
| 313 | 313 | #define TValuefields \ |
| 314 | 314 | union { struct { int tt__; Value v__; } i; double d__; } u |
| 315 | #define NILCONSTANT | |
| 315 | #define NILCONSTANT {{tag2tt(LUA_TNIL), {NULL}}} | |
| 316 | 316 | /* 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__) | |
| 320 | 320 | |
| 321 | #endif | |
| 321 | #endif /* } */ | |
| 322 | 322 | |
| 323 | #endif | |
| 323 | #endif /* } */ | |
| 324 | 324 | |
| 325 | 325 | |
| 326 | 326 | /* correspondence with standard representation */ |
| 327 | 327 | #undef val_ |
| 328 | #define val_(o) | |
| 328 | #define val_(o) v_(o) | |
| 329 | 329 | #undef num_ |
| 330 | #define num_(o) | |
| 330 | #define num_(o) d_(o) | |
| 331 | 331 | |
| 332 | 332 | |
| 333 | 333 | #undef numfield |
| 334 | #define numfield | |
| 334 | #define numfield /* no such field; numbers are the entire struct */ | |
| 335 | 335 | |
| 336 | 336 | /* basic check to distinguish numbers from non-numbers */ |
| 337 | 337 | #undef ttisnumber |
| 338 | #define ttisnumber(o) | |
| 338 | #define ttisnumber(o) ((tt_(o) & NNMASK) != NNMARK) | |
| 339 | 339 | |
| 340 | #define tag2tt(t) | |
| 340 | #define tag2tt(t) (NNMARK | (t)) | |
| 341 | 341 | |
| 342 | 342 | #undef rttype |
| 343 | #define rttype(o) | |
| 343 | #define rttype(o) (ttisnumber(o) ? LUA_TNUMBER : tt_(o) & 0xff) | |
| 344 | 344 | |
| 345 | 345 | #undef settt_ |
| 346 | #define settt_(o,t) | |
| 346 | #define settt_(o,t) (tt_(o) = tag2tt(t)) | |
| 347 | 347 | |
| 348 | 348 | #undef setnvalue |
| 349 | 349 | #define setnvalue(obj,x) \ |
| r31374 | r31375 | |
| 352 | 352 | #undef setobj |
| 353 | 353 | #define setobj(L,obj1,obj2) \ |
| 354 | 354 | { 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_); } | |
| 357 | 357 | |
| 358 | 358 | |
| 359 | 359 | /* |
| r31374 | r31375 | |
| 362 | 362 | |
| 363 | 363 | #undef checktag |
| 364 | 364 | #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)) | |
| 367 | 367 | |
| 368 | 368 | #undef ttisequal |
| 369 | 369 | #define ttisequal(o1,o2) \ |
| r31374 | r31375 | |
| 371 | 371 | |
| 372 | 372 | |
| 373 | 373 | #undef luai_checknum |
| 374 | #define luai_checknum(L,o,c) | |
| 374 | #define luai_checknum(L,o,c) { if (!ttisnumber(o)) c; } | |
| 375 | 375 | |
| 376 | 376 | #endif |
| 377 | 377 | /* }====================================================== */ |
| r31374 | r31375 | |
| 386 | 386 | |
| 387 | 387 | |
| 388 | 388 | union 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 */ | |
| 394 | 394 | }; |
| 395 | 395 | |
| 396 | 396 | |
| 397 | 397 | struct lua_TValue { |
| 398 | ||
| 398 | TValuefields; | |
| 399 | 399 | }; |
| 400 | 400 | |
| 401 | 401 | |
| r31374 | r31375 | |
| 408 | 408 | ** Header for string value; string bytes follow the end of this structure |
| 409 | 409 | */ |
| 410 | 410 | typedef 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; | |
| 418 | 418 | } TString; |
| 419 | 419 | |
| 420 | 420 | |
| 421 | 421 | /* get the actual string (array of bytes) from a TString */ |
| 422 | #define getstr(ts) | |
| 422 | #define getstr(ts) cast(const char *, (ts) + 1) | |
| 423 | 423 | |
| 424 | 424 | /* get the actual string (array of bytes) from a Lua value */ |
| 425 | 425 | #define svalue(o) getstr(rawtsvalue(o)) |
| r31374 | r31375 | |
| 429 | 429 | ** Header for userdata; memory area follows the end of this structure |
| 430 | 430 | */ |
| 431 | 431 | typedef 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; | |
| 439 | 439 | } Udata; |
| 440 | 440 | |
| 441 | 441 | |
| r31374 | r31375 | |
| 444 | 444 | ** Description of an upvalue for function prototypes |
| 445 | 445 | */ |
| 446 | 446 | typedef 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) */ | |
| 450 | 450 | } Upvaldesc; |
| 451 | 451 | |
| 452 | 452 | |
| r31374 | r31375 | |
| 455 | 455 | ** (used for debug information) |
| 456 | 456 | */ |
| 457 | 457 | typedef 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 */ | |
| 461 | 461 | } LocVar; |
| 462 | 462 | |
| 463 | 463 | |
| r31374 | r31375 | |
| 465 | 465 | ** Function Prototypes |
| 466 | 466 | */ |
| 467 | 467 | typedef 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 */ | |
| 489 | 489 | } Proto; |
| 490 | 490 | |
| 491 | 491 | |
| r31374 | r31375 | |
| 494 | 494 | ** Lua Upvalues |
| 495 | 495 | */ |
| 496 | 496 | typedef 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; | |
| 506 | 506 | } UpVal; |
| 507 | 507 | |
| 508 | 508 | |
| r31374 | r31375 | |
| 514 | 514 | CommonHeader; lu_byte nupvalues; GCObject *gclist |
| 515 | 515 | |
| 516 | 516 | typedef 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 */ | |
| 520 | 520 | } CClosure; |
| 521 | 521 | |
| 522 | 522 | |
| 523 | 523 | typedef 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 */ | |
| 527 | 527 | } LClosure; |
| 528 | 528 | |
| 529 | 529 | |
| 530 | 530 | typedef union Closure { |
| 531 | CClosure c; | |
| 532 | LClosure l; | |
| 531 | CClosure c; | |
| 532 | LClosure l; | |
| 533 | 533 | } Closure; |
| 534 | 534 | |
| 535 | 535 | |
| 536 | #define isLfunction(o) | |
| 536 | #define isLfunction(o) ttisLclosure(o) | |
| 537 | 537 | |
| 538 | #define getproto(o) | |
| 538 | #define getproto(o) (clLvalue(o)->p) | |
| 539 | 539 | |
| 540 | 540 | |
| 541 | 541 | /* |
| r31374 | r31375 | |
| 543 | 543 | */ |
| 544 | 544 | |
| 545 | 545 | typedef 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; | |
| 551 | 551 | } TKey; |
| 552 | 552 | |
| 553 | 553 | |
| 554 | 554 | typedef struct Node { |
| 555 | TValue i_val; | |
| 556 | TKey i_key; | |
| 555 | TValue i_val; | |
| 556 | TKey i_key; | |
| 557 | 557 | } Node; |
| 558 | 558 | |
| 559 | 559 | |
| 560 | 560 | typedef 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 */ | |
| 570 | 570 | } Table; |
| 571 | 571 | |
| 572 | 572 | |
| r31374 | r31375 | |
| 578 | 578 | (check_exp((size&(size-1))==0, (cast(int, (s) & ((size)-1))))) |
| 579 | 579 | |
| 580 | 580 | |
| 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)) | |
| 583 | 583 | |
| 584 | 584 | |
| 585 | 585 | /* |
| 586 | 586 | ** (address of) a fixed nil value |
| 587 | 587 | */ |
| 588 | #define luaO_nilobject | |
| 588 | #define luaO_nilobject (&luaO_nilobject_) | |
| 589 | 589 | |
| 590 | 590 | |
| 591 | 591 | LUAI_DDEC const TValue luaO_nilobject_; |
| r31374 | r31375 | |
| 598 | 598 | LUAI_FUNC int luaO_str2d (const char *s, size_t len, lua_Number *result); |
| 599 | 599 | LUAI_FUNC int luaO_hexavalue (int c); |
| 600 | 600 | LUAI_FUNC const char *luaO_pushvfstring (lua_State *L, const char *fmt, |
| 601 | ||
| 601 | va_list argp); | |
| 602 | 602 | LUAI_FUNC const char *luaO_pushfstring (lua_State *L, const char *fmt, ...); |
| 603 | 603 | LUAI_FUNC void luaO_chunkid (char *out, const char *source, size_t len); |
| 604 | 604 | |
| 605 | 605 | |
| 606 | 606 | #endif |
| 607 |
| r31374 | r31375 | |
|---|---|---|
| 12 | 12 | #include "lstate.h" |
| 13 | 13 | |
| 14 | 14 | |
| 15 | #define sizestring(s) | |
| 15 | #define sizestring(s) (sizeof(union TString)+((s)->len+1)*sizeof(char)) | |
| 16 | 16 | |
| 17 | #define sizeudata(u) | |
| 17 | #define sizeudata(u) (sizeof(union Udata)+(u)->len) | |
| 18 | 18 | |
| 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)) | |
| 21 | 21 | |
| 22 | #define luaS_fix(s) | |
| 22 | #define luaS_fix(s) l_setbit((s)->tsv.marked, FIXEDBIT) | |
| 23 | 23 | |
| 24 | 24 | |
| 25 | 25 | /* |
| 26 | 26 | ** test whether a string is a reserved word |
| 27 | 27 | */ |
| 28 | #define isreserved(s) | |
| 28 | #define isreserved(s) ((s)->tsv.tt == LUA_TSHRSTR && (s)->tsv.extra > 0) | |
| 29 | 29 | |
| 30 | 30 | |
| 31 | 31 | /* |
| 32 | 32 | ** equality for short strings, which are always internalized |
| 33 | 33 | */ |
| 34 | #define eqshrstr(a,b) | |
| 34 | #define eqshrstr(a,b) check_exp((a)->tsv.tt == LUA_TSHRSTR, (a) == (b)) | |
| 35 | 35 | |
| 36 | 36 | |
| 37 | 37 | LUAI_FUNC unsigned int luaS_hash (const char *str, size_t l, unsigned int seed); |
| r31374 | r31375 | |
|---|---|---|
| 24 | 24 | ** grep "ORDER OPR" if you change these enums (ORDER OP) |
| 25 | 25 | */ |
| 26 | 26 | typedef 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 | |
| 33 | 33 | } BinOpr; |
| 34 | 34 | |
| 35 | 35 | |
| 36 | 36 | typedef enum UnOpr { OPR_MINUS, OPR_NOT, OPR_LEN, OPR_NOUNOPR } UnOpr; |
| 37 | 37 | |
| 38 | 38 | |
| 39 | #define getcode(fs,e) | |
| 39 | #define getcode(fs,e) ((fs)->f->code[(e)->u.info]) | |
| 40 | 40 | |
| 41 | #define luaK_codeAsBx(fs,o,A,sBx) | |
| 41 | #define luaK_codeAsBx(fs,o,A,sBx) luaK_codeABx(fs,o,A,(sBx)+MAXARG_sBx) | |
| 42 | 42 | |
| 43 | #define luaK_setmultret(fs,e) | |
| 43 | #define luaK_setmultret(fs,e) luaK_setreturns(fs, e, LUA_MULTRET) | |
| 44 | 44 | |
| 45 | #define luaK_jumpto(fs,t) | |
| 45 | #define luaK_jumpto(fs,t) luaK_patchlist(fs, luaK_jump(fs), t) | |
| 46 | 46 | |
| 47 | 47 | LUAI_FUNC int luaK_codeABx (FuncState *fs, OpCode o, int A, unsigned int Bx); |
| 48 | 48 | LUAI_FUNC int luaK_codeABC (FuncState *fs, OpCode o, int A, int B, int C); |
| r31374 | r31375 | |
| 76 | 76 | LUAI_FUNC void luaK_prefix (FuncState *fs, UnOpr op, expdesc *v, int line); |
| 77 | 77 | LUAI_FUNC void luaK_infix (FuncState *fs, BinOpr op, expdesc *v); |
| 78 | 78 | LUAI_FUNC void luaK_posfix (FuncState *fs, BinOpr op, expdesc *v1, |
| 79 | ||
| 79 | expdesc *v2, int line); | |
| 80 | 80 | LUAI_FUNC void luaK_setlist (FuncState *fs, int base, int nelems, int tostore); |
| 81 | 81 | |
| 82 | 82 |
| r31374 | r31375 | |
|---|---|---|
| 30 | 30 | |
| 31 | 31 | |
| 32 | 32 | #if !defined(LUA_ANSI) && defined(_WIN32) && !defined(_WIN32_WCE) |
| 33 | #define LUA_WIN | |
| 33 | #define LUA_WIN /* enable goodies for regular Windows platforms */ | |
| 34 | 34 | #endif |
| 35 | 35 | |
| 36 | 36 | #if defined(LUA_WIN) |
| 37 | 37 | #define LUA_DL_DLL |
| 38 | #define LUA_USE_AFORMAT | |
| 38 | #define LUA_USE_AFORMAT /* assume 'printf' handles 'aA' specifiers */ | |
| 39 | 39 | #endif |
| 40 | 40 | |
| 41 | 41 | |
| 42 | 42 | |
| 43 | 43 | #if defined(LUA_USE_LINUX) |
| 44 | 44 | #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 */ | |
| 50 | 50 | #endif |
| 51 | 51 | |
| 52 | 52 | #if defined(LUA_USE_MACOSX) |
| 53 | 53 | #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 */ | |
| 59 | 59 | #endif |
| 60 | 60 | |
| 61 | 61 | |
| r31374 | r31375 | |
| 84 | 84 | ** hierarchy or if you want to install your libraries in |
| 85 | 85 | ** non-conventional directories. |
| 86 | 86 | */ |
| 87 | #if defined(_WIN32) | |
| 87 | #if defined(_WIN32) /* { */ | |
| 88 | 88 | /* |
| 89 | 89 | ** In Windows, any exclamation mark ('!') in the path is replaced by the |
| 90 | 90 | ** path of the directory of the executable file of the current process. |
| 91 | 91 | */ |
| 92 | #define LUA_LDIR "!\\lua\\" | |
| 93 | #define LUA_CDIR "!\\" | |
| 92 | #define LUA_LDIR "!\\lua\\" | |
| 93 | #define LUA_CDIR "!\\" | |
| 94 | 94 | #define LUA_PATH_DEFAULT \ |
| 95 | 95 | LUA_LDIR"?.lua;" LUA_LDIR"?\\init.lua;" \ |
| 96 | 96 | LUA_CDIR"?.lua;" LUA_CDIR"?\\init.lua;" ".\\?.lua" |
| 97 | 97 | #define LUA_CPATH_DEFAULT \ |
| 98 | 98 | LUA_CDIR"?.dll;" LUA_CDIR"loadall.dll;" ".\\?.dll" |
| 99 | 99 | |
| 100 | #else | |
| 100 | #else /* }{ */ | |
| 101 | 101 | |
| 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 | |
| 106 | 106 | #define LUA_PATH_DEFAULT \ |
| 107 | 107 | LUA_LDIR"?.lua;" LUA_LDIR"?/init.lua;" \ |
| 108 | 108 | LUA_CDIR"?.lua;" LUA_CDIR"?/init.lua;" "./?.lua" |
| 109 | 109 | #define LUA_CPATH_DEFAULT \ |
| 110 | 110 | LUA_CDIR"?.so;" LUA_CDIR"loadall.so;" "./?.so" |
| 111 | #endif | |
| 111 | #endif /* } */ | |
| 112 | 112 | |
| 113 | 113 | |
| 114 | 114 | /* |
| r31374 | r31375 | |
| 117 | 117 | ** and is not Windows. (On Windows Lua automatically uses "\".) |
| 118 | 118 | */ |
| 119 | 119 | #if defined(_WIN32) |
| 120 | #define LUA_DIRSEP | |
| 120 | #define LUA_DIRSEP "\\" | |
| 121 | 121 | #else |
| 122 | #define LUA_DIRSEP | |
| 122 | #define LUA_DIRSEP "/" | |
| 123 | 123 | #endif |
| 124 | 124 | |
| 125 | 125 | |
| r31374 | r31375 | |
| 128 | 128 | @@ environment, used to access global names. |
| 129 | 129 | ** CHANGE it if you do not like this name. |
| 130 | 130 | */ |
| 131 | #define LUA_ENV | |
| 131 | #define LUA_ENV "_ENV" | |
| 132 | 132 | |
| 133 | 133 | |
| 134 | 134 | /* |
| r31374 | r31375 | |
| 140 | 140 | ** the libraries, you may want to use the following definition (define |
| 141 | 141 | ** LUA_BUILD_AS_DLL to get it). |
| 142 | 142 | */ |
| 143 | #if defined(LUA_BUILD_AS_DLL) | |
| 143 | #if defined(LUA_BUILD_AS_DLL) /* { */ | |
| 144 | 144 | |
| 145 | #if defined(LUA_CORE) || defined(LUA_LIB) | |
| 145 | #if defined(LUA_CORE) || defined(LUA_LIB) /* { */ | |
| 146 | 146 | #define LUA_API __declspec(dllexport) |
| 147 | #else | |
| 147 | #else /* }{ */ | |
| 148 | 148 | #define LUA_API __declspec(dllimport) |
| 149 | #endif | |
| 149 | #endif /* } */ | |
| 150 | 150 | |
| 151 | #else | |
| 151 | #else /* }{ */ | |
| 152 | 152 | |
| 153 | #define LUA_API | |
| 153 | #define LUA_API extern | |
| 154 | 154 | |
| 155 | #endif | |
| 155 | #endif /* } */ | |
| 156 | 156 | |
| 157 | 157 | |
| 158 | 158 | /* 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 | |
| 161 | 161 | |
| 162 | 162 | |
| 163 | 163 | /* |
| r31374 | r31375 | |
| 175 | 175 | ** default definition. |
| 176 | 176 | */ |
| 177 | 177 | #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 */ | |
| 182 | 182 | |
| 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 /* } */ | |
| 188 | 188 | |
| 189 | 189 | |
| 190 | 190 | |
| r31374 | r31375 | |
| 192 | 192 | @@ LUA_QL describes how error messages quote program elements. |
| 193 | 193 | ** CHANGE it if you want a different appearance. |
| 194 | 194 | */ |
| 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") | |
| 197 | 197 | |
| 198 | 198 | |
| 199 | 199 | /* |
| r31374 | r31375 | |
| 201 | 201 | @* of a function in debug information. |
| 202 | 202 | ** CHANGE it if you want a different size. |
| 203 | 203 | */ |
| 204 | #define LUA_IDSIZE | |
| 204 | #define LUA_IDSIZE 60 | |
| 205 | 205 | |
| 206 | 206 | |
| 207 | 207 | /* |
| r31374 | r31375 | |
| 211 | 211 | */ |
| 212 | 212 | #if defined(LUA_LIB) || defined(lua_c) |
| 213 | 213 | #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)) | |
| 216 | 216 | #endif |
| 217 | 217 | |
| 218 | 218 | /* |
| r31374 | r31375 | |
| 244 | 244 | ** You can define it to get all options, or change specific options |
| 245 | 245 | ** to fit your specific needs. |
| 246 | 246 | */ |
| 247 | #if defined(LUA_COMPAT_ALL) | |
| 247 | #if defined(LUA_COMPAT_ALL) /* { */ | |
| 248 | 248 | |
| 249 | 249 | /* |
| 250 | 250 | @@ LUA_COMPAT_UNPACK controls the presence of global 'unpack'. |
| r31374 | r31375 | |
| 264 | 264 | */ |
| 265 | 265 | #define lua_cpcall(L,f,u) \ |
| 266 | 266 | (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)) | |
| 269 | 269 | |
| 270 | 270 | |
| 271 | 271 | /* |
| r31374 | r31375 | |
| 290 | 290 | ** changes in the API. The macros themselves document how to |
| 291 | 291 | ** change your code to avoid using them. |
| 292 | 292 | */ |
| 293 | #define lua_strlen(L,i) | |
| 293 | #define lua_strlen(L,i) lua_rawlen(L, (i)) | |
| 294 | 294 | |
| 295 | #define lua_objlen(L,i) | |
| 295 | #define lua_objlen(L,i) lua_rawlen(L, (i)) | |
| 296 | 296 | |
| 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) | |
| 299 | 299 | |
| 300 | 300 | /* |
| 301 | 301 | @@ LUA_COMPAT_MODULE controls compatibility with previous |
| r31374 | r31375 | |
| 303 | 303 | */ |
| 304 | 304 | #define LUA_COMPAT_MODULE |
| 305 | 305 | |
| 306 | #endif | |
| 306 | #endif /* } */ | |
| 307 | 307 | |
| 308 | 308 | /* }================================================================== */ |
| 309 | 309 | |
| r31374 | r31375 | |
| 315 | 315 | ** your machine. Probably you do not need to change this. |
| 316 | 316 | */ |
| 317 | 317 | /* 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 /* }{ */ | |
| 321 | 321 | /* int has at least 32 bits */ |
| 322 | #define LUAI_BITSINT 32 | |
| 323 | #else /* }{ */ | |
| 322 | #define LUAI_BITSINT 32 | |
| 323 | #else /* }{ */ | |
| 324 | 324 | #error "you must define LUA_BITSINT with number of bits in an integer" |
| 325 | #endif | |
| 325 | #endif /* } */ | |
| 326 | 326 | |
| 327 | 327 | |
| 328 | 328 | /* |
| r31374 | r31375 | |
| 335 | 335 | ** good enough for your machine. Probably you do not need to change |
| 336 | 336 | ** this. |
| 337 | 337 | */ |
| 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 /* }{ */ | |
| 343 | 343 | /* 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 /* } */ | |
| 348 | 348 | |
| 349 | 349 | |
| 350 | 350 | /* |
| r31374 | r31375 | |
| 354 | 354 | ** space (and to reserve some numbers for pseudo-indices). |
| 355 | 355 | */ |
| 356 | 356 | #if LUAI_BITSINT >= 32 |
| 357 | #define LUAI_MAXSTACK | |
| 357 | #define LUAI_MAXSTACK 1000000 | |
| 358 | 358 | #else |
| 359 | #define LUAI_MAXSTACK | |
| 359 | #define LUAI_MAXSTACK 15000 | |
| 360 | 360 | #endif |
| 361 | 361 | |
| 362 | 362 | /* reserve some space for error handling */ |
| 363 | #define LUAI_FIRSTPSEUDOIDX | |
| 363 | #define LUAI_FIRSTPSEUDOIDX (-LUAI_MAXSTACK - 1000) | |
| 364 | 364 | |
| 365 | 365 | |
| 366 | 366 | |
| r31374 | r31375 | |
| 369 | 369 | @@ LUAL_BUFFERSIZE is the buffer size used by the lauxlib buffer system. |
| 370 | 370 | ** CHANGE it if it uses too much C-stack space. |
| 371 | 371 | */ |
| 372 | #define LUAL_BUFFERSIZE | |
| 372 | #define LUAL_BUFFERSIZE BUFSIZ | |
| 373 | 373 | |
| 374 | 374 | |
| 375 | 375 | |
| r31374 | r31375 | |
| 384 | 384 | */ |
| 385 | 385 | |
| 386 | 386 | #define LUA_NUMBER_DOUBLE |
| 387 | #define LUA_NUMBER | |
| 387 | #define LUA_NUMBER double | |
| 388 | 388 | |
| 389 | 389 | /* |
| 390 | 390 | @@ LUAI_UACNUMBER is the result of an 'usual argument conversion' |
| 391 | 391 | @* over a number. |
| 392 | 392 | */ |
| 393 | #define LUAI_UACNUMBER | |
| 393 | #define LUAI_UACNUMBER double | |
| 394 | 394 | |
| 395 | 395 | |
| 396 | 396 | /* |
| r31374 | r31375 | |
| 399 | 399 | @@ lua_number2str converts a number to a string. |
| 400 | 400 | @@ LUAI_MAXNUMBER2STR is maximum size of previous conversion. |
| 401 | 401 | */ |
| 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 */ | |
| 406 | 406 | |
| 407 | 407 | |
| 408 | 408 | /* |
| 409 | 409 | @@ l_mathop allows the addition of an 'l' or 'f' to all math operations |
| 410 | 410 | */ |
| 411 | #define l_mathop(x) | |
| 411 | #define l_mathop(x) (x) | |
| 412 | 412 | |
| 413 | 413 | |
| 414 | 414 | /* |
| r31374 | r31375 | |
| 419 | 419 | ** systems, you can leave 'lua_strx2number' undefined and Lua will |
| 420 | 420 | ** provide its own implementation. |
| 421 | 421 | */ |
| 422 | #define lua_str2number(s,p) | |
| 422 | #define lua_str2number(s,p) strtod((s), (p)) | |
| 423 | 423 | |
| 424 | 424 | #if defined(LUA_USE_STRTODHEX) |
| 425 | #define lua_strx2number(s,p) | |
| 425 | #define lua_strx2number(s,p) strtod((s), (p)) | |
| 426 | 426 | #endif |
| 427 | 427 | |
| 428 | 428 | |
| r31374 | r31375 | |
| 433 | 433 | /* the following operations need the math library */ |
| 434 | 434 | #if defined(lobject_c) || defined(lvm_c) |
| 435 | 435 | #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)) | |
| 438 | 438 | #endif |
| 439 | 439 | |
| 440 | 440 | /* these are quite standard operations */ |
| 441 | 441 | #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))) | |
| 451 | 451 | #endif |
| 452 | 452 | |
| 453 | 453 | |
| r31374 | r31375 | |
| 457 | 457 | ** CHANGE that if ptrdiff_t is not adequate on your machine. (On most |
| 458 | 458 | ** machines, ptrdiff_t gives a good choice between int or long.) |
| 459 | 459 | */ |
| 460 | #define LUA_INTEGER | |
| 460 | #define LUA_INTEGER ptrdiff_t | |
| 461 | 461 | |
| 462 | 462 | /* |
| 463 | 463 | @@ LUA_UNSIGNED is the integral type used by lua_pushunsigned/lua_tounsigned. |
| 464 | 464 | ** It must have at least 32 bits. |
| 465 | 465 | */ |
| 466 | #define LUA_UNSIGNED | |
| 466 | #define LUA_UNSIGNED unsigned LUA_INT32 | |
| 467 | 467 | |
| 468 | 468 | |
| 469 | 469 | |
| r31374 | r31375 | |
| 471 | 471 | ** Some tricks with doubles |
| 472 | 472 | */ |
| 473 | 473 | |
| 474 | #if defined(LUA_NUMBER_DOUBLE) && !defined(LUA_ANSI) | |
| 474 | #if defined(LUA_NUMBER_DOUBLE) && !defined(LUA_ANSI) /* { */ | |
| 475 | 475 | /* |
| 476 | 476 | ** The next definitions activate some tricks to speed up the |
| 477 | 477 | ** conversion from doubles to integer types, mainly to LUA_UNSIGNED. |
| r31374 | r31375 | |
| 498 | 498 | */ |
| 499 | 499 | |
| 500 | 500 | /* 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) /* { */ | |
| 502 | 502 | |
| 503 | 503 | #define LUA_MSASMTRICK |
| 504 | #define LUA_IEEEENDIAN | |
| 504 | #define LUA_IEEEENDIAN 0 | |
| 505 | 505 | #define LUA_NANTRICK |
| 506 | 506 | |
| 507 | 507 | |
| r31374 | r31375 | |
| 510 | 510 | |
| 511 | 511 | #define LUA_IEEE754TRICK |
| 512 | 512 | #define LUA_IEEELL |
| 513 | #define LUA_IEEEENDIAN | |
| 513 | #define LUA_IEEEENDIAN 0 | |
| 514 | 514 | #define LUA_NANTRICK |
| 515 | 515 | |
| 516 | 516 | /* pentium 64 bits? */ |
| 517 | #elif defined(__x86_64) | |
| 517 | #elif defined(__x86_64) /* }{ */ | |
| 518 | 518 | |
| 519 | 519 | #define LUA_IEEE754TRICK |
| 520 | #define LUA_IEEEENDIAN | |
| 520 | #define LUA_IEEEENDIAN 0 | |
| 521 | 521 | |
| 522 | #elif defined(__POWERPC__) || defined(__ppc__) | |
| 522 | #elif defined(__POWERPC__) || defined(__ppc__) /* }{ */ | |
| 523 | 523 | |
| 524 | 524 | #define LUA_IEEE754TRICK |
| 525 | #define LUA_IEEEENDIAN | |
| 525 | #define LUA_IEEEENDIAN 1 | |
| 526 | 526 | |
| 527 | #else | |
| 527 | #else /* }{ */ | |
| 528 | 528 | |
| 529 | 529 | /* assume IEEE754 and a 32-bit integer type */ |
| 530 | 530 | #define LUA_IEEE754TRICK |
| 531 | 531 | |
| 532 | #endif | |
| 532 | #endif /* } */ | |
| 533 | 533 | |
| 534 | #endif | |
| 534 | #endif /* } */ | |
| 535 | 535 | |
| 536 | 536 | /* }================================================================== */ |
| 537 | 537 | |
| r31374 | r31375 | |
| 548 | 548 | |
| 549 | 549 | |
| 550 | 550 | #endif |
| 551 |
| r31374 | r31375 | |
|---|---|---|
| 22 | 22 | ** cast to 'void' avoids warnings of "value unused". |
| 23 | 23 | */ |
| 24 | 24 | #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))) | |
| 28 | 28 | |
| 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) | |
| 31 | 31 | #define luaM_freearray(L, b, n) luaM_reallocv(L, (b), n, 0, sizeof((b)[0])) |
| 32 | 32 | |
| 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))) | |
| 35 | 35 | #define luaM_newvector(L,n,t) \ |
| 36 | 36 | cast(t *, luaM_reallocv(L, NULL, 0, n, sizeof(t))) |
| 37 | 37 | |
| 38 | #define luaM_newobject(L,tag,s) | |
| 38 | #define luaM_newobject(L,tag,s) luaM_realloc_(L, NULL, tag, (s)) | |
| 39 | 39 | |
| 40 | 40 | #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))) | |
| 43 | 43 | |
| 44 | 44 | #define luaM_reallocvector(L, v,oldn,n,t) \ |
| 45 | ||
| 45 | ((v)=cast(t *, luaM_reallocv(L, v, oldn, n, sizeof(t)))) | |
| 46 | 46 | |
| 47 | 47 | LUAI_FUNC l_noret luaM_toobig (lua_State *L); |
| 48 | 48 | |
| 49 | 49 | /* not to be called directly */ |
| 50 | 50 | LUAI_FUNC void *luaM_realloc_ (lua_State *L, void *block, size_t oldsize, |
| 51 | ||
| 51 | size_t size); | |
| 52 | 52 | LUAI_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); | |
| 55 | 55 | |
| 56 | 56 | #endif |
| 57 |
| r31374 | r31375 | |
|---|---|---|
| 51 | 51 | |
| 52 | 52 | |
| 53 | 53 | /* 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 */ | |
| 57 | 57 | |
| 58 | 58 | |
| 59 | 59 | typedef 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; | |
| 63 | 63 | } stringtable; |
| 64 | 64 | |
| 65 | 65 | |
| r31374 | r31375 | |
| 67 | 67 | ** information about a call |
| 68 | 68 | */ |
| 69 | 69 | typedef 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; | |
| 89 | 89 | } CallInfo; |
| 90 | 90 | |
| 91 | 91 | |
| 92 | 92 | /* |
| 93 | 93 | ** Bits in CallInfo status |
| 94 | 94 | */ |
| 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 | |
| 98 | 98 | 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 */ | |
| 104 | 104 | |
| 105 | 105 | |
| 106 | #define isLua(ci) | |
| 106 | #define isLua(ci) ((ci)->callstatus & CIST_LUA) | |
| 107 | 107 | |
| 108 | 108 | |
| 109 | 109 | /* |
| 110 | 110 | ** `global state', shared by all threads of this state |
| 111 | 111 | */ |
| 112 | 112 | typedef 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 */ | |
| 148 | 148 | } global_State; |
| 149 | 149 | |
| 150 | 150 | |
| r31374 | r31375 | |
| 152 | 152 | ** `per thread' state |
| 153 | 153 | */ |
| 154 | 154 | struct 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) */ | |
| 176 | 176 | }; |
| 177 | 177 | |
| 178 | 178 | |
| 179 | #define G(L) | |
| 179 | #define G(L) (L->l_G) | |
| 180 | 180 | |
| 181 | 181 | |
| 182 | 182 | /* |
| 183 | 183 | ** Union of all collectable objects |
| 184 | 184 | */ |
| 185 | 185 | union 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 */ | |
| 194 | 194 | }; |
| 195 | 195 | |
| 196 | 196 | |
| 197 | #define gch(o) | |
| 197 | #define gch(o) (&(o)->gch) | |
| 198 | 198 | |
| 199 | 199 | /* macros to convert a GCObject into a specific value */ |
| 200 | 200 | #define rawgco2ts(o) \ |
| 201 | 201 | 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)) | |
| 207 | 207 | #define gco2cl(o) \ |
| 208 | 208 | 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)) | |
| 213 | 213 | |
| 214 | 214 | /* macro to convert any Lua object into a GCObject */ |
| 215 | #define obj2gco(v) | |
| 215 | #define obj2gco(v) (cast(GCObject *, (v))) | |
| 216 | 216 | |
| 217 | 217 | |
| 218 | 218 | /* actual number of total bytes allocated */ |
| 219 | #define gettotalbytes(g) | |
| 219 | #define gettotalbytes(g) ((g)->totalbytes + (g)->GCdebt) | |
| 220 | 220 | |
| 221 | 221 | LUAI_FUNC void luaE_setdebt (global_State *g, l_mem debt); |
| 222 | 222 | LUAI_FUNC void luaE_freethread (lua_State *L, lua_State *L1); |
| r31374 | r31375 | |
| 225 | 225 | |
| 226 | 226 | |
| 227 | 227 | #endif |
| 228 |
| r31374 | r31375 | |
|---|---|---|
| 20 | 20 | |
| 21 | 21 | #if 'A' == 65 && '0' == 48 |
| 22 | 22 | /* ASCII case: can use its own tables; faster and fixed */ |
| 23 | #define LUA_USE_CTYPE | |
| 23 | #define LUA_USE_CTYPE 0 | |
| 24 | 24 | #else |
| 25 | 25 | /* must use standard C ctype */ |
| 26 | #define LUA_USE_CTYPE | |
| 26 | #define LUA_USE_CTYPE 1 | |
| 27 | 27 | #endif |
| 28 | 28 | |
| 29 | 29 | #endif |
| 30 | 30 | |
| 31 | 31 | |
| 32 | #if !LUA_USE_CTYPE | |
| 32 | #if !LUA_USE_CTYPE /* { */ | |
| 33 | 33 | |
| 34 | 34 | #include <limits.h> |
| 35 | 35 | |
| 36 | 36 | #include "llimits.h" |
| 37 | 37 | |
| 38 | 38 | |
| 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 | |
| 44 | 44 | |
| 45 | 45 | |
| 46 | #define MASK(B) | |
| 46 | #define MASK(B) (1 << (B)) | |
| 47 | 47 | |
| 48 | 48 | |
| 49 | 49 | /* |
| 50 | 50 | ** add 1 to char to allow index -1 (EOZ) |
| 51 | 51 | */ |
| 52 | #define testprop(c,p) | |
| 52 | #define testprop(c,p) (luai_ctype_[(c)+1] & (p)) | |
| 53 | 53 | |
| 54 | 54 | /* |
| 55 | 55 | ** 'lalpha' (Lua alphabetic) and 'lalnum' (Lua alphanumeric) both include '_' |
| 56 | 56 | */ |
| 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)) | |
| 63 | 63 | |
| 64 | 64 | /* |
| 65 | 65 | ** this 'ltolower' only works for alphabetic characters |
| 66 | 66 | */ |
| 67 | #define ltolower(c) | |
| 67 | #define ltolower(c) ((c) | ('A' ^ 'a')) | |
| 68 | 68 | |
| 69 | 69 | |
| 70 | 70 | /* two more entries for 0 and -1 (EOZ) */ |
| 71 | 71 | LUAI_DDEC const lu_byte luai_ctype_[UCHAR_MAX + 2]; |
| 72 | 72 | |
| 73 | 73 | |
| 74 | #else | |
| 74 | #else /* }{ */ | |
| 75 | 75 | |
| 76 | 76 | /* |
| 77 | 77 | ** use standard C ctypes |
| r31374 | r31375 | |
| 80 | 80 | #include <ctype.h> |
| 81 | 81 | |
| 82 | 82 | |
| 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)) | |
| 89 | 89 | |
| 90 | #define ltolower(c) | |
| 90 | #define ltolower(c) (tolower(c)) | |
| 91 | 91 | |
| 92 | #endif | |
| 92 | #endif /* } */ | |
| 93 | 93 | |
| 94 | 94 | #endif |
| 95 |
| r31374 | r31375 | |
|---|---|---|
| 21 | 21 | |
| 22 | 22 | |
| 23 | 23 | typedef struct luaL_Reg { |
| 24 | const char *name; | |
| 25 | lua_CFunction func; | |
| 24 | const char *name; | |
| 25 | lua_CFunction func; | |
| 26 | 26 | } luaL_Reg; |
| 27 | 27 | |
| 28 | 28 | |
| 29 | 29 | LUALIB_API void (luaL_checkversion_) (lua_State *L, lua_Number ver); |
| 30 | #define luaL_checkversion(L) | |
| 30 | #define luaL_checkversion(L) luaL_checkversion_(L, LUA_VERSION_NUM) | |
| 31 | 31 | |
| 32 | 32 | LUALIB_API int (luaL_getmetafield) (lua_State *L, int obj, const char *e); |
| 33 | 33 | LUALIB_API int (luaL_callmeta) (lua_State *L, int obj, const char *e); |
| 34 | 34 | LUALIB_API const char *(luaL_tolstring) (lua_State *L, int idx, size_t *len); |
| 35 | 35 | LUALIB_API int (luaL_argerror) (lua_State *L, int numarg, const char *extramsg); |
| 36 | 36 | LUALIB_API const char *(luaL_checklstring) (lua_State *L, int numArg, |
| 37 | ||
| 37 | size_t *l); | |
| 38 | 38 | LUALIB_API const char *(luaL_optlstring) (lua_State *L, int numArg, |
| 39 | ||
| 39 | const char *def, size_t *l); | |
| 40 | 40 | LUALIB_API lua_Number (luaL_checknumber) (lua_State *L, int numArg); |
| 41 | 41 | LUALIB_API lua_Number (luaL_optnumber) (lua_State *L, int nArg, lua_Number def); |
| 42 | 42 | |
| 43 | 43 | LUALIB_API lua_Integer (luaL_checkinteger) (lua_State *L, int numArg); |
| 44 | 44 | LUALIB_API lua_Integer (luaL_optinteger) (lua_State *L, int nArg, |
| 45 | ||
| 45 | lua_Integer def); | |
| 46 | 46 | LUALIB_API lua_Unsigned (luaL_checkunsigned) (lua_State *L, int numArg); |
| 47 | 47 | LUALIB_API lua_Unsigned (luaL_optunsigned) (lua_State *L, int numArg, |
| 48 | ||
| 48 | lua_Unsigned def); | |
| 49 | 49 | |
| 50 | 50 | LUALIB_API void (luaL_checkstack) (lua_State *L, int sz, const char *msg); |
| 51 | 51 | LUALIB_API void (luaL_checktype) (lua_State *L, int narg, int t); |
| r31374 | r31375 | |
| 60 | 60 | LUALIB_API int (luaL_error) (lua_State *L, const char *fmt, ...); |
| 61 | 61 | |
| 62 | 62 | LUALIB_API int (luaL_checkoption) (lua_State *L, int narg, const char *def, |
| 63 | ||
| 63 | const char *const lst[]); | |
| 64 | 64 | |
| 65 | 65 | LUALIB_API int (luaL_fileresult) (lua_State *L, int stat, const char *fname); |
| 66 | 66 | LUALIB_API int (luaL_execresult) (lua_State *L, int stat); |
| r31374 | r31375 | |
| 73 | 73 | LUALIB_API void (luaL_unref) (lua_State *L, int t, int ref); |
| 74 | 74 | |
| 75 | 75 | LUALIB_API int (luaL_loadfilex) (lua_State *L, const char *filename, |
| 76 | ||
| 76 | const char *mode); | |
| 77 | 77 | |
| 78 | #define luaL_loadfile(L,f) | |
| 78 | #define luaL_loadfile(L,f) luaL_loadfilex(L,f,NULL) | |
| 79 | 79 | |
| 80 | 80 | LUALIB_API int (luaL_loadbufferx) (lua_State *L, const char *buff, size_t sz, |
| 81 | ||
| 81 | const char *name, const char *mode); | |
| 82 | 82 | LUALIB_API int (luaL_loadstring) (lua_State *L, const char *s); |
| 83 | 83 | |
| 84 | 84 | LUALIB_API lua_State *(luaL_newstate) (void); |
| r31374 | r31375 | |
| 86 | 86 | LUALIB_API int (luaL_len) (lua_State *L, int idx); |
| 87 | 87 | |
| 88 | 88 | LUALIB_API const char *(luaL_gsub) (lua_State *L, const char *s, const char *p, |
| 89 | ||
| 89 | const char *r); | |
| 90 | 90 | |
| 91 | 91 | LUALIB_API void (luaL_setfuncs) (lua_State *L, const luaL_Reg *l, int nup); |
| 92 | 92 | |
| 93 | 93 | LUALIB_API int (luaL_getsubtable) (lua_State *L, int idx, const char *fname); |
| 94 | 94 | |
| 95 | 95 | LUALIB_API void (luaL_traceback) (lua_State *L, lua_State *L1, |
| 96 | ||
| 96 | const char *msg, int level); | |
| 97 | 97 | |
| 98 | 98 | LUALIB_API void (luaL_requiref) (lua_State *L, const char *modname, |
| 99 | ||
| 99 | lua_CFunction openf, int glb); | |
| 100 | 100 | |
| 101 | 101 | /* |
| 102 | 102 | ** =============================================================== |
| r31374 | r31375 | |
| 105 | 105 | */ |
| 106 | 106 | |
| 107 | 107 | |
| 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) | |
| 110 | 110 | |
| 111 | #define luaL_newlib(L,l) | |
| 111 | #define luaL_newlib(L,l) (luaL_newlibtable(L,l), luaL_setfuncs(L,l,0)) | |
| 112 | 112 | |
| 113 | #define luaL_argcheck(L, cond,numarg,extramsg) | |
| 113 | #define luaL_argcheck(L, cond,numarg,extramsg) \ | |
| 114 | 114 | ((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))) | |
| 121 | 121 | |
| 122 | #define luaL_typename(L,i) | |
| 122 | #define luaL_typename(L,i) lua_typename(L, lua_type(L,(i))) | |
| 123 | 123 | |
| 124 | 124 | #define luaL_dofile(L, fn) \ |
| 125 | 125 | (luaL_loadfile(L, fn) || lua_pcall(L, 0, LUA_MULTRET, 0)) |
| r31374 | r31375 | |
| 127 | 127 | #define luaL_dostring(L, s) \ |
| 128 | 128 | (luaL_loadstring(L, s) || lua_pcall(L, 0, LUA_MULTRET, 0)) |
| 129 | 129 | |
| 130 | #define luaL_getmetatable(L,n) | |
| 130 | #define luaL_getmetatable(L,n) (lua_getfield(L, LUA_REGISTRYINDEX, (n))) | |
| 131 | 131 | |
| 132 | #define luaL_opt(L,f,n,d) | |
| 132 | #define luaL_opt(L,f,n,d) (lua_isnoneornil(L,(n)) ? (d) : f(L,(n))) | |
| 133 | 133 | |
| 134 | #define luaL_loadbuffer(L,s,sz,n) | |
| 134 | #define luaL_loadbuffer(L,s,sz,n) luaL_loadbufferx(L,s,sz,n,NULL) | |
| 135 | 135 | |
| 136 | 136 | |
| 137 | 137 | /* |
| r31374 | r31375 | |
| 141 | 141 | */ |
| 142 | 142 | |
| 143 | 143 | typedef 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 */ | |
| 149 | 149 | } luaL_Buffer; |
| 150 | 150 | |
| 151 | 151 | |
| 152 | 152 | #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))) | |
| 155 | 155 | |
| 156 | #define luaL_addsize(B,s) | |
| 156 | #define luaL_addsize(B,s) ((B)->n += (s)) | |
| 157 | 157 | |
| 158 | 158 | LUALIB_API void (luaL_buffinit) (lua_State *L, luaL_Buffer *B); |
| 159 | 159 | LUALIB_API char *(luaL_prepbuffsize) (luaL_Buffer *B, size_t sz); |
| r31374 | r31375 | |
| 164 | 164 | LUALIB_API void (luaL_pushresultsize) (luaL_Buffer *B, size_t sz); |
| 165 | 165 | LUALIB_API char *(luaL_buffinitsize) (lua_State *L, luaL_Buffer *B, size_t sz); |
| 166 | 166 | |
| 167 | #define luaL_prepbuffer(B) | |
| 167 | #define luaL_prepbuffer(B) luaL_prepbuffsize(B, LUAL_BUFFERSIZE) | |
| 168 | 168 | |
| 169 | 169 | /* }====================================================== */ |
| 170 | 170 | |
| r31374 | r31375 | |
| 186 | 186 | |
| 187 | 187 | |
| 188 | 188 | typedef 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) */ | |
| 191 | 191 | } luaL_Stream; |
| 192 | 192 | |
| 193 | 193 | /* }====================================================== */ |
| r31374 | r31375 | |
| 198 | 198 | #if defined(LUA_COMPAT_MODULE) |
| 199 | 199 | |
| 200 | 200 | LUALIB_API void (luaL_pushmodule) (lua_State *L, const char *modname, |
| 201 | ||
| 201 | int sizehint); | |
| 202 | 202 | LUALIB_API void (luaL_openlib) (lua_State *L, const char *libname, |
| 203 | ||
| 203 | const luaL_Reg *l, int nup); | |
| 204 | 204 | |
| 205 | #define luaL_register(L,n,l) | |
| 205 | #define luaL_register(L,n,l) (luaL_openlib(L,(n),(l),0)) | |
| 206 | 206 | |
| 207 | 207 | #endif |
| 208 | 208 | |
| 209 | 209 | |
| 210 | 210 | #endif |
| 211 | ||
| 212 |
| r31374 | r31375 | |
|---|---|---|
| 10 | 10 | #include "lobject.h" |
| 11 | 11 | |
| 12 | 12 | |
| 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) | |
| 17 | 17 | |
| 18 | #define invalidateTMcache(t) | |
| 18 | #define invalidateTMcache(t) ((t)->flags = 0) | |
| 19 | 19 | |
| 20 | 20 | /* returns the key, given the value of a table entry */ |
| 21 | 21 | #define keyfromval(v) \ |
| 22 | ||
| 22 | (gkey(cast(Node *, cast(char *, (v)) - offsetof(Node, i_val)))) | |
| 23 | 23 | |
| 24 | 24 | |
| 25 | 25 | LUAI_FUNC const TValue *luaH_getint (Table *t, int key); |
| r31374 | r31375 | |
|---|---|---|
| 11 | 11 | #include "lzio.h" |
| 12 | 12 | |
| 13 | 13 | |
| 14 | #define FIRST_RESERVED | |
| 14 | #define FIRST_RESERVED 257 | |
| 15 | 15 | |
| 16 | 16 | |
| 17 | 17 | |
| r31374 | r31375 | |
| 20 | 20 | * grep "ORDER RESERVED" |
| 21 | 21 | */ |
| 22 | 22 | enum 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 | |
| 31 | 31 | }; |
| 32 | 32 | |
| 33 | 33 | /* number of reserved words */ |
| 34 | #define NUM_RESERVED | |
| 34 | #define NUM_RESERVED (cast(int, TK_WHILE-FIRST_RESERVED+1)) | |
| 35 | 35 | |
| 36 | 36 | |
| 37 | 37 | typedef union { |
| 38 | lua_Number r; | |
| 39 | TString *ts; | |
| 38 | lua_Number r; | |
| 39 | TString *ts; | |
| 40 | 40 | } SemInfo; /* semantics information */ |
| 41 | 41 | |
| 42 | 42 | |
| 43 | 43 | typedef struct Token { |
| 44 | int token; | |
| 45 | SemInfo seminfo; | |
| 44 | int token; | |
| 45 | SemInfo seminfo; | |
| 46 | 46 | } Token; |
| 47 | 47 | |
| 48 | 48 | |
| 49 | 49 | /* state of the lexer plus state of the parser when shared by all |
| 50 | 50 | functions */ |
| 51 | 51 | typedef 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 */ | |
| 65 | 65 | } LexState; |
| 66 | 66 | |
| 67 | 67 | |
| 68 | 68 | LUAI_FUNC void luaX_init (lua_State *L); |
| 69 | 69 | LUAI_FUNC void luaX_setinput (lua_State *L, LexState *ls, ZIO *z, |
| 70 | ||
| 70 | TString *source, int firstchar); | |
| 71 | 71 | LUAI_FUNC TString *luaX_newstring (LexState *ls, const char *str, size_t l); |
| 72 | 72 | LUAI_FUNC void luaX_next (LexState *ls); |
| 73 | 73 | LUAI_FUNC int luaX_lookahead (LexState *ls); |
| r31374 | r31375 | |
|---|---|---|
| 1 | 1 | //------------------------------------------------------------------------------ |
| 2 | 2 | /* |
| 3 | 3 | https://github.com/vinniefalco/LuaBridge |
| 4 | ||
| 4 | ||
| 5 | 5 | Copyright 2012, Vinnie Falco <vinnie.falco@gmail.com> |
| 6 | 6 | Copyright 2007, Nathan Reed |
| 7 | 7 | |
| r31374 | r31375 | |
| 32 | 32 | #if LUA_VERSION_NUM < 502 |
| 33 | 33 | inline int lua_absindex (lua_State* L, int idx) |
| 34 | 34 | { |
| 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; | |
| 39 | 39 | } |
| 40 | 40 | |
| 41 | 41 | inline void lua_rawgetp (lua_State* L, int idx, void const* p) |
| 42 | 42 | { |
| 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); | |
| 46 | 46 | } |
| 47 | 47 | |
| 48 | 48 | inline void lua_rawsetp (lua_State* L, int idx, void const* p) |
| 49 | 49 | { |
| 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); | |
| 55 | 55 | } |
| 56 | 56 | |
| 57 | 57 | #define LUA_OPEQ 1 |
| r31374 | r31375 | |
| 60 | 60 | |
| 61 | 61 | inline int lua_compare (lua_State* L, int idx1, int idx2, int op) |
| 62 | 62 | { |
| 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; | |
| 68 | 68 | |
| 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; | |
| 72 | 72 | |
| 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; | |
| 76 | 76 | |
| 77 | default: | |
| 78 | return 0; | |
| 79 | }; | |
| 77 | default: | |
| 78 | return 0; | |
| 79 | }; | |
| 80 | 80 | } |
| 81 | 81 | |
| 82 | 82 | inline int get_length (lua_State* L, int idx) |
| 83 | 83 | { |
| 84 | ||
| 84 | return int (lua_objlen (L, idx)); | |
| 85 | 85 | } |
| 86 | 86 | |
| 87 | 87 | #else |
| 88 | 88 | inline int get_length (lua_State* L, int idx) |
| 89 | 89 | { |
| 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; | |
| 94 | 94 | } |
| 95 | 95 | |
| 96 | 96 | #endif |
| r31374 | r31375 | |
| 102 | 102 | #endif |
| 103 | 103 | |
| 104 | 104 | /** Get a table value, bypassing metamethods. |
| 105 | */ | |
| 105 | */ | |
| 106 | 106 | inline void rawgetfield (lua_State* L, int index, char const* key) |
| 107 | 107 | { |
| 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); | |
| 112 | 112 | } |
| 113 | 113 | |
| 114 | 114 | /** Set a table value, bypassing metamethods. |
| 115 | */ | |
| 115 | */ | |
| 116 | 116 | inline void rawsetfield (lua_State* L, int index, char const* key) |
| 117 | 117 | { |
| 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); | |
| 123 | 123 | } |
| 124 | 124 | |
| 125 | 125 | /** Returns true if the value is a full userdata (not light). |
| 126 | 126 | */ |
| 127 | 127 | inline bool isfulluserdata (lua_State* L, int index) |
| 128 | 128 | { |
| 129 | ||
| 129 | return lua_isuserdata (L, index) && !lua_islightuserdata (L, index); | |
| 130 | 130 | } |
| 131 | 131 | |
| 132 | 132 | /** Test lua_State objects for global equality. |
| r31374 | r31375 | |
| 138 | 138 | */ |
| 139 | 139 | inline bool equalstates (lua_State* L1, lua_State* L2) |
| 140 | 140 | { |
| 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); | |
| 143 | 143 | } |
| r31374 | r31375 | |
|---|---|---|
| 1 | 1 | //------------------------------------------------------------------------------ |
| 2 | 2 | /* |
| 3 | 3 | https://github.com/vinniefalco/LuaBridge |
| 4 | ||
| 4 | ||
| 5 | 5 | Copyright 2012, Vinnie Falco <vinnie.falco@gmail.com> |
| 6 | 6 | Copyright 2007, Nathan Reed |
| 7 | 7 | |
| r31374 | r31375 | |
| 49 | 49 | template <class T> |
| 50 | 50 | struct Constructor <T, None> |
| 51 | 51 | { |
| 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 | } | |
| 60 | 60 | }; |
| 61 | 61 | |
| 62 | 62 | template <class T, class P1> |
| 63 | 63 | struct Constructor <T, TypeList <P1> > |
| 64 | 64 | { |
| 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 | } | |
| 73 | 73 | }; |
| 74 | 74 | |
| 75 | 75 | template <class T, class P1, class P2> |
| 76 | 76 | struct Constructor <T, TypeList <P1, TypeList <P2> > > |
| 77 | 77 | { |
| 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 | } | |
| 86 | 86 | }; |
| 87 | 87 | |
| 88 | 88 | template <class T, class P1, class P2, class P3> |
| 89 | 89 | struct Constructor <T, TypeList <P1, TypeList <P2, TypeList <P3> > > > |
| 90 | 90 | { |
| 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 | } | |
| 101 | 101 | }; |
| 102 | 102 | |
| 103 | 103 | template <class T, class P1, class P2, class P3, class P4> |
| 104 | 104 | struct Constructor <T, TypeList <P1, TypeList <P2, TypeList <P3, |
| 105 | ||
| 105 | TypeList <P4> > > > > | |
| 106 | 106 | { |
| 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 | } | |
| 117 | 117 | }; |
| 118 | 118 | |
| 119 | 119 | template <class T, class P1, class P2, class P3, class P4, |
| 120 | ||
| 120 | class P5> | |
| 121 | 121 | struct Constructor <T, TypeList <P1, TypeList <P2, TypeList <P3, |
| 122 | ||
| 122 | TypeList <P4, TypeList <P5> > > > > > | |
| 123 | 123 | { |
| 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 | } | |
| 136 | 136 | }; |
| 137 | 137 | |
| 138 | 138 | template <class T, class P1, class P2, class P3, class P4, |
| 139 | ||
| 139 | class P5, class P6> | |
| 140 | 140 | struct Constructor <T, TypeList <P1, TypeList <P2, TypeList <P3, |
| 141 | ||
| 141 | TypeList <P4, TypeList <P5, TypeList <P6> > > > > > > | |
| 142 | 142 | { |
| 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 | } | |
| 155 | 155 | }; |
| 156 | 156 | |
| 157 | 157 | template <class T, class P1, class P2, class P3, class P4, |
| 158 | ||
| 158 | class P5, class P6, class P7> | |
| 159 | 159 | struct Constructor <T, TypeList <P1, TypeList <P2, TypeList <P3, |
| 160 | ||
| 160 | TypeList <P4, TypeList <P5, TypeList <P6, TypeList <P7> > > > > > > > | |
| 161 | 161 | { |
| 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 | } | |
| 178 | 178 | }; |
| 179 | 179 | |
| 180 | 180 | template <class T, class P1, class P2, class P3, class P4, |
| 181 | ||
| 181 | class P5, class P6, class P7, class P8> | |
| 182 | 182 | struct 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> > > > > > > > > | |
| 185 | 185 | { |
| 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 | } | |
| 202 | 202 | }; |
| 203 | 203 | |
| 204 | 204 | #endif |
| r31374 | r31375 | |
|---|---|---|
| 34 | 34 | template <> |
| 35 | 35 | struct Stack <lua_State*> |
| 36 | 36 | { |
| 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 | } | |
| 41 | 41 | }; |
| 42 | 42 | |
| 43 | 43 | //------------------------------------------------------------------------------ |
| r31374 | r31375 | |
| 47 | 47 | template <> |
| 48 | 48 | struct Stack <lua_CFunction> |
| 49 | 49 | { |
| 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 | } | |
| 54 | 54 | |
| 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 | } | |
| 59 | 59 | }; |
| 60 | 60 | |
| 61 | 61 | //------------------------------------------------------------------------------ |
| r31374 | r31375 | |
| 65 | 65 | template <> |
| 66 | 66 | struct Stack <int> |
| 67 | 67 | { |
| 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 | } | |
| 77 | 77 | }; |
| 78 | 78 | |
| 79 | 79 | template <> |
| 80 | 80 | struct Stack <int const&> |
| 81 | 81 | { |
| 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 | } | |
| 91 | 91 | }; |
| 92 | 92 | //------------------------------------------------------------------------------ |
| 93 | 93 | /** |
| r31374 | r31375 | |
| 96 | 96 | template <> |
| 97 | 97 | struct Stack <unsigned int> |
| 98 | 98 | { |
| 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 | } | |
| 108 | 108 | }; |
| 109 | 109 | |
| 110 | 110 | template <> |
| 111 | 111 | struct Stack <unsigned int const&> |
| 112 | 112 | { |
| 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 | } | |
| 122 | 122 | }; |
| 123 | 123 | |
| 124 | 124 | //------------------------------------------------------------------------------ |
| r31374 | r31375 | |
| 128 | 128 | template <> |
| 129 | 129 | struct Stack <unsigned char> |
| 130 | 130 | { |
| 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 | } | |
| 140 | 140 | }; |
| 141 | 141 | |
| 142 | 142 | template <> |
| 143 | 143 | struct Stack <unsigned char const&> |
| 144 | 144 | { |
| 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 | } | |
| 154 | 154 | }; |
| 155 | 155 | |
| 156 | 156 | //------------------------------------------------------------------------------ |
| r31374 | r31375 | |
| 160 | 160 | template <> |
| 161 | 161 | struct Stack <short> |
| 162 | 162 | { |
| 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 | } | |
| 172 | 172 | }; |
| 173 | 173 | |
| 174 | 174 | template <> |
| 175 | 175 | struct Stack <short const&> |
| 176 | 176 | { |
| 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 | } | |
| 186 | 186 | }; |
| 187 | 187 | |
| 188 | 188 | //------------------------------------------------------------------------------ |
| r31374 | r31375 | |
| 192 | 192 | template <> |
| 193 | 193 | struct Stack <unsigned short> |
| 194 | 194 | { |
| 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 | } | |
| 204 | 204 | }; |
| 205 | 205 | |
| 206 | 206 | template <> |
| 207 | 207 | struct Stack <unsigned short const&> |
| 208 | 208 | { |
| 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 | } | |
| 218 | 218 | }; |
| 219 | 219 | |
| 220 | 220 | //------------------------------------------------------------------------------ |
| r31374 | r31375 | |
| 224 | 224 | template <> |
| 225 | 225 | struct Stack <long> |
| 226 | 226 | { |
| 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 | } | |
| 236 | 236 | }; |
| 237 | 237 | |
| 238 | 238 | template <> |
| 239 | 239 | struct Stack <long const&> |
| 240 | 240 | { |
| 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 | } | |
| 250 | 250 | }; |
| 251 | 251 | |
| 252 | 252 | //------------------------------------------------------------------------------ |
| r31374 | r31375 | |
| 256 | 256 | template <> |
| 257 | 257 | struct Stack <unsigned long> |
| 258 | 258 | { |
| 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 | } | |
| 268 | 268 | }; |
| 269 | 269 | |
| 270 | 270 | template <> |
| 271 | 271 | struct Stack <unsigned long const&> |
| 272 | 272 | { |
| 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 | } | |
| 282 | 282 | }; |
| 283 | 283 | |
| 284 | 284 | //------------------------------------------------------------------------------ |
| r31374 | r31375 | |
| 288 | 288 | template <> |
| 289 | 289 | struct Stack <float> |
| 290 | 290 | { |
| 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 | } | |
| 300 | 300 | }; |
| 301 | 301 | |
| 302 | 302 | template <> |
| 303 | 303 | struct Stack <float const&> |
| 304 | 304 | { |
| 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 | } | |
| 314 | 314 | }; |
| 315 | 315 | |
| 316 | 316 | //------------------------------------------------------------------------------ |
| r31374 | r31375 | |
| 319 | 319 | */ |
| 320 | 320 | template <> struct Stack <double> |
| 321 | 321 | { |
| 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 | } | |
| 331 | 331 | }; |
| 332 | 332 | |
| 333 | 333 | template <> struct Stack <double const&> |
| 334 | 334 | { |
| 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 | } | |
| 344 | 344 | }; |
| 345 | 345 | |
| 346 | 346 | //------------------------------------------------------------------------------ |
| r31374 | r31375 | |
| 349 | 349 | */ |
| 350 | 350 | template <> |
| 351 | 351 | struct 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 | } | |
| 361 | 361 | }; |
| 362 | 362 | |
| 363 | 363 | template <> |
| 364 | 364 | struct 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 | } | |
| 374 | 374 | }; |
| 375 | 375 | |
| 376 | 376 | //------------------------------------------------------------------------------ |
| r31374 | r31375 | |
| 380 | 380 | template <> |
| 381 | 381 | struct Stack <char> |
| 382 | 382 | { |
| 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 | } | |
| 393 | 393 | }; |
| 394 | 394 | |
| 395 | 395 | template <> |
| 396 | 396 | struct Stack <char const&> |
| 397 | 397 | { |
| 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 | } | |
| 408 | 408 | }; |
| 409 | 409 | |
| 410 | 410 | //------------------------------------------------------------------------------ |
| r31374 | r31375 | |
| 414 | 414 | template <> |
| 415 | 415 | struct Stack <char const*> |
| 416 | 416 | { |
| 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 | } | |
| 424 | 424 | |
| 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 | } | |
| 429 | 429 | }; |
| 430 | 430 | |
| 431 | 431 | //------------------------------------------------------------------------------ |
| r31374 | r31375 | |
| 435 | 435 | template <> |
| 436 | 436 | struct Stack <std::string> |
| 437 | 437 | { |
| 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 | } | |
| 442 | 442 | |
| 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 | } | |
| 449 | 449 | }; |
| 450 | 450 | |
| 451 | 451 | //------------------------------------------------------------------------------ |
| r31374 | r31375 | |
| 455 | 455 | template <> |
| 456 | 456 | struct Stack <std::string const&> |
| 457 | 457 | { |
| 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 | } | |
| 462 | 462 | |
| 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 | } | |
| 469 | 469 | }; |
| r31374 | r31375 | |
|---|---|---|
| 13 | 13 | ostr << " " << i << ": '" << lua_tostring(L, i) << "'\n"; |
| 14 | 14 | break; |
| 15 | 15 | case LUA_TBOOLEAN: |
| 16 | ostr << " " << i << ": " << | |
| 16 | ostr << " " << i << ": " << | |
| 17 | 17 | (lua_toboolean(L, i) ? "true" : "false") << "\n"; |
| 18 | 18 | break; |
| 19 | 19 | case LUA_TNUMBER: |
| r31374 | r31375 | |
|---|---|---|
| 1 | 1 | //------------------------------------------------------------------------------ |
| 2 | 2 | /* |
| 3 | 3 | https://github.com/vinniefalco/LuaBridge |
| 4 | ||
| 4 | ||
| 5 | 5 | Copyright 2012, Vinnie Falco <vinnie.falco@gmail.com> |
| 6 | 6 | |
| 7 | 7 | License: The MIT License (http://www.opensource.org/licenses/mit-license.php) |
| r31374 | r31375 | |
| 56 | 56 | template <class T> |
| 57 | 57 | struct ContainerTraits |
| 58 | 58 | { |
| 59 | ||
| 59 | typedef bool isNotContainer; | |
| 60 | 60 | }; |
| 61 | 61 | |
| 62 | 62 | //------------------------------------------------------------------------------ |
| r31374 | r31375 | |
| 67 | 67 | */ |
| 68 | 68 | struct TypeTraits |
| 69 | 69 | { |
| 70 | ||
| 70 | /** Determine if type T is a container. | |
| 71 | 71 | |
| 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 | |
| 81 | 81 | |
| 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*); | |
| 91 | 84 | |
| 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 (...); | |
| 100 | 87 | |
| 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 | }; | |
| 107 | 91 | |
| 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 | }; | |
| 116 | 100 | |
| 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 | /**@}*/ | |
| 123 | 123 | }; |
| 124 | 124 | |
| 125 | 125 | #endif |
| r31374 | r31375 | |
|---|---|---|
| 1 | 1 | //------------------------------------------------------------------------------ |
| 2 | 2 | /* |
| 3 | 3 | https://github.com/vinniefalco/LuaBridge |
| 4 | ||
| 4 | ||
| 5 | 5 | Copyright 2012, Vinnie Falco <vinnie.falco@gmail.com> |
| 6 | 6 | |
| 7 | 7 | License: The MIT License (http://www.opensource.org/licenses/mit-license.php) |
| r31374 | r31375 | |
| 52 | 52 | */ |
| 53 | 53 | inline void* getIdentityKey () |
| 54 | 54 | { |
| 55 | static char value; | |
| 56 | return &value; | |
| 55 | static char value; | |
| 56 | return &value; | |
| 57 | 57 | } |
| 58 | 58 | |
| 59 | 59 | /** |
| r31374 | r31375 | |
| 62 | 62 | class Userdata |
| 63 | 63 | { |
| 64 | 64 | protected: |
| 65 | ||
| 65 | void* m_p; // subclasses must set this | |
| 66 | 66 | |
| 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 | } | |
| 75 | 75 | |
| 76 | 76 | private: |
| 77 | //-------------------------------------------------------------------------- | |
| 78 | /** | |
| 79 | Validate and retrieve a Userdata on the stack. | |
| 77 | //-------------------------------------------------------------------------- | |
| 78 | /** | |
| 79 | Validate and retrieve a Userdata on the stack. | |
| 80 | 80 | |
| 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); | |
| 91 | 91 | |
| 92 | bool mismatch = false; | |
| 93 | char const* got = 0; | |
| 92 | bool mismatch = false; | |
| 93 | char const* got = 0; | |
| 94 | 94 | |
| 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)); | |
| 97 | 97 | |
| 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; | |
| 101 | 101 | |
| 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 | } | |
| 117 | 117 | |
| 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 | } | |
| 146 | 146 | |
| 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); | |
| 152 | 152 | |
| 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)); | |
| 155 | 155 | |
| 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); | |
| 158 | 158 | |
| 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 | } | |
| 164 | 164 | |
| 165 | return ud; | |
| 166 | } | |
| 165 | return ud; | |
| 166 | } | |
| 167 | 167 | |
| 168 | //-------------------------------------------------------------------------- | |
| 169 | /** | |
| 170 | Validate and retrieve a Userdata on the stack. | |
| 168 | //-------------------------------------------------------------------------- | |
| 169 | /** | |
| 170 | Validate and retrieve a Userdata on the stack. | |
| 171 | 171 | |
| 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; | |
| 184 | 184 | |
| 185 | bool mismatch = false; | |
| 186 | char const* got = 0; | |
| 185 | bool mismatch = false; | |
| 186 | char const* got = 0; | |
| 187 | 187 | |
| 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)); | |
| 190 | 190 | |
| 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); | |
| 200 | 200 | |
| 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); | |
| 206 | 206 | |
| 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 | } | |
| 214 | 214 | |
| 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); | |
| 220 | 220 | |
| 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"); | |
| 236 | 236 | /* |
| 237 | 237 | ud |
| 238 | 238 | class metatable |
| r31374 | r31375 | |
| 240 | 240 | ud __parent (nil) |
| 241 | 241 | */ |
| 242 | 242 | |
| 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 | } | |
| 271 | 271 | |
| 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); | |
| 278 | 278 | |
| 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)); | |
| 281 | 281 | |
| 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); | |
| 284 | 284 | |
| 285 | luaL_argerror (L, index, msg); | |
| 286 | } | |
| 285 | luaL_argerror (L, index, msg); | |
| 286 | } | |
| 287 | 287 | |
| 288 | return ud; | |
| 289 | } | |
| 288 | return ud; | |
| 289 | } | |
| 290 | 290 | |
| 291 | 291 | public: |
| 292 | ||
| 292 | virtual ~Userdata () { } | |
| 293 | 293 | |
| 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. | |
| 297 | 297 | |
| 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 | } | |
| 305 | 305 | |
| 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. | |
| 309 | 309 | |
| 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 | } | |
| 322 | 322 | }; |
| 323 | 323 | |
| 324 | 324 | //---------------------------------------------------------------------------- |
| r31374 | r31375 | |
| 332 | 332 | class UserdataValue : public Userdata |
| 333 | 333 | { |
| 334 | 334 | private: |
| 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&); | |
| 337 | 337 | |
| 338 | ||
| 338 | char m_storage [sizeof (T)]; | |
| 339 | 339 | |
| 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 | } | |
| 347 | 347 | |
| 348 | 348 | private: |
| 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 | } | |
| 356 | 356 | |
| 357 | ~UserdataValue () | |
| 358 | { | |
| 359 | getObject ()->~T (); | |
| 360 | } | |
| 357 | ~UserdataValue () | |
| 358 | { | |
| 359 | getObject ()->~T (); | |
| 360 | } | |
| 361 | 361 | |
| 362 | 362 | public: |
| 363 | /** | |
| 364 | Push a T via placement new. | |
| 363 | /** | |
| 364 | Push a T via placement new. | |
| 365 | 365 | |
| 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 | } | |
| 379 | 379 | |
| 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 | } | |
| 388 | 388 | }; |
| 389 | 389 | |
| 390 | 390 | //---------------------------------------------------------------------------- |
| r31374 | r31375 | |
| 396 | 396 | class UserdataPtr : public Userdata |
| 397 | 397 | { |
| 398 | 398 | private: |
| 399 | UserdataPtr (UserdataPtr const&); | |
| 400 | UserdataPtr operator= (UserdataPtr const&); | |
| 399 | UserdataPtr (UserdataPtr const&); | |
| 400 | UserdataPtr operator= (UserdataPtr const&); | |
| 401 | 401 | |
| 402 | 402 | private: |
| 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 | } | |
| 420 | 420 | |
| 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 | } | |
| 439 | 439 | |
| 440 | explicit UserdataPtr (void* const p) | |
| 441 | { | |
| 442 | m_p = p; | |
| 440 | explicit UserdataPtr (void* const p) | |
| 441 | { | |
| 442 | m_p = p; | |
| 443 | 443 | |
| 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 | } | |
| 448 | 448 | |
| 449 | 449 | public: |
| 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 | } | |
| 460 | 460 | |
| 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 | } | |
| 471 | 471 | }; |
| 472 | 472 | |
| 473 | 473 | //============================================================================ |
| r31374 | r31375 | |
| 481 | 481 | class UserdataShared : public Userdata |
| 482 | 482 | { |
| 483 | 483 | private: |
| 484 | UserdataShared (UserdataShared <C> const&); | |
| 485 | UserdataShared <C>& operator= (UserdataShared <C> const&); | |
| 484 | UserdataShared (UserdataShared <C> const&); | |
| 485 | UserdataShared <C>& operator= (UserdataShared <C> const&); | |
| 486 | 486 | |
| 487 | typedef typename TypeTraits::removeConst < | |
| 488 | typename ContainerTraits <C>::Type>::Type T; | |
| 487 | typedef typename TypeTraits::removeConst < | |
| 488 | typename ContainerTraits <C>::Type>::Type T; | |
| 489 | 489 | |
| 490 | ||
| 490 | C m_c; | |
| 491 | 491 | |
| 492 | 492 | private: |
| 493 | ~UserdataShared () | |
| 494 | { | |
| 495 | } | |
| 493 | ~UserdataShared () | |
| 494 | { | |
| 495 | } | |
| 496 | 496 | |
| 497 | 497 | public: |
| 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 | } | |
| 507 | 507 | |
| 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 | } | |
| 517 | 517 | }; |
| 518 | 518 | |
| 519 | 519 | //---------------------------------------------------------------------------- |
| r31374 | r31375 | |
| 525 | 525 | template <class C, bool makeObjectConst> |
| 526 | 526 | struct UserdataSharedHelper |
| 527 | 527 | { |
| 528 | typedef typename TypeTraits::removeConst < | |
| 529 | typename ContainerTraits <C>::Type>::Type T; | |
| 528 | typedef typename TypeTraits::removeConst < | |
| 529 | typename ContainerTraits <C>::Type>::Type T; | |
| 530 | 530 | |
| 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 | } | |
| 546 | 546 | |
| 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 | } | |
| 562 | 562 | }; |
| 563 | 563 | |
| 564 | 564 | // const objects |
| 565 | 565 | template <class C> |
| 566 | 566 | struct UserdataSharedHelper <C, true> |
| 567 | 567 | { |
| 568 | typedef typename TypeTraits::removeConst < | |
| 569 | typename ContainerTraits <C>::Type>::Type T; | |
| 568 | typedef typename TypeTraits::removeConst < | |
| 569 | typename ContainerTraits <C>::Type>::Type T; | |
| 570 | 570 | |
| 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 | } | |
| 586 | 586 | |
| 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 | } | |
| 602 | 602 | }; |
| 603 | 603 | |
| 604 | 604 | /** |
| r31374 | r31375 | |
| 613 | 613 | template <class C, bool byContainer> |
| 614 | 614 | struct StackHelper |
| 615 | 615 | { |
| 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 | } | |
| 621 | 621 | |
| 622 | typedef typename TypeTraits::removeConst < | |
| 623 | typename ContainerTraits <C>::Type>::Type T; | |
| 622 | typedef typename TypeTraits::removeConst < | |
| 623 | typename ContainerTraits <C>::Type>::Type T; | |
| 624 | 624 | |
| 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 | } | |
| 629 | 629 | }; |
| 630 | 630 | |
| 631 | 631 | /** |
| r31374 | r31375 | |
| 638 | 638 | template <class T> |
| 639 | 639 | struct StackHelper <T, false> |
| 640 | 640 | { |
| 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 | } | |
| 645 | 645 | |
| 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 | } | |
| 650 | 650 | }; |
| 651 | 651 | |
| 652 | 652 | //============================================================================== |
| r31374 | r31375 | |
| 658 | 658 | struct Stack |
| 659 | 659 | { |
| 660 | 660 | public: |
| 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 | } | |
| 666 | 666 | |
| 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 | } | |
| 672 | 672 | }; |
| 673 | 673 | |
| 674 | 674 | //------------------------------------------------------------------------------ |
| r31374 | r31375 | |
| 684 | 684 | template <class T> |
| 685 | 685 | struct Stack <T*> |
| 686 | 686 | { |
| 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 | } | |
| 691 | 691 | |
| 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 | } | |
| 696 | 696 | }; |
| 697 | 697 | |
| 698 | 698 | // Strips the const off the right side of * |
| 699 | 699 | template <class T> |
| 700 | 700 | struct Stack <T* const> |
| 701 | 701 | { |
| 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 | } | |
| 706 | 706 | |
| 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 | } | |
| 711 | 711 | }; |
| 712 | 712 | |
| 713 | 713 | // pointer to const |
| 714 | 714 | template <class T> |
| 715 | 715 | struct Stack <T const*> |
| 716 | 716 | { |
| 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 | } | |
| 721 | 721 | |
| 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 | } | |
| 726 | 726 | }; |
| 727 | 727 | |
| 728 | 728 | // Strips the const off the right side of * |
| 729 | 729 | template <class T> |
| 730 | 730 | struct Stack <T const* const> |
| 731 | 731 | { |
| 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 | } | |
| 736 | 736 | |
| 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 | } | |
| 741 | 741 | }; |
| 742 | 742 | |
| 743 | 743 | // reference |
| 744 | 744 | template <class T> |
| 745 | 745 | struct Stack <T&> |
| 746 | 746 | { |
| 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 | } | |
| 751 | 751 | |
| 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 | } | |
| 759 | 759 | }; |
| 760 | 760 | |
| 761 | 761 | template <class C, bool byContainer> |
| 762 | 762 | struct RefStackHelper |
| 763 | 763 | { |
| 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; | |
| 771 | 765 | |
| 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 | } | |
| 774 | 771 | |
| 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 | } | |
| 779 | 779 | }; |
| 780 | 780 | |
| 781 | 781 | template <class T> |
| 782 | 782 | struct RefStackHelper <T, false> |
| 783 | 783 | { |
| 784 | typedef T const& return_type; | |
| 785 | ||
| 784 | typedef T const& return_type; | |
| 785 | ||
| 786 | 786 | static inline void push (lua_State* L, T const& t) |
| 787 | 787 | { |
| 788 | | |
| 788 | UserdataPtr::push (L, &t); | |
| 789 | 789 | } |
| 790 | 790 | |
| 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); | |
| 794 | 794 | |
| 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 | ||
| 800 | 800 | }; |
| 801 | 801 | |
| 802 | 802 | // reference to const |
| 803 | 803 | template <class T> |
| 804 | 804 | struct Stack <T const&> |
| 805 | 805 | { |
| 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; | |
| 812 | 807 | |
| 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 | } | |
| 817 | 817 | }; |
| r31374 | r31375 | |
|---|---|---|
| 1 | 1 | //------------------------------------------------------------------------------ |
| 2 | 2 | /* |
| 3 | 3 | https://github.com/vinniefalco/LuaBridge |
| 4 | ||
| 4 | ||
| 5 | 5 | Copyright 2012, Vinnie Falco <vinnie.falco@gmail.com> |
| 6 | 6 | |
| 7 | 7 | License: The MIT License (http://www.opensource.org/licenses/mit-license.php) |
| r31374 | r31375 | |
| 31 | 31 | class Iterator |
| 32 | 32 | { |
| 33 | 33 | private: |
| 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; | |
| 38 | 38 | |
| 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 | } | |
| 55 | 55 | |
| 56 | 56 | public: |
| 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 | } | |
| 65 | 65 | |
| 66 | lua_State* state () const | |
| 67 | { | |
| 68 | return m_L; | |
| 69 | } | |
| 66 | lua_State* state () const | |
| 67 | { | |
| 68 | return m_L; | |
| 69 | } | |
| 70 | 70 | |
| 71 | LuaRef operator* () const | |
| 72 | { | |
| 73 | return m_value; | |
| 74 | } | |
| 71 | LuaRef operator* () const | |
| 72 | { | |
| 73 | return m_value; | |
| 74 | } | |
| 75 | 75 | |
| 76 | LuaRef operator-> () const | |
| 77 | { | |
| 78 | return m_value; | |
| 79 | } | |
| 76 | LuaRef operator-> () const | |
| 77 | { | |
| 78 | return m_value; | |
| 79 | } | |
| 80 | 80 | |
| 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 | } | |
| 94 | 94 | |
| 95 | inline bool isNil () const | |
| 96 | { | |
| 97 | return m_key.isNil (); | |
| 98 | } | |
| 95 | inline bool isNil () const | |
| 96 | { | |
| 97 | return m_key.isNil (); | |
| 98 | } | |
| 99 | 99 | |
| 100 | inline LuaRef key () const | |
| 101 | { | |
| 102 | return m_key; | |
| 103 | } | |
| 100 | inline LuaRef key () const | |
| 101 | { | |
| 102 | return m_key; | |
| 103 | } | |
| 104 | 104 | |
| 105 | inline LuaRef value () const | |
| 106 | { | |
| 107 | return m_value; | |
| 108 | } | |
| 105 | inline LuaRef value () const | |
| 106 | { | |
| 107 | return m_value; | |
| 108 | } | |
| 109 | 109 | |
| 110 | 110 | private: |
| 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); | |
| 113 | 113 | }; |
| 114 |
| r31374 | r31375 | |
|---|---|---|
| 1 | 1 | //------------------------------------------------------------------------------ |
| 2 | 2 | /* |
| 3 | 3 | https://github.com/vinniefalco/LuaBridge |
| 4 | ||
| 4 | ||
| 5 | 5 | Copyright 2012, Vinnie Falco <vinnie.falco@gmail.com> |
| 6 | 6 | |
| 7 | 7 | License: The MIT License (http://www.opensource.org/licenses/mit-license.php) |
| r31374 | r31375 | |
| 30 | 30 | // |
| 31 | 31 | struct CFunc |
| 32 | 32 | { |
| 33 | //---------------------------------------------------------------------------- | |
| 34 | /** | |
| 35 | __index metamethod for a namespace or class static members. | |
| 33 | //---------------------------------------------------------------------------- | |
| 34 | /** | |
| 35 | __index metamethod for a namespace or class static members. | |
| 36 | 36 | |
| 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 | } | |
| 78 | 78 | |
| 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 | } | |
| 94 | 94 | |
| 95 | return result; | |
| 96 | } | |
| 95 | return result; | |
| 96 | } | |
| 97 | 97 | |
| 98 | //---------------------------------------------------------------------------- | |
| 99 | /** | |
| 100 | __newindex metamethod for a namespace or class static members. | |
| 98 | //---------------------------------------------------------------------------- | |
| 99 | /** | |
| 100 | __newindex metamethod for a namespace or class static members. | |
| 101 | 101 | |
| 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 | } | |
| 130 | 130 | |
| 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 | } | |
| 144 | 144 | |
| 145 | return result; | |
| 146 | } | |
| 145 | return result; | |
| 146 | } | |
| 147 | 147 | |
| 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. | |
| 151 | 151 | |
| 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; | |
| 159 | 157 | |
| 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"; | |
| 166 | 159 | |
| 167 | This is used for global variables or class static data members. | |
| 160 | return luaL_error (L, s.c_str ()); | |
| 161 | } | |
| 168 | 162 | |
| 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. | |
| 180 | 166 | |
| 181 | //---------------------------------------------------------------------------- | |
| 182 | /** | |
| 183 | lua_CFunction to set a variable. | |
| 167 | This is used for global variables or class static data members. | |
| 184 | 168 | |
| 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 | } | |
| 186 | 180 | |
| 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. | |
| 198 | 184 | |
| 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. | |
| 202 | 186 | |
| 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 | } | |
| 205 | 198 | |
| 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. | |
| 223 | 202 | |
| 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. | |
| 227 | 205 | |
| 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 | }; | |
| 230 | 223 | |
| 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. | |
| 247 | 227 | |
| 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. | |
| 251 | 230 | |
| 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 | }; | |
| 261 | 247 | |
| 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. | |
| 273 | 251 | |
| 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; | |
| 280 | 261 | |
| 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 | }; | |
| 292 | 273 | |
| 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; | |
| 296 | 280 | |
| 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 | }; | |
| 305 | 292 | |
| 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. | |
| 317 | 296 | |
| 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; | |
| 323 | 305 | |
| 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 | }; | |
| 335 | 317 | |
| 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; | |
| 339 | 323 | |
| 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 | }; | |
| 356 | 335 | |
| 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. | |
| 370 | 339 | |
| 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 | }; | |
| 372 | 356 | |
| 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 | }; | |
| 374 | 370 | |
| 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 | //-------------------------------------------------------------------------- | |
| 387 | 372 | |
| 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 | |
| 398 | 374 | |
| 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 | }; | |
| 410 | 387 | |
| 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 | }; | |
| 414 | 398 | |
| 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 | } | |
| 426 | 410 | |
| 427 | //-------------------------------------------------------------------------- | |
| 428 | /** | |
| 429 | lua_CFunction to set a class data member. | |
| 411 | //-------------------------------------------------------------------------- | |
| 412 | /** | |
| 413 | lua_CFunction to get a class data member. | |
| 430 | 414 | |
| 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 | } | |
| 442 | 442 | }; |
| r31374 | r31375 | |
|---|---|---|
| 1 | 1 | //------------------------------------------------------------------------------ |
| 2 | 2 | /* |
| 3 | 3 | https://github.com/vinniefalco/LuaBridge |
| 4 | ||
| 4 | ||
| 5 | 5 | Copyright 2012, Vinnie Falco <vinnie.falco@gmail.com> |
| 6 | 6 | Copyright 2007, Nathan Reed |
| 7 | 7 | |
| r31374 | r31375 | |
| 35 | 35 | class Namespace |
| 36 | 36 | { |
| 37 | 37 | private: |
| 38 | ||
| 38 | Namespace& operator= (Namespace const& other); | |
| 39 | 39 | |
| 40 | lua_State* const L; | |
| 41 | int mutable m_stackSize; | |
| 40 | lua_State* const L; | |
| 41 | int mutable m_stackSize; | |
| 42 | 42 | |
| 43 | 43 | private: |
| 44 | //============================================================================ | |
| 45 | /** | |
| 46 | Error reporting. | |
| 44 | //============================================================================ | |
| 45 | /** | |
| 46 | Error reporting. | |
| 47 | 47 | |
| 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 | */ | |
| 50 | 50 | #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; | |
| 55 | 55 | |
| 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 | } | |
| 72 | 72 | |
| 73 | ||
| 73 | s = s + message; | |
| 74 | 74 | |
| 75 | return luaL_error (L, s.c_str ()); | |
| 76 | } | |
| 75 | return luaL_error (L, s.c_str ()); | |
| 76 | } | |
| 77 | 77 | #endif |
| 78 | 78 | |
| 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 | } | |
| 95 | 95 | |
| 96 | 96 | private: |
| 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); | |
| 104 | 104 | |
| 105 | protected: | |
| 106 | friend class Namespace; | |
| 105 | protected: | |
| 106 | friend class Namespace; | |
| 107 | 107 | |
| 108 | lua_State* const L; | |
| 109 | int mutable m_stackSize; | |
| 108 | lua_State* const L; | |
| 109 | int mutable m_stackSize; | |
| 110 | 110 | |
| 111 | protected: | |
| 112 | //-------------------------------------------------------------------------- | |
| 113 | /** | |
| 114 | __index metamethod for a class. | |
| 111 | protected: | |
| 112 | //-------------------------------------------------------------------------- | |
| 113 | /** | |
| 114 | __index metamethod for a class. | |
| 115 | 115 | |
| 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. | |
| 119 | 119 | |
| 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; | |
| 126 | 126 | |
| 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 | } | |
| 148 | 148 | |
| 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); | |
| 170 | 170 | |
| 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); | |
| 178 | 178 | |
| 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 | } | |
| 182 | 182 | |
| 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); | |
| 199 | 199 | |
| 200 | throw std::logic_error ("__parent is not a table"); | |
| 201 | } | |
| 202 | } | |
| 200 | throw std::logic_error ("__parent is not a table"); | |
| 201 | } | |
| 202 | } | |
| 203 | 203 | |
| 204 | return result; | |
| 205 | } | |
| 204 | return result; | |
| 205 | } | |
| 206 | 206 | |
| 207 | //-------------------------------------------------------------------------- | |
| 208 | /** | |
| 209 | __newindex metamethod for classes. | |
| 207 | //-------------------------------------------------------------------------- | |
| 208 | /** | |
| 209 | __newindex metamethod for classes. | |
| 210 | 210 | |
| 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; | |
| 217 | 217 | |
| 218 | ||
| 218 | lua_getmetatable (L, 1); | |
| 219 | 219 | |
| 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); | |
| 241 | 241 | |
| 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 | } | |
| 252 | 252 | |
| 253 | return result; | |
| 254 | } | |
| 253 | return result; | |
| 254 | } | |
| 255 | 255 | |
| 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"); | |
| 282 | 275 | |
| 283 | //-------------------------------------------------------------------------- | |
| 284 | /** | |
| 285 | Create the class table. | |
| 276 | if (Security::hideMetatables ()) | |
| 277 | { | |
| 278 | lua_pushnil (L); | |
| 279 | rawsetfield (L, -2, "__metatable"); | |
| 280 | } | |
| 281 | } | |
| 286 | 282 | |
| 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. | |
| 306 | 286 | |
| 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"); | |
| 309 | 306 | |
| 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 | |
| 312 | 309 | |
| 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 | |
| 319 | 312 | |
| 320 | //-------------------------------------------------------------------------- | |
| 321 | /** | |
| 322 | Create the static table. | |
| 313 | if (Security::hideMetatables ()) | |
| 314 | { | |
| 315 | lua_pushnil (L); | |
| 316 | rawsetfield (L, -2, "__metatable"); | |
| 317 | } | |
| 318 | } | |
| 323 | 319 | |
| 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. | |
| 337 | 323 | |
| 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 | ||
| 338 | 338 | #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"); | |
| 342 | 342 | #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"); | |
| 351 | 351 | |
| 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 | |
| 354 | 354 | |
| 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 | } | |
| 361 | 361 | |
| 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 | } | |
| 375 | 375 | |
| 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 | } | |
| 387 | 387 | |
| 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 | } | |
| 404 | 404 | |
| 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 | } | |
| 412 | 412 | |
| 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 | } | |
| 424 | 424 | |
| 425 | ~ClassBase () | |
| 426 | { | |
| 427 | pop (m_stackSize); | |
| 428 | } | |
| 429 | }; | |
| 425 | ~ClassBase () | |
| 426 | { | |
| 427 | pop (m_stackSize); | |
| 428 | } | |
| 429 | }; | |
| 430 | 430 | |
| 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. | |
| 438 | 438 | |
| 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; | |
| 457 | 457 | |
| 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); | |
| 464 | 460 | |
| 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); | |
| 468 | 464 | |
| 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"); | |
| 472 | 468 | |
| 473 | createStaticTable (name); | |
| 469 | createClassTable (name); | |
| 470 | lua_pushcfunction (L, &CFunc::gcMetaMethod <T>); | |
| 471 | rawsetfield (L, -2, "__gc"); | |
| 474 | 472 | |
| 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); | |
| 487 | 474 | |
| 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"); | |
| 493 | 487 | |
| 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 | } | |
| 503 | 493 | |
| 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; | |
| 505 | 503 | |
| 506 | createConstTable (name); | |
| 507 | lua_pushcfunction (L, &CFunc::gcMetaMethod <T>); | |
| 508 | rawsetfield (L, -2, "__gc"); | |
| 504 | assert (lua_istable (L, -1)); | |
| 509 | 505 | |
| 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"); | |
| 513 | 509 | |
| 514 | createStaticTable (name); | |
| 510 | createClassTable (name); | |
| 511 | lua_pushcfunction (L, &CFunc::gcMetaMethod <T>); | |
| 512 | rawsetfield (L, -2, "__gc"); | |
| 515 | 513 | |
| 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); | |
| 522 | 515 | |
| 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)); | |
| 526 | 522 | |
| 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"); | |
| 534 | 526 | |
| 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 | } | |
| 543 | 534 | |
| 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 | } | |
| 552 | 543 | |
| 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)); | |
| 559 | 552 | |
| 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); | |
| 574 | 559 | |
| 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); | |
| 577 | 574 | |
| 578 | //-------------------------------------------------------------------------- | |
| 579 | /** | |
| 580 | Add or replace a static property member. | |
| 575 | return *this; | |
| 576 | } | |
| 581 | 577 | |
| 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. | |
| 591 | 581 | |
| 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); | |
| 598 | 589 | |
| 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)); | |
| 613 | 591 | |
| 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); | |
| 616 | 598 | |
| 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); | |
| 627 | 613 | |
| 628 | return *this; | |
| 629 | } | |
| 614 | return *this; | |
| 615 | } | |
| 630 | 616 | |
| 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); | |
| 641 | 627 | |
| 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 | } | |
| 650 | 630 | |
| 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 | } | |
| 662 | 641 | |
| 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; | |
| 673 | 650 | |
| 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 | } | |
| 676 | 662 | |
| 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 | } | |
| 696 | 673 | |
| 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 | } | |
| 707 | 676 | |
| 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 | } | |
| 710 | 696 | |
| 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 | } | |
| 725 | 707 | |
| 726 | return *this; | |
| 727 | } | |
| 708 | return *this; | |
| 709 | } | |
| 728 | 710 | |
| 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); | |
| 732 | 725 | |
| 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 | } | |
| 736 | 728 | |
| 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. | |
| 755 | 732 | |
| 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. | |
| 767 | 736 | |
| 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 | } | |
| 770 | 755 | |
| 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 | } | |
| 785 | 767 | |
| 786 | return *this; | |
| 787 | } | |
| 768 | return *this; | |
| 769 | } | |
| 788 | 770 | |
| 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); | |
| 799 | 785 | |
| 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 | } | |
| 811 | 788 | |
| 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 | } | |
| 814 | 799 | |
| 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 | |
| 828 | 811 | |
| 829 | return *this; | |
| 830 | } | |
| 812 | return *this; | |
| 813 | } | |
| 831 | 814 | |
| 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 | |
| 835 | 828 | |
| 836 | The primary Constructor is invoked when calling the class type table | |
| 837 | like a function. | |
| 829 | return *this; | |
| 830 | } | |
| 838 | 831 | |
| 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. | |
| 849 | 835 | |
| 850 | return *this; | |
| 851 | } | |
| 836 | The primary Constructor is invoked when calling the class type table | |
| 837 | like a function. | |
| 852 | 838 | |
| 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"); | |
| 859 | 849 | |
| 860 | return *this; | |
| 861 | } | |
| 862 | }; | |
| 850 | return *this; | |
| 851 | } | |
| 863 | 852 | |
| 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 | ||
| 864 | 864 | private: |
| 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 | } | |
| 876 | 876 | |
| 877 | //---------------------------------------------------------------------------- | |
| 878 | /** | |
| 879 | Open a namespace for registrations. | |
| 877 | //---------------------------------------------------------------------------- | |
| 878 | /** | |
| 879 | Open a namespace for registrations. | |
| 880 | 880 | |
| 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; | |
| 890 | 890 | |
| 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); | |
| 896 | 896 | |
| 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); | |
| 910 | 910 | #if 0 |
| 911 | lua_pushcfunction (L, &tostringMetaMethod); | |
| 912 | rawsetfield (L, -2, "__tostring"); | |
| 911 | lua_pushcfunction (L, &tostringMetaMethod); | |
| 912 | rawsetfield (L, -2, "__tostring"); | |
| 913 | 913 | #endif |
| 914 | } | |
| 915 | } | |
| 914 | } | |
| 915 | } | |
| 916 | 916 | |
| 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); | |
| 928 | 928 | |
| 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 | } | |
| 934 | 934 | |
| 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 | } | |
| 947 | 947 | |
| 948 | 948 | public: |
| 949 | //---------------------------------------------------------------------------- | |
| 950 | /** | |
| 951 | Copy Constructor. | |
| 949 | //---------------------------------------------------------------------------- | |
| 950 | /** | |
| 951 | Copy Constructor. | |
| 952 | 952 | |
| 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 | } | |
| 962 | 962 | |
| 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 | } | |
| 971 | 971 | |
| 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 | } | |
| 980 | 980 | |
| 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 | } | |
| 989 | 989 | |
| 990 | //---------------------------------------------------------------------------- | |
| 991 | /** | |
| 992 | Continue namespace registration in the parent. | |
| 990 | //---------------------------------------------------------------------------- | |
| 991 | /** | |
| 992 | Continue namespace registration in the parent. | |
| 993 | 993 | |
| 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 | } | |
| 1000 | 1000 | |
| 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)); | |
| 1009 | 1009 | |
| 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); | |
| 1016 | 1016 | |
| 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); | |
| 1031 | 1031 | |
| 1032 | return *this; | |
| 1033 | } | |
| 1034 | ||
| 1035 | //---------------------------------------------------------------------------- | |
| 1036 | /** | |
| 1037 | Add or replace a property. | |
| 1032 | return *this; | |
| 1033 | } | |
| 1038 | 1034 | |
| 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. | |
| 1045 | 1038 | |
| 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)); | |
| 1053 | 1045 | |
| 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); | |
| 1069 | 1053 | |
| 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); | |
| 1072 | 1069 | |
| 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 | } | |
| 1081 | 1072 | |
| 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)); | |
| 1085 | 1081 | |
| 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); | |
| 1088 | 1085 | |
| 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 | } | |
| 1097 | 1088 | |
| 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); | |
| 1100 | 1097 | |
| 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 | } | |
| 1110 | 1100 | |
| 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 | } | |
| 1114 | 1110 | |
| 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 | } | |
| 1123 | 1123 | }; |
| 1124 | 1124 | |
| 1125 | 1125 | //------------------------------------------------------------------------------ |
| r31374 | r31375 | |
| 1132 | 1132 | */ |
| 1133 | 1133 | inline Namespace getGlobalNamespace (lua_State* L) |
| 1134 | 1134 | { |
| 1135 | ||
| 1135 | return Namespace::getGlobalNamespace (L); | |
| 1136 | 1136 | } |
| r31374 | r31375 | |
|---|---|---|
| 1 | 1 | //------------------------------------------------------------------------------ |
| 2 | 2 | /* |
| 3 | 3 | https://github.com/vinniefalco/LuaBridge |
| 4 | ||
| 4 | ||
| 5 | 5 | Copyright 2012, Vinnie Falco <vinnie.falco@gmail.com> |
| 6 | 6 | Copyright 2007, Nathan Reed |
| 7 | 7 | |
| r31374 | r31375 | |
| 26 | 26 | SOFTWARE. |
| 27 | 27 | |
| 28 | 28 | This file incorporates work covered by the following copyright and |
| 29 | permission notice: | |
| 29 | permission notice: | |
| 30 | 30 | |
| 31 | 31 | The Loki Library |
| 32 | 32 | Copyright (c) 2001 by Andrei Alexandrescu |
| 33 | 33 | 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 | |
| 35 | 35 | 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 | |
| 39 | 39 | 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" | |
| 42 | 42 | without express or implied warranty. |
| 43 | 43 | */ |
| 44 | 44 | //============================================================================== |
| r31374 | r31375 | |
| 59 | 59 | template <typename List> |
| 60 | 60 | struct TypeListValues |
| 61 | 61 | { |
| 62 | static std::string const tostring (bool) | |
| 63 | { | |
| 64 | return ""; | |
| 65 | } | |
| 62 | static std::string const tostring (bool) | |
| 63 | { | |
| 64 | return ""; | |
| 65 | } | |
| 66 | 66 | }; |
| 67 | 67 | |
| 68 | 68 | /** |
| r31374 | r31375 | |
| 71 | 71 | template <typename Head, typename Tail> |
| 72 | 72 | struct TypeListValues <TypeList <Head, Tail> > |
| 73 | 73 | { |
| 74 | Head hd; | |
| 75 | TypeListValues <Tail> tl; | |
| 74 | Head hd; | |
| 75 | TypeListValues <Tail> tl; | |
| 76 | 76 | |
| 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 | } | |
| 81 | 81 | |
| 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; | |
| 85 | 85 | |
| 86 | if (comma) | |
| 87 | s = ", "; | |
| 86 | if (comma) | |
| 87 | s = ", "; | |
| 88 | 88 | |
| 89 | ||
| 89 | s = s + typeid (Head).name (); | |
| 90 | 90 | |
| 91 | return s + TypeListValues <Tail>::tostring (true); | |
| 92 | } | |
| 91 | return s + TypeListValues <Tail>::tostring (true); | |
| 92 | } | |
| 93 | 93 | }; |
| 94 | 94 | |
| 95 | 95 | // Specializations of type/value list for head types that are references and |
| r31374 | r31375 | |
| 99 | 99 | template <typename Head, typename Tail> |
| 100 | 100 | struct TypeListValues <TypeList <Head&, Tail> > |
| 101 | 101 | { |
| 102 | Head hd; | |
| 103 | TypeListValues <Tail> tl; | |
| 102 | Head hd; | |
| 103 | TypeListValues <Tail> tl; | |
| 104 | 104 | |
| 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 | } | |
| 109 | 109 | |
| 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; | |
| 113 | 113 | |
| 114 | if (comma) | |
| 115 | s = ", "; | |
| 114 | if (comma) | |
| 115 | s = ", "; | |
| 116 | 116 | |
| 117 | ||
| 117 | s = s + typeid (Head).name () + "&"; | |
| 118 | 118 | |
| 119 | return s + TypeListValues <Tail>::tostring (true); | |
| 120 | } | |
| 119 | return s + TypeListValues <Tail>::tostring (true); | |
| 120 | } | |
| 121 | 121 | }; |
| 122 | 122 | |
| 123 | 123 | template <typename Head, typename Tail> |
| 124 | 124 | struct TypeListValues <TypeList <Head const&, Tail> > |
| 125 | 125 | { |
| 126 | Head hd; | |
| 127 | TypeListValues <Tail> tl; | |
| 126 | Head hd; | |
| 127 | TypeListValues <Tail> tl; | |
| 128 | 128 | |
| 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 | } | |
| 133 | 133 | |
| 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; | |
| 137 | 137 | |
| 138 | if (comma) | |
| 139 | s = ", "; | |
| 138 | if (comma) | |
| 139 | s = ", "; | |
| 140 | 140 | |
| 141 | ||
| 141 | s = s + typeid (Head).name () + " const&"; | |
| 142 | 142 | |
| 143 | return s + TypeListValues <Tail>::tostring (true); | |
| 144 | } | |
| 143 | return s + TypeListValues <Tail>::tostring (true); | |
| 144 | } | |
| 145 | 145 | }; |
| 146 | 146 | |
| 147 | 147 | //============================================================================== |
| r31374 | r31375 | |
| 157 | 157 | template <int Start> |
| 158 | 158 | struct ArgList <None, Start> : public TypeListValues <None> |
| 159 | 159 | { |
| 160 | ArgList (lua_State*) | |
| 161 | { | |
| 162 | } | |
| 160 | ArgList (lua_State*) | |
| 161 | { | |
| 162 | } | |
| 163 | 163 | }; |
| 164 | 164 | |
| 165 | 165 | template <typename Head, typename Tail, int Start> |
| 166 | 166 | struct ArgList <TypeList <Head, Tail>, Start> |
| 167 | ||
| 167 | : public TypeListValues <TypeList <Head, Tail> > | |
| 168 | 168 | { |
| 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 | } | |
| 174 | 174 | }; |
| r31374 | r31375 | |
|---|---|---|
| 1 | 1 | //------------------------------------------------------------------------------ |
| 2 | 2 | /* |
| 3 | 3 | https://github.com/vinniefalco/LuaBridge |
| 4 | ||
| 4 | ||
| 5 | 5 | Copyright 2012, Vinnie Falco <vinnie.falco@gmail.com> |
| 6 | 6 | Copyright 2008, Nigel Atkinson <suprapilot+LuaCode@gmail.com> |
| 7 | 7 | |
| r31374 | r31375 | |
| 51 | 51 | class LuaRef |
| 52 | 52 | { |
| 53 | 53 | private: |
| 54 | class Proxy; | |
| 55 | friend struct Stack <Proxy>; | |
| 54 | class Proxy; | |
| 55 | friend struct Stack <Proxy>; | |
| 56 | 56 | |
| 57 | //---------------------------------------------------------------------------- | |
| 58 | /** | |
| 59 | Pop the Lua stack. | |
| 57 | //---------------------------------------------------------------------------- | |
| 58 | /** | |
| 59 | Pop the Lua stack. | |
| 60 | 60 | |
| 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: | |
| 64 | 64 | |
| 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 | } | |
| 72 | 72 | |
| 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. | |
| 79 | 79 | |
| 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 | } | |
| 87 | 87 | |
| 88 | ~StackPop () | |
| 89 | { | |
| 90 | lua_pop (m_L, m_count); | |
| 91 | } | |
| 88 | ~StackPop () | |
| 89 | { | |
| 90 | lua_pop (m_L, m_count); | |
| 91 | } | |
| 92 | 92 | |
| 93 | private: | |
| 94 | lua_State* m_L; | |
| 95 | int m_count; | |
| 96 | }; | |
| 93 | private: | |
| 94 | lua_State* m_L; | |
| 95 | int m_count; | |
| 96 | }; | |
| 97 | 97 | |
| 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; | |
| 108 | 108 | |
| 109 | public: | |
| 110 | //-------------------------------------------------------------------------- | |
| 111 | /** | |
| 112 | Construct a Proxy from a table value. | |
| 109 | public: | |
| 110 | //-------------------------------------------------------------------------- | |
| 111 | /** | |
| 112 | Construct a Proxy from a table value. | |
| 113 | 113 | |
| 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 | } | |
| 123 | 123 | |
| 124 | //-------------------------------------------------------------------------- | |
| 125 | /** | |
| 126 | Create a Proxy via copy constructor. | |
| 124 | //-------------------------------------------------------------------------- | |
| 125 | /** | |
| 126 | Create a Proxy via copy constructor. | |
| 127 | 127 | |
| 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); | |
| 140 | 140 | |
| 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 | } | |
| 144 | 144 | |
| 145 | //-------------------------------------------------------------------------- | |
| 146 | /** | |
| 147 | Destroy the proxy. | |
| 145 | //-------------------------------------------------------------------------- | |
| 146 | /** | |
| 147 | Destroy the proxy. | |
| 148 | 148 | |
| 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 | } | |
| 155 | 155 | |
| 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 | } | |
| 165 | 165 | |
| 166 | //-------------------------------------------------------------------------- | |
| 167 | /** | |
| 168 | Assign a new value to this table key. | |
| 166 | //-------------------------------------------------------------------------- | |
| 167 | /** | |
| 168 | Assign a new value to this table key. | |
| 169 | 169 | |
| 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 | } | |
| 182 | 182 | |
| 183 | //-------------------------------------------------------------------------- | |
| 184 | /** | |
| 185 | Assign a new value to this table key. | |
| 183 | //-------------------------------------------------------------------------- | |
| 184 | /** | |
| 185 | Assign a new value to this table key. | |
| 186 | 186 | |
| 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 | } | |
| 199 | 199 | |
| 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. | |
| 203 | 203 | |
| 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 | } | |
| 210 | 210 | |
| 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 | } | |
| 223 | 223 | |
| 224 | //-------------------------------------------------------------------------- | |
| 225 | /** | |
| 226 | Determine the object type. | |
| 224 | //-------------------------------------------------------------------------- | |
| 225 | /** | |
| 226 | Determine the object type. | |
| 227 | 227 | |
| 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 | } | |
| 238 | 238 | |
| 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; } | |
| 247 | 247 | |
| 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); | |
| 257 | 257 | |
| 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 | } | |
| 263 | 263 | |
| 264 | //-------------------------------------------------------------------------- | |
| 265 | /** | |
| 266 | Universal implicit conversion operator. | |
| 264 | //-------------------------------------------------------------------------- | |
| 265 | /** | |
| 266 | Universal implicit conversion operator. | |
| 267 | 267 | |
| 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: | |
| 270 | 270 | |
| 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 | |
| 273 | 273 | |
| 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 | } | |
| 288 | 288 | |
| 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 | } | |
| 302 | 302 | |
| 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 | } | |
| 311 | 311 | |
| 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 | } | |
| 320 | 320 | |
| 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 | } | |
| 329 | 329 | |
| 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 | } | |
| 338 | 338 | |
| 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 | /** @} */ | |
| 348 | 348 | |
| 349 | //-------------------------------------------------------------------------- | |
| 350 | /** | |
| 351 | Access a table value using a key. | |
| 349 | //-------------------------------------------------------------------------- | |
| 350 | /** | |
| 351 | Access a table value using a key. | |
| 352 | 352 | |
| 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 | } | |
| 360 | 360 | |
| 361 | //-------------------------------------------------------------------------- | |
| 362 | /** | |
| 363 | Access a table value using a key. | |
| 361 | //-------------------------------------------------------------------------- | |
| 362 | /** | |
| 363 | Access a table value using a key. | |
| 364 | 364 | |
| 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 | } | |
| 377 | 377 | |
| 378 | //-------------------------------------------------------------------------- | |
| 379 | /** | |
| 380 | Append a value to the table. | |
| 378 | //-------------------------------------------------------------------------- | |
| 379 | /** | |
| 380 | Append a value to the table. | |
| 381 | 381 | |
| 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 | } | |
| 392 | 392 | |
| 393 | //-------------------------------------------------------------------------- | |
| 394 | /** | |
| 395 | Call the length operator. | |
| 393 | //-------------------------------------------------------------------------- | |
| 394 | /** | |
| 395 | Call the length operator. | |
| 396 | 396 | |
| 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 | } | |
| 405 | 405 | |
| 406 | //-------------------------------------------------------------------------- | |
| 407 | /** | |
| 408 | Call Lua code. | |
| 406 | //-------------------------------------------------------------------------- | |
| 407 | /** | |
| 408 | Call Lua code. | |
| 409 | 409 | |
| 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 | } | |
| 421 | 421 | |
| 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 | } | |
| 430 | 430 | |
| 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 | } | |
| 440 | 440 | |
| 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 | } | |
| 451 | 451 | |
| 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 | } | |
| 463 | 463 | |
| 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 | } | |
| 476 | 476 | |
| 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 | } | |
| 490 | 490 | |
| 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 | } | |
| 505 | 505 | |
| 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 | /** @} */ | |
| 522 | 522 | |
| 523 | //========================================================================== | |
| 524 | }; | |
| 523 | //========================================================================== | |
| 524 | }; | |
| 525 | 525 | |
| 526 | 526 | private: |
| 527 | ||
| 527 | friend struct Stack <LuaRef>; | |
| 528 | 528 | |
| 529 | //---------------------------------------------------------------------------- | |
| 530 | /** | |
| 531 | Type tag for stack construction. | |
| 532 | */ | |
| 533 | struct FromStack { }; | |
| 529 | //---------------------------------------------------------------------------- | |
| 530 | /** | |
| 531 | Type tag for stack construction. | |
| 532 | */ | |
| 533 | struct FromStack { }; | |
| 534 | 534 | |
| 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. | |
| 538 | 538 | |
| 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. | |
| 541 | 541 | |
| 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 | } | |
| 549 | 549 | |
| 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. | |
| 553 | 553 | |
| 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. | |
| 556 | 556 | |
| 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 | } | |
| 565 | 565 | |
| 566 | ||
| 566 | //---------------------------------------------------------------------------- | |
| 567 | 567 | |
| 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 | } | |
| 574 | 574 | |
| 575 | //---------------------------------------------------------------------------- | |
| 576 | /** | |
| 577 | Create a reference to this ref. | |
| 575 | //---------------------------------------------------------------------------- | |
| 576 | /** | |
| 577 | Create a reference to this ref. | |
| 578 | 578 | |
| 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 | } | |
| 593 | 593 | |
| 594 | 594 | public: |
| 595 | //---------------------------------------------------------------------------- | |
| 596 | /** | |
| 597 | Create a nil reference. | |
| 595 | //---------------------------------------------------------------------------- | |
| 596 | /** | |
| 597 | Create a nil reference. | |
| 598 | 598 | |
| 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 | } | |
| 606 | 606 | |
| 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 | } | |
| 618 | 618 | |
| 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 | } | |
| 628 | 628 | |
| 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 | } | |
| 638 | 638 | |
| 639 | //---------------------------------------------------------------------------- | |
| 640 | /** | |
| 641 | Destroy a reference. | |
| 639 | //---------------------------------------------------------------------------- | |
| 640 | /** | |
| 641 | Destroy a reference. | |
| 642 | 642 | |
| 643 | ||
| 643 | The corresponding Lua registry reference will be released. | |
| 644 | 644 | |
| 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 | } | |
| 653 | 653 | |
| 654 | //---------------------------------------------------------------------------- | |
| 655 | /** | |
| 656 | Return a LuaRef from a stack item. | |
| 654 | //---------------------------------------------------------------------------- | |
| 655 | /** | |
| 656 | Return a LuaRef from a stack item. | |
| 657 | 657 | |
| 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 | } | |
| 665 | 665 | |
| 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. | |
| 669 | 669 | |
| 670 | ||
| 670 | It is also possible to use the free function `newTable`. | |
| 671 | 671 | |
| 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 | } | |
| 679 | 679 | |
| 680 | //---------------------------------------------------------------------------- | |
| 681 | /** | |
| 682 | Return a reference to a named global. | |
| 680 | //---------------------------------------------------------------------------- | |
| 681 | /** | |
| 682 | Return a reference to a named global. | |
| 683 | 683 | |
| 684 | ||
| 684 | It is also possible to use the free function `getGlobal`. | |
| 685 | 685 | |
| 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 | } | |
| 693 | 693 | |
| 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 | } | |
| 706 | 706 | |
| 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 | } | |
| 719 | 719 | |
| 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 | } | |
| 733 | 733 | |
| 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. | |
| 737 | 737 | |
| 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; | |
| 747 | 747 | |
| 748 | case LUA_TNUMBER: | |
| 749 | os << cast <lua_Number> (); | |
| 750 | break; | |
| 748 | case LUA_TNUMBER: | |
| 749 | os << cast <lua_Number> (); | |
| 750 | break; | |
| 751 | 751 | |
| 752 | case LUA_TBOOLEAN: | |
| 753 | os << (cast <bool> () ? "true" : "false"); | |
| 754 | break; | |
| 752 | case LUA_TBOOLEAN: | |
| 753 | os << (cast <bool> () ? "true" : "false"); | |
| 754 | break; | |
| 755 | 755 | |
| 756 | case LUA_TSTRING: | |
| 757 | os << '"' << cast <std::string> () << '"'; | |
| 758 | break; | |
| 756 | case LUA_TSTRING: | |
| 757 | os << '"' << cast <std::string> () << '"'; | |
| 758 | break; | |
| 759 | 759 | |
| 760 | case LUA_TTABLE: | |
| 761 | os << "table: " << tostring(); | |
| 762 | break; | |
| 760 | case LUA_TTABLE: | |
| 761 | os << "table: " << tostring(); | |
| 762 | break; | |
| 763 | 763 | |
| 764 | case LUA_TFUNCTION: | |
| 765 | os << "function: " << tostring(); | |
| 766 | break; | |
| 764 | case LUA_TFUNCTION: | |
| 765 | os << "function: " << tostring(); | |
| 766 | break; | |
| 767 | 767 | |
| 768 | case LUA_TUSERDATA: | |
| 769 | os << "userdata: " << tostring(); | |
| 770 | break; | |
| 768 | case LUA_TUSERDATA: | |
| 769 | os << "userdata: " << tostring(); | |
| 770 | break; | |
| 771 | 771 | |
| 772 | case LUA_TTHREAD: | |
| 773 | os << "thread: " << tostring(); | |
| 774 | break; | |
| 772 | case LUA_TTHREAD: | |
| 773 | os << "thread: " << tostring(); | |
| 774 | break; | |
| 775 | 775 | |
| 776 | case LUA_TLIGHTUSERDATA: | |
| 777 | os << "lightuserdata: " << tostring(); | |
| 778 | break; | |
| 776 | case LUA_TLIGHTUSERDATA: | |
| 777 | os << "lightuserdata: " << tostring(); | |
| 778 | break; | |
| 779 | 779 | |
| 780 | default: | |
| 781 | os << "unknown"; | |
| 782 | break; | |
| 783 | } | |
| 784 | } | |
| 780 | default: | |
| 781 | os << "unknown"; | |
| 782 | break; | |
| 783 | } | |
| 784 | } | |
| 785 | 785 | |
| 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 | // | |
| 790 | 790 | |
| 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 | } | |
| 797 | 797 | |
| 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 | } | |
| 807 | 807 | |
| 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 | } | |
| 818 | 818 | |
| 819 | //---------------------------------------------------------------------------- | |
| 820 | /** | |
| 821 | Determine the object type. | |
| 819 | //---------------------------------------------------------------------------- | |
| 820 | /** | |
| 821 | Determine the object type. | |
| 822 | 822 | |
| 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 | } | |
| 839 | 839 | |
| 840 | return result; | |
| 841 | } | |
| 840 | return result; | |
| 841 | } | |
| 842 | 842 | |
| 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; } | |
| 845 | 845 | |
| 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 | /** @} */ | |
| 855 | 855 | |
| 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); | |
| 865 | 865 | |
| 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 | } | |
| 871 | 871 | |
| 872 | //---------------------------------------------------------------------------- | |
| 873 | /** | |
| 874 | Universal implicit conversion operator. | |
| 872 | //---------------------------------------------------------------------------- | |
| 873 | /** | |
| 874 | Universal implicit conversion operator. | |
| 875 | 875 | |
| 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: | |
| 878 | 878 | |
| 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 | |
| 881 | 881 | |
| 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 | } | |
| 896 | 896 | |
| 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 | } | |
| 910 | 910 | |
| 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 | } | |
| 919 | 919 | |
| 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 | } | |
| 928 | 928 | |
| 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 | } | |
| 937 | 937 | |
| 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 | } | |
| 946 | 946 | |
| 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 | /** @} */ | |
| 956 | 956 | |
| 957 | //---------------------------------------------------------------------------- | |
| 958 | /** | |
| 959 | Append a value to the table. | |
| 957 | //---------------------------------------------------------------------------- | |
| 958 | /** | |
| 959 | Append a value to the table. | |
| 960 | 960 | |
| 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 | } | |
| 971 | 971 | |
| 972 | //---------------------------------------------------------------------------- | |
| 973 | /** | |
| 974 | Call the length operator. | |
| 972 | //---------------------------------------------------------------------------- | |
| 973 | /** | |
| 974 | Call the length operator. | |
| 975 | 975 | |
| 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 | } | |
| 984 | 984 | |
| 985 | //---------------------------------------------------------------------------- | |
| 986 | /** | |
| 987 | Access a table value using a key. | |
| 985 | //---------------------------------------------------------------------------- | |
| 986 | /** | |
| 987 | Access a table value using a key. | |
| 988 | 988 | |
| 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 | } | |
| 997 | 997 | |
| 998 | //---------------------------------------------------------------------------- | |
| 999 | /** | |
| 1000 | Call Lua code. | |
| 998 | //---------------------------------------------------------------------------- | |
| 999 | /** | |
| 1000 | Call Lua code. | |
| 1001 | 1001 | |
| 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 | } | |
| 1013 | 1013 | |
| 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 | } | |
| 1022 | 1022 | |
| 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 | } | |
| 1032 | 1032 | |
| 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 | } | |
| 1043 | 1043 | |
| 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 | } | |
| 1055 | 1055 | |
| 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 | } | |
| 1068 | 1068 | |
| 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 | } | |
| 1082 | 1082 | |
| 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 | } | |
| 1097 | 1097 | |
| 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 | /** @} */ | |
| 1114 | 1114 | |
| 1115 | ||
| 1115 | //============================================================================ | |
| 1116 | 1116 | |
| 1117 | 1117 | private: |
| 1118 | lua_State* m_L; | |
| 1119 | int m_ref; | |
| 1118 | lua_State* m_L; | |
| 1119 | int m_ref; | |
| 1120 | 1120 | }; |
| 1121 | 1121 | |
| 1122 | 1122 | //------------------------------------------------------------------------------ |
| r31374 | r31375 | |
| 1127 | 1127 | struct Stack <Nil> |
| 1128 | 1128 | { |
| 1129 | 1129 | public: |
| 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 | } | |
| 1134 | 1134 | }; |
| 1135 | 1135 | |
| 1136 | 1136 | //------------------------------------------------------------------------------ |
| r31374 | r31375 | |
| 1141 | 1141 | struct Stack <LuaRef> |
| 1142 | 1142 | { |
| 1143 | 1143 | public: |
| 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 | } | |
| 1150 | 1150 | |
| 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 | } | |
| 1155 | 1155 | }; |
| 1156 | 1156 | |
| 1157 | 1157 | //------------------------------------------------------------------------------ |
| r31374 | r31375 | |
| 1162 | 1162 | struct Stack <LuaRef::Proxy> |
| 1163 | 1163 | { |
| 1164 | 1164 | public: |
| 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 | } | |
| 1171 | 1171 | }; |
| 1172 | 1172 | |
| 1173 | 1173 | //------------------------------------------------------------------------------ |
| r31374 | r31375 | |
| 1178 | 1178 | */ |
| 1179 | 1179 | inline LuaRef newTable (lua_State* L) |
| 1180 | 1180 | { |
| 1181 | ||
| 1181 | return LuaRef::newTable (L); | |
| 1182 | 1182 | } |
| 1183 | 1183 | |
| 1184 | 1184 | //------------------------------------------------------------------------------ |
| r31374 | r31375 | |
| 1189 | 1189 | */ |
| 1190 | 1190 | inline LuaRef getGlobal (lua_State *L, char const* name) |
| 1191 | 1191 | { |
| 1192 | ||
| 1192 | return LuaRef::getGlobal (L, name); | |
| 1193 | 1193 | } |
| 1194 | 1194 | |
| 1195 | 1195 | //------------------------------------------------------------------------------ |
| r31374 | r31375 | |
| 1200 | 1200 | */ |
| 1201 | 1201 | inline std::ostream& operator<< (std::ostream& os, LuaRef const& ref) |
| 1202 | 1202 | { |
| 1203 | ref.print (os); | |
| 1204 | return os; | |
| 1203 | ref.print (os); | |
| 1204 | return os; | |
| 1205 | 1205 | } |
| 1206 | 1206 | |
| 1207 | 1207 | //------------------------------------------------------------------------------ |
| r31374 | r31375 | |
| 1211 | 1211 | template<class T> |
| 1212 | 1212 | inline T LuaRef_cast(LuaRef const& lr) |
| 1213 | 1213 | { |
| 1214 | ||
| 1214 | return lr.cast<T>(); | |
| 1215 | 1215 | } |
| r31374 | r31375 | |
|---|---|---|
| 1 | 1 | //------------------------------------------------------------------------------ |
| 2 | 2 | /* |
| 3 | 3 | https://github.com/vinniefalco/LuaBridge |
| 4 | ||
| 4 | ||
| 5 | 5 | Copyright 2012, Vinnie Falco <vinnie.falco@gmail.com> |
| 6 | 6 | Copyright 2008, Nigel Atkinson <suprapilot+LuaCode@gmail.com> |
| 7 | 7 | |
| r31374 | r31375 | |
| 27 | 27 | */ |
| 28 | 28 | //============================================================================== |
| 29 | 29 | |
| 30 | class LuaException : public std::exception | |
| 30 | class LuaException : public std::exception | |
| 31 | 31 | { |
| 32 | 32 | private: |
| 33 | lua_State* m_L; | |
| 34 | std::string m_what; | |
| 33 | lua_State* m_L; | |
| 34 | std::string m_what; | |
| 35 | 35 | |
| 36 | 36 | public: |
| 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 | } | |
| 46 | 46 | |
| 47 | ||
| 47 | //---------------------------------------------------------------------------- | |
| 48 | 48 | |
| 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 | } | |
| 57 | 57 | |
| 58 | ||
| 58 | //---------------------------------------------------------------------------- | |
| 59 | 59 | |
| 60 | ~LuaException() throw () | |
| 61 | { | |
| 62 | } | |
| 60 | ~LuaException() throw () | |
| 61 | { | |
| 62 | } | |
| 63 | 63 | |
| 64 | ||
| 64 | //---------------------------------------------------------------------------- | |
| 65 | 65 | |
| 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 | } | |
| 70 | 70 | |
| 71 | //============================================================================ | |
| 72 | /** | |
| 73 | Throw an exception. | |
| 71 | //============================================================================ | |
| 72 | /** | |
| 73 | Throw an exception. | |
| 74 | 74 | |
| 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 | } | |
| 84 | 84 | |
| 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); | |
| 92 | 92 | |
| 93 | if (code != LUABRIDGE_LUA_OK) | |
| 94 | Throw (LuaException (L, code)); | |
| 95 | } | |
| 93 | if (code != LUABRIDGE_LUA_OK) | |
| 94 | Throw (LuaException (L, code)); | |
| 95 | } | |
| 96 | 96 | |
| 97 | ||
| 97 | //---------------------------------------------------------------------------- | |
| 98 | 98 | |
| 99 | 99 | protected: |
| 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 | } | |
| 113 | 113 | }; |
| r31374 | r31375 | |
|---|---|---|
| 1 | 1 | //------------------------------------------------------------------------------ |
| 2 | 2 | /* |
| 3 | 3 | https://github.com/vinniefalco/LuaBridge |
| 4 | ||
| 4 | ||
| 5 | 5 | Copyright 2012, Vinnie Falco <vinnie.falco@gmail.com> |
| 6 | 6 | |
| 7 | 7 | License: The MIT License (http://www.opensource.org/licenses/mit-license.php) |
| r31374 | r31375 | |
| 36 | 36 | class ClassInfo |
| 37 | 37 | { |
| 38 | 38 | public: |
| 39 | ||
| 39 | /** Get the key for the static table. | |
| 40 | 40 | |
| 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 | } | |
| 49 | 49 | |
| 50 | ||
| 50 | /** Get the key for the class table. | |
| 51 | 51 | |
| 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 | } | |
| 61 | 61 | |
| 62 | ||
| 62 | /** Get the key for the const table. | |
| 63 | 63 | |
| 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 | } | |
| 72 | 72 | }; |
| 73 |
| r31374 | r31375 | |
|---|---|---|
| 1 | 1 | //------------------------------------------------------------------------------ |
| 2 | 2 | /* |
| 3 | 3 | https://github.com/vinniefalco/LuaBridge |
| 4 | ||
| 4 | ||
| 5 | 5 | Copyright 2012, Vinnie Falco <vinnie.falco@gmail.com> |
| 6 | 6 | |
| 7 | 7 | License: The MIT License (http://www.opensource.org/licenses/mit-license.php) |
| r31374 | r31375 | |
| 33 | 33 | 'noexcept' (if C++11 is available) to distinguish the functions. |
| 34 | 34 | */ |
| 35 | 35 | #if defined (__APPLE_CPP__) || defined(__APPLE_CC__) || defined(__clang__) || defined(__GNUC__) || \ |
| 36 | ||
| 36 | (defined (_MSC_VER) && (_MSC_VER >= 1700)) | |
| 37 | 37 | // Do not define LUABRIDGE_THROWSPEC since the Xcode and gcc compilers do not |
| 38 | 38 | // distinguish the throw specification in the function signature. |
| 39 | 39 | #else |
| r31374 | r31375 | |
| 64 | 64 | template <class R, class D> |
| 65 | 65 | struct FuncTraits <R (*) (), D> |
| 66 | 66 | { |
| 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 | } | |
| 75 | 75 | }; |
| 76 | 76 | |
| 77 | 77 | template <class R, class P1, class D> |
| 78 | 78 | struct FuncTraits <R (*) (P1), D> |
| 79 | 79 | { |
| 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 | } | |
| 88 | 88 | }; |
| 89 | 89 | |
| 90 | 90 | template <class R, class P1, class P2, class D> |
| 91 | 91 | struct FuncTraits <R (*) (P1, P2), D> |
| 92 | 92 | { |
| 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 | } | |
| 101 | 101 | }; |
| 102 | 102 | |
| 103 | 103 | template <class R, class P1, class P2, class P3, class D> |
| 104 | 104 | struct FuncTraits <R (*) (P1, P2, P3), D> |
| 105 | 105 | { |
| 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 | } | |
| 114 | 114 | }; |
| 115 | 115 | |
| 116 | 116 | template <class R, class P1, class P2, class P3, class P4, class D> |
| 117 | 117 | struct FuncTraits <R (*) (P1, P2, P3, P4), D> |
| 118 | 118 | { |
| 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 | } | |
| 127 | 127 | }; |
| 128 | 128 | |
| 129 | 129 | template <class R, class P1, class P2, class P3, class P4, class P5, class D> |
| 130 | 130 | struct FuncTraits <R (*) (P1, P2, P3, P4, P5), D> |
| 131 | 131 | { |
| 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 | } | |
| 140 | 140 | }; |
| 141 | 141 | |
| 142 | 142 | template <class R, class P1, class P2, class P3, class P4, class P5, class P6, class D> |
| 143 | 143 | struct FuncTraits <R (*) (P1, P2, P3, P4, P5, P6), D> |
| 144 | 144 | { |
| 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 | } | |
| 153 | 153 | }; |
| 154 | 154 | |
| 155 | 155 | template <class R, class P1, class P2, class P3, class P4, class P5, class P6, class P7, class D> |
| 156 | 156 | struct FuncTraits <R (*) (P1, P2, P3, P4, P5, P6, P7), D> |
| 157 | 157 | { |
| 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 | } | |
| 166 | 166 | }; |
| 167 | 167 | |
| 168 | 168 | template <class R, class P1, class P2, class P3, class P4, class P5, class P6, class P7, class P8, class D> |
| 169 | 169 | struct FuncTraits <R (*) (P1, P2, P3, P4, P5, P6, P7, P8), D> |
| 170 | 170 | { |
| 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 | } | |
| 179 | 179 | }; |
| 180 | 180 | |
| 181 | 181 | /* Non-const member function pointers. */ |
| r31374 | r31375 | |
| 183 | 183 | template <class T, class R, class D> |
| 184 | 184 | struct FuncTraits <R (T::*) (), D> |
| 185 | 185 | { |
| 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 | } | |
| 196 | 196 | }; |
| 197 | 197 | |
| 198 | 198 | template <class T, class R, class P1, class D> |
| 199 | 199 | struct FuncTraits <R (T::*) (P1), D> |
| 200 | 200 | { |
| 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 | } | |
| 211 | 211 | }; |
| 212 | 212 | |
| 213 | 213 | template <class T, class R, class P1, class P2, class D> |
| 214 | 214 | struct FuncTraits <R (T::*) (P1, P2), D> |
| 215 | 215 | { |
| 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 | } | |
| 226 | 226 | }; |
| 227 | 227 | |
| 228 | 228 | template <class T, class R, class P1, class P2, class P3, class D> |
| 229 | 229 | struct FuncTraits <R (T::*) (P1, P2, P3), D> |
| 230 | 230 | { |
| 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 | } | |
| 241 | 241 | }; |
| 242 | 242 | |
| 243 | 243 | template <class T, class R, class P1, class P2, class P3, class P4, class D> |
| 244 | 244 | struct FuncTraits <R (T::*) (P1, P2, P3, P4), D> |
| 245 | 245 | { |
| 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 | } | |
| 256 | 256 | }; |
| 257 | 257 | |
| 258 | 258 | template <class T, class R, class P1, class P2, class P3, class P4, class P5, class D> |
| 259 | 259 | struct FuncTraits <R (T::*) (P1, P2, P3, P4, P5), D> |
| 260 | 260 | { |
| 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 | } | |
| 271 | 271 | }; |
| 272 | 272 | |
| 273 | 273 | template <class T, class R, class P1, class P2, class P3, class P4, class P5, class P6, class D> |
| 274 | 274 | struct FuncTraits <R (T::*) (P1, P2, P3, P4, P5, P6), D> |
| 275 | 275 | { |
| 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 | } | |
| 286 | 286 | }; |
| 287 | 287 | |
| 288 | 288 | template <class T, class R, class P1, class P2, class P3, class P4, class P5, class P6, class P7, class D> |
| 289 | 289 | struct FuncTraits <R (T::*) (P1, P2, P3, P4, P5, P6, P7), D> |
| 290 | 290 | { |
| 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 | } | |
| 301 | 301 | }; |
| 302 | 302 | |
| 303 | 303 | template <class T, class R, class P1, class P2, class P3, class P4, class P5, class P6, class P7, class P8, class D> |
| 304 | 304 | struct FuncTraits <R (T::*) (P1, P2, P3, P4, P5, P6, P7, P8), D> |
| 305 | 305 | { |
| 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 | } | |
| 316 | 316 | }; |
| 317 | 317 | |
| 318 | 318 | /* Const member function pointers. */ |
| r31374 | r31375 | |
| 320 | 320 | template <class T, class R, class D> |
| 321 | 321 | struct FuncTraits <R (T::*) () const, D> |
| 322 | 322 | { |
| 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 | } | |
| 333 | 333 | }; |
| 334 | 334 | |
| 335 | 335 | template <class T, class R, class P1, class D> |
| 336 | 336 | struct FuncTraits <R (T::*) (P1) const, D> |
| 337 | 337 | { |
| 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 | } | |
| 348 | 348 | }; |
| 349 | 349 | |
| 350 | 350 | template <class T, class R, class P1, class P2, class D> |
| 351 | 351 | struct FuncTraits <R (T::*) (P1, P2) const, D> |
| 352 | 352 | { |
| 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 | } | |
| 364 | 364 | }; |
| 365 | 365 | |
| 366 | 366 | template <class T, class R, class P1, class P2, class P3, class D> |
| 367 | 367 | struct FuncTraits <R (T::*) (P1, P2, P3) const, D> |
| 368 | 368 | { |
| 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 | } | |
| 379 | 379 | }; |
| 380 | 380 | |
| 381 | 381 | template <class T, class R, class P1, class P2, class P3, class P4, class D> |
| 382 | 382 | struct FuncTraits <R (T::*) (P1, P2, P3, P4) const, D> |
| 383 | 383 | { |
| 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 | } | |
| 394 | 394 | }; |
| 395 | 395 | |
| 396 | 396 | template <class T, class R, class P1, class P2, class P3, class P4, class P5, class D> |
| 397 | 397 | struct FuncTraits <R (T::*) (P1, P2, P3, P4, P5) const, D> |
| 398 | 398 | { |
| 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 | } | |
| 409 | 409 | }; |
| 410 | 410 | |
| 411 | 411 | template <class T, class R, class P1, class P2, class P3, class P4, class P5, class P6, class D> |
| 412 | 412 | struct FuncTraits <R (T::*) (P1, P2, P3, P4, P5, P6) const, D> |
| 413 | 413 | { |
| 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 | } | |
| 424 | 424 | }; |
| 425 | 425 | |
| 426 | 426 | template <class T, class R, class P1, class P2, class P3, class P4, class P5, class P6, class P7, class D> |
| 427 | 427 | struct FuncTraits <R (T::*) (P1, P2, P3, P4, P5, P6, P7) const, D> |
| 428 | 428 | { |
| 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 | } | |
| 439 | 439 | }; |
| 440 | 440 | |
| 441 | 441 | template <class T, class R, class P1, class P2, class P3, class P4, class P5, class P6, class P7, class P8, class D> |
| 442 | 442 | struct FuncTraits <R (T::*) (P1, P2, P3, P4, P5, P6, P7, P8) const, D> |
| 443 | 443 | { |
| 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 | } | |
| 454 | 454 | }; |
| 455 | 455 | |
| 456 | 456 | #if defined (LUABRIDGE_THROWSPEC) |
| r31374 | r31375 | |
| 460 | 460 | template <class R, class D> |
| 461 | 461 | struct FuncTraits <R (*) () LUABRIDGE_THROWSPEC, D> |
| 462 | 462 | { |
| 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 | } | |
| 471 | 471 | }; |
| 472 | 472 | |
| 473 | 473 | template <class R, class P1, class D> |
| 474 | 474 | struct FuncTraits <R (*) (P1) LUABRIDGE_THROWSPEC, D> |
| 475 | 475 | { |
| 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 | } | |
| 484 | 484 | }; |
| 485 | 485 | |
| 486 | 486 | template <class R, class P1, class P2, class D> |
| 487 | 487 | struct FuncTraits <R (*) (P1, P2) LUABRIDGE_THROWSPEC, D> |
| 488 | 488 | { |
| 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 | } | |
| 497 | 497 | }; |
| 498 | 498 | |
| 499 | 499 | template <class R, class P1, class P2, class P3, class D> |
| 500 | 500 | struct FuncTraits <R (*) (P1, P2, P3) LUABRIDGE_THROWSPEC, D> |
| 501 | 501 | { |
| 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 | } | |
| 510 | 510 | }; |
| 511 | 511 | |
| 512 | 512 | template <class R, class P1, class P2, class P3, class P4, class D> |
| 513 | 513 | struct FuncTraits <R (*) (P1, P2, P3, P4) LUABRIDGE_THROWSPEC, D> |
| 514 | 514 | { |
| 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 | } | |
| 523 | 523 | }; |
| 524 | 524 | |
| 525 | 525 | template <class R, class P1, class P2, class P3, class P4, class P5, class D> |
| 526 | 526 | struct FuncTraits <R (*) (P1, P2, P3, P4, P5) LUABRIDGE_THROWSPEC, D> |
| 527 | 527 | { |
| 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 | } | |
| 536 | 536 | }; |
| 537 | 537 | |
| 538 | 538 | template <class R, class P1, class P2, class P3, class P4, class P5, class P6, class D> |
| 539 | 539 | struct FuncTraits <R (*) (P1, P2, P3, P4, P5, P6) LUABRIDGE_THROWSPEC, D> |
| 540 | 540 | { |
| 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 | } | |
| 549 | 549 | }; |
| 550 | 550 | |
| 551 | 551 | template <class R, class P1, class P2, class P3, class P4, class P5, class P6, class P7, class D> |
| 552 | 552 | struct FuncTraits <R (*) (P1, P2, P3, P4, P5, P6, P7) LUABRIDGE_THROWSPEC, D> |
| 553 | 553 | { |
| 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 | } | |
| 562 | 562 | }; |
| 563 | 563 | |
| 564 | 564 | template <class R, class P1, class P2, class P3, class P4, class P5, class P6, class P7, class P8, class D> |
| 565 | 565 | struct FuncTraits <R (*) (P1, P2, P3, P4, P5, P6, P7, P8) LUABRIDGE_THROWSPEC, D> |
| 566 | 566 | { |
| 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 | } | |
| 575 | 575 | }; |
| 576 | 576 | |
| 577 | 577 | /* Non-const member function pointers with THROWSPEC. */ |
| r31374 | r31375 | |
| 579 | 579 | template <class T, class R, class D> |
| 580 | 580 | struct FuncTraits <R (T::*) () LUABRIDGE_THROWSPEC, D> |
| 581 | 581 | { |
| 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 | } | |
| 592 | 592 | }; |
| 593 | 593 | |
| 594 | 594 | template <class T, class R, class P1, class D> |
| 595 | 595 | struct FuncTraits <R (T::*) (P1) LUABRIDGE_THROWSPEC, D> |
| 596 | 596 | { |
| 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 | } | |
| 607 | 607 | }; |
| 608 | 608 | |
| 609 | 609 | template <class T, class R, class P1, class P2, class D> |
| 610 | 610 | struct FuncTraits <R (T::*) (P1, P2) LUABRIDGE_THROWSPEC, D> |
| 611 | 611 | { |
| 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 | } | |
| 622 | 622 | }; |
| 623 | 623 | |
| 624 | 624 | template <class T, class R, class P1, class P2, class P3, class D> |
| 625 | 625 | struct FuncTraits <R (T::*) (P1, P2, P3) LUABRIDGE_THROWSPEC, D> |
| 626 | 626 | { |
| 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 | } | |
| 637 | 637 | }; |
| 638 | 638 | |
| 639 | 639 | template <class T, class R, class P1, class P2, class P3, class P4, class D> |
| 640 | 640 | struct FuncTraits <R (T::*) (P1, P2, P3, P4) LUABRIDGE_THROWSPEC, D> |
| 641 | 641 | { |
| 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 | } | |
| 652 | 652 | }; |
| 653 | 653 | |
| 654 | 654 | template <class T, class R, class P1, class P2, class P3, class P4, class P5, class D> |
| 655 | 655 | struct FuncTraits <R (T::*) (P1, P2, P3, P4, P5) LUABRIDGE_THROWSPEC, D> |
| 656 | 656 | { |
| 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 | } | |
| 667 | 667 | }; |
| 668 | 668 | |
| 669 | 669 | template <class T, class R, class P1, class P2, class P3, class P4, class P5, class P6, class D> |
| 670 | 670 | struct FuncTraits <R (T::*) (P1, P2, P3, P4, P5, P6) LUABRIDGE_THROWSPEC, D> |
| 671 | 671 | { |
| 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 | } | |
| 682 | 682 | }; |
| 683 | 683 | |
| 684 | 684 | template <class T, class R, class P1, class P2, class P3, class P4, class P5, class P6, class P7, class D> |
| 685 | 685 | struct FuncTraits <R (T::*) (P1, P2, P3, P4, P5, P6, P7) LUABRIDGE_THROWSPEC, D> |
| 686 | 686 | { |
| 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 | } | |
| 697 | 697 | }; |
| 698 | 698 | |
| 699 | 699 | template <class T, class R, class P1, class P2, class P3, class P4, class P5, class P6, class P7, class P8, class D> |
| 700 | 700 | struct FuncTraits <R (T::*) (P1, P2, P3, P4, P5, P6, P7, P8) LUABRIDGE_THROWSPEC, D> |
| 701 | 701 | { |
| 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 | } | |
| 712 | 712 | }; |
| 713 | 713 | |
| 714 | 714 | /* Const member function pointers with THROWSPEC. */ |
| r31374 | r31375 | |
| 716 | 716 | template <class T, class R, class D> |
| 717 | 717 | struct FuncTraits <R (T::*) () const LUABRIDGE_THROWSPEC, D> |
| 718 | 718 | { |
| 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 | } | |
| 729 | 729 | }; |
| 730 | 730 | |
| 731 | 731 | template <class T, class R, class P1, class D> |
| 732 | 732 | struct FuncTraits <R (T::*) (P1) const LUABRIDGE_THROWSPEC, D> |
| 733 | 733 | { |
| 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 | } | |
| 744 | 744 | }; |
| 745 | 745 | |
| 746 | 746 | template <class T, class R, class P1, class P2, class D> |
| 747 | 747 | struct FuncTraits <R (T::*) (P1, P2) const LUABRIDGE_THROWSPEC, D> |
| 748 | 748 | { |
| 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 | } | |
| 759 | 759 | }; |
| 760 | 760 | |
| 761 | 761 | template <class T, class R, class P1, class P2, class P3, class D> |
| 762 | 762 | struct FuncTraits <R (T::*) (P1, P2, P3) const LUABRIDGE_THROWSPEC, D> |
| 763 | 763 | { |
| 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 | } | |
| 774 | 774 | }; |
| 775 | 775 | |
| 776 | 776 | template <class T, class R, class P1, class P2, class P3, class P4, class D> |
| 777 | 777 | struct FuncTraits <R (T::*) (P1, P2, P3, P4) const LUABRIDGE_THROWSPEC, D> |
| 778 | 778 | { |
| 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 | } | |
| 789 | 789 | }; |
| 790 | 790 | |
| 791 | 791 | template <class T, class R, class P1, class P2, class P3, class P4, class P5, class D> |
| 792 | 792 | struct FuncTraits <R (T::*) (P1, P2, P3, P4, P5) const LUABRIDGE_THROWSPEC, D> |
| 793 | 793 | { |
| 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 | } | |
| 805 | 805 | }; |
| 806 | 806 | |
| 807 | 807 | template <class T, class R, class P1, class P2, class P3, class P4, class P5, class P6, class D> |
| 808 | 808 | struct FuncTraits <R (T::*) (P1, P2, P3, P4, P5, P6) const LUABRIDGE_THROWSPEC, D> |
| 809 | 809 | { |
| 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 | } | |
| 820 | 820 | }; |
| 821 | 821 | |
| 822 | 822 | template <class T, class R, class P1, class P2, class P3, class P4, class P5, class P6, class P7, class D> |
| 823 | 823 | struct FuncTraits <R (T::*) (P1, P2, P3, P4, P5, P6, P7) const LUABRIDGE_THROWSPEC, D> |
| 824 | 824 | { |
| 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 | } | |
| 835 | 835 | }; |
| 836 | 836 | |
| 837 | 837 | template <class T, class R, class P1, class P2, class P3, class P4, class P5, class P6, class P7, class P8, class D> |
| 838 | 838 | struct FuncTraits <R (T::*) (P1, P2, P3, P4, P5, P6, P7, P8) const LUABRIDGE_THROWSPEC, D> |
| 839 | 839 | { |
| 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 | } | |
| 850 | 850 | }; |
| 851 | 851 | |
| 852 | 852 | #endif |
| r31374 | r31375 | |
|---|---|---|
| 1 | 1 | //------------------------------------------------------------------------------ |
| 2 | 2 | /* |
| 3 | 3 | https://github.com/vinniefalco/LuaBridge |
| 4 | ||
| 4 | ||
| 5 | 5 | Copyright 2012, Vinnie Falco <vinnie.falco@gmail.com> |
| 6 | 6 | Copyright 2007, Nathan Reed |
| 7 | 7 | |
| r31374 | r31375 | |
| 45 | 45 | |
| 46 | 46 | namespace luabridge |
| 47 | 47 | { |
| 48 | ||
| 49 | 48 | // Forward declaration |
| 50 | 49 | // |
| 51 | 50 | template <class T> |
| r31374 | r31375 | |
| 73 | 72 | class Security |
| 74 | 73 | { |
| 75 | 74 | public: |
| 76 | static bool hideMetatables () | |
| 77 | { | |
| 78 | return getSettings().hideMetatables; | |
| 79 | } | |
| 75 | static bool hideMetatables () | |
| 76 | { | |
| 77 | return getSettings().hideMetatables; | |
| 78 | } | |
| 80 | 79 | |
| 81 | static void setHideMetatables (bool shouldHide) | |
| 82 | { | |
| 83 | getSettings().hideMetatables = shouldHide; | |
| 84 | } | |
| 80 | static void setHideMetatables (bool shouldHide) | |
| 81 | { | |
| 82 | getSettings().hideMetatables = shouldHide; | |
| 83 | } | |
| 85 | 84 | |
| 86 | 85 | private: |
| 87 | struct Settings | |
| 88 | { | |
| 89 | Settings () : hideMetatables (true) | |
| 90 | { | |
| 91 | } | |
| 86 | struct Settings | |
| 87 | { | |
| 88 | Settings () : hideMetatables (true) | |
| 89 | { | |
| 90 | } | |
| 92 | 91 | |
| 93 | bool hideMetatables; | |
| 94 | }; | |
| 92 | bool hideMetatables; | |
| 93 | }; | |
| 95 | 94 | |
| 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 | } | |
| 101 | 100 | }; |
| 102 | 101 | |
| 103 | 102 | #include "detail/Userdata.h" |
| r31374 | r31375 | |
| 111 | 110 | template <class T> |
| 112 | 111 | inline void push (lua_State* L, T t) |
| 113 | 112 | { |
| 114 | ||
| 113 | Stack <T>::push (L, t); | |
| 115 | 114 | } |
| 116 | 115 | |
| 117 | 116 | //------------------------------------------------------------------------------ |
| r31374 | r31375 | |
| 124 | 123 | template <class T> |
| 125 | 124 | inline void setGlobal (lua_State* L, T t, char const* name) |
| 126 | 125 | { |
| 127 | push (L, t); | |
| 128 | lua_setglobal (L, name); | |
| 126 | push (L, t); | |
| 127 | lua_setglobal (L, name); | |
| 129 | 128 | } |
| 130 | 129 | |
| 131 | 130 | //------------------------------------------------------------------------------ |
| r31374 | r31375 | |
| 134 | 133 | */ |
| 135 | 134 | inline void setHideMetatables (bool shouldHide) |
| 136 | 135 | { |
| 137 | ||
| 136 | Security::setHideMetatables (shouldHide); | |
| 138 | 137 | } |
| 139 | 138 | |
| 140 | 139 | } |
| r31374 | r31375 | |
|---|---|---|
| 14 | 14 | We assume that instructions are unsigned numbers. |
| 15 | 15 | All instructions have an opcode in the first 6 bits. |
| 16 | 16 | 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 | |
| 23 | 23 | |
| 24 | 24 | A signed argument is represented in excess K; that is, the number |
| 25 | 25 | value is the unsigned value minus K. K is exactly the maximum value |
| r31374 | r31375 | |
| 35 | 35 | /* |
| 36 | 36 | ** size and position of opcode arguments. |
| 37 | 37 | */ |
| 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) | |
| 43 | 43 | |
| 44 | #define SIZE_OP | |
| 44 | #define SIZE_OP 6 | |
| 45 | 45 | |
| 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 | |
| 52 | 52 | |
| 53 | 53 | |
| 54 | 54 | /* |
| r31374 | r31375 | |
| 65 | 65 | #endif |
| 66 | 66 | |
| 67 | 67 | #if SIZE_Ax < LUAI_BITSINT-1 |
| 68 | #define MAXARG_Ax | |
| 68 | #define MAXARG_Ax ((1<<SIZE_Ax)-1) | |
| 69 | 69 | #else |
| 70 | #define MAXARG_Ax | |
| 70 | #define MAXARG_Ax MAX_INT | |
| 71 | 71 | #endif |
| 72 | 72 | |
| 73 | 73 | |
| r31374 | r31375 | |
| 77 | 77 | |
| 78 | 78 | |
| 79 | 79 | /* creates a mask with `n' 1 bits at position `p' */ |
| 80 | #define MASK1(n,p) | |
| 80 | #define MASK1(n,p) ((~((~(Instruction)0)<<(n)))<<(p)) | |
| 81 | 81 | |
| 82 | 82 | /* creates a mask with `n' 0 bits at position `p' */ |
| 83 | #define MASK0(n,p) | |
| 83 | #define MASK0(n,p) (~MASK1(n,p)) | |
| 84 | 84 | |
| 85 | 85 | /* |
| 86 | 86 | ** the following macros help to manipulate instructions |
| 87 | 87 | */ |
| 88 | 88 | |
| 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)) | \ | |
| 91 | 91 | ((cast(Instruction, o)<<POS_OP)&MASK1(SIZE_OP,POS_OP)))) |
| 92 | 92 | |
| 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)))) | |
| 96 | 96 | |
| 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) | |
| 99 | 99 | |
| 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) | |
| 102 | 102 | |
| 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) | |
| 105 | 105 | |
| 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) | |
| 108 | 108 | |
| 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) | |
| 111 | 111 | |
| 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)) | |
| 114 | 114 | |
| 115 | 115 | |
| 116 | #define CREATE_ABC(o,a,b,c) | |
| 116 | #define CREATE_ABC(o,a,b,c) ((cast(Instruction, o)<<POS_OP) \ | |
| 117 | 117 | | (cast(Instruction, a)<<POS_A) \ |
| 118 | 118 | | (cast(Instruction, b)<<POS_B) \ |
| 119 | 119 | | (cast(Instruction, c)<<POS_C)) |
| 120 | 120 | |
| 121 | #define CREATE_ABx(o,a,bc) | |
| 121 | #define CREATE_ABx(o,a,bc) ((cast(Instruction, o)<<POS_OP) \ | |
| 122 | 122 | | (cast(Instruction, a)<<POS_A) \ |
| 123 | 123 | | (cast(Instruction, bc)<<POS_Bx)) |
| 124 | 124 | |
| 125 | #define CREATE_Ax(o,a) | |
| 125 | #define CREATE_Ax(o,a) ((cast(Instruction, o)<<POS_OP) \ | |
| 126 | 126 | | (cast(Instruction, a)<<POS_Ax)) |
| 127 | 127 | |
| 128 | 128 | |
| r31374 | r31375 | |
| 131 | 131 | */ |
| 132 | 132 | |
| 133 | 133 | /* this bit 1 means constant (0 means register) */ |
| 134 | #define BITRK | |
| 134 | #define BITRK (1 << (SIZE_B - 1)) | |
| 135 | 135 | |
| 136 | 136 | /* test whether value is a constant */ |
| 137 | #define ISK(x) | |
| 137 | #define ISK(x) ((x) & BITRK) | |
| 138 | 138 | |
| 139 | 139 | /* gets the index of the constant */ |
| 140 | #define INDEXK(r) | |
| 140 | #define INDEXK(r) ((int)(r) & ~BITRK) | |
| 141 | 141 | |
| 142 | #define MAXINDEXRK | |
| 142 | #define MAXINDEXRK (BITRK - 1) | |
| 143 | 143 | |
| 144 | 144 | /* code a constant index as a RK value */ |
| 145 | #define RKASK(x) | |
| 145 | #define RKASK(x) ((x) | BITRK) | |
| 146 | 146 | |
| 147 | 147 | |
| 148 | 148 | /* |
| 149 | 149 | ** invalid register that fits in 8 bits |
| 150 | 150 | */ |
| 151 | #define NO_REG | |
| 151 | #define NO_REG MAXARG_A | |
| 152 | 152 | |
| 153 | 153 | |
| 154 | 154 | /* |
| r31374 | r31375 | |
| 164 | 164 | |
| 165 | 165 | typedef enum { |
| 166 | 166 | /*---------------------------------------------------------------------- |
| 167 | name | |
| 167 | name args description | |
| 168 | 168 | ------------------------------------------------------------------------*/ |
| 169 | OP_MOVE,/* A B R(A) := R(B) */ | |
| 170 | OP_LOADK,/* A Bx R(A) := Kst(Bx) */ | |
| 171 | OP_LOADKX,/* A R(A) := Kst(extra arg) */ | |
| 172 | OP_LOADBOOL,/* A B C R(A) := (Bool)B; if (C) pc++ */ | |
| 173 | OP_LOADNIL,/* A B R(A), R(A+1), ..., R(A+B) := nil */ | |
| 174 | OP_GETUPVAL,/* A B R(A) := UpValue[B] */ | |
| 169 | OP_MOVE,/* A B R(A) := R(B) */ | |
| 170 | OP_LOADK,/* A Bx R(A) := Kst(Bx) */ | |
| 171 | OP_LOADKX,/* A R(A) := Kst(extra arg) */ | |
| 172 | OP_LOADBOOL,/* A B C R(A) := (Bool)B; if (C) pc++ */ | |
| 173 | OP_LOADNIL,/* A B R(A), R(A+1), ..., R(A+B) := nil */ | |
| 174 | OP_GETUPVAL,/* A B R(A) := UpValue[B] */ | |
| 175 | 175 | |
| 176 | OP_GETTABUP,/* A B C R(A) := UpValue[B][RK(C)] */ | |
| 177 | OP_GETTABLE,/* A B C R(A) := R(B)[RK(C)] */ | |
| 176 | OP_GETTABUP,/* A B C R(A) := UpValue[B][RK(C)] */ | |
| 177 | OP_GETTABLE,/* A B C R(A) := R(B)[RK(C)] */ | |
| 178 | 178 | |
| 179 | OP_SETTABUP,/* A B C UpValue[A][RK(B)] := RK(C) */ | |
| 180 | OP_SETUPVAL,/* A B UpValue[B] := R(A) */ | |
| 181 | OP_SETTABLE,/* A B C R(A)[RK(B)] := RK(C) */ | |
| 179 | OP_SETTABUP,/* A B C UpValue[A][RK(B)] := RK(C) */ | |
| 180 | OP_SETUPVAL,/* A B UpValue[B] := R(A) */ | |
| 181 | OP_SETTABLE,/* A B C R(A)[RK(B)] := RK(C) */ | |
| 182 | 182 | |
| 183 | OP_NEWTABLE,/* | |
| 183 | OP_NEWTABLE,/* A B C R(A) := {} (size = B,C) */ | |
| 184 | 184 | |
| 185 | OP_SELF,/* | |
| 185 | OP_SELF,/* A B C R(A+1) := R(B); R(A) := R(B)[RK(C)] */ | |
| 186 | 186 | |
| 187 | OP_ADD,/* A B C R(A) := RK(B) + RK(C) */ | |
| 188 | OP_SUB,/* A B C R(A) := RK(B) - RK(C) */ | |
| 189 | OP_MUL,/* A B C R(A) := RK(B) * RK(C) */ | |
| 190 | OP_DIV,/* A B C R(A) := RK(B) / RK(C) */ | |
| 191 | OP_MOD,/* A B C R(A) := RK(B) % RK(C) */ | |
| 192 | OP_POW,/* A B C R(A) := RK(B) ^ RK(C) */ | |
| 193 | OP_UNM,/* A B R(A) := -R(B) */ | |
| 194 | OP_NOT,/* A B R(A) := not R(B) */ | |
| 195 | OP_LEN,/* A B R(A) := length of R(B) */ | |
| 187 | OP_ADD,/* A B C R(A) := RK(B) + RK(C) */ | |
| 188 | OP_SUB,/* A B C R(A) := RK(B) - RK(C) */ | |
| 189 | OP_MUL,/* A B C R(A) := RK(B) * RK(C) */ | |
| 190 | OP_DIV,/* A B C R(A) := RK(B) / RK(C) */ | |
| 191 | OP_MOD,/* A B C R(A) := RK(B) % RK(C) */ | |
| 192 | OP_POW,/* A B C R(A) := RK(B) ^ RK(C) */ | |
| 193 | OP_UNM,/* A B R(A) := -R(B) */ | |
| 194 | OP_NOT,/* A B R(A) := not R(B) */ | |
| 195 | OP_LEN,/* A B R(A) := length of R(B) */ | |
| 196 | 196 | |
| 197 | OP_CONCAT,/* | |
| 197 | OP_CONCAT,/* A B C R(A) := R(B).. ... ..R(C) */ | |
| 198 | 198 | |
| 199 | OP_JMP,/* A sBx pc+=sBx; if (A) close all upvalues >= R(A) + 1 */ | |
| 200 | OP_EQ,/* A B C if ((RK(B) == RK(C)) ~= A) then pc++ */ | |
| 201 | OP_LT,/* A B C if ((RK(B) < RK(C)) ~= A) then pc++ */ | |
| 202 | OP_LE,/* A B C if ((RK(B) <= RK(C)) ~= A) then pc++ */ | |
| 199 | OP_JMP,/* A sBx pc+=sBx; if (A) close all upvalues >= R(A) + 1 */ | |
| 200 | OP_EQ,/* A B C if ((RK(B) == RK(C)) ~= A) then pc++ */ | |
| 201 | OP_LT,/* A B C if ((RK(B) < RK(C)) ~= A) then pc++ */ | |
| 202 | OP_LE,/* A B C if ((RK(B) <= RK(C)) ~= A) then pc++ */ | |
| 203 | 203 | |
| 204 | OP_TEST,/* A C if not (R(A) <=> C) then pc++ */ | |
| 205 | OP_TESTSET,/* A B C if (R(B) <=> C) then R(A) := R(B) else pc++ */ | |
| 204 | OP_TEST,/* A C if not (R(A) <=> C) then pc++ */ | |
| 205 | OP_TESTSET,/* A B C if (R(B) <=> C) then R(A) := R(B) else pc++ */ | |
| 206 | 206 | |
| 207 | OP_CALL,/* A B C R(A), ... ,R(A+C-2) := R(A)(R(A+1), ... ,R(A+B-1)) */ | |
| 208 | OP_TAILCALL,/* A B C return R(A)(R(A+1), ... ,R(A+B-1)) */ | |
| 209 | OP_RETURN,/* A B return R(A), ... ,R(A+B-2) (see note) */ | |
| 207 | OP_CALL,/* A B C R(A), ... ,R(A+C-2) := R(A)(R(A+1), ... ,R(A+B-1)) */ | |
| 208 | OP_TAILCALL,/* A B C return R(A)(R(A+1), ... ,R(A+B-1)) */ | |
| 209 | OP_RETURN,/* A B return R(A), ... ,R(A+B-2) (see note) */ | |
| 210 | 210 | |
| 211 | OP_FORLOOP,/* A sBx R(A)+=R(A+2); | |
| 212 | if R(A) <?= R(A+1) then { pc+=sBx; R(A+3)=R(A) }*/ | |
| 213 | OP_FORPREP,/* A sBx R(A)-=R(A+2); pc+=sBx */ | |
| 211 | OP_FORLOOP,/* A sBx R(A)+=R(A+2); | |
| 212 | if R(A) <?= R(A+1) then { pc+=sBx; R(A+3)=R(A) }*/ | |
| 213 | OP_FORPREP,/* A sBx R(A)-=R(A+2); pc+=sBx */ | |
| 214 | 214 | |
| 215 | OP_TFORCALL,/* A C R(A+3), ... ,R(A+2+C) := R(A)(R(A+1), R(A+2)); */ | |
| 216 | OP_TFORLOOP,/* A sBx if R(A+1) ~= nil then { R(A)=R(A+1); pc += sBx }*/ | |
| 215 | OP_TFORCALL,/* A C R(A+3), ... ,R(A+2+C) := R(A)(R(A+1), R(A+2)); */ | |
| 216 | OP_TFORLOOP,/* A sBx if R(A+1) ~= nil then { R(A)=R(A+1); pc += sBx }*/ | |
| 217 | 217 | |
| 218 | OP_SETLIST,/* | |
| 218 | OP_SETLIST,/* A B C R(A)[(C-1)*FPF+i] := R(A+i), 1 <= i <= B */ | |
| 219 | 219 | |
| 220 | OP_CLOSURE,/* | |
| 220 | OP_CLOSURE,/* A Bx R(A) := closure(KPROTO[Bx]) */ | |
| 221 | 221 | |
| 222 | OP_VARARG,/* | |
| 222 | OP_VARARG,/* A B R(A), R(A+1), ..., R(A+B-2) = vararg */ | |
| 223 | 223 | |
| 224 | OP_EXTRAARG/* | |
| 224 | OP_EXTRAARG/* Ax extra (larger) argument for previous opcode */ | |
| 225 | 225 | } OpCode; |
| 226 | 226 | |
| 227 | 227 | |
| 228 | #define NUM_OPCODES | |
| 228 | #define NUM_OPCODES (cast(int, OP_EXTRAARG) + 1) | |
| 229 | 229 | |
| 230 | 230 | |
| 231 | 231 | |
| r31374 | r31375 | |
| 263 | 263 | */ |
| 264 | 264 | |
| 265 | 265 | enum 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 */ | |
| 270 | 270 | }; |
| 271 | 271 | |
| 272 | 272 | LUAI_DDEC const lu_byte luaP_opmodes[NUM_OPCODES]; |
| 273 | 273 | |
| 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)) | |
| 279 | 279 | |
| 280 | 280 | |
| 281 | 281 | LUAI_DDEC const char *const luaP_opnames[NUM_OPCODES+1]; /* opcode names */ |
| 282 | 282 | |
| 283 | 283 | |
| 284 | 284 | /* number of list items to accumulate before a SETLIST instruction */ |
| 285 | #define LFIELDS_PER_FLUSH | |
| 285 | #define LFIELDS_PER_FLUSH 50 | |
| 286 | 286 | |
| 287 | 287 | |
| 288 | 288 | #endif |
| r31374 | r31375 | |
|---|---|---|
| 13 | 13 | #include "lmem.h" |
| 14 | 14 | |
| 15 | 15 | |
| 16 | #define EOZ | |
| 16 | #define EOZ (-1) /* end of stream */ | |
| 17 | 17 | |
| 18 | 18 | typedef struct Zio ZIO; |
| 19 | 19 | |
| r31374 | r31375 | |
| 21 | 21 | |
| 22 | 22 | |
| 23 | 23 | typedef struct Mbuffer { |
| 24 | char *buffer; | |
| 25 | size_t n; | |
| 26 | size_t buffsize; | |
| 24 | char *buffer; | |
| 25 | size_t n; | |
| 26 | size_t buffsize; | |
| 27 | 27 | } Mbuffer; |
| 28 | 28 | |
| 29 | 29 | #define luaZ_initbuffer(L, buff) ((buff)->buffer = NULL, (buff)->buffsize = 0) |
| 30 | 30 | |
| 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) | |
| 34 | 34 | |
| 35 | 35 | #define luaZ_resetbuffer(buff) ((buff)->n = 0) |
| 36 | 36 | |
| r31374 | r31375 | |
| 39 | 39 | (luaM_reallocvector(L, (buff)->buffer, (buff)->buffsize, size, char), \ |
| 40 | 40 | (buff)->buffsize = size) |
| 41 | 41 | |
| 42 | #define luaZ_freebuffer(L, buff) | |
| 42 | #define luaZ_freebuffer(L, buff) luaZ_resizebuffer(L, buff, 0) | |
| 43 | 43 | |
| 44 | 44 | |
| 45 | 45 | LUAI_FUNC char *luaZ_openspace (lua_State *L, Mbuffer *buff, size_t n); |
| 46 | 46 | LUAI_FUNC void luaZ_init (lua_State *L, ZIO *z, lua_Reader reader, |
| 47 | void *data); | |
| 48 | LUAI_FUNC size_t luaZ_read (ZIO* z, void* b, size_t n); /* read next n bytes */ | |
| 47 | void *data); | |
| 48 | LUAI_FUNC size_t luaZ_read (ZIO* z, void* b, size_t n); /* read next n bytes */ | |
| 49 | 49 | |
| 50 | 50 | |
| 51 | 51 | |
| 52 | 52 | /* --------- Private Part ------------------ */ |
| 53 | 53 | |
| 54 | 54 | struct 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) */ | |
| 60 | 60 | }; |
| 61 | 61 | |
| 62 | 62 |
| r31374 | r31375 | |
|---|---|---|
| 13 | 13 | #include "lzio.h" |
| 14 | 14 | |
| 15 | 15 | |
| 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); | |
| 18 | 18 | |
| 19 | 19 | |
| 20 | 20 | #define incr_top(L) {L->top++; luaD_checkstack(L,0);} |
| 21 | 21 | |
| 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))) | |
| 24 | 24 | |
| 25 | 25 | |
| 26 | 26 | /* type of protected functions, to be ran by `runprotected' */ |
| 27 | 27 | typedef void (*Pfunc) (lua_State *L, void *ud); |
| 28 | 28 | |
| 29 | 29 | LUAI_FUNC int luaD_protectedparser (lua_State *L, ZIO *z, const char *name, |
| 30 | ||
| 30 | const char *mode); | |
| 31 | 31 | LUAI_FUNC void luaD_hook (lua_State *L, int event, int line); |
| 32 | 32 | LUAI_FUNC int luaD_precall (lua_State *L, StkId func, int nresults); |
| 33 | 33 | LUAI_FUNC void luaD_call (lua_State *L, StkId func, int nResults, |
| 34 | ||
| 34 | int allowyield); | |
| 35 | 35 | LUAI_FUNC int luaD_pcall (lua_State *L, Pfunc func, void *u, |
| 36 | ||
| 36 | ptrdiff_t oldtop, ptrdiff_t ef); | |
| 37 | 37 | LUAI_FUNC int luaD_poscall (lua_State *L, StkId firstResult); |
| 38 | 38 | LUAI_FUNC void luaD_reallocstack (lua_State *L, int newsize); |
| 39 | 39 | LUAI_FUNC void luaD_growstack (lua_State *L, int n); |
| r31374 | r31375 | |
| 43 | 43 | LUAI_FUNC int luaD_rawrunprotected (lua_State *L, Pfunc f, void *ud); |
| 44 | 44 | |
| 45 | 45 | #endif |
| 46 |
| r31374 | r31375 | |
|---|---|---|
| 20 | 20 | LUAI_FUNC int luaU_dump (lua_State* L, const Proto* f, lua_Writer w, void* data, int strip); |
| 21 | 21 | |
| 22 | 22 | /* data to catch conversion errors */ |
| 23 | #define LUAC_TAIL | |
| 23 | #define LUAC_TAIL "\x19\x93\r\n\x1a\n" | |
| 24 | 24 | |
| 25 | 25 | /* size in bytes of header of binary files */ |
| 26 | #define LUAC_HEADERSIZE | |
| 26 | #define LUAC_HEADERSIZE (sizeof(LUA_SIGNATURE)-sizeof(char)+2+6+sizeof(LUAC_TAIL)-sizeof(char)) | |
| 27 | 27 | |
| 28 | 28 | #endif |
| r31374 | r31375 | |
|---|---|---|
| 15 | 15 | "stack overflow");} |
| 16 | 16 | |
| 17 | 17 | #define adjustresults(L,nres) \ |
| 18 | ||
| 18 | { if ((nres) == LUA_MULTRET && L->ci->top < L->top) L->ci->top = L->top; } | |
| 19 | 19 | |
| 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") | |
| 22 | 22 | |
| 23 | 23 | |
| 24 | 24 | #endif |
| r31374 | r31375 | |
|---|---|---|
| 16 | 16 | * grep "ORDER TM" |
| 17 | 17 | */ |
| 18 | 18 | typedef 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 */ | |
| 37 | 37 | } TMS; |
| 38 | 38 | |
| 39 | 39 | |
| 40 | 40 | |
| 41 | 41 | #define gfasttm(g,et,e) ((et) == NULL ? NULL : \ |
| 42 | ||
| 42 | ((et)->flags & (1u<<(e))) ? NULL : luaT_gettm(et, e, (g)->tmname[e])) | |
| 43 | 43 | |
| 44 | #define fasttm(l,et,e) | |
| 44 | #define fasttm(l,et,e) gfasttm(G(l), et, e) | |
| 45 | 45 | |
| 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)) | |
| 48 | 48 | |
| 49 | 49 | LUAI_DDEC const char *const luaT_typenames_[LUA_TOTALTAGS]; |
| 50 | 50 | |
| 51 | 51 | |
| 52 | 52 | LUAI_FUNC const TValue *luaT_gettm (Table *events, TMS event, TString *ename); |
| 53 | 53 | LUAI_FUNC const TValue *luaT_gettmbyobj (lua_State *L, const TValue *o, |
| 54 | ||
| 54 | TMS event); | |
| 55 | 55 | LUAI_FUNC void luaT_init (lua_State *L); |
| 56 | 56 | |
| 57 | 57 | #endif |
| r31374 | r31375 | |
|---|---|---|
| 15 | 15 | |
| 16 | 16 | #define tostring(L,o) (ttisstring(o) || (luaV_tostring(L, o))) |
| 17 | 17 | |
| 18 | #define tonumber(o,n) | |
| 18 | #define tonumber(o,n) (ttisnumber(o) || (((o) = luaV_tonumber(o,n)) != NULL)) | |
| 19 | 19 | |
| 20 | 20 | #define equalobj(L,o1,o2) (ttisequal(o1, o2) && luaV_equalobj_(L, o1, o2)) |
| 21 | 21 | |
| 22 | #define luaV_rawequalobj(o1,o2) | |
| 22 | #define luaV_rawequalobj(o1,o2) equalobj(NULL,o1,o2) | |
| 23 | 23 | |
| 24 | 24 | |
| 25 | 25 | /* not to called directly */ |
| r31374 | r31375 | |
| 31 | 31 | LUAI_FUNC const TValue *luaV_tonumber (const TValue *obj, TValue *n); |
| 32 | 32 | LUAI_FUNC int luaV_tostring (lua_State *L, StkId obj); |
| 33 | 33 | LUAI_FUNC void luaV_gettable (lua_State *L, const TValue *t, TValue *key, |
| 34 | ||
| 34 | StkId val); | |
| 35 | 35 | LUAI_FUNC void luaV_settable (lua_State *L, const TValue *t, TValue *key, |
| 36 | ||
| 36 | StkId val); | |
| 37 | 37 | LUAI_FUNC void luaV_finishOp (lua_State *L); |
| 38 | 38 | LUAI_FUNC void luaV_execute (lua_State *L); |
| 39 | 39 | LUAI_FUNC void luaV_concat (lua_State *L, int total); |
| 40 | 40 | LUAI_FUNC void luaV_arith (lua_State *L, StkId ra, const TValue *rb, |
| 41 | ||
| 41 | const TValue *rc, TMS op); | |
| 42 | 42 | LUAI_FUNC void luaV_objlen (lua_State *L, StkId ra, const TValue *rb); |
| 43 | 43 | |
| 44 | 44 | #endif |
| r31374 | r31375 | |
|---|---|---|
| 11 | 11 | #include "lstate.h" |
| 12 | 12 | |
| 13 | 13 | |
| 14 | #define pcRel(pc, p) | |
| 14 | #define pcRel(pc, p) (cast(int, (pc) - (p)->code) - 1) | |
| 15 | 15 | |
| 16 | #define getfuncline(f,pc) | |
| 16 | #define getfuncline(f,pc) (((f)->lineinfo) ? (f)->lineinfo[pc] : 0) | |
| 17 | 17 | |
| 18 | #define resethookcount(L) | |
| 18 | #define resethookcount(L) (L->hookcount = L->basehookcount) | |
| 19 | 19 | |
| 20 | 20 | /* Active Lua function (given call info) */ |
| 21 | #define ci_func(ci) | |
| 21 | #define ci_func(ci) (clLvalue((ci)->func)) | |
| 22 | 22 | |
| 23 | 23 | |
| 24 | 24 | LUAI_FUNC l_noret luaG_typeerror (lua_State *L, const TValue *o, |
| 25 | ||
| 25 | const char *opname); | |
| 26 | 26 | LUAI_FUNC l_noret luaG_concaterror (lua_State *L, StkId p1, StkId p2); |
| 27 | 27 | LUAI_FUNC l_noret luaG_aritherror (lua_State *L, const TValue *p1, |
| 28 | ||
| 28 | const TValue *p2); | |
| 29 | 29 | LUAI_FUNC l_noret luaG_ordererror (lua_State *L, const TValue *p1, |
| 30 | ||
| 30 | const TValue *p2); | |
| 31 | 31 | LUAI_FUNC l_noret luaG_runerror (lua_State *L, const char *fmt, ...); |
| 32 | 32 | LUAI_FUNC l_noret luaG_errormsg (lua_State *L); |
| 33 | 33 |
| r31374 | r31375 | |
|---|---|---|
| 54 | 54 | dev.m_floppy_drive_tags[2] = tag3; |
| 55 | 55 | dev.m_floppy_drive_tags[3] = tag4; |
| 56 | 56 | } |
| 57 | ||
| 57 | ||
| 58 | 58 | void set_drive(UINT8 drive); // set current drive (0-3) |
| 59 | 59 | |
| 60 | 60 | DECLARE_READ8_MEMBER( status_r ); |
| r31374 | r31375 | |
|---|---|---|
| 35 | 35 | }; |
| 36 | 36 | |
| 37 | 37 | #endif |
| 38 |
| r31374 | r31375 | |
|---|---|---|
| 43 | 43 | // "Sequential Row Read is available only on K9F5608U0D_Y,P,V,F or K9F5608D0D_Y,P" |
| 44 | 44 | enum |
| 45 | 45 | { |
| 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 | |
| 51 | 51 | }; |
| 52 | 52 | |
| 53 | 53 | // ======================> nand_device |
| r31374 | r31375 | |
| 133 | 133 | break; |
| 134 | 134 | } |
| 135 | 135 | } |
| 136 | ||
| 136 | ||
| 137 | 137 | int is_present(); |
| 138 | 138 | int is_protected(); |
| 139 | 139 | int is_busy(); |
| r31374 | r31375 | |
| 186 | 186 | int m_col_address_cycles; |
| 187 | 187 | int m_row_address_cycles; |
| 188 | 188 | int m_sequential_row_read; |
| 189 | ||
| 189 | ||
| 190 | 190 | devcb_write_line m_write_rnb; |
| 191 | 191 | |
| 192 | 192 | #ifdef SMARTMEDIA_IMAGE_SAVE |
| r31374 | r31375 | |
|---|---|---|
| 44 | 44 | }; |
| 45 | 45 | |
| 46 | 46 | #endif |
| 47 |
| r31374 | r31375 | |
|---|---|---|
| 29 | 29 | }; |
| 30 | 30 | |
| 31 | 31 | #endif |
| 32 |
| r31374 | r31375 | |
|---|---|---|
| 205 | 205 | int m_current_fifo_read_pos; |
| 206 | 206 | int m_fifo_block_a_full; |
| 207 | 207 | int m_fifo_block_b_full; |
| 208 | ||
| 208 | ||
| 209 | 209 | required_device<palette_device> m_palette; |
| 210 | 210 | }; |
| 211 | 211 |
| r31374 | r31375 | |
|---|---|---|
| 143 | 143 | MCFG_DEVICE_ADD(_tag, TI99VIDEO, 0) \ |
| 144 | 144 | MCFG_DEVICE_ADD( VDP_TAG, _chip, XTAL_10_738635MHz / 2 ) \ |
| 145 | 145 | 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)) \ | |
| 147 | 147 | MCFG_TMS9928A_SCREEN_ADD_PAL( SCREEN_TAG ) \ |
| 148 | 148 | MCFG_SCREEN_UPDATE_DEVICE( VDP_TAG, tms9928a_device, screen_update ) |
| 149 | 149 | |
| r31374 | r31375 | |
| 174 | 174 | MCFG_SCREEN_SIZE(_x, _y) \ |
| 175 | 175 | MCFG_SCREEN_VISIBLE_AREA(0, _x - 1, 0, _y - 1) \ |
| 176 | 176 | MCFG_SCREEN_PALETTE(VDP_TAG ":palette") |
| 177 | ||
| 177 | ||
| 178 | 178 | #define MCFG_TI_SOUND_94624_ADD(_tag) \ |
| 179 | 179 | MCFG_DEVICE_ADD(_tag, TISOUND_94624, 0) |
| 180 | 180 |
| r31374 | r31375 | |
|---|---|---|
| 42 | 42 | public: |
| 43 | 43 | 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); |
| 44 | 44 | ie15_keyboard_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock); |
| 45 | ||
| 45 | ||
| 46 | 46 | 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); } |
| 47 | 47 | |
| 48 | 48 | virtual ioport_constructor device_input_ports() const; |
| r31374 | r31375 | |
|---|---|---|
| 330 | 330 | virtual void device_reset(); |
| 331 | 331 | |
| 332 | 332 | private: |
| 333 | UINT8 m_csrb; | |
| 334 | UINT8 m_ip6; | |
| 333 | UINT8 m_csrb; | |
| 334 | UINT8 m_ip6; | |
| 335 | 335 | }; |
| 336 | 336 | |
| 337 | 337 | extern const device_type APOLLO_SIO; |
| r31374 | r31375 | |
|---|---|---|
| 23 | 23 | m_gfxdecode(*this, "gfxdecode"), |
| 24 | 24 | m_palette(*this, "palette"), |
| 25 | 25 | m_videoram(*this, "videoram"), |
| 26 | m_keyboard(*this, "KEY") | |
| 26 | m_keyboard(*this, "KEY") { } | |
| 27 | 27 | |
| 28 | 28 | required_device<cpu_device> m_maincpu; |
| 29 | 29 | required_device<speaker_sound_device> m_speaker; |
| r31374 | r31375 | |
|---|---|---|
| 314 | 314 | |
| 315 | 315 | int m_centronics_busy; |
| 316 | 316 | int m_centronics_perror; |
| 317 | ||
| 317 | ||
| 318 | 318 | MC6854_OUT_FRAME_CB(to7_network_got_frame); |
| 319 | 319 | |
| 320 | 320 | protected: |
| r31374 | r31375 | |
|---|---|---|
| 110 | 110 | LSI53C810_DMA_CB(scsi_dma_callback); |
| 111 | 111 | |
| 112 | 112 | void bebox_set_irq_bit(unsigned int interrupt_bit, int val); |
| 113 | void bebox_update_interrupts(); | |
| 113 | void bebox_update_interrupts(); | |
| 114 | 114 | |
| 115 | 115 | protected: |
| 116 | 116 | virtual void device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr); |
| r31374 | r31375 | |
|---|---|---|
| 91 | 91 | optional_shared_ptr<UINT8> m_videoram; |
| 92 | 92 | optional_shared_ptr<UINT8> m_hector_videoram; |
| 93 | 93 | required_ioport_array<9> m_keyboard; |
| 94 | ||
| 94 | ||
| 95 | 95 | UINT8 m_hector_flag_hr; |
| 96 | 96 | UINT8 m_hector_flag_80c; |
| 97 | 97 | UINT8 m_hector_color[4]; |
| r31374 | r31375 | |
|---|---|---|
| 89 | 89 | required_device<pcf8593_device> m_rtc; |
| 90 | 90 | required_device<ram_device> m_ram; |
| 91 | 91 | optional_device<at45db041_device> m_flash1; |
| 92 | required_device<nvram_device> | |
| 92 | required_device<nvram_device> m_nvram; | |
| 93 | 93 | DECLARE_DRIVER_INIT(cybikoxt); |
| 94 | 94 | DECLARE_DRIVER_INIT(cybiko); |
| 95 | 95 | virtual void machine_start(); |
| r31374 | r31375 | |
|---|---|---|
| 77 | 77 | APPLE_II, // Apple II/II+ |
| 78 | 78 | APPLE_IIE, // Apple IIe with aux slots |
| 79 | 79 | APPLE_IIGS, // Apple IIgs |
| 80 | APPLE_IIC, // Apple IIc | |
| 81 | APPLE_IICPLUS, // Apple IIc+ | |
| 80 | APPLE_IIC, // Apple IIc | |
| 81 | APPLE_IICPLUS, // Apple IIc+ | |
| 82 | 82 | TK2000, // Microdigital TK2000 |
| 83 | 83 | LASER128, // Laser 128/128EX/128EX2 |
| 84 | 84 | SPACE84, // "Space 84" with flipped text mode |
| r31374 | r31375 | |
|---|---|---|
| 182 | 182 | |
| 183 | 183 | static void set_port_config(device_t &device, int port, int module, int max_size) |
| 184 | 184 | { |
| 185 | downcast<hp48_port_image_device &>(device).m_port = port; | |
| 185 | downcast<hp48_port_image_device &>(device).m_port = port; | |
| 186 | 186 | downcast<hp48_port_image_device &>(device).m_module = module; |
| 187 | 187 | downcast<hp48_port_image_device &>(device).m_max_size = max_size; |
| 188 | 188 | } |
| 189 | ||
| 189 | ||
| 190 | 190 | // image-level overrides |
| 191 | 191 | virtual iodevice_t image_type() const { return IO_MEMCARD; } |
| 192 | 192 |
| r31374 | r31375 | |
|---|---|---|
| 251 | 251 | ADC0808_ANALOG_READ_CB(adc_vref_pos_r); |
| 252 | 252 | ADC0808_ANALOG_READ_CB(adc_vref_neg_r); |
| 253 | 253 | ADC0808_ANALOG_READ_CB(adc_input_r); |
| 254 | ||
| 254 | ||
| 255 | 255 | TIMER_DEVICE_CALLBACK_MEMBER(ctc_c2_tick); |
| 256 | 256 | |
| 257 | 257 | void bankswitch(); |
| r31374 | r31375 | |
|---|---|---|
| 73 | 73 | |
| 74 | 74 | #define MCFG_MSX_LAYOUT_DISK2(_tag, _prim, _sec, _page, _numpages, _region, _offset) \ |
| 75 | 75 | 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); | |
| 76 | msx_state::install_slot_pages(*owner, _prim, _sec, _page, _numpages + 1, device); /* Memory mapped FDC registers are also accessible through page 2 */ | |
| 77 | 77 | |
| 78 | 78 | #define MCFG_MSX_LAYOUT_DISK3(_tag, _prim, _sec, _page, _numpages, _region, _offset) \ |
| 79 | 79 | MCFG_MSX_SLOT_DISK3_ADD(_tag, _page, _numpages, _region, _offset, "fdc", "fdc:0", "fdc:1") \ |
| r31374 | r31375 | |
| 163 | 163 | } |
| 164 | 164 | |
| 165 | 165 | // 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); | |
| 167 | 167 | |
| 168 | 168 | DECLARE_ADDRESS_MAP(switched_device_map, 8); |
| 169 | 169 | DECLARE_WRITE8_MEMBER(msx_sec_slot_w); |
| r31374 | r31375 | |
|---|---|---|
| 130 | 130 | |
| 131 | 131 | // floating bus |
| 132 | 132 | DECLARE_READ8_MEMBER( floating_bus_read ) { return floating_bus_read(); } |
| 133 | ||
| 133 | ||
| 134 | 134 | DECLARE_WRITE_LINE_MEMBER( cart_w ) { cart_w((bool) state); } |
| 135 | 135 | protected: |
| 136 | 136 | // device-level overrides |
| r31374 | r31375 | |
|---|---|---|
| 27 | 27 | #define ZX8302_TAG "ic23" |
| 28 | 28 | #define RS232_A_TAG "ser1" |
| 29 | 29 | #define RS232_B_TAG "ser2" |
| 30 | #define QIMI_TAG | |
| 30 | #define QIMI_TAG "qimi" | |
| 31 | 31 | |
| 32 | 32 | #define X1 XTAL_15MHz |
| 33 | 33 | #define X2 XTAL_32_768kHz |
| r31374 | r31375 | |
|---|---|---|
| 52 | 52 | DECLARE_WRITE8_MEMBER( pia2_pa_w ); |
| 53 | 53 | DECLARE_WRITE_LINE_MEMBER( pia2_firq_a ); |
| 54 | 54 | DECLARE_WRITE_LINE_MEMBER( pia2_firq_b ); |
| 55 | ||
| 55 | ||
| 56 | 56 | /* psg */ |
| 57 | 57 | DECLARE_READ8_MEMBER( psg_porta_read ); |
| 58 | 58 | DECLARE_WRITE8_MEMBER( psg_porta_write ); |
| r31374 | r31375 | |
|---|---|---|
| 63 | 63 | m_screen(*this, "screen"), |
| 64 | 64 | m_upd72065(*this, "upd72065"), |
| 65 | 65 | m_options(*this, "options"), |
| 66 | m_mouse1(*this, "mouse1"), | |
| 67 | m_mouse2(*this, "mouse2"), | |
| 66 | m_mouse1(*this, "mouse1"), | |
| 67 | m_mouse2(*this, "mouse2"), | |
| 68 | 68 | m_mouse3(*this, "mouse3"), |
| 69 | 69 | m_xpd1lr(*this, "xpd1lr"), |
| 70 | 70 | m_ctrltype(*this, "ctrltype"), |
| r31374 | r31375 | |
|---|---|---|
| 71 | 71 | |
| 72 | 72 | const char *m_char_rom_tag; /* character rom region */ |
| 73 | 73 | required_device<palette_device> m_palette; |
| 74 | ||
| 74 | ||
| 75 | 75 | bool m_notify_vblank; |
| 76 | 76 | int m_last_scroll; |
| 77 | 77 |
| r31374 | r31375 | |
|---|---|---|
| 203 | 203 | const char *m_maincpu_tag; /* tag of main CPU */ |
| 204 | 204 | const char *m_ram_tag; /* tag of RAM device */ |
| 205 | 205 | const char *m_ext_tag; /* tag of expansion device */ |
| 206 | ||
| 206 | ||
| 207 | 207 | // timer constants |
| 208 | 208 | static const device_timer_id TIMER_FRAME = 0; |
| 209 | 209 | static const device_timer_id TIMER_HSYNC_OFF = 1; |
| r31374 | r31375 | |
|---|---|---|
| 60 | 60 | dev.m_window_width = width; |
| 61 | 61 | dev.m_window_height = height; |
| 62 | 62 | } |
| 63 | ||
| 63 | ||
| 64 | 64 | void plot(int x, int y); |
| 65 | 65 | void eof(); |
| 66 | 66 | void update(bitmap_ind16 &bitmap); |
| 67 | ||
| 67 | ||
| 68 | 68 | protected: |
| 69 | 69 | // device-level overrides |
| 70 | 70 | virtual void device_start(); |
| r31374 | r31375 | |
|---|---|---|
| 704 | 704 | c128dcr_se |
| 705 | 705 | c128d81 |
| 706 | 706 | |
| 707 | a1000 | |
| 707 | a1000 // Commodore Amiga 1000 | |
| 708 | 708 | a1000n |
| 709 | a2000 | |
| 709 | a2000 // Commodore Amiga 2000 | |
| 710 | 710 | a2000n |
| 711 | a500 | |
| 711 | a500 // Commodore Amiga 500 | |
| 712 | 712 | a500n |
| 713 | cdtv | |
| 713 | cdtv // Commodore CDTV | |
| 714 | 714 | cdtvn |
| 715 | a3000 | |
| 715 | a3000 // Commodore Amiga 3000 | |
| 716 | 716 | a3000n |
| 717 | a500p | |
| 717 | a500p // Commodore Amiga 500 Plus | |
| 718 | 718 | a500pn |
| 719 | a600 | |
| 719 | a600 // Commodore Amiga 600 | |
| 720 | 720 | a600n |
| 721 | a1200 | |
| 721 | a1200 // Commodore Amiga 1200 | |
| 722 | 722 | a1200n |
| 723 | a4000 | |
| 723 | a4000 // Commodore Amiga 4000/040 | |
| 724 | 724 | a4000n |
| 725 | a400030 | |
| 725 | a400030 // Commodore Amiga 4000/030 | |
| 726 | 726 | a400030n |
| 727 | cd32 | |
| 727 | cd32 // Commodore Amiga CD32 | |
| 728 | 728 | cd32n |
| 729 | a4000t | |
| 729 | a4000t // Commodore Amiga 4000T | |
| 730 | 730 | a4000tn |
| 731 | 731 | |
| 732 | 732 | c65 // 1991 C65 / C64DX (Prototype, NTSC) |
| r31374 | r31375 | |
| 860 | 860 | aprpand |
| 861 | 861 | aprfte |
| 862 | 862 | megapc // 1992 Amstrad plc |
| 863 | megapcpl | |
| 863 | megapcpl | |
| 864 | 864 | megapcpla // AMI BIOS version with Winbond WINBUS chipset |
| 865 | 865 | ec1849 |
| 866 | 866 | t2000sx |
| r31374 | r31375 | |
| 1915 | 1915 | fmtownssj // FM-Towns II SJ |
| 1916 | 1916 | fmtownshr // 1992 FM-Towns II HR |
| 1917 | 1917 | fmtownsmx // FM-Towns II MX |
| 1918 | fmtownsftv // 1994 FM-Towns II FreshTV | |
| 1918 | fmtownsftv // 1994 FM-Towns II FreshTV | |
| 1919 | 1919 | fmtmarty // 1993 Fujitsu FM-Towns Marty |
| 1920 | 1920 | fmtmarty2 // 1993 Fujitsu FM-Towns Marty 2 |
| 1921 | 1921 | carmarty // Fujitsu FM-Towns Car Marty |
| r31374 | r31375 | |
|---|---|---|
| 75 | 75 | </element> |
| 76 | 76 | |
| 77 | 77 | <!-- |
| 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 | |
| 80 | 80 | |
| 81 | Inst Inst Voice Voice | |
| 82 | Assign Function Function Select | |
| 81 | Inst Inst Voice Voice | |
| 82 | Assign Function Function Select | |
| 83 | 83 | |
| 84 | 84 | --> |
| 85 | 85 |
| Previous | 199869 Revisions | Next |