trying to understand this code snippit

Hi I need some clarity on how something works in c++

if you take a look at the code below, this is a plugin/ dll that is called from lightwave 3d when the user clicks to activates my plugin

im dissecting the code at the moment, and am trying to understand a few things...

xcall is defined as a macro...
1) is xcall the return type of the activate function, or is it a separate beast?

if not, then what purpose would a line of code like this serve?


2) correct me if im wrong here, but serverdesc is an array of serverrecord, which is a record that takes 3 parameters- is this correct? and so far i have created 2 records, one with all the info that is needs, and one that is empty


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
#include <lwserver.h>
   #include <lwcmdseq.h>
   #include <stdio.h>

   XCALL_( int )
   Activate( long version, GlobalFunc *global, LWModCommand *local,
      void *serverData)
   {
      char cmd[ 128 ];

      if ( version != LWMODCOMMAND_VERSION )
         return AFUNC_BADVERSION;
      sprintf( cmd, "MAKEBOX <%g %g %g> <%g %g %g> <%d %d %d>",
         -0.5, -0.5, -0.5,  0.5, 0.5, 0.5,  1, 1, 1 );
      local->evaluate( local->data, cmd );
      return AFUNC_OK;
   }

   ServerRecord ServerDesc[] = {
      { LWMODCOMMAND_CLASS, "Tutorial_Box1", Activate },
      { NULL }
   };

1. I would need to seed the declaration of XCALL_().
2. Right, but that might be better done with a vector.
is this what you are looking for- it is in the lwserver.h file

1
2
3
4
5
6
7
8
9
10
11
12
#ifdef _MSWIN
    #define XCALL_(t)   t
#endif
#ifdef _XGL
    #define XCALL_(t)   t
#endif
#ifdef _MACOS
    #define XCALL_(t)   t
#endif

#define XCALL_INIT
Q1 The syntax is a bit weird on this; it would be useful to see code that is calling activate(), but I think the return value is being passed to XCALL as an int and XCALL's return value then becomes activates return value. You would do this so you could call activate like this

x = activate(. . .)

and not have to do this

x = XCALL_((int)activate(.......))

Q2 you are correct
Last edited on
Topic archived. No new replies allowed.