~ubuntu-branches/ubuntu/maverick/coccinelle/maverick

« back to all changes in this revision

Viewing changes to debian/patches/fixes/system-pycaml.diff

  • Committer: Bazaar Package Importer
  • Author(s): Daniel T Chen
  • Date: 2009-09-08 13:06:20 UTC
  • mfrom: (7.1.2 sid)
  • Revision ID: james.westby@ubuntu.com-20090908130620-s33aehu14xddef4u
Tags: 0.1.10.deb-1ubuntu1
* Merge from Debian unstable, remaining changes:
  - debian/control: build-depend on python2.6-dev,
    set XB-Python-Version to 2.6

Show diffs side-by-side

added added

removed removed

Lines of Context:
8
8
---
9
9
 Makefile              |   17 ++++++++---------
10
10
 python/Makefile       |    4 ++--
11
 
 python/yes_pycocci.ml |   24 ++++++++++++++++++++----
12
 
 3 files changed, 30 insertions(+), 15 deletions(-)
 
11
 python/yes_pycocci.ml |    2 +-
 
12
 3 files changed, 11 insertions(+), 12 deletions(-)
13
13
 
14
14
diff --git a/Makefile b/Makefile
15
 
index 156318f..892ba07 100644
 
15
index 7d216f6..e76f965 100644
16
16
--- a/Makefile
17
17
+++ b/Makefile
18
18
@@ -34,11 +34,11 @@ TARGET=spatch
54
54
  engine extra python
55
55
 INCLUDEDIRS=commons commons/ocamlextra ocamlsexp \
56
56
  globals menhirlib $(PYDIR) ctl \
57
 
@@ -288,7 +288,6 @@ install-python:
 
57
@@ -289,7 +289,6 @@ install-python:
58
58
                $(DESTDIR)$(SHAREDIR)/python/coccilib/coccigui
59
59
        $(INSTALL_DATA) python/coccilib/coccigui/pygui.gladep \
60
60
                $(DESTDIR)$(SHAREDIR)/python/coccilib/coccigui
85
85
 ##############################################################################
86
86
 # Generic ocaml variables
87
87
diff --git a/python/yes_pycocci.ml b/python/yes_pycocci.ml
88
 
index 2ef2807..7949d91 100644
 
88
index 8de88e0..6662eb7 100644
89
89
--- a/python/yes_pycocci.ml
90
90
+++ b/python/yes_pycocci.ml
91
 
@@ -66,6 +66,11 @@ let load_module module_name =
92
 
 (* end python module handling part *)
93
 
 
94
 
 (* initialisation routines *)
95
 
+let _pycocci_setargs argv0 =
96
 
+  let argv = pysequence_list (pytuple_fromsingle (pystring_fromstring argv0)) in
97
 
+  let sys_mod = load_module "sys" in
98
 
+  pyobject_setattrstring (sys_mod, "argv", argv)
99
 
+
100
 
 let pycocci_init () =
101
 
   (* initialize *)
102
 
   if not !initialised then (
103
 
@@ -78,7 +83,7 @@ let pycocci_init () =
104
 
 
105
 
   (* set argv *)
106
 
   let argv0 = Printf.sprintf "%s%sspatch" (Sys.getcwd ()) (match Sys.os_type with "Win32" -> "\\" | _ -> "/") in
107
 
-  let _ = pycaml_setargs argv0 in
108
 
+  let _ = _pycocci_setargs argv0 in
109
 
 
110
 
   coccinelle_module := (pymodule_new "coccinelle");
111
 
   module_map := StringMap.add "coccinelle" !coccinelle_module !module_map;
112
 
@@ -107,7 +112,7 @@ let pycocci_get_class_type fqn =
 
91
@@ -103,7 +103,7 @@ let pycocci_get_class_type fqn =
113
92
 
114
93
 let pycocci_instantiate_class fqn args =
115
94
   let class_type = pycocci_get_class_type fqn in
118
97
   check_return_value obj;
119
98
   obj
120
99
 
121
 
@@ -137,13 +142,21 @@ let build_class cname parent methods pymodule =
122
 
   check_int_return_value v;
123
 
   (cd, cx)
124
 
 
125
 
+let _pycocci_true () =
126
 
+  let builtins = pyeval_getbuiltins () in
127
 
+  pyobject_getitem (builtins, pystring_fromstring "True")
128
 
+
129
 
+let _pycocci_false () =
130
 
+  let builtins = pyeval_getbuiltins () in
131
 
+  pyobject_getitem (builtins, pystring_fromstring "False")
132
 
+
133
 
 let has_environment_binding env name =
134
 
   let a = pytuple_toarray name in
135
 
   let (rule, name) = (Array.get a 1, Array.get a 2) in
136
 
   let orule = pystring_asstring rule in
137
 
   let oname = pystring_asstring name in
138
 
   let e = List.exists (function (x,y) -> orule =$= x && oname =$= y) env in
139
 
-  if e then pytrue () else pyfalse ()
140
 
+  if e then _pycocci_true () else _pycocci_false ()
141
 
 
142
 
 let pyoutputinstance = ref (pynone ())
143
 
 let pyoutputdict = ref (pynone ())
144
 
@@ -178,6 +191,9 @@ let contains_binding e (_,(r,m)) =
145
 
     let _ = List.find (function ((re, rm), _) -> r =$= re && m =$= rm) e in true
146
 
   with Not_found -> false
147
 
 
148
 
+let _pycocci_tuple6 (a,b,c,d,e,f) =
149
 
+  pytuple_fromarray ([|a; b; c; d; e; f|])
150
 
+
151
 
 let construct_variables mv e =
152
 
   let find_binding (r,m) =
153
 
     try
154
 
@@ -211,7 +227,7 @@ let construct_variables mv e =
155
 
        let locs =
156
 
         List.map
157
 
           (function (fname,current_element,(line,col),(line_end,col_end)) ->
158
 
-               pycocci_instantiate_class "coccilib.elems.Location" (pytuple6
159
 
+               pycocci_instantiate_class "coccilib.elems.Location" (_pycocci_tuple6
160
 
                (pystring_fromstring fname,pystring_fromstring current_element,
161
 
                pystring_fromstring (Printf.sprintf "%d" line),
162
 
                pystring_fromstring (Printf.sprintf "%d" col),
163
100
-- 
164
 
tg: (3dd4272..) fixes/system-pycaml (depends on: upstream)
 
101
tg: (9b26161..) fixes/system-pycaml (depends on: upstream)