You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@thrift.apache.org by "Nathan Marz (JIRA)" <ji...@apache.org> on 2008/10/08 20:47:44 UTC

[jira] Created: (THRIFT-163) Create an Plugin Framework so Developers can plug-in arbitrary code-generation features

Create an Plugin Framework so Developers can plug-in arbitrary code-generation features
---------------------------------------------------------------------------------------

                 Key: THRIFT-163
                 URL: https://issues.apache.org/jira/browse/THRIFT-163
             Project: Thrift
          Issue Type: New Feature
            Reporter: Nathan Marz


It would be really nice to be able to plug in arbitrary code-generation extensions to the Thrift compiler. There are a lot of application-specific problems that can be elegantly solved by augmenting the Thrift compiler. For example, in my application, I need to be able to find all instances of an object of a certain type reachable from a Thrift object. (Java reflection is too expensive). I doubt that the community would accept this is a feature within the core compiler, but if I could do it via my own extension that would be ideal. 

There are a number of steps that need to happen to make this work:

1. Create an interface that extensions implement - this could be as simple as one method called "generate_body" which is called within the class definition. This allows extensions to create field declarations and new methods. Possibly we might need a "generate_constructor" if the extension needs to do anything in the object's constructor.

2. Create a way for the compiler to dynamically load extension modules - I'm not that familiar with how to do this in C++. We might need a configuration file for each module which specifies what language it generates for.


I think one of the main objections to this will be robustness - how do we ensure that extensions don't conflict with one another or with the Thrift compiler itself? I would propose that we take the Firefox route to addressing this and don't worry about it. It should be up to the extensions designed to choose sufficiently good method and field names to prevent conflicts.

Thoughts?

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Updated: (THRIFT-163) Create an Plugin Framework so Developers can plug-in arbitrary code-generation features

Posted by "Bryan Duxbury (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/THRIFT-163?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Bryan Duxbury updated THRIFT-163:
---------------------------------

    Priority: Trivial  (was: Major)

> Create an Plugin Framework so Developers can plug-in arbitrary code-generation features
> ---------------------------------------------------------------------------------------
>
>                 Key: THRIFT-163
>                 URL: https://issues.apache.org/jira/browse/THRIFT-163
>             Project: Thrift
>          Issue Type: New Feature
>            Reporter: Nathan Marz
>            Priority: Trivial
>         Attachments: 0001-shared-generators-take-1.patch
>
>
> It would be really nice to be able to plug in arbitrary code-generation extensions to the Thrift compiler. There are a lot of application-specific problems that can be elegantly solved by augmenting the Thrift compiler. For example, in my application, I need to be able to find all instances of an object of a certain type reachable from a Thrift object. (Java reflection is too expensive). I doubt that the community would accept this is a feature within the core compiler, but if I could do it via my own extension that would be ideal. 
> There are a number of steps that need to happen to make this work:
> 1. Create an interface that extensions implement - this could be as simple as one method called "generate_body" which is called within the class definition. This allows extensions to create field declarations and new methods. Possibly we might need a "generate_constructor" if the extension needs to do anything in the object's constructor.
> 2. Create a way for the compiler to dynamically load extension modules - I'm not that familiar with how to do this in C++. We might need a configuration file for each module which specifies what language it generates for.
> I think one of the main objections to this will be robustness - how do we ensure that extensions don't conflict with one another or with the Thrift compiler itself? I would propose that we take the Firefox route to addressing this and don't worry about it. It should be up to the extensions designed to choose sufficiently good method and field names to prevent conflicts.
> Thoughts?

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Updated: (THRIFT-163) Create an Plugin Framework so Developers can plug-in arbitrary code-generation features

Posted by "David Reiss (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/THRIFT-163?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

David Reiss updated THRIFT-163:
-------------------------------

    Attachment: 0001-shared-generators-take-1.patch

