Example #1
0
/** Yf --> f(Yf) */
static Object *
apply_Y( Array *spine, unsigned int nargs, Manager *m )
{
    Object *a1, *f;

    if ( nargs >= 1 )
    {
        a1 = array__pop( spine );

        f = OPERAND( a1 );

        /* Replace the operand of the Apply with new object @Yf. */
        SET_OPERAND( a1,
             manager__object( m, apply_type,
                 apply__new( FUNCTION( a1 ), f ), NOFLAGS ) );

        /* Replace the function of the Apply with f. */
        SET_FUNCTION( a1, f );

        return a1;
    }

    else
        return 0;
}
Example #2
0
/** Wxy --> xyy */
static Object *
apply_W( Array *spine, unsigned int nargs, Manager *m )
{
    Object *a1, *a2;

    if ( nargs >= 2 )
    {
        a1 = array__pop( spine );
        a2 = array__pop( spine );

        /* Replace the function of the Apply with new object @xy. */
        SET_FUNCTION( a2,
            manager__object( m, apply_type,
                apply__new( OPERAND( a1 ), OPERAND( a2 ) ), NOFLAGS ) );

        /* Replace the operand of the Apply with new object y. */
        SET_OPERAND( a2, OPERAND( a2 ) );

        array__push( spine, a2 );

        return a2;
    }

    else
        return 0;
}
Example #3
0
/** Rxyz --> yzx */
static Object *
apply_R( Array *spine, unsigned int nargs, Manager *m )
{
    Object *a1, *a2, *a3;

    if ( nargs >= 3 )
    {
        a1 = array__pop( spine );
        a2 = array__pop( spine );
        a3 = array__pop( spine );

        /* Replace the function of the Apply with new object @yz. */
        SET_FUNCTION( a3,
            manager__object( m, apply_type,
                apply__new( OPERAND( a2 ), OPERAND( a3 ) ), NOFLAGS ) );

        /* Replace the operand of the Apply with x. */
        SET_OPERAND( a3, OPERAND( a1 ) );

        return a3;
    }

    else
        return 0;
}
Example #4
0
void gf_w32_neon_split_init(gf_t *gf)
{
  gf_internal_t *h = (gf_internal_t *) gf->scratch;

  if (h->region_type & GF_REGION_ALTMAP)
      SET_FUNCTION(gf,multiply_region,w32,gf_w32_split_4_32_lazy_altmap_multiply_region_neon)
  else
      SET_FUNCTION(gf,multiply_region,w32,gf_w32_split_4_32_lazy_multiply_region_neon)

}
Example #5
0
/** wx --> xx */
static Object *
apply_w( Array *spine, unsigned int nargs )
{
    Object *a1;

    if ( nargs >= 1 )
    {
        a1 = array__pop( spine );

        /* Replace the function of the Apply with x. */
        SET_FUNCTION( a1, OPERAND( a1 ) );

        return a1;
    }

    else
        return 0;
}
Example #6
0
/** Txy --> yx */
static Object *
apply_T( Array *spine, unsigned int nargs )
{
    Object *a1, *a2;

    if ( nargs >= 2 )
    {
        a1 = array__pop( spine );
        a2 = array__pop( spine );

        /* Replace the function of the Apply with y. */
        SET_FUNCTION( a2, OPERAND( a2 ) );

        /* Replace the operand of the Apply with x. */
        SET_OPERAND( a2, OPERAND( a1 ) );

        return a2;
    }

    else
        return 0;
}
Example #7
0
void 
reg_luadecoder(lua_State *L)
{
	lua_newtable(L);
	SET_FUNCTION(L,"rpacket",lua_rpacket_decoder_new);
}
Example #8
0
void RegLuaPacket(lua_State *L) {

    luaL_Reg packet_mt[] = {
        {"__gc", destroy_luapacket},
        {NULL, NULL}
    };

    luaL_Reg rpacket_methods[] = {
        {"ReadU8",  ReadUint8},
        {"ReadU16", ReadUint16},
        {"ReadU32", ReadUint32},
        {"ReadI8",  ReadInt8},
        {"ReadI16", ReadInt16},
        {"ReadI32", ReadInt32},        
        {"ReadNum", ReadDouble},        
        {"ReadStr", ReadString},
        {"ReadTable", ReadTable},
        {NULL, NULL}
    };

    luaL_Reg wpacket_methods[] = {                 
        {"WriteU8", WriteUint8},
        {"WriteU16",WriteUint16},
        {"WriteU32",WriteUint32},
        {"WriteNum",WriteDouble},        
        {"WriteStr",WriteString},
        {"WriteTable",WriteTable},
        {"RewriteU8",RewriteUint8},
        {"RewriteU16",RewriteUint16},
        {"RewriteU32",RewriteUint32},
        {"RewriteNum",RewriteDouble},
        {"GetWritePos",GetWritePos},
        {NULL, NULL}
    }; 

    luaL_Reg rawpacket_methods[] = {                 
		{"ReadBinary", ReadBinary},
        {NULL, NULL}
    };

    luaL_Reg cmdrpacket_methods[] = {
        {"ReadU8",  ReadUint8},
        {"ReadU16", ReadUint16},
        {"ReadU32", ReadUint32},
        {"ReadI8",  ReadInt8},
        {"ReadI16", ReadInt16},
        {"ReadI32", ReadInt32},        
        {"ReadNum", ReadDouble},        
        {"ReadStr", ReadString},
        {"ReadTable", ReadTable},
        {"ReadCmd",ReadCmd},
        {NULL, NULL}
    };

    luaL_Reg cmdwpacket_methods[] = {                 
        {"WriteU8", WriteUint8},
        {"WriteU16",WriteUint16},
        {"WriteU32",WriteUint32},
        {"WriteNum",WriteDouble},        
        {"WriteStr",WriteString},
        {"WriteTable",WriteTable},
        {"RewriteU8",RewriteUint8},
        {"RewriteU16",RewriteUint16},
        {"RewriteU32",RewriteUint32},
        {"RewriteNum",RewriteDouble},
        {"WriteCmd",WriteCmd},        
        {"GetWritePos",GetWritePos},
        {NULL, NULL}
    };

    luaL_Reg httppacket_methods[] = {                 
        {"GetUrl", GetUrl},
        {"GetStatus",GetStatus},
        {"GetBody",GetBody},       
        {"GetHeaders",GetHeaders},
        {"GetMethod",GetMethod},
        {NULL, NULL}
    };


    luaL_newmetatable(L, LUARPACKET_METATABLE);
    luaL_setfuncs(L, packet_mt, 0);

    luaL_newlib(L, rpacket_methods);
    lua_setfield(L, -2, "__index");
    lua_pop(L, 1);

    luaL_newmetatable(L, LUAWPACKET_METATABLE);
    luaL_setfuncs(L, packet_mt, 0);

    luaL_newlib(L, wpacket_methods);
    lua_setfield(L, -2, "__index");
    lua_pop(L, 1);

    luaL_newmetatable(L, LUARAWPACKET_METATABLE);
    luaL_setfuncs(L, packet_mt, 0);

    luaL_newlib(L, rawpacket_methods);
    lua_setfield(L, -2, "__index");
    lua_pop(L, 1);

    luaL_newmetatable(L, LUACMDRPACKET_METATABLE);
    luaL_setfuncs(L, packet_mt, 0);

    luaL_newlib(L, cmdrpacket_methods);
    lua_setfield(L, -2, "__index");
    lua_pop(L, 1); 

    luaL_newmetatable(L, LUACMDWPACKET_METATABLE);
    luaL_setfuncs(L, packet_mt, 0);

    luaL_newlib(L, cmdwpacket_methods);
    lua_setfield(L, -2, "__index");
    lua_pop(L, 1);                       

    luaL_newmetatable(L, LUAHTTPPACKET_METATABLE);
    luaL_setfuncs(L, packet_mt, 0);

    luaL_newlib(L, httppacket_methods);
    lua_setfield(L, -2, "__index");
    lua_pop(L, 1); 

    SET_FUNCTION(L,"NewWPacket",NewWPacket);
    SET_FUNCTION(L,"NewRPacket",NewRPacket);
    SET_FUNCTION(L,"NewCmdWPacket",NewCmdWPacket);
    SET_FUNCTION(L,"NewCmdRPacket",NewCmdRPacket);
    SET_FUNCTION(L,"NewRawPacket",NewRawPacket);

}