From c7cd32c902bf055dd5dcae8669fbf3580d744277 Mon Sep 17 00:00:00 2001
From: Andreas Kloeckner <inform@tiker.net>
Date: Wed, 26 May 2010 21:29:44 -0400
Subject: [PATCH] Whitespace and Vim sectioning.

---
 src/wrapper/wrap_cl.cpp |  87 +++++++++++++++++++++++-----------
 src/wrapper/wrap_cl.hpp | 101 ++++++++++++++++++----------------------
 2 files changed, 105 insertions(+), 83 deletions(-)

diff --git a/src/wrapper/wrap_cl.cpp b/src/wrapper/wrap_cl.cpp
index a9d948b3..250de49b 100644
--- a/src/wrapper/wrap_cl.cpp
+++ b/src/wrapper/wrap_cl.cpp
@@ -34,7 +34,7 @@ namespace
 
 
 
-  // 'fake' constant scopes
+  // {{{ 'fake' constant scopes
   class platform_info { };
   class device_type { };
   class device_info { };
@@ -68,6 +68,7 @@ namespace
 
   class gl_object_type { };
   class gl_texture_info { };
+  // }}}
 }
 
 
@@ -75,6 +76,7 @@ namespace
 
 BOOST_PYTHON_MODULE(_cl)
 {
+  // {{{ exceptions
 #define DECLARE_EXC(NAME, BASE) \
   CL##NAME = py::handle<>(PyErr_NewException("pyopencl." #NAME, BASE, NULL)); \
   py::scope().attr(#NAME) = CL##NAME;
@@ -90,7 +92,9 @@ BOOST_PYTHON_MODULE(_cl)
 
     py::register_exception_translator<error>(translate_cl_error);
   }
+  // }}}
 
+  // {{{ constants
 #define ADD_ATTR(PREFIX, NAME) \
   cls.attr(#NAME) = CL_##PREFIX##NAME
 
@@ -409,6 +413,9 @@ BOOST_PYTHON_MODULE(_cl)
     ADD_ATTR(PROFILING_COMMAND_, END);
   }
 
+  // }}}
+
+  // {{{ platform
   DEF_SIMPLE_FUNCTION(get_platforms);
 
   {
@@ -423,6 +430,9 @@ BOOST_PYTHON_MODULE(_cl)
       ;
   }
 
+  // }}}
+
+  // {{{ device
   {
     typedef device cls;
     py::class_<cls, boost::noncopyable>("Device", py::no_init)
@@ -433,6 +443,10 @@ BOOST_PYTHON_MODULE(_cl)
       ;
   }
 
+  // }}}
+
+  // {{{ context
+
   {
     typedef context cls;
     py::class_<cls, boost::noncopyable>("Context", py::no_init)
@@ -449,10 +463,13 @@ BOOST_PYTHON_MODULE(_cl)
       ;
   }
 
+  // }}}
+
+  // {{{ command queue
   {
     typedef command_queue cls;
-    py::class_<cls, boost::noncopyable>("CommandQueue", 
-        py::init<const context &, 
+    py::class_<cls, boost::noncopyable>("CommandQueue",
+        py::init<const context &,
           const device *, cl_command_queue_properties>
         ((py::arg("context"), py::arg("device")=py::object(), py::arg("properties")=0)))
       .DEF_SIMPLE_METHOD(get_info)
@@ -464,6 +481,10 @@ BOOST_PYTHON_MODULE(_cl)
       .def(py::self != py::self)
       ;
   }
+
+  // }}}
+
+  // {{{ events/synchronization
   {
     typedef event cls;
     py::class_<cls, boost::noncopyable>("Event", py::no_init)
@@ -480,8 +501,9 @@ BOOST_PYTHON_MODULE(_cl)
       py::return_value_policy<py::manage_new_object>());
   DEF_SIMPLE_FUNCTION(enqueue_wait_for_events);
   DEF_SIMPLE_FUNCTION(enqueue_barrier);
+  // }}}
 
-  // memory_object ------------------------------------------------------------
+  // {{{ memory_object
   {
     typedef memory_object cls;
     py::class_<cls, boost::noncopyable>("MemoryObject", py::no_init)
@@ -508,7 +530,7 @@ BOOST_PYTHON_MODULE(_cl)
   }
 
   py::def("enqueue_read_buffer", enqueue_read_buffer,
-      (py::args("queue", "mem", "hostbuf"), 
+      (py::args("queue", "mem", "hostbuf"),
        py::arg("device_offset")=0,
        py::arg("wait_for")=py::object(),
        py::arg("is_blocking")=false,
@@ -516,7 +538,7 @@ BOOST_PYTHON_MODULE(_cl)
        ),
       py::return_value_policy<py::manage_new_object>());
   py::def("enqueue_write_buffer", enqueue_write_buffer,
-      (py::args("queue", "mem", "hostbuf"), 
+      (py::args("queue", "mem", "hostbuf"),
        py::arg("device_offset")=0,
        py::arg("wait_for")=py::object(),
        py::arg("is_blocking")=false,
@@ -524,23 +546,23 @@ BOOST_PYTHON_MODULE(_cl)
        ),
       py::return_value_policy<py::manage_new_object>());
   py::def("enqueue_copy_buffer", enqueue_copy_buffer,
-      (py::args("queue", "src", "dst"), 
+      (py::args("queue", "src", "dst"),
        py::arg("byte_count")=0,
        py::arg("src_offset")=0,
        py::arg("dst_offset")=0,
        py::arg("wait_for")=py::object()
        ),
       py::return_value_policy<py::manage_new_object>());
+  // }}}
 
-
-  // image --------------------------------------------------------------------
+  // {{{ image
   {
     typedef image cls;
     py::class_<cls, py::bases<memory_object>, boost::noncopyable>(
         "Image", py::no_init)
       .def("__init__", make_constructor(create_image,
             py::default_call_policies(),
-            (py::args("context", "flags", "format"), 
+            (py::args("context", "flags", "format"),
              py::arg("shape")=py::object(),
              py::arg("pitches")=py::object(),
              py::arg("hostbuf")=py::object(),
@@ -565,7 +587,7 @@ BOOST_PYTHON_MODULE(_cl)
   DEF_SIMPLE_FUNCTION(get_supported_image_formats);
 
   py::def("enqueue_read_image", enqueue_read_image,
-      (py::args("queue", "mem", "origin", "region", "hostbuf"), 
+      (py::args("queue", "mem", "origin", "region", "hostbuf"),
        py::arg("row_pitch")=0,
        py::arg("slice_pitch")=0,
        py::arg("wait_for")=py::object(),
@@ -574,7 +596,7 @@ BOOST_PYTHON_MODULE(_cl)
        ),
       py::return_value_policy<py::manage_new_object>());
   py::def("enqueue_write_image", enqueue_write_image,
-      (py::args("queue", "mem", "origin", "region", "hostbuf"), 
+      (py::args("queue", "mem", "origin", "region", "hostbuf"),
        py::arg("row_pitch")=0,
        py::arg("slice_pitch")=0,
        py::arg("wait_for")=py::object(),
@@ -584,19 +606,21 @@ BOOST_PYTHON_MODULE(_cl)
       py::return_value_policy<py::manage_new_object>());
 
   py::def("enqueue_copy_image", enqueue_copy_image,
-      (py::args("queue", "src", "dest", "src_origin", "dest_origin", "region"), 
+      (py::args("queue", "src", "dest", "src_origin", "dest_origin", "region"),
        py::arg("wait_for")=py::object()),
       py::return_value_policy<py::manage_new_object>());
   py::def("enqueue_copy_image_to_buffer", enqueue_copy_image_to_buffer,
-      (py::args("queue", "src", "dest", "origin", "region", "offset"), 
+      (py::args("queue", "src", "dest", "origin", "region", "offset"),
        py::arg("wait_for")=py::object()),
       py::return_value_policy<py::manage_new_object>());
   py::def("enqueue_copy_buffer_to_image", enqueue_copy_image_to_buffer,
-      (py::args("queue", "src", "dest", "offset", "origin", "region"), 
+      (py::args("queue", "src", "dest", "offset", "origin", "region"),
        py::arg("wait_for")=py::object()),
       py::return_value_policy<py::manage_new_object>());
 
-  // memory_map ---------------------------------------------------------------
+  // }}}
+
+  // {{{ memory_map
   {
     typedef memory_map cls;
     py::class_<cls, boost::noncopyable>("MemoryMap", py::no_init)
@@ -607,23 +631,24 @@ BOOST_PYTHON_MODULE(_cl)
   }
 
   py::def("enqueue_map_buffer", enqueue_map_buffer,
-      (py::args("queue", "buf", "flags", 
-                "offset", 
-                "shape", "dtype", "order"), 
+      (py::args("queue", "buf", "flags",
+                "offset",
+                "shape", "dtype", "order"),
        py::arg("wait_for")=py::object(),
        py::arg("is_blocking")=false));
   py::def("enqueue_map_image", enqueue_map_image,
-      (py::args("queue", "img", "flags", 
+      (py::args("queue", "img", "flags",
                 "origin", "region",
-                "shape", "dtype", "order"), 
+                "shape", "dtype", "order"),
        py::arg("wait_for")=py::object(),
        py::arg("is_blocking")=false));
 
+  // }}}
 
-  // sampler ------------------------------------------------------------------
+  // {{{ sampler
   {
     typedef sampler cls;
-    py::class_<cls, boost::noncopyable>("Sampler", 
+    py::class_<cls, boost::noncopyable>("Sampler",
         py::init<context const &, bool, cl_addressing_mode, cl_filter_mode>())
       .DEF_SIMPLE_METHOD(get_info)
       .add_property("obj_ptr", &cls::obj_ptr)
@@ -632,7 +657,9 @@ BOOST_PYTHON_MODULE(_cl)
       ;
   }
 
-  // program ------------------------------------------------------------------
+  // }}}
+
+  // {{{ program
   {
     typedef program cls;
     py::class_<cls, boost::noncopyable>("Program", py::no_init)
@@ -659,7 +686,7 @@ BOOST_PYTHON_MODULE(_cl)
 
   {
     typedef kernel cls;
-    py::class_<cls, boost::noncopyable>("Kernel", 
+    py::class_<cls, boost::noncopyable>("Kernel",
         py::init<const program &, std::string const &>())
       .DEF_SIMPLE_METHOD(get_info)
       .DEF_SIMPLE_METHOD(get_work_group_info)
@@ -672,7 +699,7 @@ BOOST_PYTHON_MODULE(_cl)
 
   {
     typedef local_memory cls;
-    py::class_<cls, boost::noncopyable>("LocalMemory", 
+    py::class_<cls, boost::noncopyable>("LocalMemory",
         py::init<size_t>(py::arg("size")))
       .add_property("size", &cls::size)
       ;
@@ -694,8 +721,9 @@ BOOST_PYTHON_MODULE(_cl)
       py::return_value_policy<py::manage_new_object>());
 
   // TODO: clEnqueueNativeKernel
+  // }}}
 
-  // GL interop ---------------------------------------------------------------
+  // {{{ GL interop
   DEF_SIMPLE_FUNCTION(have_gl);
 
 #ifdef HAVE_GL
@@ -741,7 +769,7 @@ BOOST_PYTHON_MODULE(_cl)
         "GLTexture", py::no_init)
       .def("__init__", make_constructor(create_from_gl_texture,
             py::default_call_policies(),
-            (py::args("context", "flags", 
+            (py::args("context", "flags",
                       "texture_target", "miplevel",
                       "texture", "dims"))))
       .def("get_gl_object_info", get_gl_object_info)
@@ -761,4 +789,7 @@ BOOST_PYTHON_MODULE(_cl)
       py::return_value_policy<py::manage_new_object>());
 
 #endif
+  // }}}
 }
+
+// vim: foldmethod=marker
diff --git a/src/wrapper/wrap_cl.hpp b/src/wrapper/wrap_cl.hpp
index 8fd478a8..d1111747 100644
--- a/src/wrapper/wrap_cl.hpp
+++ b/src/wrapper/wrap_cl.hpp
@@ -4,11 +4,7 @@
 
 
 
-// TODO: GL Interop
-
-
-
-
+// {{{ includes 
 #ifdef __APPLE__
 
 // Mac ------------------------------------------------------------------------
@@ -38,6 +34,8 @@
 #include "wrap_helpers.hpp"
 #include "numpy_init.hpp"
 
+// }}}
+
 
 
 
@@ -46,7 +44,7 @@
 
 
 
-// tools ----------------------------------------------------------------------
+// {{{ tools
 #if PY_VERSION_HEX >= 0x02050000
   typedef Py_ssize_t PYOPENCL_BUFFER_SIZE_T;
 #else
@@ -67,10 +65,9 @@
         EXTRA_MSG); \
   }
 
+// }}}
 
-
-
-// tracing and error reporting ------------------------------------------------
+// {{{ tracing and error reporting
 #ifdef PYOPENCL_TRACE
   #define PYOPENCL_PRINT_CALL_TRACE(NAME) \
     std::cerr << NAME << std::endl;
@@ -133,11 +130,9 @@
         << std::endl; \
   }
 
+// }}}
 
-
-
-
-// get_info helpers -----------------------------------------------------------
+// {{{ get_info helpers
 #define PYOPENCL_GET_OPAQUE_INFO(WHAT, FIRST_ARG, SECOND_ARG, CL_TYPE, TYPE) \
   { \
     CL_TYPE param_value; \
@@ -186,10 +181,9 @@
     return py::object(param_value); \
   }
 
+// }}}
 
-
-
-// event helpers --------------------------------------------------------------
+// {{{ event helpers --------------------------------------------------------------
 #define PYOPENCL_PARSE_WAIT_FOR \
     cl_uint num_events_in_wait_list = 0; \
     std::vector<cl_event> event_wait_list; \
@@ -213,21 +207,22 @@
       throw; \
     }
 
+// }}}
 
-
-
-// equality testing -----------------------------------------------------------
+// {{{ equality testing
 #define PYOPENCL_EQUALITY_TESTS(cls) \
     bool operator==(cls const &other) const \
     { return data() == other.data(); } \
     bool operator!=(cls const &other) const \
     { return data() != other.data(); }
 
+// }}}
 
 
 
 namespace pyopencl
 {
+  // {{{ error
   class error : public std::runtime_error
   {
     private:
@@ -326,10 +321,9 @@ namespace pyopencl
       }
   };
 
+  // }}}
 
-
-
-  // platform -----------------------------------------------------------------
+  // {{{ platform
   class platform : boost::noncopyable
   {
     private:
@@ -397,10 +391,9 @@ namespace pyopencl
     return result;
   }
 
+  // }}}
 
-
-
-  // device -------------------------------------------------------------------
+  // {{{ device
   class device : boost::noncopyable
   {
     private:
@@ -526,10 +519,9 @@ namespace pyopencl
     return result;
   }
 
+  // }}}
 
-
-
-  // context ------------------------------------------------------------------
+  // {{{ context
   class context : public boost::noncopyable
   {
     private:
@@ -733,10 +725,9 @@ namespace pyopencl
     }
   }
 
+  // }}}
 
-
-
-  // command_queue ------------------------------------------------------------
+  // {{{ command_queue
   class command_queue
   {
     private:
@@ -837,10 +828,9 @@ namespace pyopencl
       { PYOPENCL_CALL_GUARDED_THREADED(clFinish, (m_queue)); }
   };
 
+  // }}}
 
-
-
-  // events -------------------------------------------------------------------
+  // {{{ event/synchronization
   class event : boost::noncopyable
   {
     private:
@@ -965,10 +955,9 @@ namespace pyopencl
     PYOPENCL_CALL_GUARDED(clEnqueueBarrier, (cq.data()));
   }
 
+  // }}}
 
-
-
-  // memory -------------------------------------------------------------------
+  // {{{ memory objects
   class memory_object : boost::noncopyable
   {
     private:
@@ -1241,10 +1230,9 @@ namespace pyopencl
     PYOPENCL_RETURN_NEW_EVENT(evt);
   }
 
+  // }}}
 
-
-
-  // images -------------------------------------------------------------------
+  // {{{ image
   class image : public memory_object
   {
     public:
@@ -1652,10 +1640,9 @@ namespace pyopencl
     PYOPENCL_RETURN_NEW_EVENT(evt);
   }
 
+  // }}}
 
-
-
-  // maps ---------------------------------------------------------------------
+  // {{{ maps
   class memory_map
   {
     private:
@@ -1814,10 +1801,9 @@ namespace pyopencl
         row_pitch, slice_pitch);
   }
 
+  // }}}
 
-
-
-  // sampler ------------------------------------------------------------------
+  // {{{ sampler
   class sampler : boost::noncopyable
   {
     private:
@@ -1881,10 +1867,9 @@ namespace pyopencl
       }
   };
 
+  // }}}
 
-
-
-  // program ------------------------------------------------------------------
+  // {{{ program
   class program : boost::noncopyable
   {
     private:
@@ -2116,10 +2101,9 @@ namespace pyopencl
     PYOPENCL_CALL_GUARDED(clUnloadCompiler, ());
   }
 
+  // }}}
 
-
-
-  // kernel -------------------------------------------------------------------
+  // {{{ kernel
   class local_memory
   {
     private:
@@ -2397,10 +2381,9 @@ namespace pyopencl
     PYOPENCL_RETURN_NEW_EVENT(evt);
   }
 
+  // }}}
 
-
-
-  // gl interop ---------------------------------------------------------------
+  // {{{ gl interop
   bool have_gl()
   {
 #ifdef HAVE_GL
@@ -2555,9 +2538,17 @@ namespace pyopencl
   WRAP_GL_ENQUEUE(acquire, Acquire);
   WRAP_GL_ENQUEUE(release, Release);
 #endif
+
+#if defined(cl_khr_gl_sharing) && (cl_khr_gl_sharing >= 1)
+  
+#endif
+
+  // }}}
 }
 
 
 
 
 #endif
+
+// vim: foldmethod=marker
-- 
GitLab