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
3fc08f0e
Commit
3fc08f0e
authored
Jan 11, 2009
by
twanvl
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
EnumReader now warns about the correct string,
parse_enum function throws if the string can not be parsed
parent
b7fdf553
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
24 additions
and
15 deletions
+24
-15
src/data/settings.hpp
src/data/settings.hpp
+1
-1
src/script/functions/image.cpp
src/script/functions/image.cpp
+3
-7
src/script/scriptable.cpp
src/script/scriptable.cpp
+1
-1
src/util/io/reader.cpp
src/util/io/reader.cpp
+14
-0
src/util/io/reader.hpp
src/util/io/reader.hpp
+5
-6
No files found.
src/data/settings.hpp
View file @
3fc08f0e
...
@@ -43,7 +43,7 @@ enum InstallType
...
@@ -43,7 +43,7 @@ enum InstallType
,
INSTALL_GLOBAL
// install to the global files
,
INSTALL_GLOBAL
// install to the global files
};
};
bool
parse_enum
(
const
String
&
,
InstallType
&
);
void
parse_enum
(
const
String
&
,
InstallType
&
);
bool
is_install_local
(
InstallType
type
);
bool
is_install_local
(
InstallType
type
);
/// How to handle filename conflicts
/// How to handle filename conflicts
...
...
src/script/functions/image.cpp
View file @
3fc08f0e
...
@@ -21,7 +21,7 @@
...
@@ -21,7 +21,7 @@
DECLARE_TYPEOF_COLLECTION
(
SymbolVariationP
);
DECLARE_TYPEOF_COLLECTION
(
SymbolVariationP
);
bool
parse_enum
(
const
String
&
,
ImageCombine
&
out
);
void
parse_enum
(
const
String
&
,
ImageCombine
&
out
);
// ----------------------------------------------------------------------------- : Utility
// ----------------------------------------------------------------------------- : Utility
...
@@ -56,9 +56,7 @@ SCRIPT_FUNCTION(combine_blend) {
...
@@ -56,9 +56,7 @@ SCRIPT_FUNCTION(combine_blend) {
SCRIPT_PARAM
(
GeneratedImageP
,
image1
);
SCRIPT_PARAM
(
GeneratedImageP
,
image1
);
SCRIPT_PARAM
(
GeneratedImageP
,
image2
);
SCRIPT_PARAM
(
GeneratedImageP
,
image2
);
ImageCombine
image_combine
;
ImageCombine
image_combine
;
if
(
!
parse_enum
(
combine
,
image_combine
))
{
parse_enum
(
combine
,
image_combine
);
throw
ScriptError
(
_
(
"Not a valid combine mode: '"
)
+
combine
+
_
(
"'"
));
}
return
new_intrusive3
<
CombineBlendImage
>
(
image1
,
image2
,
image_combine
);
return
new_intrusive3
<
CombineBlendImage
>
(
image1
,
image2
,
image_combine
);
}
}
...
@@ -78,9 +76,7 @@ SCRIPT_FUNCTION(set_combine) {
...
@@ -78,9 +76,7 @@ SCRIPT_FUNCTION(set_combine) {
SCRIPT_PARAM
(
String
,
combine
);
SCRIPT_PARAM
(
String
,
combine
);
SCRIPT_PARAM_C
(
GeneratedImageP
,
input
);
SCRIPT_PARAM_C
(
GeneratedImageP
,
input
);
ImageCombine
image_combine
;
ImageCombine
image_combine
;
if
(
!
parse_enum
(
combine
,
image_combine
))
{
parse_enum
(
combine
,
image_combine
);
throw
ScriptError
(
_
(
"Not a valid combine mode: '"
)
+
combine
+
_
(
"'"
));
}
return
new_intrusive2
<
SetCombineImage
>
(
input
,
image_combine
);
return
new_intrusive2
<
SetCombineImage
>
(
input
,
image_combine
);
}
}
...
...
src/script/scriptable.cpp
View file @
3fc08f0e
...
@@ -15,7 +15,7 @@
...
@@ -15,7 +15,7 @@
#include <gfx/color.hpp>
#include <gfx/color.hpp>
Alignment
from_string
(
const
String
&
);
Alignment
from_string
(
const
String
&
);
bool
parse_enum
(
const
String
&
,
Direction
&
);
void
parse_enum
(
const
String
&
,
Direction
&
);
DECLARE_TYPEOF_COLLECTION
(
ScriptParseError
);
DECLARE_TYPEOF_COLLECTION
(
ScriptParseError
);
...
...
src/util/io/reader.cpp
View file @
3fc08f0e
...
@@ -411,3 +411,17 @@ template <> void Reader::handle(FileName& f) {
...
@@ -411,3 +411,17 @@ template <> void Reader::handle(FileName& f) {
handle
(
static_cast
<
String
&>
(
f
));
handle
(
static_cast
<
String
&>
(
f
));
}
}
}
}
// ----------------------------------------------------------------------------- : EnumReader
void
EnumReader
::
warnIfNotDone
(
Reader
*
errors_to
)
{
if
(
!
done
)
{
// warning: unknown value
errors_to
->
warning
(
_ERROR_1_
(
"unrecognized value"
,
read
));
}
}
void
EnumReader
::
errorIfNotDone
()
{
if
(
!
done
)
{
throw
ParseError
(
_ERROR_1_
(
"unrecognized value"
,
read
));
}
}
src/util/io/reader.hpp
View file @
3fc08f0e
...
@@ -256,15 +256,12 @@ void Reader::handle(IndexMap<K,V>& m) {
...
@@ -256,15 +256,12 @@ void Reader::handle(IndexMap<K,V>& m) {
template
<>
void
Reader
::
handle
<
Enum
>
(
Enum
&
enum_
)
{
\
template
<>
void
Reader
::
handle
<
Enum
>
(
Enum
&
enum_
)
{
\
EnumReader
reader
(
getValue
());
\
EnumReader
reader
(
getValue
());
\
reflect_
##
Enum
(
enum_
,
reader
);
\
reflect_
##
Enum
(
enum_
,
reader
);
\
if
(
!
reader
.
isDone
())
{
\
reader
.
warnIfNotDone
(
this
);
\
/* warning: unknown value */
\
warning
(
_ERROR_1_
(
"unrecognized value"
,
value
));
\
}
\
}
\
}
\
bool
parse_enum
(
const
String
&
value
,
Enum
&
out
)
{
\
void
parse_enum
(
const
String
&
value
,
Enum
&
out
)
{
\
EnumReader
reader
(
value
);
\
EnumReader
reader
(
value
);
\
reflect_
##
Enum
(
out
,
reader
);
\
reflect_
##
Enum
(
out
,
reader
);
\
re
turn
reader
.
isDone
();
\
re
ader
.
errorIfNotDone
();
\
}
}
/// 'Tag' to be used when reflecting enumerations for Reader
/// 'Tag' to be used when reflecting enumerations for Reader
...
@@ -287,6 +284,8 @@ class EnumReader {
...
@@ -287,6 +284,8 @@ class EnumReader {
}
}
inline
bool
isDone
()
const
{
return
done
;
}
inline
bool
isDone
()
const
{
return
done
;
}
void
warnIfNotDone
(
Reader
*
errors_to
);
void
errorIfNotDone
();
private:
private:
String
read
;
///< The string to match to a value name
String
read
;
///< The string to match to a value name
...
...
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