Код: Выделить всё
struct outer {
.
.
.
unsigned int rsi;
unsigned int flags;
struct internal_state *state;
};
struct internal_state {
int (*mode)(struct outer *);
int (**id_table)(struct outer *);
void (*flush_output)(struct outer *);
int id;
int id_len;
.
.
.
}
Если я попытаюсь добавить в режиме, id_table иlush_output в качестве типа Func/Action, вызов вылетает со следующим исключением (что неудивительно)
Невозможно маршалировать поле 'mode' типа 'internal_state': непреобразуемые универсальные типы не могут быть маршалированы.
Учитывая, что код C# не затрагивает свойство state, существует ли какой-либо способ «конфисковать» код C#/C для этого свойства?
Пример кода C#
Код: Выделить всё
public unsafe byte[] GetData(byte[] data)
{
var myOuter = new outer
{
.
.
.
rsi = 128,
flags = 8
};
var intitResponse = Init(ref myOuter);
var actResponse = Act(ref myOuter, 0);
var endResponse = End(ref myOuter);
return dataOut;
}
[DllImport("lib/aec.dll", EntryPoint = "init")]
public static extern int Init(ref outer outr);
[DllImport("lib/aec.dll", EntryPoint = "act")]
public static extern int Act(ref outer outr, nuint flush);
[DllImport("lib/aec.dll", EntryPoint = "end")]
public static extern int End(ref outer outr);
public struct outer
{
.
.
.
public nuint rsi;
public nuint flags;
public internal_state state;
}
Подробнее здесь: https://stackoverflow.com/questions/788 ... in-c-sharp