comparison scripts/dgen.rb @ 9:3592b41928fe

Fixed: bindings were not generated
author Jacob Carlborg <doob@me.com>
date Thu, 09 Jul 2009 23:21:08 +0200
parents 2c0fd7bb4de6
children 27e00625790b
comparison
equal deleted inserted replaced
8:2c0fd7bb4de6 9:3592b41928fe
307 307
308 File.open(file_path, "w") do |file| 308 File.open(file_path, "w") do |file|
309 file << copyright 309 file << copyright
310 file << "module #{mod};" 310 file << "module #{mod};"
311 file << header.imports 311 file << header.imports
312 file << "\n" unless @d_constants.length > 0 || @function_wrappers.length > 0 312 file << "\n" if header.d_constants.nil? || header.function_wrappers.nil?
313 file << "import bindings = #{mod}_bindings".nl.nl(false) if @d_constants.length > 0 || @function_wrappers.length > 0 313 file << "import bindings = #{mod}_bindings".nl.nl(false) unless header.d_constants.nil? || header.function_wrappers.nil?
314 file << header.defines 314 file << header.defines
315 file << header.typedefs 315 file << header.typedefs
316 file << header.cftypes 316 file << header.cftypes
317 file << header.function_pointers 317 file << header.function_pointers
318 file << header.c_constants 318 file << header.c_constants
357 file << mod 357 file << mod
358 file << "_bindings;" 358 file << "_bindings;"
359 file << header.imports.nl(false) 359 file << header.imports.nl(false)
360 file << header.constants 360 file << header.constants
361 file << header.functions 361 file << header.functions
362 end if @d_constants.length > 0 || @function_wrappers.length > 0 362 end unless header.d_constants.nil? || header.function_wrappers.nil?
363 end 363 end
364 end 364 end
365 365
366 package_path = "#{@out_dir}/#{@package}" 366 package_path = "#{@out_dir}/#{@package}"
367 FileUtils.mkdir_p(package_path) unless File.exist?(package_path) 367 FileUtils.mkdir_p(package_path) unless File.exist?(package_path)
374 374
375 File.open(header_path, "w") do |file| 375 File.open(header_path, "w") do |file|
376 file << copyright 376 file << copyright
377 file << "module #{mod};" 377 file << "module #{mod};"
378 file << header.imports 378 file << header.imports
379 file << "\n" unless @d_constants.length > 0 || @function_wrappers.length > 0 379 file << "\n" if header.d_constants.nil? || header.function_wrappers.nil?
380 file << "import bindings = #{mod}_bindings".nl.nl(false) if @d_constants.length > 0 || @function_wrappers.length > 0 380 file << "import bindings = #{mod}_bindings".nl.nl(false) unless header.d_constants.nil? || header.function_wrappers.nil?
381 file << header.defines 381 file << header.defines
382 file << header.typedefs 382 file << header.typedefs
383 file << header.cftypes 383 file << header.cftypes
384 file << header.function_pointers 384 file << header.function_pointers
385 file << header.c_constants 385 file << header.c_constants
424 file << mod 424 file << mod
425 file << "_bindings;" 425 file << "_bindings;"
426 file << header.imports.nl(false) 426 file << header.imports.nl(false)
427 file << header.constants 427 file << header.constants
428 file << header.functions 428 file << header.functions
429 end if @d_constants.length > 0 || @function_wrappers.length > 0 429 end unless header.d_constants.nil? || header.function_wrappers.nil?
430 end 430 end
431 431
432 @classes.each do |clazz, value| 432 @classes.each do |clazz, value|
433 class_path = "#{package_path}/#{get_identifier(clazz)}.d" 433 class_path = "#{package_path}/#{get_identifier(clazz)}.d"
434 434
1067 static = method.classMethod == "true" 1067 static = method.classMethod == "true"
1068 1068
1069 index = 0 1069 index = 0
1070 declaration = build_function(method, true, static)[0 ... -2].indent.nl(false) 1070 declaration = build_function(method, true, static)[0 ... -2].indent.nl(false)
1071 index = declaration.index_of(" ", index) 1071 index = declaration.index_of(" ", index)
1072 index = declaration.index_of(" ", index + 1) if static
1072 str << ((declaration[0 .. index] + get_method_name(method["selector"]) + declaration[index .. -1]).gsub(/ +/, " "))[0 .. -2] 1073 str << ((declaration[0 .. index] + get_method_name(method["selector"]) + declaration[index .. -1]).gsub(/ +/, " "))[0 .. -2]
1073 str << ";\n" 1074 str << ";\n"
1074 end 1075 end
1075 1076
1076 str.string 1077 str.string
1194 # get_type("I", "Q", "NSUInteger") #=> NSUInteger 1195 # get_type("I", "Q", "NSUInteger") #=> NSUInteger
1195 # get_type("I", "I", "unsigned int") #=> uint 1196 # get_type("I", "I", "unsigned int") #=> uint
1196 # 1197 #
1197 def get_type (type, type64, declared_type) 1198 def get_type (type, type64, declared_type)
1198 declared_type = "I" + $1 if declared_type =~ /\w+\s*<(.+)>/ 1199 declared_type = "I" + $1 if declared_type =~ /\w+\s*<(.+)>/
1200 declared_type.gsub!(/\(|\)/, "")
1199 1201
1200 return get_identifier(declared_type) if type.nil? && type64.nil? 1202 return get_identifier(declared_type) if type.nil? && type64.nil?
1201 1203
1202 t = check_declared_type(declared_type) 1204 t = check_declared_type(declared_type)
1203 return t unless t.nil? 1205 return t unless t.nil?