Method: Qt::Internal.makeMetaData

Defined in:
lib/Qt/qtruby4.rb

.makeMetaData(classname, classinfos, dbus, signals, slots) ⇒ Object



2927
2928
2929
2930
2931
2932
2933
2934
2935
2936
2937
2938
2939
2940
2941
2942
2943
2944
2945
2946
2947
2948
2949
2950
2951
2952
2953
2954
2955
2956
2957
2958
2959
2960
2961
2962
2963
2964
2965
2966
2967
2968
2969
2970
2971
2972
2973
2974
2975
2976
2977
2978
# File 'lib/Qt/qtruby4.rb', line 2927

def Internal.(classname, classinfos, dbus, signals, slots)
  # Each entry in 'stringdata' corresponds to a string in the
  # qt_meta_stringdata_<classname> structure.
  # 'pack_string' is used to convert 'stringdata' into the
  # binary sequence of null terminated strings for the metaObject
  stringdata = []
  pack_string = ""
  string_table = string_table_handler(stringdata, pack_string)

  # This is used to create the array of uints that make up the
  # qt_meta_data_<classname> structure in the metaObject
  data = [1,                 # revision
      string_table.call(classname),   # classname
      classinfos.length, classinfos.length > 0 ? 10 : 0,   # classinfo
      signals.length + slots.length,
      10 + (2*classinfos.length),   # methods
      0, 0,               # properties
      0, 0]              # enums/sets

  classinfos.each do |entry|
    data.push string_table.call(entry[0])    # key
    data.push string_table.call(entry[1])    # value
  end

  signals.each do |entry|
    data.push string_table.call(entry.full_name)        # signature
    data.push string_table.call(entry.full_name.delete("^,"))  # parameters
    data.push string_table.call(entry.reply_type)        # type, "" means void
    data.push string_table.call("")        # tag
    if dbus
      data.push MethodScriptable | MethodSignal | AccessPublic
    else
      data.push entry.access  # flags, always protected for now
    end
  end

  slots.each do |entry|
    data.push string_table.call(entry.full_name)        # signature
    data.push string_table.call(entry.full_name.delete("^,"))  # parameters
    data.push string_table.call(entry.reply_type)        # type, "" means void
    data.push string_table.call("")        # tag
    if dbus
      data.push MethodScriptable | MethodSlot | AccessPublic  # flags, always public for now
    else
      data.push entry.access    # flags, always public for now
    end
  end

  data.push 0    # eod

  return [stringdata.pack(pack_string), data]
end