summaryrefslogtreecommitdiff
path: root/ext/rpc/com/variant.h
blob: 2cef0bdeaa7acc137310641feb1ff4cd71aa34f3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
/*
   +----------------------------------------------------------------------+
   | PHP Version 4                                                        |
   +----------------------------------------------------------------------+
   | Copyright (c) 1997-2003 The PHP Group                                |
   +----------------------------------------------------------------------+
   | This source file is subject to version 2.02 of the PHP license,      |
   | that is bundled with this package in the file LICENSE, and is        |
   | available at through the world-wide-web at                           |
   | http://www.php.net/license/2_02.txt.                                 |
   | If you did not receive a copy of the PHP license and are unable to   |
   | obtain it through the world-wide-web, please send a note to          |
   | license@php.net so we can mail you a copy immediately.               |
   +----------------------------------------------------------------------+
   | Author: Harald Radi <h.radi@nme.at>                                  |
   +----------------------------------------------------------------------+
 */


#ifndef VARIANT_H
#define VARIANT_H

#if PHP_WIN32

#define ALLOC_VARIANT(v)	(v) = (variantval *) emalloc(sizeof(variantval));	\
							(v)->var = (VARIANT *) emalloc(sizeof(VARIANT));	\
							(v)->codepage = CP_ACP;								\
							VariantInit((v)->var);

#define FREE_VARIANT(v)		VariantClear((v)->var);								\
							efree((v)->var);									\
							efree((v));

#define ZVAL_VARIANT(z, v, cp)													\
	if (V_VT(v) == VT_DISPATCH) {												\
		rpc_internal *intern;													\
		comval *obj;															\
		ALLOC_COM(obj);															\
		Z_TYPE_P(z) = IS_OBJECT;												\
		(z)->value.obj = rpc_objects_new(com_class_entry TSRMLS_CC);			\
		if (GET_INTERNAL_EX(intern, (z)) != SUCCESS) {							\
			/* TODO: exception */												\
		}																		\
		php_COM_set(obj, &V_DISPATCH(v), TRUE);									\
		intern->data = obj;														\
	} else {																	\
		php_variant_to_zval((v), (z), cp);										\
		VariantClear(v);														\
		efree(v);																\
	}

#define RETVAL_VARIANT(v, cp)	ZVAL_VARIANT(return_value, v, cp)
#define RETURN_VARIANT(v, cp)	RETVAL_VARIANT(v, cp)							\
								return;

typedef struct variantval_ {
	VARIANT* var;
	long codepage;
} variantval;

void php_variant_init(int module_number TSRMLS_DC);
void php_variant_shutdown(TSRMLS_D);

ZEND_FUNCTION(variant_load);

#endif  /* PHP_WIN32 */

#endif  /* VARIANT_H */