From: Stefan Z. <sz...@gm...> - 2011-10-05 14:58:31
|
Even if you manage to get this to compile, you won't be able to do anything useful with the anBBList field -- you won't be able to access individual elements or slices. If you want to do that, you have a lot more work to do with typemaps in your interface file. However, if you don't need to do anything with the anBBList field and you just want to make it work, I suggest ignoring it by putting this in your interface file: %ignore anBBList; Stefan On Tue, Oct 4, 2011 at 11:54 PM, Hongbin Wei - SISA <hon...@si...> wrote: > In C code I have a 3 dimensional array shown as below defined in a data > structure. > > > > UINT16 anBBList[MAX_TOTAL_DIES][TOTAL_PLANES][MAX_BAD_BLOCK_CNT]; > ///< bad block list > > > > The wrapper C file generated contains a setter method on the array as below. > The line in blue causes the compile error “error C2106: '=' : left operand > must be l-value”. > > > > SWIGINTERN PyObject *_wrap_BOOT_CONTEXT_anBBList_set(PyObject > *SWIGUNUSEDPARM(self), PyObject *args) { > > PyObject *resultobj = 0; > > BOOT_CONTEXT *arg1 = (BOOT_CONTEXT *) 0 ; > > UINT16 (*arg2)[(4)][((8192) *25/(1000*(4)))] ; > > void *argp1 = 0 ; > > int res1 = 0 ; > > void *argp2 = 0 ; > > int res2 = 0 ; > > PyObject * obj0 = 0 ; > > PyObject * obj1 = 0 ; > > > > if (!PyArg_ParseTuple(args,(char > *)"OO:BOOT_CONTEXT_anBBList_set",&obj0,&obj1)) SWIG_fail; > > res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_BOOT_CONTEXT, 0 | 0 ); > > if (!SWIG_IsOK(res1)) { > > SWIG_exception_fail(SWIG_ArgError(res1), "in method '" > "BOOT_CONTEXT_anBBList_set" "', argument " "1"" of type '" "BOOT_CONTEXT > *""'"); > > } > > arg1 = (BOOT_CONTEXT *)(argp1); > > res2 = SWIG_ConvertPtr(obj1, > &argp2,SWIGTYPE_p_a__4___a___8192___25__1000__4_____unsigned_short, 0 | 0 > ); > > if (!SWIG_IsOK(res2)) { > > SWIG_exception_fail(SWIG_ArgError(res2), "in method '" > "BOOT_CONTEXT_anBBList_set" "', argument " "2"" of type '" "UINT16 [((2) > *(4))][(4)][((8192) *25/(1000*(4)))]""'"); > > } > > arg2 = (UINT16 (*)[(4)][((8192) *25/(1000*(4)))])(argp2); > > { > > if (arg2) { > > size_t ii = 0; > > for (; ii < (size_t)((2) *(4)); ++ii) { > > if (arg2[ii]) { > > size_t jj = 0; > > for (; jj < (size_t)(4); ++jj) arg1->anBBList[ii][jj] = > arg2[ii][jj]; > > } else { > > SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in > variable '""anBBList""' of type '""UINT16 [((2) *(4))][(4)][((8192) > *25/(1000*(4)))]""'"); > > } > > } > > } else { > > SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in > variable '""anBBList""' of type '""UINT16 [((2) *(4))][(4)][((8192) > *25/(1000*(4)))]""'"); > > } > > } > > resultobj = SWIG_Py_Void(); > > return resultobj; > > fail: > > return NULL; > > } > > > > It looks like the wrapper file is treating the 3-dimensional array as a > 2-dimensional one, since I have another 2-dimensional array defined in C > code, and the wrapper file is treating them almost the same. > > > > I tried to replace the highlighted line with following code and it compiles. > > > > for (; jj < (size_t)(4); ++jj) { > > if (arg2[ii][jj]) { > > size_t kk = 0; > > for (; kk < > (size_t)((8192)*25/(1000*(4))); ++kk) arg1->anBBList[ii][jj][kk] = > arg2[ii][jj][kk]; > > } > > } > > > > I’m wondering if the SWIG is having trouble handling the 3-dimensional > array. I’m using swigwin-2.0.4. > > > > Thanks, > > > > Hongbin Wei > > > > Firmware Engineer > > SAS SSD > > Samsung Information Systems America > > San Jose, CA > > ------------------------------------------------------------------------------ > All the data continuously generated in your IT infrastructure contains a > definitive record of customers, application performance, security > threats, fraudulent activity and more. Splunk takes this data and makes > sense of it. Business sense. IT sense. Common sense. > http://p.sf.net/sfu/splunk-d2dcopy1 > _______________________________________________ > Swig-user mailing list > Swi...@li... > https://lists.sourceforge.net/lists/listinfo/swig-user > > |