示例#1
0
文件: lv2-ecl.c 项目: psilord/lv2-ecl
const LV2_Descriptor*
lv2_descriptor(uint32_t index)
{
	int lv2_desc_index;

	initialize_plugin_internals();
	initialize_ecl();

	// Trampoline this request to the ECL side, then unpack the resultant
	// return value into something suitable for the caller.

	cl_object obj = 
		cl_funcall(2, c_string_to_object("lv2-descriptor"),
			MAKE_FIXNUM(index));

	printf("C: lv2_descriptor got from lisp:");
	cl_pprint(1, obj);
	cl_princ(1, c_string_to_object("#\\Newline"));

	if (obj == Cnil) {
		// Don't make an association in this case.
		return NULL;
	}

	// Associate the lisp description with a C address of a real LV2_Descriptor
	lv2_desc_index = da_allocate();
	da_associate(lv2_desc_index, obj);

	// The application will use this to talk about this specific plugin.
	return da_get_address(lv2_desc_index);
}
示例#2
0
文件: ecl.cpp 项目: taksatou/embench
std::string ECL::echo(const std::string &s) const {
    cl_object o = cl_funcall(2, c_string_to_object("echo"), ecl_make_pointer((void*)s.c_str()));
    return (char*)ecl_to_pointer(o);
}
示例#3
0
文件: lv2-ecl.c 项目: psilord/lv2-ecl
// Create a new plugin instance.
static LV2_Handle
instantiate(const LV2_Descriptor*     descriptor,
            double                    rate,
            const char*               bundle_path,
            const LV2_Feature* const* features)
{
	char *real_string = NULL;
	int lv2_desc_index;
	int lv2_handle_index;
	DescAssoc *da = NULL;
	LV2_Handle ret;


	// lookup the DescAssoc with this descripter pointer
	lv2_desc_index = da_get_index(descriptor);
	da = da_get_da(lv2_desc_index);

	printf("C: instantiate() for LV2_Desc called:\n"
		"\tlv2_desc_index = %d\n"
		"\tdescriptor = %p\n"
		"\trate = %f\n"
		"\tbundle path = %s\n"
		"\tfeatures array = %p\n", 
		lv2_desc_index, descriptor, rate, bundle_path, features);

	// Call the mirrored lisp instantiate function from the associated
	// lisp version of the lv2-descriptor. This is going to return a
	// cl_object that represents an LV2_Handle.

	// first, get the function we need to call from the right lisp lv2
	// descriptor.
	cl_object lisp_instantiate_function = 
		cl_funcall(2,
			c_string_to_object("lv2-instantiate"),
			da->lisp_lv2_desc);

	
	// Then call it, passing the usual stuff. lisp will return to us the
	// handle it wants back.
	real_string = stringify(bundle_path);
	cl_object lisp_handle =
		cl_funcall(5,
			lisp_instantiate_function,
			da->lisp_lv2_desc,
			ecl_make_double_float(rate),
			c_string_to_object(real_string),
			Cnil);
	free(real_string);

	// Associate the lisp_handle with a duck handle we're going to give to the
	// host.

	lv2_handle_index = hda_allocate();
	hda_associate(lv2_handle_index, 
		lv2_desc_index, lisp_handle);

	// Then, return the fake LV2_Handle to the host.

	ret = hda_get_address(lv2_handle_index);

	return ret;
}
示例#4
0
// Make sure this doesn't get called before 'cl_boot'
int lisp_add(int x, int y)
{
  cl_object sum = cl_funcall(3, c_string_to_object("add"), ecl_make_int(x), ecl_make_int(y));
  return ecl_to_int(sum);
}