~ubuntu-branches/ubuntu/oneiric/swig1.3/oneiric

« back to all changes in this revision

Viewing changes to Lib/octave/octrun.swg

  • Committer: Bazaar Package Importer
  • Author(s): Benjamin Drung
  • Date: 2009-11-15 14:00:28 UTC
  • mfrom: (1.2.9 upstream) (2.1.4 squeeze)
  • Revision ID: james.westby@ubuntu.com-20091115140028-me7amr2rie8zz1xn
Tags: 1.3.40-2ubuntu1
* Merge from Debian testing (LP: #356529), remaining changes:
  - Drop libchicken-dev from the build-depends (it's in universe)
  - Remove Pike from package description and from configure flags
  - drop "--without-mzscheme", we don't have it in our build-depends
  - use php-config5
  - Clean Runtime/ as well.
  - debian/rules (clean): Remove Lib/ocaml/swigp4.ml.
* debian/rules: Remove hardcoded python version.
* Remove upper limit for python from Build-Depends.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
 
 
2
#if OCTAVE_API_VERSION_OPTION>0
 
3
#define USE_OCTAVE_API_VERSION OCTAVE_API_VERSION_OPTION
 
4
#else
 
5
 
 
6
#include <octave/version.h>
 
7
#ifdef OCTAVE_API_VERSION_N
 
8
#define USE_OCTAVE_API_VERSION OCTAVE_API_VERSION_N
 
9
 
 
10
#else // Interim hack to distinguish between Octave 3.2 and earlier versions.
 
11
 
 
12
#define ComplexLU __ignore
 
13
#include <octave/CmplxLU.h>
 
14
#undef ComplexLU
 
15
#ifdef octave_Complex_LU_h
 
16
#define USE_OCTAVE_API_VERSION 36
 
17
#else
 
18
#define USE_OCTAVE_API_VERSION 37
 
19
#endif
 
20
 
 
21
#endif
 
22
 
 
23
#endif
2
24
 
3
25
SWIGRUNTIME bool SWIG_check_num_args(const char *func_name, int num_args, int max_args, int min_args, int varargs) {
4
26
  if (num_args > max_args && !varargs)
105
127
 
106
128
  typedef std::map < void *, Director * > rtdir_map;
107
129
 
108
 
  SWIGINTERN rtdir_map &get_rtdir_map() {
 
130
  SWIGINTERN rtdir_map* get_rtdir_map() {
109
131
    static swig_module_info *module = 0;
110
132
    if (!module)
111
133
      module = SWIG_GetModule(0);
112
 
    assert(module);
 
134
    if (!module)
 
135
      return 0;
113
136
    if (!module->clientdata)
114
137
      module->clientdata = new rtdir_map;
115
 
    return *(rtdir_map *) module->clientdata;
 
138
    return (rtdir_map *) module->clientdata;
116
139
  }
117
140
 
118
141
  SWIGINTERNINLINE void set_rtdir(void *vptr, Director *d) {
119
 
    get_rtdir_map()[vptr] = d;
 
142
    rtdir_map* rm = get_rtdir_map();
 
143
    if (rm)
 
144
      (*rm)[vptr] = d;
120
145
  }
121
146
 
122
147
  SWIGINTERNINLINE void erase_rtdir(void *vptr) {
123
 
    get_rtdir_map().erase(vptr);
 
148
    rtdir_map* rm = get_rtdir_map();
 
149
    if (rm)
 
150
      (*rm).erase(vptr);
124
151
  }
125
152
 
126
153
  SWIGINTERNINLINE Director *get_rtdir(void *vptr) {
127
 
    rtdir_map::const_iterator pos = get_rtdir_map().find(vptr);
128
 
    Director *rtdir = (pos != get_rtdir_map().end())? pos->second : 0;
 
154
    rtdir_map* rm = get_rtdir_map();
 
155
    if (!rm)
 
156
      return 0;
 
157
    rtdir_map::const_iterator pos = rm->find(vptr);
 
158
    Director *rtdir = (pos != rm->end())? pos->second : 0;
129
159
    return rtdir;
130
160
  }
131
161
}
439
469
          install_builtin_function(it->second.first->method, it->first,
440
470
                                   it->second.first->doc?it->second.first->doc:std::string());
441
471
        else if (it->second.second.is_defined()) {
 
472
#if USE_OCTAVE_API_VERSION<37
442
473
          link_to_global_variable(curr_sym_tab->lookup(it->first, true));
 
474
#else 
 
475
          symbol_table::varref(it->first);
 
476
          symbol_table::mark_global(it->first);
 
477
#endif
443
478
          set_global_value(it->first, it->second.second);
444
479
          
 
480
#if USE_OCTAVE_API_VERSION<37
445
481
          octave_swig_type *ost = Swig::swig_value_deref(it->second.second);
446
482
          if (ost) {
447
483
            const char* h = ost->help_text();
450
486
              sr->document(h);
451
487
            }
452
488
          }
 
489
#endif
453
490
        }
454
491
      }
455
492
    }
