Example #1
0
File: hash.cpp Project: Zoxc/mirb
	value_t Hash::to_s(Hash *self)
	{
		RecursionDetector<RecursionType::Hash_to_s, false> rd(self);

		if(rd.recursion())
			return String::get("{...}");

		CharArray result = "{";

		OnStack<1> os1(self);
		OnStackString<1> os2(result);

		HashAccess::each_pair(self, [&](value_t key, value_t value) -> bool {

			OnStack<1> os(value);
			
			result += inspect(key);
			result += "=>";
			result += inspect(value);
			result += ", ";

			return true;
		});

		if(result.size() > 1)
			result.shrink(result.size() - 2);

		result += "}";

		return result.to_string();
	}
Example #2
0
int setup_point_sources(char* file_name)
{
    int status;
    int point_index;

    status = h5_get_attr(file_name, "excitations", "number_of_point_sources", &total_point_sources);
    inspect(status, "fail to load hdf5 dataset");
    if (total_point_sources == 0) return 1;

    status = h5_get_attr(file_name, "settings", "starting_index", &starting_index);
    inspect(status, "fail to get h5 attributes");

    source_points = (int **)h5_load2(file_name, "/excitations/source_points", total_point_sources, 3);
    inspect(source_points, "fail to load hdf5 dataset");

    for (point_index = 0; point_index < total_point_sources; point_index ++)
    {
        source_points[point_index][0] = source_points[point_index][0] - starting_index;
        source_points[point_index][1] = source_points[point_index][1] - starting_index;
        source_points[point_index][2] = source_points[point_index][2] - starting_index;
    }
    source_polarizations = (int *)h5_load1(file_name, "/excitations/source_polarizations", total_point_sources);
    inspect(source_polarizations, "fail to load hdf5 dataset");
    source_signals = (double **)h5_load2(file_name, "/excitations/source_signals", total_timesteps, total_point_sources);
    inspect(source_signals, "fail to load hdf5 dataset");

    return 1;
}
Example #3
0
File: bp.cpp Project: rkonow/topk
i64 isleaf(bp *b, i64 s)
{
    if (inspect(b,s) != OP) {
        printf("isleaf: error!!! B[%d] = OP\n",(int)s);
    }
    if (inspect(b,s+1) == CP) return 1;
    else return 0;
}
Example #4
0
int main(int, char**)
{
    test        t;
    test2       w;
    test3       l;
    std::string str = "salut";
    inspect(t);
    inspect(str);
    inspect(l);
    inspect(w);
    return 0;
}
		/*
			Test with invalid URI
		*/
		void invalidTest() {
			::toolkit::Inspector inspect("asdf://asdf");
			isFalse(inspect.audio());
			isFalse(inspect.video());
			isTrue(inspect.title().empty());
			isTrue(inspect.album().empty());
		}
Example #6
0
 TEST_F(ObLogCacheTest, PushAndGet){
   int64_t end_id2 = 5;
   ASSERT_EQ(OB_SUCCESS, push(end_id2));
   inspect(true);
   ASSERT_EQ(OB_SUCCESS, get(1, end_id));
   ASSERT_GE(end_id, end_id2);
 }
