symmetryinvestments / autowrap

Wrap existing D code for use in Python, Excel, C#
BSD 3-Clause "New" or "Revised" License
80 stars 16 forks source link

C# types as arguments and returns #121

Open Laeeth opened 5 years ago

Laeeth commented 5 years ago

I want to replace step by step a large c sharp codebase. 800k sloc!

I need to be able to take csharp classes and interfaces as parameters and return type. But how?

You could make a ClrClass(T) type. Two stage build. Stage one it just accepts any old opdispatch and generates csharp boilerplate. Stage two the same calls generate D mixin code to hook up to the boilerplate.

Exactly what boilerplate depends. But maybe see what you think of concept.

atilaneves commented 5 years ago

I need to be able to take csharp classes and interfaces as parameters and return type. But how?

I would assume in the same way that excel-d and pynih do it: convert at the seams.

Laeeth commented 5 years ago

I don't see how excel-d does it. You don't have Excel types that don't exist at the time excel-d was written.

Python is dynamic so how do static types from alien code come to be relevant?

atilaneves commented 5 years ago

Python is dynamic so how do static types from alien code come to be relevant?

At the moment, they all become Python classes in both python backends. I would expect C# to be similar, with the difference that it has more options for conversion, but since they map to D's interface, class and struct types anyway I don't foresee any problems.

atilaneves commented 5 years ago

But wait: this is wrapping C# for D then, right? So the opposite direction of what we're doing.

Laeeth commented 5 years ago

It's the opposite direction yes. But lambdas, return types and the ability to replace part of it at a time.

Laeeth commented 5 years ago

This is quite different from problems of python and excel. You never get an excel type that wasn't known at the time you wrote autowrap.