~ubuntu-branches/ubuntu/breezy/orbit2/breezy

« back to all changes in this revision

Viewing changes to src/idl-compiler/orbit-idl-utils.c

  • Committer: Bazaar Package Importer
  • Author(s): Sebastien Bacher
  • Date: 2005-09-06 16:37:02 UTC
  • mfrom: (1.2.1 upstream) (2.1.1 sarge)
  • Revision ID: james.westby@ubuntu.com-20050906163702-hrqi0ctymth53bnn
Tags: 1:2.12.4-0ubuntu1
* New upstream version.
* debian/patches/100-compile-name-server.patch:
  - updated.

Show diffs side-by-side

added added

removed removed

Lines of Context:
127
127
    break;
128
128
 
129
129
  case IDLN_GENTREE:
130
 
    g_print("GENTREE:\n");
131
 
#if 0
132
 
    /* Changed in libIDL.  But don't need it here anyway. */
133
 
    orbit_idl_print_node(IDL_GENTREE(node).data, indent_level + INDENT_INCREMENT_1);
134
 
    do_indent(indent_level + INDENT_INCREMENT_1);
135
 
    g_print("children:\n");
136
 
    orbit_idl_print_node(IDL_GENTREE(node).children, indent_level + INDENT_INCREMENT_2);
137
 
#endif
138
130
    break;
139
131
 
140
132
  case IDLN_INTEGER:
379
371
  }
380
372
}
381
373
 
382
 
void
383
 
oidl_marshal_tree_dump(IDL_tree tree, int indent_level)
384
 
{
385
 
  IDL_tree node;
386
 
 
387
 
  if(!tree) return;
388
 
 
389
 
  switch(IDL_NODE_TYPE(tree)) {
390
 
  case IDLN_LIST:
391
 
    for(node = tree; node; node = IDL_LIST(node).next) {
392
 
      oidl_marshal_tree_dump(IDL_LIST(node).data, indent_level);
393
 
    }
394
 
    break;
395
 
  case IDLN_MODULE:
396
 
    do_indent(indent_level);
397
 
    g_print("Module %s:\n", IDL_IDENT(IDL_MODULE(tree).ident).str);
398
 
    oidl_marshal_tree_dump(IDL_MODULE(tree).definition_list, indent_level + INDENT_INCREMENT_2);
399
 
    break;
400
 
  case IDLN_INTERFACE:
401
 
    do_indent(indent_level);
402
 
    g_print("Interface %s:\n", IDL_IDENT(IDL_INTERFACE(tree).ident).str);
403
 
    oidl_marshal_tree_dump(IDL_INTERFACE(tree).body, indent_level + INDENT_INCREMENT_2);
404
 
    break;
405
 
  case IDLN_OP_DCL:
406
 
    do_indent(indent_level);
407
 
    g_print("Operation %s:\n", IDL_IDENT(IDL_OP_DCL(tree).ident).str);
408
 
#if 0
409
 
    oidl_marshal_node_dump(((OIDL_Op_Info *)tree->data)->in_stubs, indent_level + INDENT_INCREMENT_2);
410
 
    oidl_marshal_node_dump(((OIDL_Op_Info *)tree->data)->out_stubs, indent_level + INDENT_INCREMENT_2);
411
 
#else
412
 
    oidl_marshal_node_dump(((OIDL_Op_Info *)tree->data)->in_skels, indent_level + INDENT_INCREMENT_2);
413
 
    oidl_marshal_node_dump(((OIDL_Op_Info *)tree->data)->out_skels, indent_level + INDENT_INCREMENT_2);
414
 
#endif
415
 
    break;
416
 
  case IDLN_ATTR_DCL:
417
 
    {
418
 
      IDL_tree curnode, attr_name;
419
 
 
420
 
      for(curnode = IDL_ATTR_DCL(tree).simple_declarations; curnode; curnode = IDL_LIST(curnode).next) {
421
 
        attr_name = IDL_LIST(curnode).data;
422
 
 
423
 
        oidl_marshal_tree_dump(((OIDL_Attr_Info *)attr_name->data)->op1, indent_level + INDENT_INCREMENT_2);
424
 
        if(((OIDL_Attr_Info *)attr_name->data)->op2)
425
 
          oidl_marshal_tree_dump(((OIDL_Attr_Info *)attr_name->data)->op2, indent_level + INDENT_INCREMENT_2);
426
 
      }
427
 
    }
428
 
    break;
429
 
  default:
430
 
    break;
431
 
  }
432
 
}
433
 
 
434
 
