OWLNext
7.0
Borland's Object Windows Library for the modern age
Toggle main menu visibility
Loading...
Searching...
No Matches
autostck.cpp
Go to the documentation of this file.
1
//----------------------------------------------------------------------------
2
// ObjectComponents
3
// Copyright (c) 1994, 1996 by Borland International, All Rights Reserved
4
//
5
/// \file
6
/// OLE Automation - Implementation of TAutoStack
7
//----------------------------------------------------------------------------
8
#include <
ocf/pch.h
>
9
#include <
ocf/appdesc.h
>
10
#include <
ocf/ocreg.h
>
11
#include <
ocf/occtrl.h
>
12
13
namespace
ocf
{
14
15
//----------------------------------------------------------------------------
16
// TAutoStack implementation
17
//
18
19
TAutoStack::TAutoStack
(DISPID
id
, VARIANT *stack,
TLocaleId
locale,
20
int
argcount,
int
named,
long
* map,
21
TServedObject
* owner)
22
:
23
Owner
(owner),
24
Stack
((
TAutoVal
*)stack),
25
LangId
(LANGIDFROMLCID(locale)),
26
ArgCount
(argcount),
27
NamedCount
(named),
28
NamedIds
(map),
29
CurrentArg
(-1),
30
DispId
(id)
31
{
32
}
33
34
TAutoStack::~TAutoStack
()
35
{
36
TAutoVal
* val;
37
for
(val =
Stack
;
ArgCount
; --*
const_cast<
int
*
>
(&
ArgCount
), val++)
38
val->
Restore
();
39
}
40
41
TAutoVal
&
TAutoStack::operator []
(
int
index)
42
{
43
TAutoSymbol
* argSymbol =
nullptr
;
44
if
(index <
ArgSymbolCount
)
45
argSymbol = index >= 0 ?
Symbol
+ index + 1 :
Symbol
;
46
int
vIndex =
ArgCount
- index - 1;
// index if not a named argument
47
if
(index ==
TAutoStack::SetValue
||
// property value to set
48
index >=
ArgCount
-
NamedCount
) {
// named or out of range
49
for
(vIndex =
NamedCount
; --vIndex >= 0; )
50
if
(
NamedIds
[vIndex] == index) {
51
break
;
52
}
53
}
54
TAutoVal
* val;
55
if
(vIndex >= 0) {
56
CurrentArg
= vIndex;
// save index for error return
57
val =
Stack
[vIndex].
DereferenceVariant
();
58
val->
SetLocale
(
LangId
);
59
if
((val->
GetDataType
() ==
atString
) &&
60
((argSymbol) && (argSymbol->
IsEnum
()) &&
61
(argSymbol->
GetEnum
()->
Convert
(*val,
Default
))))
62
return
Default
;
63
}
64
else
if
(index ==
TAutoStack::SetValue
) {
65
TXAuto::Raise
(
TXAuto::xParameterMissing
);
66
}
67
else
{
68
val = &
Default
;
69
val->
SetLocale
(
LangId
);
70
if
(!argSymbol)
71
TXAuto::Raise
(
TXAuto::xNoArgSymbol
);
72
const
_TCHAR* dfltStr = argSymbol->
Doc
.
Translate
(
LangId
);
// load default
73
if
(!dfltStr)
74
TXAuto::Raise
(
TXAuto::xNoDefaultValue
);
75
Default
= dfltStr;
// makes a BSTR in order to use OLE conversions
76
}
77
return
*val;
78
}
79
80
81
}
// OCF namespace
82
83
//==============================================================================
84
appdesc.h
TAppDescriptor - OLE application descriptor definitions.
ocf::TAutoEnum::Convert
virtual bool Convert(TAutoVal &txtVal, TAutoVal &numVal)=0
ocf::TAutoStack::LangId
owl::TLangId LangId
Definition
autodefs.h:827
ocf::TAutoStack::DispId
DISPID DispId
Definition
autodefs.h:826
ocf::TAutoStack::SetValue
@ SetValue
Definition
autodefs.h:815
ocf::TAutoStack::ArgSymbolCount
int ArgSymbolCount
Definition
autodefs.h:825
ocf::TAutoStack::TAutoStack
TAutoStack(DISPID dispid, VARIANT *stack, TLocaleId locale, int argcount, int namedcount, long *map, TServedObject *owner)
Definition
autostck.cpp:19
ocf::TAutoStack::~TAutoStack
~TAutoStack()
Definition
autostck.cpp:34
ocf::TAutoStack::ArgCount
int ArgCount
Definition
autodefs.h:824
ocf::TAutoStack::Owner
TServedObject * Owner
Definition
autodefs.h:828
ocf::TAutoStack::NamedCount
int NamedCount
Definition
autodefs.h:833
ocf::TAutoStack::Default
TAutoVal Default
Definition
autodefs.h:835
ocf::TAutoStack::Symbol
TAutoSymbol * Symbol
Symbol of method/prop, args follow.
Definition
autodefs.h:822
ocf::TAutoStack::operator[]
TAutoVal & operator[](int index)
Definition
autostck.cpp:41
ocf::TAutoStack::CurrentArg
int CurrentArg
Index of last arg requested by operator[].
Definition
autodefs.h:823
ocf::TAutoStack::Stack
TAutoVal * Stack
Definition
autodefs.h:836
ocf::TAutoStack::NamedIds
long * NamedIds
Definition
autodefs.h:834
ocf::TAutoVal
Automation data element (same data as OLE/BASIC VARIANT).
Definition
autodefs.h:526
ocf::TAutoVal::GetDataType
int GetDataType() const
Definition
autodefs.h:1684
ocf::TAutoVal::DereferenceVariant
TAutoVal * DereferenceVariant()
Definition
autodefs.h:1747
ocf::TAutoVal::SetLocale
void SetLocale(TLocaleId)
Definition
autoval.cpp:77
ocf::TAutoVal::Restore
void Restore()
Definition
autodefs.h:1708
ocf::TServedObject
OLE object exposed for automated access of internal object.
Definition
autodefs.h:972
ocf::TXAuto::Raise
static void Raise(TError err)
Definition
autoval.cpp:831
ocf::TXAuto::xParameterMissing
@ xParameterMissing
Definition
autodefs.h:124
ocf::TXAuto::xNoArgSymbol
@ xNoArgSymbol
Definition
autodefs.h:123
ocf::TXAuto::xNoDefaultValue
@ xNoDefaultValue
Definition
autodefs.h:125
pch.h
Include for OC, gets common headers when precompiled headers are enabled.
ocf
Object Component Framework (COM encapsulation).
Definition
appdesc.h:22
ocf::TLocaleId
unsigned long TLocaleId
Definition
autodefs.h:72
ocf::atString
@ atString
Definition
autodefs.h:331
occtrl.h
Definition of TOcControl class - Proxy object representing a control in.
ocreg.h
OLE Registration definitions.
ocf::TAutoSymbol
Symbol table element.
Definition
autodefs.h:404
ocf::TAutoSymbol::IsEnum
bool IsEnum() const
Definition
autodefs.h:1513
ocf::TAutoSymbol::Doc
owl::TLocaleString Doc
documentation string, initially untranslated
Definition
autodefs.h:406
ocf::TAutoSymbol::GetEnum
TAutoEnum * GetEnum() const
Definition
autodefs.h:1534
owl::TLocaleString::Translate
const tchar * Translate(TLangId lang)
translate string
Definition
locale.cpp:368
source
ocf
autostck.cpp
Generated by
1.18.0