X-Git-Url: http://git.buserror.net/cgi-bin/gitweb.cgi?p=polintos%2Fscott%2Fpriv.git;a=blobdiff_plain;f=idlcomp%2Flanguages%2Fc%2B%2B%2Fc%2B%2B.h;h=771cba1ccf97f09a77fb876623cb68d9bb6a0233;hp=ba7e769277b75ae91fe2ae1a4f56ca79df98d4f7;hb=ed94ee97c9872c957efa4790c4ea073f371262a6;hpb=b024710fe2b60cd4a42a8993b61333d6cdb56ca3 diff --git a/idlcomp/languages/c++/c++.h b/idlcomp/languages/c++/c++.h index ba7e769..771cba1 100644 --- a/idlcomp/languages/c++/c++.h +++ b/idlcomp/languages/c++/c++.h @@ -27,6 +27,47 @@ void cpp_output_type(ostream &file, CompiledBasicType &t, bool is_mutable); void cpp_output_one_param(ostream &file, Param *p, bool is_server, bool is_copy = false); + +enum CPPTraversal { + trav_full, // Full, final output + trav_obj_def, // Object struct definition + trav_obj_stub, // Object pointer stub, + // so it can be used in structs. + trav_nsdecl, // _ns declaration + trav_forward, // Forward declaration of + // structs/interfaces in nsdecl + + num_traversals, + + // Values beyond this point are not part of the + // above sequential pass scheme; they are merely + // for dynamic dispatch. + trav_marshall, + trav_unmarshall, +}; + +// Per-symbol language-private data +struct CPPData : public Releasable { + // The traversal indices are also passed as "arg1" to determine + // which pass to generate. Higher numbers are performed first. + + int traversed[num_traversals]; + + CPPData() : Releasable(1) + { + memset(traversed, 0, sizeof(traversed)); + } +}; + +static inline CPPData &cpp_symdata(Symbol *sym) +{ + if (!sym->lang_priv) + sym->lang_priv = new CPPData; + + CPPData *ptr = dynamic_cast(sym->lang_priv); + assert(ptr); + return *ptr; +} // Each IDL namespace is mapped to a C++ header file, // represented by a CPPFile. @@ -57,7 +98,21 @@ class CPPFile : public LangCallback { //// Marshalling methods - void output_marshall(Struct *sym, int pass); + void output_marshall_pass(Struct *sym, int pass); + void output_marshall_method(Struct *sym); + void output_marshall_inline_method(Struct *sym); + void marshall_members(Struct *sym); + + void output_marshall_array(Datum *d); + void output_marshall(Struct *sym, Datum *d); + void output_marshall(Interface *sym, Datum *d); + void output_marshall(Enum *sym, Datum *d); + void output_marshall(BitField *sym, Datum *d); + void output_marshall(BasicType *sym, Datum *d); + void output_marshall(CompiledBasicType &cbt, Datum *d); + + void align_type(Symbol *sym); + void grow_buf(); // Output the downcast and implicit upcast methods for // the given interface/superinterface pair. @@ -180,28 +235,15 @@ class CPPFile : public LangCallback { int first_traversal; - // The traversal indices are also passed as "arg1" to determine - // which pass to generate. Higher numbers are performed first. - - enum { - trav_full = 0, // Full, final output - trav_obj_def = 1, // Object struct definition - trav_obj_stub = 2, // Object pointer stub, - // so it can be used in structs. - trav_nsdecl = 3, // _ns declaration - trav_forward = 4, // Forward declaration of - // structs/interfaces in nsdecl - }; - bool pass_needed(Symbol *sym, int pass) { - return first_traversal > sym->traversed[pass]; + return first_traversal > cpp_symdata(sym).traversed[pass]; } void output_pass(Symbol *sym, int pass) { if (pass_needed(sym, pass)) { - sym->traversed[pass] = traversal; + cpp_symdata(sym).traversed[pass] = traversal; sym->output_lang(this, pass); } } @@ -241,6 +283,18 @@ public: void output(Alias *sym, int pass = trav_full, void *arg2 = NULL); void output(TypeDef *sym, int pass = trav_full, void *arg2 = NULL); void output(Datum *sym, int pass = trav_full, void *arg2 = NULL); + + void marshall(Struct *sym); + void marshall(Interface *sym); + void marshall(BitField *sym); + void marshall(Enum *sym); + void marshall(BasicType *sym); + + void unmarshall(Struct *sym); + void unmarshall(Interface *sym); + void unmarshall(BitField *sym); + void unmarshall(Enum *sym); + void unmarshall(BasicType *sym); }; class CPPBinding : public Language {