djinni icon indicating copy to clipboard operation
djinni copied to clipboard

Add Windows Phone (C++/Cx) support

Open DEGoodmanWilson opened this issue 8 years ago • 9 comments

The code in this PR is over a year old. I don't rightly know how hard this is going to be to merge. I imagine it's not going to be easy—there'll be changes that need to be made. Let's talk! I'm ready to finally get this in.

DEGoodmanWilson avatar Nov 20 '16 07:11 DEGoodmanWilson

Automated message from Dropbox CLA bot

@DEGoodmanWilson, thanks for the pull request! It looks like you haven't yet signed the Dropbox CLA. Please sign it here.

smarx avatar Nov 20 '16 07:11 smarx

Automated message from Dropbox CLA bot

@DEGoodmanWilson, thanks for signing the CLA!

smarx avatar Nov 20 '16 16:11 smarx

@DEGoodmanWilson have you seen the blog MS released this morning? I know it is early, but would this change your thinking or do you think Cx is still a valid way to go? https://blogs.windows.com/buildingapps/2016/11/28/standard-c-windows-runtime-cwinrt

gnichola avatar Nov 29 '16 17:11 gnichola

Well, that's pretty darned cool! I like Cx OK, but it's got its quirks (and was a huge step up on CLI), but this looks very very promising. That said, in the end, if you are developing with .NET assemblies, you might not care how those assemblies were built, and to the end user of djinni it might not make a whole lot of diffference, since all of the Cx code is auto-generated, So…

DEGoodmanWilson avatar Nov 29 '16 18:11 DEGoodmanWilson

(Also, I know I need to clean up the commit history a bit here! This was many months of effort, and there are some extraneous commits I need to remove from the PR)

DEGoodmanWilson avatar Nov 29 '16 18:11 DEGoodmanWilson

I was actually about to start working on this but this looks pretty far along! I'm probably not the best person to fix the conflicts (I'm not even sure how since I definitely don't have write access) but I'd be happy to assist if possible. At the very least I could probably test this against our code base and see how that flies.

AndrewAtAvenza avatar Dec 13 '16 16:12 AndrewAtAvenza

We'd love to see this as well and I offer to help. We use djinni a lot and our C++ parts run on Windows as well - can try this branch with our setup as a larger test case once it's rebased - if that helps.

steipete avatar Dec 22 '16 12:12 steipete

@steipete I've got this refactored so only the relevant contributions—and only my contributions—are included. I can't see what the conflicts are, curiously. Git is not cooperating today. Anyway, would absolutely love your feedback.

DEGoodmanWilson avatar Dec 22 '16 22:12 DEGoodmanWilson

For anyone else trying this out here are a few hints to get the example generating code you can use in a Visual Studio project to build a WinRT component called MyComponent that bridges your native C++ with the managed languages, C# etc.

I added this to run_djinni.sh

cxcpp_out="$base_dir/generated-src/cxcpp"
cx_out="$base_dir/generated-src/cx"
...
    --cpp-namespace MyComponent_CPP \
...
    --cxcpp-out "$temp_out/cxcpp" \
    --cx-out "$temp_out/cx" \
    --cx-namespace MyComponent \
    --cxcpp-namespace MyComponent_CXCPP \
    --cpp-include-prefix "generated-src/cpp/" \
    --cx-include-prefix "generated-src/cx/" \
    --cxcpp-include-prefix "generated-src/cxcpp/" \
    --cxcpp-include-cpp-prefix "generated-src/cpp/" \
...
mirror "cxcpp" "$temp_out/cxcpp" "$cxcpp_out"
mirror "cx" "$temp_out/cx" "$cx_out"

You need different namespaces for cx, cpp and cppcx or you will have problems in your WinRT component. The cx namespace should be the same as the name of your component.

In example.djinni

textbox_listener = interface +x {

In handwritten-src/cpp/sort_items_impl.hpp

#include "generated-src/cpp/sort_items.hpp"
#include "generated-src/cpp/textbox_listener.hpp"

namespace MyComponent_CPP {

In handwritten-src/cpp/sort_items_impl.cpp

namespace MyComponent_CPP {

phraemer avatar Feb 08 '17 10:02 phraemer