Example #1
0
static int
showall(struct buffer *bp, KEYMAP *map, char *prefix)
{
	KEYMAP	*newmap;
	char	 buf[80], keybuf[16];
	PF	 fun;
	int	 c;

	if (addline(bp, "") == FALSE)
		return (FALSE);

	/* XXX - 256 ? */
	for (c = 0; c < 256; c++) {
		fun = doscan(map, c, &newmap);
		if (fun == rescan || fun == selfinsert)
			continue;
		getkeyname(buf, sizeof(buf), c);
		(void)snprintf(keybuf, sizeof(keybuf), "%s%s ", prefix, buf);
		if (fun == NULL) {
			if (showall(bp, newmap, keybuf) == FALSE)
				return (FALSE);
		} else {
			if (addlinef(bp, "%-16s%s", keybuf,
				    function_name(fun)) == FALSE)
				return (FALSE);
		}
	}
	return (TRUE);
}
Example #2
0
bool EventListener::Compile()
{
	Rocket::Core::String function_name(64, "Event_%x", this);
	Rocket::Core::String function_code(64, "def %s():", function_name.CString());

	Rocket::Core::StringList lines;
	Rocket::Core::StringUtilities::ExpandString(lines, source_code, ';');
	for (size_t i = 0; i < lines.size(); i++)
	{
		// Python doesn't handle \r's, strip em and indent the code correctly
		function_code += Rocket::Core::String(1024, "\n\t%s", lines[i].CString()).Replace("\r", "");
	}

	ROCKET_ASSERT(element != NULL);

	PyObject* py_namespace = GetGlobalNamespace();

	// Add our function to the namespace
	PyObject* result = PyRun_String(function_code.CString(), Py_file_input, py_namespace, py_namespace);
	if (!result)
	{
		Rocket::Core::Python::Utilities::PrintError();		
		return false;
	}
	Py_DECREF(result);

	// Get a handle to our function
	callable = PyDict_GetItemString(py_namespace, function_name.CString());
	Py_INCREF(callable);

	return true;
}
Example #3
0
void c_call(int  func, int  num_arg) {
    function_t *funp;
    
    func += function_index_offset;
    /*
     * Find the function in the function table. As the
     * function may have been redefined by inheritance, we
     * must look in the last table, which is pointed to by
     * current_object.
     */
    DEBUG_CHECK(func >= current_object->prog->last_inherited +
		current_object->prog->num_functions_defined,
		"Illegal function index\n");
    
    if (current_object->prog->function_flags[func] & FUNC_UNDEFINED)
	error("Undefined function: %s\n", function_name(current_object->prog, func));
    /* Save all important global stack machine registers */
    push_control_stack(FRAME_FUNCTION);
    
    caller_type = ORIGIN_LOCAL;
    /* This assigment must be done after push_control_stack() */
    current_prog = current_object->prog;
    /*
     * If it is an inherited function, search for the real
     * definition.
     */
    csp->num_local_variables = num_arg + num_varargs;
    num_varargs = 0;
    funp = setup_new_frame(func);
    csp->pc = pc;	/* The corrected return address */
    call_program(current_prog, funp->address);
}
static bool resolve_express_is_function(const string express) {
    split_result split(split_string(express,"("));
    string function_name(split.first),function_arg(separate_string(express,"(",")"));

    if (resolve_express_is_function_name(function_name) && !function_arg.empty())
        return true;
    return false;
}
Example #5
0
 Scope(std::ostream &os, const char *debug_ns, const char *func): os_(os), debug_ns_(debug_ns), func_(func)
 {
     if (do_log())
     {
         stream() << ">> " << debug_ns_ << " => " << function_name() << std::endl;
         ++details::Level<Scope>::value;
     }
 }
Example #6
0
 ~Scope()
 {
     if (do_log())
     {
         --details::Level<Scope>::value;
         stream() << "<< " << debug_ns_ << " => " << function_name() << std::endl;
     }
 }
