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
9f6c7817
Commit
9f6c7817
authored
Dec 29, 2008
by
twanvl
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
toCode should now never give an error, instead returning things like "<card>"
parent
4da7d716
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
11 additions
and
4 deletions
+11
-4
src/script/to_value.hpp
src/script/to_value.hpp
+11
-4
No files found.
src/script/to_value.hpp
View file @
9f6c7817
...
@@ -52,6 +52,14 @@ template <typename K, typename V> inline String type_name(const pair<K,V>& p) {
...
@@ -52,6 +52,14 @@ template <typename K, typename V> inline String type_name(const pair<K,V>& p) {
return
type_name
(
p
.
second
);
// for maps
return
type_name
(
p
.
second
);
// for maps
}
}
/// Script code for an object, or anything else we can show
template
<
typename
T
>
inline
String
to_code
(
const
T
&
v
)
{
return
format_string
(
_
(
"<%s>"
),
type_name
(
v
));
}
template
<
typename
T
>
inline
String
to_code
(
const
intrusive_ptr
<
T
>&
p
)
{
return
type_name
(
*
p
.
get
());
}
// ----------------------------------------------------------------------------- : Errors
// ----------------------------------------------------------------------------- : Errors
/// A delayed error message.
/// A delayed error message.
...
@@ -113,6 +121,7 @@ ScriptValueP to_script(int);
...
@@ -113,6 +121,7 @@ ScriptValueP to_script(int);
class
ScriptCollectionBase
:
public
ScriptValue
{
class
ScriptCollectionBase
:
public
ScriptValue
{
public:
public:
virtual
ScriptType
type
()
const
{
return
SCRIPT_COLLECTION
;
}
virtual
ScriptType
type
()
const
{
return
SCRIPT_COLLECTION
;
}
virtual
String
typeName
()
const
{
return
_TYPE_
(
"collection"
);
}
virtual
String
toCode
()
const
;
virtual
String
toCode
()
const
;
};
};
...
@@ -213,7 +222,6 @@ class ScriptMap : public ScriptValue {
...
@@ -213,7 +222,6 @@ class ScriptMap : public ScriptValue {
/// Script value containing a custom collection, returned from script functions
/// Script value containing a custom collection, returned from script functions
class
ScriptCustomCollection
:
public
ScriptCollectionBase
{
class
ScriptCustomCollection
:
public
ScriptCollectionBase
{
public:
public:
virtual
String
typeName
()
const
{
return
_TYPE_
(
"collection"
);
}
virtual
ScriptValueP
getMember
(
const
String
&
name
)
const
;
virtual
ScriptValueP
getMember
(
const
String
&
name
)
const
;
virtual
ScriptValueP
getIndex
(
int
index
)
const
;
virtual
ScriptValueP
getIndex
(
int
index
)
const
;
virtual
ScriptValueP
makeIterator
(
const
ScriptValueP
&
thisP
)
const
;
virtual
ScriptValueP
makeIterator
(
const
ScriptValueP
&
thisP
)
const
;
...
@@ -235,11 +243,9 @@ DECLARE_POINTER_TYPE(ScriptCustomCollection);
...
@@ -235,11 +243,9 @@ DECLARE_POINTER_TYPE(ScriptCustomCollection);
// ----------------------------------------------------------------------------- : Collections : concatenation
// ----------------------------------------------------------------------------- : Collections : concatenation
/// Script value containing the concatenation of two collections
/// Script value containing the concatenation of two collections
class
ScriptConcatCollection
:
public
Script
Valu
e
{
class
ScriptConcatCollection
:
public
Script
CollectionBas
e
{
public:
public:
inline
ScriptConcatCollection
(
ScriptValueP
a
,
ScriptValueP
b
)
:
a
(
a
),
b
(
b
)
{}
inline
ScriptConcatCollection
(
ScriptValueP
a
,
ScriptValueP
b
)
:
a
(
a
),
b
(
b
)
{}
virtual
ScriptType
type
()
const
{
return
SCRIPT_COLLECTION
;
}
virtual
String
typeName
()
const
{
return
_TYPE_
(
"collection"
);
}
virtual
ScriptValueP
getMember
(
const
String
&
name
)
const
;
virtual
ScriptValueP
getMember
(
const
String
&
name
)
const
;
virtual
ScriptValueP
getIndex
(
int
index
)
const
;
virtual
ScriptValueP
getIndex
(
int
index
)
const
;
virtual
ScriptValueP
makeIterator
(
const
ScriptValueP
&
thisP
)
const
;
virtual
ScriptValueP
makeIterator
(
const
ScriptValueP
&
thisP
)
const
;
...
@@ -269,6 +275,7 @@ class ScriptObject : public ScriptValue {
...
@@ -269,6 +275,7 @@ class ScriptObject : public ScriptValue {
virtual
operator
int
()
const
{
ScriptValueP
d
=
getDefault
();
return
d
?
*
d
:
ScriptValue
::
operator
int
();
}
virtual
operator
int
()
const
{
ScriptValueP
d
=
getDefault
();
return
d
?
*
d
:
ScriptValue
::
operator
int
();
}
virtual
operator
bool
()
const
{
ScriptValueP
d
=
getDefault
();
return
d
?
*
d
:
ScriptValue
::
operator
bool
();
}
virtual
operator
bool
()
const
{
ScriptValueP
d
=
getDefault
();
return
d
?
*
d
:
ScriptValue
::
operator
bool
();
}
virtual
operator
AColor
()
const
{
ScriptValueP
d
=
getDefault
();
return
d
?
*
d
:
ScriptValue
::
operator
AColor
();
}
virtual
operator
AColor
()
const
{
ScriptValueP
d
=
getDefault
();
return
d
?
*
d
:
ScriptValue
::
operator
AColor
();
}
virtual
String
toCode
()
const
{
ScriptValueP
d
=
getDefault
();
return
d
?
d
->
toCode
()
:
to_code
(
*
value
);
}
virtual
GeneratedImageP
toImage
(
const
ScriptValueP
&
thisP
)
const
{
virtual
GeneratedImageP
toImage
(
const
ScriptValueP
&
thisP
)
const
{
ScriptValueP
d
=
getDefault
();
return
d
?
d
->
toImage
(
d
)
:
ScriptValue
::
toImage
(
thisP
);
ScriptValueP
d
=
getDefault
();
return
d
?
d
->
toImage
(
d
)
:
ScriptValue
::
toImage
(
thisP
);
}
}
...
...
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