summaryrefslogtreecommitdiff
path: root/core
diff options
context:
space:
mode:
Diffstat (limited to 'core')
-rw-r--r--core/bind/core_bind.cpp91
-rw-r--r--core/bind/core_bind.h20
-rw-r--r--core/event_queue.cpp18
-rw-r--r--core/global_constants.cpp1
-rw-r--r--core/io/file_access_pack.cpp4
-rw-r--r--core/io/file_access_pack.h1
-rw-r--r--core/math/geometry.h4
-rw-r--r--core/os/dir_access.h1
-rw-r--r--core/os/os.h24
-rw-r--r--core/ustring.cpp54
-rw-r--r--core/ustring.h2
-rw-r--r--core/variant_call.cpp10
-rw-r--r--core/variant_op.cpp16
13 files changed, 190 insertions, 56 deletions
diff --git a/core/bind/core_bind.cpp b/core/bind/core_bind.cpp
index 8d18acdc23..5839467388 100644
--- a/core/bind/core_bind.cpp
+++ b/core/bind/core_bind.cpp
@@ -176,6 +176,76 @@ bool _OS::is_video_mode_fullscreen(int p_screen) const {
}
+
+int _OS::get_screen_count() const {
+ return OS::get_singleton()->get_screen_count();
+}
+
+int _OS::get_current_screen() const {
+ return OS::get_singleton()->get_current_screen();
+}
+
+void _OS::set_current_screen(int p_screen) {
+ OS::get_singleton()->set_current_screen(p_screen);
+}
+
+Point2 _OS::get_screen_position(int p_screen) const {
+ return OS::get_singleton()->get_screen_position(p_screen);
+}
+
+Size2 _OS::get_screen_size(int p_screen) const {
+ return OS::get_singleton()->get_screen_size(p_screen);
+}
+
+Point2 _OS::get_window_position() const {
+ return OS::get_singleton()->get_window_position();
+}
+
+void _OS::set_window_position(const Point2& p_position) {
+ OS::get_singleton()->set_window_position(p_position);
+}
+
+Size2 _OS::get_window_size() const {
+ return OS::get_singleton()->get_window_size();
+}
+
+void _OS::set_window_size(const Size2& p_size) {
+ OS::get_singleton()->set_window_size(p_size);
+}
+
+void _OS::set_window_fullscreen(bool p_enabled) {
+ OS::get_singleton()->set_window_fullscreen(p_enabled);
+}
+
+bool _OS::is_window_fullscreen() const {
+ return OS::get_singleton()->is_window_fullscreen();
+}
+
+void _OS::set_window_resizable(bool p_enabled) {
+ OS::get_singleton()->set_window_resizable(p_enabled);
+}
+
+bool _OS::is_window_resizable() const {
+ return OS::get_singleton()->is_window_resizable();
+}
+
+void _OS::set_window_minimized(bool p_enabled) {
+ OS::get_singleton()->set_window_minimized(p_enabled);
+}
+
+bool _OS::is_window_minimized() const {
+ return OS::get_singleton()->is_window_minimized();
+}
+
+void _OS::set_window_maximized(bool p_enabled) {
+ OS::get_singleton()->set_window_maximized(p_enabled);
+}
+
+bool _OS::is_window_maximized() const {
+ return OS::get_singleton()->is_window_maximized();
+}
+
+
void _OS::set_use_file_access_save_and_swap(bool p_enable) {
FileAccess::set_backup_save(p_enable);
@@ -186,7 +256,6 @@ bool _OS::is_video_mode_resizable(int p_screen) const {
OS::VideoMode vm;
vm = OS::get_singleton()->get_video_mode(p_screen);
return vm.resizable;
-
}
Array _OS::get_fullscreen_mode_list(int p_screen) const {
@@ -637,6 +706,26 @@ void _OS::_bind_methods() {
ObjectTypeDB::bind_method(_MD("is_video_mode_resizable","screen"),&_OS::is_video_mode_resizable,DEFVAL(0));
ObjectTypeDB::bind_method(_MD("get_fullscreen_mode_list","screen"),&_OS::get_fullscreen_mode_list,DEFVAL(0));
+
+ ObjectTypeDB::bind_method(_MD("get_screen_count"),&_OS::get_screen_count);
+ ObjectTypeDB::bind_method(_MD("get_current_screen"),&_OS::get_current_screen);
+ ObjectTypeDB::bind_method(_MD("set_current_screen"),&_OS::set_current_screen);
+ ObjectTypeDB::bind_method(_MD("get_screen_position"),&_OS::get_screen_position,DEFVAL(0));
+ ObjectTypeDB::bind_method(_MD("get_screen_size"),&_OS::get_screen_size,DEFVAL(0));
+ ObjectTypeDB::bind_method(_MD("get_window_position"),&_OS::get_window_position);
+ ObjectTypeDB::bind_method(_MD("set_window_position"),&_OS::set_window_position);
+ ObjectTypeDB::bind_method(_MD("get_window_size"),&_OS::get_window_size);
+ ObjectTypeDB::bind_method(_MD("set_window_size"),&_OS::set_window_size);
+ ObjectTypeDB::bind_method(_MD("set_window_fullscreen","enabled"),&_OS::set_window_fullscreen);
+ ObjectTypeDB::bind_method(_MD("is_window_fullscreen"),&_OS::is_window_fullscreen);
+ ObjectTypeDB::bind_method(_MD("set_window_resizable","enabled"),&_OS::set_window_resizable);
+ ObjectTypeDB::bind_method(_MD("is_window_resizable"),&_OS::is_window_resizable);
+ ObjectTypeDB::bind_method(_MD("set_window_minimized", "enabled"),&_OS::set_window_minimized);
+ ObjectTypeDB::bind_method(_MD("is_window_minimized"),&_OS::is_window_minimized);
+ ObjectTypeDB::bind_method(_MD("set_window_maximized", "enabled"),&_OS::set_window_maximized);
+ ObjectTypeDB::bind_method(_MD("is_window_maximized"),&_OS::is_window_maximized);
+
+
ObjectTypeDB::bind_method(_MD("set_iterations_per_second","iterations_per_second"),&_OS::set_iterations_per_second);
ObjectTypeDB::bind_method(_MD("get_iterations_per_second"),&_OS::get_iterations_per_second);
ObjectTypeDB::bind_method(_MD("set_target_fps","target_fps"),&_OS::set_target_fps);
diff --git a/core/bind/core_bind.h b/core/bind/core_bind.h
index 057ad90fe9..f3601e35fb 100644
--- a/core/bind/core_bind.h
+++ b/core/bind/core_bind.h
@@ -108,6 +108,26 @@ public:
bool is_video_mode_resizable(int p_screen=0) const;
Array get_fullscreen_mode_list(int p_screen=0) const;
+
+ virtual int get_screen_count() const;
+ virtual int get_current_screen() const;
+ virtual void set_current_screen(int p_screen);
+ virtual Point2 get_screen_position(int p_screen=0) const;
+ virtual Size2 get_screen_size(int p_screen=0) const;
+ virtual Point2 get_window_position() const;
+ virtual void set_window_position(const Point2& p_position);
+ virtual Size2 get_window_size() const;
+ virtual void set_window_size(const Size2& p_size);
+ virtual void set_window_fullscreen(bool p_enabled);
+ virtual bool is_window_fullscreen() const;
+ virtual void set_window_resizable(bool p_enabled);
+ virtual bool is_window_resizable() const;
+ virtual void set_window_minimized(bool p_enabled);
+ virtual bool is_window_minimized() const;
+ virtual void set_window_maximized(bool p_enabled);
+ virtual bool is_window_maximized() const;
+
+
Error native_video_play(String p_path, float p_volume, String p_audio_track, String p_subtitle_track);
bool native_video_is_playing();
void native_video_pause();
diff --git a/core/event_queue.cpp b/core/event_queue.cpp
index cf6e742f79..161fb4fedd 100644
--- a/core/event_queue.cpp
+++ b/core/event_queue.cpp
@@ -56,28 +56,36 @@ Error EventQueue::push_call(uint32_t p_instance_ID, const StringName& p_method,
buffer_end+=sizeof(Event);
- if (args==1) {
+ if (args>=1) {
Variant * v = memnew_placement( &event_buffer[ buffer_end ], Variant );
buffer_end+=sizeof(Variant);
*v=p_arg1;
- } else if (args==2) {
+ }
+
+ if (args>=2) {
Variant * v = memnew_placement( &event_buffer[ buffer_end ], Variant );
buffer_end+=sizeof(Variant);
*v=p_arg2;
- } else if (args==3) {
+ }
+
+ if (args>=3) {
Variant * v = memnew_placement( &event_buffer[ buffer_end ], Variant );
buffer_end+=sizeof(Variant);
*v=p_arg3;
- } else if (args==4) {
+ }
+
+ if (args>=4) {
Variant * v = memnew_placement( &event_buffer[ buffer_end ], Variant );
buffer_end+=sizeof(Variant);
*v=p_arg4;
- } else if (args==5) {
+ }
+
+ if (args>=5) {
Variant * v = memnew_placement( &event_buffer[ buffer_end ], Variant );
buffer_end+=sizeof(Variant);
diff --git a/core/global_constants.cpp b/core/global_constants.cpp
index ae4abc627d..fc48a105db 100644
--- a/core/global_constants.cpp
+++ b/core/global_constants.cpp
@@ -313,6 +313,7 @@ static _GlobalConstant _global_constants[]={
BIND_GLOBAL_CONSTANT( KEY_MASK_ALT ),
BIND_GLOBAL_CONSTANT( KEY_MASK_META ),
BIND_GLOBAL_CONSTANT( KEY_MASK_CTRL ),
+ BIND_GLOBAL_CONSTANT( KEY_MASK_CMD ),
BIND_GLOBAL_CONSTANT( KEY_MASK_KPAD ),
BIND_GLOBAL_CONSTANT( KEY_MASK_GROUP_SWITCH ),
diff --git a/core/io/file_access_pack.cpp b/core/io/file_access_pack.cpp
index 6e03819aac..afbd7e3d46 100644
--- a/core/io/file_access_pack.cpp
+++ b/core/io/file_access_pack.cpp
@@ -362,6 +362,10 @@ bool DirAccessPack::current_is_dir() const{
return cdir;
}
+bool DirAccessPack::current_is_hidden() const{
+
+ return false;
+}
void DirAccessPack::list_dir_end() {
list_dirs.clear();
diff --git a/core/io/file_access_pack.h b/core/io/file_access_pack.h
index 5fcc79aaf4..2d0cf5b32e 100644
--- a/core/io/file_access_pack.h
+++ b/core/io/file_access_pack.h
@@ -208,6 +208,7 @@ public:
virtual bool list_dir_begin();
virtual String get_next();
virtual bool current_is_dir() const;
+ virtual bool current_is_hidden() const;
virtual void list_dir_end();
virtual int get_drive_count();
diff --git a/core/math/geometry.h b/core/math/geometry.h
index 7e0cc01a22..4ad4db8523 100644
--- a/core/math/geometry.h
+++ b/core/math/geometry.h
@@ -519,9 +519,9 @@ public:
bool s_ab = (b.x-a.x)*as_y-(b.y-a.y)*as_x > 0;
- if((c.x-a.x)*as_y-(c.y-a.y)*as_x > 0 == s_ab) return false;
+ if(((c.x-a.x)*as_y-(c.y-a.y)*as_x > 0) == s_ab) return false;
- if((c.x-b.x)*(s.y-b.y)-(c.y-b.y)*(s.x-b.x) > 0 != s_ab) return false;
+ if(((c.x-b.x)*(s.y-b.y)-(c.y-b.y)*(s.x-b.x) > 0) != s_ab) return false;
return true;
}
diff --git a/core/os/dir_access.h b/core/os/dir_access.h
index d8672218bd..dc56f2308e 100644
--- a/core/os/dir_access.h
+++ b/core/os/dir_access.h
@@ -78,6 +78,7 @@ public:
virtual String get_next(bool* p_is_dir); // compatibility
virtual String get_next()=0;
virtual bool current_is_dir() const=0;
+ virtual bool current_is_hidden() const=0;
virtual void list_dir_end()=0; ///<
diff --git a/core/os/os.h b/core/os/os.h
index d4deff2f5e..d4ac433644 100644
--- a/core/os/os.h
+++ b/core/os/os.h
@@ -73,7 +73,7 @@ public:
bool fullscreen;
bool resizable;
float get_aspect() const { return (float)width/(float)height; }
- VideoMode(int p_width=640,int p_height=480,bool p_fullscreen=false, bool p_resizable = true) { width=p_width; height=p_height; fullscreen=p_fullscreen; resizable = p_resizable; }
+ VideoMode(int p_width=640,int p_height=480,bool p_fullscreen=false, bool p_resizable = true) {width=p_width; height=p_height; fullscreen=p_fullscreen; resizable = p_resizable; }
};
protected:
friend class Main;
@@ -149,7 +149,27 @@ public:
virtual void set_video_mode(const VideoMode& p_video_mode,int p_screen=0)=0;
virtual VideoMode get_video_mode(int p_screen=0) const=0;
virtual void get_fullscreen_mode_list(List<VideoMode> *p_list,int p_screen=0) const=0;
-
+
+
+ virtual int get_screen_count() const{ return 1; }
+ virtual int get_current_screen() const { return 0; }
+ virtual void set_current_screen(int p_screen) { }
+ virtual Point2 get_screen_position(int p_screen=0) { return Point2(); }
+ virtual Size2 get_screen_size(int p_screen=0) const { return get_window_size(); }
+ virtual Point2 get_window_position() const { return Vector2(); }
+ virtual void set_window_position(const Point2& p_position) {}
+ virtual Size2 get_window_size() const=0;
+ virtual void set_window_size(const Size2 p_size){}
+ virtual void set_window_fullscreen(bool p_enabled) {}
+ virtual bool is_window_fullscreen() const { return true; }
+ virtual void set_window_resizable(bool p_enabled) {}
+ virtual bool is_window_resizable() const { return false; }
+ virtual void set_window_minimized(bool p_enabled) {}
+ virtual bool is_window_minimized() const { return false; }
+ virtual void set_window_maximized(bool p_enabled) {}
+ virtual bool is_window_maximized() const { return true; }
+
+
virtual void set_iterations_per_second(int p_ips);
virtual int get_iterations_per_second() const;
diff --git a/core/ustring.cpp b/core/ustring.cpp
index 476ab3f936..09d3d95b68 100644
--- a/core/ustring.cpp
+++ b/core/ustring.cpp
@@ -3550,8 +3550,8 @@ String String::lpad(int min_length, const String& character) const {
// sprintf is implemented in GDScript via:
// "fish %s pie" % "frog"
// "fish %s %d pie" % ["frog", 12]
-String String::sprintf(const Array& values) const {
-
+// In case of an error, the string returned is the error description and "error" is true.
+String String::sprintf(const Array& values, bool* error) const {
String formatted;
CharType* self = (CharType*)c_str();
int num_items = values.size();
@@ -3564,6 +3564,7 @@ String String::sprintf(const Array& values) const {
bool left_justified;
bool show_sign;
+ *error = true;
for (; *self; self++) {
const CharType c = *self;
@@ -3580,13 +3581,11 @@ String String::sprintf(const Array& values) const {
case 'x': // Hexadecimal (lowercase)
case 'X': { // Hexadecimal (uppercase)
if (value_index >= values.size()) {
- ERR_EXPLAIN("not enough arguments for format string");
- ERR_FAIL_V("");
+ return "not enough arguments for format string";
}
if (!values[value_index].is_num()) {
- ERR_EXPLAIN("a number is required");
- ERR_FAIL_V("");
+ return "a number is required";
}
int64_t value = values[value_index];
@@ -3622,13 +3621,11 @@ String String::sprintf(const Array& values) const {
}
case 'f': { // Float
if (value_index >= values.size()) {
- ERR_EXPLAIN("not enough arguments for format string");
- ERR_FAIL_V("");
+ return "not enough arguments for format string";
}
if (!values[value_index].is_num()) {
- ERR_EXPLAIN("a number is required");
- ERR_FAIL_V("");
+ return "a number is required";
}
double value = values[value_index];
@@ -3657,8 +3654,7 @@ String String::sprintf(const Array& values) const {
}
case 's': { // String
if (value_index >= values.size()) {
- ERR_EXPLAIN("not enough arguments for format string");
- ERR_FAIL_V("");
+ return "not enough arguments for format string";
}
String str = values[value_index];
@@ -3676,8 +3672,7 @@ String String::sprintf(const Array& values) const {
}
case 'c': {
if (value_index >= values.size()) {
- ERR_EXPLAIN("not enough arguments for format string");
- ERR_FAIL_V("");
+ return "not enough arguments for format string";
}
// Convert to character.
@@ -3685,22 +3680,18 @@ String String::sprintf(const Array& values) const {
if (values[value_index].is_num()) {
int value = values[value_index];
if (value < 0) {
- ERR_EXPLAIN("unsigned byte integer is lower than maximum")
- ERR_FAIL_V("");
+ return "unsigned byte integer is lower than maximum";
} else if (value > 255) {
- ERR_EXPLAIN("unsigned byte integer is greater than maximum")
- ERR_FAIL_V("");
+ return "unsigned byte integer is greater than maximum";
}
str = chr(values[value_index]);
} else if (values[value_index].get_type() == Variant::STRING) {
str = values[value_index];
if (str.length() != 1) {
- ERR_EXPLAIN("%c requires number or single-character string");
- ERR_FAIL_V("");
+ return "%c requires number or single-character string";
}
} else {
- ERR_EXPLAIN("%c requires number or single-character string");
- ERR_FAIL_V("");
+ return "%c requires number or single-character string";
}
// Padding.
@@ -3741,8 +3732,7 @@ String String::sprintf(const Array& values) const {
}
case '.': { // Float separtor.
if (in_decimals) {
- ERR_EXPLAIN("too many decimal points in format");
- ERR_FAIL_V("");
+ return "too many decimal points in format";
}
in_decimals = true;
min_decimals = 0; // We want to add the value manually.
@@ -3751,13 +3741,11 @@ String String::sprintf(const Array& values) const {
case '*': { // Dyanmic width, based on value.
if (value_index >= values.size()) {
- ERR_EXPLAIN("not enough arguments for format string");
- ERR_FAIL_V("");
+ return "not enough arguments for format string";
}
if (!values[value_index].is_num()) {
- ERR_EXPLAIN("* wants number");
- ERR_FAIL_V("");
+ return "* wants number";
}
int size = values[value_index];
@@ -3773,8 +3761,7 @@ String String::sprintf(const Array& values) const {
}
default: {
- ERR_EXPLAIN("unsupported format character");
- ERR_FAIL_V("");
+ return "unsupported format character";
}
}
} else { // Not in format string.
@@ -3796,14 +3783,13 @@ String String::sprintf(const Array& values) const {
}
if (in_format) {
- ERR_EXPLAIN("incomplete format");
- ERR_FAIL_V("");
+ return "incomplete format";
}
if (value_index != values.size()) {
- ERR_EXPLAIN("not all arguments converted during string formatting");
- ERR_FAIL_V("");
+ return "not all arguments converted during string formatting";
}
+ *error = false;
return formatted;
}
diff --git a/core/ustring.h b/core/ustring.h
index af5ffb7c35..d4b854ea76 100644
--- a/core/ustring.h
+++ b/core/ustring.h
@@ -130,7 +130,7 @@ public:
String pad_zeros(int p_digits) const;
String lpad(int min_length,const String& character=" ") const;
String rpad(int min_length,const String& character=" ") const;
- String sprintf(const Array& values) const;
+ String sprintf(const Array& values, bool* error) const;
static String num(double p_num,int p_decimals=-1);
static String num_scientific(double p_num);
static String num_real(double p_num);
diff --git a/core/variant_call.cpp b/core/variant_call.cpp
index 50a60390e5..c6b498ff28 100644
--- a/core/variant_call.cpp
+++ b/core/variant_call.cpp
@@ -511,7 +511,7 @@ static void _call_##m_type##_##m_method(Variant& r_ret,Variant& p_self,const Var
VCALL_LOCALMEM1(ColorArray,append_array);
#define VCALL_PTR0(m_type,m_method)\
-static void _call_##m_type##m_method(Variant& r_ret,Variant& p_self,const Variant** p_args) { reinterpret_cast<m_type*>(p_self._data._ptr)->m_method(); }
+static void _call_##m_type##_##m_method(Variant& r_ret,Variant& p_self,const Variant** p_args) { reinterpret_cast<m_type*>(p_self._data._ptr)->m_method(); }
#define VCALL_PTR0R(m_type,m_method)\
static void _call_##m_type##_##m_method(Variant& r_ret,Variant& p_self,const Variant** p_args) { r_ret=reinterpret_cast<m_type*>(p_self._data._ptr)->m_method(); }
#define VCALL_PTR1(m_type,m_method)\
@@ -519,7 +519,7 @@ static void _call_##m_type##_##m_method(Variant& r_ret,Variant& p_self,const Var
#define VCALL_PTR1R(m_type,m_method)\
static void _call_##m_type##_##m_method(Variant& r_ret,Variant& p_self,const Variant** p_args) { r_ret=reinterpret_cast<m_type*>(p_self._data._ptr)->m_method(*p_args[0]); }
#define VCALL_PTR2(m_type,m_method)\
-static void _call_##m_type##m_method(Variant& r_ret,Variant& p_self,const Variant** p_args) { reinterpret_cast<m_type*>(p_self._data._ptr)->m_method(*p_args[0],*p_args[1]); }
+static void _call_##m_type##_##m_method(Variant& r_ret,Variant& p_self,const Variant** p_args) { reinterpret_cast<m_type*>(p_self._data._ptr)->m_method(*p_args[0],*p_args[1]); }
#define VCALL_PTR2R(m_type,m_method)\
static void _call_##m_type##_##m_method(Variant& r_ret,Variant& p_self,const Variant** p_args) { r_ret=reinterpret_cast<m_type*>(p_self._data._ptr)->m_method(*p_args[0],*p_args[1]); }
#define VCALL_PTR3(m_type,m_method)\
@@ -531,7 +531,7 @@ static void _call_##m_type##_##m_method(Variant& r_ret,Variant& p_self,const Var
#define VCALL_PTR4R(m_type,m_method)\
static void _call_##m_type##_##m_method(Variant& r_ret,Variant& p_self,const Variant** p_args) { r_ret=reinterpret_cast<m_type*>(p_self._data._ptr)->m_method(*p_args[0],*p_args[1],*p_args[2],*p_args[3]); }
#define VCALL_PTR5(m_type,m_method)\
-static void _call_##m_type##m_method(Variant& r_ret,Variant& p_self,const Variant** p_args) { reinterpret_cast<m_type*>(p_self._data._ptr)->m_method(*p_args[0],*p_args[1],*p_args[2],*p_args[3],*p_args[4]); }
+static void _call_##m_type##_##m_method(Variant& r_ret,Variant& p_self,const Variant** p_args) { reinterpret_cast<m_type*>(p_self._data._ptr)->m_method(*p_args[0],*p_args[1],*p_args[2],*p_args[3],*p_args[4]); }
#define VCALL_PTR5R(m_type,m_method)\
static void _call_##m_type##_##m_method(Variant& r_ret,Variant& p_self,const Variant** p_args) { r_ret=reinterpret_cast<m_type*>(p_self._data._ptr)->m_method(*p_args[0],*p_args[1],*p_args[2],*p_args[3],*p_args[4]); }
@@ -685,7 +685,7 @@ static void _call_##m_type##_##m_method(Variant& r_ret,Variant& p_self,const Var
VCALL_PTR0R( InputEvent, is_pressed );
VCALL_PTR1R( InputEvent, is_action );
VCALL_PTR0R( InputEvent, is_echo );
- //VCALL_PTR2( InputEvent, set_as_action );
+ VCALL_PTR2( InputEvent, set_as_action );
struct ConstructData {
@@ -1496,7 +1496,7 @@ _VariantCall::addfunc(Variant::m_vtype,Variant::m_ret,_SCS(#m_method),VCALL(m_cl
ADDFUNC0(INPUT_EVENT,BOOL,InputEvent,is_pressed,varray());
ADDFUNC1(INPUT_EVENT,BOOL,InputEvent,is_action,STRING,"action",varray());
ADDFUNC0(INPUT_EVENT,BOOL,InputEvent,is_echo,varray());
- //ADDFUNC2(INPUT_EVENT,NIL,InputEvent,set_as_action,STRING,"action",BOOL,"pressed",varray());
+ ADDFUNC2(INPUT_EVENT,NIL,InputEvent,set_as_action,STRING,"action",BOOL,"pressed",varray());
/* REGISTER CONSTRUCTORS */
diff --git a/core/variant_op.cpp b/core/variant_op.cpp
index d6129e150c..87d9738b06 100644
--- a/core/variant_op.cpp
+++ b/core/variant_op.cpp
@@ -741,18 +741,22 @@ void Variant::evaluate(const Operator& p_op, const Variant& p_a, const Variant&
_RETURN( p_a._data._int % p_b._data._int );
} else if (p_a.type==STRING) {
- const String *str=reinterpret_cast<const String*>(p_a._data._mem);
+ const String* format=reinterpret_cast<const String*>(p_a._data._mem);
+ String result;
+ bool error;
if (p_b.type==ARRAY) {
// e.g. "frog %s %d" % ["fish", 12]
- const Array *arr=reinterpret_cast<const Array*>(p_b._data._mem);
- _RETURN(str->sprintf(*arr));
+ const Array* args=reinterpret_cast<const Array*>(p_b._data._mem);
+ result=format->sprintf(*args, &error);
} else {
// e.g. "frog %d" % 12
- Array arr;
- arr.push_back(p_b);
- _RETURN(str->sprintf(arr));
+ Array args;
+ args.push_back(p_b);
+ result=format->sprintf(args, &error);
}
+ r_valid = !error;
+ _RETURN(result);
}
r_valid=false;