Example #7
0
int main(int argc, char** argv) {
    if (argc != 2) {
        fprintf(stderr, "Expected one argument. Got %d.\n", argc);
        fprintf(stderr, "Usage: inspect-gui <trace file>\n");
        return EXIT_FAILURE;
    }
    
    trace_t* trace = load_trace(argv[1]);
    trace_error_t error = get_trace_error();
    if (error == TraceError_Invalid) {
        fprintf(stderr, "Invalid trace file: %s\n", get_trace_error_desc());
        return EXIT_FAILURE;
    } else if (error == TraceError_UnableToOpen) {
        fprintf(stderr, "Unable to open trace file.\n");
        return EXIT_FAILURE;
    }
    
    inspection_t* inspection = create_inspection(trace);
    inspect(inspection);
    
    inspector_t* inspector = create_inspector(inspection);
    
    for (size_t i = 0; i < inspection->frame_count; i++)
        for (size_t j = 0; j < inspection->frames[i].command_count; j++)
            seek_inspector(inspector, i, j);
    
    free_inspector(inspector);
    free_inspection(inspection);
    free_trace(trace);
    
    return EXIT_SUCCESS;
}
static VALUE
cr_image_surface_initialize (int argc, VALUE *argv, VALUE self)
{
  cairo_surface_t *surface;
  VALUE arg1, arg2, arg3, arg4, arg5;
  int n;
  
  n = rb_scan_args (argc, argv, "23", &arg1, &arg2, &arg3, &arg4, &arg5);

  if (n == 2)
    surface = cr_image_surface_create (self, Qnil, arg1, arg2);
  else if (n == 3)
    surface = cr_image_surface_create (self, arg1, arg2, arg3);
  else if (n == 5)
    surface =
      cr_image_surface_create_for_data (self, arg1, arg2, arg3, arg4, arg5);
  else
    rb_raise (rb_eArgError,
              "invalid argument (expect "
              "(width, height) or "
              "(format, width, height) or "
              "(data, format, width, height, stride)): %s",
              inspect (rb_ary_new3 (4, arg1, arg2, arg3, arg4)));

  cr_surface_check_status (surface);
  DATA_PTR (self) = surface;
  if (rb_block_given_p ())
    yield_and_finish (self);
  return Qnil;
}
Example #9
0
int main(int argc, char** argv) {
    if (argc != 2) {
        fprintf(stderr, "Expected one argument. Got %d.\n", argc);
        fprintf(stderr, "Usage: inspect-gui <trace file>\n");
        return EXIT_FAILURE;
    }
    
    trace_t* trace = load_trace(argv[1]);
    trace_error_t error = get_trace_error();
    if (error == TraceError_Invalid) {
        fprintf(stderr, "Invalid trace file: %s\n", get_trace_error_desc());
        return EXIT_FAILURE;
    } else if (error == TraceError_UnableToOpen) {
        fprintf(stderr, "Unable to open trace file.\n");
        return EXIT_FAILURE;
    }
    inspection_t* inspection = create_inspection(trace);
    
    inspect(inspection);
    
    free_inspection(inspection);
    free_trace(trace);
    
    return EXIT_SUCCESS;
}
Example #10
0
void
GNEInspectorFrame::inspect(GNEAttributeCarrier* AC, GNEAttributeCarrier* previousElement) {
    // Use the implementation of inspect for multiple AttributeCarriers to avoid repetition of code
    std::vector<GNEAttributeCarrier*> itemToInspect;
    itemToInspect.push_back(AC);
    inspect(itemToInspect, previousElement);
}
		/*
			Test with audio file
		*/
		void audioTest() {
			::toolkit::Inspector inspect("file://" + ::core::Path::current() + "/tests/audio.ogg");
			isTrue(inspect.audio());
			isFalse(inspect.video());
			equal(inspect.title(), "Test Audio");
			equal(inspect.album(), "Test Album");
		}
Example #12
0
int tool_main(int argc, char** argv) {
    SkAutoGraphics ag;
    if (argc < 2) {
        printf("Usage: pinspect [--dump-ops] filename [filename ...]\n");
        return 1;
    }

    bool doDumpOps = false;

    int index = 1;
    if (!strcmp(argv[index], "--dump-ops")) {
        index += 1;
        doDumpOps = true;
    }

    for (; index < argc; ++index) {
        SkAutoTUnref<SkPicture> pic(inspect(argv[index]));
        if (doDumpOps) {
            dumpOps(pic);
        }
        if (index < argc - 1) {
            printf("\n");
        }
    }
    return 0;
}
		/*
			Test with video file
		*/
		void videoTest() {
			::toolkit::Inspector inspect("file://" + ::core::Path::current() + "/tests/video.ogg");
			isFalse(inspect.audio());
			isTrue(inspect.video());
			isTrue(inspect.title().empty());
			isTrue(inspect.album().empty());
		}
