Esempio n. 1
0
    /**
     *  Startup function that is called by the Zend engine 
     *  to retrieve all information about the extension
     *  @return void*
     */
    PHPCPP_EXPORT void *get_module() {
        // create static instance of the extension object
        static Php::Extension myExtension("complex", "1.0");

        Php::Namespace myNamespace("trComplex");
        
        // description of the class so that PHP knows which methods are accessible
        Php::Class<Complex> complex("Complex");

        // register the increment method, and specify its parameters
        complex.method("mod", &Complex::mod, {});
        complex.method("__construct", &Complex::__construct);
        //complex.method("getReal", &Complex::getReal);
        complex.method("add", &Complex::add, {
            Php::ByVal("op", "trComplex\\Complex", false, true)
        });
        
        myNamespace.add(std::move(complex));

        // add the class to the extension
        //myExtension.add(std::move(complex));
        myExtension.add(std::move(myNamespace));

        // return the extension
        return myExtension;
    }
 // export the "get_module" function that will be called by the Zend engine
 PHPCPP_EXPORT void *get_module()
 {
     // create extension
     static Php::Extension extension("my_function_with_parameters","1.0");
     
     // add function, with undefined parameters, to extension
     extension.add<my_with_undefined_parameters_function>("my_with_undefined_parameters_function");
     
     // add function, with defined numeric parameters, to extension
     extension.add<my_with_defined_parameters_function>("my_with_defined_parameters_function", {
         Php::ByVal("x", Php::Type::Numeric),
         Php::ByVal("y", Php::Type::Numeric)
         });
     
     // add function, with defined parameter by reference, to extension
     extension.add<my_with_defined_parameters_reference_function>("my_with_defined_parameters_reference_function", {
         Php::ByRef("string", Php::Type::String)
         });
     
     // add function, with defined array parameter, to extension
     extension.add<my_with_defined_array_parameters_function>("my_with_defined_array_parameters_function", {
         Php::ByVal("array", Php::Type::Array)
         });
     
     // add function, with defined object parameter, to extension
     extension.add<my_with_defined_object_parameters_function>("my_with_defined_object_parameters_function", {
         Php::ByVal("myClassObjVar", "MyPhpClass")
         });
     
     // return the extension module
     return extension.module();
 }
Esempio n. 3
0
	PHPCPP_EXPORT void *get_module()
	{
		static Php::Extension extension("PHP Osu Performance Points", "1.0");
		Php::Class<POPP> POPP("POPP");
		POPP.method<&POPP::__construct>("__construct");
		POPP.method<&POPP::calculate>("calculate");
		POPP.method<&POPP::calculateAcc>("calculateAcc");
		extension.add(POPP);
		return extension;
	}
    // export the "get_module" function that will be called by the Zend engine
    PHPCPP_EXPORT void *get_module()
    {
        // create extension
        static Php::Extension extension("my_function_return_value","1.0");

        // add function to extension
        extension.add<my_return_value_function>("my_return_value_function");

        // return the extension module
        return extension.module();
    }
Esempio n. 5
0
 // export the "get_module" function that will be called by the Zend engine
 PHPCPP_EXPORT void *get_module()
 {
     // create extension
     static Php::Extension extension("my_function_void","1.0");
     
     // add function to extension
     extension.add("my_void_function", my_function_void);
     
     // return the extension module
     return extension.module();
 }
Esempio n. 6
0
 // export the "get_module" function that will be called by the Zend engine
 PHPCPP_EXPORT void *get_module()
 {
     // create extension
     static Php::Extension extension("globals","1.0");
     
     // add function to extension
     extension.add("process_globals", process_globals);
     
     // return the extension module
     return extension.module();
 }
Esempio n. 7
0
 // export the "get_module" function that will be called by the Zend engine
 PHPCPP_EXPORT void *get_module()
 {
     // create extension
     static Php::Extension extension("elmars", "1.0");
     extension.add("hallo", hello, {
         Php::ByVal("firstname", Php::Type::Numeric),
         Php::ByVal("lastname", Php::Type::String)
     });
     extension.add("sum_all", sumAll);
     // return the extension module
     return extension.module();
 }
