Changeset 192 for Include/com
- Timestamp:
- Mar 28, 2007, 10:29:58 AM (18 years ago)
- Location:
- Include/com
- Files:
-
- 1 added
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
Include/com/bstring.ab
r175 r192 80 80 End Sub 81 81 82 Sub Attach( bstr As BSTR)82 Sub Attach(ByRef bstr As BSTR) 83 83 Clear() 84 84 BString.Move(bs, bstr) -
Include/com/index.ab
r142 r192 2 2 3 3 #require <com/bstring.ab> 4 #require <com/variant.ab> 5 #require <com/vbojbect.ab> 6 #require <com/currency.ab> -
Include/com/variant.ab
r175 r192 20 20 End Sub 21 21 22 Sub Variant( vAs VARIANT)22 Sub Variant(ByRef y As VARIANT) 23 23 VariantInit(v) 24 24 VariantCopy(v, y) … … 132 132 End Sub 133 133 134 Sub Assign(from As VARIANT) 135 Clear() 134 Sub Assign(ByRef from As VARIANT) 136 135 Variant.Copy(v, from) 136 End Sub 137 138 Sub AssignInd(ByRef from As VARIANT) 139 VariantCopyInd(v, from) 137 140 End Sub 138 141 … … 141 144 End Sub 142 145 146 Const Function Copy() As VARIANT 147 Variant.Copy(Copy, v) 148 End Function 149 143 150 Function Detach() As VARIANT 144 151 Variant.Move(Detach, v) … … 153 160 End Function 154 161 155 Function Operator -() As Variant 162 Const Function Operator +() As Variant 163 Return New Variant(This) 164 End Function 165 166 Const Function Operator -() As Variant 156 167 Dim ret As Variant 157 168 VarNeg(This.v, ret.v) … … 219 230 End Function 220 231 221 Function Operator Not() As Variant232 Const Function Operator Not() As Variant 222 233 Dim ret As Variant 223 234 VarNot(This.v, ret.v) … … 237 248 End Function 238 249 239 Function Abs() As Variant250 Const Function Abs() As Variant 240 251 Dim ret As Variant 241 252 VarAbs(This.v, ret.v) … … 243 254 End Function 244 255 245 Function Fix() As Variant256 Const Function Fix() As Variant 246 257 Dim ret As Variant 247 258 VarFix(This.v, ret.v) … … 249 260 End Function 250 261 251 Function Int() As Variant262 Const Function Int() As Variant 252 263 Dim ret As Variant 253 264 VarInt(This.v, ret.v) … … 255 266 End Function 256 267 257 Function Round(cDecimals As Long) As Variant268 Const Function Round(cDecimals As Long) As Variant 258 269 Dim ret As Variant 259 270 VarRound(This.v, cDecimals, ret) … … 261 272 End Function 262 273 263 Function Round() As Variant274 Const Function Round() As Variant 264 275 Return Round(0) 265 276 End Function … … 274 285 275 286 Const Function Operator ==(y As Variant) As Boolean 276 Return Compare(This, y) = VARCMP_EQ 287 Dim c = Compare(This, y) 288 If c = VARCMP_EQ Then 289 Return True 290 Else 291 Return False 292 End If 277 293 End Function 278 294 279 295 Const Function Operator <>(y As Variant) As Boolean 280 Return Compare(This, y) <> VARCMP_EQ 296 Dim c = Compare(This, y) 297 If c <> VARCMP_EQ Then 298 Return True 299 Else 300 Return False 301 End If 281 302 End Function 282 303 283 304 Const Function Operator <(y As Variant) As Boolean 284 Return Compare(This, y) = VARCMP_LT 285 End Function 286 287 ' Const Function Operator >(y As Variant) As Boolean 288 ' Return Compare(This, y) = VARCMP_GT 289 ' End Function 290 305 Dim c = Compare(This, y) 306 If c = VARCMP_LT Then 307 Return True 308 Else 309 Return False 310 End If 311 End Function 312 /* 313 Const Function Operator >(y As Variant) As Boolean 314 Dim c = Compare(This, y) 315 If c = VARCMP_GT Then 316 Return True 317 Else 318 Return False 319 End If 320 End Function 321 */ 291 322 Const Function Operator <=(y As Variant) As Boolean 292 Dim result = Compare(This, y) 293 Return result = VARCMP_LT Or result = VARCMP_EQ 323 Dim c = Compare(This, y) 324 If result = VARCMP_LT Or result = VARCMP_EQ Then 325 Return True 326 Else 327 Return False 328 End If 294 329 End Function 295 330 296 331 Const Function Operator >=(y As Variant) As Boolean 297 Dim result = Compare(This, y) 298 Return result = VARCMP_GT Or result = VARCMP_EQ 332 Dim c = Compare(This, y) 333 If result = VARCMP_GT Or result = VARCMP_EQ Then 334 Return True 335 Else 336 Return False 337 End If 299 338 End Function 300 339 … … 469 508 'ValDate 470 509 471 Const Function Val BStr() As BString510 Const Function ValStr() As BString 472 511 Dim r As VARIANT 473 512 ChangeType(r, 0, VT_BSTR) … … 477 516 End Function 478 517 479 Sub Val BStr(x As BString)518 Sub ValStr(x As BString) 480 519 Clear() 481 520 v.vt = VT_BSTR … … 497 536 Const Function ValObject() As VBObject 498 537 Dim r As VARIANT 499 ChangeType(r, 0, VT_DISPAT H)500 Dim o As VBO Bject538 ChangeType(r, 0, VT_DISPATCH) 539 Dim o As VBObject 501 540 o.Attach(GetPointer(VarPtr(r.val)) As *IDispatch) 502 541 Return o … … 517 556 Return VarPtr(v) 518 557 End Function 558 519 559 Private 520 560 v As VARIANT … … 523 563 VariantCopy(dst, src) 524 564 End Sub 525 565 526 566 527 567 Static Sub Move(ByRef dst As VARIANT, ByRef src As VARIANT) -
Include/com/vbobject.ab
r186 r192 12 12 End Sub 13 13 14 Sub VBObject(className As String) 15 VBObject(ToWCStr(className)) 16 End Sub 17 18 Sub VBObject(className As PCWSTR) 14 Sub VBObject(className As String, pOuter As *IUnknown, clsContext As DWord) 15 VBObject(ToWCStr(className), pOuter, clsContext) 16 End Sub 17 18 Sub VBObject(className As PCSTR, pOuter As *IUnknown, clsContext As DWord) 19 VBObject(ToWCStr(className), pOuter, clsContext) 20 End Sub 21 22 Sub VBObject(className As PCWSTR, pOuter As *IUnknown, clsContext As DWord) 19 23 pdisp = 0 20 24 Dim clsid As CLSID 21 25 Dim hr = _System_CLSIDFromString(className, clsid) 22 Dim hr2 = CoCreateInstance(clsid, 0, CLSCTX_ALL, IID_IDispatch, pdisp) 26 VBObject(clsid, pOuter, clsContext) 27 End Sub 28 29 Sub VBObject(ByRef clsid As CLSID, pOuter As *IUnknown, clsContext As DWord) 30 Dim hr = CoCreateInstance(clsid, pOuter, clsContext, IID_IDispatch, pdisp) 23 31 End Sub 24 32 … … 53 61 54 62 Function Equals(y As VBObject) As Boolean 55 Dim punkX = GetUnknown() 56 Dim punkY = y.GetUnknown() 57 Equals = (punkX == punkY) 58 punkX->Release() 59 punkY->Release() 63 Return _System_COMReferenceEquals(pdisp, y.pdisp) 60 64 End Function 61 65 /* 62 66 Override Function GetHashCode() As Long 63 Dim punk = GetUnknown()67 Dim punk = _System_GetUnknown(pdisp) 64 68 GetHashCode = _System_HashFromPtr(punk) 65 69 punk->Release() … … 79 83 End Sub 80 84 81 Function GetDispatch() As *IDispatch85 Function Copy() As *IDispatch 82 86 VBObject.Copy(GetDispatch, pdisp) 83 87 End Function … … 88 92 End Sub 89 93 90 Sub Detach()94 Function Detach() As *IDispatch 91 95 VBObject.Move(Detach, pdisp) 92 End Sub 96 End Function 97 98 Function Dispatch() As *IDispatch 99 Dispatch = pdisp 100 End Function 93 101 Private 94 102 Function GetCaller(name As PCWSTR) As DispatchCaller … … 96 104 Dim hr = pdisp->GetIDsOfNames(GUID_NULL, VarPtr(name), 1, LOCALE_USER_DEFAULT, VarPtr(dispid)) 97 105 Return New DispatchCaller(pdisp, dispid) 98 End Function99 100 Function GetUnknown() As *IUnknown101 If FAILDED(pdisp->QueryInterface(IID_Unknown, GetUnknown)) Then102 GetUnknown = 0103 End If104 106 End Function 105 107 … … 170 172 171 173 Sub Prop(ByRef arg As VARIANT) 172 Dim dispParams As DISPPARAMS 173 With dispParams 174 .rgvarg = VarPtr(arg) 175 .rgdispidNamedArgs = 0 176 .cArgs = 1 177 .cNamedArgs = 1 178 End With 179 Dim ret As VARIANT 180 Dim hr = pdisp->Invoke(dispid, GUID_NULL, LOCALE_USER_DEFAULT, DISPATCH_PROPERTYPUT, dispParams, ret, ByVal 0, 0) 181 Dispose() 174 setProp(arg, DISPATCH_PROPERTYPUT) 182 175 End Sub 183 176 … … 187 180 188 181 Sub PropRef(ByRef arg As VARIANT) 189 Dim dispParams As DISPPARAMS 190 With dispParams 191 .rgvarg = 1 192 .rgdispidNamedArgs = 0 193 .cArgs = VarPtr(arg) 194 .cNamedArgs = 0 195 End With 196 Dim ret As VARIANT 197 Dim hr = pdisp->Invoke(dispid, GUID_NULL, LOCALE_USER_DEFAULT, DISPATCH_PROPERTYPUTREF, dispParams, ret, ByVal 0, 0) 198 Dispose() 182 setProp(arg, DISPATCH_PROPERTYPUTREF) 199 183 End Sub 200 184 … … 228 212 Function Call(ByRef arg1 As Variant, ByRef arg2 As Variant) As Variant 229 213 Dim arg[1] As VARIANT 230 214 231 215 Return Call(2, VarPtr(arg1) As *VARIANT) 232 216 End Function 233 217 234 218 Private 219 Sub setProp(ByRef arg As VARIANT, callType As Word) 220 Dim dispidNamed = DISPID_PROPERTYPUT As DISPID 221 Dim dispParams As DISPPARAMS 222 With dispParams 223 .rgvarg = VarPtr(arg) 224 .rgdispidNamedArgs = VarPtr(dispidNamed) 225 .cArgs = 1 226 .cNamedArgs = 1 227 End With 228 Dim hr = pdisp->Invoke(dispid, GUID_NULL, LOCALE_USER_DEFAULT, callType, dispParams, ByVal 0, ByVal 0, 0) 229 Dispose() 230 End Sub 231 232 235 233 pdisp As *IDispatch 236 234 dispid As DISPID 237 235 End Class 238 /* 236 237 Function CallByName(obj As VBObject, procName As String, callType As Word, cArgs As Long, args As *VARIANT) As Variant 238 Return CallByName(obj.Dispatch, ToWCStr(procName), callType, cArgs, args) 239 End Function 240 241 Function CallByName(obj As VBObject, procName As PCWSTR, callType As Word, cArgs As Long, args As *VARIANT) As Variant 242 Return CallByName(obj.Dispatch, procName, callType, cArgs, args) 243 End Function 244 245 Function CallByName(obj As *IDispatch, name As PCWSTR, callType As Word, cArgs As Long, args As *VARIANT) As Variant 246 Dim dispid As DISPID 247 Dim hr = obj->GetIDsOfNames(GUID_NULL, VarPtr(name), 1, LOCALE_USER_DEFAULT, VarPtr(dispid)) 248 Dim dispParams As DISPPARAMS 249 With dispParams 250 .rgvarg = args 251 .rgdispidNamedArgs = 0 252 .cArgs = cArgs 253 .cNamedArgs = 0 254 End With 255 Dim ret As VARIANT 256 hr = obj->Invoke(dispid, GUID_NULL, LOCALE_USER_DEFAULT, DISPATCH_METHOD, dispParams, ret, ByVal 0, 0) 257 CallByName.Attach(ret) 258 Return CallByName 259 End Function 260 239 261 Function CreateObject(className As PCWSTR) As VBObject 240 262 Return New VBObject(className) … … 244 266 Return New VBObject(ToWCStr(className)) 245 267 End Function 246 268 /* 247 269 #ifdef _WIN32_DCOM 248 270 Function CreateObject(className As PCWSTR, serverName As PCWSTR) As VBObject … … 250 272 Dim si As COSERVERINFO 251 273 Dim context As DWord 252 253 254 255 256 257 274 If /*Server = 0 OrElse* / Server[0] = 0 Then 275 context = CLSCTX_SERVER 276 Else 277 context = CLSCTX_REMOTE_SERVER 278 si.pwszName = serverName 279 End If 258 280 259 281 Dim hr = _System_CLSIDFromString(className, clsid) … … 270 292 Return Nothing 271 293 End If 272 End Function 294 End Function 273 295 274 296 Function CreateObject(className As String, serverName As String) As VBObject … … 279 301 Function _System_CLSIDFromString(pwString As PCWSTR, ByRef guid As GUID) As HRESULT 280 302 If pwString[0] = &h007b As WCHAR Then 281 ' 1文字目が { ならクラスIDの文字列表現と見なしCLSIDFromStringで変換。 282 _System_CLSIDFromString = CLSIDFromString(pwString, guid) 283 Else 284 _System_CLSIDFromString = CLSIDFromProgID(pwString, guid) 285 End If 303 ' 1文字目が { ならクラスIDの文字列表現と見なしCLSIDFromStringで変換。 304 _System_CLSIDFromString = CLSIDFromString(pwString, guid) 305 Else 306 _System_CLSIDFromString = CLSIDFromProgID(pwString, guid) 307 End If 308 End Function 309 310 Function _System_COMReferenceEquals(p As *IUnknown, q As *IUnknown) As Boolean 311 If p = q Then 312 Return True 313 Else If p = 0 Or q = 0 Then 314 Return False 315 End If 316 317 Dim punkX = _System_GetUnknown(p) 318 Dim punkY = _System_GetUnknown(q) 319 If punkX = punkY Then 320 _System_COMReferenceEquals = True 321 Else 322 _System_COMReferenceEquals = False 323 End If 324 punkX->Release() 325 punkY->Release() 326 End Function 327 328 Function _System_GetUnknown(p As *IUnknown) As *IUnknown 'pは任意のCOMインタフェース 329 If FAILDED(pdisp->QueryInterface(IID_Unknown, _System_GetUnknown)) Then 330 GetUnknown = 0 331 End If 286 332 End Function 287 333
Note:
See TracChangeset
for help on using the changeset viewer.