Commits

raineszm  committed e9dcf72

Using the root FFI namespace in all cases to avoid name collisions

  • Participants
  • Parent commits a951b22

Comments (0)

Files changed (6)

File lib/rubypython/conversion.rb

   # Convert a Ruby Proc to a \Python Function. Returns an FFI::Pointer to a
   # PyCFunction.
   def self.rtopFunction(rObj)
-    proc = FFI::Function.new(:pointer, [:pointer, :pointer]) do |p_self, p_args|
+    proc = ::FFI::Function.new(:pointer, [:pointer, :pointer]) do |p_self, p_args|
       retval = rObj.call(*ptorTuple(p_args))
       pObject = retval.is_a?(RubyPython::RubyPyProxy) ? retval.pObject : RubyPython::PyObject.new(retval)
 
     end
 
     defn = RubyPython::Python::PyMethodDef.new
-    defn[:ml_name] = FFI::MemoryPointer.from_string("RubyPython::Proc::%s" % rObj.object_id)
+    defn[:ml_name] = ::FFI::MemoryPointer.from_string("RubyPython::Proc::%s" % rObj.object_id)
     defn[:ml_meth] = proc
     defn[:ml_flags] = RubyPython::Python::METH_VARARGS
     defn[:ml_doc] = nil
   # Convert an FFI::Pointer to a \Python String (PyStringObject) to a Ruby
   # String.
   def self.ptorString(pString)
-    strPtr  = FFI::MemoryPointer.new(:pointer)
-    sizePtr = FFI::MemoryPointer.new(:ssize_t)
+    strPtr  = ::FFI::MemoryPointer.new(:pointer)
+    sizePtr = ::FFI::MemoryPointer.new(:ssize_t)
 
     RubyPython::Python.PyString_AsStringAndSize(pString, strPtr, sizePtr)
 
-    size = case FFI.find_type(:ssize_t)
-           when FFI.find_type(:long)
+    size = case ::FFI.find_type(:ssize_t)
+           when ::FFI.find_type(:long)
              sizePtr.read_long
-           when FFI.find_type(:int)
+           when ::FFI.find_type(:int)
              sizePtr.read_int
-           when FFI.find_type(:long_long)
+           when ::FFI.find_type(:long_long)
              sizePtr.read_long_long
            else
              nil
   def self.ptorDict(pDict)
     rb_hash = {}
 
-    pos = FFI::MemoryPointer.new :ssize_t
+    pos = ::FFI::MemoryPointer.new :ssize_t
     pos.write_int 0
-    key = FFI::MemoryPointer.new :pointer
-    val = FFI::MemoryPointer.new :pointer
+    key = ::FFI::MemoryPointer.new :pointer
+    val = ::FFI::MemoryPointer.new :pointer
 
     while RubyPython::Python.PyDict_Next(pDict, pos, key, val) != 0
       pKey = key.read_pointer

File lib/rubypython/interpreter.rb

     rc, @version    = runpy "import sys; print '%d.%d' % sys.version_info[:2]"
     rc, @sys_prefix = runpy "import sys; print sys.prefix"
 
-    if FFI::Platform.windows?
+    if ::FFI::Platform.windows?
       flat_version  = @version.tr('.', '')
       basename      = File.basename(@python, '.exe')
 
   def find_python_lib
     # By default, the library name will be something like
     # libpython2.6.so, but that won't always work.
-    @libbase = "#{FFI::Platform::LIBPREFIX}#{@version_name}"
-    @libext = FFI::Platform::LIBSUFFIX
+    @libbase = "#{::FFI::Platform::LIBPREFIX}#{@version_name}"
+    @libext = ::FFI::Platform::LIBSUFFIX
     @libname = "#{@libbase}.#{@libext}"
 
     # We may need to look in multiple locations for Python, so let's
     # build this as an array.
     @locations = [ File.join(@sys_prefix, "lib", @libname) ]
 
-    if FFI::Platform.mac?
+    if ::FFI::Platform.mac?
       # On the Mac, let's add a special case that has even a different
       # @libname. This may not be fully useful on future versions of OS
       # X, but it should work on 10.5 and 10.6. Even if it doesn't, the
       File.join(@sys_prefix, "lib", "#{@realname}", "config", @libname)
     end
 
-    if FFI::Platform.unix?
+    if ::FFI::Platform.unix?
       # On Unixes, let's look in some standard alternative places, too.
       # Just in case. Some Unixes don't include a .so symlink when they
       # should, so let's look for the base cases of .so.1 and .so.1.0, too.
       [ @libname, "#{@libname}.1", "#{@libname}.1.0" ].each do |name|
