PageRenderTime 15ms CodeModel.GetById 8ms app.highlight 3ms RepoModel.GetById 1ms app.codeStats 0ms

/trunk/Examples/test-suite/smart_pointer_templatevariables.i

#
Swig | 39 lines | 33 code | 6 blank | 0 comment | 0 complexity | 8dd00f976f94d60f4cc11341aaa021cc MD5 | raw file
 1%module smart_pointer_templatevariables
 2
 3%inline %{
 4template <class _CharT>
 5struct basic_string {
 6    int npos;
 7};
 8
 9template<class T>
10struct Ptr {
11    Ptr(T *p = 0) : ptr(p) {}
12    ~Ptr() { delete ptr; }
13    T *operator->() const { return ptr; }
14private:
15    T *ptr;
16};
17
18template <typename KernelPixelT>
19struct DiffImContainer {
20    int id;
21// static members seem to be can of worms. Note that SWIG wraps them as non-static members. Why?
22// Note CHANGES entry 10/14/2003. Static const variables are not wrapped as constants but as a read only variable. Why?
23//    static short xyz;
24//    static const short constvar = 555;
25};
26//template<typename KernelPixelT> short DiffImContainer<KernelPixelT>::xyz = 0;
27
28DiffImContainer<double>* create(int id, short xyz) { 
29  DiffImContainer<double> *d = new DiffImContainer<double>();
30  d->id = id;
31//  DiffImContainer<double>::xyz = xyz;
32  return d;
33}
34%}
35
36%template(BasicString)                     basic_string<char>;
37%template(DiffImContainer_D)               DiffImContainer<double>;
38%template(DiffImContainerPtr_D)            Ptr<DiffImContainer<double> >;
39