Skip to content

Commit

Permalink
Merge pull request RemedyIT#291 from jwillemsen/jwi-bitmask
Browse files Browse the repository at this point in the history
Initial bitmask compilation test
  • Loading branch information
jwillemsen committed Jul 18, 2023
2 parents 86f36ca + f9ff083 commit c126dfb
Show file tree
Hide file tree
Showing 11 changed files with 225 additions and 0 deletions.
2 changes: 2 additions & 0 deletions bin/taox11_tests.lst
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,8 @@ tests/hello/run_cross_tao_server.pl:
tests/hello/run_test.pl:
tests/hello_regen/run_test.pl:
tests/idl_test/run_test.pl: !CORBA_E_MICRO
tests/idl4/bitmask/run_test.pl:
tests/idl4/bitmask/run_illegal_idl3_test.pl:
tests/idl4/explicit_ints/run_test.pl:
tests/idl4/explicit_ints/run_illegal_idl3_test.pl:
tests/idl4/map/run_test.pl:
Expand Down
4 changes: 4 additions & 0 deletions ridlbe/base/writerbase.rb
Original file line number Diff line number Diff line change
Expand Up @@ -530,6 +530,10 @@ def visit_enum(node); end

def visit_enumerator(node); end

def visit_bitmask(node); end

def visit_bitvalue(node); end

def visit_typedef(node); end
end # CodeWriterMethods
end # Base
Expand Down
19 changes: 19 additions & 0 deletions ridlbe/c++11/config/cxx_type.rb
Original file line number Diff line number Diff line change
Expand Up @@ -841,6 +841,25 @@ def is_pod?
end
end

class BitMask
include IdlType_Mixin
def cxx_type(scope = nil)
(scope && (scope == node || scope == node.enclosure)) ? node.cxxname : ('::' + node.scoped_cxxname)
end

def proxy_cxxtype(scope = nil)
(scope && (scope == node || scope == node.enclosure)) ? node.proxy_cxxname : ('::' + node.scoped_proxy_cxxname)
end

def value_to_s(v, scope = nil)
((scope && (scope == node.enclosure)) ? node.cxxname : ('::' + node.scoped_cxxname)) + '::' + node.bitvalues[v].cxxname
end

def is_pod?
true
end
end

class Fixed
def cxx_type(_scope = nil)
digits.nil? ? 'TAOX11_NAMESPACE::IDL::Fixed' : "TAOX11_NAMESPACE::IDL::Fixed<#{digits}, #{scale}>"
Expand Down
10 changes: 10 additions & 0 deletions ridlbe/c++11/templates/cli/hdr/bitmask.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@

// generated from <%= ridl_template_path %>
/// @copydoc <%= doc_scoped_name %>
enum <%= cxxname %>Bit : uint32_t
{
<%= bitvalues.collect {|e| "/// @copydoc #{doc_scoped_name}::#{e.name}\n #{e.cxxname} = #{e.value}" }.join(",\n ") %>
};// <%= cxxname %>Bit
using <%= cxxname %> = uint32_t;

% visit_template('typecode') if generate_typecode_support?
33 changes: 33 additions & 0 deletions ridlbe/c++11/visitors/bitmask.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
#--------------------------------------------------------------------
# @file bitmask.rb
# @author Johnny Willemsen
#
# @brief visitor class(es)
#
# @copyright Copyright (c) Remedy IT Expertise BV
#--------------------------------------------------------------------

module IDL
module Cxx11
class BitMaskVisitor < NodeVisitorBase
def bitvalues
@bitvalues ||= node.bitvalues.collect { |en|
(ev = visitor(BitValueVisitor)).visit(en)
ev
}
end

# template mapping

map_template :bitmask, :bitmask
map_template :typecode, :typecode
map_template :tao_typecode, :enum_typecode
end

class BitValueVisitor < NodeVisitorBase
def value
node.value
end
end
end
end
4 changes: 4 additions & 0 deletions ridlbe/c++11/writers/stubheader.rb
Original file line number Diff line number Diff line change
Expand Up @@ -298,6 +298,10 @@ def visit_enum(node)
visitor(EnumVisitor).visit_enum(node)
end

def visit_bitmask(node)
visitor(BitMaskVisitor).visit_bitmask(node)
end

def visit_typedef(node)
return if node.idltype.resolved_type.is_a?(IDL::Type::Native) && params[:no_gen_native]

