Use inline namespace dcx for common/arch/sdl

This commit is contained in:
Kp 2015-12-05 22:57:24 +00:00
parent de6c2b3982
commit dbe4918f27
23 changed files with 74 additions and 35 deletions

View file

@ -25,6 +25,8 @@
#include "u_mem.h"
#include "console.h"
inline namespace dcx {
namespace {
class current_music_t
@ -184,3 +186,5 @@ void mix_pause_resume_music()
else if (Mix_PlayingMusic())
Mix_PauseMusic();
}
}

View file

@ -25,6 +25,8 @@
#include "joy.h"
#include "args.h"
inline namespace dcx {
void event_poll()
{
SDL_Event event;
@ -200,3 +202,4 @@ fix event_get_idle_seconds()
return (timer_query() - last_event)/F1_0;
}
}

View file

@ -26,6 +26,8 @@
#include "compiler-integer_sequence.h"
#include "compiler-type_traits.h"
inline namespace dcx {
namespace {
int num_joysticks = 0;
@ -381,4 +383,6 @@ int event_joystick_get_button(const d_event &event)
Assert(e.type == EVENT_JOYSTICK_BUTTON_DOWN || e.type == EVENT_JOYSTICK_BUTTON_UP);
return e.button;
}
}
#endif

View file

@ -28,6 +28,8 @@
#include "dxxsconf.h"
#include "compiler-array.h"
inline namespace dcx {
//-------- Variable accessed by outside functions ---------
static bool keyd_repeat; // 1 = use repeats, 0 no repeats
pressed_keys keyd_pressed;
@ -509,3 +511,5 @@ void key_toggle_repeat(int enable)
}
key_flush();
}
}

View file

@ -23,6 +23,8 @@
#include "args.h"
#include "gr.h"
inline namespace dcx {
namespace {
struct flushable_mouseinfo
@ -251,3 +253,5 @@ void mouse_cursor_autohide()
}
SDL_ShowCursor(result);
}
}

View file

@ -31,6 +31,8 @@
#include "partial_range.h"
#include "compiler-range_for.h"
inline namespace dcx {
#define REDBOOK_VOLUME_SCALE 255
static SDL_CD *s_cd = NULL;
@ -319,3 +321,5 @@ void RBAList(void)
range_for (auto &i, partial_range(s_cd->track, static_cast<unsigned>(s_cd->numtracks)))
con_printf(CON_VERBOSE, "RBAudio: CD track %d, type %s, length %d, offset %d", i.id, (i.type == SDL_AUDIO_TRACK) ? "audio" : "data", i.length, i.offset);
}
}

View file

@ -17,6 +17,8 @@
#include "config.h"
#include "multi.h"
inline namespace dcx {
static fix64 F64_RunTime = 0;
fix64 timer_update()
@ -71,3 +73,5 @@ void timer_delay_bound(const unsigned caller_bound)
}
}
}
}

View file

