diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000..cd368d1 --- /dev/null +++ b/.gitattributes @@ -0,0 +1 @@ +*.h linguist-language=C \ No newline at end of file diff --git a/.gitignore b/.gitignore index 0a95508..5490167 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,38 @@ +.deps +*.lo +*.la +.libs +acinclude.m4 +aclocal.m4 +autom4te.cache +build +config.guess +config.h +config.h.in +config.log +config.nice +config.status +config.sub +configure +configure.in +configure.ac +include +install-sh +libtool +ltmain.sh +Makefile +Makefile.fragments +Makefile.global +Makefile.objects +missing +mkinstalldirs +modules +run-tests.php +tests/*/*.diff +tests/*/*.out +tests/*/*.php +tests/*/*.exp +tests/*/*.log +tests/*/*.sh .idea/ -.vscode/ \ No newline at end of file +.vscode/ diff --git a/LICENSE b/LICENSE index ab60297..6764e12 100644 --- a/LICENSE +++ b/LICENSE @@ -1,6 +1,6 @@ MIT License -Copyright (c) 2018 +Copyright (c) 2019 CismonX Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/config.m4 b/config.m4 new file mode 100644 index 0000000..ac66182 --- /dev/null +++ b/config.m4 @@ -0,0 +1,7 @@ +PHP_ARG_ENABLE(arma, for armadillo support, +[ --enable-arma Enable armadillo support]) + +if test "$PHP_ARMA" != "no"; then + ARMA_SRC="src/arma.c" + PHP_NEW_EXTENSION(arma, $ARMA_SRC, $ext_shared) +fi diff --git a/src/arma.c b/src/arma.c new file mode 100644 index 0000000..98c43b7 --- /dev/null +++ b/src/arma.c @@ -0,0 +1,64 @@ +// +// php-armadillo/arma.c +// +// @Author CismonX +// + +#include "php_arma.h" + +#include +#include + +#define ARMA_CE_INIT(cls, name) \ + zend_class_entry cls##_ce; \ + INIT_CLASS_ENTRY(cls##_ce, name, cls##_methods); \ + arma_##cls##_ce = zend_register_internal_class(&cls##_ce) +#define ARMA_CONST_DECLARE(cls, name, val) \ + zend_declare_class_constant_long(arma_##cls##_ce, name, sizeof(name) - 1, val) +#define ARMA_PROP_DECLARE(cls, name, flags) \ + zend_declare_property_null(arma_##cls##_ce, name, sizeof(name) - 1, flags) +#define ARMA_HANDLERS_INIT(cls) \ + memcpy(&cls##_handlers, &std_object_handlers, sizeof(zend_object_handlers)) +#define ARMA_HANDLER_SET(cls, name) \ + cls##_handlers.name = cls##_##name + +ZEND_DECLARE_MODULE_GLOBALS(arma) + +#ifdef ZTS +ZEND_TSRMLS_CACHE_DEFINE() +#endif + +PHP_MINIT_FUNCTION(arma) +{ +#ifdef ZTS + ZEND_INIT_MODULE_GLOBALS(arma, NULL, NULL); +#endif + + // ... + + return SUCCESS; +} + +PHP_MINFO_FUNCTION(arma) +{ + php_info_print_table_start(); + php_info_print_table_header(2, "armadillo support", "enabled"); + php_info_print_table_end(); +} + +zend_module_entry arma_module_entry = { + STANDARD_MODULE_HEADER, + "arma", + NULL, + PHP_MINIT(arma), + NULL, + NULL, + NULL, + PHP_MINFO(arma), + PHP_ARMA_VERSION, + STANDARD_MODULE_PROPERTIES +}; + +#ifdef COMPILE_DL_ARMA +ZEND_GET_MODULE(arma) +#endif diff --git a/src/php_arma.h b/src/php_arma.h new file mode 100644 index 0000000..f714484 --- /dev/null +++ b/src/php_arma.h @@ -0,0 +1,43 @@ +// +// php-armadillo/php_arma.h +// +// @Author CismonX +// + +#ifndef PHP_ARMA_H +#define PHP_ARMA_H + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include + +extern zend_module_entry arma_module_entry; + +#define PHP_ARMA_VERSION "0.0.1" + +#ifdef PHP_WIN32 +#define PHP_ARMA_API __declspec(dllexport) +#elif defined(__GNUC__) && __GNUC__ >= 4 +#define PHP_ARMA_API __attribute__ ((visibility("default"))) +#else +#define PHP_ARMA_API +#endif + +ZEND_BEGIN_MODULE_GLOBALS(arma) + int unused; +ZEND_END_MODULE_GLOBALS(arma) + +ZEND_EXTERN_MODULE_GLOBALS(arma) + +#ifdef ZTS +#ifdef COMPILE_DL_ARMA +ZEND_TSRMLS_CACHE_EXTERN() +#endif +#define ARMA_G(v) TSRMG(arma_globals_id, zend_arma_globals*, v) +#else +#define ARMA_G(v) (arma_globals.v) +#endif + +#endif // !PHP_ARMA_H diff --git a/stubs/Base.php b/stubs/Base.php new file mode 100644 index 0000000..f73cc5d --- /dev/null +++ b/stubs/Base.php @@ -0,0 +1,26 @@ +