~ubuntu-branches/ubuntu/feisty/fpc/feisty

« back to all changes in this revision

Viewing changes to packages/extra/univint/CFPlugInCOM.pas

  • Committer: Bazaar Package Importer
  • Author(s): Torsten Werner
  • Date: 2007-01-27 20:08:50 UTC
  • mfrom: (1.2.3 upstream)
  • Revision ID: james.westby@ubuntu.com-20070127200850-9mrptaqqjsx9nwa7
Tags: 2.0.4-5
* Fixed Build-Depends.
* Add myself to Uploaders in debian/control.
* Make sure that the sources are really patched before building them.
* Build unit 'libc' on powerpc too.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
{       CFPlugInCOM.h
 
2
        Copyright (c) 1999-2005, Apple, Inc. All rights reserved.
 
3
}
 
4
{   Pascal Translation Updated:  Peter N Lewis, <peter@stairways.com.au>, September 2005 }
 
5
{
 
6
    Modified for use with Free Pascal
 
7
    Version 200
 
8
    Please report any bugs to <gpc@microbizz.nl>
 
9
}
 
10
 
 
11
{$mode macpas}
 
12
{$packenum 1}
 
13
{$macro on}
 
14
{$inline on}
 
15
{$CALLING MWPASCAL}
 
16
 
 
17
unit CFPlugInCOM;
 
18
interface
 
19
{$setc UNIVERSAL_INTERFACES_VERSION := $0342}
 
20
{$setc GAP_INTERFACES_VERSION := $0200}
 
21
 
 
22
{$ifc not defined USE_CFSTR_CONSTANT_MACROS}
 
23
    {$setc USE_CFSTR_CONSTANT_MACROS := TRUE}
 
24
{$endc}
 
25
 
 
26
{$ifc defined CPUPOWERPC and defined CPUI386}
 
27
        {$error Conflicting initial definitions for CPUPOWERPC and CPUI386}
 
28
{$endc}
 
29
{$ifc defined FPC_BIG_ENDIAN and defined FPC_LITTLE_ENDIAN}
 
30
        {$error Conflicting initial definitions for FPC_BIG_ENDIAN and FPC_LITTLE_ENDIAN}
 
31
{$endc}
 
32
 
 
33
{$ifc not defined __ppc__ and defined CPUPOWERPC}
 
34
        {$setc __ppc__ := 1}
 
35
{$elsec}
 
36
        {$setc __ppc__ := 0}
 
37
{$endc}
 
38
{$ifc not defined __i386__ and defined CPUI386}
 
39
        {$setc __i386__ := 1}
 
40
{$elsec}
 
41
        {$setc __i386__ := 0}
 
42
{$endc}
 
43
 
 
44
{$ifc defined __ppc__ and __ppc__ and defined __i386__ and __i386__}
 
45
        {$error Conflicting definitions for __ppc__ and __i386__}
 
46
{$endc}
 
47
 
 
48
{$ifc defined __ppc__ and __ppc__}
 
49
        {$setc TARGET_CPU_PPC := TRUE}
 
50
        {$setc TARGET_CPU_X86 := FALSE}
 
51
{$elifc defined __i386__ and __i386__}
 
52
        {$setc TARGET_CPU_PPC := FALSE}
 
53
        {$setc TARGET_CPU_X86 := TRUE}
 
54
{$elsec}
 
55
        {$error Neither __ppc__ nor __i386__ is defined.}
 
56
{$endc}
 
57
{$setc TARGET_CPU_PPC_64 := FALSE}
 
58
 
 
59
{$ifc defined FPC_BIG_ENDIAN}
 
60
        {$setc TARGET_RT_BIG_ENDIAN := TRUE}
 
61
        {$setc TARGET_RT_LITTLE_ENDIAN := FALSE}
 
62
{$elifc defined FPC_LITTLE_ENDIAN}
 