Example #7
0
void am_error(const char *pretty_func, const char *_file,
              int                line, const char *_format, ...)
{
  init();
  if (AM_UNLIKELY(AM_LOG_LEVEL_ERROR <= logLevel)) {
    char text[2*1024]   = {0};
    char module[256]    = {0};
    char func[256]      = {0};
    char file[256]      = {0};
    char format[2*1024] = {0};
    va_list vlist;

    function_name(func, sizeof(func), pretty_func);
    class_name(module, sizeof(module), pretty_func);
    file_name(file, sizeof(file), _file);
    snprintf(format, sizeof(format), "%s", _format);
    if (format[strlen(format) - 1] == '\n') {
      //Eat trailing \n, \n will be added automatically!
      format[strlen(format) - 1] = '\0';
    }
    if (logTarget == AM_LOG_TARGET_SYSLOG) {
      sprintf(text, "[%6s][%s:%d: %s]: %s",
              "ERROR", file, line, func, format);
    } else if (logTarget == AM_LOG_TARGET_FILE) {
      sprintf(text, "[%20s][%6s][%s:%d: %s]: %s",
              module, "ERROR", file, line, func, format);
    } else {
      sprintf(text, "["B_GREEN("%20s")"]["B_RED("%6s")"]"\
              CYAN("[%s:%d: %s]: ")RED("%s"),
              module, "ERROR", file, line, func, format);
    }
    va_start(vlist, _format);
    am_level_logv(module, AM_LOG_LEVEL_ERROR, text, vlist);
    va_end(vlist);
  }
}
string resolve_express_function(const string express) {
    if (!resolve_express_is_function(express)) return "";

    split_result split(split_string(express,"|"));
    string function(split.first),next_function(split.second);
    left_move_string(next_function,1);
    string result;

    while (!function.empty()) {
        if (!resolve_express_is_function(function)) return function;

        split=split_string(function,"(");
        string function_name(upper_string(split.first)),function_arg(separate_string(function,"(",")"));

        if (function_rnd==function_name) {
            function_arg=separate_string(function_arg,"[","]");
            string down,up;
            split=split_string(function_arg,"-");
            if (1<count_string(function_arg,"-")) {
                left_move_string(split.second,1);
                if (resolve_express_is_function(split.second)) {
                    down=split.first;
                    up=split.second;
                    left_move_string(up,1);
                } else {
                    split=split_string(function_arg,")");
                    down=split.first;
                    down+=")";
                    left_move_string(split.second,1);
                    split=split_string(split.second,"-");
                    left_move_string(split.second,1);
                    up=split.second;
                }
            } else {
                down=split.first;
                up=split.second;
                left_move_string(up,1);
            }

            if (down.empty() || up.empty())
                return "";

            if (resolve_express_is_function(down))
                down=resolve_express_function(down);
            if (resolve_express_is_function(up))
                up=resolve_express_function(up);

            long down_=string_to_number(down),up_=string_to_number(up);
            long rnd=ramdon(down_,up_);
            result+=number_to_string(rnd);
        } else if (function_time==function_name) {
        } else if (function_base64==function_name) {
            if (!resolve_express_is_function(function_arg)) {
                return base64_encode(function_arg.c_str(),function_arg.length());
            } else {
                string encode_string(resolve_express_function(function_arg));
                return base64_encode(encode_string.c_str(),encode_string.length());
            }
        } else if (function_len==function_name) {
            unsigned int length=function_arg.length();
            return number_to_string(length);
        }
        split=split_string(next_function,",");
        function=split.first;
        next_function=split.second;
        left_move_string(next_function,1);
    }
    return result;
}
Example #9
0
svalue_t *
call_function_pointer (funptr_t * funp, int num_arg)
{
    static func_t *oefun_table = efun_table - BASE;
    array_t *v;
    
    if (!funp->hdr.owner || (funp->hdr.owner->flags & O_DESTRUCTED))
        error("Owner (/%s) of function pointer is destructed.\n",
              (funp->hdr.owner ? funp->hdr.owner->obname : "(null)"));
    setup_fake_frame(funp);
    if ((v=funp->hdr.args)) {
        check_for_destr(v);
        num_arg = merge_arg_lists(num_arg, v, 0);
    }

    switch (funp->hdr.type) {
    case FP_SIMUL:
        call_simul_efun(funp->f.simul.index, num_arg);
        break;
    case FP_EFUN:
        {
            int i, def;
            fp = sp - num_arg + 1;

            i = funp->f.efun.index;
            if (num_arg == instrs[i].min_arg - 1 && 
                ((def = instrs[i].Default) != DEFAULT_NONE)) {
                if (def == DEFAULT_THIS_OBJECT) {
                    push_object(current_object);
                } else {
                    push_number(def);
                }
                num_arg++;
            } else
                if (num_arg < instrs[i].min_arg) {
                    error("Too few arguments to efun %s in efun pointer.\n", query_instr_name(i));
                } else if (num_arg > instrs[i].max_arg && instrs[i].max_arg != -1) {
                    error("Too many arguments to efun %s in efun pointer.\n", query_instr_name(i));
                }
            /* possibly we should add TRACE, OPC, etc here;
               also on eval_cost here, which is ok for just 1 efun */
            {
                int j, n = num_arg;
                st_num_arg = num_arg;

                if (n >= 4 || instrs[i].max_arg == -1)
                    n = instrs[i].min_arg;

                for (j = 0; j < n; j++) {
                    CHECK_TYPES(sp - num_arg + j + 1, instrs[i].type[j], j + 1, i);
                }
                (*oefun_table[i])();

                free_svalue(&apply_ret_value, "call_function_pointer");
                if (instrs[i].ret_type == TYPE_NOVALUE)
                    apply_ret_value = const0;
                else
                    apply_ret_value = *sp--;
               	remove_fake_frame();
                return &apply_ret_value;
            }
        }
    case FP_LOCAL | FP_NOT_BINDABLE: {
        function_t *func;

        fp = sp - num_arg + 1;

        if (current_object->prog->function_flags[funp->f.local.index] & (FUNC_PROTOTYPE|FUNC_UNDEFINED))
            error("Undefined lfun pointer called: %s\n", function_name(current_object->prog, funp->f.local.index));
        push_control_stack(FRAME_FUNCTION);
        current_prog = funp->hdr.owner->prog;
        
        caller_type = ORIGIN_LOCAL;

        csp->num_local_variables = num_arg;
        func = setup_new_frame(funp->f.local.index);

        call_program(current_prog, func->address);
        break;
    }
    case FP_FUNCTIONAL: 
    case FP_FUNCTIONAL | FP_NOT_BINDABLE: {

        fp = sp - num_arg + 1;
        push_control_stack(FRAME_FUNP);
        current_prog = funp->f.functional.prog;
        csp->fr.funp = funp;
        
        caller_type = ORIGIN_FUNCTIONAL;

        setup_variables(num_arg, funp->f.functional.num_local,
                        funp->f.functional.num_arg);

        function_index_offset = funp->f.functional.fio;
        variable_index_offset = funp->f.functional.vio;
        call_program(funp->f.functional.prog, funp->f.functional.offset);
        break;
    }
    default:
        error("Unsupported function pointer type.\n");
    }
    free_svalue(&apply_ret_value, "call_function_pointer");
    apply_ret_value = *sp--;
    remove_fake_frame();
    return &apply_ret_value;
}
Example #10
0
openGL_function_info::
openGL_function_info(const string &line_from_gl_h_in,
                     const string &APIprefix_type,
                     const string &APIsuffix_type):
  m_returnsValue(false),
  m_createdFrom(line_from_gl_h_in),
  m_use_function_pointer(sm_use_function_pointer_mode)
{
  ++sm_numberFunctions;

  //typical line: expectedAPItype  return-type APIENTRY function-name (argument-list);
  string::size_type firstParen, glStart, glEnd,lastParen, argStart, argEnd;
  string::size_type retBegin,retEnd, frontMaterialEnd;
  string name, retType,argList;
  string line_from_gl_h;

  line_from_gl_h=RemoveEndOfLines(line_from_gl_h_in);

  /* first get the the first parentisis of the line */
  firstParen=line_from_gl_h.find_first_of('(');
  lastParen=line_from_gl_h.find_last_of(')');

  /* here is the argument list without parentesis but with spaces and all */
  argStart=line_from_gl_h.find_first_not_of(' ',firstParen+1);
  argEnd=line_from_gl_h.find_last_not_of(' ',lastParen-1);
  argList=line_from_gl_h.substr(argStart,argEnd-argStart+1);

  if(APIprefix_type.empty())
    {
      retBegin=0;
    }
  else
    {
      retBegin=line_from_gl_h.find(APIprefix_type);
      if(retBegin!=string::npos)
        retBegin+=APIprefix_type.length();
      else
        retBegin=0;
    }

  retEnd=line_from_gl_h.find(APIsuffix_type,retBegin);

  if(retEnd==string::npos)
    {
      //unable to find GLAPIENTRY to mark
      //where the return type ends, so we
      //look for gl
      retEnd=line_from_gl_h.find("gl",retBegin);
    }

  retType=line_from_gl_h.substr(retBegin,retEnd-retBegin);


  /* get the function name by looking at the string before the firstParen */
  glStart=line_from_gl_h.find("gl",retEnd);
  glEnd=line_from_gl_h.rfind(' ',firstParen);
  if(glEnd!=string::npos && glEnd>glStart)
    {
      glEnd--;
    }
  else
    {
      glEnd=firstParen-1;
    }

  /* here is the function name */
  name=line_from_gl_h.substr(glStart,glEnd-glStart+1);

  frontMaterialEnd=line_from_gl_h.find(name);
  m_frontMaterial=line_from_gl_h.substr(0,frontMaterialEnd);

  SetNames(name,retType,argList);

  m_newDeclaration=(sm_lookUp.find(function_name())==sm_lookUp.end());
  if(m_newDeclaration)
    {
      sm_lookUp.insert( pair<string,openGL_function_info*>(function_name(),this) );
    }
  else
    {
      // cout << "Warning: " << function_name() << " in already in list, this object will not be added!\n";
    }
}
Example #11
0
void
openGL_function_info::
output_to_source(ostream &sourceFile)
{
  int i;

  if(!m_newDeclaration)
    {
      //      cerr << "Warning: " << function_name() << " in list twice not putting into source file!\n";
      return;
    }

  //typedef for function pointer type
  sourceFile << "\ntypedef  " << return_type() << "( APIENTRY* " << function_pointer_type()
             << " )("   << full_arg_list_withoutnames() << ");\n";

  if(m_use_function_pointer)
    {
      //declare prototypes:
      sourceFile << front_material() << " " << do_nothing_function_name() << "("
                 << full_arg_list_withoutnames() <<  ");\n";
      sourceFile << "int " << m_existsFunctionName << "(void);\n";
      sourceFile << front_material() << " " << local_function_name() << "("
                 << full_arg_list_with_names() <<  ");\n";
      sourceFile << front_material() << " " << do_nothing_function_name() << "("
                 << full_arg_list_withoutnames() <<  ");\n"
                 << function_pointer_type() << " " << m_getFunctionName << "(void);\n";

      //init the pointer for the function!
      sourceFile << function_pointer_type() << " " << function_pointer_name() << "="
                 << local_function_name() << ";\n\n\n";


      //first the function which holds the initial value of the function pointer:
      sourceFile << front_material() << " " << local_function_name() << "("
                 << full_arg_list_with_names() <<  ")\n{\n\t"
                 << m_getFunctionName << "();\n\t";

      if(returns_value())
        {
          sourceFile << "return ";
        }

      sourceFile << function_pointer_name()
                 << "(" << argument_list_names_only() << ");\n}\n\n";

      //thirdly the do nothing function:
      sourceFile << front_material() << " " << do_nothing_function_name() << "("
                 << full_arg_list_withoutnames() <<  ")\n{\n\t";
      if(returns_value())
        {
            sourceFile << return_type() << " retval = 0;\n\t";
        }
      sourceFile << "return";
      if(returns_value())
        {
          sourceFile << " retval";
        }
      sourceFile << ";\n}\n";

      //fourthly the getFunction, which does the loading.
      sourceFile << function_pointer_type() << " " << m_getFunctionName << "(void)\n{\n\t"
                 << "if(" << function_pointer_name() << "==" << local_function_name()
                 << ")\n\t{\n\t\t" << function_pointer_name() << "=("
                 << function_pointer_type() << ")" << function_loader() << "(\""
                 << function_name() << "\");\n\t\tif(" << function_pointer_name()
                 << "==NULL)\n\t\t{\n\t\t\t"<< function_error_loading() << "(\""
                 << function_name() << "\");\n\t\t\t" << function_pointer_name()
                 << "=" << do_nothing_function_name() << ";\n\t\t}\n\t}\n\t"
                 << "return " << function_pointer_name() << ";\n}\n\n";

      //lastly the exists function:
      sourceFile << "int " << m_existsFunctionName << "(void)\n{\n\t"
                 << m_getFunctionName << "();\n\t"
                 << "return " << function_pointer_name() << "!="
                 << do_nothing_function_name() << ";\n}\n\n";

    }
  else
    {
      sourceFile << function_pointer_type() << " " << function_pointer_name() << "="
                 << m_functionName << ";\n\n\n";
    }



  //second the debug function.
  sourceFile << "#ifdef GL_DEBUG\n"
             << return_type() << " " << debug_function_name()
             << "(";
  if(number_arguments()!=0)
    {
      sourceFile  << full_arg_list_with_names() << ", ";
    }
  sourceFile << "const char *file, int line, const char *call";
  for(int i=0;i<number_arguments();++i)
    {
      sourceFile  << ", const char *argumentName_" << i;
    }


  sourceFile << ")\n{\n\tstd::ostringstream call_stream;\n\t"
             << "std::string call_string;\n\t";


  if(returns_value())
    {
      sourceFile << return_type() << " retval;\n\t";
    }


  if(function_name()=="glBegin")
    {
      sourceFile << inside_begin_end_pair_counter() << "=1;\n\t";
    }

  sourceFile << "call_stream << \"" << function_name() << "(\" ";
  for(i=0;i<number_arguments();++i)
    {
      if(i!=0)
        {
          sourceFile << " << \",\" ";
        }
      sourceFile << "<< argumentName_" << i << " ";
      if(!arg_type_is_pointer(i))
        {
          sourceFile << "<< \"=0x\" ";
        }
      else
        {
          sourceFile << "<< \"=\" ";
        }

      sourceFile << "<< std::hex << argument_" << i << " ";
    }
  sourceFile << "<< \")\";\n\tcall_string=call_stream.str();\n\t";


  sourceFile << function_pregl_error() << "(call_string.c_str(),call,\""
             << function_name() << "\",file,line,(void*)"
             << function_pointer_name() << ");\n\t";

  if(returns_value())
    {
      sourceFile << "retval=";
    }


  sourceFile << function_pointer_name() << "(" << argument_list_names_only()
             << ");\n\t"
             << function_gl_error() << "(call_string.c_str(),call,\""
             << function_name() << "\",file,line,(void*)"
             << function_pointer_name() << ");\n\t";

  if(function_name()=="glEnd")
    {
      sourceFile << inside_begin_end_pair_counter() << "=0;\n\t";
    }
  if(returns_value())
    {
      sourceFile << "return retval;";
    }
  else
    {
      sourceFile << "//no return value";
    }
  sourceFile << "\n}\n#endif\n\n";




}
Example #12
0
void
openGL_function_info::
output_to_header(ostream &headerFile)
{

  if(!m_newDeclaration)
    {
      //      cerr << "Warning: " << function_name() << " in list twice not putting into header file!\n";
      return;
    }

  headerFile << "\ntypedef  " << return_type() << "( APIENTRY* " << function_pointer_type()
             << " )("   << full_arg_list_withoutnames() << ");\n";

  headerFile << "extern " << function_pointer_type() << " "
             << function_pointer_name() << ";\n";

  if(m_use_function_pointer)
    {
      headerFile << "int " << m_existsFunctionName << "(void);\n"
                 << function_pointer_type() << " " << m_getFunctionName << "(void);\n";
    }
  else
    {
      headerFile << "inline int " << m_existsFunctionName << "(void) { return 1; }\n"
                 << "inline " << function_pointer_type() << " " << m_getFunctionName
                 << "(void) { return " << m_functionName << "; }\n";
    }
  headerFile << "#ifdef GL_DEBUG\n";
  headerFile << return_type() << " " << debug_function_name() << "(";

  if(number_arguments()!=0)
    {
      headerFile << full_arg_list_with_names() << ", " ;
    }
  headerFile << "const char *file, int line, const char *call";

  for(int i=0;i<number_arguments();++i)
    {
      headerFile << ", const char *argumentName_" << i;
    }
  headerFile << ");\n"
             << "#define "  << function_name()
             << "(" << argument_list_names_only()
             << ") " << sm_namespace << "::" << debug_function_name()  << "(";

  if(number_arguments()!=0)
    {
      headerFile << argument_list_names_only() << "," ;
    }

  headerFile << " __FILE__, __LINE__, \"" << function_name() << "(\"";

  for(int i=0;i<number_arguments();++i)
    {
      if(i!=0)
        headerFile << "\",\"";
      headerFile << "#" << argument_name() << i;
    }
  headerFile << "\")\"";
  for(int i=0;i<number_arguments();++i)
    {
      headerFile << ", #" <<  argument_name() << i;
    }


  headerFile << ")\n"
             << "#else\n" << "#define " << function_name() << "(" << argument_list_names_only()
             << ") "
             << sm_namespace << "::" << function_pointer_name() <<  "(" << argument_list_names_only()
             << ")\n#endif\n\n";



}
Example #13
0
/*
 * Converts any LPC datatype into an arbitrary string format
 * and returns a pointer to this string.
 * Scary number of parameters for a recursive function.
 */
