[jira] Created: (BOO-1057) Attribute Before/After events

View: New views
4 Messages — Rating Filter:   Alert me  

[jira] Created: (BOO-1057) Attribute Before/After events

by JIRA jira@codehaus.org :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Attribute Before/After events
-----------------------------

                 Key: BOO-1057
                 URL: http://jira.codehaus.org/browse/BOO-1057
             Project: Boo
          Issue Type: New Feature
          Components: Compiler
            Reporter: Michael Phipps
            Priority: Minor


It would be really helpful to developers if a method marked with an attribute could call the attribute both before and after invocation. This would allow "real" AOP.
Example:
class MyAttribute
    def OnEnter():
         print "Before!"

    def OnExit():
         print "After!"

class Sample
    @MyAttribute@
    def DoSomething()
        print "Doing Something"

would print
Before!
Doing Something
After!
   

--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://jira.codehaus.org/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

       

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email



[jira] Closed: (BOO-1057) Attribute Before/After events

by JIRA jira@codehaus.org :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


     [ http://jira.codehaus.org/browse/BOO-1057?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Rodrigo B. de Oliveira closed BOO-1057.
---------------------------------------

    Resolution: Not A Bug

This can be implemented trivially with attributes today, here's a complete example:

{code}
namespace boospikes

import Boo.Lang.Compiler
import Boo.Lang.Compiler.Ast
import Boo.Lang.Compiler.MetaProgramming

class AroundAttribute(AbstractAstAttribute):
        override def Apply(node as Node):
                method as Method = node
                method.Body = [|
                        print "before"
                        try:
                                $(method.Body)
                        ensure:
                                print "after"
                |]
               
code = [|
        import boospikes
       
        class Foo:
               
                [around]
                def run():
                        print "running"
|]

type = compile(code, typeof(AroundAttribute).Assembly).GetType("Foo")
foo as duck = type()
foo.run()
{code}

> Attribute Before/After events
> -----------------------------
>
>                 Key: BOO-1057
>                 URL: http://jira.codehaus.org/browse/BOO-1057
>             Project: Boo
>          Issue Type: New Feature
>          Components: Compiler
>            Reporter: Michael Phipps
>            Priority: Minor
>
> It would be really helpful to developers if a method marked with an attribute could call the attribute both before and after invocation. This would allow "real" AOP.
> Example:
> class MyAttribute
>     def OnEnter():
>          print "Before!"
>     def OnExit():
>          print "After!"
> class Sample
>     @MyAttribute@
>     def DoSomething()
>         print "Doing Something"
> would print
> Before!
> Doing Something
> After!
>    

--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://jira.codehaus.org/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

       

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email



[jira] Commented: (BOO-1057) Attribute Before/After events

by JIRA jira@codehaus.org :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


    [ http://jira.codehaus.org/browse/BOO-1057?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=139038#action_139038 ]

Michael Phipps commented on BOO-1057:
-------------------------------------

Can you use this, though, without compiling the "client" class dynamically? I don't mind the syntax for the Attribute, but if every construction of a class that is tagged with an attribute would then require a dynamic recompile, that would be a lot of refactoring work...

> Attribute Before/After events
> -----------------------------
>
>                 Key: BOO-1057
>                 URL: http://jira.codehaus.org/browse/BOO-1057
>             Project: Boo
>          Issue Type: New Feature
>          Components: Compiler
>            Reporter: Michael Phipps
>            Priority: Minor
>
> It would be really helpful to developers if a method marked with an attribute could call the attribute both before and after invocation. This would allow "real" AOP.
> Example:
> class MyAttribute
>     def OnEnter():
>          print "Before!"
>     def OnExit():
>          print "After!"
> class Sample
>     @MyAttribute@
>     def DoSomething()
>         print "Doing Something"
> would print
> Before!
> Doing Something
> After!
>    

--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://jira.codehaus.org/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

       

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email



[jira] Commented: (BOO-1057) Attribute Before/After events

by JIRA jira@codehaus.org :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


    [ http://jira.codehaus.org/browse/BOO-1057?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=139040#action_139040 ]

Daniel Grunwald commented on BOO-1057:
--------------------------------------

The "client" class does not have to be compiled dynamically, but AroundAttribute must be in a separate assembly.

> Attribute Before/After events
> -----------------------------
>
>                 Key: BOO-1057
>                 URL: http://jira.codehaus.org/browse/BOO-1057
>             Project: Boo
>          Issue Type: New Feature
>          Components: Compiler
>            Reporter: Michael Phipps
>            Priority: Minor
>
> It would be really helpful to developers if a method marked with an attribute could call the attribute both before and after invocation. This would allow "real" AOP.
> Example:
> class MyAttribute
>     def OnEnter():
>          print "Before!"
>     def OnExit():
>          print "After!"
> class Sample
>     @MyAttribute@
>     def DoSomething()
>         print "Doing Something"
> would print
> Before!
> Doing Something
> After!
>    

--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://jira.codehaus.org/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

       

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email