63
        {$setc TARGET_RT_BIG_ENDIAN := FALSE}
 
64
        {$setc TARGET_RT_LITTLE_ENDIAN := TRUE}
 
65
{$elsec}
 
66
        {$error Neither FPC_BIG_ENDIAN nor FPC_LITTLE_ENDIAN are defined.}
 
67
{$endc}
 
68
{$setc ACCESSOR_CALLS_ARE_FUNCTIONS := TRUE}
 
69
{$setc CALL_NOT_IN_CARBON := FALSE}
 
70
{$setc OLDROUTINENAMES := FALSE}
 
71
{$setc OPAQUE_TOOLBOX_STRUCTS := TRUE}
 
72
{$setc OPAQUE_UPP_TYPES := TRUE}
 
73
{$setc OTCARBONAPPLICATION := TRUE}
 
74
{$setc OTKERNEL := FALSE}
 
75
{$setc PM_USE_SESSION_APIS := TRUE}
 
76
{$setc TARGET_API_MAC_CARBON := TRUE}
 
77
{$setc TARGET_API_MAC_OS8 := FALSE}
 
78
{$setc TARGET_API_MAC_OSX := TRUE}
 
79
{$setc TARGET_CARBON := TRUE}
 
80
{$setc TARGET_CPU_68K := FALSE}
 
81
{$setc TARGET_CPU_MIPS := FALSE}
 
82
{$setc TARGET_CPU_SPARC := FALSE}
 
83
{$setc TARGET_OS_MAC := TRUE}
 
84
{$setc TARGET_OS_UNIX := FALSE}
 
85
{$setc TARGET_OS_WIN32 := FALSE}
 
86
{$setc TARGET_RT_MAC_68881 := FALSE}
 
87
{$setc TARGET_RT_MAC_CFM := FALSE}
 
88
{$setc TARGET_RT_MAC_MACHO := TRUE}
 
89
{$setc TYPED_FUNCTION_POINTERS := TRUE}
 
90
{$setc TYPE_BOOL := FALSE}
 
91
{$setc TYPE_EXTENDED := FALSE}
 
92
{$setc TYPE_LONGLONG := TRUE}
 
93
uses MacTypes,CFPlugIn,CFUUID;
 
94
{$ALIGN POWER}
 
95
 
 
96
 
 
97
{ ================= IUnknown definition (C struct) ================= }
 
98
 
 
99
{ All interface structs must have an IUnknownStruct at the beginning. }
 
100
{ The _reserved field is part of the Microsoft COM binary standard on Macintosh. }
 
101
{ You can declare new C struct interfaces by defining a new struct that includes "IUNKNOWN_C_GUTS;" before the first field of the struct. }
 
102
 
 
103
type
 
104
        HRESULT = SInt32;
 
105
        ULONG = UInt32;
 
106
        LPVOID = UnivPtr;
 
107
        REFIID = CFUUIDBytes;
 
108
 
 
109
{ Macros for more detailed HRESULT analysis }
 
110
 
 
111
function SUCCEEDED( Status: HRESULT ): Boolean; inline;
 
112
function FAILED( Status: HRESULT ): Boolean; inline;
 
113
function IS_ERROR( Status: HRESULT ): Boolean; inline;
 
114
function HRESULT_CODE( hr: HRESULT ): HRESULT; inline;
 
115
function HRESULT_FACILITY( hr: HRESULT ): HRESULT; inline;
 
116
function HRESULT_SEVERITY( hr: HRESULT ): HRESULT; inline;
 
117
 
 
118
const
 
119
        SEVERITY_SUCCESS = 0;
 
120
const
 
121
        SEVERITY_ERROR = 1;
 
122
 
 
123
{ Creating an HRESULT from its component pieces }
 
124
function MAKE_HRESULT( sev, fac, code: ULONG ): HRESULT; inline;
 
125
 
 
126
{ Pre-defined success HRESULTS }
 
127
const
 
