X-Git-Url: https://git.hcoop.net/bpt/coccinelle.git/blobdiff_plain/785a3008ddade80f642257bb47d43158ac8b8311..97111a47d707638a835d7498276ac6768a052ee8:/python/yes_pycocci.ml diff --git a/python/yes_pycocci.ml b/python/yes_pycocci.ml index a369170..39e0468 100644 --- a/python/yes_pycocci.ml +++ b/python/yes_pycocci.ml @@ -1,3 +1,27 @@ +(* + * Copyright 2010, INRIA, University of Copenhagen + * Julia Lawall, Rene Rydhof Hansen, Gilles Muller, Nicolas Palix + * Copyright 2005-2009, Ecole des Mines de Nantes, University of Copenhagen + * Yoann Padioleau, Julia Lawall, Rene Rydhof Hansen, Henrik Stuart, Gilles Muller, Nicolas Palix + * This file is part of Coccinelle. + * + * Coccinelle is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, according to version 2 of the License. + * + * Coccinelle is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Coccinelle. If not, see . + * + * The authors reserve the right to distribute this or future versions of + * Coccinelle under other licenses. + *) + + open Ast_c open Common open Pycaml @@ -91,6 +115,7 @@ let pycocci_instantiate_class fqn args = (* end python interaction *) let inc_match = ref true +let exited = ref false let include_match v = let truth = pyobject_istrue (pytuple_getitem (v, 1)) in @@ -98,6 +123,10 @@ let include_match v = inc_match := truth != 0; _pycocci_none () +let sp_exit _ = + exited := true; + _pycocci_none () + let build_method (mname, camlfunc, args) pymodule classx classdict = let cmx = pymethod_new(pywrap_closure camlfunc, args, classx) in let v = pydict_setitemstring(classdict, mname, cmx) in @@ -162,7 +191,8 @@ let pycocci_init () = coccinelle_module := pymodule_new "coccinelle"; let mx = !coccinelle_module in let (cd, cx) = build_class "Cocci" (!Flag.pyoutput) - [("include_match", include_match, (pynull())); + [("exit", sp_exit, (pynull())); + ("include_match", include_match, (pynull())); ("has_env_binding", has_environment_binding, (pynull()))] mx in pyoutputinstance := cx; pyoutputdict := cd; @@ -182,12 +212,13 @@ let added_variables = ref [] let build_classes env = let _ = pycocci_init () in inc_match := true; + exited := false; the_environment := env; let mx = !coccinelle_module in let dict = pymodule_getdict mx in List.iter (function - "include_match" | "has_env_binding" -> () + "include_match" | "has_env_binding" | "exit" -> () | name -> let v = pydict_delitemstring(dict,name) in check_int_return_value v) @@ -270,7 +301,9 @@ let construct_script_variables mv = List.iter (function (_,py) -> let vl = - let str = pystring_fromstring "initial value" in + let str = + pystring_fromstring + "initial value: consider using coccinelle.varname" in pycocci_instantiate_class "coccilib.elems.Identifier" (pytuple_fromsingle (str)) in let _ = build_variable py vl in