#include <stdint.h>
#include <tcl.h>


static int Test1_cmd(ClientData cdata, Tcl_Interp *interp, int objc,
	Tcl_Obj *const objv[])
{
	int src = 10, dst = 0;

	const Tcl_ArgvInfo arg_table[] =
	{
		{TCL_ARGV_CONSTANT, "-opt", &src, &dst, "Help", 0}
	};
	if(Tcl_ParseArgsObjv(interp, arg_table, &objc, objv, NULL) != TCL_OK)
		return TCL_ERROR;

	Tcl_SetObjResult(interp, Tcl_NewIntObj(dst));
	return TCL_OK;
}

static int Test2_cmd(ClientData cdata, Tcl_Interp *interp, int objc,
	Tcl_Obj *const objv[])
{
	int src = 10, dst = 0;

	const Tcl_ArgvInfo arg_table[] =
	{
		{TCL_ARGV_CONSTANT, "-opt", (void *)(intptr_t)src, &dst, "Help", 0}
	};
	if(Tcl_ParseArgsObjv(interp, arg_table, &objc, objv, NULL) != TCL_OK)
		return TCL_ERROR;

	Tcl_SetObjResult(interp, Tcl_NewIntObj(dst));
	return TCL_OK;
}


int Test_Init(Tcl_Interp *interp)
{
	if(Tcl_InitStubs(interp, TCL_VERSION, 0) == NULL)
		return TCL_ERROR;

	if(Tcl_PkgProvide(interp, "test", "1.0") == TCL_ERROR)
		return TCL_ERROR;

	Tcl_CreateObjCommand(interp, "test1", Test1_cmd, NULL, NULL);
	Tcl_CreateObjCommand(interp, "test2", Test2_cmd, NULL, NULL);
	return TCL_OK;
}
