Revert "Make some functions static"

This reverts commit 6b04db075d45ad5258586a4ffd5db46cb108ebdc.
This commit is contained in:
twinaphex 2015-06-03 10:13:25 +02:00
parent 6b04db075d
commit bfcf1a7288
9 changed files with 404 additions and 311 deletions

View File

@ -339,6 +339,7 @@ ifeq ($(HAVE_MENU_COMMON), 1)
menu/menu_entry.o \
menu/menu_navigation.o \
menu/menu_setting.o \
menu/menu_settings_list.o \
menu/menu_shader.o \
menu/menu_entries_cbs_ok.o \
menu/menu_entries_cbs_cancel.o \

View File

@ -714,6 +714,7 @@ MENU
#include "../menu/menu.c"
#include "../menu/menu_entry.c"
#include "../menu/menu_setting.c"
#include "../menu/menu_settings_list.c"
#include "../menu/menu_list.c"
#include "../menu/menu_entries_cbs_ok.c"
#include "../menu/menu_entries_cbs_cancel.c"

View File

@ -202,8 +202,7 @@ static void menu_free_list(menu_handle_t *menu)
if (!menu)
return;
if (menu->list_settings)
free(menu->list_settings);
settings_list_free(menu->list_settings);
menu_list_free(menu->menu_list);
menu->menu_list = NULL;
menu->list_settings = NULL;

View File

