PyType class, wrapper for Python types#1395
Conversation
|
Hm, on non-Windows, utf8 decoding fails inside Python with a funky nÁmæ. This might be an existing problem with UTF-8 string marshaling. |
src/runtime/clrobject.cs
Outdated
| IntPtr py = Runtime.PyType_GenericAlloc(tp, 0); | ||
|
|
||
| long flags = Util.ReadCLong(tp, TypeOffset.tp_flags); | ||
| var flags = (TypeFlags)Marshal.ReadInt32(tp, TypeOffset.tp_flags); |
There was a problem hiding this comment.
tp_flags is a long, not an int32.
There was a problem hiding this comment.
Reverted back to using Util.ReadCLong.
Surprisingly in PyType_Spec flags are of type unsigned int, which implies they should never exceed 2^32.
typedef struct{
const char* name;
int basicsize;
int itemsize;
unsigned int flags;
PyType_Slot *slots; /* terminated by slot==0. */
} PyType_Spec;There was a problem hiding this comment.
Hm. Actually, because of the above we can probably use ReadInt32.
tp_flags is the only field, that is assumed to be declared as long. So we could remove ReadCLong and WriteCLong helpers then.
982a4de to
73661fd
Compare
|
Damn Mono incorrectly marshaled [StructLayout(Sequential)]
class ByReference
{
Some Fields;
}No idea why. Wasted whole day trying to figure it out. .NET Core and .NET Framework worked correctly on all platforms. According to Mono docs it should have worked. After switching to [StructLayout(Sequential)]
struct ByValue
{
Some Fields;
}and passing it as |
|
P.S. I tried to isolate commits, so best to rebase or merge. |
|
@filmor can you re-review this one? I am continuing to do cleanup, and in-progress work on |
…e construction from PyType_Spec (TypeSpec class)
73661fd to
d3c5654
Compare
What does this implement/fix? Explain your changes.
This introduces a new
PyTypeclass (similar toPyInt, but for types). It can:PyObject, that points to a typeTypeSpecclass)Does this close any currently open issues?
It is WIP on #1033
It is related to #1196
Checklist
Check all those that are applicable and complete.
CHANGELOG