Enlightenment CVS committal

Author  : nerochiaro
Project : e17
Module  : proto

Dir     : e17/proto/ruby-efl/src


Modified Files:
        autobindings.rb 


Log Message:
- fixed bug where some type aliases were not defined.
- added ability to specify shared library name if different from module name.

===================================================================
RCS file: /cvs/e/e17/proto/ruby-efl/src/autobindings.rb,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -3 -r1.2 -r1.3
--- autobindings.rb     31 Aug 2006 21:55:04 -0000      1.2
+++ autobindings.rb     16 Sep 2006 12:09:37 -0000      1.3
@@ -112,18 +112,20 @@
         #~ puts "--------------------------------"
         tree = parser.parse(@data)
                         
-        @enums   = {}
-        @types   = []
-        @synon   = {}
-        @decls   = []
-        @structs = []
-        @protos  = {}
+        @enums      = {}
+        @types      = []
+        @decls      = []
+        @structs    = []
+        @protos     = {}
+        @synon      = {}
+        @all_synon  = {}
         
         tree.entities.each { |e|
             if !(C::Declaration === e)
                 puts "Skipping #{e.class.to_s}" if @debug
                 next
             end
+
             if e.typedef?
                 # check if this a typedef defining a pointer to function, 
which we will use for callbacks
                 fp = FunctionPtr.parse(e)
@@ -132,18 +134,18 @@
                 else
                     name = e.type.to_s
                     name << e.declarators[0].indirect_type.to_s if C::Pointer 
=== e.declarators[0].indirect_type
-                    @synon[name] = e.declarators[0].name
+                    @all_synon[name] = e.declarators[0].name
                 end 
             end
             
             # -- ENUMERATION
             if C::Enum === e.type then
-                
-                if e.type.name.nil?
+                                
+                if e.type.name.nil? # and !e.typedef? <<< todo: work more on 
this, see comment below too
                     puts "Skipping anonymous enum" if @debug
                     next
                 end
-                
+
                 next if e.type.members.nil? # the enum was already defined, 
this is just the typedef. todo: refactor into the typedef case
 
                 @types << 'enum ' + e.type.name
@@ -151,6 +153,7 @@
                 en = (@enums[e.type.name] = {})
 
                 e.type.members.each { |mem|
+                    
                     if mem.val.nil? then 
                         en[mem.name] = lv.to_i
                         lv += 1
@@ -174,38 +177,39 @@
                     end
                 }
         
-                # -- STRUCTURE (todo: not yet implemented)
-                elsif C::Struct === e.type then
-                    @types << 'struct ' + e.type.name
-                    @structs << [e.type.name, []]
-                    # st = (@structs[e.type.name] = [])
-                    # e.type.members.each { |mem|
-                    #  #todo: nested structures, initializers, etc
-                    #  st << [mem.declarators[0].name, 
mem.declarators[0].type.to_s]
-                    #}
-        
-                # -- FUNCTION DECLARATION
-                elsif e.declarators.length > 0 && C::Function === 
e.declarators[0].type
-                    functype = e.declarators[0].indirect_type
-                    decl = {}
-                    decl[:name] = e.declarators[0].name
-                    decl[:varargs] = e.declarators[0].type.var_args?
-                    decl[:full] = e.type.to_s + 
FunctionPtr.pointers(functype.type)
-                    decl[:full] << ' ' << decl[:name] << ' ('
-                    
-                    functype.params.each_with_index { |p,i|
+            # -- STRUCTURE (todo: not yet implemented)
+            elsif C::Struct === e.type then
+                @types << 'struct ' + e.type.name
+                @structs << [e.type.name, []]
+                @synon[e.type.to_s] = @all_synon[e.type.to_s]
+                # st = (@structs[e.type.name] = [])
+                # e.type.members.each { |mem|
+                #      #todo: nested structures, initializers, etc
+                #      st << [mem.declarators[0].name, 
mem.declarators[0].type.to_s]
+                #}
+    
+            # -- FUNCTION DECLARATION
+            elsif e.declarators.length > 0 && C::Function === 
e.declarators[0].type
+                functype = e.declarators[0].indirect_type
+                decl = {}
+                decl[:name] = e.declarators[0].name
+                decl[:varargs] = e.declarators[0].type.var_args?
+                decl[:full] = e.type.to_s + FunctionPtr.pointers(functype.type)
+                decl[:full] << ' ' << decl[:name] << ' ('
+                
+                functype.params.each_with_index { |p,i|
 
-                        if (C::CustomType === p.type && p.type.name == 
'va_list') then
-                            decl[:varargs] = true 
-                            next # we leave this last va_args param out since 
it's a placeholder for the actual varargs params anyway
-                        end
-            
-                        decl[:full] << ((i != 0) ? ', ' : '')
-                                            
-                        if C::Pointer === p.type && 
-                           (C::Int === p.type.direct_type || C::Float === 
p.type.direct_type) then
-                           decl[:full] << p.type.direct_type.to_s << ' ref'
-                        else
+                    if (C::CustomType === p.type && p.type.name == 'va_list') 
then
+                        decl[:varargs] = true 
+                        next # we leave this last va_args param out since it's 
a placeholder for the actual varargs params anyway
+                    end
+        
+                    decl[:full] << ((i != 0) ? ', ' : '')
+                                        
+                    if C::Pointer === p.type && 
+                       (C::Int === p.type.direct_type || C::Float === 
p.type.direct_type) then
+                       decl[:full] << p.type.direct_type.to_s << ' ref'
+                    else
                         fp = FunctionPtr.parse(p)
                         if fp.nil? then decl[:full] << p.type.to_s
                         else
@@ -224,6 +228,8 @@
                 decl[:full] << ")"
                 #breakpoint if functype.params.length > 0 unless 
functype.params.nil?
                 @decls << decl
+            else
+                @synon[e.type.to_s] = @all_synon[e.type.to_s]
             end
         }
         