-        if FFI::Platform::ARCH != 'i386'
+        if ::FFI::Platform::ARCH != 'i386'
           @locations << File.join("/opt/local/lib64", name)
           @locations << File.join("/opt/lib64", name)
           @locations << File.join("/usr/local/lib64", name)
       end
     end
 
-    if FFI::Platform.windows?
+    if ::FFI::Platform.windows?
       # On Windows, the appropriate DLL is usually be found in
       # %SYSTEMROOT%\system or %SYSTEMROOT%\system32; as a fallback we'll
       # use C:\Windows\system{,32} as well as the install directory and the
   # Run a Python command-line command.
   def runpy(command)
     i = @python || @python_exe || 'python'
-    if FFI::Platform.windows?
+    if ::FFI::Platform.windows?
       o = %x(#{i} -c "#{command}" 2> NUL:)
     else
       o = %x(#{i} -c "#{command}" 2> /dev/null)
 
   def debug_s(format = nil)
     system = ""
-    system << "windows " if FFI::Platform.windows?
-    system << "mac " if FFI::Platform.mac?
-    system << "unix " if FFI::Platform.unix?
+    system << "windows " if ::FFI::Platform.windows?
+    system << "mac " if ::FFI::Platform.mac?
+    system << "unix " if ::FFI::Platform.unix?
     system << "unknown " if system.empty?
 
     case format

File lib/rubypython/pygenerator.rb

           fib = Fiber.new do
             yield *args
             Python.PyErr_SetNone(Python.PyExc_StopIteration)
-            FFI::Pointer::NULL
+            ::FFI::Pointer::NULL
           end
           generator_type.__call__(lambda { fib.resume })
         end

File lib/rubypython/pyobject.rb

   # and wrapped in an AutoPyPointer. The conversion is done with
   # +RubyPython::Conversion.rtopObject+.
   def initialize(rObject)
-    if rObject.kind_of? FFI::AutoPointer
-      new_pointer = FFI::Pointer.new rObject
+    if rObject.kind_of? ::FFI::AutoPointer
+      new_pointer = ::FFI::Pointer.new rObject
       @pointer = AutoPyPointer.new new_pointer
       xIncref
-    elsif rObject.kind_of? FFI::Pointer
+    elsif rObject.kind_of? ::FFI::Pointer
       @pointer = AutoPyPointer.new rObject
     else
       @pointer = AutoPyPointer.new RubyPython::Conversion.rtopObject(rObject)

File lib/rubypython/python.rb

         undef :infect!
       end
 
-      mod.extend FFI::Library
+      mod.extend ::FFI::Library
       # FFI::DynamicLibrary::RTLD_LAZY | FFI::DynamicLibrary::RTLD_GLOBAL
       mod.ffi_lib_flags :lazy, :global
       mod.ffi_lib self.library
       # This class is a little bit of a hack to extract the address of
       # global structs. If someone knows a better way please let me know.
       mod.module_eval do
-        self.const_set :DummyStruct, Class.new(FFI::Struct)
+        self.const_set :DummyStruct, Class.new(::FFI::Struct)
         self::DummyStruct.layout :dummy_var, :int
 
         self.const_set(:PY_FILE_INPUT, 257)
         # struct. The C struct is actually much larger, but since we only access
         # the first two data members via FFI and always deal with struct
         # pointers there is no need to mess around with the rest of the object.
-        self.const_set :PyObjectStruct, Class.new(FFI::Struct)
+        self.const_set :PyObjectStruct, Class.new(::FFI::Struct)
         self::PyObjectStruct.layout :ob_refcnt, :ssize_t,
           :ob_type, :pointer
 
         # This struct is used when defining Python methods.
-        self.const_set :PyMethodDef, Class.new(FFI::Struct)
+        self.const_set :PyMethodDef, Class.new(::FFI::Struct)
         self::PyMethodDef.layout :ml_name, :pointer,
           :ml_meth, :PyCFunction,
           :ml_flags, :int,

File lib/rubypython/pythonerror.rb

   # with three PyObject instances, representing the Type, the Value, and the
   # stack trace of the Python error.
   def self.fetch
-    typePointer = FFI::MemoryPointer.new :pointer
-    valuePointer = FFI::MemoryPointer.new :pointer
-    tracebackPointer = FFI::MemoryPointer.new :pointer
+    typePointer = ::FFI::MemoryPointer.new :pointer
+    valuePointer = ::FFI::MemoryPointer.new :pointer
+    tracebackPointer = ::FFI::MemoryPointer.new :pointer
 
     RubyPython::Python.PyErr_Fetch typePointer, valuePointer, tracebackPointer