From ef1d4403af3f3028372c098a9657e2e48e34f5a2 Mon Sep 17 00:00:00 2001 From: Emiel Bruijntjes Date: Wed, 5 Mar 2014 12:30:39 +0100 Subject: added syntax highlighting --- documentation/loading-extensions.html | 124 +++++++++++++++++----------------- 1 file changed, 62 insertions(+), 62 deletions(-) (limited to 'documentation') diff --git a/documentation/loading-extensions.html b/documentation/loading-extensions.html index 6163596..fac26da 100644 --- a/documentation/loading-extensions.html +++ b/documentation/loading-extensions.html @@ -62,34 +62,34 @@ class that can be used instead.

-

-        #include <phpcpp.h>
+

+#include <phpcpp.h>
+
+/**
+ *  tell the compiler that the get_module is a pure C function
+ */
+extern "C" {
+    
+    /**
+     *  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 myExtension("my_extension", "1.0");
         
-        /**
-         *  tell the compiler that the get_module is a pure C function
-         */
-        extern "C" {
-            
-            /**
-             *  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 myExtension("my_extension", "1.0");
-                
-                // @todo    add your own functions, classes, namespaces to the extension
-                
-                // return the extension
-                return myExtension;
-            }
-        }
-    
+ // @todo add your own functions, classes, namespaces to the extension + + // return the extension + return myExtension; + } +} +

In the example above you see a very straightforward implementation of the @@ -160,25 +160,25 @@ by adding your native function implementations to the Extension object:

-

-        #include <phpcpp.h>
-        
-        extern void example1();
-        extern void example2(Php::Parameters &params);
-        extern Php::Value example3();
-        extern Php::Value example4(Php::Parameters &params);
-        
-        extern "C" {
-            PHPCPP_EXPORT void *get_module() {
-                static Php::Extension myExtension("my_extension", "1.0");
-                myExtension.add("native1", example1);
-                myExtension.add("native2", example2);
-                myExtension.add("native3", example3);
-                myExtension.add("native4", example4);
-                return myExtension.module();
-            }
+

+    #include <phpcpp.h>
+    
+    extern void example1();
+    extern void example2(Php::Parameters &params);
+    extern Php::Value example3();
+    extern Php::Value example4(Php::Parameters &params);
+    
+    extern "C" {
+        PHPCPP_EXPORT void *get_module() {
+            static Php::Extension myExtension("my_extension", "1.0");
+            myExtension.add("native1", example1);
+            myExtension.add("native2", example2);
+            myExtension.add("native3", example3);
+            myExtension.add("native4", example4);
+            return myExtension.module();
         }
-    
+ } +

What do we see here? We've added four function declarations ("example1", @@ -238,23 +238,23 @@ the parameters is:

-

-        #include <phpcpp.h>
-        
-        extern void example(Php::Parameters &params);
-        
-        extern "C" {
-            PHPCPP_EXPORT void *get_module() {
-                static Php::Extension myExtension("my_extension", "1.0");
-                myExtension.add("example", example, {
-                    Php::ByVal("a", Php::Type::Numeric),
-                    Php::ByVal("b", "ExampleClass"),
-                    Php::ByRef("c", "OtherClass")
-                });
-                return myExtension.module();
-            }
-        }
-    
+

+#include <phpcpp.h>
+
+extern void example(Php::Parameters &params);
+
+extern "C" {
+    PHPCPP_EXPORT void *get_module() {
+        static Php::Extension myExtension("my_extension", "1.0");
+        myExtension.add("example", example, {
+            Php::ByVal("a", Php::Type::Numeric),
+            Php::ByVal("b", "ExampleClass"),
+            Php::ByRef("c", "OtherClass")
+        });
+        return myExtension.module();
+    }
+}
+

Above you see that we passed in additional information when we registered the -- cgit v1.2.3