Skip to content

Commit

Permalink
Merge pull request #352 from jwillemsen/jwi-external
Browse files Browse the repository at this point in the history
Basic support for @external support, only basic generation and compil…
  • Loading branch information
jwillemsen authored Jan 24, 2024
2 parents a0b82a7 + d0b3f45 commit 0a0054c
Show file tree
Hide file tree
Showing 13 changed files with 122 additions and 22 deletions.
1 change: 1 addition & 0 deletions bin/taox11_tests.lst
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ tests/idl4/default/run_test.pl:
tests/idl4/enum/run_test.pl:
tests/idl4/explicit_ints/run_test.pl:
tests/idl4/explicit_ints/run_illegal_idl3_test.pl:
tests/idl4/external/run_test.pl:
tests/idl4/illegal_idl/run_test.pl:
tests/idl4/map/run_test.pl:
tests/idl4/map/run_illegal_idl3_test.pl:
Expand Down
2 changes: 1 addition & 1 deletion ridlbe/c++11/templates/cli/hdr/struct_idl_traits_def.erb
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ struct formatter<<%= scoped_cxxtype %>, OStrm_>
<< "object}"
% end
% else
% unless _m.optional?
% unless _m.optional? || _m.external?
<< "<%= _sep %><%= _m.cxxname %>=" << IDL::traits<<%= _m.scoped_cxxtype %>>::write(val_.<%= _m.cxxname %> ())
% else
%# TODO
Expand Down
44 changes: 29 additions & 15 deletions ridlbe/c++11/visitors/struct.rb
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,10 @@ def optional?
!node.annotations[:optional].first.nil?
end

def external?
!node.annotations[:external].first.nil?
end

def is_reference?
if optional?
false
Expand All @@ -95,42 +99,52 @@ def is_pod?
end

def cxx_byval_type
unless optional?
super
else
if optional?
"IDL::optional<#{cxx_return_type}>"
elsif external?
"std::shared_ptr<#{cxx_return_type}>"
else
super
end
end

def cxx_out_type
unless optional?
super
else
if optional?
"IDL::optional<#{cxx_return_type}>&"
elsif external?
"std::shared_ptr<#{cxx_return_type}>&"
else
super
end
end

def cxx_in_type
unless optional?
super
else
if optional?
"const IDL::optional<#{super}>&"
elsif external?
"const std::shared_ptr<#{super}>&"
else
super
end
end

def cxx_move_type
unless optional?
super
else
if optional?
"IDL::optional<#{cxx_return_type}>&&"
elsif external?
"std::shared_ptr<#{cxx_return_type}>&&"
else
super
end
end

def cxx_member_type
unless optional?
super
else
if optional?
"IDL::optional<#{super}>"
elsif external?
"std::shared_ptr<#{super}>"
else
super
end
end
end
Expand Down
2 changes: 1 addition & 1 deletion tests/annotations/run_test.pl
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
$server = $SV->SpawnWaitKill ($target->ProcessStartWaitInterval());

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

Expand Down
2 changes: 1 addition & 1 deletion tests/idl4/bitset/run_test.pl
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
$server = $SV->SpawnWaitKill ($target->ProcessStartWaitInterval());

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

Expand Down
2 changes: 1 addition & 1 deletion tests/idl4/enum/run_test.pl
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
$server = $SV->SpawnWaitKill ($target->ProcessStartWaitInterval());

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

Expand Down
2 changes: 1 addition & 1 deletion tests/idl4/explicit_ints/run_test.pl
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
$server = $SV->SpawnWaitKill ($target->ProcessStartWaitInterval());

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

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

#include "testC.h"
#include "testlib/taox11_testlog.h"

int main (int /*argc*/, char* /*argv*/[])
{
int retval {};
bar mybar;

TAOX11_TEST_INFO << "mybar: " << mybar << std::endl;
return retval;
}
31 changes: 31 additions & 0 deletions tests/idl4/external/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: client returned $server\n";
$status = 1;
}

$target->GetStderrLog();

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

struct bar
{
short x;
string y;
@external short z;
};

20 changes: 20 additions & 0 deletions tests/idl4/external/test.mpc
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
// -*- MPC -*-

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

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

2 changes: 1 addition & 1 deletion tests/idl4/optional/run_test.pl
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
$server = $SV->SpawnWaitKill ($target->ProcessStartWaitInterval());

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

Expand Down
2 changes: 1 addition & 1 deletion tests/idl4/union/run_test.pl
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
$server = $SV->SpawnWaitKill ($target->ProcessStartWaitInterval());

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

Expand Down

0 comments on commit 0a0054c

Please sign in to comment.