Jump to content

I am trying to take apart a library, but I need help

- - - - -

  • Please log in to reply
3 replies to this topic

#1
Guest_x42_*

Guest_x42_*
  • Guests
after having given up help from humans :mad:, I decided to take apart this allegro library, but I need help figuring out what this means:

typedef struct MOUSE_DRIVER

{

   int  id;

   AL_CONST char *name;

   AL_CONST char *desc;

   AL_CONST char *ascii_name;

   AL_METHOD(int,  init, (void));

   AL_METHOD(void, exit, (void));

   AL_METHOD(void, poll, (void));

   AL_METHOD(void, timer_poll, (void));

   AL_METHOD(void, position, (int x, int y));

   AL_METHOD(void, set_range, (int x1, int y_1, int x2, int y2));

   AL_METHOD(void, set_speed, (int xspeed, int yspeed));

   AL_METHOD(void, get_mickeys, (int *mickeyx, int *mickeyy));

   AL_METHOD(int,  analyse_data, (AL_CONST char *buffer, int size));

   AL_METHOD(void, enable_hardware_cursor, (int mode));

   AL_METHOD(int,  select_system_cursor, (int cursor));

} MOUSE_DRIVER;

I don't want you to explain all that, just explain if this was a type definition, a data structure, or something else, because I don't know what this is

#2
WingedPanther

WingedPanther

    A spammer's worst nightmare

  • Moderators
  • 16,831 posts
  • Location:Upstate, South Carolina
  • Programming Language:C, C++, PL/SQL, Delphi/Object Pascal, Pascal, Transact-SQL, Others
  • Learning:Java, C#, PHP, JavaScript, Lisp, Fortran, Haskell, Others
MOUSE_DRIVER is a struct.
Programming is a branch of mathematics.
My CodeCall Blog | My Personal Blog

#3
Guest_x42_*

Guest_x42_*
  • Guests
ok, then what does the "typedef" mean, I mean I know what it means, but I don't know why it is there (and do you think you can explain some of the random looking code in the structure?, like say the functions?)

#4
julmuri

julmuri

    Programmer

  • Members
  • PipPipPipPip
  • 139 posts
It is a type of structure that defines four types of public variables
   int  id;
   AL_CONST char *name;
   AL_CONST char *desc;
   AL_CONST char *ascii_name
I suppose that AL_CONST is equivalent of const, ie
#define AL_CONST const
And rest are member functions:
   AL_METHOD(int,  init, (void));
   AL_METHOD(void, exit, (void));
   AL_METHOD(void, poll, (void));
   AL_METHOD(void, timer_poll, (void));
   AL_METHOD(void, position, (int x, int y));
   AL_METHOD(void, set_range, (int x1, int y_1, int x2, int y2));
   AL_METHOD(void, set_speed, (int xspeed, int yspeed));
   AL_METHOD(void, get_mickeys, (int *mickeyx, int *mickeyy));
   AL_METHOD(int,  analyse_data, (AL_CONST char *buffer, int size));
   AL_METHOD(void, enable_hardware_cursor, (int mode));
   AL_METHOD(int,  select_system_cursor, (int cursor));
AL_METHOD being
#define AL_METHOD( ret, name, ... ) ret name( ... ) 
or some such, macro horror.
You can look up the definitions.
std::string s("oberq zhpu?");std::for_each(s.begin(),s.end(),[&](char&c){c=~c;c=~c-0x01/(~(c|0x20)/0x0D*0x02-0x0B)*0x0D;});std::cout<<s;




1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users