Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add documentaiton string for defun() #111

Closed
wants to merge 2 commits into from

Conversation

k-okada
Copy link
Member

@k-okada k-okada commented May 13, 2015

DO NOT MEARGE UNTIL NEXT VACATION

see #75 for discussion

  • add NULL documentation string
  • add argument to defun for adding documentation string to functions written by C

@k-okada
Copy link
Member Author

k-okada commented May 13, 2015

I tried to use optional argument as follow, but this sometimes segfaults... not sure why

#ifdef USE_STDARG
pointer defun(register context *ctx, char *name, pointer mod, pointer (*f)(), ...)
#else
pointer defun(ctx,name,mod,f)
register context *ctx;
char *name;
pointer mod;
pointer (*f)();
#endif
{ register pointer sym,pkg,pdoc;
  char* doc = NULL;
#ifdef USE_STDARG
  va_list args;
  va_start(args, f);
  doc = va_arg(args, char*);
  printf("name =%s, f=%p(%p), doc=%p\n", name, f, *f, doc);
  va_end(args);
#endif
#if defined(DEFUN_DEBUG) || defined(DEBUG_COUNT)
  static int count=0;

  count++;
#endif
#ifdef DEFUN_DEBUG
  printf( "defun:%d:%s:", count, name );
#endif
  pkg=Spevalof(PACKAGE);
  sym=intern(ctx,name,strlen(name),pkg);
#ifdef USE_STDARG
  if (doc != NULL) {
    pdoc = makestring(doc,strlen(doc));
    vpush(pdoc);
  }
  compfun(ctx, sym, mod, f, pdoc);
  if (doc != NULL) vpop();
#else
  pointer_update(sym->c.sym.spefunc,makecode(mod,f,SUBR_FUNCTION));
#endif
#ifdef DEFUN_DEBUG
  printf( "0x%lx\n", sym->c.sym.spefunc->c.code.entry );
#endif
  return(sym);}

@k-okada
Copy link
Member Author

k-okada commented Jul 11, 2018

closed since this is duplicates of #116

@k-okada k-okada closed this Jul 11, 2018
@k-okada k-okada reopened this Jul 18, 2018
@k-okada
Copy link
Member Author

k-okada commented Jul 18, 2018

@Affonso-Gui
We have to re-compile roseus, to solve #291 problem,

  • in general change of euslisp which require re-compilation of downstream package is not a good idea
  • for for documentation, I think that's worth doing and this force all users to write documentation. so we should accept this idea

In order to do this.

  1. merge this
  2. remove macro in https://github.com/euslisp/EusLisp/pull/116/files#diff-326a8ed4a8484866ade7137571f87d54R1078
+#define defun(a, b, c, d) defun(a, b, c, d, NULL)
  1. remove _defun from https://github.com/jsk-ros-pkg/jsk_roseus/blob/1.7.0/roseus/roseus.cpp#L1878

@Affonso-Gui
Copy link
Member

@k-okada
Thanks for the explanation.
I agree with these steps, and would also be glad to start adding documentation to C defined functions.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants