Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

rest protocol definition #8

Open
petr-tik opened this issue Feb 14, 2017 · 10 comments
Open

rest protocol definition #8

petr-tik opened this issue Feb 14, 2017 · 10 comments

Comments

@petr-tik
Copy link
Member

As suggested by @jbcoe in FFIG/ffig#77,
The API will receive and send the following JSON:

request:

{
  "translation_unit": "class A { int x_; public: int getX() const { return x_; } void setX(int x) { x_ = x; } };",
  "bindings": ["ruby", "python"],
  "module": "TestModule"
}

response:

{
  "TestModule.py" : " ... ",
  "TestModule.rb" : " ... ",
  "TestModule_c.cpp" : " ... ",
  "TestModule_c.h" : " ... "
}

I was thinking, it's better to make separate requests for each binding.

Thoughts?

@petr-tik
Copy link
Member Author

petr-tik commented Feb 14, 2017

Also, the above spec implies that the client will turn source file into a translation unit.

Why not pass the whole source file in the POST request?

request:

{
  "translation_unit": 
"#ifdef __clang__
#define C_API __attribute__((annotate("GENERATE_C_API")))
#else
#define C_API
#endif

struct Asset
{
  virtual double PV() const = 0;
  virtual const char* name() const = 0;
  virtual ~Asset() = default;
} C_API;

struct CDO : Asset
{
  CDO() {}

  double PV() const override { return 0.0; }
  const char* name() const override { return "CDO"; }
};",
  "binding": "python",
  "module": "TestAsset"
}

@ajbennieston
Copy link
Member

Separate requests for each binding would mean building the clang AST and ffig code model repeatedly, would it not?

@jbcoe
Copy link
Collaborator

jbcoe commented Feb 15, 2017

It would and would be best avoided

@petr-tik
Copy link
Member Author

What about caching results?

@jbcoe
Copy link
Collaborator

jbcoe commented Feb 15, 2017

Seems unnecessary. What are the advantages over the wide REST API as proposed?

@petr-tik
Copy link
Member Author

ok. Just to clarify on my second point.

From what I understand, the api will receive translation units and I thought it's best to use the whole of FFIG. Send the source file and generate TU on server.

what am I missing?

@jbcoe
Copy link
Collaborator

jbcoe commented Feb 15, 2017

The user may have some of the headers so will need to locally construct the TU

@petr-tik
Copy link
Member Author

What about restricting to standard headers?

@petr-tik
Copy link
Member Author

Also, if you want to POST requests with translation units, it would be great to refactor ffig.main, so we can enter it from TU stage.

@jbcoe
Copy link
Collaborator

jbcoe commented Feb 16, 2017

If we restrict to standard headers we can take source. Let's get something working first and nuance it later

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants