summaryrefslogtreecommitdiff
path: root/tests/cpp/include
diff options
context:
space:
mode:
authorvalmat <ufabiz@gmail.com>2014-03-28 00:05:14 +0600
committervalmat <ufabiz@gmail.com>2014-03-28 00:05:14 +0600
commitf56cff9e4f67a949e6f0ae35ca63aaaea16d9a41 (patch)
treef23abcc134dc189d695152057528365f412d9be2 /tests/cpp/include
parentb2e2aa93754a12fac360e8de5196e45cd2f0f2aa (diff)
add test variables/005-cast-objects-to-scalars.phpt
Diffstat (limited to 'tests/cpp/include')
-rw-r--r--tests/cpp/include/variables.h55
1 files changed, 55 insertions, 0 deletions
diff --git a/tests/cpp/include/variables.h b/tests/cpp/include/variables.h
index b7063ef..e8cb526 100644
--- a/tests/cpp/include/variables.h
+++ b/tests/cpp/include/variables.h
@@ -289,6 +289,61 @@ namespace TestVariables {
return object;
}
+ /**
+ * A sample class, with methods to cast objects to scalars
+ */
+ class Obj2Scalar : public Php::Base
+ {
+ public:
+ /**
+ * C++ constructor and C++ destructpr
+ */
+ Obj2Scalar() {}
+ virtual ~Obj2Scalar() {}
+
+ /**
+ * Cast to a string
+ *
+ * Note that now we use const char* as return value, and not Php::Value.
+ * The __toString function is detected at compile time, and it does
+ * not have a fixed signature. You can return any value that can be picked
+ * up by a Php::Value object.
+ *
+ * @return const char *
+ */
+ const char *__toString()
+ {
+ return "Mount Meru, also called Sumeru (Sanskrit)";
+ }
+
+ /**
+ * Cast to a integer
+ * @return long
+ */
+ long __toInteger()
+ {
+ return 27032014;
+ }
+
+ /**
+ * Cast to a floating point number
+ * @return double
+ */
+ double __toFloat()
+ {
+ return 3.14159265359;
+ }
+
+ /**
+ * Cast to a boolean
+ * @return bool
+ */
+ bool __toBool()
+ {
+ return true;
+ }
+ };
+
/*
* Test Php::Value resize
*/