Skip to content
Browse files

improve operator new:

  • Loading branch information...
1 parent 95760c0 commit 1511b37cb232178b4af31caaa90077799dcab963 @NotFound committed Jun 11, 2012
Showing with 35 additions and 31 deletions.
  1. +4 −2 t/base/03class.t
  2. +6 −3 winxedxx.winxed
  3. +6 −24 winxedxx_types.h
  4. +19 −2 winxedxx_util.cxx
View
6 t/base/03class.t
@@ -46,12 +46,14 @@ class Parent { }
class Foo : Parent
{
+ var n;
function Foo()
{
+ self.n = 3;
}
function get()
{
- return 3;
+ return self.n;
}
}
@@ -75,7 +77,7 @@ function main [main] (var args)
is(i, 7, "new qualified without constructor call");
foo = new Bar.Foo();
i = foo.get();
- is(i, 3, "class with same name in other namespace");
+ is(i, 3, "class with same name in other namespace - constructor with 0 args");
}
// End
View
9 winxedxx.winxed
@@ -906,9 +906,12 @@ function emit_NewQualifiedExpr(out, expr)
out.print(".childNamespace(\"", key[i], "\")");
string clname = "\"" + string(key[n - 1]) + "\"";
out.print(".get(", clname, ")");
- if (numinits > 0) {
- out.print(ARGSEP, clname, ARGSEP);
- emit_callargs(out, initializer);
+ if (numinits >= 0) {
+ out.print(ARGSEP, clname);
+ if (numinits > 0) {
+ out.print(ARGSEP);
+ emit_callargs(out, initializer);
+ }
}
out.print(")");
}
View
30 winxedxx_types.h
@@ -153,30 +153,12 @@ WxxObjectPtr wxx_new(const std::string &name);
WxxObjectPtr wxx_new(const std::string &name, WxxObjectArray args);
WxxObjectPtr wxx_new_string(const std::string &name);
WxxObjectPtr wxx_new_string(const std::string &name, WxxObjectPtr arg);
-/*
-WxxObjectPtr wxx_new_keyed(const char * const name[], int n);
-template <int N>
-WxxObjectPtr wxx_new_keyed(const char * const name[N])
-{
- return wxx_new_keyed(name, N);
-}
-*/
-inline WxxObjectPtr wxx_new_obj(const WxxObjectPtr &clobj)
-{
- return clobj.instantiate();
-}
-inline WxxObjectPtr wxx_new_obj(const WxxObjectPtr &clobj, const std::string &constructor)
-{
- WxxObjectPtr obj = clobj.instantiate();
- obj.call_method(constructor);
- return obj;
-}
-inline WxxObjectPtr wxx_new_obj(const WxxObjectPtr &clobj, const std::string &constructor, WxxObjectArray &args)
-{
- WxxObjectPtr obj = clobj.instantiate();
- obj.call_method(constructor, args);
- return obj;
-}
+
+WxxObjectPtr wxx_new_obj(const WxxObjectPtr &clobj);
+WxxObjectPtr wxx_new_obj(const WxxObjectPtr &clobj,
+ const std::string &constructor);
+WxxObjectPtr wxx_new_obj(const WxxObjectPtr &clobj,
+ const std::string &constructor, WxxObjectArray args);
WxxObjectPtr wxx_open(const std::string &filename);
WxxObjectPtr wxx_open(const std::string &filename, const std::string &mode);
View
21 winxedxx_util.cxx
@@ -565,11 +565,28 @@ WxxObjectPtr wxx_new_string(const std::string &name, WxxObjectPtr arg)
return WxxObjectPtr(obj);
}
-WxxObjectPtr wxx_new_keyed(const char * const name[], int n)
+WxxObjectPtr wxx_new_obj(const WxxObjectPtr &clobj)
{
- return winxedxxnull;
+ return clobj.instantiate();
}
+WxxObjectPtr wxx_new_obj(const WxxObjectPtr &clobj,
+ const std::string &constructor)
+{
+ WxxObjectPtr obj = clobj.instantiate();
+ obj.call_method(constructor);
+ return obj;
+}
+
+WxxObjectPtr wxx_new_obj(const WxxObjectPtr &clobj,
+ const std::string &constructor, WxxObjectArray args)
+{
+ WxxObjectPtr obj = clobj.instantiate();
+ obj.call_method(constructor, args);
+ return obj;
+}
+
+
WxxObjectPtr wxx_open(const std::string &filename)
{
WxxFileHandle *handle = new WxxFileHandle();

0 comments on commit 1511b37

Please sign in to comment.
Something went wrong with that request. Please try again.