128
        S_OK = 0;
 
129
const
 
130
        S_FALSE = 1;
 
131
 
 
132
{ Common error HRESULTS }
 
133
const
 
134
        E_UNEXPECTED = $8000FFFF;
 
135
        E_NOTIMPL = $80000001;
 
136
        E_OUTOFMEMORY = $80000002;
 
137
        E_INVALIDARG = $80000003;
 
138
        E_NOINTERFACE = $80000004;
 
139
        E_POINTER = $80000005;
 
140
        E_HANDLE = $80000006;
 
141
        E_ABORT = $80000007;
 
142
        E_FAIL = $80000008;
 
143
        E_ACCESSDENIED = $80000009;
 
144
 
 
145
{ This macro should be used when defining all interface functions (as it is for the IUnknown functions below). }
 
146
{#define STDMETHODCALLTYPE}
 
147
 
 
148
{ The __RPC_FAR macro is for COM source compatibility only. This macro is used a lot in COM interface definitions.  If your CFPlugIn interfaces need to be COM interfaces as well, you can use this macro to get better source compatibility.  It is not used in the IUnknown definition below, because when doing COM, you will be using the Microsoft supplied IUnknown interface anyway. }
 
149
{#define __RPC_FAR}
 
150
 
 
151
{ The IUnknown interface }
 
152
function IUnknownUUID: CFUUIDRef; inline;
 
153
 
 
154
type
 
155
        IUnknownVTbl = record
 
156
                _reserved: UnivPtr;
 
157
                QueryInterface: function( thisPointer: UnivPtr; iid: REFIID; var ppv: LPVOID ): HRESULT;
 
158
                AddRef: function( thisPointer: UnivPtr ): ULONG;
 
159
                Release: function( thisPointer: UnivPtr ): ULONG;
 
160
        end;
 
161
 
 
162
{ End of extern "C" stuff }
 
163
 
 
164
 
 
165
{ C++ specific stuff }
 
166
 
 
167
implementation
 
168
 
 
169
 
 
170
{$R-}
 
171
 
 
172
function SUCCEEDED( Status: HRESULT ): Boolean; inline;
 
173
begin
 
174
        SUCCEEDED := Status >= 0;
 
175
end;
 
176
 
 
177
function FAILED( Status: HRESULT ): Boolean; inline;
 
178
begin
 
179
        FAILED := Status < 0;
 
180
end;
 
181
 
 
182
function IS_ERROR( Status: HRESULT ): Boolean; inline;
 
183
begin
 
184
        IS_ERROR := Status shr 31 = SEVERITY_ERROR;
 
185
end;
 
186
 
 
187
function HRESULT_CODE( hr: HRESULT ): HRESULT; inline;
 
188
begin
 
189
        HRESULT_CODE := hr and $FFFF;
 
190
end;
 
191
 
 
192
function HRESULT_FACILITY( hr: HRESULT ): HRESULT; inline;
 
193
begin
 
194
        HRESULT_FACILITY := (hr shr 16) and $1FFF;
 
195
end;
 
196
 
 
197
function HRESULT_SEVERITY( hr: HRESULT ): HRESULT; inline;
 
198
begin
 
199
        HRESULT_SEVERITY := (hr shr 31) and $01;
 
200
end;
 
201
 
 
202
function MAKE_HRESULT( sev, fac, code: ULONG ): HRESULT; inline;
 
203
begin
 
204
        MAKE_HRESULT := HRESULT((sev shl 31) or (fac shl 16) or code);
 
205
end;
 
206
 
 
207
function IUnknownUUID: CFUUIDRef; inline;
 
208
begin
 
209
        IUnknownUUID:= CFUUIDGetConstantUUIDWithBytes( nil, $00, $00, $00, $00, $00, $00, $00, $00, ByteParameter($C0), $00, $00, $00, $00, $00, $00, $46 )
 
210
end;
 
211
 
 
212
 
 
213
end.