Commit graph

65 commits

Author SHA1 Message Date
Kp ea153a60fa Switch libmve to C++ casts 2016-09-04 00:02:52 +00:00
Kp 439d82955f Switch mveplay.cpp to reinterpret_cast 2016-09-04 00:02:52 +00:00
Kp bbdecad649 Add helper macro to handle printf .* conversion for 32/64
Field width conversion `.*` always takes an `int`.

On Win32, casting `long` to `int` triggers a `-Wuseless-cast` warning.
Omitting the cast works correctly.

On Linux/amd64, casting `long` to `int` works correctly.
Omitting the cast triggers a `-Wformat` warning.

Add a macro that conditionally expands to `static_cast<int>` or to ``,
as necessary for the target platform.
2016-08-19 03:41:41 +00:00
Kp 9be68f4e99 Add SConf test for struct timespec 2016-08-19 03:41:40 +00:00
Kp cb99240c2c Remove useless casts in d2x-rebirth/libmve/decoder8.cpp 2016-08-17 04:44:22 +00:00
Kp 7f3b725c40 Use std::swap to exchange mveplay back buffer pointers 2016-08-17 04:44:22 +00:00
Kp c636dc4b98 Convert various static const expressions to constexpr 2016-07-16 16:52:04 +00:00
Kp b0a2205a4e Convert various pointer casts to reinterpret_cast 2016-07-06 01:54:24 +00:00
Kp 19f31eb420 Rewrite simple pointer casts from C style to reinterpret_cast<>
This pass only targets int8_t and uint8_t.

s/(\s*\(u\?int8_t\s*\*\+\)\s*)\s*(/reinterpret_cast<\1>(/g
2016-07-03 00:54:14 +00:00
Kp a7ceee3c03 Add parentheses around target of simple unsigned char casts
C casts do not require parentheses.  C++ casts require grouping around
the target.  Prepare for conversion to C++ casts by adding otherwise
unnecessary parentheses around the target of simple C casts.

s/(\s*unsigned\s\+char\s*\(\*\+\)\s*)\s*\([&+-]\?\)\([[:alnum:]_.]\+\s*->\s*\)*\([[:alnum:]_.]\+\)\(\s*\([];+>)*\/^%,|&<>]\)\|$\|\(\s*-\s*[^>]\)\)/(uint8_t \1)(\2\3\4)\5/g
2016-07-03 00:54:14 +00:00
Kp 3469ff8c34 Change (short*) to (int16_t*)
Uses of `(short*)` usually want exactly a 16-bit signed integer.  Most
platforms provide that as `short`, but that is not guaranteed.

s/(short \(*\+\)\s*)/(int16_t \1)/g
2016-06-27 04:11:13 +00:00
Kp 65f68877aa Rewrite simple integer casts from C style to static_cast<>
This pass only targets commonly used standard types.