Esempio n. 8
0
 // export the "get_module" function that will be called by the Zend engine
 PHPCPP_EXPORT void *get_module()
 {
     // create extension
     static Php::Extension extension("call_php_function","1.0");
     
     // add function to extension
     extension.add("call_php_function", call_php_function, {
         Php::ByVal("addFunc", Php::Type::Callable),
         Php::ByVal("x", Php::Type::Numeric)
         });
     
     // return the extension module
     return extension.module();
 }
Esempio n. 9
0
    /**
     *  Function that is called by PHP right after the PHP process
     *  has started, and that returns an address of an internal PHP
     *  structure with all the details and features of your extension
     *
     *  @return void*   a pointer to an address that is understood by PHP
     */
    PHPCPP_EXPORT void *get_module() 
    {
        static Php::Extension extension("dbreader", "0.2");

        Php::Class<DBReader<int32_t>> intDB("IntDBReader");
        intDB.method("__construct", &DBReader<int32_t>::__construct);
        intDB.method("__destruct", &DBReader<int32_t>::__destruct);
        intDB.method("getDataSize", &DBReader<int32_t>::getDataSize);
        intDB.method("getSize", &DBReader<int32_t>::getSize);
        intDB.method("getData", &DBReader<int32_t>::getData);
        intDB.method("getDbKey", &DBReader<int32_t>::getDbKey);
        intDB.method("getLength", &DBReader<int32_t>::getLength);
        intDB.method("getOffset", &DBReader<int32_t>::getOffset);
        intDB.method("getId", &DBReader<int32_t>::getId);

        intDB.property("USE_DATA", "1", Php::Public | Php::Static);
        intDB.property("USE_WRITABLE", "2", Php::Public | Php::Static);

        extension.add(std::move(intDB));

        Php::Class<DBReader<char[32]>> stringDB("StringDBReader");
        stringDB.method("__construct", &DBReader<char[32]>::__construct);
        stringDB.method("__destruct", &DBReader<char[32]>::__destruct);
        stringDB.method("getDataSize", &DBReader<char[32]>::getDataSize);
        stringDB.method("getSize", &DBReader<char[32]>::getSize);
        stringDB.method("getData", &DBReader<char[32]>::getData);
        stringDB.method("getDbKey", &DBReader<char[32]>::getDbKey);
        stringDB.method("getLength", &DBReader<char[32]>::getLength);
        stringDB.method("getOffset", &DBReader<char[32]>::getOffset);
        stringDB.method("getId", &DBReader<char[32]>::getId);

        stringDB.property("USE_DATA", "1", Php::Public | Php::Static);
        stringDB.property("USE_WRITABLE", "2", Php::Public | Php::Static);

        extension.add(std::move(stringDB));

        Php::Class<PhpDBWriter> intDBWriter("IntDBWriter");
        intDBWriter.method("__construct", &PhpDBWriter::__construct);
        intDBWriter.method("__destruct", &PhpDBWriter::__destruct);
        intDBWriter.method("write", &PhpDBWriter::write);


        intDBWriter.property("ASCII_MODE", "0", Php::Public | Php::Static);
        intDBWriter.property("BINARY_MODE", "1", Php::Public | Php::Static);

        extension.add(std::move(intDBWriter));

        return extension;
    }
Esempio n. 10
0
    /**
     *  Function that is called by PHP right after the PHP process
     *  has started, and that returns an address of an internal PHP
     *  strucure with all the details and features of your extension
     *
     *  @return void*   a pointer to an address that is understood by PHP
     */
    PHPCPP_EXPORT void *get_module() {
        // static(!) Php::Extension object that should stay in memory
        // for the entire duration of the process (that's why it's static)
        static Php::Extension extension("skeleton", "1.0");
        extension.add("helloWorld", helloWorld);
        extension.add("swap", swap,{
            Php::ByRef("a", Php::Type::Numeric),
            Php::ByRef("b", Php::Type::Numeric)
        });
        extension.add("swapObject", swap,{
            Php::ByRef("a", "sampleClass"),
            Php::ByRef("b", "sampleClass")
        });

        // @todo    add your own functions, classes, namespaces to the extension

        // return the extension
        return extension;
    }