Expand Down
21 changes: 21 additions & 0 deletions tests/idl4/bitmask/client.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
/**
* @file client.cpp
* @author Johnny Willemsen
*
* @brief CORBA C++11 client application
*
* @copyright Copyright (c) Remedy IT Expertise BV
*/

#include "testC.h"

int main (int /*argc*/, char* /*argv*/[])
{
// Just compilation test

MyBitMask my_bitmask;
MyBitMaskBit my_bitmaskbit;
X11_UNUSED_ARG(my_bitmask);
X11_UNUSED_ARG(my_bitmaskbit);
return 0;
}
69 changes: 69 additions & 0 deletions tests/idl4/bitmask/run_illegal_idl3_test.pl
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
#---------------------------------------------------------------------
# @file run_illegal_idl3_test.pl
# @author Mark Drijver
#
# @copyright Copyright (c) Remedy IT Expertise BV
#---------------------------------------------------------------------
eval '(exit $?0)' && eval 'exec perl -S $0 ${1+"$@"}'
& eval 'exec perl -S $0 $argv:q'
if 0;

print "IDL test\n";

use lib "$ENV{ACE_ROOT}/bin";
use PerlACE::TestTarget;
use File::Spec;

my $status =0;
my $server = PerlACE::TestTarget::create_target(2) || die "Create target 2 failed\n";

# The location of the ridl utility
my $ridl = "$ENV{X11_BASE_ROOT}/bin/ridlc";

unless (-e $ridl) {
die "ERROR: Cannot find " . $ridl;
}

opendir(DIRH, ".") or die "Could not open dir. $!";
@files = grep(/\.idl$/,readdir(DIRH));
foreach (sort(@files)){
print "Testing ", $_, ": ";
my $input_file = $_;

#Redirect the screen output to the null device.
open (OLDOUT, ">&STDOUT");
# open (STDOUT, ">" . File::Spec->devnull());
open (STDOUT, ">" . output);
open (OLDERR, ">&STDERR");
open (STDERR, ">&STDOUT");

# Compile the IDL
system ("$ridl", "$input_file");

#Redirect the null device output back to the screen
open (STDOUT, ">&OLDOUT");
open (STDERR, ">&OLDERR");

$found = 0;
open FILE, "<output";
while (my $line = <FILE>)
{
#print $line;
if ($line =~ "IDL::Parse")
{
$found = 1;
close FILE;
last;
}
}
#print "\nFound: " . $found;
if ($found>0) {
print "parsing failed as expected.\n";
} else {
print STDERR "ERROR: Unable to detect expected ridlc error.\n";
$status = 1;
}

}

exit $status;
31 changes: 31 additions & 0 deletions tests/idl4/bitmask/run_test.pl
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
#---------------------------------------------------------------------
# @file run_test.pl
# @author Marcel Smit
#
# @copyright Copyright (c) Remedy IT Expertise BV
#---------------------------------------------------------------------
eval '(exit $?0)' && eval 'exec perl -S $0 ${1+"$@"}'
& eval 'exec perl -S $0 $argv:q'
if 0;

# -*- perl -*-

use lib "$ENV{ACE_ROOT}/bin";
use PerlACE::TestTarget;

my $target = PerlACE::TestTarget::create_target(2) || die "Create target 2 failed\n";

$status = 0;

$SV = $target->CreateProcess ("client");

$server = $SV->SpawnWaitKill ($target->ProcessStartWaitInterval());

if ($server != 0) {
print STDERR "ERROR: const returned $server\n";
$status = 1;
}

$target->GetStderrLog();

exit $status;
12 changes: 12 additions & 0 deletions tests/idl4/bitmask/test.idl
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
/**
* @file test.idl
* @author Johnny Willemsen
*
* @copyright Copyright (c) Remedy IT Expertise BV
*/

bitmask MyBitMask {
flag0,
flag1,
flag2
};
20 changes: 20 additions & 0 deletions tests/idl4/bitmask/test.mpc
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
// -*- MPC -*-

project(*bitmask_gen_idl): ridl_ostream_defaults {
IDL_Files {
test.idl
idlflags += --idl-version=4
}
custom_only = 1
}

project(*bitmask_client): taox11_client {
after += *bitmask_gen_idl
Source_Files {
client.cpp
}
Source_Files {
testC.cpp
}
}

0 comments on commit c126dfb

Please sign in to comment.