added some extra interfaces for heap support, and the code structures defined
in the IDL files necessitated some refinements to the PIDL parser and code generator
This commit is contained in:
@@ -4,7 +4,7 @@
|
||||
|
||||
package Parse::Pidl::COMROGUE::Header;
|
||||
|
||||
use Parse::Pidl::Typelist qw(mapTypeName maybeMapScalarType is_struct);
|
||||
use Parse::Pidl::Typelist qw(mapTypeName maybeMapScalarType is_struct is_enum);
|
||||
use Parse::Pidl::Util qw(has_property is_constant);
|
||||
|
||||
use vars qw($VERSION);
|
||||
@@ -140,7 +140,13 @@ sub ParseElement($$)
|
||||
my $element = shift;
|
||||
my $res = "";
|
||||
|
||||
$res .= $prefix . maybeMapScalarType($element->{TYPE}) . " " . $element->{NAME};
|
||||
$res .= $prefix . maybeMapScalarType($element->{TYPE}) . " ";
|
||||
my $l = $element->{POINTERS};
|
||||
$l-- if (Parse::Pidl::Typelist::scalar_is_reference($element->{TYPE}));
|
||||
foreach my $i (1..$l) {
|
||||
$res .= "*";
|
||||
}
|
||||
$res .= $element->{NAME};
|
||||
if (defined($element->{ARRAY_LEN})) {
|
||||
foreach my $l (@{$element->{ARRAY_LEN}}) {
|
||||
$res .= "[" . $l . "]";
|
||||
@@ -166,6 +172,15 @@ sub ParseTypedef($)
|
||||
$res .= ParseElement("\t", $elt);
|
||||
}
|
||||
$res .= "} ";
|
||||
} elsif (is_enum($def->{DATA})) {
|
||||
$res .= mapTypeName($def->{DATA}) . " {";
|
||||
my $first = 1;
|
||||
foreach my $elt (@{$def->{DATA}->{ELEMENTS}}) {
|
||||
$res .= "," if $first == 0;
|
||||
$first = 0;
|
||||
$res .= "\n\t" . $elt;
|
||||
}
|
||||
$res .= "\n} ";
|
||||
} else {
|
||||
$res .= mapTypeName($def->{DATA}) . " ";
|
||||
}
|
||||
@@ -208,8 +223,12 @@ sub ParseInterface($)
|
||||
$res .= " *---------------------------------------------------------------\n";
|
||||
$res .= " */\n\n";
|
||||
|
||||
foreach $d (@{$if->{DATA}}) {
|
||||
$res .= stripquotes($d->{DATA}) . "\n" if ($d->{TYPE} eq "CPP_QUOTE");
|
||||
$res .= ParseTypedef($d) if ($d->{TYPE} eq "TYPEDEF");
|
||||
}
|
||||
|
||||
$res .= MakeGUIDDef("IID", $if->{NAME}, $if->{PROPERTIES}->{uuid});
|
||||
|
||||
$res .= MethodsDefinition($if);
|
||||
|
||||
if (defined($if->{BASE})) {
|
||||
@@ -220,11 +239,6 @@ sub ParseInterface($)
|
||||
$res .= "\tMETHODS_" . $if->{NAME} . "\n";
|
||||
$res .= "END_INTERFACE(" . $if->{NAME} . ")\n\n";
|
||||
|
||||
foreach $d (@{$if->{DATA}}) {
|
||||
$res .= stripquotes($d->{DATA}) . "\n" if ($d->{TYPE} eq "CPP_QUOTE");
|
||||
$res .= ParseTypedef($d) if ($d->{TYPE} eq "TYPEDEF");
|
||||
}
|
||||
|
||||
$res .= "\n#ifdef CINTERFACE\n\n";
|
||||
|
||||
foreach $d (@{$if->{DATA}}) {
|
||||
@@ -277,6 +291,19 @@ sub Parse($$$)
|
||||
"#ifndef __ASM__\n\n";
|
||||
my $want_macro_headers = 1;
|
||||
|
||||
foreach (@{$idl})
|
||||
{
|
||||
next unless ($_->{TYPE} eq "INTERFACE");
|
||||
next unless (has_property($_, "object"));
|
||||
if ($want_macro_headers) {
|
||||
$res .= "#include <comrogue/object_definition_macros.h>\n\n";
|
||||
$want_macro_headers = 0;
|
||||
}
|
||||
$res .= "DECLARE_INTERFACE(" . $_->{NAME} . ")\n";
|
||||
}
|
||||
|
||||
$res .= "\n";
|
||||
|
||||
foreach (@{$idl})
|
||||
{
|
||||
if ($_->{TYPE} eq "CPP_QUOTE") {
|
||||
|
||||
@@ -8,8 +8,8 @@ package Parse::Pidl::Typelist;
|
||||
require Exporter;
|
||||
@ISA = qw(Exporter);
|
||||
@EXPORT_OK = qw(hasType getType resolveType mapTypeName scalar_is_reference expandAlias
|
||||
mapScalarType maybeMapScalarType addType typeIs is_signed is_scalar is_struct enum_type_fn
|
||||
bitmap_type_fn mapType typeHasBody is_fixed_size_scalar
|
||||
mapScalarType maybeMapScalarType addType typeIs is_signed is_scalar is_struct is_enum
|
||||
enum_type_fn bitmap_type_fn mapType typeHasBody is_fixed_size_scalar
|
||||
);
|
||||
use vars qw($VERSION);
|
||||
$VERSION = '0.01';
|
||||
@@ -34,6 +34,7 @@ my @non_fixed_size_scalars = (
|
||||
my %scalars = (
|
||||
"void" => "void",
|
||||
"char" => "char",
|
||||
"wchar_t" => "wchar_t",
|
||||
"int8" => "int8_t",
|
||||
"uint8" => "uint8_t",
|
||||
"int16" => "int16_t",
|
||||
@@ -215,6 +216,17 @@ sub is_struct($)
|
||||
return 0;
|
||||
}
|
||||
|
||||
sub is_enum($)
|
||||
{
|
||||
my $type = shift;
|
||||
return 1 if (ref($type) eq "HASH" and $type->{TYPE} eq "ENUM");
|
||||
if (my $dt = getType($type)) {
|
||||
return is_enum($dt->{DATA}) if ($dt->{TYPE} eq "TYPEDEF");
|
||||
return 1 if ($dt->{TYPE} eq "ENUM");
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
sub is_fixed_size_scalar($)
|
||||
{
|
||||
my $name = shift;
|
||||
|
||||
Reference in New Issue
Block a user