Back to index

php5  5.3.10
php_com_dotnet_internal.h
Go to the documentation of this file.
00001 /*
00002    +----------------------------------------------------------------------+
00003    | PHP Version 5                                                        |
00004    +----------------------------------------------------------------------+
00005    | Copyright (c) 1997-2012 The PHP Group                                |
00006    +----------------------------------------------------------------------+
00007    | This source file is subject to version 3.01 of the PHP license,      |
00008    | that is bundled with this package in the file LICENSE, and is        |
00009    | available through the world-wide-web at the following url:           |
00010    | http://www.php.net/license/3_01.txt                                  |
00011    | If you did not receive a copy of the PHP license and are unable to   |
00012    | obtain it through the world-wide-web, please send a note to          |
00013    | license@php.net so we can mail you a copy immediately.               |
00014    +----------------------------------------------------------------------+
00015    | Author: Wez Furlong <wez@thebrainroom.com>                           |
00016    +----------------------------------------------------------------------+
00017  */
00018 
00019 /* $Id: php_com_dotnet_internal.h 321634 2012-01-01 13:15:04Z felipe $ */
00020 
00021 #ifndef PHP_COM_DOTNET_INTERNAL_H
00022 #define PHP_COM_DOTNET_INTERNAL_H
00023 
00024 #define _WIN32_DCOM
00025 #define COBJMACROS
00026 #include <ocidl.h>
00027 #include <oleauto.h>
00028 #include <unknwn.h>
00029 #include <dispex.h>
00030 #include "win32/winutil.h"
00031 
00032 /* brain-death in winutil.h defines the macro to hide the useful function... */
00033 #undef php_win_err
00034 
00035 typedef struct _php_com_dotnet_object {
00036        zend_object zo;
00037 
00038        VARIANT v;
00039        int modified;
00040 
00041        ITypeInfo *typeinfo;
00042        long code_page;
00043 
00044        zend_class_entry *ce;
00045 
00046        /* associated event sink */
00047        IDispatch *sink_dispatch;
00048        GUID sink_id;
00049        DWORD sink_cookie;
00050 
00051        /* cache for method signatures */
00052        HashTable *method_cache;
00053        /* cache for name -> DISPID */
00054        HashTable *id_of_name_cache;
00055 } php_com_dotnet_object;
00056 
00057 static inline int php_com_is_valid_object(zval *zv TSRMLS_DC)
00058 {
00059        zend_class_entry *ce = Z_OBJCE_P(zv);
00060        return strcmp("com", ce->name) == 0 ||
00061               strcmp("dotnet", ce->name) == 0 ||
00062               strcmp("variant", ce->name) == 0;
00063 }
00064 
00065 #define CDNO_FETCH(zv)                    (php_com_dotnet_object*)zend_object_store_get_object(zv TSRMLS_CC)
00066 #define CDNO_FETCH_VERIFY(obj, zv) do { \
00067        if (!php_com_is_valid_object(zv TSRMLS_CC)) { \
00068               php_com_throw_exception(E_UNEXPECTED, "expected a variant object" TSRMLS_CC); \
00069               return; \
00070        } \
00071        obj = (php_com_dotnet_object*)zend_object_store_get_object(zv TSRMLS_CC); \
00072 } while(0)
00073 
00074 /* com_extension.c */
00075 TsHashTable php_com_typelibraries;
00076 zend_class_entry *php_com_variant_class_entry, *php_com_exception_class_entry, *php_com_saproxy_class_entry;
00077 
00078 /* com_handlers.c */
00079 zend_object_value php_com_object_new(zend_class_entry *ce TSRMLS_DC);
00080 void php_com_object_clone(void *object, void **clone_ptr TSRMLS_DC);
00081 void php_com_object_free_storage(void *object TSRMLS_DC);
00082 zend_object_handlers php_com_object_handlers;
00083 void php_com_object_enable_event_sink(php_com_dotnet_object *obj, int enable TSRMLS_DC);
00084 
00085 /* com_saproxy.c */
00086 zend_object_iterator *php_com_saproxy_iter_get(zend_class_entry *ce, zval *object, int by_ref TSRMLS_DC);
00087 int php_com_saproxy_create(zval *com_object, zval *proxy_out, zval *index TSRMLS_DC);
00088 
00089 /* com_olechar.c */
00090 PHPAPI char *php_com_olestring_to_string(OLECHAR *olestring,
00091               uint *string_len, int codepage TSRMLS_DC);
00092 PHPAPI OLECHAR *php_com_string_to_olestring(char *string,
00093               uint string_len, int codepage TSRMLS_DC);
00094 
00095 
00096 /* com_com.c */
00097 PHP_FUNCTION(com_create_instance);
00098 PHP_FUNCTION(com_event_sink);
00099 PHP_FUNCTION(com_create_guid);
00100 PHP_FUNCTION(com_print_typeinfo);
00101 PHP_FUNCTION(com_message_pump);
00102 PHP_FUNCTION(com_load_typelib);
00103 PHP_FUNCTION(com_get_active_object);
00104 
00105 HRESULT php_com_invoke_helper(php_com_dotnet_object *obj, DISPID id_member,
00106               WORD flags, DISPPARAMS *disp_params, VARIANT *v, int silent, int allow_noarg TSRMLS_DC);
00107 HRESULT php_com_get_id_of_name(php_com_dotnet_object *obj, char *name,
00108               int namelen, DISPID *dispid TSRMLS_DC);
00109 int php_com_do_invoke_by_id(php_com_dotnet_object *obj, DISPID dispid,
00110               WORD flags,   VARIANT *v, int nargs, zval **args, int silent, int allow_noarg TSRMLS_DC);
00111 int php_com_do_invoke(php_com_dotnet_object *obj, char *name, int namelen,
00112               WORD flags,   VARIANT *v, int nargs, zval **args, int allow_noarg TSRMLS_DC);
00113 int php_com_do_invoke_byref(php_com_dotnet_object *obj, char *name, int namelen,
00114               WORD flags,   VARIANT *v, int nargs, zval ***args TSRMLS_DC);
00115 
00116 /* com_wrapper.c */
00117 int php_com_wrapper_minit(INIT_FUNC_ARGS);
00118 PHPAPI IDispatch *php_com_wrapper_export_as_sink(zval *val, GUID *sinkid, HashTable *id_to_name TSRMLS_DC);
00119 PHPAPI IDispatch *php_com_wrapper_export(zval *val TSRMLS_DC);
00120 
00121 /* com_persist.c */
00122 int php_com_persist_minit(INIT_FUNC_ARGS);
00123 
00124 /* com_variant.c */
00125 PHP_FUNCTION(com_variant_create_instance);
00126 PHP_FUNCTION(variant_set);
00127 PHP_FUNCTION(variant_add);
00128 PHP_FUNCTION(variant_cat);
00129 PHP_FUNCTION(variant_sub);
00130 PHP_FUNCTION(variant_mul);
00131 PHP_FUNCTION(variant_and);
00132 PHP_FUNCTION(variant_div);
00133 PHP_FUNCTION(variant_eqv);
00134 PHP_FUNCTION(variant_idiv);
00135 PHP_FUNCTION(variant_imp);
00136 PHP_FUNCTION(variant_mod);
00137 PHP_FUNCTION(variant_or);
00138 PHP_FUNCTION(variant_pow);
00139 PHP_FUNCTION(variant_xor);
00140 PHP_FUNCTION(variant_abs);
00141 PHP_FUNCTION(variant_fix);
00142 PHP_FUNCTION(variant_int);
00143 PHP_FUNCTION(variant_neg);
00144 PHP_FUNCTION(variant_not);
00145 PHP_FUNCTION(variant_round);
00146 PHP_FUNCTION(variant_cmp);
00147 PHP_FUNCTION(variant_date_to_timestamp);
00148 PHP_FUNCTION(variant_date_from_timestamp);
00149 PHP_FUNCTION(variant_get_type);
00150 PHP_FUNCTION(variant_set_type);
00151 PHP_FUNCTION(variant_cast);
00152 
00153 PHPAPI void php_com_variant_from_zval_with_type(VARIANT *v, zval *z, VARTYPE type, int codepage TSRMLS_DC);
00154 PHPAPI void php_com_variant_from_zval(VARIANT *v, zval *z, int codepage TSRMLS_DC);
00155 PHPAPI int php_com_zval_from_variant(zval *z, VARIANT *v, int codepage TSRMLS_DC);
00156 PHPAPI int php_com_copy_variant(VARIANT *dst, VARIANT *src TSRMLS_DC);
00157 
00158 /* com_dotnet.c */
00159 PHP_FUNCTION(com_dotnet_create_instance);
00160 void php_com_dotnet_rshutdown(TSRMLS_D);
00161 void php_com_dotnet_mshutdown(TSRMLS_D);
00162 
00163 /* com_misc.c */
00164 void php_com_throw_exception(HRESULT code, char *message TSRMLS_DC);
00165 PHPAPI void php_com_wrap_dispatch(zval *z, IDispatch *disp,
00166               int codepage TSRMLS_DC);
00167 PHPAPI void php_com_wrap_variant(zval *z, VARIANT *v,
00168               int codepage TSRMLS_DC);
00169 PHPAPI int php_com_safearray_get_elem(VARIANT *array, VARIANT *dest, LONG dim1 TSRMLS_DC);
00170 
00171 /* com_typeinfo.c */
00172 PHPAPI ITypeLib *php_com_load_typelib_via_cache(char *search_string,
00173               int codepage, int *cached TSRMLS_DC);
00174 PHPAPI ITypeLib *php_com_load_typelib(char *search_string, int codepage TSRMLS_DC);
00175 PHPAPI int php_com_import_typelib(ITypeLib *TL, int mode,
00176               int codepage TSRMLS_DC);
00177 void php_com_typelibrary_dtor(void *pDest);
00178 ITypeInfo *php_com_locate_typeinfo(char *typelibname, php_com_dotnet_object *obj, char *dispname, int sink TSRMLS_DC);
00179 int php_com_process_typeinfo(ITypeInfo *typeinfo, HashTable *id_to_name, int printdef, GUID *guid, int codepage TSRMLS_DC);
00180 
00181 /* com_iterator.c */
00182 zend_object_iterator *php_com_iter_get(zend_class_entry *ce, zval *object, int by_ref TSRMLS_DC);
00183 
00184 
00185 #endif