void svalue_to_string (svalue_t * obj, outbuffer_t * outbuf, int indent, int trailing, int indent2)
{
    int i;

    /* prevent an infinite recursion on self-referential structures */
    if (indent > 20) {
        outbuf_add(outbuf, "...");
        return;
    }
    if (!indent2)
        add_space(outbuf, indent);
    switch ((obj->type & ~T_FREED)) {
        case T_INVALID:
            outbuf_add(outbuf, "T_INVALID");
            break;
        case T_LVALUE:
            outbuf_add(outbuf, "lvalue: ");
            svalue_to_string(obj->u.lvalue, outbuf, indent + 2, trailing, 0);
            break;
        case T_REF:
            if(!obj->u.ref->lvalue)
                kill_ref(obj->u.ref);
            else {
                outbuf_add(outbuf, "ref: ");
                svalue_to_string(obj->u.ref->lvalue, outbuf, indent + 2, trailing, 0);
            }
            break;
        case T_NUMBER:
            numadd(outbuf, obj->u.number);
            break;
        case T_REAL:
            outbuf_addv(outbuf, "%f", obj->u.real);
            break;
        case T_STRING:
            outbuf_add(outbuf, "\"");
            outbuf_add(outbuf, obj->u.string);
            outbuf_add(outbuf, "\"");
            break;
        case T_CLASS:
            {
                int n = obj->u.arr->size;
                outbuf_add(outbuf, "CLASS( ");
                        numadd(outbuf, n);
                        outbuf_add(outbuf, n == 1 ? " element\n" : " elements\n");
                        for (i = 0; i < (obj->u.arr->size) - 1; i++)
                        svalue_to_string(&(obj->u.arr->item[i]), outbuf,
                            indent + 2, 1, 0);
                        if(obj->u.arr->size)
                        svalue_to_string(&(obj->u.arr->item[i]), outbuf,
                            indent + 2, 0, 0);
                        outbuf_add(outbuf, "\n");
                        add_space(outbuf, indent);
                        outbuf_add(outbuf, " )");
                        break;
            }
        case T_ARRAY:
            if (!(obj->u.arr->size)) {
                outbuf_add(outbuf, "({ })");
            } else {
                outbuf_add(outbuf, "({ /* sizeof() == ");
                        numadd(outbuf, obj->u.arr->size);
                        outbuf_add(outbuf, " */\n");
                        for (i = 0; i < (obj->u.arr->size) - 1; i++)
                        svalue_to_string(&(obj->u.arr->item[i]), outbuf, indent + 2, 1, 0);
                        svalue_to_string(&(obj->u.arr->item[i]), outbuf, indent + 2, 0, 0);
                        outbuf_add(outbuf, "\n");
                        add_space(outbuf, indent);
                        outbuf_add(outbuf, "})");
            }
            break;
#ifndef NO_BUFFER_TYPE
        case T_BUFFER:
            outbuf_add(outbuf, "<buffer>");
            break;
#endif
        case T_FUNCTION:
            {
                svalue_t tmp;
                object_t *ob;
                tmp.type = T_ARRAY;

                outbuf_add(outbuf, "(: ");
                        switch (obj->u.fp->hdr.type) {
                        case FP_LOCAL | FP_NOT_BINDABLE:
                        ob = obj->u.fp->hdr.owner;
                        if (!ob || ob->flags & O_DESTRUCTED) {
                        outbuf_add(outbuf, "0");
                        break;
                        }
                        outbuf_add(outbuf, function_name(ob->prog,
                                obj->u.fp->f.local.index));
                        break;
                        case FP_SIMUL:
                        outbuf_add(outbuf, simuls[obj->u.fp->f.simul.index].func->funcname);
                        break;
                        case FP_FUNCTIONAL:
                        case FP_FUNCTIONAL | FP_NOT_BINDABLE:
                        {
                        char buf[10];
                        int n = obj->u.fp->f.functional.num_arg;

                        outbuf_add(outbuf, "<code>(");
                            for (i=1; i < n; i++) {
                            sprintf(buf, "$%i, ", i);
                            outbuf_add(outbuf, buf);
                            }
                            if (n) {
                            sprintf(buf, "$%i", n);
                            outbuf_add(outbuf, buf);
                            }
                            outbuf_add(outbuf, ")");
                            break;
                        }
                        case FP_EFUN:
                        {
                            int i;
                            i = obj->u.fp->f.efun.index;
                            outbuf_add(outbuf, query_instr_name(i));
                            break;
                        }
                        }
                        if (obj->u.fp->hdr.args) {
                            for (i=0; i<obj->u.fp->hdr.args->size; i++) {
                                outbuf_add(outbuf, ", ");
                                svalue_to_string(&(obj->u.fp->hdr.args->item[i]), outbuf, indent, 0, 0);
                            }
                        }
            }
            outbuf_add(outbuf, " :)");
            break;
        case T_MAPPING:
            if (!(obj->u.map->count)) {
                outbuf_add(outbuf, "([ ])");
            } else {
                outbuf_add(outbuf, "([ /* sizeof() == ");
                        numadd(outbuf, obj->u.map->count);
                        outbuf_add(outbuf, " */\n");
                        for (i = 0; i <= obj->u.map->table_size; i++) {
                        mapping_node_t *elm;

                        for (elm = obj->u.map->table[i]; elm; elm = elm->next) {
                        svalue_to_string(&(elm->values[0]), outbuf, indent + 2, 0, 0);
                        outbuf_add(outbuf, " : ");
                        svalue_to_string(&(elm->values[1]), outbuf, indent + 4, 1, 1);
                        }
                        }
                        add_space(outbuf, indent);
                        outbuf_add(outbuf, "])");
            }
            break;
        case T_OBJECT:
            {
                svalue_t *temp;

                if (obj->u.ob->flags & O_DESTRUCTED) {
                    numadd(outbuf, 0);
                    break;
                }

                outbuf_addchar(outbuf, '/');
                outbuf_add(outbuf, obj->u.ob->obname);

                if (!max_eval_error && !too_deep_error) {
                    push_object(obj->u.ob);
                    temp = safe_apply_master_ob(APPLY_OBJECT_NAME, 1);
                    if (temp && temp != (svalue_t *) -1 && (temp->type == T_STRING)) {
                        outbuf_add(outbuf, " (\"");
                                outbuf_add(outbuf, temp->u.string);
                                outbuf_add(outbuf, "\")");
                    }
                }
                break;
            }
        default:
            outbuf_addv(outbuf, "!ERROR: GARBAGE SVALUE: %x!", obj->type);
    }                           /* end of switch (obj->type) */
    if (trailing)
        outbuf_add(outbuf, ",\n");
}                               /* end of svalue_to_string() */
Example #14
0
/* ARGSUSED */
int
desckey(int f, int n)
{
	KEYMAP	*curmap;
	PF	 funct;
	int	 c, m, i, num;
	char	*pep;
	char	 dprompt[80];

	if (inmacro)
		return (TRUE);	/* ignore inside keyboard macro */

	num = strlcpy(dprompt, "Describe key briefly: ", sizeof(dprompt));
	if (num >= sizeof(dprompt))
		num = sizeof(dprompt) - 1;
	pep = dprompt + num;
	key.k_count = 0;
	m = curbp->b_nmodes;
	curmap = curbp->b_modes[m]->p_map;
	for (;;) {
		for (;;) {
			ewprintf("%s", dprompt);
			pep[-1] = ' ';
			pep = getkeyname(pep, sizeof(dprompt) - (pep - dprompt),
			    key.k_chars[key.k_count++] = c = getkey(FALSE));
			if ((funct = doscan(curmap, c, &curmap)) != NULL)
				break;
			*pep++ = '-';
			*pep = '\0';
		}
		if (funct != rescan)
			break;
		if (ISUPPER(key.k_chars[key.k_count - 1])) {
			funct = doscan(curmap,
			    TOLOWER(key.k_chars[key.k_count - 1]), &curmap);
			if (funct == NULL) {
				*pep++ = '-';
				*pep = '\0';
				continue;
			}
			if (funct != rescan)
				break;
		}
nextmode:
		if (--m < 0)
			break;
		curmap = curbp->b_modes[m]->p_map;
		for (i = 0; i < key.k_count; i++) {
			funct = doscan(curmap, key.k_chars[i], &curmap);
			if (funct != NULL) {
				if (i == key.k_count - 1 && funct != rescan)
					goto found;
				funct = rescan;
				goto nextmode;
			}
		}
		*pep++ = '-';
		*pep = '\0';
	}
found:
	if (funct == rescan || funct == selfinsert)
		ewprintf("%k is not bound to any function");
	else if ((pep = (char *)function_name(funct)) != NULL)
		ewprintf("%k runs the command %s", pep);
	else
		ewprintf("%k is bound to an unnamed function");
	return (TRUE);
}
Example #15
0
void foobar()
   {
  // function_name({1.0f, -3.45f, -0.4f});
     function_name({1.0f, -3.45f, -0.4f});
   }
