src/t_pck__format.c
struct t_pck
*t_pck_getPacker( lua_State *L, int pos )
{
	struct t_pck *p = NULL; ///< packer
	int           l = _default_endian;
	int           n = 0;    ///< counter for packers created from fmt string
	int           t = lua_gettop( L );  ///< top of stack before operations
	const char   *fmt;

	pos = lua_absindex( L, pos );

	// T.Pack or T.Pack.Index at pos
	if (lua_isuserdata( L, pos ))
		p    = t_pck_idx_getPackFromStack( L, pos, NULL );
		//p    = t_pck_idx_getPackFromFieldOnStack( L, pos, NULL, 1 );
	else // format string at pos
	{
		fmt = luaL_checkstring( L, pos );
		p   = t_pck_parseFmt( L, &fmt, &l );
		while (NULL != p )
		{
			n++;
			p = t_pck_parseFmt( L, &fmt, &l );
		}
		if (n > 1)
			p =  t_pck_seq_create( L, t+1, lua_gettop( L ) );
		else
			p = t_pck_check_ud( L, -1, 1 );
		lua_replace( L, pos );
	}
	return p;
}
/**--------------------------------------------------------------------------
 * Decides if the element on pos is a packer kind of type.
 * It decides between the following options:
 *     - t.Pack type              : just return it
 *     - t.Pack.Index             : return referenced packer location identifier
 *     - fmt string of single item: fetch from cache or create
 *     - fmt string of multp items: let Sequence constructor handle and return result
 * \param   L      Lua state.
 * \param   pos    position on stack.
 * \param   int*   bit offset runner.
 * \return  struct t_pck* pointer.
 * --------------------------------------------------------------------------*/
Decides if the element on pos is a packer kind of type.
Decides if the element on pos is a packer kind of type .
struct t_pck
*t_pck_getPacker( lua_State *L, int pos )
{
	struct t_pck *p = NULL; 
	int           l = _default_endian;
	int           n = 0;    
	int           t = lua_gettop( L );  
	const char   *fmt;
	pos = lua_absindex( L, pos );
	if (lua_isuserdata( L, pos ))
		p    = t_pck_idx_getPackFromStack( L, pos, NULL );
	else 
	{
		fmt = luaL_checkstring( L, pos );
		p   = t_pck_parseFmt( L, &fmt, &l );
		while (NULL != p )
		{
			n++;
			p = t_pck_parseFmt( L, &fmt, &l );
		}
		if (n > 1)
			p =  t_pck_seq_create( L, t+1, lua_gettop( L ) );
		else
			p = t_pck_check_ud( L, -1, 1 );
		lua_replace( L, pos );
	}
	return p;
}
struct t_pck * t_pck_getPacker ( lua_State * L , int pos ) { struct t_pck * p = NULL ; int l = _default_endian ; int n = 0 ; int t = lua_gettop ( L ) ; const char * fmt ; pos = lua_absindex ( L , pos ) ; if ( lua_isuserdata ( L , pos ) ) p = t_pck_idx_getPackFromStack ( L , pos , NULL ) ; else { fmt = luaL_checkstring ( L , pos ) ; p = t_pck_parseFmt ( L , & fmt , & l ) ; while ( NULL != p ) { n ++ ; p = t_pck_parseFmt ( L , & fmt , & l ) ; } if ( n > 1 ) p = t_pck_seq_create ( L , t + 1 , lua_gettop ( L ) ) ; else p = t_pck_check_ud ( L , -1 , 1 ) ; lua_replace ( L , pos ) ; } return p ; }
Decides if the element on pos is a packer kind of type.
Decides if the element on pos is a packer kind of type .
///< packer ///< counter for packers created from fmt string ///< top of stack before operations // T.Pack or T.Pack.Index at pos //p    = t_pck_idx_getPackFromFieldOnStack( L, pos, NULL, 1 ); // format string at pos