summaryrefslogtreecommitdiff
path: root/pidl/lib/Parse/Pidl/CUtil.pm
diff options
context:
space:
mode:
authorJelmer Vernooij <jelmer@samba.org>2008-09-17 17:12:27 +0200
committerJelmer Vernooij <jelmer@samba.org>2008-09-17 17:12:27 +0200
commit79190992b3820cd028c961c48bdea9b35baf13c9 (patch)
tree0de851669d98f04e947d20349d96723462cd1eb0 /pidl/lib/Parse/Pidl/CUtil.pm
parent3b5330e9094ecf0be94d3dbea744de140ec55e19 (diff)
downloadsamba-79190992b3820cd028c961c48bdea9b35baf13c9.tar.gz
samba-79190992b3820cd028c961c48bdea9b35baf13c9.tar.bz2
samba-79190992b3820cd028c961c48bdea9b35baf13c9.zip
Move pidl to top-level directory.
Diffstat (limited to 'pidl/lib/Parse/Pidl/CUtil.pm')
-rw-r--r--pidl/lib/Parse/Pidl/CUtil.pm52
1 files changed, 52 insertions, 0 deletions
diff --git a/pidl/lib/Parse/Pidl/CUtil.pm b/pidl/lib/Parse/Pidl/CUtil.pm
new file mode 100644
index 0000000000..9deb6ee177
--- /dev/null
+++ b/pidl/lib/Parse/Pidl/CUtil.pm
@@ -0,0 +1,52 @@
+###################################################
+# C utility functions for pidl
+# Copyright jelmer@samba.org 2005-2007
+# released under the GNU GPL
+package Parse::Pidl::CUtil;
+
+require Exporter;
+@ISA = qw(Exporter);
+@EXPORT = qw(get_pointer_to get_value_of get_array_element);
+use vars qw($VERSION);
+$VERSION = '0.01';
+
+use strict;
+
+sub get_pointer_to($)
+{
+ my $var_name = shift;
+
+ if ($var_name =~ /^\*(.*)$/) {
+ return $1;
+ } elsif ($var_name =~ /^\&(.*)$/) {
+ return "&($var_name)";
+ } else {
+ return "&$var_name";
+ }
+}
+
+sub get_value_of($)
+{
+ my $var_name = shift;
+
+ if ($var_name =~ /^\&(.*)$/) {
+ return $1;
+ } else {
+ return "*$var_name";
+ }
+}
+
+sub get_array_element($$)
+{
+ my ($var_name, $idx) = @_;
+
+ if ($var_name =~ /^\*.*$/) {
+ $var_name = "($var_name)";
+ } elsif ($var_name =~ /^\&.*$/) {
+ $var_name = "($var_name)";
+ }
+
+ return "$var_name"."[$idx]";
+}
+
+1;