Alter the matching process

The following discards the environment that caused execution of the python rule.

cocci.include_match(False)

API for org mode

Legacy API

@r@
position p,p1;
@@

// Place your cocci code here
// using position p and then position p1.

@script:python@
p << r.p;
p1 << r.p1;
@@

cocci.print_main("main message",p)

# Use print_sec when you have exactly one p1 for every p.
cocci.print_sec("secondary message", p1)

# Use print_secs when you have at least one p1 for every p.
cocci.print_secs ("sec. msg", p1)

New API

@initialize:python@

from coccilib.org import print_todo, print_link

@r@
position p1, p2;
identifier f;
expression E;
@@

f@p1(E@p2)

@ script:python @
p1 << r.p1;
p2 << r.p2;
f  << r.f;
@@

# Same output as print_main
# but message and color are optional
# the input is a single position instead of an array
print_todo (p1[0])
print_todo (p1[0], "My message")
print_todo (p1[0], "My message", "ovl-face1")

# An empty message will print information about
# the position p has follows: "file::line"

# Font color refers to the ones defined in org-view
# Recognized values are "ovl-face1" to "ovl-face4"

# Same output as print_sec
# but message and color are optional
# the input is a single position instead of an array
print_link (p2[0])

# Note that print_todo and print_link do not use the
# "cocci" object to be invoked. You simply have to import
# them from the org module.

print ""

# Legacy functions still works
cocci.print_main ("foo", p1)
cocci.print_sec ("foo", p2)
cocci.print_secs ("foo", p2)

print ""

# Legacy functions have been extented with an optional argument
# for color overlay in orgmode.
cocci.print_main ("foo", p1, "ovl-face3")
cocci.print_sec ("foo", p2, "ovl-face4")
cocci.print_secs ("foo", p2, "ovl-face4")
 
coccinelle_api_for_use_with_python.txt · Last modified: 2010/04/23 08:45 by npalix
 
Except where otherwise noted, content on this wiki is licensed under the following license:CC Attribution-Noncommercial-Share Alike 3.0 Unported
Recent changes RSS feed Donate Powered by PHP Valid XHTML 1.0 Valid CSS Driven by DokuWiki