Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

operator pre -- and decrement in Integer

  • Loading branch information...
commit 5e6ce74a3f64c735401d86c1c312b84d66008145 1 parent a2bb508
@NotFound authored
View
4 t/base/features.t
@@ -324,6 +324,10 @@ function main [main] (args)
test.is(vi1, 43, "var preincrement");
i = ++vi1;
test.is(i, 44, "var preincrement with assignment");
+ --vi1;
+ test.is(vi1, 43, "var peedecrement");
+ i = --vi1;
+ test.is(i, 42, "var predecrement with assignment");
string s = "abc";
test.is_string(s * 3, "abcabcabc", "repeat string");
View
15 winxedxx_classes.cxx
@@ -97,6 +97,11 @@ void WxxNull::increment()
nullaccess("increment");
}
+void WxxNull::decrement()
+{
+ nullaccess("decrement");
+}
+
std::string WxxNull::get_string_keyed(int i)
{
nullaccess("get_pmc_keyed");
@@ -284,6 +289,11 @@ void WxxDefault::increment()
notimplemented("increment");
}
+void WxxDefault::decrement()
+{
+ notimplemented("decrement");
+}
+
std::string WxxDefault::get_string_keyed(int i)
{
return get_pmc_keyed(i);
@@ -425,6 +435,11 @@ void WxxInteger::increment()
++i;
}
+void WxxInteger::decrement()
+{
+ --i;
+}
+
void WxxInteger::print() { std::cout << i; }
//*************************************************************
View
1  winxedxx_default.h
@@ -30,6 +30,7 @@ class WxxDefault : public WxxObject
WxxObject & set(const char *s);
WxxObject & set(const std::string &s);
void increment();
+ void decrement();
std::string get_string_keyed(int i);
WxxObjectPtr get_pmc_keyed(int i);
WxxObjectPtr get_pmc_keyed(const std::string &s);
View
1  winxedxx_integer.h
@@ -32,6 +32,7 @@ class WxxInteger : public WxxDefault
WxxObject & set(int value);
WxxObject & set(double value);
void increment();
+ void decrement();
void print();
private:
int i;
View
1  winxedxx_null.h
@@ -25,6 +25,7 @@ class WxxNull : public WxxObject
WxxObject & set(const char *s);
WxxObject & set(const std::string &s);
void increment();
+ void decrement();
std::string get_string_keyed(int i);
WxxObjectPtr get_pmc_keyed(int i);
WxxObjectPtr get_pmc_keyed(const std::string &s);
View
1  winxedxx_object.h
@@ -24,6 +24,7 @@ class WxxObject
virtual WxxObject & set(const char *s) = 0;
virtual WxxObject & set(const std::string &s) = 0;
virtual void increment() = 0;
+ virtual void decrement() = 0;
virtual std::string get_string_keyed(int i) = 0;
virtual WxxObjectPtr get_pmc_keyed(int i) = 0;
virtual WxxObjectPtr get_pmc_keyed(const std::string &s) = 0;
View
6 winxedxx_objectptr.cxx
@@ -170,6 +170,12 @@ WxxObjectPtr & WxxObjectPtr::operator++()
return *this;
}
+WxxObjectPtr & WxxObjectPtr::operator--()
+{
+ object->decrement();
+ return *this;
+}
+
int WxxObjectPtr::is_null() const
{
return object->is_null();
View
1  winxedxx_types.h
@@ -60,6 +60,7 @@ class WxxObjectPtr
operator double() const;
operator std::string() const;
WxxObjectPtr & operator++();
+ WxxObjectPtr & operator--();
int is_null() const;
int instanceof(const std::string &type);
std::string get_string() const;
Please sign in to comment.
Something went wrong with that request. Please try again.