@@ -52,62 +52,53 @@ static Converter()
5252 /// </summary>
5353 internal static Type GetTypeByAlias ( IntPtr op )
5454 {
55- if ( op == Runtime . PyStringType ||
56- op == Runtime . PyUnicodeType )
57- {
55+ if ( op == Runtime . PyStringType )
5856 return stringType ;
59- }
60- else if ( op == Runtime . PyIntType )
61- {
57+
58+ if ( op == Runtime . PyUnicodeType )
59+ return stringType ;
60+
61+ if ( op == Runtime . PyIntType )
6262 return int32Type ;
63- }
64- else if ( op == Runtime . PyLongType )
65- {
63+
64+ if ( op == Runtime . PyLongType )
6665 return int64Type ;
67- }
68- else if ( op == Runtime . PyFloatType )
69- {
66+
67+ if ( op == Runtime . PyFloatType )
7068 return doubleType ;
71- }
72- else if ( op == Runtime . PyBoolType )
73- {
69+
70+ if ( op == Runtime . PyBoolType )
7471 return boolType ;
75- }
72+
7673 return null ;
7774 }
7875
7976 internal static IntPtr GetPythonTypeByAlias ( Type op )
8077 {
8178 if ( op == stringType )
82- {
8379 return Runtime . PyUnicodeType ;
84- }
8580
86- else if ( Runtime . IsPython3 && ( op == int16Type ||
87- op == int32Type ||
88- op == int64Type ) )
89- {
81+ if ( op == int16Type )
9082 return Runtime . PyIntType ;
91- }
9283
93- else if ( op == int16Type ||
94- op == int32Type )
95- {
84+ if ( op == int32Type )
9685 return Runtime . PyIntType ;
97- }
98- else if ( op == int64Type )
99- {
86+
87+ if ( op == int64Type && Runtime . IsPython2 )
10088 return Runtime . PyLongType ;
101- }
102- else if ( op == doubleType ||
103- op == singleType )
104- {
89+
90+ if ( op == int64Type )
91+ return Runtime . PyIntType ;
92+
93+ if ( op == doubleType )
10594 return Runtime . PyFloatType ;
106- }
107- else if ( op == boolType )
108- {
95+
96+ if ( op == singleType )
97+ return Runtime . PyFloatType ;
98+
99+ if ( op == boolType )
109100 return Runtime . PyBoolType ;
110- }
101+
111102 return IntPtr . Zero ;
112103 }
113104
@@ -329,27 +320,27 @@ internal static bool ToManagedValue(IntPtr value, Type obType,
329320 return ToPrimitive ( value , stringType , out result , setError ) ;
330321 }
331322
332- else if ( Runtime . PyBool_Check ( value ) )
323+ if ( Runtime . PyBool_Check ( value ) )
333324 {
334325 return ToPrimitive ( value , boolType , out result , setError ) ;
335326 }
336327
337- else if ( Runtime . PyInt_Check ( value ) )
328+ if ( Runtime . PyInt_Check ( value ) )
338329 {
339330 return ToPrimitive ( value , int32Type , out result , setError ) ;
340331 }
341332
342- else if ( Runtime . PyLong_Check ( value ) )
333+ if ( Runtime . PyLong_Check ( value ) )
343334 {
344335 return ToPrimitive ( value , int64Type , out result , setError ) ;
345336 }
346337
347- else if ( Runtime . PyFloat_Check ( value ) )
338+ if ( Runtime . PyFloat_Check ( value ) )
348339 {
349340 return ToPrimitive ( value , doubleType , out result , setError ) ;
350341 }
351342
352- else if ( Runtime . PySequence_Check ( value ) )
343+ if ( Runtime . PySequence_Check ( value ) )
353344 {
354345 return ToArray ( value , typeof ( object [ ] ) , out result , setError ) ;
355346 }
@@ -371,31 +362,31 @@ internal static bool ToManagedValue(IntPtr value, Type obType,
371362 return true ;
372363 }
373364
374- else if ( value == Runtime . PyBoolType )
365+ if ( value == Runtime . PyBoolType )
375366 {
376367 result = boolType ;
377368 return true ;
378369 }
379370
380- else if ( value == Runtime . PyIntType )
371+ if ( value == Runtime . PyIntType )
381372 {
382373 result = int32Type ;
383374 return true ;
384375 }
385376
386- else if ( value == Runtime . PyLongType )
377+ if ( value == Runtime . PyLongType )
387378 {
388379 result = int64Type ;
389380 return true ;
390381 }
391382
392- else if ( value == Runtime . PyFloatType )
383+ if ( value == Runtime . PyFloatType )
393384 {
394385 result = doubleType ;
395386 return true ;
396387 }
397388
398- else if ( value == Runtime . PyListType || value == Runtime . PyTupleType )
389+ if ( value == Runtime . PyListType || value == Runtime . PyTupleType )
399390 {
400391 result = typeof ( object [ ] ) ;
401392 return true ;
0 commit comments