void
435
 
oidl_marshal_node_dump(OIDL_Marshal_Node *tree, int indent_level)
436
 
{
437
 
  char *ctmp;
438
 
 
439
 
  do_indent(indent_level);
440
 
 
441
 
  if(!tree) { g_print("Nil\n"); return; }
442
 
 
443
 
  if(tree->use_count)
444
 
    {
445
 
      g_print("Recursive loopback to %p\n", tree);
446
 
      return;
447
 
    }
448
 
 
449
 
  tree->use_count++;
450
 
 
451
 
  ctmp = oidl_marshal_node_fqn(tree);
452
 
  if(tree->name)
453
 
    g_print("\"%s\" (\"%s\") ", tree->name, ctmp);
454
 
  else
455
 
    g_print("(\"%s\") ", ctmp);
456
 
  g_free(ctmp);
457
 
 
458
 
  g_print("(%s %p): [", nodenames[tree->type], tree);
459
 
  if(tree->flags & MN_INOUT)
460
 
    g_print("INOUT ");
461
 
  if(tree->flags & MN_NSROOT)
462
 
    g_print("NSROOT ");
463
 
  if(tree->flags & MN_NEED_TMPVAR)
464
 
    g_print("NEED_TMPVAR ");
465
 
  if(tree->flags & MN_NOMARSHAL)
466
 
    g_print("NOMARSHAL ");
467
 
  if(tree->flags & MN_ISSEQ)
468
 
    g_print("ISSEQ ");
469
 
  if(tree->flags & MN_ISSTRING)
470
 
    g_print("ISSTRING ");
471
 
  if(tree->flags & MN_LOOPED)
472
 
    g_print("LOOPED ");
473
 
  if(tree->flags & MN_COALESCABLE)
474
 
    g_print("COALESCABLE ");
475
 
  if(tree->flags & MN_ENDIAN_DEPENDANT)
476
 
    g_print("ENDIAN_DEPENDANT ");
477
 
  if(tree->flags & MN_DEMARSHAL_UPDATE_AFTER)
478
 
    g_print("DEMARSHAL_UPDATE_AFTER ");
479
 
  if(tree->flags & MN_RECURSIVE_TOP)
480
 
    g_print("RECURSIVE_TOP ");
481
 
  if(tree->flags & MN_TOPLEVEL)
482
 
    g_print("TOPLEVEL ");
483
 
  if(tree->flags & MN_PARAM_INOUT)
484
 
    g_print("PARAM_INOUT ");
485
 
  if(tree->flags & MN_NEED_CURPTR_LOCAL)
486
 
    g_print("NEED_CURPTR_LOCAL ");
487
 
  if(tree->flags & MN_NEED_CURPTR_RECVBUF)
488
 
    g_print("NEED_CURPTR_RECVBUF ");
489
 
  g_print("] ");
490
 
 
491
 
  if(tree->pre)
492
 
    g_print("pre-check %d+%s*%s ", tree->pre->len, tree->pre->mult_const,
493
 
            tree->pre->mult_expr?tree->pre->mult_expr->name:"(null)");
494
 
  if(tree->post)
495
 
    g_print("post-check %d+%s*%s ", tree->post->len, tree->post->mult_const,
496
 
            tree->post->mult_expr?tree->post->mult_expr->name:"(null)");
497
 
 
498
 
  g_print("*%d arch (%d,%d) iiop (%d,%d)\n", tree->nptrs,
499
 
          tree->arch_head_align, tree->arch_tail_align, tree->iiop_head_align, tree->iiop_tail_align);
500
 
 
501
 
  switch(tree->type) {
502
 
  case MARSHAL_LOOP:
503
 
    do_indent(indent_level + INDENT_INCREMENT_1);
504
 
    g_print("loop_var:\n");
505
 
    oidl_marshal_node_dump(tree->u.loop_info.loop_var, indent_level + INDENT_INCREMENT_2);
506
 
    do_indent(indent_level + INDENT_INCREMENT_1);
507
 
    g_print("length_var:\n");
508
 
    oidl_marshal_node_dump(tree->u.loop_info.length_var, indent_level + INDENT_INCREMENT_2);
509
 
    do_indent(indent_level + INDENT_INCREMENT_1);
510
 
    g_print("contents:\n");
511
 
    oidl_marshal_node_dump(tree->u.loop_info.contents, indent_level + INDENT_INCREMENT_2);
512
 
    break;
513
 
  case MARSHAL_DATUM:
514
 
    do_indent(indent_level + INDENT_INCREMENT_1);
515
 
    g_print("datum_size: %d\n", tree->u.datum_info.datum_size);
516
 
    break;
517
 
  case MARSHAL_SET:
518
 
    {
519
 
      GSList *ltmp;
520
 
      do_indent(indent_level + INDENT_INCREMENT_1);
521
 
      g_print("subnodes:\n");
522
 
      for(ltmp = tree->u.set_info.subnodes; ltmp; ltmp = g_slist_next(ltmp)) {
523
 
        oidl_marshal_node_dump(ltmp->data, indent_level + INDENT_INCREMENT_2);
524
 
        g_print("\n");
525
 
      }
526
 
    }
527
 
    break;
528
 
  case MARSHAL_SWITCH:
529
 
    {
530
 
      GSList *ltmp;
531
 
 
532
 
      do_indent(indent_level + INDENT_INCREMENT_1);
533
 
      g_print("discrim:\n");
534
 
      oidl_marshal_node_dump(tree->u.switch_info.discrim, indent_level + INDENT_INCREMENT_2);
535
 
      do_indent(indent_level + INDENT_INCREMENT_1);
536
 
      g_print("cases:\n");
537
 
      for(ltmp = tree->u.switch_info.cases; ltmp; ltmp = g_slist_next(ltmp)) {
538
 
        oidl_marshal_node_dump(ltmp->data, indent_level + INDENT_INCREMENT_2);
539
 
        g_print("\n");
540
 
      }
541
 
    }
542
 
    break;
543
 
  case MARSHAL_CASE:
544
 
    {
545
 
      GSList *ltmp;
546
 
 
547
 
      do_indent(indent_level + INDENT_INCREMENT_1);
548
 
      g_print("labels:\n");
549
 
      for(ltmp = tree->u.case_info.labels; ltmp; ltmp = g_slist_next(ltmp)) {
550
 
        oidl_marshal_node_dump(ltmp->data, indent_level + INDENT_INCREMENT_2);
551
 
        g_print("\n");
552
 
      }
553
 
      g_print("contents:\n");
554
 
      oidl_marshal_node_dump(tree->u.case_info.contents, indent_level + INDENT_INCREMENT_2);
555
 
    }
556
 
    break;
557
 
  case MARSHAL_COMPLEX:
558
 
    break;
559
 
  case MARSHAL_CONST:
560
 
    do_indent(indent_level + INDENT_INCREMENT_1);
561
 
    g_print("amount: %ld\n", tree->u.const_info.amount);
562
 
    break;
563
 
  default:
564
 
    g_warning("Don't know any details about %s nodes", nodenames[tree->type]);
565
 
    break;
566
 
  }
567
 
 
568
 
  tree->use_count--;
569
 
570
 
 
571
 
IDL_tree
572
 
orbit_idl_get_array_type(IDL_tree tree)
573
 
{
574
 
  IDL_tree parent;
575
 
 
576
 
  parent = IDL_get_parent_node(tree, IDLN_ANY, NULL);
577
 
  g_assert(IDL_NODE_TYPE(parent) == IDLN_LIST);
578
 
 
579
 
  parent = IDL_get_parent_node(parent, IDLN_ANY, NULL);
580
 
  switch(IDL_NODE_TYPE(parent)) {
581
 
  case IDLN_MEMBER:
582
 
    return IDL_MEMBER(parent).type_spec;
583
 
    break;
584
 
  case IDLN_TYPE_DCL:
585
 
    return IDL_TYPE_DCL(parent).type_spec;
586
 
    break;
587
 
  default:
588
 
    g_assert(IDL_NODE_TYPE(parent) == IDLN_MEMBER
589
 
               || IDL_NODE_TYPE(parent) == IDLN_TYPE_DCL);
590
 
  }
591
 
 
592
 
  return NULL;
593
 
}
594
 
 
595
 
char *
596
 
orbit_idl_member_get_name(IDL_tree tree)
597
 
{
598
 
  switch(IDL_NODE_TYPE(tree)) {
599
 
  case IDLN_TYPE_ARRAY:
600
 
    return orbit_idl_member_get_name(IDL_TYPE_ARRAY(tree).ident);
601
 
    break;
602
 
  case IDLN_IDENT:
603
 
    return IDL_IDENT(tree).str;
604
 
    break;
605
 
  default:
606
 
    g_error("Don't know how to get member name of a %s", IDL_tree_type_names[IDL_NODE_TYPE(tree)]);
607
 
  }
608
 
 
609
 
  return NULL;
610
 
}
611
 
 
612
 
void
613
 
orbit_idl_node_foreach(OIDL_Marshal_Node *node, GFunc func, gpointer user_data)
614
 
{
615
 
  if(!node) return;
616
 
 
617
 
  if(node->use_count)
618
 
    return;
619
 
 
620
 
  node->use_count++;
621
 
 
622
 
  func(node, user_data);
623
 
 
624
 
  switch(node->type) {
625
 
  case MARSHAL_LOOP:
626
 
    orbit_idl_node_foreach(node->u.loop_info.loop_var, func, user_data);
627
 
    orbit_idl_node_foreach(node->u.loop_info.length_var, func, user_data);
628
 
    orbit_idl_node_foreach(node->u.loop_info.contents, func, user_data);
629
 
    break;
630
 
  case MARSHAL_SWITCH:
631
 
    {
632
 
      GSList *ltmp;
633
 
 
634
 
      orbit_idl_node_foreach(node->u.switch_info.discrim, func, user_data);
635
 
 
636
 
      for(ltmp = node->u.switch_info.cases; ltmp; ltmp = g_slist_next(ltmp))
637
 
        orbit_idl_node_foreach((OIDL_Marshal_Node *)ltmp->data, func, user_data);
638
 
    }
639
 
    break;
640
 
  case MARSHAL_CASE:
641
 
    {
642
 
      GSList *ltmp;
643
 
 
644
 
      for(ltmp = node->u.case_info.labels; ltmp; ltmp = g_slist_next(ltmp))
645
 
        orbit_idl_node_foreach((OIDL_Marshal_Node *)ltmp->data, func, user_data);
646
 
 
647
 
      orbit_idl_node_foreach(node->u.case_info.contents, func, user_data);
648
 
    }
649
 
    break;
650
 
  case MARSHAL_SET:
651
 
    {
652
 
      GSList *ltmp;
653
 
 
654
 
      for(ltmp = node->u.set_info.subnodes; ltmp; ltmp = g_slist_next(ltmp))
655
 
        orbit_idl_node_foreach((OIDL_Marshal_Node *)ltmp->data, func, user_data);
656
 
    }
657
 
    break;
658
 
  default:
659
 
    break;
660
 
  }
661
 
  node->use_count--;
662
 
}
663
 
 
664
374
static void
665
375
IDL_tree_traverse_helper(IDL_tree p, GFunc f,
666
376
                         gconstpointer func_data,
667
 
                         GHashTable *visited_nodes)
 
377
                         GHashTable *visited_nodes,
 
378
                         gboolean    include_self)
