php_com_dotnet_internal.h 7.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182
  1. /*
  2. +----------------------------------------------------------------------+
  3. | PHP Version 5 |
  4. +----------------------------------------------------------------------+
  5. | Copyright (c) 1997-2016 The PHP Group |
  6. +----------------------------------------------------------------------+
  7. | This source file is subject to version 3.01 of the PHP license, |
  8. | that is bundled with this package in the file LICENSE, and is |
  9. | available through the world-wide-web at the following url: |
  10. | http://www.php.net/license/3_01.txt |
  11. | If you did not receive a copy of the PHP license and are unable to |
  12. | obtain it through the world-wide-web, please send a note to |
  13. | license@php.net so we can mail you a copy immediately. |
  14. +----------------------------------------------------------------------+
  15. | Author: Wez Furlong <wez@thebrainroom.com> |
  16. +----------------------------------------------------------------------+
  17. */
  18. /* $Id$ */
  19. #ifndef PHP_COM_DOTNET_INTERNAL_H
  20. #define PHP_COM_DOTNET_INTERNAL_H
  21. #define _WIN32_DCOM
  22. #define COBJMACROS
  23. #include <ocidl.h>
  24. #include <oleauto.h>
  25. #include <unknwn.h>
  26. #include <dispex.h>
  27. #include "win32/winutil.h"
  28. typedef struct _php_com_dotnet_object {
  29. zend_object zo;
  30. VARIANT v;
  31. int modified;
  32. ITypeInfo *typeinfo;
  33. long code_page;
  34. zend_class_entry *ce;
  35. /* associated event sink */
  36. IDispatch *sink_dispatch;
  37. GUID sink_id;
  38. DWORD sink_cookie;
  39. /* cache for method signatures */
  40. HashTable *method_cache;
  41. /* cache for name -> DISPID */
  42. HashTable *id_of_name_cache;
  43. } php_com_dotnet_object;
  44. static inline int php_com_is_valid_object(zval *zv TSRMLS_DC)
  45. {
  46. zend_class_entry *ce = Z_OBJCE_P(zv);
  47. return strcmp("com", ce->name) == 0 ||
  48. strcmp("dotnet", ce->name) == 0 ||
  49. strcmp("variant", ce->name) == 0;
  50. }
  51. #define CDNO_FETCH(zv) (php_com_dotnet_object*)zend_object_store_get_object(zv TSRMLS_CC)
  52. #define CDNO_FETCH_VERIFY(obj, zv) do { \
  53. if (!php_com_is_valid_object(zv TSRMLS_CC)) { \
  54. php_com_throw_exception(E_UNEXPECTED, "expected a variant object" TSRMLS_CC); \
  55. return; \
  56. } \
  57. obj = (php_com_dotnet_object*)zend_object_store_get_object(zv TSRMLS_CC); \
  58. } while(0)
  59. /* com_extension.c */
  60. TsHashTable php_com_typelibraries;
  61. zend_class_entry *php_com_variant_class_entry, *php_com_exception_class_entry, *php_com_saproxy_class_entry;
  62. /* com_handlers.c */
  63. zend_object_value php_com_object_new(zend_class_entry *ce TSRMLS_DC);
  64. void php_com_object_clone(void *object, void **clone_ptr TSRMLS_DC);
  65. void php_com_object_free_storage(void *object TSRMLS_DC);
  66. zend_object_handlers php_com_object_handlers;
  67. void php_com_object_enable_event_sink(php_com_dotnet_object *obj, int enable TSRMLS_DC);
  68. /* com_saproxy.c */
  69. zend_object_iterator *php_com_saproxy_iter_get(zend_class_entry *ce, zval *object, int by_ref TSRMLS_DC);
  70. int php_com_saproxy_create(zval *com_object, zval *proxy_out, zval *index TSRMLS_DC);
  71. /* com_olechar.c */
  72. PHP_COM_DOTNET_API char *php_com_olestring_to_string(OLECHAR *olestring,
  73. uint *string_len, int codepage TSRMLS_DC);
  74. PHP_COM_DOTNET_API OLECHAR *php_com_string_to_olestring(char *string,
  75. uint string_len, int codepage TSRMLS_DC);
  76. /* com_com.c */
  77. PHP_FUNCTION(com_create_instance);
  78. PHP_FUNCTION(com_event_sink);
  79. PHP_FUNCTION(com_create_guid);
  80. PHP_FUNCTION(com_print_typeinfo);
  81. PHP_FUNCTION(com_message_pump);
  82. PHP_FUNCTION(com_load_typelib);
  83. PHP_FUNCTION(com_get_active_object);
  84. HRESULT php_com_invoke_helper(php_com_dotnet_object *obj, DISPID id_member,
  85. WORD flags, DISPPARAMS *disp_params, VARIANT *v, int silent, int allow_noarg TSRMLS_DC);
  86. HRESULT php_com_get_id_of_name(php_com_dotnet_object *obj, char *name,
  87. int namelen, DISPID *dispid TSRMLS_DC);
  88. int php_com_do_invoke_by_id(php_com_dotnet_object *obj, DISPID dispid,
  89. WORD flags, VARIANT *v, int nargs, zval **args, int silent, int allow_noarg TSRMLS_DC);
  90. int php_com_do_invoke(php_com_dotnet_object *obj, char *name, int namelen,
  91. WORD flags, VARIANT *v, int nargs, zval **args, int allow_noarg TSRMLS_DC);
  92. int php_com_do_invoke_byref(php_com_dotnet_object *obj, char *name, int namelen,
  93. WORD flags, VARIANT *v, int nargs, zval ***args TSRMLS_DC);
  94. /* com_wrapper.c */
  95. int php_com_wrapper_minit(INIT_FUNC_ARGS);
  96. PHP_COM_DOTNET_API IDispatch *php_com_wrapper_export_as_sink(zval *val, GUID *sinkid, HashTable *id_to_name TSRMLS_DC);
  97. PHP_COM_DOTNET_API IDispatch *php_com_wrapper_export(zval *val TSRMLS_DC);
  98. /* com_persist.c */
  99. int php_com_persist_minit(INIT_FUNC_ARGS);
  100. /* com_variant.c */
  101. PHP_FUNCTION(com_variant_create_instance);
  102. PHP_FUNCTION(variant_set);
  103. PHP_FUNCTION(variant_add);
  104. PHP_FUNCTION(variant_cat);
  105. PHP_FUNCTION(variant_sub);
  106. PHP_FUNCTION(variant_mul);
  107. PHP_FUNCTION(variant_and);
  108. PHP_FUNCTION(variant_div);
  109. PHP_FUNCTION(variant_eqv);
  110. PHP_FUNCTION(variant_idiv);
  111. PHP_FUNCTION(variant_imp);
  112. PHP_FUNCTION(variant_mod);
  113. PHP_FUNCTION(variant_or);
  114. PHP_FUNCTION(variant_pow);
  115. PHP_FUNCTION(variant_xor);
  116. PHP_FUNCTION(variant_abs);
  117. PHP_FUNCTION(variant_fix);
  118. PHP_FUNCTION(variant_int);
  119. PHP_FUNCTION(variant_neg);
  120. PHP_FUNCTION(variant_not);
  121. PHP_FUNCTION(variant_round);
  122. PHP_FUNCTION(variant_cmp);
  123. PHP_FUNCTION(variant_date_to_timestamp);
  124. PHP_FUNCTION(variant_date_from_timestamp);
  125. PHP_FUNCTION(variant_get_type);
  126. PHP_FUNCTION(variant_set_type);
  127. PHP_FUNCTION(variant_cast);
  128. PHP_COM_DOTNET_API void php_com_variant_from_zval_with_type(VARIANT *v, zval *z, VARTYPE type, int codepage TSRMLS_DC);
  129. PHP_COM_DOTNET_API void php_com_variant_from_zval(VARIANT *v, zval *z, int codepage TSRMLS_DC);
  130. PHP_COM_DOTNET_API int php_com_zval_from_variant(zval *z, VARIANT *v, int codepage TSRMLS_DC);
  131. PHP_COM_DOTNET_API int php_com_copy_variant(VARIANT *dst, VARIANT *src TSRMLS_DC);
  132. /* com_dotnet.c */
  133. PHP_FUNCTION(com_dotnet_create_instance);
  134. void php_com_dotnet_rshutdown(TSRMLS_D);
  135. void php_com_dotnet_mshutdown(TSRMLS_D);
  136. /* com_misc.c */
  137. void php_com_throw_exception(HRESULT code, char *message TSRMLS_DC);
  138. PHP_COM_DOTNET_API void php_com_wrap_dispatch(zval *z, IDispatch *disp,
  139. int codepage TSRMLS_DC);
  140. PHP_COM_DOTNET_API void php_com_wrap_variant(zval *z, VARIANT *v,
  141. int codepage TSRMLS_DC);
  142. PHP_COM_DOTNET_API int php_com_safearray_get_elem(VARIANT *array, VARIANT *dest, LONG dim1 TSRMLS_DC);
  143. /* com_typeinfo.c */
  144. PHP_COM_DOTNET_API ITypeLib *php_com_load_typelib_via_cache(char *search_string,
  145. int codepage, int *cached TSRMLS_DC);
  146. PHP_COM_DOTNET_API ITypeLib *php_com_load_typelib(char *search_string, int codepage TSRMLS_DC);
  147. PHP_COM_DOTNET_API int php_com_import_typelib(ITypeLib *TL, int mode,
  148. int codepage TSRMLS_DC);
  149. void php_com_typelibrary_dtor(void *pDest);
  150. ITypeInfo *php_com_locate_typeinfo(char *typelibname, php_com_dotnet_object *obj, char *dispname, int sink TSRMLS_DC);
  151. int php_com_process_typeinfo(ITypeInfo *typeinfo, HashTable *id_to_name, int printdef, GUID *guid, int codepage TSRMLS_DC);
  152. /* com_iterator.c */
  153. zend_object_iterator *php_com_iter_get(zend_class_entry *ce, zval *object, int by_ref TSRMLS_DC);
  154. #endif