Example #14
0
int
main(int argc, char **args) {
    param_t     param;
    param.path = NULL;
    param.touch = false;

    if (!parse_params(argc, args, &param)) {
        exit(1);
    }

    if (!isdir(param.path)) {
        inspect(param.path, param.touch);
    } else if (nftw(param.path, traverse, 10, 0) == -1) {
        fprintf(stderr, "error on walking through %s\n", param.path);
        exit(1);
    }
    fprintf(stderr,
            "total:\n"
            "\t page count: %lu, cached: %lu\n"
            "\t file size: %lu(%luK), cached: %lu(%luK)\n",
            pages_total, pages_incore_total,
            fsize_total, fsize_total/1024, bytes_incore_total, bytes_incore_total/1024);

    return 0;
}
Example #15
0
int MainWindow::qt_metacall(QMetaObject::Call _c, int _id, void **_a)
{
    _id = QMainWindow::qt_metacall(_c, _id, _a);
    if (_id < 0)
        return _id;
    if (_c == QMetaObject::InvokeMetaMethod) {
        switch (_id) {
        case 0: about(); break;
        case 1: newFile(); break;
        case 2: openFile((*reinterpret_cast< const QString(*)>(_a[1]))); break;
        case 3: openFile(); break;
        case 4: saveFile(); break;
        case 5: saveFileAs((*reinterpret_cast< const QString(*)>(_a[1]))); break;
        case 6: saveFileAs(); break;
        case 7: runFile(); break;
        case 8: inspect(); break;
        case 9: append((*reinterpret_cast< const QString(*)>(_a[1])),(*reinterpret_cast< const QString(*)>(_a[2]))); break;
        case 10: onEngineStarted(); break;
        case 11: onEngineStopped(); break;
        case 12: onEnginePanic((*reinterpret_cast< Atom(*)>(_a[1])),(*reinterpret_cast< Word(*)>(_a[2])),(*reinterpret_cast< const QString(*)>(_a[3])),(*reinterpret_cast< const QString(*)>(_a[4]))); break;
        default: ;
        }
        _id -= 13;
    }
    return _id;
}
Example #16
0
	void Environment::run(RunningContext *context)
	{
		const Instruction &ins = m_ipos;
		m_context = context;
		if (!context)
		{
			m_running = false;
		} else if (!m_running)
		{
			clear_vstore();
			TRACE_PRINTF(TRACE_VM, TRACE_INFO, "Entering running state with %p\n", context);
			m_running = true;
			SourcePos *last_pos = NULL; // used for debug output below.
			const Instruction *ipos;
			while (m_context && (ipos = m_context->next()))
			{
				size_t output = -1;
				size_t expected = -1;
#				define CHECK_STACK(in, out) TRACE_OUT(TRACE_VM, TRACE_SPAM) {\
					assert(m_context->stack_count() >= (size_t)(in)); \
					if ((out) != -1) { assert((long)(expected = m_context->stack_count() - (size_t)(in) + (size_t)(out)) >= 0); } \
					tprintf("Stack info: before(%d), in(%d), out(%d), expected(%d)\n", (int)m_context->stack_count(), (int)(in), (int)(out), (int)expected); \
					output = (out); \
				}

				m_ipos = *ipos;

				TRACE_DO(TRACE_VM, TRACE_INFO) {
					SourcePos &pos = m_context->m_instructions->source_pos(ipos);
					if (!last_pos || *last_pos != pos)
						tprintf("Source Position: %s:%d:%d (%s)\n", pos.file.c_str(), (int)pos.line_num, (int)pos.column, pos.annotation.c_str());
					last_pos = &pos;
				}
				TRACE_OUT(TRACE_VM, TRACE_SPAM) {
					tprintf("Instruction: %s@%d\n",
						inspect(ins).c_str(),
						(int)(ipos - &*m_context->instructions().begin())
						);
					tprintf("Stack: %d deep", (int)m_context->stack_count());

					const Value *it;
					for (it = m_context->stack_begin(); it != m_context->stack_pos(); it++)
					{
						tprintf("\n   %s", inspect(*it).c_str());
					}
					tprintf(" <--\n");
				}
Example #17
0
long
GNEInspectorFrame::onCmdGoBack(FXObject*, FXSelector, void*) {
    // Inspect previous element (if was defined)
    if (myPreviousElement) {
        inspect(myPreviousElement);
    }
    return 1;
}
Example #18
0
File: bp.cpp Project: rkonow/topk
///////////////////////////////////////////
//  postorder_rank(bp *b,i64 s)
//    returns the postorder (>= 1) of node s (s >= 0)
//            -1 if s-th bit is not OP
///////////////////////////////////////////
i64 postorder_rank(bp *b,i64 s)
{
    i64 t;
    if (inspect(b,s) == CP) return -1;
    t = find_close(b,s);
    //  return t+1 - darray_rank(b->da,t);
    return rank_close(b,t);
}
Example #19
0
void inspect_widget(widget* w) {
	for(int i = 0; i < Elements_in(widgetInfos); i++) {
		if(w->vtable == widgetInfos[i]->vtable) {
			inspect(widgetInfos[i], w);
			return;
		}
	}
	printf("Unsupported widget detected (list box, drop down, or dimmer)\n\n");
}
Example #20
0
std::string inspect(StrValuesMap &map) 
{
	std::string retVal = "(";
	for (StrValuesMap::iterator it = map.begin(); it != map.end(); it++)
	{
		retVal += std::string(it->first) + std::string(": ") + inspect(it->second) + std::string(", ");
	}
	return retVal + ")";
}
Example #21
0
QuickInfo Stage::preview()
{
    m_args.reset(new ProgramArgs);
    handleOptions();
    pushLogLeader();
    QuickInfo qi = inspect();
    popLogLeader();
    return qi;
}
Example #22
0
long
GNEInspectorFrame::onCmdCopyTemplate(FXObject*, FXSelector, void*) {
    for (std::vector<GNEAttributeCarrier*>::iterator it = myACs.begin(); it != myACs.end(); it++) {
        GNEEdge* edge = dynamic_cast<GNEEdge*>(*it);
        assert(edge);
        edge->copyTemplate(myEdgeTemplate, myViewNet->getUndoList());
        inspect(myACs);
    }
    return 1;
}
Example #23
0
File: bp.cpp Project: rkonow/topk
///////////////////////////////////////////
//  next_sibling(bp *b,i64 s)
//    returns the next sibling of parent(s)
//            -1 if s is the last child
//////////////////////////////////////////
i64 next_sibling(bp *b, i64 s)
{
    i64 t;
    t = find_close(b,s)+1;
    if (t >= b->n) {
        printf("next_sibling: error s=%d t=%d\n",(int)s,(int)t);
    }
    if (inspect(b,t) == CP) return -1;
    return t;
}
Example #24
0
int
traverse(const char *path, const struct stat *st, int type, struct FTW *ftw) {
    if (type == FTW_F) {
        //! touch is dangerous while traversing
        inspect(path, false);
    } else {
        fprintf(stderr, "<%s>\n", path);
    }
    return 0;
}
Example #25
0
void InspectorAgent::enable(ErrorString*)
{
    m_enabled = true;

    if (m_pendingInspectData.first)
        inspect(m_pendingInspectData.first, m_pendingInspectData.second);

    for (Vector<pair<long, String>>::iterator it = m_pendingEvaluateTestCommands.begin(); m_frontendDispatcher && it != m_pendingEvaluateTestCommands.end(); ++it)
        m_frontendDispatcher->evaluateForTestInFrontend(static_cast<int>((*it).first), (*it).second);
    m_pendingEvaluateTestCommands.clear();
}
Example #26
0
void InspectorAgent::enable(ErrorString*)
{
    m_state->setBoolean(InspectorAgentState::enabled, true);

    if (m_pendingInspectData.first)
        inspect(m_pendingInspectData.first, m_pendingInspectData.second);

    for (Vector<pair<long, String> >::iterator it = m_pendingEvaluateTestCommands.begin(); m_frontend && it != m_pendingEvaluateTestCommands.end(); ++it)
        m_frontend->inspector()->evaluateForTestInFrontend(static_cast<int>((*it).first), (*it).second);
    m_pendingEvaluateTestCommands.clear();
}
Example #27
0
bool InspectorOverlay::handleTouchEvent(const PlatformTouchEvent& event) {
  if (!shouldSearchForNode())
    return false;
  Node* node = hoveredNodeForEvent(m_frameImpl->frame(), event, false);
  if (node && m_inspectModeHighlightConfig) {
    highlightNode(node, *m_inspectModeHighlightConfig, false);
    inspect(node);
    return true;
  }
  return false;
}
Example #28
0
bool InspectorOverlay::handleMousePress() {
  if (!shouldSearchForNode())
    return false;

  if (m_hoveredNodeForInspectMode) {
    inspect(m_hoveredNodeForInspectMode.get());
    m_hoveredNodeForInspectMode.clear();
    return true;
  }
  return false;
}
Example #29
0
void dump_tree(Node *node, int depth) {
  assert(node != NULL);
  for(int i=0;i<depth;i++) {
    fprintf(stderr, "  ");
  }
  inspect(node);
  depth++;
  for(int i=0;i<node->length;i++) {
    dump_tree(node->data[i], depth);
  }
}
Example #30
0
File: mem.c Project: emguy/ezfdtd
void *mem1(int type, size_t xmax)
{
    void  *p;
    p = NULL;

    switch (type)
    {
        case type_int:
            p = (int *)calloc(xmax, sizeof(int));
            inspect(p, KCYN "malloc failed for %d bytes", xmax * sizeof(int));
            break;

        case type_double:
            p = (double *)calloc(xmax, sizeof(double));
            inspect(p, KCYN "malloc failed for %d bytes", xmax * sizeof(double));
            break;
    }

    return(p);
}