From d14a2d2c32bfa68cfd2f4cee0b7cbbcb51baf18e Mon Sep 17 00:00:00 2001 From: Curt Coder Date: Mon, 14 Sep 2009 12:28:14 +0000 Subject: [PATCH] Added device_find_child_by_tag helper function. --- src/emu/devintrf.c | 21 +++++++++++++++++++++ src/emu/devintrf.h | 3 +++ 2 files changed, 24 insertions(+) diff --git a/src/emu/devintrf.c b/src/emu/devintrf.c index b8b2c321bec..57397dd18a1 100644 --- a/src/emu/devintrf.c +++ b/src/emu/devintrf.c @@ -360,6 +360,27 @@ const device_config *device_list_find_by_tag(const device_config *listhead, cons } +/*------------------------------------------------- + device_find_child_by_tag - retrieve a child + device configuration based on a tag +-------------------------------------------------*/ + +const device_config *device_find_child_by_tag(const device_config *owner, const char *tag) +{ + astring *tempstring; + const device_config *child; + + assert(owner != NULL); + assert(tag != NULL); + + tempstring = astring_alloc(); + child = device_list_find_by_tag(owner->machine->config->devicelist, device_build_tag(tempstring, owner, tag)); + astring_free(tempstring); + + return child; +} + + /*------------------------------------------------- device_list_index - return the index of a device based on its type and tag; diff --git a/src/emu/devintrf.h b/src/emu/devintrf.h index 78d60ffc67f..31d8db7cca1 100644 --- a/src/emu/devintrf.h +++ b/src/emu/devintrf.h @@ -367,6 +367,9 @@ const device_config *device_list_next(const device_config *prevdevice, device_ty /* retrieve a device configuration based on a tag */ const device_config *device_list_find_by_tag(const device_config *listhead, const char *tag); +/* retrieve a child device configuration based on a tag */ +const device_config *device_find_child_by_tag(const device_config *owner, const char *tag); + /* return the index of a device based on its type and tag; DEVICE_TYPE_WILDCARD is allowed */ int device_list_index(const device_config *listhead, device_type type, const char *tag);