Commits

ZyX_I committed c5f732c

doc: Added description of fwc_compile feature, mentioned possibility of supplying string argument to conschecker and consfilter
@/checks: Removed `unload keys from conschecker and consfilter features descriptions

Comments (0)

Files changed (2)

         3.4. @/decorators/altervars features      |frawor-f-decorators/altervars|
         3.5. plugin/frawor/options features       |frawor-f-frawor/options|
         3.6. plugin/frawor/checks features        |frawor-f-frawor/checks|
-        3.7. plugin/frawor/mappings features      |frawor-f-frawor/mappings|
-        3.8. plugin/frawor/autocommands features  |frawor-f-frawor/autocommands|
-        3.9. plugin/frawor/commands features      |frawor-f-frawor/commands|
-        3.10. plugin/frawor/resources features     |frawor-f-frawor/resources|
-        3.11. plugin/frawor/python features       |frawor-f-frawor/python|
-        3.12. plugin/frawor/perl features         |frawor-f-frawor/perl|
-        3.13. plugin/frawor/lua features          |frawor-f-frawor/lua|
-        3.14. plugin/frawor/ruby features         |frawor-f-frawor/ruby|
-        3.15. plugin/frawor/tcl features          |frawor-f-frawor/tcl|
+        3.7. @/fwc/compiler features              |frawor-f-fwc/compiler|
+        3.8. plugin/frawor/mappings features      |frawor-f-frawor/mappings|
+        3.9. plugin/frawor/autocommands features  |frawor-f-frawor/autocommands|
+        3.10. plugin/frawor/commands features     |frawor-f-frawor/commands|
+        3.11. plugin/frawor/resources features    |frawor-f-frawor/resources|
+        3.12. plugin/frawor/python features       |frawor-f-frawor/python|
+        3.13. plugin/frawor/perl features         |frawor-f-frawor/perl|
+        3.14. plugin/frawor/lua features          |frawor-f-frawor/lua|
+        3.15. plugin/frawor/ruby features         |frawor-f-frawor/ruby|
+        3.16. plugin/frawor/tcl features          |frawor-f-frawor/tcl|
     4. Resources                                  |frawor-resources|
         4.1. map resource                         |frawor-r-map|
         4.2. os resource                          |frawor-r-os|
         @filter     Filters function arguments before running the function 
                     itself. See |frawor-t-filter| for description of an 
                     argument. Priority: 64. Defined in plugin/frawor/checks.
+        @FWC        Accepts tuple with two elements: FWC string and type. 
+                    Depending on type, acts like @checker (if type is "check") 
+                    or @filter (if type is "filter"). Unlike @checker and 
+                    @filter does not create additional function.
+                    Priority: 128. Defined in plugin/frawor/fwc/compiler.
 
 ------------------------------------------------------------------------------
 3.4. @/decorators/altervars features           *frawor-f-decorators/altervars*
 
                                                         *frawor-f-conschecker*
 conschecker : function ({checker})
-           + unload
         Creates a checker function. Constructed function takes exactly one 
         argument: |List| containing checked arguments. For {checker} 
         description see |frawor-t-checker| >
 <
                                                          *frawor-f-consfilter*
 consfilter : function ({filter})
-           + unload
         Like |frawor-f-conschecker|, but for filters, see |frawor-t-filter|.
 
 ------------------------------------------------------------------------------
-3.7. plugin/frawor/mappings features                *frawor-f-frawor/mappings*
+3.7. @/fwc/compiler features                           *frawor-f-fwc/compiler*
+
+fwc_compile : function ({FWCstring}, {type})            *frawor-f-fwc_compile*
+            + unload
+        Create a function out of {FWCstring} code. This function takes a list 
+        of values (unless |fwc-o-only| is enabled) and returns either 
+        (possibly modified) its argument (or 0) when {type} is "filter", or 
+        a boolean value when {type} is "check".
+        Note that created function will be anonymous dictionary function, so 
+        you will need to supply a dictionary when you call it even though it 
+        does not use this dictionary. See |Dictionary-function| and 
+        description of the third argument to |call()|.
+
+------------------------------------------------------------------------------
+3.8. plugin/frawor/mappings features                *frawor-f-frawor/mappings*
 
                                                         *frawor-f-addmapgroup*
 mapgroup.add : function ({mgid}, {mappings}[, {mgopts}])
         that one which defined this group.
 
 ------------------------------------------------------------------------------
-3.8. plugin/frawor/autocommands features        *frawor-f-frawor/autocommands*
+3.9. plugin/frawor/autocommands features        *frawor-f-frawor/autocommands*
 
 augroup.add : function ({agid}, {events})               *frawor-f-augroup.add*
             + unload
             let s:_augroups+=['FooBar']
 
 ------------------------------------------------------------------------------
-3.9. plugin/frawor/commands features                *frawor-f-frawor/commands*
+3.10. plugin/frawor/commands features               *frawor-f-frawor/commands*
 
 delcommands : unloadpre + s:_commands                   *frawor-f-delcommands*
               register + s:_commands
             let s:_commands+=["Foo"]
 
 ------------------------------------------------------------------------------
-3.10. plugin/frawor/resources features             *frawor-f-frawor/resources*
+3.11. plugin/frawor/resources features             *frawor-f-frawor/resources*
 
                                                        *frawor-f-postresource*
 postresource : function ({rid}, {resource}[, {copyfunc}])
         so you don't need anything to get it working.
 
 ------------------------------------------------------------------------------
-3.11. plugin/frawor/python features                   *frawor-f-frawor/python*
+3.12. plugin/frawor/python features                   *frawor-f-frawor/python*
 
 All plugin/frawor/python features are available only if vim is compiled with 
 python support.
         feature, so you don't need to do anything to make it work.
 
 ------------------------------------------------------------------------------
-3.12. plugin/frawor/perl features                       *frawor-f-frawor/perl*
+3.13. plugin/frawor/perl features                       *frawor-f-frawor/perl*
 
 All plugin/frawor/perl features are available only if vim is compiled with 
 perl support.
         feature, so you don't need to do anything to make it work.
 
 ------------------------------------------------------------------------------
-3.13. plugin/frawor/lua features                        *frawor-f-frawor/lua*
+3.14. plugin/frawor/lua features                        *frawor-f-frawor/lua*
 
 All plugin/frawor/lua features are available only if vim is compiled with 
 lua support.
         need to do anything to make it work.
 
 ------------------------------------------------------------------------------
-3.14. plugin/frawor/ruby features                       *frawor-f-frawor/ruby*
+3.15. plugin/frawor/ruby features                       *frawor-f-frawor/ruby*
 
 All plugin/frawor/ruby features are available only if vim is compiled with 
 ruby support.
         feature, so you don't need to do anything to make it work.
 
 ------------------------------------------------------------------------------
-3.15. plugin/frawor/tcl features                        *frawor-f-frawor/tcl*
+3.16. plugin/frawor/tcl features                        *frawor-f-frawor/tcl*
 
 All plugin/frawor/tcl features are available only if vim is compiled with 
 tcl support.
         this function will be called with an argument list as an only 
         argument. Check is considered passed when this function returns 1 and 
         failed when this function returns 0.
+        If checker is a string, then it is passed to |frawor-f-fwc_compile| 
+        with "check" as a second argument, then generated function is 
+        returned.
 filter :: Function                                           *frawor-t-filter*
         If filter is a function reference, then in order to filter arguments 
         this function will be called with an argument list as an only 
         argument. If function returns a |List|, then it will be used as a new 
         argument list. Function should return 0 if some error occured.
+        If filter is a string, then it is passed to |frawor-f-fwc_compile| 
+        with "filter" as a second argument, then generated function is 
+        returned.
 option :: {}                                                 *frawor-t-option*
         Dictionary which describes option. It has the following keys:
         Key         Description ~

plugin/frawor/checks.vim

             \}
 endif
 "▶1 conschecker feature
-let s:checkers={'lastid': 0}
-"▶2 conschecker  :: {f}, checker → chkfunc + s:checkers
+"▶2 conschecker  :: {f}, checker → chkfunc + ?
 function s:F.conschecker(plugdict, fdict, Chk)
-    let id=printf('%x', s:checkers.lastid)
-    call add(a:fdict.ids, id)
-    let s:checkers.lastid+=1
     if type(a:Chk)==2
         if !exists('*a:Chk')
             call s:_f.throw('chkncall', a:plugdict.id)
         call s:_f.throw('uchecker', a:plugdict.id)
     endif
 endfunction
-"▶2 delcheckers  :: {f} → + s:checkers
-function s:F.delcheckers(plugdict, fdict)
-    for id in filter(a:fdict.ids, 'has_key(s:checkers, v:val)')
-        unlet s:checkers[id]
-    endfor
-endfunction
 "▶2 Register feature
-call s:_f.newfeature('conschecker', {'cons': s:F.conschecker,
-            \                      'unload': s:F.delcheckers,
-            \                        'init': {'ids': []}})
+call s:_f.newfeature('conschecker', {'cons': s:F.conschecker})
 "▶1 consfilter feature
-let s:filters={'lastid': 0}
-"▶2 consfilter  :: {f}, filter → filfunc + s:filters
+"▶2 consfilter  :: {f}, filter → filfunc + ?
 function s:F.consfilter(plugdict, fdict, Fil)
-    let id=printf('%x', s:filters.lastid)
-    call add(a:fdict.ids, id)
-    let s:filters.lastid+=1
     if type(a:Fil)==2
         if !exists('*a:Fil')
             call s:_f.throw('filncall', a:plugdict.id)
         call s:_f.throw('ufilter', a:plugdict.id)
     endif
 endfunction
-"▶2 delfilters  :: {f} → + s:filters
-function s:F.delfilters(plugdict, fdict)
-    for id in a:fdict.ids
-        unlet s:filters[id]
-    endfor
-endfunction
 "▶2 Register feature
-call s:_f.newfeature('consfilter', {'cons': s:F.consfilter,
-            \                     'unload': s:F.delfilters,
-            \                       'init': {'ids': []}})
+call s:_f.newfeature('consfilter', {'cons': s:F.consfilter})
 "▶1 Decorators: checker and filter
 let s:F.de={}
 "▶2 checker