示例#1
0
文件: eel_image.c 项目: olofson/eel
EEL_xno eel_image_init(EEL_vm *vm)
{
	EEL_object *m;
	m = eel_create_module(vm, "SDL_image", img_unload, NULL);
	if(!m)
		return EEL_XMODULEINIT;

	eel_export_cfunction(m, 1, "Load", 1, 0, 0, img_Load);
	eel_export_cfunction(m, 0, "SavePNG", 2, 1, 0, img_SavePNG);

	/* Constants and enums */
	eel_export_lconstants(m, img_constants);

	eel_disown(m);
	return 0;
}
示例#2
0
EEL_xno eb_net_init(EEL_vm *vm)
{
	EEL_object *c;
	EEL_object *m;

	if(eb_sockets)
		return EEL_XDEVICEOPENED;

	m = eel_create_module(vm, "NET2", eb_net_unload, NULL);
	if(!m)
		return EEL_XMODULEINIT;

	eb_sockets = (EEL_object **)eel_malloc(vm,
			NET2_MAX_SOCKETS * sizeof(EEL_object *));
	if(!eb_sockets)
	{
		eel_disown(m);
		return EEL_XMODULEINIT;
	}
	memset(eb_sockets, 0, NET2_MAX_SOCKETS * sizeof(EEL_object *));

	/* Types */
	c = eel_export_class(m, "IPaddress", EEL_COBJECT,
			ipa_construct, NULL, NULL);
	md.ipaddress_cid = eel_class_typeid(c);
	eel_set_metamethod(c, EEL_MM_GETINDEX, ipa_getindex);
	eel_set_metamethod(c, EEL_MM_SETINDEX, ipa_setindex);
	eel_set_casts(vm, md.ipaddress_cid, md.ipaddress_cid, ipa_clone);

	c = eel_export_class(m, "Socket", EEL_COBJECT,
			n2s_construct, n2s_destruct, NULL);
	eel_set_metamethod(c, EEL_MM_GETINDEX, n2s_getindex);
	md.net2_socket_cid = eel_class_typeid(c);

	/* TCP functions */
	eel_export_cfunction(m, 1, "TCPAcceptOn", 1, 0, 0, n2_tcp_accept_on);
	eel_export_cfunction(m, 1, "TCPSend", 1, 0, 1, n2_tcp_send);
	eel_export_cfunction(m, 1, "TCPRead", 1, 0, 0, n2_tcp_read);
	eel_export_cfunction(m, 0, "TCPClose", 1, 0, 0, n2_tcp_close);
	eel_export_cfunction(m, 0, "TCPSetBuffer", 2, 1, 0, n2_tcp_setbuf);

	/* Constants and enums */
	eel_export_lconstants(m, n2_constants);

	eel_disown(m);
	return 0;
}