FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
pythonnet/src/runtime/classmanager.cs at refactor-qc-pythonnet5 · QuantConnect/pythonnet · GitHub
Uh oh!
There was an error while loading.
Please reload this page
.
QuantConnect
/
pythonnet
Public
forked from
pythonnet/pythonnet
Notifications
You must be signed in to change notification settings
Fork
31
Star
29
Code
Issues
5
Pull requests
0
Actions
Projects
Wiki
Security and quality
0
Insights
Additional navigation options
Code
Issues
Pull requests
Actions
Projects
Wiki
Security and quality
Insights
Expand file tree
Breadcrumbs
pythonnet
/
src
/
runtime
/
classmanager.cs
Copy path
More file actions
More file actions
Latest commit
History
History
History
609 lines (536 loc) · 22.7 KB
Breadcrumbs
pythonnet
/
src
/
runtime
/
classmanager.cs
Copy path
File metadata and controls
609 lines (536 loc) · 22.7 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
using
System
;
using
System
.
Collections
;
using
System
.
Collections
.
Generic
;
using
System
.
Reflection
;
using
System
.
Runtime
.
InteropServices
;
using
System
.
Security
;
using
System
.
Linq
;
namespace
Python
.
Runtime
{
/// <summary>
/// The ClassManager is responsible for creating and managing instances
/// that implement the Python type objects that reflect managed classes.
/// Each managed type reflected to Python is represented by an instance
/// of a concrete subclass of ClassBase. Each instance is associated with
/// a generated Python type object, whose slots point to static methods
/// of the managed instance's class.
/// </summary>
internal
class
ClassManager
{
// Binding flags to determine which members to expose in Python.
// This is complicated because inheritance in Python is name
// based. We can't just find DeclaredOnly members, because we
// could have a base class A that defines two overloads of a
// method and a class B that defines two more. The name-based
// descriptor Python will find needs to know about inherited
// overloads as well as those declared on the sub class.
internal
static
readonly
BindingFlags
BindingFlags
=
BindingFlags
.
Static
|
BindingFlags
.
Instance
|
BindingFlags
.
Public
|
BindingFlags
.
NonPublic
;
private
static
Dictionary
<
MaybeType
,
ClassBase
>
cache
;
private
static
readonly
Type
dtype
;
private
ClassManager
(
)
{
}
static
ClassManager
(
)
{
// SEE: https://msdn.microsoft.com/en-us/library/96b1ayy4(v=vs.100).aspx
// ""All delegates inherit from MulticastDelegate, which inherits from Delegate.""
// Was Delegate, which caused a null MethodInfo returned from GetMethode("Invoke")
// and crashed on Linux under Mono.
dtype
=
typeof
(
MulticastDelegate
)
;
}
public
static
void
Reset
(
)
{
cache
=
new
Dictionary
<
MaybeType
,
ClassBase
>
(
128
)
;
}
internal
static
void
DisposePythonWrappersForClrTypes
(
)
{
var
visited
=
new
HashSet
<
IntPtr
>
(
)
;
var
visitedHandle
=
GCHandle
.
Alloc
(
visited
)
;
var
visitedPtr
=
(
IntPtr
)
visitedHandle
;
try
{
foreach
(
var
cls
in
cache
.
Values
)
{
// XXX: Force to release instance's managed resources
// but not dealloc itself immediately.
// These managed resources should preserve vacant shells
// since others may still referencing it.
cls
.
CallTypeTraverse
(
TraverseTypeClear
,
visitedPtr
)
;
cls
.
CallTypeClear
(
)
;
cls
.
DecrRefCount
(
)
;
}
}
finally
{
visitedHandle
.
Free
(
)
;
}
cache
.
Clear
(
)
;
}
private
static
int
TraverseTypeClear
(
IntPtr
ob
,
IntPtr
arg
)
{
var
visited
=
(
HashSet
<
IntPtr
>
)
GCHandle
.
FromIntPtr
(
arg
)
.
Target
;
if
(
!
visited
.
Add
(
ob
)
)
{
return
0
;
}
var
clrObj
=
ManagedType
.
GetManagedObject
(
ob
)
;
if
(
clrObj
!=
null
)
{
clrObj
.
CallTypeTraverse
(
TraverseTypeClear
,
arg
)
;
clrObj
.
CallTypeClear
(
)
;
}
return
0
;
}
internal
static
void
SaveRuntimeData
(
RuntimeDataStorage
storage
)
{
var
contexts
=
storage
.
AddValue
(
"contexts"
,
new
Dictionary
<
IntPtr
,
InterDomainContext
>
(
)
)
;
storage
.
AddValue
(
"cache"
,
cache
)
;
foreach
(
var
cls
in
cache
)
{
if
(
!
cls
.
Key
.
Valid
)
{
// Don't serialize an invalid class
continue
;
}
// This incref is for cache to hold the cls,
// thus no need for decreasing it at RestoreRuntimeData.
Runtime
.
XIncref
(
cls
.
Value
.
pyHandle
)
;
var
context
=
contexts
[
cls
.
Value
.
pyHandle
]
=
new
InterDomainContext
(
)
;
cls
.
Value
.
Save
(
context
)
;
// Remove all members added in InitBaseClass.
// this is done so that if domain reloads and a member of a
// reflected dotnet class is removed, it is removed from the
// Python object's dictionary tool; thus raising an AttributeError
// instead of a TypeError.
// Classes are re-initialized on in RestoreRuntimeData.
var
dict
=
new
BorrowedReference
(
Marshal
.
ReadIntPtr
(
cls
.
Value
.
tpHandle
,
TypeOffset
.
tp_dict
)
)
;
foreach
(
var
member
in
cls
.
Value
.
dotNetMembers
)
{
// No need to decref the member, the ClassBase instance does
// not own the reference.
if
(
(
Runtime
.
PyDict_DelItemString
(
dict
,
member
)
==
-
1
)
&&
(
Exceptions
.
ExceptionMatches
(
Exceptions
.
KeyError
)
)
)
{
// Trying to remove a key that's not in the dictionary
// raises an error. We don't care about it.
Runtime
.
PyErr_Clear
(
)
;
}
else
if
(
Exceptions
.
ErrorOccurred
(
)
)
{
throw
new
PythonException
(
)
;
}
}
// We modified the Type object, notify it we did.
Runtime
.
PyType_Modified
(
cls
.
Value
.
tpHandle
)
;
}
}
internal
static
Dictionary
<
ManagedType
,
InterDomainContext
>
RestoreRuntimeData
(
RuntimeDataStorage
storage
)
{
cache
=
storage
.
GetValue
<
Dictionary
<
MaybeType
,
ClassBase
>
>
(
"cache"
)
;
var
invalidClasses
=
new
List
<
KeyValuePair
<
MaybeType
,
ClassBase
>
>
(
)
;
var
contexts
=
storage
.
GetValue
<
Dictionary
<
IntPtr
,
InterDomainContext
>
>
(
"contexts"
)
;
var
loadedObjs
=
new
Dictionary
<
ManagedType
,
InterDomainContext
>
(
)
;
foreach
(
var
pair
in
cache
)
{
if
(
!
pair
.
Key
.
Valid
)
{
invalidClasses
.
Add
(
pair
)
;
continue
;
}
// re-init the class
InitClassBase
(
pair
.
Key
.
Value
,
pair
.
Value
)
;
// We modified the Type object, notify it we did.
Runtime
.
PyType_Modified
(
pair
.
Value
.
tpHandle
)
;
var
context
=
contexts
[
pair
.
Value
.
pyHandle
]
;
pair
.
Value
.
Load
(
context
)
;
loadedObjs
.
Add
(
pair
.
Value
,
context
)
;
}
foreach
(
var
pair
in
invalidClasses
)
{
cache
.
Remove
(
pair
.
Key
)
;
Runtime
.
XDecref
(
pair
.
Value
.
pyHandle
)
;
}
return
loadedObjs
;
}
/// <summary>
/// Return the ClassBase-derived instance that implements a particular
/// reflected managed type, creating it if it doesn't yet exist.
/// </summary>
/// <returns>A Borrowed reference to the ClassBase object</returns>
internal
static
ClassBase
GetClass
(
Type
type
)
{
ClassBase
cb
;
if
(
cache
.
TryGetValue
(
type
,
out
cb
)
)
{
return
cb
;
}
cb
=
CreateClass
(
type
)
;
cache
.
Add
(
type
,
cb
)
;
// Initialize the object later, as this might call this GetClass method
// recursively (for example when a nested class inherits its declaring class...)
InitClassBase
(
type
,
cb
)
;
return
cb
;
}
/// <summary>
/// Create a new ClassBase-derived instance that implements a reflected
/// managed type. The new object will be associated with a generated
/// Python type object.
/// </summary>
private
static
ClassBase
CreateClass
(
Type
type
)
{
// Next, select the appropriate managed implementation class.
// Different kinds of types, such as array types or interface
// types, want to vary certain implementation details to make
// sure that the type semantics are consistent in Python.
ClassBase
impl
;
// Check to see if the given type extends System.Exception. This
// lets us check once (vs. on every lookup) in case we need to
// wrap Exception-derived types in old-style classes
if
(
type
.
ContainsGenericParameters
)
{
impl
=
new
GenericType
(
type
)
;
}
else
if
(
type
.
IsSubclassOf
(
dtype
)
)
{
impl
=
new
DelegateObject
(
type
)
;
}
else
if
(
type
.
IsArray
)
{
impl
=
new
ArrayObject
(
type
)
;
}
else
if
(
type
.
IsKeyValuePairEnumerable
(
)
)
{
impl
=
new
KeyValuePairEnumerableObject
(
type
)
;
}
else
if
(
type
.
IsInterface
)
{
impl
=
new
InterfaceObject
(
type
)
;
}
else
if
(
type
==
typeof
(
Exception
)
||
type
.
IsSubclassOf
(
typeof
(
Exception
)
)
)
{
impl
=
new
ExceptionClassObject
(
type
)
;
}
else
if
(
null
!=
type
.
GetField
(
"__pyobj__"
)
)
{
impl
=
new
ClassDerivedObject
(
type
)
;
}
else
{
impl
=
new
ClassObject
(
type
)
;
}
return
impl
;
}
private
static
void
InitClassBase
(
Type
type
,
ClassBase
impl
)
{
// First, we introspect the managed type and build some class
// information, including generating the member descriptors
// that we'll be putting in the Python class __dict__.
ClassInfo
info
=
GetClassInfo
(
type
)
;
impl
.
indexer
=
info
.
indexer
;
impl
.
richcompare
=
new
Dictionary
<
int
,
MethodObject
>
(
)
;
// Now we allocate the Python type object to reflect the given
// managed type, filling the Python type slots with thunks that
// point to the managed methods providing the implementation.
IntPtr
tp
=
TypeManager
.
GetTypeHandle
(
impl
,
type
)
;
// Finally, initialize the class __dict__ and return the object.
var
dict
=
new
BorrowedReference
(
Marshal
.
ReadIntPtr
(
tp
,
TypeOffset
.
tp_dict
)
)
;
if
(
impl
.
dotNetMembers
==
null
)
{
impl
.
dotNetMembers
=
new
List
<
string
>
(
)
;
}
IDictionaryEnumerator
iter
=
info
.
members
.
GetEnumerator
(
)
;
while
(
iter
.
MoveNext
(
)
)
{
var
item
=
(
ManagedType
)
iter
.
Value
;
var
name
=
(
string
)
iter
.
Key
;
impl
.
dotNetMembers
.
Add
(
name
)
;
Runtime
.
PyDict_SetItemString
(
dict
,
name
,
item
.
ObjectReference
)
;
// Decref the item now that it's been used.
item
.
DecrRefCount
(
)
;
if
(
ClassBase
.
CilToPyOpMap
.
TryGetValue
(
name
,
out
var
pyOp
)
)
{
impl
.
richcompare
.
Add
(
pyOp
,
(
MethodObject
)
item
)
;
}
}
// If class has constructors, generate an __doc__ attribute.
NewReference
doc
=
default
;
Type
marker
=
typeof
(
DocStringAttribute
)
;
var
attrs
=
(
Attribute
[
]
)
type
.
GetCustomAttributes
(
marker
,
false
)
;
if
(
attrs
.
Length
!=
0
)
{
var
attr
=
(
DocStringAttribute
)
attrs
[
0
]
;
string
docStr
=
attr
.
DocString
;
doc
=
NewReference
.
DangerousFromPointer
(
Runtime
.
PyString_FromString
(
docStr
)
)
;
Runtime
.
PyDict_SetItem
(
dict
,
PyIdentifier
.
__doc__
,
doc
)
;
}
var
co
=
impl
as
ClassObject
;
// If this is a ClassObject AND it has constructors, generate a __doc__ attribute.
// required that the ClassObject.ctors be changed to internal
if
(
co
!=
null
)
{
if
(
co
.
NumCtors
>
0
)
{
// Implement Overloads on the class object
if
(
!
CLRModule
.
_SuppressOverloads
)
{
var
ctors
=
new
ConstructorBinding
(
type
,
tp
,
co
.
binder
)
;
// ExtensionType types are untracked, so don't Incref() them.
// TODO: deprecate __overloads__ soon...
Runtime
.
PyDict_SetItem
(
dict
,
PyIdentifier
.
__overloads__
,
ctors
.
ObjectReference
)
;
Runtime
.
PyDict_SetItem
(
dict
,
PyIdentifier
.
Overloads
,
ctors
.
ObjectReference
)
;
ctors
.
DecrRefCount
(
)
;
}
// don't generate the docstring if one was already set from a DocStringAttribute.
if
(
!
CLRModule
.
_SuppressDocs
&&
doc
.
IsNull
(
)
)
{
doc
=
co
.
GetDocString
(
)
;
Runtime
.
PyDict_SetItem
(
dict
,
PyIdentifier
.
__doc__
,
doc
)
;
}
}
}
doc
.
Dispose
(
)
;
// The type has been modified after PyType_Ready has been called
// Refresh the type
Runtime
.
PyType_Modified
(
tp
)
;
}
internal
static
bool
ShouldBindMethod
(
MethodBase
mb
)
{
return
(
mb
.
IsPublic
||
mb
.
IsFamily
||
mb
.
IsFamilyOrAssembly
)
;
}
internal
static
bool
ShouldBindField
(
FieldInfo
fi
)
{
return
(
fi
.
IsPublic
||
fi
.
IsFamily
||
fi
.
IsFamilyOrAssembly
)
;
}
internal
static
bool
ShouldBindProperty
(
PropertyInfo
pi
)
{
MethodInfo
mm
=
null
;
try
{
mm
=
pi
.
GetGetMethod
(
true
)
;
if
(
mm
==
null
)
{
mm
=
pi
.
GetSetMethod
(
true
)
;
}
}
catch
(
SecurityException
)
{
// GetGetMethod may try to get a method protected by
// StrongNameIdentityPermission - effectively private.
return
false
;
}
if
(
mm
==
null
)
{
return
false
;
}
return
ShouldBindMethod
(
mm
)
;
}
internal
static
bool
ShouldBindEvent
(
EventInfo
ei
)
{
return
ShouldBindMethod
(
ei
.
GetAddMethod
(
true
)
)
;
}
private
static
ClassInfo
GetClassInfo
(
Type
type
)
{
var
ci
=
new
ClassInfo
(
)
;
var
methods
=
new
Hashtable
(
)
;
ArrayList
list
;
MethodInfo
meth
;
ManagedType
ob
;
string
name
;
object
item
;
Type
tp
;
int
i
,
n
;
MemberInfo
[
]
info
=
type
.
GetMembers
(
BindingFlags
)
;
var
local
=
new
Hashtable
(
)
;
var
items
=
new
ArrayList
(
)
;
MemberInfo
m
;
// Loop through once to find out which names are declared
for
(
i
=
0
;
i
<
info
.
Length
;
i
++
)
{
m
=
info
[
i
]
;
if
(
m
.
DeclaringType
==
type
)
{
local
[
m
.
Name
]
=
1
;
}
}
// Now again to filter w/o losing overloaded member info
for
(
i
=
0
;
i
<
info
.
Length
;
i
++
)
{
m
=
info
[
i
]
;
if
(
local
[
m
.
Name
]
!=
null
)
{
items
.
Add
(
m
)
;
}
}
if
(
type
.
IsInterface
)
{
// Interface inheritance seems to be a different animal:
// more contractual, less structural. Thus, a Type that
// represents an interface that inherits from another
// interface does not return the inherited interface's
// methods in GetMembers. For example ICollection inherits
// from IEnumerable, but ICollection's GetMemebers does not
// return GetEnumerator.
//
// Not sure if this is the correct way to fix this, but it
// seems to work. Thanks to Bruce Dodson for the fix.
Type
[
]
inheritedInterfaces
=
type
.
GetInterfaces
(
)
;
for
(
i
=
0
;
i
<
inheritedInterfaces
.
Length
;
++
i
)
{
Type
inheritedType
=
inheritedInterfaces
[
i
]
;
MemberInfo
[
]
imembers
=
inheritedType
.
GetMembers
(
BindingFlags
)
;
for
(
n
=
0
;
n
<
imembers
.
Length
;
n
++
)
{
m
=
imembers
[
n
]
;
if
(
local
[
m
.
Name
]
==
null
)
{
items
.
Add
(
m
)
;
}
}
}
// All interface implementations inherit from Object,
// but GetMembers don't return them either.
var
objFlags
=
BindingFlags
.
Public
|
BindingFlags
.
Instance
;
foreach
(
var
mi
in
typeof
(
object
)
.
GetMembers
(
objFlags
)
)
{
if
(
local
[
mi
.
Name
]
==
null
)
{
items
.
Add
(
mi
)
;
}
}
}
for
(
i
=
0
;
i
<
items
.
Count
;
i
++
)
{
var
mi
=
(
MemberInfo
)
items
[
i
]
;
switch
(
mi
.
MemberType
)
{
case
MemberTypes
.
Method
:
meth
=
(
MethodInfo
)
mi
;
if
(
!
ShouldBindMethod
(
meth
)
)
{
continue
;
}
name
=
meth
.
Name
;
item
=
methods
[
name
]
;
if
(
item
==
null
)
{
item
=
methods
[
name
]
=
new
ArrayList
(
)
;
}
list
=
(
ArrayList
)
item
;
list
.
Add
(
meth
)
;
continue
;
case
MemberTypes
.
Property
:
var
pi
=
(
PropertyInfo
)
mi
;
if
(
!
ShouldBindProperty
(
pi
)
)
{
continue
;
}
// Check for indexer
ParameterInfo
[
]
args
=
pi
.
GetIndexParameters
(
)
;
if
(
args
.
GetLength
(
0
)
>
0
)
{
Indexer
idx
=
ci
.
indexer
;
if
(
idx
==
null
)
{
ci
.
indexer
=
new
Indexer
(
)
;
idx
=
ci
.
indexer
;
}
idx
.
AddProperty
(
pi
)
;
continue
;
}
ob
=
new
PropertyObject
(
pi
)
;
ci
.
members
[
pi
.
Name
]
=
ob
;
continue
;
case
MemberTypes
.
Field
:
var
fi
=
(
FieldInfo
)
mi
;
if
(
!
ShouldBindField
(
fi
)
)
{
continue
;
}
ob
=
new
FieldObject
(
fi
)
;
ci
.
members
[
mi
.
Name
]
=
ob
;
continue
;
case
MemberTypes
.
Event
:
var
ei
=
(
EventInfo
)
mi
;
if
(
!
ShouldBindEvent
(
ei
)
)
{
continue
;
}
ob
=
new
EventObject
(
ei
)
;
ci
.
members
[
ei
.
Name
]
=
ob
;
continue
;
case
MemberTypes
.
NestedType
:
tp
=
(
Type
)
mi
;
if
(
!
(
tp
.
IsNestedPublic
||
tp
.
IsNestedFamily
||
tp
.
IsNestedFamORAssem
)
)
{
continue
;
}
// Note the given instance might be uninitialized
ob
=
GetClass
(
tp
)
;
// GetClass returns a Borrowed ref. ci.members owns the reference.
ob
.
IncrRefCount
(
)
;
ci
.
members
[
mi
.
Name
]
=
ob
;
continue
;
}
}
IDictionaryEnumerator
iter
=
methods
.
GetEnumerator
(
)
;
while
(
iter
.
MoveNext
(
)
)
{
name
=
(
string
)
iter
.
Key
;
list
=
(
ArrayList
)
iter
.
Value
;
var
mlist
=
(
MethodInfo
[
]
)
list
.
ToArray
(
typeof
(
MethodInfo
)
)
;
ob
=
new
MethodObject
(
type
,
name
,
mlist
)
;
ci
.
members
[
name
]
=
ob
;
if
(
mlist
.
Any
(
OperatorMethod
.
IsOperatorMethod
)
)
{
string
pyName
=
OperatorMethod
.
GetPyMethodName
(
name
)
;
string
pyNameReverse
=
OperatorMethod
.
ReversePyMethodName
(
pyName
)
;
OperatorMethod
.
FilterMethods
(
mlist
,
out
var
forwardMethods
,
out
var
reverseMethods
)
;
// Only methods where the left operand is the declaring type.
if
(
forwardMethods
.
Length
>
0
)
ci
.
members
[
pyName
]
=
new
MethodObject
(
type
,
name
,
forwardMethods
)
;
// Only methods where only the right operand is the declaring type.
if
(
reverseMethods
.
Length
>
0
)
ci
.
members
[
pyNameReverse
]
=
new
MethodObject
(
type
,
name
,
reverseMethods
)
;
}
}
if
(
ci
.
indexer
==
null
&&
type
.
IsClass
)
{
// Indexer may be inherited.
var
parent
=
type
.
BaseType
;
while
(
parent
!=
null
&&
ci
.
indexer
==
null
)
{
foreach
(
var
prop
in
parent
.
GetProperties
(
)
)
{
var
args
=
prop
.
GetIndexParameters
(
)
;
if
(
args
.
GetLength
(
0
)
>
0
)
{
ci
.
indexer
=
new
Indexer
(
)
;
ci
.
indexer
.
AddProperty
(
prop
)
;
break
;
}
}
parent
=
parent
.
BaseType
;
}
}
return
ci
;
}
/// <summary>
/// This class owns references to PyObjects in the `members` member.
/// The caller has responsibility to DECREF them.
/// </summary>
private
class
ClassInfo
{
public
Indexer
indexer
;
public
Hashtable
members
;
internal
ClassInfo
(
)
{
members
=
new
Hashtable
(
)
;
indexer
=
null
;
}
}
}
}
Back
|
FazBrowse Home
|
New Git URL