Permalink
Browse files

use more explicit conversions

  • Loading branch information...
1 parent c8cfa80 commit 576f7d3abef2f2677977becd7044e63d339b07fa @NotFound committed Jun 1, 2012
Showing with 45 additions and 26 deletions.
  1. +20 −7 winxedxx.winxed
  2. +12 −7 winxedxx_classes.cxx
  3. +1 −1 winxedxx_default.cxx
  4. +1 −1 winxedxx_default.h
  5. +5 −4 winxedxx_integer.h
  6. +1 −1 winxedxx_null.cxx
  7. +1 −1 winxedxx_null.h
  8. +1 −1 winxedxx_object.h
  9. +2 −2 winxedxx_objectptr.cxx
  10. +1 −1 winxedxx_util.cxx
View
@@ -1313,7 +1313,7 @@ function emit_conststatement(out, st)
{
}
-function emit_varstatement(out, st)
+function emit_VarStatement(out, st)
{
string name = st.name;
var init = st.init;
@@ -1629,7 +1629,7 @@ function emit_statement(out, st)
else if (st instanceof StringArrayStatement)
emit_nativearraystatement(out, st, "String");
else if (st instanceof VarStatement)
- emit_varstatement(out, st);
+ emit_VarStatement(out, st);
else if (st instanceof LabelStatement)
emit_labelstatement(out, st);
else if (st instanceof BreakStatement)
@@ -1740,17 +1740,29 @@ function declareDataVar(out, string varname, string vartype)
//out.print(";\n");
}
-function getArgValue(out, int i)
+function getArgValue(out, string type, int i)
{
- out.print("(wxx_fun_args[", i, "]);\n");
+ out.print(" = wxx_fun_args.get_pmc_keyed(", i, ")");
+ switch (type) {
+ case REGint:
+ out.print(".get_integer()");
+ break;
+ case REGfloat:
+ out.print(".get_number()");
+ break;
+ case REGstring:
+ out.print(".get_string()");
+ break;
+ }
+ out.print(";\n");
}
function setDataVarFromArg(out, string name, string type, int i)
{
out.print(DATA + "->", name, " = ");
if (type == REGstring)
out.print(Type_String);
- getArgValue(out, i);
+ getArgValue(out, type, i);
}
function declareReferenceToData(out, string name, string type)
@@ -1873,8 +1885,9 @@ class EmitFunction
for (int i = 0; i < nparams; ++i) {
var param = params[i];
string name = param.name;
- declareDataVar(out, name, funst.getvar(name).gettype());
- getArgValue(out, i);
+ string type = funst.getvar(name).gettype();
+ declareDataVar(out, name, type);
+ getArgValue(out, type, i);
}
}
}
View
@@ -119,7 +119,7 @@ WxxIntegerArray::~WxxIntegerArray()
{
}
-int WxxIntegerArray::elements()
+int WxxIntegerArray::elements() const
{
return arr.size();
}
@@ -181,7 +181,7 @@ WxxFloatArray::~WxxFloatArray()
{
}
-int WxxFloatArray::elements()
+int WxxFloatArray::elements() const
{
return arr.size();
}
@@ -251,7 +251,7 @@ WxxStringArray::~WxxStringArray()
{
}
-int WxxStringArray::elements()
+int WxxStringArray::elements() const
{
return arr.size();
}
@@ -274,13 +274,13 @@ std::string WxxStringArray::operator[](int i) const
if (i < 0)
throw wxx_error(getname() + ": index out of bounds!");
if (i >= size)
- return winxedxxnull;
+ return std::string();
return arr[i];
}
WxxStringArray& WxxStringArray::push(WxxObjectPtr obj)
{
- arr.push_back(obj);
+ arr.push_back(obj.get_string());
return *this;
}
@@ -304,7 +304,7 @@ WxxStringArray& WxxStringArray::push(const std::string &str)
void WxxStringArray::set_pmc_keyed(int i, const WxxObjectPtr &value)
{
- arr[i] = std::string(value);
+ arr[i] = value.get_string();
}
WxxObjectPtr WxxStringArray::call_method(const std::string &methname, WxxObjectArray &args)
@@ -332,11 +332,16 @@ WxxObjectArray::~WxxObjectArray()
delete arr[i];
}
-int WxxObjectArray::elements()
+int WxxObjectArray::elements() const
{
return arr.size();
}
+WxxObjectPtr WxxObjectArray::get_pmc_keyed(int i) const
+{
+ return this->operator[](i);
+}
+
WxxObjectPtr WxxObjectArray::get_pmc_keyed(int i)
{
return this->operator[](i);
View
@@ -61,7 +61,7 @@ double WxxDefault::get_number()
return 0;
}
-int WxxDefault::elements()
+int WxxDefault::elements() const
{
notimplemented("elements");
return 0;
View
@@ -22,7 +22,7 @@ class WxxDefault : public WxxObject
int get_bool();
int get_integer();
double get_number();
- int elements();
+ int elements() const;
virtual std::string get_string();
int is_equal(const WxxObject &to);
WxxObject & set(int value);
View
@@ -91,7 +91,7 @@ class WxxIntegerArray : public WxxArrayBase
public:
WxxIntegerArray();
~WxxIntegerArray();
- int elements();
+ int elements() const;
int operator[](int i) const;
WxxObjectPtr get_pmc_keyed(int i);
WxxIntegerArray& push(WxxObjectPtr obj);
@@ -108,7 +108,7 @@ class WxxFloatArray : public WxxArrayBase
public:
WxxFloatArray();
~WxxFloatArray();
- int elements();
+ int elements() const;
double operator[](int i) const;
WxxObjectPtr get_pmc_keyed(int i);
WxxFloatArray& push(WxxObjectPtr obj);
@@ -126,7 +126,7 @@ class WxxStringArray : public WxxArrayBase
WxxStringArray();
WxxStringArray(char **argv);
~WxxStringArray();
- int elements();
+ int elements() const;
std::string operator[](int i) const;
std::string get_string_keyed(int i);
WxxObjectPtr get_pmc_keyed(int i);
@@ -145,8 +145,9 @@ class WxxObjectArray : public WxxArrayBase
public:
WxxObjectArray();
~WxxObjectArray();
- int elements();
+ int elements() const;
WxxObjectPtr operator[](int i) const;
+ WxxObjectPtr get_pmc_keyed(int i) const;
WxxObjectPtr get_pmc_keyed(int i);
WxxObjectArray& push(WxxObjectPtr obj);
WxxObjectArray& push(int i);
View
@@ -44,7 +44,7 @@ double WxxNull::get_number()
return 0;
}
-int WxxNull::elements()
+int WxxNull::elements() const
{
nullaccess("elements");
return 0;
View
@@ -17,7 +17,7 @@ class WxxNull : public WxxObject
int get_bool();
int get_integer();
double get_number();
- int elements();
+ int elements() const;
std::string get_string();
int is_equal(const WxxObject &to);
WxxObject & set(int value);
View
@@ -16,7 +16,7 @@ class WxxObject : public WxxRefcounted
virtual int get_bool() = 0;
virtual int get_integer() = 0;
virtual double get_number() = 0;
- virtual int elements() = 0;
+ virtual int elements() const = 0;
virtual std::string get_string() = 0;
virtual int is_equal(const WxxObject &to) = 0;
virtual WxxObject & set(int value) = 0;
View
@@ -217,7 +217,7 @@ WxxObjectPtr WxxObjectPtr::get_pmc_keyed(const std::string &s) const
WxxObjectPtr WxxObjectPtr::get_pmc_keyed(const WxxObjectPtr & key) const
{
- return object->get_pmc_keyed(std::string(key));
+ return object->get_pmc_keyed(key.get_string());
}
void WxxObjectPtr::set_pmc_keyed(int i, const WxxObjectPtr &value) const
@@ -234,7 +234,7 @@ WxxObjectPtr & WxxObjectPtr::set_pmc_keyed(const std::string &s,
WxxObjectPtr & WxxObjectPtr::set_pmc_keyed(const WxxObjectPtr &key,
const WxxObjectPtr &value) const
{
- return object->set_pmc_keyed(std::string(key), value);
+ return object->set_pmc_keyed(key.get_string(), value);
}
int WxxObjectPtr::exists(const std::string &key) const
View
@@ -408,7 +408,7 @@ WxxObjectPtr wxx_spawnw(WxxObjectPtr obj)
std::string args[len + 1];
const char *argv[len + 1];
for (int i = 0; i < len; ++i) {
- args[i] = std::string(obj.get_pmc_keyed(i));
+ args[i] = obj.get_string_keyed(i);
argv[i] = args[i].c_str();
}
argv[len] = 0;

0 comments on commit 576f7d3

Please sign in to comment.