s/(\(\s*\(\(un\)\?signed\|int\|char\|short\|long\|float\|double\|s\?size_t\|\(u\?int[[:digit:]]\+_t\)\)\)\s*)\s*(/static_cast<\1>(/g
2016-06-16 03:56:44 +00:00
Kp 1b12a3f7ef Add parentheses around target of more complicated casts
C casts do not require parentheses.  C++ casts require grouping around
the target.  Prepare for conversion to C++ casts by adding otherwise
unnecessary parentheses around the target of some C casts.

This pass attempts to process expressions that involve parenthesized or
bracketed subexpressions, but only if those subexpressions do not
themselves contain parenthesized or bracketed subexpressions.

	(int) f(1);	// changed
	(int) f(g());	// not changed

perl -p -i -e 's/(\(\s*((?:un)?signed|int|char|short|long|float|double|s?size_t|(?:u?int[[:digit:]]+_t))\s*\**\s*\)\s*)([&+-]?)([[:alnum:]_.]+\s*->\s*)*([[:alnum:]_.]+)((?:\s*(?:\[[^][]*\])*|(?:\([^()]*\))*))(\s*([;+>*\/^%,|&<>])|$|(\s*-\s*[^>]))/\1\(\3\4\5\6\)\7/g'
2016-06-12 03:45:37 +00:00
Kp b282bea173 Rewrite simple integer casts from C style to static_cast<>
This pass only targets commonly used standard types.

s/(\(\s*\(\(un\)\?signed\|int\|char\|short\|long\|float\|double\|s\?size_t\|\(u\?int[[:digit:]]\+_t\)\)\)\s*)\s*(/static_cast<\1>(/g
2016-06-05 01:04:26 +00:00
Kp 7fdce88558 Add parentheses around target of simple casts
C casts do not require parentheses.  C++ casts require grouping around
the target.  Prepare for conversion to C++ casts by adding otherwise
unnecessary parentheses around the target of simple C casts.

This pass does not attempt to process expressions that involve
any subexpression that can nest arbitrarily, such as parentheses or
brackets.  It also works only on commonly used standard types.

	(int) a->b;	// changed
	(int) a[b];	// not changed

s/\((\s*\(\(un\)\?signed\|int\|char\|short\|long\|float\|double\|s\?size_t\|\(u\?int[[:digit:]]\+_t\)\)\s*\**\s*)\s*\)\([&+-]\?\)\([[:alnum:]_.]\+\s*->\s*\)*\([[:alnum:]_.]\+\)\(\s*\([];+>)*\/^%,|&<>]\)\|$\|\(\s*-\s*[^>]\)\)/\1(\5\6\7)\8/g
2016-06-05 01:04:25 +00:00
Kp 195c589e3f Move file-local classes into anonymous namespace 2016-03-04 04:12:35 +00:00
Kp a579f75d05 Move SndDisableSdlMixer to CGameArg 2015-11-24 04:05:36 +00:00
Kp edea687627 Remove HAVE_STRUCT_TIMEVAL
SConstruct defines it for all platforms.  It is only false on Mac OS 9,
which is no longer supported.
2015-10-27 03:04:49 +00:00
Kp 15fb75c1c7 Fix check_header_includes build 2015-07-25 23:10:45 +00:00
Kp ce72014e2e Always parse WORDS_BIGENDIAN and !WORDS_BIGENDIAN 2015-06-13 22:42:21 +00:00
Kp 7243e76c80 Fix gcc-4.6 decoder8 build
Fixes: 8a28f7e1c2 ("Use array<> for movie decoder")
2015-05-22 03:33:20 +00:00
Kp 6792c1bc4b Enable -Wunused-parameter 2015-04-26 20:15:56 +00:00
Kp f8ac14b737 Convert mvelib to vector<uint8_t> 2015-04-26 20:15:51 +00:00
Kp 8a28f7e1c2 Use array<> for movie decoder 2015-04-02 02:36:56 +00:00
Kp f900d4a5ee Remove RAIIdmem::operator pointer
Mac OS X defines uint_fast32_t to unsigned int, causing ambiguous
overloads between RAIIdmem::operator[](std::size_t) and
RAIIdmem::operator[](int).  Adding a disambiguating overload for OS X
breaks Windows.  Remove operator pointer and operator[].  Rely on the
inherited operator[] for indexing.  Require users to call ->get() to
convert to a simple pointer.

First btb ambiguity reported: https://github.com/dxx-rebirth/dxx-rebirth/pull/34
Second btb ambiguity reported: https://github.com/dxx-rebirth/dxx-rebirth/pull/43
2015-02-17 03:52:59 +00:00
Kp 91cc111295 Provide SndDisableSdlMixer=true if !USE_SDLMIXER
Accept -nosdlmixer as a no-op in !USE_SDLMIXER builds.
2015-02-08 17:43:29 +00:00
Kp ff4a0ccd70 Fix RAIIdmem array usage
Some RAIIdmem instances managed a T[], but were declared to manage a T.
2015-01-28 03:42:53 +00:00
Kp 786b7c35a5 Use unique_ptr for mve_audio_spec 2015-01-28 03:42:53 +00:00
Kp accd1db476 Use unique_ptr for mve_audio_buffers 2015-01-28 03:42:52 +00:00
Kp a3edc2b4f8 Use unique_ptr for MVEFILE::cur_chunk 2015-01-28 03:42:52 +00:00
Kp 84e3a03451 Remove unused parameters 2015-01-18 01:58:33 +00:00
Bradley Bell 3daa0f63b1 Add search SDL_mixer framework paths for headers instead of using <Framework/Header.h> notation 2014-12-03 15:14:18 -08:00
Kp 91a2eb8491 Include <vector> in mveplay.cpp for std::vector
Reported by btb: https://github.com/dxx-rebirth/dxx-rebirth/pull/12
Fixed by btb: f502740fdd
2014-11-30 17:01:39 +00:00
Kp ad527a7551 Use unique_ptr for MVEFILE 2014-11-01 15:04:30 +00:00
Kp a42e7c3db1 Use unique_ptr for MVESTREAM 2014-11-01 15:00:48 +00:00
Kp 279233cf24 Use std::vector for MVE buffer 2014-11-01 15:00:04 +00:00
Kp d8024d4d26 Use RAII to manage MVESTREAM 2014-10-29 02:59:08 +00:00
Kp 19bb554f31 Move MVESTREAM pointer up one layer 2014-10-29 02:57:52 +00:00
Kp 6934dc863c Fix gcc 4.6 build of libmve 2014-10-16 01:40:48 +00:00
Kp 4e368ac946 Make mve args const 2014-10-10 02:57:07 +00:00
Kp 6943024647 Fix signaure of mve_cb_Alloc 2014-10-10 02:43:40 +00:00
Kp 2d7ce50951 Propagate for variables in d2x-rebirth/libmve/mveplay.cpp 2014-09-26 02:42:16 +00:00
Kp 301629be91 Propagate for variables in d2x-rebirth/libmve/mve_audio.cpp 2014-09-26 02:42:16 +00:00
Kp c79281de1e Propagate for variables in d2x-rebirth/libmve/decoder8.cpp 2014-09-26 02:42:15 +00:00
Kp dc3924c076 Precompute MVE tables 2014-06-24 03:08:42 +00:00
zico ad7cb106bc Changed custom D1X license to GPLv3 2014-06-01 19:55:23 +02:00
Kp 073f00974a Eliminate uses of the typedef struct X { ... } X; pattern
C++ does not require this pattern.

import re, fileinput
to = re.compile(r'^typedef struct ([a-z_A-Z]+)\s*{')
tc = re.compile(r'^}(.*?)\s*([a-z_A-Z]+);$')
osn = None
for line in fileinput.input(inplace=True):
	m = to.match(line)
	if m:
		osn = m.group(1)
		print 'struct %s\n{' % osn
		continue
	if osn:
		m = tc.match(line)
		if m:
			csn = m.group(2)
			if osn == csn:
				print '}%s;' % m.group(1)
				osn = None
				continue
			else:
				osn = None
	print line,
2013-12-28 22:48:07 +00:00
Kp a3d66a3b37 Add typedef palette_array_t for palette data 2013-12-22 00:05:13 +00:00
Kp cf49fd0c98 Fix memory leak in audio conversion 2013-12-20 03:24:09 +00:00
Kp 75c229c6bf Normalize con_printf newline usage 2013-12-07 21:13:37 +00:00