Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
M
magicseteditor
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Packages
Packages
Container Registry
Analytics
Analytics
CI / CD
Code Review
Insights
Issues
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
MyCard
magicseteditor
Commits
c155ce75
Commit
c155ce75
authored
Jan 28, 2007
by
twanvl
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixed compilation errors for gcc@linux (not all yet).
parent
1cfe91f5
Changes
15
Show whitespace changes
Inline
Side-by-side
Showing
15 changed files
with
159 additions
and
71 deletions
+159
-71
src/data/format/formats.hpp
src/data/format/formats.hpp
+1
-0
src/data/set.hpp
src/data/set.hpp
+2
-1
src/gui/thumbnail_thread.hpp
src/gui/thumbnail_thread.hpp
+4
-1
src/script/scriptable.hpp
src/script/scriptable.hpp
+1
-1
src/script/value.hpp
src/script/value.hpp
+3
-40
src/util/action_stack.hpp
src/util/action_stack.hpp
+1
-0
src/util/age.hpp
src/util/age.hpp
+7
-17
src/util/atomic.hpp
src/util/atomic.hpp
+88
-0
src/util/error.hpp
src/util/error.hpp
+3
-3
src/util/for_each.hpp
src/util/for_each.hpp
+2
-0
src/util/index_map.hpp
src/util/index_map.hpp
+3
-3
src/util/io/package.hpp
src/util/io/package.hpp
+1
-0
src/util/prec.hpp
src/util/prec.hpp
+1
-0
src/util/smart_ptr.hpp
src/util/smart_ptr.hpp
+41
-4
src/util/vector2d.hpp
src/util/vector2d.hpp
+1
-1
No files found.
src/data/format/formats.hpp
View file @
c155ce75
...
...
@@ -22,6 +22,7 @@ DECLARE_POINTER_TYPE(FileFormat);
/// A filter for a specific file format
class
FileFormat
{
public:
virtual
~
FileFormat
()
{}
/// File extension used by this file format
virtual
String
extension
()
=
0
;
/// Name of the filter
...
...
src/data/set.hpp
View file @
c155ce75
...
...
@@ -13,6 +13,7 @@
#include <util/reflect.hpp>
#include <util/action_stack.hpp>
#include <util/io/package.hpp>
#include <data/field.hpp> // for Set::value
#include <boost/scoped_ptr.hpp>
DECLARE_POINTER_TYPE
(
Card
);
...
...
src/gui/thumbnail_thread.hpp
View file @
c155ce75
...
...
@@ -15,6 +15,7 @@
#include <queue>
DECLARE_POINTER_TYPE
(
ThumbnailRequest
);
class
ThumbnailThreadWorker
;
// ----------------------------------------------------------------------------- : ThumbnailRequest
...
...
@@ -24,6 +25,8 @@ class ThumbnailRequest {
ThumbnailRequest
(
void
*
owner
,
const
String
&
cache_name
,
const
wxDateTime
&
modified
)
:
owner
(
owner
),
cache_name
(
cache_name
),
modified
(
modified
)
{}
virtual
~
ThumbnailRequest
()
{}
/// Generate the thumbnail, called in another thread
virtual
Image
generate
()
=
0
;
/// Store the thumbnail, called from the main thread
...
...
src/script/scriptable.hpp
View file @
c155ce75
...
...
@@ -141,7 +141,7 @@ void Reader::handle(Scriptable<T>& s) {
if
(
starts_with
(
s
.
script
.
unparsed
,
_
(
"script:"
)))
{
s
.
script
.
unparsed
=
s
.
script
.
unparsed
.
substr
(
7
);
s
.
script
.
parse
(
*
this
);
}
else
if
(
s
.
script
.
unparsed
.
find_first_of
(
'{'
)
!=
String
.
npos
)
{
}
else
if
(
s
.
script
.
unparsed
.
find_first_of
(
'{'
)
!=
String
::
npos
)
{
s
.
script
.
parse
(
*
this
,
true
);
}
else
{
handle
(
s
.
value
);
...
...
src/script/value.hpp
View file @
c155ce75
...
...
@@ -15,17 +15,6 @@
class
Context
;
class
Dependency
;
#ifdef _MSC_VER
extern
"C"
{
LONG
__cdecl
_InterlockedIncrement
(
LONG
volatile
*
Addend
);
LONG
__cdecl
_InterlockedDecrement
(
LONG
volatile
*
Addend
);
}
#pragma intrinsic (_InterlockedIncrement)
#define InterlockedIncrement _InterlockedIncrement
#pragma intrinsic (_InterlockedDecrement)
#define InterlockedDecrement _InterlockedDecrement
#endif
// ----------------------------------------------------------------------------- : ScriptValue
DECLARE_INTRUSIVE_POINTER_TYPE
(
ScriptValue
);
...
...
@@ -46,7 +35,7 @@ enum ScriptType
/// A value that can be handled by the scripting engine.
/// Actual values are derived types
class
ScriptValue
{
class
ScriptValue
:
public
IntrusivePtrBase
{
public:
inline
ScriptValue
()
#ifdef USE_INTRUSIVE_PTR
...
...
@@ -87,34 +76,8 @@ class ScriptValue {
virtual
ScriptValueP
next
();
/// Return the number of items in this value (assuming it is a collection)
virtual
int
itemCount
()
const
;
protected:
/// Delete this object
virtual
void
destroy
()
{
delete
this
;
}
#ifdef USE_INTRUSIVE_PTR
private:
volatile
LONG
refCount
;
friend
void
intrusive_ptr_add_ref
(
ScriptValue
*
);
friend
void
intrusive_ptr_release
(
ScriptValue
*
);
#endif
};
#ifdef USE_INTRUSIVE_PTR
inline
void
intrusive_ptr_add_ref
(
ScriptValue
*
p
)
{
//p->refCount += 1;
InterlockedIncrement
(
&
p
->
refCount
);
}
inline
void
intrusive_ptr_release
(
ScriptValue
*
p
)
{
if
(
InterlockedDecrement
(
&
p
->
refCount
)
==
0
)
{
//if (--p->refCount == 0) {
p
->
destroy
();
}
}
#endif
extern
ScriptValueP
script_nil
;
///< The preallocated nil value
extern
ScriptValueP
script_true
;
///< The preallocated true value
extern
ScriptValueP
script_false
;
///< The preallocated false value
...
...
@@ -181,7 +144,7 @@ class ScriptCollection : public ScriptValue {
template
<
typename
V
>
ScriptValueP
get_member
(
const
map
<
String
,
V
>&
m
,
const
String
&
name
)
{
map
<
String
,
V
>::
const_iterator
it
=
m
.
find
(
name
);
typename
map
<
String
,
V
>::
const_iterator
it
=
m
.
find
(
name
);
if
(
it
!=
m
.
end
())
{
return
toScript
(
it
->
second
);
}
else
{
...
...
@@ -191,7 +154,7 @@ ScriptValueP get_member(const map<String,V>& m, const String& name) {
template
<
typename
K
,
typename
V
>
ScriptValueP
get_member
(
const
IndexMap
<
K
,
V
>&
m
,
const
String
&
name
)
{
IndexMap
<
K
,
V
>::
const_iterator
it
=
m
.
find
(
name
);
typename
IndexMap
<
K
,
V
>::
const_iterator
it
=
m
.
find
(
name
);
if
(
it
!=
m
.
end
())
{
return
toScript
(
*
it
);
}
else
{
...
...
src/util/action_stack.hpp
View file @
c155ce75
...
...
@@ -48,6 +48,7 @@ class Action {
/// Base class/interface for objects that listen to actions
class
ActionListener
{
public:
virtual
~
ActionListener
()
{}
/// Notification that an action a has been performed or undone
virtual
void
onAction
(
const
Action
&
a
,
bool
undone
)
=
0
;
};
...
...
src/util/age.hpp
View file @
c155ce75
...
...
@@ -11,17 +11,7 @@
#include <util/prec.hpp>
#include <util/dynamic_arg.hpp>
#ifdef _MSC_VER
extern
"C"
{
LONG
__cdecl
_InterlockedIncrement
(
LONG
volatile
*
Addend
);
LONG
__cdecl
_InterlockedDecrement
(
LONG
volatile
*
Addend
);
}
#pragma intrinsic (_InterlockedIncrement)
#define InterlockedIncrement _InterlockedIncrement
#pragma intrinsic (_InterlockedDecrement)
#define InterlockedDecrement _InterlockedDecrement
#endif
#include <util/atomic.hpp>
// ----------------------------------------------------------------------------- : Age
...
...
@@ -33,24 +23,24 @@ class Age {
Age
()
{
update
();
}
Age
(
LONG
age
)
:
age
(
age
)
{}
Age
(
AtomicIntEquiv
age
)
:
age
(
age
)
{}
/// Update the age to become the newest one
inline
void
update
()
{
age
=
InterlockedIncrement
(
&
new_age
)
;
age
=
++
new_age
;
}
/// Compare two ages, smaller means earlier
inline
bool
operator
<
(
Age
a
)
const
{
return
age
<
a
.
age
;
}
/// A number corresponding to the age
inline
LONG
get
()
const
{
return
age
;
}
inline
AtomicIntEquiv
get
()
const
{
return
age
;
}
private:
/// This age
LONG
age
;
AtomicIntEquiv
age
;
/// Global age counter, value of the last age created
static
volatile
LONG
new_age
;
static
AtomicInt
new_age
;
};
...
...
@@ -60,7 +50,7 @@ class Age {
* if last_update_age > 0 they return whether the image is still up to date
* if last_update_age == 0 they generate the image
*/
DECLARE_DYNAMIC_ARG
(
long
,
last_update_age
);
DECLARE_DYNAMIC_ARG
(
AtomicIntEquiv
,
last_update_age
);
// ----------------------------------------------------------------------------- : EOF
#endif
src/util/atomic.hpp
0 → 100644
View file @
c155ce75
//+----------------------------------------------------------------------------+
//| Description: Magic Set Editor - Program to make Magic (tm) cards |
//| Copyright: (C) 2001 - 2006 Twan van Laarhoven |
//| License: GNU General Public License 2 or later (see file COPYING) |
//+----------------------------------------------------------------------------+
#ifndef HEADER_UTIL_ATOMIC
#define HEADER_UTIL_ATOMIC
/** @file util/atomic.hpp
*
* @brief Provides the type AtomicInt, which is an integer that can be incremented and decremented atomicly
*/
// ----------------------------------------------------------------------------- : Includes
// ----------------------------------------------------------------------------- : AtomicInt : windows
#ifdef _WX_MSW_
#ifdef _MSC_VER
extern
"C"
{
LONG
__cdecl
_InterlockedIncrement
(
LONG
volatile
*
Addend
);
LONG
__cdecl
_InterlockedDecrement
(
LONG
volatile
*
Addend
);
}
#pragma intrinsic (_InterlockedIncrement)
#define InterlockedIncrement _InterlockedIncrement
#pragma intrinsic (_InterlockedDecrement)
#define InterlockedDecrement _InterlockedDecrement
#endif
/// An integer which is equivalent to an AtomicInt, but which doesn't support attomic operations
typedef
LONG
AtomicIntEquiv
;
/// An integer that can be incremented and decremented atomicly
class
AtomicInt
{
public:
AtomicInt
(
AtomicIntEquiv
v
)
:
v
(
v
)
{}
inline
operator
AtomicIntEquiv
()
const
{
return
v
;
}
/// Attomicly increments this AtomicInt, returns the new value
inline
AtomicIntEquiv
operator
++
()
{
return
InterlockedIncrement
(
&
v
);
}
/// Attomicly decrements this AtomicInt, returns the new value
inline
AtomicIntEquiv
operator
--
()
{
return
InterlockedDecrement
(
&
v
);
}
private:
AtomicIntEquiv
v
;
///< The value
};
/// We have a fast AtomicInt
#define HAVE_FAST_ATOMIC
// ----------------------------------------------------------------------------- : AtomicInt : portable
#else
/// An integer which is equivalent to an AtomicInt, but which doesn't support attomic operations
typedef
long
AtomicIntEquiv
;
/// An integer that can be incremented and decremented atomicly
class
AtomicInt
{
public:
AtomicInt
(
AtomicIntEquiv
v
)
:
v
(
v
)
{}
inline
operator
AtomicIntEquiv
()
const
{
return
v
;
}
/// Attomicly increments this AtomicInt, returns the new value
inline
AtomicIntEquiv
operator
++
()
{
wxCriticalSectionLocker
lock
(
cs
);
return
++
v
;
}
/// Attomicly decrements this AtomicInt, returns the new value
inline
AtomicIntEquiv
operator
--
()
{
wxCriticalSectionLocker
lock
(
cs
);
return
--
v
;
}
private:
AtomicIntEquiv
v
;
///< The value
wxCriticalSection
cs
;
///< Critical section protecting v
};
#endif
// ----------------------------------------------------------------------------- : EOF
#endif
src/util/error.hpp
View file @
c155ce75
...
...
@@ -36,7 +36,7 @@ class Error {
class
InternalError
:
public
Error
{
public:
inline
InternalError
(
const
String
&
str
)
:
Error
(
_ERROR_1_
(
"internal error"
,
str
))
:
Error
(
_ERROR_1_
(
"internal error"
,
str
.
c_str
()
))
{}
};
...
...
@@ -52,7 +52,7 @@ class PackageError : public Error {
class
FileNotFoundError
:
public
PackageError
{
public:
inline
FileNotFoundError
(
const
String
&
file
,
const
String
&
package
)
:
PackageError
(
_ERROR_2_
(
"file not found"
,
file
,
package
))
:
PackageError
(
_ERROR_2_
(
"file not found"
,
file
.
c_str
(),
package
.
c_str
()
))
{}
};
...
...
@@ -68,7 +68,7 @@ class ParseError : public Error {
class
FileParseError
:
public
ParseError
{
public:
inline
FileParseError
(
const
String
&
err
,
const
String
&
file
)
:
ParseError
(
_ERROR_2_
(
"file parse error"
,
file
,
err
))
ParseError
(
_ERROR_2_
(
"file parse error"
,
file
.
c_str
(),
err
.
c_str
()
))
{}
};
...
...
src/util/for_each.hpp
View file @
c155ce75
...
...
@@ -21,6 +21,8 @@
#ifdef __GNUC__
// GCC has a buildin typeof function, so it doesn't need (as much) hacks
#define DECLARE_TYPEOF(T)
#define DECLARE_TYPEOF_NO_REV(T)
#define DECLARE_TYPEOF_CONST(T)
#define DECLARE_TYPEOF_COLLECTION(T)
#define TYPEOF(Value) __typeof(Value)
...
...
src/util/index_map.hpp
View file @
c155ce75
...
...
@@ -46,7 +46,7 @@ class IndexMap : private vector<Value> {
void
init
(
const
vector
<
Key
>&
keys
)
{
if
(
this
->
size
()
==
keys
.
size
())
return
;
this
->
reserve
(
keys
.
size
());
for
(
vector
<
Key
>::
const_iterator
it
=
keys
.
begin
()
;
it
!=
keys
.
end
()
;
++
it
)
{
for
(
typename
vector
<
Key
>::
const_iterator
it
=
keys
.
begin
()
;
it
!=
keys
.
end
()
;
++
it
)
{
const
Key
&
key
=
*
it
;
assert
(
key
);
if
(
key
->
index
>=
this
->
size
())
this
->
resize
(
key
->
index
+
1
);
...
...
@@ -82,8 +82,8 @@ class IndexMap : private vector<Value> {
/// Find a value given the key name, return an iterator
template
<
typename
Name
>
const_iterator
find
(
const
Name
&
key
)
const
{
for
(
vector
<
Value
>::
const_iterator
it
=
begin
()
;
it
!=
end
()
;
++
it
)
{
typename
vector
<
Value
>::
const_iterator
find
(
const
Name
&
key
)
const
{
for
(
typename
vector
<
Value
>::
const_iterator
it
=
begin
()
;
it
!=
end
()
;
++
it
)
{
if
(
get_key_name
(
*
it
)
==
key
)
return
it
;
}
return
end
();
...
...
src/util/io/package.hpp
View file @
c155ce75
...
...
@@ -11,6 +11,7 @@
#include <util/reflect.hpp>
#include <util/dynamic_arg.hpp>
#include <util/error.hpp>
class
Package
;
class
wxFileInputStream
;
...
...
src/util/prec.hpp
View file @
c155ce75
...
...
@@ -25,6 +25,7 @@
// Wx headers
#include <wx/setup.h>
#include <wx/wxprec.h>
#include <wx/wx.h>
#include <wx/image.h>
#include <wx/datetime.h>
...
...
src/util/smart_ptr.hpp
View file @
c155ce75
...
...
@@ -14,9 +14,11 @@
// ----------------------------------------------------------------------------- : Includes
// MOVEME
/// Using intrusive_ptr where possible? (as opposed to smart_ptr)
#define USE_INTRUSIVE_PTR
#include <util/atomic.hpp>
#ifdef HAVE_FAST_ATOMIC
/// Using intrusive_ptr where possible? (as opposed to smart_ptr)
#define USE_INTRUSIVE_PTR
#endif
#include <boost/shared_ptr.hpp>
#ifdef USE_INTRUSIVE_PTR
...
...
@@ -100,6 +102,30 @@ inline shared_ptr<T> new_shared7(const A0& a0, const A1& a1, const A2& a2, const
return
intrusive_ptr
<
T
>
(
new
T
(
a0
,
a1
));
}
/// Base class for objects wishing to use intrusive_ptrs
class
IntrusivePtrBase
{
public:
virtual
~
IntrusivePtrBase
();
protected:
/// Delete this object
virtual
void
destroy
()
{
delete
this
;
}
private:
volatile
AtomicInt
ref_count
;
friend
void
intrusive_ptr_add_ref
(
IntrusivePtrBase
*
);
friend
void
intrusive_ptr_release
(
IntrusivePtrBase
*
);
};
inline
void
intrusive_ptr_add_ref
(
IntrusivePtrBase
*
p
)
{
++
p
->
ref_count
;
}
inline
void
intrusive_ptr_release
(
IntrusivePtrBase
*
p
)
{
if
(
--
p
->
ref_count
==
0
)
{
p
->
destroy
();
}
}
#else
#define DECLARE_INTRUSIVE_POINTER_TYPE DECLARE_POINTER_TYPE
#define intrusive_ptr shared_ptr
...
...
@@ -107,6 +133,17 @@ inline shared_ptr<T> new_shared7(const A0& a0, const A1& a1, const A2& a2, const
#define new_intrusive1 new_shared1
#define new_intrusive2 new_shared2
#define new_intrusive3 new_shared3
class
IntrusivePtrBase
{
public:
virtual
~
IntrusivePtrBase
();
protected:
/// Delete this object
virtual
void
destroy
()
{
delete
this
;
}
};
#endif
// ----------------------------------------------------------------------------- : EOF
...
...
src/util/vector2d.hpp
View file @
c155ce75
...
...
@@ -18,7 +18,7 @@
/** Intentionally uses slightly less then 0.5, to give a more consistent result
* when for instance something like "x/2" is used. */
inline
int
to_int
(
double
d
)
{
return
d
>
0
?
d
+
0.4999995
:
d
-
0.4999995
;
return
static_cast
<
int
>
(
d
>
0
?
d
+
0.4999995
:
d
-
0.4999995
)
;
}
// ----------------------------------------------------------------------------- : Vector2D
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment