예제 #1
0
/***************************************************************************\
* CGM CD_SCLMDE.                                                            *
\***************************************************************************/
static int cgm_sclmdecb(cdCanvas *canvas, short scl_mde, short *draw_mode_i, double *factor_f)
{
    lua_Object func, result, draw_mode, factor;
    int result_i;

    lua_beginblock();
    func = lua_getref(cdluacgmcb[CD_CGMSCLMDECB].lock);

    cdlua_pushcanvas(canvas);
    lua_pushnumber( scl_mde);
    lua_callfunction(func);

    result = lua_getresult(1);
    if (!lua_isnumber(result))
        lua_error("cdPlay: CD_CGMSCLMDECB: invalid return value!");
    result_i = (int) lua_getnumber(result);
    if (result_i == 1) {
        lua_endblock();
        return 1;
    }

    draw_mode = lua_getresult(2);
    if (!lua_isnumber(draw_mode))
        lua_error("cdPlay: CD_CGMSCLMDECB: invalid draw_mode return value!");
    *draw_mode_i = (short) lua_getnumber(draw_mode);

    factor = lua_getresult(3);
    if (!lua_isnumber(factor))
        lua_error("cdPlay: CD_CGMSCLMDECB: invalid factor return value!");
    *factor_f = (double) lua_getnumber(factor);

    lua_endblock();

    return result_i;
}
예제 #2
0
파일: cdlua5ctx.c 프로젝트: Vulcanior/IUP
/***************************************************************************\
* CGM CD_SCLMDE.                                                            *
\***************************************************************************/
static int cgm_sclmdecb(cdCanvas *canvas, short scl_mde, short *draw_mode_i, double *factor_f)
{
  int result_i;
  /* little Wrapper */
  lua_State * L = cdlua_getplaystate();

  lua_rawgeti(L, LUA_REGISTRYINDEX, cdluacgmcb[CD_CGMSCLMDECB].lock);

  cdlua_pushcanvas(L, canvas);
  lua_pushnumber(L, scl_mde);
  if(lua_pcall(L, 2, 3, 0) != 0)
    luaL_error(L, "error running function: %s", lua_tostring(L, -1));

  if (!lua_isnumber(L, -3))
    luaL_error(L, "invalid return value");

  result_i = (int)luaL_checkinteger(L, -3);

  if (result_i == 1)
    return 1;
  
  if (!lua_isnumber(L, -2))
    luaL_error(L, "invalid draw mode return value");
  *draw_mode_i = (short) lua_tonumber(L,-2);

  if (!lua_isnumber(L, -1))
    luaL_error(L, "invalid factor return value");

  *factor_f = (double) lua_tonumber(L, -1);

  return result_i;
}
예제 #3
0
static int matrix_draw_cb(Ihandle *self, int p0, int p1, int p2, int p3, int p4, int p5, cdCanvas* cnv)
{
  lua_State *L = iuplua_call_start(self, "draw_cb");
  lua_pushnumber(L, p0);
  lua_pushnumber(L, p1);
  lua_pushnumber(L, p2);
  lua_pushnumber(L, p3);
  lua_pushnumber(L, p4);
  lua_pushnumber(L, p5);
  cdlua_pushcanvas(L, cnv);
  return iuplua_call(L, 7);
}
예제 #4
0
/***************************************************************************\
* CGM CD_VDCEXTCB.                                                          *
\***************************************************************************/
static int cgm_vdcextcb(cdCanvas *canvas, short type, void *xmn, void *ymn, void *xmx, void *ymx)
{
    lua_Object func, result, xmn_l, ymn_l, xmx_l, ymx_l;
    int result_i;

    lua_beginblock();
    func = lua_getref(cdluacgmcb[CD_CGMVDCEXTCB].lock);

    cdlua_pushcanvas(canvas);
    lua_callfunction(func);

    result = lua_getresult(1);
    if (!lua_isnumber(result))
        lua_error("cdPlay: CD_CGMVDCEXTCB: invalid return value!");
    result_i = (int) lua_getnumber(result);
    if (result_i == 1) {
        lua_endblock();
        return 1;
    }

    xmn_l = lua_getresult(2);
    if (!lua_isnumber(xmn_l))
        lua_error("cdPlay: CD_CGMVDCEXTCB: invalid xmn return value!");
    if (type == 1) *((float *) xmn) = (float) lua_getnumber(xmn_l);
    else *((int *) xmn) = (int) lua_getnumber(xmn_l);

    ymn_l = lua_getresult(3);
    if (!lua_isnumber(ymn_l))
        lua_error("cdPlay: CD_CGMVDCEXTCB: invalid ymn return value!");
    if (type == 1) *((float *) ymn) = (float) lua_getnumber(ymn_l);
    else *((int *) ymn) = (int) lua_getnumber(ymn_l);

    xmx_l = lua_getresult(4);
    if (!lua_isnumber(xmx_l))
        lua_error("cdPlay: CD_CGMVDCEXTCB: invalid xmx return value!");
    if (type == 1) *((float *) xmx) = (float) lua_getnumber(xmx_l);
    else *((int *) xmx) = (int) lua_getnumber(xmx_l);

    ymx_l = lua_getresult(5);
    if (!lua_isnumber(ymx_l))
        lua_error("cdPlay: CD_CGMVDCEXTCB: invalid ymx return value!");
    if (type == 1) *((float *) ymx) = (float) lua_getnumber(ymx_l);
    else *((int *) ymx) = (int) lua_getnumber(ymx_l);

    lua_endblock();

    return result_i;
}
예제 #5
0
파일: cdlua5ctx.c 프로젝트: Vulcanior/IUP
/***************************************************************************\
* CGM CD_BEGPICTBCB.                                                         *
\***************************************************************************/
static int cgm_begpictbcb(cdCanvas *canvas)
{
  /* little Wrapper */
  lua_State * L = cdlua_getplaystate();

  lua_rawgeti(L, LUA_REGISTRYINDEX, cdluacgmcb[CD_CGMBEGPICTBCB].lock);

  cdlua_pushcanvas(L, canvas);
  if(lua_pcall(L, 1, 1, 0) != 0)
    luaL_error(L, "error running function: %s", lua_tostring(L, -1));

  if (!lua_isnumber(L, -1))
    luaL_error(L, "invalid return value");
    
  return (int)luaL_checkinteger(L,-1);
}
예제 #6
0
static int cgm_begmtfcb(cdCanvas *canvas, int *xmn, int *ymn, int *xmx, int *ymx)
{
    lua_Object func, result, xmn_l, ymn_l, xmx_l, ymx_l;
    int result_i;

    lua_beginblock();
    func = lua_getref(cdluacgmcb[CD_CGMBEGMTFCB].lock);

    cdlua_pushcanvas(canvas);
    lua_callfunction(func);

    result = lua_getresult(1);
    if (!lua_isnumber(result))
        lua_error("cdPlay: CD_CGMBEGMTFCB: invalid return value!");
    result_i = (int) lua_getnumber(result);
    if (result_i == 1) {
        lua_endblock();
        return 1;
    }

    xmn_l = lua_getresult(2);
    if (!lua_isnumber(xmn_l))
        lua_error("cdPlay: CD_CGMBEGMTFCB: invalid xmn return value!");
    *xmn = (int) lua_getnumber(xmn_l);

    ymn_l = lua_getresult(3);
    if (!lua_isnumber(ymn_l))
        lua_error("cdPlay: CD_CGMBEGMTFCB: invalid ymn return value!");
    *ymn = (int) lua_getnumber(ymn_l);

    xmx_l = lua_getresult(4);
    if (!lua_isnumber(xmx_l))
        lua_error("cdPlay: CD_CGMBEGMTFCB: invalid xmx return value!");
    *xmx = (int) lua_getnumber(xmx_l);

    ymx_l = lua_getresult(5);
    if (!lua_isnumber(ymx_l))
        lua_error("cdPlay: CD_CGMBEGMTFCB: invalid ymx return value!");
    *ymx = (int) lua_getnumber(ymx_l);

    lua_endblock();

    return result_i;
}
예제 #7
0
파일: cdlua5ctx.c 프로젝트: Vulcanior/IUP
static int cdlua5_sizecb(cdCanvas *canvas, int w, int h, double mm_w, double mm_h, int lock)
{
  /* little Wrapper */
  lua_State * L = cdlua_getplaystate();
  lua_rawgeti(L, LUA_REGISTRYINDEX, lock);

  cdlua_pushcanvas(L, canvas);
  lua_pushnumber(L, w);
  lua_pushnumber(L, h);
  lua_pushnumber(L, mm_w);
  lua_pushnumber(L, mm_h);
  if(lua_pcall(L, 5, 1, 0) != 0)
    luaL_error(L, "error running function: %s", lua_tostring(L, -1));

  if (!lua_isnumber(L,-1))
    luaL_error(L, "invalid return value");

  return (int)luaL_checkinteger(L,-1);
}
예제 #8
0
/***************************************************************************\
* CGM CD_BEGPICTBCB.                                                         *
\***************************************************************************/
static int cgm_begpictbcb(cdCanvas *canvas)
{
    lua_Object func, result;
    int result_i;

    lua_beginblock();
    func = lua_getref(cdluacgmcb[CD_CGMBEGPICTBCB].lock);

    cdlua_pushcanvas(canvas);
    lua_callfunction(func);

    result = lua_getresult(1);
    if (!lua_isnumber(result))
        lua_error("cdPlay: CD_CGMBEGPICTBCB: invalid return value!");
    result_i = (int) lua_getnumber(result);

    lua_endblock();

    return result_i;
}
예제 #9
0
/***************************************************************************\
* CGM CD_COUNTERCB.                                                         *
\***************************************************************************/
static int cgm_countercb(cdCanvas *canvas, double percent)
{
    lua_Object func, result;
    int result_i;

    lua_beginblock();
    func = lua_getref(cdluacgmcb[CD_CGMCOUNTERCB].lock);

    cdlua_pushcanvas(canvas);
    lua_pushnumber( percent);
    lua_callfunction(func);

    result = lua_getresult(1);
    if (!lua_isnumber(result))
        lua_error("cdPlay: CD_CGMCOUNTERCB: invalid return value!");
    result_i = (int) lua_getnumber(result);

    lua_endblock();

    return result_i;
}
예제 #10
0
파일: cdlua5ctx.c 프로젝트: Vulcanior/IUP
/***************************************************************************\
* CGM CD_VDCEXTCB.                                                          *
\***************************************************************************/
static int cgm_vdcextcb(cdCanvas *canvas, short type, void *xmn, void *ymn, void *xmx, void *ymx)
{  
  int result_i;
  /* little Wrapper */
  lua_State * L = cdlua_getplaystate();

  lua_rawgeti(L, LUA_REGISTRYINDEX, cdluacgmcb[CD_CGMVDCEXTCB].lock);

  cdlua_pushcanvas(L, canvas);
  if(lua_pcall(L, 1, 5, 0) != 0)
    luaL_error(L, "error running function: %s", lua_tostring(L, -1));

  if (!lua_isnumber(L, -5))
    luaL_error(L, "invalid return value");
  result_i = (int)luaL_checkinteger(L,-5);
  if (result_i == 1)
    return 1;

  if (!lua_isnumber(L, -4))
    luaL_error(L, "invalid xmn return value");
  if (type == 1) *((double *) xmn) = lua_tonumber(L, -4);
  else *((int *) xmn) = (int)luaL_checkinteger(L, -4);

  if (!lua_isnumber(L, -3))
    luaL_error(L, "invalid ymn return value");
  if (type == 1) *((double *) ymn) = lua_tonumber(L, -3);
  else *((int *) ymn) = (int)luaL_checkinteger(L, -3);

  if (!lua_isnumber(L, -2))
    luaL_error(L,"invalid xmx return value");
  if (type == 1) *((double *) xmx) = lua_tonumber(L, -2);
  else *((int *) xmx) = (int)luaL_checkinteger(L, -2);

  if (!lua_isnumber(L, -1))
    luaL_error(L,"invalid ymx return value");
  if (type == 1) *((double *) ymx) = lua_tonumber(L, -1);
  else *((int *) ymx) = (int) luaL_checkinteger(L, -1);

  return result_i;
}
예제 #11
0
파일: cdlua5ctx.c 프로젝트: Vulcanior/IUP
static int cgm_begmtfcb(cdCanvas *canvas, int *xmn, int *ymn, int *xmx, int *ymx)
{
  int result_i;
  /* little Wrapper */
  lua_State * L = cdlua_getplaystate();

  lua_rawgeti(L, LUA_REGISTRYINDEX, cdluacgmcb[CD_CGMBEGMTFCB].lock);

  cdlua_pushcanvas(L, canvas);
  if(lua_pcall(L, 1, 5, 0) != 0)
    luaL_error(L, "error running function: %s", lua_tostring(L, -1));

  if (!lua_isnumber(L, -5))
    luaL_error(L, "invalid return value");
  
  result_i = (int)luaL_checkinteger(L, -5);
  if (result_i == 1)
    return 1;

  if (!lua_isnumber(L, -4))
    luaL_error(L, "invalid xmn return value");
  *xmn = (int)luaL_checkinteger(L, -4);

  if (!lua_isnumber(L, -3))
    luaL_error(L, "invalid ymn return value");
  *ymn = (int)luaL_checkinteger(L, -3);

  if (!lua_isnumber(L, -2))
    luaL_error(L, "invalid xmx return value");
  *xmx = (int)luaL_checkinteger(L, -2);

  if (!lua_isnumber(L, -1))
    luaL_error(L, "invalid ymx return value");
  *ymx = (int)luaL_checkinteger(L, -1);

  return result_i;
}
예제 #12
0
/***************************************************************************\
* CLIPBOARD CD_SIZECB.                                                      *
\***************************************************************************/
static int clipboard_sizecb(cdCanvas *canvas, int w, int h, double mm_w, double mm_h)
{
    lua_Object func, result;
    int result_i;

    lua_beginblock();
    func = lua_getref(cdluaclipboardcb[CD_SIZECB].lock);

    cdlua_pushcanvas(canvas);
    lua_pushnumber( w);
    lua_pushnumber( h);
    lua_pushnumber( mm_w);
    lua_pushnumber( mm_h);
    lua_callfunction(func);

    result = lua_getresult(1);
    if (!lua_isnumber(result))
        lua_error("cdPlay: CD_SIZECB: invalid return value!");
    result_i = (int) lua_getnumber(result);

    lua_endblock();

    return result_i;
}
예제 #13
0
static int pplot_predraw_cb(Ihandle *self, cdCanvas* cnv)
{
  iuplua_call_start(self, "predraw_cb");
  cdlua_pushcanvas(cnv);
  return iuplua_call();
}
예제 #14
0
static int plot_predraw_cb(Ihandle *self, cdCanvas* cnv)
{
  lua_State *L = iuplua_call_start(self, "predraw_cb");
  cdlua_pushcanvas(L, cnv);
  return iuplua_call(L, 1);
}