589
626
      // index operator
590
627
      else {
591
628
        if (ops[skip] == '(' || ops[skip] == '{') {
592
 
          const char *op_name = ops[skip] == '(' ? "__paren" : "__brace";
 
629
          const char *op_name = ops[skip] == '(' ? "__paren__" : "__brace__";
593
630
          octave_value_list args;
594
631
          args.append(*idx_it++);
595
632
          ++skip;
628
665
      }
629
666
 
630
667
      else if (ops[skip] == '(' || ops[skip] == '{') {
631
 
        const char *op_name = ops[skip] == '(' ? "__paren_asgn" : "__brace_asgn";
 
668
        const char *op_name = ops[skip] == '(' ? "__paren_asgn__" : "__brace_asgn__";
632
669
        member_value_pair *m = find_member(op_name, false);
633
670
        if (m) {
634
671
          octave_value_list args;
666
703
 
667
704
    virtual bool is_string() const {
668
705
      octave_swig_type *nc_this = const_cast < octave_swig_type *>(this);
669
 
      return !!nc_this->find_member("__str", false);
 
706
      return !!nc_this->find_member("__str__", false);
670
707
    }
671
708
 
672
709
    virtual std::string string_value(bool force = false) const {
673
710
      octave_swig_type *nc_this = const_cast < octave_swig_type *>(this);
674
 
      member_value_pair *m = nc_this->find_member("__str", false);
 
711
      member_value_pair *m = nc_this->find_member("__str__", false);
675
712
      if (!m) {
676
 
        error("__str method not defined");
 
713
        error("__str__ method not defined");
677
714
        return std::string();
678
715
      }
679
716
      octave_value_list outarg = nc_this->member_invoke(m, octave_value_list(nc_this->as_value()), 1);
680
717
      if (outarg.length() < 1 || !outarg(0).is_string()) {
681
 
        error("__str method did not return a string");
 
718
        error("__str__ method did not return a string");
682
719
        return std::string();
683
720
      }
684
721
      return outarg(0).string_value();
685
722
    }
686
723
 
687
 
    /*
688
724
    virtual Octave_map map_value() const {
689
 
      octave_swig_type *nc_this = const_cast < octave_swig_type *>(this);
690
 
      member_value_pair *m = nc_this->find_member("__str", false);
691
 
      if (!m) {
692
 
        error("__map method not defined");
693
 
        return std::string();
694
 
      }
695
 
      octave_value_list outarg = nc_this->member_invoke(m, octave_value_list(nc_this->as_value()), 1);
696
 
      if (outarg.length() < 1 || !outarg(0).is_map()) {
697
 
        error("__map method did not return a string");
698
 
        return std::string();
699
 
      }
700
 
      return outarg(0).map_value();
 
725
      return Octave_map();
701
726
    }
702
 
    */
703
727
 
704
728
    virtual string_vector map_keys() const {
705
729
      member_map tmp;
713
737
      return keys;
714
738
    }
715
739
 
 
740
    virtual bool save_ascii (std::ostream& os) {
 
741
      return true;
 
742
    }
 
743
 
 
744
    virtual bool load_ascii (std::istream& is) {
 
745
      return true;
 
746
    }
 
747
 
 
748
    virtual bool save_binary (std::ostream& os, bool& save_as_floats) {
 
749
      return true;
 
750
    }
 
751
 
 
752
    virtual bool load_binary (std::istream& is, bool swap, 
 
753
                              oct_mach_info::float_format fmt) {
 
754
      return true;
 
755
    }
 
756
 
 
757
#if defined (HAVE_HDF5)
 
758
    virtual bool
 
759
      save_hdf5 (hid_t loc_id, const char *name, bool save_as_floats) {
 
760
      return true;
 
761
    }
 
762
 
 
763
    virtual bool
 
764
      load_hdf5 (hid_t loc_id, const char *name, bool have_h5giterate_bug) {
 
765
      return true;
 
766
    }
 
767
#endif
 
768
 
716
769
    virtual octave_value convert_to_str(bool pad = false, bool force = false, char type = '"') const {
717
770
      return string_value();
718
771
    }
737
790
      assert(ost);
738
791
 
739
792
      octave_value ret;
740
 
      if (ost->dispatch_unary_op(std::string("__") + op_name, ret))
 
793
      if (ost->dispatch_unary_op(std::string("__") + op_name + std::string("__"), ret))
741
794
        return ret;
742
795
      std::string symbol = "op_" + ost->swig_type_name() + "_" + op_name;
743
796
      octave_value_list args;
754
807
      octave_swig_type *rhs_ost = Swig::swig_value_deref(rhs);
755
808
 
756
809
      octave_value ret;
757
 
      if (lhs_ost && lhs_ost->dispatch_binary_op(std::string("__") + op_name, rhs, ret))
 
810
      if (lhs_ost && lhs_ost->dispatch_binary_op(std::string("__") + op_name + std::string("__"), rhs, ret))
758
811
        return ret;
759
812
 
760
813
      std::string symbol;
876
929
    virtual std::string string_value(bool force = false) const 
877
930
      { return ptr->string_value(force); }
878
931
 
 
932
    virtual Octave_map map_value() const
 
933
      { return ptr->map_value(); }
 
934
 
879
935
    virtual string_vector map_keys() const
880
936
      { return ptr->map_keys(); }
881
937
 
 
938
    virtual bool save_ascii (std::ostream& os)
 
939
      { return ptr->save_ascii(os); }
 
940
 
 
941
    virtual bool load_ascii (std::istream& is)
 
942
      { return ptr->load_ascii(is); }
 
943
 
 
944
    virtual bool save_binary (std::ostream& os, bool& save_as_floats)
 
945
      { return ptr->save_binary(os, save_as_floats); }
 
946
 
 
947
    virtual bool load_binary (std::istream& is, bool swap, 
 
948
                              oct_mach_info::float_format fmt)
 
949
      { return ptr->load_binary(is, swap, fmt); }
 
950
 
 
951
#if defined (HAVE_HDF5)
 
952
    virtual bool
 
953
      save_hdf5 (hid_t loc_id, const char *name, bool save_as_floats)
 
954
      { return ptr->save_hdf5(loc_id, name, save_as_floats); }
 
955
 
 
956
    virtual bool
 
957
      load_hdf5 (hid_t loc_id, const char *name, bool have_h5giterate_bug)
 
958
      { return ptr->load_hdf5(loc_id, name, have_h5giterate_bug); }
 
959
#endif
 
960
 
882
961
    virtual octave_value convert_to_str(bool pad = false, bool force = false, char type = '"') const
883
962
      { return ptr->convert_to_str(pad, force, type); }
884
963
 
927
1006
    void print(std::ostream &os, bool pr_as_read_syntax = false) const {
928
1007
      os << "swig packed type: name = " << (type ? type->name : std::string()) << ", len = " << buf.size() << std::endl;
929
1008
    }
 
1009
 
 
1010
 
 
1011
    virtual bool save_ascii (std::ostream& os) {
 
1012
      return true;
 
1013
    }
 
1014
 
 
1015
    virtual bool load_ascii (std::istream& is) {
 
1016
      return true;
 
1017
    }
 
1018
 
 
1019
    virtual bool save_binary (std::ostream& os, bool& save_as_floats) {
 
1020
      return true;
 
1021
    }
 
1022
 
 
1023
    virtual bool load_binary (std::istream& is, bool swap, 
 
1024
                              oct_mach_info::float_format fmt) {
 
1025
      return true;
 
1026
    }
 
1027
 
 
1028
#if defined (HAVE_HDF5)
 
1029
    virtual bool
 
1030
      save_hdf5 (hid_t loc_id, const char *name, bool save_as_floats) {
 
1031
      return true;
 
1032
    }
 
1033
 
 
1034
    virtual bool
 
1035
      load_hdf5 (hid_t loc_id, const char *name, bool have_h5giterate_bug) {
 
1036
      return true;
 
1037
    }
 
1038
#endif
 
1039
 
930
1040
  private:
931
1041
    DECLARE_OCTAVE_ALLOCATOR;
932
1042
    DECLARE_OV_TYPEID_FUNCTIONS_AND_DATA;
1279
1389
SWIGRUNTIME void SWIG_Octave_SetModule(void *clientdata, swig_module_info *pointer) {
1280
1390
  octave_value ov = new octave_swig_packed(0, &pointer, sizeof(swig_module_info *));
1281
1391
  const char *module_var = "__SWIG_MODULE__" SWIG_TYPE_TABLE_NAME SWIG_RUNTIME_VERSION;
 
1392
#if USE_OCTAVE_API_VERSION<37
1282
1393
  link_to_global_variable(curr_sym_tab->lookup(module_var, true));
 
1394
#else
 
1395
  symbol_table::varref(module_var);
 
1396
  symbol_table::mark_global(module_var);
 
1397
#endif
1283
1398
  set_global_value(module_var, ov);
1284
1399
}