static void generate_marshal (const gchar *signame, Signature *sig) { guint ind, a; GList *node; gchar *tmp = g_strconcat (marshaller_prefix, "_", signame, NULL); gboolean have_std_marshaller = FALSE; /* here we have to make sure a marshaller named <marshaller_prefix>_<signame> * exists. we might have put it out already, can revert to a standard marshaller * provided by glib, or need to generate one. */ if (g_hash_table_lookup (marshallers, tmp)) { /* done, marshaller already generated */ g_free (tmp); return; } else { /* need to alias/generate marshaller, register name */ g_hash_table_insert (marshallers, tmp, tmp); } /* can we revert to a standard marshaller? */ if (std_includes) { tmp = g_strconcat (std_marshaller_prefix, "_", signame, NULL); have_std_marshaller = g_hash_table_lookup (marshallers, tmp) != NULL; g_free (tmp); } if (gen_cheader && have_std_marshaller) { g_fprintf (fout, "#define %s_%s\t%s_%s\n", marshaller_prefix, signame, std_marshaller_prefix, signame); } if (gen_cheader && !have_std_marshaller) { ind = g_fprintf (fout, "extern void "); ind += g_fprintf (fout, "%s_%s (", marshaller_prefix, signame); g_fprintf (fout, "GClosure *closure,\n"); g_fprintf (fout, "%sGValue *return_value,\n", indent (ind)); g_fprintf (fout, "%sguint n_param_values,\n", indent (ind)); g_fprintf (fout, "%sconst GValue *param_values,\n", indent (ind)); g_fprintf (fout, "%sgpointer invocation_hint,\n", indent (ind)); g_fprintf (fout, "%sgpointer marshal_data);\n", indent (ind)); } if (gen_cbody && !have_std_marshaller) { /* cfile marhsal header */ g_fprintf (fout, "void\n"); ind = g_fprintf (fout, "%s_%s (", marshaller_prefix, signame); g_fprintf (fout, "GClosure *closure,\n"); g_fprintf (fout, "%sGValue *return_value,\n", indent (ind)); g_fprintf (fout, "%sguint n_param_values,\n", indent (ind)); g_fprintf (fout, "%sconst GValue *param_values,\n", indent (ind)); g_fprintf (fout, "%sgpointer invocation_hint,\n", indent (ind)); g_fprintf (fout, "%sgpointer marshal_data)\n", indent (ind)); g_fprintf (fout, "{\n"); /* cfile GMarshalFunc typedef */ ind = g_fprintf (fout, " typedef %s (*GMarshalFunc_%s) (", sig->rarg->ctype, signame); g_fprintf (fout, "%s data1,\n", pad ("gpointer")); for (a = 1, node = sig->args; node; node = node->next) { InArgument *iarg = node->data; if (iarg->getter) g_fprintf (fout, "%s%s arg_%d,\n", indent (ind), pad (iarg->ctype), a++); } g_fprintf (fout, "%s%s data2);\n", indent (ind), pad ("gpointer")); /* cfile marshal variables */ g_fprintf (fout, " register GMarshalFunc_%s callback;\n", signame); g_fprintf (fout, " register GCClosure *cc = (GCClosure*) closure;\n"); g_fprintf (fout, " register gpointer data1, data2;\n"); if (sig->rarg->setter) g_fprintf (fout, " %s v_return;\n", sig->rarg->ctype); if (sig->args || sig->rarg->setter) { g_fprintf (fout, "\n"); if (sig->rarg->setter) g_fprintf (fout, " g_return_if_fail (return_value != NULL);\n"); if (sig->args) { for (a = 0, node = sig->args; node; node = node->next) { InArgument *iarg = node->data; if (iarg->getter) a++; } g_fprintf (fout, " g_return_if_fail (n_param_values == %u);\n", 1 + a); } } /* cfile marshal data1, data2 and callback setup */ g_fprintf (fout, "\n"); g_fprintf (fout, " if (G_CCLOSURE_SWAP_DATA (closure))\n {\n"); g_fprintf (fout, " data1 = closure->data;\n"); g_fprintf (fout, " data2 = g_value_peek_pointer (param_values + 0);\n"); g_fprintf (fout, " }\n else\n {\n"); g_fprintf (fout, " data1 = g_value_peek_pointer (param_values + 0);\n"); g_fprintf (fout, " data2 = closure->data;\n"); g_fprintf (fout, " }\n"); g_fprintf (fout, " callback = (GMarshalFunc_%s) (marshal_data ? marshal_data : cc->callback);\n", signame); /* cfile marshal callback action */ g_fprintf (fout, "\n"); ind = g_fprintf (fout, " %s callback (", sig->rarg->setter ? " v_return =" : ""); g_fprintf (fout, "data1,\n"); for (a = 1, node = sig->args; node; node = node->next) { InArgument *iarg = node->data; if (iarg->getter) g_fprintf (fout, "%s%s (param_values + %d),\n", indent (ind), iarg->getter, a++); } g_fprintf (fout, "%sdata2);\n", indent (ind)); /* cfile marshal return value storage */ if (sig->rarg->setter) { g_fprintf (fout, "\n"); g_fprintf (fout, " %s (return_value, v_return);\n", sig->rarg->setter); } /* cfile marshal footer */ g_fprintf (fout, "}\n"); } }
static int print_dyn_verb( ctl* control, SSHORT level) { const SSHORT offset = control->ctl_blr - control->ctl_blr_start; const UCHAR dyn_operator = BLR_BYTE; const char* p; const int size = FB_NELEM(dyn_table); if (dyn_operator > size || dyn_operator <= 0 || !(p = dyn_table[dyn_operator])) { return error(control, offset, "*** dyn operator %d is undefined ***\n", (int) dyn_operator); } indent(control, level); blr_format(control, p); PUT_BYTE(','); PUT_BYTE(' '); ++level; int length; switch (dyn_operator) { case isc_dyn_drop_difference: case isc_dyn_begin_backup: case isc_dyn_end_backup: return 0; case isc_dyn_begin: case isc_dyn_mod_database: print_line(control, offset); while (NEXT_BYTE != isc_dyn_end) PRINT_DYN_VERB; PRINT_DYN_VERB; return 0; case isc_dyn_view_blr: case isc_dyn_fld_validation_blr: case isc_dyn_fld_computed_blr: case isc_dyn_trg_blr: case isc_dyn_fld_missing_value: case isc_dyn_prc_blr: case isc_dyn_fld_default_value: length = print_word(control); print_line(control, offset); if (length) { control->ctl_level = level; fb_print_blr(control->ctl_blr, length, print_blr_line, control, control->ctl_language); control->ctl_blr += length; } return 0; case isc_dyn_scl_acl: // case isc_dyn_log_check_point_length: // case isc_dyn_log_num_of_buffers: // case isc_dyn_log_buffer_size: // case isc_dyn_log_group_commit_wait: case isc_dyn_idx_inactive: length = print_word(control); while (length--) print_byte(control); print_line(control, offset); return 0; case isc_dyn_view_source: case isc_dyn_fld_validation_source: case isc_dyn_fld_computed_source: case isc_dyn_description: case isc_dyn_prc_source: case isc_dyn_fld_default_source: length = print_word(control); while (length--) print_char(control, offset); print_line(control, offset); return 0; case isc_dyn_del_exception: if (length = print_word(control)) do { print_char(control, offset); } while (--length); return 0; case isc_dyn_fld_not_null: case isc_dyn_sql_object: // case isc_dyn_drop_log: // case isc_dyn_drop_cache: // case isc_dyn_def_default_log: // case isc_dyn_log_file_serial: // case isc_dyn_log_file_raw: // case isc_dyn_log_file_overflow: case isc_dyn_single_validation: case isc_dyn_del_computed: case isc_dyn_del_default: case isc_dyn_del_validation: case isc_dyn_idx_statistic: case isc_dyn_foreign_key_delete: case isc_dyn_foreign_key_update: case isc_dyn_foreign_key_cascade: case isc_dyn_foreign_key_default: case isc_dyn_foreign_key_null: case isc_dyn_foreign_key_none: print_line(control, offset); return 0; case isc_dyn_end: print_line(control, offset); return 0; } if (length = print_word(control)) do { print_char(control, offset); } while (--length); print_line(control, offset); switch (dyn_operator) { case isc_dyn_def_database: case isc_dyn_def_dimension: case isc_dyn_def_exception: case isc_dyn_def_file: // case isc_dyn_def_log_file: // case isc_dyn_def_cache_file: case isc_dyn_def_filter: case isc_dyn_def_function: case isc_dyn_def_function_arg: case isc_dyn_def_generator: case isc_dyn_def_global_fld: case isc_dyn_def_idx: case isc_dyn_def_local_fld: case isc_dyn_def_rel: case isc_dyn_def_procedure: case isc_dyn_def_parameter: case isc_dyn_def_security_class: case isc_dyn_def_shadow: case isc_dyn_def_sql_fld: case isc_dyn_def_trigger: case isc_dyn_def_trigger_msg: case isc_dyn_def_view: case isc_dyn_delete_database: case isc_dyn_delete_dimensions: case isc_dyn_delete_filter: case isc_dyn_delete_function: case isc_dyn_delete_global_fld: case isc_dyn_delete_idx: case isc_dyn_delete_local_fld: case isc_dyn_delete_rel: case isc_dyn_delete_procedure: case isc_dyn_delete_parameter: case isc_dyn_delete_security_class: case isc_dyn_delete_trigger: case isc_dyn_delete_trigger_msg: case isc_dyn_delete_shadow: case isc_dyn_mod_exception: case isc_dyn_mod_global_fld: case isc_dyn_mod_idx: case isc_dyn_mod_local_fld: case isc_dyn_mod_procedure: case isc_dyn_mod_rel: case isc_dyn_mod_security_class: case isc_dyn_mod_trigger: case isc_dyn_mod_trigger_msg: case isc_dyn_rel_constraint: case isc_dyn_mod_view: case isc_dyn_grant: case isc_dyn_revoke: case isc_dyn_view_relation: case isc_dyn_def_sql_role: while (NEXT_BYTE != isc_dyn_end) PRINT_DYN_VERB; PRINT_DYN_VERB; return 0; } return 0; }
void xs_console_log(xsMachine* the) { xsIntegerValue c = xsToInteger(xsArgc), i; xsBooleanValue space = 0; xsBooleanValue comma = 0; xsBooleanValue nonl = 0; int options = 0; FILE *console_out = stdout; xsVars(4); console_log_depth++; for (i = 0; i < c; i++) { if (space && !nonl) CONSOLE_OUT("\n"); else space = 1; switch (xsTypeOf(xsArg(i))) { case xsUndefinedType: case xsNullType: case xsBooleanType: case xsIntegerType: case xsNumberType: CONSOLE_OUT("%s", xsToString(xsArg(i))); break; case xsSymbolType: xsResult = xsCall1(xsGlobal, xsID("String"), xsArg(i)); CONSOLE_OUT("%s", xsToString(xsResult)); break; case xsStringType: case xsStringXType: if (i == 0 || options) { const char *opt = xsToString(xsArg(i)); options = 0; if (strcmp(opt, "-n") == 0) { nonl++; options++; } else if (strcmp(opt, "-stderr") == 0) { console_out = stderr; options++; } else if (strcmp(opt, "-stdout") == 0) { console_out = stdout; options++; } else if (strncmp(opt, "-", 1) == 0) /* end of the option args */ break; if (options) { space = 0; break; } } if (console_log_depth == 1) CONSOLE_OUT("%s", xsToString(xsArg(i))); else CONSOLE_OUT("\"%s\"", xsToString(xsArg(i))); break; case xsReferenceType: if (xsIsInstanceOf(xsArg(i), xsFunctionPrototype)) { CONSOLE_OUT("function(...) { ... }"); } else if (xsIsInstanceOf(xsArg(i), xsArrayPrototype)) { xsGet(xsVar(0), xsArg(i), xsID("length")); xsIntegerValue length = xsToInteger(xsVar(0)), index; CONSOLE_OUT("[\n"); for (index = 0; index < length; index++) { xsGet(xsVar(1), xsArg(i), (xsIndex)index); if (comma) CONSOLE_OUT(",\n"); else comma = 1; indent(the, console_out, 0); fxPush(xsVar(1)); fxPushCount(the, 1); fxPush(xsThis); fxPush(xsFunction); fxCall(the); } CONSOLE_OUT("\n"); indent(the, console_out, -1); CONSOLE_OUT("]"); } else { CONSOLE_OUT( "{\n"); xsVar(0) = xsEnumerate(xsArg(i)); for (;;) { xsVar(1) = xsCall0(xsVar(0), xsID("next")); xsGet(xsVar(2), xsVar(1), xsID("done")); if (xsTest(xsVar(2))) break; xsGet(xsVar(2), xsVar(1), xsID("value")); xsGetAt(xsVar(3), xsArg(i), xsVar(2)); if (comma) CONSOLE_OUT( ",\n"); else comma = 1; indent(the, console_out, 0); CONSOLE_OUT("%s: ", xsToString(xsVar(2))); fxPush(xsVar(3)); fxPushCount(the, 1); fxPush(xsThis); fxPush(xsFunction); fxCall(the); } CONSOLE_OUT("\n"); indent(the, console_out, -1); CONSOLE_OUT("}"); } break; } } console_log_depth--; if (!console_log_depth && !nonl) CONSOLE_OUT("\n"); }
void ViewLogger::auxiliaryDataChanged(const ModelNode &node, const QString &name, const QVariant &data) { m_output << time() << indent("auxiliaryDataChanged:") << node << "\t" << name << "\t" << data.toString() << endl; }
void ViewLogger::nodeCreated(const ModelNode &createdNode) { m_output << time() << indent("nodeCreated:") << createdNode << endl; }
void ViewLogger::rootNodeTypeChanged(const QString &type, int majorVersion, int minorVersion) { m_output << time() << indent("rootNodeTypeChanged:") << rootModelNode() << type << majorVersion << minorVersion << endl; }
void ViewLogger::nodeOrderChanged(const NodeListProperty &listProperty, const ModelNode &movedNode, int oldIndex) { m_output << time() << indent("nodeOrderChanged:") << listProperty << movedNode << oldIndex << endl; }
void ScCodeEditor::indentCurrentRegion() { indent(currentRegion()); }
void ScCodeEditor::indent() { indent(textCursor()); }
void decodePS_PES_packet (u_char *b, u_int len, int pid) { /* IS13818-1 2.4.3.6 */ u_long packet_start_code_prefix; // 24 bit u_int stream_id; u_int PES_packet_length; u_int stream_type; // -- Get/check packet header prefix (sync bits) packet_start_code_prefix = getBits (b, 0, 0, 24); if (packet_start_code_prefix != 0x000001) { out_nl (3," !!! Packet_Start_CODE [%06lx] is wrong (= no PES/PS [0x000001])!!!\n", packet_start_code_prefix); print_databytes (4,"Unknown packet data:", b, len); return; } out_nl (3,"Packet_start_code_prefix: 0x%06lx",packet_start_code_prefix); stream_id = b[3]; // -- decode PES packet header if ((stream_id >= 0xC0 && stream_id <= 0xDF) // audio PES || (stream_id >= 0xE0 && stream_id <= 0xEF)) { // video PES PES_packet_length = outBit_Sx_NL (3, "PES_packet_length: ", b, 32, 16); b += 6; len -= 6; if ((PES_packet_length==0) && ((stream_id & 0xF0)==0xE0)) { out_nl (3," ==> unbound video elementary stream... \n"); } if (len > 0) { indent (+1); PES_decode_std (b, len, stream_id); indent (-1); } return; } stream_type = get_StreamFromMem(pid)->stream_type; //fprintf (stdout, "-># decodePS_PES_packet: len=%u; pid=%d stream_type=%u\n", len, pid, stream_type); if (stream_type == 0) { out_nl (3, "!!! Can not find stream type for PID = %d (0x%x) (PMT was not received yet)!!!\n", pid, pid); return; } // -- H.264 NALU if (stream_type == 0x1B) { u_char nal_ref_idc = getBits(b, 0, 25, 2); out_SB_NL(3, "nal_ref_idc: ", nal_ref_idc); stream_id = outBit_S2x_NL(3,"H.264 NALU: ", b, 27, 5, (char *(*)(u_long))dvbstrPESH264_NALU_ID ); //b += 4; //len -= 4; indent (+1); switch(stream_id) { case NAL_IDR: case NAL_NONIDR: H264_decodeSlice(4, b, len); break; case NAL_AUD: H264_decodeAUD(4, b, len); break; case NAL_SPS: H264_decodeSPS(4, b, len); break; case NAL_PPS: H264_decodePPS(4, b, len); break; case NAL_SEI: H264_decodeSEI(4, b, len); break; } print_databytes (5, "Bytes (incl. sync + id):", b, len); indent (-1); return; } // -- PS/PES stream ID stream_id = outBit_S2x_NL(3,"Stream_id: ", b, 24, 8, (char *(*)(u_long))dvbstrPESstream_ID ); // // -- PES Stream ID 0x00 - 0xB8 // -- ISO 13818-2 // if (stream_id <= 0xB8) { // $$$ TODO PES Stream ID 0x00 - 0xB8 // reserved B0 // reserved B1 // sequence_error_code B4 (not for streams) // reserved B6 indent (+1); switch (stream_id) { case 0x00: // picture_start_code 00 MPEG2_decodePictureHeader (4, b, len); break; case 0xB2: // user_data_start_code B2 MPEG2_decodeUserData (4, b, len); break; case 0xB3: // sequence_header_code B3 MPEG2_decodeSequenceHeader (4, b, len); break; case 0xB5: // extension_data B5 MPEG2_decodeExtension (4, b, len); break; case 0xB7: // sequence_end_code B7 MPEG2_decodeSequenceEnd (4, b, len); return; case 0xB8: // group_start_code B8 MPEG2_decodeGroupOfPictures (4, b, len); break; default: // slice_start_code 01 through AF if (stream_id >= 0x01 && stream_id <= 0xAF) { MPEG2_decodeSlice (4, b, len); } else { // unkown if (len > 4) { // sync + stream_id = 4 bytes print_databytes (4,"MPEG2 Data (incl. sync + id):", b, len); } } break; } indent (-1); return; } // // -- PES Stream ID 0xB9 - 0xBB // -- check PS decoding (ProgramStream) // switch (stream_id) { case 0xB9: // MPEG_program_end // stream ID already printed, nothing else to do return; case 0xBA: // MPEG_pack_header_start mpeg_pack_header (3, b, -1); // startcode & ID already printed return; case 0xBB: // MPEG_system_header_start mpeg_system_header (3, b, -1); // startcode & ID already printed return; } // // -- PES decoding ... // -- StreamID 0xBC..0xFF // PES_packet_length = outBit_Sx_NL (3,"PES_packet_length: ", b,32, 16); b += 6; len -= 6; switch (stream_id) { case 0xBC: // program_stream_map PES_decodePSM (b, PES_packet_length); break; case 0xBE: // padding stream! print_databytes (3,"Padding_bytes:", b, PES_packet_length); break; case 0xF2: // DSMCC stream PES_decodeDSMCC (b, PES_packet_length); break; case 0xFF: // program_stream_directory PES_decodePSDIR (b, PES_packet_length); break; case 0xBF: // private_stream_2 (EN301192-1.3.1 S.10) case 0xF0: // ECM case 0xF1: // EMM case 0xF8: // ITU-T Rec. H.222.1 type E print_databytes (3,"PES_packet_data_bytes:", b, PES_packet_length); break; // case 0xFC: // metadata stream (see: H.222.0 AMD1) // $$$ TODO // case 0xBD: // Data Stream, privat_stream_1 (EN301192-1.3.1 S.11) // case 0xC0-0xDF // ISO/IEC 13818-3 or 11172-3 or 13818-7 or 14496-3 audio stream // case 0xE0-0xEF // ITU-T Rec. H.262 | ISO/IEC 13818-2 or 11172-2 or 14496-2 video stream // case 0xF3 // ISO/IEC_13522_stream // case 0xF4 // ITU-T Rec. H.222.1 type A // case 0xF5 // ITU-T Rec. H.222.1 type B // case 0xF6 // ITU-T Rec. H.222.1 type C // case 0xF7 // ITU-T Rec. H.222.1 type D // case 0xF9 // ancillary_stream // case 0xFA // ISO/IEC14496-1_SL-packetized_stream // case 0xFB // ISO/IEC14496-1_FlexMux_stream // case 0xFD // extended_stream_id // case 0xFE // reserved data stream //default: // { // int xlen = PES_packet_length; // if ((PES_packet_length==0) && ((stream_id & 0xF0)==0xE0)) { // out_nl (3," ==> unbound video elementary stream... \n"); // xlen = len; // PES len field == 0, use read packet len // } // if (xlen > 0) { // indent (+1); // PES_decode_std (b, xlen, stream_id); // indent (-1); // } // } // break; } // switch }
static void print_css_node_rec( css_node_t *node, css_print_options_t options, int level ) { indent(level); printf("{"); if (node->print) { node->print(node->context); } if (options & CSS_PRINT_LAYOUT) { printf("layout: {"); printf("width: %g, ", node->layout.dimensions[CSS_WIDTH]); printf("height: %g, ", node->layout.dimensions[CSS_HEIGHT]); printf("top: %g, ", node->layout.position[CSS_TOP]); printf("left: %g", node->layout.position[CSS_LEFT]); printf("}, "); } if (options & CSS_PRINT_STYLE) { if (node->style.flex_direction == CSS_FLEX_DIRECTION_COLUMN) { printf("flexDirection: 'column', "); } else if (node->style.flex_direction == CSS_FLEX_DIRECTION_COLUMN_REVERSE) { printf("flexDirection: 'columnReverse', "); } else if (node->style.flex_direction == CSS_FLEX_DIRECTION_ROW) { printf("flexDirection: 'row', "); } else if (node->style.flex_direction == CSS_FLEX_DIRECTION_ROW_REVERSE) { printf("flexDirection: 'rowReverse', "); } if (node->style.justify_content == CSS_JUSTIFY_CENTER) { printf("justifyContent: 'center', "); } else if (node->style.justify_content == CSS_JUSTIFY_FLEX_END) { printf("justifyContent: 'flex-end', "); } else if (node->style.justify_content == CSS_JUSTIFY_SPACE_AROUND) { printf("justifyContent: 'space-around', "); } else if (node->style.justify_content == CSS_JUSTIFY_SPACE_BETWEEN) { printf("justifyContent: 'space-between', "); } if (node->style.align_items == CSS_ALIGN_CENTER) { printf("alignItems: 'center', "); } else if (node->style.align_items == CSS_ALIGN_FLEX_END) { printf("alignItems: 'flex-end', "); } else if (node->style.align_items == CSS_ALIGN_STRETCH) { printf("alignItems: 'stretch', "); } if (node->style.align_content == CSS_ALIGN_CENTER) { printf("alignContent: 'center', "); } else if (node->style.align_content == CSS_ALIGN_FLEX_END) { printf("alignContent: 'flex-end', "); } else if (node->style.align_content == CSS_ALIGN_STRETCH) { printf("alignContent: 'stretch', "); } if (node->style.align_self == CSS_ALIGN_FLEX_START) { printf("alignSelf: 'flex-start', "); } else if (node->style.align_self == CSS_ALIGN_CENTER) { printf("alignSelf: 'center', "); } else if (node->style.align_self == CSS_ALIGN_FLEX_END) { printf("alignSelf: 'flex-end', "); } else if (node->style.align_self == CSS_ALIGN_STRETCH) { printf("alignSelf: 'stretch', "); } print_number_nan("flex", node->style.flex); if (four_equal(node->style.margin)) { print_number_0("margin", node->style.margin[CSS_LEFT]); } else { print_number_0("marginLeft", node->style.margin[CSS_LEFT]); print_number_0("marginRight", node->style.margin[CSS_RIGHT]); print_number_0("marginTop", node->style.margin[CSS_TOP]); print_number_0("marginBottom", node->style.margin[CSS_BOTTOM]); print_number_0("marginStart", node->style.margin[CSS_START]); print_number_0("marginEnd", node->style.margin[CSS_END]); } if (four_equal(node->style.padding)) { print_number_0("padding", node->style.margin[CSS_LEFT]); } else { print_number_0("paddingLeft", node->style.padding[CSS_LEFT]); print_number_0("paddingRight", node->style.padding[CSS_RIGHT]); print_number_0("paddingTop", node->style.padding[CSS_TOP]); print_number_0("paddingBottom", node->style.padding[CSS_BOTTOM]); print_number_0("paddingStart", node->style.padding[CSS_START]); print_number_0("paddingEnd", node->style.padding[CSS_END]); } if (four_equal(node->style.border)) { print_number_0("borderWidth", node->style.border[CSS_LEFT]); } else { print_number_0("borderLeftWidth", node->style.border[CSS_LEFT]); print_number_0("borderRightWidth", node->style.border[CSS_RIGHT]); print_number_0("borderTopWidth", node->style.border[CSS_TOP]); print_number_0("borderBottomWidth", node->style.border[CSS_BOTTOM]); print_number_0("borderStartWidth", node->style.border[CSS_START]); print_number_0("borderEndWidth", node->style.border[CSS_END]); } print_number_nan("width", node->style.dimensions[CSS_WIDTH]); print_number_nan("height", node->style.dimensions[CSS_HEIGHT]); if (node->style.position_type == CSS_POSITION_ABSOLUTE) { printf("position: 'absolute', "); } print_number_nan("left", node->style.position[CSS_LEFT]); print_number_nan("right", node->style.position[CSS_RIGHT]); print_number_nan("top", node->style.position[CSS_TOP]); print_number_nan("bottom", node->style.position[CSS_BOTTOM]); } if (options & CSS_PRINT_CHILDREN && node->children_count > 0) { printf("children: [\n"); for (int i = 0; i < node->children_count; ++i) { print_css_node_rec(node->get_child(node->context, i), options, level + 1); } indent(level); printf("]},\n"); } else { printf("},\n"); } }
static int base2json(heim_object_t obj, struct twojson *j) { heim_tid_t type; int first = 0; if (obj == NULL) { if (j->flags & HEIM_JSON_F_CNULL2JSNULL) { obj = heim_null_create(); } else if (j->flags & HEIM_JSON_F_NO_C_NULL) { return EINVAL; } else { indent(j); j->out(j->ctx, "<NULL>\n"); /* This is NOT valid JSON! */ return 0; } } type = heim_get_tid(obj); switch (type) { case HEIM_TID_ARRAY: indent(j); j->out(j->ctx, "[\n"); j->indent++; first = j->first; j->first = 1; heim_array_iterate_f(obj, j, array2json); j->indent--; if (!j->first) j->out(j->ctx, "\n"); indent(j); j->out(j->ctx, "]\n"); j->first = first; break; case HEIM_TID_DICT: indent(j); j->out(j->ctx, "{\n"); j->indent++; first = j->first; j->first = 1; heim_dict_iterate_f(obj, j, dict2json); j->indent--; if (!j->first) j->out(j->ctx, "\n"); indent(j); j->out(j->ctx, "}\n"); j->first = first; break; case HEIM_TID_STRING: indent(j); j->out(j->ctx, "\""); j->out(j->ctx, heim_string_get_utf8(obj)); j->out(j->ctx, "\""); break; case HEIM_TID_DATA: { heim_dict_t d; heim_string_t v; const heim_octet_string *data; char *b64 = NULL; int ret; if (j->flags & HEIM_JSON_F_NO_DATA) return EINVAL; /* JSON doesn't do binary */ data = heim_data_get_data(obj); ret = base64_encode(data->data, data->length, &b64); if (ret < 0 || b64 == NULL) return ENOMEM; if (j->flags & HEIM_JSON_F_NO_DATA_DICT) { indent(j); j->out(j->ctx, "\""); j->out(j->ctx, b64); /* base64-encode; hope there's no aliasing */ j->out(j->ctx, "\""); free(b64); } else { /* * JSON has no way to represent binary data, therefore the * following is a Heimdal-specific convention. * * We encode binary data as a dict with a single very magic * key with a base64-encoded value. The magic key includes * a uuid, so we're not likely to alias accidentally. */ d = heim_dict_create(2); if (d == NULL) { free(b64); return ENOMEM; } v = heim_string_ref_create(b64, free); if (v == NULL) { free(b64); heim_release(d); return ENOMEM; } ret = heim_dict_set_value(d, heim_tid_data_uuid_key, v); heim_release(v); if (ret) { heim_release(d); return ENOMEM; } ret = base2json(d, j); heim_release(d); if (ret) return ret; } break; } case HEIM_TID_NUMBER: { char num[32]; indent(j); snprintf(num, sizeof (num), "%d", heim_number_get_int(obj)); j->out(j->ctx, num); break; } case HEIM_TID_NULL: indent(j); j->out(j->ctx, "null"); break; case HEIM_TID_BOOL: indent(j); j->out(j->ctx, heim_bool_val(obj) ? "true" : "false"); break; default: return 1; } return 0; }
int ts_pidbandwidth (OPTION *opt) { u_char buf[TS_BUF_SIZE]; struct pollfd pfd; struct dmx_pes_filter_params flt; int dmxfd; struct timeval tv,last_tv, first_tv; int pid; unsigned long long b_total; long b; long packets_bad; long packets_total; struct { // simple struct for storing last average bandwidth unsigned long kb_sec; unsigned long b_sec; } last_avg; if (opt->ts_raw_mode) { pid = PID_FULL_TS; } else { pid = opt->pid; } indent (0); out_nl (2,""); out_nl (2,"---------------------------------------------------------"); out_nl (2,"PID bandwidth statistics..."); if (opt->ts_raw_mode) { out (2,"Full Transponder"); } else { out (2,"PID: %u (0x%04x)", pid, pid); } if (opt->rd_packet_count != 0) { out (2," - max packet count: %ld ", opt->rd_packet_count); } out_nl (2,""); out_nl (2,"---------------------------------------------------------"); // -- open DVR device for reading pfd.events = POLLIN | POLLPRI; if((pfd.fd = open(opt->devDvr,O_RDONLY|O_NONBLOCK)) < 0){ IO_error(opt->devDvr); return -1; } if ((dmxfd=open(opt->devDemux,O_RDWR)) < 0) { IO_error(opt->devDemux); close(pfd.fd); return -1; } ioctl (dmxfd,DMX_SET_BUFFER_SIZE, sizeof(buf)); flt.pid = pid; flt.input = DMX_IN_FRONTEND; flt.output = DMX_OUT_TS_TAP; flt.pes_type = DMX_PES_OTHER; flt.flags = DMX_IMMEDIATE_START; if (ioctl(dmxfd, DMX_SET_PES_FILTER, &flt) < 0) { IO_error("DMX_SET_PES_FILTER"); close(pfd.fd); close(dmxfd); return -1; } gettimeofday (&first_tv, NULL); last_tv.tv_sec = first_tv.tv_sec; last_tv.tv_usec = first_tv.tv_usec; b_total = 0; packets_total = 0; packets_bad = 0; while ( !isSigAbort() ) { int b_len, b_start; // -- we will poll the PID in 2 secs intervall int timeout = 2000; b_len = 0; b_start = 0; if (poll(&pfd, 1, timeout) > 0) { if (pfd.revents & POLLIN) { b_len = read(pfd.fd, buf, sizeof(buf)); gettimeofday (&tv, NULL); if (b_len >= TS_LEN) { b_start = sync_ts (buf, b_len); } else { b_len = 0; } b = b_len - b_start; if (b == 0) continue; if (b < 0) { IO_error("read"); continue; } b_total += b; // -- calc bandwidth { unsigned long long bit_s; long d_tim_ms; int packets; packets = b/TS_LEN; packets_total += packets; // output on different verbosity levels // -- current bandwidth d_tim_ms = delta_time_ms (&tv, &last_tv); if (d_tim_ms <= 0) d_tim_ms = 1; // ignore usecs out (3, "packets read: %3d/(%ld) d_time: %2ld.%03ld s = ", packets, packets_total, d_tim_ms / 1000UL, d_tim_ms % 1000UL); // -- current bandwidth in kbit/sec // --- cast to unsigned long long so it doesn't overflow as // --- early, add time / 2 before division for correct rounding bit_s = (((unsigned long long)b * 8000ULL) + ((unsigned long long)d_tim_ms / 2ULL)) / (unsigned long long)d_tim_ms; out (1, "%5llu.%03llu kbit/s", bit_s / 1000ULL, bit_s % 1000ULL); // -- average bandwidth d_tim_ms = delta_time_ms (&tv,&first_tv); if (d_tim_ms <= 0) d_tim_ms = 1; // ignore usecs bit_s = ((b_total * 8000ULL) + ((unsigned long long)d_tim_ms / 2ULL)) / (unsigned long long)d_tim_ms; last_avg.kb_sec = (unsigned long) (bit_s / 1000ULL); last_avg.b_sec = (unsigned long) (bit_s % 1000ULL); out (2, " (Avrg: %5lu.%03lu kbit/s)", last_avg.kb_sec, last_avg.b_sec); // -- bad packet(s) check in buffer { int bp; bp = ts_error_count (buf+b_start, b); packets_bad += bp; out (4, " [bad: %d]", bp); } out_NL (1); } last_tv.tv_sec = tv.tv_sec; last_tv.tv_usec = tv.tv_usec; // count packets ? if (opt->rd_packet_count > 0) { opt->rd_packet_count -= b/TS_LEN; if (opt->rd_packet_count <= 0) break; } } } } // -- packets stats out (4, "## "); if (opt->ts_raw_mode) { out (2,"PID: <ALL>"); } else { out (2,"PID: %u (0x%04x)", pid, pid); } out (4, " bad/total packets: %ld/%ld (= %1.1Lf%%)", packets_bad, packets_total, (((long double) packets_bad)*100)/packets_total ); out (4, " Avrg: %5lu.%03lu kbit/s", last_avg.kb_sec, last_avg.b_sec); out_NL(4); if (ioctl(dmxfd, DMX_STOP) < 0) { IO_error("DMX_STOP"); } close(dmxfd); close(pfd.fd); return 0; }
static void stylesheet (unsigned margin) { indent (margin++, "<style type='text/css'>"); indent (margin, "table { table-layout: fixed; background: transparent; border-collapse: separate; border-spacing: 1pt; font: normal 10pt verdana; }"); indent (margin, "th { background: inherit; padding: 2px 10px; text-align: center; vertical-align: middle; }"); indent (margin, "td { background: inherit; padding: 2px 10px; text-align: left; vertical-align: top; }"); indent (margin--, "</style>"); indent (margin++, "<style type='text/css'>"); indent (margin, "table.%s { border: solid 1pt black; border-spacing: 1px; background: white; }", STYLE_DATA); indent (margin, "th.%s, td.%s { border: solid 1pt silver; text-align: left; width: 250px; }", STYLE_NAME, STYLE_NAME); indent (margin, "th.%s, td.%s { border: solid 1pt silver; text-align: right; width: 100px; }", STYLE_SIZE, STYLE_SIZE); indent (margin, "th.%s, td.%s { border: solid 1pt silver; text-align: left; };", STYLE_TEXT, STYLE_TEXT); indent (margin--, "</style>"); return; }
void ViewLogger::propertiesRemoved(const QList<AbstractProperty> &propertyList) { m_output << time() << indent("propertiesRemoved:") << endl; foreach (const AbstractProperty &property, propertyList) m_output << time() << indent() << property << endl; }
void ScCodeEditor::indent( const QTextCursor & selection ) { if (selection.isNull()) return; QTextCursor cursor(selection); cursor.beginEditBlock(); QTextDocument *doc = QPlainTextEdit::document(); int startBlockNum = doc->findBlock(cursor.selectionStart()).blockNumber(); int endBlockNum = cursor.hasSelection() ? doc->findBlock(cursor.selectionEnd()).blockNumber() : startBlockNum; QStack<int> stack; int level = 0; int blockNum = 0; QTextBlock block = QPlainTextEdit::document()->begin(); while (block.isValid()) { if (level > 0) { stack.push(level); level = 0; } int initialStackSize = stack.size(); TextBlockData *data = static_cast<TextBlockData*>(block.userData()); if (data) { int count = data->tokens.size(); for (int idx = 0; idx < count; ++idx) { const Token & token = data->tokens[idx]; switch (token.type) { case Token::OpeningBracket: if (token.character != '(' || stack.size() || token.positionInBlock) level += 1; break; case Token::ClosingBracket: if (level) level -= 1; else if(!stack.isEmpty()) { stack.top() -= 1; if (stack.top() <= 0) stack.pop(); } break; default: ; } } } if(blockNum >= startBlockNum) { int indentLevel; if (data && data->tokens.size() && data->tokens[0].type == Token::ClosingBracket) indentLevel = stack.size(); else indentLevel = initialStackSize; block = indent(block, indentLevel); } if(blockNum == endBlockNum) break; block = block.next(); ++blockNum; } cursor.endEditBlock(); }
void ViewLogger::bindingPropertiesChanged(const QList<BindingProperty>& propertyList, PropertyChangeFlags propertyChange) { m_output << time() << indent("bindingPropertiesChanged:") << serialize(propertyChange) << endl; foreach(const BindingProperty &property, propertyList) m_output << time() << indent() << property << endl; }
void ScCodeEditor::keyPressEvent( QKeyEvent *e ) { QTextCursor cursor( textCursor() ); bool cursorMoved = true; if (e == QKeySequence::MoveToNextWord) moveToNextToken( cursor, QTextCursor::MoveAnchor ); else if (e == QKeySequence::MoveToPreviousWord) moveToPreviousToken( cursor, QTextCursor::MoveAnchor ); else if (e == QKeySequence::SelectNextWord) moveToNextToken( cursor, QTextCursor::KeepAnchor ); else if (e == QKeySequence::SelectPreviousWord) moveToPreviousToken( cursor, QTextCursor::KeepAnchor ); else cursorMoved = false; if (cursorMoved) { setTextCursor( cursor ); return; } switch (e->key()) { case Qt::Key_Home: { Qt::KeyboardModifiers mods(e->modifiers()); if (mods && mods != Qt::ShiftModifier) { GenericCodeEditor::keyPressEvent(e); return; } hideMouseCursor(); QTextCursor::MoveMode mode = mods & Qt::ShiftModifier ? QTextCursor::KeepAnchor : QTextCursor::MoveAnchor; QTextCursor c(textCursor()); QTextBlock b(c.block()); int pos = indentedStartOfLine(b); pos += b.position(); if (c.position() == pos) c.movePosition(QTextCursor::StartOfLine, mode); else c.setPosition(pos, mode); setTextCursor(c); return; } case Qt::Key_Backtab: { hideMouseCursor(); QTextCursor cursor = textCursor(); insertSpaceToNextTabStop( cursor ); ensureCursorVisible(); return; } case Qt::Key_Enter: case Qt::Key_Return: case Qt::Key_BraceRight: case Qt::Key_BracketRight: case Qt::Key_ParenRight: { hideMouseCursor(); // Wrap superclass' implementation into an edit block, // so it can be joined with indentation later: QTextCursor cursor = textCursor(); cursor.beginEditBlock(); GenericCodeEditor::keyPressEvent(e); cursor.endEditBlock(); cursor.joinPreviousEditBlock(); indent(); cursor.endEditBlock(); cursor.setVerticalMovementX(-1); setTextCursor(cursor); break; } default: GenericCodeEditor::keyPressEvent(e); } mAutoCompleter->keyPress(e); }
void ViewLogger::fileUrlChanged(const QUrl &oldUrl, const QUrl &newUrl) { m_output << time() << indent("fileUrlChanged:") << oldUrl.toString() << "\t" << newUrl.toString() << endl; }
string GateStatement:: toString(int n) { string indent(n, '\t'); string output = indent+"subCircuits["+index+"] = "+className+".newInstance();\n"; return output; }
void ViewLogger::importsChanged() { m_output << time() << indent("importsChanged:") << endl; }
void ViewLogger::nodeAboutToBeRemoved(const ModelNode &removedNode) { m_output << time() << indent("nodeAboutToBeRemoved:") << removedNode << endl; }
void ViewLogger::modelAboutToBeDetached(Model *model) { m_output << time() << indent("modelAboutToBeDetached:") << model << endl; AbstractView::modelAboutToBeDetached(model); }
void ViewLogger::nodeRemoved(const ModelNode &removedNode, const NodeAbstractProperty &parentProperty, PropertyChangeFlags propertyChange) { m_output << time() << indent("nodeRemoved:") << removedNode << parentProperty << serialize(propertyChange) << endl; }
std::string StateConverter::generateDescription(unsigned int indentation) { std::string msg; msg += indent(indentation) + "# Beliefs: " + boost::lexical_cast<std::string>(numBeliefs) + "\n"; msg += indent(indentation) + "# Bins: " + boost::lexical_cast<std::string>(numBins); return msg; }
void ViewLogger::nodeReparented(const ModelNode &node, const NodeAbstractProperty &newPropertyParent, const NodeAbstractProperty &oldPropertyParent, AbstractView::PropertyChangeFlags propertyChange) { m_output << time() << indent("nodeReparented:") << node << "\t" << newPropertyParent << "\t" << oldPropertyParent << "\t" << serialize(propertyChange) << endl; }
static int print_sdl_verb( ctl* control, SSHORT level) { const char* p; SSHORT offset = control->ctl_blr - control->ctl_blr_start; const UCHAR sdl_operator = BLR_BYTE; if (sdl_operator > FB_NELEM(sdl_table) || sdl_operator <= 0 || !(p = sdl_table[sdl_operator])) { return error(control, offset, "*** SDL operator %d is undefined ***\n", (int) sdl_operator); } indent(control, level); blr_format(control, p); PUT_BYTE(','); PUT_BYTE(' '); ++level; int n = 0; switch (sdl_operator) { case isc_sdl_begin: print_line(control, offset); while (NEXT_BYTE != isc_sdl_end) PRINT_SDL_VERB; PRINT_SDL_VERB; return 0; case isc_sdl_struct: n = print_byte(control); while (n--) { print_line(control, offset); indent(control, level + 1); offset = control->ctl_blr - control->ctl_blr_start; print_blr_dtype(control, true); } break; case isc_sdl_scalar: print_byte(control); case isc_sdl_element: n = print_byte(control); print_line(control, offset); while (n--) PRINT_SDL_VERB; return 0; case isc_sdl_field: case isc_sdl_relation: print_string(control, offset); break; case isc_sdl_fid: case isc_sdl_rid: case isc_sdl_short_integer: print_word(control); break; case isc_sdl_variable: case isc_sdl_tiny_integer: print_byte(control); break; case isc_sdl_long_integer: print_long(control); break; case isc_sdl_add: case isc_sdl_subtract: case isc_sdl_multiply: case isc_sdl_divide: print_line(control, offset); PRINT_SDL_VERB; PRINT_SDL_VERB; return 0; case isc_sdl_negate: print_line(control, offset); PRINT_SDL_VERB; return 0; case isc_sdl_do3: n++; case isc_sdl_do2: n++; case isc_sdl_do1: n += 2; print_byte(control); print_line(control, offset); while (n--) PRINT_SDL_VERB; return 0; } print_line(control, offset); return 0; }
void ViewLogger::nodeIdChanged(const ModelNode& node, const QString& newId, const QString& oldId) { m_output << time() << indent("nodeIdChanged:") << node << "\t" << newId << "\t" << oldId << endl; }
static void color_print_package (void *p, printpkgfn f) { static int number = 0; const bool aur = (f == aur_get_str); const bool grp = (f == alpm_grp_get_str); /* Numbering list */ if (config.numbering) { fprintf (stdout, "%s%d%s ", color (C_NB), ++number, color (C_NO)); } /* repo/name */ const char *info = color_print_repo (p, f); if (grp) { /* no more output for groups */ fprintf (stdout, "\n"); return; } /* Version * different colors: * C_ORPHAN if package exists in AUR and is orphaned * C_OD if package exists and is out of date * C_VER otherwise */ const char *lver = alpm_local_pkg_get_str (info, 'l'); info = f(p, (config.aur_upgrades || config.filter & F_UPGRADES) ? 'V' : 'v'); char *ver = STRDUP (info); info = (aur) ? f(p, 'm') : NULL; if (config.aur_foreign) { /* Compare foreign package with AUR */ if (aur) { info = color_print_aur_version (p, f, info, lver, ver); } else { fprintf (stdout, " %s%s%s\n", color(C_VER), lver, color(C_NO)); } FREE (ver); return; } if (aur && !info) { fprintf (stdout, "%s", color(C_ORPHAN)); } else { fprintf (stdout, "%s", color(C_VER)); } if (config.filter & F_UPGRADES) { fprintf (stdout, "%s%s -> %s%s%s", lver, color (C_NO), color(C_VER), ver, color (C_NO)); } else { fprintf (stdout, "%s%s", ver, color (C_NO)); } /* show size */ if (config.show_size) { color_print_size (p, f); } if (config.aur_upgrades || config.filter & F_UPGRADES) { fprintf (stdout, "\n"); FREE (ver); return; } /* show groups */ color_print_groups (p, f); /* show install information */ color_print_install_info (p, f, lver, ver); /* ver no more needed */ FREE (ver); /* Out of date status & votes */ if (aur) { color_print_aur_status (p, f); } /* Nothing more to display */ fprintf (stdout, "\n"); /* Description * if -Q or -Sl or -Sg <target>, don't display description */ if (config.op != OP_SEARCH && config.op != OP_LIST_REPO_S) { return; } fprintf (stdout, "%s", color(C_DSC)); indent (f(p, 'd')); fprintf (stdout, "%s", color(C_NO)); }
json_serializer& json_serializer::write_object(const string& name, const string& obj) { indent(); (*_s_stream) << " \"" << name << "\":" << endl << obj << "," << endl; return *this; }