1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 // Basic.h : Declaration of the CBasic
24 
25 #ifndef __BASIC_H_
26 #define __BASIC_H_
27 
28 #include "resource.h"       // main symbols
29 //#include "AxTestComponents.h"
30 #import  "AxTestComponents.tlb" no_namespace no_implementation raw_interfaces_only named_guids
31 //#include "AxTestComponents.h"
32 /////////////////////////////////////////////////////////////////////////////
33 // CBasic
34 class ATL_NO_VTABLE CBasic :
35 	public CComObjectRootEx<CComSingleThreadModel>,
36 	public CComCoClass<CBasic, &CLSID_Basic>,
37 	public IDispatchImpl<IBasic, &IID_IBasic, &LIBID_AXTESTCOMPONENTSLib>
38 	{
39 public:
40 	CBasic();
41 	~CBasic();
42 
43 	DECLARE_REGISTRY_RESOURCEID(IDR_BASIC)
44 
45 	DECLARE_PROTECT_FINAL_CONSTRUCT()
46 
47 	BEGIN_COM_MAP(CBasic)
48 		COM_INTERFACE_ENTRY(IBasic)
49 		COM_INTERFACE_ENTRY(IDispatch)
50 	END_COM_MAP()
51 
52 	// IBasic
53 public:
54 	STDMETHOD(outMore)(/*[out]*/long* val1, /*[out]*/long* val2);
55 	STDMETHOD(inMulDimArrayByte2)(LPSAFEARRAY val);
56 	STDMETHOD(inMulDimArrayByte)(LPSAFEARRAY val);
57 	STDMETHOD(inMulDimArrayVariant2)(LPSAFEARRAY val);
58 	STDMETHOD(inMulDimArrayLong2)(LPSAFEARRAY val);
59 	STDMETHOD(inMulDimArrayVariant)(LPSAFEARRAY val);
60 	STDMETHOD(inMulDimArrayLong)( LPSAFEARRAY val);
61 	STDMETHOD(inoutSequenceObject)(LPSAFEARRAY* val);
62 	STDMETHOD(inoutSequenceDouble)(LPSAFEARRAY * val);
63 	STDMETHOD(inoutSequenceFloat)(LPSAFEARRAY * val);
64 	STDMETHOD(inoutSequenceString)(LPSAFEARRAY* val);
65 	STDMETHOD(inoutSequenceLong)(LPSAFEARRAY * val);
66 	STDMETHOD(inoutSequenceShort)(LPSAFEARRAY * val);
67 	STDMETHOD(inoutSequenceByte)(LPSAFEARRAY * val);
68 	STDMETHOD(outSequenceObject)(/*[out]*/ LPSAFEARRAY* val);
69 	STDMETHOD(outSequenceDouble)(/*[out]*/ LPSAFEARRAY* val);
70 	STDMETHOD(outSequenceFloat)(/*[out]*/ LPSAFEARRAY* val);
71 	STDMETHOD(outSequenceString)(/*[out]*/ LPSAFEARRAY* val);
72 	STDMETHOD(outSequenceLong)(/*[out]*/ LPSAFEARRAY* val);
73 	STDMETHOD(outSequenceShort)(/*[out]*/ LPSAFEARRAY* val);
74 	STDMETHOD(outSequenceByte)(/*[out]*/ LPSAFEARRAY* val);
75 	STDMETHOD(inSequenceObject)(LPSAFEARRAY ar);
76 	STDMETHOD(inSequenceDouble)(LPSAFEARRAY ar);
77 	STDMETHOD(inSequenceFloat)(LPSAFEARRAY ar);
78 	STDMETHOD(inSequenceString)(LPSAFEARRAY ar);
79 	STDMETHOD(inSequenceShort)(LPSAFEARRAY ar);
80 	STDMETHOD(inSequenceByte)(LPSAFEARRAY ar);
81 	STDMETHOD(inSequenceLong)(LPSAFEARRAY  ar);
82 	STDMETHOD(mixed1)(
83 		/* [out][in] */ unsigned char *aChar,
84 		/* [out][in] */ float *aFloat,
85 		/* [out][in] */ VARIANT *aVar);
86 		STDMETHOD(get_prpObject)(/*[out, retval]*/ IDispatch* *pVal);
87 	STDMETHOD(put_prpObject)(/*[in]*/ IDispatch* newVal);
88 	STDMETHOD(get_prpArray)(/*[out, retval]*/ LPSAFEARRAY *pVal);
89 	STDMETHOD(put_prpArray)(/*[in]*/ LPSAFEARRAY newVal);
90 	STDMETHOD(get_prpVariant)(/*[out, retval]*/ VARIANT *pVal);
91 	STDMETHOD(put_prpVariant)(/*[in]*/ VARIANT newVal);
92 	STDMETHOD(get_prpDouble)(/*[out, retval]*/ double *pVal);
93 	STDMETHOD(put_prpDouble)(/*[in]*/ double newVal);
94 	STDMETHOD(get_prpFloat)(/*[out, retval]*/ float *pVal);
95 	STDMETHOD(put_prpFloat)(/*[in]*/ float newVal);
96 	STDMETHOD(get_prpString)(/*[out, retval]*/ BSTR *pVal);
97 	STDMETHOD(put_prpString)(/*[in]*/ BSTR newVal);
98 	STDMETHOD(get_prpLong)(/*[out, retval]*/ long *pVal);
99 	STDMETHOD(put_prpLong)(/*[in]*/ long newVal);
100 	STDMETHOD(get_prpShort)(/*[out, retval]*/ short *pVal);
101 	STDMETHOD(put_prpShort)(/*[in]*/ short newVal);
102 	STDMETHOD(get_prpByte)(/*[out, retval]*/ unsigned char *pVal);
103 	STDMETHOD(put_prpByte)(/*[in]*/ unsigned char newVal);
104 	STDMETHOD(get_prpBool)(/*[out, retval]*/ VARIANT_BOOL *pVal);
105 	STDMETHOD(put_prpBool)(/*[in]*/ VARIANT_BOOL newVal);
106 
107 	STDMETHOD(outObject)(/*[out]*/ IDispatch* *val);
108 	STDMETHOD(outArray)(/*[out]*/ LPSAFEARRAY * val);
109 	STDMETHOD(outVariant)(/*[out]*/ VARIANT* val);
110 	STDMETHOD(outDouble)(/*[out]*/ double* val);
111 	STDMETHOD(outFloat)(/*[out]*/ float* val);
112 	STDMETHOD(outString)(/*[out]*/ BSTR* val);
113 	STDMETHOD(outLong)(/*[out]*/ long* val);
114 	STDMETHOD(outShort)(/*[out]*/ short* val);
115 	STDMETHOD(outByte)(/*[out]*/ unsigned char* val);
116 	STDMETHOD(outBool)(/*[out]*/ VARIANT_BOOL* val);
117 
118 	STDMETHOD(inoutObject)(/*[in,out]*/ IDispatch* *val);
119 	STDMETHOD(inoutArray)(/*[in,out]*/ LPSAFEARRAY * val);
120 	STDMETHOD(inoutVariant)(/*[in,out]*/ VARIANT * val);
121 	STDMETHOD(inoutDouble)(/*[in,out]*/ double * val);
122 	STDMETHOD(inoutFloat)(/*[in,out]*/ float * val);
123 	STDMETHOD(inoutString)(/*[in, out]*/ BSTR* val);
124 	STDMETHOD(inoutLong)(/*[in,out]*/ long * val);
125 	STDMETHOD(inoutShort)(/*[in,out]*/ short* val);
126 	STDMETHOD(inoutByte)(/*[in,out]*/ unsigned char* val);
127 	STDMETHOD(inoutBool)(/*[in,out]*/ VARIANT_BOOL* val);
128 
129 
130 	STDMETHOD(inObject)(/*[in]*/ IDispatch* val);
131 	STDMETHOD(inArray)(/*[in]*/ LPSAFEARRAY val);
132 	STDMETHOD(inVariant)(/*[in]*/ VARIANT val);
133 	STDMETHOD(inDouble)(/*[in]*/ double val);
134 	STDMETHOD(inFloat)(/*[in]*/ float val);
135 	STDMETHOD(inString)(/*[in]*/ BSTR val);
136 	STDMETHOD(inLong)(/*[in]*/ long val);
137 	STDMETHOD(inShort)(/*[in]*/ short val);
138 	STDMETHOD(inByte)(/*[in]*/ unsigned char val);
139 	STDMETHOD(inBool)(/*[in]*/ VARIANT_BOOL val);
140 
141 
142 	STDMETHOD(optional1)(/*[in]*/ long val1, /*[in, optional]*/ VARIANT* val2);
143 	STDMETHOD(optional2)(/*[out]*/ long* val1,/*[out, optional]*/ VARIANT* val2);
144 	STDMETHOD(optional3)(/*[in, optional]*/ VARIANT* val1,/*[in, optional]*/ VARIANT* val2);
145 	STDMETHOD(optional4)(/*[in, out, optional]*/ VARIANT* val1,/*[in, out, optional]*/ VARIANT* val2);
146 	STDMETHOD(optional5)(/*[out, optional]*/ VARIANT* val1,/*[out, optional]*/ VARIANT* val2);
147 
148 
149 	STDMETHOD(defaultvalue1)(/*[in, defaultvalue(10)]*/ long val1,
150 		/*[in, defaultvalue(3.14)]*/ double* val2,
151 		// /*[in, defaultvalue(10)]*/ VARIANT val3,
152 		/*[in, defaultvalue(100)]*/ VARIANT* val4);
153 
154 		STDMETHOD(defaultvalue2)(/*[in, out, defaultvalue(10)]*/ long* val1,
155 		/*[in, out, defaultvalue(3.14)]*/ double* val2,
156 		// /*[in, out, defaultvalue(10)]*/ VARIANT* val3,
157 		/*[in, out, defaultvalue(100)]*/ VARIANT* val4);
158 
159 		STDMETHOD(varargfunc1)(/*[in]*/ long val1,/*[in]*/ LPSAFEARRAY val2);
160 
161 	STDMETHOD(varargfunc2)(/*[out]*/ long* val1, /*[out]*/ SAFEARRAY ** val2);
162 
163 
164 	// members for property implementations
165 	unsigned char m_cPrpByte;
166 	short m_nPrpShort;
167 	long m_lPrpLong;
168 	float m_fPrpFloat;
169 	double m_dPrpDouble;
170 	CComPtr<IDispatch> m_PrpObject;
171 	CComPtr<IUnknown> m_prpUnknown;
172 
173 	CComBSTR m_bstrPrpString;
174 	CComVariant m_PropVariant;
175 	LPSAFEARRAY m_PrpArray;
176 protected:
177 	VARIANT_BOOL m_bool;
178 	unsigned char  m_byte;
179 	short m_short;
180 	long m_long;
181 	long m_long2;
182 	float m_float;
183 	double m_double;
184 	CComVariant m_var1;
185 	CComVariant m_var2;
186 	CComVariant m_var3;
187 	CComVariant m_var4;
188 	CComBSTR m_bstr;
189 	CY m_cy;
190 	DATE m_date;
191 	DECIMAL m_decimal;
192 	SCODE m_scode;
193 	SAFEARRAY * m_safearray;
194 	CComPtr<IDispatch> m_obj;
195 	CComPtr<IUnknown> m_unknown;
196 
197 	SAFEARRAY * m_arByte;
198 	SAFEARRAY * m_arShort;
199 	SAFEARRAY * m_arLong;
200 	SAFEARRAY * m_arString;
201 	SAFEARRAY * m_arVariant;
202 	SAFEARRAY * m_arFloat;
203 	SAFEARRAY * m_arDouble;
204 	SAFEARRAY * m_arObject;
205 	SAFEARRAY * m_arByteDim2;
206 
207 	static void printArray(LPSAFEARRAY val, BSTR message, VARTYPE type);
208 	static void printMulArray(LPSAFEARRAY val, VARTYPE type);
209 
210 
211 public:
212 	STDMETHOD(inSequenceByteDim2)(LPSAFEARRAY val);
213 	STDMETHOD(inCurrency)(CY val);
214 	STDMETHOD(outCurrency)(CY* val);
215 	STDMETHOD(inoutCurrency)(CY* val);
216 	STDMETHOD(inDate)(DATE val);
217 	STDMETHOD(outDate)(DATE* val);
218 	STDMETHOD(inoutDate)(DATE* val);
219 	STDMETHOD(get_prpCurrency)(CY* pVal);
220 	STDMETHOD(put_prpCurrency)(CY newVal);
221 	STDMETHOD(get_prpDate)(DATE* pVal);
222 	STDMETHOD(put_prpDate)(DATE newVal);
223 	STDMETHOD(inDecimal)(DECIMAL val);
224 	STDMETHOD(outDecimal)(DECIMAL* val);
225 	STDMETHOD(inoutDecimal)(DECIMAL* val);
226 	STDMETHOD(get_prpDecimal)(DECIMAL* pVal);
227 	STDMETHOD(put_prpDecimal)(DECIMAL newVal);
228 	STDMETHOD(inSCode)(SCODE val);
229 	STDMETHOD(outScode)(SCODE* val);
230 	STDMETHOD(inoutSCode)(SCODE* val);
231 	STDMETHOD(get_prpSCode)(SCODE* pVal);
232 	STDMETHOD(put_prpSCode)(SCODE newVal);
233 	STDMETHOD(inrefLong)(LONG* val);
234 	STDMETHOD(inrefVariant)(VARIANT* val);
235 	STDMETHOD(inrefDecimal)(DECIMAL* val);
236 	STDMETHOD(get_prpRefLong)(long* pVal);
237 	STDMETHOD(putref_prpRefLong)(long* newVal);
238 	STDMETHOD(get_prprefVariant)(VARIANT* pVal);
239 	STDMETHOD(putref_prprefVariant)(VARIANT* newVal);
240 	STDMETHOD(get_prprefDecimal)(DECIMAL* pVal);
241 	STDMETHOD(putref_prprefDecimal)(DECIMAL* newVal);
242 	STDMETHOD(optional6)(VARIANT* val1, VARIANT* val2, VARIANT* val3, VARIANT* val4);
243 	STDMETHOD(optional7)(VARIANT* val1, VARIANT* val2, VARIANT* val3, VARIANT* val4);
244 
245 	STDMETHOD(get_prpMultiArg1)(VARIANT* val1, VARIANT* val2, VARIANT* pVal);
246 	//STDMETHOD(get_prpMultiArg1)(VARIANT* val1, VARIANT* pVal);
247 	STDMETHOD(put_prpMultiArg1)(VARIANT* val1, VARIANT* val2, VARIANT* newVal);
248 	//STDMETHOD(put_prpMultiArg1)(VARIANT* val1, VARIANT* newVal);
249 	STDMETHOD(get_prpMultiArg2)(VARIANT val1, VARIANT* pVal);
250 	STDMETHOD(put_prpMultiArg2)(VARIANT val1, VARIANT newVal);
251 	STDMETHOD(prpMultiArg2GetValues)(VARIANT* val1, VARIANT* valProperty);
252 	STDMETHOD(get_prpMultiArg3)(LONG* val1, LONG* pVal);
253 	STDMETHOD(put_prpMultiArg3)(LONG* val1, LONG newVal);
254 
255 	// IFoo Methods
256 public:
257 	STDMETHOD(inUnknown)(IUnknown* val);
258 	STDMETHOD(outUnknown)(IUnknown** val);
259 	STDMETHOD(inoutUnknown)(IUnknown** val);
260 	STDMETHOD(get_prpUnknown)(IUnknown** pVal);
261 	STDMETHOD(put_prpUnknown)(IUnknown* newVal);
262 };
263 
264 #endif //__BASIC_H_
265 
266