示例#1
0
static void L_wdFont(void)
{
 int type_face = (int)luaL_check_number(1);
 int style = (int)luaL_check_number(2);
 double size = (double)luaL_check_number(3);
 wdFont(type_face,style,size);
}
示例#2
0
static void L_wdPointInRegion(void)
{
 double x = (double)luaL_check_number(1);
 double y = (double)luaL_check_number(2);
 int L_result = wdPointInRegion(x,y);
 lua_pushnumber((double)L_result);
}
示例#3
0
static void L_wdMultiLineVectorText(void)
{
 double x = (double)luaL_check_number(1);
 double y = (double)luaL_check_number(2);
 char* s = (char*)luaL_check_string(3);
 wdMultiLineVectorText(x,y,s);
}
示例#4
0
static void L_wdVectorTextSize(void)
{
 double size_x = (double)luaL_check_number(1);
 double size_y = (double)luaL_check_number(2);
 char* s = (char*)luaL_check_string(3);
 wdVectorTextSize(size_x,size_y,s);
}
示例#5
0
static void PlotTransform(void)
{
  Ihandle *ih = iuplua_checkihandle(1);
  int ix, iy;
  IupPlotTransform(ih, (float)luaL_check_number(2), (float)luaL_check_number(3), &ix, &iy);
  lua_pushnumber(ix);
  lua_pushnumber(iy);
}
示例#6
0
static void L_wdVectorTextDirection(void)
{
 double x1 = (double)luaL_check_number(1);
 double y1 = (double)luaL_check_number(2);
 double x2 = (double)luaL_check_number(3);
 double y2 = (double)luaL_check_number(4);
 wdVectorTextDirection(x1,y1,x2,y2);
}
示例#7
0
static void L_wdViewport(void)
{
 int xmin = (int)luaL_check_number(1);
 int xmax = (int)luaL_check_number(2);
 int ymin = (int)luaL_check_number(3);
 int ymax = (int)luaL_check_number(4);
 wdViewport(xmin,xmax,ymin,ymax);
}
示例#8
0
static void L_wdLine(void)
{
 double x1 = (double)luaL_check_number(1);
 double y1 = (double)luaL_check_number(2);
 double x2 = (double)luaL_check_number(3);
 double y2 = (double)luaL_check_number(4);
 wdLine(x1,y1,x2,y2);
}
示例#9
0
static void L_wdRect(void)
{
 double xmin = (double)luaL_check_number(1);
 double xmax = (double)luaL_check_number(2);
 double ymin = (double)luaL_check_number(3);
 double ymax = (double)luaL_check_number(4);
 wdRect(xmin,xmax,ymin,ymax);
}
示例#10
0
static void str_format (void)
{
  int32 arg = 1;
  const char *strfrmt = luaL_check_string(arg);
  struct Capture cap;
  cap.src_end = strfrmt+strlen(strfrmt)+1;
  luaL_resetbuffer();
  while (*strfrmt) {
    if (*strfrmt != '%')
      luaL_addchar(*strfrmt++);
    else if (*++strfrmt == '%')
      luaL_addchar(*strfrmt++);  /* %% */
    else { /* format item */
      char form[MAX_FORMAT];      /* store the format ('%...') */
      char *buff;
      const char *initf = strfrmt;
      form[0] = '%';
      cap.level = 0;
      if (isdigit((byte)initf[0]) && initf[1] == '$') {
        arg = initf[0] - '0';
        initf += 2;  /* skip the 'n$' */
      }
      arg++;
      strfrmt = match(initf, "[-+ #0]*(%d*)%.?(%d*)", &cap);
      if (cap.capture[0].len > 2 || cap.capture[1].len > 2)  /* < 100? */
        lua_error("invalid format (width or precision too long)");
      strncpy(form+1, initf, strfrmt-initf+1); /* +1 to include conversion */
      form[strfrmt-initf+2] = 0;
      buff = luaL_openspace(1000);  /* to store the formatted value */
      switch (*strfrmt++) {
        case 'q':
          luaI_addquoted(luaL_check_string(arg));
          continue;
        case 's': {
          const char *s = luaL_check_string(arg);
          buff = luaL_openspace(strlen(s));
          sprintf(buff, form, s);
          break;
        }
        case 'c':  case 'd':  case 'i':
          sprintf(buff, form, (int)luaL_check_number(arg));
          break;
        case 'o':  case 'u':  case 'x':  case 'X':
          sprintf(buff, form, (unsigned int)luaL_check_number(arg));
          break;
        case 'e':  case 'E': case 'f': case 'g': case 'G':
          sprintf(buff, form, luaL_check_number(arg));
          break;
        default:  /* also treat cases 'pnLlh' */
          lua_error("invalid option in `format'");
      }
      luaL_addsize(strlen(buff));
    }
  }
  closeandpush();  /* push the result */
}
示例#11
0
static void math_max (void) {
  int i = 1;
  double dmax = luaL_check_number(i);
  while (lua_getparam(++i) != LUA_NOOBJECT) {
    double d = luaL_check_number(i);
    if (d > dmax)
      dmax = d;
  }
  lua_pushnumber(dmax);
}
示例#12
0
static void math_max() {
	int32 i = 1;
	float dmax = luaL_check_number(i);
	while (lua_getparam(++i) != LUA_NOOBJECT) {
		float d = luaL_check_number(i);
		if (d > dmax)
			dmax = d;
	}
	lua_pushnumber(dmax);
}
示例#13
0
static void math_min (void)
{
  int32 i = 1;
  double dmin = luaL_check_number(i);
  while (lua_getparam(++i) != LUA_NOOBJECT) {
    double d = luaL_check_number(i);
    if (d < dmin)
      dmin = d;
  }
  lua_pushnumber(dmin);
}
示例#14
0
static int math_min (lua_State *L) {
  int n = lua_gettop(L);  /* number of arguments */
  double dmin = luaL_check_number(L, 1);
  int i;
  for (i=2; i<=n; i++) {
    double d = luaL_check_number(L, i);
    if (d < dmin)
      dmin = d;
  }
  lua_pushnumber(L, dmin);
  return 1;
}
示例#15
0
static int math_max (lua_State *L) {
  int n = lua_gettop(L);  /* number of arguments */
  double dmax = Re(luaL_check_number(L, 1));
  int i;
  for (i=2; i<=n; i++) {
    double d = Re(luaL_check_number(L, i));
    if (d > dmax)
      dmax = d;
  }
  lua_pushnumber(L, dmax);
  return 1;
}
示例#16
0
static void settag (void)
{
  lua_Object o = luaL_tablearg(1);
  lua_pushobject(o);
  lua_settag((int32)luaL_check_number(2));
  lua_pushobject(o);  /* returns first argument */
}
示例#17
0
static void settagmethod (void)
{
  lua_Object nf = luaL_nonnullarg(3);
  lua_pushobject(nf);
  lua_pushobject(lua_settagmethod((int32)luaL_check_number(1),
                                  luaL_check_string(2)));
}
static int _sleep(lua_State *lua_state)
{
   double dtime = luaL_check_number(lua_state, 1);
   DWORD time = (DWORD) (dtime*1000);
   Sleep(time);

   return 0; /* returns no values to lua */
}
示例#19
0
static void str_format (void)
{
  int arg = 1;
  char *strfrmt = luaL_check_string(arg++);
  luaI_emptybuff();  /* initialize */
  while (*strfrmt) {
    if (*strfrmt != '%')
      luaI_addchar(*strfrmt++);
    else if (*++strfrmt == '%')
      luaI_addchar(*strfrmt++);  /* %% */
    else { /* format item */
      char form[MAX_FORMAT];      /* store the format ('%...') */
      char *buff;
      char *initf = strfrmt-1;  /* -1 to include % */
      strfrmt = match(strfrmt, "[-+ #]*(%d*)%.?(%d*)", 0);
      if (capture[0].len > 3 || capture[1].len > 3)  /* < 1000? */
        lua_error("invalid format (width or precision too long)");
      strncpy(form, initf, strfrmt-initf+1); /* +1 to include convertion */
      form[strfrmt-initf+1] = 0;
      buff = openspace(1000);  /* to store the formated value */
      switch (*strfrmt++) {
        case 'q':
          luaI_addquoted(luaL_check_string(arg++));
          continue;
        case 's': {
          char *s = luaL_check_string(arg++);
          buff = openspace(strlen(s));
          sprintf(buff, form, s);
          break;
        }
        case 'c':  case 'd':  case 'i': case 'o':
        case 'u':  case 'x':  case 'X':
          sprintf(buff, form, (int)luaL_check_number(arg++));
          break;
        case 'e':  case 'E': case 'f': case 'g':
          sprintf(buff, form, luaL_check_number(arg++));
          break;
        default:  /* also treat cases 'pnLlh' */
          lua_error("invalid format option in function `format'");
      }
      lbuffer.size += strlen(buff);
    }
  }
  lua_pushstring(luaI_addchar(0));  /* push the result */
}
示例#20
0
static void str_rep (void)
{
  char *s = luaL_check_string(1);
  int n = (int)luaL_check_number(2);
  luaI_emptybuff();
  while (n-- > 0)
    addstr(s);
  lua_pushstring(luaI_addchar(0));
}
示例#21
0
static void str_sub (void)
{
  int32 l;
  const char *s = luaL_check_lstr(1, &l);
  int32 start = posrelat((int32)luaL_check_number(2), l);
  int32 end = posrelat((int32)luaL_opt_number(3, -1), l);
  if (1 <= start && start <= end && end <= l)
    lua_pushlstring(s+start-1, end-start+1);
  else lua_pushstring("");
}
示例#22
0
static void str_rep (void)
{
  int32 l;
  const char *s = luaL_check_lstr(1, &l);
  int32 n = (int32)luaL_check_number(2);
  luaL_resetbuffer();
  while (n-- > 0)
    addnchar(s, l);
  closeandpush();
}
示例#23
0
static void str_char (void) {
  int32 i = 0;
  luaL_resetbuffer();
  while (lua_getparam(++i) != LUA_NOOBJECT) {
    double c = luaL_check_number(i);
    luaL_arg_check((byte)c == c, i, "invalid value");
    luaL_addchar((int32)c);
  }
  closeandpush();
}
示例#24
0
static int math_sqrt (lua_State *L) {
	
  lua_pushnumber(L, sqrt(luaL_check_number(L, 1)));
  return 1;

//	CComplex x;
//	x = sqrt(lua_tonumber(L,1));
//	lua_pushnumber(L,x);
//	return 1;
}
static int _kill_process(lua_State *lua_state)
{
   DWORD pid = (DWORD)luaL_check_number(lua_state, 1);
   HANDLE hProcess = OpenProcess(PROCESS_TERMINATE,0,pid);

   if (hProcess != NULL)
   {
      TerminateProcess(hProcess, 0);
      CloseHandle(hProcess);
   }

   return 0;
}
示例#26
0
/*
** Return the substring of a string
*/
static void str_sub (void)
{
  char *s = luaL_check_string(1);
  long l = strlen(s);
  long start = (long)luaL_check_number(2);
  long end = (long)luaL_opt_number(3, -1);
  if (start < 0) start = l+start+1;
  if (end < 0) end = l+end+1;
  if (1 <= start && start <= end && end <= l) {
    luaI_emptybuff();
    addnchar(s+start-1, end-start+1);
    lua_pushstring(luaI_addchar(0));
  }
  else lua_pushstring("");
}
示例#27
0
static void L_wdChord(void)
{
 double xc = (double)luaL_check_number(1);
 double yc = (double)luaL_check_number(2);
 double w = (double)luaL_check_number(3);
 double h = (double)luaL_check_number(4);
 double angle1 = (double)luaL_check_number(5);
 double angle2 = (double)luaL_check_number(6);
 wdChord(xc,yc,w,h,angle1,angle2);
}
示例#28
0
static int param_action(Ihandle* dialog, int param_index, void* user_data)
{
  int ret = 1;
  getparam_data* gp = (getparam_data*)user_data;
  if (gp->has_func)
  {
    lua_Object func;
    lua_beginblock();
    func = lua_getref(gp->func_ref);
    iuplua_pushihandle(dialog);
    lua_pushnumber(param_index);
    lua_callfunction(func);
    ret = (int)luaL_check_number(1);
    lua_endblock();
  }
  return ret;
}
示例#29
0
static void GetParam(void)
{
  getparam_data gp;
  lua_Object func;
  const char* title = luaL_check_string(1);
  void* user_data = (void*)&gp;
  const char* format = luaL_check_string(3);
  int param_count, param_extra, i, size, ret,
      line_size = 0, lua_param_start = 4;
  const char* f = format;
  const char* s;
  void* param_data[50];
  char param_type[50];

  gp.has_func = 0;
  gp.func_ref = 0;

  memset(param_data, 0, sizeof(void*)*50);
  memset(param_type, 0, sizeof(char)*50);

  param_count = IupGetParamCount(format, &param_extra);

  for (i = 0; i < param_count; i++)
  {
    char* t = IupGetParamType(f, &line_size);

    if (*t == 't') /* if separator */
    {
      f += line_size;
      i--; /* compensate next increment */
      continue;
    }

    switch(*t)
    {
    case 'b':
    case 'i':
    case 'l':
      param_data[i] = malloc(sizeof(int));
      *(int*)(param_data[i]) = (int)luaL_check_number(lua_param_start); lua_param_start++;
      break;
    case 'a':
    case 'r':
      param_data[i] = malloc(sizeof(float));
      *(float*)(param_data[i]) = (float)luaL_check_number(lua_param_start); lua_param_start++;
      break;
    case 's':
    case 'm':
      s = luaL_check_string(lua_param_start); lua_param_start++;
      size = strlen(s);
      if (size < 512)
        param_data[i] = malloc(512);
      else
        param_data[i] = malloc(2*size);
      memcpy(param_data[i], s, size+1);
      break;
    }

    param_type[i] = *t;
    f += line_size;
  }

  func = lua_getparam(2);
  if (lua_isfunction(func))
  {
    lua_pushobject(func);
    gp.func_ref = lua_ref(1);
    gp.has_func = 1;
  }

  ret = IupGetParamv(title, param_action, user_data, format, param_count, param_extra, param_data);

  lua_pushnumber(ret);

  if (ret)
  {
    for (i = 0; i < param_count; i++)
    {
      switch(param_type[i])
      {
      case 'b':
      case 'i':
      case 'l':
        lua_pushnumber(*(int*)(param_data[i]));
        break;
      case 'a':
      case 'r':
        lua_pushnumber(*(float*)(param_data[i]));
        break;
      case 's':
      case 'm':
        lua_pushstring((char*)(param_data[i]));
        break;
      }
    }
  }

  for (i = 0; i < param_count; i++)
  {
    free(param_data[i]);
  }

  if (gp.has_func)
    lua_unref(gp.func_ref);
}
示例#30
0
static void gettagmethod() {
	lua_pushobject(lua_gettagmethod((int32)luaL_check_number(1), luaL_check_string(2)));
}