+ex function::expand(unsigned options) const
+{
+ GINAC_ASSERT(serial<registered_functions().size());
+ const function_options &opt = registered_functions()[serial];
+
+ // No expand defined? Then return the same function with expanded arguments (if required)
+ if (opt.expand_f == NULL) {
+ // Only expand arguments when asked to do so
+ if (options & expand_options::expand_function_args)
+ return inherited::expand(options);
+ else
+ return (options == 0) ? setflag(status_flags::expanded) : *this;
+ }
+
+ current_serial = serial;
+ if (opt.expand_use_exvector_args)
+ return ((expand_funcp_exvector)(opt.expand_f))(seq, options);
+ switch (opt.nparams) {
+ // the following lines have been generated for max. @maxargs@ parameters
++++ for N in range(1, maxargs + 1):
+ case @N@:
+ return ((expand_funcp_@N@)(opt.expand_f))(@seq('seq[%(n)d]', N, 0)@, options);
+---
+ // end of generated lines
+ }
+ throw(std::logic_error("function::expand(): no expand of function defined"));
+}
+