668
379
{
669
380
        IDL_tree curitem;
670
381
 
671
 
        if(g_hash_table_lookup(visited_nodes, p))
 
382
        if (g_hash_table_lookup (visited_nodes, p))
672
383
                return;
673
384
 
674
 
        g_hash_table_insert(visited_nodes, p, ((gpointer)1));
 
385
        g_hash_table_insert (visited_nodes, p, ((gpointer)1));
675
386
 
676
 
        for(curitem = IDL_INTERFACE(p).inheritance_spec; curitem;
677
 
            curitem = IDL_LIST(curitem).next) {
678
 
                IDL_tree_traverse_helper(IDL_get_parent_node(IDL_LIST(curitem).data, IDLN_INTERFACE, NULL), f, func_data, visited_nodes);
 
387
        for (curitem = IDL_INTERFACE (p).inheritance_spec; curitem;
 
388
             curitem = IDL_LIST (curitem).next) {
 
389
                IDL_tree_traverse_helper (IDL_get_parent_node 
 
390
                        (IDL_LIST (curitem).data, IDLN_INTERFACE, NULL), f, func_data, visited_nodes, TRUE);
679
391
        }
680
392
 
681
 
        f(p, (gpointer)func_data);
682
 
}
683
 
 
684
 
void
685
 
IDL_tree_traverse_parents(IDL_tree p,
686
 
                          GFunc f,
687
 
                          gconstpointer func_data)
688
 
{
689
 
        GHashTable *visited_nodes = g_hash_table_new(NULL, g_direct_equal);
690
 
 
691
 
        if(!(p && f))
692
 
                return;
693
 
 
694
 
        if(IDL_NODE_TYPE(p) != IDLN_INTERFACE)
695
 
                p = IDL_get_parent_node(p, IDLN_INTERFACE, NULL);
696
 
 
697
 
        if(!p)
698
 
                return;
699
 
 
700
 
        IDL_tree_traverse_helper(p, f, func_data, visited_nodes);
701
 
 
702
 
        g_hash_table_destroy(visited_nodes);
 
393
        if (include_self)
 
394
                f(p, (gpointer)func_data);
 
395
}
 
396
 
 
397
void
 
398
IDL_tree_traverse_parents_full (IDL_tree      p,
 
399
                                GFunc         f,
 
400
                                gconstpointer func_data,
 
401
                                gboolean      include_self)
 
402
{
 
403
        GHashTable *visited_nodes = g_hash_table_new (NULL, g_direct_equal);
 
404
 
 
405
        if (!(p && f))
 
406
                return;
 
407
 
 
408
        if (IDL_NODE_TYPE(p) != IDLN_INTERFACE)
 
409
                p = IDL_get_parent_node (p, IDLN_INTERFACE, NULL);
 
410
 
 
411
        if (!p)
 
412
                return;
 
413
 
 
414
        IDL_tree_traverse_helper (p, f, func_data, visited_nodes, include_self);
 
415
 
 
416
        g_hash_table_destroy (visited_nodes);
 
417
}
 
418
 
 
419
void
 
420
IDL_tree_traverse_parents (IDL_tree p,
 
421
                           GFunc f,
 
422
                           gconstpointer func_data)
 
423
{
 
424
        IDL_tree_traverse_parents_full (p, f, func_data, TRUE);
703
425
}
704
426
 
705
427
/* For use by below function */
753
475
        from the IDLN_* enums into an index into nptrrefs_required (typeoffsets)
754
476
**/
755
477
gint
756
 
oidl_param_info(IDL_tree param, IDL_ParamRole role, gboolean *isSlice)
757
 
{
758
 
  const int * const typeoffsets = orbit_cbe_get_typeoffsets_table ();
759
 
  const int nptrrefs_required[][4] = {
760
 
    {0,1,1,0} /* float */,
761
 
    {0,1,1,0} /* double */,
762
 
    {0,1,1,0} /* long double */,
763
 
    {1,1,1,0} /* fixed_d_s 3 */, 
764
 
    {0,1,1,0} /* boolean */,
765
 
    {0,1,1,0} /* char */,
766
 
    {0,1,1,0} /* wchar */,
767
 
    {0,1,1,0} /* octet */,
768
 
    {0,1,1,0} /* enum */,
769
 
    {0,1,1,0} /* objref */,
770
 
    {1,1,1,0} /* fixed struct 10 */,
771
 
    {1,1,1,0} /* fixed union */,
772
 
    {0,1,1,0} /* string */,
773
 
    {0,1,1,0} /* wstring */,
774
 
    {1,1,2,1} /* sequence */,
775
 
    {0,0,0,0} /* fixed array */,
776
 
    {1,1,2,1} /* any 16 */
777
 
  };
778
 
  int retval = 0;
779
 
  int typeidx;
780
 
 
781
 
  *isSlice = FALSE;
782
 
 
783
 
  if(!param)
784
 
    return 0; /* void */
785
 
 
786
 
  /* Now, how do we use this table? :) */
787
 
  param = orbit_cbe_get_typespec(param);
788
 
 
789
 
  g_assert(param);
790
 
 
791
 
  switch(IDL_NODE_TYPE(param)) {
792
 
  case IDLN_TYPE_STRUCT:
793
 
  case IDLN_TYPE_UNION:
794
 
    if(((role == DATA_RETURN) || (role == DATA_OUT))
795
 
       && !orbit_cbe_type_is_fixed_length(param))
796
 
      retval++;
797
 
    break;
798
 
  case IDLN_TYPE_ARRAY:
799
 
    if ( role == DATA_RETURN ) {
800
 
      *isSlice = TRUE;
801
 
      retval = 1;
802
 
    } else if (role==DATA_OUT && !orbit_cbe_type_is_fixed_length(param)) {
803
 
      *isSlice = TRUE;
804
 
      retval = 2;
805
 
    }
806
 
    break;
807
 
  case IDLN_NATIVE:
808
 
    if ( IDL_NATIVE(param).user_type
809
 
         && strcmp(IDL_NATIVE(param).user_type,"IDL_variable_length_struct")==0 ) {
810
 
      return role==DATA_OUT ? 2 : 1;
811
 
    }
812
 
    break;
813
 
      
814
 
  default:
815
 
    break;
816
 
  }
817
 
 
818
 
  typeidx = typeoffsets[IDL_NODE_TYPE(param)];
819
 
  g_assert(typeidx >= 0);
820
 
 
821
 
  switch(role) {
822
 
  case DATA_IN: role = 0; break;
823
 
  case DATA_INOUT: role = 1; break;
824
 
  case DATA_OUT: role = 2; break;
825
 
  case DATA_RETURN: role = 3; break;
826
 
  default: g_assert_not_reached();
827
 
  }
828
 
 
829
 
  retval += nptrrefs_required[typeidx][role];
830
 
  return retval;
831
 
}
832
 
 
833
 
gint
834
 
oidl_param_numptrs(IDL_tree param, IDL_ParamRole role)
835
 
{
836
 
    gboolean isSlice;
837
 
    return oidl_param_info(param, role, &isSlice);
 
478
oidl_param_info(IDL_tree in_param, IDL_ParamRole role, gboolean *isSlice)
 
479
{
 
480
        IDL_tree param;
 
481
        const int * const typeoffsets = orbit_cbe_get_typeoffsets_table ();
 
482
        const int nptrrefs_required[][4] = {
 
483
                {0,1,1,0} /* float */,
 
484
                {0,1,1,0} /* double */,
 
485
                {0,1,1,0} /* long double */,
 
486
                {1,1,1,0} /* fixed_d_s 3 */, 
 
487
                {0,1,1,0} /* boolean */,
 
488
                {0,1,1,0} /* char */,
 
489
                {0,1,1,0} /* wchar */,
 
490
                {0,1,1,0} /* octet */,
 
491
                {0,1,1,0} /* enum */,
 
492
                {0,1,1,0} /* objref */,
 
493
                {1,1,1,0} /* fixed struct 10 */,
 
494
                {1,1,1,0} /* fixed union */,
 
495
                {0,1,1,0} /* string */,
 
496
                {0,1,1,0} /* wstring */,
 
497
                {1,1,2,1} /* sequence */,
 
498
                {0,0,0,0} /* fixed array */,
 
499
                {1,1,2,1} /* any 16 */
 
500
        };
 
501
        int retval = 0;
 
502
        int typeidx;
 
503
 
 
504
        *isSlice = FALSE;
 
505
 
 
506
        if(!in_param)
 
507
                return 0; /* void */
 
508
 
 
509
        /* Now, how do we use this table? :) */
 
510
        param = orbit_cbe_get_typespec (in_param);
 
511
 
 
512
        g_assert (param);
 
513
 
 
514
        switch (IDL_NODE_TYPE (param)) {
 
515
        case IDLN_TYPE_STRUCT:
 
516
        case IDLN_TYPE_UNION:
 
517
                if (((role == DATA_RETURN) || (role == DATA_OUT)) &&
 
518
                    !orbit_cbe_type_is_fixed_length(param))
 
519
                        retval++;
 
520
                break;
 
521
 
 
522
        case IDLN_TYPE_ARRAY:
 
523
                if ( role == DATA_RETURN ) {
 
524
                        *isSlice = TRUE;
 
525
                        retval = 1;
 
526
 
 
527
                } else if (role == DATA_OUT &&
 
528
                           !orbit_cbe_type_is_fixed_length (param)) {
 
529
                        *isSlice = TRUE;
 
530
                        retval = 2;
 
531
                }
 
532
                break;
 
533
 
 
534
        case IDLN_NATIVE:
 
535
                if ( IDL_NATIVE (param).user_type
 
536
                     && strcmp (IDL_NATIVE (param).user_type,
 
537
                                "IDL_variable_length_struct") == 0 )
 
538
                        return role == DATA_OUT ? 2 : 1;
 
539
                break;
 
540
 
 
541
        case IDLN_EXCEPT_DCL:
 
542
                fprintf (stderr, "Error: exception declared at '%s:%d' cannot be "
 
543
                         "used as a method parameter\n", in_param->_file,
 
544
                         in_param->_line);
 
545
                exit (1);
 
546
                break;
 
547
        default:
 
548
                break;
 
549
        }
 
550
 
 
551
        /* ERROR ! */
 
552
        typeidx = typeoffsets [IDL_NODE_TYPE (param)];
 
553
        g_assert (typeidx >= 0);
 
554
 
 
555
        switch (role) {
 
556
        case DATA_IN:
 
557
                role = 0;
 
558
                break;
 
559
        case DATA_INOUT:
 
560
                role = 1;
 
561
                break;
 
562
        case DATA_OUT:
 
563
                role = 2;
 
564
                break;
 
565
        case DATA_RETURN:
 
566
                role = 3;
 
567
                break;
 
568
        default:
 
569
                g_assert_not_reached ();
 
570
                break;
 
571
        }
 
572
 
 
573
        retval += nptrrefs_required [typeidx] [role];
 
574
 
 
575
        return retval;
838
576
}
839
577
 
840
578
/**
916
654
  }
917
655
}
918
656
 
919
 
#if 0
920
 
/**
921
 
    I have no idea what is meant by "complex" here. CORBA/GIOP defines
922
 
    a type as being "empty", "simple" or "complex", and basically
923
 
    describes how much info the TC has. But in that definition,
924
 
    a sequnce is always complex, regardless of what it is a sequence of.
925
 
    We need to research the caller's of this func, and see what
926
 
    they really mean.
927
 
**/
928
 
gboolean
929
 
orbit_cbe_type_contains_complex(IDL_tree ts)
930
 
{
931
 
  gboolean has_complex = FALSE;
932
 
  IDL_tree curitem;
933
 
 
934
 
  ts = orbit_cbe_get_typespec(ts);
935
 
 
936
 
  switch(IDL_NODE_TYPE(ts)) {
937
 
  case IDLN_TYPE_FLOAT:
938
 
  case IDLN_TYPE_INTEGER:
939
 
  case IDLN_TYPE_ENUM:
940
 
  case IDLN_TYPE_CHAR:
941
 
  case IDLN_TYPE_WIDE_CHAR:
942
 
  case IDLN_TYPE_OCTET:
943
 
  case IDLN_TYPE_BOOLEAN:
944
 
  case IDLN_TYPE_STRING:
945
 
  case IDLN_TYPE_WIDE_STRING:
946
 
    return FALSE;
947
 
    break;
948
 
  case IDLN_TYPE_SEQUENCE:
949
 
    return orbit_cbe_type_contains_complex(IDL_TYPE_SEQUENCE(ts).simple_type_spec);
950
 
    break;
951
 
  case IDLN_TYPE_OBJECT:
952
 
  case IDLN_FORWARD_DCL:
953
 
  case IDLN_INTERFACE:
954
 
  case IDLN_TYPE_ANY:
955
 
  case IDLN_TYPE_TYPECODE:
956
 
    return TRUE;
957
 
    break;
958
 
  case IDLN_TYPE_UNION:
959
 
    for(curitem = IDL_TYPE_UNION(ts).switch_body; curitem;
960
 
        curitem = IDL_LIST(curitem).next) {
961
 
      has_complex |= orbit_cbe_type_contains_complex(IDL_LIST(IDL_CASE_STMT(IDL_LIST(curitem).data).element_spec).data);
962
 
    }
963
 
    return has_complex;
964
 
    break;
965
 
  case IDLN_EXCEPT_DCL:
966
 
  case IDLN_TYPE_STRUCT:
967
 
    for(curitem = IDL_TYPE_STRUCT(ts).member_list; curitem;
968
 
        curitem = IDL_LIST(curitem).next) {
969
 
      has_complex |= orbit_cbe_type_contains_complex(IDL_LIST(curitem).data);
970
 
    }
971
 
    return has_complex;
972
 
    break;
973
 
  case IDLN_TYPE_ARRAY:
974
 
    return orbit_cbe_type_contains_complex(IDL_TYPE_DCL(IDL_get_parent_node(ts, IDLN_TYPE_DCL, NULL)).type_spec);
975
 
    break;
976
 
  case IDLN_TYPE_DCL:
977
 
    return orbit_cbe_type_contains_complex(IDL_TYPE_DCL(ts).type_spec);
978
 
    break;
979
 
  case IDLN_IDENT:
980
 
  case IDLN_LIST:
981
 
    return orbit_cbe_type_contains_complex(IDL_NODE_UP(ts));
982
 
    break;
983
 
  case IDLN_MEMBER:
984
 
    return orbit_cbe_type_contains_complex(IDL_MEMBER(ts).type_spec);
985
 
    break;
986
 
  default:
987
 
    g_warning("I'm not sure if type %s has a complex...", IDL_tree_type_names[IDL_NODE_TYPE(ts)]);
988
 
    return FALSE;
989
 
  }
990
 
}
991
 
#endif
992
 
 
993
657
IDL_tree
994
658
orbit_cbe_get_typespec(IDL_tree node)
995
659
{
1054
718
    return -1;
1055
719
  }
1056
720
}
1057
 
 
1058
 
gboolean
1059
 
oidl_tree_is_pidl(IDL_tree tree) {
1060
 
    IDL_tree pnt;
1061
 
    for ( pnt=tree; pnt; pnt=IDL_NODE_UP(pnt) ) {
1062
 
        if ( pnt->declspec & IDLF_DECLSPEC_PIDL )
1063
 
            return TRUE;
1064
 
    }
1065
 
    return FALSE;
1066
 
}