Update for stubs and fast zpp

This commit is contained in:
Derick Rethans
2024-02-13 14:11:47 +00:00
parent b296eb7fe1
commit 8621aa0483
6 changed files with 121 additions and 40 deletions

62
phpext-confoo24.xml Normal file
View File

@@ -0,0 +1,62 @@
<?xml version="1.0" encoding="utf-8"?>
<presentation css="derick.css">
<topic>PHP</topic>
<title>Introduction into PHP Extensions</title>
<event>ConFoo 2024</event>
<location>Montréal, Canada</location>
<date>February 23rd, 2024</date>
<speaker>Derick Rethans</speaker>
<email>derick@php.net</email>
<twitter>derickr</twitter>
<mastodon>@derickr@phpc.social</mastodon>
<url>https://derickrethans.nl/talks/phpext-confoo24</url>
<joindin></joindin>
<slide>slides/mongodb/title.xml</slide>
<slide>slides/mongodb/me.xml</slide>
<slide>slides/internals/extension-agenda.xml</slide>
<slide>slides/internals/extension-agenda2.xml</slide>
<slide>slides/internals/extension-what1.xml</slide>
<slide>slides/internals/extension-why1.xml</slide>
<slide>slides/internals/extension-why-wrap.xml</slide>
<slide>slides/internals/extension-why-not-possible.xml</slide>
<slide>slides/internals/extension-why-speed.xml</slide>
<slide>slides/internals/extension-why-not1.xml</slide>
<slide>slides/internals/rdp-intro.xml</slide>
<slide>slides/internals/rdp-intro2.xml</slide>
<slide>slides/internals/rdp-intro3.xml</slide>
<slide>slides/internals/rdp-intro4.xml</slide>
<slide>slides/internals/extension-parts.xml</slide>
<slide>slides/internals/config.m4.xml</slide>
<slide>slides/internals/config.w32.xml</slide>
<slide>slides/internals/phpize.xml</slide>
<slide>slides/internals/extension.h.xml</slide>
<slide>slides/internals/extension.c-part1.xml</slide>
<slide>slides/internals/extension.c-part1-arginfo.xml</slide>
<slide>slides/internals/extension.c-part2.xml</slide>
<slide>slides/internals/extension.c-part3.xml</slide>
<slide>slides/internals/function.xml</slide>
<slide>slides/internals/rdp_simplify-part1.xml</slide>
<slide>slides/internals/rdp_simplify-zedval.xml</slide>
<slide>slides/internals/rdp_simplify-part1b.xml</slide>
<slide>slides/internals/rdp_simplify-convert-data.xml</slide>
<slide>slides/internals/rdp_simplify-run-algorithm.xml</slide>
<slide>slides/internals/rdp_simplify-php.xml</slide>
<slide>slides/internals/rdp_simplify-c.xml</slide>
<slide>slides/internals/rdp_simplify-return-result.xml</slide>
<slide>slides/internals/rdp_simplify-return-scalars.xml</slide>
<slide>slides/internals/memory-management.xml</slide>
<slide>slides/internals/tests.xml</slide>
<slide>slides/internals/rdp-test.xml</slide>
<slide>slides/internals/debug.xml</slide>
<slide>slides/mongodb/questions.xml</slide>
<slide>slides/mongodb/resources.xml</slide>
</presentation>

View File

@@ -0,0 +1,31 @@
<slide>
<title>Extension Set-Up</title>
<subtitle>Function Definitions</subtitle>
<blurb>%php_geospatial.stub.php%</blurb>
<example><![CDATA[
<?php
/** @generate-function-entries */
function rdp_simplify(array $points, float $epsilon): array {}
]]></example>
<break lines="1"/>
<blurb>Generates %php_geospatial_arginfo.h%:</blurb>
<example><![CDATA[
/* This is a generated file, edit the .stub.php file instead.
* Stub hash: e128dccdbd9aa407d95c5b62e8000cb12d0bffa3 */
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_rdp_simplify, 0, 2, IS_ARRAY, 0)
ZEND_ARG_TYPE_INFO(0, points, IS_ARRAY, 0)
ZEND_ARG_TYPE_INFO(0, epsilon, IS_DOUBLE, 0)
ZEND_END_ARG_INFO()
ZEND_FUNCTION(rdp_simplify);
static const zend_function_entry ext_functions[] = {
ZEND_FE(rdp_simplify, arginfo_rdp_simplify)
ZEND_FE_END
};
]]></example>
</slide>

View File