@ -20,6 +20,8 @@
#include "dxxerror.h"
#include "event.h"
inline namespace dcx {
struct window
{
grs_canvas w_canv; // the window's canvas to draw to
@ -221,3 +223,5 @@ int window_is_modal(window &wind)
{
return wind.w_modal;
}
}

View file

@ -10,10 +10,10 @@
* -- MD2211 (2006-04-24)
*/
#ifndef _SDLMIXER_MUSIC_H
#define _SDLMIXER_MUSIC_H
#pragma once
#ifdef __cplusplus
inline namespace dcx {
int mix_play_music(const char *, int);
int mix_play_file(const char *, int, void (*)());
@ -24,6 +24,5 @@ void mix_resume_music();
void mix_pause_resume_music();
void mix_free_music();
#endif
}
#endif

View file

@ -30,10 +30,8 @@ COPYRIGHT 1993-1999 PARALLAX SOFTWARE CORPORATION. ALL RIGHTS RESERVED.
#include "ui.h"
#include "fmtcheck.h"
struct window;
#ifdef __cplusplus
#include "fwd-window.h"
#include "fwd-segment.h"
#include "objnum.h"

View file

@ -23,17 +23,13 @@ COPYRIGHT 1993-1998 PARALLAX SOFTWARE CORPORATION. ALL RIGHTS RESERVED.
*
*/
#ifndef _INFO_H
#define _INFO_H
#pragma once
#ifdef __cplusplus
struct window;
#include "fwd-window.h"
struct window *info_window_create(void);
extern int init_info;
#endif
#endif

View file

@ -23,14 +23,13 @@ COPYRIGHT 1993-1998 PARALLAX SOFTWARE CORPORATION. ALL RIGHTS RESERVED.
*
*/
#ifndef _OBJPAGE_H
#define _OBJPAGE_H
#pragma once
#include "ui.h"
#ifdef __cplusplus
#include "fwd-event.h"
struct d_event;
struct vms_angvec;
int objpage_grab_current(int n);
@ -43,5 +42,3 @@ int objpage_do(const d_event &event);
extern void draw_object_picture(int id, vms_angvec *orient_angles, int type);
#endif
#endif

View file

@ -29,8 +29,7 @@ COPYRIGHT 1993-1999 PARALLAX SOFTWARE CORPORATION. ALL RIGHTS RESERVED.
#include "ui.h"
#ifdef __cplusplus
struct d_event;
#include "fwd-event.h"
extern int TextureLights;
extern int TextureEffects;

View file

@ -12,6 +12,7 @@
#include "maths.h"
#ifdef __cplusplus
inline namespace dcx {
enum event_type : unsigned
{
@ -79,4 +80,5 @@ struct d_select_event : d_event
fix event_get_idle_seconds();
}
#endif

View file

@ -7,13 +7,13 @@
#pragma once
inline namespace dcx {
struct d_event;
struct d_create_event;
struct d_change_event;
struct d_select_event;
#ifdef __cplusplus
enum event_type : unsigned;
int event_init();
@ -44,4 +44,4 @@ static inline void event_toggle_focus(int activate_focus)
// See how long we were idle for
void event_reset_idle_seconds();
#endif
}

View file

@ -11,9 +11,11 @@
#include "fwd-event.h"
#include "fwd-gr.h"
void arch_init();
inline namespace dcx {
struct window;
enum class window_event_result : uint8_t;
void arch_init();
template <typename T>
using window_subfunction = window_event_result (*)(window *menu,const d_event &event, T *userdata);
@ -45,4 +47,6 @@ int window_is_modal(window &wind);
#define WINDOW_SEND_EVENT(w, e) (event.type = e, (WINDOW_SEND_EVENT)(*w, event, __FILE__, __LINE__, #e))
}
#endif

View file

@ -19,7 +19,7 @@
#include "maths.h"
#include <SDL.h>
#ifdef __cplusplus
inline namespace dcx {
struct d_event;
@ -37,13 +37,16 @@ extern void joy_close();
const d_event_joystick_axis_value &event_joystick_get_axis(const d_event &event);
extern void joy_flush();
extern int event_joystick_get_button(const d_event &event);
#endif
}
#else
#define joy_init()
#define joy_flush()
#define joy_close()
#endif
inline namespace dcx {
#if MAX_BUTTONS_PER_JOYSTICK
extern void joy_button_handler(SDL_JoyButtonEvent *jbe);
#else
@ -61,3 +64,5 @@ extern int joy_axis_handler(SDL_JoyAxisEvent *jae);
#else
#define joy_axis_handler(jae) (static_cast<void>(static_cast<SDL_JoyAxisEvent *const &>(jae)), 1)
#endif
}

View file

@ -41,6 +41,8 @@ COPYRIGHT 1993-1999 PARALLAX SOFTWARE CORPORATION. ALL RIGHTS RESERVED.
struct SDL_KeyboardEvent;
inline namespace dcx {
//==========================================================================
// This installs the int9 vector and initializes the keyboard in buffered
// ASCII mode. key_close simply undoes that.
@ -55,7 +57,7 @@ extern array<unsigned char, KEY_BUFFER_SIZE> unicode_frame_buffer;
extern void key_flush(); // Clears the 256 char buffer
extern int event_key_get(const d_event &event); // Get the keycode from the EVENT_KEY_COMMAND event
extern int event_key_get_raw(const d_event &event); // same as above but without mod states
extern unsigned char key_ascii();
unsigned char key_ascii();
class pressed_keys
{
@ -224,4 +226,6 @@ struct key_props
extern const array<key_props, 256> key_properties;
}
#endif

View file

@ -23,6 +23,8 @@
struct SDL_MouseButtonEvent;
struct SDL_MouseMotionEvent;
inline namespace dcx {
#define MOUSE_MAX_BUTTONS 16
#define Z_SENSITIVITY 100
#define MBTN_LEFT 0
@ -87,4 +89,6 @@ static inline void event_mouse_get_delta(const d_event &event, int *dx, int *dy,
*dz = e.dz;
}
}
#endif

View file

@ -17,14 +17,12 @@ AND AGREES TO THE TERMS HEREIN AND ACCEPTS THE SAME BY USE OF THIS FILE.
COPYRIGHT 1993-1999 PARALLAX SOFTWARE CORPORATION. ALL RIGHTS RESERVED.
*/
#ifndef _RBAUDIO_H
#define _RBAUDIO_H
#pragma once
#define RBA_MEDIA_CHANGED -1
#ifdef __cplusplus
inline namespace dcx {
struct RBACHANNELCTL
{
@ -74,6 +72,5 @@ unsigned long RBAGetDiscID();
// List the tracks on the CD
void RBAList(void);
#endif
}
#endif

View file

@ -16,6 +16,7 @@
#include "maths.h"
#ifdef __cplusplus
inline namespace dcx {
fix64 timer_update();
__attribute_warn_unused_result
@ -31,4 +32,5 @@ static inline void timer_delay2(int fps)
timer_delay_bound(1000u / fps);
}
}
#endif

View file

@ -21,6 +21,7 @@
#ifdef __cplusplus
#include "fwd-window.h"
inline namespace dcx {
enum class window_event_result : uint8_t
{
@ -83,4 +84,5 @@ static inline window_event_result (WINDOW_SEND_EVENT)(window &w, const d_event &
return window_send_event(w, event);
}
}
#endif

View file

@ -30,11 +30,10 @@ COPYRIGHT 1993-1999 PARALLAX SOFTWARE CORPORATION. ALL RIGHTS RESERVED.
#ifdef __cplusplus
#include <vector>
#include "fwd-event.h"
#include "compiler-array.h"
#include "compiler-type_traits.h"
struct d_event;
#if defined(DXX_BUILD_DESCENT_I) || defined(DXX_BUILD_DESCENT_II)
struct control_info {
template <typename T>