[svn] r7750: nemerle/trunk/snippets/aop: . src/helper/TypePattern.n
src/helper/Weaver.n src/macros/aspect....
Luntain
svnadmin at nemerle.org
Thu Jul 12 16:50:51 CEST 2007
Log:
refactored out a weaver
Author: Luntain
Date: Thu Jul 12 16:50:49 2007
New Revision: 7750
Added:
nemerle/trunk/snippets/aop/src/helper/Weaver.n
Modified:
nemerle/trunk/snippets/aop/ (props changed)
nemerle/trunk/snippets/aop/src/helper/TypePattern.n
nemerle/trunk/snippets/aop/src/macros/aspect.n
Modified: nemerle/trunk/snippets/aop/src/helper/TypePattern.n
==============================================================================
--- nemerle/trunk/snippets/aop/src/helper/TypePattern.n (original)
+++ nemerle/trunk/snippets/aop/src/helper/TypePattern.n Thu Jul 12 16:50:49 2007
@@ -84,7 +84,7 @@
public Void(): ParamPattern
ParamPattern(<[void]>)
- public ClassLike(full_name: list[string],args: list[ParamPattern], env: GlobalEnv): ParamPattern
+ public ClassLike(full_name: list[string],args: list[ParamPattern],_env: GlobalEnv): ParamPattern
// match (env.LookupType(full_name))
// | Some =>
// ()
Added: nemerle/trunk/snippets/aop/src/helper/Weaver.n
==============================================================================
--- (empty file)
+++ nemerle/trunk/snippets/aop/src/helper/Weaver.n Thu Jul 12 16:50:49 2007
@@ -0,0 +1,29 @@
+#pragma indent
+
+using Nemerle.Compiler
+
+namespace Nemerle.Aop.Helper
+ module Weaver
+ public Weave(types_manager: TypesManager): void
+ def weave_if_matches(jp)
+ Advices.Instance.WeaveIfMatches(jp)
+
+ types_manager.Iter( fun(tb) {
+ when (!tb.IsInterface) {
+ tb.GetMethods().Iter( fun(meth) {
+ when (meth is MethodBuilder) {
+ weave_if_matches(Joinpoint(meth:>MethodBuilder))
+ }
+ });
+ tb.GetConstructors().Iter( fun(meth) {
+ when (meth is MethodBuilder)
+ weave_if_matches(Joinpoint(meth:>MethodBuilder))
+ });
+ tb.GetProperties().Iter( fun(prop: IProperty) {
+ when(prop.GetGetter() != null && prop.GetGetter() is MethodBuilder)
+ weave_if_matches(Joinpoint.MakePropertyGetJoinpoint(prop.GetGetter() :> MethodBuilder,prop.Name));
+ when(prop.GetSetter() != null && prop.GetSetter() is MethodBuilder)
+ weave_if_matches(Joinpoint.MakePropertySetJoinpoint(prop.GetSetter() :> MethodBuilder,prop.Name));
+ });
+ }
+ });
Modified: nemerle/trunk/snippets/aop/src/macros/aspect.n
==============================================================================
--- nemerle/trunk/snippets/aop/src/macros/aspect.n (original)
+++ nemerle/trunk/snippets/aop/src/macros/aspect.n Thu Jul 12 16:50:49 2007
@@ -48,29 +48,7 @@
when (!Aspects.AlreadyWoven) {
def types_manager = type_builder.TyManager;
- def weave_if_matches(jp) {
- Advices.Instance.WeaveIfMatches(jp)
- }
-
- types_manager.Iter( fun(tb) {
- when (!tb.IsInterface) {
- tb.GetMethods().Iter( fun(meth) {
- when (meth is MethodBuilder) {
- weave_if_matches(Joinpoint(meth:>MethodBuilder))
- }
- });
- tb.GetConstructors().Iter( fun(meth) {
- when (meth is MethodBuilder)
- weave_if_matches(Joinpoint(meth:>MethodBuilder))
- });
- tb.GetProperties().Iter( fun(prop: IProperty) {
- when(prop.GetGetter() != null && prop.GetGetter() is MethodBuilder)
- weave_if_matches(Joinpoint.MakePropertyGetJoinpoint(prop.GetGetter() :> MethodBuilder,prop.Name));
- when(prop.GetSetter() != null && prop.GetSetter() is MethodBuilder)
- weave_if_matches(Joinpoint.MakePropertySetJoinpoint(prop.GetSetter() :> MethodBuilder,prop.Name));
- });
- }
- });
+ Weaver.Weave(types_manager);
Advices.Instance.WarnIfAdviceNotWeaved();
Aspects.AlreadyWoven = true;
More information about the svn
mailing list