Esempio n. 11
0
 /**
  *  Function that is called by PHP right after the PHP process
  *  has started, and that returns an address of an internal PHP
  *  strucure with all the details and features of your extension
  *
  *  @return void*   a pointer to an address that is understood by PHP
  */
 PHPCPP_EXPORT void *get_module() 
 {
     // static(!) Php::Extension object that should stay in memory
     // for the entire duration of the process (that's why it's static)
     static Php::Extension extension("returnobjecy", "1.0");
     
     // we have to class - master and child
     Php::Class<Master> master("master");
     Php::Class<Child> child("child");
     
     // the master class has one method - to return a child
     master.method("child", &Master::child);
     
     // add all classes to the extension
     extension.add(master);
     extension.add(child);
     
     // return the extension
     return extension;
 }
Esempio n. 12
0
    /**
     *  Function that is called by PHP right after the PHP process
     *  has started, and that returns an address of an internal PHP
     *  strucure with all the details and features of your extension
     *
     *  @return void*   a pointer to an address that is understood by PHP
     */
    PHPCPP_EXPORT void *get_module() {
        // static(!) Php::Extension object that should stay in memory
        // for the entire duration of the process (that's why it's static)
        static Php::Extension extension("complex", "0.0.1");

        Php::Namespace myNamespace("tr");
        Php::Class<Complex> complex("Complex");

        complex.method("mod", &Complex::mod,{});
        complex.method("phi", &Complex::phi,{});

        complex.method("real", &Complex::getReal,{});
        complex.method("image", &Complex::getImage,{});

        complex.method("__construct", &Complex::__construct);

        complex.method("add", &Complex::add,{
            Php::ByVal("op", "tr\\Complex", false, true)
        });
        complex.method("sub", &Complex::sub,{
            Php::ByVal("op", "tr\\Complex", false, true)
        });
        complex.method("mul", &Complex::mul,{
            Php::ByVal("op", "tr\\Complex", false, true)
        });
        complex.method("div", &Complex::div,{
            Php::ByVal("op", "tr\\Complex", false, true)
        });

        complex.method("conjugate", &Complex::conjugate,{});

        complex.method("__toString", &Complex::__toString);

        myNamespace.add(std::move(complex));

        extension.add(std::move(myNamespace));
        //extension.add(std::move(complex));

        // return the extension
        return extension;
    }