@ -1215,8 +1215,10 @@ static int menu_displaylist_parse_settings(menu_handle_t *menu,
rarch_setting_t *setting = NULL;
settings_t *settings = config_get_ptr();
setting_realloc(menu->list_settings, setting_flags);
if (menu && menu->list_settings)
settings_list_free(menu->list_settings);
menu->list_settings = setting_new(setting_flags);
setting = menu_setting_find(info->label);
if (!setting)
@ -1266,7 +1268,8 @@ static int menu_displaylist_parse_settings_in_subgroup(menu_displaylist_info_t *
}
}
setting_realloc(menu->list_settings, SL_FLAG_ALL_SETTINGS);
settings_list_free(menu->list_settings);
menu->list_settings = setting_new(SL_FLAG_ALL_SETTINGS);
info->setting = menu_setting_find(elem0);
@ -1843,7 +1846,8 @@ static int menu_displaylist_parse(menu_displaylist_info_t *info,
*need_push = true;
break;
case DISPLAYLIST_SETTINGS_ALL:
setting_realloc(menu->list_settings, SL_FLAG_ALL_SETTINGS);
settings_list_free(menu->list_settings);
menu->list_settings = setting_new(SL_FLAG_ALL_SETTINGS);
setting = menu_setting_find("Driver Settings");

View File

@ -27,7 +27,7 @@
#include "menu_list.h"
#include "menu_navigation.h"
#include "menu_database.h"
#include "menu_setting.h"
#include "menu_settings_list.h"
#include "../../libretro.h"
#ifdef __cplusplus

View File

@ -18,6 +18,7 @@
#include "menu.h"
#include "menu_setting.h"
#include "menu_settings_list.h"
#include "../driver.h"
#include "../gfx/video_monitor.h"
@ -3204,25 +3205,6 @@ static void general_write_handler(void *data)
event_command(rarch_cmd);
}
static bool settings_list_append(rarch_setting_t **list,
rarch_setting_info_t *list_info, rarch_setting_t value)
{
if (!list || !*list || !list_info)
return false;
if (list_info->index == list_info->size)
{
list_info->size *= 2;
*list = (rarch_setting_t*)
realloc(*list, sizeof(rarch_setting_t) * list_info->size);
if (!*list)
return false;
}
(*list)[list_info->index++] = value;
return true;
}
#define START_GROUP(group_info, NAME) \
{ \
group_info.name = NAME; \
@ -3340,26 +3322,6 @@ static void setting_add_special_callbacks(
(*list)[idx].action_toggle = setting_string_action_toggle_driver;
}
static void null_write_handler(void *data)
{
(void)data;
}
static void settings_list_current_add_flags(
rarch_setting_t **list,
rarch_setting_info_t *list_info,
unsigned values)
{
unsigned idx = list_info->index - 1;
(*list)[idx].flags |= values;
if (values & SD_FLAG_IS_DEFERRED)
{
(*list)[idx].deferred_handler = (*list)[idx].change_handler;
(*list)[idx].change_handler = null_write_handler;
}
}
static void settings_data_list_current_add_flags(
rarch_setting_t **list,
rarch_setting_info_t *list_info,
@ -3385,52 +3347,6 @@ static void overlay_enable_toggle_change_handler(void *data)
event_command(EVENT_CMD_OVERLAY_DEINIT);
}
static void settings_list_current_add_bind_type(
rarch_setting_t **list,
rarch_setting_info_t *list_info,
unsigned type)
{
unsigned idx = list_info->index - 1;
(*list)[idx].bind_type = type;
}
static void settings_list_current_add_range(
rarch_setting_t **list,
rarch_setting_info_t *list_info,
float min, float max, float step,
bool enforce_minrange_enable, bool enforce_maxrange_enable)
{
unsigned idx = list_info->index - 1;
(*list)[idx].min = min;
(*list)[idx].step = step;
(*list)[idx].max = max;
(*list)[idx].enforce_minrange = enforce_minrange_enable;
(*list)[idx].enforce_maxrange = enforce_maxrange_enable;
settings_list_current_add_flags(list, list_info, SD_FLAG_HAS_RANGE);
}
static void settings_list_current_add_values(
rarch_setting_t **list,
rarch_setting_info_t *list_info,
const char *values)
{
unsigned idx = list_info->index - 1;
(*list)[idx].values = values;
}
static void settings_list_current_add_cmd(
rarch_setting_t **list,
rarch_setting_info_t *list_info,
enum event_command values)
{
unsigned idx = list_info->index - 1;
(*list)[idx].cmd_trigger.idx = values;
}
static bool setting_append_list_main_menu_options(
rarch_setting_t **list,
rarch_setting_info_t *list_info)
@ -6720,40 +6636,6 @@ static bool setting_append_list_privacy_options(
return true;
}
static rarch_setting_info_t *settings_info_list_new(void)
{
rarch_setting_info_t *list_info = (rarch_setting_info_t*)
calloc(1, sizeof(*list_info));
if (!list_info)
return NULL;
list_info->size = 32;
return list_info;
}
static void settings_info_list_free(rarch_setting_info_t *list_info)
{
if (list_info)
free(list_info);
list_info = NULL;
}
static rarch_setting_t *settings_list_new(unsigned size)
{
rarch_setting_t *list = (rarch_setting_t*)calloc(size, sizeof(*list));
if (!list)
return NULL;
return list;
}
static void settings_list_free(rarch_setting_t *list)
{
if (list)
free(list);
}
/**
* setting_new:
@ -6764,7 +6646,7 @@ static void settings_list_free(rarch_setting_t *list)
* Returns: settings list composed of all requested
* settings on success, otherwise NULL.
**/
static rarch_setting_t *setting_new(unsigned mask)
rarch_setting_t *setting_new(unsigned mask)
{
rarch_setting_t terminator = { ST_NONE };
rarch_setting_t* list = NULL;
@ -6951,14 +6833,6 @@ error:
return NULL;
}
void setting_realloc(rarch_setting_t *setting, unsigned mask)
{
if (setting)
settings_list_free(setting);
setting = setting_new(mask);
}
bool setting_is_of_path_type(rarch_setting_t *setting)
{
if (

View File

@ -18,13 +18,10 @@
#define _MENU_SETTING_H
#include <stdint.h>
#include <stdlib.h>
#include <boolean.h>
#include <file/file_list.h>
#include <file/config_file.h>
#include <retro_miscellaneous.h>
#include "../command_event.h"
#include "menu_settings_list.h"
#define BINDFOR(s) (*(&(s))->value.keybind)
@ -32,178 +29,6 @@
extern "C" {
#endif
enum setting_type
{
ST_NONE = 0,
ST_ACTION,
ST_BOOL,
ST_INT,
ST_UINT,
ST_FLOAT,
ST_PATH,
ST_DIR,
ST_STRING,
ST_HEX,
ST_BIND,
ST_GROUP,
ST_SUB_GROUP,
ST_END_GROUP,
ST_END_SUB_GROUP
};
enum setting_flags
{
SD_FLAG_PATH_DIR = (1 << 0),
SD_FLAG_PATH_FILE = (1 << 1),
SD_FLAG_ALLOW_EMPTY = (1 << 2),
SD_FLAG_VALUE_DESC = (1 << 3),
SD_FLAG_HAS_RANGE = (1 << 4),
SD_FLAG_ALLOW_INPUT = (1 << 5),
SD_FLAG_IS_DRIVER = (1 << 6),
SD_FLAG_EXIT = (1 << 7),
SD_FLAG_CMD_APPLY_AUTO = (1 << 8),
SD_FLAG_IS_DEFERRED = (1 << 9),
SD_FLAG_BROWSER_ACTION = (1 << 10),
SD_FLAG_ADVANCED = (1 << 11)
};
enum setting_list_flags
{
SL_FLAG_MAIN_MENU = (1 << 0),
SL_FLAG_DRIVER_OPTIONS = (1 << 1),
SL_FLAG_CORE_OPTIONS = (1 << 2),
SL_FLAG_CONFIGURATION_OPTIONS = (1 << 3),
SL_FLAG_REWIND_OPTIONS = (1 << 4),
SL_FLAG_VIDEO_OPTIONS = (1 << 5),
SL_FLAG_SHADER_OPTIONS = (1 << 6),
SL_FLAG_FONT_OPTIONS = (1 << 7),
SL_FLAG_AUDIO_OPTIONS = (1 << 8),
SL_FLAG_INPUT_OPTIONS = (1 << 9),
SL_FLAG_OVERLAY_OPTIONS = (1 << 10),
SL_FLAG_OSK_OVERLAY_OPTIONS = (1 << 11),
SL_FLAG_MENU_OPTIONS = (1 << 12),
SL_FLAG_UI_OPTIONS = (1 << 13),
SL_FLAG_CORE_UPDATER_OPTIONS = (1 << 14),
SL_FLAG_NETPLAY_OPTIONS = (1 << 15),
SL_FLAG_USER_OPTIONS = (1 << 16),
SL_FLAG_DIRECTORY_OPTIONS = (1 << 17),
SL_FLAG_PRIVACY_OPTIONS = (1 << 18),
SL_FLAG_PLAYLIST_OPTIONS = (1 << 19),
SL_FLAG_ARCHIVE_OPTIONS = (1 << 20),
SL_FLAG_PATCH_OPTIONS = (1 << 21),
SL_FLAG_RECORDING_OPTIONS = (1 << 21),
SL_FLAG_FRAME_THROTTLE_OPTIONS= (1 << 22),
SL_FLAG_LOGGING_OPTIONS = (1 << 23),
SL_FLAG_SAVING_OPTIONS = (1 << 24),
SL_FLAG_ALL = (1 << 25),
};
#define SL_FLAG_ALL_SETTINGS (SL_FLAG_ALL - SL_FLAG_MAIN_MENU)
typedef void (*change_handler_t )(void *data);
typedef int (*action_toggle_handler_t )(void *data, unsigned action, bool wraparound);
typedef int (*action_up_or_down_handler_t )(void *data, unsigned action);
typedef int (*action_start_handler_t )(void *data);
typedef int (*action_iterate_handler_t )(unsigned action);
typedef int (*action_cancel_handler_t )(void *data, unsigned action);
typedef int (*action_ok_handler_t )(void *data, unsigned action);
typedef void (*get_string_representation_t )(void *data, char *s, size_t len);
typedef struct rarch_setting_info
{
int index;
int size;
} rarch_setting_info_t;
typedef struct rarch_setting_group_info
{
const char *name;
} rarch_setting_group_info_t;
typedef struct rarch_setting
{
enum setting_type type;
const char *name;
uint32_t size;
const char* short_description;
const char* group;
const char* subgroup;
uint32_t index;
uint32_t index_offset;
double min;
double max;
const char* values;
uint64_t flags;
change_handler_t change_handler;
change_handler_t deferred_handler;
change_handler_t read_handler;
action_start_handler_t action_start;
action_iterate_handler_t action_iterate;
action_toggle_handler_t action_toggle;
action_up_or_down_handler_t action_up_or_down;
action_cancel_handler_t action_cancel;
action_ok_handler_t action_ok;
get_string_representation_t get_string_representation;
union
{
bool boolean;
int integer;
unsigned int unsigned_integer;
float fraction;
const char* string;
const struct retro_keybind* keybind;
} default_value;
union
{
bool* boolean;
int* integer;
unsigned int* unsigned_integer;
float* fraction;
char* string;
struct retro_keybind* keybind;
} value;
union
{
bool boolean;
int integer;
unsigned int unsigned_integer;
float fraction;
} original_value;
struct
{
const char *empty_path;
} dir;
struct
{
enum event_command idx;
bool triggered;
} cmd_trigger;
struct
{
const char *off_label;
const char *on_label;
} boolean;
unsigned bind_type;
unsigned browser_selection_type;
float step;
const char *rounding_fraction;
bool enforce_minrange;
bool enforce_maxrange;
} rarch_setting_t;
void menu_setting_apply_deferred(void);
int menu_setting_set_flags(rarch_setting_t *setting);
@ -508,7 +333,16 @@ void setting_get_label(file_list_t *list, char *s,
size_t len, unsigned *w, unsigned type,
const char *menu_label, const char *label, unsigned idx);
void setting_realloc(rarch_setting_t *setting, unsigned mask);
/**
* setting_new:
* @mask : Bitmask of settings to include.
*
* Request a list of settings based on @mask.
*
* Returns: settings list composed of all requested
* settings on success, otherwise NULL.
**/
rarch_setting_t* setting_new(unsigned mask);
bool setting_is_of_path_type(rarch_setting_t *setting);

136
menu/menu_settings_list.c Normal file
View File

@ -0,0 +1,136 @@
/* RetroArch - A frontend for libretro.
* Copyright (C) 2013-2014 - Jason Fetters
* Copyright (C) 2011-2015 - Daniel De Matteis
*
* RetroArch is free software: you can redistribute it and/or modify it under the terms
* of the GNU General Public License as published by the Free Software Found-
* ation, either version 3 of the License, or (at your option) any later version.
*
* RetroArch is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
* PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with RetroArch.
* If not, see <http://www.gnu.org/licenses/>.
*/
#include "menu_settings_list.h"
void settings_info_list_free(rarch_setting_info_t *list_info)
{
if (list_info)
free(list_info);
list_info = NULL;
}
rarch_setting_info_t *settings_info_list_new(void)
{
rarch_setting_info_t *list_info = (rarch_setting_info_t*)
calloc(1, sizeof(*list_info));
if (!list_info)
return NULL;
list_info->index = 0;
list_info->size = 32;
return list_info;
}
bool settings_list_append(rarch_setting_t **list,
rarch_setting_info_t *list_info, rarch_setting_t value)
{
if (!list || !*list || !list_info)
return false;
if (list_info->index == list_info->size)
{
list_info->size *= 2;
*list = (rarch_setting_t*)
realloc(*list, sizeof(rarch_setting_t) * list_info->size);
if (!*list)
return false;
}
(*list)[list_info->index++] = value;
return true;
}
static void null_write_handler(void *data)
{
(void)data;
}
void settings_list_current_add_bind_type(
rarch_setting_t **list,
rarch_setting_info_t *list_info,
unsigned type)
{
unsigned idx = list_info->index - 1;
(*list)[idx].bind_type = type;
}
void settings_list_current_add_flags(
rarch_setting_t **list,
rarch_setting_info_t *list_info,
unsigned values)
{
unsigned idx = list_info->index - 1;
(*list)[idx].flags |= values;
if (values & SD_FLAG_IS_DEFERRED)
{
(*list)[idx].deferred_handler = (*list)[idx].change_handler;
(*list)[idx].change_handler = null_write_handler;
}
}
void settings_list_current_add_range(
rarch_setting_t **list,
rarch_setting_info_t *list_info,
float min, float max, float step,
bool enforce_minrange_enable, bool enforce_maxrange_enable)
{
unsigned idx = list_info->index - 1;
(*list)[idx].min = min;
(*list)[idx].step = step;
(*list)[idx].max = max;
(*list)[idx].enforce_minrange = enforce_minrange_enable;
(*list)[idx].enforce_maxrange = enforce_maxrange_enable;
settings_list_current_add_flags(list, list_info, SD_FLAG_HAS_RANGE);
}
void settings_list_current_add_values(
rarch_setting_t **list,
rarch_setting_info_t *list_info,
const char *values)
{
unsigned idx = list_info->index - 1;
(*list)[idx].values = values;
}
void settings_list_current_add_cmd(
rarch_setting_t **list,
rarch_setting_info_t *list_info,
enum event_command values)
{
unsigned idx = list_info->index - 1;
(*list)[idx].cmd_trigger.idx = values;
}
void settings_list_free(rarch_setting_t *list)
{
if (list)
free(list);
}
rarch_setting_t *settings_list_new(unsigned size)
{
rarch_setting_t *list = (rarch_setting_t*)calloc(size, sizeof(*list));
if (!list)
return NULL;
return list;
}

244
menu/menu_settings_list.h Normal file
View File

@ -0,0 +1,244 @@
/* RetroArch - A frontend for libretro.
* Copyright (C) 2013-2014 - Jason Fetters
* Copyright (C) 2011-2015 - Daniel De Matteis
*
* RetroArch is free software: you can redistribute it and/or modify it under the terms
* of the GNU General Public License as published by the Free Software Found-
* ation, either version 3 of the License, or (at your option) any later version.
*
* RetroArch is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
* PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with RetroArch.
* If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef _SETTINGS_LIST_H
#define _SETTINGS_LIST_H
#include <stdint.h>
#include <stdlib.h>
#include <boolean.h>
#include "../command_event.h"
#ifdef __cplusplus
extern "C" {
#endif
enum setting_type
{
ST_NONE = 0,
ST_ACTION,
ST_BOOL,
ST_INT,
ST_UINT,
ST_FLOAT,
ST_PATH,
ST_DIR,
ST_STRING,
ST_HEX,
ST_BIND,
ST_GROUP,
ST_SUB_GROUP,
ST_END_GROUP,
ST_END_SUB_GROUP
};
enum setting_flags
{
SD_FLAG_PATH_DIR = (1 << 0),
SD_FLAG_PATH_FILE = (1 << 1),
SD_FLAG_ALLOW_EMPTY = (1 << 2),
SD_FLAG_VALUE_DESC = (1 << 3),
SD_FLAG_HAS_RANGE = (1 << 4),
SD_FLAG_ALLOW_INPUT = (1 << 5),
SD_FLAG_IS_DRIVER = (1 << 6),
SD_FLAG_EXIT = (1 << 7),
SD_FLAG_CMD_APPLY_AUTO = (1 << 8),
SD_FLAG_IS_DEFERRED = (1 << 9),
SD_FLAG_BROWSER_ACTION = (1 << 10),
SD_FLAG_ADVANCED = (1 << 11)
};
enum setting_list_flags
{
SL_FLAG_MAIN_MENU = (1 << 0),
SL_FLAG_DRIVER_OPTIONS = (1 << 1),
SL_FLAG_CORE_OPTIONS = (1 << 2),
SL_FLAG_CONFIGURATION_OPTIONS = (1 << 3),
SL_FLAG_REWIND_OPTIONS = (1 << 4),
SL_FLAG_VIDEO_OPTIONS = (1 << 5),
SL_FLAG_SHADER_OPTIONS = (1 << 6),
SL_FLAG_FONT_OPTIONS = (1 << 7),
SL_FLAG_AUDIO_OPTIONS = (1 << 8),
SL_FLAG_INPUT_OPTIONS = (1 << 9),
SL_FLAG_OVERLAY_OPTIONS = (1 << 10),
SL_FLAG_OSK_OVERLAY_OPTIONS = (1 << 11),
SL_FLAG_MENU_OPTIONS = (1 << 12),
SL_FLAG_UI_OPTIONS = (1 << 13),
SL_FLAG_CORE_UPDATER_OPTIONS = (1 << 14),
SL_FLAG_NETPLAY_OPTIONS = (1 << 15),
SL_FLAG_USER_OPTIONS = (1 << 16),
SL_FLAG_DIRECTORY_OPTIONS = (1 << 17),
SL_FLAG_PRIVACY_OPTIONS = (1 << 18),
SL_FLAG_PLAYLIST_OPTIONS = (1 << 19),
SL_FLAG_ARCHIVE_OPTIONS = (1 << 20),
SL_FLAG_PATCH_OPTIONS = (1 << 21),
SL_FLAG_RECORDING_OPTIONS = (1 << 21),
SL_FLAG_FRAME_THROTTLE_OPTIONS= (1 << 22),
SL_FLAG_LOGGING_OPTIONS = (1 << 23),
SL_FLAG_SAVING_OPTIONS = (1 << 24),
SL_FLAG_ALL = (1 << 25),
};
#define SL_FLAG_ALL_SETTINGS (SL_FLAG_ALL - SL_FLAG_MAIN_MENU)
typedef void (*change_handler_t )(void *data);
typedef int (*action_toggle_handler_t )(void *data, unsigned action, bool wraparound);
typedef int (*action_up_or_down_handler_t )(void *data, unsigned action);
typedef int (*action_start_handler_t )(void *data);
typedef int (*action_iterate_handler_t )(unsigned action);
typedef int (*action_cancel_handler_t )(void *data, unsigned action);
typedef int (*action_ok_handler_t )(void *data, unsigned action);
typedef void (*get_string_representation_t )(void *data, char *s, size_t len);
typedef struct rarch_setting_info
{
int index;
int size;
} rarch_setting_info_t;
typedef struct rarch_setting_group_info
{
const char *name;
} rarch_setting_group_info_t;
typedef struct rarch_setting
{
enum setting_type type;
const char *name;
uint32_t size;
const char* short_description;
const char* group;
const char* subgroup;
uint32_t index;
uint32_t index_offset;
double min;
double max;
const char* values;
uint64_t flags;
change_handler_t change_handler;
change_handler_t deferred_handler;
change_handler_t read_handler;
action_start_handler_t action_start;
action_iterate_handler_t action_iterate;
action_toggle_handler_t action_toggle;
action_up_or_down_handler_t action_up_or_down;
action_cancel_handler_t action_cancel;
action_ok_handler_t action_ok;
get_string_representation_t get_string_representation;
union
{
bool boolean;
int integer;
unsigned int unsigned_integer;
float fraction;
const char* string;
const struct retro_keybind* keybind;
} default_value;
union
{
bool* boolean;
int* integer;
unsigned int* unsigned_integer;
float* fraction;
char* string;
struct retro_keybind* keybind;
} value;
union
{
bool boolean;
int integer;
unsigned int unsigned_integer;
float fraction;
} original_value;
struct
{
const char *empty_path;
} dir;
struct
{
enum event_command idx;
bool triggered;
} cmd_trigger;
struct
{
const char *off_label;
const char *on_label;
} boolean;
unsigned bind_type;
unsigned browser_selection_type;
float step;
const char *rounding_fraction;
bool enforce_minrange;
bool enforce_maxrange;
} rarch_setting_t;
bool settings_list_append(rarch_setting_t **list,
rarch_setting_info_t *list_info, rarch_setting_t value);
void settings_list_current_add_flags(
rarch_setting_t **list,
rarch_setting_info_t *list_info,
unsigned values);
void settings_list_current_add_bind_type(
rarch_setting_t **list,
rarch_setting_info_t *list_info,
unsigned type);
void settings_list_current_add_range(
rarch_setting_t **list,
rarch_setting_info_t *list_info,
float min, float max, float step,
bool enforce_minrange_enable, bool enforce_maxrange_enable);
void settings_list_current_add_values(
rarch_setting_t **list,
rarch_setting_info_t *list_info,
const char *values);
void settings_list_current_add_cmd(
rarch_setting_t **list,
rarch_setting_info_t *list_info,
enum event_command values);
void settings_info_list_free(rarch_setting_info_t *list_info);
void settings_list_free(rarch_setting_t *list);
rarch_setting_info_t *settings_info_list_new(void);
rarch_setting_t *settings_list_new(unsigned size);
#ifdef __cplusplus
}
#endif
#endif