This is actually way more primitive than I remembered.  If I recall properly, it successfully builds the generators as shared objects.  Since this was written, we've modified most of the generators to use a dynamic registry, which was one of the big hurdles to getting this to work.  I think the big chunks that remain to be done are first modifying the compiler to load the appropriate shared objects with libltdl and investigating whether it is possible to compile some of the objects directly into the compiler so that we don't have to worry about library search paths.

> Create an Plugin Framework so Developers can plug-in arbitrary code-generation features
> ---------------------------------------------------------------------------------------
>
>                 Key: THRIFT-163
>                 URL: https://issues.apache.org/jira/browse/THRIFT-163
>             Project: Thrift
>          Issue Type: New Feature
>            Reporter: Nathan Marz
>         Attachments: 0001-shared-generators-take-1.patch
>
>
> It would be really nice to be able to plug in arbitrary code-generation extensions to the Thrift compiler. There are a lot of application-specific problems that can be elegantly solved by augmenting the Thrift compiler. For example, in my application, I need to be able to find all instances of an object of a certain type reachable from a Thrift object. (Java reflection is too expensive). I doubt that the community would accept this is a feature within the core compiler, but if I could do it via my own extension that would be ideal. 
> There are a number of steps that need to happen to make this work:
> 1. Create an interface that extensions implement - this could be as simple as one method called "generate_body" which is called within the class definition. This allows extensions to create field declarations and new methods. Possibly we might need a "generate_constructor" if the extension needs to do anything in the object's constructor.
> 2. Create a way for the compiler to dynamically load extension modules - I'm not that familiar with how to do this in C++. We might need a configuration file for each module which specifies what language it generates for.
> I think one of the main objections to this will be robustness - how do we ensure that extensions don't conflict with one another or with the Thrift compiler itself? I would propose that we take the Firefox route to addressing this and don't worry about it. It should be up to the extensions designed to choose sufficiently good method and field names to prevent conflicts.
> Thoughts?

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (THRIFT-163) Create an Plugin Framework so Developers can plug-in arbitrary code-generation features

Posted by "Hannes Baldursson (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/THRIFT-163?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12658628#action_12658628 ] 

Hannes Baldursson commented on THRIFT-163:
------------------------------------------

This one looks interesting

> Create an Plugin Framework so Developers can plug-in arbitrary code-generation features
> ---------------------------------------------------------------------------------------
>
>                 Key: THRIFT-163
>                 URL: https://issues.apache.org/jira/browse/THRIFT-163
>             Project: Thrift
>          Issue Type: New Feature
>            Reporter: Nathan Marz
>         Attachments: 0001-shared-generators-take-1.patch
>
>
> It would be really nice to be able to plug in arbitrary code-generation extensions to the Thrift compiler. There are a lot of application-specific problems that can be elegantly solved by augmenting the Thrift compiler. For example, in my application, I need to be able to find all instances of an object of a certain type reachable from a Thrift object. (Java reflection is too expensive). I doubt that the community would accept this is a feature within the core compiler, but if I could do it via my own extension that would be ideal. 
> There are a number of steps that need to happen to make this work:
> 1. Create an interface that extensions implement - this could be as simple as one method called "generate_body" which is called within the class definition. This allows extensions to create field declarations and new methods. Possibly we might need a "generate_constructor" if the extension needs to do anything in the object's constructor.
> 2. Create a way for the compiler to dynamically load extension modules - I'm not that familiar with how to do this in C++. We might need a configuration file for each module which specifies what language it generates for.
> I think one of the main objections to this will be robustness - how do we ensure that extensions don't conflict with one another or with the Thrift compiler itself? I would propose that we take the Firefox route to addressing this and don't worry about it. It should be up to the extensions designed to choose sufficiently good method and field names to prevent conflicts.
> Thoughts?

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (THRIFT-163) Create an Plugin Framework so Developers can plug-in arbitrary code-generation features

Posted by "David Reiss (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/THRIFT-163?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12638083#action_12638083 ] 