Esempio n. 13
0
    // export the "get_module" function that will be called by the Zend engine
    PHPCPP_EXPORT void *get_module()
    {
        // create extension
        static Php::Extension extension("extension_for_tests","0.1");
        
        // build an interface
        //Php::Interface interface("MyInterface");
        
        // add methods to the interface
        //interface.method("method1");
        //interface.method("method2");
        
        // add the interface to the extension
        //extension.add(interface);

        


        /**
         *  Classes and objects
         * 
         */
        // we are going to define a class
        Php::Class<TestBaseClass::MyCustomClass> customClass("TestBaseClass\\MyClass");
        
        // add methods to it
        customClass.method("myMethod", &TestBaseClass::MyCustomClass::myMethod, Php::Final, {});
        customClass.property("property1", "prop1");
        customClass.property("property2", "prop2", Php::Protected);

        customClass.property("CONSTANT1", "some string", Php::Const);
        customClass.property("EXP",       2.718281828459, Php::Const);
        customClass.property("CONSTANT2", -2582341, Php::Const);
        customClass.property("CONSTANT3", true, Php::Const);

        customClass.property("StatProp1", "some string", Php::Static);
        customClass.property("Exp",       2.718281828459, Php::Static);
        customClass.property("StatProp2", -2582341, Php::Static);
        customClass.property("StatProp3", true, Php::Static);

        // add the class to the extension
        extension.add(customClass);

        // Comparable
        extension.add( Php::Class<TestBaseClass::Comparable>("TestBaseClass\\Comparable") );


        // test static functions
        //
        // description of the class so that PHP knows which methods are accessible
        Php::Class<TestBaseClass::testStaticPubClass> ClassWithStatic("TestBaseClass\\ClassWithStatic");
        // register the testStaticPubClass::staticMethod to be a static method callable from PHP
        ClassWithStatic.method("static1", &TestBaseClass::testStaticPubClass::staticMethod);
        // regular functions have the same signatures as static methods. So nothing forbids you to register a normal function as static method too
        ClassWithStatic.method("static2", TestBaseClass::testStaticRegFunc);
        // and even static methods from completely different classes have the same function signature and can thus be registered
        ClassWithStatic.method("static3", &TestBaseClass::testStaticPrivClass::staticMethod);
        // add the class to the extension
        extension.add(std::move(ClassWithStatic));
        // In fact, because a static method has the same signature
        // as a regular function, you can also register static
        // C++ methods as regular global PHP functions
        extension.add("TestBaseClass\\staticFun1", &TestBaseClass::testStaticPrivClass::staticMethod);




        /**
         *  tests for Iterators
         * 
         */
        // add function to extension
        //extension.add("TestValueIterator\\loopValue", TestValueIterator::loopValue/*, {
        extension.add("TestValueIterator\\loopValue", TestValueIterator::loopValue);
        extension.add("TestValueIterator\\loopArray", TestValueIterator::loopArray);


        /**
         *  tests for variables
         * 
         */
        // create a nested namespace
        extension.add("TestVariables\\process_globals",   TestVariables::process_globals);
        extension.add("TestVariables\\get_complex_array", TestVariables::get_complex_array);
        extension.add("TestVariables\\value_types",       TestVariables::value_types);
        extension.add("TestVariables\\scalar_store",      TestVariables::scalar_store);
        extension.add("TestVariables\\value_casting",     TestVariables::value_casting);
        extension.add("TestVariables\\value_cast2double", TestVariables::value_cast2double);
        extension.add("TestVariables\\value_cast2str",    TestVariables::value_cast2str);
        extension.add("TestVariables\\overloaded_op",     TestVariables::overloaded_op);
        extension.add("TestVariables\\value_arrays",      TestVariables::value_arrays);
        extension.add("TestVariables\\value_object1",     TestVariables::value_object1);
        extension.add("TestVariables\\value_object2",     TestVariables::value_object2);
        extension.add("TestVariables\\fnFromUserSpace",   TestVariables::fnFromUserSpace);
        extension.add("TestVariables\\fnFromUserSpace2",  TestVariables::fnFromUserSpace2);
        extension.add("TestVariables\\fnCallback",        TestVariables::fnCallback);
        extension.add("TestVariables\\test_HashMember_1", TestVariables::test_HashMember_1);
        extension.add("TestVariables\\test_HashMember_2", TestVariables::test_HashMember_2);
        extension.add("TestVariables\\test_HashMember_3", TestVariables::test_HashMember_3);
        extension.add("TestVariables\\test_HashMember_4", TestVariables::test_HashMember_4);
        extension.add("TestVariables\\getCookie",         TestVariables::getCookie);
        extension.add("TestVariables\\get_post",          TestVariables::get_post);
        extension.add("TestVariables\\post_raw1",         TestVariables::post_raw1);
        extension.add("TestVariables\\post_raw2",         TestVariables::post_raw2);
        extension.add("TestVariables\\test_env",          TestVariables::test_env);
        extension.add("TestVariables\\test_compare1",     TestVariables::test_compare1);
        extension.add("TestVariables\\test_compare2",     TestVariables::test_compare2);


        


        // A sample class, with methods to cast objects to scalars
        Php::Class<TestVariables::Obj2Scalar> cObj2Scalar("TestVariables\\Obj2Scalar");
        extension.add(std::move(cObj2Scalar));


        /**
         *  tests ini entries
         * 
         */
        extension
            .add(Php::Ini("ini1", "valIni1"))
            .add(Php::Ini("ini2", "valIni2", "OrigValIni2"))
            .add(Php::Ini("ini3", "valIni3", "OrigValIni3", Php::Ini::System))
            .add(Php::Ini("ini4", true,      false, Php::Ini::Place::User))
            .add(Php::Ini("ini5",            false));

        Php::Ini ini6("ini6", 55, 11);
        extension
            .add(ini6)
            .add(Php::Ini("ini7", 74,5));

        Php::Ini ini8("ini8", 3.1415926, 6.2831852);
        Php::Ini ini9("ini9", 2.7182818, 5.4365636, Php::Ini::User);
        //extension.add(Php::Ini("ini9", 0.333333, 0.777777, Php::Ini::Perdir));

        extension.add(ini8);
        extension.add(std::move(ini9));

        extension.add("TestIniEntries\\iniTest1", TestIniEntries::iniTest1);

        extension.onStartup([](){
            // Retrieve a value at boot extension
            TestIniEntries::ini6val = Php::ini_get("ini6");
        });
         





        
        // return the extension module
        return extension;
    }