@@ -329,6 +335,11 @@
             "\ttypealias '#{typ}', '#{talias}'" 
         }
 
+        internal_aliases = ""
+        @synon.each { |name, typ| 
+            internal_aliases << "\ttypealias '#{typ}', '#{name}'\n" 
+        }
+
         prototypes = ''
         @protos.each { |name, decl| 
             prototypes << "\tprototype '#{decl}'\n" unless ignored?(name)
@@ -395,6 +406,12 @@
                 handmade << IO.read(@handmade) 
         end
 
+        libname = @config[:library_name]
+        libname = "[EMAIL PROTECTED]:module_base_name].downcase}" if 
libname.nil?
+        
+        basename = @config[:root_call_prefix]
+        basename = @config[:module_base_name].downcase if basename.nil?
+
         dl = <<-END_DL_CODE
 #-------------------------------------------------------
 # This piece of wrapper code was automatically generated
@@ -405,8 +422,8 @@
 
 module [EMAIL PROTECTED]:module_base_name]}
        extend DL::Importable
-       dlload '[EMAIL PROTECTED]:module_base_name].downcase}.so'
-       BASE_NAME = '[EMAIL PROTECTED]:module_base_name].downcase}'
+       dlload '#{libname}.so'
+       BASE_NAME = '#{basename}'
 
     # Type aliases (from external types)
     #
@@ -420,6 +437,10 @@
     #
 #{struct_aliases}
 
+    # Type aliases (internal from the headers)
+    #
+#{internal_aliases}
+
     # Function declarations
     #
 #{declarations}
@@ -460,8 +481,8 @@
         o = ''
         o += title "[EMAIL PROTECTED] Types:" + @types.join(" | ") + "\n"
                         
-        o += title "[EMAIL PROTECTED] Type aliases:"
-        @synon.each { |syn,syn_to|
+        o += title "[EMAIL PROTECTED] Type aliases:"
+        @all_synon.each { |syn,syn_to|
             o += "#{syn} => #{syn_to}\n"
         }
         o += "\n"
@@ -517,7 +538,6 @@
             cfg = IO::read(config_file);
             cfg = eval(cfg);
             @config = cfg
-
             puts "Preprocessing the headers"
             run_preprocessor
             puts "Parsing the C code"



-------------------------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
enlightenment-cvs mailing list
enlightenment-cvs@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/enlightenment-cvs

Reply via email to