diff options
author | valmat <ufabiz@gmail.com> | 2014-03-28 02:34:51 +0600 |
---|---|---|
committer | valmat <ufabiz@gmail.com> | 2014-03-28 02:34:51 +0600 |
commit | 7bc500847e3027bb785c5525a21078ff72acc2ab (patch) | |
tree | 06e29578cbaf38e328b662c6e4130ad07b055f39 /tests/cpp/include/Classes_and_objects.h | |
parent | 28152192b85cbe9bf5ea08ebe8c706d12e2e13e5 (diff) |
add test: 004-static-funct.phpt (Test class with static function)
Diffstat (limited to 'tests/cpp/include/Classes_and_objects.h')
-rw-r--r-- | tests/cpp/include/Classes_and_objects.h | 81 |
1 files changed, 79 insertions, 2 deletions
diff --git a/tests/cpp/include/Classes_and_objects.h b/tests/cpp/include/Classes_and_objects.h index e9b7434..0977da9 100644 --- a/tests/cpp/include/Classes_and_objects.h +++ b/tests/cpp/include/Classes_and_objects.h @@ -49,7 +49,7 @@ namespace TestBaseClass { // check number of parameters //if (params.size() != 1) throw Php::Exception("Invalid number of parameters supplied"); - std::cout << "myMethod is called for object " << _x << std::endl; + Php::out << "myMethod is called for object " << _x << std::endl; return 5; @@ -58,7 +58,7 @@ namespace TestBaseClass { /** - * custom comparison operator + * Test custom comparison operator */ class Comparable : public Php::Base { @@ -110,6 +110,83 @@ namespace TestBaseClass { int Comparable::count = 0; + /** + * Begin test static functions + */ + + + /** + * Regular function + * + * Because a regular function does not have a 'this' pointer, + * it has the same signature as static methods + * + * @param params Parameters passed to the function + */ + void testStaticRegFunc(Php::Parameters ¶ms) + { + Php::out << "testStatic regular function"<< std::endl; + } + + /** + * A very simple class that will not be exported to PHP + */ + class testStaticPrivClass + { + public: + /** + * C++ constructor and destructor + */ + testStaticPrivClass() {} + virtual ~testStaticPrivClass() {} + + /** + * Static method + * + * A static method also has no 'this' pointer and has + * therefore a signature identical to regular functions + * + * @param params Parameters passed to the method + */ + static void staticMethod(Php::Parameters ¶ms) + { + Php::out << "testStaticPrivClass::staticMethod()"<< std::endl; + } + }; + + /** + * A very simple class that will be exported to PHP + */ + class testStaticPubClass : public Php::Base + { + public: + /** + * C++ constructor and destructor + */ + testStaticPubClass() {} + virtual ~testStaticPubClass() {} + + /** + * Another static method + * + * This static has exactly the same signature as the + * regular function and static method that were mentioned + * before + * + * @param params Parameters passed to the method + */ + static void staticMethod(Php::Parameters ¶ms) + { + Php::out << "testStaticPubClass::staticMethod()"<< std::endl; + } + }; + + + /** + * End test static functions + */ + + |