Esempio n. 14
0
	PHPCPP_EXPORT void *get_module()
	{

		static Php::Extension extension("Phalcon++", "0.0.1");

		Php::Ini ini("phalcon.debug.enable_debug", false);
		extension.add(std::move(ini));

		/**
		 * Define Phalcon namespace
		 */
		Php::Namespace phalconNamespace("Phalcon");

		/* Class Phalcon\Di\Injectable */
		Php::Class<Phalcon::Injectable> injectable("Injectable", Php::Abstract);
		phalconNamespace.add(injectable);

		/* Class Phalcon\Version */
		Php::Class<Phalcon::Version> version("Version");
		phalconNamespace.add(std::move(version));

		/* Class Phalcon\Debug */
		Php::Class<Phalcon::Debug> debug("Debug");
		phalconNamespace.add(std::move(debug));

		/* Class Phalcon\Acl */
		Php::Class<Phalcon::Acl> acl("Acl", Php::Abstract);
		phalconNamespace.add(std::move(acl));

		/* Class Phalcon\Application */
		Php::Class<Phalcon::Application> application("Application", Php::Abstract);
		phalconNamespace.add(std::move(application));

		/* Class Phalcon\Arr */
		Php::Class<Phalcon::Arr> arr("Arr");
		phalconNamespace.add(std::move(arr));

		/* Class Phalcon\Config */
		Php::Class<Phalcon::Config> config("Config");
		phalconNamespace.add(std::move(config));

		/* Class Phalcon\Loader */
		Php::Class<Phalcon::Loader> loader("Loader", injectable);
		phalconNamespace.add(std::move(loader));

		/* Interface Phalcon\DiInterface */
		Phalcon::DiInterface diInterface("DiInterface");
		phalconNamespace.add(std::move(diInterface));

		/* Class Phalcon\Di */
		Php::Class<Phalcon::Di> di("Di", diInterface);
		phalconNamespace.add(std::move(di));

		/* Interface Phalcon\DiInterface */
		Phalcon::DispatcherInterface dispatcherInterface("DispatcherInterface");
		phalconNamespace.add(std::move(dispatcherInterface));

		/* Class Phalcon\Dispatcher */
		Php::Class<Phalcon::Dispatcher> dispatcher("Dispatcher", dispatcherInterface);
		phalconNamespace.add(std::move(dispatcher));

		/* Class Phalcon\Db */
		Php::Class<Phalcon::Db> db("Db");

		phalconNamespace.add(std::move(db));

		/**
		 * Define Di namespace
		 */
		Php::Namespace diNamespace("Di");

		/* Interface Phalcon\Di\ServiceInterface */
		Phalcon::Di_ServiceInterface diServiceInterface("ServiceInterface");
		diNamespace.add(std::move(diServiceInterface));

		/* Class Phalcon\Di\Service */
		Php::Class<Phalcon::Di_Service> di_service("Service", diServiceInterface);
		diNamespace.add(std::move(di_service));

		phalconNamespace.add(std::move(diNamespace));
		extension.add(std::move(phalconNamespace));
		return extension;
	}