Example #16
0
void foo() {
    function_name({1.0f, -3.45f, -0.4f});
    
    std::vector<std::string> v = { "xyzzy", "plugh", "abracadabra" };
    std::vector<std::string> v2{ "xyzzy", "plugh", "abracadabra" };
}
void JvmtiTrace::initialize() {
  if (_initialized) {
    return;
  }
  SafeResourceMark rm;

  const char *very_end;
  const char *curr;
  if (TraceJVMTI != NULL) {
    curr = TraceJVMTI;
  } else {
    curr = "";  // hack in fixed tracing here
  }
  very_end = curr + strlen(curr);
  while (curr < very_end) {
    const char *curr_end = strchr(curr, ',');
    if (curr_end == NULL) {
      curr_end = very_end;
    }
    const char *op_pos = strchr(curr, '+');
    const char *minus_pos = strchr(curr, '-');
    if (minus_pos != NULL && (minus_pos < op_pos || op_pos == NULL)) {
      op_pos = minus_pos;
    }
    char op;
    const char *flags = op_pos + 1;
    const char *flags_end = curr_end;
    if (op_pos == NULL || op_pos > curr_end) {
      flags = "ies";
      flags_end = flags + strlen(flags);
      op_pos = curr_end;
      op = '+';
    } else {
      op = *op_pos;
    }
    jbyte bits = 0;
    for (; flags < flags_end; ++flags) {
      switch (*flags) {
      case 'i':
        bits |= SHOW_IN;
        break;
      case 'I':
        bits |= SHOW_IN_DETAIL;
        break;
      case 'e':
        bits |= SHOW_ERROR;
        break;
      case 'o':
        bits |= SHOW_OUT;
        break;
      case 'O':
        bits |= SHOW_OUT_DETAIL;
        break;
      case 't':
        bits |= SHOW_EVENT_TRIGGER;
        break;
      case 's':
        bits |= SHOW_EVENT_SENT;
        break;
      default:
        tty->print_cr("Invalid trace flag '%c'", *flags);
        break;
      }
    }
    const int FUNC = 1;
    const int EXCLUDE  = 2;
    const int ALL_FUNC = 4;
    const int EVENT = 8;
    const int ALL_EVENT = 16;
    int domain = 0;
    size_t len = op_pos - curr;
    if (op_pos == curr) {
      domain = ALL_FUNC | FUNC | ALL_EVENT | EVENT | EXCLUDE;
    } else if (len==3 && strncmp(curr, "all", 3)==0) {
      domain = ALL_FUNC | FUNC | ALL_EVENT | EVENT;
    } else if (len==7 && strncmp(curr, "allfunc", 7)==0) {
      domain = ALL_FUNC | FUNC;
    } else if (len==4 && strncmp(curr, "func", 4)==0) {
      domain = ALL_FUNC | FUNC | EXCLUDE;
    } else if (len==8 && strncmp(curr, "allevent", 8)==0) {
      domain = ALL_EVENT | EVENT;
    } else if (len==5 && strncmp(curr, "event", 5)==0) {
      domain = ALL_EVENT | EVENT;
    } else if (len==2 && strncmp(curr, "ec", 2)==0) {
      _trace_event_controller = true;
      tty->print_cr("JVMTI Tracing the event controller");
    } else {
      domain = FUNC | EVENT;  // go searching
    }

    int exclude_index = 0;
    if (domain & FUNC) {
      if (domain & ALL_FUNC) {
        if (domain & EXCLUDE) {
          tty->print("JVMTI Tracing all significant functions");
        } else {
          tty->print_cr("JVMTI Tracing all functions");
        }
      }
      for (int i = 0; i <= _max_function_index; ++i) {
        if (domain & EXCLUDE && i == _exclude_functions[exclude_index]) {
          ++exclude_index;
        } else {
          bool do_op = false;
          if (domain & ALL_FUNC) {
            do_op = true;
          } else {
            const char *fname = function_name(i);
            if (fname != NULL) {
              size_t fnlen = strlen(fname);
              if (len==fnlen && strncmp(curr, fname, fnlen)==0) {
                tty->print_cr("JVMTI Tracing the function: %s", fname);
                do_op = true;
              }
            }
          }
          if (do_op) {
            if (op == '+') {
              _trace_flags[i] |= bits;
            } else {
              _trace_flags[i] &= ~bits;
            }
            _on = true;
          }
        }
      }
    }
    if (domain & EVENT) {
      if (domain & ALL_EVENT) {
        tty->print_cr("JVMTI Tracing all events");
      }
      for (int i = 0; i <= _max_event_index; ++i) {
        bool do_op = false;
        if (domain & ALL_EVENT) {
          do_op = true;
        } else {
          const char *ename = event_name(i);
          if (ename != NULL) {
            size_t evtlen = strlen(ename);
            if (len==evtlen && strncmp(curr, ename, evtlen)==0) {
              tty->print_cr("JVMTI Tracing the event: %s", ename);
              do_op = true;
            }
          }
        }
        if (do_op) {
          if (op == '+') {
            _event_trace_flags[i] |= bits;
          } else {
            _event_trace_flags[i] &= ~bits;
          }
          _on = true;
        }
      }
    }
    if (!_on && (domain & (FUNC|EVENT))) {
      tty->print_cr("JVMTI Trace domain not found");
    }
    curr = curr_end + 1;
  }
  _initialized = true;
}
Example #18
0
void
dump_map_to_message_buffer (char *prefix, Keymap map)
{
  register int i;
  unsigned prefix_len = strlen (prefix);
  char *new_prefix = xmalloc (prefix_len + 2);

  strncpy (new_prefix, prefix, prefix_len);
  new_prefix[prefix_len + 1] = '\0';

  for (i = 0; i < 256; i++)
    {
      new_prefix[prefix_len] = i;
      if (map[i].type == ISKMAP)
        {
          dump_map_to_message_buffer (new_prefix, (Keymap)map[i].function);
        }
      else if (map[i].function)
        {
          register int last;
          char *doc, *name;

          doc = function_documentation (map[i].function);
          name = function_name (map[i].function);

          if (!*doc)
            continue;

          /* Find out if there is a series of identical functions, as in
             ea_insert (). */
          for (last = i + 1; last < 256; last++)
            if ((map[last].type != ISFUNC) ||
                (map[last].function != map[i].function))
              break;

          if (last - 1 != i)
            {
              printf_to_message_buffer ("%s .. ", pretty_keyseq (new_prefix),
                  NULL, NULL);
              new_prefix[prefix_len] = last - 1;
              printf_to_message_buffer ("%s\t", pretty_keyseq (new_prefix),
                  NULL, NULL);
              i = last - 1;
            }
          else
            printf_to_message_buffer ("%s\t", pretty_keyseq (new_prefix),
                NULL, NULL);

#if defined (NAMED_FUNCTIONS)
          /* Print the name of the function, and some padding before the
             documentation string is printed. */
          {
            int length_so_far;
            int desired_doc_start = 40; /* Must be multiple of 8. */

            printf_to_message_buffer ("(%s)", name, NULL, NULL);
            length_so_far = message_buffer_length_this_line ();

            if ((desired_doc_start + strlen (doc))
                >= (unsigned int) the_screen->width)
              printf_to_message_buffer ("\n     ", NULL, NULL, NULL);
            else
              {
                while (length_so_far < desired_doc_start)
                  {
                    printf_to_message_buffer ("\t", NULL, NULL, NULL);
                    length_so_far += character_width ('\t', length_so_far);
                  }
              }
          }
#endif /* NAMED_FUNCTIONS */
          printf_to_message_buffer ("%s\n", doc, NULL, NULL);
        }
    }
  free (new_prefix);
}