sub new($) {
my ($class) = @_;
- my $self = { res => "", res_hdr => "", tabs => "", constants => {},
+ my $self = { res => "", res_hdr => "", tabs => "",
+ constants => [], constants_uniq => {},
module_methods => [], module_objects => [], ready_types => [],
- module_imports => {}, type_imports => {},
+ module_imports => [], module_imports_uniq => {},
+ type_imports => [], type_imports_uniq => {},
patch_type_calls => [], prereadycode => [],
postreadycode => []};
bless($self, $class);
{
my ($self, $name, $type, $value) = @_;
- $self->{constants}->{$name} = [$type, $value];
+ unless (defined $self->{constants_uniq}->{$name}) {
+ my $h = {"key" => $name, "val" => [$type, $value]};
+ push @{$self->{constants}}, $h;
+ $self->{constants_uniq}->{$name} = $h;
+ }
}
sub EnumAndBitmapConsts($$$)
$var_name =~ s/\./_/g;
$var_name = "dep_$var_name";
- $self->{module_imports}->{$var_name} = $module_path;
-
+ unless (defined $self->{module_imports_uniq}->{$var_name}) {
+ my $h = { "key" => $var_name, "val" => $module_path};
+ push @{$self->{module_imports}}, $h;
+ $self->{module_imports_uniq}->{$var_name} = $h;
+ }
return $var_name;
}
my ($self, $module, $name) = @_;
$self->register_module_import($module);
- unless (defined($self->{type_imports}->{$name})) {
- $self->{type_imports}->{$name} = $module;
+ unless (defined $self->{type_imports_uniq}->{$name}) {
+ my $h = { "key" => $name, "val" => $module};
+ push @{$self->{type_imports}}, $h;
+ $self->{type_imports_uniq}->{$name} = $h;
}
return "$name\_Type";
}
$self->pidl("{");
$self->indent;
$self->pidl("PyObject *m;");
- foreach (keys %{$self->{module_imports}}) {
- $self->pidl("PyObject *$_;");
+ foreach my $h (@{$self->{module_imports}}) {
+ $self->pidl("PyObject *$h->{'key'};");
}
$self->pidl("");
- foreach (keys %{$self->{module_imports}}) {
- my $var_name = $_;
- my $module_path = $self->{module_imports}->{$var_name};
+ foreach my $h (@{$self->{module_imports}}) {
+ my $var_name = $h->{'key'};
+ my $module_path = $h->{'val'};
$self->pidl("$var_name = PyImport_ImportModule(\"$module_path\");");
$self->pidl("if ($var_name == NULL)");
$self->pidl("\treturn;");
$self->pidl("");
}
- foreach (keys %{$self->{type_imports}}) {
- my $type_var = "$_\_Type";
- my $module_path = $self->{type_imports}->{$_};
+ foreach my $h (@{$self->{type_imports}}) {
+ my $type_var = "$h->{'key'}\_Type";
+ my $module_path = $h->{'val'};
$self->pidl_hdr("static PyTypeObject *$type_var;\n");
- my $pretty_name = PrettifyTypeName($_, $module_path);
+ my $pretty_name = PrettifyTypeName($h->{'key'}, $module_path);
my $module_var = "dep_$module_path";
$module_var =~ s/\./_/g;
$self->pidl("$type_var = (PyTypeObject *)PyObject_GetAttrString($module_var, \"$pretty_name\");");
$self->pidl("if (m == NULL)");
$self->pidl("\treturn;");
$self->pidl("");
- foreach my $name (keys %{$self->{constants}}) {
+ foreach my $h (@{$self->{constants}}) {
+ my $name = $h->{'key'};
my $py_obj;
- my ($ctype, $cvar) = @{$self->{constants}->{$name}};
+ my ($ctype, $cvar) = @{$h->{'val'}};
if ($cvar =~ /^[0-9]+$/ or $cvar =~ /^0x[0-9a-fA-F]+$/) {
$py_obj = "PyInt_FromLong($cvar)";
} elsif ($cvar =~ /^".*"$/) {
$self->Interface($x);
$self->pidl_code("\n".DumpFunctionTable($x));
- foreach (keys %{$return_types{$x->{NAME}}}) {
+ foreach (sort(keys %{$return_types{$x->{NAME}}})) {
my ($type, $desc) = @{$return_types{$x->{NAME}}->{$_}};
my $dt = $self->find_type($type);
$dt or die("Unable to find information about return type `$type'");
$res = "\n/* Header field declarations */\n";
- foreach (keys %{$self->{conformance}->{header_fields}})
+ foreach (sort(keys %{$self->{conformance}->{header_fields}}))
{
$res .= "static gint $_ = -1;\n";
}
my ($self) = @_;
my $res = "\tstatic hf_register_info hf[] = {\n";
- foreach (values %{$self->{conformance}->{header_fields}})
+ foreach (sort {$a->{INDEX} cmp $b->{INDEX}} values %{$self->{conformance}->{header_fields}})
{
$res .= "\t{ &$_->{INDEX},
{ ".make_str($_->{NAME}).", ".make_str($_->{FILTER}).", $_->{FT_TYPE}, $_->{BASE_TYPE}, $_->{VALSSTRING}, $_->{MASK}, ".make_str_or_null($_->{BLURB}).", HFILL }},