1# -*- python -*-
2#                           Package   : omniidl
3# marshal.py                Created on: 1999/12/1
4#			    Author    : David Scott (djs)
5#
6#    Copyright (C) 2003-2011 Apasphere Ltd
7#    Copyright (C) 1999 AT&T Laboratories Cambridge
8#
9#  This file is part of omniidl.
10#
11#  omniidl is free software; you can redistribute it and/or modify it
12#  under the terms of the GNU General Public License as published by
13#  the Free Software Foundation; either version 2 of the License, or
14#  (at your option) any later version.
15#
16#  This program is distributed in the hope that it will be useful,
17#  but WITHOUT ANY WARRANTY; without even the implied warranty of
18#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
19#  General Public License for more details.
20#
21#  You should have received a copy of the GNU General Public License
22#  along with this program.  If not, see http://www.gnu.org/licenses/
23#
24# Description:
25#
26#   Produce the main header alignment and marshal function definitions
27#   for the C++ backend
28
29"""Produce the main header alignment and marshal function definitions
30  for the C++ backend"""
31
32from omniidl_be.cxx import ast, id
33from omniidl_be.cxx.header import template
34
35import sys
36self = sys.modules[__name__]
37
38stream = None
39
40def init(s):
41    global stream
42    stream = s
43    return self
44
45# Control arrives here
46#
47def visitAST(node):
48    for n in node.declarations():
49        if ast.shouldGenerateCodeForDecl(n):
50            n.accept(self)
51
52def visitModule(node):
53    for n in node.definitions():
54        n.accept(self)
55
56def visitStruct(node):
57    for n in node.members():
58        n.accept(self)
59
60def visitStructForward(node):
61    pass
62
63def visitUnion(node):
64    pass
65
66def visitUnionForward(node):
67    pass
68
69def visitMember(node):
70    if node.constrType():
71        node.memberType().decl().accept(self)
72
73def visitEnum(node):
74    pass
75
76def visitInterface(node):
77    # interfaces act as containers for other declarations
78    # output their operators here
79    for d in node.declarations():
80        d.accept(self)
81
82    name = id.Name(node.scopedName())
83    cxx_name = name.fullyQualify()
84
85    if node.local():
86        stream.out(template.local_interface_marshal_forward,
87                   name = cxx_name)
88
89    elif node.abstract():
90        stream.out(template.abstract_interface_marshal_forward,
91                   name = cxx_name)
92    else:
93        stream.out(template.interface_marshal_forward,
94                   name = cxx_name)
95
96def visitTypedef(node):
97    pass
98
99def visitForward(node):
100    pass
101def visitConst(node):
102    pass
103def visitDeclarator(node):
104    pass
105def visitException(node):
106    pass
107def visitValue(node):
108    pass
109def visitValueForward(node):
110    pass
111def visitValueAbs(node):
112    pass
113def visitValueBox(node):
114    pass
115