Jackie
Jackie

Reputation: 23577

Confused by function signature

So I am playing around with porting PRBoom to arm and I can across an issue...

There is the following code....

R_DrawColumn_f R_GetDrawColumnFunc(enum column_pipeline_e type,
                               enum draw_filter_type_e filter,
                               enum draw_filter_type_e filterz) {
  R_DrawColumn_f result = drawcolumnfuncs[V_GetMode()][filterz][filter][type];
  if (result == NULL)
    I_Error("R_GetDrawColumnFunc: undefined function (%d, %d, %d)",
        type, filter, filterz);
  return result;
}

Which produces

04-12 12:58:45.970: E/DJNI(16943): Sys Error: R_GetDrawColumnFunc: undefined function (2, 1, 0)

So it is my understanding that the drawcolumnfuncs method is going haywire. But here is where I struggle, I am not sure what this function sig is doing...

static R_DrawColumn_f drawcolumnfuncs[VID_MODEMAX][RDRAW_FILTER_MAXFILTERS][RDRAW_FILTER_MAXFILTERS][RDC_PIPELINE_MAXPIPELINES] = {
{
  {
    {NULL, NULL, NULL, NULL,},
    {R_DrawColumn8_PointUV,
     R_DrawTLColumn8_PointUV,
     R_DrawTranslatedColumn8_PointUV,
     R_DrawFuzzColumn8_PointUV,},
    {R_DrawColumn8_LinearUV,
     R_DrawTLColumn8_LinearUV,
     R_DrawTranslatedColumn8_LinearUV,
     R_DrawFuzzColumn8_LinearUV,},
    {R_DrawColumn8_RoundedUV,
     R_DrawTLColumn8_RoundedUV,
     R_DrawTranslatedColumn8_RoundedUV,
     R_DrawFuzzColumn8_RoundedUV,},
  },
...

Which just looks like it is making a C version of a HashMap but why would it return null then?

Upvotes: 0

Views: 72

Answers (1)

Medinoc
Medinoc

Reputation: 6608

Tis not a function, sir, merely an array.

And it says in this array that if the second index is zero, all its contents is NULL. And its second index is your function's third argument, which happens to be zero.

Which means your function R_GetDrawColumnFunc is being called with the wrong arguments.

Upvotes: 3

Related Questions