David Reiss commented on THRIFT-163:
------------------------------------

I have some code lying around that implements part of this using libtool.  I'll try to dig it up in the next few days.  I think the biggest risk is the Thrift compiler having problems loading the generator modules.  I think the second biggest risk is build errors on all sorts of platforms (I'm looking at you, OS X).

> Create an Plugin Framework so Developers can plug-in arbitrary code-generation features
> ---------------------------------------------------------------------------------------
>
>                 Key: THRIFT-163
>                 URL: https://issues.apache.org/jira/browse/THRIFT-163
>             Project: Thrift
>          Issue Type: New Feature
>            Reporter: Nathan Marz
>
> It would be really nice to be able to plug in arbitrary code-generation extensions to the Thrift compiler. There are a lot of application-specific problems that can be elegantly solved by augmenting the Thrift compiler. For example, in my application, I need to be able to find all instances of an object of a certain type reachable from a Thrift object. (Java reflection is too expensive). I doubt that the community would accept this is a feature within the core compiler, but if I could do it via my own extension that would be ideal. 
> There are a number of steps that need to happen to make this work:
> 1. Create an interface that extensions implement - this could be as simple as one method called "generate_body" which is called within the class definition. This allows extensions to create field declarations and new methods. Possibly we might need a "generate_constructor" if the extension needs to do anything in the object's constructor.
> 2. Create a way for the compiler to dynamically load extension modules - I'm not that familiar with how to do this in C++. We might need a configuration file for each module which specifies what language it generates for.
> I think one of the main objections to this will be robustness - how do we ensure that extensions don't conflict with one another or with the Thrift compiler itself? I would propose that we take the Firefox route to addressing this and don't worry about it. It should be up to the extensions designed to choose sufficiently good method and field names to prevent conflicts.
> Thoughts?

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (THRIFT-163) Create an Plugin Framework so Developers can plug-in arbitrary code-generation features

Posted by "Mark Slee (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/THRIFT-163?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12638032#action_12638032 ] 

Mark Slee commented on THRIFT-163:
----------------------------------

I think this is an excellent idea, and its one that we had discussed doing internally even before open sourcing Thrift. Theoretically, all of the language generators could just use this plugin architecture. There will be a bit of heavy lifting in setting up the dynamic loading, but I'm sure there's someone on the project who's already roughly familiar enough with that to start thinking about tackling it.

But overall, this would be great to have. I think it'll promote greater sharing of extended functionality that doesn't belong in the core compiler.

> Create an Plugin Framework so Developers can plug-in arbitrary code-generation features
> ---------------------------------------------------------------------------------------
>
>                 Key: THRIFT-163
>                 URL: https://issues.apache.org/jira/browse/THRIFT-163
>             Project: Thrift
>          Issue Type: New Feature
>            Reporter: Nathan Marz
>
> It would be really nice to be able to plug in arbitrary code-generation extensions to the Thrift compiler. There are a lot of application-specific problems that can be elegantly solved by augmenting the Thrift compiler. For example, in my application, I need to be able to find all instances of an object of a certain type reachable from a Thrift object. (Java reflection is too expensive). I doubt that the community would accept this is a feature within the core compiler, but if I could do it via my own extension that would be ideal. 
> There are a number of steps that need to happen to make this work:
> 1. Create an interface that extensions implement - this could be as simple as one method called "generate_body" which is called within the class definition. This allows extensions to create field declarations and new methods. Possibly we might need a "generate_constructor" if the extension needs to do anything in the object's constructor.
> 2. Create a way for the compiler to dynamically load extension modules - I'm not that familiar with how to do this in C++. We might need a configuration file for each module which specifies what language it generates for.
> I think one of the main objections to this will be robustness - how do we ensure that extensions don't conflict with one another or with the Thrift compiler itself? I would propose that we take the Firefox route to addressing this and don't worry about it. It should be up to the extensions designed to choose sufficiently good method and field names to prevent conflicts.
> Thoughts?

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.