@@ -7,25 +7,12 @@
#include "php.h"
#include "php_ini.h"
#include "ext/standard/info.h"
#include "php_geospatial.h"
#include "php_geospatial_arginfo.h"
#include "Zend/zend_exceptions.h"
#include "ext/spl/spl_exceptions.h"
]]></example>
<blurb>Argument Information:</blurb>
<example><![CDATA[
ZEND_BEGIN_ARG_INFO_EX(rdp_simplify_args, 0, 0, 2)
ZEND_ARG_INFO(0, pointsArray)
ZEND_ARG_INFO(0, epsilon)
ZEND_END_ARG_INFO()
]]></example>
<blurb>List of functions:</blurb>
<example><![CDATA[
const zend_function_entry geospatial_functions[] = {
PHP_FE(rdp_simplify, rdp_simplify_args)
{ NULL, NULL, NULL }
};
]]></example>
</slide>

View File

@@ -9,7 +9,7 @@ zend_module_entry geospatial_module_entry = {
STANDARD_MODULE_HEADER,
#endif
"geospatial",
geospatial_functions,
ext_functions,
PHP_MINIT(geospatial),
NULL,
NULL,

View File

@@ -6,23 +6,20 @@ PHP_FUNCTION(rdp_simplify)
{
*zval* *points_array;
*double* epsilon;
if (*zend_parse_parameters*(ZEND_NUM_ARGS() TSRMLS_CC, *"zd"*, &points_array, &epsilon)
== FAILURE) {
return;
}
if (Z_TYPE_P(points_array) != IS_ARRAY) {
return;
}
*ZEND_PARSE_PARAMETERS_START*(2, 2)
Z_PARAM_*ARRAY*(points_array)
*Z_PARAM_*DOUBLE(epsilon)
ZEND_PARSE_PARAMETERS_END();
]]></example>
<break/>
<blurb>%zend_parse_parameters%</blurb>
<break lines="3"/>
<list>
<bullet>A format letter for every type</bullet>
<bullet>A different macro for each different data type</bullet>
<bullet>Matched with a C data type</bullet>
<bullet>Cleaned up for you</bullet>
<bullet>Tests for type matches</bullet>
<bullet>Can deal with optional arguments too</bullet>
</list>
</slide>

View File

@@ -2,18 +2,22 @@
<title>Parsing Input Parameters</title>
<table>
<tr><th>letter</th><th>variable</th><th>C data-type</th></tr>
<tr><td>a</td><td>array</td><td>%zval*%</td></tr>
<tr><td>b</td><td>boolean</td><td>%zend_bool%</td></tr>
<tr><td>d</td><td>double</td><td>%double%</td></tr>
<tr><td>l</td><td>long</td><td>%zend_long%</td></tr>
<tr><td>O</td><td>object of specific type</td><td>%zval*%, %zend_class_entry%</td></tr>
<tr><td>P</td><td>path</td><td>%zend_string*%</td></tr>
<tr><td>s</td><td>string</td><td>%char*%, %size_t%</td></tr>
<tr><td>S</td><td>string</td><td>%zend_string*%</td></tr>
<tr><td>z</td><td>the actual zval</td><td>%zval*%</td></tr>
<tr><th>macro</th><th>variable</th><th>C data-type</th></tr>
<tr><td>Z_PARAM_ARRAY</td><td>array</td><td>%zval*%</td></tr>
<tr><td>Z_PARAM_ARRAY_HT</td><td>array</td><td>%HashTable%</td></tr>
<tr><td>Z_PARAM_BOOL</td><td>boolean</td><td>%zend_bool%</td></tr>
<tr><td>Z_PARAM_DOUBLE</td><td>double</td><td>%double%</td></tr>
<tr><td>Z_PARAM_LONG</td><td>long</td><td>%zend_long%</td></tr>
<tr><td>Z_PARAM_OBJECT_OF_CLASS</td><td>object of specific type</td><td>%zval*%, %zend_class_entry%</td></tr>
<tr><td>Z_PARAM_PATH</td><td>path</td><td>%zend_string*%</td></tr>
<tr><td>Z_PARAM_STRING</td><td>string</td><td>%char*%, %size_t%</td></tr>
<tr><td>Z_PARAM_STR</td><td>string</td><td>%zend_string*%</td></tr>
</table>
<break lines="2"/>
<blurb class="centre">%docs/parameter-parsing-api.md%</blurb>
<break lines="2"/>
<image filename="inputs.jpg" attr="Clive Darra - https://www.flickr.com/photos/fsse-info/3414368958/ - CC-BY-SA"/>
</slide>