diff options
256 files changed, 20373 insertions, 13247 deletions
diff --git a/bootstrap/lib/compiler/ebin/core_pp.beam b/bootstrap/lib/compiler/ebin/core_pp.beam Binary files differindex 8f97709248..6047596cb6 100644 --- a/bootstrap/lib/compiler/ebin/core_pp.beam +++ b/bootstrap/lib/compiler/ebin/core_pp.beam diff --git a/bootstrap/lib/compiler/ebin/v3_core.beam b/bootstrap/lib/compiler/ebin/v3_core.beam Binary files differindex 9b2450089a..3b3b8f4208 100644 --- a/bootstrap/lib/compiler/ebin/v3_core.beam +++ b/bootstrap/lib/compiler/ebin/v3_core.beam diff --git a/bootstrap/lib/kernel/ebin/code_server.beam b/bootstrap/lib/kernel/ebin/code_server.beam Binary files differindex aa1ba78550..6f99487ca7 100644 --- a/bootstrap/lib/kernel/ebin/code_server.beam +++ b/bootstrap/lib/kernel/ebin/code_server.beam diff --git a/bootstrap/lib/kernel/ebin/dist_util.beam b/bootstrap/lib/kernel/ebin/dist_util.beam Binary files differindex 369871f398..eb09a06785 100644 --- a/bootstrap/lib/kernel/ebin/dist_util.beam +++ b/bootstrap/lib/kernel/ebin/dist_util.beam diff --git a/bootstrap/lib/kernel/ebin/global_group.beam b/bootstrap/lib/kernel/ebin/global_group.beam Binary files differindex 1269f7e321..03202f68eb 100644 --- a/bootstrap/lib/kernel/ebin/global_group.beam +++ b/bootstrap/lib/kernel/ebin/global_group.beam diff --git a/bootstrap/lib/kernel/ebin/rpc.beam b/bootstrap/lib/kernel/ebin/rpc.beam Binary files differindex 3b77ed641a..684d95afa0 100644 --- a/bootstrap/lib/kernel/ebin/rpc.beam +++ b/bootstrap/lib/kernel/ebin/rpc.beam diff --git a/bootstrap/lib/stdlib/ebin/epp.beam b/bootstrap/lib/stdlib/ebin/epp.beam Binary files differindex 5c98ffdafc..54909eeaa3 100644 --- a/bootstrap/lib/stdlib/ebin/epp.beam +++ b/bootstrap/lib/stdlib/ebin/epp.beam diff --git a/bootstrap/lib/stdlib/ebin/erl_lint.beam b/bootstrap/lib/stdlib/ebin/erl_lint.beam Binary files differindex 22d3607866..aeea1e2fcd 100644 --- a/bootstrap/lib/stdlib/ebin/erl_lint.beam +++ b/bootstrap/lib/stdlib/ebin/erl_lint.beam diff --git a/bootstrap/lib/stdlib/ebin/gen_statem.beam b/bootstrap/lib/stdlib/ebin/gen_statem.beam Binary files differindex 08cb19ca6f..5a3fd2a1a5 100644 --- a/bootstrap/lib/stdlib/ebin/gen_statem.beam +++ b/bootstrap/lib/stdlib/ebin/gen_statem.beam diff --git a/bootstrap/lib/stdlib/ebin/lists.beam b/bootstrap/lib/stdlib/ebin/lists.beam Binary files differindex 91297311b2..422a9bd214 100644 --- a/bootstrap/lib/stdlib/ebin/lists.beam +++ b/bootstrap/lib/stdlib/ebin/lists.beam diff --git a/bootstrap/lib/stdlib/ebin/maps.beam b/bootstrap/lib/stdlib/ebin/maps.beam Binary files differindex 7533b56554..5f041ab10f 100644 --- a/bootstrap/lib/stdlib/ebin/maps.beam +++ b/bootstrap/lib/stdlib/ebin/maps.beam diff --git a/erts/doc/src/absform.xml b/erts/doc/src/absform.xml index 6d6ba224a0..bfabb7f042 100644 --- a/erts/doc/src/absform.xml +++ b/erts/doc/src/absform.xml @@ -68,22 +68,12 @@ <item>If D is a module declaration consisting of the forms <c>F_1</c>, ..., <c>F_k</c>, then Rep(D) = <c>[Rep(F_1), ..., Rep(F_k)]</c>.</item> - <item>If F is an attribute <c>-behavior(Behavior)</c>, then - Rep(F) = <c>{attribute,LINE,behavior,Behavior}</c>.</item> - <item>If F is an attribute <c>-behaviour(Behaviour)</c>, then - Rep(F) = <c>{attribute,LINE,behaviour,Behaviour}</c>.</item> - <item>If F is an attribute <c>-compile(Options)</c>, then - Rep(F) = <c>{attribute,LINE,compile,Options}</c>.</item> <item>If F is an attribute <c>-export([Fun_1/A_1, ..., Fun_k/A_k])</c>, then Rep(F) = <c>{attribute,LINE,export,[{Fun_1,A_1}, ..., {Fun_k,A_k}]}</c>.</item> - <item>If F is an attribute <c>-export_type([Type_1/A_1, ..., Type_k/A_k])</c>, then - Rep(F) = <c>{attribute,LINE,export_type,[{Type_1,A_1}, ..., {Type_k,A_k}]}</c>.</item> <item>If F is an attribute <c>-import(Mod,[Fun_1/A_1, ..., Fun_k/A_k])</c>, then Rep(F) = <c>{attribute,LINE,import,{Mod,[{Fun_1,A_1}, ..., {Fun_k,A_k}]}}</c>.</item> <item>If F is an attribute <c>-module(Mod)</c>, then Rep(F) = <c>{attribute,LINE,module,Mod}</c>.</item> - <item>If F is an attribute <c>-optional_callbacks([Fun_1/A_1, ..., Fun_k/A_k])</c>, then - Rep(F) = <c>{attribute,LINE,optional_callbacks,[{Fun_1,A_1}, ..., {Fun_k,A_k}]}</c>.</item> <item>If F is an attribute <c>-file(File,Line)</c>, then Rep(F) = <c>{attribute,LINE,file,{File,Line}}</c>.</item> <item>If F is a function declaration diff --git a/erts/doc/src/erl.xml b/erts/doc/src/erl.xml index e13470c83c..c499fc8081 100644 --- a/erts/doc/src/erl.xml +++ b/erts/doc/src/erl.xml @@ -632,6 +632,15 @@ <p>Sets the initial process dictionary size of processes to the size <c><![CDATA[Size]]></c>.</p> </item> + <tag><marker id="+hmqd"><c>+hmqd off_heap|on_heap|mixed</c></marker></tag> + <item><p> + Sets the default value for the process flag + <c>message_queue_data</c>. If <c>+hmqd</c> is not + passed, <c>mixed</c> will be the default. For more information, + see the documentation of + <seealso marker="erlang#process_flag_message_queue_data"><c>process_flag(message_queue_data, + MQD)</c></seealso>. + </p></item> <tag><c><![CDATA[+K true | false]]></c></tag> <item> <p>Enables or disables the kernel poll functionality if @@ -1361,21 +1370,6 @@ <seealso marker="kernel:error_logger#warning_map/0">error_logger(3)</seealso> for further information.</p> </item> - <tag><c><![CDATA[+xFlag Value]]></c></tag> - <item> - <p>Default process flag settings.</p> - <taglist> - <tag><marker id="+xmqd"><c>+xmqd off_heap|on_heap|mixed</c></marker></tag> - <item><p> - Sets the default value for the process flag - <c>message_queue_data</c>. If <c>+xmqd</c> is not - passed, <c>mixed</c> will be the default. For more information, - see the documentation of - <seealso marker="erlang#process_flag_message_queue_data"><c>process_flag(message_queue_data, - MQD)</c></seealso>. - </p></item> - </taglist> - </item> <tag><c><![CDATA[+zFlag Value]]></c></tag> <item> <p>Miscellaneous flags.</p> diff --git a/erts/doc/src/erlang.xml b/erts/doc/src/erlang.xml index 5af4f0bd66..bdaa6caa15 100644 --- a/erts/doc/src/erlang.xml +++ b/erts/doc/src/erlang.xml @@ -4371,7 +4371,7 @@ os_prompt% </pre> </taglist> <p> The default <c>message_queue_data</c> process flag is determined - by the <seealso marker="erl#+xmqd"><c>+xmqd</c></seealso> + by the <seealso marker="erl#+hmqd"><c>+hmqd</c></seealso> <c>erl</c> command line argument. </p> <p> @@ -4702,7 +4702,7 @@ os_prompt% </pre> detailed information about garbage collection for this process. The content of <c><anno>GCInfo</anno></c> can be changed without prior notice. - See <seealso marker="#gc_start">gc_start</seealso> in + See <seealso marker="#gc_minor_start">gc_minor_start</seealso> in <seealso marker="#trace/3">erlang:trace/3</seealso> for details about what each item means. </p> @@ -4878,7 +4878,9 @@ os_prompt% </pre> <tag><c>{total_heap_size, <anno>Size</anno>}</c></tag> <item> <p><c><anno>Size</anno></c> is the total size, in words, of all heap - fragments of the process. This includes the process stack.</p> + fragments of the process. This includes the process stack and + any unreceived messages that are considered to be part of the + heap. </p> </item> <tag><c>{trace, <anno>InternalTraceFlags</anno>}</c></tag> <item> @@ -5709,7 +5711,7 @@ true</pre> flag. <c><anno>MQD</anno></c> should be either <c>off_heap</c>, <c>on_heap</c>, or <c>mixed</c>. The default <c>message_queue_data</c> process flag is determined by the - <seealso marker="erl#+xmqd"><c>+xmqd</c></seealso> <c>erl</c> + <seealso marker="erl#+hmqd"><c>+hmqd</c></seealso> <c>erl</c> command line argument. For more information, see the documentation of <seealso marker="#process_flag_message_queue_data"><c>process_flag(message_queue_data, @@ -7388,7 +7390,7 @@ ok <p>Returns the default value of the <c>message_queue_data</c> process flag which is either <c>off_heap</c>, <c>on_heap</c>, or <c>mixed</c>. This default is set by the <c>erl</c> command line argument - <seealso marker="erl#+xmqd"><c>+xmqd</c></seealso>. For more information on the + <seealso marker="erl#+hmqd"><c>+hmqd</c></seealso>. For more information on the <c>message_queue_data</c> process flag, see documentation of <seealso marker="#process_flag_message_queue_data"><c>process_flag(message_queue_data, MQD)</c></seealso>.</p> @@ -7966,7 +7968,7 @@ ok <c>stack_size</c>, <c>mbuf_size</c>, <c>old_heap_size</c>, and <c>old_heap_block_size</c>. These tuples are explained in the description of trace message - <seealso marker="#gc_start">gc_start</seealso> (see + <seealso marker="#gc_minor_start">gc_minor_start</seealso> (see <seealso marker="#trace/3">erlang:trace/3</seealso>). New tuples can be added, and the order of the tuples in the <c>Info</c> list can be changed at any time without @@ -8556,7 +8558,7 @@ timestamp() -> <tag><c>garbage_collection</c></tag> <item> <p>Traces garbage collections of processes.</p> - <p>Message tags: <c><seealso marker="#trace_3_trace_messages_gc_start">gc_start</seealso></c> and <c><seealso marker="#trace_3_trace_messages_gc_end">gc_end</seealso></c>.</p> + <p>Message tags: <c><seealso marker="#trace_3_trace_messages_gc_minor_start">gc_minor_start</seealso></c> and <c><seealso marker="#trace_3_trace_messages_gc_minor_end">gc_minor_end</seealso></c>.</p> </item> <tag><c>timestamp</c></tag> <item> @@ -8637,8 +8639,8 @@ timestamp() -> <p>Specifies that a tracer module should be called instead of sending a trace message. The tracer module can then ignore or change the trace message. For more details - on how to write a tracer module see <seealso marker="erl_tracer"> - erl_tracer</seealso> + on how to write a tracer module see + <seealso marker="erts:erl_tracer"><c>erl_tracer</c></seealso> </p> </item> </taglist> @@ -8880,12 +8882,12 @@ timestamp() -> </p> </item> <tag> - <marker id="trace_3_trace_messages_gc_start"></marker> - <c>{trace, Pid, gc_start, Info}</c> + <marker id="trace_3_trace_messages_gc_minor_start"></marker> + <c>{trace, Pid, gc_minor_start, Info}</c> </tag> <item> - <marker id="gc_start"></marker> - <p>Sent when garbage collection is about to be started. + <marker id="gc_minor_start"></marker> + <p>Sent when a young garbage collection is about to be started. <c>Info</c> is a list of two-element tuples, where the first element is a key, and the second is the value. Do not depend on any order of the tuples. @@ -8925,15 +8927,32 @@ timestamp() -> <p>All sizes are in words.</p> </item> <tag> - <marker id="trace_3_trace_messages_gc_end"></marker> - <c>{trace, Pid, gc_end, Info}</c> + <marker id="trace_3_trace_messages_gc_minor_end"></marker> + <c>{trace, Pid, gc_minor_end, Info}</c> </tag> <item> - <p>Sent when garbage collection is finished. <c>Info</c> - contains the same kind of list as in message <c>gc_start</c>, + <p>Sent when young garbage collection is finished. <c>Info</c> + contains the same kind of list as in message <c>gc_minor_start</c>, but the sizes reflect the new sizes after garbage collection.</p> </item> + <tag> + <marker id="trace_3_trace_messages_gc_major_start"></marker> + <c>{trace, Pid, gc_major_start, Info}</c> + </tag> + <item> + <p>Sent when fullsweep garbage collection is about to be started. <c>Info</c> + contains the same kind of list as in message <c>gc_minor_start</c>.</p> + </item> + <tag> + <marker id="trace_3_trace_messages_gc_major_end"></marker> + <c>{trace, Pid, gc_major_end, Info}</c> + </tag> + <item> + <p>Sent when fullsweep garbage collection is finished. <c>Info</c> + contains the same kind of list as in message <c>gc_minor_start</c> + but the sizes reflect the new sizes after a fullsweep garbage collection.</p> + </item> </taglist> <p>If the tracing process/port dies or the tracer module returns <c>remove</c>, the flags are silently removed.</p> @@ -8989,7 +9008,7 @@ timestamp() -> <c>erlang:trace_delivered(<anno>Tracee</anno>)</c> resides on. The special <c><anno>Tracee</anno></c> atom <c>all</c> denotes all processes that currently are traced in the node.</p> - <p>When used together with an <seealso marker="#erl_tracer"> + <p>When used together with an <seealso marker="erts:erl_tracer"> Tracer Module</seealso> any message sent in the trace callback is guaranteed to have reached it's recipient before the <c>trace_delivered</c> message is sent.</p> diff --git a/erts/emulator/beam/beam_bif_load.c b/erts/emulator/beam/beam_bif_load.c index 87508dcf5f..40d44dda4c 100644 --- a/erts/emulator/beam/beam_bif_load.c +++ b/erts/emulator/beam/beam_bif_load.c @@ -38,7 +38,7 @@ #include "erl_thr_progress.h" static void set_default_trace_pattern(Eterm module); -static Eterm check_process_code(Process* rp, Module* modp, Uint flags, int *redsp); +static Eterm check_process_code(Process* rp, Module* modp, Uint flags, int *redsp, int fcalls); static void delete_code(Module* modp); static void decrement_refc(BeamCodeHeader*); static int any_heap_ref_ptrs(Eterm* start, Eterm* end, char* mod_start, Uint mod_size); @@ -467,7 +467,7 @@ check_old_code_1(BIF_ALIST_1) } Eterm -erts_check_process_code(Process *c_p, Eterm module, Uint flags, int *redsp) +erts_check_process_code(Process *c_p, Eterm module, Uint flags, int *redsp, int fcalls) { Module* modp; Eterm res; @@ -483,7 +483,7 @@ erts_check_process_code(Process *c_p, Eterm module, Uint flags, int *redsp) return am_false; erts_rlock_old_code(code_ix); res = (!modp->old.code_hdr ? am_false : - check_process_code(c_p, modp, flags, redsp)); + check_process_code(c_p, modp, flags, redsp, fcalls)); erts_runlock_old_code(code_ix); return res; @@ -506,7 +506,7 @@ BIF_RETTYPE erts_internal_check_process_code_2(BIF_ALIST_2) goto badarg; } - res = erts_check_process_code(BIF_P, BIF_ARG_1, flags, &reds); + res = erts_check_process_code(BIF_P, BIF_ARG_1, flags, &reds, BIF_P->fcalls); ASSERT(is_value(res)); @@ -625,8 +625,8 @@ BIF_RETTYPE call_on_load_function_1(BIF_ALIST_1) { Module* modp = erts_get_module(BIF_ARG_1, erts_active_code_ix()); - if (modp && modp->curr.code_hdr) { - BIF_TRAP_CODE_PTR_0(BIF_P, modp->curr.code_hdr->on_load_function_ptr); + if (modp && modp->old.code_hdr) { + BIF_TRAP_CODE_PTR_0(BIF_P, modp->old.code_hdr->on_load_function_ptr); } else { BIF_ERROR(BIF_P, BADARG); @@ -651,14 +651,14 @@ BIF_RETTYPE finish_after_on_load_2(BIF_ALIST_2) code_ix = erts_active_code_ix(); modp = erts_get_module(BIF_ARG_1, code_ix); - if (!modp || !modp->curr.code_hdr) { + if (!modp || !modp->old.code_hdr) { error: erts_smp_thr_progress_unblock(); erts_smp_proc_lock(BIF_P, ERTS_PROC_LOCK_MAIN); erts_release_code_write_permission(); BIF_ERROR(BIF_P, BADARG); } - if (modp->curr.code_hdr->on_load_function_ptr == NULL) { + if (modp->old.code_hdr->on_load_function_ptr == NULL) { goto error; } if (BIF_ARG_2 != am_false && BIF_ARG_2 != am_true) { @@ -667,44 +667,55 @@ BIF_RETTYPE finish_after_on_load_2(BIF_ALIST_2) if (BIF_ARG_2 == am_true) { int i; + struct erl_module_instance t; + + /* + * Swap old and new code. + */ + t = modp->curr; + modp->curr = modp->old; + modp->old = t; /* * The on_load function succeded. Fix up export entries. */ for (i = 0; i < export_list_size(code_ix); i++) { Export *ep = export_list(i,code_ix); - if (ep != NULL && - ep->code[0] == BIF_ARG_1 && - ep->code[4] != 0) { + if (ep == NULL || ep->code[0] != BIF_ARG_1) { + continue; + } + if (ep->code[4] != 0) { ep->addressv[code_ix] = (void *) ep->code[4]; ep->code[4] = 0; + } else { + if (ep->addressv[code_ix] == ep->code+3 && + ep->code[3] == (BeamInstr) em_apply_bif) { + continue; + } + ep->addressv[code_ix] = ep->code+3; + ep->code[3] = (BeamInstr) em_call_error_handler; } } modp->curr.code_hdr->on_load_function_ptr = NULL; set_default_trace_pattern(BIF_ARG_1); } else if (BIF_ARG_2 == am_false) { - BeamInstr* code; - BeamInstr* end; + int i; /* - * The on_load function failed. Remove the loaded code. - * This is an combination of delete and purge. We purge - * the current code; the old code is not touched. + * The on_load function failed. Remove references to the + * code that is about to be purged from the export entries. */ - erts_total_code_size -= modp->curr.code_length; - code = (BeamInstr*) modp->curr.code_hdr; - end = (BeamInstr *) ((char *)code + modp->curr.code_length); - erts_cleanup_funs_on_purge(code, end); - beam_catches_delmod(modp->curr.catches, code, modp->curr.code_length, - erts_active_code_ix()); - if (modp->curr.code_hdr->literals_start) { - erts_free(ERTS_ALC_T_LITERAL, modp->curr.code_hdr->literals_start); - } - erts_free(ERTS_ALC_T_CODE, modp->curr.code_hdr); - modp->curr.code_hdr = NULL; - modp->curr.code_length = 0; - modp->curr.catches = BEAM_CATCHES_NIL; - erts_remove_from_ranges(code); + + for (i = 0; i < export_list_size(code_ix); i++) { + Export *ep = export_list(i,code_ix); + if (ep == NULL || ep->code[0] != BIF_ARG_1) { + continue; + } + if (ep->code[3] == (BeamInstr) em_apply_bif) { + continue; + } + ep->code[4] = 0; + } } erts_smp_thr_progress_unblock(); erts_smp_proc_lock(BIF_P, ERTS_PROC_LOCK_MAIN); @@ -753,7 +764,7 @@ check_mod_funs(Process *p, ErlOffHeap *off_heap, char *area, size_t area_size) static Eterm -check_process_code(Process* rp, Module* modp, Uint flags, int *redsp) +check_process_code(Process* rp, Module* modp, Uint flags, int *redsp, int fcalls) { BeamInstr* start; char* literals; @@ -955,7 +966,7 @@ check_process_code(Process* rp, Module* modp, Uint flags, int *redsp) if (need_gc & ERTS_ORDINARY_GC__) { FLAGS(rp) |= F_NEED_FULLSWEEP; - *redsp += erts_garbage_collect_nobump(rp, 0, rp->arg_reg, rp->arity); + *redsp += erts_garbage_collect_nobump(rp, 0, rp->arg_reg, rp->arity, fcalls); done_gc |= ERTS_ORDINARY_GC__; } if (need_gc & ERTS_LITERAL_GC__) { diff --git a/erts/emulator/beam/beam_bp.h b/erts/emulator/beam/beam_bp.h index fc17f95b5d..9c2fc007a2 100644 --- a/erts/emulator/beam/beam_bp.h +++ b/erts/emulator/beam/beam_bp.h @@ -173,19 +173,7 @@ void erts_clear_time_trace_bif(BeamInstr *pc); BeamInstr *erts_find_local_func(Eterm mfa[3]); -ERTS_GLB_INLINE Uint erts_bp_sched2ix(void); - #if ERTS_GLB_INLINE_INCL_FUNC_DEF -ERTS_GLB_INLINE Uint erts_bp_sched2ix(void) -{ -#ifdef ERTS_SMP - ErtsSchedulerData *esdp; - esdp = erts_get_scheduler_data(); - return esdp->no - 1; -#else - return 0; -#endif -} extern erts_smp_atomic32_t erts_active_bp_index; extern erts_smp_atomic32_t erts_staging_bp_index; diff --git a/erts/emulator/beam/beam_emu.c b/erts/emulator/beam/beam_emu.c index aab0baebea..99eb26bec5 100644 --- a/erts/emulator/beam/beam_emu.c +++ b/erts/emulator/beam/beam_emu.c @@ -308,7 +308,8 @@ void** beam_ops; if (E - HTOP < (needed + (HeapNeed))) { \ SWAPOUT; \ PROCESS_MAIN_CHK_LOCKS(c_p); \ - FCALLS -= erts_garbage_collect_nobump(c_p, needed + (HeapNeed), reg, (M)); \ + FCALLS -= erts_garbage_collect_nobump(c_p, needed + (HeapNeed), \ + reg, (M), FCALLS); \ ERTS_VERIFY_UNUSED_TEMP_ALLOC(c_p); \ PROCESS_MAIN_CHK_LOCKS(c_p); \ SWAPIN; \ @@ -360,7 +361,7 @@ void** beam_ops; if ((E - HTOP < need) || (MSO(c_p).overhead + (VNh) >= BIN_VHEAP_SZ(c_p))) {\ SWAPOUT; \ PROCESS_MAIN_CHK_LOCKS(c_p); \ - FCALLS -= erts_garbage_collect_nobump(c_p, need, reg, (Live)); \ + FCALLS -= erts_garbage_collect_nobump(c_p, need, reg, (Live), FCALLS); \ ERTS_VERIFY_UNUSED_TEMP_ALLOC(c_p); \ PROCESS_MAIN_CHK_LOCKS(c_p); \ SWAPIN; \ @@ -381,7 +382,7 @@ void** beam_ops; if (E - HTOP < need) { \ SWAPOUT; \ PROCESS_MAIN_CHK_LOCKS(c_p); \ - FCALLS -= erts_garbage_collect_nobump(c_p, need, reg, (Live));\ + FCALLS -= erts_garbage_collect_nobump(c_p, need, reg, (Live), FCALLS); \ ERTS_VERIFY_UNUSED_TEMP_ALLOC(c_p); \ PROCESS_MAIN_CHK_LOCKS(c_p); \ SWAPIN; \ @@ -402,7 +403,7 @@ void** beam_ops; SWAPOUT; \ reg[Live] = Extra; \ PROCESS_MAIN_CHK_LOCKS(c_p); \ - FCALLS -= erts_garbage_collect_nobump(c_p, need, reg, (Live)+1); \ + FCALLS -= erts_garbage_collect_nobump(c_p, need, reg, (Live)+1, FCALLS); \ ERTS_VERIFY_UNUSED_TEMP_ALLOC(c_p); \ PROCESS_MAIN_CHK_LOCKS(c_p); \ Extra = reg[Live]; \ @@ -1196,6 +1197,25 @@ init_emulator(void) #define DTRACE_NIF_RETURN(p, m, f, a) do {} while (0) #endif /* USE_VM_PROBES */ +#ifdef DEBUG +#define ERTS_DBG_CHK_REDS(P, FC) \ + do { \ + if (ERTS_PROC_GET_SAVED_CALLS_BUF((P))) { \ + ASSERT(FC <= 0); \ + ASSERT(ERTS_PROC_GET_SCHDATA(c_p)->virtual_reds \ + <= 0 - (FC)); \ + } \ + else { \ + ASSERT(FC <= CONTEXT_REDS); \ + ASSERT(ERTS_PROC_GET_SCHDATA(c_p)->virtual_reds \ + <= CONTEXT_REDS - (FC)); \ + } \ +} while (0) +#else +#define ERTS_DBG_CHK_REDS(P, FC) +#endif + + /* * process_main() is called twice: * The first call performs some initialisation, including exporting @@ -1290,7 +1310,12 @@ void process_main(void) goto do_schedule1; do_schedule: - reds_used = REDS_IN(c_p) - FCALLS; + ASSERT(c_p->debug_reds_in == REDS_IN(c_p)); + if (!ERTS_PROC_GET_SAVED_CALLS_BUF(c_p)) + reds_used = REDS_IN(c_p) - FCALLS; + else + reds_used = REDS_IN(c_p) - (CONTEXT_REDS + FCALLS); + ASSERT(reds_used >= 0); do_schedule1: if (start_time != 0) { @@ -1310,6 +1335,7 @@ void process_main(void) ERTS_SMP_UNREQ_PROC_MAIN_LOCK(c_p); ERTS_VERIFY_UNUSED_TEMP_ALLOC(c_p); c_p = schedule(c_p, reds_used); + ASSERT(!(c_p->flags & F_HIPE_MODE)); ERTS_VERIFY_UNUSED_TEMP_ALLOC(c_p); start_time = 0; #ifdef DEBUG @@ -1348,16 +1374,21 @@ void process_main(void) SET_I(c_p->i); - reds = c_p->fcalls; - if (ERTS_PROC_GET_SAVED_CALLS_BUF(c_p) - && (ERTS_TRACE_FLAGS(c_p) & F_SENSITIVE) == 0) { - neg_o_reds = -reds; - FCALLS = REDS_IN(c_p) = 0; + REDS_IN(c_p) = reds = c_p->fcalls; +#ifdef DEBUG + c_p->debug_reds_in = reds; +#endif + + if (ERTS_PROC_GET_SAVED_CALLS_BUF(c_p)) { + neg_o_reds = -CONTEXT_REDS; + FCALLS = neg_o_reds + reds; } else { neg_o_reds = 0; - FCALLS = REDS_IN(c_p) = reds; + FCALLS = reds; } + ERTS_DBG_CHK_REDS(c_p, FCALLS); + next = (BeamInstr *) *I; SWAPIN; ASSERT(VALID_INSTR(next)); @@ -1770,7 +1801,7 @@ void process_main(void) if (E - HTOP < 3) { SWAPOUT; PROCESS_MAIN_CHK_LOCKS(c_p); - FCALLS -= erts_garbage_collect_nobump(c_p, 3, reg+2, 1); + FCALLS -= erts_garbage_collect_nobump(c_p, 3, reg+2, 1, FCALLS); ERTS_VERIFY_UNUSED_TEMP_ALLOC(c_p); PROCESS_MAIN_CHK_LOCKS(c_p); SWAPIN; @@ -1865,6 +1896,7 @@ void process_main(void) c_p->flags |= F_DELAY_GC; loop_rec__: + PROCESS_MAIN_CHK_LOCKS(c_p); msgp = PEEK_MESSAGE(c_p); @@ -2007,6 +2039,8 @@ void process_main(void) ERTS_VBUMP_LEAVE_REDS_INTERNAL(c_p, 5, FCALLS); } + ERTS_DBG_CHK_REDS(c_p, FCALLS); + ERTS_VERIFY_UNUSED_TEMP_ALLOC(c_p); PROCESS_MAIN_CHK_LOCKS(c_p); NextPF(0, next); @@ -2535,6 +2569,7 @@ do { \ GetArg1(2, tmp_reg[0]); bf = (BifFunction) Arg(1); + ERTS_DBG_CHK_REDS(c_p, FCALLS); c_p->fcalls = FCALLS; PROCESS_MAIN_CHK_LOCKS(c_p); ASSERT(!ERTS_PROC_IS_EXITING(c_p)); @@ -2544,6 +2579,7 @@ do { \ PROCESS_MAIN_CHK_LOCKS(c_p); ERTS_HOLE_CHECK(c_p); FCALLS = c_p->fcalls; + ERTS_DBG_CHK_REDS(c_p, FCALLS); if (is_value(result)) { StoreBifResult(3, result); } @@ -2564,6 +2600,7 @@ do { \ GetArg1(1, tmp_reg[0]); bf = (BifFunction) Arg(0); + ERTS_DBG_CHK_REDS(c_p, FCALLS); c_p->fcalls = FCALLS; PROCESS_MAIN_CHK_LOCKS(c_p); ASSERT(!ERTS_PROC_IS_EXITING(c_p)); @@ -2573,6 +2610,7 @@ do { \ PROCESS_MAIN_CHK_LOCKS(c_p); ERTS_HOLE_CHECK(c_p); FCALLS = c_p->fcalls; + ERTS_DBG_CHK_REDS(c_p, FCALLS); if (is_value(result)) { StoreBifResult(2, result); } @@ -2591,6 +2629,7 @@ do { \ GetArg1(2, x(live)); bf = (GcBifFunction) Arg(1); + ERTS_DBG_CHK_REDS(c_p, FCALLS); c_p->fcalls = FCALLS; SWAPOUT; PROCESS_MAIN_CHK_LOCKS(c_p); @@ -2602,6 +2641,7 @@ do { \ SWAPIN; ERTS_HOLE_CHECK(c_p); FCALLS = c_p->fcalls; + ERTS_DBG_CHK_REDS(c_p, FCALLS); if (is_value(result)) { StoreBifResult(4, result); } @@ -2630,6 +2670,7 @@ do { \ */ live++; bf = (GcBifFunction) Arg(1); + ERTS_DBG_CHK_REDS(c_p, FCALLS); c_p->fcalls = FCALLS; SWAPOUT; PROCESS_MAIN_CHK_LOCKS(c_p); @@ -2641,6 +2682,7 @@ do { \ SWAPIN; ERTS_HOLE_CHECK(c_p); FCALLS = c_p->fcalls; + ERTS_DBG_CHK_REDS(c_p, FCALLS); if (is_value(result)) { StoreBifResult(5, result); } @@ -2671,6 +2713,7 @@ do { \ */ live += 2; bf = (GcBifFunction) Arg(1); + ERTS_DBG_CHK_REDS(c_p, FCALLS); c_p->fcalls = FCALLS; SWAPOUT; PROCESS_MAIN_CHK_LOCKS(c_p); @@ -2682,6 +2725,7 @@ do { \ SWAPIN; ERTS_HOLE_CHECK(c_p); FCALLS = c_p->fcalls; + ERTS_DBG_CHK_REDS(c_p, FCALLS); if (is_value(result)) { StoreBifResult(5, result); } @@ -2708,6 +2752,7 @@ do { \ GetArg2(2, tmp_reg[0], tmp_reg[1]); bf = (BifFunction) Arg(1); + ERTS_DBG_CHK_REDS(c_p, FCALLS); c_p->fcalls = FCALLS; PROCESS_MAIN_CHK_LOCKS(c_p); ASSERT(!ERTS_PROC_IS_EXITING(c_p)); @@ -2717,6 +2762,7 @@ do { \ PROCESS_MAIN_CHK_LOCKS(c_p); ERTS_HOLE_CHECK(c_p); FCALLS = c_p->fcalls; + ERTS_DBG_CHK_REDS(c_p, FCALLS); if (is_value(result)) { StoreBifResult(4, result); } @@ -2775,6 +2821,7 @@ do { \ bf = GET_BIF_ADDRESS(Arg(0)); PRE_BIF_SWAPOUT(c_p); + ERTS_DBG_CHK_REDS(c_p, FCALLS); c_p->fcalls = FCALLS - 1; if (FCALLS <= 0) { save_calls(c_p, (Export *) Arg(0)); @@ -2796,6 +2843,7 @@ do { \ PROCESS_MAIN_CHK_LOCKS(c_p); HTOP = HEAP_TOP(c_p); FCALLS = c_p->fcalls; + ERTS_DBG_CHK_REDS(c_p, FCALLS); /* We have to update the cache if we are enabled in order to make sure no book keeping is done after we disabled msacc. We don't always do this as it is quite expensive. */ @@ -3324,8 +3372,13 @@ do { \ * (beacuse the code for the Dispatch() macro becomes shorter that way). */ - reds_used = REDS_IN(c_p) - FCALLS + 1; - + ASSERT(c_p->debug_reds_in == REDS_IN(c_p)); + if (!ERTS_PROC_GET_SAVED_CALLS_BUF(c_p)) + reds_used = REDS_IN(c_p) - FCALLS; + else + reds_used = REDS_IN(c_p) - (CONTEXT_REDS + FCALLS); + ASSERT(reds_used >= 0); + /* * Save the argument registers and everything else. */ @@ -3514,6 +3567,7 @@ do { \ DTRACE_BIF_ENTRY(c_p, (Eterm)I[-3], (Eterm)I[-2], (Uint)I[-1]); SWAPOUT; + ERTS_DBG_CHK_REDS(c_p, FCALLS - 1); c_p->fcalls = FCALLS - 1; vbf = (BifFunction) Arg(0); PROCESS_MAIN_CHK_LOCKS(c_p); @@ -3549,6 +3603,7 @@ do { \ } SWAPIN; /* There might have been a garbage collection. */ FCALLS = c_p->fcalls; + ERTS_DBG_CHK_REDS(c_p, FCALLS); if (is_value(nif_bif_result)) { r(0) = nif_bif_result; CHECK_TERM(r(0)); @@ -4611,9 +4666,9 @@ do { \ OpCase(i_generic_breakpoint): { BeamInstr real_I; ASSERT(I[-5] == (BeamInstr) BeamOp(op_i_func_info_IaaI)); - SWAPOUT; + HEAVY_SWAPOUT; real_I = erts_generic_breakpoint(c_p, I, reg); - SWAPIN; + HEAVY_SWAPIN; ASSERT(VALID_INSTR(real_I)); Goto(real_I); } @@ -4790,6 +4845,7 @@ do { \ { #define HIPE_MODE_SWITCH(Cmd) \ SWAPOUT; \ + ERTS_DBG_CHK_REDS(c_p, FCALLS); \ c_p->fcalls = FCALLS; \ c_p->def_arg_reg[4] = -neg_o_reds; \ c_p = hipe_mode_switch(c_p, Cmd, reg); \ @@ -4828,6 +4884,9 @@ do { \ #undef HIPE_MODE_SWITCH L_post_hipe_mode_switch: +#ifdef DEBUG + pid = c_p->common.id; /* may have switched process... */ +#endif reg = ERTS_PROC_GET_SCHDATA(c_p)->x_reg_array; freg = ERTS_PROC_GET_SCHDATA(c_p)->f_reg_array; ERL_BITS_RELOAD_STATEP(c_p); @@ -4835,6 +4894,7 @@ do { \ neg_o_reds = -c_p->def_arg_reg[4]; FCALLS = c_p->fcalls; SWAPIN; + ERTS_DBG_CHK_REDS(c_p, FCALLS); switch( c_p->def_arg_reg[3] ) { case HIPE_MODE_SWITCH_RES_RETURN: ASSERT(is_value(reg[0])); @@ -6839,7 +6899,7 @@ erts_current_reductions(Process *current, Process *p) if (current != p) { return 0; } else if (current->fcalls < 0 && ERTS_PROC_GET_SAVED_CALLS_BUF(current)) { - return -current->fcalls; + return current->fcalls + CONTEXT_REDS; } else { return REDS_IN(current) - current->fcalls; } diff --git a/erts/emulator/beam/beam_load.c b/erts/emulator/beam/beam_load.c index 2e21a553ed..95489d9a63 100644 --- a/erts/emulator/beam/beam_load.c +++ b/erts/emulator/beam/beam_load.c @@ -32,6 +32,7 @@ #include "bif.h" #include "external.h" #include "beam_load.h" +#include "beam_bp.h" #include "big.h" #include "erl_bits.h" #include "beam_catches.h" @@ -479,9 +480,9 @@ static void free_loader_state(Binary* magic); static ErlHeapFragment* new_literal_fragment(Uint size); static void free_literal_fragment(ErlHeapFragment*); static void loader_state_dtor(Binary* magic); -static Eterm insert_new_code(Process *c_p, ErtsProcLocks c_p_locks, - Eterm group_leader, Eterm module, - BeamCodeHeader* code, Uint size); +static Eterm stub_insert_new_code(Process *c_p, ErtsProcLocks c_p_locks, + Eterm group_leader, Eterm module, + BeamCodeHeader* code, Uint size); static int init_iff_file(LoaderState* stp, byte* code, Uint size); static int scan_iff_file(LoaderState* stp, Uint* chunk_types, Uint num_types, Uint num_mandatory); @@ -513,7 +514,7 @@ static GenOp* gen_get_map_element(LoaderState* stp, GenOpArg Fail, GenOpArg Src, static int freeze_code(LoaderState* stp); -static void final_touch(LoaderState* stp); +static void final_touch(LoaderState* stp, struct erl_module_instance* inst_p); static void short_file(int line, LoaderState* stp, unsigned needed); static void load_printf(int line, LoaderState* context, char *fmt, ...); static int transform_engine(LoaderState* st); @@ -766,8 +767,11 @@ Eterm erts_finish_loading(Binary* magic, Process* c_p, ErtsProcLocks c_p_locks, Eterm* modp) { - Eterm retval; + Eterm retval = NIL; LoaderState* stp = ERTS_MAGIC_BIN_DATA(magic); + Module* mod_tab_p; + struct erl_module_instance* inst_p; + Uint size; /* * No other process may run since we will update the export @@ -776,27 +780,80 @@ erts_finish_loading(Binary* magic, Process* c_p, ERTS_SMP_LC_ASSERT(erts_initialized == 0 || erts_has_code_write_permission() || erts_smp_thr_progress_is_blocking()); - /* * Make current code for the module old and insert the new code * as current. This will fail if there already exists old code * for the module. */ + mod_tab_p = erts_put_module(stp->module); CHKBLK(ERTS_ALC_T_CODE,stp->code); - retval = insert_new_code(c_p, c_p_locks, stp->group_leader, stp->module, - stp->hdr, stp->loaded_size); - if (retval != NIL) { - goto load_error; + if (!stp->on_load) { + /* + * Normal case -- no -on_load() function. + */ + retval = beam_make_current_old(c_p, c_p_locks, stp->module); + ASSERT(retval == NIL); + } else { + ErtsCodeIndex code_ix = erts_staging_code_ix(); + Eterm module = stp->module; + int i; + + /* + * There is an -on_load() function. We will keep the current + * code, but we must turn off any tracing. + */ + + for (i = 0; i < export_list_size(code_ix); i++) { + Export *ep = export_list(i, code_ix); + if (ep == NULL || ep->code[0] != module) { + continue; + } + if (ep->addressv[code_ix] == ep->code+3) { + if (ep->code[3] == (BeamInstr) em_apply_bif) { + continue; + } else if (ep->code[3] == + (BeamInstr) BeamOp(op_i_generic_breakpoint)) { + ERTS_SMP_LC_ASSERT(erts_smp_thr_progress_is_blocking()); + ASSERT(mod_tab_p->curr.num_traced_exports > 0); + erts_clear_export_break(mod_tab_p, ep->code+3); + ep->addressv[code_ix] = (BeamInstr *) ep->code[4]; + ep->code[4] = 0; + } + ASSERT(ep->code[4] == 0); + } + } + ASSERT(mod_tab_p->curr.num_breakpoints == 0); + ASSERT(mod_tab_p->curr.num_traced_exports == 0); } /* + * Update module table. + */ + + size = stp->loaded_size; + erts_total_code_size += size; + if (stp->on_load) { + inst_p = &mod_tab_p->old; + } else { + inst_p = &mod_tab_p->curr; + } + inst_p->code_hdr = stp->hdr; + inst_p->code_length = size; + + /* + * Update ranges (used for finding a function from a PC value). + */ + + erts_update_ranges((BeamInstr*)inst_p->code_hdr, size); + + /* * Ready for the final touch: fixing the export table entries for * exported and imported functions. This can't fail. */ CHKBLK(ERTS_ALC_T_CODE,stp->code); - final_touch(stp); + final_touch(stp, inst_p); /* * Loading succeded. @@ -820,7 +877,6 @@ erts_finish_loading(Binary* magic, Process* c_p, retval = am_on_load; } - load_error: free_loader_state(magic); return retval; } @@ -1026,9 +1082,9 @@ loader_state_dtor(Binary* magic) } static Eterm -insert_new_code(Process *c_p, ErtsProcLocks c_p_locks, - Eterm group_leader, Eterm module, BeamCodeHeader* code_hdr, - Uint size) +stub_insert_new_code(Process *c_p, ErtsProcLocks c_p_locks, + Eterm group_leader, Eterm module, + BeamCodeHeader* code_hdr, Uint size) { Module* modp; Eterm retval; @@ -4700,14 +4756,13 @@ freeze_code(LoaderState* stp) } static void -final_touch(LoaderState* stp) +final_touch(LoaderState* stp, struct erl_module_instance* inst_p) { int i; int on_load = stp->on_load; unsigned catches; Uint index; BeamInstr* codev = stp->codev; - Module* modp; /* * Allocate catch indices and fix up all catch_yf instructions. @@ -4722,8 +4777,7 @@ final_touch(LoaderState* stp) codev[index+2] = make_catch(catches); index = next; } - modp = erts_put_module(stp->module); - modp->curr.catches = catches; + inst_p->catches = catches; /* * Export functions. @@ -4743,10 +4797,10 @@ final_touch(LoaderState* stp) ep->addressv[erts_staging_code_ix()] = address; } else { /* - * Don't make any of the exported functions - * callable yet. + * on_load: Don't make any of the exported functions + * callable yet. Keep any function in the current + * code callable. */ - ep->addressv[erts_staging_code_ix()] = ep->code+3; ep->code[4] = (BeamInstr) address; } } @@ -6421,7 +6475,8 @@ erts_make_stub_module(Process* p, Eterm Mod, Eterm Beam, Eterm Info) * Insert the module in the module table. */ - rval = insert_new_code(p, 0, p->group_leader, Mod, code_hdr, code_size); + rval = stub_insert_new_code(p, 0, p->group_leader, Mod, + code_hdr, code_size); if (rval != NIL) { goto error; } diff --git a/erts/emulator/beam/bif.c b/erts/emulator/beam/bif.c index ac77fa96e1..eed0702688 100644 --- a/erts/emulator/beam/bif.c +++ b/erts/emulator/beam/bif.c @@ -1569,7 +1569,32 @@ static BIF_RETTYPE process_flag_aux(Process *BIF_P, scb->n = 0; } - scb = ERTS_PROC_SET_SAVED_CALLS_BUF(rp, scb); +#ifdef HIPE + if (rp->flags & F_HIPE_MODE) { + ASSERT(!ERTS_PROC_GET_SAVED_CALLS_BUF(rp)); + scb = ERTS_PROC_SET_SUSPENDED_SAVED_CALLS_BUF(rp, scb); + } + else +#endif + { +#ifdef HIPE + ASSERT(!ERTS_PROC_GET_SUSPENDED_SAVED_CALLS_BUF(rp)); +#endif + scb = ERTS_PROC_SET_SAVED_CALLS_BUF(rp, scb); + if (rp == BIF_P && ((scb && i == 0) || (!scb && i != 0))) { + /* Adjust fcalls to match save calls setting... */ + if (i == 0) + BIF_P->fcalls += CONTEXT_REDS; /* disabled it */ + else + BIF_P->fcalls -= CONTEXT_REDS; /* enabled it */ + + /* + * Make sure we reschedule immediately so the + * change take effect at once. + */ + ERTS_VBUMP_ALL_REDS(BIF_P); + } + } if (!scb) old_value = make_small(0); @@ -1578,12 +1603,7 @@ static BIF_RETTYPE process_flag_aux(Process *BIF_P, erts_free(ERTS_ALC_T_CALLS_BUF, (void *) scb); } - /* Make sure the process in question is rescheduled - immediately, if it's us, so the call saving takes effect. */ - if (rp == BIF_P) - BIF_RET2(old_value, CONTEXT_REDS); - else - BIF_RET(old_value); + BIF_RET(old_value); } error: @@ -1736,7 +1756,9 @@ BIF_RETTYPE process_flag_2(BIF_ALIST_2) ERTS_TRACE_FLAGS(BIF_P) &= ~F_SENSITIVE; } erts_smp_proc_unlock(BIF_P, ERTS_PROC_LOCKS_ALL_MINOR); - BIF_RET(old_value); + /* make sure to bump all reds so that we get + rescheduled immediately so setting takes effect */ + BIF_RET2(old_value, CONTEXT_REDS); } else if (BIF_ARG_1 == am_monitor_nodes) { /* @@ -1775,10 +1797,18 @@ BIF_RETTYPE process_flag_3(BIF_ALIST_3) Process *rp; Eterm res; - if ((rp = erts_pid2proc(BIF_P, ERTS_PROC_LOCK_MAIN, - BIF_ARG_1, ERTS_PROC_LOCK_MAIN)) == NULL) { +#ifdef ERTS_SMP + rp = erts_pid2proc_not_running(BIF_P, ERTS_PROC_LOCK_MAIN, + BIF_ARG_1, ERTS_PROC_LOCK_MAIN); + if (rp == ERTS_PROC_LOCK_BUSY) + ERTS_BIF_YIELD3(bif_export[BIF_process_flag_3], BIF_P, + BIF_ARG_1, BIF_ARG_2, BIF_ARG_3); +#else + rp = erts_proc_lookup(BIF_ARG_1); +#endif + + if (!rp) BIF_ERROR(BIF_P, BADARG); - } res = process_flag_aux(BIF_P, rp, BIF_ARG_2, BIF_ARG_3); diff --git a/erts/emulator/beam/bif.h b/erts/emulator/beam/bif.h index 546e3830b9..5d751dd67d 100644 --- a/erts/emulator/beam/bif.h +++ b/erts/emulator/beam/bif.h @@ -52,6 +52,7 @@ extern Export *erts_convert_time_unit_trap; (p)->fcalls = 0; \ else \ (p)->fcalls = -CONTEXT_REDS; \ + ASSERT(ERTS_BIF_REDS_LEFT((p)) == 0); \ } while(0) #define ERTS_VBUMP_ALL_REDS_INTERNAL(p, fcalls) \ diff --git a/erts/emulator/beam/break.c b/erts/emulator/beam/break.c index 4f5e80f2e5..d02c6828f9 100644 --- a/erts/emulator/beam/break.c +++ b/erts/emulator/beam/break.c @@ -347,8 +347,11 @@ print_process_info(int to, void *to_arg, Process *p) static void print_garb_info(int to, void *to_arg, Process* p) { +#ifdef ERTS_SMP /* ERTS_SMP: A scheduler is probably concurrently doing gc... */ -#ifndef ERTS_SMP + if (!ERTS_IS_CRASH_DUMPING) + return; +#endif erts_print(to, to_arg, "New heap start: %bpX\n", p->heap); erts_print(to, to_arg, "New heap top: %bpX\n", p->htop); erts_print(to, to_arg, "Stack top: %bpX\n", p->stop); @@ -356,7 +359,6 @@ print_garb_info(int to, void *to_arg, Process* p) erts_print(to, to_arg, "Old heap start: %bpX\n", OLD_HEAP(p)); erts_print(to, to_arg, "Old heap top: %bpX\n", OLD_HTOP(p)); erts_print(to, to_arg, "Old heap end: %bpX\n", OLD_HEND(p)); -#endif } void diff --git a/erts/emulator/beam/dist.c b/erts/emulator/beam/dist.c index b020f16805..09c83f1117 100644 --- a/erts/emulator/beam/dist.c +++ b/erts/emulator/beam/dist.c @@ -1967,7 +1967,7 @@ dist_port_command(Port *prt, ErtsDistOutputBuf *obuf) ERTS_SMP_LC_ASSERT(erts_lc_is_port_locked(prt)); if (size > (Uint) INT_MAX) - erts_exit(ERTS_ABORT_EXIT, + erts_exit(ERTS_DUMP_EXIT, "Absurdly large distribution output data buffer " "(%beu bytes) passed.\n", size); @@ -2007,7 +2007,7 @@ dist_port_commandv(Port *prt, ErtsDistOutputBuf *obuf) ERTS_SMP_LC_ASSERT(erts_lc_is_port_locked(prt)); if (size > (Uint) INT_MAX) - erts_exit(ERTS_ABORT_EXIT, + erts_exit(ERTS_DUMP_EXIT, "Absurdly large distribution output data buffer " "(%beu bytes) passed.\n", size); diff --git a/erts/emulator/beam/erl_async.c b/erts/emulator/beam/erl_async.c index 4d6d699d9f..84254af0c2 100644 --- a/erts/emulator/beam/erl_async.c +++ b/erts/emulator/beam/erl_async.c @@ -283,10 +283,10 @@ static ERTS_INLINE void async_add(ErtsAsync *a, ErtsAsyncQ* q) erts_thr_q_enqueue(&q->thr_q, a); #ifdef USE_LTTNG_VM_TRACEPOINTS - if (LTTNG_ENABLED(aio_pool_add)) { + if (LTTNG_ENABLED(aio_pool_put)) { lttng_decl_portbuf(port_str); lttng_portid_to_str(a->port, port_str); - LTTNG2(aio_pool_add, port_str, -1); + LTTNG2(aio_pool_put, port_str, -1); } #endif #ifdef USE_VM_PROBES diff --git a/erts/emulator/beam/erl_bif_info.c b/erts/emulator/beam/erl_bif_info.c index c9741b361f..99fe847ba2 100644 --- a/erts/emulator/beam/erl_bif_info.c +++ b/erts/emulator/beam/erl_bif_info.c @@ -1359,9 +1359,10 @@ process_info_aux(Process *BIF_P, total_heap_size += rp->mbuf_sz; - for (mp = rp->msg.first; mp; mp = mp->next) - if (mp->data.attached) - total_heap_size += erts_msg_attached_data_size(mp); + if (rp->flags & F_ON_HEAP_MSGQ) + for (mp = rp->msg.first; mp; mp = mp->next) + if (mp->data.attached) + total_heap_size += erts_msg_attached_data_size(mp); (void) erts_bld_uint(NULL, &hsz, total_heap_size); hp = HAlloc(BIF_P, hsz); diff --git a/erts/emulator/beam/erl_gc.c b/erts/emulator/beam/erl_gc.c index 85a1467a52..bed7e668d7 100644 --- a/erts/emulator/beam/erl_gc.c +++ b/erts/emulator/beam/erl_gc.c @@ -116,7 +116,7 @@ static Eterm *full_sweep_heaps(Process *p, char *oh, Uint oh_size, Eterm *objv, int nobj); static int garbage_collect(Process* p, ErlHeapFragment *live_hf_end, - int need, Eterm* objv, int nobj); + int need, Eterm* objv, int nobj, int fcalls); static int major_collection(Process* p, ErlHeapFragment *live_hf_end, int need, Eterm* objv, int nobj, Uint *recl); static int minor_collection(Process* p, ErlHeapFragment *live_hf_end, @@ -392,15 +392,15 @@ erts_gc_after_bif_call_lhf(Process* p, ErlHeapFragment *live_hf_end, regs = ERTS_PROC_GET_SCHDATA(p)->x_reg_array; } #endif - cost = garbage_collect(p, live_hf_end, 0, regs, p->arity); + cost = garbage_collect(p, live_hf_end, 0, regs, p->arity, p->fcalls); } else { - cost = garbage_collect(p, live_hf_end, 0, regs, arity); + cost = garbage_collect(p, live_hf_end, 0, regs, arity, p->fcalls); } } else { Eterm val[1]; val[0] = result; - cost = garbage_collect(p, live_hf_end, 0, val, 1); + cost = garbage_collect(p, live_hf_end, 0, val, 1, p->fcalls); result = val[0]; } BUMP_REDS(p, cost); @@ -431,7 +431,7 @@ static ERTS_INLINE void reset_active_writer(Process *p) #define ERTS_ABANDON_HEAP_COST 10 static int -delay_garbage_collection(Process *p, ErlHeapFragment *live_hf_end, int need) +delay_garbage_collection(Process *p, ErlHeapFragment *live_hf_end, int need, int fcalls) { ErlHeapFragment *hfrag; Eterm *orig_heap, *orig_hend, *orig_htop, *orig_stop; @@ -506,12 +506,16 @@ delay_garbage_collection(Process *p, ErlHeapFragment *live_hf_end, int need) /* Make sure that we do a proper GC as soon as possible... */ p->flags |= F_FORCE_GC; - reds_left = ERTS_BIF_REDS_LEFT(p); + reds_left = ERTS_REDS_LEFT(p, fcalls); + ASSERT(CONTEXT_REDS - reds_left >= ERTS_PROC_GET_SCHDATA(p)->virtual_reds); + if (reds_left > ERTS_ABANDON_HEAP_COST) { int vreds = reds_left - ERTS_ABANDON_HEAP_COST; - ERTS_VBUMP_REDS(p, vreds); + ERTS_PROC_GET_SCHDATA((p))->virtual_reds += vreds; } - return ERTS_ABANDON_HEAP_COST; + + ASSERT(CONTEXT_REDS >= ERTS_PROC_GET_SCHDATA(p)->virtual_reds); + return reds_left; } static ERTS_FORCE_INLINE Uint @@ -570,7 +574,7 @@ young_gen_usage(Process *p) */ static int garbage_collect(Process* p, ErlHeapFragment *live_hf_end, - int need, Eterm* objv, int nobj) + int need, Eterm* objv, int nobj, int fcalls) { Uint reclaimed_now = 0; int reds; @@ -581,8 +585,11 @@ garbage_collect(Process* p, ErlHeapFragment *live_hf_end, DTRACE_CHARBUF(pidbuf, DTRACE_TERM_BUF_SIZE); #endif + ASSERT(CONTEXT_REDS - ERTS_REDS_LEFT(p, fcalls) + >= ERTS_PROC_GET_SCHDATA(p)->virtual_reds); + if (p->flags & (F_DISABLE_GC|F_DELAY_GC)) - return delay_garbage_collection(p, live_hf_end, need); + return delay_garbage_collection(p, live_hf_end, need, fcalls); if (p->abandoned_heap) live_hf_end = ERTS_INVALID_HFRAG_PTR; @@ -703,16 +710,23 @@ do_major_collection: } int -erts_garbage_collect_nobump(Process* p, int need, Eterm* objv, int nobj) +erts_garbage_collect_nobump(Process* p, int need, Eterm* objv, int nobj, int fcalls) { - return garbage_collect(p, ERTS_INVALID_HFRAG_PTR, need, objv, nobj); + int reds = garbage_collect(p, ERTS_INVALID_HFRAG_PTR, need, objv, nobj, fcalls); + int reds_left = ERTS_REDS_LEFT(p, fcalls); + if (reds > reds_left) + reds = reds_left; + ASSERT(CONTEXT_REDS - (reds_left - reds) >= ERTS_PROC_GET_SCHDATA(p)->virtual_reds); + return reds; } void erts_garbage_collect(Process* p, int need, Eterm* objv, int nobj) { - int reds = garbage_collect(p, ERTS_INVALID_HFRAG_PTR, need, objv, nobj); + int reds = garbage_collect(p, ERTS_INVALID_HFRAG_PTR, need, objv, nobj, p->fcalls); BUMP_REDS(p, reds); + ASSERT(CONTEXT_REDS - ERTS_BIF_REDS_LEFT(p) + >= ERTS_PROC_GET_SCHDATA(p)->virtual_reds); } /* @@ -3009,10 +3023,30 @@ erts_process_gc_info(Process *p, Uint *sizep, Eterm **hpp) }; Eterm res = THE_NON_VALUE; + ErtsMessage *mp; ERTS_CT_ASSERT(sizeof(values)/sizeof(*values) == sizeof(tags)/sizeof(*tags)); ERTS_CT_ASSERT(sizeof(values)/sizeof(*values) == ERTS_PROCESS_GC_INFO_MAX_TERMS); + if (p->abandoned_heap) { + Eterm *htop, *heap; + ERTS_GET_ORIG_HEAP(p, heap, htop); + values[3] = HIGH_WATER(p) - heap; + values[6] = htop - heap; + } + + if (p->flags & F_ON_HEAP_MSGQ) { + /* If on heap messages in the internal queue are counted + as being part of the heap, so we have to add them to the + am_mbuf_size value. process_info(total_heap_size) should + be the same as adding old_heap_block_size + heap_block_size + + mbuf_size. + */ + for (mp = p->msg.first; mp; mp = mp->next) + if (mp->data.attached) + values[2] += erts_msg_attached_data_size(mp); + } + res = erts_bld_atom_uword_2tup_list(hpp, sizep, sizeof(values)/sizeof(*values), diff --git a/erts/emulator/beam/erl_gc.h b/erts/emulator/beam/erl_gc.h index 40b7c5d12c..8a6ff99990 100644 --- a/erts/emulator/beam/erl_gc.h +++ b/erts/emulator/beam/erl_gc.h @@ -139,7 +139,7 @@ Eterm erts_process_gc_info(struct process*, Uint *, Eterm **); void erts_gc_info(ErtsGCInfo *gcip); void erts_init_gc(void); -int erts_garbage_collect_nobump(struct process*, int, Eterm*, int); +int erts_garbage_collect_nobump(struct process*, int, Eterm*, int, int); void erts_garbage_collect(struct process*, int, Eterm*, int); void erts_garbage_collect_hibernate(struct process* p); Eterm erts_gc_after_bif_call_lhf(struct process* p, ErlHeapFragment *live_hf_end, diff --git a/erts/emulator/beam/erl_init.c b/erts/emulator/beam/erl_init.c index dec9bdfedc..fcd2739ac3 100644 --- a/erts/emulator/beam/erl_init.c +++ b/erts/emulator/beam/erl_init.c @@ -206,15 +206,15 @@ int erts_no_line_info = 0; /* -L: Don't load line information */ ErtsModifiedTimings erts_modified_timings[] = { /* 0 */ {make_small(0), CONTEXT_REDS, INPUT_REDUCTIONS}, - /* 1 */ {make_small(0), 2*CONTEXT_REDS, 2*INPUT_REDUCTIONS}, + /* 1 */ {make_small(0), (3*CONTEXT_REDS)/4, 2*INPUT_REDUCTIONS}, /* 2 */ {make_small(0), CONTEXT_REDS/2, INPUT_REDUCTIONS/2}, - /* 3 */ {make_small(0), 3*CONTEXT_REDS, 3*INPUT_REDUCTIONS}, + /* 3 */ {make_small(0), (7*CONTEXT_REDS)/8, 3*INPUT_REDUCTIONS}, /* 4 */ {make_small(0), CONTEXT_REDS/3, 3*INPUT_REDUCTIONS}, - /* 5 */ {make_small(0), 4*CONTEXT_REDS, INPUT_REDUCTIONS/2}, + /* 5 */ {make_small(0), (10*CONTEXT_REDS)/11, INPUT_REDUCTIONS/2}, /* 6 */ {make_small(1), CONTEXT_REDS/4, 2*INPUT_REDUCTIONS}, - /* 7 */ {make_small(1), 5*CONTEXT_REDS, INPUT_REDUCTIONS/3}, + /* 7 */ {make_small(1), (5*CONTEXT_REDS)/7, INPUT_REDUCTIONS/3}, /* 8 */ {make_small(10), CONTEXT_REDS/5, 3*INPUT_REDUCTIONS}, - /* 9 */ {make_small(10), 6*CONTEXT_REDS, INPUT_REDUCTIONS/4} + /* 9 */ {make_small(10), (6*CONTEXT_REDS)/7, INPUT_REDUCTIONS/4} }; #define ERTS_MODIFIED_TIMING_LEVELS \ @@ -578,6 +578,8 @@ void erts_usage(void) VH_DEFAULT_SIZE); erts_fprintf(stderr, "-hpds size initial process dictionary size (default %d)\n", erts_pd_initial_size); + erts_fprintf(stderr, "-hmqd val set default message queue data flag for processes,\n"); + erts_fprintf(stderr, " valid values are: off_heap | on_heap | mixed\n"); /* erts_fprintf(stderr, "-i module set the boot module (default init)\n"); */ @@ -655,8 +657,6 @@ void erts_usage(void) erts_fprintf(stderr, "-W<i|w|e> set error logger warnings mapping,\n"); erts_fprintf(stderr, " see error_logger documentation for details\n"); - erts_fprintf(stderr, "-xmqd val set default message queue data flag for processes,\n"); - erts_fprintf(stderr, " valid values are: off_heap | on_heap | mixed\n"); erts_fprintf(stderr, "-zdbbl size set the distribution buffer busy limit in kilobytes\n"); erts_fprintf(stderr, " valid range is [1-%d]\n", INT_MAX/1024); erts_fprintf(stderr, "-zdntgc time set delayed node table gc in seconds\n"); @@ -1487,6 +1487,7 @@ erl_start(int argc, char **argv) * h|ms - min_heap_size * h|mbs - min_bin_vheap_size * h|pds - erts_pd_initial_size + * h|mqd - message_queue_data * */ if (has_prefix("mbs", sub_param)) { @@ -1512,6 +1513,23 @@ erl_start(int argc, char **argv) } VERBOSE(DEBUG_SYSTEM, ("using initial process dictionary size %d\n", erts_pd_initial_size)); + } else if (has_prefix("mqd", sub_param)) { + arg = get_arg(sub_param+3, argv[i+1], &i); + if (sys_strcmp(arg, "mixed") == 0) + erts_default_spo_flags &= ~(SPO_ON_HEAP_MSGQ|SPO_OFF_HEAP_MSGQ); + else if (sys_strcmp(arg, "on_heap") == 0) { + erts_default_spo_flags &= ~SPO_OFF_HEAP_MSGQ; + erts_default_spo_flags |= SPO_ON_HEAP_MSGQ; + } + else if (sys_strcmp(arg, "off_heap") == 0) { + erts_default_spo_flags &= ~SPO_ON_HEAP_MSGQ; + erts_default_spo_flags |= SPO_OFF_HEAP_MSGQ; + } + else { + erts_fprintf(stderr, + "Invalid message_queue_data flag: %s\n", arg); + erts_usage(); + } } else { /* backward compatibility */ arg = get_arg(argv[i]+2, argv[i+1], &i); @@ -2047,32 +2065,6 @@ erl_start(int argc, char **argv) } break; - case 'x': { - char *sub_param = argv[i]+2; - if (has_prefix("mqd", sub_param)) { - arg = get_arg(sub_param+3, argv[i+1], &i); - if (sys_strcmp(arg, "mixed") == 0) - erts_default_spo_flags &= ~(SPO_ON_HEAP_MSGQ|SPO_OFF_HEAP_MSGQ); - else if (sys_strcmp(arg, "on_heap") == 0) { - erts_default_spo_flags &= ~SPO_OFF_HEAP_MSGQ; - erts_default_spo_flags |= SPO_ON_HEAP_MSGQ; - } - else if (sys_strcmp(arg, "off_heap") == 0) { - erts_default_spo_flags &= ~SPO_ON_HEAP_MSGQ; - erts_default_spo_flags |= SPO_OFF_HEAP_MSGQ; - } - else { - erts_fprintf(stderr, - "Invalid message_queue_data flag: %s\n", arg); - erts_usage(); - } - } else { - erts_fprintf(stderr, "bad -x option %s\n", argv[i]); - erts_usage(); - } - break; - } - case 'z': { char *sub_param = argv[i]+2; diff --git a/erts/emulator/beam/erl_nif.c b/erts/emulator/beam/erl_nif.c index bd3e7ebe54..a695a028ba 100644 --- a/erts/emulator/beam/erl_nif.c +++ b/erts/emulator/beam/erl_nif.c @@ -2781,7 +2781,7 @@ BIF_RETTYPE load_nif_2(BIF_ALIST_2) ErlNifEntry* entry = NULL; ErlNifEnv env; int i, err, encoding; - Module* mod; + Module* module_p; Eterm mod_atom; const Atom* mod_atomp; Eterm f_atom; @@ -2791,6 +2791,8 @@ BIF_RETTYPE load_nif_2(BIF_ALIST_2) int veto; struct erl_module_nif* lib = NULL; int reload_warning = 0; + struct erl_module_instance* this_mi; + struct erl_module_instance* prev_mi; encoding = erts_get_native_filename_encoding(); if (encoding == ERL_FILENAME_WIN_WCHAR) { @@ -2824,21 +2826,29 @@ BIF_RETTYPE load_nif_2(BIF_ALIST_2) ASSERT(caller != NULL); mod_atom = caller[0]; ASSERT(is_atom(mod_atom)); - mod=erts_get_module(mod_atom, erts_active_code_ix()); - ASSERT(mod != NULL); + module_p = erts_get_module(mod_atom, erts_active_code_ix()); + ASSERT(module_p != NULL); mod_atomp = atom_tab(atom_val(mod_atom)); init_func = erts_static_nif_get_nif_init((char*)mod_atomp->name, mod_atomp->len); if (init_func != NULL) handle = init_func; - if (!in_area(caller, mod->curr.code_hdr, mod->curr.code_length)) { - ASSERT(in_area(caller, mod->old.code_hdr, mod->old.code_length)); + if (in_area(caller, module_p->old.code_hdr, module_p->old.code_length)) { + if (module_p->old.code_hdr->on_load_function_ptr) { + this_mi = &module_p->old; + prev_mi = &module_p->curr; + } else { + ret = load_nif_error(BIF_P, "old_code", "Calling load_nif from old " + "module '%T' not allowed", mod_atom); + goto error; + } + } else { + this_mi = &module_p->curr; + prev_mi = &module_p->old; + } - ret = load_nif_error(BIF_P, "old_code", "Calling load_nif from old " - "module '%T' not allowed", mod_atom); - } - else if (init_func == NULL && + if (init_func == NULL && (err=erts_sys_ddll_open(lib_name, &handle, &errdesc)) != ERL_DE_NO_ERROR) { const char slogan[] = "Failed to load NIF library"; if (strstr(errdesc.str, lib_name) != NULL) { @@ -2887,7 +2897,7 @@ BIF_RETTYPE load_nif_2(BIF_ALIST_2) for (i=0; i < entry->num_of_funcs && ret==am_ok; i++) { BeamInstr** code_pp; if (!erts_atom_get(f->name, sys_strlen(f->name), &f_atom, ERTS_ATOM_ENC_LATIN1) - || (code_pp = get_func_pp(mod->curr.code_hdr, f_atom, f->arity))==NULL) { + || (code_pp = get_func_pp(this_mi->code_hdr, f_atom, f->arity))==NULL) { ret = load_nif_error(BIF_P,bad_lib,"Function not found %T:%s/%u", mod_atom, f->name, f->arity); } @@ -2938,9 +2948,9 @@ BIF_RETTYPE load_nif_2(BIF_ALIST_2) erts_refc_init(&lib->rt_cnt, 0); erts_refc_init(&lib->rt_dtor_cnt, 0); ASSERT(opened_rt_list == NULL); - lib->mod = mod; + lib->mod = module_p; env.mod_nif = lib; - if (mod->curr.nif != NULL) { /*************** Reload ******************/ + if (this_mi->nif != NULL) { /*************** Reload ******************/ /* * Repeated load_nif calls from same Erlang module instance ("reload") * is deprecated and was only ment as a development feature not to @@ -2948,16 +2958,16 @@ BIF_RETTYPE load_nif_2(BIF_ALIST_2) */ int k, old_incr = 0; ErlNifFunc* old_func; - lib->priv_data = mod->curr.nif->priv_data; + lib->priv_data = this_mi->nif->priv_data; - ASSERT(mod->curr.nif->entry != NULL); + ASSERT(this_mi->nif->entry != NULL); if (entry->reload == NULL) { ret = load_nif_error(BIF_P,reload,"Reload not supported by this NIF library."); goto error; } /* Check that no NIF is removed */ - old_func = mod->curr.nif->entry->funcs; - for (k=0; k < mod->curr.nif->entry->num_of_funcs; k++) { + old_func = this_mi->nif->entry->funcs; + for (k=0; k < this_mi->nif->entry->num_of_funcs; k++) { int incr = 0; ErlNifFunc* f = entry->funcs; for (i=0; i < entry->num_of_funcs; i++) { @@ -2973,7 +2983,7 @@ BIF_RETTYPE load_nif_2(BIF_ALIST_2) old_func->name, old_func->arity); goto error; } - old_func = next_func(mod->curr.nif->entry, &old_incr, old_func); + old_func = next_func(this_mi->nif->entry, &old_incr, old_func); } erts_pre_nif(&env, BIF_P, lib, NULL); veto = entry->reload(&env, &lib->priv_data, BIF_ARG_2); @@ -2983,24 +2993,24 @@ BIF_RETTYPE load_nif_2(BIF_ALIST_2) } else { commit_opened_resource_types(lib); - mod->curr.nif->entry = NULL; /* to prevent 'unload' callback */ - erts_unload_nif(mod->curr.nif); + this_mi->nif->entry = NULL; /* to prevent 'unload' callback */ + erts_unload_nif(this_mi->nif); reload_warning = 1; } } else { lib->priv_data = NULL; - if (mod->old.nif != NULL) { /**************** Upgrade ***************/ - void* prev_old_data = mod->old.nif->priv_data; + if (prev_mi->nif != NULL) { /**************** Upgrade ***************/ + void* prev_old_data = prev_mi->nif->priv_data; if (entry->upgrade == NULL) { ret = load_nif_error(BIF_P, upgrade, "Upgrade not supported by this NIF library."); goto error; } - erts_pre_nif(&env, BIF_P, lib, NULL); - veto = entry->upgrade(&env, &lib->priv_data, &mod->old.nif->priv_data, BIF_ARG_2); + erts_pre_nif(&env, BIF_P, lib, NULL); + veto = entry->upgrade(&env, &lib->priv_data, &prev_mi->nif->priv_data, BIF_ARG_2); erts_post_nif(&env); if (veto) { - mod->old.nif->priv_data = prev_old_data; + prev_mi->nif->priv_data = prev_old_data; ret = load_nif_error(BIF_P, upgrade, "Library upgrade-call unsuccessful."); } else @@ -3025,12 +3035,12 @@ BIF_RETTYPE load_nif_2(BIF_ALIST_2) int incr = 0; ErlNifFunc* f = entry->funcs; - mod->curr.nif = lib; + this_mi->nif = lib; for (i=0; i < entry->num_of_funcs; i++) { BeamInstr* code_ptr; erts_atom_get(f->name, sys_strlen(f->name), &f_atom, ERTS_ATOM_ENC_LATIN1); - code_ptr = *get_func_pp(mod->curr.code_hdr, f_atom, f->arity); + code_ptr = *get_func_pp(this_mi->code_hdr, f_atom, f->arity); if (code_ptr[1] == 0) { code_ptr[5+0] = (BeamInstr) BeamOp(op_call_nif); diff --git a/erts/emulator/beam/erl_process.c b/erts/emulator/beam/erl_process.c index da2559839d..36b0af0c1a 100644 --- a/erts/emulator/beam/erl_process.c +++ b/erts/emulator/beam/erl_process.c @@ -6688,10 +6688,8 @@ schedule_process_sys_task(Process *p, erts_aint32_t prio, ErtsProcSysTask *st) erts_aint32_t e; n = e = a; - if (a & ERTS_PSFLG_FREE) { - res = 0; + if (a & ERTS_PSFLG_FREE) goto cleanup; /* We don't want to schedule free processes... */ - } enqueue = ERTS_ENQUEUE_NOT; n |= ERTS_PSFLG_ACTIVE_SYS; @@ -9240,6 +9238,21 @@ erts_set_process_priority(Process *p, Eterm value) } } +static int +scheduler_gc_proc(Process *c_p, int reds_left) +{ + int fcalls, reds; + if (!ERTS_PROC_GET_SAVED_CALLS_BUF(c_p)) + fcalls = reds_left; + else + fcalls = reds_left - CONTEXT_REDS; + reds = erts_garbage_collect_nobump(c_p, 0, c_p->arg_reg, c_p->arity, fcalls); + ASSERT(reds_left >= reds); + return reds; +} + + + /* * schedule() is called from BEAM (process_main()) or HiPE * (hipe_mode_switch()) when the current process is to be @@ -9318,6 +9331,7 @@ Process *schedule(Process *p, int calls) #endif reds = actual_reds = calls - esdp->virtual_reds; + ASSERT(actual_reds >= 0); if (reds < ERTS_PROC_MIN_CONTEXT_SWITCH_REDS_COST) reds = ERTS_PROC_MIN_CONTEXT_SWITCH_REDS_COST; esdp->virtual_reds = 0; @@ -9740,7 +9754,7 @@ Process *schedule(Process *p, int calls) esdp->current_process = p; - + calls = 0; reds = context_reds; #ifdef ERTS_SMP @@ -9819,9 +9833,7 @@ Process *schedule(Process *p, int calls) /* Migrate to dirty scheduler... */ sunlock_sched_out_proc: erts_smp_proc_unlock(p, ERTS_PROC_LOCK_STATUS); - p->fcalls = reds; goto sched_out_proc; - } } else { @@ -9856,8 +9868,6 @@ Process *schedule(Process *p, int calls) #endif /* ERTS_SMP */ - p->fcalls = reds; - erts_smp_proc_unlock(p, ERTS_PROC_LOCK_STATUS); if (IS_TRACED(p)) { @@ -9890,14 +9900,15 @@ Process *schedule(Process *p, int calls) * not allowed to execute system tasks. */ if (!(p->flags & F_DELAY_GC)) { - reds -= execute_sys_tasks(p, &state, reds); + int cost = execute_sys_tasks(p, &state, reds); + calls += cost; + reds -= cost; if (reds <= 0 #ifdef ERTS_DIRTY_SCHEDULERS || ERTS_SCHEDULER_IS_DIRTY(esdp) || (state & ERTS_PSFLGS_DIRTY_WORK) #endif ) { - p->fcalls = reds; goto sched_out_proc; } } @@ -9910,8 +9921,9 @@ Process *schedule(Process *p, int calls) if (((state & (ERTS_PSFLG_SUSPENDED | ERTS_PSFLG_ACTIVE)) != ERTS_PSFLG_ACTIVE) - && !(state & ERTS_PSFLG_EXITING)) + && !(state & ERTS_PSFLG_EXITING)) { goto sched_out_proc; + } n = e = state; n &= ~ERTS_PSFLG_RUNNING_SYS; @@ -9930,11 +9942,11 @@ Process *schedule(Process *p, int calls) if (ERTS_IS_GC_DESIRED(p)) { if (!(state & ERTS_PSFLG_EXITING) && !(p->flags & (F_DELAY_GC|F_DISABLE_GC))) { - reds -= erts_garbage_collect_nobump(p, 0, p->arg_reg, p->arity); - if (reds <= 0) { - p->fcalls = reds; + int cost = scheduler_gc_proc(p, reds); + calls += cost; + reds -= cost; + if (reds <= 0) goto sched_out_proc; - } } } @@ -9942,6 +9954,8 @@ Process *schedule(Process *p, int calls) free_proxy_proc(proxy_p); proxy_p = NULL; } + + p->fcalls = reds; ERTS_SMP_CHK_HAVE_ONLY_MAIN_PROC_LOCK(p); @@ -10211,21 +10225,24 @@ execute_sys_tasks(Process *c_p, erts_aint32_t *statep, int in_reds) else { if (!garbage_collected) { FLAGS(c_p) |= F_NEED_FULLSWEEP; - reds -= erts_garbage_collect_nobump(c_p, - 0, - c_p->arg_reg, - c_p->arity); + reds -= scheduler_gc_proc(c_p, reds); garbage_collected = 1; } st_res = am_true; } break; case ERTS_PSTT_CPC: { + int fcalls; int cpc_reds = 0; + if (!ERTS_PROC_GET_SAVED_CALLS_BUF(c_p)) + fcalls = reds; + else + fcalls = reds - CONTEXT_REDS; st_res = erts_check_process_code(c_p, st->arg[0], unsigned_val(st->arg[1]), - &cpc_reds); + &cpc_reds, + fcalls); reds -= cpc_reds; if (is_non_value(st_res)) { /* Needed gc, but gc was disabled */ @@ -10257,6 +10274,9 @@ execute_sys_tasks(Process *c_p, erts_aint32_t *statep, int in_reds) *statep = state; + if (in_reds < reds) + return in_reds; + return in_reds - reds; } @@ -11482,8 +11502,10 @@ delete_process(Process* p) psd = (ErtsPSD *) erts_smp_atomic_read_nob(&p->psd); - if (psd) + if (psd) { + erts_smp_atomic_set_nob(&p->psd, (erts_aint_t) NULL); /* Reduction counting depends on this... */ erts_free(ERTS_ALC_T_PSD, psd); + } /* Clean binaries and funs */ erts_cleanup_offheap(&p->off_heap); @@ -12577,6 +12599,8 @@ erts_continue_exit_process(Process *p) dep = (p->flags & F_DISTRIBUTION) ? erts_this_dist_entry : NULL; scb = ERTS_PROC_SET_SAVED_CALLS_BUF(p, NULL); + if (scb) + p->fcalls += CONTEXT_REDS; /* Reduction counting depends on this... */ pbt = ERTS_PROC_SET_CALL_TIME(p, NULL); nif_export = ERTS_PROC_SET_NIF_TRAP_EXPORT(p, NULL); diff --git a/erts/emulator/beam/erl_process.h b/erts/emulator/beam/erl_process.h index 61acf5924b..59da9c1779 100644 --- a/erts/emulator/beam/erl_process.h +++ b/erts/emulator/beam/erl_process.h @@ -805,8 +805,15 @@ erts_smp_reset_max_len(ErtsRunQueue *rq, ErtsRunQueueInfo *rqi) #define ERTS_PSD_CALL_TIME_BP 3 #define ERTS_PSD_DELAYED_GC_TASK_QS 4 #define ERTS_PSD_NIF_TRAP_EXPORT 5 +#ifdef HIPE +#define ERTS_PSD_SUSPENDED_SAVED_CALLS_BUF 6 +#endif +#ifdef HIPE +#define ERTS_PSD_SIZE 7 +#else #define ERTS_PSD_SIZE 6 +#endif typedef struct { void *data[ERTS_PSD_SIZE]; @@ -925,7 +932,6 @@ struct process { Eterm* stop; /* Stack top */ Eterm* heap; /* Heap start */ Eterm* hend; /* Heap end */ - Eterm* abandoned_heap; Uint heap_sz; /* Size of heap in words */ Uint min_heap_size; /* Minimum size of heap (in words). */ Uint min_vheap_size; /* Minimum size of virtual heap (in words). */ @@ -941,6 +947,16 @@ struct process { #endif /* + * Moved to after "struct hipe_process_state hipe", as a temporary fix for + * LLVM hard-coding offsetof(struct process, hipe.nstack) (sic!) + * (see void X86FrameLowering::adjustForHiPEPrologue(...) in + * lib/Target/X86/X86FrameLowering.cpp). + * + * Used to be below "Eterm* hend". + */ + Eterm* abandoned_heap; + + /* * Saved x registers. */ Uint arity; /* Number of live argument registers (only valid @@ -1071,6 +1087,10 @@ struct process { Uint space_verified; /* Avoid HAlloc forcing heap fragments when */ Eterm* space_verified_from; /* we rely on available heap space (TestHeap) */ #endif + +#ifdef DEBUG + Uint debug_reds_in; +#endif }; extern const Process erts_invalid_process; @@ -1342,6 +1362,7 @@ extern int erts_system_profile_ts_type; #define F_DELAY_GC (1 << 16) /* Similar to disable GC (see below) */ #define F_SCHDLR_ONLN_WAITQ (1 << 17) /* Process enqueued waiting to change schedulers online */ #define F_HAVE_BLCKD_NMSCHED (1 << 18) /* Process has blocked normal multi-scheduling */ +#define F_HIPE_MODE (1 << 19) /* * F_DISABLE_GC and F_DELAY_GC are similar. Both will prevent @@ -1999,6 +2020,13 @@ erts_psd_set(Process *p, int ix, void *data) #define ERTS_PROC_SET_NIF_TRAP_EXPORT(P, NTE) \ erts_psd_set((P), ERTS_PSD_NIF_TRAP_EXPORT, (void *) (NTE)) +#ifdef HIPE +#define ERTS_PROC_GET_SUSPENDED_SAVED_CALLS_BUF(P) \ + ((struct saved_calls *) erts_psd_get((P), ERTS_PSD_SUSPENDED_SAVED_CALLS_BUF)) +#define ERTS_PROC_SET_SUSPENDED_SAVED_CALLS_BUF(P, SCB) \ + ((struct saved_calls *) erts_psd_set((P), ERTS_PSD_SUSPENDED_SAVED_CALLS_BUF, (void *) (SCB))) +#endif + ERTS_GLB_INLINE Eterm erts_proc_get_error_handler(Process *p); ERTS_GLB_INLINE Eterm erts_proc_set_error_handler(Process *p, Eterm handler); diff --git a/erts/emulator/beam/erl_trace.c b/erts/emulator/beam/erl_trace.c index 9f3341537d..1c0fc0a11f 100644 --- a/erts/emulator/beam/erl_trace.c +++ b/erts/emulator/beam/erl_trace.c @@ -658,6 +658,7 @@ do { \ # define GET_NOW(m, s, u) do {get_now(m, s, u);} while (0) #endif + static void write_sys_msg_to_port(Eterm unused_to, Port* trace_port, @@ -1380,16 +1381,18 @@ trace_proc_spawn(Process *p, Eterm what, Eterm pid, void save_calls(Process *p, Export *e) { - struct saved_calls *scb = ERTS_PROC_GET_SAVED_CALLS_BUF(p); - if (scb) { - Export **ct = &scb->ct[0]; - int len = scb->len; - - ct[scb->cur] = e; - if (++scb->cur >= len) - scb->cur = 0; - if (scb->n < len) - scb->n++; + if ((ERTS_TRACE_FLAGS(p) & F_SENSITIVE) == 0) { + struct saved_calls *scb = ERTS_PROC_GET_SAVED_CALLS_BUF(p); + if (scb) { + Export **ct = &scb->ct[0]; + int len = scb->len; + + ct[scb->cur] = e; + if (++scb->cur >= len) + scb->cur = 0; + if (scb->n < len) + scb->n++; + } } } @@ -1796,41 +1799,6 @@ profile_scheduler(Eterm scheduler_id, Eterm state) { } -void -profile_scheduler_q(Eterm scheduler_id, Eterm state, Eterm no_schedulers, Uint Ms, Uint s, Uint us) { - Eterm *hp, msg, timestamp; - -#ifndef ERTS_SMP -#define LOCAL_HEAP_SIZE (4 + 7) - DeclareTmpHeapNoproc(local_heap,LOCAL_HEAP_SIZE); - UseTmpHeapNoproc(LOCAL_HEAP_SIZE); - - hp = local_heap; -#else - ErlHeapFragment *bp; - Uint hsz; - - hsz = 4 + 7; - - bp = new_message_buffer(hsz); - hp = bp->mem; -#endif - - erts_smp_mtx_lock(&smq_mtx); - - timestamp = TUPLE3(hp, make_small(Ms), make_small(s), make_small(us)); hp += 4; - msg = TUPLE6(hp, am_profile, am_scheduler, scheduler_id, state, no_schedulers, timestamp); hp += 7; -#ifndef ERTS_SMP - profile_send(NIL, msg); - UnUseTmpHeapNoproc(LOCAL_HEAP_SIZE); -#undef LOCAL_HEAP_SIZE -#else - enqueue_sys_msg_unlocked(SYS_MSG_TYPE_SYSPROF, NIL, NIL, msg, bp); -#endif - erts_smp_mtx_unlock(&smq_mtx); - -} - /* Port profiling */ void @@ -1994,7 +1962,10 @@ trace_port_receive(Port *t_p, Eterm caller, Eterm what, ...) } data = TUPLE2(hp, caller, data); - send_to_tracer_nif(NULL, &t_p->common, t_p->common.id, tnif, TRACE_FUN_T_RECEIVE, + hp += 3; + ASSERT(hp <= (local_heap + LOCAL_HEAP_SIZE) || orig_hp); + send_to_tracer_nif(NULL, &t_p->common, t_p->common.id, tnif, + TRACE_FUN_T_RECEIVE, am_receive, data, THE_NON_VALUE, am_true); if (bptr && erts_refc_dectest(&bptr->refc, 1) == 0) diff --git a/erts/emulator/beam/erlang_lttng.h b/erts/emulator/beam/erlang_lttng.h index 43ceeda671..12f68e477b 100644 --- a/erts/emulator/beam/erlang_lttng.h +++ b/erts/emulator/beam/erlang_lttng.h @@ -218,13 +218,13 @@ TRACEPOINT_EVENT( driver_stop, TP_ARGS( char*, pid, - char*, driver, - char*, port + char*, port, + char*, driver ), TP_FIELDS( ctf_string(pid, pid) - ctf_string(driver, driver) ctf_string(port, port) + ctf_string(driver, driver) ) ) @@ -324,7 +324,7 @@ TRACEPOINT_EVENT( TRACEPOINT_EVENT( com_ericsson_otp, - aio_pool_add, + aio_pool_put, TP_ARGS( char*, port, int, length diff --git a/erts/emulator/beam/global.h b/erts/emulator/beam/global.h index baa0a201d1..550db95ba8 100644 --- a/erts/emulator/beam/global.h +++ b/erts/emulator/beam/global.h @@ -997,7 +997,7 @@ Eterm erl_is_function(Process* p, Eterm arg1, Eterm arg2); #define ERTS_CPC_ALLOW_GC (1 << 0) #define ERTS_CPC_COPY_LITERALS (1 << 1) #define ERTS_CPC_ALL (ERTS_CPC_ALLOW_GC | ERTS_CPC_COPY_LITERALS) -Eterm erts_check_process_code(Process *c_p, Eterm module, Uint flags, int *redsp); +Eterm erts_check_process_code(Process *c_p, Eterm module, Uint flags, int *redsp, int fcalls); typedef struct { Eterm *ptr; diff --git a/erts/emulator/beam/io.c b/erts/emulator/beam/io.c index 1d307ae15e..b9f6ab04c6 100644 --- a/erts/emulator/beam/io.c +++ b/erts/emulator/beam/io.c @@ -3865,7 +3865,7 @@ terminate_port(Port *prt) lttng_decl_procbuf(proc_str); lttng_pid_to_str(connected_id, proc_str); lttng_port_to_str(prt, port_str); - LTTNG3(driver_stop, proc_str, drv->name, port_str); + LTTNG3(driver_stop, proc_str, port_str, drv->name); } #endif diff --git a/erts/emulator/beam/utils.c b/erts/emulator/beam/utils.c index 74114626be..cedc88e5fe 100644 --- a/erts/emulator/beam/utils.c +++ b/erts/emulator/beam/utils.c @@ -71,41 +71,6 @@ #define HAVE_MALLOPT 0 #endif -/* profile_scheduler mini message queue */ - -typedef struct { - Uint scheduler_id; - Uint no_schedulers; - Uint Ms; - Uint s; - Uint us; - Eterm state; -} profile_sched_msg; - -typedef struct { - profile_sched_msg msg[2]; - Uint n; -} profile_sched_msg_q; - -#ifdef ERTS_SMP - -#if 0 /* Unused */ -static void -dispatch_profile_msg_q(profile_sched_msg_q *psmq) -{ - int i = 0; - profile_sched_msg *msg = NULL; - ASSERT(psmq != NULL); - for (i = 0; i < psmq->n; i++) { - msg = &(psmq->msg[i]); - profile_scheduler_q(make_small(msg->scheduler_id), msg->state, am_undefined, msg->Ms, msg->s, msg->us); - } -} -#endif - -#endif - - Eterm* erts_heap_alloc(Process* p, Uint need, Uint xtra) { diff --git a/erts/emulator/hipe/hipe_mode_switch.c b/erts/emulator/hipe/hipe_mode_switch.c index 43144e75ec..9ad44b25ac 100644 --- a/erts/emulator/hipe/hipe_mode_switch.c +++ b/erts/emulator/hipe/hipe_mode_switch.c @@ -218,15 +218,37 @@ static __inline__ void hipe_pop_beam_trap_frame(Process *p) Process *hipe_mode_switch(Process *p, unsigned cmd, Eterm reg[]) { unsigned result; -#if NR_ARG_REGS > 5 - /* When NR_ARG_REGS > 5, we need to protect the process' input - reduction count (which BEAM stores in def_arg_reg[5]) from - being clobbered by the arch glue code. */ Eterm reds_in = p->def_arg_reg[5]; -#endif -#if NR_ARG_REGS > 4 - Eterm o_reds = p->def_arg_reg[4]; -#endif + /* + * Process is in the normal case scheduled out when reduction + * count reach zero. When "save calls" is enabled reduction + * count is subtracted with CONTEXT_REDS, i.e. initial reduction + * count will be zero or less and process is scheduled out + * when -CONTEXT_REDS is reached. + * + * HiPE does not support the "save calls" feature, so we switch + * to using a positive reduction counter when executing in + * hipe mode, but need to restore the "save calls" when + * returning to beam. We also need to hide the save calls buffer + * from BIFs. We do that by moving the saved calls buf to + * suspended saved calls buf. + * + * Beam has initial reduction count in stored in p->def_arg_reg[5]. + * + * Beam expects -neg_o_reds to be found in p->def_arg_reg[4] + * on return to beam. + */ + + { + struct saved_calls *scb = ERTS_PROC_SET_SAVED_CALLS_BUF(p, NULL); + if (scb) { + reds_in += CONTEXT_REDS; + p->fcalls += CONTEXT_REDS; + ERTS_PROC_SET_SUSPENDED_SAVED_CALLS_BUF(p, scb); + } + } + + p->flags |= F_HIPE_MODE; /* inform bifs where we are comming from... */ p->i = NULL; /* Set current_function to undefined. stdlib hibernate tests rely on it. */ @@ -481,12 +503,21 @@ Process *hipe_mode_switch(Process *p, unsigned cmd, Eterm reg[]) erts_smp_proc_unlock(p, ERTS_PROC_LOCKS_MSG_RECEIVE); do_schedule: { -#if !(NR_ARG_REGS > 5) - int reds_in = p->def_arg_reg[5]; + struct saved_calls *scb; + + scb = ERTS_PROC_SET_SUSPENDED_SAVED_CALLS_BUF(p, NULL); + if (scb) + ERTS_PROC_SET_SAVED_CALLS_BUF(p, scb); + +#ifdef DEBUG + ASSERT(p->debug_reds_in == reds_in); #endif + p->flags &= ~F_HIPE_MODE; + ERTS_SMP_UNREQ_PROC_MAIN_LOCK(p); p = schedule(p, reds_in - p->fcalls); ERTS_SMP_REQ_PROC_MAIN_LOCK(p); + ASSERT(!(p->flags & F_HIPE_MODE)); #ifdef ERTS_SMP p->hipe_smp.have_receive_locks = 0; reg = p->scheduler_data->x_reg_array; @@ -501,28 +532,32 @@ Process *hipe_mode_switch(Process *p, unsigned cmd, Eterm reg[]) reg[i] = argp[i]; } { -#if !(NR_ARG_REGS > 5) - Eterm reds_in; -#endif -#if !(NR_ARG_REGS > 4) - Eterm o_reds; -#endif + struct saved_calls *scb; reds_in = p->fcalls; - o_reds = 0; - if (ERTS_PROC_GET_SAVED_CALLS_BUF(p)) { - o_reds = reds_in; - reds_in = 0; - p->fcalls = 0; - } - p->def_arg_reg[4] = o_reds; p->def_arg_reg[5] = reds_in; +#ifdef DEBUG + p->debug_reds_in = reds_in; +#endif if (p->i == hipe_beam_pc_resume) { + p->flags |= F_HIPE_MODE; /* inform bifs where we are comming from... */ + scb = ERTS_PROC_SET_SAVED_CALLS_BUF(p, NULL); + if (scb) + ERTS_PROC_SET_SUSPENDED_SAVED_CALLS_BUF(p, scb); p->i = NULL; p->arity = 0; goto do_resume; } + + scb = ERTS_PROC_GET_SAVED_CALLS_BUF(p); + if (!scb) + p->def_arg_reg[4] = 0; + else { + p->def_arg_reg[4] = CONTEXT_REDS; + p->fcalls = -CONTEXT_REDS + reds_in; + } } + HIPE_CHECK_PCB(p); result = HIPE_MODE_SWITCH_RES_CALL_BEAM; p->def_arg_reg[3] = result; @@ -562,14 +597,29 @@ Process *hipe_mode_switch(Process *p, unsigned cmd, Eterm reg[]) default: erts_exit(ERTS_ERROR_EXIT, "hipe_mode_switch: result %#x\r\n", result); } + + { + struct saved_calls *scb = ERTS_PROC_SET_SUSPENDED_SAVED_CALLS_BUF(p, NULL); + if (!scb) + p->def_arg_reg[4] = 0; + else { + p->def_arg_reg[4] = CONTEXT_REDS; + p->fcalls -= CONTEXT_REDS; + ERTS_PROC_SET_SAVED_CALLS_BUF(p, scb); + } + } + HIPE_CHECK_PCB(p); p->def_arg_reg[3] = result; -#if NR_ARG_REGS > 4 - p->def_arg_reg[4] = o_reds; -#endif #if NR_ARG_REGS > 5 + /* + * When NR_ARG_REGS > 5, we need to protect the process' input + * reduction count (which BEAM stores in def_arg_reg[5]) from + * being clobbered by the arch glue code. + */ p->def_arg_reg[5] = reds_in; #endif + p->flags &= ~F_HIPE_MODE; return p; } diff --git a/erts/emulator/nifs/common/erl_tracer_nif.c b/erts/emulator/nifs/common/erl_tracer_nif.c index 1bb6b940c4..8a9a1bf16c 100644 --- a/erts/emulator/nifs/common/erl_tracer_nif.c +++ b/erts/emulator/nifs/common/erl_tracer_nif.c @@ -72,8 +72,6 @@ ERL_NIF_INIT(erl_tracer, nif_funcs, load, NULL, upgrade, unload) ATOM_DECL(trace); \ ATOM_DECL(trace_ts); \ ATOM_DECL(true); \ - ATOM_DECL(gc_start); \ - ATOM_DECL(gc_end); \ ATOM_DECL(gc_minor_start); \ ATOM_DECL(gc_minor_end); \ ATOM_DECL(gc_major_start); \ @@ -130,6 +128,9 @@ static ERL_NIF_TERM enabled(ErlNifEnv* env, int argc, const ERL_NIF_TERM argv[]) if (!enif_is_port_alive(env, &to_port)) /* tracer is dead so we should remove this trace point */ return atom_remove; + } else { + /* The state was not a pid or a port */ + return atom_remove; } /* Only generate trace for when tracer != tracee */ diff --git a/erts/emulator/test/lttng_SUITE.erl b/erts/emulator/test/lttng_SUITE.erl index d0f6292d5b..efc79f42ed 100644 --- a/erts/emulator/test/lttng_SUITE.erl +++ b/erts/emulator/test/lttng_SUITE.erl @@ -89,8 +89,8 @@ end_per_testcase(Case, _Config) -> %% com_ericsson_otp:carrier_pool_put %% com_ericsson_otp:carrier_destroy %% com_ericsson_otp:carrier_create -%% com_ericsson_otp:aio_pool_add -%% com_ericsson_otp:aio_pool_get +%% com_ericsson_otp:aio_pool_put +%% com_ericsson_otp:aio_pool_get %% com_ericsson_otp:driver_control %% com_ericsson_otp:driver_call %% com_ericsson_otp:driver_finish @@ -151,7 +151,7 @@ t_memory_carrier(Config) -> ok end. -%% com_ericsson_otp:aio_pool_add +%% com_ericsson_otp:aio_pool_put %% com_ericsson_otp:aio_pool_get t_async_io_pool(Config) -> case have_async_threads() of @@ -168,7 +168,7 @@ t_async_io_pool(Config) -> {ok, _} = file:list_dir(Path2), Res = lttng_stop_and_view(Config), - ok = check_tracepoint("com_ericsson_otp:aio_pool_add", Res), + ok = check_tracepoint("com_ericsson_otp:aio_pool_put", Res), ok = check_tracepoint("com_ericsson_otp:aio_pool_get", Res), ok end. @@ -416,7 +416,7 @@ txt() -> "%% com_ericsson_otp:carrier_pool_put\n" "%% com_ericsson_otp:carrier_destroy\n" "%% com_ericsson_otp:carrier_create\n" - "%% com_ericsson_otp:aio_pool_add\n" + "%% com_ericsson_otp:aio_pool_put\n" "%% com_ericsson_otp:aio_pool_get\n" "%% com_ericsson_otp:driver_control\n" "%% com_ericsson_otp:driver_call\n" diff --git a/erts/emulator/test/match_spec_SUITE.erl b/erts/emulator/test/match_spec_SUITE.erl index ea973276db..6733237b20 100644 --- a/erts/emulator/test/match_spec_SUITE.erl +++ b/erts/emulator/test/match_spec_SUITE.erl @@ -597,16 +597,15 @@ ms_trace3(Config) when is_list(Config) -> end), ok. -ms_trace_dead(doc) -> - ["Test that a dead tracer is removed using ms"]; -ms_trace_dead(suite) -> []; -ms_trace_dead(Config) when is_list(Config) -> +%% Test that a dead tracer is removed using ms +ms_trace_dead(_Config) -> Self = self(), TFun = fun F() -> receive M -> Self ! M, F() end end, {Tracer, MRef} = spawn_monitor(TFun), MetaTracer = spawn_link(TFun), erlang:trace_pattern({?MODULE, f1, '_'}, - [{'_',[],[{trace,[], + [{'_',[],[{message, false}, + {trace,[], [call,{const,{tracer,Tracer}}]}]}], [{meta, MetaTracer}]), erlang:trace_pattern({?MODULE, f2, '_'}, []), @@ -623,8 +622,6 @@ ms_trace_dead(Config) when is_list(Config) -> ?MODULE:f2(3,4), TRef = erlang:trace_delivered(all), receive {trace_delivered, _, TRef} -> ok end, - receive {trace_ts, Self, call, {?MODULE, f1, _}, _} -> ok end, - receive {trace_ts, Self, call, {?MODULE, f1, _}, _} -> ok end, receive M -> ct:fail({unexpected, M}) after 10 -> ok end. %% Test that destructive operations in test bif does not really happen diff --git a/erts/emulator/test/message_queue_data_SUITE.erl b/erts/emulator/test/message_queue_data_SUITE.erl index 6efca5b39e..226462676c 100644 --- a/erts/emulator/test/message_queue_data_SUITE.erl +++ b/erts/emulator/test/message_queue_data_SUITE.erl @@ -21,7 +21,7 @@ -module(message_queue_data_SUITE). -export([all/0, suite/0]). --export([basic/1, process_info_messages/1]). +-export([basic/1, process_info_messages/1, total_heap_size/1]). -export([basic_test/1]). @@ -32,7 +32,7 @@ suite() -> {timetrap, {minutes, 2}}]. all() -> - [basic, process_info_messages]. + [basic, process_info_messages, total_heap_size]. %% %% @@ -44,15 +44,15 @@ basic(Config) when is_list(Config) -> basic_test(erlang:system_info(message_queue_data)), - {ok, Node1} = start_node(Config, "+xmqd off_heap"), + {ok, Node1} = start_node(Config, "+hmqd off_heap"), ok = rpc:call(Node1, ?MODULE, basic_test, [off_heap]), stop_node(Node1), - {ok, Node2} = start_node(Config, "+xmqd on_heap"), + {ok, Node2} = start_node(Config, "+hmqd on_heap"), ok = rpc:call(Node2, ?MODULE, basic_test, [on_heap]), stop_node(Node2), - {ok, Node3} = start_node(Config, "+xmqd mixed"), + {ok, Node3} = start_node(Config, "+hmqd mixed"), ok = rpc:call(Node3, ?MODULE, basic_test, [mixed]), stop_node(Node3), @@ -190,6 +190,28 @@ process_info_messages(Config) when is_list(Config) -> ok. +total_heap_size(_Config) -> + + Fun = fun F() -> receive Pid when is_pid(Pid) -> Pid ! ok,F() end end, + + %% Test that on_heap messages grow the heap even if they are not received + OnPid = spawn_opt(Fun, [{message_queue_data, on_heap}]), + {total_heap_size, OnSize} = erlang:process_info(OnPid, total_heap_size), + [OnPid ! lists:duplicate(N,N) || N <- lists:seq(1,100)], + OnPid ! self(), receive ok -> ok end, + {total_heap_size, OnSizeAfter} = erlang:process_info(OnPid, total_heap_size), + ct:log("OnSize = ~p, OnSizeAfter = ~p",[OnSize, OnSizeAfter]), + true = OnSize < OnSizeAfter, + + %% Test that off_heap messages do not grow the heap if they are not received + OffPid = spawn_opt(Fun, [{message_queue_data, off_heap}]), + {total_heap_size, OffSize} = erlang:process_info(OffPid, total_heap_size), + [OffPid ! lists:duplicate(N,N) || N <- lists:seq(1,100)], + OffPid ! self(), receive ok -> ok end, + {total_heap_size, OffSizeAfter} = erlang:process_info(OffPid, total_heap_size), + ct:log("OffSize = ~p, OffSizeAfter = ~p",[OffSize, OffSizeAfter]), + true = OffSize == OffSizeAfter. + %% %% %% helpers diff --git a/erts/emulator/test/port_trace_SUITE.erl b/erts/emulator/test/port_trace_SUITE.erl index 41e8a316c4..bfdea0761b 100644 --- a/erts/emulator/test/port_trace_SUITE.erl +++ b/erts/emulator/test/port_trace_SUITE.erl @@ -240,19 +240,23 @@ command(Config) -> Prt ! {S, {command, <<?ECHO_DRV_NOOP:8>>}}, [{trace, Prt, 'receive', {S, {command, <<?ECHO_DRV_NOOP:8>>}}}] = flush(), + OutputMsg = <<?ECHO_DRV_NOOP:8,0:(8*512)>>, + Prt ! {S, {command, OutputMsg}}, + [{trace, Prt, 'receive', {S, {command, OutputMsg}}}] = flush(), + close(Prt, Flags), os:putenv("OUTPUTV","true"), reload_drv(Config), Prt2 = erlang:open_port({spawn, echo_drv}, [binary]), - Msg = [<<0:8>>,<<0:(8*512)>>,<<0:(8*256)>>,<<0:8>>], + OutputvMsg = [<<0:8>>,<<0:(8*512)>>,<<0:(8*256)>>,<<0:8>>], - erlang:port_command(Prt2, Msg), - [{trace, Prt2, 'receive', {S, {command, Msg}}}] = flush(), + erlang:port_command(Prt2, OutputvMsg), + [{trace, Prt2, 'receive', {S, {command, OutputvMsg}}}] = flush(), - Prt2 ! {S, {command, Msg}}, - [{trace, Prt2, 'receive', {S, {command, Msg}}}] = flush(), + Prt2 ! {S, {command, OutputvMsg}}, + [{trace, Prt2, 'receive', {S, {command, OutputvMsg}}}] = flush(), close(Prt2, Flags), @@ -274,6 +278,12 @@ control(_Config) -> [{trace, Prt, 'receive', {S, {control, {(1 bsl 32) - 1, <<?ECHO_DRV_NOOP:8, 0:8>>}}}}, {trace, Prt, send, {Prt, {control, <<0:8>>}}, S}] = flush(), + Msg = <<?ECHO_DRV_NOOP:8, 0:(8*512)>>, + Pat = lists:duplicate(512, 0), + Pat = erlang:port_control(Prt, 1, Msg), + [{trace, Prt, 'receive', {S, {control, {1, Msg}}}}, + {trace, Prt, send, {Prt, {control, <<0:(8*512)>>}}, S}] = flush(), + close(Prt, Flags), ok. @@ -331,12 +341,16 @@ call(_Config) -> Flags = [send,'receive'], {Prt, S} = trace_and_open(Flags,[binary]), - Msg = {hello, world, make_ref()}, - BinMsg = term_to_binary(Msg), + Test = fun(Msg) -> + BinMsg = term_to_binary(Msg), + + Msg = erlang:port_call(Prt, 0, Msg), + [{trace, Prt, 'receive', {S, {call, {0, BinMsg}}}}, + {trace, Prt, send, {Prt, {call, BinMsg}}, S}] = flush() + end, - Msg = erlang:port_call(Prt, 0, Msg), - [{trace, Prt, 'receive', {S, {call, {0, BinMsg}}}}, - {trace, Prt, send, {Prt, {call, BinMsg}}, S}] = flush(), + Test({hello, world, make_ref()}), + Test({hello, world, lists:seq(1,1000)}), close(Prt, Flags), diff --git a/erts/emulator/test/port_trace_SUITE_data/echo_drv.c b/erts/emulator/test/port_trace_SUITE_data/echo_drv.c index b5728bc170..b5ae9389b4 100644 --- a/erts/emulator/test/port_trace_SUITE_data/echo_drv.c +++ b/erts/emulator/test/port_trace_SUITE_data/echo_drv.c @@ -217,6 +217,8 @@ static ErlDrvSSizeT echo_drv_control(ErlDrvData drv_data, char *buf, ErlDrvSizeT len, char **rbuf, ErlDrvSizeT rlen) { + if ((len - 1) > rlen) + *rbuf = driver_alloc(len - 1); memcpy(*rbuf, buf+1, len-1); return len-1; } @@ -232,6 +234,8 @@ static ErlDrvSSizeT echo_drv_call(ErlDrvData drv_data, char **rbuf, ErlDrvSizeT rlen, unsigned int *flags) { + if ((len - command) > rlen) + *rbuf = driver_alloc(len - command); memcpy(*rbuf, buf+command, len-command); return len-command; } diff --git a/erts/emulator/test/save_calls_SUITE.erl b/erts/emulator/test/save_calls_SUITE.erl index af1a0d35d6..aae7651f6d 100644 --- a/erts/emulator/test/save_calls_SUITE.erl +++ b/erts/emulator/test/save_calls_SUITE.erl @@ -60,7 +60,7 @@ dont_break_reductions(Config) when is_list(Config) -> RPS1 = reds_per_sched(0), RPS2 = reds_per_sched(20), Diff = abs(RPS1 - RPS2), - true = (Diff < (0.05 * RPS1)), + true = (Diff < (0.2 * RPS1)), ok. diff --git a/erts/emulator/test/trace_SUITE.erl b/erts/emulator/test/trace_SUITE.erl index 3d7cb41fc0..da6a6bdea4 100644 --- a/erts/emulator/test/trace_SUITE.erl +++ b/erts/emulator/test/trace_SUITE.erl @@ -27,11 +27,12 @@ -export([all/0, suite/0, link_receive_call_correlation/0, receive_trace/1, link_receive_call_correlation/1, self_send/1, timeout_trace/1, send_trace/1, - procs_trace/1, dist_procs_trace/1, + procs_trace/1, dist_procs_trace/1, procs_new_trace/1, suspend/1, mutual_suspend/1, suspend_exit/1, suspender_exit/1, suspend_system_limit/1, suspend_opts/1, suspend_waiting/1, new_clear/1, existing_clear/1, set_on_spawn/1, set_on_first_spawn/1, cpu_timestamp/1, + set_on_link/1, set_on_first_link/1, system_monitor_args/1, more_system_monitor_args/1, system_monitor_long_gc_1/1, system_monitor_long_gc_2/1, system_monitor_large_heap_1/1, system_monitor_large_heap_2/1, @@ -54,7 +55,8 @@ all() -> mutual_suspend, suspend_exit, suspender_exit, suspend_system_limit, suspend_opts, suspend_waiting, new_clear, existing_clear, set_on_spawn, - set_on_first_spawn, system_monitor_args, + set_on_first_spawn, set_on_link, set_on_first_link, + system_monitor_args, more_system_monitor_args, system_monitor_long_gc_1, system_monitor_long_gc_2, system_monitor_large_heap_1, system_monitor_long_schedule, @@ -654,6 +656,34 @@ dist_procs_trace(Config) when is_list(Config) -> true = stop_node(OtherNode), ok. +%% Test trace(new, How, [procs]). +procs_new_trace(Config) when is_list(Config) -> + Self = self(), + process_flag(trap_exit, true), + %% + Proc1 = spawn_link(?MODULE, process, [Self]), + io:format("Proc1 = ~p ~n", [Proc1]), + %% + 0 = erlang:trace(new, true, [procs]), + + MFA = {?MODULE, process, [Self]}, + %% + %% spawn, link + Proc1 ! {spawn_link_please, Self, MFA}, + Proc3 = receive {spawned, Proc1, P3} -> P3 end, + receive {trace, Proc3, spawned, Proc1, MFA} -> ok end, + receive {trace, Proc3, getting_linked, Proc1} -> ok end, + io:format("Proc3 = ~p ~n", [Proc3]), + receive_nothing(), + %% + %% + %% exit (not linked to tracing process) + Reason1 = make_ref(), + Proc1 ! {exit_please, Reason1}, + receive {'EXIT', Proc1, Reason1} -> ok end, + {trace, Proc3, exit, Reason1} = receive_first_trace(), + receive_nothing(), + ok. @@ -701,6 +731,51 @@ set_on_first_spawn(Config) when is_list(Config) -> receive_nothing(), ok. +%% Tests trace(Pid, How, [set_on_link]). + +set_on_link(Config) -> + Listener = fun_spawn(fun process/0), + + %% Create and trace a process with the set_on_link flag. + %% Make sure it is traced. + Father_SOL = fun_spawn(fun process/0), + 1 = erlang:trace(Father_SOL, true, [send, set_on_link]), + true = is_send_traced(Father_SOL, Listener, sol_father), + + %% Have the process spawn of two children and test that they + %% are traced. + [Child1, Child2] = spawn_children(Father_SOL, 2), + true = is_send_traced(Child1, Listener, child1), + true = is_send_traced(Child2, Listener, child2), + + %% Second generation. + [Child11, Child12] = spawn_children(Child1, 2), + true = is_send_traced(Child11, Listener, child11), + true = is_send_traced(Child12, Listener, child12), + ok. + +%% Tests trace(Pid, How, [set_on_first_spawn]). + +set_on_first_link(Config) -> + ct:timetrap({seconds, 10}), + Listener = fun_spawn(fun process/0), + + %% Create and trace a process with the set_on_first_spawn flag. + %% Make sure it is traced. + Parent = fun_spawn(fun process/0), + 1 = erlang:trace(Parent, true, [send, set_on_first_link]), + is_send_traced(Parent, Listener, sol_father), + + %% Have the process spawn off three children and test that the + %% first is traced. + [Child1, Child2, Child3] = spawn_children(Parent, 3), + true = is_send_traced(Child1, Listener, child1), + false = is_send_traced(Child2, Listener, child2), + false = is_send_traced(Child3, Listener, child3), + receive_nothing(), + ok. + + %% Tests arguments to erlang:system_monitor/0,1,2 system_monitor_args(Config) when is_list(Config) -> diff --git a/erts/etc/common/erlexec.c b/erts/etc/common/erlexec.c index 82a0303f86..5a5021b003 100644 --- a/erts/etc/common/erlexec.c +++ b/erts/etc/common/erlexec.c @@ -150,6 +150,7 @@ static char *plush_val_switches[] = { "ms", "mbs", "pds", + "mqd", "", NULL }; @@ -160,12 +161,6 @@ static char *plusr_val_switches[] = { NULL }; -/* +x arguments with values */ -static char *plusx_val_switches[] = { - "mqd", - NULL -}; - /* +z arguments with values */ static char *plusz_val_switches[] = { "dbbl", @@ -986,20 +981,6 @@ int main(int argc, char **argv) add_Eargs(argv[i+1]); i++; break; - case 'x': - if (!is_one_of_strings(&argv[i][2], plusx_val_switches)) { - goto the_default; - } else { - if (i+1 >= argc - || argv[i+1][0] == '-' - || argv[i+1][0] == '+') - usage(argv[i]); - argv[i][0] = '-'; - add_Eargs(argv[i]); - add_Eargs(argv[i+1]); - i++; - } - break; case 'z': if (!is_one_of_strings(&argv[i][2], plusz_val_switches)) { goto the_default; @@ -1200,7 +1181,7 @@ usage_aux(void) "[+S NO_SCHEDULERS:NO_SCHEDULERS_ONLINE] " "[+SP PERCENTAGE_SCHEDULERS:PERCENTAGE_SCHEDULERS_ONLINE] " "[+T LEVEL] [+V] [+v] " - "[+W<i|w|e>] [+x DEFAULT_PROC_FLAGS] [+z MISC_OPTION] [args ...]\n"); + "[+W<i|w|e>] [+z MISC_OPTION] [args ...]\n"); exit(1); } diff --git a/erts/preloaded/ebin/erl_prim_loader.beam b/erts/preloaded/ebin/erl_prim_loader.beam Binary files differindex 77685013ae..3e82b8e20e 100644 --- a/erts/preloaded/ebin/erl_prim_loader.beam +++ b/erts/preloaded/ebin/erl_prim_loader.beam diff --git a/erts/preloaded/ebin/erl_tracer.beam b/erts/preloaded/ebin/erl_tracer.beam Binary files differindex b8f3f6d8c2..67d96d0f0d 100644 --- a/erts/preloaded/ebin/erl_tracer.beam +++ b/erts/preloaded/ebin/erl_tracer.beam diff --git a/erts/preloaded/ebin/erlang.beam b/erts/preloaded/ebin/erlang.beam Binary files differindex 15e4ca82a7..321e4e7e1b 100644 --- a/erts/preloaded/ebin/erlang.beam +++ b/erts/preloaded/ebin/erlang.beam diff --git a/erts/preloaded/ebin/erts_code_purger.beam b/erts/preloaded/ebin/erts_code_purger.beam Binary files differindex 3e95b1e42e..0c667663fd 100644 --- a/erts/preloaded/ebin/erts_code_purger.beam +++ b/erts/preloaded/ebin/erts_code_purger.beam diff --git a/erts/preloaded/ebin/erts_internal.beam b/erts/preloaded/ebin/erts_internal.beam Binary files differindex 53dd2897de..ed2e328f5b 100644 --- a/erts/preloaded/ebin/erts_internal.beam +++ b/erts/preloaded/ebin/erts_internal.beam diff --git a/erts/preloaded/ebin/init.beam b/erts/preloaded/ebin/init.beam Binary files differindex ee32066f53..23ebd2cad9 100644 --- a/erts/preloaded/ebin/init.beam +++ b/erts/preloaded/ebin/init.beam diff --git a/erts/preloaded/ebin/otp_ring0.beam b/erts/preloaded/ebin/otp_ring0.beam Binary files differindex 51a412b7f7..b63fa24848 100644 --- a/erts/preloaded/ebin/otp_ring0.beam +++ b/erts/preloaded/ebin/otp_ring0.beam diff --git a/erts/preloaded/ebin/prim_eval.beam b/erts/preloaded/ebin/prim_eval.beam Binary files differindex 45bed5cf7e..7c8fdc82c0 100644 --- a/erts/preloaded/ebin/prim_eval.beam +++ b/erts/preloaded/ebin/prim_eval.beam diff --git a/erts/preloaded/ebin/prim_file.beam b/erts/preloaded/ebin/prim_file.beam Binary files differindex c25bffb6a5..d4559bc9ed 100644 --- a/erts/preloaded/ebin/prim_file.beam +++ b/erts/preloaded/ebin/prim_file.beam diff --git a/erts/preloaded/ebin/prim_inet.beam b/erts/preloaded/ebin/prim_inet.beam Binary files differindex 85d74de065..5a0678632e 100644 --- a/erts/preloaded/ebin/prim_inet.beam +++ b/erts/preloaded/ebin/prim_inet.beam diff --git a/erts/preloaded/ebin/prim_zip.beam b/erts/preloaded/ebin/prim_zip.beam Binary files differindex 1f8fe6f03b..3d32dd8449 100644 --- a/erts/preloaded/ebin/prim_zip.beam +++ b/erts/preloaded/ebin/prim_zip.beam diff --git a/erts/preloaded/ebin/zlib.beam b/erts/preloaded/ebin/zlib.beam Binary files differindex 059585ec99..ced9f9c952 100644 --- a/erts/preloaded/ebin/zlib.beam +++ b/erts/preloaded/ebin/zlib.beam diff --git a/lib/common_test/doc/src/ct.xml b/lib/common_test/doc/src/ct.xml index 23aeaa38ea..5231ef24a4 100644 --- a/lib/common_test/doc/src/ct.xml +++ b/lib/common_test/doc/src/ct.xml @@ -601,18 +601,21 @@ </func> <func> - <name>get_timetrap_info() -> {Time, Scale}</name> + <name>get_timetrap_info() -> {Time, {Scaling,ScaleVal}}</name> <fsummary>Reads information about the timetrap set for the current test case.</fsummary> <type> <v>Time = integer() | infinity</v> - <v>Scale = true | false</v> + <v>Scaling = true | false</v> + <v>ScaleVal = integer()</v> </type> <desc><marker id="get_timetrap_info-0"/> <p>Reads information about the timetrap set for the current test - case. <c>Scale</c> indicates if <c>Common Test</c> will attempt + case. <c>Scaling</c> indicates if <c>Common Test</c> will attempt to compensate timetraps automatically for runtime delays - introduced by, for example, tools like cover.</p> + introduced by, for example, tools like cover. <c>ScaleVal</c> is + the value of the current scaling multipler (always 1 if scaling is + disabled). Note the <c>Time</c> is not the scaled result.</p> </desc> </func> @@ -1136,7 +1139,7 @@ Opts.</fsummary> <type> <v>Opts = [OptTuples]</v> - <v>OptTuples = {dir, TestDirs} | {suite, Suites} | {group, Groups} | {testcase, Cases} | {spec, TestSpecs} | {join_specs, Bool} | {label, Label} | {config, CfgFiles} | {userconfig, UserConfig} | {allow_user_terms, Bool} | {logdir, LogDir} | {silent_connections, Conns} | {stylesheet, CSSFile} | {cover, CoverSpecFile} | {cover_stop, Bool} | {step, StepOpts} | {event_handler, EventHandlers} | {include, InclDirs} | {auto_compile, Bool} | {abort_if_missing_suites, Bool} | {create_priv_dir, CreatePrivDir} | {multiply_timetraps, M} | {scale_timetraps, Bool} | {repeat, N} | {duration, DurTime} | {until, StopTime} | {force_stop, ForceStop} | {decrypt, DecryptKeyOrFile} | {refresh_logs, LogDir} | {logopts, LogOpts} | {verbosity, VLevels} | {basic_html, Bool} | {ct_hooks, CTHs} | {enable_builtin_hooks, Bool} | {release_shell, Bool}</v> + <v>OptTuples = {dir, TestDirs} | {suite, Suites} | {group, Groups} | {testcase, Cases} | {spec, TestSpecs} | {join_specs, Bool} | {label, Label} | {config, CfgFiles} | {userconfig, UserConfig} | {allow_user_terms, Bool} | {logdir, LogDir} | {silent_connections, Conns} | {stylesheet, CSSFile} | {cover, CoverSpecFile} | {cover_stop, Bool} | {step, StepOpts} | {event_handler, EventHandlers} | {include, InclDirs} | {auto_compile, Bool} | {abort_if_missing_suites, Bool} | {create_priv_dir, CreatePrivDir} | {multiply_timetraps, M} | {scale_timetraps, Bool} | {repeat, N} | {duration, DurTime} | {until, StopTime} | {force_stop, ForceStop} | {decrypt, DecryptKeyOrFile} | {refresh_logs, LogDir} | {logopts, LogOpts} | {verbosity, VLevels} | {basic_html, Bool} | {esc_chars, Bool} | {ct_hooks, CTHs} | {enable_builtin_hooks, Bool} | {release_shell, Bool}</v> <v>TestDirs = [string()] | string()</v> <v>Suites = [string()] | [atom()] | string() | atom()</v> <v>Cases = [atom()] | atom()</v> diff --git a/lib/common_test/doc/src/ct_run.xml b/lib/common_test/doc/src/ct_run.xml index 88873ce5b2..9e6229f1dd 100644 --- a/lib/common_test/doc/src/ct_run.xml +++ b/lib/common_test/doc/src/ct_run.xml @@ -124,6 +124,7 @@ [-duration HHMMSS [-force_stop [skip_rest]]] | [-until [YYMoMoDD]HHMMSS [-force_stop [skip_rest]]] [-basic_html] + [-no_esc_chars] [-ct_hooks CTHModule1 CTHOpts1 and CTHModule2 CTHOpts2 and .. CTHModuleN CTHOptsN] [-exit_status ignore_config] @@ -162,6 +163,7 @@ [-duration HHMMSS [-force_stop [skip_rest]]] | [-until [YYMoMoDD]HHMMSS [-force_stop [skip_rest]]] [-basic_html] + [-no_esc_chars] [-ct_hooks CTHModule1 CTHOpts1 and CTHModule2 CTHOpts2 and .. CTHModuleN CTHOptsN] [-exit_status ignore_config]</pre> @@ -186,7 +188,8 @@ [-muliply_timetraps Multiplier] [-scale_timetraps] [-create_priv_dir auto_per_run | auto_per_tc | manual_per_tc] - [-basic_html]</pre> + [-basic_html] + [-no_esc_chars]</pre> </section> <section> diff --git a/lib/common_test/doc/src/ct_telnet.xml b/lib/common_test/doc/src/ct_telnet.xml index b35e511501..e2a45e894b 100644 --- a/lib/common_test/doc/src/ct_telnet.xml +++ b/lib/common_test/doc/src/ct_telnet.xml @@ -64,6 +64,8 @@ remaining string terminated) = 0</p></item> <item><p>Polling interval (sleep time between polls) = 1 second</p> </item> + <item><p>The TCP_NODELAY option for the telnet socket + is disabled (set to <c>false</c>) per default</p></item> </list> <p>These parameters can be modified by the user with the following @@ -76,7 +78,8 @@ {reconnection_interval,Millisec}, {keep_alive,Bool}, {poll_limit,N}, - {poll_interval,Millisec}]}.</pre> + {poll_interval,Millisec}, + {tcp_nodelay,Bool}]}.</pre> <p><c>Millisec = integer(), N = integer()</c></p> diff --git a/lib/common_test/doc/src/notes.xml b/lib/common_test/doc/src/notes.xml index aba71b0d4a..ebba864606 100644 --- a/lib/common_test/doc/src/notes.xml +++ b/lib/common_test/doc/src/notes.xml @@ -33,6 +33,68 @@ <file>notes.xml</file> </header> +<section><title>Common_Test 1.12.1</title> + + <section><title>Fixed Bugs and Malfunctions</title> + <list> + <item> + <p> + The <c>nodelay</c> option used to be enabled + (<c>true</c>) by default for sockets opened by the Common + Test telnet client. This appeared to cause communication + problems with telnet servers on some systems, and + therefore the option is no longer used. Its value may + instead be specified in the telnet connection settings. + See the man page for <c>ct_telnet</c> for details. Please + note that the interface function <c>connect</c> in + <c>unix_telnet</c> has been updated with an extra + argument and is now <c>unix_telnet:connect/7</c>.</p> + <p> + Own Id: OTP-13462 Aux Id: seq13077 </p> + </item> + <item> + <p> + Fix bug in cth_surefire: When a pre_init_per_suite hook + fails before reaching the + cth_surefire:pre_init_per_suite, cth_surefire produced + incorrect XML.</p> + <p> + Own Id: OTP-13513</p> + </item> + <item> + <p> + The <c>ct:get_timetrap_info/0</c> function has been + updated to return more information about timetrap + scaling.</p> + <p> + Own Id: OTP-13535</p> + </item> + <item> + <p> + A problem with stylesheet HTML tags getting incorrectly + escaped by Common Test has been corrected.</p> + <p> + Own Id: OTP-13536</p> + </item> + <item> + <p> + The <c>ct_run</c> start flag <c>-no_esc_chars</c> and + <c>ct:run_test/1</c> start option <c>{esc_chars,Bool}</c> + have been introduced to make it possible to disable + automatic escaping of characters. Automatic escaping of + special HTML characters printed with <c>io:format/1,2</c> + and <c>ct:pal/1,2,3,4</c> was introduced in Common Test + 1.12. The new flag/option may be used to disable this + feature for backwards compatibility reasons. (The option + is also supported in test specifications).</p> + <p> + Own Id: OTP-13537</p> + </item> + </list> + </section> + +</section> + <section><title>Common_Test 1.12</title> <section><title>Fixed Bugs and Malfunctions</title> diff --git a/lib/common_test/doc/src/run_test_chapter.xml b/lib/common_test/doc/src/run_test_chapter.xml index 5ae32ee230..43e36adfb6 100644 --- a/lib/common_test/doc/src/run_test_chapter.xml +++ b/lib/common_test/doc/src/run_test_chapter.xml @@ -266,6 +266,10 @@ <tag><c><![CDATA[-verbosity <levels>]]></c></tag> <item><p>Sets <seealso marker="write_test_chapter#logging">verbosity levels for printouts</seealso>.</p></item> + + <tag><c><![CDATA[-no_esc_chars]]></c></tag> + <item><p>Disables automatic escaping of special HTML characters. + See the <seealso marker="write_test_chapter#logging">Logging chapter</seealso>.</p></item> </taglist> <note><p>Directories passed to <c>Common Test</c> can have either relative or absolute paths.</p></note> @@ -802,7 +806,7 @@ program</seealso> for an overview of available start flags (as most flags have a corresponding configuration term)</item> <item><seealso marker="write_test_chapter#logging">Logging</seealso> - (for terms <c>verbosity</c>, <c>stylesheet</c> and <c>basic_html</c>)</item> + (for terms <c>verbosity</c>, <c>stylesheet</c>, <c>basic_html</c> and <c>esc_chars</c>)</item> <item><seealso marker="config_file_chapter#top">External Configuration Data</seealso> (for terms <c>config</c> and <c>userconfig</c>)</item> <item><seealso marker="event_handler_chapter#event_handling">Event @@ -887,6 +891,9 @@ {basic_html, Bool}. {basic_html, NodeRefs, Bool}. + {esc_chars, Bool}. + {esc_chars, NodeRefs, Bool}. + {release_shell, Bool}.</pre> <p><em>Test terms:</em></p> diff --git a/lib/common_test/doc/src/unix_telnet.xml b/lib/common_test/doc/src/unix_telnet.xml index 701d5ec88e..b2314a53ec 100644 --- a/lib/common_test/doc/src/unix_telnet.xml +++ b/lib/common_test/doc/src/unix_telnet.xml @@ -80,7 +80,7 @@ <funcs> <func> - <name>connect(ConnName, Ip, Port, Timeout, KeepAlive, Extra) -> {ok, Handle} | {error, Reason}</name> + <name>connect(ConnName, Ip, Port, Timeout, KeepAlive, TCPNoDelay, Extra) -> {ok, Handle} | {error, Reason}</name> <fsummary>Callback for ct_telnet.erl.</fsummary> <type> <v>ConnName = target_name()</v> @@ -88,6 +88,7 @@ <v>Port = integer()</v> <v>Timeout = integer()</v> <v>KeepAlive = bool()</v> + <v>TCPNoDelay = bool()</v> <v>Extra = target_name() | {Username, Password}</v> <v>Username = string()</v> <v>Password = string()</v> diff --git a/lib/common_test/doc/src/write_test_chapter.xml b/lib/common_test/doc/src/write_test_chapter.xml index 40e02347f2..83daf771a6 100644 --- a/lib/common_test/doc/src/write_test_chapter.xml +++ b/lib/common_test/doc/src/write_test_chapter.xml @@ -1047,9 +1047,15 @@ <p>Common Test will escape special HTML characters (<, > and &) in printouts to the log file made with <c>ct:pal/4</c> and <c>io:format/2</c>. In order to print - strings with HTML tags to the log, use the <c>ct:log/5</c> function. The character escaping - feature is per default disabled for <c>ct:log/5</c>, but can be enabled with the - <c>esc_chars</c> option.</p> + strings with HTML tags to the log, use the <c>ct:log/3,4,5</c> function. The character + escaping feature is per default disabled for <c>ct:log/3,4,5</c> but can be enabled with + the <c>esc_chars</c> option in the <c>Opts</c> list, see <seealso marker="ct#log-5"> + <c>ct:log/3,4,5</c></seealso>.</p> + + <p>If the character escaping feature needs to be disabled (typically for backwards + compatibility reasons), use the <c>ct_run</c> start flag <c>-no_esc_chars</c>, or the + <c>ct:run_test/1</c> start option <c>{esc_chars,Bool}</c> (this start option is also + supported in test specifications).</p> <p>For more information about log files, see section <seealso marker="run_test_chapter#log_files">Log Files</seealso> diff --git a/lib/common_test/src/ct.erl b/lib/common_test/src/ct.erl index 7fe90b60ff..cae7bea406 100644 --- a/lib/common_test/src/ct.erl +++ b/lib/common_test/src/ct.erl @@ -161,9 +161,9 @@ run(TestDirs) -> %%% {repeat,N} | {duration,DurTime} | {until,StopTime} | %%% {force_stop,ForceStop} | {decrypt,DecryptKeyOrFile} | %%% {refresh_logs,LogDir} | {logopts,LogOpts} | -%%% {verbosity,VLevels} | {basic_html,Bool} | -%%% {ct_hooks, CTHs} | {enable_builtin_hooks,Bool} | -%%% {release_shell,Bool} +%%% {verbosity,VLevels} | {basic_html,Bool} | +%%% {esc_chars,Bool} | {ct_hooks, CTHs} | +%%% {enable_builtin_hooks,Bool} | {release_shell,Bool} %%% TestDirs = [string()] | string() %%% Suites = [string()] | [atom()] | string() | atom() %%% Cases = [atom()] | atom() diff --git a/lib/common_test/src/ct_groups.erl b/lib/common_test/src/ct_groups.erl index 80f5c30c2a..dd04c5410a 100644 --- a/lib/common_test/src/ct_groups.erl +++ b/lib/common_test/src/ct_groups.erl @@ -325,7 +325,7 @@ modify_tc_list1(GrSpecTs, TSCs) -> true -> {[TC|TSCs1],lists:delete(TC,GrSpecTs2)}; false -> - case lists:keymember(TC, 2, GrSpecTs) of + case lists:keysearch(TC, 2, GrSpecTs) of {value,Test} -> {[Test|TSCs1], lists:keydelete(TC, 2, GrSpecTs2)}; diff --git a/lib/common_test/src/ct_hooks.erl b/lib/common_test/src/ct_hooks.erl index d8f583455b..5422d449fd 100644 --- a/lib/common_test/src/ct_hooks.erl +++ b/lib/common_test/src/ct_hooks.erl @@ -67,6 +67,8 @@ terminate(Hooks) -> %% tests. -spec init_tc(Mod :: atom(), FuncSpec :: atom() | + {ConfigFunc :: init_per_testcase | end_per_testcase, + TestCase :: atom()} | {ConfigFunc :: init_per_group | end_per_group, GroupName :: atom(), Properties :: list()}, @@ -103,7 +105,9 @@ init_tc(_Mod, TC = error_in_suite, Config) -> %% @doc Called as each test case is completed. This includes all configuration %% tests. -spec end_tc(Mod :: atom(), - FuncSpec :: atom() | + FuncSpec :: atom() | + {ConfigFunc :: init_per_testcase | end_per_testcase, + TestCase :: atom()} | {ConfigFunc :: init_per_group | end_per_group, GroupName :: atom(), Properties :: list()}, diff --git a/lib/common_test/src/ct_logs.erl b/lib/common_test/src/ct_logs.erl index 77828a2186..29b38e9748 100644 --- a/lib/common_test/src/ct_logs.erl +++ b/lib/common_test/src/ct_logs.erl @@ -609,7 +609,8 @@ log_timestamp({MS,S,US}) -> ct_log_fd, tc_groupleaders, stylesheet, - async_print_jobs}). + async_print_jobs, + tc_esc_chars}). logger(Parent, Mode, Verbosity) -> register(?MODULE,self()), @@ -728,14 +729,18 @@ logger(Parent, Mode, Verbosity) -> end end || {Cat,VLvl} <- Verbosity], io:nl(CtLogFd), - + TcEscChars = case application:get_env(common_test, esc_chars) of + {ok,ECBool} -> ECBool; + _ -> true + end, logger_loop(#logger_state{parent=Parent, log_dir=AbsDir, start_time=Time, orig_GL=group_leader(), ct_log_fd=CtLogFd, tc_groupleaders=[], - async_print_jobs=[]}). + async_print_jobs=[], + tc_esc_chars=TcEscChars}). copy_priv_files([SrcF | SrcFs], [DestF | DestFs]) -> case file:copy(SrcF, DestF) of @@ -761,20 +766,21 @@ logger_loop(State) -> end, if Importance >= (100-VLvl) -> CtLogFd = State#logger_state.ct_log_fd, + DoEscChars = State#logger_state.tc_esc_chars and EscChars, case get_groupleader(Pid, GL, State) of {tc_log,TCGL,TCGLs} -> case erlang:is_process_alive(TCGL) of true -> State1 = print_to_log(SyncOrAsync, Pid, Category, TCGL, Content, - EscChars, State), + DoEscChars, State), logger_loop(State1#logger_state{ tc_groupleaders = TCGLs}); false -> %% Group leader is dead, so write to the %% CtLog or unexpected_io log instead unexpected_io(Pid, Category, Importance, - Content, CtLogFd, EscChars), + Content, CtLogFd, DoEscChars), logger_loop(State) end; @@ -783,7 +789,7 @@ logger_loop(State) -> %% to ct_log, else write to unexpected_io %% log unexpected_io(Pid, Category, Importance, Content, - CtLogFd, EscChars), + CtLogFd, DoEscChars), logger_loop(State#logger_state{ tc_groupleaders = TCGLs}) end; @@ -794,7 +800,7 @@ logger_loop(State) -> %% make sure no IO for this test case from the %% CT logger gets rejected test_server:permit_io(GL, self()), - print_style(GL, State#logger_state.stylesheet), + print_style(GL,GL,State#logger_state.stylesheet), set_evmgr_gl(GL), TCGLs = add_tc_gl(TCPid,GL,State), if not RefreshLog -> @@ -882,7 +888,7 @@ create_io_fun(FromPid, CtLogFd, EscChars) -> {_HdOrFt,S,A} -> {false,S,A}; {S,A} -> {true,S,A} end, - try io_lib:format(Str,Args) of + try io_lib:format(Str, Args) of IoStr when Escapable, EscChars, IoList == [] -> escape_chars(IoStr); IoStr when Escapable, EscChars -> @@ -925,7 +931,12 @@ print_to_log(sync, FromPid, Category, TCGL, Content, EscChars, State) -> if FromPid /= TCGL -> IoFun = create_io_fun(FromPid, CtLogFd, EscChars), IoList = lists:foldl(IoFun, [], Content), - io:format(TCGL,["$tc_html","~ts"], [IoList]); + try io:format(TCGL,["$tc_html","~ts"], [IoList]) of + ok -> ok + catch + _:_ -> + io:format(TCGL,"~ts", [IoList]) + end; true -> unexpected_io(FromPid, Category, ?MAX_IMPORTANCE, Content, CtLogFd, EscChars) @@ -958,7 +969,10 @@ print_to_log(async, FromPid, Category, TCGL, Content, EscChars, State) -> _:terminated -> unexpected_io(FromPid, Category, ?MAX_IMPORTANCE, - Content, CtLogFd, EscChars) + Content, CtLogFd, EscChars); + _:_ -> + io:format(TCGL, "~ts", + [lists:foldl(IoFun,[],Content)]) end; false -> unexpected_io(FromPid, Category, @@ -1099,26 +1113,27 @@ open_ctlog(MiscIoName) -> "View I/O logged after the test run</a></li>\n</ul>\n", [MiscIoName,MiscIoName]), - print_style(Fd,undefined), + print_style(Fd,group_leader(),undefined), io:format(Fd, xhtml("<br><h2>Progress Log</h2>\n<pre>\n", "<br />\n<h4>PROGRESS LOG</h4>\n<pre>\n"), []), Fd. -print_style(Fd,undefined) -> +print_style(Fd,GL,undefined) -> case basic_html() of true -> - io:format(Fd, - "<style>\n" - "div.ct_internal { background:lightgrey; color:black; }\n" - "div.default { background:lightgreen; color:black; }\n" - "</style>\n", - []); + Style = "<style>\n + div.ct_internal { background:lightgrey; color:black; }\n + div.default { background:lightgreen; color:black; }\n + </style>\n", + if Fd == GL -> io:format(["$tc_html",Style], []); + true -> io:format(Fd, Style, []) + end; _ -> ok end; -print_style(Fd,StyleSheet) -> +print_style(Fd,GL,StyleSheet) -> case file:read_file(StyleSheet) of {ok,Bin} -> Str = b2s(Bin,encoding(StyleSheet)), @@ -1131,23 +1146,30 @@ print_style(Fd,StyleSheet) -> N1 -> N1 end, if (Pos0 == 0) and (Pos1 /= 0) -> - print_style_error(Fd,StyleSheet,missing_style_start_tag); + print_style_error(Fd,GL,StyleSheet,missing_style_start_tag); (Pos0 /= 0) and (Pos1 == 0) -> - print_style_error(Fd,StyleSheet,missing_style_end_tag); + print_style_error(Fd,GL,StyleSheet,missing_style_end_tag); Pos0 /= 0 -> Style = string:sub_string(Str,Pos0,Pos1+7), - io:format(Fd,"~ts\n",[Style]); + if Fd == GL -> io:format(Fd,["$tc_html","~ts\n"],[Style]); + true -> io:format(Fd,"~ts\n",[Style]) + end; Pos0 == 0 -> - io:format(Fd,"<style>~ts</style>\n",[Str]) + if Fd == GL -> io:format(Fd,["$tc_html","<style>\n~ts</style>\n"],[Str]); + true -> io:format(Fd,"<style>\n~ts</style>\n",[Str]) + end end; {error,Reason} -> - print_style_error(Fd,StyleSheet,Reason) + print_style_error(Fd,GL,StyleSheet,Reason) end. -print_style_error(Fd,StyleSheet,Reason) -> - io:format(Fd,"\n<!-- Failed to load stylesheet ~ts: ~p -->\n", - [StyleSheet,Reason]), - print_style(Fd,undefined). +print_style_error(Fd,GL,StyleSheet,Reason) -> + IO = io_lib:format("\n<!-- Failed to load stylesheet ~ts: ~p -->\n", + [StyleSheet,Reason]), + if Fd == GL -> io:format(Fd,["$tc_html",IO],[]); + true -> io:format(Fd,IO,[]) + end, + print_style(Fd,GL,undefined). close_ctlog(Fd) -> io:format(Fd, "\n</pre>\n", []), diff --git a/lib/common_test/src/ct_master.erl b/lib/common_test/src/ct_master.erl index 32c8ab96ec..c4905b316f 100644 --- a/lib/common_test/src/ct_master.erl +++ b/lib/common_test/src/ct_master.erl @@ -27,7 +27,7 @@ -export([run_on_node/2,run_on_node/3]). -export([run_test/1,run_test/2]). -export([get_event_mgr_ref/0]). --export([basic_html/1]). +-export([basic_html/1,esc_chars/1]). -export([abort/0,abort/1,progress/0]). @@ -317,6 +317,16 @@ basic_html(Bool) -> ok. %%%----------------------------------------------------------------- +%%% @spec esc_chars(Bool) -> ok +%%% Bool = true | false +%%% +%%% @doc If set to false, the ct_master logs will be written without +%%% special characters being escaped in the HTML logs. +esc_chars(Bool) -> + application:set_env(common_test_master, esc_chars, Bool), + ok. + +%%%----------------------------------------------------------------- %%% MASTER, runs on central controlling node. %%%----------------------------------------------------------------- start_master(NodeOptsList) -> diff --git a/lib/common_test/src/ct_run.erl b/lib/common_test/src/ct_run.erl index e156c9b773..1e5f935198 100644 --- a/lib/common_test/src/ct_run.erl +++ b/lib/common_test/src/ct_run.erl @@ -65,6 +65,7 @@ logdir, logopts = [], basic_html, + esc_chars = true, verbosity = [], config = [], event_handlers = [], @@ -346,6 +347,15 @@ script_start1(Parent, Args) -> application:set_env(common_test, basic_html, true), true end, + %% esc_chars - used by ct_logs + EscChars = case proplists:get_value(no_esc_chars, Args) of + undefined -> + application:set_env(common_test, esc_chars, true), + undefined; + _ -> + application:set_env(common_test, esc_chars, false), + false + end, %% disable_log_cache - used by ct_logs case proplists:get_value(disable_log_cache, Args) of undefined -> @@ -359,6 +369,7 @@ script_start1(Parent, Args) -> cover = Cover, cover_stop = CoverStop, logdir = LogDir, logopts = LogOpts, basic_html = BasicHtml, + esc_chars = EscChars, verbosity = Verbosity, event_handlers = EvHandlers, ct_hooks = CTHooks, @@ -587,6 +598,17 @@ combine_test_opts(TS, Specs, Opts) -> BHBool end, + EscChars = + case choose_val(Opts#opts.esc_chars, + TSOpts#opts.esc_chars) of + undefined -> + true; + ECBool -> + application:set_env(common_test, esc_chars, + ECBool), + ECBool + end, + Opts#opts{label = Label, profile = Profile, testspec_files = Specs, @@ -595,6 +617,7 @@ combine_test_opts(TS, Specs, Opts) -> logdir = which(logdir, LogDir), logopts = AllLogOpts, basic_html = BasicHtml, + esc_chars = EscChars, verbosity = AllVerbosity, silent_connections = AllSilentConns, config = TSOpts#opts.config, @@ -795,6 +818,7 @@ script_usage() -> "\n\t [-scale_timetraps]" "\n\t [-create_priv_dir auto_per_run | auto_per_tc | manual_per_tc]" "\n\t [-basic_html]" + "\n\t [-no_esc_chars]" "\n\t [-repeat N] |" "\n\t [-duration HHMMSS [-force_stop [skip_rest]]] |" "\n\t [-until [YYMoMoDD]HHMMSS [-force_stop [skip_rest]]]" @@ -822,6 +846,7 @@ script_usage() -> "\n\t [-scale_timetraps]" "\n\t [-create_priv_dir auto_per_run | auto_per_tc | manual_per_tc]" "\n\t [-basic_html]" + "\n\t [-no_esc_chars]" "\n\t [-repeat N] |" "\n\t [-duration HHMMSS [-force_stop [skip_rest]]] |" "\n\t [-until [YYMoMoDD]HHMMSS [-force_stop [skip_rest]]]\n\n"), @@ -847,7 +872,8 @@ script_usage() -> "\n\t [-multiply_timetraps N]" "\n\t [-scale_timetraps]" "\n\t [-create_priv_dir auto_per_run | auto_per_tc | manual_per_tc]" - "\n\t [-basic_html]\n\n"). + "\n\t [-basic_html]" + "\n\t [-no_esc_chars]\n\n"). %%%----------------------------------------------------------------- %%% @hidden @@ -1089,7 +1115,17 @@ run_test2(StartOpts) -> application:set_env(common_test, basic_html, BasicHtmlBool), BasicHtmlBool end, - + %% esc_chars - used by ct_logs + EscChars = + case proplists:get_value(esc_chars, StartOpts) of + undefined -> + application:set_env(common_test, esc_chars, true), + undefined; + EscCharsBool -> + application:set_env(common_test, esc_chars, EscCharsBool), + EscCharsBool + end, + %% disable_log_cache - used by ct_logs case proplists:get_value(disable_log_cache, StartOpts) of undefined -> application:set_env(common_test, disable_log_cache, false); @@ -1104,6 +1140,7 @@ run_test2(StartOpts) -> cover = Cover, cover_stop = CoverStop, step = Step, logdir = LogDir, logopts = LogOpts, basic_html = BasicHtml, + esc_chars = EscChars, config = CfgFiles, verbosity = Verbosity, event_handlers = EvHandlers, @@ -1445,6 +1482,7 @@ get_data_for_node(#testspec{label = Labels, logdir = LogDirs, logopts = LogOptsList, basic_html = BHs, + esc_chars = EscChs, stylesheet = SSs, verbosity = VLvls, silent_connections = SilentConnsList, @@ -1472,6 +1510,7 @@ get_data_for_node(#testspec{label = Labels, LOs -> LOs end, BasicHtml = proplists:get_value(Node, BHs), + EscChars = proplists:get_value(Node, EscChs), Stylesheet = proplists:get_value(Node, SSs), Verbosity = case proplists:get_value(Node, VLvls) of undefined -> []; @@ -1498,6 +1537,7 @@ get_data_for_node(#testspec{label = Labels, logdir = LogDir, logopts = LogOpts, basic_html = BasicHtml, + esc_chars = EscChars, stylesheet = Stylesheet, verbosity = Verbosity, silent_connections = SilentConns, @@ -2182,10 +2222,18 @@ do_run_test(Tests, Skip, Opts0) -> %% test_server needs to know the include path too InclPath = case application:get_env(common_test, include) of {ok,Incls} -> Incls; - _ -> [] + _ -> [] end, application:set_env(test_server, include, InclPath), + %% copy the escape characters setting to test_server + EscChars = + case application:get_env(common_test, esc_chars) of + {ok,ECBool} -> ECBool; + _ -> true + end, + application:set_env(test_server, esc_chars, EscChars), + test_server_ctrl:start_link(local), %% let test_server expand the test tuples and count no of cases @@ -3069,6 +3117,10 @@ opts2args(EnvStartOpts) -> [{basic_html,[]}]; ({basic_html,false}) -> []; + ({esc_chars,false}) -> + [{no_esc_chars,[]}]; + ({esc_chars,true}) -> + []; ({event_handler,EH}) when is_atom(EH) -> [{event_handler,[atom_to_list(EH)]}]; ({event_handler,EHs}) when is_list(EHs) -> diff --git a/lib/common_test/src/ct_telnet.erl b/lib/common_test/src/ct_telnet.erl index 4d3fd2d094..f5f4f648f4 100644 --- a/lib/common_test/src/ct_telnet.erl +++ b/lib/common_test/src/ct_telnet.erl @@ -42,7 +42,8 @@ %% {reconnection_interval,Millisec}, %% {keep_alive,Bool}, %% {poll_limit,N}, -%% {poll_interval,Millisec}]}.</pre> +%% {poll_interval,Millisec}, +%% {tcp_nodelay,Bool}]}.</pre> %% <p><code>Millisec = integer(), N = integer()</code></p> %% <p>Enter the <code>telnet_settings</code> term in a configuration %% file included in the test and ct_telnet will retrieve the information @@ -182,7 +183,8 @@ conn_to=?DEFAULT_TIMEOUT, com_to=?DEFAULT_TIMEOUT, reconns=?RECONNS, - reconn_int=?RECONN_TIMEOUT}). + reconn_int=?RECONN_TIMEOUT, + tcp_nodelay=false}). %%%----------------------------------------------------------------- %%% @spec open(Name) -> {ok,Handle} | {error,Reason} @@ -602,8 +604,18 @@ init(Name,{Ip,Port,Type},{TargetMod,KeepAlive,Extra}) -> Settings -> set_telnet_defaults(Settings,#state{}) end, - case catch TargetMod:connect(Name,Ip,Port,S0#state.conn_to, - KeepAlive,Extra) of + %% Handle old user versions of TargetMod + code:ensure_loaded(TargetMod), + try + case erlang:function_exported(TargetMod,connect,7) of + true -> + TargetMod:connect(Name,Ip,Port,S0#state.conn_to, + KeepAlive,S0#state.tcp_nodelay,Extra); + false -> + TargetMod:connect(Name,Ip,Port,S0#state.conn_to, + KeepAlive,Extra) + end + of {ok,TelnPid} -> put({ct_telnet_pid2name,TelnPid},Name), S1 = S0#state{host=Ip, @@ -625,15 +637,18 @@ init(Name,{Ip,Port,Type},{TargetMod,KeepAlive,Extra}) -> "Connection timeout: ~p\n" "Keep alive: ~w\n" "Poll limit: ~w\n" - "Poll interval: ~w", + "Poll interval: ~w\n" + "TCP nodelay: ~w", [Ip,Port,S1#state.com_to,S1#state.reconns, S1#state.reconn_int,S1#state.conn_to,KeepAlive, - S1#state.poll_limit,S1#state.poll_interval]), + S1#state.poll_limit,S1#state.poll_interval, + S1#state.tcp_nodelay]), {ok,TelnPid,S1}; - {'EXIT',Reason} -> - {error,Reason}; Error -> Error + catch + _:Reason -> + {error,Reason} end. type(telnet) -> ip; @@ -653,6 +668,8 @@ set_telnet_defaults([{poll_limit,PL}|Ss],S) -> set_telnet_defaults(Ss,S#state{poll_limit=PL}); set_telnet_defaults([{poll_interval,PI}|Ss],S) -> set_telnet_defaults(Ss,S#state{poll_interval=PI}); +set_telnet_defaults([{tcp_nodelay,NoDelay}|Ss],S) -> + set_telnet_defaults(Ss,S#state{tcp_nodelay=NoDelay}); set_telnet_defaults([Unknown|Ss],S) -> force_log(S,error, "Bad element in telnet_settings: ~p",[Unknown]), @@ -794,8 +811,17 @@ reconnect(Ip,Port,N,State=#state{name=Name, keep_alive=KeepAlive, extra=Extra, conn_to=ConnTo, - reconn_int=ReconnInt}) -> - case TargetMod:connect(Name,Ip,Port,ConnTo,KeepAlive,Extra) of + reconn_int=ReconnInt, + tcp_nodelay=NoDelay}) -> + %% Handle old user versions of TargetMod + ConnResult = + case erlang:function_exported(TargetMod,connect,7) of + true -> + TargetMod:connect(Name,Ip,Port,ConnTo,KeepAlive,NoDelay,Extra); + false -> + TargetMod:connect(Name,Ip,Port,ConnTo,KeepAlive,Extra) + end, + case ConnResult of {ok,NewPid} -> put({ct_telnet_pid2name,NewPid},Name), {ok, NewPid, State#state{teln_pid=NewPid}}; diff --git a/lib/common_test/src/ct_telnet_client.erl b/lib/common_test/src/ct_telnet_client.erl index f1dee1f3bb..1f1311776f 100644 --- a/lib/common_test/src/ct_telnet_client.erl +++ b/lib/common_test/src/ct_telnet_client.erl @@ -35,7 +35,7 @@ %%-define(debug, true). --export([open/2, open/3, open/4, open/5, close/1]). +-export([open/2, open/3, open/4, open/5, open/6, close/1]). -export([send_data/2, send_data/3, get_data/1]). -define(TELNET_PORT, 23). @@ -70,19 +70,22 @@ -record(state,{conn_name, get_data, keep_alive=true, log_pos=1}). open(Server, ConnName) -> - open(Server, ?TELNET_PORT, ?OPEN_TIMEOUT, true, ConnName). + open(Server, ?TELNET_PORT, ?OPEN_TIMEOUT, true, false, ConnName). open(Server, Port, ConnName) -> - open(Server, Port, ?OPEN_TIMEOUT, true, ConnName). + open(Server, Port, ?OPEN_TIMEOUT, true, false, ConnName). open(Server, Port, Timeout, ConnName) -> - open(Server, Port, Timeout, true, ConnName). + open(Server, Port, Timeout, true, false, ConnName). open(Server, Port, Timeout, KeepAlive, ConnName) -> + open(Server, Port, Timeout, KeepAlive, false, ConnName). + +open(Server, Port, Timeout, KeepAlive, NoDelay, ConnName) -> Self = self(), Pid = spawn(fun() -> init(Self, Server, Port, Timeout, - KeepAlive, ConnName) + KeepAlive, NoDelay, ConnName) end), receive {open,Pid} -> @@ -114,8 +117,8 @@ get_data(Pid) -> %%%----------------------------------------------------------------- %%% Internal functions -init(Parent, Server, Port, Timeout, KeepAlive, ConnName) -> - case gen_tcp:connect(Server, Port, [list,{packet,0},{nodelay,true}], Timeout) of +init(Parent, Server, Port, Timeout, KeepAlive, NoDelay, ConnName) -> + case gen_tcp:connect(Server, Port, [list,{packet,0},{nodelay,NoDelay}], Timeout) of {ok,Sock} -> dbg("~p connected to: ~p (port: ~w, keep_alive: ~w)\n", [ConnName,Server,Port,KeepAlive]), diff --git a/lib/common_test/src/ct_testspec.erl b/lib/common_test/src/ct_testspec.erl index df5587b069..991abb0666 100644 --- a/lib/common_test/src/ct_testspec.erl +++ b/lib/common_test/src/ct_testspec.erl @@ -1146,8 +1146,9 @@ should_be_added(Tag,Node,_Data,Spec) -> if %% list terms *without* possible duplicates here Tag == logdir; Tag == logopts; - Tag == basic_html; Tag == label; - Tag == auto_compile; Tag == abort_if_missing_suites; + Tag == basic_html; Tag == esc_chars; + Tag == label; Tag == auto_compile; + Tag == abort_if_missing_suites; Tag == stylesheet; Tag == verbosity; Tag == silent_connections -> lists:keymember(ref2node(Node,Spec#testspec.nodes),1, @@ -1544,6 +1545,8 @@ valid_terms() -> {logopts,3}, {basic_html,2}, {basic_html,3}, + {esc_chars,2}, + {esc_chars,3}, {verbosity,2}, {verbosity,3}, {silent_connections,2}, diff --git a/lib/common_test/src/ct_util.erl b/lib/common_test/src/ct_util.erl index c372763ae9..d5a8e3fbc0 100644 --- a/lib/common_test/src/ct_util.erl +++ b/lib/common_test/src/ct_util.erl @@ -459,6 +459,7 @@ loop(Mode,TestData,StartDir) -> error:badarg -> [] end, ct_hooks:terminate(Callbacks), + close_connections(ets:tab2list(?conn_table)), ets:delete(?conn_table), ets:delete(?board_table), diff --git a/lib/common_test/src/ct_util.hrl b/lib/common_test/src/ct_util.hrl index c1cc1eafbd..d7efa26863 100644 --- a/lib/common_test/src/ct_util.hrl +++ b/lib/common_test/src/ct_util.hrl @@ -37,6 +37,7 @@ logdir=["."], logopts=[], basic_html=[], + esc_chars=[], verbosity=[], silent_connections=[], cover=[], diff --git a/lib/common_test/src/cth_log_redirect.erl b/lib/common_test/src/cth_log_redirect.erl index e762d5060f..33a3813a16 100644 --- a/lib/common_test/src/cth_log_redirect.erl +++ b/lib/common_test/src/cth_log_redirect.erl @@ -130,7 +130,14 @@ handle_event(Event, #eh_state{log_func = LogFunc} = State) -> tag_event(Event)), if is_list(SReport) -> SaslHeader = format_header(State), - ct_logs:LogFunc(sasl, ?STD_IMPORTANCE, SaslHeader, SReport, []); + case LogFunc of + tc_log -> + ct_logs:tc_log(sasl, ?STD_IMPORTANCE, + SaslHeader, SReport, [], []); + tc_log_async -> + ct_logs:tc_log_async(sasl, ?STD_IMPORTANCE, + SaslHeader, SReport, []) + end; true -> %% Report is an atom if no logging is to be done ignore end @@ -139,7 +146,14 @@ handle_event(Event, #eh_state{log_func = LogFunc} = State) -> tag_event(Event),io_lib), if is_list(EReport) -> ErrHeader = format_header(State), - ct_logs:LogFunc(error_logger, ?STD_IMPORTANCE, ErrHeader, EReport, []); + case LogFunc of + tc_log -> + ct_logs:tc_log(error_logger, ?STD_IMPORTANCE, + ErrHeader, EReport, [], []); + tc_log_async -> + ct_logs:tc_log_async(error_logger, ?STD_IMPORTANCE, + ErrHeader, EReport, []) + end; true -> %% Report is an atom if no logging is to be done ignore end, diff --git a/lib/common_test/src/cth_surefire.erl b/lib/common_test/src/cth_surefire.erl index 74a97fe2e2..59b916851e 100644 --- a/lib/common_test/src/cth_surefire.erl +++ b/lib/common_test/src/cth_surefire.erl @@ -82,7 +82,8 @@ init(Path, Opts) -> url_base = proplists:get_value(url_base,Opts), timer = ?now }. -pre_init_per_suite(Suite,SkipOrFail,State) when is_tuple(SkipOrFail) -> +pre_init_per_suite(Suite,SkipOrFail,#state{ test_cases = [] } = State) + when is_tuple(SkipOrFail) -> {SkipOrFail, init_tc(State#state{curr_suite = Suite, curr_suite_ts = ?now}, SkipOrFail) }; diff --git a/lib/common_test/src/test_server.erl b/lib/common_test/src/test_server.erl index 34acad6fd1..919526c5d7 100644 --- a/lib/common_test/src/test_server.erl +++ b/lib/common_test/src/test_server.erl @@ -2165,10 +2165,19 @@ get_timetrap_info(TCPid, SendToServer) -> Timers -> case [Info || {Handle,Pid,Info} <- Timers, Pid == TCPid, Handle /= infinity] of - [I|_] -> - I; + [{TVal,true}|_] -> + {TVal,{true,test_server:timetrap_scale_factor()}}; + [{TVal,false}|_] -> + {TVal,{false,1}}; [] when SendToServer == true -> - tc_supervisor_req({get_timetrap_info,TCPid}); + case tc_supervisor_req({get_timetrap_info,TCPid}) of + {TVal,true} -> + {TVal,{true,test_server:timetrap_scale_factor()}}; + {TVal,false} -> + {TVal,{false,1}}; + Error -> + Error + end; [] -> undefined end diff --git a/lib/common_test/src/test_server_gl.erl b/lib/common_test/src/test_server_gl.erl index c150570604..333c8fc06e 100644 --- a/lib/common_test/src/test_server_gl.erl +++ b/lib/common_test/src/test_server_gl.erl @@ -131,6 +131,10 @@ set_props(GL, PropList) -> %%% Internal functions. init([]) -> + EscChars = case application:get_env(test_server, esc_chars) of + {ok,ECBool} -> ECBool; + _ -> true + end, {ok,#st{tc_supervisor=none, minor=none, minor_monitor=none, @@ -139,7 +143,7 @@ init([]) -> permit_io=gb_sets:empty(), auto_nl=true, levels={1,19,10}, - escape_chars=true + escape_chars=EscChars }}. req(GL, Req) -> diff --git a/lib/common_test/src/unix_telnet.erl b/lib/common_test/src/unix_telnet.erl index cd493d293f..4897ddb2f8 100644 --- a/lib/common_test/src/unix_telnet.erl +++ b/lib/common_test/src/unix_telnet.erl @@ -27,7 +27,8 @@ %%% {port,PortNum}, % optional %%% {username,UserName}, %%% {password,Password}, -%%% {keep_alive,Bool}]}. % optional</pre> +%%% {keep_alive,Bool}, % optional +%%% {tcp_nodely,Bool}]} % optional</pre> %%% %%% <p>To communicate via telnet to the host specified by %%% <code>HostNameOrIpAddress</code>, use the interface functions in @@ -55,7 +56,7 @@ -compile(export_all). %% Callbacks for ct_telnet.erl --export([connect/6,get_prompt_regexp/0]). +-export([connect/7,get_prompt_regexp/0]). -import(ct_telnet,[start_gen_log/1,log/4,end_gen_log/0]). -define(username,"login: "). @@ -82,6 +83,7 @@ get_prompt_regexp() -> %%% Port = integer() %%% Timeout = integer() %%% KeepAlive = bool() +%%% TCPNoDelay = bool() %%% Extra = ct:target_name() | {Username,Password} %%% Username = string() %%% Password = string() @@ -91,25 +93,25 @@ get_prompt_regexp() -> %%% @doc Callback for ct_telnet.erl. %%% %%% <p>Setup telnet connection to a unix host.</p> -connect(ConnName,Ip,Port,Timeout,KeepAlive,Extra) -> +connect(ConnName,Ip,Port,Timeout,KeepAlive,TCPNoDelay,Extra) -> case Extra of {Username,Password} -> - connect1(ConnName,Ip,Port,Timeout,KeepAlive, + connect1(ConnName,Ip,Port,Timeout,KeepAlive,TCPNoDelay, Username,Password); KeyOrName -> case get_username_and_password(KeyOrName) of {ok,{Username,Password}} -> - connect1(ConnName,Ip,Port,Timeout,KeepAlive, + connect1(ConnName,Ip,Port,Timeout,KeepAlive,TCPNoDelay, Username,Password); Error -> Error end end. -connect1(Name,Ip,Port,Timeout,KeepAlive,Username,Password) -> +connect1(Name,Ip,Port,Timeout,KeepAlive,TCPNoDelay,Username,Password) -> start_gen_log("unix_telnet connect"), Result = - case ct_telnet_client:open(Ip,Port,Timeout,KeepAlive,Name) of + case ct_telnet_client:open(Ip,Port,Timeout,KeepAlive,TCPNoDelay,Name) of {ok,Pid} -> case ct_telnet:silent_teln_expect(Name,Pid,[], [prompt],?prx,[]) of diff --git a/lib/common_test/test/ct_hooks_SUITE_data/cth/tests/ct_update_config_SUITE.erl b/lib/common_test/test/ct_hooks_SUITE_data/cth/tests/ct_update_config_SUITE.erl index a281ddc938..20f139bcc8 100644 --- a/lib/common_test/test/ct_hooks_SUITE_data/cth/tests/ct_update_config_SUITE.erl +++ b/lib/common_test/test/ct_hooks_SUITE_data/cth/tests/ct_update_config_SUITE.erl @@ -1,8 +1,8 @@ -%%
-%% %CopyrightBegin%
-%%
-%% Copyright Ericsson AB 2010-2016. All Rights Reserved.
-%%
+%% +%% %CopyrightBegin% +%% +%% Copyright Ericsson AB 2010-2016. All Rights Reserved. +%% %% Licensed under the Apache License, Version 2.0 (the "License"); %% you may not use this file except in compliance with the License. %% You may obtain a copy of the License at @@ -14,46 +14,46 @@ %% WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. %% See the License for the specific language governing permissions and %% limitations under the License. -%%
-%% %CopyrightEnd%
-%%
-
--module(ct_update_config_SUITE).
-
--suite_defaults([{timetrap, {minutes, 10}}]).
-
-%% Note: This directive should only be used in test suites.
--compile(export_all).
-
--include("ct.hrl").
-
--define(now, os:timestamp()).
-
-%% Test server callback functions
-init_per_suite(Config) ->
- [{init_per_suite,?now}|Config].
-
-end_per_suite(_Config) ->
- ok.
-
-init_per_testcase(_TestCase, Config) ->
- [{init_per_testcase,?now}|Config].
-
-end_per_testcase(_TestCase, _Config) ->
- ok.
-
-init_per_group(GroupName, Config) ->
- [{init_per_group,?now}|Config].
-
-end_per_group(GroupName, Config) ->
- ok.
-
-all() ->
- [{group,group1}].
-
-groups() ->
- [{group1,[],[test_case]}].
-
-%% Test cases starts here.
-test_case(Config) when is_list(Config) ->
- ok.
+%% +%% %CopyrightEnd% +%% + +-module(ct_update_config_SUITE). + +-suite_defaults([{timetrap, {minutes, 10}}]). + +%% Note: This directive should only be used in test suites. +-compile(export_all). + +-include("ct.hrl"). + +-define(now, ct_test_support:unique_timestamp()). + +%% Test server callback functions +init_per_suite(Config) -> + [{init_per_suite,?now}|Config]. + +end_per_suite(_Config) -> + ok. + +init_per_testcase(_TestCase, Config) -> + [{init_per_testcase,?now}|Config]. + +end_per_testcase(_TestCase, _Config) -> + ok. + +init_per_group(GroupName, Config) -> + [{init_per_group,?now}|Config]. + +end_per_group(GroupName, Config) -> + ok. + +all() -> + [{group,group1}]. + +groups() -> + [{group1,[],[test_case]}]. + +%% Test cases starts here. +test_case(Config) when is_list(Config) -> + ok. diff --git a/lib/common_test/test/ct_hooks_SUITE_data/cth/tests/empty_cth.erl b/lib/common_test/test/ct_hooks_SUITE_data/cth/tests/empty_cth.erl index dc0056b61b..c00eb5cf93 100644 --- a/lib/common_test/test/ct_hooks_SUITE_data/cth/tests/empty_cth.erl +++ b/lib/common_test/test/ct_hooks_SUITE_data/cth/tests/empty_cth.erl @@ -90,7 +90,7 @@ id(Opts) -> gen_event:notify(?CT_EVMGR_REF, #event{ name = cth, node = node(), data = {?MODULE, id, [Opts]}}), ct:log("~w:id called", [?MODULE]), - os:timestamp(). + ct_test_support:unique_timestamp(). %% @doc Called before init_per_suite is called. Note that this callback is %% only called if the CTH is added before init_per_suite is run (eg. in a test diff --git a/lib/common_test/test/ct_hooks_SUITE_data/cth/tests/update_config_cth.erl b/lib/common_test/test/ct_hooks_SUITE_data/cth/tests/update_config_cth.erl index 02f7fa7564..d48981f667 100644 --- a/lib/common_test/test/ct_hooks_SUITE_data/cth/tests/update_config_cth.erl +++ b/lib/common_test/test/ct_hooks_SUITE_data/cth/tests/update_config_cth.erl @@ -25,7 +25,7 @@ -include_lib("common_test/src/ct_util.hrl"). -include_lib("common_test/include/ct_event.hrl"). --define(now, os:timestamp()). +-define(now, ct_test_support:unique_timestamp()). %% CT Hooks -compile(export_all). diff --git a/lib/common_test/test/ct_netconfc_SUITE.erl b/lib/common_test/test/ct_netconfc_SUITE.erl index 72c1de4023..03fbc17bd2 100644 --- a/lib/common_test/test/ct_netconfc_SUITE.erl +++ b/lib/common_test/test/ct_netconfc_SUITE.erl @@ -48,7 +48,12 @@ init_per_suite(Config) -> {error,Reason} when Reason=/={already_loaded,crypto} -> {skip, Reason}; _ -> - ct_test_support:init_per_suite(Config) + case application:load(ssh) of + {error,Reason} when Reason=/={already_loaded,ssh} -> + {skip, Reason}; + _ -> + ct_test_support:init_per_suite(Config) + end end. end_per_suite(Config) -> diff --git a/lib/common_test/test/ct_netconfc_SUITE_data/netconfc1_SUITE.erl b/lib/common_test/test/ct_netconfc_SUITE_data/netconfc1_SUITE.erl index e4062a7d62..065639dd36 100644 --- a/lib/common_test/test/ct_netconfc_SUITE_data/netconfc1_SUITE.erl +++ b/lib/common_test/test/ct_netconfc_SUITE_data/netconfc1_SUITE.erl @@ -123,15 +123,21 @@ init_per_testcase(_Case, Config) -> end_per_testcase(_Case, _Config) -> ok. +init_per_suite() -> + [{timetrap,2*?default_timeout}]. % making dsa files can be slow init_per_suite(Config) -> - case catch {crypto:start(), ssh:start()} of - {ok, ok} -> + case catch ssh:start() of + Ok when Ok==ok; Ok=={error,{already_started,ssh}} -> + ct:log("ssh started",[]), {ok, _} = netconfc_test_lib:get_id_keys(Config), netconfc_test_lib:make_dsa_files(Config), + ct:log("dsa files created",[]), Server = ?NS:start(?config(data_dir,Config)), + ct:log("netconf server started",[]), [{server,Server}|Config]; - _ -> - {skip, "Crypto and/or SSH could not be started!"} + Other -> + ct:log("could not start ssh: ~p",[Other]), + {skip, "SSH could not be started!"} end. end_per_suite(Config) -> @@ -806,7 +812,7 @@ close_while_waiting_for_chunked_data(Config) -> %% Order server to expect a get - then the process above will make %% sure the rpc-reply is sent - but only a part of it - then close. ?NS:expect('get'), - {error,closed} = ct_netconfc:get(Client,{server,[{xmlns,"myns"}],[]},2000), + {error,closed} = ct_netconfc:get(Client,{server,[{xmlns,"myns"}],[]},4000), ok. connection_crash(Config) -> diff --git a/lib/common_test/test/ct_netconfc_SUITE_data/netconfc_remote_SUITE.erl b/lib/common_test/test/ct_netconfc_SUITE_data/netconfc_remote_SUITE.erl index ae9087ce45..04bfe75187 100644 --- a/lib/common_test/test/ct_netconfc_SUITE_data/netconfc_remote_SUITE.erl +++ b/lib/common_test/test/ct_netconfc_SUITE_data/netconfc_remote_SUITE.erl @@ -26,7 +26,8 @@ -compile(export_all). suite() -> - [{ct_hooks, [{cth_conn_log,[{ct_netconfc,[{log_type,html}]}]}]}]. + [{timetrap,?default_timeout}, + {ct_hooks, [{cth_conn_log,[{ct_netconfc,[{log_type,html}]}]}]}]. all() -> case os:find_executable("ssh") of @@ -48,13 +49,10 @@ end_per_group(_GroupName, Config) -> init_per_testcase(Case, Config) -> stop_node(Case), - Dog = test_server:timetrap(?default_timeout), - [{watchdog, Dog}|Config]. + Config. end_per_testcase(Case, Config) -> stop_node(Case), - Dog=?config(watchdog, Config), - test_server:timetrap_cancel(Dog), ok. stop_node(Case) -> @@ -63,14 +61,19 @@ stop_node(Case) -> rpc:call(Node,erlang,halt,[]). +init_per_suite() -> + [{timetrap,2*?default_timeout}]. % making dsa files can be slow init_per_suite(Config) -> - case {crypto:start(),ssh:start()} of - {ok,ok} -> + case ssh:start() of + Ok when Ok==ok; Ok=={error,{already_started,ssh}} -> + ct:log("SSH started locally",[]), {ok, _} = netconfc_test_lib:get_id_keys(Config), netconfc_test_lib:make_dsa_files(Config), + ct:log("dsa files created",[]), Config; - _ -> - {skip, "Crypto and/or SSH could not be started locally!"} + Other -> + ct:log("could not start ssh locally: ~p",[Other]), + {skip, "SSH could not be started locally!"} end. end_per_suite(Config) -> @@ -87,12 +90,15 @@ remote_crash(Config) -> Pa = filename:dirname(code:which(?NS)), true = rpc:call(Node,code,add_patha,[Pa]), - case {rpc:call(Node,crypto,start,[]),rpc:call(Node,ssh,start,[])} of - {ok,ok} -> + case rpc:call(Node,ssh,start,[]) of + Ok when Ok==ok; Ok=={error,{already_started,ssh}} -> + ct:log("SSH started remote",[]), Server = rpc:call(Node,?NS,start,[?config(data_dir,Config)]), + ct:log("netconf server started remote",[]), remote_crash(Node,Config); - _ -> - {skip, "Crypto and/or SSH could not be started remote!"} + Other -> + ct:log("could not start ssh remote: ~p",[Other]), + {skip, "SSH could not be started remote!"} end. remote_crash(Node,Config) -> diff --git a/lib/common_test/test/ct_pre_post_test_io_SUITE.erl b/lib/common_test/test/ct_pre_post_test_io_SUITE.erl index 74ef3a26ce..7ffe6f045b 100644 --- a/lib/common_test/test/ct_pre_post_test_io_SUITE.erl +++ b/lib/common_test/test/ct_pre_post_test_io_SUITE.erl @@ -44,13 +44,29 @@ %% instance, the tests need to be performed on a separate node (or %% there will be clashes with logging processes etc). %%-------------------------------------------------------------------- +suite() -> + [{ct_hooks,[ts_install_cth]}, + {timetrap,{seconds,120}}]. + +all() -> + [ + pre_post_io + ]. + init_per_suite(Config) -> - DataDir = ?config(data_dir, Config), - CTH = filename:join(DataDir, "cth_ctrl.erl"), - ct:pal("Compiling ~p: ~p", - [CTH,compile:file(CTH,[{outdir,DataDir},debug_info])]), - ct_test_support:init_per_suite([{path_dirs,[DataDir]}, - {start_sasl,true} | Config]). + TTInfo = {_T,{_Scaled,ScaleVal}} = ct:get_timetrap_info(), + ct:pal("Timetrap info = ~w", [TTInfo]), + if ScaleVal > 1 -> + {skip,"Skip on systems running e.g. cover or debug!"}; + ScaleVal =< 1 -> + DataDir = ?config(data_dir, Config), + CTH = filename:join(DataDir, "cth_ctrl.erl"), + ct:pal("Compiling ~p: ~p", + [CTH,compile:file(CTH,[{outdir,DataDir}, + debug_info])]), + ct_test_support:init_per_suite([{path_dirs,[DataDir]}, + {start_sasl,true} | Config]) + end. end_per_suite(Config) -> ct_test_support:end_per_suite(Config). @@ -61,13 +77,6 @@ init_per_testcase(TestCase, Config) -> end_per_testcase(TestCase, Config) -> ct_test_support:end_per_testcase(TestCase, Config). -suite() -> [{ct_hooks,[ts_install_cth]}]. - -all() -> - [ - pre_post_io - ]. - %%-------------------------------------------------------------------- %% TEST CASES %%-------------------------------------------------------------------- @@ -90,31 +99,50 @@ pre_post_io(Config) -> %%!-------------------------------------------------------------------- spawn(fun() -> - ct:pal("CONTROLLER: Started!", []), + ct:pal("CONTROLLER: Starting test run #1...", []), %% --- test run 1 --- - ct:sleep(3000), - ct:pal("CONTROLLER: Handle remote events = true", []), - ok = ct_test_support:ct_rpc({cth_log_redirect, - handle_remote_events, - [true]}, Config), - ct:sleep(2000), - ct:pal("CONTROLLER: Proceeding with test run #1!", []), + try_loop(ct_test_support, ct_rpc, [{cth_log_redirect, + handle_remote_events, + [true]}, Config], 3000), + CTLoggerPid1 = ct_test_support:ct_rpc({erlang,whereis, + [ct_logs]}, Config), + ct:pal("CONTROLLER: Logger = ~w~nHandle remote events = true", + [CTLoggerPid1]), + ct:sleep(5000), + ct:pal("CONTROLLER: Proceeding with test run #1...", []), ok = ct_test_support:ct_rpc({cth_ctrl,proceed,[]}, Config), ct:sleep(6000), - ct:pal("CONTROLLER: Proceeding with shutdown #1!", []), + ct:pal("CONTROLLER: Proceeding with shutdown #1...", []), ok = ct_test_support:ct_rpc({cth_ctrl,proceed,[]}, Config), + try_loop(fun() -> + false = ct_test_support:ct_rpc({erlang, + is_process_alive, + [CTLoggerPid1]}, + Config) + end, 3000), + ct:pal("CONTROLLER: Shutdown #1 complete!", []), + ct:pal("CONTROLLER: Starting test run #2...", []), %% --- test run 2 --- - ct:sleep(3000), - ct:pal("CONTROLLER: Handle remote events = true", []), - ok = ct_test_support:ct_rpc({cth_log_redirect, - handle_remote_events, - [true]}, Config), - ct:sleep(2000), - ct:pal("CONTROLLER: Proceeding with test run #2!", []), + try_loop(ct_test_support, ct_rpc, [{cth_log_redirect, + handle_remote_events, + [true]}, Config], 3000), + CTLoggerPid2 = ct_test_support:ct_rpc({erlang,whereis, + [ct_logs]}, Config), + ct:pal("CONTROLLER: Logger = ~w~nHandle remote events = true", + [CTLoggerPid2]), + ct:sleep(5000), + ct:pal("CONTROLLER: Proceeding with test run #2...", []), ok = ct_test_support:ct_rpc({cth_ctrl,proceed,[]}, Config), ct:sleep(6000), - ct:pal("CONTROLLER: Proceeding with shutdown #2!", []), - ok = ct_test_support:ct_rpc({cth_ctrl,proceed,[]}, Config) + ct:pal("CONTROLLER: Proceeding with shutdown #2...", []), + ok = ct_test_support:ct_rpc({cth_ctrl,proceed,[]}, Config), + try_loop(fun() -> + false = ct_test_support:ct_rpc({erlang, + is_process_alive, + [CTLoggerPid2]}, + Config) + end, 3000), + ct:pal("CONTROLLER: Shutdown #2 complete!", []) end), ct_test_support:run(Opts, Config), Events = ct_test_support:get_events(ERPid, Config), @@ -157,7 +185,7 @@ pre_post_io(Config) -> Counters end, {pre,0,0,0,0}, Ts), [_|Counters] = tuple_to_list(PrePostIOEntries), - ct:log("Entries in the Pre/Post Test IO Log: ~p", [Counters]), + ct:pal("Entries in the Pre/Post Test IO Log: ~w", [Counters]), case [C || C <- Counters, C < 2] of [] -> ok; @@ -183,7 +211,7 @@ pre_post_io(Config) -> [LogN,ErrN+1]; (_, Counters) -> Counters end, [0,0], Ts), - ct:log("Entries in the Unexpected IO Log: ~p", [UnexpIOEntries]), + ct:log("Entries in the Unexpected IO Log: ~w", [UnexpIOEntries]), case [N || N <- UnexpIOEntries, N < 2] of [] -> ok; @@ -208,6 +236,38 @@ setup(Test, Config) -> reformat(Events, EH) -> ct_test_support:reformat(Events, EH). +try_loop(_Fun, 0) -> + ct:pal("WARNING! Fun never succeeded!", []), + gave_up; +try_loop(Fun, N) -> + try Fun() of + {error,_} -> + timer:sleep(10), + try_loop(Fun, N-1); + Result -> + Result + catch + _:_What -> + timer:sleep(10), + try_loop(Fun, N-1) + end. + +try_loop(M, F, _A, 0) -> + ct:pal("WARNING! ~w:~w never succeeded!", [M,F]), + gave_up; +try_loop(M, F, A, N) -> + try apply(M, F, A) of + {error,_} -> + timer:sleep(10), + try_loop(M, F, A, N-1); + Result -> + Result + catch + _:_ -> + timer:sleep(10), + try_loop(M, F, A, N-1) + end. + %%%----------------------------------------------------------------- %%% TEST EVENTS %%%----------------------------------------------------------------- diff --git a/lib/common_test/test/ct_pre_post_test_io_SUITE_data/cth_ctrl.erl b/lib/common_test/test/ct_pre_post_test_io_SUITE_data/cth_ctrl.erl index cb0c5ed14e..347b507c78 100644 --- a/lib/common_test/test/ct_pre_post_test_io_SUITE_data/cth_ctrl.erl +++ b/lib/common_test/test/ct_pre_post_test_io_SUITE_data/cth_ctrl.erl @@ -53,8 +53,7 @@ init(_Id, _Opts) -> receive {?MODULE,proceed} -> ok after - 10000 -> - ok + 10000 -> ok end, {ok,[],ct_last}. @@ -66,8 +65,7 @@ terminate(_State) -> receive {?MODULE,proceed} -> ok after - 10000 -> - ok + 10000 -> ok end, stop_external_logger(cth_logger), stop_dispatcher(), @@ -94,7 +92,7 @@ init_logger(Name) -> logger_loop(N) -> ct:log("Logger iteration: ~p", [N]), error_logger:error_report(N), - timer:sleep(250), + timer:sleep(100), logger_loop(N+1). %%%----------------------------------------------------------------- diff --git a/lib/common_test/test/ct_surefire_SUITE.erl b/lib/common_test/test/ct_surefire_SUITE.erl index a39a3887f7..42ec685c16 100644 --- a/lib/common_test/test/ct_surefire_SUITE.erl +++ b/lib/common_test/test/ct_surefire_SUITE.erl @@ -49,8 +49,11 @@ %% there will be clashes with logging processes etc). %%-------------------------------------------------------------------- init_per_suite(Config) -> - Config1 = ct_test_support:init_per_suite(Config), - Config1. + DataDir = ?config(data_dir,Config), + Hook = "fail_pre_init_per_suite.erl", + io:format("Compiling ~p: ~p~n", + [Hook, compile:file(Hook,[{outdir,DataDir},debug_info])]), + ct_test_support:init_per_suite([{path_dirs,[DataDir]}|Config]). end_per_suite(Config) -> ct_test_support:end_per_suite(Config). @@ -69,7 +72,8 @@ all() -> absolute_path, relative_path, url, - logdir + logdir, + fail_pre_init_per_suite ]. %%-------------------------------------------------------------------- @@ -107,6 +111,14 @@ logdir(Config) when is_list(Config) -> Path = "logdir.xml", run(logdir,[{cth_surefire,[{path,Path}]}],Path,Config,[{logdir,MyLogDir}]). +fail_pre_init_per_suite(Config) when is_list(Config) -> + DataDir = ?config(data_dir,Config), + Suites = [filename:join(DataDir,"pass_SUITE"), + filename:join(DataDir,"fail_SUITE")], + Path = "fail_pre_init_per_suite.xml", + run(fail_pre_init_per_suite,[fail_pre_init_per_suite, + {cth_surefire,[{path,Path}]}],Path,Config,[],Suites). + %%%----------------------------------------------------------------- %%% HELP FUNCTIONS %%%----------------------------------------------------------------- @@ -115,6 +127,8 @@ run(Case,CTHs,Report,Config) -> run(Case,CTHs,Report,Config,ExtraOpts) -> DataDir = ?config(data_dir, Config), Suite = filename:join(DataDir, "surefire_SUITE"), + run(Case,CTHs,Report,Config,ExtraOpts,Suite). +run(Case,CTHs,Report,Config,ExtraOpts,Suite) -> {Opts,ERPid} = setup([{suite,Suite},{ct_hooks,CTHs},{label,Case}|ExtraOpts], Config), ok = execute(Case, Opts, ERPid, Config), @@ -142,7 +156,6 @@ setup(Test, Config) -> execute(Name, Opts, ERPid, Config) -> ok = ct_test_support:run(Opts, Config), Events = ct_test_support:get_events(ERPid, Config), - ct_test_support:log_events(Name, reformat(Events, ?eh), ?config(priv_dir, Config), @@ -166,10 +179,30 @@ events_to_check(_, 0) -> events_to_check(Test, N) -> test_events(Test) ++ events_to_check(Test, N-1). -test_events(_) -> - [{?eh,start_logging,'_'}, - {?eh,start_info,{1,1,9}}, - {?eh,tc_start,{surefire_SUITE,init_per_suite}}, +test_suite_events(fail_SUITE, TestStat) -> + [{?eh,tc_start,{ct_framework,init_per_suite}}, + {?eh,tc_done,{ct_framework,init_per_suite, + {failed,{error,pre_init_per_suite}}}}, + {?eh,tc_auto_skip, + {fail_SUITE,test_case, + {failed,{ct_framework,init_per_suite,{failed,pre_init_per_suite}}}}}, + {?eh,test_stats,TestStat}, + {?eh,tc_auto_skip, + {ct_framework,end_per_suite, + {failed,{ct_framework,init_per_suite,{failed,pre_init_per_suite}}}}}]. + +test_suite_events(fail_SUITE) -> + test_suite_events(fail_SUITE, {0,0,{0,1}}); +test_suite_events(pass_SUITE) -> + [{?eh,tc_start,{ct_framework,init_per_suite}}, + {?eh,tc_done,{ct_framework,init_per_suite,ok}}, + {?eh,tc_start,{pass_SUITE,test_case}}, + {?eh,tc_done,{pass_SUITE,test_case,ok}}, + {?eh,test_stats,{1,0,{0,0}}}, + {?eh,tc_start,{ct_framework,end_per_suite}}, + {?eh,tc_done,{ct_framework,end_per_suite,ok}}]; +test_suite_events(_) -> + [{?eh,tc_start,{surefire_SUITE,init_per_suite}}, {?eh,tc_done,{surefire_SUITE,init_per_suite,ok}}, {?eh,tc_start,{surefire_SUITE,tc_ok}}, {?eh,tc_done,{surefire_SUITE,tc_ok,ok}}, @@ -216,9 +249,18 @@ test_events(_) -> {surefire_SUITE,init_per_group, {'EXIT',all_cases_should_be_skipped}}}}}], {?eh,tc_start,{surefire_SUITE,end_per_suite}}, - {?eh,tc_done,{surefire_SUITE,end_per_suite,ok}}, - {?eh,stop_logging,[]}]. - + {?eh,tc_done,{surefire_SUITE,end_per_suite,ok}}]. + +test_events(fail_pre_init_per_suite) -> + [{?eh,start_logging,{'DEF','RUNDIR'}}, + {?eh,start_info,{2,2,2}}] ++ + test_suite_events(pass_SUITE) ++ + test_suite_events(fail_SUITE, {1,0,{0,1}}) ++ + [{?eh,stop_logging,[]}]; +test_events(Test) -> + [{?eh,start_logging,'_'}, {?eh,start_info,{1,1,9}}] ++ + test_suite_events(Test) ++ + [{?eh,stop_logging,[]}]. %%%----------------------------------------------------------------- %%% Check generated xml log files @@ -251,9 +293,9 @@ do_check_xml(Case,[Xml|Xmls]) -> {E,_} = xmerl_scan:file(Xml), Expected = events_to_result(lists:flatten(test_events(Case))), ParseResult = testsuites(Case,E), - ct:log("Expecting: ~p~n",[[Expected]]), + ct:log("Expecting: ~p~n",[Expected]), ct:log("Actual : ~p~n",[ParseResult]), - [Expected] = ParseResult, + Expected = ParseResult, do_check_xml(Case,Xmls); do_check_xml(_,[]) -> ok. @@ -265,7 +307,8 @@ testsuites(Case,#xmlElement{name=testsuites,content=TS}) -> testsuite(Case,TS). testsuite(Case,[#xmlElement{name=testsuite,content=TC,attributes=A}|TS]) -> - {ET,EF,ES} = events_to_numbers(lists:flatten(test_events(Case))), + TestSuiteEvents = test_suite_events(get_ts_name(A)), + {ET,EF,ES} = events_to_numbers(lists:flatten(TestSuiteEvents)), {T,E,F,S} = get_numbers_from_attrs(A,false,false,false,false), ct:log("Expecting total:~p, error:~p, failure:~p, skipped:~p~n",[ET,0,EF,ES]), ct:log("Actual total:~p, error:~p, failure:~p, skipped:~p~n",[T,E,F,S]), @@ -318,14 +361,32 @@ failed_or_skipped([]) -> %% Testsuites = [Testsuite] %% Testsuite = [Testcase] %% Testcase = [] | [f] | [s], indicating ok, failed and skipped respectively -events_to_result([{?eh,tc_done,{_Suite,_Case,R}}|E]) -> - [result(R)|events_to_result(E)]; -events_to_result([{?eh,tc_auto_skip,_}|E]) -> - [[s]|events_to_result(E)]; -events_to_result([_|E]) -> - events_to_result(E); -events_to_result([]) -> - []. +events_to_result(E) -> + events_to_result(E, []). + +events_to_result([{?eh,tc_auto_skip,{_Suite,init_per_suite,_}}|E], Result) -> + {Suite,Rest} = events_to_result1(E), + events_to_result(Rest, [[[s]|Suite]|Result]); +events_to_result([{?eh,tc_done,{_Suite,init_per_suite,R}}|E], Result) -> + {Suite,Rest} = events_to_result1(E), + events_to_result(Rest, [[result(R)|Suite]|Result]); +events_to_result([_|E], Result) -> + events_to_result(E, Result); +events_to_result([], Result) -> + Result. + +events_to_result1([{?eh,tc_auto_skip,{_Suite, end_per_suite,_}}|E]) -> + {[[s]],E}; +events_to_result1([{?eh,tc_done,{_Suite, end_per_suite,R}}|E]) -> + {[result(R)],E}; +events_to_result1([{?eh,tc_done,{_Suite,_Case,R}}|E]) -> + {Suite,Rest} = events_to_result1(E), + {[result(R)|Suite],Rest}; +events_to_result1([{?eh,tc_auto_skip,_}|E]) -> + {Suite,Rest} = events_to_result1(E), + {[[s]|Suite],Rest}; +events_to_result1([_|E]) -> + events_to_result1(E). result(ok) ->[]; result({skipped,_}) -> [s]; @@ -374,3 +435,7 @@ del_files(Dir,[F0|Fs] ) -> end; del_files(_,[]) -> ok. + +get_ts_name(Attributes) -> + {_,name,_,_,_,_,_,_,Name,_} = lists:keyfind(name, 2, Attributes), + list_to_atom(Name). diff --git a/lib/common_test/test/ct_surefire_SUITE_data/fail_SUITE.erl b/lib/common_test/test/ct_surefire_SUITE_data/fail_SUITE.erl new file mode 100644 index 0000000000..3f5f42c054 --- /dev/null +++ b/lib/common_test/test/ct_surefire_SUITE_data/fail_SUITE.erl @@ -0,0 +1,28 @@ +%% %CopyrightBegin% +%% +%% Copyright Ericsson AB 2016. All Rights Reserved. +%% +%% Licensed under the Apache License, Version 2.0 (the "License"); +%% you may not use this file except in compliance with the License. +%% You may obtain a copy of the License at +%% +%% http://www.apache.org/licenses/LICENSE-2.0 +%% +%% Unless required by applicable law or agreed to in writing, software +%% distributed under the License is distributed on an "AS IS" BASIS, +%% WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +%% See the License for the specific language governing permissions and +%% limitations under the License. +%% +%% %CopyrightEnd% +%% +-module(fail_SUITE). +-include_lib("common_test/include/ct.hrl"). + +-export([all/0, test_case/1]). + +all() -> + [test_case]. + +test_case(_Config) -> + ok. diff --git a/lib/common_test/test/ct_surefire_SUITE_data/fail_pre_init_per_suite.erl b/lib/common_test/test/ct_surefire_SUITE_data/fail_pre_init_per_suite.erl new file mode 100644 index 0000000000..ff278db378 --- /dev/null +++ b/lib/common_test/test/ct_surefire_SUITE_data/fail_pre_init_per_suite.erl @@ -0,0 +1,47 @@ +%% +%% %CopyrightBegin% +%% +%% Copyright Ericsson AB 2016. All Rights Reserved. +%% +%% Licensed under the Apache License, Version 2.0 (the "License"); +%% you may not use this file except in compliance with the License. +%% You may obtain a copy of the License at +%% +%% http://www.apache.org/licenses/LICENSE-2.0 +%% +%% Unless required by applicable law or agreed to in writing, software +%% distributed under the License is distributed on an "AS IS" BASIS, +%% WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +%% See the License for the specific language governing permissions and +%% limitations under the License. +%% +%% %CopyrightEnd% +%% + +%%% This tests that the correct XML is produced when pre_init_per_suite +%%% fails in a hook +-module(fail_pre_init_per_suite). + +%% CT Hooks +-export([init/2, pre_init_per_suite/3]). + +-type config() :: proplists:proplist(). +-type reason() :: term(). +-type skip_or_fail() :: skip | auto_skip | fail | 'EXIT'. + +-record(state, {}). + +-spec init(Id :: term(), Opts :: proplists:proplist()) -> + {ok, proplists:proplist()}. +init(_Id, Opts) -> + {ok, Opts}. + +-spec pre_init_per_suite(Suite :: atom(), + Config :: config(), + State :: #state{}) -> + {config() | {skip_or_fail(), reason()}, NewState :: #state{}}. +pre_init_per_suite(fail_SUITE, _Config, State) -> + {{fail, pre_init_per_suite}, State}; +pre_init_per_suite(_Suite, Config, State) -> + {Config, State}. + diff --git a/lib/common_test/test/ct_surefire_SUITE_data/pass_SUITE.erl b/lib/common_test/test/ct_surefire_SUITE_data/pass_SUITE.erl new file mode 100644 index 0000000000..74ed5b730e --- /dev/null +++ b/lib/common_test/test/ct_surefire_SUITE_data/pass_SUITE.erl @@ -0,0 +1,28 @@ +%% %CopyrightBegin% +%% +%% Copyright Ericsson AB 2016. All Rights Reserved. +%% +%% Licensed under the Apache License, Version 2.0 (the "License"); +%% you may not use this file except in compliance with the License. +%% You may obtain a copy of the License at +%% +%% http://www.apache.org/licenses/LICENSE-2.0 +%% +%% Unless required by applicable law or agreed to in writing, software +%% distributed under the License is distributed on an "AS IS" BASIS, +%% WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +%% See the License for the specific language governing permissions and +%% limitations under the License. +%% +%% %CopyrightEnd% +%% +-module(pass_SUITE). +-include_lib("common_test/include/ct.hrl"). + +-export([all/0, test_case/1]). + +all() -> + [test_case]. + +test_case(_Config) -> + ok. diff --git a/lib/common_test/test/ct_test_support.erl b/lib/common_test/test/ct_test_support.erl index 51ca691d69..477fcb8a26 100644 --- a/lib/common_test/test/ct_test_support.erl +++ b/lib/common_test/test/ct_test_support.erl @@ -43,6 +43,8 @@ -export([random_error/1]). +-export([unique_timestamp/0]). + -include_lib("kernel/include/file.hrl"). %%%----------------------------------------------------------------- @@ -110,7 +112,8 @@ start_slave(NodeName, Config, Level) -> undefined -> []; Ds -> Ds end, - PathDirs = [PrivDir,TSDir | AddPathDirs], + TestSupDir = filename:dirname(code:which(?MODULE)), + PathDirs = [PrivDir,TSDir,TestSupDir | AddPathDirs], [true = rpc:call(CTNode, code, add_patha, [D]) || D <- PathDirs], test_server:format(Level, "Dirs added to code path (on ~w):~n", [CTNode]), @@ -1430,7 +1433,21 @@ rm_files([F | Fs]) -> end; rm_files([]) -> ok. - + +unique_timestamp() -> + unique_timestamp(os:timestamp(), 100000). + +unique_timestamp(TS, 0) -> + TS; +unique_timestamp(TS0, N) -> + case os:timestamp() of + TS0 -> + timer:sleep(1), + unique_timestamp(TS0, N-1); + TS1 -> + TS1 + end. + %%%----------------------------------------------------------------- %%% slave_stop(Node) -> diff --git a/lib/compiler/src/v3_kernel.erl b/lib/compiler/src/v3_kernel.erl index 4a6330fce4..402e3c4912 100644 --- a/lib/compiler/src/v3_kernel.erl +++ b/lib/compiler/src/v3_kernel.erl @@ -1,7 +1,7 @@ %% %% %CopyrightBegin% %% -%% Copyright Ericsson AB 1999-2015. All Rights Reserved. +%% Copyright Ericsson AB 1999-2016. All Rights Reserved. %% %% Licensed under the Apache License, Version 2.0 (the "License"); %% you may not use this file except in compliance with the License. @@ -147,6 +147,7 @@ include_attribute(callback) -> false; include_attribute(opaque) -> false; include_attribute(export_type) -> false; include_attribute(record) -> false; +include_attribute(optional_callbacks) -> false; include_attribute(_) -> true. function({#c_var{name={F,Arity}=FA},Body}, St0) -> diff --git a/lib/dialyzer/README b/lib/dialyzer/README index 82d0f5ec48..951a92469b 100644 --- a/lib/dialyzer/README +++ b/lib/dialyzer/README @@ -6,7 +6,7 @@ ## Copyright: Held by the authors; all rights reserved (2004 - 2010). ##---------------------------------------------------------------------------- -The DIALYZER, a DIscrepany AnaLYZer for ERlang programs. +The DIALYZER, a DIscrepancy AnaLYZer for ERlang programs. ----------------------------------------------- diff --git a/lib/dialyzer/doc/about.txt b/lib/dialyzer/doc/about.txt index 7d9d819731..1318d9a65e 100644 --- a/lib/dialyzer/doc/about.txt +++ b/lib/dialyzer/doc/about.txt @@ -1,5 +1,5 @@ This is DIALYZER version 2.1.0 - DIALYZER is a DIscrepany AnaLYZer for ERlang programs. + DIALYZER is a DIscrepancy AnaLYZer for ERlang programs. Copyright (C) Tobias Lindahl <[email protected]> Kostis Sagonas <[email protected]> diff --git a/lib/dialyzer/doc/manual.txt b/lib/dialyzer/doc/manual.txt index 29c9518d84..be1fd2f8bc 100644 --- a/lib/dialyzer/doc/manual.txt +++ b/lib/dialyzer/doc/manual.txt @@ -4,7 +4,7 @@ ## Kostis Sagonas <[email protected]> ##---------------------------------------------------------------------------- -The DIALYZER, a DIscrepany AnaLYZer for ERlang programs. +The DIALYZER, a DIscrepancy AnaLYZer for ERlang programs. ----------------------------------------------- diff --git a/lib/dialyzer/info b/lib/dialyzer/info index 9fba4b54ad..b9ea26b712 100644 --- a/lib/dialyzer/info +++ b/lib/dialyzer/info @@ -1,2 +1,2 @@ group: tools -short: The DIALYZER, a DIscrepany AnaLYZer for ERlang programs. +short: The DIALYZER, a DIscrepancy AnaLYZer for ERlang programs. diff --git a/lib/dialyzer/src/dialyzer.app.src b/lib/dialyzer/src/dialyzer.app.src index 003d7f2ba4..5b28f7ae86 100644 --- a/lib/dialyzer/src/dialyzer.app.src +++ b/lib/dialyzer/src/dialyzer.app.src @@ -2,7 +2,7 @@ %% %% %CopyrightBegin% %% -%% Copyright Ericsson AB 2006-2015. All Rights Reserved. +%% Copyright Ericsson AB 2006-2016. All Rights Reserved. %% %% Licensed under the Apache License, Version 2.0 (the "License"); %% you may not use this file except in compliance with the License. @@ -47,6 +47,6 @@ {registered, []}, {applications, [compiler, hipe, kernel, stdlib, wx]}, {env, []}, - {runtime_dependencies, ["wx-1.2","syntax_tools-1.6.14","stdlib-2.5", - "kernel-3.0","hipe-3.13","erts-7.0", - "compiler-5.0"]}]}. + {runtime_dependencies, ["wx-1.2","syntax_tools-2.0","stdlib-3.0", + "kernel-5.0","hipe-3.15.1","erts-8.0", + "compiler-7.0"]}]}. diff --git a/lib/dialyzer/src/dialyzer_contracts.erl b/lib/dialyzer/src/dialyzer_contracts.erl index 1895a98e96..116260778c 100644 --- a/lib/dialyzer/src/dialyzer_contracts.erl +++ b/lib/dialyzer/src/dialyzer_contracts.erl @@ -210,10 +210,10 @@ check_contract(Contract, SuccType) -> check_contract(#contract{contracts = Contracts}, SuccType, Opaques) -> try - Contracts1 = [{Contract, insert_constraints(Constraints, dict:new())} + Contracts1 = [{Contract, insert_constraints(Constraints)} || {Contract, Constraints} <- Contracts], - Contracts2 = [erl_types:t_subst(Contract, Dict) - || {Contract, Dict} <- Contracts1], + Contracts2 = [erl_types:t_subst(Contract, Map) + || {Contract, Map} <- Contracts1], GenDomains = [erl_types:t_fun_args(C) || C <- Contracts2], case check_domains(GenDomains) of error -> @@ -344,15 +344,15 @@ process_contract({Contract, Constraints}, CallTypes0) -> [erl_types:t_to_string(ContArgsFun), erl_types:t_to_string(CallTypesFun)]), case solve_constraints(ContArgsFun, CallTypesFun, Constraints) of - {ok, VarDict} -> - {ok, erl_types:t_subst(erl_types:t_fun_range(Contract), VarDict)}; + {ok, VarMap} -> + {ok, erl_types:t_subst(erl_types:t_fun_range(Contract), VarMap)}; error -> error end. solve_constraints(Contract, Call, Constraints) -> %% First make sure the call follows the constraints - CDict = insert_constraints(Constraints, dict:new()), - Contract1 = erl_types:t_subst(Contract, CDict), + CMap = insert_constraints(Constraints), + Contract1 = erl_types:t_subst(Contract, CMap), %% Just a safe over-approximation. %% TODO: Find the types for type variables properly ContrArgs = erl_types:t_fun_args(Contract1), @@ -360,7 +360,7 @@ solve_constraints(Contract, Call, Constraints) -> InfList = erl_types:t_inf_lists(ContrArgs, CallArgs), case erl_types:any_none_or_unit(InfList) of true -> error; - false -> {ok, CDict} + false -> {ok, CMap} end. %%Inf = erl_types:t_inf(Contract1, Call), %% Then unify with the constrained call type. @@ -390,23 +390,26 @@ warn_spec_missing_fun({M, F, A} = MFA, Contracts) -> {?WARN_CONTRACT_SYNTAX, WarningInfo, {spec_missing_fun, [M, F, A]}}. %% This treats the "when" constraints. It will be extended, we hope. -insert_constraints([{subtype, Type1, Type2}|Left], Dict) -> +insert_constraints(Constraints) -> + insert_constraints(Constraints, maps:new()). + +insert_constraints([{subtype, Type1, Type2}|Left], Map) -> case erl_types:t_is_var(Type1) of true -> Name = erl_types:t_var_name(Type1), - Dict1 = case dict:find(Name, Dict) of - error -> - dict:store(Name, Type2, Dict); - {ok, VarType} -> - dict:store(Name, erl_types:t_inf(VarType, Type2), Dict) - end, - insert_constraints(Left, Dict1); + Map1 = case maps:find(Name, Map) of + error -> + maps:put(Name, Type2, Map); + {ok, VarType} -> + maps:put(Name, erl_types:t_inf(VarType, Type2), Map) + end, + insert_constraints(Left, Map1); false -> %% A lot of things should change to add supertypes throw({error, io_lib:format("First argument of is_subtype constraint " "must be a type variable: ~p\n", [Type1])}) end; -insert_constraints([], Dict) -> Dict. +insert_constraints([], Map) -> Map. -type types() :: erl_types:type_table(). @@ -476,7 +479,7 @@ initialize_constraints([], _MFA, _RecDict, _ExpTypes, _AllRecords, Acc) -> initialize_constraints([Constr|Rest], MFA, RecDict, ExpTypes, AllRecords, Acc) -> case Constr of {type, _, constraint, [{atom, _, is_subtype}, [Type1, Type2]]} -> - T1 = final_form(Type1, ExpTypes, MFA, AllRecords, dict:new()), + T1 = final_form(Type1, ExpTypes, MFA, AllRecords, maps:new()), Entry = {T1, Type2}, initialize_constraints(Rest, MFA, RecDict, ExpTypes, AllRecords, [Entry|Acc]); {type, _, constraint, [{atom,_,Name}, List]} -> @@ -487,7 +490,7 @@ initialize_constraints([Constr|Rest], MFA, RecDict, ExpTypes, AllRecords, Acc) - constraints_fixpoint(Constrs, MFA, RecDict, ExpTypes, AllRecords) -> VarDict = - constraints_to_dict(Constrs, MFA, RecDict, ExpTypes, AllRecords, dict:new()), + constraints_to_dict(Constrs, MFA, RecDict, ExpTypes, AllRecords, maps:new()), constraints_fixpoint(VarDict, MFA, Constrs, RecDict, ExpTypes, AllRecords). constraints_fixpoint(OldVarDict, MFA, Constrs, RecDict, ExpTypes, AllRecords) -> @@ -499,7 +502,7 @@ constraints_fixpoint(OldVarDict, MFA, Constrs, RecDict, ExpTypes, AllRecords) -> fun(Key, Value, Acc) -> [{subtype, erl_types:t_var(Key), Value}|Acc] end, - FinalConstrs = dict:fold(DictFold, [], NewVarDict), + FinalConstrs = maps:fold(DictFold, [], NewVarDict), {FinalConstrs, NewVarDict}; _Other -> constraints_fixpoint(NewVarDict, MFA, Constrs, RecDict, ExpTypes, AllRecords) @@ -509,7 +512,7 @@ final_form(Form, ExpTypes, MFA, AllRecords, VarDict) -> from_form_with_check(Form, ExpTypes, MFA, AllRecords, VarDict). from_form_with_check(Form, ExpTypes, MFA, AllRecords) -> - from_form_with_check(Form, ExpTypes, MFA, AllRecords, dict:new()). + from_form_with_check(Form, ExpTypes, MFA, AllRecords, maps:new()). from_form_with_check(Form, ExpTypes, MFA, AllRecords, VarDict) -> Site = {spec, MFA}, @@ -520,7 +523,7 @@ from_form_with_check(Form, ExpTypes, MFA, AllRecords, VarDict) -> constraints_to_dict(Constrs, MFA, RecDict, ExpTypes, AllRecords, VarDict) -> Subtypes = constraints_to_subs(Constrs, MFA, RecDict, ExpTypes, AllRecords, VarDict, []), - insert_constraints(Subtypes, dict:new()). + insert_constraints(Subtypes). constraints_to_subs([], _MFA, _RecDict, _ExpTypes, _AllRecords, _VarDict, Acc) -> Acc; @@ -605,8 +608,8 @@ general_domain(List) -> general_domain(List, erl_types:t_none()). general_domain([{Sig, Constraints}|Left], AccSig) -> - Dict = insert_constraints(Constraints, dict:new()), - Sig1 = erl_types:t_subst(Sig, Dict), + Map = insert_constraints(Constraints), + Sig1 = erl_types:t_subst(Sig, Map), general_domain(Left, erl_types:t_sup(AccSig, Sig1)); general_domain([], AccSig) -> %% Get rid of all variables in the domain. diff --git a/lib/dialyzer/src/dialyzer_dataflow.erl b/lib/dialyzer/src/dialyzer_dataflow.erl index f0fa9fbb4e..5ab0c39c04 100644 --- a/lib/dialyzer/src/dialyzer_dataflow.erl +++ b/lib/dialyzer/src/dialyzer_dataflow.erl @@ -2,7 +2,7 @@ %%-------------------------------------------------------------------- %% %CopyrightBegin% %% -%% Copyright Ericsson AB 2006-2015. All Rights Reserved. +%% Copyright Ericsson AB 2006-2016. All Rights Reserved. %% %% Licensed under the Apache License, Version 2.0 (the "License"); %% you may not use this file except in compliance with the License. @@ -43,7 +43,6 @@ -include("dialyzer.hrl"). -%%-import(helper, %% 'helper' could be any module doing sanity checks... -import(erl_types, [t_inf/2, t_inf/3, t_inf_lists/2, t_inf_lists/3, t_inf_lists/3, t_is_equal/2, t_is_subtype/2, t_subtract/2, @@ -126,8 +125,8 @@ curr_fun :: curr_fun() }). --record(map, {dict = dict:new() :: type_tab(), - subst = dict:new() :: subst_tab(), +-record(map, {map = maps:new() :: type_tab(), + subst = maps:new() :: subst_tab(), modified = [] :: [Key :: term()], modified_stack = [] :: [{[Key :: term()],reference()}], ref = undefined :: reference() | undefined}). @@ -135,10 +134,10 @@ -type env_tab() :: dict:dict(label(), #map{}). -type fun_entry() :: {Args :: [type()], RetType :: type()}. -type fun_tab() :: dict:dict('top' | label(), - {'not_handled', fun_entry()} | fun_entry()). + {'not_handled', fun_entry()} | fun_entry()). -type key() :: label() | cerl:cerl(). --type type_tab() :: dict:dict(key(), type()). --type subst_tab() :: dict:dict(key(), cerl:cerl()). +-type type_tab() :: #{key() => type()}. +-type subst_tab() :: #{key() => cerl:cerl()}. %% Exported Types @@ -1766,7 +1765,7 @@ bind_opaque_pats(GenType, Type, Pat, State) -> %% bind_guard(Guard, Map, State) -> - try bind_guard(Guard, Map, dict:new(), pos, State) of + try bind_guard(Guard, Map, maps:new(), pos, State) of {Map1, _Type} -> Map1 catch throw:{fail, Warning} -> {error, Warning}; @@ -1804,7 +1803,7 @@ bind_guard(Guard, Map, Env, Eval, State) -> catch throw:HE -> {{Map2, t_none()}, HE} end, - BodyEnv = dict:store(get_label(Var), Arg, Env), + BodyEnv = maps:put(get_label(Var), Arg, Env), Wanted = case Eval of pos -> t_atom(true); neg -> t_atom(false); dont_know -> t_any() end, case t_is_none(t_inf(HandlerType, Wanted)) of @@ -1850,7 +1849,7 @@ bind_guard(Guard, Map, Env, Eval, State) -> Arg = cerl:let_arg(Guard), [Var] = cerl:let_vars(Guard), %%?debug("Storing: ~w\n", [Var]), - NewEnv = dict:store(get_label(Var), Arg, Env), + NewEnv = maps:put(get_label(Var), Arg, Env), bind_guard(cerl:let_body(Guard), Map, NewEnv, Eval, State); values -> Es = cerl:values_es(Guard), @@ -1859,7 +1858,7 @@ bind_guard(Guard, Map, Env, Eval, State) -> {Map, Type}; var -> ?debug("Looking for var(~w)...", [cerl_trees:get_label(Guard)]), - case dict:find(get_label(Guard), Env) of + case maps:find(get_label(Guard), Env) of error -> ?debug("Did not find it\n", []), Type = lookup_type(Guard, Map), @@ -2689,10 +2688,10 @@ join_maps_end(Maps, MapOut) -> #map{ref = Ref, modified_stack = [{M1,R1} | S]} = MapOut, true = lists:all(fun(M) -> M#map.ref =:= Ref end, Maps), % sanity Keys0 = lists:usort(lists:append([M#map.modified || M <- Maps])), - #map{dict = Dict, subst = Subst} = MapOut, + #map{map = Map, subst = Subst} = MapOut, Keys = [Key || Key <- Keys0, - dict:is_key(Key, Dict) orelse dict:is_key(Key, Subst)], + maps:is_key(Key, Map) orelse maps:is_key(Key, Subst)], Out = case Maps of [] -> join_maps(Maps, MapOut); _ -> join_maps(Keys, Maps, MapOut) @@ -2703,8 +2702,8 @@ join_maps_end(Maps, MapOut) -> modified_stack = S}. join_maps(Maps, MapOut) -> - #map{dict = Dict, subst = Subst} = MapOut, - Keys = ordsets:from_list(dict:fetch_keys(Dict) ++ dict:fetch_keys(Subst)), + #map{map = Map, subst = Subst} = MapOut, + Keys = ordsets:from_list(maps:keys(Map) ++ maps:keys(Subst)), join_maps(Keys, Maps, MapOut). join_maps(Keys, Maps, MapOut) -> @@ -2733,11 +2732,11 @@ join_maps_one_key([], _Key, AccType) -> -ifdef(DEBUG). debug_join_check(Maps, MapOut, Out) -> - #map{dict = Dict, subst = Subst} = Out, - #map{dict = Dict2, subst = Subst2} = join_maps(Maps, MapOut), - F = fun(D) -> lists:keysort(1, dict:to_list(D)) end, + #map{map = Map, subst = Subst} = Out, + #map{map = Map2, subst = Subst2} = join_maps(Maps, MapOut), + F = fun(D) -> lists:keysort(1, maps:to_list(D)) end, [throw({bug, join_maps}) || - F(Dict) =/= F(Dict2) orelse F(Subst) =/= F(Subst2)]. + F(Map) =/= F(Map2) orelse F(Subst) =/= F(Subst2)]. -else. debug_join_check(_Maps, _MapOut, _Out) -> ok. -endif. @@ -2768,15 +2767,15 @@ enter_type(Key, Val, MS) -> enter_type_lists(Keys, t_to_tlist(Val), MS) end; false -> - #map{dict = Dict, subst = Subst} = MS, + #map{map = Map, subst = Subst} = MS, KeyLabel = get_label(Key), - case dict:find(KeyLabel, Subst) of + case maps:find(KeyLabel, Subst) of {ok, NewKey} -> ?debug("Binding ~p to ~p\n", [KeyLabel, NewKey]), enter_type(NewKey, Val, MS); error -> ?debug("Entering ~p :: ~s\n", [KeyLabel, t_to_string(Val)]), - case dict:find(KeyLabel, Dict) of + case maps:find(KeyLabel, Map) of {ok, Value} -> case erl_types:t_is_equal(Val, Value) of true -> MS; @@ -2788,10 +2787,10 @@ enter_type(Key, Val, MS) -> end end. -store_map(Key, Val, #map{dict = Dict, ref = undefined} = Map) -> - Map#map{dict = dict:store(Key, Val, Dict)}; -store_map(Key, Val, #map{dict = Dict, modified = Mod} = Map) -> - Map#map{dict = dict:store(Key, Val, Dict), modified = [Key | Mod]}. +store_map(Key, Val, #map{map = Map, ref = undefined} = MapRec) -> + MapRec#map{map = maps:put(Key, Val, Map)}; +store_map(Key, Val, #map{map = Map, modified = Mod} = MapRec) -> + MapRec#map{map = maps:put(Key, Val, Map), modified = [Key | Mod]}. enter_subst(Key, Val0, #map{subst = Subst} = MS) -> KeyLabel = get_label(Key), @@ -2804,7 +2803,7 @@ enter_subst(Key, Val0, #map{subst = Subst} = MS) -> false -> MS; true -> ValLabel = get_label(Val), - case dict:find(ValLabel, Subst) of + case maps:find(ValLabel, Subst) of {ok, NewVal} -> enter_subst(Key, NewVal, MS); error -> @@ -2818,22 +2817,22 @@ enter_subst(Key, Val0, #map{subst = Subst} = MS) -> end. store_subst(Key, Val, #map{subst = S, ref = undefined} = Map) -> - Map#map{subst = dict:store(Key, Val, S)}; + Map#map{subst = maps:put(Key, Val, S)}; store_subst(Key, Val, #map{subst = S, modified = Mod} = Map) -> - Map#map{subst = dict:store(Key, Val, S), modified = [Key | Mod]}. + Map#map{subst = maps:put(Key, Val, S), modified = [Key | Mod]}. -lookup_type(Key, #map{dict = Dict, subst = Subst}) -> - lookup(Key, Dict, Subst, t_none()). +lookup_type(Key, #map{map = Map, subst = Subst}) -> + lookup(Key, Map, Subst, t_none()). -lookup(Key, Dict, Subst, AnyNone) -> +lookup(Key, Map, Subst, AnyNone) -> case cerl:is_literal(Key) of true -> literal_type(Key); false -> Label = get_label(Key), - case dict:find(Label, Subst) of - {ok, NewKey} -> lookup(NewKey, Dict, Subst, AnyNone); + case maps:find(Label, Subst) of + {ok, NewKey} -> lookup(NewKey, Map, Subst, AnyNone); error -> - case dict:find(Label, Dict) of + case maps:find(Label, Map) of {ok, Val} -> Val; error -> AnyNone end @@ -2871,12 +2870,12 @@ mark_as_fresh([], Map) -> Map. -ifdef(DEBUG). -debug_pp_map(#map{dict = Dict}=Map) -> - Keys = dict:fetch_keys(Dict), +debug_pp_map(#map{map = Map}=MapRec) -> + Keys = maps:keys(Map), io:format("Map:\n", []), lists:foreach(fun (Key) -> io:format("\t~w :: ~s\n", - [Key, t_to_string(lookup_type(Key, Map))]) + [Key, t_to_string(lookup_type(Key, MapRec))]) end, Keys), ok. -else. diff --git a/lib/dialyzer/src/dialyzer_gui_wx.erl b/lib/dialyzer/src/dialyzer_gui_wx.erl index 9f344d87ff..30d2bdeca4 100644 --- a/lib/dialyzer/src/dialyzer_gui_wx.erl +++ b/lib/dialyzer/src/dialyzer_gui_wx.erl @@ -422,7 +422,7 @@ gui_loop(#gui_state{backend_pid = BackendPid, doc_plt = DocPlt, #wx{id=?menuID_HELP_ABOUT, obj=Frame, event=#wxCommand{type=command_menu_selected}} -> Message = " This is DIALYZER version " ++ ?VSN ++ " \n"++ - "DIALYZER is a DIscrepany AnaLYZer for ERlang programs.\n\n"++ + "DIALYZER is a DIscrepancy AnaLYZer for ERlang programs.\n\n"++ " Copyright (C) Tobias Lindahl <[email protected]>\n"++ " Kostis Sagonas <[email protected]>\n\n", output_sms(State, "About Dialyzer", Message, info), diff --git a/lib/dialyzer/src/dialyzer_typesig.erl b/lib/dialyzer/src/dialyzer_typesig.erl index 50fcbc555b..1787b66192 100644 --- a/lib/dialyzer/src/dialyzer_typesig.erl +++ b/lib/dialyzer/src/dialyzer_typesig.erl @@ -2,7 +2,7 @@ %%----------------------------------------------------------------------- %% %CopyrightBegin% %% -%% Copyright Ericsson AB 2006-2015. All Rights Reserved. +%% Copyright Ericsson AB 2006-2016. All Rights Reserved. %% %% Licensed under the Apache License, Version 2.0 (the "License"); %% you may not use this file except in compliance with the License. @@ -66,9 +66,11 @@ %%----------------------------------------------------------------------------- -type dep() :: integer(). %% type variable names used as constraint ids +-type deps() :: ordsets:ordset(dep()). + -type type_var() :: erl_types:erl_type(). %% actually: {'c','var',_,_} --record(fun_var, {'fun' :: fun((_) -> erl_types:erl_type()), deps :: [dep()], +-record(fun_var, {'fun' :: fun((_) -> erl_types:erl_type()), deps :: deps(), origin :: integer() | 'undefined'}). -type constr_op() :: 'eq' | 'sub'. @@ -77,20 +79,21 @@ -record(constraint, {lhs :: erl_types:erl_type(), op :: constr_op(), rhs :: fvar_or_type(), - deps :: [dep()]}). + deps :: deps()}). -type constraint() :: #constraint{}. +-type mask() :: ordsets:ordset(non_neg_integer()). + -record(constraint_list, {type :: 'conj' | 'disj', list :: [constr()], - deps :: [dep()], - masks = [] :: [{dep(),[non_neg_integer()]}] | - {'d',dict:dict(dep(), [non_neg_integer()])}, + deps :: deps(), + masks = maps:new() :: #{dep() => mask()}, id :: {'list', dep()} | 'undefined'}). -type constraint_list() :: #constraint_list{}. --record(constraint_ref, {id :: type_var(), deps :: [dep()]}). +-record(constraint_ref, {id :: type_var(), deps :: deps()}). -type constraint_ref() :: #constraint_ref{}. @@ -99,32 +102,29 @@ -type types() :: erl_types:type_table(). -type typesig_scc() :: [{mfa(), {cerl:c_var(), cerl:c_fun()}, types()}]. --type typesig_funmap() :: [{type_var(), type_var()}]. %% Orddict +-type typesig_funmap() :: #{type_var() => type_var()}. -type prop_types() :: dict:dict(label(), types()). --type dict_or_ets() :: {'d', prop_types()} | {'e', ets:tid()}. - --record(state, {callgraph :: dialyzer_callgraph:callgraph() - | 'undefined', - cs = [] :: [constr()], - cmap = {'d', dict:new()} :: dict_or_ets(), - fun_map = [] :: typesig_funmap(), - fun_arities = dict:new() :: dict:dict(type_var(), arity()), - in_match = false :: boolean(), - in_guard = false :: boolean(), - module :: module(), - name_map = dict:new() :: dict:dict(mfa(), - cerl:c_fun()), - next_label = 0 :: label(), - self_rec :: 'false' | erl_types:erl_type(), - plt :: dialyzer_plt:plt() - | 'undefined', - prop_types = {'d', dict:new()} :: dict_or_ets(), - records = dict:new() :: types(), - scc = [] :: [type_var()], - mfas :: [tuple()], - solvers = [] :: [solver()] +-record(state, {callgraph :: dialyzer_callgraph:callgraph() + | 'undefined', + cs = [] :: [constr()], + cmap = maps:new() :: #{type_var() => constr()}, + fun_map = maps:new() :: typesig_funmap(), + fun_arities = maps:new() :: #{type_var() => arity()}, + in_match = false :: boolean(), + in_guard = false :: boolean(), + module :: module(), + name_map = maps:new() :: #{mfa() => cerl:c_fun()}, + next_label = 0 :: label(), + self_rec :: 'false' | erl_types:erl_type(), + plt :: dialyzer_plt:plt() + | 'undefined', + prop_types = dict:new() :: prop_types(), + records = dict:new() :: types(), + scc = [] :: ordsets:ordset(type_var()), + mfas :: [mfa()], + solvers = [] :: [solver()] }). -type state() :: #state{}. @@ -190,7 +190,8 @@ analyze_scc(SCC, NextLabel, CallGraph, Plt, PropTypes, Solvers0) -> Funs = state__scc(State3), pp_constrs_scc(Funs, State3), constraints_to_dot_scc(Funs, State3), - solve(Funs, State3). + T = solve(Funs, State3), + dict:from_list(maps:to_list(T)). assert_format_of_scc([{_MFA, {_Var, _Fun}, _Records}|Left]) -> assert_format_of_scc(Left); @@ -944,11 +945,11 @@ get_safe_underapprox(Pats, Guard) -> Map1 = cerl_trees:fold(fun(X, Acc) -> case cerl:is_c_var(X) of true -> - dict:store(cerl_trees:get_label(X), t_any(), - Acc); + maps:put(cerl_trees:get_label(X), t_any(), + Acc); false -> Acc end - end, dict:new(), cerl:c_values(Pats)), + end, maps:new(), cerl:c_values(Pats)), {Type, Map2} = get_underapprox_from_guard(Guard, Map1), Map3 = case t_is_none(t_inf(t_from_term(true), Type)) of true -> throw(dont_know); @@ -956,8 +957,8 @@ get_safe_underapprox(Pats, Guard) -> case cerl:is_c_var(Guard) of false -> Map2; true -> - dict:store(cerl_trees:get_label(Guard), - t_from_term(true), Map2) + maps:put(cerl_trees:get_label(Guard), + t_from_term(true), Map2) end end, {Ts, _Map4} = get_safe_underapprox_1(Pats, [], Map3), @@ -983,7 +984,7 @@ get_underapprox_from_guard(Tree, Map) -> case t_is_none(Inf) of true -> throw(dont_know); false -> - {True, dict:store(cerl_trees:get_label(Fun), Inf, Map1)} + {True, maps:put(cerl_trees:get_label(Fun), Inf, Map1)} end end; MFA -> @@ -999,7 +1000,7 @@ get_underapprox_from_guard(Tree, Map) -> case cerl:is_literal(Arg) of true -> {True, Map1}; false -> - {True, dict:store(cerl_trees:get_label(Arg), Inf, Map1)} + {True, maps:put(cerl_trees:get_label(Arg), Inf, Map1)} end end; error -> @@ -1031,7 +1032,7 @@ get_underapprox_from_guard(Tree, Map) -> end; var -> Type = - case dict:find(cerl_trees:get_label(Tree), Map) of + case maps:find(cerl_trees:get_label(Tree), Map) of error -> throw(dont_know); {ok, T} -> T end, @@ -1135,7 +1136,7 @@ get_safe_underapprox_1([Pat0|Left], Acc, Map) -> case t_is_none(Inf) of true -> throw(dont_know); false -> - Map3 = dict:store(cerl_trees:get_label(AVar), Inf, Map2), + Map3 = maps:put(cerl_trees:get_label(AVar), Inf, Map2), get_safe_underapprox_1(Left, [Inf|Acc], Map3) end; binary -> @@ -1203,7 +1204,7 @@ get_safe_underapprox_1([Pat0|Left], Acc, Map) -> Type = t_product(Ts), get_safe_underapprox_1(Left, [Type|Acc], Map1); var -> - case dict:find(cerl_trees:get_label(Pat), Map) of + case maps:find(cerl_trees:get_label(Pat), Map) of error -> throw(dont_know); {ok, VarType} -> get_safe_underapprox_1(Left, [VarType|Acc], Map) end @@ -1802,12 +1803,16 @@ solve([Fun], State) -> solve([_|_] = SCC, State) -> ?debug("============ Analyzing SCC: ~w ===========\n", [[debug_lookup_name(F) || F <- SCC]]), - {Parallel, NewState} = - case parallel_split(SCC) of - false -> {false, State}; - SplitSCC -> {SplitSCC, minimize_state(State)} - end, - solve_scc(SCC, Parallel, map_new(), NewState, false). + Users = comp_users(SCC, State), + solve_scc(SCC, map_new(), State, Users, _ToSolve=SCC, false). + +comp_users(SCC, State) -> + Vars0 = [{Fun, state__get_rec_var(Fun, State)} || Fun <- SCC], + Vars = lists:sort([t_var_name(Var) || {_, {ok, Var}} <- Vars0]), + family([{t_var(V), F} || + F <- SCC, + V <- ordsets:intersection(get_deps(state__get_cs(F, State)), + Vars)]). solve_fun(Fun, FunMap, State) -> Cs = state__get_cs(Fun, State), @@ -1822,7 +1827,7 @@ solve_fun(Fun, FunMap, State) -> end, enter_type(Fun, NewType, NewFunMap1). -solve_scc(SCC, Parallel, Map, State, TryingUnit) -> +solve_scc(SCC, Map, State, Users, ToSolve, TryingUnit) -> Vars0 = [{Fun, state__get_rec_var(Fun, State)} || Fun <- SCC], Vars = [Var || {_, {ok, Var}} <- Vars0], Funs = [Fun || {Fun, {ok, _}} <- Vars0], @@ -1830,16 +1835,13 @@ solve_scc(SCC, Parallel, Map, State, TryingUnit) -> RecTypes = [t_limit(Type, ?TYPE_LIMIT) || Type <- Types], CleanMap = lists:foldl(fun(Fun, AccFunMap) -> erase_type(t_var_name(Fun), AccFunMap) - end, Map, SCC), + end, Map, ToSolve), Map1 = enter_type_lists(Vars, RecTypes, CleanMap), ?debug("Checking SCC: ~w\n", [[debug_lookup_name(F) || F <- SCC]]), - FunSet = ordsets:from_list([t_var_name(F) || F <- SCC]), - Map2 = - case Parallel of - false -> solve_whole_scc(SCC, Map1, State); - SplitSCC -> solve_whole_scc_parallel(SplitSCC, Map1, State) - end, - case maps_are_equal(Map2, Map, FunSet) of + SolveFun = fun(X, Y) -> scc_fold_fun(X, Y, State) end, + Map2 = lists:foldl(SolveFun, Map1, ToSolve), + Updated = updated_vars_only(Vars, Map, Map2), + case Updated =:= [] of true -> ?debug("SCC ~w reached fixpoint\n", [SCC]), NewTypes = unsafe_lookup_type_list(Funs, Map2), @@ -1852,130 +1854,21 @@ solve_scc(SCC, Parallel, Map, State, TryingUnit) -> true -> t_fun(t_fun_args(T), t_unit()) end || T <- NewTypes], Map3 = enter_type_lists(Funs, UnitTypes, Map2), - solve_scc(SCC, Parallel, Map3, State, true); + solve_scc(SCC, Map3, State, Users, SCC, true); false -> - case Parallel of - false -> true; - _ -> dispose_state(State) - end, Map2 end; false -> ?debug("SCC ~w did not reach fixpoint\n", [SCC]), - solve_scc(SCC, Parallel, Map2, State, TryingUnit) + ToSolve1 = affected(Updated, Users), + solve_scc(SCC, Map2, State, Users, ToSolve1, TryingUnit) end. -solve_whole_scc(SCC, Map, State) -> - SolveFun = fun(X, Y) -> scc_fold_fun(X, Y, State) end, - lists:foldl(SolveFun, Map, SCC). - -%%------------------------------------------------------------------------------ - --define(worth_it, 42). - -parallel_split(SCC) -> - Length = length(SCC), - case Length > 2*?worth_it of - false -> false; - true -> - case min(dialyzer_utils:parallelism(), 8) of - 1 -> false; - CPUs -> - FullShare = Length div CPUs + 1, - Unit = max(FullShare, ?worth_it), - split(SCC, Unit, []) - end - end. - -minimize_state(#state{ - cmap = {d, CMap}, - fun_map = FunMap, - fun_arities = FunArities, - self_rec = SelfRec, - prop_types = {d, PropTypes}, - solvers = Solvers - }) -> - Opts = [{read_concurrency, true}], - ETSCMap = ets:new(cmap, Opts), - ETSPropTypes = ets:new(prop_types, Opts), - true = ets:insert(ETSCMap, dict:to_list(CMap)), - true = ets:insert(ETSPropTypes, dict:to_list(PropTypes)), - #state - {cmap = {e, ETSCMap}, - fun_map = FunMap, - fun_arities = FunArities, - self_rec = SelfRec, - prop_types = {e, ETSPropTypes}, - solvers = Solvers, - callgraph = undefined, - plt = undefined, - mfas = [] - }. - -dispose_state(#state{cmap = {e, ETSCMap}, - prop_types = {e, ETSPropTypes}}) -> - true = ets:delete(ETSCMap), - true = ets:delete(ETSPropTypes). - -solve_whole_scc_parallel(SplitSCC, Map, State) -> - Workers = spawn_workers(SplitSCC, Map, State), - wait_results(Workers, Map, fold_res_fun(State)). - -spawn_workers(SplitSCC, Map, State) -> - Spawner = solve_scc_spawner(self(), Map, State), - lists:foreach(Spawner, SplitSCC), - length(SplitSCC). - -wait_results(0, Map, _FoldResFun) -> - Map; -wait_results(Pending, Map, FoldResFun) -> - Res = receive_scc_result(), - NewMap = lists:foldl(FoldResFun, Map, Res), - wait_results(Pending-1, NewMap, FoldResFun). - -solve_scc_spawner(Parent, Map, State) -> - fun(SCCPart) -> - spawn_link(fun() -> solve_scc_worker(Parent, SCCPart, Map, State) end) - end. - -split([], _Unit, Acc) -> - Acc; -split(List, Unit, Acc) -> - {Taken, Rest} = - try - lists:split(Unit, List) - catch - _:_ -> {List, []} - end, - split(Rest, Unit, [Taken|Acc]). - -solve_scc_worker(Parent, SCCPart, Map, State) -> - SolveFun = fun(X, Y) -> scc_fold_fun(X, Y, State) end, - FinalMap = lists:foldl(SolveFun, Map, SCCPart), - Res = - [{F, t_limit(unsafe_lookup_type(F, FinalMap), ?TYPE_LIMIT)} || - F <- SCCPart], - send_scc_result(Parent, Res). - -fold_res_fun(State) -> - fun({F, Type}, Map) -> - case state__get_rec_var(F, State) of - {ok, R} -> - enter_type(R, Type, enter_type(F, Type, Map)); - error -> - enter_type(F, Type, Map) - end - end. - -receive_scc_result() -> - receive - {scc_fun, Res} -> Res - end. - -send_scc_result(Parent, Res) -> - Parent ! {scc_fun, Res}. - -%%------------------------------------------------------------------------------ +affected(Updated, Users) -> + lists:umerge([case lists:keyfind(V, 1, Users) of + {V, Vs} -> Vs; + false -> [] + end || V <- Updated]). scc_fold_fun(F, FunMap, State) -> Deps = get_deps(state__get_cs(F, State)), @@ -2017,7 +1910,7 @@ solver(Solver, SolveFun) -> solve_fun(v1, _Fun, Cs, FunMap, State) -> fun() -> - {ok, _MapDict, NewMap} = solve_ref_or_list(Cs, FunMap, dict:new(), State), + {ok, _MapDict, NewMap} = solve_ref_or_list(Cs, FunMap, map_new(), State), {ok, NewMap} end; solve_fun(v2, Fun, _Cs, FunMap, State) -> @@ -2057,7 +1950,7 @@ sane_maps(Map1, Map2, Keys, _S1, _S2) -> %% Solver v2 --record(v2_state, {constr_data = dict:new() :: dict:dict(), +-record(v2_state, {constr_data = maps:new() :: map(), state :: state()}). v2_solve_ref(Fun, Map, State) -> @@ -2219,30 +2112,30 @@ v2_solve_disj(Is, [C|Cs], I, Map, V2State, UL, MapL, Eval, Uneval0, Failed) -> v2_solve_disj(Is, Cs, I+1, Map, V2State, UL, MapL, Eval, Uneval, Failed). save_local_map(#v2_state{constr_data = ConData}=V2State, Id, U, Map) -> - Part0 = [{V,dict:fetch(V, Map)} || V <- U], + Part0 = [{V,maps:get(V, Map)} || V <- U], Part1 = - case dict:find(Id, ConData) of + case maps:find(Id, ConData) of error -> []; % cannot happen {ok, {Part2,[]}} -> Part2 end, ?debug("save local map Id=~w:\n", [Id]), Part = lists:ukeymerge(1, lists:keysort(1, Part0), Part1), - pp_map("New Part", dict:from_list(Part0)), - pp_map("Old Part", dict:from_list(Part1)), - pp_map(" => Part", dict:from_list(Part)), - V2State#v2_state{constr_data = dict:store(Id, {Part,[]}, ConData)}. + pp_map("New Part", maps:from_list(Part0)), + pp_map("Old Part", maps:from_list(Part1)), + pp_map(" => Part", maps:from_list(Part)), + V2State#v2_state{constr_data = maps:put(Id, {Part,[]}, ConData)}. restore_local_map(#v2_state{constr_data = ConData}, Id, Map0) -> - case dict:find(Id, ConData) of + case maps:find(Id, ConData) of error -> Map0; {ok, failed} -> Map0; {ok, {[],_}} -> Map0; {ok, {Part0,U}} -> Part = [KV || {K,_V} = KV <- Part0, not lists:member(K, U)], ?debug("restore local map Id=~w U=~w\n", [Id, U]), - pp_map("Part", dict:from_list(Part)), + pp_map("Part", maps:from_list(Part)), pp_map("Map0", Map0), - Map = lists:foldl(fun({K,V}, D) -> dict:store(K, V, D) end, Map0, Part), + Map = lists:foldl(fun({K,V}, D) -> maps:put(K, V, D) end, Map0, Part), pp_map("Map", Map), Map end. @@ -2322,31 +2215,26 @@ report_detected_loop(_) -> add_mask_to_flags(Flags, [Im|M], I, L) when I > Im -> add_mask_to_flags(Flags, M, I, [Im|L]); add_mask_to_flags(Flags, [_|M], _I, L) -> - {lists:umerge(Flags, M), lists:reverse(L)}. + {lists:umerge(M, Flags), lists:reverse(L)}. -get_mask(V, {d, Masks}) -> - case dict:find(V, Masks) of +get_mask(V, Masks) -> + case maps:find(V, Masks) of error -> []; {ok, M} -> M - end; -get_mask(V, Masks) -> - case lists:keyfind(V, 1, Masks) of - false -> []; - {V, M} -> M end. get_flags(#v2_state{constr_data = ConData}=V2State0, C) -> #constraint_list{id = Id, list = Cs, masks = Masks} = C, - case dict:find(Id, ConData) of + case maps:find(Id, ConData) of error -> ?debug("get_flags Id=~w Flags=all ~w\n", [Id, length(Cs)]), - V2State = V2State0#v2_state{constr_data = dict:store(Id, {[],[]}, ConData)}, + V2State = V2State0#v2_state{constr_data = maps:put(Id, {[],[]}, ConData)}, {V2State, lists:seq(1, length(Cs))}; {ok, failed} -> {V2State0, failed_list}; {ok, {Part,U}} when U =/= [] -> ?debug("get_flags Id=~w U=~w\n", [Id, U]), - V2State = V2State0#v2_state{constr_data = dict:store(Id, {Part,[]}, ConData)}, + V2State = V2State0#v2_state{constr_data = maps:put(Id, {Part,[]}, ConData)}, save_updated_vars_list(Cs, vars_per_child(U, Masks), V2State) end. @@ -2375,13 +2263,13 @@ save_updated_vars(#constraint_ref{id = Id}, U, V2State) -> save_updated_vars1(V2State, C, U) -> #v2_state{constr_data = ConData} = V2State, #constraint_list{id = Id} = C, - case dict:find(Id, ConData) of + case maps:find(Id, ConData) of error -> V2State; % error means everything is flagged {ok, failed} -> V2State; {ok, {Part,U0}} -> %% Duplicates are not so common; let masks/2 remove them. U1 = U ++ U0, - V2State#v2_state{constr_data = dict:store(Id, {Part,U1}, ConData)} + V2State#v2_state{constr_data = maps:put(Id, {Part,U1}, ConData)} end. -ifdef(DEBUG). @@ -2391,12 +2279,12 @@ pp_constr_data(_Tag, #v2_state{constr_data = D}) -> case _PartU of {_Part, _U} -> io:format("Id: ~w Vars: ~w\n", [_Id, _U]), - [pp_map("Part", dict:from_list(_Part)) || _Part =/= []]; + [pp_map("Part", maps:from_list(_Part)) || _Part =/= []]; failed -> io:format("Id: ~w failed list\n", [_Id]) end end || - {_Id, _PartU} <- lists:keysort(1, dict:to_list(D))], + {_Id, _PartU} <- lists:keysort(1, maps:to_list(D))], ok. -else. @@ -2406,17 +2294,17 @@ pp_constr_data(_Tag, _V2State) -> failed_list(#constraint_list{id = Id}, #v2_state{constr_data = D}=V2State) -> ?debug("error list ~w~n", [Id]), - V2State#v2_state{constr_data = dict:store(Id, failed, D)}. + V2State#v2_state{constr_data = maps:put(Id, failed, D)}. is_failed_list(#constraint_list{id = Id}, #v2_state{constr_data = D}) -> - dict:find(Id, D) =:= {ok, failed}. + maps:find(Id, D) =:= {ok, failed}. %% Solver v1 solve_ref_or_list(#constraint_ref{id = Id, deps = Deps}, Map, MapDict, State) -> {OldLocalMap, Check} = - case dict:find(Id, MapDict) of + case maps:find(Id, MapDict) of error -> {map_new(), false}; {ok, M} -> {M, true} end, @@ -2462,12 +2350,12 @@ solve_ref_or_list(#constraint_ref{id = Id, deps = Deps}, {ok, Var} -> enter_type(Var, FunType, NewMap1); error -> NewMap1 end, - {ok, dict:store(Id, NewMap2, NewMapDict), NewMap2} + {ok, maps:put(Id, NewMap2, NewMapDict), NewMap2} end; solve_ref_or_list(#constraint_list{type=Type, list = Cs, deps = Deps, id = Id}, Map, MapDict, State) -> {OldLocalMap, Check} = - case dict:find(Id, MapDict) of + case maps:find(Id, MapDict) of error -> {map_new(), false}; {ok, M} -> {M, true} end, @@ -2517,7 +2405,7 @@ solve_self_recursive(Cs, Map, MapDict, Id, RecType0, State) -> solve_clist(Cs, conj, Id, Deps, MapDict, Map, State) -> case solve_cs(Cs, Map, MapDict, State) of {error, NewMapDict} -> - {error, dict:store(Id, error, NewMapDict)}; + {error, maps:put(Id, error, NewMapDict)}; {ok, NewMapDict, NewMap} = Ret -> case Cs of [_] -> @@ -2525,7 +2413,7 @@ solve_clist(Cs, conj, Id, Deps, MapDict, Map, State) -> Ret; _ -> case maps_are_equal(Map, NewMap, Deps) of - true -> {ok, dict:store(Id, NewMap, NewMapDict), NewMap}; + true -> {ok, maps:put(Id, NewMap, NewMapDict), NewMap}; false -> solve_clist(Cs, conj, Id, Deps, NewMapDict, NewMap, State) end end @@ -2539,10 +2427,10 @@ solve_clist(Cs, disj, Id, _Deps, MapDict, Map, State) -> end, {Maps, NewMapDict} = lists:mapfoldl(Fun, MapDict, Cs), case [X || {ok, X} <- Maps] of - [] -> {error, dict:store(Id, error, NewMapDict)}; + [] -> {error, maps:put(Id, error, NewMapDict)}; MapList -> NewMap = join_maps(MapList), - {ok, dict:store(Id, NewMap, NewMapDict), NewMap} + {ok, maps:put(Id, NewMap, NewMapDict), NewMap} end. solve_cs([#constraint_ref{} = C|Tail], Map, MapDict, State) -> @@ -2623,7 +2511,7 @@ report_failed_constraint(_C, _Map) -> %% ============================================================================ map_new() -> - dict:new(). + maps:new(). join_maps([Map]) -> Map; @@ -2633,9 +2521,9 @@ join_maps(Maps) -> constrained_keys(Maps) -> lists:foldl(fun(TmpMap, AccKeys) -> - [Key || Key <- AccKeys, dict:is_key(Key, TmpMap)] + [Key || Key <- AccKeys, maps:is_key(Key, TmpMap)] end, - dict:fetch_keys(hd(Maps)), tl(Maps)). + maps:keys(hd(Maps)), tl(Maps)). join_maps([Key|Left], Maps = [Map|MapsLeft], AccMap) -> NewType = join_one_key(Key, MapsLeft, lookup_type(Key, Map)), @@ -2681,11 +2569,11 @@ prune_keys(Map1, Map2, Deps) -> NofDeps = length(Deps), case NofDeps > ?PRUNE_LIMIT of true -> - Keys1 = dict:fetch_keys(Map1), + Keys1 = maps:keys(Map1), case length(Keys1) > NofDeps of true -> Set1 = lists:sort(Keys1), - Set2 = lists:sort(dict:fetch_keys(Map2)), + Set2 = lists:sort(maps:keys(Map2)), ordsets:intersection(ordsets:union(Set1, Set2), Deps); false -> Deps @@ -2706,7 +2594,7 @@ enter_type(Key, Val, Map) when is_integer(Key) -> true -> ok; false -> ?debug("LimitedVal ~s\n", [format_type(LimitedVal)]) end, - case dict:find(Key, Map) of + case maps:find(Key, Map) of {ok, Value} -> case is_equal(Value, LimitedVal) of true -> Map; @@ -2740,16 +2628,16 @@ enter_type2(Key, Val, Map) -> map_store(Key, Val, Map) -> ?debug("Storing ~w :: ~s\n", [Key, format_type(Val)]), - dict:store(Key, Val, Map). + maps:put(Key, Val, Map). erase_type(Key, Map) -> - dict:erase(Key, Map). + maps:remove(Key, Map). lookup_type_list(List, Map) -> [lookup_type(X, Map) || X <- List]. unsafe_lookup_type(Key, Map) -> - case dict:find(t_var_name(Key), Map) of + case maps:find(t_var_name(Key), Map) of {ok, Type} -> Type; error -> t_none() end. @@ -2758,7 +2646,7 @@ unsafe_lookup_type_list(List, Map) -> [unsafe_lookup_type(X, Map) || X <- List]. lookup_type(Key, Map) when is_integer(Key) -> - case dict:find(Key, Map) of + case maps:find(Key, Map) of error -> t_any(); {ok, Val} -> Val end; @@ -2806,7 +2694,7 @@ is_equal(Type1, Type2) -> pp_map(_S, _Map) -> ?debug("\t~s: ~p\n", [_S, [{X, lists:flatten(format_type(Y))} || - {X, Y} <- lists:keysort(1, dict:to_list(_Map))]]). + {X, Y} <- lists:keysort(1, maps:to_list(_Map))]]). %% ============================================================================ %% @@ -2816,7 +2704,7 @@ pp_map(_S, _Map) -> new_state(SCC0, NextLabel, CallGraph, Plt, PropTypes, Solvers) -> List = [{MFA, Var} || {MFA, {Var, _Fun}, _Rec} <- SCC0], - NameMap = dict:from_list(List), + NameMap = maps:from_list(List), MFAs = [MFA || {MFA, _Var} <- List], SCC = [mk_var(Fun) || {_MFA, {_Var, Fun}, _Rec} <- SCC0], SelfRec = @@ -2830,7 +2718,7 @@ new_state(SCC0, NextLabel, CallGraph, Plt, PropTypes, Solvers) -> _Many -> false end, #state{callgraph = CallGraph, name_map = NameMap, next_label = NextLabel, - prop_types = {d, PropTypes}, plt = Plt, scc = ordsets:from_list(SCC), + prop_types = PropTypes, plt = Plt, scc = ordsets:from_list(SCC), mfas = MFAs, self_rec = SelfRec, solvers = Solvers}. state__set_rec_dict(State, RecDict) -> @@ -2858,15 +2746,15 @@ state__get_fun_prototype(Op, Arity, State) -> end. state__lookup_rec_var_in_scope(MFA, #state{name_map = NameMap}) -> - dict:find(MFA, NameMap). + maps:find(MFA, NameMap). state__store_fun_arity(Tree, #state{fun_arities = Map} = State) -> Arity = length(cerl:fun_vars(Tree)), Id = mk_var(Tree), - State#state{fun_arities = dict:store(Id, Arity, Map)}. + State#state{fun_arities = maps:put(Id, Arity, Map)}. state__fun_arity(Id, #state{fun_arities = Map}) -> - dict:fetch(Id, Map). + maps:get(Id, Map). state__lookup_undef_var(Tree, #state{callgraph = CG, plt = Plt}) -> Label = cerl_trees:get_label(Tree), @@ -2926,21 +2814,14 @@ state__plt(#state{plt = PLT}) -> state__new_constraint_context(State) -> State#state{cs = []}. -state__prop_domain(FunLabel, #state{prop_types = {e, ETSPropTypes}}) -> - try ets:lookup_element(ETSPropTypes, FunLabel, 2) of - {_Range_Fun, Dom} -> {ok, Dom}; - FunType -> {ok, t_fun_args(FunType)} - catch - _:_ -> error - end; -state__prop_domain(FunLabel, #state{prop_types = {d, PropTypes}}) -> +state__prop_domain(FunLabel, #state{prop_types = PropTypes}) -> case dict:find(FunLabel, PropTypes) of error -> error; {ok, {_Range_Fun, Dom}} -> {ok, Dom}; {ok, FunType} -> {ok, t_fun_args(FunType)} end. -state__add_prop_constrs(Tree, #state{prop_types = {d, PropTypes}} = State) -> +state__add_prop_constrs(Tree, #state{prop_types = PropTypes} = State) -> Label = cerl_trees:get_label(Tree), case dict:find(Label, PropTypes) of error -> State; @@ -3003,14 +2884,12 @@ state__mk_vars(N, #state{next_label = NL} = State) -> Vars = [t_var(X) || X <- lists:seq(NL, NewLabel-1)], {State#state{next_label = NewLabel}, Vars}. -state__store_constrs(Id, Cs, #state{cmap = {d, Dict}} = State) -> - NewDict = dict:store(Id, Cs, Dict), - State#state{cmap = {d, NewDict}}. +state__store_constrs(Id, Cs, #state{cmap = Map} = State) -> + NewMap = maps:put(Id, Cs, Map), + State#state{cmap = NewMap}. -state__get_cs(Var, #state{cmap = {e, ETSDict}}) -> - ets:lookup_element(ETSDict, Var, 2); -state__get_cs(Var, #state{cmap = {d, Dict}}) -> - dict:fetch(Var, Dict). +state__get_cs(Var, #state{cmap = Map}) -> + maps:get(Var, Map). state__is_self_rec(Fun, #state{self_rec = SelfRec}) -> not (SelfRec =:= 'false') andalso is_equal(Fun, SelfRec). @@ -3019,15 +2898,12 @@ state__store_funs(Vars0, Funs0, #state{fun_map = Map} = State) -> debug_make_name_map(Vars0, Funs0), Vars = mk_var_list(Vars0), Funs = mk_var_list(Funs0), - NewMap = lists:foldl(fun({Var, Fun}, MP) -> orddict:store(Var, Fun, MP) end, + NewMap = lists:foldl(fun({Var, Fun}, MP) -> maps:put(Fun, Var, MP) end, Map, lists:zip(Vars, Funs)), State#state{fun_map = NewMap}. state__get_rec_var(Fun, #state{fun_map = Map}) -> - case [V || {V, FV} <- Map, FV =:= Fun] of - [Var] -> {ok, Var}; - [] -> error - end. + maps:find(Fun, Map). state__finalize(State) -> State1 = enumerate_constraints(State), @@ -3094,13 +2970,13 @@ mk_fun_var(Fun, Types) -> -endif. --spec get_deps(constr()) -> [dep()]. +-spec get_deps(constr()) -> deps(). get_deps(#constraint{deps = D}) -> D; get_deps(#constraint_list{deps = D}) -> D; get_deps(#constraint_ref{deps = D}) -> D. --spec find_constraint_deps([fvar_or_type()]) -> [dep()]. +-spec find_constraint_deps([fvar_or_type()]) -> deps(). find_constraint_deps(List) -> ordsets:from_list(find_constraint_deps(List, [])). @@ -3348,18 +3224,11 @@ order_fun_constraints([], Funs, Acc, State) -> update_masks(C, Masks) -> C#constraint_list{masks = Masks}. --define(VARS_LIMIT, 50). - calculate_masks([C|Cs], I, L0) -> calculate_masks(Cs, I+1, [{V, I} || V <- get_deps(C)] ++ L0); calculate_masks([], _I, L) -> M = family(L), - case length(M) > ?VARS_LIMIT of - true -> - {d, dict:from_list(M)}; - false -> - M - end. + maps:from_list(M). %% ============================================================================ %% @@ -3487,7 +3356,7 @@ join_chars([H|T], Sep) -> [H|[[Sep,X] || X <- T]]. debug_lookup_name(Var) -> - case dict:find(t_var_name(Var), get(dialyzer_typesig_map)) of + case maps:find(t_var_name(Var), get(dialyzer_typesig_map)) of error -> Var; {ok, Name} -> Name end. @@ -3497,7 +3366,7 @@ debug_lookup_name(Var) -> debug_make_name_map(Vars, Funs) -> Map = get(dialyzer_typesig_map), NewMap = - if Map =:= undefined -> debug_make_name_map(Vars, Funs, dict:new()); + if Map =:= undefined -> debug_make_name_map(Vars, Funs, maps:new()); true -> debug_make_name_map(Vars, Funs, Map) end, put(dialyzer_typesig_map, NewMap). @@ -3505,7 +3374,7 @@ debug_make_name_map(Vars, Funs) -> debug_make_name_map([Var|VarLeft], [Fun|FunLeft], Map) -> Name = {cerl:fname_id(Var), cerl:fname_arity(Var)}, FunLabel = cerl_trees:get_label(Fun), - debug_make_name_map(VarLeft, FunLeft, dict:store(FunLabel, Name, Map)); + debug_make_name_map(VarLeft, FunLeft, maps:put(FunLabel, Name, Map)); debug_make_name_map([], [], Map) -> Map. diff --git a/lib/edoc/src/edoc.erl b/lib/edoc/src/edoc.erl index d2494b69fe..94013bb5ac 100644 --- a/lib/edoc/src/edoc.erl +++ b/lib/edoc/src/edoc.erl @@ -653,20 +653,7 @@ find_invalid_unicode([]) -> none. parse_file(Epp) -> case scan_and_parse(Epp) of {ok, Form} -> - case Form of - {attribute,La,record,{Record, Fields}} -> - case epp:normalize_typed_record_fields(Fields) of - {typed, NewFields} -> - [{attribute, La, record, {Record, NewFields}}, - {attribute, La, type, - {{record, Record}, Fields, []}} - | parse_file(Epp)]; - not_typed -> - [Form | parse_file(Epp)] - end; - _ -> - [Form | parse_file(Epp)] - end; + [Form | parse_file(Epp)]; {error, E} -> [{error, E} | parse_file(Epp)]; {eof, Location} -> diff --git a/lib/edoc/src/edoc_extract.erl b/lib/edoc/src/edoc_extract.erl index 758750083d..e7a4c36ca4 100644 --- a/lib/edoc/src/edoc_extract.erl +++ b/lib/edoc/src/edoc_extract.erl @@ -355,6 +355,8 @@ preprocess_forms_2(F, Fs) -> [F | preprocess_forms_1(Fs)]; text -> [F | preprocess_forms_1(Fs)]; + {attribute, {record, _}} -> + [F | preprocess_forms_1(Fs)]; {attribute, {N, _}} -> case edoc_specs:is_tag(N) of true -> @@ -373,50 +375,62 @@ preprocess_forms_2(F, Fs) -> %% in the list. collect(Fs, Mod) -> - collect(Fs, [], [], [], [], undefined, Mod). + collect(Fs, [], [], [], [], [], undefined, Mod). -collect([F | Fs], Cs, Ss, Ts, As, Header, Mod) -> +collect([F | Fs], Cs, Ss, Ts, Rs, As, Header, Mod) -> case erl_syntax_lib:analyze_form(F) of comment -> - collect(Fs, [F | Cs], Ss, Ts, As, Header, Mod); + collect(Fs, [F | Cs], Ss, Ts, Rs, As, Header, Mod); {function, Name} -> L = erl_syntax:get_pos(F), Export = ordsets:is_element(Name, Mod#module.exports), Args = parameters(erl_syntax:function_clauses(F)), - collect(Fs, [], [], [], + collect(Fs, [], [], [], [], [#entry{name = Name, args = Args, line = L, export = Export, - data = {comment_text(Cs),Ss,Ts}} | As], + data = {comment_text(Cs),Ss,Ts,Rs}} | As], Header, Mod); {attribute, {module, _}} when Header =:= undefined -> L = erl_syntax:get_pos(F), - collect(Fs, [], [], [], As, + collect(Fs, [], [], [], [], As, #entry{name = module, line = L, - data = {comment_text(Cs),Ss,Ts}}, + data = {comment_text(Cs),Ss,Ts,Rs}}, Mod); + {attribute, {record, {_Name, Fields}}} -> + case is_typed_record(Fields) of + true -> + collect(Fs, Cs, Ss, Ts, [F | Rs], As, Header, Mod); + false -> + collect(Fs, Cs, Ss, Ts, Rs, As, Header, Mod) + end; {attribute, {N, _}} -> case edoc_specs:tag(N) of spec -> - collect(Fs, Cs, [F | Ss], Ts, As, Header, Mod); + collect(Fs, Cs, [F | Ss], Ts, Rs, As, Header, Mod); type -> - collect(Fs, Cs, Ss, [F | Ts], As, Header, Mod); + collect(Fs, Cs, Ss, [F | Ts], Rs, As, Header, Mod); unknown -> %% Drop current seen comments. - collect(Fs, [], [], [], As, Header, Mod) + collect(Fs, [], [], [], Rs, As, Header, Mod) end; _ -> %% Drop current seen comments. - collect(Fs, [], [], [], As, Header, Mod) + collect(Fs, [], [], [], [], As, Header, Mod) end; -collect([], Cs, Ss, Ts, As, Header, _Mod) -> - Footer = #entry{name = footer, data = {comment_text(Cs),Ss,Ts}}, +collect([], Cs, Ss, Ts, Rs, As, Header, _Mod) -> + Footer = #entry{name = footer, data = {comment_text(Cs),Ss,Ts,Rs}}, As1 = lists:reverse(As), if Header =:= undefined -> - {#entry{name = module, data = {[],[],[]}}, Footer, As1}; + {#entry{name = module, data = {[],[],[],[]}}, Footer, As1}; true -> {Header, Footer, As1} end. +is_typed_record([]) -> + false; +is_typed_record([{_, {_, Type}} | Fs]) -> + Type =/= none orelse is_typed_record(Fs). + %% Returns a list of simplified comment information (position and text) %% for a list of abstract comments. The order of elements is reversed. @@ -549,8 +563,8 @@ get_tags(Es, Env, File, TypeDocs) -> How = dict:from_list(edoc_tags:tag_parsers()), get_tags(Es, Tags, Env, How, File, TypeDocs). -get_tags([#entry{name = Name, data = {Cs,Specs,Types}} = E | Es], Tags, Env, - How, File, TypeDocs) -> +get_tags([#entry{name = Name, data = {Cs,Specs,Types,Records}} = E | Es], + Tags, Env, How, File, TypeDocs) -> Where = {File, Name}, Ts0 = scan_tags(Cs), {Ts1,Specs1} = select_spec(Ts0, Where, Specs), @@ -558,7 +572,7 @@ get_tags([#entry{name = Name, data = {Cs,Specs,Types}} = E | Es], Tags, Env, Ts3 = edoc_macros:expand_tags(Ts2, Env, Where), Ts4 = edoc_tags:parse_tags(Ts3, How, Env, Where), Ts = selected_specs(Specs1, Ts4), - ETypes = [edoc_specs:type(Type, TypeDocs) || Type <- Types], + ETypes = [edoc_specs:type(Type, TypeDocs) || Type <- Types ++ Records], [E#entry{data = Ts++ETypes} | get_tags(Es, Tags, Env, How, File, TypeDocs)]; get_tags([], _, _, _, _, _) -> []. diff --git a/lib/edoc/src/edoc_specs.erl b/lib/edoc/src/edoc_specs.erl index f2e5891c2e..faee8adf7b 100644 --- a/lib/edoc/src/edoc_specs.erl +++ b/lib/edoc/src/edoc_specs.erl @@ -42,14 +42,15 @@ %% TypeDocs is a dict of {Name, Doc}. %% Note: #t_typedef.name is set to {record, R} for record types. type(Form, TypeDocs) -> - {Name, Data0} = erl_syntax_lib:analyze_wild_attribute(Form), - type = tag(Name), + {Name, Data0} = analyze_type_attribute(Form), {TypeName, Type, Args, Doc} = case Data0 of - {{record, R}, Fs, []} -> + {R, Fs} -> + record = Name, L = erl_syntax:get_pos(Form), {{record, R}, {type, L, record, [{atom,L,R} | Fs]}, [], ""}; {N,T,As} -> + type = tag(Name), Doc0 = case dict:find({N, length(As)}, TypeDocs) of {ok, Doc1} -> @@ -188,7 +189,7 @@ strip([_ | S]) -> %% Find the type name and the greatest line number of a type spec. %% Should use syntax_tools but this has to do for now. get_name_and_last_line(F) -> - {Name, Data} = erl_syntax_lib:analyze_wild_attribute(F), + {Name, Data} = analyze_type_attribute(F), type = edoc_specs:tag(Name), Attr = {attribute, erl_syntax:get_pos(F), Name, Data}, Fun = fun(A) -> @@ -229,6 +230,7 @@ get_all_tags(Es) -> %% Turns an opaque type into an abstract datatype. %% Note: top level annotation is ignored. opaque2abstr(opaque, _T) -> undefined; +opaque2abstr(record, T) -> T; opaque2abstr(type, T) -> T. %% Replaces the parameters extracted from the source (by @@ -608,6 +610,16 @@ type_name(#tag{name = type, data = {#t_typedef{name = Name, args = As},_}}) -> {Name, length(As)}. +analyze_type_attribute(Form) -> + Name = erl_syntax:atom_value(erl_syntax:attribute_name(Form)), + case tag(Name) of + type -> + erl_syntax_lib:analyze_wild_attribute(Form); + _ when Name =:= record -> + {attribute, _, record, {N, Fields}} = erl_syntax:revert(Form), + {record, {N, Fields}} + end. + %% @doc Return `true' if `Tag' is one of the specification and type %% attribute tags recognized by the Erlang compiler. diff --git a/lib/eldap/vsn.mk b/lib/eldap/vsn.mk index 99c474d588..721387d97d 100644 --- a/lib/eldap/vsn.mk +++ b/lib/eldap/vsn.mk @@ -1 +1 @@ -ELDAP_VSN = 1.2.1 +ELDAP_VSN = 1.2.2 diff --git a/lib/et/src/et.app.src b/lib/et/src/et.app.src index 77b9488c7e..7a5928d6ab 100644 --- a/lib/et/src/et.app.src +++ b/lib/et/src/et.app.src @@ -33,6 +33,6 @@ {registered, [et_collector]}, {applications, [stdlib, kernel]}, {env, []}, - {runtime_dependencies, ["wx-1.2","stdlib-2.0","runtime_tools-1.8.14", - "kernel-3.0","erts-6.0"]} + {runtime_dependencies, ["wx-1.2","stdlib-2.0","runtime_tools-1.10", + "kernel-3.0","erts-8.0"]} ]}. diff --git a/lib/et/src/et_selector.erl b/lib/et/src/et_selector.erl index 0e2d7010cd..a0297c21d1 100644 --- a/lib/et/src/et_selector.erl +++ b/lib/et/src/et_selector.erl @@ -23,11 +23,9 @@ -module(et_selector). --export([ - make_pattern/1, +-export([make_pattern/1, change_pattern/1, - parse_event/2 - ]). + parse_event/2]). -compile([{nowarn_deprecated_function,[{erlang,now,0}]}]). @@ -535,7 +533,7 @@ parse_event(Mod, Trace, ParsedTS, ReportedTS, From, Label, Contents) -> {from, From}, {to, From}, {mfa, MFA}]}}; % MFA | 0 - gc_start -> + gc_minor_start -> DetailLevel = 80, [GcKeyValueList] = Contents, {true, #event{detail_level = DetailLevel, @@ -549,7 +547,7 @@ parse_event(Mod, Trace, ParsedTS, ReportedTS, From, Label, Contents) -> {from, From}, {to, From}, {gc_items, GcKeyValueList}]}}; - gc_end -> + gc_minor_end -> DetailLevel = 85, [GcKeyValueList] = Contents, {true, #event{detail_level = DetailLevel, @@ -559,10 +557,38 @@ parse_event(Mod, Trace, ParsedTS, ReportedTS, From, Label, Contents) -> to = From, label = Label, contents = [{label, Label}, - {detail_level, DetailLevel}, - {from, From}, - {to, From}, - {gc_items, GcKeyValueList}]}}; + {detail_level, DetailLevel}, + {from, From}, + {to, From}, + {gc_items, GcKeyValueList}]}}; + gc_major_start -> + DetailLevel = 80, + [GcKeyValueList] = Contents, + {true, #event{detail_level = DetailLevel, + trace_ts = ReportedTS, + event_ts = ParsedTS, + from = From, + to = From, + label = Label, + contents = [{label, Label}, + {detail_level, DetailLevel}, + {from, From}, + {to, From}, + {gc_items, GcKeyValueList}]}}; + gc_major_end -> + DetailLevel = 85, + [GcKeyValueList] = Contents, + {true, #event{detail_level = DetailLevel, + trace_ts = ReportedTS, + event_ts = ParsedTS, + from = From, + to = From, + label = Label, + contents = [{label, Label}, + {detail_level, DetailLevel}, + {from, From}, + {to, From}, + {gc_items, GcKeyValueList}]}}; _ -> error_logger:format("~p(~p): Ignoring unknown trace type -> ~p~n~n", [?MODULE, ?LINE, Trace]), diff --git a/lib/et/test/et_SUITE.erl b/lib/et/test/et_SUITE.erl index 4a26b46439..199aff43a8 100644 --- a/lib/et/test/et_SUITE.erl +++ b/lib/et/test/et_SUITE.erl @@ -16,7 +16,8 @@ %% -module(et_SUITE). --compile([export_all]). +-export([suite/0, all/0]). +-export([app/1, appup/1]). -include_lib("common_test/include/ct.hrl"). suite() -> @@ -25,27 +26,10 @@ suite() -> all() -> [app, appup]. -groups() -> - []. - -init_per_suite(Config) -> - Config. - -end_per_suite(_Config) -> - ok. - -init_per_group(_GroupName, Config) -> - Config. - -end_per_group(_GroupName, Config) -> - Config. - -app() -> - [{doc, "Test that the et app file is ok"}]. +%% Test that the et app file is ok app(Config) when is_list(Config) -> ok = ?t:app_test(et). -appup() -> - [{doc, "Test that the et appup file is ok"}]. +%% Test that the et appup file is ok appup(Config) when is_list(Config) -> ok = ?t:appup_test(et). diff --git a/lib/et/test/et_wx_SUITE.erl b/lib/et/test/et_wx_SUITE.erl index 785d1b8145..6475b6706b 100644 --- a/lib/et/test/et_wx_SUITE.erl +++ b/lib/et/test/et_wx_SUITE.erl @@ -19,11 +19,10 @@ -module(et_wx_SUITE). --export([all/0, suite/0,groups/0,init_per_group/2,end_per_group/2, - init_per_suite/1, end_per_suite/1, - init_per_testcase/2, end_per_testcase/2]). - --compile(export_all). +-export([all/0, suite/0, + init_per_testcase/2, end_per_testcase/2, + init_per_suite/1, end_per_suite/1]). +-export([start_all_windows/1]). -include("et_test_lib.hrl"). @@ -40,21 +39,13 @@ end_per_testcase(Func,Config) -> et_test_lib:end_per_testcase(Func,Config). %% SUITE specification -suite() -> [{ct_hooks,[ts_install_cth]}]. + +suite() -> + [{ct_hooks,[ts_install_cth]}]. all() -> [start_all_windows]. -groups() -> - []. - -init_per_group(_GroupName, Config) -> - Config. - -end_per_group(_GroupName, Config) -> - Config. - - %% The test cases %% Display all windows and see if something crashes diff --git a/lib/hipe/cerl/erl_types.erl b/lib/hipe/cerl/erl_types.erl index 02e1625965..84addcc105 100644 --- a/lib/hipe/cerl/erl_types.erl +++ b/lib/hipe/cerl/erl_types.erl @@ -236,7 +236,7 @@ -export([t_is_identifier/1]). -endif. --export_type([erl_type/0, opaques/0, type_table/0, var_table/0]). +-export_type([erl_type/0, opaques/0, type_table/0]). %%-define(DEBUG, true). @@ -380,7 +380,7 @@ -type type_table() :: dict:dict(record_key() | type_key(), record_value() | type_value()). --type var_table() :: dict:dict(atom(), erl_type()). +-type var_table() :: #{atom() => erl_type()}. %%----------------------------------------------------------------------------- %% Unions @@ -3295,87 +3295,33 @@ findfirst(N1, N2, U1, B1, U2, B2) -> %%----------------------------------------------------------------------------- %% Substitution of variables %% -%% Dialyzer versions prior to R15B used a dict data structure to map variables -%% to types. Hans Bolinder suggested the use of lists of Key-Value pairs for -%% this data structure and measurements showed a non-trivial speedup when using -%% them for operations within this module (e.g. in t_unify/2). However, there -%% is code outside erl_types that still passes a dict:dict() in the 2nd argument. -%% So, for the time being, this module provides a t_subst/2 function for these -%% external calls and a clone of it (t_subst_kv/2) which is used from all calls -%% from within this module. This code duplication needs to be eliminated at -%% some point. - --spec t_subst(erl_type(), dict:dict(atom(), erl_type())) -> erl_type(). - -t_subst(T, Dict) -> + +-type subst_table() :: #{any() => erl_type()}. + +-spec t_subst(erl_type(), subst_table()) -> erl_type(). + +t_subst(T, Map) -> case t_has_var(T) of - true -> t_subst_dict(T, Dict); + true -> t_subst_aux(T, Map); false -> T end. -t_subst_dict(?var(Id), Dict) -> - case dict:find(Id, Dict) of - error -> ?any; - {ok, Type} -> Type - end; -t_subst_dict(?list(Contents, Termination, Size), Dict) -> - case t_subst_dict(Contents, Dict) of - ?none -> ?none; - NewContents -> - %% Be careful here to make the termination collapse if necessary. - case t_subst_dict(Termination, Dict) of - ?nil -> ?list(NewContents, ?nil, Size); - ?any -> ?list(NewContents, ?any, Size); - Other -> - ?list(NewContents2, NewTermination, _) = t_cons(NewContents, Other), - ?list(NewContents2, NewTermination, Size) - end - end; -t_subst_dict(?function(Domain, Range), Dict) -> - ?function(t_subst_dict(Domain, Dict), t_subst_dict(Range, Dict)); -t_subst_dict(?product(Types), Dict) -> - ?product([t_subst_dict(T, Dict) || T <- Types]); -t_subst_dict(?tuple(?any, ?any, ?any) = T, _Dict) -> - T; -t_subst_dict(?tuple(Elements, _Arity, _Tag), Dict) -> - t_tuple([t_subst_dict(E, Dict) || E <- Elements]); -t_subst_dict(?tuple_set(_) = TS, Dict) -> - t_sup([t_subst_dict(T, Dict) || T <- t_tuple_subtypes(TS)]); -t_subst_dict(?map(Pairs, DefK, DefV), Dict) -> - t_map([{K, MNess, t_subst_dict(V, Dict)} || {K, MNess, V} <- Pairs], - t_subst_dict(DefK, Dict), t_subst_dict(DefV, Dict)); -t_subst_dict(?opaque(Es), Dict) -> - List = [Opaque#opaque{args = [t_subst_dict(Arg, Dict) || Arg <- Args], - struct = t_subst_dict(S, Dict)} || - Opaque = #opaque{args = Args, struct = S} <- set_to_list(Es)], - ?opaque(ordsets:from_list(List)); -t_subst_dict(?union(List), Dict) -> - ?union([t_subst_dict(E, Dict) || E <- List]); -t_subst_dict(T, _Dict) -> - T. - -spec subst_all_vars_to_any(erl_type()) -> erl_type(). subst_all_vars_to_any(T) -> - t_subst_kv(T, []). + t_subst(T, #{}). -t_subst_kv(T, KVMap) -> - case t_has_var(T) of - true -> t_subst_aux(T, KVMap); - false -> T - end. - -t_subst_aux(?var(Id), VarMap) -> - case lists:keyfind(Id, 1, VarMap) of - false -> ?any; - {Id, Type} -> Type +t_subst_aux(?var(Id), Map) -> + case maps:find(Id, Map) of + error -> ?any; + {ok, Type} -> Type end; -t_subst_aux(?list(Contents, Termination, Size), VarMap) -> - case t_subst_aux(Contents, VarMap) of +t_subst_aux(?list(Contents, Termination, Size), Map) -> + case t_subst_aux(Contents, Map) of ?none -> ?none; NewContents -> %% Be careful here to make the termination collapse if necessary. - case t_subst_aux(Termination, VarMap) of + case t_subst_aux(Termination, Map) of ?nil -> ?list(NewContents, ?nil, Size); ?any -> ?list(NewContents, ?any, Size); Other -> @@ -3383,27 +3329,27 @@ t_subst_aux(?list(Contents, Termination, Size), VarMap) -> ?list(NewContents2, NewTermination, Size) end end; -t_subst_aux(?function(Domain, Range), VarMap) -> - ?function(t_subst_aux(Domain, VarMap), t_subst_aux(Range, VarMap)); -t_subst_aux(?product(Types), VarMap) -> - ?product([t_subst_aux(T, VarMap) || T <- Types]); -t_subst_aux(?tuple(?any, ?any, ?any) = T, _VarMap) -> +t_subst_aux(?function(Domain, Range), Map) -> + ?function(t_subst_aux(Domain, Map), t_subst_aux(Range, Map)); +t_subst_aux(?product(Types), Map) -> + ?product([t_subst_aux(T, Map) || T <- Types]); +t_subst_aux(?tuple(?any, ?any, ?any) = T, _Map) -> T; -t_subst_aux(?tuple(Elements, _Arity, _Tag), VarMap) -> - t_tuple([t_subst_aux(E, VarMap) || E <- Elements]); -t_subst_aux(?tuple_set(_) = TS, VarMap) -> - t_sup([t_subst_aux(T, VarMap) || T <- t_tuple_subtypes(TS)]); -t_subst_aux(?map(Pairs, DefK, DefV), VarMap) -> - t_map([{K, MNess, t_subst_aux(V, VarMap)} || {K, MNess, V} <- Pairs], - t_subst_aux(DefK, VarMap), t_subst_aux(DefV, VarMap)); -t_subst_aux(?opaque(Es), VarMap) -> - List = [Opaque#opaque{args = [t_subst_aux(Arg, VarMap) || Arg <- Args], - struct = t_subst_aux(S, VarMap)} || - Opaque = #opaque{args = Args, struct = S} <- set_to_list(Es)], - ?opaque(ordsets:from_list(List)); -t_subst_aux(?union(List), VarMap) -> - ?union([t_subst_aux(E, VarMap) || E <- List]); -t_subst_aux(T, _VarMap) -> +t_subst_aux(?tuple(Elements, _Arity, _Tag), Map) -> + t_tuple([t_subst_aux(E, Map) || E <- Elements]); +t_subst_aux(?tuple_set(_) = TS, Map) -> + t_sup([t_subst_aux(T, Map) || T <- t_tuple_subtypes(TS)]); +t_subst_aux(?map(Pairs, DefK, DefV), Map) -> + t_map([{K, MNess, t_subst_aux(V, Map)} || {K, MNess, V} <- Pairs], + t_subst_aux(DefK, Map), t_subst_aux(DefV, Map)); +t_subst_aux(?opaque(Es), Map) -> + List = [Opaque#opaque{args = [t_subst_aux(Arg, Map) || Arg <- Args], + struct = t_subst_aux(S, Map)} || + Opaque = #opaque{args = Args, struct = S} <- set_to_list(Es)], + ?opaque(ordsets:from_list(List)); +t_subst_aux(?union(List), Map) -> + ?union([t_subst_aux(E, Map) || E <- List]); +t_subst_aux(T, _Map) -> T. %%----------------------------------------------------------------------------- @@ -3415,33 +3361,33 @@ t_subst_aux(T, _VarMap) -> -spec t_unify(erl_type(), erl_type()) -> t_unify_ret(). t_unify(T1, T2) -> - {T, VarMap} = t_unify(T1, T2, []), - {t_subst_kv(T, VarMap), lists:keysort(1, VarMap)}. + {T, VarMap} = t_unify(T1, T2, #{}), + {t_subst(T, VarMap), lists:keysort(1, maps:to_list(VarMap))}. t_unify(?var(Id) = T, ?var(Id), VarMap) -> {T, VarMap}; t_unify(?var(Id1) = T, ?var(Id2), VarMap) -> - case lists:keyfind(Id1, 1, VarMap) of - false -> - case lists:keyfind(Id2, 1, VarMap) of - false -> {T, [{Id2, T} | VarMap]}; - {Id2, Type} -> t_unify(T, Type, VarMap) + case maps:find(Id1, VarMap) of + error -> + case maps:find(Id2, VarMap) of + error -> {T, VarMap#{Id2 => T}}; + {ok, Type} -> t_unify(T, Type, VarMap) end; - {Id1, Type1} -> - case lists:keyfind(Id2, 1, VarMap) of - false -> {Type1, [{Id2, T} | VarMap]}; - {Id2, Type2} -> t_unify(Type1, Type2, VarMap) + {ok, Type1} -> + case maps:find(Id2, VarMap) of + error -> {Type1, VarMap#{Id2 => T}}; + {ok, Type2} -> t_unify(Type1, Type2, VarMap) end end; t_unify(?var(Id), Type, VarMap) -> - case lists:keyfind(Id, 1, VarMap) of - false -> {Type, [{Id, Type} | VarMap]}; - {Id, VarType} -> t_unify(VarType, Type, VarMap) + case maps:find(Id, VarMap) of + error -> {Type, VarMap#{Id => Type}}; + {ok, VarType} -> t_unify(VarType, Type, VarMap) end; t_unify(Type, ?var(Id), VarMap) -> - case lists:keyfind(Id, 1, VarMap) of - false -> {Type, [{Id, Type} | VarMap]}; - {Id, VarType} -> t_unify(VarType, Type, VarMap) + case maps:find(Id, VarMap) of + error -> {Type, VarMap#{Id => Type}}; + {ok, VarType} -> t_unify(VarType, Type, VarMap) end; t_unify(?function(Domain1, Range1), ?function(Domain2, Range2), VarMap) -> {Domain, VarMap1} = t_unify(Domain1, Domain2, VarMap), @@ -4472,7 +4418,7 @@ mod_name(Mod, Name) -> site(), mod_records()) -> erl_type(). t_from_form(Form, ExpTypes, Site, RecDict) -> - t_from_form(Form, ExpTypes, Site, RecDict, dict:new()). + t_from_form(Form, ExpTypes, Site, RecDict, maps:new()). -spec t_from_form(parse_form(), sets:set(mfa()), site(), mod_records(), var_table()) -> erl_type(). @@ -4489,7 +4435,7 @@ t_from_form_without_remote(Form, Site, TypeTable) -> Module = site_module(Site), RecDict = dict:from_list([{Module, TypeTable}]), ExpTypes = replace_by_none, - {T, _} = t_from_form1(Form, ExpTypes, Site, RecDict, dict:new()), + {T, _} = t_from_form1(Form, ExpTypes, Site, RecDict, maps:new()), T. %% REC_TYPE_LIMIT is used for limiting the depth of recursive types. @@ -4545,7 +4491,7 @@ t_from_form(_, _TypeNames, _ET, _S, _MR, _V, D, L) when D =< 0 ; L =< 0 -> t_from_form({var, _L, '_'}, _TypeNames, _ET, _S, _MR, _V, _D, L) -> {t_any(), L}; t_from_form({var, _L, Name}, _TypeNames, _ET, _S, _MR, V, _D, L) -> - case dict:find(Name, V) of + case maps:find(Name, V) of error -> {t_var(Name), L}; {ok, Val} -> {Val, L} end; @@ -4764,7 +4710,7 @@ type_from_form(Name, Args, TypeNames, ET, Site0, MR, V, D, L) -> {ArgTypes, L1} = list_from_form(Args, TypeNames, ET, Site0, MR, V, D, L), List = lists:zip(ArgNames, ArgTypes), - TmpV = dict:from_list(List), + TmpV = maps:from_list(List), Site = TypeName, t_from_form(Form, NewTypeNames, ET, Site, MR, TmpV, D, L1); false -> @@ -4777,7 +4723,7 @@ type_from_form(Name, Args, TypeNames, ET, Site0, MR, V, D, L) -> {ArgTypes, L1} = list_from_form(Args, NewTypeNames, ET, Site0, MR, V, D, L), List = lists:zip(ArgNames, ArgTypes), - TmpV = dict:from_list(List), + TmpV = maps:from_list(List), Site = TypeName, {Rep, L2} = t_from_form(Form, NewTypeNames, ET, Site, MR, TmpV, D, L1), @@ -4819,7 +4765,7 @@ remote_from_form(RemMod, Name, Args, TypeNames, ET, S, MR, V, D, L) -> {ArgTypes, L1} = list_from_form(Args, TypeNames, ET, S, MR, V, D, L), List = lists:zip(ArgNames, ArgTypes), - TmpVarDict = dict:from_list(List), + TmpVarDict = maps:from_list(List), Site = RemType, t_from_form(Form, NewTypeNames, ET, Site, MR, TmpVarDict, D, L1); @@ -4833,7 +4779,7 @@ remote_from_form(RemMod, Name, Args, TypeNames, ET, S, MR, V, D, L) -> {ArgTypes, L1} = list_from_form(Args, NewTypeNames, ET, S, MR, V, D, L), List = lists:zip(ArgNames, ArgTypes), - TmpVarDict = dict:from_list(List), + TmpVarDict = maps:from_list(List), Site = RemType, {NewRep, L2} = t_from_form(Form, NewTypeNames, ET, Site, MR, @@ -4904,7 +4850,7 @@ record_from_form({atom, _, Name}, ModFields, TypeNames, ET, S, MR, V, D, L) -> {ok, NewFields} -> {NewFields1, L2} = fields_from_form(NewFields, NewTypeNames, ET, S1, MR, - dict:new(), D, L1), + maps:new(), D, L1), Rec = t_tuple( [t_atom(Name)|[Type || {_FieldName, Type} <- NewFields1]]), @@ -5023,7 +4969,7 @@ promote_to_mand(MKs, [E={K,_,V}|T]) -> mod_records()) -> ok. t_check_record_fields(Form, ExpTypes, Site, RecDict) -> - t_check_record_fields(Form, ExpTypes, Site, RecDict, dict:new()). + t_check_record_fields(Form, ExpTypes, Site, RecDict, maps:new()). -spec t_check_record_fields(parse_form(), sets:set(mfa()), site(), mod_records(), var_table()) -> ok. @@ -5192,8 +5138,9 @@ t_form_to_string({type, _L, Name, []} = T) -> D0 = dict:new(), MR = dict:from_list([{M, D0}]), S = {type, {M,Name,0}}, + V = #{}, {T1, _} = - t_from_form(T, [], sets:new(), S, MR, D0, _Deep=1000, _ALot=100000), + t_from_form(T, [], sets:new(), S, MR, V, _Deep=1000, _ALot=100000), t_to_string(T1) catch throw:{error, _} -> atom_to_string(Name) ++ "()" end; diff --git a/lib/hipe/test/bs_SUITE_data/bs_match_compiler.erl b/lib/hipe/test/bs_SUITE_data/bs_match_compiler.erl new file mode 100644 index 0000000000..4cb48ff57e --- /dev/null +++ b/lib/hipe/test/bs_SUITE_data/bs_match_compiler.erl @@ -0,0 +1,1235 @@ +%%% -*- erlang-indent-level: 2 -*- +%%%------------------------------------------------------------------- +%%% File : bs_match_compiler.erl +%%% +%%%------------------------------------------------------------------- +-module(bs_match_compiler). +-compile(nowarn_shadow_vars). + +-export([test/0]). +-export([exported_id/1, exported_id/2]). %% needed by a test + +test() -> + Funs = [fun fun_shadow/0, fun int_float/0, fun otp_5269/0, fun null_fields/0, + fun wiger/0, fun bin_tail/0, fun save_restore/0, + fun partitioned_bs_match/0, fun function_clause/0, fun unit/0, + fun shared_sub_bins/0, fun bin_and_float/0, fun dec_subidentifiers/0, + fun skip_optional_tag/0, fun wfbm/0, fun degenerated_match/0, + fun bs_sum/0, fun coverage/0, fun multiple_uses/0, fun zero_label/0, + fun followed_by_catch/0, fun matching_meets_construction/0, + fun simon/0, fun matching_and_andalso/0, + fun otp_7188/0, fun otp_7233/0, fun otp_7240/0, fun otp_7498/0, + fun match_string/0, fun zero_width/0, fun bad_size/0, fun haystack/0, + fun cover_beam_bool/0, fun matched_out_size/0, fun follow_fail_br/0, + fun no_partition/0, fun calling_a_binary/0, fun binary_in_map/0, + fun match_string_opt/0, fun map_and_binary/0, + fun unsafe_branch_caching/0], + lists:foreach(fun (F) -> ok = F() end, Funs). + + +%%-------------------------------------------------------------------- +%% OTP-5270 + +fun_shadow() -> + 7 = fun_shadow_1(), + 7 = fun_shadow_2(8), + 7 = fun_shadow_3(), + no = fun_shadow_4(8), + ok. + +fun_shadow_1() -> + L = 8, + F = fun(<<L:L,B:L>>) -> B end, + F(<<16:8, 7:16>>). + +fun_shadow_2(L) -> + F = fun(<<L:L,B:L>>) -> B end, + F(<<16:8, 7:16>>). + +fun_shadow_3() -> + L = 8, + F = fun(<<L:L,B:L,L:L>>) -> B end, + F(<<16:8, 7:16,16:16>>). + +fun_shadow_4(L) -> + F = fun(<<L:L,B:L,L:L>>) -> B; + (_) -> no end, + F(<<16:8, 7:16,15:16>>). + +%%-------------------------------------------------------------------- +%% OTP-5323 + +int_float() -> + <<103133.0:64/float>> = <<103133:64/float>>, + <<103133:64/float>> = <<103133:64/float>>, + ok. + +%%-------------------------------------------------------------------- +%% Stolen from erl_eval_SUITE and modified. +%% OTP-5269. Bugs in the bit syntax. + +otp_5269() -> + check(fun() -> L = 8, F = fun(<<A:L,B:A>>) -> B end, F(<<16:8, 7:16>>) end, 7), + check(fun() -> L = 8, <<A:L,B:A>> = <<16:8, 7:16>>, B end, 7), + check(fun() -> U = 8, (fun(<<U:U>>) -> U end)(<<32:8>>) end, 32), + check(fun() -> U = 8, [U || <<U:U>> <- [<<32:8>>]] end, [32]), + check(fun() -> [X || <<A:8, B:A>> <- [<<16:8,19:16>>], + <<X:8>> <- [<<B:8>>]] end, + [19]), + check(fun() -> A = 4, B = 28, _ = bit_size(<<13:(A+(X=B))>>), X end, 28), + check(fun() -> + <<Size,B:Size/binary,Rest/binary>> = <<2,"AB","CD">>, + {Size,B,Rest} + end, {2,<<"AB">>,<<"CD">>}), + check(fun() -> X = 32, [X || <<X:X>> <- [<<1:32>>,<<2:32>>,<<3:8>>]] end, + %% "binsize variable" ^ + [1,2]), + check(fun() -> + (fun (<<A:1/binary, B:8/integer, _C:B/binary>>) -> + case A of + B -> wrong; + _ -> ok + end + end)(<<1,2,3,4>>) end, + ok), + ok. + +%%-------------------------------------------------------------------- + +null_fields() -> + check(fun() -> + W = id(0), + F = fun(<<_:W>>) -> tail; + (<<>>) -> empty + end, + F(<<>>) + end, tail), + check(fun() -> + F = fun(<<_/binary>>) -> tail; + (<<>>) -> empty + end, + F(<<>>) + end, tail), + ok. + +%%-------------------------------------------------------------------- + +wiger() -> + ok1 = wcheck(<<3>>), + ok2 = wcheck(<<1,2,3>>), + ok3 = wcheck(<<4>>), + {error,<<1,2,3,4>>} = wcheck(<<1,2,3,4>>), + {error,<<>>} = wcheck(<<>>), + ok. + +wcheck(<<A>>) when A==3-> + ok1; +wcheck(<<_,_:2/binary>>) -> + ok2; +wcheck(<<_>>) -> + ok3; +wcheck(Other) -> + {error,Other}. + +%%-------------------------------------------------------------------- + +bin_tail() -> + S = <<"abcde">>, + $a = bin_tail_c(S, 0), + $c = bin_tail_c(S, 2), + $e = bin_tail_c(S, 4), + {'EXIT',_} = (catch bin_tail_c(S, 5)), + {'EXIT',_} = (catch bin_tail_c_var(S, 5)), + + $a = bin_tail_d(S, 0), + $b = bin_tail_d(S, 8), + $d = bin_tail_d(S, 3*8), + {'EXIT',_} = (catch bin_tail_d_dead(S, 1)), + {'EXIT',_} = (catch bin_tail_d_dead(S, 9)), + {'EXIT',_} = (catch bin_tail_d_dead(S, 5*8)), + {'EXIT',_} = (catch bin_tail_d_var(S, 1)), + + ok = bin_tail_e(<<2:2,0:1,1:5>>), + ok = bin_tail_e(<<2:2,1:1,1:5,42:64>>), + error = bin_tail_e(<<3:2,1:1,1:5,42:64>>), + error = bin_tail_e(<<>>), + ok. + +bin_tail_c(Bin, Offset) -> + Res = bin_tail_c_dead(Bin, Offset), + <<_:Offset/binary,_,Tail/binary>> = Bin, + {Res,Tail} = bin_tail_c_var(Bin, Offset), + Res. + +bin_tail_c_dead(Bin, Offset) -> + <<_:Offset/binary,C,_/binary>> = Bin, + C. + +bin_tail_c_var(Bin, Offset) -> + <<_:Offset/binary,C,Tail/binary>> = Bin, + {C,Tail}. + +bin_tail_d(Bin, BitOffset) -> + Res = bin_tail_d_dead(Bin, BitOffset), + <<_:BitOffset,_:8,Tail/binary>> = Bin, + {Res,Tail} = bin_tail_d_var(Bin, BitOffset), + Res. + +bin_tail_d_dead(Bin, BitOffset) -> + <<_:BitOffset,C,_/binary>> = Bin, + C. + +bin_tail_d_var(Bin, BitOffset) -> + <<_:BitOffset,C,Tail/binary>> = Bin, + {C,Tail}. + +bin_tail_e(Bin) -> + case bin_tail_e_dead(Bin) of + ok -> + <<_,Tail/binary>> = Bin, + Tail = bin_tail_e_var(Bin), + ok; + error -> + bin_tail_e_var(Bin) + end. + +bin_tail_e_dead(Bin) -> + case Bin of + %% The binary is aligned at the end; neither the bs_skip_bits2 nor + %% bs_test_tail2 instructions are needed. + <<2:2,_:1,1:5,_/binary>> -> ok; + _ -> error + end. + +bin_tail_e_var(Bin) -> + case Bin of + %% The binary is aligned at the end; neither the bs_skip_bits2 nor + %% bs_test_tail2 instructions are needed. + <<2:2,_:1,1:5,Tail/binary>> -> Tail; + _ -> error + end. + +%%-------------------------------------------------------------------- + +save_restore() -> + 0 = save_restore_1(<<0:2,42:6>>), + {1,3456} = save_restore_1(<<1:2,3456:14>>), + {2,7981234} = save_restore_1(<<2:2,7981234:30>>), + {3,763967493838} = save_restore_1(<<0:2,763967493838:62>>), + + A = <<" x">>, + B = <<".x">>, + C = <<"-x">>, + + {" ",<<"x">>} = lll(A), + {" ",<<"x">>} = mmm(A), + {" ",<<"x">>} = nnn(A), + {" ",<<"x">>} = ooo(A), + + {".",<<"x">>} = lll(B), + {".",<<"x">>} = mmm(B), + {".",<<"x">>} = nnn(B), + {".",<<"x">>} = ooo(B), + + {"-",<<"x">>} = lll(C), + {"-",<<"x">>} = mmm(C), + {"-",<<"x">>} = nnn(C), + {"-",<<"x">>} = ooo(C), + + Bin = <<-1:64>>, + case bad_float_unpack_match(Bin) of + -1 -> ok; + _Other -> bad_return_value_probably_NaN + end. + +save_restore_1(Bin) -> + case Bin of + <<0:2,_:6>> -> 0; + <<1:2,A:14>> -> {1,A}; + <<2:2,A:30>> -> {2,A}; + <<A:64>> -> {3,A} + end. + +lll(<<Char, Tail/binary>>) -> {[Char],Tail}. + +mmm(<<$.,$.,$., Tail/binary>>) -> Tail; +mmm(<<$\s,$-,$\s, Tail/binary>>) -> Tail; +mmm(<<Char, Tail/binary>>) -> {[Char],Tail}. %% Buggy Tail! + +nnn(<<"...", Tail/binary>>) -> Tail; +nnn(<<" - ", Tail/binary>>) -> Tail; +nnn(<<Char, Tail/binary>>) -> {[Char],Tail}. %% Buggy Tail! + +ooo(<<" - ", Tail/binary>>) -> Tail; +ooo(<<Char, Tail/binary>>) -> {[Char],Tail}. + +bad_float_unpack_match(<<F:64/float>>) -> F; +bad_float_unpack_match(<<I:64/integer-signed>>) -> I. + +%%-------------------------------------------------------------------- + +partitioned_bs_match() -> + <<1,2,3>> = partitioned_bs_match(blurf, <<42,1,2,3>>), + error = partitioned_bs_match(10, <<7,8,15,13>>), + error = partitioned_bs_match(100, {a,tuple,is,'not',a,binary}), + ok = partitioned_bs_match(0, <<>>), + fc(partitioned_bs_match, [-1,blurf], + catch partitioned_bs_match(-1, blurf)), + fc(partitioned_bs_match, [-1,<<1,2,3>>], + catch partitioned_bs_match(-1, <<1,2,3>>)), + {17,<<1,2,3>>} = partitioned_bs_match_2(1, <<17,1,2,3>>), + {7,<<1,2,3>>} = partitioned_bs_match_2(7, <<17,1,2,3>>), + + fc(partitioned_bs_match_2, [4,<<0:17>>], + catch partitioned_bs_match_2(4, <<0:17>>)), + + anything = partitioned_bs_match_3(anything, <<42>>), + ok = partitioned_bs_match_3(1, 2), + ok. + +partitioned_bs_match(_, <<42:8,T/binary>>) -> T; +partitioned_bs_match(N, _) when N > 0 -> error; +partitioned_bs_match(_, <<>>) -> ok. + +partitioned_bs_match_2(1, <<B:8,T/binary>>) -> {B,T}; +partitioned_bs_match_2(Len, <<_:8,T/binary>>) -> {Len,T}. + +partitioned_bs_match_3(Var, <<_>>) -> Var; +partitioned_bs_match_3(1, 2) -> ok. + +%%-------------------------------------------------------------------- + +function_clause() -> + ok = function_clause_1(<<0,7,0,7,42>>), + fc(function_clause_1, [<<0,1,2,3>>], + catch function_clause_1(<<0,1,2,3>>)), + fc(function_clause_1, [<<0,1,2,3>>], + catch function_clause_1(<<0,7,0,1,2,3>>)), + + ok = function_clause_2(<<0,7,0,7,42>>), + ok = function_clause_2(<<255>>), + ok = function_clause_2(<<13:4>>), + fc(function_clause_2, [<<0,1,2,3>>], + catch function_clause_2(<<0,1,2,3>>)), + fc(function_clause_2, [<<0,1,2,3>>], + catch function_clause_2(<<0,7,0,1,2,3>>)), + ok. + +function_clause_1(<<0:8,7:8,T/binary>>) -> + function_clause_1(T); +function_clause_1(<<_:8>>) -> + ok. + +function_clause_2(<<0:8,7:8,T/binary>>) -> + function_clause_2(T); +function_clause_2(<<_:8>>) -> + ok; +function_clause_2(<<_:4>>) -> + ok. + +%%-------------------------------------------------------------------- + +unit() -> + 42 = peek1(<<42>>), + 43 = peek1(<<43,1,2>>), + 43 = peek1(<<43,1,2,(-1):1>>), + 43 = peek1(<<43,1,2,(-1):2>>), + 43 = peek1(<<43,1,2,(-1):7>>), + + 99 = peek8(<<99>>), + 100 = peek8(<<100,101>>), + fc(peek8, [<<100,101,0:1>>], catch peek8(<<100,101,0:1>>)), + + 37484 = peek16(<<37484:16>>), + 37489 = peek16(<<37489:16,5566:16>>), + fc(peek16, [<<8>>], catch peek16(<<8>>)), + fc(peek16, [<<42:15>>], catch peek16(<<42:15>>)), + fc(peek16, [<<1,2,3,4,5>>], catch peek16(<<1,2,3,4,5>>)), + + 127 = peek7(<<127:7>>), + 100 = peek7(<<100:7,19:7>>), + fc(peek7, [<<1,2>>], catch peek7(<<1,2>>)), + ok. + +peek1(<<B:8,_/bitstring>>) -> B. + +peek7(<<B:7,_/binary-unit:7>>) -> B. + +peek8(<<B:8,_/binary>>) -> B. + +peek16(<<B:16,_/binary-unit:16>>) -> B. + +%%-------------------------------------------------------------------- + +shared_sub_bins() -> + {15,[<<>>,<<5>>,<<4,5>>,<<3,4,5>>,<<2,3,4,5>>]} = sum(<<1,2,3,4,5>>, [], 0), + ok. + +sum(<<B,T/binary>>, Acc, Sum) -> + sum(T, [T|Acc], Sum+B); +sum(<<>>, Last, Sum) -> {Sum,Last}. + +%%-------------------------------------------------------------------- + +bin_and_float() -> + 14.0 = bin_and_float(<<1.0/float,2.0/float,3.0/float>>, 0.0), + ok. + +bin_and_float(<<X/float,Y/float,Z/float,T/binary>>, Sum) when is_float(X), + is_float(Y), + is_float(Z) -> + bin_and_float(T, Sum+X*X+Y*Y+Z*Z); +bin_and_float(<<>>, Sum) -> Sum. + +%%-------------------------------------------------------------------- + +dec_subidentifiers() -> + {[],<<1,2,3>>} = + do_dec_subidentifiers(<<1:1,42:7,1:1,99:7,1,2,3>>, 0, [], 2), + {[5389],<<1,2,3>>} = + do_dec_subidentifiers(<<1:1,42:7,0:1,13:7,1,2,3>>, 0, [], 2), + {[3,2,1],not_a_binary} = dec_subidentifiers(not_a_binary, any, [1,2,3], 0), + ok. + +do_dec_subidentifiers(Buffer, Av, Al, Len) -> + Res = dec_subidentifiers(Buffer, Av, Al, Len), + Res = dec_subidentifiers2(Buffer, Av, Al, Len), + Res = dec_subidentifiers4(Buffer, Av, Al, Len), + Res = dec_subidentifiers3(Buffer, Av, Al, Len). + +dec_subidentifiers(Buffer, _Av, Al, 0) -> + {lists:reverse(Al),Buffer}; +dec_subidentifiers(<<1:1,H:7,T/binary>>, Av, Al, Len) -> + dec_subidentifiers(T, (Av bsl 7) bor H, Al, Len-1); +dec_subidentifiers(<<H,T/binary>>, Av, Al, Len) -> + dec_subidentifiers(T, 0, [((Av bsl 7) bor H)|Al], Len-1). + +dec_subidentifiers2(<<Buffer/binary>>, _Av, Al, 0) -> + {lists:reverse(Al),Buffer}; +dec_subidentifiers2(<<1:1,H:7,T/binary>>, Av, Al, Len) -> + dec_subidentifiers2(T, (Av bsl 7) bor H, Al, Len-1); +dec_subidentifiers2(<<H,T/binary>>, Av, Al, Len) -> + dec_subidentifiers2(T, 0, [((Av bsl 7) bor H)|Al], Len-1). + +dec_subidentifiers3(Buffer, _Av, Al, 0) when is_binary(Buffer) -> + {lists:reverse(Al),Buffer}; +dec_subidentifiers3(<<1:1,H:7,T/binary>>, Av, Al, Len) -> + dec_subidentifiers3(T, (Av bsl 7) bor H, Al, Len-1); +dec_subidentifiers3(<<H,T/binary>>, Av, Al, Len) -> + dec_subidentifiers3(T, 0, [((Av bsl 7) bor H)|Al], Len-1). + +dec_subidentifiers4(<<1:1,H:7,T/binary>>, Av, Al, Len) when Len =/= 0 -> + dec_subidentifiers4(T, (Av bsl 7) bor H, Al, Len-1); +dec_subidentifiers4(<<H,T/binary>>, Av, Al, Len) when Len =/= 0 -> + dec_subidentifiers4(T, 0, [((Av bsl 7) bor H)|Al], Len-1); +dec_subidentifiers4(Buffer, _Av, Al, 0) -> + {lists:reverse(Al),Buffer}. + +%%-------------------------------------------------------------------- + +skip_optional_tag() -> + {ok,<<>>} = skip_optional_tag(<<42>>, <<42>>), + {ok,<<>>} = skip_optional_tag(<<42,1>>, <<42,1>>), + {ok,<<1,2,3>>} = skip_optional_tag(<<42>>, <<42,1,2,3>>), + missing = skip_optional_tag(<<2:3>>, blurf), + ok. + +skip_optional_tag(<<>>, Binary) -> + {ok,Binary}; +skip_optional_tag(<<Tag,RestTag/binary>>, <<Tag,Rest/binary>>) -> + skip_optional_tag(RestTag, Rest); +skip_optional_tag(_, _) -> missing. + +%%-------------------------------------------------------------------- + +-define(DATELEN, 16). + +wfbm() -> + %% check_for_dot_or_space and get_tail is from wfbm4 by Steve Vinoski, + %% with modifications. + {nomatch,0} = check_for_dot_or_space(<<" ">>), + {nomatch,0} = check_for_dot_or_space(<<" abc">>), + {ok,<<"abcde">>} = check_for_dot_or_space(<<"abcde 34555">>), + {nomatch,0} = check_for_dot_or_space(<<".gurka">>), + {nomatch,1} = check_for_dot_or_space(<<"g.urka">>), + nomatch = get_tail(<<>>), + {ok,<<"2007/10/23/blurf">>} = get_tail(<<"200x/2007/10/23/blurf ">>), + {skip,?DATELEN+5} = get_tail(<<"200x/2007/10/23/blurf.">>), + nomatch = get_tail(<<"200y.2007.10.23.blurf ">>), + {'EXIT',_} = (catch get_tail({no,binary,at,all})), + {'EXIT',_} = (catch get_tail(no_binary)), + ok. + +check_for_dot_or_space(Bin) -> + check_for_dot_or_space(Bin, 0). + +check_for_dot_or_space(<<$\s, _/binary>>, 0) -> + {nomatch,0}; +check_for_dot_or_space(Bin, Len) -> + case Bin of + <<Front:Len/binary, $\s, _/binary>> -> + {ok,Front}; + <<_:Len/binary, $., _/binary>> -> + {nomatch,Len}; + _ -> + check_for_dot_or_space(Bin, Len+1) + end. + +get_tail(<<>>) -> + nomatch; +get_tail(Bin) -> + <<Front:?DATELEN/binary, Tail/binary>> = Bin, + case Front of + <<_:3/binary,"x/",Y:4/binary,$/,M:2/binary,$/,D:2/binary,$/>> -> + case check_for_dot_or_space(Tail) of + {ok,Match} -> + {ok,<<Y/binary,$/,M/binary,$/,D/binary,$/, Match/binary>>}; + {nomatch,Skip} -> {skip,?DATELEN + Skip} + end; + _ -> nomatch + end. + +%%-------------------------------------------------------------------- + +degenerated_match() -> + error = degenerated_match_1(<<>>), + 1 = degenerated_match_1(<<1:1>>), + 2 = degenerated_match_1(<<42,43>>), + + error = degenerated_match_2(<<>>), + no_split = degenerated_match_2(<<1,2>>), + {<<1,2,3,4>>,<<5>>} = degenerated_match_2(<<1,2,3,4,5>>), + ok. + +degenerated_match_1(<<>>) -> error; +degenerated_match_1(Bin) -> byte_size(Bin). + +degenerated_match_2(<<>>) -> error; +degenerated_match_2(Bin) -> + case byte_size(Bin) > 4 of + true -> split_binary(Bin, 4); + false -> no_split + end. + +%%-------------------------------------------------------------------- + +bs_sum() -> + 0 = bs_sum_1([]), + 0 = bs_sum_1(<<>>), + 42 = bs_sum_1([42]), + 1 = bs_sum_1(<<1>>), + 10 = bs_sum_1([1,2,3,4]), + 15 = bs_sum_1(<<1,2,3,4,5>>), + 21 = bs_sum_1([1,2,3|<<4,5,6>>]), + 15 = bs_sum_1([1,2,3|{4,5}]), + 6 = bs_sum_1([1,2,3|zero]), + 6 = bs_sum_1([1,2,3|0]), + 7 = bs_sum_1([1,2,3|one]), + + fc(catch bs_sum_1({too,big,tuple})), + fc(catch bs_sum_1([1,2,3|{too,big,tuple}])), + + [] = sneaky_alias(<<>>), + [559,387655] = sneaky_alias(id(<<559:32,387655:32>>)), + fc(sneaky_alias, [<<1>>], catch sneaky_alias(id(<<1>>))), + fc(sneaky_alias, [[1,2,3,4]], catch sneaky_alias(lists:seq(1, 4))), + ok. + +bs_sum_1(<<H,T/binary>>) -> H+bs_sum_1(T); +bs_sum_1([H|T]) -> H+bs_sum_1(T); +bs_sum_1({A,B}=_Tuple=_AliasForNoGoodReason) -> A+B; +bs_sum_1(0) -> 0; +bs_sum_1(zero=_Zero) -> 0; +bs_sum_1(one) -> 1; +bs_sum_1([]) -> 0; +bs_sum_1(<<>>) -> 0. + +sneaky_alias(<<>>=L) -> binary_to_list(L); +sneaky_alias(<<From:32,L/binary>>) -> [From|sneaky_alias(L)]. + +%%-------------------------------------------------------------------- + +coverage() -> + 0 = coverage_fold(fun(B, A) -> A+B end, 0, <<>>), + 6 = coverage_fold(fun(B, A) -> A+B end, 0, <<1,2,3>>), + fc(catch coverage_fold(fun(B, A) -> A+B end, 0, [a,b,c])), + + {<<42.0:64/float>>,float} = coverage_build(<<>>, <<42>>, float), + {<<>>,not_a_tuple} = coverage_build(<<>>, <<>>, not_a_tuple), + {<<16#76,"abc",16#A9,"abc">>,{x,42,43}} = + coverage_build(<<>>, <<16#7,16#A>>, {x,y,z}), + + [<<2>>,<<1>>] = coverage_bc(<<1,2>>, []), + + {x,<<"abc">>,z} = coverage_setelement(<<2,"abc">>, {x,y,z}), + + [42] = coverage_apply(<<42>>, [exported_id]), + 42 = coverage_external(<<42>>), + + do_coverage_bin_to_term_list([]), + do_coverage_bin_to_term_list([lists:seq(0, 10),{a,b,c},<<23:42>>]), + fc(coverage_bin_to_term_list, [<<0,0,0,7>>], + catch do_coverage_bin_to_term_list_1(<<7:32>>)), + + <<>> = coverage_per_key(<<4:32>>), + <<$a,$b,$c>> = coverage_per_key(<<7:32,"abc">>), + + ok. + +coverage_fold(Fun, Acc, <<H,T/binary>>) -> + IdFun = fun id/1, + coverage_fold(Fun, Fun(IdFun(H), IdFun(Acc)), T); +coverage_fold(Fun, Acc, <<>>) when is_function(Fun, 2) -> Acc. + +coverage_build(Acc0, <<H,T/binary>>, float) -> + Float = id(<<H:64/float>>), + Acc = <<Acc0/binary,Float/binary>>, + coverage_build(Acc, T, float); +coverage_build(Acc0, <<H,T/binary>>, Tuple0) -> + Str = id(<<H:(id(4)),(H-1):4,"abc">>), + Acc = id(<<Acc0/bitstring,Str/bitstring>>), + Tuple = setelement(2, setelement(3, Tuple0, 43), 42), + if + byte_size(Acc) > 0 -> + coverage_build(Acc, T, Tuple) + end; +coverage_build(Acc, <<>>, Tuple) -> {Acc,Tuple}. + +coverage_bc(<<H,T/binary>>, Acc) -> + B = << <<C:8>> || C <- [H] >>, + coverage_bc(T, [B|Acc]); +coverage_bc(<<>>, Acc) -> Acc. + +coverage_setelement(<<H,T1/binary>>, Tuple) when element(1, Tuple) =:= x -> + setelement(H, Tuple, T1). + +coverage_apply(<<H,T/binary>>, [F|Fs]) -> + [?MODULE:F(H)|coverage_apply(T, Fs)]; +coverage_apply(<<>>, []) -> []. + +coverage_external(<<H,T/binary>>) -> + ?MODULE:exported_id(T, T), + H. + +exported_id(I) -> id(I). + +exported_id(_, _) -> ok. + +do_coverage_bin_to_term_list(L) -> + Bin = << <<(begin BinTerm = term_to_binary(Term), + <<(byte_size(BinTerm)):32,BinTerm/binary>> end)/binary>> || + Term <- L >>, + L = do_coverage_bin_to_term_list_1(Bin), + L = do_coverage_bin_to_term_list_1(<<Bin/binary,7:32,"garbage">>), + L = do_coverage_bin_to_term_list_1(<<7:32,"garbage",Bin/binary>>). + +do_coverage_bin_to_term_list_1(Bin) -> + Res = coverage_bin_to_term_list(Bin), + Res = coverage_bin_to_term_list(Bin, []), + Res = coverage_bin_to_term_list_catch(Bin), + Res = coverage_bin_to_term_list_catch(Bin, []). + +coverage_bin_to_term_list(<<Sz:32,BinTerm:Sz/binary,T/binary>>) -> + try binary_to_term(BinTerm) of + Term -> [Term|coverage_bin_to_term_list(T)] + catch + error:badarg -> coverage_bin_to_term_list(T) + end; +coverage_bin_to_term_list(<<>>) -> []. + +coverage_bin_to_term_list(<<Sz:32,BinTerm:Sz/binary,T/binary>>, Acc) -> + try binary_to_term(BinTerm) of + Term -> coverage_bin_to_term_list(T, [Term|Acc]) + catch + error:badarg -> coverage_bin_to_term_list(T, Acc) + end; +coverage_bin_to_term_list(<<>>, Acc) -> lists:reverse(Acc). + +coverage_bin_to_term_list_catch(<<Sz:32,BinTerm:Sz/binary,T/binary>>) -> + case catch binary_to_term(BinTerm) of + {'EXIT',_} -> coverage_bin_to_term_list_catch(T); + Term -> [Term|coverage_bin_to_term_list_catch(T)] + end; +coverage_bin_to_term_list_catch(<<>>) -> []. + +coverage_bin_to_term_list_catch(<<Sz:32,BinTerm:Sz/binary,T/binary>>, Acc) -> + case catch binary_to_term(BinTerm) of + {'EXIT',_} -> coverage_bin_to_term_list_catch(T, Acc); + Term -> coverage_bin_to_term_list_catch(T, [Term|Acc]) + end; +coverage_bin_to_term_list_catch(<<>>, Acc) -> lists:reverse(Acc). + +coverage_per_key(<<BinSize:32,Bin/binary>> = B) -> + true = (byte_size(B) =:= BinSize), + Bin. + +%%-------------------------------------------------------------------- + +multiple_uses() -> + {344,62879,345,<<245,159,1,89>>} = multiple_uses_1(<<1,88,245,159,1,89>>), + true = multiple_uses_2(<<0,0,197,18>>), + <<42,43>> = multiple_uses_3(<<0,0,42,43>>, fun id/1), + ok. + +multiple_uses_1(<<X:16,Tail/binary>>) -> + %% NOT OPTIMIZED: sub binary is matched or used in more than one place + {Y,Z} = multiple_uses_match(Tail), + {X,Y,Z,Tail}. + +multiple_uses_2(<<_:16,Tail/binary>>) -> + %% NOT OPTIMIZED: sub binary is matched or used in more than one place + multiple_uses_cmp(Tail, Tail). + +multiple_uses_3(<<_:16,Tail/binary>>, Fun) -> + %% NOT OPTIMIZED: sub binary is used or returned + Fun(Tail). + +multiple_uses_match(<<Y:16,Z:16>>) -> {Y,Z}. + +multiple_uses_cmp(<<Y:16>>, <<Y:16>>) -> true; +multiple_uses_cmp(<<_:16>>, <<_:16>>) -> false. + +%%-------------------------------------------------------------------- + +zero_label() -> + <<"nosemouth">> = read_pols(<<"FACE","nose","mouth">>), + <<"CE">> = read_pols(<<"noFACE">>), + ok. + +read_pols(Data) -> + <<PolygonType:4/binary,Rest/binary>> = Data, + %% Intentional warning. + _ = (PolygonType == <<"FACE">>) or (PolygonType == <<"PTCH">>), + Rest. + +%%-------------------------------------------------------------------- + +followed_by_catch() -> + ok = handle(<<0,1,2,3,4,5>>). + +-record(rec,{field}). +handle(<<>>) -> ok; +handle(Msg) -> + <<_DataLen:16, Rest/binary>> = Msg, + case catch fooX:func() of + [X] -> + X#rec.field; + _ -> + ok + end, + handle(Rest). + +%%-------------------------------------------------------------------- + +matching_meets_construction() -> + Bin = id(<<"abc">>), + Len = id(2), + Tail0 = id(<<1,2,3,4,5>>), + <<_:Len/binary,Tail/binary>> = Tail0, + Res = <<Tail/binary,Bin/binary>>, + <<3,4,5,"abc">> = Res, + {'EXIT',{badarg,_}} = (catch matching_meets_construction_1(<<"Abc">>)), + {'EXIT',{badarg,_}} = (catch matching_meets_construction_2(<<"Abc">>)), + <<"Bbc">> = matching_meets_construction_3(<<"Abc">>), + <<1,2>> = encode_octet_string(<<1,2,3>>, 2), + ok. + +matching_meets_construction_1(<<"A",H/binary>>) -> <<"B",H>>. + +matching_meets_construction_2(<<"A",H/binary>>) -> <<"B",H/float>>. + +matching_meets_construction_3(<<"A",H/binary>>) -> <<"B",H/binary>>. + +encode_octet_string(<<OctetString/binary>>, Len) -> + <<OctetString:Len/binary-unit:8>>. + +%%-------------------------------------------------------------------- + +simon() -> + one = simon(blurf, <<>>), + two = simon(0, <<42>>), + fc(simon, [17,<<1>>], catch simon(17, <<1>>)), + fc(simon, [0,<<1,2,3>>], catch simon(0, <<1,2,3>>)), + + one = simon2(blurf, <<9>>), + two = simon2(0, <<9,1>>), + fc(simon2, [0,<<9,10,11>>], catch simon2(0, <<9,10,11>>)), + ok. + +simon(_, <<>>) -> one; +simon(0, <<_>>) -> two. + +simon2(_, <<9>>) -> one; +simon2(0, <<_:16>>) -> two. + +%%-------------------------------------------------------------------- +%% OTP-7113: Crash in v3_codegen. + +matching_and_andalso() -> + ok = matching_and_andalso_1(<<1,2,3>>, 3), + {'EXIT',{function_clause,_}} = (catch matching_and_andalso_1(<<1,2,3>>, -8)), + {'EXIT',{function_clause,_}} = (catch matching_and_andalso_1(<<1,2,3>>, blurf)), + {'EXIT',{function_clause,_}} = (catch matching_and_andalso_1(<<1,2,3>>, 19)), + + {"abc",<<"xyz">>} = matching_and_andalso_2("abc", <<"-xyz">>), + {"abc",<<"">>} = matching_and_andalso_2("abc", <<($a-1)>>), + {"abc",<<"">>} = matching_and_andalso_2("abc", <<($z+1)>>), + {"abc",<<"">>} = matching_and_andalso_2("abc", <<($A-1)>>), + {"abc",<<"">>} = matching_and_andalso_2("abc", <<($Z+1)>>), + error = matching_and_andalso_2([], <<>>), + error = matching_and_andalso_2([], <<$A>>), + error = matching_and_andalso_2([], <<$Z>>), + error = matching_and_andalso_2([], <<$a>>), + error = matching_and_andalso_2([], <<$z>>), + ok. + +matching_and_andalso_1(<<Bitmap/binary>>, K) + when is_integer(K) andalso size(Bitmap) >= K andalso 0 < K -> ok. + +matching_and_andalso_2(Datetime, <<H,T/binary>>) + when not ((H >= $a) andalso (H =< $z)) andalso + not ((H >= $A) andalso (H =< $Z)) -> + {Datetime,T}; +matching_and_andalso_2(_, _) -> error. + +%%-------------------------------------------------------------------- +%% Thanks to Tomas Stejskal. + +otp_7188() -> + MP3 = <<84,65,71,68,117,154,105,232,107,121,0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0,0,0,0,68,97,110,105,101,108,32,76, + 97,110,100,97,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,66, + 101,115,116,32,79,102,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,50,48,48,48,50,48,48,48,32,45,32,66,101,115, + 116,32,79,102,32,32,32,32,32,32,32,32,32,32,32,32,32,32, + 32,32,12>>, + {ok,{"ID3v1", + [{title,<<68,117,154,105,232,107,121>>}, + {artist,<<"Daniel Landa">>}, + {album,<<"Best Of">>}]}} = parse_v1_or_v11_tag(MP3), + ok. + +parse_v1_or_v11_tag(<<"TAG", Title:30/binary, + Artist:30/binary, Album:30/binary, + _Year:4/binary, _Comment:28/binary, + 0:8, Track:8, _Genre:8>>) -> + {ok, + {"ID3v1.1", + [{track, Track}, {title, trim(Title)}, + {artist, trim(Artist)}, {album, trim(Album)}]}}; +parse_v1_or_v11_tag(<<"TAG", Title:30/binary, + Artist:30/binary, Album:30/binary, + _Year:4/binary, _Comment:30/binary, + _Genre:8>>) -> + {ok, + {"ID3v1", + [{title, trim(Title)}, + {artist, trim(Artist)}, + {album, trim(Album)}]}}; +parse_v1_or_v11_tag(_) -> + error. + +trim(Bin) -> + list_to_binary(trim_blanks(binary_to_list(Bin))). + +trim_blanks(L) -> + lists:reverse(skip_blanks_and_zero(lists:reverse(L))). + +skip_blanks_and_zero([$\s|T]) -> + skip_blanks_and_zero(T); +skip_blanks_and_zero([0|T]) -> + skip_blanks_and_zero(T); +skip_blanks_and_zero(L) -> + L. + +%%-------------------------------------------------------------------- +%% OTP-7233. Record and binary matching optimizations clashed. +%% Thanks to Vladimir Klebansky. + +-record(rec_otp_7233, {key, val}). + +otp_7233() -> + otp_7233_1(#rec_otp_7233{key = <<"XXabcde">>,val=[{"xxxxxxxx",42}]}), + [<<"XXabcde">>,{"xxxxxxxx",42}] = get(io_format), + erase(io_format), + otp_7233_1(#rec_otp_7233{key = <<"XXabcde">>,val=[]}), + undefined = get(io_format), + ok. + +otp_7233_1(Rec) -> + <<K:2/binary,_Rest:5/binary>> = Rec#rec_otp_7233.key, + case K of + <<"XX">> -> + Value = Rec#rec_otp_7233.val, + case lists:keysearch("xxxxxxxx", 1, Value) of + {value,T} -> put(io_format, [Rec#rec_otp_7233.key,T]); + false -> ok + end; + _ -> ok + end. + +%%-------------------------------------------------------------------- + +otp_7240() -> + a = otp_7240_a(0, <<>>), + b = otp_7240_a(1, 2), + + a = otp_7240_b(anything, <<>>), + b = otp_7240_b(1, {x,y}), + + a = otp_7240_c(anything, <<>>), + b = otp_7240_c(1, <<2>>), + + a = otp_7240_d(anything, <<>>), + b = otp_7240_d(again, <<2>>), + + a = otp_7240_e(anything, <<>>), + b = otp_7240_e(1, 41), + + a = otp_7240_f(anything, <<>>), + b = otp_7240_f(1, {}), + + ok. + +otp_7240_a(_, <<>>) -> a; +otp_7240_a(1, 2) -> b. + +otp_7240_b(_, <<>>) -> a; +otp_7240_b(1, {_,_}) -> b. + +otp_7240_c(_, <<>>) -> a; +otp_7240_c(1, <<2>>) -> b. + +otp_7240_d(_, <<>>) -> a; +otp_7240_d(_, <<2>>) -> b. + +otp_7240_e(_, <<>>) -> a; +otp_7240_e(1, B) when B < 42 -> b. + +otp_7240_f(_, <<>>) -> a; +otp_7240_f(1, B) when is_tuple(B) -> b. + +%%-------------------------------------------------------------------- + +otp_7498() -> + <<1,2,3>> = otp_7498_foo(<<1,2,3>>, 0), + <<2,3>> = otp_7498_foo(<<1,2,3>>, 1), + <<1,2,3>> = otp_7498_foo(<<1,2,3>>, 2), + + <<1,2,3>> = otp_7498_bar(<<1,2,3>>, 0), + <<2,3>> = otp_7498_bar(<<1,2,3>>, 1), + <<1,2,3>> = otp_7498_bar(<<1,2,3>>, 2), + <<>> = otp_7498_bar(<<>>, 2), + <<1,2,3>> = otp_7498_bar(<<1,2,3>>, 3), + ok. + +otp_7498_foo(Bin, 0) -> + otp_7498_foo(Bin, 42); +otp_7498_foo(<<_A, Rest/bitstring>>, 1) -> + otp_7498_foo(Rest, 43); +otp_7498_foo(Bin, _I) -> + Bin. + +otp_7498_bar(Bin, 0) -> + otp_7498_bar(Bin, 42); +otp_7498_bar(<<_A, Rest/bitstring>>, 1) -> + otp_7498_bar(Rest, 43); +otp_7498_bar(<<>>, 2) -> + otp_7498_bar(<<>>, 44); +otp_7498_bar(Bin, _I) -> + Bin. + +%%-------------------------------------------------------------------- + +match_string() -> + %% To make sure that native endian really is handled correctly + %% (i.e. that the compiler does not attempt to use bs_match_string/4 + %% instructions for native segments), running this test is not enough. + %% Either examine the generated for do_match_string_native/1 or + %% check the coverage for the v3_kernel module. + case erlang:system_info(endian) of + little -> + do_match_string_native(<<$a,0,$b,0>>); + big -> + do_match_string_native(<<0,$a,0,$b>>) + end, + do_match_string_big(<<0,$a,0,$b>>), + do_match_string_little(<<$a,0,$b,0>>), + + do_match_string_big_signed(<<255,255>>), + do_match_string_little_signed(<<255,255>>), + + plain = no_match_string_opt(<<"abc">>), + strange = no_match_string_opt(<<$a:9,$b:9,$c:9>>), + ok. + +do_match_string_native(<<$a:16/native,$b:16/native>>) -> ok. + +do_match_string_big(<<$a:16/big,$b:16/big>>) -> ok. + +do_match_string_little(<<$a:16/little,$b:16/little>>) -> ok. + +do_match_string_big_signed(<<(-1):16/signed>>) -> ok. + +do_match_string_little_signed(<<(-1):16/little-signed>>) -> ok. + +no_match_string_opt(<<"abc">>) -> plain; +no_match_string_opt(<<$a:9,$b:9,$c:9>>) -> strange. + +%%-------------------------------------------------------------------- +%% OTP-7591: A zero-width segment in matching would crash the compiler. + +zero_width() -> + <<Len:16/little, Str:Len/binary, 0:0>> = <<2, 0, $h, $i, 0:0>>, + 2 = Len, + Str = <<"hi">>, + %% Match sure that values that cannot fit in a segment will not match. + case id(<<0:8>>) of + <<256:8>> -> error; + _ -> ok + end. + +%%-------------------------------------------------------------------- +%% OTP_7650: A invalid size for binary segments could crash the compiler. + +bad_size() -> + Tuple = {a,b,c}, + {'EXIT',{{badmatch,<<>>},_}} = (catch <<32:Tuple>> = id(<<>>)), + Binary = <<1,2,3>>, + {'EXIT',{{badmatch,<<>>},_}} = (catch <<32:Binary>> = id(<<>>)), + ok. + +%%-------------------------------------------------------------------- + +haystack() -> + <<0:10/unit:8>> = haystack_1(<<0:10/unit:8>>), + [<<0:10/unit:8>>, + <<0:20/unit:8>>] = haystack_2(<<1:8192>>), + ok. + +%% Used to crash the compiler. +haystack_1(Haystack) -> + Subs = [10], + [begin + <<B:Y/binary>> = Haystack, + B + end || Y <- Subs], + Haystack. + +%% There would be an incorrect badmatch exception. +haystack_2(Haystack) -> + Subs = [{687,10},{369,20}], + [begin + <<_:X/binary,B:Y/binary,_/binary>> = Haystack, + B + end || {X,Y} <- Subs]. + +fc({'EXIT',{function_clause,_}}) -> ok. + +fc(Name, Args, {'EXIT',{function_clause,[{?MODULE,Name,Args,_}|_]}}) -> ok; +fc(Name, Args, {'EXIT',{function_clause,[{?MODULE,Name,Arity,_}|_]}}) + when length(Args) =:= Arity -> + true = test_server:is_native(?MODULE). + +%%-------------------------------------------------------------------- +%% Cover the clause handling bs_context to binary in +%% beam_block:initialized_regs/2. +cover_beam_bool() -> + ok = do_cover_beam_bool(<<>>, 3), + <<19>> = do_cover_beam_bool(<<19>>, 2), + <<42>> = do_cover_beam_bool(<<42>>, 1), + <<17>> = do_cover_beam_bool(<<13,17>>, 0), + ok. + +do_cover_beam_bool(Bin, X) when X > 0 -> + if + X =:= 1; X =:= 2 -> + Bin; + true -> + ok + end; +do_cover_beam_bool(<<_,Bin/binary>>, X) -> + do_cover_beam_bool(Bin, X+1). + +%%-------------------------------------------------------------------- + +matched_out_size() -> + {253,16#DEADBEEF} = mos_int(<<8,253,16#DEADBEEF:32>>), + {6,16#BEEFDEAD} = mos_int(<<3,6:3,16#BEEFDEAD:32>>), + {53,16#CAFEDEADBEEFCAFE} = mos_int(<<16,53:16,16#CAFEDEADBEEFCAFE:64>>), + {23,16#CAFEDEADBEEFCAFE} = mos_int(<<5,23:5,16#CAFEDEADBEEFCAFE:64>>), + + {<<1,2,3>>,4} = mos_bin(<<3,1,2,3,4,3>>), + {<<1,2,3,7>>,19,42} = mos_bin(<<4,1,2,3,7,19,4,42>>), + <<1,2,3,7>> = mos_bin(<<4,1,2,3,7,"abcdefghij">>), + ok. + +mos_int(<<L,I:L,X:32>>) -> + {I,X}; +mos_int(<<L,I:L,X:64>>) -> + {I,X}. + +mos_bin(<<L,Bin:L/binary,X:8,L>>) -> + L = byte_size(Bin), + {Bin,X}; +mos_bin(<<L,Bin:L/binary,X:8,L,Y:8>>) -> + L = byte_size(Bin), + {Bin,X,Y}; +mos_bin(<<L,Bin:L/binary,"abcdefghij">>) -> + L = byte_size(Bin), + Bin. + +%%-------------------------------------------------------------------- + +follow_fail_br() -> + 42 = ffb_1(<<0,1>>, <<0>>), + 8 = ffb_1(<<0,1>>, [a]), + 42 = ffb_2(<<0,1>>, <<0>>, 17), + 8 = ffb_2(<<0,1>>, [a], 0), + ok. + +ffb_1(<<_,T/bitstring>>, List) -> + case List of + <<_>> -> + 42; + [_|_] -> + %% The fail branch of the bs_start_match2 instruction pointing + %% to here would be ignored, making the compiler incorrectly + %% assume that the delayed sub-binary optimization was safe. + bit_size(T) + end. + +ffb_2(<<_,T/bitstring>>, List, A) -> + case List of + <<_>> when A =:= 17 -> 42; + [_|_] -> bit_size(T) + end. + +%%-------------------------------------------------------------------- + +no_partition() -> + one = no_partition_1(<<"string">>, a1), + {two,<<"string">>} = no_partition_1(<<"string">>, a2), + {two,<<>>} = no_partition_1(<<>>, a2), + {two,a} = no_partition_1(a, a2), + three = no_partition_1(undefined, a3), + {four,a,[]} = no_partition_1([a], a4), + {five,a,b} = no_partition_1({a,b}, a5), + + one = no_partition_2(<<"string">>, a1), + two = no_partition_2(<<"string">>, a2), + two = no_partition_2(<<>>, a2), + two = no_partition_2(a, a2), + three = no_partition_2(undefined, a3), + four = no_partition_2(42, a4), + five = no_partition_2([], a5), + six = no_partition_2(42.0, a6), + ok. + +no_partition_1(<<"string">>, a1) -> one; +no_partition_1(V, a2) -> {two,V}; +no_partition_1(undefined, a3) -> three; +no_partition_1([H|T], a4) -> {four,H,T}; +no_partition_1({A,B}, a5) -> {five,A,B}. + +no_partition_2(<<"string">>, a1) -> one; +no_partition_2(_, a2) -> two; +no_partition_2(undefined, a3) -> three; +no_partition_2(42, a4) -> four; +no_partition_2([], a5) -> five; +no_partition_2(42.0, a6) -> six. + +%%-------------------------------------------------------------------- + +calling_a_binary() -> + [] = call_binary(<<>>, []), + {'EXIT',{badarg,_}} = (catch call_binary(<<1>>, [])), + {'EXIT',{badarg,_}} = (catch call_binary(<<1,2,3>>, [])), + ok. + +call_binary(<<>>, Acc) -> + Acc; +call_binary(<<H,T/bits>>, Acc) -> + T(<<Acc/binary,H>>). + +%%-------------------------------------------------------------------- + +binary_in_map() -> + ok = match_binary_in_map(#{key => <<42:8>>}), + {'EXIT',{{badmatch,#{key := 1}},_}} = + (catch match_binary_in_map(#{key => 1})), + {'EXIT',{{badmatch,#{key := <<1023:16>>}},_}} = + (catch match_binary_in_map(#{key => <<1023:16>>})), + {'EXIT',{{badmatch,#{key := <<1:8>>}},_}} = + (catch match_binary_in_map(#{key => <<1:8>>})), + {'EXIT',{{badmatch,not_a_map},_}} = + (catch match_binary_in_map(not_a_map)), + ok. + +match_binary_in_map(Map) -> + case 8 of + N -> + #{key := <<42:N>>} = Map, + ok + end. + +%%-------------------------------------------------------------------- + +match_string_opt() -> + {x,<<1,2,3>>,{<<1>>,{v,<<1,2,3>>}}} = match_string_opt({<<1>>,{v,<<1,2,3>>}}), + ok. + +match_string_opt({<<1>>,{v,V}}=T) -> + {x,V,T}. + +%%-------------------------------------------------------------------- +%% If 'bin_opt_info' was given the warning would lack filename and +%% line number. + +map_and_binary() -> + {<<"10">>,<<"37">>,<<"am">>} = do_map_and_binary(<<"10:37am">>), + Map1 = #{time => "noon"}, + {ok,Map1} = do_map_and_binary(Map1), + Map2 = #{hour => 8, min => 42}, + {8,42,Map2} = do_map_and_binary(Map2), + ok. + +do_map_and_binary(<<Hour:2/bytes, $:, Min:2/bytes, Rest/binary>>) -> + {Hour, Min, Rest}; +do_map_and_binary(#{time := _} = T) -> + {ok, T}; +do_map_and_binary(#{hour := Hour, min := Min} = T) -> + {Hour, Min, T}. + +%%-------------------------------------------------------------------- +%% Unsafe caching of branch outcomes in beam_bsm would cause the +%% delayed creation of sub-binaries optimization to be applied even +%% when it was unsafe. + +unsafe_branch_caching() -> + <<>> = do_unsafe_branch_caching(<<42,1>>), + <<>> = do_unsafe_branch_caching(<<42,2>>), + <<>> = do_unsafe_branch_caching(<<42,3>>), + <<17,18>> = do_unsafe_branch_caching(<<42,3,17,18>>), + <<>> = do_unsafe_branch_caching(<<1,3,42,2>>), + ok. + +do_unsafe_branch_caching(<<Code/integer, Bin/binary>>) -> + <<C1/integer, B1/binary>> = Bin, + case C1 of + X when X =:= 1 orelse X =:= 2 -> + Bin2 = <<>>; + _ -> + Bin2 = B1 + end, + case Code of + 1 -> do_unsafe_branch_caching(Bin2); + _ -> Bin2 + end. + +%%-------------------------------------------------------------------- + +check(F, R) -> + R = F(). + +id(I) -> I. diff --git a/lib/hipe/test/hipe_testsuite_driver.erl b/lib/hipe/test/hipe_testsuite_driver.erl index 9f5d7421b4..64c5c0a7c9 100644 --- a/lib/hipe/test/hipe_testsuite_driver.erl +++ b/lib/hipe/test/hipe_testsuite_driver.erl @@ -107,7 +107,7 @@ write_suite(Suite) -> write_header(#suite{suitename = SuiteName, outputfile = OutputFile, testcases = TestCases}) -> Exports = format_export(TestCases), - TimeLimit = 2, %% with 1 it fails on some slow machines... + TimeLimit = 3, %% with 1 or 2 it fails on some slow machines... io:format(OutputFile, "%% ATTENTION!\n" "%% This is an automatically generated file. Do not edit.\n\n" diff --git a/lib/inets/doc/src/notes.xml b/lib/inets/doc/src/notes.xml index bd6b76a73e..5cebce18a9 100644 --- a/lib/inets/doc/src/notes.xml +++ b/lib/inets/doc/src/notes.xml @@ -33,7 +33,25 @@ <file>notes.xml</file> </header> - <section><title>Inets 6.2.2</title> + <section><title>Inets 6.2.3</title> + + <section><title>Improvements and New Features</title> + <list> + <item> + <p> + Put back unused module inets_regexp and remove it in OTP + 19 instead as it is an incompatibility, although it is an + undocumented module and should not affect other + applications.</p> + <p> + Own Id: OTP-13533</p> + </item> + </list> + </section> + +</section> + +<section><title>Inets 6.2.2</title> <section><title>Improvements and New Features</title> <list> diff --git a/lib/inets/src/inets_app/Makefile b/lib/inets/src/inets_app/Makefile index 1d870c14e8..a294381f67 100644 --- a/lib/inets/src/inets_app/Makefile +++ b/lib/inets/src/inets_app/Makefile @@ -49,7 +49,8 @@ MODULES = \ inets_sup \ inets_trace \ inets_lib \ - inets_time_compat + inets_time_compat \ + inets_regexp INTERNAL_HRL_FILES = inets_internal.hrl EXTERNAL_HRL_FILES = ../../include/httpd.hrl \ diff --git a/lib/inets/src/inets_app/inets.app.src b/lib/inets/src/inets_app/inets.app.src index 5706a335d7..abf8c0cdea 100644 --- a/lib/inets/src/inets_app/inets.app.src +++ b/lib/inets/src/inets_app/inets.app.src @@ -29,6 +29,7 @@ inets_trace, inets_lib, inets_time_compat, + inets_regexp, %% FTP ftp, diff --git a/lib/inets/src/inets_app/inets.appup.src b/lib/inets/src/inets_app/inets.appup.src index a603357ebd..3a31daeb20 100644 --- a/lib/inets/src/inets_app/inets.appup.src +++ b/lib/inets/src/inets_app/inets.appup.src @@ -18,16 +18,10 @@ %% %CopyrightEnd% {"%VSN%", [ - {<<"6.2.1">>, [{load_module, httpd_script_env, soft_purge, soft_purge, []}]}, - {<<"6.2">>, [{load_module, httpd_script_env, soft_purge, soft_purge, []}, - {load_module, httpc, soft_purge, soft_purge, []}]}, {<<"6\\..*">>,[{restart_application, inets}]}, {<<"5\\..*">>,[{restart_application, inets}]} ], [ - {<<"6.2.1">>, [{load_module, httpd_script_env, soft_purge, soft_purge, []}]}, - {<<"6.2">>, [{load_module, httpd_script_env, soft_purge, soft_purge, []}, - {load_module, httpc, soft_purge, soft_purge, []}]}, {<<"6\\..*">>,[{restart_application, inets}]}, {<<"5\\..*">>,[{restart_application, inets}]} ] diff --git a/lib/inets/src/inets_app/inets_regexp.erl b/lib/inets/src/inets_app/inets_regexp.erl new file mode 100644 index 0000000000..fc1608bc5a --- /dev/null +++ b/lib/inets/src/inets_app/inets_regexp.erl @@ -0,0 +1,414 @@ +%% +%% %CopyrightBegin% +%% +%% Copyright Ericsson AB 2009. All Rights Reserved. +%% +%% Licensed under the Apache License, Version 2.0 (the "License"); +%% you may not use this file except in compliance with the License. +%% You may obtain a copy of the License at +%% +%% http://www.apache.org/licenses/LICENSE-2.0 +%% +%% Unless required by applicable law or agreed to in writing, software +%% distributed under the License is distributed on an "AS IS" BASIS, +%% WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +%% See the License for the specific language governing permissions and +%% limitations under the License. +%% +%% %CopyrightEnd% +%% + +-module(inets_regexp). + +-export([parse/1, match/2, first_match/2, split/2, sub/3, gsub/3]). + + +%%%========================================================================= +%%% API +%%%========================================================================= + +%% parse(RegExp) -> {ok, RE} | {error, E}. +%% Parse the regexp described in the string RegExp. + +parse(S) -> + case (catch reg(S)) of + {R, []} -> + {ok, R}; + {_R, [C|_]} -> + {error, {illegal, [C]}}; + {error, E} -> + {error, E} + end. + + +%% Find the longest match of RegExp in String. + +match(S, RegExp) when is_list(RegExp) -> + case parse(RegExp) of + {ok,RE} -> match(S, RE); + {error,E} -> {error,E} + end; +match(S, RE) -> + case match(RE, S, 1, 0, -1) of + {Start,Len} when Len >= 0 -> + {match, Start, Len}; + {_Start,_Len} -> + nomatch + end. + +%% Find the first match of RegExp in String. + +first_match(S, RegExp) when is_list(RegExp) -> + case parse(RegExp) of + {ok, RE} -> + first_match(S, RE); + {error, E} -> + {error, E} + end; +first_match(S, RE) -> + case first_match(RE, S, 1) of + {Start,Len} when Len >= 0 -> + {match, Start,Len}; + nomatch -> + nomatch + end. + +first_match(RE, S, St) when S =/= [] -> + case re_apply(S, St, RE) of + {match, P, _Rest} -> + {St, P-St}; + nomatch -> + first_match(RE, tl(S), St+1) + end; +first_match(_RE, [], _St) -> + nomatch. + + +match(RE, S, St, Pos, L) -> + case first_match(RE, S, St) of + {St1, L1} -> + Nst = St1 + 1, + if L1 > L -> + match(RE, lists:nthtail(Nst-St, S), Nst, St1, L1); + true -> + match(RE, lists:nthtail(Nst-St, S), Nst, Pos, L) + end; + nomatch -> + {Pos, L} + end. + + +%% Split a string into substrings where the RegExp describes the +%% field seperator. The RegExp " " is specially treated. + +split(String, " ") -> %This is really special + {ok, RE} = parse("[ \t]+"), + case split_apply(String, RE, true) of + [[]|Ss] -> + {ok,Ss}; + Ss -> + {ok,Ss} + end; +split(String, RegExp) when is_list(RegExp) -> + case parse(RegExp) of + {ok, RE} -> + {ok, split_apply(String, RE, false)}; + {error, E} -> + {error,E} + end; +split(String, RE) -> + {ok, split_apply(String, RE, false)}. + + +%% Substitute the first match of the regular expression RegExp +%% with the string Replace in String. Accept pre-parsed regular +%% expressions. + +sub(String, RegExp, Rep) when is_list(RegExp) -> + case parse(RegExp) of + {ok, RE} -> + sub(String, RE, Rep); + {error, E} -> + {error, E} + end; +sub(String, RE, Rep) -> + Ss = sub_match(String, RE, 1), + {ok, sub_repl(Ss, Rep, String, 1), length(Ss)}. + + +%% Substitute every match of the regular expression RegExp with +%% the string New in String. Accept pre-parsed regular expressions. + +gsub(String, RegExp, Rep) when is_list(RegExp) -> + case parse(RegExp) of + {ok, RE} -> + gsub(String, RE, Rep); + {error, E} -> + {error, E} + end; +gsub(String, RE, Rep) -> + Ss = matches(String, RE, 1), + {ok, sub_repl(Ss, Rep, String, 1), length(Ss)}. + + +%%%======================================================================== +%%% Internal functions +%%%======================================================================== + +%% This is the regular expression grammar used. It is equivalent to the +%% one used in AWK, except that we allow ^ $ to be used anywhere and fail +%% in the matching. +%% +%% reg -> reg1 : '$1'. +%% reg1 -> reg1 "|" reg2 : {'or','$1','$2'}. +%% reg1 -> reg2 : '$1'. +%% reg2 -> reg2 reg3 : {concat,'$1','$2'}. +%% reg2 -> reg3 : '$1'. +%% reg3 -> reg3 "*" : {kclosure,'$1'}. +%% reg3 -> reg3 "+" : {pclosure,'$1'}. +%% reg3 -> reg3 "?" : {optional,'$1'}. +%% reg3 -> reg4 : '$1'. +%% reg4 -> "(" reg ")" : '$2'. +%% reg4 -> "\\" char : '$2'. +%% reg4 -> "^" : bos. +%% reg4 -> "$" : eos. +%% reg4 -> "." : char. +%% reg4 -> "[" class "]" : {char_class,char_class('$2')} +%% reg4 -> "[" "^" class "]" : {comp_class,char_class('$3')} +%% reg4 -> "\"" chars "\"" : char_string('$2') +%% reg4 -> char : '$1'. +%% reg4 -> empty : epsilon. +%% The grammar of the current regular expressions. The actual parser +%% is a recursive descent implementation of the grammar. + +reg(S) -> reg1(S). + +%% reg1 -> reg2 reg1' +%% reg1' -> "|" reg2 +%% reg1' -> empty + +reg1(S0) -> + {L,S1} = reg2(S0), + reg1p(S1, L). + +reg1p([$||S0], L) -> + {R,S1} = reg2(S0), + reg1p(S1, {'or',L,R}); +reg1p(S, L) -> {L,S}. + +%% reg2 -> reg3 reg2' +%% reg2' -> reg3 +%% reg2' -> empty + +reg2(S0) -> + {L,S1} = reg3(S0), + reg2p(S1, L). + +reg2p([C|S0], L) when (C =/= $|) andalso (C =/= $)) -> + {R,S1} = reg3([C|S0]), + reg2p(S1, {concat,L,R}); +reg2p(S, L) -> {L,S}. + +%% reg3 -> reg4 reg3' +%% reg3' -> "*" reg3' +%% reg3' -> "+" reg3' +%% reg3' -> "?" reg3' +%% reg3' -> empty + +reg3(S0) -> + {L,S1} = reg4(S0), + reg3p(S1, L). + +reg3p([$*|S], L) -> reg3p(S, {kclosure,L}); +reg3p([$+|S], L) -> reg3p(S, {pclosure,L}); +reg3p([$?|S], L) -> reg3p(S, {optional,L}); +reg3p(S, L) -> {L,S}. + +reg4([$(|S0]) -> + case reg(S0) of + {R,[$)|S1]} -> {R,S1}; + {_R,_S} -> throw({error,{unterminated,"("}}) + end; +reg4([$\\,O1,O2,O3|S]) + when ((O1 >= $0) andalso + (O1 =< $7) andalso + (O2 >= $0) andalso + (O2 =< $7) andalso + (O3 >= $0) andalso + (O3 =< $7)) -> + {(O1*8 + O2)*8 + O3 - 73*$0,S}; +reg4([$\\,C|S]) -> + {escape_char(C),S}; +reg4([$\\]) -> + throw({error, {unterminated,"\\"}}); +reg4([$^|S]) -> + {bos,S}; +reg4([$$|S]) -> + {eos,S}; +reg4([$.|S]) -> + {{comp_class,"\n"},S}; +reg4("[^" ++ S0) -> + case char_class(S0) of + {Cc,[$]|S1]} -> {{comp_class,Cc},S1}; + {_Cc,_S} -> throw({error,{unterminated,"["}}) + end; +reg4([$[|S0]) -> + case char_class(S0) of + {Cc,[$]|S1]} -> {{char_class,Cc},S1}; + {_Cc,_S1} -> throw({error,{unterminated,"["}}) + end; +reg4([C|S]) + when (C =/= $*) andalso (C =/= $+) andalso (C =/= $?) andalso (C =/= $]) -> + {C, S}; +reg4([C|_S]) -> + throw({error,{illegal,[C]}}); +reg4([]) -> + {epsilon,[]}. + +escape_char($n) -> $\n; %\n = LF +escape_char($r) -> $\r; %\r = CR +escape_char($t) -> $\t; %\t = TAB +escape_char($v) -> $\v; %\v = VT +escape_char($b) -> $\b; %\b = BS +escape_char($f) -> $\f; %\f = FF +escape_char($e) -> $\e; %\e = ESC +escape_char($s) -> $\s; %\s = SPACE +escape_char($d) -> $\d; %\d = DEL +escape_char(C) -> C. + +char_class([$]|S]) -> char_class(S, [$]]); +char_class(S) -> char_class(S, []). + +char($\\, [O1,O2,O3|S]) when + O1 >= $0, O1 =< $7, O2 >= $0, O2 =< $7, O3 >= $0, O3 =< $7 -> + {(O1*8 + O2)*8 + O3 - 73*$0,S}; +char($\\, [C|S]) -> {escape_char(C),S}; +char(C, S) -> {C,S}. + +char_class([C1|S0], Cc) when C1 =/= $] -> + case char(C1, S0) of + {Cf,[$-,C2|S1]} when C2 =/= $] -> + case char(C2, S1) of + {Cl,S2} when Cf < Cl -> char_class(S2, [{Cf,Cl}|Cc]); + {Cl,_S2} -> throw({error,{char_class,[Cf,$-,Cl]}}) + end; + {C,S1} -> char_class(S1, [C|Cc]) + end; +char_class(S, Cc) -> {Cc,S}. + + +%% re_apply(String, StartPos, RegExp) -> re_app_res(). +%% +%% Apply the (parse of the) regular expression RegExp to String. If +%% there is a match return the position of the remaining string and +%% the string if else return 'nomatch'. BestMatch specifies if we want +%% the longest match, or just a match. +%% +%% StartPos should be the real start position as it is used to decide +%% if we ae at the beginning of the string. +%% +%% Pass two functions to re_apply_or so it can decide, on the basis +%% of BestMatch, whether to just any take any match or try both to +%% find the longest. This is slower but saves duplicatng code. + +re_apply(S, St, RE) -> re_apply(RE, [], S, St). + +re_apply(epsilon, More, S, P) -> %This always matches + re_apply_more(More, S, P); +re_apply({'or',RE1,RE2}, More, S, P) -> + re_apply_or(re_apply(RE1, More, S, P), + re_apply(RE2, More, S, P)); +re_apply({concat,RE1,RE2}, More, S0, P) -> + re_apply(RE1, [RE2|More], S0, P); +re_apply({kclosure,CE}, More, S, P) -> + %% Be careful with the recursion, explicitly do one call before + %% looping. + re_apply_or(re_apply_more(More, S, P), + re_apply(CE, [{kclosure,CE}|More], S, P)); +re_apply({pclosure,CE}, More, S, P) -> + re_apply(CE, [{kclosure,CE}|More], S, P); +re_apply({optional,CE}, More, S, P) -> + re_apply_or(re_apply_more(More, S, P), + re_apply(CE, More, S, P)); +re_apply(bos, More, S, 1) -> re_apply_more(More, S, 1); +re_apply(eos, More, [$\n|S], P) -> re_apply_more(More, S, P); +re_apply(eos, More, [], P) -> re_apply_more(More, [], P); +re_apply({char_class,Cc}, More, [C|S], P) -> + case in_char_class(C, Cc) of + true -> re_apply_more(More, S, P+1); + false -> nomatch + end; +re_apply({comp_class,Cc}, More, [C|S], P) -> + case in_char_class(C, Cc) of + true -> nomatch; + false -> re_apply_more(More, S, P+1) + end; +re_apply(C, More, [C|S], P) when is_integer(C) -> + re_apply_more(More, S, P+1); +re_apply(_RE, _More, _S, _P) -> nomatch. + +%% re_apply_more([RegExp], String, Length) -> re_app_res(). + +re_apply_more([RE|More], S, P) -> re_apply(RE, More, S, P); +re_apply_more([], S, P) -> {match,P,S}. + +%% in_char_class(Char, Class) -> bool(). + +in_char_class(C, [{C1,C2}|_Cc]) when C >= C1, C =< C2 -> true; +in_char_class(C, [C|_Cc]) -> true; +in_char_class(C, [_|Cc]) -> in_char_class(C, Cc); +in_char_class(_C, []) -> false. + +%% re_apply_or(Match1, Match2) -> re_app_res(). +%% If we want the best match then choose the longest match, else just +%% choose one by trying sequentially. + +re_apply_or({match,P1,S1}, {match,P2,_S2}) when P1 >= P2 -> {match,P1,S1}; +re_apply_or({match,_P1,_S1}, {match,P2,S2}) -> {match,P2,S2}; +re_apply_or(nomatch, R2) -> R2; +re_apply_or(R1, nomatch) -> R1. + + +matches(S, RE, St) -> + case first_match(RE, S, St) of + {St1,0} -> + [{St1,0}|matches(string:substr(S, St1+2-St), RE, St1+1)]; + {St1,L1} -> + [{St1,L1}|matches(string:substr(S, St1+L1+1-St), RE, St1+L1)]; + nomatch -> + [] + end. + +sub_match(S, RE, St) -> + case first_match(RE, S, St) of + {St1,L1} -> [{St1,L1}]; + nomatch -> [] + end. + +sub_repl([{St,L}|Ss], Rep, S, Pos) -> + Rs = sub_repl(Ss, Rep, S, St+L), + string:substr(S, Pos, St-Pos) ++ + sub_repl(Rep, string:substr(S, St, L), Rs); +sub_repl([], _Rep, S, Pos) -> + string:substr(S, Pos). + +sub_repl([$&|Rep], M, Rest) -> M ++ sub_repl(Rep, M, Rest); +sub_repl("\\&" ++ Rep, M, Rest) -> [$&|sub_repl(Rep, M, Rest)]; +sub_repl([C|Rep], M, Rest) -> [C|sub_repl(Rep, M, Rest)]; +sub_repl([], _M, Rest) -> Rest. + +split_apply(S, RE, Trim) -> split_apply(S, 1, RE, Trim, []). + +split_apply([], _P, _RE, true, []) -> + []; +split_apply([], _P, _RE, _T, Sub) -> + [lists:reverse(Sub)]; +split_apply(S, P, RE, T, Sub) -> + case re_apply(S, P, RE) of + {match,P,_Rest} -> + split_apply(tl(S), P+1, RE, T, [hd(S)|Sub]); + {match,P1,Rest} -> + [lists:reverse(Sub)|split_apply(Rest, P1, RE, T, [])]; + nomatch -> + split_apply(tl(S), P+1, RE, T, [hd(S)|Sub]) + end. diff --git a/lib/inets/vsn.mk b/lib/inets/vsn.mk index fc33b546d9..ef985f7c4e 100644 --- a/lib/inets/vsn.mk +++ b/lib/inets/vsn.mk @@ -18,7 +18,6 @@ # # %CopyrightEnd% -APPLICATION = inets -INETS_VSN = 6.2.2 +INETS_VSN = 6.3 PRE_VSN = APP_VSN = "$(APPLICATION)-$(INETS_VSN)$(PRE_VSN)" diff --git a/lib/jinterface/java_src/pom.xml.src b/lib/jinterface/java_src/pom.xml.src index cef49b735a..98232db78c 100644 --- a/lib/jinterface/java_src/pom.xml.src +++ b/lib/jinterface/java_src/pom.xml.src @@ -7,14 +7,14 @@ <version>%VSN%</version> <name>jinterface</name> <description> - Jinterface Java package contains java classes, which help you integrate programs written in Java with Erlang. + Jinterface Java package contains java classes, which help you integrate programs written in Java with Erlang. Erlang is a programming language designed at the Ericsson Computer Science Laboratory. - </description> + </description> <url>http://erlang.org/</url> <licenses> <license> - <name>ERLANG PUBLIC LICENSE 1.1</name> - <url>http://www.erlang.org/EPLICENSE</url> + <name>Apache License 2.0</name> + <url>http://www.apache.org/licenses/LICENSE-2.0</url> <distribution>repo</distribution> </license> </licenses> @@ -37,14 +37,16 @@ <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-compiler-plugin</artifactId> + <version>3.5.1</version> <configuration> - <source>1.5</source> - <target>1.5</target> + <source>1.6</source> + <target>1.6</target> </configuration> </plugin> <plugin> <groupId>org.codehaus.mojo</groupId> <artifactId>build-helper-maven-plugin</artifactId> + <version>1.10</version> <executions> <execution> <phase>generate-sources</phase> @@ -59,6 +61,32 @@ </execution> </executions> </plugin> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-source-plugin</artifactId> + <version>3.0.0</version> + <executions> + <execution> + <id>attach-sources</id> + <goals> + <goal>jar-no-fork</goal> + </goals> + </execution> + </executions> + </plugin> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-javadoc-plugin</artifactId> + <version>2.10.3</version> + <executions> + <execution> + <id>attach-javadocs</id> + <goals> + <goal>jar</goal> + </goals> + </execution> + </executions> + </plugin> </plugins> </build> <distributionManagement> @@ -85,7 +113,7 @@ <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-gpg-plugin</artifactId> - <version>1.0-alpha-4</version> + <version>1.6</version> <executions> <execution> <id>sign-artifacts</id> diff --git a/lib/kernel/src/code_server.erl b/lib/kernel/src/code_server.erl index 25dddb1f6c..6174136507 100644 --- a/lib/kernel/src/code_server.erl +++ b/lib/kernel/src/code_server.erl @@ -32,7 +32,12 @@ -import(lists, [foreach/2]). --type on_load_item() :: {reference(),module(),file:name_all(),[pid()]}. +-type on_load_action() :: + fun((term(), state()) -> {'reply',term(),state()} | + {'noreply',state()}). + +-type on_load_item() :: {{pid(),reference()},module(), + [{pid(),on_load_action()}]}. -record(state, {supervisor :: pid(), root :: file:name_all(), @@ -76,7 +81,7 @@ init(Ref, Parent, [Root,Mode]) -> interactive -> LibDir = filename:append(Root, "lib"), {ok,Dirs} = erl_prim_loader:list_dir(LibDir), - {Paths,_Libs} = make_path(LibDir, Dirs), + Paths = make_path(LibDir, Dirs), UserLibPaths = get_user_lib_dirs(), ["."] ++ UserLibPaths ++ Paths; _ -> @@ -111,7 +116,7 @@ get_user_lib_dirs() -> get_user_lib_dirs_1([Dir|DirList]) -> case erl_prim_loader:list_dir(Dir) of {ok, Dirs} -> - {Paths,_Libs} = make_path(Dir, Dirs), + Paths = make_path(Dir, Dirs), %% Only add paths trailing with ./ebin. [P || P <- Paths, filename:basename(P) =:= "ebin"] ++ get_user_lib_dirs_1(DirList); @@ -142,7 +147,7 @@ reply(Pid, Res) -> loop(#state{supervisor=Supervisor}=State0) -> receive {code_call, Pid, Req} -> - case handle_call(Req, {Pid, call}, State0) of + case handle_call(Req, Pid, State0) of {reply, Res, State} -> _ = reply(Pid, Res), loop(State); @@ -155,8 +160,8 @@ loop(#state{supervisor=Supervisor}=State0) -> system_terminate(Reason, Supervisor, [], State0); {system, From, Msg} -> handle_system_msg(running,Msg, From, Supervisor, State0); - {'DOWN',Ref,process,_,Res} -> - State = finish_on_load(Ref, Res, State0), + {'DOWN',Ref,process,Pid,Res} -> + State = finish_on_load({Pid,Ref}, Res, State0), loop(State); _Msg -> loop(State0) @@ -225,90 +230,90 @@ system_code_change(State, _Module, _OldVsn, _Extra) -> %% The gen_server call back functions. %% -handle_call({stick_dir,Dir}, {_From,_Tag}, S) -> +handle_call({stick_dir,Dir}, _From, S) -> {reply,stick_dir(Dir, true, S),S}; -handle_call({unstick_dir,Dir}, {_From,_Tag}, S) -> +handle_call({unstick_dir,Dir}, _From, S) -> {reply,stick_dir(Dir, false, S),S}; -handle_call({stick_mod,Mod}, {_From,_Tag}, S) -> +handle_call({stick_mod,Mod}, _From, S) -> {reply,stick_mod(Mod, true, S),S}; -handle_call({unstick_mod,Mod}, {_From,_Tag}, S) -> +handle_call({unstick_mod,Mod}, _From, S) -> {reply,stick_mod(Mod, false, S),S}; -handle_call({dir,Dir}, {_From,_Tag}, S) -> +handle_call({dir,Dir}, _From, S) -> Root = S#state.root, Resp = do_dir(Root,Dir,S#state.namedb), {reply,Resp,S}; -handle_call({load_file,Mod}, Caller, St) when is_atom(Mod) -> - load_file(Mod, Caller, St); +handle_call({load_file,Mod}, From, St) when is_atom(Mod) -> + load_file(Mod, From, St); -handle_call({add_path,Where,Dir0}, {_From,_Tag}, +handle_call({add_path,Where,Dir0}, _From, #state{namedb=Namedb,path=Path0}=S) -> {Resp,Path} = add_path(Where, Dir0, Path0, Namedb), {reply,Resp,S#state{path=Path}}; -handle_call({add_paths,Where,Dirs0}, {_From,_Tag}, +handle_call({add_paths,Where,Dirs0}, _From, #state{namedb=Namedb,path=Path0}=S) -> {Resp,Path} = add_paths(Where, Dirs0, Path0, Namedb), {reply,Resp,S#state{path=Path}}; -handle_call({set_path,PathList}, {_From,_Tag}, +handle_call({set_path,PathList}, _From, #state{path=Path0,namedb=Namedb}=S) -> {Resp,Path,NewDb} = set_path(PathList, Path0, Namedb), {reply,Resp,S#state{path=Path,namedb=NewDb}}; -handle_call({del_path,Name}, {_From,_Tag}, +handle_call({del_path,Name}, _From, #state{path=Path0,namedb=Namedb}=S) -> {Resp,Path} = del_path(Name, Path0, Namedb), {reply,Resp,S#state{path=Path}}; -handle_call({replace_path,Name,Dir}, {_From,_Tag}, +handle_call({replace_path,Name,Dir}, _From, #state{path=Path0,namedb=Namedb}=S) -> {Resp,Path} = replace_path(Name, Dir, Path0, Namedb), {reply,Resp,S#state{path=Path}}; -handle_call(get_path, {_From,_Tag}, S) -> +handle_call(get_path, _From, S) -> {reply,S#state.path,S}; %% Messages to load, delete and purge modules/files. -handle_call({load_abs,File,Mod}, Caller, S) when is_atom(Mod) -> +handle_call({load_abs,File,Mod}, From, S) when is_atom(Mod) -> case modp(File) of false -> {reply,{error,badarg},S}; true -> - load_abs(File, Mod, Caller, S) + load_abs(File, Mod, From, S) end; -handle_call({load_binary,Mod,File,Bin}, Caller, S) when is_atom(Mod) -> - do_load_binary(Mod, File, Bin, Caller, S); +handle_call({load_binary,Mod,File,Bin}, From, S) when is_atom(Mod) -> + do_load_binary(Mod, File, Bin, From, S); -handle_call({load_native_partial,Mod,Bin}, {_From,_Tag}, S) -> +handle_call({load_native_partial,Mod,Bin}, _From, S) -> Architecture = erlang:system_info(hipe_architecture), Result = (catch hipe_unified_loader:load(Mod, Bin, Architecture)), Status = hipe_result_to_status(Result, S), {reply,Status,S}; -handle_call({load_native_sticky,Mod,Bin,WholeModule}, {_From,_Tag}, S) -> +handle_call({load_native_sticky,Mod,Bin,WholeModule}, _From, S) -> Architecture = erlang:system_info(hipe_architecture), Result = (catch hipe_unified_loader:load_module(Mod, Bin, WholeModule, Architecture)), Status = hipe_result_to_status(Result, S), {reply,Status,S}; -handle_call({ensure_loaded,Mod}, Caller, St) when is_atom(Mod) -> +handle_call({ensure_loaded,Mod}, From, St) when is_atom(Mod) -> case erlang:module_loaded(Mod) of true -> {reply,{module,Mod},St}; false when St#state.mode =:= interactive -> - load_file(Mod, Caller, St); + ensure_loaded(Mod, From, St); false -> {reply,{error,embedded},St} end; -handle_call({delete,Mod}, {_From,_Tag}, St) when is_atom(Mod) -> +handle_call({delete,Mod}, _From, St) when is_atom(Mod) -> case catch erlang:delete_module(Mod) of true -> ets:delete(St#state.moddb, Mod), @@ -317,48 +322,50 @@ handle_call({delete,Mod}, {_From,_Tag}, St) when is_atom(Mod) -> {reply,false,St} end; -handle_call({purge,Mod}, {_From,_Tag}, St) when is_atom(Mod) -> +handle_call({purge,Mod}, _From, St) when is_atom(Mod) -> {reply,do_purge(Mod),St}; -handle_call({soft_purge,Mod}, {_From,_Tag}, St) when is_atom(Mod) -> +handle_call({soft_purge,Mod}, _From, St) when is_atom(Mod) -> {reply,do_soft_purge(Mod),St}; -handle_call({is_loaded,Mod}, {_From,_Tag}, St) when is_atom(Mod) -> +handle_call({is_loaded,Mod}, _From, St) when is_atom(Mod) -> {reply,is_loaded(Mod, St#state.moddb),St}; -handle_call(all_loaded, {_From,_Tag}, S) -> +handle_call(all_loaded, _From, S) -> Db = S#state.moddb, {reply,all_loaded(Db),S}; -handle_call({get_object_code,Mod}, {_From,_Tag}, St) when is_atom(Mod) -> +handle_call({get_object_code,Mod}, _From, St) when is_atom(Mod) -> Path = St#state.path, case mod_to_bin(Path, Mod) of {_,Bin,FName} -> {reply,{Mod,Bin,FName},St}; Error -> {reply,Error,St} end; -handle_call({is_sticky, Mod}, {_From,_Tag}, S) -> +handle_call({is_sticky, Mod}, _From, S) -> Db = S#state.moddb, {reply, is_sticky(Mod,Db), S}; -handle_call(stop,{_From,_Tag}, S) -> +handle_call(stop,_From, S) -> {stop,normal,stopped,S}; -handle_call({set_primary_archive, File, ArchiveBin, FileInfo, ParserFun}, {_From,_Tag}, S=#state{mode=Mode}) -> - case erl_prim_loader:set_primary_archive(File, ArchiveBin, FileInfo, ParserFun) of +handle_call({set_primary_archive, File, ArchiveBin, FileInfo, ParserFun}, + _From, S=#state{mode=Mode}) -> + case erl_prim_loader:set_primary_archive(File, ArchiveBin, FileInfo, + ParserFun) of {ok, Files} -> {reply, {ok, Mode, Files}, S}; {error, _Reason} = Error -> {reply, Error, S} end; -handle_call(get_mode, {_From,_Tag}, S=#state{mode=Mode}) -> +handle_call(get_mode, _From, S=#state{mode=Mode}) -> {reply, Mode, S}; -handle_call({finish_loading,Prepared,EnsureLoaded}, {_,_}, S) -> +handle_call({finish_loading,Prepared,EnsureLoaded}, _From, S) -> {reply,finish_loading(Prepared, EnsureLoaded, S),S}; -handle_call(Other,{_From,_Tag}, S) -> +handle_call(Other,_From, S) -> error_msg(" ** Codeserver*** ignoring ~w~n ",[Other]), {noreply,S}. @@ -371,7 +378,7 @@ handle_call(Other,{_From,_Tag}, S) -> %% make_path(BundleDir, Bundles0) -> Bundles = choose_bundles(Bundles0), - make_path(BundleDir, Bundles, [], []). + make_path(BundleDir, Bundles, []). choose_bundles(Bundles) -> ArchiveExt = archive_extension(), @@ -381,12 +388,10 @@ choose_bundles(Bundles) -> create_bundle(FullName, ArchiveExt) -> BaseName = filename:basename(FullName, ArchiveExt), - case split(BaseName, "-") of - [_, _|_] = Toks -> - VsnStr = lists:last(Toks), + case split_base(BaseName) of + {Name, VsnStr} -> case vsn_to_num(VsnStr) of {ok, VsnNum} -> - Name = join(lists:sublist(Toks, length(Toks)-1),"-"), {Name,VsnNum,FullName}; false -> {FullName,[0],FullName} @@ -457,41 +462,44 @@ choose([{Name,NumVsn,NewFullName}=New|Bs], Acc, ArchiveExt) -> choose([],Acc, _ArchiveExt) -> Acc. -make_path(_,[],Res,Bs) -> - {Res,Bs}; -make_path(BundleDir,[Bundle|Tail],Res,Bs) -> - Dir = filename:append(BundleDir,Bundle), - Ebin = filename:append(Dir,"ebin"), +make_path(_, [], Res) -> + Res; +make_path(BundleDir, [Bundle|Tail], Res) -> + Dir = filename:append(BundleDir, Bundle), + Ebin = filename:append(Dir, "ebin"), %% First try with /ebin - case erl_prim_loader:read_file_info(Ebin) of - {ok,#file_info{type=directory}} -> - make_path(BundleDir,Tail,[Ebin|Res],[Bundle|Bs]); - _ -> + case is_dir(Ebin) of + true -> + make_path(BundleDir, Tail, [Ebin|Res]); + false -> %% Second try with archive Ext = archive_extension(), - Base = filename:basename(Dir, Ext), - Ebin2 = filename:join([filename:dirname(Dir), Base ++ Ext, Base, "ebin"]), + Base = filename:basename(Bundle, Ext), + Ebin2 = filename:join([BundleDir, Base ++ Ext, Base, "ebin"]), Ebins = - case split(Base, "-") of - [_, _|_] = Toks -> - AppName = join(lists:sublist(Toks, length(Toks)-1),"-"), - Ebin3 = filename:join([filename:dirname(Dir), Base ++ Ext, AppName, "ebin"]), + case split_base(Base) of + {AppName,_} -> + Ebin3 = filename:join([BundleDir, Base ++ Ext, + AppName, "ebin"]), [Ebin3, Ebin2, Dir]; _ -> [Ebin2, Dir] end, - try_ebin_dirs(Ebins,BundleDir,Tail,Res,Bundle, Bs) + case try_ebin_dirs(Ebins) of + {ok,FoundEbin} -> + make_path(BundleDir, Tail, [FoundEbin|Res]); + error -> + make_path(BundleDir, Tail, Res) + end end. -try_ebin_dirs([Ebin | Ebins],BundleDir,Tail,Res,Bundle,Bs) -> - case erl_prim_loader:read_file_info(Ebin) of - {ok,#file_info{type=directory}} -> - make_path(BundleDir,Tail,[Ebin|Res],[Bundle|Bs]); - _ -> - try_ebin_dirs(Ebins,BundleDir,Tail,Res,Bundle,Bs) +try_ebin_dirs([Ebin|Ebins]) -> + case is_dir(Ebin) of + true -> {ok,Ebin}; + false -> try_ebin_dirs(Ebins) end; -try_ebin_dirs([],BundleDir,Tail,Res,_Bundle,Bs) -> - make_path(BundleDir,Tail,Res,Bs). +try_ebin_dirs([]) -> + error. %% @@ -609,19 +617,34 @@ exclude(Dir,Path) -> %% %% get_name(Dir) -> - get_name2(get_name1(Dir), []). + get_name_from_splitted(filename:split(Dir)). + +get_name_from_splitted([DirName,"ebin"]) -> + discard_after_hyphen(DirName); +get_name_from_splitted([DirName]) -> + discard_after_hyphen(DirName); +get_name_from_splitted([_|T]) -> + get_name_from_splitted(T); +get_name_from_splitted([]) -> + "". %No name. + +discard_after_hyphen("-"++_) -> + []; +discard_after_hyphen([H|T]) -> + [H|discard_after_hyphen(T)]; +discard_after_hyphen([]) -> + []. -get_name1(Dir) -> - case lists:reverse(filename:split(Dir)) of - ["ebin",DirName|_] -> DirName; - [DirName|_] -> DirName; - _ -> "" % No name ! +split_base(BaseName) -> + case split(BaseName, "-") of + [_, _|_] = Toks -> + Vsn = lists:last(Toks), + AllButLast = lists:droplast(Toks), + {join(AllButLast, "-"),Vsn}; + [_|_] -> + BaseName end. -get_name2([$-|_],Acc) -> lists:reverse(Acc); -get_name2([H|T],Acc) -> get_name2(T,[H|Acc]); -get_name2(_,Acc) -> lists:reverse(Acc). - check_path(Path) -> PathChoice = init:code_path_choice(), ArchiveExt = archive_extension(), @@ -630,23 +653,23 @@ check_path(Path) -> do_check_path([], _PathChoice, _ArchiveExt, Acc) -> {ok, lists:reverse(Acc)}; do_check_path([Dir | Tail], PathChoice, ArchiveExt, Acc) -> - case catch erl_prim_loader:read_file_info(Dir) of - {ok, #file_info{type=directory}} -> + case is_dir(Dir) of + true -> do_check_path(Tail, PathChoice, ArchiveExt, [Dir | Acc]); - _ when PathChoice =:= strict -> + false when PathChoice =:= strict -> %% Be strict. Only use dir as explicitly stated {error, bad_directory}; - _ when PathChoice =:= relaxed -> + false when PathChoice =:= relaxed -> %% Be relaxed case catch lists:reverse(filename:split(Dir)) of {'EXIT', _} -> {error, bad_directory}; ["ebin", App] -> Dir2 = filename:join([App ++ ArchiveExt, App, "ebin"]), - case erl_prim_loader:read_file_info(Dir2) of - {ok, #file_info{type = directory}} -> + case is_dir(Dir2) of + true -> do_check_path(Tail, PathChoice, ArchiveExt, [Dir2 | Acc]); - _ -> + false -> {error, bad_directory} end; ["ebin", App, OptArchive | RevTop] -> @@ -666,10 +689,10 @@ do_check_path([Dir | Tail], PathChoice, ArchiveExt, Acc) -> Top = lists:reverse([OptArchive | RevTop]), filename:join(Top ++ [App ++ ArchiveExt, App, "ebin"]) end, - case erl_prim_loader:read_file_info(Dir2) of - {ok, #file_info{type = directory}} -> + case is_dir(Dir2) of + true -> do_check_path(Tail, PathChoice, ArchiveExt, [Dir2 | Acc]); - _ -> + false -> {error, bad_directory} end; _ -> @@ -768,7 +791,7 @@ init_namedb(Path) -> Db. init_namedb([P|Path], Db) -> - insert_name(P, Db), + insert_dir(P, Db), init_namedb(Path, Db); init_namedb([], _) -> ok. @@ -781,59 +804,39 @@ clear_namedb([], _) -> ok. -endif. -insert_name(Dir, Db) -> - case get_name(Dir) of - Dir -> false; - Name -> insert_name(Name, Dir, Db) - end. +%% Dir must be a complete pathname (not only a name). +insert_dir(Dir, Db) -> + Splitted = filename:split(Dir), + Name = get_name_from_splitted(Splitted), + AppDir = filename:join(del_ebin_1(Splitted)), + do_insert_name(Name, AppDir, Db). insert_name(Name, Dir, Db) -> AppDir = del_ebin(Dir), + do_insert_name(Name, AppDir, Db). + +do_insert_name(Name, AppDir, Db) -> {Base, SubDirs} = archive_subdirs(AppDir), ets:insert(Db, {Name, AppDir, Base, SubDirs}), true. archive_subdirs(AppDir) -> - IsDir = - fun(RelFile) -> - File = filename:join([AppDir, RelFile]), - case erl_prim_loader:read_file_info(File) of - {ok, #file_info{type = directory}} -> - false; - _ -> - true - end - end, - {Base, ArchiveDirs} = all_archive_subdirs(AppDir), - {Base, lists:filter(IsDir, ArchiveDirs)}. - -all_archive_subdirs(AppDir) -> - Ext = archive_extension(), Base = filename:basename(AppDir), - Dirs = - case split(Base, "-") of - [_, _|_] = Toks -> - Base2 = join(lists:sublist(Toks, length(Toks)-1), "-"), - [Base2, Base]; - _ -> - [Base] + Dirs = case split_base(Base) of + {Name, _} -> [Name, Base]; + _ -> [Base] end, + Ext = archive_extension(), try_archive_subdirs(AppDir ++ Ext, Base, Dirs). try_archive_subdirs(Archive, Base, [Dir | Dirs]) -> - ArchiveDir = filename:join([Archive, Dir]), + ArchiveDir = filename:append(Archive, Dir), case erl_prim_loader:list_dir(ArchiveDir) of {ok, Files} -> - IsDir = - fun(RelFile) -> - File = filename:join([ArchiveDir, RelFile]), - case erl_prim_loader:read_file_info(File) of - {ok, #file_info{type = directory}} -> - true; - _ -> - false - end - end, + IsDir = fun(RelFile) -> + File = filename:append(ArchiveDir, RelFile), + is_dir(File) + end, {Dir, lists:filter(IsDir, Files)}; _ -> try_archive_subdirs(Archive, Base, Dirs) @@ -927,22 +930,22 @@ check_pars(Name,Dir) -> end. del_ebin(Dir) -> - case filename:basename(Dir) of - "ebin" -> - Dir2 = filename:dirname(Dir), - Dir3 = filename:dirname(Dir2), - Ext = archive_extension(), - case filename:extension(Dir3) of - E when E =:= Ext -> - %% Strip archive extension - filename:join([filename:dirname(Dir3), - filename:basename(Dir3, Ext)]); - _ -> - Dir2 - end; - _ -> - Dir - end. + filename:join(del_ebin_1(filename:split(Dir))). + +del_ebin_1([Parent,App,"ebin"]) -> + Ext = archive_extension(), + case filename:basename(Parent, Ext) of + Parent -> + %% Plain directory. + [Parent,App]; + Archive -> + %% Archive. + [Archive] + end; +del_ebin_1([H|T]) -> + [H|del_ebin_1(T)]; +del_ebin_1([]) -> + []. replace_name(Dir, Db) -> case get_name(Dir) of @@ -1058,14 +1061,14 @@ add_paths(Where,[Dir|Tail],Path,NameDb) -> add_paths(_,_,Path,_) -> {ok,Path}. -do_load_binary(Module, File, Binary, Caller, St) -> +do_load_binary(Module, File, Binary, From, St) -> case modp(File) andalso is_binary(Binary) of true -> case erlang:module_loaded(Module) of true -> do_purge(Module); false -> ok end, - try_load_module(File, Module, Binary, Caller, St); + try_load_module(File, Module, Binary, From, St); false -> {reply,{error,badarg},St} end. @@ -1074,63 +1077,61 @@ modp(Atom) when is_atom(Atom) -> true; modp(List) when is_list(List) -> int_list(List); modp(_) -> false. -load_abs(File, Mod, Caller, St) -> +load_abs(File, Mod, From, St) -> Ext = objfile_extension(), FileName0 = lists:concat([File, Ext]), FileName = absname(FileName0), case erl_prim_loader:get_file(FileName) of {ok,Bin,_} -> - try_load_module(FileName, Mod, Bin, Caller, St); + try_load_module(FileName, Mod, Bin, From, St); error -> {reply,{error,nofile},St} end. -try_load_module(File, Mod, Bin, {From,_}=Caller, St0) -> - case pending_on_load(Mod, From, St0) of - no -> - try_load_module_1(File, Mod, Bin, Caller, St0); - {yes,St} -> - {noreply,St} - end. +try_load_module(File, Mod, Bin, From, St) -> + Action = fun(_, S) -> + try_load_module_1(File, Mod, Bin, From, S) + end, + handle_pending_on_load(Action, Mod, From, St). -try_load_module_1(File, Mod, Bin, Caller, #state{moddb=Db}=St) -> +try_load_module_1(File, Mod, Bin, From, #state{moddb=Db}=St) -> case is_sticky(Mod, Db) of true -> %% Sticky file reject the load error_msg("Can't load module '~w' that resides in sticky dir\n",[Mod]), {reply,{error,sticky_directory},St}; false -> Architecture = erlang:system_info(hipe_architecture), - try_load_module_2(File, Mod, Bin, Caller, Architecture, St) + try_load_module_2(File, Mod, Bin, From, Architecture, St) end. -try_load_module_2(File, Mod, Bin, Caller, undefined, St) -> - try_load_module_3(File, Mod, Bin, Caller, undefined, St); -try_load_module_2(File, Mod, Bin, Caller, Architecture, +try_load_module_2(File, Mod, Bin, From, undefined, St) -> + try_load_module_3(File, Mod, Bin, From, undefined, St); +try_load_module_2(File, Mod, Bin, From, Architecture, #state{moddb=Db}=St) -> case catch hipe_unified_loader:load_native_code(Mod, Bin, Architecture) of {module,Mod} = Module -> ets:insert(Db, [{{native,Mod},true},{Mod,File}]), {reply,Module,St}; no_native -> - try_load_module_3(File, Mod, Bin, Caller, Architecture, St); + try_load_module_3(File, Mod, Bin, From, Architecture, St); Error -> error_msg("Native loading of ~ts failed: ~p\n", [File,Error]), {reply,ok,St} end. -try_load_module_3(File, Mod, Bin, Caller, Architecture, - #state{moddb=Db}=St) -> - case erlang:load_module(Mod, Bin) of - {module,Mod} = Module -> - ets:insert(Db, {Mod,File}), - post_beam_load([Mod], Architecture, St), - {reply,Module,St}; - {error,on_load} -> - handle_on_load(Mod, File, Caller, St); - {error,What} = Error -> - error_msg("Loading of ~ts failed: ~p\n", [File, What]), - {reply,Error,St} - end. +try_load_module_3(File, Mod, Bin, From, Architecture, St0) -> + Action = fun({module,_}=Module, #state{moddb=Db}=S) -> + ets:insert(Db, {Mod,File}), + post_beam_load([Mod], Architecture, S), + {reply,Module,S}; + ({error,on_load_failure}=Error, S) -> + {reply,Error,S}; + ({error,What}=Error, S) -> + error_msg("Loading of ~ts failed: ~p\n", [File, What]), + {reply,Error,S} + end, + Res = erlang:load_module(Mod, Bin), + handle_on_load(Res, Action, Mod, From, St0). hipe_result_to_status(Result, #state{moddb=Db}) -> case Result of @@ -1155,18 +1156,29 @@ int_list([H|T]) when is_integer(H) -> int_list(T); int_list([_|_]) -> false; int_list([]) -> true. -load_file(Mod, {From,_}=Caller, St0) -> - case pending_on_load(Mod, From, St0) of - no -> load_file_1(Mod, Caller, St0); - {yes,St} -> {noreply,St} - end. - -load_file_1(Mod, Caller, #state{path=Path}=St) -> +ensure_loaded(Mod, From, St0) -> + Action = fun(_, S) -> + case erlang:module_loaded(Mod) of + true -> + {reply,{module,Mod},S}; + false -> + load_file_1(Mod, From, S) + end + end, + handle_pending_on_load(Action, Mod, From, St0). + +load_file(Mod, From, St0) -> + Action = fun(_, S) -> + load_file_1(Mod, From, S) + end, + handle_pending_on_load(Action, Mod, From, St0). + +load_file_1(Mod, From, #state{path=Path}=St) -> case mod_to_bin(Path, Mod) of error -> {reply,{error,nofile},St}; {Mod,Binary,File} -> - try_load_module_1(File, Mod, Binary, Caller, St) + try_load_module_1(File, Mod, Binary, From, St) end. mod_to_bin([Dir|Tail], Mod) -> @@ -1174,8 +1186,13 @@ mod_to_bin([Dir|Tail], Mod) -> case erl_prim_loader:get_file(File) of error -> mod_to_bin(Tail, Mod); - {ok,Bin,FName} -> - {Mod,Bin,absname(FName)} + {ok,Bin,_} -> + case filename:pathtype(File) of + absolute -> + {Mod,Bin,File}; + _ -> + {Mod,Bin,absname(File)} + end end; mod_to_bin([], Mod) -> %% At last, try also erl_prim_loader's own method @@ -1236,6 +1253,11 @@ do_purge(Mod) -> do_soft_purge(Mod) -> erts_code_purger:soft_purge(Mod). +is_dir(Path) -> + case erl_prim_loader:read_file_info(Path) of + {ok,#file_info{type=directory}} -> true; + _ -> false + end. %%% %%% Loading of multiple modules in parallel. @@ -1299,59 +1321,78 @@ run([F|Fs], Data0) -> %% The on_load functionality. %% ------------------------------------------------------- -handle_on_load(Mod, File, {From,_}, #state{on_load=OnLoad0}=St0) -> +handle_on_load({error,on_load}, Action, Mod, From, St0) -> + #state{on_load=OnLoad0} = St0, Fun = fun() -> Res = erlang:call_on_load_function(Mod), exit(Res) end, - {_,Ref} = spawn_monitor(Fun), - OnLoad = [{Ref,Mod,File,[From]}|OnLoad0], + PidRef = spawn_monitor(Fun), + PidAction = {From,Action}, + OnLoad = [{PidRef,Mod,[PidAction]}|OnLoad0], St = St0#state{on_load=OnLoad}, - {noreply,St}. + {noreply,St}; +handle_on_load(Res, Action, _, _, St) -> + Action(Res, St). -pending_on_load(_, _, #state{on_load=[]}) -> - no; -pending_on_load(Mod, From, #state{on_load=OnLoad0}=St) -> - case lists:keymember(Mod, 2, OnLoad0) of +handle_pending_on_load(Action, Mod, From, #state{on_load=OnLoad0}=St) -> + case lists:keyfind(Mod, 2, OnLoad0) of false -> - no; - true -> - OnLoad = pending_on_load_1(Mod, From, OnLoad0), - {yes,St#state{on_load=OnLoad}} + Action(ok, St); + {{From,_Ref},Mod,_Pids} -> + %% The on_load function tried to make an external + %% call to its own module. That would be a deadlock. + %% Fail the call. (The call is probably from error_handler, + %% and it will ignore the actual error reason and cause + %% an undef execption.) + {reply,{error,deadlock},St}; + {_,_,_} -> + OnLoad = handle_pending_on_load_1(Mod, {From,Action}, OnLoad0), + {noreply,St#state{on_load=OnLoad}} end. -pending_on_load_1(Mod, From, [{Ref,Mod,File,Pids}|T]) -> - [{Ref,Mod,File,[From|Pids]}|T]; -pending_on_load_1(Mod, From, [H|T]) -> - [H|pending_on_load_1(Mod, From, T)]; -pending_on_load_1(_, _, []) -> []. +handle_pending_on_load_1(Mod, From, [{PidRef,Mod,Pids}|T]) -> + [{PidRef,Mod,[From|Pids]}|T]; +handle_pending_on_load_1(Mod, From, [H|T]) -> + [H|handle_pending_on_load_1(Mod, From, T)]; +handle_pending_on_load_1(_, _, []) -> []. -finish_on_load(Ref, OnLoadRes, #state{on_load=OnLoad0,moddb=Db}=State) -> - case lists:keyfind(Ref, 1, OnLoad0) of +finish_on_load(PidRef, OnLoadRes, #state{on_load=OnLoad0}=St0) -> + case lists:keyfind(PidRef, 1, OnLoad0) of false -> %% Since this process in general silently ignores messages %% it doesn't understand, it should also ignore a 'DOWN' %% message with an unknown reference. - State; - {Ref,Mod,File,WaitingPids} -> - finish_on_load_1(Mod, File, OnLoadRes, WaitingPids, Db), - OnLoad = [E || {R,_,_,_}=E <- OnLoad0, R =/= Ref], - State#state{on_load=OnLoad} + St0; + {PidRef,Mod,Waiting} -> + St = finish_on_load_1(Mod, OnLoadRes, Waiting, St0), + OnLoad = [E || {R,_,_}=E <- OnLoad0, R =/= PidRef], + St#state{on_load=OnLoad} end. -finish_on_load_1(Mod, File, OnLoadRes, WaitingPids, Db) -> +finish_on_load_1(Mod, OnLoadRes, Waiting, St) -> Keep = OnLoadRes =:= ok, erlang:finish_after_on_load(Mod, Keep), Res = case Keep of false -> _ = finish_on_load_report(Mod, OnLoadRes), + _ = erts_code_purger:purge(Mod), {error,on_load_failure}; true -> - ets:insert(Db, {Mod,File}), {module,Mod} end, - _ = [reply(Pid, Res) || Pid <- WaitingPids], - ok. + finish_on_load_2(Waiting, Res, St). + +finish_on_load_2([{Pid,Action}|T], Res, St0) -> + case Action(Res, St0) of + {reply,Rep,St} -> + _ = reply(Pid, Rep), + finish_on_load_2(T, Res, St); + {noreply,St} -> + finish_on_load_2(T, Res, St) + end; +finish_on_load_2([], _, St) -> + St. finish_on_load_report(_Mod, Atom) when is_atom(Atom) -> %% No error reports for atoms. diff --git a/lib/kernel/src/dist_util.erl b/lib/kernel/src/dist_util.erl index 580a896357..47d0c1b861 100644 --- a/lib/kernel/src/dist_util.erl +++ b/lib/kernel/src/dist_util.erl @@ -156,7 +156,7 @@ is_allowed(#hs_data{other_node = Node, send_status(HSData, not_allowed), error_msg("** Connection attempt from " "disallowed node ~w ** ~n", [Node]), - ?shutdown(Node); + ?shutdown2(Node, {is_allowed, not_allowed}); _ -> true end. @@ -607,10 +607,10 @@ recv_challenge_reply(#hs_data{socket = Socket, _ -> error_msg("** Connection attempt from " "disallowed node ~w ** ~n", [NodeB]), - ?shutdown(NodeB) + ?shutdown2(NodeB, {recv_challenge_reply_failed, bad_cookie}) end; - _ -> - ?shutdown(no_node) + Other -> + ?shutdown2(no_node, {recv_challenge_reply_failed, Other}) end. recv_challenge_ack(#hs_data{socket = Socket, f_recv = FRecv, diff --git a/lib/kernel/src/rpc.erl b/lib/kernel/src/rpc.erl index 6f9ce17c0c..21bff02214 100644 --- a/lib/kernel/src/rpc.erl +++ b/lib/kernel/src/rpc.erl @@ -63,7 +63,7 @@ %%------------------------------------------------------------------------ --type state() :: gb_trees:tree(pid(), {pid(), reference()}). +-type state() :: map(). %%------------------------------------------------------------------------ @@ -91,7 +91,7 @@ stop(Rpc) -> init([]) -> process_flag(trap_exit, true), - {ok, gb_trees:empty()}. + {ok, maps:new()}. -spec handle_call(term(), term(), state()) -> {'noreply', state()} | @@ -130,29 +130,15 @@ handle_cast(_, S) -> -spec handle_info(term(), state()) -> {'noreply', state()}. +handle_info({'DOWN', _, process, Caller, normal}, S) -> + {noreply, maps:remove(Caller, S)}; handle_info({'DOWN', _, process, Caller, Reason}, S) -> - case gb_trees:lookup(Caller, S) of - {value, To} -> - receive - {Caller, {reply, Reply}} -> - gen_server:reply(To, Reply) - after 0 -> - gen_server:reply(To, {badrpc, {'EXIT', Reason}}) - end, - {noreply, gb_trees:delete(Caller, S)}; - none -> - {noreply, S} - end; -handle_info({Caller, {reply, Reply}}, S) -> - case gb_trees:lookup(Caller, S) of - {value, To} -> - receive - {'DOWN', _, process, Caller, _} -> - gen_server:reply(To, Reply), - {noreply, gb_trees:delete(Caller, S)} - end; - none -> - {noreply, S} + case maps:get(Caller, S, undefined) of + undefined -> + {noreply, S}; + {_, _} = To -> + gen_server:reply(To, {badrpc, {'EXIT', Reason}}), + {noreply, maps:remove(Caller, S)} end; handle_info({From, {sbcast, Name, Msg}}, S) -> _ = case catch Name ! Msg of %% use catch to get the printout @@ -190,7 +176,6 @@ code_change(_, S, _) -> %% Auxiliary function to avoid a false dialyzer warning -- do not inline %% handle_call_call(Mod, Fun, Args, Gleader, To, S) -> - RpcServer = self(), %% Spawn not to block the rpc server. {Caller,_} = erlang:spawn_monitor( @@ -205,9 +190,9 @@ handle_call_call(Mod, Fun, Args, Gleader, To, S) -> Result -> Result end, - RpcServer ! {self(), {reply, Reply}} + gen_server:reply(To, Reply) end), - {noreply, gb_trees:insert(Caller, To, S)}. + {noreply, maps:put(Caller, To, S)}. %% RPC aid functions .... diff --git a/lib/kernel/test/code_SUITE.erl b/lib/kernel/test/code_SUITE.erl index 7f9718a354..8da67c89f8 100644 --- a/lib/kernel/test/code_SUITE.erl +++ b/lib/kernel/test/code_SUITE.erl @@ -20,6 +20,7 @@ -module(code_SUITE). -include_lib("common_test/include/ct.hrl"). +-include_lib("syntax_tools/include/merl.hrl"). -export([all/0, suite/0,groups/0,init_per_group/2,end_per_group/2]). -export([set_path/1, get_path/1, add_path/1, add_paths/1, del_path/1, @@ -33,7 +34,9 @@ where_is_file/1, purge_stacktrace/1, mult_lib_roots/1, bad_erl_libs/1, code_archive/1, code_archive2/1, on_load/1, on_load_binary/1, - on_load_embedded/1, on_load_errors/1, big_boot_embedded/1, + on_load_embedded/1, on_load_errors/1, on_load_update/1, + on_load_purge/1, on_load_self_call/1, on_load_pending/1, + big_boot_embedded/1, native_early_modules/1, get_mode/1, normalized_paths/1]). @@ -61,7 +64,8 @@ all() -> ext_mod_dep, clash, where_is_file, purge_stacktrace, mult_lib_roots, bad_erl_libs, code_archive, code_archive2, on_load, - on_load_binary, on_load_embedded, on_load_errors, + on_load_binary, on_load_embedded, on_load_errors, on_load_update, + on_load_purge, on_load_self_call, on_load_pending, big_boot_embedded, native_early_modules, get_mode, normalized_paths]. groups() -> @@ -826,6 +830,12 @@ check_funs({'$M_EXPR',warning_msg,2}, [{code_server,finish_on_load_report,2} | _]) -> 0; check_funs({'$M_EXPR','$F_EXPR',1}, [{code_server,run,2}|_]) -> 0; +check_funs({'$M_EXPR','$F_EXPR',2}, + [{code_server,handle_on_load,5}|_]) -> 0; +check_funs({'$M_EXPR','$F_EXPR',2}, + [{code_server,handle_pending_on_load,4}|_]) -> 0; +check_funs({'$M_EXPR','$F_EXPR',2}, + [{code_server,finish_on_load_2,3}|_]) -> 0; %% This is cheating! /raimo %% %% check_funs(This = {M,_,_}, Path) -> @@ -1023,6 +1033,12 @@ do_code_archive(Config, Root, StripVsn) when is_list(Config) -> {ok, _} = zip:create(Archive, [Base], [{compress, []}, {cwd, PrivDir}]), + %% Create a directory and a file outside of the archive. + OtherFile = filename:join([RootDir,VsnBase,"other","other.txt"]), + OtherContents = ?MODULE:module_info(md5), + filelib:ensure_dir(OtherFile), + ok = file:write_file(OtherFile, OtherContents), + %% Set up ERL_LIBS and start a slave node. {ok, Node} = test_server:start_node(code_archive, slave, @@ -1037,13 +1053,25 @@ do_code_archive(Config, Root, StripVsn) when is_list(Config) -> %% Start the app ok = rpc:call(Node, application, start, [App]), + %% Get the lib dir for the app. + AppLibDir = rpc:call(Node, code, lib_dir, [App]), + io:format("AppLibDir: ~p\n", [AppLibDir]), + AppLibDir = filename:join(RootDir, VsnBase), + %% Access the app priv dir AppPrivDir = rpc:call(Node, code, priv_dir, [App]), AppPrivFile = filename:join([AppPrivDir, "code_archive.txt"]), io:format("AppPrivFile: ~p\n", [AppPrivFile]), - {ok, _Bin, _Path} = + {ok, _Bin, _} = rpc:call(Node, erl_prim_loader, get_file, [AppPrivFile]), + %% Read back the other text file. + OtherDirPath = rpc:call(Node, code, lib_dir, [App,other]), + OtherFilePath = filename:join(OtherDirPath, "other.txt"), + io:format("OtherFilePath: ~p\n", [OtherFilePath]), + {ok, OtherContents, _} = + rpc:call(Node, erl_prim_loader, get_file, [OtherFilePath]), + %% Use the app Tab = code_archive_tab, Key = foo, @@ -1166,22 +1194,17 @@ on_load_binary(_) -> register(Master, self()), %% Construct, compile and pretty-print. - Mod = on_load_binary, + Mod = ?FUNCTION_NAME, File = atom_to_list(Mod) ++ ".erl", - Forms = [{attribute,1,file,{File,1}}, - {attribute,1,module,Mod}, - {attribute,2,export,[{ok,0}]}, - {attribute,3,on_load,{init,0}}, - {function,5,init,0, - [{clause,5,[],[], - [{op,6,'!', - {atom,6,Master}, - {tuple,6,[{atom,6,Mod},{call,6,{atom,6,self},[]}]}}, - {'receive',7,[{clause,8,[{atom,8,go}],[],[{atom,8,ok}]}]}]}]}, - {function,11,ok,0,[{clause,11,[],[],[{atom,11,true}]}]}], - Forms1 = erl_parse:new_anno(Forms), - {ok,Mod,Bin} = compile:forms(Forms1, [report]), - [io:put_chars(erl_pp:form(F)) || F <- Forms1], + Tree = ?Q(["-module('@Mod@').\n", + "-export([ok/0]).\n", + "-on_load({init,0}).\n", + "init() ->\n", + " '@Master@' ! {on_load_binary,self()},\n", + " receive go -> ok end.\n", + "ok() -> true.\n"]), + {ok,Mod,Bin} = merl:compile(Tree), + merl:print(Tree), {Pid1,Ref1} = spawn_monitor(fun() -> code:load_binary(Mod, File, Bin), @@ -1423,6 +1446,163 @@ do_on_load_error(ReturnValue) -> {undef,[{on_load_error,main,[],_}|_]} = Exit end. +on_load_update(_Config) -> + {Mod,Code1} = on_load_update_code(1), + {module,Mod} = code:load_binary(Mod, "", Code1), + 42 = Mod:a(), + 100 = Mod:b(99), + 4 = erlang:trace_pattern({Mod,'_','_'}, true), + + {Mod,Code2} = on_load_update_code(2), + {error,on_load_failure} = code:load_binary(Mod, "", Code2), + 42 = Mod:a(), + 100 = Mod:b(99), + {'EXIT',{undef,_}} = (catch Mod:never()), + 4 = erlang:trace_pattern({Mod,'_','_'}, false), + + {Mod,Code3} = on_load_update_code(3), + {module,Mod} = code:load_binary(Mod, "", Code3), + 100 = Mod:c(), + {'EXIT',{undef,_}} = (catch Mod:a()), + {'EXIT',{undef,_}} = (catch Mod:b(10)), + {'EXIT',{undef,_}} = (catch Mod:never()), + + ok. + +on_load_update_code(Version) -> + Mod = ?FUNCTION_NAME, + Tree = on_load_update_code_1(Version, Mod), + io:format("Version ~p", [Version]), + {ok,Mod,Code} = merl:compile(Tree), + merl:print(Tree), + io:nl(), + {Mod,Code}. + +on_load_update_code_1(1, Mod) -> + ?Q(["-module('@Mod@').\n", + "-export([a/0,b/1]).\n" + "-on_load(f/0).\n", + "f() -> ok.\n", + "a() -> 42.\n" + "b(I) -> I+1.\n"]); +on_load_update_code_1(2, Mod) -> + ?Q(["-module('@Mod@').\n", + "-export([never/0]).\n" + "-on_load(f/0).\n", + "f() -> 42 = '@Mod@':a(), 1 = '@Mod@':b(0), fail.\n", + "never() -> never.\n"]); +on_load_update_code_1(3, Mod) -> + ?Q(["-module('@Mod@').\n", + "-export([c/0]).\n" + "-on_load(f/0).\n", + "f() -> ok.\n", + "c() -> 100.\n"]). + +on_load_purge(_Config) -> + Mod = ?FUNCTION_NAME, + register(Mod, self()), + Tree = ?Q(["-module('@Mod@').\n", + "-on_load(f/0).\n", + "loop() -> loop().\n", + "f() ->\n", + "'@Mod@' ! {self(),spawn(fun loop/0)},\n", + "receive Ack -> Ack end.\n"]), + merl:print(Tree), + {ok,Mod,Code} = merl:compile(Tree), + P = spawn(fun() -> + exit(code:load_binary(Mod, "", Code)) + end), + monitor(process, P), + receive + {Pid1,Pid2} -> + monitor(process, Pid2), + Pid1 ! ack_and_failure, + receive + {'DOWN',_,process,P,Exit1} -> + {error,on_load_failure} = Exit1 + end, + receive + {'DOWN',_,process,Pid2,Exit2} -> + io:format("~p\n", [Exit2]) + after 10000 -> + ct:fail(no_down_message) + end + end. + +on_load_self_call(_Config) -> + Mod = ?FUNCTION_NAME, + register(Mod, self()), + Tree = ?Q(["-module('@Mod@').\n", + "-export([ext/0]).\n", + "-on_load(f/0).\n", + "f() ->\n", + " '@Mod@' ! (catch '@Mod@':ext()),\n", + " ok.\n", + "ext() -> good_work.\n"]), + merl:print(Tree), + {ok,Mod,Code} = merl:compile(Tree), + + {'EXIT',{undef,_}} = on_load_do_load(Mod, Code), + good_work = on_load_do_load(Mod, Code), + + ok. + +on_load_do_load(Mod, Code) -> + spawn(fun() -> + {module,Mod} = code:load_binary(Mod, "", Code) + end), + receive + Any -> Any + end. + +on_load_pending(_Config) -> + Mod = ?FUNCTION_NAME, + Tree1 = ?Q(["-module('@Mod@').\n", + "-on_load(f/0).\n", + "f() ->\n", + " register('@Mod@', self()),\n", + " receive _ -> ok end.\n"]), + merl:print(Tree1), + {ok,Mod,Code1} = merl:compile(Tree1), + + Tree2 = ?Q(["-module('@Mod@').\n", + "-export([t/0]).\n", + "t() -> ok.\n"]), + merl:print(Tree2), + {ok,Mod,Code2} = merl:compile(Tree2), + + Self = self(), + {_,Ref1} = + spawn_monitor(fun() -> + Self ! started1, + {module,Mod} = code:load_binary(Mod, "", Code1) + end), + receive started1 -> ok end, + timer:sleep(10), + {_,Ref2} = + spawn_monitor(fun() -> + Self ! started2, + {module,Mod} = code:load_binary(Mod, "", Code2), + ok = Mod:t() + end), + receive started2 -> ok end, + receive + Unexpected -> + ct:fail({unexpected,Unexpected}) + after 100 -> + ok + end, + Mod ! go, + receive + {'DOWN',Ref1,process,_,normal} -> ok + end, + receive + {'DOWN',Ref2,process,_,normal} -> ok + end, + ok = Mod:t(), + ok. + + %% Test that the native code of early loaded modules is loaded. native_early_modules(Config) when is_list(Config) -> case erlang:system_info(hipe_architecture) of diff --git a/lib/kernel/test/erl_distribution_SUITE.erl b/lib/kernel/test/erl_distribution_SUITE.erl index bf1548591a..eb58e92224 100644 --- a/lib/kernel/test/erl_distribution_SUITE.erl +++ b/lib/kernel/test/erl_distribution_SUITE.erl @@ -634,7 +634,7 @@ monitor_nodes_nodedown_reason(Config) when is_list(Config) -> stop_node(N4), true = net_kernel:disconnect(N2), TickTime = net_kernel:get_net_ticktime(), - SleepTime = TickTime + (TickTime div 4), + SleepTime = TickTime + (TickTime div 2), spawn(N3, fun () -> block_emu(SleepTime*1000), halt() @@ -911,15 +911,14 @@ monitor_nodes_otp_6481_test(Config, TestType) when is_list(Config) -> %% Verify that '{nodeup, Node}' comes before '{NodeMsg, 1}' (the message %% bringing up the connection). - no_msgs(500), {nodeup, Node} = receive Msg1 -> Msg1 end, - {NodeMsg, 1} = receive Msg2 -> Msg2 end, + {NodeMsg, N} = receive Msg2 -> Msg2 end, %% msg stream has begun, kill the node RemotePid ! {self(), kill_it}, %% Verify that '{nodedown, Node}' comes after the last '{NodeMsg, N}' %% message. - {nodedown, Node} = flush_node_msgs(NodeMsg, 2), + {nodedown, Node} = flush_node_msgs(NodeMsg, N+1), no_msgs(500), Mon = erlang:monitor(process, MN), @@ -932,8 +931,10 @@ monitor_nodes_otp_6481_test(Config, TestType) when is_list(Config) -> flush_node_msgs(NodeMsg, No) -> case receive Msg -> Msg end of - {NodeMsg, No} -> flush_node_msgs(NodeMsg, No+1); - OtherMsg -> OtherMsg + {NodeMsg, N} when N >= No -> + flush_node_msgs(NodeMsg, N+1); + OtherMsg -> + OtherMsg end. node_loop_send(Pid, Msg, No) -> diff --git a/lib/kernel/test/seq_trace_SUITE.erl b/lib/kernel/test/seq_trace_SUITE.erl index 000994751f..be23a1933f 100644 --- a/lib/kernel/test/seq_trace_SUITE.erl +++ b/lib/kernel/test/seq_trace_SUITE.erl @@ -498,7 +498,13 @@ match_set_seq_token(Config) when is_list(Config) -> exit(P2, timeout), {error, "Test node hung"} end, - ok = check_match_set_seq_token_log(Lbl, Log), + + %% Sort the log on Pid, as events from different processes + %% are not guaranteed to arrive in a certain order to the + %% tracer + SortedLog = lists:keysort(2, Log), + + ok = check_match_set_seq_token_log(Lbl, SortedLog), %% stop_node(Sandbox), ok. @@ -551,13 +557,13 @@ do_match_set_seq_token(Label) -> check_match_set_seq_token_log( Label, - [{trace,C,call,{?MODULE,countdown,[B,Ref]}, {0,Label,0,C,0}}, + [{trace,B,call,{?MODULE,bounce, [Ref]}, {0,Label,2,B,1}}, + {trace,B,call,{?MODULE,bounce, [Ref]}, {0,Label,4,B,3}}, + {trace,B,call,{?MODULE,bounce, [Ref]}, {0,Label,6,B,5}}, + {trace,C,call,{?MODULE,countdown,[B,Ref]}, {0,Label,0,C,0}}, {trace,C,call,{?MODULE,countdown,[B,Ref,3]},{0,Label,0,C,0}}, - {trace,B,call,{?MODULE,bounce, [Ref]}, {0,Label,2,B,1}}, {trace,C,call,{?MODULE,countdown,[B,Ref,2]},{0,Label,2,B,1}}, - {trace,B,call,{?MODULE,bounce, [Ref]}, {0,Label,4,B,3}}, {trace,C,call,{?MODULE,countdown,[B,Ref,1]},{0,Label,4,B,3}}, - {trace,B,call,{?MODULE,bounce, [Ref]}, {0,Label,6,B,5}}, {trace,C,call,{?MODULE,countdown,[B,Ref,0]},{0,Label,6,B,5}} ]) -> ok; diff --git a/lib/mnesia/src/Makefile b/lib/mnesia/src/Makefile index ae24bc72de..08a00e6aba 100644 --- a/lib/mnesia/src/Makefile +++ b/lib/mnesia/src/Makefile @@ -43,6 +43,7 @@ RELSYSDIR = $(RELEASE_PATH)/lib/mnesia-$(VSN) # ---------------------------------------------------- MODULES= \ mnesia \ + mnesia_backend_type \ mnesia_backup \ mnesia_bup \ mnesia_checkpoint \ @@ -50,6 +51,7 @@ MODULES= \ mnesia_controller \ mnesia_dumper\ mnesia_event \ + mnesia_ext_sup \ mnesia_frag \ mnesia_frag_hash \ mnesia_frag_old_hash \ diff --git a/lib/mnesia/src/mnesia.app.src b/lib/mnesia/src/mnesia.app.src index c78a7cba1e..006ad4bac1 100644 --- a/lib/mnesia/src/mnesia.app.src +++ b/lib/mnesia/src/mnesia.app.src @@ -3,6 +3,7 @@ {vsn, "%VSN%"}, {modules, [ mnesia, + mnesia_backend_type, mnesia_backup, mnesia_bup, mnesia_checkpoint, @@ -10,6 +11,7 @@ mnesia_controller, mnesia_dumper, mnesia_event, + mnesia_ext_sup, mnesia_frag, mnesia_frag_hash, mnesia_frag_old_hash, diff --git a/lib/mnesia/src/mnesia.erl b/lib/mnesia/src/mnesia.erl index e3d9bb1484..9586adbf93 100644 --- a/lib/mnesia/src/mnesia.erl +++ b/lib/mnesia/src/mnesia.erl @@ -82,7 +82,8 @@ system_info/0, % Not for public use %% Database mgt - create_schema/1, delete_schema/1, + create_schema/1, create_schema/2, delete_schema/1, + add_backend_type/2, backup/1, backup/2, traverse_backup/4, traverse_backup/6, install_fallback/1, install_fallback/2, uninstall_fallback/0, uninstall_fallback/1, @@ -197,6 +198,9 @@ e_has_var(X, Pos) -> %% Start and stop start() -> + start([]). + +start_() -> {Time , Res} = timer:tc(application, start, [?APPLICATION, temporary]), Secs = Time div 1000000, @@ -232,7 +236,7 @@ patched_start([{Env, Val} | Tail]) when is_atom(Env) -> patched_start([Head | _]) -> {error, {bad_type, Head}}; patched_start([]) -> - start(). + start_(). stop() -> case application:stop(?APPLICATION) of @@ -297,6 +301,7 @@ ms() -> %% Keep these last in the list, so %% mnesia_sup kills these last + mnesia_ext_sup, mnesia_monitor, mnesia_event ]. @@ -556,22 +561,16 @@ write(_Tid, _Ts, Tab, Val, LockKind) -> abort({bad_type, Tab, Val, LockKind}). write_to_store(Tab, Store, Oid, Val) -> - case ?catch_val({Tab, record_validation}) of - {RecName, Arity, Type} - when tuple_size(Val) == Arity, RecName == element(1, Val) -> - case Type of - bag -> - ?ets_insert(Store, {Oid, Val, write}); - _ -> - ?ets_delete(Store, Oid), - ?ets_insert(Store, {Oid, Val, write}) - end, - ok; - {'EXIT', _} -> - abort({no_exists, Tab}); - _ -> - abort({bad_type, Val}) - end. + {_, _, Type} = mnesia_lib:validate_record(Tab, Val), + Oid = {Tab, element(2, Val)}, + case Type of + bag -> + ?ets_insert(Store, {Oid, Val, write}); + _ -> + ?ets_delete(Store, Oid), + ?ets_insert(Store, {Oid, Val, write}) + end, + ok. delete({Tab, Key}) -> delete(Tab, Key, write); @@ -1548,16 +1547,9 @@ dirty_write(Tab, Val) -> do_dirty_write(SyncMode, Tab, Val) when is_atom(Tab), Tab /= schema, is_tuple(Val), tuple_size(Val) > 2 -> - case ?catch_val({Tab, record_validation}) of - {RecName, Arity, _Type} - when tuple_size(Val) == Arity, RecName == element(1, Val) -> - Oid = {Tab, element(2, Val)}, - mnesia_tm:dirty(SyncMode, {Oid, Val, write}); - {'EXIT', _} -> - abort({no_exists, Tab}); - _ -> - abort({bad_type, Val}) - end; + {_, _, _} = mnesia_lib:validate_record(Tab, Val), + Oid = {Tab, element(2, Val)}, + mnesia_tm:dirty(SyncMode, {Oid, Val, write}); do_dirty_write(_SyncMode, Tab, Val) -> abort({bad_type, Tab, Val}). @@ -1609,8 +1601,8 @@ dirty_update_counter(Tab, Key, Incr) -> do_dirty_update_counter(SyncMode, Tab, Key, Incr) when is_atom(Tab), Tab /= schema, is_integer(Incr) -> - case ?catch_val({Tab, record_validation}) of - {RecName, 3, set} -> + case mnesia_lib:validate_key(Tab, Key) of + {RecName, 3, Type} when Type == set; Type == ordered_set -> Oid = {Tab, Key}, mnesia_tm:dirty(SyncMode, {Oid, {RecName, Incr}, update_counter}); _ -> @@ -1910,6 +1902,8 @@ raw_table_info(Tab, Item) -> info_reply(?ets_info(Tab, Item), Tab, Item); disc_only_copies -> info_reply(dets:info(Tab, Item), Tab, Item); + {ext, Alias, Mod} -> + info_reply(catch Mod:info(Alias, Tab, Item), Tab, Item); unknown -> bad_info_reply(Tab, Item) end @@ -2022,15 +2016,26 @@ display_tab_info() -> MasterTabs = mnesia_recover:get_master_node_tables(), io:format("master node tables = ~p~n", [lists:sort(MasterTabs)]), + case get_backend_types() of + [] -> ok; + Ts -> list_backend_types(Ts, "backend types = ") + end, + + case get_index_plugins() of + [] -> ok; + Ps -> list_index_plugins(Ps, "index plugins = ") + end, + Tabs = system_info(tables), - {Unknown, Ram, Disc, DiscOnly} = - lists:foldl(fun storage_count/2, {[], [], [], []}, Tabs), + {Unknown, Ram, Disc, DiscOnly, Ext} = + lists:foldl(fun storage_count/2, {[], [], [], [], []}, Tabs), io:format("remote = ~p~n", [lists:sort(Unknown)]), io:format("ram_copies = ~p~n", [lists:sort(Ram)]), io:format("disc_copies = ~p~n", [lists:sort(Disc)]), io:format("disc_only_copies = ~p~n", [lists:sort(DiscOnly)]), + [io:format("~-19s= ~p~n", [atom_to_list(A), Ts]) || {A,Ts} <- Ext], Rfoldl = fun(T, Acc) -> Rpat = @@ -2038,7 +2043,7 @@ display_tab_info() -> read_only -> lists:sort([{A, read_only} || A <- val({T, active_replicas})]); read_write -> - table_info(T, where_to_commit) + [fix_wtc(W) || W <- table_info(T, where_to_commit)] end, case lists:keysearch(Rpat, 1, Acc) of {value, {_Rpat, Rtabs}} -> @@ -2051,12 +2056,60 @@ display_tab_info() -> Rdisp = fun({Rpat, Rtabs}) -> io:format("~p = ~p~n", [Rpat, Rtabs]) end, lists:foreach(Rdisp, lists:sort(Repl)). -storage_count(T, {U, R, D, DO}) -> +get_backend_types() -> + case ?catch_val({schema, user_property, mnesia_backend_types}) of + {'EXIT', _} -> + []; + {mnesia_backend_types, Ts} -> + lists:sort(Ts) + end. + +get_index_plugins() -> + case ?catch_val({schema, user_property, mnesia_index_plugins}) of + {'EXIT', _} -> + []; + {mnesia_index_plugins, Ps} -> + lists:sort(Ps) + end. + + +list_backend_types([{A,M} | T] = Ts, Legend) -> + Indent = [$\s || _ <- Legend], + W = integer_to_list( + lists:foldl(fun({Alias,_}, Wa) -> + erlang:max(Wa, length(atom_to_list(Alias))) + end, 0, Ts)), + io:fwrite(Legend ++ "~-" ++ W ++ "s - ~s~n", + [atom_to_list(A), atom_to_list(M)]), + [io:fwrite(Indent ++ "~-" ++ W ++ "s - ~s~n", + [atom_to_list(A1), atom_to_list(M1)]) + || {A1,M1} <- T]. + +list_index_plugins([{N,M,F} | T] = Ps, Legend) -> + Indent = [$\s || _ <- Legend], + W = integer_to_list( + lists:foldl(fun({N1,_,_}, Wa) -> + erlang:max(Wa, length(pp_ix_name(N1))) + end, 0, Ps)), + io:fwrite(Legend ++ "~-" ++ W ++ "s - ~s:~s~n", + [pp_ix_name(N), atom_to_list(M), atom_to_list(F)]), + [io:fwrite(Indent ++ "~-" ++ W ++ "s - ~s:~s~n", + [pp_ix_name(N1), atom_to_list(M1), atom_to_list(F1)]) + || {N1,M1,F1} <- T]. + +pp_ix_name(N) -> + lists:flatten(io_lib:fwrite("~w", [N])). + +fix_wtc({N, {ext,A,_}}) -> {N, A}; +fix_wtc({N,A}) when is_atom(A) -> {N, A}. + +storage_count(T, {U, R, D, DO, Ext}) -> case table_info(T, storage_type) of - unknown -> {[T | U], R, D, DO}; - ram_copies -> {U, [T | R], D, DO}; - disc_copies -> {U, R, [T | D], DO}; - disc_only_copies -> {U, R, D, [T | DO]} + unknown -> {[T | U], R, D, DO, Ext}; + ram_copies -> {U, [T | R], D, DO, Ext}; + disc_copies -> {U, R, [T | D], DO, Ext}; + disc_only_copies -> {U, R, D, [T | DO], Ext}; + {ext, A, _} -> {U, R, D, DO, orddict:append(A, T, Ext)} end. system_info(Item) -> @@ -2071,9 +2124,10 @@ system_info2(all) -> system_info2(db_nodes) -> DiscNs = ?catch_val({schema, disc_copies}), RamNs = ?catch_val({schema, ram_copies}), + ExtNs = ?catch_val({schema, external_copies}), if - is_list(DiscNs), is_list(RamNs) -> - DiscNs ++ RamNs; + is_list(DiscNs), is_list(RamNs), is_list(ExtNs) -> + DiscNs ++ RamNs ++ ExtNs; true -> case mnesia_schema:read_nodes() of {ok, Nodes} -> Nodes; @@ -2177,6 +2231,7 @@ system_info2(access_module) -> mnesia_monitor:get_env(access_module); system_info2(auto_repair) -> mnesia_monitor:get_env(auto_repair); system_info2(is_running) -> mnesia_lib:is_running(); system_info2(backup_module) -> mnesia_monitor:get_env(backup_module); +system_info2(backend_types) -> mnesia_schema:backend_types(); system_info2(event_module) -> mnesia_monitor:get_env(event_module); system_info2(debug) -> mnesia_monitor:get_env(debug); system_info2(dump_log_load_regulation) -> mnesia_monitor:get_env(dump_log_load_regulation); @@ -2213,6 +2268,7 @@ system_info_items(yes) -> [ access_module, auto_repair, + backend_types, backup_module, checkpoints, db_nodes, @@ -2306,11 +2362,17 @@ load_mnesia_or_abort() -> %% Database mgt create_schema(Ns) -> - mnesia_bup:create_schema(Ns). + create_schema(Ns, []). + +create_schema(Ns, Properties) -> + mnesia_bup:create_schema(Ns, Properties). delete_schema(Ns) -> mnesia_schema:delete_schema(Ns). +add_backend_type(Alias, Module) -> + mnesia_schema:add_backend_type(Alias, Module). + backup(Opaque) -> mnesia_log:backup(Opaque). diff --git a/lib/mnesia/src/mnesia.hrl b/lib/mnesia/src/mnesia.hrl index c58b4cfccd..0716dd87c8 100644 --- a/lib/mnesia/src/mnesia.hrl +++ b/lib/mnesia/src/mnesia.hrl @@ -68,6 +68,7 @@ ram_copies = [], % [Node] disc_copies = [], % [Node] disc_only_copies = [], % [Node] + external_copies = [], % [{{Alias,Mod},[Node]}] load_order = 0, % Integer access_mode = read_write, % read_write | read_only majority = false, % true | false @@ -103,7 +104,7 @@ ram_copies = [], disc_copies = [], disc_only_copies = [], - snmp = [], + ext = [], schema_ops = [] }). diff --git a/lib/mnesia/src/mnesia_backend_type.erl b/lib/mnesia/src/mnesia_backend_type.erl new file mode 100644 index 0000000000..4791b82a01 --- /dev/null +++ b/lib/mnesia/src/mnesia_backend_type.erl @@ -0,0 +1,115 @@ +%% +%% %CopyrightBegin% +%% +%% Copyright Ericsson AB 1996-2015. All Rights Reserved. +%% +%% Licensed under the Apache License, Version 2.0 (the "License"); +%% you may not use this file except in compliance with the License. +%% You may obtain a copy of the License at +%% +%% http://www.apache.org/licenses/LICENSE-2.0 +%% +%% Unless required by applicable law or agreed to in writing, software +%% distributed under the License is distributed on an "AS IS" BASIS, +%% WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +%% See the License for the specific language governing permissions and +%% limitations under the License. +%% +%% %CopyrightEnd% +%% + +%% +%% Behaviour definition for mnesia backend types. +%% + +%%%header_doc_include + +-module(mnesia_backend_type). + +-export([behaviour_info/1]). + +%%%header_doc_include + +%%%impl_doc_include + +%% Note that mnesia considers all callbacks mandatory!! +%% +behaviour_info(callbacks) -> + [ + {add_aliases, 1}, % (Aliases) -> ok + {check_definition, 4}, % (TypeAlias, Tab, Nodes, Properties) -> ok + {close_table, 2}, % (TypeAlias, Tab) -> ok + {create_table, 3}, % (TypeAlias, Tab, Properties) -> ok + {delete, 3}, % (TypeAlias, Tab, Key) -> true | ok + {delete_table, 2}, % (TypeAlias, Tab) -> ok + {first, 2}, % (TypeAlias, Tab) -> Key::Term | '$end_of_table' + {fixtable, 3}, % (TypeAlias, Tab, Bool) -> ok | true + {last, 2}, % (TypeAlias, Tab) -> Key::Term | '$end_of_table' + {index_is_consistent,3}, % (TypeAlias, IxTag, Bool) -> ok + {init_backend, 0}, % () -> ok + {info, 3}, % (TypeAlias, Tab, Item) -> Term + {insert, 3}, % (TypeAlias, Tab, Object) -> ok + {lookup, 3}, % (TypeAlias, Tab, Key) -> [Objects] + {is_index_consistent,2}, % (TypeAlias, IxTag) -> Bool + {load_table, 4}, % (TypeAlias, Tab, Reason, CsList) -> ok + {match_delete, 3}, % (TypeAlias, Tab, Pattern) -> ok + {next, 3}, % (TypeAlias, Tab, Key) -> Key::Term | '$end_of_table' + {prev, 3}, % (TypeAlias, Tab, Key) -> Key::Term | '$end_of_table' + {receiver_first_message, 4}, % (Sender, FirstMsg, Alias, Tab) -> {Size, State} + {receive_data, 5}, % (Data, Alias, Name, Sender, State) -> {more, State} | {{more, Msg}, State} + {receive_done, 4}, % (Alias, Tab, Sender, State) -> ok + {real_suffixes, 0}, % () -> [FileSuffix] + {remove_aliases, 1}, % (Aliases) -> ok + {repair_continuation, 2}, % (Continuation, MatchSpec) -> Continuation + {select, 1}, % (Continuation) -> {[Match], Continuation'} | '$end_of_table' + {select, 3}, % (TypeAlias, Tab, Pattern) -> {[Match], Continuation'} | '$end_of_table' + {select, 4}, % (TypeAlias, Tab, MatchSpec, Limit) {[Match], Continuation'} | '$end_of_table' + {sender_init, 4}, % (TypeAlias, Tab, LoadReason, Pid) -> + % {standard, Init(), Chunk()} | {Init(), Chunk()} + {semantics, 2}, % (TypeAlias, storage | types | index_fun | index_types) -> + % ram_copies | disc_copies, set | ordered_set | bag, fun(), ordered | bag + {slot, 3}, % (TypeAlias, Tab, Pos) -> '$end_of_table' | Objects | {error, Reason} + {sync_close_table, 2}, % (TypeAlias, Tab) -> ok + {tmp_suffixes, 0}, % () -> [FileSuffix] + {update_counter, 4}, % (TypeAlias, Tab, Counter, Val) -> NewVal + {validate_key, 6}, % (TypeAlias, Tab, RecName, Arity, Type, Key) -> {RecName, Arity, Type} + {validate_record, 6} % (TypeAlias, Tab, RecName, Arity, Type, Obj) -> {RecName, Arity, Type} + ]. + +%%%impl_doc_include + +%% -type tab() :: atom(). +%% -type alias() :: atom(). +%% -type rec_name() :: atom(). +%% -type type() :: set | bag | ordered_set. +%% -type proplist() :: [{atom(), any()}]. +%% -type key() :: any(). +%% -type db_object() :: tuple(). + +%% -type matchspec() :: ets:match_spec(). +%% -type limit() :: integer() | infinity. + +%% -type cont_fun() :: any(). +%% -type cont() :: '$end_of_table' | cont_fun(). + +%% -callback check_definition(alias(), tab(), [node()], proplist()) -> ok. +%% -callback create_table(alias(), tab(), proplist()) -> tab(). +%% -callback load_table(alias(), tab(), any()) -> ok. +%% -callback delete_table(alias(), tab()) -> ok. +%% -callback first(alias(), tab()) -> key(). +%% -callback last(alias(), tab()) -> key(). +%% -callback next(alias(), tab(), key()) -> key(). +%% -callback prev(alias(), tab(), key()) -> key(). +%% -callback insert(alias(), tab(), db_object()) -> ok. +%% -callback lookup(alias(), tab(), key()) -> [db_object()]. +%% -callback delete(alias(), tab(), key()) -> ok. +%% -callback update_counter(alias(), tab(), key(), integer()) -> integer(). +%% -callback select(cont()) -> {list(), cont()}. +%% -callback select(alias(), tab(), matchspec()) -> list() | '$end_of_table'. +%% -callback select(alias(), tab(), matchspec(), limit()) -> {list(), cont()}. +%% -callback slot(alias(), tab(), integer()) -> key(). +%% -callback validate_key(alias(), tab(), rec_name(), arity(), type(), key()) -> +%% {rec_name(), arity(), type()}. +%% -callback validate_record(alias(),tab(),rec_name(),arity(),type(),db_obj()) -> +%% {rec_name(), arity(), type()}. +%% -callback repair_continuation(cont(), matchspec()) -> cont(). diff --git a/lib/mnesia/src/mnesia_bup.erl b/lib/mnesia/src/mnesia_bup.erl index 8b1143a352..3e55deb958 100644 --- a/lib/mnesia/src/mnesia_bup.erl +++ b/lib/mnesia/src/mnesia_bup.erl @@ -28,6 +28,7 @@ fallback_exists/0, tm_fallback_start/1, create_schema/1, + create_schema/2, install_fallback/1, install_fallback/2, uninstall_fallback/0, @@ -46,7 +47,7 @@ uninstall_fallback_master/2, local_uninstall_fallback/2, do_traverse_backup/7, - trav_apply/4 + trav_apply/5 ]). -include("mnesia.hrl"). @@ -81,7 +82,8 @@ iterate(Mod, Fun, Opaque, Acc) -> R = #restore{bup_module = Mod, bup_data = Opaque}, try read_schema_section(R) of {R2, {Header, Schema, Rest}} -> - try iter(R2, Header, Schema, Fun, Acc, Rest) of + Ext = get_ext_types(Schema), + try iter(R2, Header, Schema, Ext, Fun, Acc, Rest) of {ok, R3, Res} -> close_read(R3), {ok, Res} @@ -96,17 +98,32 @@ iterate(Mod, Fun, Opaque, Acc) -> Err end. -iter(R, Header, Schema, Fun, Acc, []) -> +get_ext_types(Schema) -> + try + List = lookup_schema(schema, Schema), + case lists:keyfind(user_properties, 1, List) of + {_, Props} -> + proplists:get_value( + mnesia_backend_types, Props, []); + false -> + [] + end + catch + throw:{error, {"Cannot lookup",_}} -> + [] + end. + +iter(R, Header, Schema, Ext, Fun, Acc, []) -> case safe_apply(R, read, [R#restore.bup_data]) of {R2, []} -> - Res = Fun([], Header, Schema, Acc), + Res = Fun([], Header, Schema, Ext, Acc), {ok, R2, Res}; {R2, BupItems} -> - iter(R2, Header, Schema, Fun, Acc, BupItems) + iter(R2, Header, Schema, Ext, Fun, Acc, BupItems) end; -iter(R, Header, Schema, Fun, Acc, BupItems) -> - Acc2 = Fun(BupItems, Header, Schema, Acc), - iter(R, Header, Schema, Fun, Acc2, []). +iter(R, Header, Schema, Ext, Fun, Acc, BupItems) -> + Acc2 = Fun(BupItems, Header, Schema, Ext, Acc), + iter(R, Header, Schema, Ext, Fun, Acc2, []). -spec safe_apply(#restore{}, atom(), list()) -> tuple(). safe_apply(R, write, [_, Items]) when Items =:= [] -> @@ -262,7 +279,7 @@ convert_0_1(Schema) -> Cs = mnesia_schema:list2cs(List), convert_0_1(Schema2, [], Cs); false -> - List = mnesia_schema:get_initial_schema(disc_copies, [node()]), + List = mnesia_schema:get_initial_schema(disc_copies, [node()], []), Cs = mnesia_schema:list2cs(List), convert_0_1(Schema, [], Cs) end. @@ -310,16 +327,19 @@ schema2bup({schema, Tab, TableDef}) -> %% Create schema on the given nodes %% Requires that old schemas has been deleted %% Returns ok | {error, Reason} -create_schema([]) -> - create_schema([node()]); -create_schema(Ns) when is_list(Ns) -> +create_schema(Nodes) -> + create_schema(Nodes, []). + +create_schema([], Props) -> + create_schema([node()], Props); +create_schema(Ns, Props) when is_list(Ns), is_list(Props) -> case is_set(Ns) of true -> - create_schema(Ns, mnesia_schema:ensure_no_schema(Ns)); + create_schema(Ns, mnesia_schema:ensure_no_schema(Ns), Props); false -> {error, {combine_error, Ns}} end; -create_schema(Ns) -> +create_schema(Ns, _Props) -> {error, {badarg, Ns}}. is_set(List) when is_list(List) -> @@ -327,7 +347,7 @@ is_set(List) when is_list(List) -> is_set(_) -> false. -create_schema(Ns, ok) -> +create_schema(Ns, ok, Props) -> %% Ensure that we access the intended Mnesia %% directory. This function may not be called %% during startup since it will cause the @@ -346,7 +366,7 @@ create_schema(Ns, ok) -> Str = mk_str(), File = mnesia_lib:dir(Str), file:delete(File), - try make_initial_backup(Ns, File, Mod) of + try make_initial_backup(Ns, File, Mod, Props) of {ok, _Res} -> case do_install_fallback(File, Mod) of ok -> @@ -363,9 +383,9 @@ create_schema(Ns, ok) -> {error, Reason} -> {error, Reason} end; -create_schema(_Ns, {error, Reason}) -> +create_schema(_Ns, {error, Reason}, _) -> {error, Reason}; -create_schema(_Ns, Reason) -> +create_schema(_Ns, Reason, _) -> {error, Reason}. mk_str() -> @@ -373,7 +393,10 @@ mk_str() -> lists:concat([node()] ++ Now ++ ".TMP"). make_initial_backup(Ns, Opaque, Mod) -> - Orig = mnesia_schema:get_initial_schema(disc_copies, Ns), + make_initial_backup(Ns, Opaque, Mod, []). + +make_initial_backup(Ns, Opaque, Mod, Props) -> + Orig = mnesia_schema:get_initial_schema(disc_copies, Ns, Props), Modded = proplists:delete(storage_properties, proplists:delete(majority, Orig)), Schema = [{schema, schema, Modded}], O2 = do_apply(Mod, open_write, [Opaque], Opaque), @@ -486,15 +509,15 @@ install_fallback_master(ClientPid, FA) -> State = {start, FA}, Opaque = FA#fallback_args.opaque, Mod = FA#fallback_args.module, - Res = iterate(Mod, fun restore_recs/4, Opaque, State), + Res = iterate(Mod, fun restore_recs/5, Opaque, State), unlink(ClientPid), ClientPid ! {self(), Res}, exit(shutdown). -restore_recs(_, _, _, stop) -> +restore_recs(_, _, _, _, stop) -> throw({error, "restore_recs already stopped"}); -restore_recs(Recs, Header, Schema, {start, FA}) -> +restore_recs(Recs, Header, Schema, Ext, {start, FA}) -> %% No records in backup Schema2 = convert_schema(Header#log_header.log_version, Schema), CreateList = lookup_schema(schema, Schema2), @@ -505,19 +528,19 @@ restore_recs(Recs, Header, Schema, {start, FA}) -> Args = [self(), FA], Pids = [spawn_link(N, ?MODULE, fallback_receiver, Args) || N <- Ns], send_fallback(Pids, {start, Header, Schema2}), - Res = restore_recs(Recs, Header, Schema2, Pids), + Res = restore_recs(Recs, Header, Schema2, Ext, Pids), global:del_lock({{mnesia_table_lock, schema}, self()}, Ns), Res catch _:Reason -> throw({error, {"Bad schema in restore_recs", Reason}}) end; -restore_recs([], _Header, _Schema, Pids) -> +restore_recs([], _Header, _Schema, _Ext, Pids) -> send_fallback(Pids, swap), send_fallback(Pids, stop), stop; -restore_recs(Recs, _, _, Pids) -> +restore_recs(Recs, _, _, _, Pids) -> send_fallback(Pids, {records, Recs}), Pids. @@ -716,7 +739,7 @@ do_fallback_start(true, false) -> BupFile = fallback_bup(), Mod = mnesia_backup, LocalTabs = ?ets_new_table(mnesia_local_tables, [set, public, {keypos, 2}]), - case iterate(Mod, fun restore_tables/4, BupFile, {start, LocalTabs}) of + case iterate(Mod, fun restore_tables/5, BupFile, {start, LocalTabs}) of {ok, _Res} -> ?SAFE(dets:close(schema)), TmpSchema = mnesia_lib:tab2tmp(schema), @@ -737,23 +760,24 @@ do_fallback_start(true, false) -> {error, {"Cannot start from fallback", Reason}} end. -restore_tables(All=[Rec | Recs], Header, Schema, State={local, LocalTabs, LT}) -> +restore_tables(All=[Rec | Recs], Header, Schema, Ext, + State={local, LocalTabs, LT}) -> Tab = element(1, Rec), if Tab =:= LT#local_tab.name -> Key = element(2, Rec), (LT#local_tab.add)(Tab, Key, Rec, LT), - restore_tables(Recs, Header, Schema, State); + restore_tables(Recs, Header, Schema, Ext, State); true -> NewState = {new, LocalTabs}, - restore_tables(All, Header, Schema, NewState) + restore_tables(All, Header, Schema, Ext, NewState) end; -restore_tables(All=[Rec | Recs], Header, Schema, {new, LocalTabs}) -> +restore_tables(All=[Rec | Recs], Header, Schema, Ext, {new, LocalTabs}) -> Tab = element(1, Rec), case ?ets_lookup(LocalTabs, Tab) of [] -> State = {not_local, LocalTabs, Tab}, - restore_tables(Recs, Header, Schema, State); + restore_tables(Recs, Header, Schema, Ext, State); [LT] when is_record(LT, local_tab) -> State = {local, LocalTabs, LT}, case LT#local_tab.opened of @@ -762,38 +786,39 @@ restore_tables(All=[Rec | Recs], Header, Schema, {new, LocalTabs}) -> (LT#local_tab.open)(Tab, LT), ?ets_insert(LocalTabs,LT#local_tab{opened=true}) end, - restore_tables(All, Header, Schema, State) + restore_tables(All, Header, Schema, Ext, State) end; -restore_tables(All=[Rec | Recs], Header, Schema, S = {not_local, LocalTabs, PrevTab}) -> +restore_tables(All=[Rec | Recs], Header, Schema, Ext, + S = {not_local, LocalTabs, PrevTab}) -> Tab = element(1, Rec), if Tab =:= PrevTab -> - restore_tables(Recs, Header, Schema, S); + restore_tables(Recs, Header, Schema, Ext, S); true -> State = {new, LocalTabs}, - restore_tables(All, Header, Schema, State) + restore_tables(All, Header, Schema, Ext, State) end; -restore_tables(Recs, Header, Schema, {start, LocalTabs}) -> +restore_tables(Recs, Header, Schema, Ext, {start, LocalTabs}) -> Dir = mnesia_lib:dir(), OldDir = filename:join([Dir, "OLD_DIR"]), mnesia_schema:purge_dir(OldDir, []), mnesia_schema:purge_dir(Dir, [fallback_name()]), - init_dat_files(Schema, LocalTabs), + init_dat_files(Schema, Ext, LocalTabs), State = {new, LocalTabs}, - restore_tables(Recs, Header, Schema, State); -restore_tables([], _Header, _Schema, State) -> + restore_tables(Recs, Header, Schema, Ext, State); +restore_tables([], _Header, _Schema, _Ext, State) -> State. %% Creates all neccessary dat files and inserts %% the table definitions in the schema table %% %% Returns a list of local_tab tuples for all local tables -init_dat_files(Schema, LocalTabs) -> +init_dat_files(Schema, Ext, LocalTabs) -> TmpFile = mnesia_lib:tab2tmp(schema), Args = [{file, TmpFile}, {keypos, 2}, {type, set}], case dets:open_file(schema, Args) of % Assume schema lock {ok, _} -> - create_dat_files(Schema, LocalTabs), + create_dat_files(Schema, Ext, LocalTabs), ok = dets:close(schema), LocalTab = #local_tab{name = schema, storage_type = disc_copies, @@ -808,10 +833,10 @@ init_dat_files(Schema, LocalTabs) -> throw({error, {"Cannot open file", schema, Args, Reason}}) end. -create_dat_files([{schema, schema, TabDef} | Tail], LocalTabs) -> +create_dat_files([{schema, schema, TabDef} | Tail], Ext, LocalTabs) -> ok = dets:insert(schema, {schema, schema, TabDef}), - create_dat_files(Tail, LocalTabs); -create_dat_files([{schema, Tab, TabDef} | Tail], LocalTabs) -> + create_dat_files(Tail, Ext, LocalTabs); +create_dat_files([{schema, Tab, TabDef} | Tail], Ext, LocalTabs) -> TmpFile = mnesia_lib:tab2tmp(Tab), DatFile = mnesia_lib:tab2dat(Tab), DclFile = mnesia_lib:tab2dcl(Tab), @@ -824,56 +849,21 @@ create_dat_files([{schema, Tab, TabDef} | Tail], LocalTabs) -> mnesia_lib:dets_sync_close(Tab), file:delete(TmpFile), - Cs = mnesia_schema:list2cs(TabDef), + Cs = mnesia_schema:list2cs(TabDef, Ext), ok = dets:insert(schema, {schema, Tab, TabDef}), RecName = Cs#cstruct.record_name, Storage = mnesia_lib:cs_to_storage_type(node(), Cs), + delete_ext(Storage, Tab), + Semantics = mnesia_lib:semantics(Storage, storage), if - Storage =:= unknown -> + Semantics =:= undefined -> ok = dets:delete(schema, {schema, Tab}), - create_dat_files(Tail, LocalTabs); - Storage =:= disc_only_copies -> - Args = [{file, TmpFile}, {keypos, 2}, - {type, mnesia_lib:disk_type(Tab, Cs#cstruct.type)}], - Open = fun(T, LT) when T =:= LT#local_tab.name -> - case mnesia_lib:dets_sync_open(T, Args) of - {ok, _} -> - ok; - {error, Reason} -> - throw({error, {"Cannot open file", T, Args, Reason}}) - end - end, - Add = fun(T, Key, Rec, LT) when T =:= LT#local_tab.name -> - case Rec of - {_T, Key} -> - ok = dets:delete(T, Key); - (Rec) when T =:= RecName -> - ok = dets:insert(Tab, Rec); - (Rec) -> - Rec2 = setelement(1, Rec, RecName), - ok = dets:insert(T, Rec2) - end - end, - Close = fun(T, LT) when T =:= LT#local_tab.name -> - mnesia_lib:dets_sync_close(T) - end, - Swap = fun(T, LT) when T =:= LT#local_tab.name -> - Expunge(), - case LT#local_tab.opened of - true -> - Close(T,LT); - false -> - Open(T,LT), - Close(T,LT) - end, - case file:rename(TmpFile, DatFile) of - ok -> - ok; - {error, Reason} -> - mnesia_lib:fatal("Cannot rename file ~p -> ~p: ~p~n", - [TmpFile, DatFile, Reason]) - end - end, + create_dat_files(Tail, Ext, LocalTabs); + Semantics =:= disc_only_copies -> + Open = disc_only_open_fun(Storage, Cs), + Add = disc_only_add_fun(Storage, Cs), + Close = disc_only_close_fun(Storage), + Swap = disc_only_swap_fun(Storage, Expunge, Open, Close), LocalTab = #local_tab{name = Tab, storage_type = Storage, open = Open, @@ -883,8 +873,8 @@ create_dat_files([{schema, Tab, TabDef} | Tail], LocalTabs) -> record_name = RecName, opened = false}, ?ets_insert(LocalTabs, LocalTab), - create_dat_files(Tail, LocalTabs); - Storage =:= ram_copies; Storage =:= disc_copies -> + create_dat_files(Tail, Ext, LocalTabs); + Semantics =:= ram_copies; Storage =:= disc_copies -> Open = fun(T, LT) when T =:= LT#local_tab.name -> mnesia_log:open_log({?MODULE, T}, mnesia_log:dcl_log_header(), @@ -945,18 +935,97 @@ create_dat_files([{schema, Tab, TabDef} | Tail], LocalTabs) -> opened = false }, ?ets_insert(LocalTabs, LocalTab), - create_dat_files(Tail, LocalTabs) + create_dat_files(Tail, Ext, LocalTabs); + true -> + error({unknown_semantics, [{semantics, Semantics}, + {tabdef, TabDef}, + {ext, Ext}]}) end; -create_dat_files([{schema, Tab} | Tail], LocalTabs) -> +create_dat_files([{schema, Tab} | Tail], Ext, LocalTabs) -> ?ets_delete(LocalTabs, Tab), ok = dets:delete(schema, {schema, Tab}), TmpFile = mnesia_lib:tab2tmp(Tab), mnesia_lib:dets_sync_close(Tab), file:delete(TmpFile), - create_dat_files(Tail, LocalTabs); -create_dat_files([], _LocalTabs) -> + create_dat_files(Tail, Ext, LocalTabs); +create_dat_files([], _Ext, _LocalTabs) -> ok. +delete_ext({ext, Alias, Mod}, Tab) -> + Mod:close_table(Alias, Tab), + Mod:delete_table(Alias, Tab), + ok; +delete_ext(_, _) -> + ok. + + +disc_only_open_fun(disc_only_copies, #cstruct{name = Tab} =Cs) -> + TmpFile = mnesia_lib:tab2tmp(Tab), + Args = [{file, TmpFile}, {keypos, 2}, + {type, mnesia_lib:disk_type(Tab, Cs#cstruct.type)}], + fun(T, LT) when T =:= LT#local_tab.name -> + case mnesia_lib:dets_sync_open(T, Args) of + {ok, _} -> + ok; + {error, Reason} -> + throw({error, {"Cannot open file", T, Args, Reason}}) + end + end; +disc_only_open_fun({ext,Alias,Mod}, Cs) -> + fun(T, LT) when T =:= LT#local_tab.name -> + ok = Mod:load_table(Alias, T, restore, mnesia_schema:cs2list(Cs)) + end. + +disc_only_add_fun(Storage, #cstruct{name = Tab, + record_name = RecName}) -> + fun(T, Key, Rec, #local_tab{name = T}) when T =:= Tab-> + case Rec of + {_T, Key} -> + ok = mnesia_lib:db_erase(Storage, T, Key); + (Rec) when T =:= RecName -> + ok = mnesia_lib:db_put(Storage, T, Rec); + (Rec) -> + ok = mnesia_lib:db_put(Storage, T, + setelement(1, Rec, RecName)) + end + end. + +disc_only_close_fun(disc_only_copies) -> + fun(T, LT) when T =:= LT#local_tab.name -> + mnesia_lib:dets_sync_close(T) + end; +disc_only_close_fun({ext, Alias, Mod}) -> + fun(T, _LT) -> + Mod:sync_close_table(Alias, T) + end. + + +disc_only_swap_fun(disc_only_copies, Expunge, Open, Close) -> + fun(T, LT) when T =:= LT#local_tab.name -> + TmpFile = mnesia_lib:tab2tmp(T), + DatFile = mnesia_lib:tab2dat(T), + Expunge(), + case LT#local_tab.opened of + true -> + Close(T,LT); + false -> + Open(T,LT), + Close(T,LT) + end, + case file:rename(TmpFile, DatFile) of + ok -> + ok; + {error, Reason} -> + mnesia_lib:fatal("Cannot rename file ~p -> ~p: ~p~n", + [TmpFile, DatFile, Reason]) + end + end; +disc_only_swap_fun({ext, _Alias, _Mod}, _Expunge, _Open, Close) -> + fun(T, #local_tab{name = T} = LT) -> + Close(T, LT) + end. + + uninstall_fallback() -> uninstall_fallback([{scope, global}]). @@ -1133,7 +1202,7 @@ do_traverse_backup(ClientPid, Source, SourceMod, Target, TargetMod, Fun, Acc) -> end, A = {start, Fun, Acc, TargetMod, Iter}, Res = - case iterate(SourceMod, fun trav_apply/4, Source, A) of + case iterate(SourceMod, fun trav_apply/5, Source, A) of {ok, {iter, _, Acc2, _, Iter2}} when TargetMod =/= read_only -> try do_apply(TargetMod, commit_write, [Iter2], Iter2), @@ -1152,7 +1221,7 @@ do_traverse_backup(ClientPid, Source, SourceMod, Target, TargetMod, Fun, Acc) -> unlink(ClientPid), ClientPid ! {iter_done, self(), Res}. -trav_apply(Recs, _Header, _Schema, {iter, Fun, Acc, Mod, Iter}) -> +trav_apply(Recs, _Header, _Schema, _Ext, {iter, Fun, Acc, Mod, Iter}) -> {NewRecs, Acc2} = filter_foldl(Fun, Acc, Recs), if Mod =/= read_only, NewRecs =/= [] -> @@ -1161,7 +1230,7 @@ trav_apply(Recs, _Header, _Schema, {iter, Fun, Acc, Mod, Iter}) -> true -> {iter, Fun, Acc2, Mod, Iter} end; -trav_apply(Recs, Header, Schema, {start, Fun, Acc, Mod, Iter}) -> +trav_apply(Recs, Header, Schema, Ext, {start, Fun, Acc, Mod, Iter}) -> Iter2 = if Mod =/= read_only -> @@ -1169,8 +1238,9 @@ trav_apply(Recs, Header, Schema, {start, Fun, Acc, Mod, Iter}) -> true -> Iter end, - TravAcc = trav_apply(Schema, Header, Schema, {iter, Fun, Acc, Mod, Iter2}), - trav_apply(Recs, Header, Schema, TravAcc). + TravAcc = trav_apply(Schema, Header, Schema, Ext, + {iter, Fun, Acc, Mod, Iter2}), + trav_apply(Recs, Header, Schema, Ext, TravAcc). filter_foldl(Fun, Acc, [Head|Tail]) -> case Fun(Head, Acc) of diff --git a/lib/mnesia/src/mnesia_checkpoint.erl b/lib/mnesia/src/mnesia_checkpoint.erl index 33b28a2f29..9eb939e8d3 100644 --- a/lib/mnesia/src/mnesia_checkpoint.erl +++ b/lib/mnesia/src/mnesia_checkpoint.erl @@ -675,6 +675,16 @@ tab2retainer({Tab, Name}) -> FlatName = lists:flatten(io_lib:write(Name)), mnesia_lib:dir(lists:concat([?MODULE, "_", Tab, "_", FlatName, ".RET"])). +retainer_create(_Cp, R, Tab, Name, Ext = {ext, Alias, Mod}) -> + T = {Tab, retainer, Name}, + P = mnesia_schema:cs2list(val({Tab, cstruct})), + Mod:delete_table(Alias, T), + ok = Mod:create_table(Alias, T, P), + Cs = val({Tab, cstruct}), + Mod:load_table(Alias, T, {retainer, create_table}, + mnesia_schema:cs2list(Cs)), + dbg_out("Checkpoint retainer created ~p ~p~n", [Name, Tab]), + R#retainer{store = {Ext, T}, really_retain = true}; retainer_create(_Cp, R, Tab, Name, disc_only_copies) -> Fname = tab2retainer({Tab, Name}), file:delete(Fname), @@ -734,15 +744,23 @@ traverse_dcd({Cont, Recs}, Log, Fun) -> %% trashed data?? traverse_dcd(eof, _Log, _Fun) -> ok. +retainer_get({{ext, Alias, Mod}, Store}, Key) -> + Mod:lookup(Alias, Store, Key); retainer_get({ets, Store}, Key) -> ?ets_lookup(Store, Key); retainer_get({dets, Store}, Key) -> dets:lookup(Store, Key). +retainer_put({{ext, Alias, Mod}, Store}, Val) -> + Mod:insert(Alias, Store, Val); retainer_put({ets, Store}, Val) -> ?ets_insert(Store, Val); retainer_put({dets, Store}, Val) -> dets:insert(Store, Val). +retainer_first({{ext, Alias, Mod}, Store}) -> + Mod:first(Alias, Store); retainer_first({ets, Store}) -> ?ets_first(Store); retainer_first({dets, Store}) -> dets:first(Store). +retainer_next({{ext, Alias, Mod}, Store}, Key) -> + Mod:next(Alias, Store, Key); retainer_next({ets, Store}, Key) -> ?ets_next(Store, Key); retainer_next({dets, Store}, Key) -> dets:next(Store, Key). @@ -761,11 +779,16 @@ retainer_next({dets, Store}, Key) -> dets:next(Store, Key). retainer_fixtable(Tab, Bool) when is_atom(Tab) -> mnesia_lib:db_fixtable(val({Tab, storage_type}), Tab, Bool); +retainer_fixtable({Ext = {ext, _, _}, Tab}, Bool) -> + mnesia_lib:db_fixtable(Ext, Tab, Bool); retainer_fixtable({ets, Tab}, Bool) -> mnesia_lib:db_fixtable(ram_copies, Tab, Bool); retainer_fixtable({dets, Tab}, Bool) -> mnesia_lib:db_fixtable(disc_only_copies, Tab, Bool). +retainer_delete({{ext, Alias, Mod}, Store}) -> + Mod:close_table(Alias, Store), + Mod:delete_table(Alias, Store); retainer_delete({ets, Store}) -> ?ets_delete_table(Store); retainer_delete({dets, Store}) -> diff --git a/lib/mnesia/src/mnesia_controller.erl b/lib/mnesia/src/mnesia_controller.erl index 58cc66e18b..4791e2e290 100644 --- a/lib/mnesia/src/mnesia_controller.erl +++ b/lib/mnesia/src/mnesia_controller.erl @@ -385,6 +385,8 @@ force_load_table(Tab) when is_atom(Tab), Tab /= schema -> do_force_load_table(Tab); disc_only_copies -> do_force_load_table(Tab); + {ext, _, _} -> + do_force_load_table(Tab); unknown -> set({Tab, load_by_force}, true), cast({force_load_updated, Tab}), @@ -1533,8 +1535,8 @@ update_whereabouts(Tab, Node, State) -> Storage == unknown -> %% No own copy, continue to read remotely add_active_replica(Tab, Node), - NodeST = mnesia_lib:storage_type_at_node(Node, Tab), - ReadST = mnesia_lib:storage_type_at_node(Read, Tab), + NodeST = mnesia_lib:semantics(mnesia_lib:storage_type_at_node(Node, Tab), storage), + ReadST = mnesia_lib:semantics(mnesia_lib:storage_type_at_node(Read, Tab), storage), if %% Avoid reading from disc_only_copies NodeST == disc_only_copies -> ignore; @@ -1588,6 +1590,7 @@ last_consistent_replica(Tab, Downs) -> Ram = Cs#cstruct.ram_copies, Disc = Cs#cstruct.disc_copies, DiscOnly = Cs#cstruct.disc_only_copies, + Ext = Cs#cstruct.external_copies, BetterCopies0 = mnesia_lib:remote_copy_holders(Cs) -- Downs, BetterCopies = BetterCopies0 -- Ram, AccessMode = Cs#cstruct.access_mode, @@ -1620,7 +1623,7 @@ last_consistent_replica(Tab, Downs) -> false; Storage == ram_copies -> if - Disc == [], DiscOnly == [] -> + Disc == [], DiscOnly == [], Ext == [] -> %% Nobody has copy on disc {true, {Tab, ram_only}}; true -> @@ -1865,6 +1868,11 @@ info([Tab | Tail]) -> dets:info(Tab, size), dets:info(Tab, file_size), "bytes on disc"); + {ext, Alias, Mod} -> + info_format(Tab, + Mod:info(Alias, Tab, size), + Mod:info(Alias, Tab, memory), + "words of mem"); _ -> info_format(Tab, ?ets_info(Tab, size), diff --git a/lib/mnesia/src/mnesia_dumper.erl b/lib/mnesia/src/mnesia_dumper.erl index 7418ab7436..eb02a585a6 100644 --- a/lib/mnesia/src/mnesia_dumper.erl +++ b/lib/mnesia/src/mnesia_dumper.erl @@ -38,6 +38,8 @@ needs_dump_ets/1, raw_dump_table/2, raw_named_dump_table/2, + dump_to_logfile/2, + load_from_logfile/3, start_regulator/0, opt_dump_log/1, update/3, @@ -227,11 +229,11 @@ insert_rec(Rec, InPlace, InitBy, LogV) when is_record(Rec, commit) -> D = Rec#commit.decision, case mnesia_recover:wait_for_decision(D, InitBy) of {Tid, committed} -> - do_insert_rec(Tid, Rec, InPlace, InitBy, LogV); + do_insert_rec(Tid, mnesia_tm:new_cr_format(Rec), InPlace, InitBy, LogV); {Tid, aborted} -> case InitBy of startup -> - mnesia_schema:undo_prepare_commit(Tid, Rec); + mnesia_schema:undo_prepare_commit(Tid, mnesia_tm:new_cr_format(Rec)); _ -> ok end @@ -271,15 +273,30 @@ do_insert_rec(Tid, Rec, InPlace, InitBy, LogV) -> end end, D = Rec#commit.disc_copies, + ExtOps = commit_ext(Rec), insert_ops(Tid, disc_copies, D, InPlace, InitBy, LogV), + [insert_ops(Tid, Ext, Ops, InPlace, InitBy, LogV) || + {Ext, Ops} <- ExtOps, + storage_semantics(Ext) == disc_copies], case InitBy of startup -> DO = Rec#commit.disc_only_copies, - insert_ops(Tid, disc_only_copies, DO, InPlace, InitBy, LogV); + insert_ops(Tid, disc_only_copies, DO, InPlace, InitBy, LogV), + [insert_ops(Tid, Ext, Ops, InPlace, InitBy, LogV) || + {Ext, Ops} <- ExtOps, storage_semantics(Ext) == disc_only_copies]; _ -> ignore end. +commit_ext(#commit{ext = []}) -> []; +commit_ext(#commit{ext = Ext}) -> + case lists:keyfind(ext_copies, 1, Ext) of + {_, C} -> + lists:foldl(fun({Ext0, Op}, D) -> + orddict:append(Ext0, Op, D) + end, orddict:new(), C); + false -> [] + end. update(_Tid, [], _DumperMode) -> dumped; @@ -330,14 +347,15 @@ insert_ops(Tid, Storage, [Op | Ops], InPlace, InitBy, Ver) when Ver < "4.3" -> %% Normal ops disc_insert(_Tid, Storage, Tab, Key, Val, Op, InPlace, InitBy) -> - case open_files(Tab, Storage, InPlace, InitBy) of + Semantics = storage_semantics(Storage), + case open_files(Tab, Semantics, Storage, InPlace, InitBy) of true -> - case Storage of + case Semantics of disc_copies when Tab /= schema -> mnesia_log:append({?MODULE,Tab}, {{Tab, Key}, Val, Op}), ok; _ -> - dets_insert(Op,Tab,Key,Val) + dets_insert(Op,Tab,Key,Val,Storage) end; false -> ignore @@ -349,34 +367,37 @@ disc_insert(_Tid, Storage, Tab, Key, Val, Op, InPlace, InitBy) -> %% Otherwise we will get a double increment. %% This is perfect but update_counter is a dirty op. -dets_insert(Op,Tab,Key,Val) -> +dets_insert(Op,Tab,Key,Val, Storage0) -> + Storage = if Tab == schema -> disc_only_copies; + true -> Storage0 + end, case Op of write -> dets_updated(Tab,Key), - ok = dets:insert(Tab, Val); + ok = mnesia_lib:db_put(Storage, Tab, Val); delete -> dets_updated(Tab,Key), - ok = dets:delete(Tab, Key); + ok = mnesia_lib:db_erase(Storage, Tab, Key); update_counter -> case dets_incr_counter(Tab,Key) of true -> {RecName, Incr} = Val, - try _ = dets:update_counter(Tab, Key, Incr) + try _ = mnesia_lib:db_update_counter(Storage, Tab, Key, Incr) catch error:_ when Incr < 0 -> Zero = {RecName, Key, 0}, - ok = dets:insert(Tab, Zero); + ok = mnesia_lib:db_put(Storage, Tab, Zero); error:_ -> Init = {RecName, Key, Incr}, - ok = dets:insert(Tab, Init) + ok = mnesia_lib:db_put(Storage, Tab, Init) end; false -> ok end; delete_object -> dets_updated(Tab,Key), - ok = dets:delete_object(Tab, Val); + mnesia_lib:db_match_erase(Storage, Tab, Val); clear_table -> dets_cleared(Tab), - ok = dets:delete_all_objects(Tab) + ok = mnesia_lib:db_match_erase(Storage, Tab, '_') end. dets_updated(Tab,Key) -> @@ -431,23 +452,29 @@ insert(_Tid, _Storage, _Tab, _Key, [], _Op, _InPlace, _InitBy) -> ok; insert(Tid, Storage, Tab, Key, Val, Op, InPlace, InitBy) -> + Semantics = storage_semantics(Storage), Item = {{Tab, Key}, Val, Op}, case InitBy of startup -> disc_insert(Tid, Storage, Tab, Key, Val, Op, InPlace, InitBy); - _ when Storage == ram_copies -> + _ when Semantics == ram_copies -> mnesia_tm:do_update_op(Tid, Storage, Item), Snmp = mnesia_tm:prepare_snmp(Tab, Key, [Item]), mnesia_tm:do_snmp(Tid, Snmp); - _ when Storage == disc_copies -> + _ when Semantics == disc_copies -> disc_insert(Tid, Storage, Tab, Key, Val, Op, InPlace, InitBy), mnesia_tm:do_update_op(Tid, Storage, Item), Snmp = mnesia_tm:prepare_snmp(Tab, Key, [Item]), mnesia_tm:do_snmp(Tid, Snmp); - _ when Storage == disc_only_copies -> + _ when Semantics == disc_only_copies -> + mnesia_tm:do_update_op(Tid, Storage, Item), + Snmp = mnesia_tm:prepare_snmp(Tab, Key, [Item]), + mnesia_tm:do_snmp(Tid, Snmp); + + _ when element(1, Storage) == ext -> mnesia_tm:do_update_op(Tid, Storage, Item), Snmp = mnesia_tm:prepare_snmp(Tab, Key, [Item]), mnesia_tm:do_snmp(Tid, Snmp); @@ -456,6 +483,9 @@ insert(Tid, Storage, Tab, Key, Val, Op, InPlace, InitBy) -> ignore end. +disc_delete_table(Tab, {ext, Alias, Mod}) -> + Mod:close_table(Alias, Tab), + Mod:delete_table(Alias, Tab); disc_delete_table(Tab, Storage) -> case mnesia_monitor:use_dir() of true -> @@ -485,11 +515,14 @@ disc_delete_table(Tab, Storage) -> ok end. -disc_delete_indecies(_Tab, _Cs, Storage) when Storage /= disc_only_copies -> - ok; -disc_delete_indecies(Tab, Cs, disc_only_copies) -> - Indecies = Cs#cstruct.index, - mnesia_index:del_transient(Tab, Indecies, disc_only_copies). +disc_delete_indecies(Tab, Cs, Storage) -> + case storage_semantics(Storage) of + disc_only_copies -> + Indecies = Cs#cstruct.index, + mnesia_index:del_transient(Tab, Indecies, Storage); + _ -> + ok + end. insert_op(Tid, Storage, {{Tab, Key}, Val, Op}, InPlace, InitBy) -> %% Propagate to disc only @@ -515,6 +548,8 @@ insert_op(Tid, _, {op, change_table_copy_type, N, FromS, ToS, TabDef}, InPlace, Cs = mnesia_schema:list2cs(TabDef), Val = mnesia_schema:insert_cstruct(Tid, Cs, true), % Update ram only {schema, Tab, _} = Val, + FromSem = storage_semantics(FromS), + ToSem = storage_semantics(ToS), case lists:member(N, val({current, db_nodes})) of true when InitBy /= startup -> mnesia_controller:add_active_replica(Tab, N, Cs); @@ -527,62 +562,118 @@ insert_op(Tid, _, {op, change_table_copy_type, N, FromS, ToS, TabDef}, InPlace, Dat = mnesia_lib:tab2dat(Tab), Dcd = mnesia_lib:tab2dcd(Tab), Dcl = mnesia_lib:tab2dcl(Tab), + Logtmp = mnesia_lib:tab2logtmp(Tab), case {FromS, ToS} of - {ram_copies, disc_copies} when Tab == schema -> - ok = ensure_rename(Dmp, Dat); - {ram_copies, disc_copies} -> - file:delete(Dcl), - ok = ensure_rename(Dmp, Dcd); - {disc_copies, ram_copies} when Tab == schema -> - mnesia_lib:set(use_dir, false), - mnesia_monitor:unsafe_close_dets(Tab), - ok = file:delete(Dat); - {disc_copies, ram_copies} -> - _ = file:delete(Dcl), - _ = file:delete(Dcd), - ok; - {ram_copies, disc_only_copies} -> - ok = ensure_rename(Dmp, Dat), - true = open_files(Tab, disc_only_copies, InPlace, InitBy), - %% ram_delete_table must be done before init_indecies, - %% it uses info which is reset in init_indecies, - %% it doesn't matter, because init_indecies don't use - %% the ram replica of the table when creating the disc - %% index; Could be improved :) - mnesia_schema:ram_delete_table(Tab, FromS), - PosList = Cs#cstruct.index, - mnesia_index:init_indecies(Tab, disc_only_copies, PosList); - {disc_only_copies, ram_copies} -> - mnesia_monitor:unsafe_close_dets(Tab), - disc_delete_indecies(Tab, Cs, disc_only_copies), - case InitBy of - startup -> - ignore; + {{ext,_FromAlias,_FromMod},{ext,ToAlias,ToMod}} -> + disc_delete_table(Tab, FromS), + ok = ToMod:delete_table(ToAlias, Tab), + ok = mnesia_monitor:unsafe_create_external(Tab, ToAlias, ToMod, TabDef), + ok = ToMod:load_table(ToAlias, Tab, {dumper,change_table_copy_type}, TabDef), + ok = load_from_logfile(ToS, Tab, Logtmp), + file:delete(Logtmp), + restore_indexes(Tab, ToS, Cs); + + {_,{ext,ToAlias,ToMod}} -> + case FromSem of + ram_copies -> + mnesia_schema:ram_delete_table(Tab, FromS); _ -> - mnesia_controller:get_disc_copy(Tab), - ok + if FromSem == disc_copies -> + mnesia_schema:ram_delete_table( + Tab, FromS); + true -> ok + end, + disc_delete_table(Tab, FromS) end, - disc_delete_table(Tab, disc_only_copies); - {disc_copies, disc_only_copies} -> - ok = ensure_rename(Dmp, Dat), - true = open_files(Tab, disc_only_copies, InPlace, InitBy), - mnesia_schema:ram_delete_table(Tab, FromS), - PosList = Cs#cstruct.index, - mnesia_index:init_indecies(Tab, disc_only_copies, PosList), - _ = file:delete(Dcl), - _ = file:delete(Dcd), - ok; - {disc_only_copies, disc_copies} -> - mnesia_monitor:unsafe_close_dets(Tab), - disc_delete_indecies(Tab, Cs, disc_only_copies), - case InitBy of - startup -> - ignore; - _ -> - mnesia_log:ets2dcd(Tab), - mnesia_controller:get_disc_copy(Tab), - disc_delete_table(Tab, disc_only_copies) - end + + ok = ToMod:delete_table(ToAlias, Tab), + ok = mnesia_monitor:unsafe_create_external(Tab, ToAlias, ToMod, TabDef), + ok = ToMod:load_table(ToAlias, Tab, {dumper,change_table_copy_type}, TabDef), + ok = load_from_logfile(ToS, Tab, Logtmp), + file:delete(Logtmp), + restore_indexes(Tab, ToS, Cs); + + {{ext,_FromAlias,_FromMod} = FromS, ToS} -> + disc_delete_table(Tab, FromS), + case ToS of + ram_copies -> + change_disc_to_ram( + Tab, Cs, FromS, ToS, Logtmp, InitBy); + disc_copies -> + Args = [{keypos, 2}, public, named_table, + Cs#cstruct.type], + mnesia_monitor:mktab(Tab, Args), + ok = load_from_logfile(ToS, Tab, Logtmp), + file:delete(Logtmp); + disc_only_copies -> + %% ok = ensure_rename(Dmp, Dat), + true = open_files(Tab, ToS, InPlace, InitBy), + ok = load_from_logfile(ToS, Tab, Logtmp), + file:delete(Logtmp) + end, + restore_indexes(Tab, ToS, Cs); + + _NoneAreExt -> + + case {FromSem, ToSem} of + {ram_copies, disc_copies} when Tab == schema -> + ok = ensure_rename(Dmp, Dat); + {ram_copies, disc_copies} -> + file:delete(Dcl), + ok = ensure_rename(Dmp, Dcd); + {disc_copies, ram_copies} when Tab == schema -> + mnesia_lib:set(use_dir, false), + mnesia_monitor:unsafe_close_dets(Tab), + ok = file:delete(Dat); + {disc_copies, ram_copies} -> + _ = file:delete(Dcl), + _ = file:delete(Dcd), + ok; + {ram_copies, disc_only_copies} -> + ok = ensure_rename(Dmp, Dat), + true = open_files(Tab, ToS, InPlace, InitBy), + %% ram_delete_table must be done before + %% init_indecies, it uses info which is reset + %% in init_indecies, it doesn't matter, because + %% init_indecies don't use the ram replica of + %% the table when creating the disc index; + %% Could be improved :) + mnesia_schema:ram_delete_table(Tab, FromS), + restore_indexes(Tab, ToS, Cs); + {disc_only_copies, ram_copies} when FromS == disc_only_copies -> + mnesia_monitor:unsafe_close_dets(Tab), + disc_delete_indecies(Tab, Cs, FromS), + case InitBy of + startup -> + ignore; + _ -> + mnesia_controller:get_disc_copy(Tab), + ok + end, + disc_delete_table(Tab, FromS); + {disc_only_copies, ram_copies} when element(1, FromS) == ext -> + change_disc_to_ram( + Tab, Cs, FromS, ToS, Logtmp, InitBy); + {disc_copies, disc_only_copies} -> + ok = ensure_rename(Dmp, Dat), + true = open_files(Tab, ToS, InPlace, InitBy), + mnesia_schema:ram_delete_table(Tab, FromS), + restore_indexes(Tab, ToS, Cs), + _ = file:delete(Dcl), + _ = file:delete(Dcd), + ok; + {disc_only_copies, disc_copies} -> + mnesia_monitor:unsafe_close_dets(Tab), + disc_delete_indecies(Tab, Cs, disc_only_copies), + case InitBy of + startup -> + ignore; + _ -> + mnesia_log:ets2dcd(Tab), + mnesia_controller:get_disc_copy(Tab), + disc_delete_table(Tab, disc_only_copies) + end + end end; true -> ignore @@ -607,6 +698,9 @@ insert_op(Tid, _, {op, restore_recreate, TabDef}, InPlace, InitBy) -> Tab = Cs#cstruct.name, Type = Cs#cstruct.type, Storage = mnesia_lib:cs_to_storage_type(node(), Cs), + Semantics = if Storage==unknown -> unknown; + true -> storage_semantics(Storage) + end, %% Delete all possibly existing files and tables disc_delete_table(Tab, Storage), disc_delete_indecies(Tab, Cs, Storage), @@ -625,13 +719,13 @@ insert_op(Tid, _, {op, restore_recreate, TabDef}, InPlace, InitBy) -> %% And create new ones.. if - (InitBy == startup) or (Storage == unknown) -> + (InitBy == startup) or (Semantics == unknown) -> ignore; - Storage == ram_copies -> + Semantics == ram_copies -> EtsProps = proplists:get_value(ets, StorageProps, []), Args = [{keypos, 2}, public, named_table, Type | EtsProps], mnesia_monitor:mktab(Tab, Args); - Storage == disc_copies -> + Semantics == disc_copies -> EtsProps = proplists:get_value(ets, StorageProps, []), Args = [{keypos, 2}, public, named_table, Type | EtsProps], mnesia_monitor:mktab(Tab, Args), @@ -640,7 +734,7 @@ insert_op(Tid, _, {op, restore_recreate, TabDef}, InPlace, InitBy) -> {repair, false}, {mode, read_write}], {ok, Log} = mnesia_monitor:open_log(FArg), mnesia_monitor:unsafe_close_log(Log); - Storage == disc_only_copies -> + Storage == disc_only_copies -> % note: Storage, not Semantics File = mnesia_lib:tab2dat(Tab), file:delete(File), DetsProps = proplists:get_value(dets, StorageProps, []), @@ -649,7 +743,10 @@ insert_op(Tid, _, {op, restore_recreate, TabDef}, InPlace, InitBy) -> {keypos, 2}, {repair, mnesia_monitor:get_env(auto_repair)} | DetsProps ], - mnesia_monitor:open_dets(Tab, Args) + mnesia_monitor:open_dets(Tab, Args); + element(1,Storage) == ext -> + {ext, Alias, Mod} = Storage, + Mod:create_table(Alias, Tab, []) end, insert_op(Tid, ignore, {op, create_table, TabDef}, InPlace, InitBy); @@ -659,9 +756,10 @@ insert_op(Tid, _, {op, create_table, TabDef}, InPlace, InitBy) -> Tab = Cs#cstruct.name, Storage = mnesia_lib:cs_to_storage_type(node(), Cs), StorageProps = Cs#cstruct.storage_properties, + Semantics = storage_semantics(Storage), case InitBy of startup -> - case Storage of + case Semantics of unknown -> ignore; ram_copies -> @@ -679,20 +777,10 @@ insert_op(Tid, _, {op, create_table, TabDef}, InPlace, InitBy) -> read_write), mnesia_log:unsafe_close_log(temp) end; - _ -> + disc_only_copies -> DetsProps = proplists:get_value(dets, StorageProps, []), - Args = [{file, mnesia_lib:tab2dat(Tab)}, - {type, mnesia_lib:disk_type(Tab, Cs#cstruct.type)}, - {keypos, 2}, - {repair, mnesia_monitor:get_env(auto_repair)} - | DetsProps ], - case mnesia_monitor:open_dets(Tab, Args) of - {ok, _} -> - mnesia_monitor:unsafe_close_dets(Tab); - {error, Error} -> - exit({"Failed to create dets table", Error}) - end + try_create_disc_only_copy(Storage, Tab, Cs, DetsProps) end; _ -> Copies = mnesia_lib:copy_holders(Cs), @@ -715,7 +803,7 @@ insert_op(Tid, _, {op, create_table, TabDef}, InPlace, InitBy) -> false -> mnesia_lib:set({Tab, where_to_read}, node()) end, - case Storage of + case Semantics of ram_copies -> ignore; _ -> @@ -838,7 +926,7 @@ insert_op(Tid, _, {op, del_table_copy, Storage, Node, TabDef}, InPlace, InitBy) insert_cstruct(Tid, Cs, true, InPlace, InitBy); Tab /= schema -> mnesia_controller:del_active_replica(Tab, Node), - mnesia_lib:del({Tab, Storage}, Node), + mnesia_lib:del({Tab, storage_alias(Storage)}, Node), if Node == node() -> case Cs#cstruct.local_content of @@ -896,9 +984,10 @@ insert_op(Tid, _, {op, add_index, Pos, TabDef}, InPlace, InitBy) -> Cs = mnesia_schema:list2cs(TabDef), Tab = insert_cstruct(Tid, Cs, true, InPlace, InitBy), Storage = mnesia_lib:cs_to_storage_type(node(), Cs), + Semantics = storage_semantics(Storage), case InitBy of - startup when Storage == disc_only_copies -> - true = open_files(Tab, Storage, InPlace, InitBy), + startup when Semantics == disc_only_copies -> + true = open_files(Tab, Semantics, Storage, InPlace, InitBy), mnesia_index:init_indecies(Tab, Storage, [Pos]); startup -> ignore; @@ -919,6 +1008,8 @@ insert_op(Tid, _, {op, del_index, Pos, TabDef}, InPlace, InitBy) -> mnesia_index:del_index_table(Tab, Storage, Pos); startup -> ignore; + _ when element(1, Storage) == ext -> + mnesia_index:del_index_table(Tab, Storage, Pos); _ -> mnesia_index:del_index_table(Tab, Storage, Pos) end, @@ -958,19 +1049,68 @@ insert_op(Tid, _, {op, change_table_frag, _Change, TabDef}, InPlace, InitBy) -> Cs = mnesia_schema:list2cs(TabDef), insert_cstruct(Tid, Cs, true, InPlace, InitBy). -open_files(Tab, Storage, UpdateInPlace, InitBy) - when Storage /= unknown, Storage /= ram_copies -> + +storage_semantics({ext, Alias, Mod}) -> + Mod:semantics(Alias, storage); +storage_semantics(Storage) when is_atom(Storage) -> + Storage. + +storage_alias({ext, Alias, _}) -> + Alias; +storage_alias(Storage) when is_atom(Storage) -> + Storage. + +change_disc_to_ram(Tab, Cs, FromS, ToS, Logtmp, InitBy) -> + disc_delete_indecies(Tab, Cs, FromS), + case InitBy of + startup -> + ignore; + _ -> + %% ram table will already have been created + Tab = ets:info(Tab, name), %% assertion + load_from_logfile(ToS, Tab, Logtmp), + PosList = Cs#cstruct.index, + mnesia_index:init_indecies(Tab, ToS, PosList) + end, + disc_delete_table(Tab, FromS). + + +try_create_disc_only_copy({ext,Alias,Mod}, Tab, Cs, _) -> + Mod:create_table(Alias, Tab, mnesia_schema:cs2list(Cs)); +try_create_disc_only_copy(disc_only_copies, Tab, Cs, DetsProps) -> + Args = [{file, mnesia_lib:tab2dat(Tab)}, + {type, mnesia_lib:disk_type(Tab, Cs#cstruct.type)}, + {keypos, 2}, + {repair, mnesia_monitor:get_env(auto_repair)} + | DetsProps], + case mnesia_monitor:open_dets(Tab, Args) of + {ok, _} -> + mnesia_monitor:unsafe_close_dets(Tab); + {error, Error} -> + exit({"Failed to create dets table", Error}) + end. + +restore_indexes(Tab, ToS, Cs) -> + PosList = Cs#cstruct.index, + mnesia_index:init_indecies(Tab, ToS, PosList). + + +open_files(Tab, Storage, UpdateInPlace, InitBy) -> + open_files(Tab, storage_semantics(Storage), Storage, UpdateInPlace, InitBy). + +open_files(Tab, Semantics, Storage, UpdateInPlace, InitBy) + when Storage /= unknown, Semantics /= ram_copies -> case get({?MODULE, Tab}) of undefined -> case ?catch_val({Tab, setorbag}) of {'EXIT', _} -> false; Type -> - case Storage of - disc_copies when Tab /= schema -> + Cs = val({Tab, cstruct}), + if Semantics == disc_copies, Tab /= schema -> Bool = open_disc_copies(Tab, InitBy), Bool; - _ -> + Storage == disc_only_copies; Tab == schema -> Props = val({Tab, storage_properties}), DetsProps = proplists:get_value(dets, Props, []), Fname = prepare_open(Tab, UpdateInPlace), @@ -981,6 +1121,12 @@ open_files(Tab, Storage, UpdateInPlace, InitBy) | DetsProps], {ok, _} = mnesia_monitor:open_dets(Tab, Args), put({?MODULE, Tab}, {opened_dumper, dat}), + true; + element(1, Storage) == ext -> + {ext, Alias, Mod} = Storage, + Mod:load_table(Alias, Tab, InitBy, + mnesia_schema:cs2list(Cs)), + put({?MODULE, Tab}, {opened_dumper, ext}), true end end; @@ -989,7 +1135,7 @@ open_files(Tab, Storage, UpdateInPlace, InitBy) {opened_dumper, _} -> true end; -open_files(_Tab, _Storage, _UpdateInPlace, _InitBy) -> +open_files(_Tab, _Semantics, _Storage, _UpdateInPlace, _InitBy) -> false. open_disc_copies(Tab, InitBy) -> @@ -1076,12 +1222,13 @@ close_files(InPlace, Outcome, InitBy, [{{?MODULE, Tab}, already_dumped} | Tail]) close_files(InPlace, Outcome, InitBy, Tail); close_files(InPlace, Outcome, InitBy, [{{?MODULE, Tab}, {opened_dumper, Type}} | Tail]) -> erase({?MODULE, Tab}), - case val({Tab, storage_type}) of + Storage = val({Tab, storage_type}), + case storage_semantics(Storage) of disc_only_copies when InitBy /= startup -> ignore; - disc_copies when Tab /= schema -> + disc_copies when Storage /= unknown, Tab /= schema -> mnesia_log:close_log({?MODULE,Tab}); - Storage -> + _ -> do_close(InPlace, Outcome, Tab, Type, Storage) end, close_files(InPlace, Outcome, InitBy, Tail); @@ -1093,11 +1240,16 @@ close_files(_, _, _InitBy, []) -> %% If storage is unknown during close clean up files, this can happen if timing %% is right and dirty_write conflicts with schema operations. +do_close(_, _, Tab, ext, {ext,Alias,Mod}) -> + Mod:close_table(Alias, Tab); do_close(_, _, Tab, dcl, unknown) -> mnesia_log:close_log({?MODULE,Tab}), file:delete(mnesia_lib:tab2dcl(Tab)); do_close(_, _, Tab, dcl, _) -> %% To be safe, can it happen? mnesia_log:close_log({?MODULE,Tab}); +do_close(_, _, _Tab, ext, unknown) -> + %% Not sure what to do here, but let's not crash + ok; do_close(InPlace, Outcome, Tab, dat, Storage) -> mnesia_monitor:close_dets(Tab), @@ -1148,7 +1300,8 @@ temp_set_master_nodes() -> Tabs = val({schema, local_tables}), Masters = [{Tab, (val({Tab, disc_copies}) ++ val({Tab, ram_copies}) ++ - val({Tab, disc_only_copies})) -- [node()]} + val({Tab, disc_only_copies}) ++ + external_copies(Tab)) -- [node()]} || Tab <- Tabs], %% UseDir = false since we don't want to remember these %% masternodes and we are running (really soon anyway) since we want this @@ -1156,6 +1309,13 @@ temp_set_master_nodes() -> mnesia_recover:log_master_nodes(Masters, false, yes), ok. +external_copies(Tab) -> + case ?catch_val({Tab, external_copies}) of + {'EXIT',_} -> []; + Ext -> + lists:concat([Ns || {_, Ns} <- Ext]) + end. + %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %% Raw dump of table. Dumper must have unique access to the ets table. @@ -1207,6 +1367,59 @@ raw_named_dump_table(Tab, Ftype) -> raw_dump_table(DetsRef, EtsRef) -> dets:from_ets(DetsRef, EtsRef). +dump_to_logfile(Storage, Tab) -> + case mnesia_monitor:use_dir() of + true -> + Logtmp = mnesia_lib:tab2logtmp(Tab), + file:delete(Logtmp), + case disk_log:open([{name, make_ref()}, + {file, Logtmp}, + {repair, false}, + {linkto, self()}]) of + {ok, Fd} -> + mnesia_lib:db_fixtable(Storage, Tab, true), + try do_dump_to_logfile(Storage, Tab, Fd) + after + mnesia_lib:db_fixtable(Storage, Tab, false) + end; + {error, _} = Error -> + Error + end; + false -> + {error, {has_no_disc, node()}} + end. + +do_dump_to_logfile(Storage, Tab, Fd) -> + Pat = [{'_',[],['$_']}], + log_terms(mnesia_lib:db_select_init(Storage, Tab, Pat, 100), Storage, Tab, Pat, Fd). + +log_terms({Objs, Cont}, Storage, Tab, Pat, Fd) -> + ok = disk_log:alog_terms(Fd, Objs), + log_terms(mnesia_lib:db_select_cont(Storage, Cont, '_'), Storage, Tab, Pat, Fd); +log_terms('$end_of_table', _, _, _, Fd) -> + disk_log:close(Fd). + +load_from_logfile(Storage, Tab, F) -> + case disk_log:open([{name, make_ref()}, + {file, F}, + {repair, true}, + {linkto, self()}]) of + {ok, Fd} -> + chunk_from_log(disk_log:chunk(Fd, start), Fd, Storage, Tab); + {repaired, Fd, _, _} -> + chunk_from_log(disk_log:chunk(Fd, start), Fd, Storage, Tab); + {error, _} = E -> + E + end. + +chunk_from_log({Cont, Terms}, Fd, Storage, Tab) -> + _ = [mnesia_lib:db_put(Storage, Tab, T) || T <- Terms], + chunk_from_log(disk_log:chunk(Fd, Cont), Fd, Storage, Tab); +chunk_from_log(eof, _, _, _) -> + ok. + + + %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %% Load regulator %% diff --git a/lib/mnesia/src/mnesia_ext_sup.erl b/lib/mnesia/src/mnesia_ext_sup.erl new file mode 100644 index 0000000000..3e6c72161c --- /dev/null +++ b/lib/mnesia/src/mnesia_ext_sup.erl @@ -0,0 +1,59 @@ +%% +%% %CopyrightBegin% +%% +%% Copyright Ericsson AB 1996-2015. All Rights Reserved. +%% +%% Licensed under the Apache License, Version 2.0 (the "License"); +%% you may not use this file except in compliance with the License. +%% You may obtain a copy of the License at +%% +%% http://www.apache.org/licenses/LICENSE-2.0 +%% +%% Unless required by applicable law or agreed to in writing, software +%% distributed under the License is distributed on an "AS IS" BASIS, +%% WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +%% See the License for the specific language governing permissions and +%% limitations under the License. +%% +%% %CopyrightEnd% +%% + +%% +%% This module implements a supervisor for external (plug-in) processes + +-module(mnesia_ext_sup). +-behaviour(supervisor). + +-export([start/0, + init/1, + start_proc/4, start_proc/5, + stop_proc/1]). + +-define(SHUTDOWN, 120000). % 2 minutes + +start() -> + supervisor:start_link({local, ?MODULE}, ?MODULE, []). + +start_proc(Name, M, F, A) -> + start_proc(Name, M, F, A, []). + +start_proc(Name, M, F, A, Opts) -> + [Restart, Shutdown, Type, Modules] = + [proplists:get_value(K, Opts, Default) + || {K, Default} <- [{restart, transient}, + {shutdown, ?SHUTDOWN}, + {type, worker}, + {modules, [M]}]], + case supervisor:start_child( + ?MODULE, {Name, {M,F,A}, Restart, Shutdown, Type, Modules}) of + {error, already_present} -> + supervisor:restart_child(?MODULE, Name); + Other -> + Other + end. + +stop_proc(Name) -> + supervisor:terminate_child(?MODULE, Name). + +init(_) -> + {ok, {{one_for_all, 10, 60}, []}}. diff --git a/lib/mnesia/src/mnesia_frag.erl b/lib/mnesia/src/mnesia_frag.erl index c4de603460..c6e812b36d 100644 --- a/lib/mnesia/src/mnesia_frag.erl +++ b/lib/mnesia/src/mnesia_frag.erl @@ -183,6 +183,8 @@ table_info2(ActivityId, Opaque, Tab, Frag, Item) -> length(val({Tab, disc_copies})); n_disc_only_copies -> length(val({Tab, disc_only_copies})); + n_external_copies -> + length(val({Tab, external_copies})); frag_names -> frag_names(Tab); @@ -498,13 +500,13 @@ expand_cstruct(Cs, Mode) -> %% Verify keys ValidKeys = [foreign_key, n_fragments, node_pool, n_ram_copies, n_disc_copies, n_disc_only_copies, - hash_module, hash_state], + n_external_copies, hash_module, hash_state], Keys = mnesia_schema:check_keys(Tab, Props, ValidKeys), mnesia_schema:check_duplicates(Tab, Keys), %% Pick fragmentation props ForeignKey = mnesia_schema:pick(Tab, foreign_key, Props, undefined), - {ForeignKey2, N, Pool, DefaultNR, DefaultND, DefaultNDO} = + {ForeignKey2, N, Pool, DefaultNR, DefaultND, DefaultNDO, DefaultNExt} = pick_props(Tab, Cs, ForeignKey), %% Verify node_pool @@ -518,6 +520,7 @@ expand_cstruct(Cs, Mode) -> NR = mnesia_schema:pick(Tab, n_ram_copies, Props, 0), ND = mnesia_schema:pick(Tab, n_disc_copies, Props, 0), NDO = mnesia_schema:pick(Tab, n_disc_only_copies, Props, 0), + NExt = mnesia_schema:pick(Tab, n_external_copies, Props, 0), PosInt = fun(I) when is_integer(I), I >= 0 -> true; (_I) -> false @@ -528,6 +531,8 @@ expand_cstruct(Cs, Mode) -> {bad_type, Tab, {n_disc_copies, ND}}), mnesia_schema:verify(true, PosInt(NDO), {bad_type, Tab, {n_disc_only_copies, NDO}}), + mnesia_schema:verify(true, PosInt(NExt), + {bad_type, Tab, {n_external_copies, NDO}}), %% Verify n_fragments Cs2 = verify_n_fragments(N, Cs, Mode), @@ -542,13 +547,13 @@ expand_cstruct(Cs, Mode) -> hash_module = HashMod, hash_state = HashState2}, if - NR == 0, ND == 0, NDO == 0 -> - do_expand_cstruct(Cs2, FH, N, Pool, DefaultNR, DefaultND, DefaultNDO, Mode); + NR == 0, ND == 0, NDO == 0, NExt == 0 -> + do_expand_cstruct(Cs2, FH, N, Pool, DefaultNR, DefaultND, DefaultNDO, DefaultNExt, Mode); true -> - do_expand_cstruct(Cs2, FH, N, Pool, NR, ND, NDO, Mode) + do_expand_cstruct(Cs2, FH, N, Pool, NR, ND, NDO, NExt, Mode) end. -do_expand_cstruct(Cs, FH, N, Pool, NR, ND, NDO, Mode) -> +do_expand_cstruct(Cs, FH, N, Pool, NR, ND, NDO, NExt, Mode) -> Tab = Cs#cstruct.name, LC = Cs#cstruct.local_content, @@ -562,14 +567,15 @@ do_expand_cstruct(Cs, FH, N, Pool, NR, ND, NDO, Mode) -> %% Add empty fragments CommonProps = [{base_table, Tab}], Cs2 = Cs#cstruct{frag_properties = lists:sort(CommonProps)}, - expand_frag_cstructs(N, NR, ND, NDO, Cs2, Pool, Pool, FH, Mode). + expand_frag_cstructs(N, NR, ND, NDO, NExt, Cs2, Pool, Pool, FH, Mode). verify_n_fragments(N, Cs, Mode) when is_integer(N), N >= 1 -> case Mode of create -> Cs#cstruct{ram_copies = [], disc_copies = [], - disc_only_copies = []}; + disc_only_copies = [], + external_copies = []}; activate -> Reason = {combine_error, Cs#cstruct.name, {n_fragments, N}}, mnesia_schema:verify(1, N, Reason), @@ -607,7 +613,8 @@ pick_props(Tab, Cs, {ForeignTab, Attr}) -> DefaultNR = length(val({ForeignTab, ram_copies})), DefaultND = length(val({ForeignTab, disc_copies})), DefaultNDO = length(val({ForeignTab, disc_only_copies})), - {Key, N, Pool, DefaultNR, DefaultND, DefaultNDO}; + DefaultNExt = length(val({ForeignTab, external_copies})), + {Key, N, Pool, DefaultNR, DefaultND, DefaultNDO, DefaultNExt}; pick_props(Tab, Cs, undefined) -> Props = Cs#cstruct.frag_properties, DefaultN = 1, @@ -617,22 +624,23 @@ pick_props(Tab, Cs, undefined) -> DefaultNR = 1, DefaultND = 0, DefaultNDO = 0, - {undefined, N, Pool, DefaultNR, DefaultND, DefaultNDO}; + DefaultNExt = 0, + {undefined, N, Pool, DefaultNR, DefaultND, DefaultNDO, DefaultNExt}; pick_props(Tab, _Cs, BadKey) -> mnesia:abort({bad_type, Tab, {foreign_key, BadKey}}). -expand_frag_cstructs(N, NR, ND, NDO, CommonCs, Dist, Pool, FH, Mode) +expand_frag_cstructs(N, NR, ND, NDO, NExt, CommonCs, Dist, Pool, FH, Mode) when N > 1, Mode == create -> Frag = n_to_frag_name(CommonCs#cstruct.name, N), Cs = CommonCs#cstruct{name = Frag}, - {Cs2, RevModDist, RestDist} = set_frag_nodes(NR, ND, NDO, Cs, Dist, []), + {Cs2, RevModDist, RestDist} = set_frag_nodes(NR, ND, NDO, NExt, Cs, Dist, []), ModDist = lists:reverse(RevModDist), Dist2 = rearrange_dist(Cs, ModDist, RestDist, Pool), %% Adjusts backwards, but it doesn't matter. {FH2, _FromFrags, _AdditionalWriteFrags} = adjust_before_split(FH), - CsList = expand_frag_cstructs(N - 1, NR, ND, NDO, CommonCs, Dist2, Pool, FH2, Mode), + CsList = expand_frag_cstructs(N - 1, NR, ND, NDO, NExt, CommonCs, Dist2, Pool, FH2, Mode), [Cs2 | CsList]; -expand_frag_cstructs(1, NR, ND, NDO, CommonCs, Dist, Pool, FH, Mode) -> +expand_frag_cstructs(1, NR, ND, NDO, NExt, CommonCs, Dist, Pool, FH, Mode) -> BaseProps = CommonCs#cstruct.frag_properties ++ [{foreign_key, FH#frag_state.foreign_key}, {hash_module, FH#frag_state.hash_module}, @@ -645,25 +653,29 @@ expand_frag_cstructs(1, NR, ND, NDO, CommonCs, Dist, Pool, FH, Mode) -> activate -> [BaseCs]; create -> - {BaseCs2, _, _} = set_frag_nodes(NR, ND, NDO, BaseCs, Dist, []), + {BaseCs2, _, _} = set_frag_nodes(NR, ND, NDO, NExt, BaseCs, Dist, []), [BaseCs2] end. -set_frag_nodes(NR, ND, NDO, Cs, [Head | Tail], Acc) when NR > 0 -> +set_frag_nodes(NR, ND, NDO, NExt, Cs, [Head | Tail], Acc) when NR > 0 -> Pos = #cstruct.ram_copies, {Cs2, Head2} = set_frag_node(Cs, Pos, Head), - set_frag_nodes(NR - 1, ND, NDO, Cs2, Tail, [Head2 | Acc]); -set_frag_nodes(NR, ND, NDO, Cs, [Head | Tail], Acc) when ND > 0 -> + set_frag_nodes(NR - 1, ND, NDO, NExt, Cs2, Tail, [Head2 | Acc]); +set_frag_nodes(NR, ND, NDO, NExt, Cs, [Head | Tail], Acc) when ND > 0 -> Pos = #cstruct.disc_copies, {Cs2, Head2} = set_frag_node(Cs, Pos, Head), - set_frag_nodes(NR, ND - 1, NDO, Cs2, Tail, [Head2 | Acc]); -set_frag_nodes(NR, ND, NDO, Cs, [Head | Tail], Acc) when NDO > 0 -> + set_frag_nodes(NR, ND - 1, NDO, NExt, Cs2, Tail, [Head2 | Acc]); +set_frag_nodes(NR, ND, NDO, NExt, Cs, [Head | Tail], Acc) when NDO > 0 -> Pos = #cstruct.disc_only_copies, {Cs2, Head2} = set_frag_node(Cs, Pos, Head), - set_frag_nodes(NR, ND, NDO - 1, Cs2, Tail, [Head2 | Acc]); -set_frag_nodes(0, 0, 0, Cs, RestDist, ModDist) -> + set_frag_nodes(NR, ND, NDO - 1, NExt, Cs2, Tail, [Head2 | Acc]); +set_frag_nodes(NR, ND, NDO, NExt, Cs, [Head | Tail], Acc) when NExt > 0 -> + Pos = #cstruct.external_copies, + {Cs2, Head2} = set_frag_node(Cs, Pos, Head), + set_frag_nodes(NR, ND, NDO, NExt - 1, Cs2, Tail, [Head2 | Acc]); +set_frag_nodes(0, 0, 0, 0, Cs, RestDist, ModDist) -> {Cs, ModDist, RestDist}; -set_frag_nodes(_, _, _, Cs, [], _) -> +set_frag_nodes(_, _, _, _, Cs, [], _) -> mnesia:abort({combine_error, Cs#cstruct.name, "Too few nodes in node_pool"}). set_frag_node(Cs, Pos, Head) -> @@ -840,13 +852,15 @@ make_add_frag(Tab, SortedNs) -> NR = length(Cs#cstruct.ram_copies), ND = length(Cs#cstruct.disc_copies), NDO = length(Cs#cstruct.disc_only_copies), + NExt = length(Cs#cstruct.external_copies), NewCs = Cs#cstruct{name = NewFrag, frag_properties = [{base_table, Tab}], ram_copies = [], disc_copies = [], - disc_only_copies = []}, + disc_only_copies = [], + external_copies = []}, - {NewCs2, _, _} = set_frag_nodes(NR, ND, NDO, NewCs, SortedNs, []), + {NewCs2, _, _} = set_frag_nodes(NR, ND, NDO, NExt, NewCs, SortedNs, []), [NewOp] = mnesia_schema:make_create_table(NewCs2), SplitOps = split(Tab, FH2, FromIndecies, FragNames, []), @@ -1319,7 +1333,8 @@ count_frag([Frag | Frags], Dist) -> Dist2 = incr_nodes(val({Frag, ram_copies}), Dist), Dist3 = incr_nodes(val({Frag, disc_copies}), Dist2), Dist4 = incr_nodes(val({Frag, disc_only_copies}), Dist3), - count_frag(Frags, Dist4); + Dist5 = incr_nodes(val({Frag, external_copies}), Dist4), + count_frag(Frags, Dist5); count_frag([], Dist) -> Dist. diff --git a/lib/mnesia/src/mnesia_index.erl b/lib/mnesia/src/mnesia_index.erl index be05cfbea3..73d170d1fa 100644 --- a/lib/mnesia/src/mnesia_index.erl +++ b/lib/mnesia/src/mnesia_index.erl @@ -23,8 +23,8 @@ -module(mnesia_index). -export([read/5, - add_index/5, - delete_index/3, + add_index/6, + delete_index/4, del_object_index/5, clear_index/4, dirty_match_object/3, @@ -39,19 +39,21 @@ get_index_table/3, tab2filename/2, - tab2tmp_filename/2, init_index/2, init_indecies/3, del_transient/2, del_transient/3, - del_index_table/3]). + del_index_table/3, + + index_info/2, + ext_index_instances/1]). -import(mnesia_lib, [val/1, verbose/2]). -include("mnesia.hrl"). -record(index, {setorbag, pos_list}). -%% read an object list throuh its index table +%% read an object list through its index table %% we assume that table Tab has index on attribute number Pos read(Tid, Store, Tab, IxKey, Pos) -> @@ -64,69 +66,103 @@ read(Tid, Store, Tab, IxKey, Pos) -> ResList end. -add_index(Index, Tab, Key, Obj, Old) -> - add_index2(Index#index.pos_list, Index#index.setorbag, Tab, Key, Obj, Old). - -add_index2([{Pos, Ixt} |Tail], bag, Tab, K, Obj, OldRecs) -> - db_put(Ixt, {element(Pos, Obj), K}), - add_index2(Tail, bag, Tab, K, Obj, OldRecs); -add_index2([{Pos, Ixt} |Tail], Type, Tab, K, Obj, OldRecs0) -> +ext_index_instances(Tab) -> + #index{pos_list = PosL} = val({Tab, index_info}), + lists:foldr( + fun({_, {{ext,Alias,Mod}, Tag}}, Acc) -> + [{Alias, Mod, Tag}|Acc]; + (_, Acc) -> + Acc + end, [], PosL). + + +add_index(#index{pos_list = PosL, setorbag = SorB}, + Storage, Tab, Key, Obj, Old) -> + add_index2(PosL, SorB, Storage, Tab, Key, Obj, Old). + +add_index2([{{Pos,Type}, Ixt} |Tail], bag, Storage, Tab, K, Obj, OldRecs) -> + ValsF = index_vals_f(Storage, Tab, Pos), + Vals = ValsF(Obj), + put_index_vals(Type, Ixt, Vals, K), + add_index2(Tail, bag, Storage, Tab, K, Obj, OldRecs); +add_index2([{{Pos, Type}, Ixt} |Tail], SorB, Storage, Tab, K, Obj, OldRecs0) -> %% Remove old tuples in index if Tab is updated + ValsF = index_vals_f(Storage, Tab, Pos), NewVals = ValsF(Obj), OldRecs1 = case OldRecs0 of - undefined -> mnesia_lib:db_get(Tab, K); + undefined -> mnesia_lib:db_get(Storage, Tab, K); _ -> OldRecs0 end, - IdxVal = element(Pos, Obj), - case [Old || Old <- OldRecs1, element(Pos, Old) =/= IdxVal] of - [] when OldRecs1 =:= [] -> %% Write - db_put(Ixt, {element(Pos, Obj), K}), - add_index2(Tail, Type, Tab, K, Obj, OldRecs0); + IdxVal = ValsF(Obj), + case [Old || Old <- OldRecs1, ValsF(Old) =/= IdxVal] of + [] when OldRecs1 =:= [] -> % Write + put_index_vals(Type, Ixt, NewVals, K), + add_index2(Tail, SorB, Storage, Tab, K, Obj, OldRecs1); [] -> %% when OldRecs1 =/= [] Update without modifying index field - add_index2(Tail, Type, Tab, K, Obj, OldRecs0); + add_index2(Tail, SorB, Storage, Tab, K, Obj, OldRecs1); OldRecs -> %% Update - db_put(Ixt, {element(Pos, Obj), K}), - del_ixes(Ixt, OldRecs, Pos, K), - add_index2(Tail, Type, Tab, K, Obj, OldRecs0) + put_index_vals(Type, Ixt, NewVals, K), + [del_ixes(Type, Ixt, ValsF, OldObj, K) || OldObj <- OldRecs], + add_index2(Tail, SorB, Storage, Tab, K, Obj, OldRecs1) end; -add_index2([], _, _Tab, _K, _Obj, _) -> ok. +add_index2([], _, _, _Tab, _K, _Obj, _) -> ok. + +delete_index(Index, Storage, Tab, K) -> + delete_index2(Index#index.pos_list, Storage, Tab, K). -delete_index(Index, Tab, K) -> - delete_index2(Index#index.pos_list, Tab, K). +delete_index2([{{Pos, Type}, Ixt} | Tail], Storage, Tab, K) -> + DelObjs = mnesia_lib:db_get(Storage, Tab, K), + ValsF = index_vals_f(Storage, Tab, Pos), + [del_ixes(Type, Ixt, ValsF, Obj, K) || Obj <- DelObjs], + delete_index2(Tail, Storage, Tab, K); +delete_index2([], _Storage, _Tab, _K) -> ok. -delete_index2([{Pos, Ixt} | Tail], Tab, K) -> - DelObjs = mnesia_lib:db_get(Tab, K), - del_ixes(Ixt, DelObjs, Pos, K), - delete_index2(Tail, Tab, K); -delete_index2([], _Tab, _K) -> ok. +put_index_vals(ordered, Ixt, Vals, K) -> + [db_put(Ixt, {{V, K}}) || V <- Vals]; +put_index_vals(bag, Ixt, Vals, K) -> + [db_put(Ixt, {V, K}) || V <- Vals]. -del_ixes(_Ixt, [], _Pos, _L) -> ok; -del_ixes(Ixt, [Obj | Tail], Pos, Key) -> - db_match_erase(Ixt, {element(Pos, Obj), Key}), - del_ixes(Ixt, Tail, Pos, Key). +del_ixes(bag, Ixt, ValsF, Obj, Key) -> + Vals = ValsF(Obj), + [db_match_erase(Ixt, {V, Key}) || V <- Vals]; +del_ixes(ordered, Ixt, ValsF, Obj, Key) -> + Vals = ValsF(Obj), + [db_erase(Ixt, {V,Key}) || V <- Vals]. -del_object_index(Index, Tab, K, Obj, Old) -> - del_object_index2(Index#index.pos_list, Index#index.setorbag, Tab, K, Obj, Old). +del_object_index(#index{pos_list = PosL, setorbag = SorB}, Storage, Tab, K, Obj) -> + del_object_index2(PosL, SorB, Storage, Tab, K, Obj). -del_object_index2([], _, _Tab, _K, _Obj, _Old) -> ok; -del_object_index2([{Pos, Ixt} | Tail], SoB, Tab, K, Obj, Old) -> +del_object_index2([], _, _Storage, _Tab, _K, _Obj) -> ok; +del_object_index2([{{Pos, Type}, Ixt} | Tail], SoB, Storage, Tab, K, Obj) -> + ValsF = index_vals_f(Storage, Tab, Pos), case SoB of bag -> - del_object_bag(Tab, K, Obj, Pos, Ixt, Old); + del_object_bag(Type, ValsF, Tab, K, Obj, Ixt); _ -> %% If set remove the tuple in index table - del_ixes(Ixt, [Obj], Pos, K) + del_ixes(Type, Ixt, ValsF, Obj, K) end, - del_object_index2(Tail, SoB, Tab, K, Obj, Old). - -del_object_bag(Tab, Key, Obj, Pos, Ixt, undefined) -> - IxKey = element(Pos, Obj), - Old = [X || X <- mnesia_lib:db_get(Tab, Key), element(Pos, X) =:= IxKey], - del_object_bag(Tab, Key, Obj, Pos, Ixt, Old); -%% If Tab type is bag we need remove index identifier if the object being -%% deleted was the last one -del_object_bag(_Tab, Key, Obj, Pos, Ixt, Old) when Old =:= [Obj] -> - del_ixes(Ixt, [Obj], Pos, Key); -del_object_bag(_Tab, _Key, _Obj, _Pos, _Ixt, _Old) -> ok. + del_object_index2(Tail, SoB, Storage, Tab, K, Obj). + +del_object_bag(Type, ValsF, Tab, Key, Obj, Ixt) -> + IxKeys = ValsF(Obj), + Found = [{X, ValsF(X)} || X <- mnesia_lib:db_get(Tab, Key)], + del_object_bag_(IxKeys, Found, Type, Tab, Key, Obj, Ixt). + +del_object_bag_([IxK|IxKs], Found, Type, Tab, Key, Obj, Ixt) -> + case [X || {X, Ixes} <- Found, lists:member(IxK, Ixes)] of + [Old] when Old =:= Obj -> + case Type of + bag -> + db_match_erase(Ixt, {IxK, Key}); + ordered -> + db_erase(Ixt, {{IxK, Key}}) + end; + _ -> + ok + end, + del_object_bag_(IxKs, Found, Type, Tab, Key, Obj, Ixt); +del_object_bag_([], _, _, _, _, _, _) -> + ok. clear_index(Index, Tab, K, Obj) -> clear_index2(Index#index.pos_list, Tab, K, Obj). @@ -138,8 +174,9 @@ clear_index2([{_Pos, Ixt} | Tail], Tab, K, Obj) -> %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -dirty_match_object(Tab, Pat, Pos) -> +dirty_match_object(Tab, Pat, Pos) when is_integer(Pos) -> %% Assume that we are on the node where the replica is + %% Cannot use index plugins here, as they don't map to match patterns case element(2, Pat) of '_' -> IxKey = element(Pos, Pat), @@ -161,7 +198,7 @@ realkeys(Tab, Pos, IxKey) -> Index = get_index_table(Tab, Pos), db_get(Index, IxKey). % a list on the form [{IxKey, RealKey1} , .... -dirty_select(Tab, Spec, Pos) -> +dirty_select(Tab, Spec, Pos) when is_integer(Pos) -> %% Assume that we are on the node where the replica is %% Returns the records without applying the match spec %% The actual filtering is handled by the caller @@ -171,59 +208,80 @@ dirty_select(Tab, Spec, Pos) -> lists:append([mnesia_lib:db_get(StorageType, Tab, Key) || {_,Key} <- RealKeys]). dirty_read(Tab, IxKey, Pos) -> - ResList = mnesia:dirty_rpc(Tab, ?MODULE, dirty_read2, - [Tab, IxKey, Pos]), - case val({Tab, setorbag}) of - bag -> - %% Remove all tuples which don't include Ixkey - mnesia_lib:key_search_all(IxKey, Pos, ResList); - _ -> - ResList - end. + mnesia:dirty_rpc(Tab, ?MODULE, dirty_read2, + [Tab, IxKey, Pos]). dirty_read2(Tab, IxKey, Pos) -> - Ix = get_index_table(Tab, Pos), - Keys = db_match(Ix, {IxKey, '$1'}), - r_keys(Keys, Tab, []). - -r_keys([[H]|T],Tab,Ack) -> - V = mnesia_lib:db_get(Tab, H), - r_keys(T, Tab, V ++ Ack); -r_keys([], _, Ack) -> - Ack. + #index{pos_list = PosL} = val({Tab, index_info}), + Storage = val({Tab, storage_type}), + {Type, Ixt} = pick_index(PosL, Tab, Pos), + Pat = case Type of + ordered -> [{{{IxKey, '$1'}}, [], ['$1']}]; + bag -> [{{IxKey, '$1'}, [], ['$1']}] + end, + Keys = db_select(Ixt, Pat), + ValsF = index_vals_f(Storage, Tab, Pos), + lists:reverse( + lists:foldl( + fun(K, Acc) -> + lists:foldl( + fun(Obj, Acc1) -> + case lists:member(IxKey, ValsF(Obj)) of + true -> [Obj|Acc1]; + false -> Acc1 + end + end, Acc, mnesia_lib:db_get(Storage, Tab, K)) + end, [], Keys)). + +pick_index([{{{Pfx,_},IxType}, Ixt}|_], _Tab, {_} = Pfx) -> + {IxType, Ixt}; +pick_index([{{Pos,IxType}, Ixt}|_], _Tab, Pos) -> + {IxType, Ixt}; +pick_index([_|T], Tab, Pos) -> + pick_index(T, Tab, Pos); +pick_index([], Tab, Pos) -> + mnesia:abort({no_exist, Tab, {index, Pos}}). + %%%%%%% Creation, Init and deletion routines for index tables %% We can have several indexes on the same table %% this can be a fairly costly operation if table is *very* large -tab2filename(Tab, Pos) -> +tab2filename(Tab, {A}) when is_atom(A) -> + mnesia_lib:dir(Tab) ++ "_-" ++ atom_to_list(A) ++ "-.DAT"; +tab2filename(Tab, T) when is_tuple(T) -> + tab2filename(Tab, element(1, T)); +tab2filename(Tab, Pos) when is_integer(Pos) -> mnesia_lib:dir(Tab) ++ "_" ++ integer_to_list(Pos) ++ ".DAT". -tab2tmp_filename(Tab, Pos) -> - mnesia_lib:dir(Tab) ++ "_" ++ integer_to_list(Pos) ++ ".TMP". - init_index(Tab, Storage) -> - PosList = val({Tab, index}), + Cs = val({Tab, cstruct}), + PosList = Cs#cstruct.index, init_indecies(Tab, Storage, PosList). init_indecies(Tab, Storage, PosList) -> case Storage of unknown -> ignore; + {ext, Alias, Mod} -> + init_ext_index(Tab, Storage, Alias, Mod, PosList); disc_only_copies -> - init_disc_index(Tab, PosList); + init_disc_index(Tab, Storage, PosList); ram_copies -> - make_ram_index(Tab, PosList); + make_ram_index(Tab, Storage, PosList); disc_copies -> - make_ram_index(Tab, PosList) + make_ram_index(Tab, Storage, PosList) end. %% works for both ram and disc indexes del_index_table(_, unknown, _) -> ignore; -del_index_table(Tab, Storage, Pos) -> +del_index_table(Tab, Storage, {_} = Pos) -> + delete_transient_index(Tab, Pos, Storage), + mnesia_lib:del({Tab, index}, Pos); +del_index_table(Tab, Storage, Pos) when is_integer(Pos) -> delete_transient_index(Tab, Pos, Storage), mnesia_lib:del({Tab, index}, Pos). @@ -236,13 +294,24 @@ del_transient(Tab, [Pos | Tail], Storage) -> delete_transient_index(Tab, Pos, Storage), del_transient(Tab, Tail, Storage). +delete_transient_index(Tab, Pos, {ext, Alias, Mod}) -> + PosInfo = case Pos of + _ when is_integer(Pos) -> + Cs = val({Tab, cstruct}), + lists:keyfind(Pos, 1, Cs#cstruct.index); + {P, T} -> {P, T} + end, + Tag = {Tab, index, PosInfo}, + Mod:close_table(Alias, Tag), + Mod:delete_table(Alias, Tag), + del_index_info(Tab, Pos), + mnesia_lib:unset({Tab, {index, Pos}}); delete_transient_index(Tab, Pos, disc_only_copies) -> Tag = {Tab, index, Pos}, mnesia_monitor:unsafe_close_dets(Tag), _ = file:delete(tab2filename(Tab, Pos)), del_index_info(Tab, Pos), %% Uses val(..) mnesia_lib:unset({Tab, {index, Pos}}); - delete_transient_index(Tab, Pos, _Storage) -> Ixt = val({Tab, {index, Pos}}), ?ets_delete_table(Ixt), @@ -252,11 +321,12 @@ delete_transient_index(Tab, Pos, _Storage) -> %%%%% misc functions for the index create/init/delete functions above %% assuming that the file exists. -init_disc_index(_Tab, []) -> +init_disc_index(_Tab, _Storage, []) -> done; -init_disc_index(Tab, [Pos | Tail]) when is_integer(Pos) -> +init_disc_index(Tab, disc_only_copies, [{Pos,_Pref} | Tail]) -> + PosInfo = {Pos, bag}, Fn = tab2filename(Tab, Pos), - IxTag = {Tab, index, Pos}, + IxTag = {Tab, index, PosInfo}, _ = file:delete(Fn), Args = [{file, Fn}, {keypos, 1}, {type, bag}], mnesia_monitor:open_dets(IxTag, Args), @@ -269,16 +339,59 @@ init_disc_index(Tab, [Pos | Tail]) when is_integer(Pos) -> mnesia_lib:db_fixtable(Storage, Tab, true), ok = dets:init_table(IxTag, create_fun(Init, Tab, Pos)), mnesia_lib:db_fixtable(Storage, Tab, false), - mnesia_lib:set({Tab, {index, Pos}}, IxTag), - add_index_info(Tab, val({Tab, setorbag}), {Pos, {dets, IxTag}}), - init_disc_index(Tab, Tail). + mnesia_lib:set({Tab, {index, PosInfo}}, IxTag), + add_index_info(Tab, val({Tab, setorbag}), {PosInfo, {dets, IxTag}}), + init_disc_index(Tab, Storage, Tail). + +init_ext_index(_, _, _, _, []) -> + done; +init_ext_index(Tab, Storage, Alias, Mod, [{Pos,Type} | Tail]) -> + PosInfo = {Pos, Type}, + IxTag = {Tab, index, PosInfo}, + CS = val({Tab, cstruct}), + CsList = mnesia_schema:cs2list(CS), + _Res = mnesia_monitor:unsafe_create_external(IxTag, Alias, Mod, CsList), + Mod:load_table(Alias, IxTag, init_index, CsList), + case Mod:is_index_consistent(Alias, IxTag) of + false -> + Mod:index_is_consistent(Alias, IxTag, false), + Mod:match_delete(Alias, IxTag, '_'), + IxValsF = index_vals_f(Storage, Tab, Pos), + IxObjF = case Type of + bag -> fun(IxVal, Key) -> {IxVal, Key} end; + ordered -> fun(IxVal, Key) -> {{IxVal, Key}} end + end, + mnesia_lib:db_fixtable(Storage, Tab, true), + mnesia_lib:db_foldl( + Storage, + fun(Rec, Acc) -> + Key = element(2, Rec), + lists:foreach( + fun(V) -> + IxObj = IxObjF(V, Key), + Mod:insert(Alias, IxTag, IxObj) + end, IxValsF(Rec)), + Acc + end, ok, Tab, + [{'_', [], ['$_']}], 100), + Mod:index_is_consistent(Alias, IxTag, true); + true -> + ignore + end, + + mnesia_lib:set({Tab, {index, PosInfo}}, IxTag), + + add_index_info(Tab, val({Tab, setorbag}), {PosInfo, {Storage, IxTag}}), + init_ext_index(Tab, Storage, Alias, Mod, Tail). create_fun(Cont, Tab, Pos) -> + IxF = index_vals_f(disc_only_copies, Tab, Pos), fun(read) -> Data = case Cont of {start, KeysPerChunk} -> - mnesia_lib:db_init_chunk(disc_only_copies, Tab, KeysPerChunk); + mnesia_lib:db_init_chunk( + disc_only_copies, Tab, KeysPerChunk); '$end_of_table' -> '$end_of_table'; _Else -> @@ -288,56 +401,82 @@ create_fun(Cont, Tab, Pos) -> '$end_of_table' -> end_of_input; {Recs, Next} -> - IdxElems = [{element(Pos, Obj), element(2, Obj)} || Obj <- Recs], + IdxElems = lists:flatmap( + fun(Obj) -> + PrimK = element(2, Obj), + [{V, PrimK} || V <- IxF(Obj)] + end, Recs), {IdxElems, create_fun(Next, Tab, Pos)} end; (close) -> ok end. -make_ram_index(_, []) -> +make_ram_index(_, _, []) -> done; -make_ram_index(Tab, [Pos | Tail]) -> - add_ram_index(Tab, Pos), - make_ram_index(Tab, Tail). +make_ram_index(Tab, Storage, [Pos | Tail]) -> + add_ram_index(Tab, Storage, Pos), + make_ram_index(Tab, Storage, Tail). -add_ram_index(Tab, Pos) when is_integer(Pos) -> - verbose("Creating index for ~w ~n", [Tab]), +add_ram_index(Tab, Storage, {Pos, _Pref}) -> + Type = ordered, + verbose("Creating index for ~w ~p ~p~n", [Tab, Pos, Type]), SetOrBag = val({Tab, setorbag}), - IndexType = case SetOrBag of - set -> duplicate_bag; - ordered_set -> duplicate_bag; - bag -> bag - end, - Index = mnesia_monitor:mktab(mnesia_index, [IndexType, public]), + IxValsF = index_vals_f(Storage, Tab, Pos), + IxFun = fun(Val, Key) -> {{Val, Key}} end, + Index = mnesia_monitor:mktab(mnesia_index, [ordered_set, public]), Insert = fun(Rec, _Acc) -> - true = ?ets_insert(Index, {element(Pos, Rec), element(2, Rec)}) + PrimK = element(2, Rec), + true = ?ets_insert( + Index, [IxFun(V, PrimK) + || V <- IxValsF(Rec)]) end, mnesia_lib:db_fixtable(ram_copies, Tab, true), - true = ets:foldl(Insert, true, Tab), + true = mnesia_lib:db_foldl(Storage, Insert, true, Tab), mnesia_lib:db_fixtable(ram_copies, Tab, false), mnesia_lib:set({Tab, {index, Pos}}, Index), - add_index_info(Tab, SetOrBag, {Pos, {ram, Index}}); -add_ram_index(_Tab, snmp) -> + add_index_info(Tab, SetOrBag, {{Pos, Type}, {ram, Index}}); +add_ram_index(_Tab, _, snmp) -> ok. -add_index_info(Tab, Type, IxElem) -> +index_info(SetOrBag, PosList) -> + IxPlugins = mnesia_schema:index_plugins(), + ExpPosList = lists:map( + fun({{P,Type},Ixt} = PI) -> + case P of + {_} = IxN -> + {_, M, F} = + lists:keyfind(IxN, 1, IxPlugins), + {{{IxN,M,F}, Type}, Ixt}; + _ -> + PI + end + end, PosList), + #index{setorbag = SetOrBag, pos_list = ExpPosList}. + +add_index_info(Tab, SetOrBag, IxElem) -> Commit = val({Tab, commit_work}), case lists:keysearch(index, 1, Commit) of false -> - Index = #index{setorbag = Type, - pos_list = [IxElem]}, - %% Check later if mnesia_tm is sensative about the order + IndexInfo = index_info(SetOrBag, [IxElem]), + %% Check later if mnesia_tm is sensitive about the order + mnesia_lib:set({Tab, index_info}, IndexInfo), + mnesia_lib:set({Tab, index}, index_positions(IndexInfo)), mnesia_lib:set({Tab, commit_work}, - mnesia_lib:sort_commit([Index | Commit])); + mnesia_lib:sort_commit([IndexInfo | Commit])); {value, Old} -> %% We could check for consistency here Index = Old#index{pos_list = [IxElem | Old#index.pos_list]}, + mnesia_lib:set({Tab, index_info}, Index), + mnesia_lib:set({Tab, index}, index_positions(Index)), NewC = lists:keyreplace(index, 1, Commit, Index), mnesia_lib:set({Tab, commit_work}, mnesia_lib:sort_commit(NewC)) end. +index_positions(#index{pos_list = PL}) -> + [P || {{P,_},_} <- PL]. + del_index_info(Tab, Pos) -> Commit = val({Tab, commit_work}), case lists:keysearch(index, 1, Commit) of @@ -345,13 +484,21 @@ del_index_info(Tab, Pos) -> %% Something is wrong ignore skip; {value, Old} -> - case lists:keydelete(Pos, 1, Old#index.pos_list) of + case lists:filter(fun({P,_}) -> + element(1,P)=/=Pos + end, + Old#index.pos_list) of [] -> + IndexInfo = index_info(Old#index.setorbag,[]), + mnesia_lib:set({Tab, index_info}, IndexInfo), + mnesia_lib:set({Tab, index}, index_positions(IndexInfo)), NewC = lists:keydelete(index, 1, Commit), mnesia_lib:set({Tab, commit_work}, mnesia_lib:sort_commit(NewC)); New -> Index = Old#index{pos_list = New}, + mnesia_lib:set({Tab, index_info}, Index), + mnesia_lib:set({Tab, index}, index_positions(Index)), NewC = lists:keyreplace(index, 1, Commit, Index), mnesia_lib:set({Tab, commit_work}, mnesia_lib:sort_commit(NewC)) @@ -360,33 +507,69 @@ del_index_info(Tab, Pos) -> db_put({ram, Ixt}, V) -> true = ?ets_insert(Ixt, V); +db_put({{ext, _, _} = Ext, Ixt}, V) -> + mnesia_lib:db_put(Ext, Ixt, V); db_put({dets, Ixt}, V) -> ok = dets:insert(Ixt, V). -db_get({ram, Ixt}, K) -> - ?ets_lookup(Ixt, K); +db_get({ram, _}=Ixt, IxKey) -> + Pat = [{{{IxKey, '$1'}}, [], [{{IxKey,'$1'}}]}], + db_select(Ixt, Pat); +db_get({{ext,_,_} = _Storage, {_,_,{_,Type}}} = Ixt, IxKey) -> + Pat = case Type of + ordered -> [{{{IxKey, '$1'}}, [], [{{IxKey,'$1'}}]}]; + bag -> [{{IxKey, '_'}, [], ['$_']}] + end, + db_select(Ixt, Pat); db_get({dets, Ixt}, K) -> dets:lookup(Ixt, K). +db_erase({ram, Ixt}, K) -> + ?ets_delete(Ixt, K); +db_erase({{ext,_,_} = Ext, Ixt}, K) -> + mnesia_lib:db_erase(Ext, Ixt, K); +db_erase({dets, Ixt}, K) -> + dets:delete(Ixt, K). + db_match_erase({ram, Ixt}, Pat) -> true = ?ets_match_delete(Ixt, Pat); +db_match_erase({{ext,_,_} = Ext, Ixt}, Pat) -> + mnesia_lib:db_match_erase(Ext, Ixt, Pat); db_match_erase({dets, Ixt}, Pat) -> ok = dets:match_delete(Ixt, Pat). -db_match({ram, Ixt}, Pat) -> - ?ets_match(Ixt, Pat); -db_match({dets, Ixt}, Pat) -> - dets:match(Ixt, Pat). +db_select({ram, Ixt}, Pat) -> + ets:select(Ixt, Pat); +db_select({{ext,_,_} = Ext, Ixt}, Pat) -> + mnesia_lib:db_select(Ext, Ixt, Pat); +db_select({dets, Ixt}, Pat) -> + dets:select(Ixt, Pat). + get_index_table(Tab, Pos) -> get_index_table(Tab, val({Tab, storage_type}), Pos). -get_index_table(Tab, ram_copies, Pos) -> - {ram, val({Tab, {index, Pos}})}; -get_index_table(Tab, disc_copies, Pos) -> - {ram, val({Tab, {index, Pos}})}; -get_index_table(Tab, disc_only_copies, Pos) -> - {dets, val({Tab, {index, Pos}})}; -get_index_table(_Tab, unknown, _Pos) -> - unknown. - +get_index_table(Tab, _Storage, Pos) -> + #index{pos_list = PosL} = val({Tab, index_info}), + {_IxType, Ixt} = pick_index(PosL, Tab, Pos), + Ixt. + +index_vals_f(Storage, Tab, {_} = Pos) -> + index_vals_f(Storage, Tab, + lists:keyfind(Pos, 1, mnesia_schema:index_plugins())); +index_vals_f(_Storage, Tab, {Pos,M,F}) -> + fun(Obj) -> + M:F(Tab, Pos, Obj) + end; +index_vals_f(Storage, Tab, Pos) when is_integer(Pos) -> + case mnesia_lib:semantics(Storage, index_fun) of + undefined -> + fun(Obj) -> + [element(Pos, Obj)] + end; + F when is_function(F, 4) -> + {ext, Alias, _Mod} = Storage, + fun(Obj) -> + F(Alias, Tab, Pos, Obj) + end + end. diff --git a/lib/mnesia/src/mnesia_lib.erl b/lib/mnesia/src/mnesia_lib.erl index a5eded4f0f..10e232c800 100644 --- a/lib/mnesia/src/mnesia_lib.erl +++ b/lib/mnesia/src/mnesia_lib.erl @@ -54,6 +54,7 @@ db_erase_tab/2, db_first/1, db_first/2, + db_foldl/3, db_foldl/4, db_foldl/6, db_last/1, db_last/2, db_fixtable/3, @@ -135,6 +136,7 @@ set_local_content_whereabouts/1, set_remote_where_to_read/1, set_remote_where_to_read/2, + semantics/2, show/1, show/2, sort_commit/1, @@ -144,6 +146,7 @@ tab2tmp/1, tab2dcd/1, tab2dcl/1, + tab2logtmp/1, to_list/1, union/2, uniq/1, @@ -151,6 +154,8 @@ unset/1, %% update_counter/2, val/1, + validate_key/2, + validate_record/2, vcore/0, vcore/1, verbose/2, @@ -319,15 +324,41 @@ tab2dcd(Tab) -> %% Disc copies data tab2dcl(Tab) -> %% Disc copies log dir(lists:concat([Tab, ".DCL"])). +tab2logtmp(Tab) -> %% Disc copies log + dir(lists:concat([Tab, ".LOGTMP"])). + storage_type_at_node(Node, Tab) -> search_key(Node, [{disc_copies, val({Tab, disc_copies})}, {ram_copies, val({Tab, ram_copies})}, - {disc_only_copies, val({Tab, disc_only_copies})}]). + {disc_only_copies, val({Tab, disc_only_copies})}| + wrap_external(val({Tab, external_copies}))]). cs_to_storage_type(Node, Cs) -> search_key(Node, [{disc_copies, Cs#cstruct.disc_copies}, {ram_copies, Cs#cstruct.ram_copies}, - {disc_only_copies, Cs#cstruct.disc_only_copies}]). + {disc_only_copies, Cs#cstruct.disc_only_copies} | + wrap_external(Cs#cstruct.external_copies)]). + +-define(native(T), T==ram_copies; T==disc_copies; T==disc_only_copies). + +semantics({ext,Alias,Mod}, Item) -> + Mod:semantics(Alias, Item); +semantics({Alias,Mod}, Item) -> + Mod:semantics(Alias, Item); +semantics(Type, storage) when ?native(Type) -> + Type; +semantics(Type, types) when ?native(Type) -> + [set, ordered_set, bag]; +semantics(disc_only_copies, index_types) -> + [bag]; +semantics(Type, index_types) when ?native(Type) -> + [bag, ordered]; +semantics(_, _) -> + undefined. + + +wrap_external(L) -> + [{{ext,Alias,Mod},Ns} || {{Alias,Mod},Ns} <- L]. schema_cs_to_storage_type(Node, Cs) -> case cs_to_storage_type(Node, Cs) of @@ -335,7 +366,6 @@ schema_cs_to_storage_type(Node, Cs) -> Other -> Other end. - search_key(Key, [{Val, List} | Tail]) -> case lists:member(Key, List) of true -> Val; @@ -344,6 +374,33 @@ search_key(Key, [{Val, List} | Tail]) -> search_key(_Key, []) -> unknown. +validate_key(Tab, Key) -> + case ?catch_val({Tab, record_validation}) of + {RecName, Arity, Type} -> + {RecName, Arity, Type}; + {RecName, Arity, Type, Alias, Mod} -> + %% external type + Mod:validate_key(Alias, Tab, RecName, Arity, Type, Key); + {'EXIT', _} -> + mnesia:abort({no_exists, Tab}) + end. + + +validate_record(Tab, Obj) -> + case ?catch_val({Tab, record_validation}) of + {RecName, Arity, Type} + when tuple_size(Obj) == Arity, RecName == element(1, Obj) -> + {RecName, Arity, Type}; + {RecName, Arity, Type, Alias, Mod} + when tuple_size(Obj) == Arity, RecName == element(1, Obj) -> + %% external type + Mod:validate_record(Alias, Tab, RecName, Arity, Type, Obj); + {'EXIT', _} -> + mnesia:abort({no_exists, Tab}); + _ -> + mnesia:abort({bad_type, Obj}) + end. + %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %% ops, we've got some global variables here :-) @@ -410,9 +467,9 @@ pr_other(Var) -> no -> {node_not_running, node()}; _ -> {no_exists, Var} end, - verbose("~p (~p) val(mnesia_gvar, ~w) -> ~p ~n", + verbose("~p (~p) val(mnesia_gvar, ~w) -> ~p ~p ~n", [self(), process_info(self(), registered_name), - Var, Why]), + Var, Why, erlang:get_stacktrace()]), mnesia:abort(Why). %% Some functions for list valued variables @@ -549,10 +606,16 @@ read_counter(Name) -> ?ets_lookup_element(mnesia_stats, Name, 2). cs_to_nodes(Cs) -> + ext_nodes(Cs#cstruct.external_copies) ++ Cs#cstruct.disc_only_copies ++ Cs#cstruct.disc_copies ++ Cs#cstruct.ram_copies. +ext_nodes(Ext) -> + lists:flatmap(fun({_, Ns}) -> + Ns + end, Ext). + overload_types() -> [mnesia_tm, mnesia_dump_log]. @@ -748,7 +811,7 @@ view(File) -> true -> view(File, dat); false -> - case suffix([".LOG", ".BUP", ".ETS"], File) of + case suffix([".LOG", ".BUP", ".ETS", ".LOGTMP"], File) of true -> view(File, log); false -> @@ -1044,18 +1107,24 @@ db_get(Tab, Key) -> db_get(val({Tab, storage_type}), Tab, Key). db_get(ram_copies, Tab, Key) -> ?ets_lookup(Tab, Key); db_get(disc_copies, Tab, Key) -> ?ets_lookup(Tab, Key); -db_get(disc_only_copies, Tab, Key) -> dets:lookup(Tab, Key). +db_get(disc_only_copies, Tab, Key) -> dets:lookup(Tab, Key); +db_get({ext, Alias, Mod}, Tab, Key) -> + Mod:lookup(Alias, Tab, Key). db_init_chunk(Tab) -> db_init_chunk(val({Tab, storage_type}), Tab, 1000). db_init_chunk(Tab, N) -> db_init_chunk(val({Tab, storage_type}), Tab, N). +db_init_chunk({ext, Alias, Mod}, Tab, N) -> + Mod:select(Alias, Tab, [{'_', [], ['$_']}], N); db_init_chunk(disc_only_copies, Tab, N) -> dets:select(Tab, [{'_', [], ['$_']}], N); db_init_chunk(_, Tab, N) -> ets:select(Tab, [{'_', [], ['$_']}], N). +db_chunk({ext, _Alias, Mod}, State) -> + Mod:select(State); db_chunk(disc_only_copies, State) -> dets:select(State); db_chunk(_, State) -> @@ -1066,7 +1135,9 @@ db_put(Tab, Val) -> db_put(ram_copies, Tab, Val) -> ?ets_insert(Tab, Val), ok; db_put(disc_copies, Tab, Val) -> ?ets_insert(Tab, Val), ok; -db_put(disc_only_copies, Tab, Val) -> dets:insert(Tab, Val). +db_put(disc_only_copies, Tab, Val) -> dets:insert(Tab, Val); +db_put({ext, Alias, Mod}, Tab, Val) -> + Mod:insert(Alias, Tab, Val). db_match_object(Tab, Pat) -> db_match_object(val({Tab, storage_type}), Tab, Pat). @@ -1075,12 +1146,36 @@ db_match_object(Storage, Tab, Pat) -> try case Storage of disc_only_copies -> dets:match_object(Tab, Pat); + {ext, Alias, Mod} -> Mod:select(Alias, Tab, [{Pat, [], ['$_']}]); _ -> ets:match_object(Tab, Pat) end after db_fixtable(Storage, Tab, false) end. +db_foldl(Fun, Acc, Tab) -> + db_foldl(val({Tab, storage_type}), Fun, Acc, Tab). + +db_foldl(Storage, Fun, Acc, Tab) -> + Limit = mnesia_monitor:get_env(fold_chunk_size), + db_foldl(Storage, Fun, Acc, Tab, [{'_', [], ['$_']}], Limit). + +db_foldl(ram_copies, Fun, Acc, Tab, Pat, Limit) -> + mnesia_lib:db_fixtable(ram_copies, Tab, true), + try select_foldl(db_select_init(ram_copies, Tab, Pat, Limit), + Fun, Acc, ram_copies) + after + mnesia_lib:db_fixtable(ram_copies, Tab, false) + end; +db_foldl(Storage, Fun, Acc, Tab, Pat, Limit) -> + select_foldl(mnesia_lib:db_select_init(Storage, Tab, Pat, Limit), Fun, Acc, Storage). + +select_foldl({Objs, Cont}, Fun, Acc, Storage) -> + select_foldl(mnesia_lib:db_select_cont(Storage, Cont, []), + Fun, lists:foldl(Fun, Acc, Objs), Storage); +select_foldl('$end_of_table', _, Acc, _) -> + Acc. + db_select(Tab, Pat) -> db_select(val({Tab, storage_type}), Tab, Pat). @@ -1089,17 +1184,33 @@ db_select(Storage, Tab, Pat) -> try case Storage of disc_only_copies -> dets:select(Tab, Pat); + {ext, Alias, Mod} -> Mod:select(Alias, Tab, Pat); _ -> ets:select(Tab, Pat) end after db_fixtable(Storage, Tab, false) end. +db_select_init({ext, Alias, Mod}, Tab, Pat, Limit) -> + case Mod:select(Alias, Tab, Pat, Limit) of + {Matches, Continuation} when is_list(Matches) -> + {Matches, {Alias, Continuation}}; + R -> + R + end; db_select_init(disc_only_copies, Tab, Pat, Limit) -> dets:select(Tab, Pat, Limit); db_select_init(_, Tab, Pat, Limit) -> ets:select(Tab, Pat, Limit). +db_select_cont({ext, Alias, Mod}, Cont0, Ms) -> + Cont = Mod:repair_continuation(Cont0, Ms), + case Mod:select(Cont) of + {Matches, Continuation} when is_list(Matches) -> + {Matches, {Alias, Continuation}}; + R -> + R + end; db_select_cont(disc_only_copies, Cont0, Ms) -> Cont = dets:repair_continuation(Cont0, Ms), dets:select(Cont); @@ -1116,13 +1227,18 @@ db_fixtable(disc_copies, Tab, Bool) -> db_fixtable(dets, Tab, Bool) -> dets:safe_fixtable(Tab, Bool); db_fixtable(disc_only_copies, Tab, Bool) -> - dets:safe_fixtable(Tab, Bool). + dets:safe_fixtable(Tab, Bool); +db_fixtable({ext, Alias, Mod}, Tab, Bool) -> + Mod:fixtable(Alias, Tab, Bool). db_erase(Tab, Key) -> db_erase(val({Tab, storage_type}), Tab, Key). db_erase(ram_copies, Tab, Key) -> ?ets_delete(Tab, Key), ok; db_erase(disc_copies, Tab, Key) -> ?ets_delete(Tab, Key), ok; -db_erase(disc_only_copies, Tab, Key) -> dets:delete(Tab, Key). +db_erase(disc_only_copies, Tab, Key) -> dets:delete(Tab, Key); +db_erase({ext, Alias, Mod}, Tab, Key) -> + Mod:delete(Alias, Tab, Key), + ok. db_match_erase(Tab, '_') -> db_delete_all(val({Tab, storage_type}),Tab); @@ -1130,7 +1246,10 @@ db_match_erase(Tab, Pat) -> db_match_erase(val({Tab, storage_type}), Tab, Pat). db_match_erase(ram_copies, Tab, Pat) -> ?ets_match_delete(Tab, Pat), ok; db_match_erase(disc_copies, Tab, Pat) -> ?ets_match_delete(Tab, Pat), ok; -db_match_erase(disc_only_copies, Tab, Pat) -> dets:match_delete(Tab, Pat). +db_match_erase(disc_only_copies, Tab, Pat) -> dets:match_delete(Tab, Pat); +db_match_erase({ext, Alias, Mod}, Tab, Pat) -> + Mod:match_delete(Alias, Tab, Pat), + ok. db_delete_all(ram_copies, Tab) -> ets:delete_all_objects(Tab); db_delete_all(disc_copies, Tab) -> ets:delete_all_objects(Tab); @@ -1140,31 +1259,41 @@ db_first(Tab) -> db_first(val({Tab, storage_type}), Tab). db_first(ram_copies, Tab) -> ?ets_first(Tab); db_first(disc_copies, Tab) -> ?ets_first(Tab); -db_first(disc_only_copies, Tab) -> dets:first(Tab). +db_first(disc_only_copies, Tab) -> dets:first(Tab); +db_first({ext, Alias, Mod}, Tab) -> + Mod:first(Alias, Tab). db_next_key(Tab, Key) -> db_next_key(val({Tab, storage_type}), Tab, Key). db_next_key(ram_copies, Tab, Key) -> ?ets_next(Tab, Key); db_next_key(disc_copies, Tab, Key) -> ?ets_next(Tab, Key); -db_next_key(disc_only_copies, Tab, Key) -> dets:next(Tab, Key). +db_next_key(disc_only_copies, Tab, Key) -> dets:next(Tab, Key); +db_next_key({ext, Alias, Mod}, Tab, Key) -> + Mod:next(Alias, Tab, Key). db_last(Tab) -> db_last(val({Tab, storage_type}), Tab). db_last(ram_copies, Tab) -> ?ets_last(Tab); db_last(disc_copies, Tab) -> ?ets_last(Tab); -db_last(disc_only_copies, Tab) -> dets:first(Tab). %% Dets don't have order +db_last(disc_only_copies, Tab) -> dets:first(Tab); %% Dets don't have order +db_last({ext, Alias, Mod}, Tab) -> + Mod:last(Alias, Tab). db_prev_key(Tab, Key) -> db_prev_key(val({Tab, storage_type}), Tab, Key). db_prev_key(ram_copies, Tab, Key) -> ?ets_prev(Tab, Key); db_prev_key(disc_copies, Tab, Key) -> ?ets_prev(Tab, Key); -db_prev_key(disc_only_copies, Tab, Key) -> dets:next(Tab, Key). %% Dets don't have order +db_prev_key(disc_only_copies, Tab, Key) -> dets:next(Tab, Key); %% Dets don't have order +db_prev_key({ext, Alias, Mod}, Tab, Key) -> + Mod:prev(Alias, Tab, Key). db_slot(Tab, Pos) -> db_slot(val({Tab, storage_type}), Tab, Pos). db_slot(ram_copies, Tab, Pos) -> ?ets_slot(Tab, Pos); db_slot(disc_copies, Tab, Pos) -> ?ets_slot(Tab, Pos); -db_slot(disc_only_copies, Tab, Pos) -> dets:slot(Tab, Pos). +db_slot(disc_only_copies, Tab, Pos) -> dets:slot(Tab, Pos); +db_slot({ext, Alias, Mod}, Tab, Pos) -> + Mod:slot(Alias, Tab, Pos). db_update_counter(Tab, C, Val) -> db_update_counter(val({Tab, storage_type}), Tab, C, Val). @@ -1173,13 +1302,16 @@ db_update_counter(ram_copies, Tab, C, Val) -> db_update_counter(disc_copies, Tab, C, Val) -> ?ets_update_counter(Tab, C, Val); db_update_counter(disc_only_copies, Tab, C, Val) -> - dets:update_counter(Tab, C, Val). + dets:update_counter(Tab, C, Val); +db_update_counter({ext, Alias, Mod}, Tab, C, Val) -> + Mod:update_counter(Alias, Tab, C, Val). db_erase_tab(Tab) -> db_erase_tab(val({Tab, storage_type}), Tab). db_erase_tab(ram_copies, Tab) -> ?ets_delete_table(Tab); db_erase_tab(disc_copies, Tab) -> ?ets_delete_table(Tab); -db_erase_tab(disc_only_copies, _Tab) -> ignore. +db_erase_tab(disc_only_copies, _Tab) -> ignore; +db_erase_tab({ext, _Alias, _Mod}, _Tab) -> ignore. %% assuming that Tab is a valid ets-table dets_to_ets(Tabname, Tab, File, Type, Rep, Lock) -> diff --git a/lib/mnesia/src/mnesia_loader.erl b/lib/mnesia/src/mnesia_loader.erl index bde5585139..71e5829c87 100644 --- a/lib/mnesia/src/mnesia_loader.erl +++ b/lib/mnesia/src/mnesia_loader.erl @@ -147,6 +147,19 @@ do_get_disc_copy2(Tab, Reason, Storage, Type) when Storage == disc_only_copies - {error, Error} -> {not_loaded, {"Failed to create dets table", Error}} end + end; + +do_get_disc_copy2(Tab, Reason, Storage = {ext, Alias, Mod}, _Type) -> + Cs = val({Tab, cstruct}), + case mnesia_monitor:unsafe_create_external(Tab, Alias, Mod, Cs) of + ok -> + ok = ext_load_table(Mod, Alias, Tab, Reason), + mnesia_index:init_index(Tab, Storage), + set({Tab, load_node}, node()), + set({Tab, load_reason}, Reason), + {loaded, ok}; + Other -> + {not_loaded, Other} end. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% @@ -259,7 +272,7 @@ init_receiver(Node, Tab,Storage,Cs,Reason) -> true = lists:member(Node, Active), {SenderPid, TabSize, DetsData} = start_remote_sender(Node,Tab,Storage), - Init = table_init_fun(SenderPid), + Init = table_init_fun(SenderPid, Storage), Args = [self(),Tab,Storage,Cs,SenderPid, TabSize,DetsData,Init], Pid = spawn_link(?MODULE, spawned_receiver, Args), @@ -289,7 +302,12 @@ start_remote_sender(Node,Tab,Storage) -> mnesia_controller:start_remote_sender(Node, Tab, self(), Storage), put(mnesia_table_sender_node, {Tab, Node}), receive - {SenderPid, {first, TabSize}} -> + {SenderPid, {first, _} = Msg} + when is_pid(SenderPid), element(1, Storage) == ext -> + {ext, Alias, Mod} = Storage, + {Sz, Data} = Mod:receiver_first_message(SenderPid, Msg, Alias, Tab), + {SenderPid, Sz, Data}; + {SenderPid, {first, TabSize}} =_M1 -> {SenderPid, TabSize, false}; {SenderPid, {first, TabSize, DetsData}} -> {SenderPid, TabSize, DetsData}; @@ -299,16 +317,18 @@ start_remote_sender(Node,Tab,Storage) -> down(Tab, Storage) end. -table_init_fun(SenderPid) -> +table_init_fun(SenderPid, Storage) -> fun(read) -> Receiver = self(), SenderPid ! {Receiver, more}, - get_data(SenderPid, Receiver) + get_data(SenderPid, Receiver, Storage); + (close) -> + ok end. %% Add_table_copy get's it's own locks. start_receiver(Tab,Storage,Cs,SenderPid,TabSize,DetsData,{dumper,{add_table_copy,_}}) -> - Init = table_init_fun(SenderPid), + Init = table_init_fun(SenderPid, Storage), case do_init_table(Tab,Storage,Cs,SenderPid,TabSize,DetsData,self(), Init) of Err = {error, _} -> SenderPid ! {copier_done, node()}, @@ -391,7 +411,15 @@ create_table(Tab, TabSize, Storage, Cs) -> {Storage, Tab}; Else -> Else - end + end; + element(1, Storage) == ext -> + {_, Alias, Mod} = Storage, + case mnesia_monitor:unsafe_create_external(Tab, Alias, Mod, Cs) of + ok -> + {Storage, Tab}; + Else -> + Else + end end. tab_receiver(Node, Tab, Storage, Cs, OrigTabRec) -> @@ -409,21 +437,25 @@ tab_receiver(Node, Tab, Storage, Cs, OrigTabRec) -> tab_receiver(Node, Tab, Storage, Cs, OrigTabRec) end. -make_table_fun(Pid, TabRec) -> +make_table_fun(Pid, TabRec, Storage) -> fun(close) -> ok; + ({read, Msg}) -> + Pid ! {TabRec, Msg}, + get_data(Pid, TabRec, Storage); (read) -> - get_data(Pid, TabRec) + get_data(Pid, TabRec, Storage) end. -get_data(Pid, TabRec) -> +get_data(Pid, TabRec, Storage) -> receive {Pid, {more_z, CompressedRecs}} when is_binary(CompressedRecs) -> - Pid ! {TabRec, more}, - {zlib_uncompress(CompressedRecs), make_table_fun(Pid,TabRec)}; + maybe_reply(Pid, {TabRec, more}, Storage), + {zlib_uncompress(CompressedRecs), + make_table_fun(Pid, TabRec, Storage)}; {Pid, {more, Recs}} -> - Pid ! {TabRec, more}, - {Recs, make_table_fun(Pid,TabRec)}; + maybe_reply(Pid, {TabRec, more}, Storage), + {Recs, make_table_fun(Pid, TabRec, Storage)}; {Pid, no_more} -> end_of_input; {copier_done, Node} -> @@ -431,13 +463,48 @@ get_data(Pid, TabRec) -> Node -> {copier_done, Node}; _ -> - get_data(Pid, TabRec) + get_data(Pid, TabRec, Storage) end; {'EXIT', Pid, Reason} -> handle_exit(Pid, Reason), - get_data(Pid, TabRec) + get_data(Pid, TabRec, Storage) end. +maybe_reply(_, _, {ext, _, _}) -> + ignore; +maybe_reply(Pid, Msg, _) -> + Pid ! Msg. + +ext_init_table(Alias, Mod, Tab, Fun, State, Sender) -> + ok = ext_load_table(Mod, Alias, Tab, {net_load, node(Sender)}), + ext_init_table(read, Alias, Mod, Tab, Fun, State, Sender). + +ext_load_table(Mod, Alias, Tab, Reason) -> + CS = val({Tab, cstruct}), + Mod:load_table(Alias, Tab, Reason, mnesia_schema:cs2list(CS)). + + +ext_init_table(Action, Alias, Mod, Tab, Fun, State, Sender) -> + case Fun(Action) of + {copier_done, Node} -> + verbose("Receiver of table ~p crashed on ~p (more)~n", [Tab, Node]), + down(Tab, {ext,Alias,Mod}); + {Data, NewFun} -> + case Mod:receive_data(Data, Alias, Tab, Sender, State) of + {more, NewState} -> + ext_init_table({read, more}, Alias, Mod, + Tab, NewFun, NewState, Sender); + {{more,Msg}, NewState} -> + ext_init_table({read, Msg}, Alias, Mod, + Tab, NewFun, NewState, Sender) + end; + end_of_input -> + Mod:receive_done(Alias, Tab, Sender, State), + ok = Fun(close) + end. + +init_table(Tab, {ext,Alias,Mod}, Fun, State, Sender) -> + ext_init_table(Alias, Mod, Tab, Fun, State, Sender); init_table(Tab, disc_only_copies, Fun, DetsInfo,Sender) -> ErtsVer = erlang:system_info(version), case DetsInfo of @@ -567,7 +634,10 @@ handle_last({ram_copies, Tab}, _Type, DatBin) -> ok; false -> ok - end. + end; + +handle_last(_Storage, _Type, nobin) -> + ok. down(Tab, Storage) -> case Storage of @@ -578,7 +648,10 @@ down(Tab, Storage) -> disc_only_copies -> TmpFile = mnesia_lib:tab2tmp(Tab), mnesia_lib:dets_sync_close(Tab), - file:delete(TmpFile) + file:delete(TmpFile); + {ext, Alias, Mod} -> + catch Mod:close_table(Alias, Tab), + catch Mod:delete_table(Alias, Tab) end, mnesia_checkpoint:tm_del_copy(Tab, node()), mnesia_controller:sync_del_table_copy_whereabouts(Tab, node()), @@ -603,21 +676,35 @@ db_erase({ram_copies, Tab}, Key) -> db_erase({disc_copies, Tab}, Key) -> true = ?ets_delete(Tab, Key); db_erase({disc_only_copies, Tab}, Key) -> - ok = dets:delete(Tab, Key). + ok = dets:delete(Tab, Key); +db_erase({{ext, Alias, Mod}, Tab}, Key) -> + ok = Mod:delete(Alias, Tab, Key). db_match_erase({ram_copies, Tab} , Pat) -> true = ?ets_match_delete(Tab, Pat); db_match_erase({disc_copies, Tab} , Pat) -> true = ?ets_match_delete(Tab, Pat); db_match_erase({disc_only_copies, Tab}, Pat) -> - ok = dets:match_delete(Tab, Pat). + ok = dets:match_delete(Tab, Pat); +db_match_erase({{ext, Alias, Mod}, Tab}, Pat) -> + % "ets style" is to return true + % "dets style" is to return N | { error, Reason } + % or sometimes ok (?) + % be nice and accept both + case Mod:match_delete(Alias, Tab, Pat) of + N when is_integer (N) -> ok; + true -> ok; + ok -> ok + end. db_put({ram_copies, Tab}, Val) -> true = ?ets_insert(Tab, Val); db_put({disc_copies, Tab}, Val) -> true = ?ets_insert(Tab, Val); db_put({disc_only_copies, Tab}, Val) -> - ok = dets:insert(Tab, Val). + ok = dets:insert(Tab, Val); +db_put({{ext, Alias, Mod}, Tab}, Val) -> + ok = Mod:insert(Alias, Tab, Val). %% This code executes at the remote site where the data is %% executes in a special copier process. @@ -636,47 +723,62 @@ send_table(Pid, Tab, RemoteS) -> unknown -> {error, {no_exists, Tab}}; Storage -> - %% Send first - TabSize = mnesia:table_info(Tab, size), - KeysPerTransfer = calc_nokeys(Storage, Tab), - ChunkData = dets:info(Tab, bchunk_format), - - UseDetsChunk = - Storage == RemoteS andalso - Storage == disc_only_copies andalso - ChunkData /= undefined, - if - UseDetsChunk == true -> - DetsInfo = erlang:system_info(version), - Pid ! {self(), {first, TabSize, {DetsInfo, ChunkData}}}; - true -> - Pid ! {self(), {first, TabSize}} - end, + do_send_table(Pid, Tab, Storage, RemoteS) + end. - %% Debug info - put(mnesia_table_sender, {Tab, node(Pid), Pid}), - {Init, Chunk} = reader_funcs(UseDetsChunk, Tab, Storage, KeysPerTransfer), - - SendIt = fun() -> - NeedLock = need_lock(Tab), - {atomic, ok} = prepare_copy(Pid, Tab, Storage, NeedLock), - send_more(Pid, 1, Chunk, Init(), Tab), - finish_copy(Pid, Tab, Storage, RemoteS, NeedLock) - end, - - try SendIt() of - {_, receiver_died} -> ok; - {atomic, no_more} -> ok - catch - throw:receiver_died -> - cleanup_tab_copier(Pid, Storage, Tab), - ok; - error:Reason -> %% Prepare failed - cleanup_tab_copier(Pid, Storage, Tab), - {error, {tab_copier, Tab, {Reason, erlang:get_stacktrace()}}} - after - unlink(whereis(mnesia_tm)) - end +do_send_table(Pid, Tab, Storage, RemoteS) -> + {Init, Chunk} = + case Storage of + {ext, Alias, Mod} -> + case Mod:sender_init(Alias, Tab, RemoteS, Pid) of + {standard, I, C} -> + Pid ! {self(), {first, Mod:info(Alias, Tab, size)}}, + {I, C}; + {_, _} = Res -> + Res + end; + Storage -> + %% Send first + TabSize = mnesia:table_info(Tab, size), + KeysPerTransfer = calc_nokeys(Storage, Tab), + ChunkData = dets:info(Tab, bchunk_format), + + UseDetsChunk = + Storage == RemoteS andalso + Storage == disc_only_copies andalso + ChunkData /= undefined, + if + UseDetsChunk == true -> + DetsInfo = erlang:system_info(version), + Pid ! {self(), {first, TabSize, {DetsInfo, ChunkData}}}; + true -> + Pid ! {self(), {first, TabSize}} + end, + {_I, _C} = + reader_funcs(UseDetsChunk, Tab, Storage, KeysPerTransfer) + end, + %% Debug info + put(mnesia_table_sender, {Tab, node(Pid), Pid}), + + SendIt = fun() -> + NeedLock = need_lock(Tab), + {atomic, ok} = prepare_copy(Pid, Tab, Storage, NeedLock), + send_more(Pid, 1, Chunk, Init(), Tab, Storage), + finish_copy(Pid, Tab, Storage, RemoteS, NeedLock) + end, + + try SendIt() of + {_, receiver_died} -> ok; + {atomic, no_more} -> ok + catch + throw:receiver_died -> + cleanup_tab_copier(Pid, Storage, Tab), + ok; + error:Reason -> %% Prepare failed + cleanup_tab_copier(Pid, Storage, Tab), + {error, {tab_copier, Tab, {Reason, erlang:get_stacktrace()}}} + after + unlink(whereis(mnesia_tm)) end. prepare_copy(Pid, Tab, Storage, NeedLock) -> @@ -726,20 +828,32 @@ update_where_to_write([H|T], Tab, AddNode) -> [{update_where_to_write, [add, Tab, AddNode], self()}]), update_where_to_write(T, Tab, AddNode). -send_more(Pid, N, Chunk, DataState, Tab) -> +send_more(Pid, N, Chunk, DataState, Tab, Storage) -> receive {NewPid, more} -> case send_packet(N - 1, NewPid, Chunk, DataState) of New when is_integer(New) -> New - 1; NewData -> - send_more(NewPid, ?MAX_NOPACKETS, Chunk, NewData, Tab) + send_more(NewPid, ?MAX_NOPACKETS, Chunk, NewData, + Tab, Storage) + end; + {NewPid, {more, Msg}} when element(1, Storage) == ext -> + {ext, Alias, Mod} = Storage, + {NewChunk, NewState} = + Mod:sender_handle_info(Msg, Alias, Tab, NewPid, DataState), + case send_packet(N - 1, NewPid, NewChunk, NewState) of + New when is_integer(New) -> + New -1; + NewData -> + send_more(NewPid, N, NewChunk, NewData, Tab, + Storage) end; {_NewPid, {old_protocol, Tab}} -> Storage = val({Tab, storage_type}), {Init, NewChunk} = reader_funcs(false, Tab, Storage, calc_nokeys(Storage, Tab)), - send_more(Pid, 1, NewChunk, Init(), Tab); + send_more(Pid, 1, NewChunk, Init(), Tab, Storage); {copier_done, Node} when Node == node(Pid)-> verbose("Receiver of table ~p crashed on ~p (more)~n", [Tab, Node]), diff --git a/lib/mnesia/src/mnesia_log.erl b/lib/mnesia/src/mnesia_log.erl index 36135418c8..9536effd42 100644 --- a/lib/mnesia/src/mnesia_log.erl +++ b/lib/mnesia/src/mnesia_log.erl @@ -224,17 +224,12 @@ sappend(Log, Term) -> ok = disk_log:log(Log, Term). %% Write commit records to the latest_log -log(C) when C#commit.disc_copies == [], - C#commit.disc_only_copies == [], - C#commit.schema_ops == [] -> - ignore; log(C) -> - case mnesia_monitor:use_dir() of + case need_log(C) andalso mnesia_monitor:use_dir() of true -> if is_record(C, commit) -> - C2 = C#commit{ram_copies = [], snmp = []}, - append(latest_log, C2); + append(latest_log, strip_snmp(C)); true -> %% Either a commit record as binary %% or some decision related info @@ -247,17 +242,12 @@ log(C) -> %% Synced -slog(C) when C#commit.disc_copies == [], - C#commit.disc_only_copies == [], - C#commit.schema_ops == [] -> - ignore; slog(C) -> - case mnesia_monitor:use_dir() of + case need_log(C) andalso mnesia_monitor:use_dir() of true -> if is_record(C, commit) -> - C2 = C#commit{ram_copies = [], snmp = []}, - sappend(latest_log, C2); + sappend(latest_log, strip_snmp(C)); true -> %% Either a commit record as binary %% or some decision related info @@ -268,6 +258,13 @@ slog(C) -> ignore end. +need_log(#commit{disc_copies=[], disc_only_copies=[], schema_ops=[], ext=Ext}) -> + lists:keymember(ext_copies, 1, Ext); +need_log(_) -> true. + +strip_snmp(#commit{ext=[]}=CR) -> CR; +strip_snmp(#commit{ext=Ext}=CR) -> + CR#commit{ext=lists:keydelete(snmp, 1, Ext)}. %% Stuff related to the file LOG diff --git a/lib/mnesia/src/mnesia_monitor.erl b/lib/mnesia/src/mnesia_monitor.erl index 4069341700..ab78c9b13e 100644 --- a/lib/mnesia/src/mnesia_monitor.erl +++ b/lib/mnesia/src/mnesia_monitor.erl @@ -32,6 +32,7 @@ init/0, mktab/2, unsafe_mktab/2, + unsafe_create_external/4, mnesia_down/2, needs_protocol_conversion/1, negotiate_protocol/1, @@ -82,9 +83,9 @@ going_down = [], tm_started = false, early_connects = [], connecting, mq = [], remote_node_status = []}). --define(current_protocol_version, {8,2}). +-define(current_protocol_version, {8,3}). --define(previous_protocol_version, {8,1}). +-define(previous_protocol_version, {8,2}). start() -> gen_server:start_link({local, ?MODULE}, ?MODULE, @@ -129,6 +130,8 @@ close_log(Name) -> unsafe_close_log(Name) -> unsafe_call({unsafe_close_log, Name}). +unsafe_create_external(Tab, Alias, Mod, Cs) -> + unsafe_call({unsafe_create_external, Tab, Alias, Mod, Cs}). disconnect(Node) -> cast({disconnect, Node}). @@ -193,7 +196,7 @@ protocol_version() -> %% A sorted list of acceptable protocols the %% preferred protocols are first in the list acceptable_protocol_versions() -> - [protocol_version(), ?previous_protocol_version]. + [protocol_version(), ?previous_protocol_version, {8,1}]. needs_protocol_conversion(Node) -> case {?catch_val({protocol, Node}), protocol_version()} of @@ -405,6 +408,14 @@ handle_call({unsafe_close_log, Name}, _From, State) -> _ = disk_log:close(Name), {reply, ok, State}; +handle_call({unsafe_create_external, Tab, Alias, Mod, Cs}, _From, State) -> + case catch Mod:create_table(Alias, Tab, mnesia_schema:cs2list(Cs)) of + {'EXIT', ExitReason} -> + {reply, {error, ExitReason}, State}; + Reply -> + {reply, Reply, State} + end; + handle_call({negotiate_protocol, Mon, _Version, _Protocols}, _From, State) when State#state.tm_started == false -> State2 = State#state{early_connects = [node(Mon) | State#state.early_connects]}, @@ -658,6 +669,7 @@ get_env(E) -> env() -> [ access_module, + allow_index_on_key, auto_repair, backup_module, debug, @@ -671,19 +683,23 @@ env() -> extra_db_nodes, ignore_fallback_at_startup, fallback_error_function, + fold_chunk_size, max_wait_for_decision, schema_location, core_dir, pid_sort_order, no_table_loaders, dc_dump_limit, - send_compressed + send_compressed, + schema ]. default_env(access_module) -> mnesia; default_env(auto_repair) -> true; +default_env(allow_index_on_key) -> + false; default_env(backup_module) -> mnesia_backup; default_env(debug) -> @@ -709,6 +725,8 @@ default_env(ignore_fallback_at_startup) -> false; default_env(fallback_error_function) -> {mnesia, lkill}; +default_env(fold_chunk_size) -> + 100; default_env(max_wait_for_decision) -> infinity; default_env(schema_location) -> @@ -722,7 +740,9 @@ default_env(no_table_loaders) -> default_env(dc_dump_limit) -> 4; default_env(send_compressed) -> - 0. + 0; +default_env(schema) -> + []. check_type(Env, Val) -> try do_check_type(Env, Val) @@ -730,6 +750,7 @@ check_type(Env, Val) -> end. do_check_type(access_module, A) when is_atom(A) -> A; +do_check_type(allow_index_on_key, B) -> bool(B); do_check_type(auto_repair, B) -> bool(B); do_check_type(backup_module, B) when is_atom(B) -> B; do_check_type(debug, debug) -> debug; @@ -753,6 +774,8 @@ do_check_type(extra_db_nodes, L) when is_list(L) -> (A) when is_atom(A) -> true end, lists:filter(Fun, L); +do_check_type(fold_chunk_size, I) when is_integer(I), I > 0; + I =:= infinity -> I; do_check_type(max_wait_for_decision, infinity) -> infinity; do_check_type(max_wait_for_decision, I) when is_integer(I), I > 0 -> I; do_check_type(schema_location, M) -> media(M); @@ -766,7 +789,8 @@ do_check_type(pid_sort_order, "standard") -> standard; do_check_type(pid_sort_order, _) -> false; do_check_type(no_table_loaders, N) when is_integer(N), N > 0 -> N; do_check_type(dc_dump_limit,N) when is_number(N), N > 0 -> N; -do_check_type(send_compressed, L) when is_integer(L), L >= 0, L =< 9 -> L. +do_check_type(send_compressed, L) when is_integer(L), L >= 0, L =< 9 -> L; +do_check_type(schema, L) when is_list(L) -> L. bool(true) -> true; bool(false) -> false. diff --git a/lib/mnesia/src/mnesia_schema.erl b/lib/mnesia/src/mnesia_schema.erl index 782493fb4f..0e4017e4c3 100644 --- a/lib/mnesia/src/mnesia_schema.erl +++ b/lib/mnesia/src/mnesia_schema.erl @@ -29,6 +29,16 @@ -module(mnesia_schema). -export([ + add_backend_type/2, + do_add_backend_type/2, + delete_backend_type/1, + do_delete_backend_type/1, + backend_types/0, + add_index_plugin/3, + do_add_index_plugin/3, + delete_index_plugin/1, + do_delete_index_plugin/1, + index_plugins/0, add_snmp/2, add_table_copy/3, add_table_index/2, @@ -55,14 +65,16 @@ dump_tables/1, ensure_no_schema/1, get_create_list/1, - get_initial_schema/2, + get_initial_schema/3, get_table_properties/1, info/0, info/1, init/1, + init_backends/0, insert_cstruct/3, is_remote_member/1, list2cs/1, + list2cs/2, lock_schema/0, merge_schema/0, merge_schema/1, @@ -110,7 +122,8 @@ do_delete_table/1, do_read_table_property/2, do_delete_table_property/2, - do_write_table_property/2]). + do_write_table_property/2, + do_change_table_copy_type/3]). -include("mnesia.hrl"). -include_lib("kernel/include/file.hrl"). @@ -138,12 +151,30 @@ init(IgnoreFallback) -> verbose("Schema initiated from: ~p~n", [Source]), set({schema, tables}, []), set({schema, local_tables}, []), + do_set_schema(schema), Tabs = set_schema(?ets_first(schema)), lists:foreach(fun(Tab) -> clear_whereabouts(Tab) end, Tabs), set({schema, where_to_read}, node()), set({schema, load_node}, node()), set({schema, load_reason}, initial), - mnesia_controller:add_active_replica(schema, node()). + mnesia_controller:add_active_replica(schema, node()), + init_backends(). + + +init_backends() -> + Backends = lists:foldl(fun({Alias, Mod}, Acc) -> + orddict:append(Mod, Alias, Acc) + end, orddict:new(), get_ext_types()), + [init_backend(Mod, Aliases) || {Mod, Aliases} <- Backends], + ok. + +init_backend(Mod, [_|_] = Aliases) -> + case Mod:init_backend() of + ok -> + Mod:add_aliases(Aliases); + Error -> + mnesia:abort({backend_init_error, Error}) + end. exit_on_error({error, Reason}) -> exit(Reason); @@ -180,6 +211,7 @@ do_set_schema(Tab, Cs) -> set({Tab, ram_copies}, Cs#cstruct.ram_copies), set({Tab, disc_copies}, Cs#cstruct.disc_copies), set({Tab, disc_only_copies}, Cs#cstruct.disc_only_copies), + set({Tab, external_copies}, Cs#cstruct.external_copies), set({Tab, load_order}, Cs#cstruct.load_order), set({Tab, access_mode}, Cs#cstruct.access_mode), set({Tab, majority}, Cs#cstruct.majority), @@ -195,15 +227,21 @@ do_set_schema(Tab, Cs) -> set({Tab, arity}, Arity), RecName = Cs#cstruct.record_name, set({Tab, record_name}, RecName), - set({Tab, record_validation}, {RecName, Arity, Type}), set({Tab, wild_pattern}, wild(RecName, Arity)), - set({Tab, index}, Cs#cstruct.index), + set({Tab, index}, [P || {P,_} <- Cs#cstruct.index]), + case Cs#cstruct.index of + [] -> + set({Tab, index_info}, mnesia_index:index_info(Type, [])); + _ -> + ignore + end, %% create actual index tabs later set({Tab, cookie}, Cs#cstruct.cookie), set({Tab, version}, Cs#cstruct.version), set({Tab, cstruct}, Cs), Storage = mnesia_lib:schema_cs_to_storage_type(node(), Cs), set({Tab, storage_type}, Storage), + set_record_validation(Tab, Storage, RecName, Arity, Type), mnesia_lib:add({schema, tables}, Tab), Ns = mnesia_lib:cs_to_nodes(Cs), case lists:member(node(), Ns) of @@ -213,7 +251,24 @@ do_set_schema(Tab, Cs) -> mnesia_lib:add({schema, local_tables}, Tab); false -> ignore - end. + end, + set_ext_types(Tab, get_ext_types(), Cs#cstruct.external_copies). + +set_record_validation(Tab, {ext,Alias,Mod}, RecName, Arity, Type) -> + set({Tab, record_validation}, {RecName, Arity, Type, Alias, Mod}); +set_record_validation(Tab, _, RecName, Arity, Type) -> + set({Tab, record_validation}, {RecName, Arity, Type}). + +set_ext_types(Tab, ExtTypes, ExtCopies) -> + lists:foreach( + fun({Type, _} = Key) -> + Nodes = case lists:keyfind(Key, 1, ExtCopies) of + {_, Ns} -> Ns; + false -> [] + end, + set({Tab, Type}, Nodes) + end, ExtTypes). + wild(RecName, Arity) -> Wp0 = list_to_tuple(lists:duplicate(Arity, '_')), @@ -525,9 +580,14 @@ do_read_disc_schema(Fname, Keep) -> Res. get_initial_schema(SchemaStorage, Nodes) -> + get_initial_schema(SchemaStorage, Nodes, []). + +get_initial_schema(SchemaStorage, Nodes, Properties) -> % + UserProps = initial_schema_properties(Properties), Cs = #cstruct{name = schema, record_name = schema, - attributes = [table, cstruct]}, + attributes = [table, cstruct], + user_properties = UserProps}, Cs2 = case SchemaStorage of ram_copies -> Cs#cstruct{ram_copies = Nodes}; @@ -535,6 +595,35 @@ get_initial_schema(SchemaStorage, Nodes) -> end, cs2list(Cs2). +initial_schema_properties(Props0) -> + DefaultProps = remove_duplicates(mnesia_monitor:get_env(schema)), + Props = lists:foldl( + fun({K,V}, Acc) -> + lists:keystore(K, 1, Acc, {K,V}) + end, DefaultProps, remove_duplicates(Props0)), + initial_schema_properties_(Props). + +initial_schema_properties_([{backend_types, Types}|Props]) -> + lists:foreach(fun({Name, Module}) -> + verify_backend_type(Name, Module) + end, Types), + [{mnesia_backend_types, Types}|initial_schema_properties_(Props)]; +initial_schema_properties_([{index_plugins, Plugins}|Props]) -> + lists:foreach(fun({Name, Module, Function}) -> + verify_index_plugin(Name, Module, Function) + end, Plugins), + [{mnesia_index_plugins, Plugins}|initial_schema_properties_(Props)]; +initial_schema_properties_([P|_Props]) -> + mnesia:abort({bad_schema_property, P}); +initial_schema_properties_([]) -> + []. + +remove_duplicates([{K,_} = H|T]) -> + [H | remove_duplicates([X || {K1,_} = X <- T, + K1 =/= K])]; +remove_duplicates([]) -> + []. + read_cstructs_from_disc() -> %% Assumptions: %% - local schema lock in global @@ -551,8 +640,9 @@ read_cstructs_from_disc() -> {type, set}], case dets:open_file(make_ref(), Args) of {ok, Tab} -> + ExtTypes = get_ext_types_disc(), Fun = fun({_, _, List}) -> - {continue, list2cs(List)} + {continue, list2cs(List, ExtTypes)} end, Cstructs = dets:traverse(Tab, Fun), dets:close(Tab), @@ -632,7 +722,7 @@ do_insert_schema_ops(_Store, []) -> api_list2cs(List) when is_list(List) -> Name = pick(unknown, name, List, must), - Keys = check_keys(Name, List, record_info(fields, cstruct)), + Keys = check_keys(Name, List), check_duplicates(Name, Keys), list2cs(List); api_list2cs(Other) -> @@ -647,7 +737,15 @@ cs2list(Cs) when is_record(Cs, cstruct) -> cs2list(CreateList) when is_list(CreateList) -> CreateList; -%% since 4.6 +cs2list(Cs) when element(1, Cs) == cstruct, tuple_size(Cs) == 20 -> + Tags = [name,type, + ram_copies,disc_copies,disc_only_copies,external_copies, + load_order,access_mode,majority,index,snmp,local_content, + record_name,attributes, + user_properties,frag_properties,storage_properties, + cookie,version], + rec2list(Tags, Tags, 2, Cs); +%% since vsn-4.6 (protocol 8.2 or older) cs2list(Cs) when element(1, Cs) == cstruct, tuple_size(Cs) == 19 -> Tags = [name,type,ram_copies,disc_copies,disc_only_copies, load_order,access_mode,majority,index,snmp,local_content, @@ -657,8 +755,38 @@ cs2list(Cs) when element(1, Cs) == cstruct, tuple_size(Cs) == 19 -> rec2list(Tags, Tags, 2, Cs). cs2list(false, Cs) -> - cs2list(Cs). + cs2list(Cs); +cs2list({8,3}, Cs) -> + cs2list(Cs); +cs2list({8,Minor}, Cs) when Minor =:= 2; Minor =:= 1 -> + Orig = record_info(fields, cstruct), + Tags = [name,type,ram_copies,disc_copies,disc_only_copies, + load_order,access_mode,majority,index,snmp,local_content, + record_name,attributes, + user_properties,frag_properties,storage_properties, + cookie,version], + CsList = rec2list(Tags, Orig, 2, Cs), + case proplists:get_value(index, CsList, []) of + [] -> CsList; + NewFormat -> + OldFormat = [Pos || {Pos, _Pref} <- NewFormat], + lists:keyreplace(index, 1, CsList, {index, OldFormat}) + end. +rec2list([index | Tags], [index|Orig], Pos, Rec) -> + Val = element(Pos, Rec), + [{index, lists:map( + fun({_, _Type}=P) -> P; + (P) when is_integer(P); is_atom(P) -> {P, ordered} + end, Val)} | rec2list(Tags, Orig, Pos + 1, Rec)]; +rec2list([external_copies | Tags], Orig0, Pos, Rec) -> + Orig = case Orig0 of + [external_copies|Rest] -> Rest; + _ -> Orig0 + end, + Val = element(Pos, Rec), + [{Alias, Ns} || {{Alias,_}, Ns} <- Val] + ++ rec2list(Tags, Orig, Pos+1, Rec); rec2list([Tag | Tags], [Tag | Orig], Pos, Rec) -> Val = element(Pos, Rec), [{Tag, Val} | rec2list(Tags, Orig, Pos + 1, Rec)]; @@ -667,17 +795,33 @@ rec2list([], _, _Pos, _Rec) -> rec2list(Tags, [_|Orig], Pos, Rec) -> rec2list(Tags, Orig, Pos+1, Rec). -normalize_cs(Cstructs, _Node) -> - Cstructs. +normalize_cs(Cstructs, Node) -> + %% backward-compatibility hack; normalize before returning + case need_old_cstructs([Node]) of + false -> + Cstructs; + Version -> + %% some other format + [convert_cs(Version, Cs) || Cs <- Cstructs] + end. + +convert_cs(Version, Cs) -> + Fields = [Value || {_, Value} <- cs2list(Version, Cs)], + list_to_tuple([cstruct|Fields]). + +list2cs(List) -> + list2cs(List, get_ext_types()). -list2cs(List) when is_list(List) -> +list2cs(List, ExtTypes) when is_list(List) -> Name = pick(unknown, name, List, must), Type = pick(Name, type, List, set), Rc0 = pick(Name, ram_copies, List, []), Dc = pick(Name, disc_copies, List, []), Doc = pick(Name, disc_only_copies, List, []), - Rc = case {Rc0, Dc, Doc} of - {[], [], []} -> [node()]; + + Ext = pick_external_copies(List, ExtTypes), + Rc = case {Rc0, Dc, Doc, Ext} of + {[], [], [], []} -> [node()]; _ -> Rc0 end, LC = pick(Name, local_content, List, false), @@ -695,8 +839,6 @@ list2cs(List) when is_list(List) -> Ix = pick(Name, index, List, []), verify({alt, [nil, list]}, mnesia_lib:etype(Ix), {bad_type, Name, {index, [Ix]}}), - Ix2 = [attr_to_pos(I, Attrs) || I <- Ix], - Frag = pick(Name, frag_properties, List, []), verify({alt, [nil, list]}, mnesia_lib:etype(Frag), {badarg, Name, {frag_properties, Frag}}), @@ -723,24 +865,48 @@ list2cs(List) when is_list(List) -> DetsOpts = proplists:get_value(dets, BEProps, []), is_list(DetsOpts) orelse mnesia:abort({badarg, Name, {dets, DetsOpts}}), [CheckProp(Prop, BadDetsOpts) || Prop <- DetsOpts], - #cstruct{name = Name, - ram_copies = Rc, - disc_copies = Dc, - disc_only_copies = Doc, - type = Type, - index = Ix2, - snmp = Snmp, - load_order = LoadOrder, - access_mode = AccessMode, - majority = Majority, - local_content = LC, - record_name = RecName, - attributes = Attrs, - user_properties = lists:sort(UserProps), - frag_properties = lists:sort(Frag), - storage_properties = lists:sort(BEProps), - cookie = Cookie, - version = Version}. + + case lists:keymember(mnesia, 1, application:which_applications()) of + true -> + Keys = check_keys(Name, List), + check_duplicates(Name, Keys); + false -> + %% check_keys/2 cannot be executed when mnesia is not + %% running, due to it not being possible to read what ext + %% backends are loaded. + %%% this doesn't work - disabled for now: + %%%Keys = check_keys(Name, List, record_info(fields, cstruct)), + %%%check_duplicates(Name, Keys) + ignore + end, + + Cs0 = #cstruct{name = Name, + ram_copies = Rc, + disc_copies = Dc, + disc_only_copies = Doc, + external_copies = Ext, + type = Type, + index = Ix, + snmp = Snmp, + load_order = LoadOrder, + access_mode = AccessMode, + majority = Majority, + local_content = LC, + record_name = RecName, + attributes = Attrs, + user_properties = lists:sort(UserProps), + frag_properties = lists:sort(Frag), + storage_properties = lists:sort(BEProps), + cookie = Cookie, + version = Version}, + case Ix of + [] -> Cs0; + [_|_] -> + Ix2 = expand_index_attrs(Cs0), + Cs0#cstruct{index = Ix2} + end; +list2cs(Other, _ExtTypes) -> + mnesia:abort({badarg, Other}). pick(Tab, Key, List, Default) -> case lists:keysearch(Key, 1, List) of @@ -754,6 +920,79 @@ pick(Tab, Key, List, Default) -> mnesia:abort({bad_type, Tab, BadArg}) end. +pick_external_copies(_List, []) -> + []; +pick_external_copies(List, ExtTypes) -> + lists:foldr( + fun({K, Val}, Acc) -> + case lists:keyfind(K, 1, ExtTypes) of + false -> + Acc; + {_, Mod} -> + [{{K,Mod}, Val}|Acc] + end + end, [], List). + +expand_storage_type(S) when S==ram_copies; + S==disc_copies; + S==disc_only_copies -> + S; +expand_storage_type(S) -> + case lists:keyfind(S, 1, get_ext_types()) of + false -> + mnesia:abort({bad_type, {storage_type, S}}); + {Alias, Mod} -> + {ext, Alias, Mod} + end. + +get_ext_types() -> + get_schema_user_property(mnesia_backend_types). + +get_index_plugins() -> + get_schema_user_property(mnesia_index_plugins). + +get_schema_user_property(Key) -> + Tab = schema, + %% Must work reliably both within transactions and outside of transactions + Res = case get(mnesia_activity_state) of + undefined -> + dirty_read_table_property(Tab, Key); + _ -> + do_read_table_property(Tab, Key) + end, + case Res of + undefined -> + []; + {_, Types} -> + Types + end. + +get_ext_types_disc() -> + try get_ext_types_disc_() + catch + error:_ ->[] + end. + +get_ext_types_disc_() -> + case mnesia_schema:remote_read_schema() of + {ok, _, Prop} -> + K1 = user_properties, + case lists:keyfind(K1, 1, Prop) of + {K1, UserProp} -> + K2 = mnesia_backend_types, + case lists:keyfind(K2, 1, UserProp) of + {K2, Types} -> + Types; + _ -> + [] + end; + _ -> + [] + end; + _ -> + [] + end. + %% Convert attribute name to integer if neccessary attr_tab_to_pos(_Tab, Pos) when is_integer(Pos) -> Pos; @@ -761,6 +1000,7 @@ attr_tab_to_pos(Tab, Attr) -> attr_to_pos(Attr, val({Tab, attributes})). %% Convert attribute name to integer if neccessary +attr_to_pos({_} = P, _) -> P; attr_to_pos(Pos, _Attrs) when is_integer(Pos) -> Pos; attr_to_pos(Attr, Attrs) when is_atom(Attr) -> @@ -775,8 +1015,18 @@ attr_to_pos(Attr, [_ | Attrs], Pos) -> attr_to_pos(Attr, _, _) -> mnesia:abort({bad_type, Attr}). +check_keys(Tab, Attrs) -> + Types = [T || {T,_} <- get_ext_types()], + check_keys(Tab, Attrs, Types ++ record_info(fields, cstruct)). + check_keys(Tab, [{Key, _Val} | Tail], Items) -> - case lists:member(Key, Items) of + Key1 = if + is_tuple(Key) -> + element(1, Key); + true -> + Key + end, + case lists:member(Key1, Items) of true -> [Key | check_keys(Tab, Tail, Items)]; false -> mnesia:abort({badarg, Tab, Key}) end; @@ -800,7 +1050,92 @@ has_duplicates([]) -> false. %% This is the only place where we check the validity of data -verify_cstruct(Cs) when is_record(Cs, cstruct) -> + +verify_cstruct(#cstruct{} = Cs) -> + assert_correct_cstruct(Cs), + Cs1 = verify_external_copies( + Cs#cstruct{index = expand_index_attrs(Cs)}), + assert_correct_cstruct(Cs1), + Cs1. + +expand_index_attrs(#cstruct{index = Ix, attributes = Attrs, + name = Tab} = Cs) -> + Prefered = prefered_index_types(Cs), + expand_index_attrs(Ix, Tab, Attrs, Prefered). + +expand_index_attrs(Ix, Tab, Attrs, Prefered) -> + lists:map(fun(P) when is_integer(P); is_atom(P) -> + {attr_to_pos(P, Attrs), Prefered}; + ({A} = P) when is_atom(A) -> + {P, Prefered}; + ({P, Type}) -> + {attr_to_pos(P, Attrs), Type}; + (_Other) -> + mnesia:abort({bad_type, Tab, {index, Ix}}) + end, Ix). + +prefered_index_types(#cstruct{external_copies = Ext}) -> + ExtTypes = [mnesia_lib:semantics(S, index_types) || + {S,Ns} <- Ext, Ns =/= []], + case intersect_types(ExtTypes) of + [] -> ordered; + [Pref|_] -> Pref + end. + +intersect_types([]) -> + []; +intersect_types([S1, S2|Rest]) -> + intersect_types([S1 -- (S1 -- S2)|Rest]); +intersect_types([S]) -> + S. + +verify_external_copies(#cstruct{external_copies = []} = Cs) -> + Cs; +verify_external_copies(#cstruct{name = Tab, external_copies = EC} = Cs) -> + Bad = {bad_type, Tab, {external_copies, EC}}, + AllECNodes = lists:concat([Ns || {_, Ns} <- EC, + is_list(Ns)]), + verify(true, length(lists:usort(AllECNodes)) == length(AllECNodes), Bad), + CsL = cs2list(Cs), + CsL1 = lists:foldl( + fun({{Alias, Mod}, Ns} = _X, CsLx) -> + BadTab = fun(Why) -> + {Why, Tab, {{ext, Alias, Mod},Ns}} + end, + verify(atom, mnesia_lib:etype(Mod), BadTab), + verify(true, fun() -> + lists:all(fun is_atom/1, Ns) + end, BadTab), + check_semantics(Mod, Alias, BadTab, Cs), + try Mod:check_definition(Alias, Tab, Ns, CsLx) of + ok -> + CsLx; + {ok, CsLx1} -> + CsLx1; + {error, Reason} -> + mnesia:abort(BadTab(Reason)) + catch + error:E -> + mnesia:abort(BadTab(E)) + end; + (_, CsLx) -> + CsLx + end, CsL, EC), + list2cs(CsL1). + +check_semantics(Mod, Alias, BadTab, #cstruct{type = Type}) -> + Ext = {ext, Alias, Mod}, + case lists:member(mnesia_lib:semantics(Ext, storage), [ram_copies, disc_copies, + disc_only_copies]) of + false -> mnesia:abort(BadTab(invalid_storage)); + true -> ok + end, + case lists:member(Type, mnesia_lib:semantics(Ext, types)) of + false -> mnesia:abort(BadTab(bad_type)); + true -> ok + end. + +assert_correct_cstruct(Cs) when is_record(Cs, cstruct) -> verify_nodes(Cs), Tab = Cs#cstruct.name, @@ -841,22 +1176,30 @@ verify_cstruct(Cs) when is_record(Cs, cstruct) -> Attrs), Index = Cs#cstruct.index, + verify({alt, [nil, list]}, mnesia_lib:etype(Index), {bad_type, Tab, {index, Index}}), + IxPlugins = get_index_plugins(), + AllowIndexOnKey = check_if_allow_index_on_key(), IxFun = - fun(Pos) -> - verify(true, fun() -> - if - is_integer(Pos), - Pos > 2, - Pos =< Arity -> - true; - true -> false - end - end, - {bad_type, Tab, {index, [Pos]}}) - end, + fun(Pos) -> + verify( + true, fun() -> + I = index_pos(Pos), + case Pos of + {_, T} -> + (T==bag orelse T==ordered) + andalso good_ix_pos( + I, AllowIndexOnKey, + Arity, IxPlugins); + _ -> + good_ix_pos(Pos, AllowIndexOnKey, + Arity, IxPlugins) + end + end, + {bad_type, Tab, {index, [Pos]}}) + end, lists:foreach(IxFun, Index), LC = Cs#cstruct.local_content, @@ -880,7 +1223,9 @@ verify_cstruct(Cs) when is_record(Cs, cstruct) -> {badarg, Tab, {snmp, Snmp}}), CheckProp = fun(Prop) when is_tuple(Prop), size(Prop) >= 1 -> ok; - (Prop) -> mnesia:abort({bad_type, Tab, {user_properties, [Prop]}}) + (Prop) -> + mnesia:abort({bad_type, Tab, + {user_properties, [Prop]}}) end, lists:foreach(CheckProp, Cs#cstruct.user_properties), @@ -900,17 +1245,45 @@ verify_cstruct(Cs) when is_record(Cs, cstruct) -> mnesia:abort({bad_type, Tab, {version, Version}}) end. +good_ix_pos({_} = P, _, _, Plugins) -> + lists:keymember(P, 1, Plugins); +good_ix_pos(I, true, Arity, _) when is_integer(I) -> + I >= 0 andalso I =< Arity; +good_ix_pos(I, false, Arity, _) when is_integer(I) -> + I > 2 andalso I =< Arity; +good_ix_pos(_, _, _, _) -> + false. + + +check_if_allow_index_on_key() -> + case mnesia_monitor:get_env(allow_index_on_key) of + true -> + true; + _ -> + false + end. + verify_nodes(Cs) -> Tab = Cs#cstruct.name, Ram = Cs#cstruct.ram_copies, Disc = Cs#cstruct.disc_copies, DiscOnly = Cs#cstruct.disc_only_copies, + Ext = lists:append([Ns || {_,Ns} <- Cs#cstruct.external_copies]), LoadOrder = Cs#cstruct.load_order, verify({alt, [nil, list]}, mnesia_lib:etype(Ram), {bad_type, Tab, {ram_copies, Ram}}), verify({alt, [nil, list]}, mnesia_lib:etype(Disc), {bad_type, Tab, {disc_copies, Disc}}), + lists:foreach( + fun({BE, Ns}) -> + verify({alt, [nil, list]}, mnesia_lib:etype(Ns), + {bad_type, Tab, {BE, Ns}}), + lists:foreach(fun(N) -> + verify(atom, mnesia_lib:etype(N), + {bad_type, Tab, {BE, Ns}}) + end, Ns) + end, Cs#cstruct.external_copies), case Tab of schema -> verify([], DiscOnly, {bad_type, Tab, {disc_only_copies, DiscOnly}}); @@ -922,12 +1295,15 @@ verify_nodes(Cs) -> verify(integer, mnesia_lib:etype(LoadOrder), {bad_type, Tab, {load_order, LoadOrder}}), - Nodes = Ram ++ Disc ++ DiscOnly, + Nodes = Ram ++ Disc ++ DiscOnly ++ Ext, verify(list, mnesia_lib:etype(Nodes), {combine_error, Tab, - [{ram_copies, []}, {disc_copies, []}, {disc_only_copies, []}]}), + [{ram_copies, []}, {disc_copies, []}, + {disc_only_copies, []}, {external_copies, []}]}), verify(false, has_duplicates(Nodes), {combine_error, Tab, Nodes}), - AtomCheck = fun(N) -> verify(atom, mnesia_lib:etype(N), {bad_type, Tab, N}) end, + AtomCheck = fun(N) -> + verify(atom, mnesia_lib:etype(N), {bad_type, Tab, N}) + end, lists:foreach(AtomCheck, Nodes). verify(Expected, Fun, Error) when is_function(Fun) -> @@ -1010,28 +1386,194 @@ check_active([{badrpc, Reason} | _Replies], Expl, Tab) -> check_active([], _Expl, _Tab) -> ok. + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%% Function for definining an external backend type + +add_backend_type(Name, Module) -> + case schema_transaction(fun() -> do_add_backend_type(Name, Module) end) of + {atomic, NeedsInit} -> + case NeedsInit of + true -> + Module:init_backend(); + false -> + ignore + end, + Module:add_aliases([Name]), + {atomic, ok}; + Other -> + Other + end. + +do_add_backend_type(Name, Module) -> + verify_backend_type(Name, Module), + Types = case do_read_table_property(schema, mnesia_backend_types) of + undefined -> + []; + {_, Ts} -> + case lists:keymember(Name, 1, Ts) of + true -> + mnesia:abort({backend_type_already_exists, Name}); + false -> + Ts + end + end, + ModuleRegistered = lists:keymember(Module, 2, Types), + do_write_table_property(schema, {mnesia_backend_types, + [{Name, Module}|Types]}), + ModuleRegistered. + +delete_backend_type(Name) -> + schema_transaction(fun() -> do_delete_backend_type(Name) end). + +do_delete_backend_type(Name) -> + case do_read_table_property(schema, mnesia_backend_types) of + undefined -> + []; + {_, Ts} -> + case lists:keyfind(Name, 1, Ts) of + {_, Mod} -> + case using_backend_type(Name, Mod) of + [_|_] = Tabs -> + mnesia:abort({backend_in_use, {Name, Tabs}}); + [] -> + do_write_table_property( + schema, {mnesia_backend_types, + lists:keydelete(Name, 1, Ts)}) + end; + false -> + mnesia:abort({no_such_backend, Name}) + end + end. + +using_backend_type(Name, Mod) -> + Ext = ets:select(mnesia_gvar, + [{ {{'$1',external_copies},'$2'}, [], [{{'$1','$2'}}] }]), + Entry = {Name, Mod}, + [T || {T,C} <- Ext, + lists:keymember(Entry, 1, C)]. + +verify_backend_type(Name, Module) -> + case legal_backend_name(Name) of + false -> + mnesia:abort({bad_type, {backend_type,Name,Module}}); + true -> + ok + end, + ExpectedExports = mnesia_backend_type:behaviour_info(callbacks), + Exports = try Module:module_info(exports) + catch + error:_ -> + mnesia:abort({undef_backend, Module}) + end, + case ExpectedExports -- Exports of + [] -> + ok; + _Other -> + io:fwrite(user, "Missing backend_type exports: ~p~n", [_Other]), + mnesia:abort({bad_type, {backend_type,Name,Module}}) + end. + +legal_backend_name(Name) -> + is_atom(Name) andalso + (not lists:member(Name, record_info(fields, cstruct))). + +%% Used e.g. by mnesia:system_info(backend_types). +backend_types() -> + [ram_copies, disc_copies, disc_only_copies | + [T || {T,_} <- get_ext_types()]]. + +add_index_plugin(Name, Module, Function) -> + schema_transaction( + fun() -> do_add_index_plugin(Name, Module, Function) end). + +do_add_index_plugin(Name, Module, Function) -> + verify_index_plugin(Name, Module, Function), + Plugins = case do_read_table_property(schema, mnesia_index_plugins) of + undefined -> + []; + {_, Ps} -> + case lists:keymember(Name, 1, Ps) of + true -> + mnesia:abort({index_plugin_already_exists, Name}); + false -> + Ps + end + end, + do_write_table_property(schema, {mnesia_index_plugins, + [{Name, Module, Function}|Plugins]}). + +delete_index_plugin(P) -> + schema_transaction( + fun() -> do_delete_index_plugin(P) end). + +do_delete_index_plugin({A} = P) when is_atom(A) -> + Plugins = get_index_plugins(), + case lists:keyfind(P, 1, Plugins) of + false -> + mnesia:abort({no_exists, {index_plugin, P}}); + _Found -> + case ets:select(mnesia_gvar, + [{ {{'$1',{index,{P,'_'}}},'_'},[],['$1']}, + { {{'$1',{index,P}},'_'},[],['$1']}], 1) of + {[_], _} -> + mnesia:abort({plugin_in_use, P}); + '$end_of_table' -> + do_write_table_property( + schema, {mnesia_index_plugins, + lists:keydelete(P, 1, Plugins)}) + end + end. + +verify_index_plugin({A} = Name, Module, Function) + when is_atom(A), is_atom(Module), is_atom(Function) -> + case code:ensure_loaded(Module) of + {error, nofile} -> + mnesia:abort({bad_type, {index_plugin,Name,Module,Function}}); + {module,_} -> + %% Index plugins are called as Module:Function(Tab, Pos, Obj) + case erlang:function_exported(Module, Function, 3) of + true -> + ok; + false -> + mnesia:abort( + {bad_type, {index_plugin,Name,Module,Function}}) + end + end; +verify_index_plugin(Name, Module, Function) -> + mnesia:abort({bad_type, {index_plugin,Name,Module,Function}}). + + +%% Used e.g. by mnesia:system_info(backend_types). +index_plugins() -> + get_index_plugins(). + %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %% Here's the real interface function to create a table -create_table(TabDef) -> - schema_transaction(fun() -> do_multi_create_table(TabDef) end). +create_table([_|_] = TabDef) -> + schema_transaction(fun() -> do_multi_create_table(TabDef) end); +create_table(Arg) -> {aborted, {badarg, Arg}}. %% And the corresponding do routines .... do_multi_create_table(TabDef) -> get_tid_ts_and_lock(schema, write), ensure_writable(schema), + do_create_table(TabDef), + ok. + +do_create_table(TabDef) when is_list(TabDef) -> Cs = api_list2cs(TabDef), case Cs#cstruct.frag_properties of [] -> - do_create_table(Cs); + do_create_table_1(Cs); _Props -> CsList = mnesia_frag:expand_cstruct(Cs), - lists:foreach(fun do_create_table/1, CsList) - end, - ok. + lists:foreach(fun do_create_table_1/1, CsList) + end. -do_create_table(Cs) -> +do_create_table_1(Cs) -> {_Mod, _Tid, Ts} = get_tid_ts_and_lock(schema, none), Store = Ts#tidstore.store, do_insert_schema_ops(Store, make_create_table(Cs)). @@ -1041,14 +1583,9 @@ make_create_table(Cs) -> verify(false, check_if_exists(Tab), {already_exists, Tab}), unsafe_make_create_table(Cs). -% unsafe_do_create_table(Cs) -> -% {_Mod, Tid, Ts} = get_tid_ts_and_lock(schema, none), -% Store = Ts#tidstore.store, -% do_insert_schema_ops(Store, unsafe_make_create_table(Cs)). - -unsafe_make_create_table(Cs) -> +unsafe_make_create_table(Cs0) -> {_Mod, Tid, Ts} = get_tid_ts_and_lock(schema, none), - verify_cstruct(Cs), + Cs = verify_cstruct(Cs0), Tab = Cs#cstruct.name, %% Check that we have all disc replica nodes running @@ -1196,8 +1733,7 @@ make_add_table_copy(Tab, Node, Storage) -> Cs = incr_version(val({Tab, cstruct})), Ns = mnesia_lib:cs_to_nodes(Cs), verify(false, lists:member(Node, Ns), {already_exists, Tab, Node}), - Cs2 = new_cs(Cs, Node, Storage, add), - verify_cstruct(Cs2), + Cs2 = verify_cstruct(new_cs(Cs, Node, Storage, add)), %% Check storage and if node is running IsRunning = lists:member(Node, val({current, db_nodes})), @@ -1245,14 +1781,14 @@ make_del_table_copy(Tab, Node) -> _ when Tab == schema -> %% ensure_active(Cs2), ensure_not_active(Tab, Node), - verify_cstruct(Cs2), + Cs3 = verify_cstruct(Cs2), Ops = remove_node_from_tabs(val({schema, tables}), Node), - [{op, del_table_copy, ram_copies, Node, vsn_cs2list(Cs2)} | Ops]; + [{op, del_table_copy, ram_copies, Node, vsn_cs2list(Cs3)} | Ops]; _ -> ensure_active(Cs), - verify_cstruct(Cs2), - get_tid_ts_and_lock(Tab, write), - [{op, del_table_copy, Storage, Node, vsn_cs2list(Cs2)}] + Cs3 = verify_cstruct(Cs2), + get_tid_ts_and_lock(Tab, write), + [{op, del_table_copy, Storage, Node, vsn_cs2list(Cs3)}] end. remove_node_from_tabs([], _Node) -> @@ -1278,9 +1814,9 @@ remove_node_from_tabs([Tab|Rest], Node) -> [{op, delete_table, vsn_cs2list(Cs)} | remove_node_from_tabs(Rest, Node)]; _Ns -> - verify_cstruct(Cs2), + Cs3 = verify_cstruct(Cs2), get_tid_ts_and_lock(Tab, write), - [{op, del_table_copy, ram_copies, Node, vsn_cs2list(Cs2)}| + [{op, del_table_copy, ram_copies, Node, vsn_cs2list(Cs3)}| remove_node_from_tabs(Rest, Node)] end end. @@ -1298,8 +1834,34 @@ new_cs(Cs, Node, disc_copies, del) -> new_cs(Cs, Node, disc_only_copies, del) -> Cs#cstruct{disc_only_copies = lists:delete(Node , Cs#cstruct.disc_only_copies)}; -new_cs(Cs, _Node, Storage, _Op) -> - mnesia:abort({badarg, Cs#cstruct.name, Storage}). +new_cs(#cstruct{external_copies = ExtCps} = Cs, Node, Storage0, Op) -> + Storage = case Storage0 of + {ext, Alias, _} -> Alias; + Alias -> Alias + end, + ExtTypes = get_ext_types(), + case lists:keyfind(Storage, 1, ExtTypes) of + false -> + mnesia:abort({badarg, Cs#cstruct.name, Storage}); + {_, Mod} -> + Key = {Storage, Mod}, + case {lists:keymember(Key, 1, ExtCps), Op} of + {false, del} -> + Cs; + {false, add} -> + Cs#cstruct{external_copies = [{Key, [Node]}|ExtCps]}; + {true, _} -> + F = fun({K, Ns}) when K == Key -> + case Op of + del -> {K, lists:delete(Node, Ns)}; + add -> {K, opt_add(Node, Ns)} + end; + (X) -> + X + end, + Cs#cstruct{external_copies = lists:map(F, ExtCps)} + end + end. opt_add(N, L) -> [N | lists:delete(N, L)]. @@ -1335,8 +1897,7 @@ make_move_table(Tab, FromNode, ToNode) -> verify(true, lists:member(ToNode, Running), {not_active, schema, ToNode}), Cs2 = new_cs(Cs, ToNode, Storage, add), - Cs3 = new_cs(Cs2, FromNode, Storage, del), - verify_cstruct(Cs3), + Cs3 = verify_cstruct(new_cs(Cs2, FromNode, Storage, del)), [{op, add_table_copy, Storage, ToNode, vsn_cs2list(Cs2)}, {op, sync_trans}, {op, del_table_copy, Storage, FromNode, vsn_cs2list(Cs3)}]. @@ -1363,9 +1924,11 @@ make_change_table_copy_type(Tab, Node, ToS) -> Cs = incr_version(val({Tab, cstruct})), FromS = mnesia_lib:storage_type_at_node(Node, Tab), - case compare_storage_type(false, FromS, ToS) of + ToSExp = expand_storage_type(ToS), + + case compare_storage_type(false, FromS, ToSExp) of {same, _} -> - mnesia:abort({already_exists, Tab, Node, ToS}); + mnesia:abort({already_exists, Tab, Node, ToSExp}); {diff, _} -> ignore; incompatible -> @@ -1373,10 +1936,8 @@ make_change_table_copy_type(Tab, Node, ToS) -> end, Cs2 = new_cs(Cs, Node, FromS, del), - Cs3 = new_cs(Cs2, Node, ToS, add), - verify_cstruct(Cs3), - - [{op, change_table_copy_type, Node, FromS, ToS, vsn_cs2list(Cs3)}]. + Cs3 = verify_cstruct(new_cs(Cs2, Node, ToS, add)), + [{op, change_table_copy_type, Node, FromS, ToSExp, vsn_cs2list(Cs3)}]. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %% change index functions .... @@ -1398,11 +1959,12 @@ make_add_table_index(Tab, Pos) -> Cs = incr_version(val({Tab, cstruct})), ensure_active(Cs), Ix = Cs#cstruct.index, - verify(false, lists:member(Pos, Ix), {already_exists, Tab, Pos}), + verify(false, lists:keymember(index_pos(Pos), 1, Ix), + {already_exists, Tab, Pos}), Ix2 = lists:sort([Pos | Ix]), - Cs2 = Cs#cstruct{index = Ix2}, - verify_cstruct(Cs2), - [{op, add_index, Pos, vsn_cs2list(Cs2)}]. + Cs2 = verify_cstruct(Cs#cstruct{index = Ix2}), + NewPosInfo = lists:keyfind(Pos, 1, Cs2#cstruct.index), + [{op, add_index, NewPosInfo, vsn_cs2list(Cs2)}]. del_table_index(Tab, Pos) -> schema_transaction(fun() -> do_del_table_index(Tab, Pos) end). @@ -1420,9 +1982,8 @@ make_del_table_index(Tab, Pos) -> Cs = incr_version(val({Tab, cstruct})), ensure_active(Cs), Ix = Cs#cstruct.index, - verify(true, lists:member(Pos, Ix), {no_exists, Tab, Pos}), - Cs2 = Cs#cstruct{index = lists:delete(Pos, Ix)}, - verify_cstruct(Cs2), + verify(true, lists:keymember(Pos, 1, Ix), {no_exists, Tab, Pos}), + Cs2 = verify_cstruct(Cs#cstruct{index = lists:keydelete(Pos, 1, Ix)}), [{op, del_index, Pos, vsn_cs2list(Cs2)}]. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% @@ -1444,8 +2005,7 @@ make_add_snmp(Tab, Ustruct) -> verify([], Cs#cstruct.snmp, {already_exists, Tab, snmp}), Error = {badarg, Tab, snmp, Ustruct}, verify(true, mnesia_snmp_hook:check_ustruct(Ustruct), Error), - Cs2 = Cs#cstruct{snmp = Ustruct}, - verify_cstruct(Cs2), + Cs2 = verify_cstruct(Cs#cstruct{snmp = Ustruct}), [{op, add_snmp, Ustruct, vsn_cs2list(Cs2)}]. del_snmp(Tab) -> @@ -1462,8 +2022,7 @@ make_del_snmp(Tab) -> ensure_writable(schema), Cs = incr_version(val({Tab, cstruct})), ensure_active(Cs), - Cs2 = Cs#cstruct{snmp = []}, - verify_cstruct(Cs2), + Cs2 = verify_cstruct(Cs#cstruct{snmp = []}), [{op, del_snmp, vsn_cs2list(Cs2)}]. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% @@ -1492,19 +2051,21 @@ make_transform(Tab, Fun, NewAttrs, NewRecName) -> Cs = incr_version(val({Tab, cstruct})), ensure_active(Cs), ensure_writable(Tab), - case mnesia_lib:val({Tab, index}) of + case Cs#cstruct.index of [] -> - Cs2 = Cs#cstruct{attributes = NewAttrs, record_name = NewRecName}, - verify_cstruct(Cs2), + Cs2 = verify_cstruct( + Cs#cstruct{attributes = NewAttrs, + record_name = NewRecName}), [{op, transform, Fun, vsn_cs2list(Cs2)}]; PosList -> - DelIdx = fun(Pos, Ncs) -> + DelIdx = fun({Pos,_}, Ncs) -> Ix = Ncs#cstruct.index, - Ncs1 = Ncs#cstruct{index = lists:delete(Pos, Ix)}, + Ix2 = lists:keydelete(Pos, 1, Ix), + Ncs1 = Ncs#cstruct{index = Ix2}, Op = {op, del_index, Pos, vsn_cs2list(Ncs1)}, {Op, Ncs1} end, - AddIdx = fun(Pos, Ncs) -> + AddIdx = fun({_,_} = Pos, Ncs) -> Ix = Ncs#cstruct.index, Ix2 = lists:sort([Pos | Ix]), Ncs1 = Ncs#cstruct{index = Ix2}, @@ -1514,10 +2075,16 @@ make_transform(Tab, Fun, NewAttrs, NewRecName) -> {DelOps, Cs1} = lists:mapfoldl(DelIdx, Cs, PosList), Cs2 = Cs1#cstruct{attributes = NewAttrs, record_name = NewRecName}, {AddOps, Cs3} = lists:mapfoldl(AddIdx, Cs2, PosList), - verify_cstruct(Cs3), - lists:flatten([DelOps, {op, transform, Fun, vsn_cs2list(Cs2)}, AddOps]) + _ = verify_cstruct(Cs3), % just a sanity check + lists:flatten([DelOps, {op, transform, Fun, vsn_cs2list(Cs2)}, + AddOps]) end. +index_pos({Pos,_}) -> Pos; +index_pos(Pos) when is_integer(Pos) -> Pos; +index_pos({P} = Pos) when is_atom(P) -> Pos. + + %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %% @@ -1537,8 +2104,7 @@ make_change_table_access_mode(Tab, Mode) -> ensure_active(Cs), OldMode = Cs#cstruct.access_mode, verify(false, OldMode == Mode, {already_exists, Tab, Mode}), - Cs2 = Cs#cstruct{access_mode = Mode}, - verify_cstruct(Cs2), + Cs2 = verify_cstruct(Cs#cstruct{access_mode = Mode}), [{op, change_table_access_mode, vsn_cs2list(Cs2), OldMode, Mode}]. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% @@ -1558,8 +2124,7 @@ make_change_table_load_order(Tab, LoadOrder) -> Cs = incr_version(val({Tab, cstruct})), ensure_active(Cs), OldLoadOrder = Cs#cstruct.load_order, - Cs2 = Cs#cstruct{load_order = LoadOrder}, - verify_cstruct(Cs2), + Cs2 = verify_cstruct(Cs#cstruct{load_order = LoadOrder}), [{op, change_table_load_order, vsn_cs2list(Cs2), OldLoadOrder, LoadOrder}]. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% @@ -1605,6 +2170,7 @@ write_table_property(Tab, Prop) when is_tuple(Prop), size(Prop) >= 1 -> schema_transaction(fun() -> do_write_table_property(Tab, Prop) end); write_table_property(Tab, Prop) -> {aborted, {bad_type, Tab, Prop}}. + do_write_table_property(Tab, Prop) -> TidTs = get_tid_ts_and_lock(schema, write), {_, _, Ts} = TidTs, @@ -1636,8 +2202,7 @@ make_write_table_properties(Tab, [Prop | Props], Cs) -> PropKey = element(1, Prop), DelProps = lists:keydelete(PropKey, 1, OldProps), MergedProps = lists:merge(DelProps, [Prop]), - Cs2 = Cs#cstruct{user_properties = MergedProps}, - verify_cstruct(Cs2), + Cs2 = verify_cstruct(Cs#cstruct{user_properties = MergedProps}), [{op, write_property, vsn_cs2list(Cs2), Prop} | make_write_table_properties(Tab, Props, Cs2)]; make_write_table_properties(_Tab, [], _Cs) -> @@ -1682,22 +2247,38 @@ do_read_table_property(Tab, Key) -> {_, _, Ts} = TidTs, Store = Ts#tidstore.store, Props = ets:foldl( - fun({op, create_table, [{name, T}|Opts]}, _Acc) - when T==Tab -> + fun({op, announce_im_running,_,Opts,_,_}, _Acc) when Tab==schema -> + find_props(Opts); + ({op, create_table, [{name, T}|Opts]}, _Acc) + when T==Tab -> find_props(Opts); ({op, Op, [{name,T}|Opts], _Prop}, _Acc) - when T==Tab, Op==write_property; Op==delete_property -> + when T==Tab, Op==write_property; + T==Tab, Op==delete_property -> find_props(Opts); ({op, delete_table, [{name,T}|_]}, _Acc) when T==Tab -> []; (_Other, Acc) -> Acc - end, [], Store), - case lists:keysearch(Key, 1, Props) of - {value, Property} -> - Property; - false -> + end, undefined, Store), + case Props of + undefined -> + get_tid_ts_and_lock(Tab, read), + dirty_read_table_property(Tab, Key); + _ when is_list(Props) -> + case lists:keyfind(Key, 1, Props) of + false -> + undefined; + Other -> + Other + end + end. + +dirty_read_table_property(Tab, Key) -> + try ets:lookup_element(mnesia_gvar, {Tab,user_property,Key}, 2) + catch + error:_ -> undefined end. @@ -1757,8 +2338,7 @@ make_delete_table_properties(Tab, PropKeys) -> make_delete_table_properties(Tab, [PropKey | PropKeys], Cs) -> OldProps = Cs#cstruct.user_properties, Props = lists:keydelete(PropKey, 1, OldProps), - Cs2 = Cs#cstruct{user_properties = Props}, - verify_cstruct(Cs2), + Cs2 = verify_cstruct(Cs#cstruct{user_properties = Props}), [{op, delete_property, vsn_cs2list(Cs2), PropKey} | make_delete_table_properties(Tab, PropKeys, Cs2)]; make_delete_table_properties(_Tab, [], _Cs) -> @@ -1899,6 +2479,11 @@ prepare_op(Tid, {op, create_table, TabDef}, _WaitFor) -> create_disc_only_table(Tab,Cs), insert_cstruct(Tid, Cs, false), {true, optional}; + {ext, Alias, Mod} -> + mnesia_lib:set({Tab, create_table},true), + create_external_table(Alias, Tab, Mod, Cs), + insert_cstruct(Tid, Cs, false), + {true, optional}; unknown -> %% No replica on this node mnesia_lib:set({Tab, create_table},true), insert_cstruct(Tid, Cs, false), @@ -1967,6 +2552,12 @@ prepare_op(_Tid, {op, change_table_copy_type, N, FromS, ToS, TabDef}, _WaitFor) NotActive = mnesia_lib:not_active_here(Tab), + if Tab =/= schema -> + check_if_disc_required(FromS, ToS); + true -> + ok + end, + if NotActive == true -> mnesia:abort({not_active, Tab, node()}); @@ -2006,6 +2597,15 @@ prepare_op(_Tid, {op, change_table_copy_type, N, FromS, ToS, TabDef}, _WaitFor) mnesia:abort({combine_error, Tab, ToS}) end; + element(1,FromS) == ext; element(1,ToS) == ext -> + if ToS == ram_copies -> + create_ram_table(Tab, Cs); + true -> + ok + end, + mnesia_dumper:dump_to_logfile(FromS, Tab), + mnesia_checkpoint:tm_change_table_copy_type(Tab, FromS, ToS); + FromS == ram_copies -> case mnesia_monitor:use_dir() of true -> @@ -2021,7 +2621,9 @@ prepare_op(_Tid, {op, change_table_copy_type, N, FromS, ToS, TabDef}, _WaitFor) disc_only_copies -> mnesia_dumper:raw_named_dump_table(Tab, dmp) end, - mnesia_checkpoint:tm_change_table_copy_type(Tab, FromS, ToS) + mnesia_checkpoint:tm_change_table_copy_type(Tab, + FromS, + ToS) end; false -> mnesia:abort({has_no_disc, node()}) @@ -2029,6 +2631,7 @@ prepare_op(_Tid, {op, change_table_copy_type, N, FromS, ToS, TabDef}, _WaitFor) FromS == disc_copies, ToS == disc_only_copies -> mnesia_dumper:raw_named_dump_table(Tab, dmp); + FromS == disc_only_copies -> Type = Cs#cstruct.type, create_ram_table(Tab, Cs), @@ -2040,6 +2643,7 @@ prepare_op(_Tid, {op, change_table_copy_type, N, FromS, ToS, TabDef}, _WaitFor) Err = "Failed to copy disc data to ram", mnesia:abort({system_limit, Tab, {Err,Reason}}) end; + true -> ignore end, @@ -2103,6 +2707,8 @@ prepare_op(_Tid, {op, transform, Fun, TabDef}, _WaitFor) -> {true, Objs, mandatory} catch _:Reason -> mnesia_lib:db_fixtable(Storage, Tab, false), + mnesia_lib:important("Transform function failed: '~p' in '~p'", + [Reason, erlang:get_stacktrace()]), exit({"Bad transform function", Tab, Fun, node(), Reason}) end end; @@ -2119,6 +2725,22 @@ prepare_op(_Tid, {op, merge_schema, TabDef}, _WaitFor) -> prepare_op(_Tid, _Op, _WaitFor) -> {true, optional}. +check_if_disc_required(FromS, ToS) -> + FromSem = mnesia_lib:semantics(FromS, storage), + ToSem = mnesia_lib:semantics(ToS, storage), + case {FromSem, ToSem} of + {ram_copies, _} when ToSem == disc_copies; + ToSem == disc_only_copies -> + case mnesia_monitor:use_dir() of + true -> + ok; + false -> + mnesia:abort({has_no_disc, node()}) + end; + _ -> + ok + end. + create_ram_table(Tab, #cstruct{type=Type, storage_properties=Props}) -> EtsOpts = proplists:get_value(ets, Props, []), Args = [{keypos, 2}, public, named_table, Type | EtsOpts], @@ -2160,6 +2782,14 @@ create_disc_only_table(Tab, #cstruct{type=Type, storage_properties=Props}) -> mnesia:abort({system_limit, Tab, {Err,Reason}}) end. +create_external_table(Alias, Tab, Mod, Cs) -> + case mnesia_monitor:unsafe_create_external(Tab, Alias, Mod, Cs) of + ok -> + ok; + {error,Reason} -> + Err = "Failed to create external table", + mnesia:abort({system_limit, Tab, {Err,Reason}}) + end. receive_sync([], Pids) -> Pids; @@ -2294,7 +2924,10 @@ undo_prepare_op(Tid, {op, create_table, TabDef}) -> mnesia_monitor:unsafe_close_dets(Tab), Dat = mnesia_lib:tab2dat(Tab), %% disc_delete_table(Tab, Storage), - file:delete(Dat) + file:delete(Dat); + {ext, Alias, Mod} -> + Mod:close_table(Alias, Tab), + Mod:delete_table(Alias, Tab) end; undo_prepare_op(Tid, {op, add_table_copy, Storage, Node, TabDef}) -> @@ -2394,6 +3027,8 @@ ram_delete_table(Tab, Storage) -> case Storage of unknown -> ignore; + {ext, _, _} -> + ignore; disc_only_copies -> ignore; _Else -> @@ -2455,13 +3090,27 @@ purge_known_files([File | Tail], KeepFiles, Dir, Suffixes) -> ignore; true -> AbsFile = filename:join([Dir, File]), - file:delete(AbsFile) - end + delete_recursive(AbsFile) + end end, purge_known_files(Tail, KeepFiles, Dir, Suffixes); purge_known_files([], _KeepFiles, _Dir, _Suffixes) -> ok. +%% Removes a directory or file recursively +delete_recursive(Path) -> + case filelib:is_dir(Path) of + true -> + {ok, Names} = file:list_dir(Path), + lists:foreach(fun(Name) -> + delete_recursive(filename:join(Path, Name)) + end, + Names), + file:del_dir(Path); + false -> + file:delete(Path) + end. + has_known_suffix(_File, _Suffixes, true) -> true; has_known_suffix(File, [Suffix | Tail], false) -> @@ -2469,11 +3118,33 @@ has_known_suffix(File, [Suffix | Tail], false) -> has_known_suffix(_File, [], Bool) -> Bool. -known_suffixes() -> real_suffixes() ++ tmp_suffixes(). +known_suffixes() -> known_suffixes(get_ext_types_disc()). + +known_suffixes(Ext) -> real_suffixes(Ext) ++ tmp_suffixes(Ext). -real_suffixes() -> [".DAT", ".LOG", ".BUP", ".DCL", ".DCD"]. +real_suffixes(Ext) -> [".DAT", ".LOG", ".BUP", ".DCL", ".DCD"] ++ ext_real_suffixes(Ext). -tmp_suffixes() -> [".TMP", ".BUPTMP", ".RET", ".DMP"]. +tmp_suffixes() -> tmp_suffixes(get_ext_types_disc()). + +tmp_suffixes(Ext) -> [".TMP", ".BUPTMP", ".RET", ".DMP", "."] ++ ext_tmp_suffixes(Ext). + +ext_real_suffixes(Ext) -> + try lists:foldl(fun(Mod, Acc) -> Acc++Mod:real_suffixes() end, [], + [M || {_,M} <- Ext]) + catch + error:E -> + verbose("Cant find real ext suffixes (~p)~n", [E]), + [] + end. + +ext_tmp_suffixes(Ext) -> + try lists:foldl(fun(Mod, Acc) -> Acc++Mod:tmp_suffixes() end, [], + [M || {_,M} <- Ext]) + catch + error:E -> + verbose("Cant find tmp ext suffixes (~p)~n", [E]), + [] + end. info() -> Tabs = lists:sort(val({schema, tables})), @@ -2591,12 +3262,12 @@ do_restore(R, BupSchema) -> arrange_restore(R, Fun, Recs) -> R2 = R#r{insert_op = Fun, recs = Recs}, - case mnesia_bup:iterate(R#r.module, fun restore_items/4, R#r.opaque, R2) of + case mnesia_bup:iterate(R#r.module, fun restore_items/5, R#r.opaque, R2) of {ok, R3} -> R3#r.recs; {error, Reason} -> mnesia:abort(Reason) end. -restore_items([Rec | Recs], Header, Schema, R) -> +restore_items([Rec | Recs], Header, Schema, Ext, R) -> Tab = element(1, Rec), case lists:keysearch(Tab, 1, R#r.tables) of {value, {Tab, Where0, Snmp, RecName}} -> @@ -2609,13 +3280,13 @@ restore_items([Rec | Recs], Header, Schema, R) -> {Rest, NRecs} = restore_tab_items([Rec | Recs], Tab, RecName, Where, Snmp, R#r.recs, R#r.insert_op), - restore_items(Rest, Header, Schema, R#r{recs = NRecs}); + restore_items(Rest, Header, Schema, Ext, R#r{recs = NRecs}); false -> Rest = skip_tab_items(Recs, Tab), - restore_items(Rest, Header, Schema, R) + restore_items(Rest, Header, Schema, Ext, R) end; -restore_items([], _Header, _Schema, R) -> +restore_items([], _Header, _Schema, _Ext, R) -> R. restore_func(Tab, R) -> @@ -2629,8 +3300,14 @@ restore_func(Tab, R) -> where_to_commit(Tab, CsList) -> Ram = [{N, ram_copies} || N <- pick(Tab, ram_copies, CsList, [])], Disc = [{N, disc_copies} || N <- pick(Tab, disc_copies, CsList, [])], - DiscO = [{N, disc_only_copies} || N <- pick(Tab, disc_only_copies, CsList, [])], - Ram ++ Disc ++ DiscO. + DiscO = [{N, disc_only_copies} || + N <- pick(Tab, disc_only_copies, CsList, [])], + ExtNodes = [{Alias, Mod, pick(Tab, Alias, CsList, [])} || + {Alias, Mod} <- get_ext_types()], + Ext = lists:foldl(fun({Alias, Mod, Ns}, Acc) -> + [{N, {ext, Alias, Mod}} || N <- Ns] ++ Acc + end, [], ExtNodes), + Ram ++ Disc ++ DiscO ++ Ext. %% Changes of the Meta info of schema itself is not allowed restore_schema([{schema, schema, _List} | Schema], R) -> @@ -2709,7 +3386,13 @@ make_dump_tables([schema | _Tabs]) -> make_dump_tables([Tab | Tabs]) -> get_tid_ts_and_lock(Tab, read), TabDef = get_create_list(Tab), - DiscResident = val({Tab, disc_copies}) ++ val({Tab, disc_only_copies}), + DiscResident = + val({Tab, disc_copies}) ++ + val({Tab, disc_only_copies}) ++ + lists:concat([Ns || {{A,M},Ns} <- val({Tab, external_copies}), + lists:member( + mnesia_lib:semantics({ext,A,M},storage), + [disc_copies, disc_only_copies])]), verify([], DiscResident, {"Only allowed on ram_copies", Tab, DiscResident}), [{op, dump_table, unknown, TabDef} | make_dump_tables(Tabs)]; @@ -2721,7 +3404,9 @@ merge_schema() -> schema_transaction(fun() -> do_merge_schema([]) end). merge_schema(UserFun) -> - schema_transaction(fun() -> UserFun(fun(Arg) -> do_merge_schema(Arg) end) end). + schema_transaction(fun() -> + UserFun(fun(Arg) -> do_merge_schema(Arg) end) + end). do_merge_schema(LockTabs0) -> {_Mod, Tid, Ts} = get_tid_ts_and_lock(schema, write), @@ -2795,11 +3480,23 @@ do_merge_schema(LockTabs0) -> end. fetch_cstructs(Node) -> - rpc:call(Node, mnesia_controller, get_remote_cstructs, []). + Convert = mnesia_monitor:needs_protocol_conversion(Node), + case rpc:call(Node, mnesia_controller, get_remote_cstructs, []) of + {cstructs, Cs0, RemoteRunning1} when Convert -> + {cstructs, [list2cs(cs2list(Cs)) || Cs <- Cs0], RemoteRunning1}; + Result -> + Result + end. -need_old_cstructs() -> false. +need_old_cstructs() -> + need_old_cstructs(val({schema, where_to_write})). -need_old_cstructs(_Nodes) -> false. +need_old_cstructs(Nodes) -> + Filter = fun(Node) -> mnesia_monitor:needs_protocol_conversion(Node) end, + case lists:filter(Filter, Nodes) of + [] -> false; + Ns -> lists:min([element(1, ?catch_val({protocol, Node})) || Node <- Ns]) + end. tab_to_nodes(Tab) when is_atom(Tab) -> Cs = val({Tab, cstruct}), @@ -2952,8 +3649,8 @@ do_make_merge_schema(Node, NeedsConv, RemoteCs = #cstruct{}) -> %% invariants must be enforced in order to allow merge of cstructs. %% %% Returns a new cstruct or issues a fatal error -merge_cstructs(Cs, RemoteCs, Force) -> - verify_cstruct(Cs), +merge_cstructs(Cs0, RemoteCs, Force) -> + Cs = verify_cstruct(Cs0), try do_merge_cstructs(Cs, RemoteCs, Force) of MergedCs when is_record(MergedCs, cstruct) -> MergedCs @@ -2963,15 +3660,15 @@ merge_cstructs(Cs, RemoteCs, Force) -> error:Reason -> exit(Reason) end. -do_merge_cstructs(Cs, RemoteCs, Force) -> - verify_cstruct(RemoteCs), +do_merge_cstructs(Cs, RemoteCs0, Force) -> + RemoteCs = verify_cstruct(RemoteCs0), Ns = mnesia_lib:uniq(mnesia_lib:cs_to_nodes(Cs) ++ mnesia_lib:cs_to_nodes(RemoteCs)), {AnythingNew, MergedCs} = merge_storage_type(Ns, false, Cs, RemoteCs, Force), - MergedCs2 = merge_versions(AnythingNew, MergedCs, RemoteCs, Force), - verify_cstruct(MergedCs2), - MergedCs2. + verify_cstruct( + merge_versions(AnythingNew, MergedCs, RemoteCs, Force)). + merge_storage_type([N | Ns], AnythingNew, Cs, RemoteCs, Force) -> Local = mnesia_lib:cs_to_storage_type(N, Cs), @@ -3115,4 +3812,3 @@ unannounce_im_running([N | Ns]) -> unannounce_im_running(Ns); unannounce_im_running([]) -> ok. - diff --git a/lib/mnesia/src/mnesia_sup.erl b/lib/mnesia/src/mnesia_sup.erl index 5037a17ada..4aece81308 100644 --- a/lib/mnesia/src/mnesia_sup.erl +++ b/lib/mnesia/src/mnesia_sup.erl @@ -60,9 +60,10 @@ init() -> Flags = {one_for_all, 0, 3600}, % Should be rest_for_one policy Event = event_procs(), + Ext = ext_procs(), Kernel = kernel_procs(), - {ok, {Flags, Event ++ Kernel}}. + {ok, {Flags, Event ++ Ext ++ Kernel}}. event_procs() -> KillAfter = timer:seconds(30), @@ -75,6 +76,11 @@ kernel_procs() -> KA = infinity, [{K, {K, start, []}, permanent, KA, supervisor, [K, supervisor]}]. +ext_procs() -> + K = mnesia_ext_sup, + KA = infinity, + [{K, {K, start, []}, permanent, KA, supervisor, [K, supervisor]}]. + %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %% event handler diff --git a/lib/mnesia/src/mnesia_tm.erl b/lib/mnesia/src/mnesia_tm.erl index 6888f61dbd..b116b48312 100644 --- a/lib/mnesia/src/mnesia_tm.erl +++ b/lib/mnesia/src/mnesia_tm.erl @@ -42,7 +42,8 @@ put_activity_id/2, block_tab/1, unblock_tab/1, - fixtable/3 + fixtable/3, + new_cr_format/1 ]). %% sys callback functions @@ -206,10 +207,10 @@ doit_loop(#state{coordinators=Coordinators,participants=Participants,supervisor= {_From, {async_dirty, Tid, Commit, Tab}} -> case lists:member(Tab, State#state.blocked_tabs) of false -> - do_async_dirty(Tid, Commit, Tab), + do_async_dirty(Tid, new_cr_format(Commit), Tab), doit_loop(State); true -> - Item = {async_dirty, Tid, Commit, Tab}, + Item = {async_dirty, Tid, new_cr_format(Commit), Tab}, State2 = State#state{dirty_queue = [Item | State#state.dirty_queue]}, doit_loop(State2) end; @@ -217,10 +218,10 @@ doit_loop(#state{coordinators=Coordinators,participants=Participants,supervisor= {From, {sync_dirty, Tid, Commit, Tab}} -> case lists:member(Tab, State#state.blocked_tabs) of false -> - do_sync_dirty(From, Tid, Commit, Tab), + do_sync_dirty(From, Tid, new_cr_format(Commit), Tab), doit_loop(State); true -> - Item = {sync_dirty, From, Tid, Commit, Tab}, + Item = {sync_dirty, From, Tid, new_cr_format(Commit), Tab}, State2 = State#state{dirty_queue = [Item | State#state.dirty_queue]}, doit_loop(State2) end; @@ -241,10 +242,11 @@ doit_loop(#state{coordinators=Coordinators,participants=Participants,supervisor= reply(From, {error, {system_limit, Msg, Reason}}, State) end; - {From, {ask_commit, Protocol, Tid, Commit, DiscNs, RamNs}} -> + {From, {ask_commit, Protocol, Tid, Commit0, DiscNs, RamNs}} -> ?eval_debug_fun({?MODULE, doit_ask_commit}, [{tid, Tid}, {prot, Protocol}]), mnesia_checkpoint:tm_enter_pending(Tid, DiscNs, RamNs), + Commit = new_cr_format(Commit0), Pid = case Protocol of asym_trans when node(Tid#tid.pid) /= node() -> @@ -1137,14 +1139,14 @@ arrange(Tid, Store, Type) -> reverse([]) -> []; reverse([H=#commit{ram_copies=Ram, disc_copies=DC, - disc_only_copies=DOC,snmp = Snmp} + disc_only_copies=DOC, ext=Ext} |R]) -> [ H#commit{ - ram_copies = lists:reverse(Ram), - disc_copies = lists:reverse(DC), - disc_only_copies = lists:reverse(DOC), - snmp = lists:reverse(Snmp) + ram_copies = lists:reverse(Ram), + disc_copies = lists:reverse(DC), + disc_only_copies = lists:reverse(DOC), + ext = [{Type, lists:reverse(E)} || {Type,E} <- Ext] } | reverse(R)]. @@ -1311,8 +1313,13 @@ pick_node({dirty,_}, Node, [], Done) -> pick_node(_Tid, Node, [], _Done) -> mnesia:abort({bad_commit, {missing_lock, Node}}). -prepare_node(Node, Storage, [Item | Items], Rec, Kind) when Kind == snmp -> - Rec2 = Rec#commit{snmp = [Item | Rec#commit.snmp]}, +prepare_node(Node, Storage, [Item | Items], #commit{ext=Ext0}=Rec, Kind) when Kind == snmp -> + Rec2 = case lists:keytake(snmp, 1, Ext0) of + false -> + Rec#commit{ext = [{snmp,[Item]}|Ext0]}; + {_, {snmp,Snmp},Ext} -> + Rec#commit{ext = [{snmp,[Item|Snmp]}|Ext]} + end, prepare_node(Node, Storage, Items, Rec2, Kind); prepare_node(Node, Storage, [Item | Items], Rec, Kind) when Kind /= schema -> Rec2 = @@ -1323,7 +1330,15 @@ prepare_node(Node, Storage, [Item | Items], Rec, Kind) when Kind /= schema -> Rec#commit{disc_copies = [Item | Rec#commit.disc_copies]}; disc_only_copies -> Rec#commit{disc_only_copies = - [Item | Rec#commit.disc_only_copies]} + [Item | Rec#commit.disc_only_copies]}; + {ext, Alias, Mod} -> + Ext0 = Rec#commit.ext, + case lists:keytake(ext_copies, 1, Ext0) of + false -> + Rec#commit{ext = [{ext_copies, [{{ext,Alias,Mod}, Item}]}|Ext0]}; + {_,{_,EC},Ext} -> + Rec#commit{ext = [{ext_copies, [{{ext,Alias,Mod}, Item}|EC]}|Ext]} + end end, prepare_node(Node, Storage, Items, Rec2, Kind); prepare_node(_Node, _Storage, Items, Rec, Kind) @@ -1750,16 +1765,30 @@ do_commit(Tid, Bin) when is_binary(Bin) -> do_commit(Tid, binary_to_term(Bin)); do_commit(Tid, C) -> do_commit(Tid, C, optional). + do_commit(Tid, Bin, DumperMode) when is_binary(Bin) -> do_commit(Tid, binary_to_term(Bin), DumperMode); do_commit(Tid, C, DumperMode) -> mnesia_dumper:update(Tid, C#commit.schema_ops, DumperMode), - R = do_snmp(Tid, C#commit.snmp), + R = do_snmp(Tid, proplists:get_value(snmp, C#commit.ext, [])), R2 = do_update(Tid, ram_copies, C#commit.ram_copies, R), R3 = do_update(Tid, disc_copies, C#commit.disc_copies, R2), R4 = do_update(Tid, disc_only_copies, C#commit.disc_only_copies, R3), + R5 = do_update_ext(Tid, C#commit.ext, R4), mnesia_subscr:report_activity(Tid), - R4. + R5. + +%% This could/should be optimized +do_update_ext(_Tid, [], OldRes) -> OldRes; +do_update_ext(Tid, Ext, OldRes) -> + case lists:keyfind(ext_copies, 1, Ext) of + false -> OldRes; + {_, Ops} -> + Do = fun({{ext, _,_} = Storage, Op}, R) -> + do_update(Tid, Storage, [Op], R) + end, + lists:foldl(Do, OldRes, Ops) + end. %% Update the items do_update(Tid, Storage, [Op | Ops], OldRes) -> @@ -1782,12 +1811,12 @@ do_update(_Tid, _Storage, [], Res) -> Res. do_update_op(Tid, Storage, {{Tab, K}, Obj, write}) -> - commit_write(?catch_val({Tab, commit_work}), Tid, + commit_write(?catch_val({Tab, commit_work}), Tid, Storage, Tab, K, Obj, undefined), mnesia_lib:db_put(Storage, Tab, Obj); do_update_op(Tid, Storage, {{Tab, K}, Val, delete}) -> - commit_delete(?catch_val({Tab, commit_work}), Tid, Tab, K, Val, undefined), + commit_delete(?catch_val({Tab, commit_work}), Tid, Storage, Tab, K, Val, undefined), mnesia_lib:db_erase(Storage, Tab, K); do_update_op(Tid, Storage, {{Tab, K}, {RecName, Incr}, update_counter}) -> @@ -1805,86 +1834,84 @@ do_update_op(Tid, Storage, {{Tab, K}, {RecName, Incr}, update_counter}) -> mnesia_lib:db_put(Storage, Tab, Zero), {Zero, []} end, - commit_update(?catch_val({Tab, commit_work}), Tid, Tab, + commit_update(?catch_val({Tab, commit_work}), Tid, Storage, Tab, K, NewObj, OldObjs), element(3, NewObj); do_update_op(Tid, Storage, {{Tab, Key}, Obj, delete_object}) -> commit_del_object(?catch_val({Tab, commit_work}), - Tid, Tab, Key, Obj, undefined), + Tid, Storage, Tab, Key, Obj), mnesia_lib:db_match_erase(Storage, Tab, Obj); do_update_op(Tid, Storage, {{Tab, Key}, Obj, clear_table}) -> - commit_clear(?catch_val({Tab, commit_work}), Tid, Tab, Key, Obj), + commit_clear(?catch_val({Tab, commit_work}), Tid, Storage, Tab, Key, Obj), mnesia_lib:db_match_erase(Storage, Tab, Obj). -commit_write([], _, _, _, _, _) -> ok; -commit_write([{checkpoints, CpList}|R], Tid, Tab, K, Obj, Old) -> +commit_write([], _, _, _, _, _, _) -> ok; +commit_write([{checkpoints, CpList}|R], Tid, Storage, Tab, K, Obj, Old) -> mnesia_checkpoint:tm_retain(Tid, Tab, K, write, CpList), - commit_write(R, Tid, Tab, K, Obj, Old); -commit_write([H|R], Tid, Tab, K, Obj, Old) + commit_write(R, Tid, Storage, Tab, K, Obj, Old); +commit_write([H|R], Tid, Storage, Tab, K, Obj, Old) when element(1, H) == subscribers -> mnesia_subscr:report_table_event(H, Tab, Tid, Obj, write, Old), - commit_write(R, Tid, Tab, K, Obj, Old); -commit_write([H|R], Tid, Tab, K, Obj, Old) + commit_write(R, Tid, Storage, Tab, K, Obj, Old); +commit_write([H|R], Tid, Storage, Tab, K, Obj, Old) when element(1, H) == index -> - mnesia_index:add_index(H, Tab, K, Obj, Old), - commit_write(R, Tid, Tab, K, Obj, Old). + mnesia_index:add_index(H, Storage, Tab, K, Obj, Old), + commit_write(R, Tid, Storage, Tab, K, Obj, Old). -commit_update([], _, _, _, _, _) -> ok; -commit_update([{checkpoints, CpList}|R], Tid, Tab, K, Obj, _) -> +commit_update([], _, _, _, _, _, _) -> ok; +commit_update([{checkpoints, CpList}|R], Tid, Storage, Tab, K, Obj, _) -> Old = mnesia_checkpoint:tm_retain(Tid, Tab, K, write, CpList), - commit_update(R, Tid, Tab, K, Obj, Old); -commit_update([H|R], Tid, Tab, K, Obj, Old) + commit_update(R, Tid, Storage, Tab, K, Obj, Old); +commit_update([H|R], Tid, Storage, Tab, K, Obj, Old) when element(1, H) == subscribers -> mnesia_subscr:report_table_event(H, Tab, Tid, Obj, write, Old), - commit_update(R, Tid, Tab, K, Obj, Old); -commit_update([H|R], Tid, Tab, K, Obj, Old) + commit_update(R, Tid, Storage, Tab, K, Obj, Old); +commit_update([H|R], Tid,Storage, Tab, K, Obj, Old) when element(1, H) == index -> - mnesia_index:add_index(H, Tab, K, Obj, Old), - commit_update(R, Tid, Tab, K, Obj, Old). + mnesia_index:add_index(H, Storage, Tab, K, Obj, Old), + commit_update(R, Tid, Storage, Tab, K, Obj, Old). -commit_delete([], _, _, _, _, _) -> ok; -commit_delete([{checkpoints, CpList}|R], Tid, Tab, K, Obj, _) -> +commit_delete([], _, _, _, _, _, _) -> ok; +commit_delete([{checkpoints, CpList}|R], Tid, Storage, Tab, K, Obj, _) -> Old = mnesia_checkpoint:tm_retain(Tid, Tab, K, delete, CpList), - commit_delete(R, Tid, Tab, K, Obj, Old); -commit_delete([H|R], Tid, Tab, K, Obj, Old) + commit_delete(R, Tid, Storage, Tab, K, Obj, Old); +commit_delete([H|R], Tid, Storage, Tab, K, Obj, Old) when element(1, H) == subscribers -> mnesia_subscr:report_table_event(H, Tab, Tid, Obj, delete, Old), - commit_delete(R, Tid, Tab, K, Obj, Old); -commit_delete([H|R], Tid, Tab, K, Obj, Old) + commit_delete(R, Tid, Storage, Tab, K, Obj, Old); +commit_delete([H|R], Tid, Storage, Tab, K, Obj, Old) when element(1, H) == index -> - mnesia_index:delete_index(H, Tab, K), - commit_delete(R, Tid, Tab, K, Obj, Old). + mnesia_index:delete_index(H, Storage, Tab, K), + commit_delete(R, Tid, Storage, Tab, K, Obj, Old). commit_del_object([], _, _, _, _, _) -> ok; -commit_del_object([{checkpoints, CpList}|R], Tid, Tab, K, Obj, _) -> - Old = mnesia_checkpoint:tm_retain(Tid, Tab, K, delete_object, CpList), - commit_del_object(R, Tid, Tab, K, Obj, Old); -commit_del_object([H|R], Tid, Tab, K, Obj, Old) - when element(1, H) == subscribers -> - mnesia_subscr:report_table_event(H, Tab, Tid, Obj, delete_object, Old), - commit_del_object(R, Tid, Tab, K, Obj, Old); -commit_del_object([H|R], Tid, Tab, K, Obj, Old) - when element(1, H) == index -> - mnesia_index:del_object_index(H, Tab, K, Obj, Old), - commit_del_object(R, Tid, Tab, K, Obj, Old). - -commit_clear([], _, _, _, _) -> ok; -commit_clear([{checkpoints, CpList}|R], Tid, Tab, K, Obj) -> +commit_del_object([{checkpoints, CpList}|R], Tid, Storage, Tab, K, Obj) -> + mnesia_checkpoint:tm_retain(Tid, Tab, K, delete_object, CpList), + commit_del_object(R, Tid, Storage, Tab, K, Obj); +commit_del_object([H|R], Tid, Storage, Tab, K, Obj) when element(1, H) == subscribers -> + mnesia_subscr:report_table_event(H, Tab, Tid, Obj, delete_object), + commit_del_object(R, Tid, Storage, Tab, K, Obj); +commit_del_object([H|R], Tid, Storage, Tab, K, Obj) when element(1, H) == index -> + mnesia_index:del_object_index(H, Storage, Tab, K, Obj), + commit_del_object(R, Tid, Storage, Tab, K, Obj). + +commit_clear([], _, _, _, _, _) -> ok; +commit_clear([{checkpoints, CpList}|R], Tid, Storage, Tab, K, Obj) -> mnesia_checkpoint:tm_retain(Tid, Tab, K, clear_table, CpList), - commit_clear(R, Tid, Tab, K, Obj); -commit_clear([H|R], Tid, Tab, K, Obj) + commit_clear(R, Tid, Storage, Tab, K, Obj); +commit_clear([H|R], Tid, Storage, Tab, K, Obj) when element(1, H) == subscribers -> mnesia_subscr:report_table_event(H, Tab, Tid, Obj, clear_table, undefined), - commit_clear(R, Tid, Tab, K, Obj); -commit_clear([H|R], Tid, Tab, K, Obj) + commit_clear(R, Tid, Storage, Tab, K, Obj); +commit_clear([H|R], Tid, Storage, Tab, K, Obj) when element(1, H) == index -> mnesia_index:clear_index(H, Tab, K, Obj), - commit_clear(R, Tid, Tab, K, Obj). + commit_clear(R, Tid, Storage, Tab, K, Obj). do_snmp(_, []) -> ok; -do_snmp(Tid, [Head | Tail]) -> +do_snmp(Tid, [Head|Tail]) -> try mnesia_snmp_hook:update(Head) catch _:Reason -> %% This should only happen when we recently have @@ -1896,31 +1923,34 @@ do_snmp(Tid, [Head | Tail]) -> end, do_snmp(Tid, Tail). -commit_nodes([C | Tail], AccD, AccR) - when C#commit.disc_copies == [], - C#commit.disc_only_copies == [], - C#commit.schema_ops == [] -> - commit_nodes(Tail, AccD, [C#commit.node | AccR]); commit_nodes([C | Tail], AccD, AccR) -> - commit_nodes(Tail, [C#commit.node | AccD], AccR); + case C of + #commit{disc_copies=[], disc_only_copies=[], schema_ops=[], ext=Ext} -> + case lists:keyfind(ext_copies, 1, Ext) of + false -> commit_nodes(Tail, AccD, [C#commit.node | AccR]); + _ -> commit_nodes(Tail, [C#commit.node | AccD], AccR) + end; + _ -> + commit_nodes(Tail, [C#commit.node | AccD], AccR) + end; commit_nodes([], AccD, AccR) -> {AccD, AccR}. commit_decision(D, [C | Tail], AccD, AccR) -> N = C#commit.node, {D2, Tail2} = - case C#commit.schema_ops of - [] when C#commit.disc_copies == [], - C#commit.disc_only_copies == [] -> - commit_decision(D, Tail, AccD, [N | AccR]); - [] -> + case C of + #commit{disc_copies=[], disc_only_copies=[], schema_ops=[], ext=Ext} -> + case lists:keyfind(ext_copies, 1, Ext) of + false -> commit_decision(D, Tail, AccD, [N | AccR]); + _ -> commit_decision(D, Tail, [N | AccD], AccR) + end; + #commit{schema_ops=[]} -> commit_decision(D, Tail, [N | AccD], AccR); - Ops -> + #commit{schema_ops=Ops} -> case ram_only_ops(N, Ops) of - true -> - commit_decision(D, Tail, AccD, [N | AccR]); - false -> - commit_decision(D, Tail, [N | AccD], AccR) + true -> commit_decision(D, Tail, AccD, [N | AccR]); + false -> commit_decision(D, Tail, [N | AccD], AccR) end end, {D2, [C#commit{decision = D2} | Tail2]}; @@ -1948,7 +1978,7 @@ sync_send_dirty(Tid, [Head | Tail], Tab, WaitFor) -> Res = do_dirty(Tid, Head), {WF, Res}; true -> - {?MODULE, Node} ! {self(), {sync_dirty, Tid, Head, Tab}}, + {?MODULE, Node} ! {self(), {sync_dirty, Tid, ext_format(Head), Tab}}, sync_send_dirty(Tid, Tail, Tab, [Node | WaitFor]) end; sync_send_dirty(_Tid, [], _Tab, WaitFor) -> @@ -1967,11 +1997,11 @@ async_send_dirty(Tid, [Head | Tail], Tab, ReadNode, WaitFor, Res) -> NewRes = do_dirty(Tid, Head), async_send_dirty(Tid, Tail, Tab, ReadNode, WaitFor, NewRes); ReadNode == Node -> - {?MODULE, Node} ! {self(), {sync_dirty, Tid, Head, Tab}}, + {?MODULE, Node} ! {self(), {sync_dirty, Tid, ext_format(Head), Tab}}, NewRes = {'EXIT', {aborted, {node_not_running, Node}}}, async_send_dirty(Tid, Tail, Tab, ReadNode, [Node | WaitFor], NewRes); true -> - {?MODULE, Node} ! {self(), {async_dirty, Tid, Head, Tab}}, + {?MODULE, Node} ! {self(), {async_dirty, Tid, ext_format(Head), Tab}}, async_send_dirty(Tid, Tail, Tab, ReadNode, WaitFor, Res) end; async_send_dirty(_Tid, [], _Tab, _ReadNode, WaitFor, Res) -> @@ -2028,23 +2058,29 @@ ask_commit(Protocol, Tid, [Head | Tail], DiscNs, RamNs, WaitFor, Local) -> Node == node() -> ask_commit(Protocol, Tid, Tail, DiscNs, RamNs, WaitFor, Head); true -> - Bin = opt_term_to_binary(Protocol, Head, DiscNs++RamNs), - Msg = {ask_commit, Protocol, Tid, Bin, DiscNs, RamNs}, + CR = ext_format(Head), + Msg = {ask_commit, Protocol, Tid, CR, DiscNs, RamNs}, {?MODULE, Node} ! {self(), Msg}, ask_commit(Protocol, Tid, Tail, DiscNs, RamNs, [Node | WaitFor], Local) end; ask_commit(_Protocol, _Tid, [], _DiscNs, _RamNs, WaitFor, Local) -> {WaitFor, Local}. -%% This used to test protocol conversion between mnesia-nodes -%% but it is really dependent on the emulator version on the -%% two nodes (if funs are sent which they are in transform table op). -%% to be safe we let erts do the translation (many times maybe and thus -%% slower but it works. -% opt_term_to_binary(asym_trans, Head, Nodes) -> -% opt_term_to_binary(Nodes, Head); -opt_term_to_binary(_Protocol, Head, _Nodes) -> - Head. +ext_format(#commit{ext=[]}=CR) -> CR; +ext_format(#commit{node=Node, ext=Ext}=CR) -> + case mnesia_monitor:needs_protocol_conversion(Node) of + true -> + case lists:keyfind(snmp, 1, Ext) of + false -> CR#commit{ext=[]}; + {snmp, List} -> CR#commit{ext=List} + end; + false -> CR + end. + +new_cr_format(#commit{ext=[]}=Cr) -> Cr; +new_cr_format(#commit{ext=[{_,_}|_]}=Cr) -> Cr; +new_cr_format(#commit{ext=Snmp}=Cr) -> + Cr#commit{ext=[{snmp,Snmp}]}. rec_all([Node | Tail], Tid, Res, Pids) -> receive diff --git a/lib/mnesia/test/Makefile b/lib/mnesia/test/Makefile index f0efbe6375..5b61b1af65 100644 --- a/lib/mnesia/test/Makefile +++ b/lib/mnesia/test/Makefile @@ -52,7 +52,8 @@ MODULES= \ mnesia_schema_recovery_test \ mnesia_measure_test \ mnesia_cost \ - mnesia_dbn_meters + mnesia_dbn_meters \ + ext_test DocExamplesDir := ../doc/src/ diff --git a/lib/mnesia/test/ext_test.erl b/lib/mnesia/test/ext_test.erl new file mode 100644 index 0000000000..45ddb148bc --- /dev/null +++ b/lib/mnesia/test/ext_test.erl @@ -0,0 +1,237 @@ +%% +%% %CopyrightBegin% +%% +%% Copyright Ericsson AB 1996-2014. All Rights Reserved. +%% +%% Licensed under the Apache License, Version 2.0 (the "License"); +%% you may not use this file except in compliance with the License. +%% You may obtain a copy of the License at +%% +%% http://www.apache.org/licenses/LICENSE-2.0 +%% +%% Unless required by applicable law or agreed to in writing, software +%% distributed under the License is distributed on an "AS IS" BASIS, +%% WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +%% See the License for the specific language governing permissions and +%% limitations under the License. +%% +%% %CopyrightEnd% +%% + +-module(ext_test). + +%% Initializations +-export([init_backend/0, add_aliases/1, remove_aliases/1, + check_definition/4, semantics/2]). + +-export([ + create_table/3, load_table/4, + delete_table/2, close_table/2, sync_close_table/2, + + sender_init/4, + receiver_first_message/4, receive_data/5, receive_done/4, + + index_is_consistent/3, is_index_consistent/2, + + real_suffixes/0, tmp_suffixes/0, + + info/3, + fixtable/3, + validate_key/6, validate_record/6, + + first/2, last/2, next/3, prev/3, slot/3, + + insert/3, update_counter/4, + lookup/3, + delete/3, match_delete/3, + select/1, select/3, select/4, repair_continuation/2 + ]). + +-ifdef(DEBUG). +-define(DBG(DATA), io:format("~p:~p: ~p~n",[?MODULE, ?LINE, DATA])). +-define(DBG(FORMAT, ARGS), io:format("~p:~p: " ++ FORMAT,[?MODULE, ?LINE] ++ ARGS)). +-else. +-define(DBG(DATA), ok). +-define(DBG(FORMAT, ARGS), ok). +-endif. + +%% types() -> +%% [{fs_copies, ?MODULE}, +%% {raw_fs_copies, ?MODULE}]. + +semantics(ext_ets, storage) -> ram_copies; +semantics(ext_ets, types ) -> [set, ordered_set, bag]; +semantics(ext_ets, index_types) -> [ordered]; +semantics(_Alias, _) -> + undefined. + +%% valid_op(_, _) -> +%% true. + +init_backend() -> + ?DBG(init_backend), + ok. + +add_aliases(_As) -> + ?DBG(_As), + ok. + +remove_aliases(_) -> + ok. + + +%% Table operations + +check_definition(ext_ets, _Tab, _Nodes, _Props) -> + ?DBG("~p ~p ~p~n", [_Tab, _Nodes, _Props]), + ok. + +create_table(ext_ets, Tab, Props) when is_atom(Tab) -> + Tid = ets:new(Tab, [public, proplists:get_value(type, Props, set), {keypos, 2}]), + ?DBG("~p Create: ~p(~p) ~p~n", [self(), Tab, Tid, Props]), + mnesia_lib:set({?MODULE, Tab}, Tid), + ok; +create_table(_, Tag={Tab, index, {_Where, Type0}}, _Opts) -> + Type = case Type0 of + ordered -> ordered_set; + _ -> Type0 + end, + Tid = ets:new(Tab, [public, Type]), + ?DBG("~p(~p) ~p~n", [Tab, Tid, Tag]), + mnesia_lib:set({?MODULE, Tag}, Tid), + ok; +create_table(_, Tag={_Tab, retainer, ChkPName}, _Opts) -> + Tid = ets:new(ChkPName, [set, public, {keypos, 2}]), + ?DBG("~p(~p) ~p~n", [_Tab, Tid, Tag]), + mnesia_lib:set({?MODULE, Tag}, Tid), + ok. + +delete_table(ext_ets, Tab) -> + try + ets:delete(mnesia_lib:val({?MODULE,Tab})), + mnesia_lib:unset({?MODULE,Tab}), + ok + catch _:_ -> + ?DBG({double_delete, Tab}), + ok + end. + +load_table(ext_ets, _Tab, init_index, _Cs) -> ok; +load_table(ext_ets, _Tab, _LoadReason, _Cs) -> + ?DBG("Load ~p ~p~n", [_Tab, _LoadReason]), + ok. +%% mnesia_monitor:unsafe_create_external(Tab, ext_ets, ?MODULE, Cs). + +sender_init(Alias, Tab, _RemoteStorage, _Pid) -> + KeysPerTransfer = 100, + {standard, + fun() -> mnesia_lib:db_init_chunk({ext,Alias,?MODULE}, Tab, KeysPerTransfer) end, + fun(Cont) -> mnesia_lib:db_chunk({ext,Alias,?MODULE}, Cont) end}. + +receiver_first_message(Sender, {first, Size}, _Alias, Tab) -> + ?DBG({first,Size}), + {Size, {Tab, Sender}}. + +receive_data(Data, ext_ets, Name, _Sender, {Name, Tab, _Sender}=State) -> + ?DBG({Data,State}), + true = ets:insert(Tab, Data), + {more, State}; +receive_data(Data, Alias, Tab, Sender, {Name, Sender}) -> + receive_data(Data, Alias, Tab, Sender, {Name, mnesia_lib:val({?MODULE,Tab}), Sender}). + +receive_done(_Alias, _Tab, _Sender, _State) -> + ?DBG({done,_State}), + ok. + +close_table(Alias, Tab) -> sync_close_table(Alias, Tab). + +sync_close_table(ext_ets, _Tab) -> + ?DBG(_Tab). + +fixtable(ext_ets, Tab, Bool) -> + ?DBG({Tab,Bool}), + ets:safe_fixtable(mnesia_lib:val({?MODULE,Tab}), Bool). + +info(ext_ets, Tab, Type) -> + ?DBG({Tab,Type}), + Tid = mnesia_lib:val({?MODULE,Tab}), + try ets:info(Tid, Type) of + Val -> Val + catch _:_ -> + undefined + end. + +real_suffixes() -> + [".dat"]. + +tmp_suffixes() -> + []. + +%% Index + +index_is_consistent(_Alias, _Ix, _Bool) -> ok. % Ignore for now +is_index_consistent(_Alias, _Ix) -> false. % Always rebuild + +%% Record operations + +validate_record(_Alias, _Tab, RecName, Arity, Type, _Obj) -> + {RecName, Arity, Type}. + +validate_key(_Alias, _Tab, RecName, Arity, Type, _Key) -> + {RecName, Arity, Type}. + +insert(ext_ets, Tab, Obj) -> + ?DBG({Tab,Obj}), + try + ets:insert(mnesia_lib:val({?MODULE,Tab}), Obj), + ok + catch _:Reason -> + io:format("CRASH ~p ~p~n",[Reason, mnesia_lib:val({?MODULE,Tab})]) + end. + +lookup(ext_ets, Tab, Key) -> + ets:lookup(mnesia_lib:val({?MODULE,Tab}), Key). + +delete(ext_ets, Tab, Key) -> + ets:delete(mnesia_lib:val({?MODULE,Tab}), Key). + +match_delete(ext_ets, Tab, Pat) -> + ets:match_delete(mnesia_lib:val({?MODULE,Tab}), Pat). + +first(ext_ets, Tab) -> + ets:first(mnesia_lib:val({?MODULE,Tab})). + +last(Alias, Tab) -> first(Alias, Tab). + +next(ext_ets, Tab, Key) -> + ets:next(mnesia_lib:val({?MODULE,Tab}), Key). + +prev(Alias, Tab, Key) -> + next(Alias, Tab, Key). + +slot(ext_ets, Tab, Pos) -> + ets:slot(mnesia_lib:val({?MODULE,Tab}), Pos). + +update_counter(ext_ets, Tab, C, Val) -> + ets:update_counter(mnesia_lib:val({?MODULE,Tab}), C, Val). + +select('$end_of_table' = End) -> End; +select({ext_ets, C}) -> ets:select(C). + +select(Alias, Tab, Ms) -> + Res = select(Alias, Tab, Ms, 100000), + select_1(Res). + +select_1('$end_of_table') -> []; +select_1({Acc, C}) -> + case ets:select(C) of + '$end_of_table' -> Acc; + {New, Cont} -> + select_1({New ++ Acc, Cont}) + end. + +select(ext_ets, Tab, Ms, Limit) when is_integer(Limit); Limit =:= infinity -> + ets:select(mnesia_lib:val({?MODULE,Tab}), Ms, Limit). + +repair_continuation({Alias, Cont}, Ms) -> + {Alias, ets:repair_continuation(Cont, Ms)}. diff --git a/lib/mnesia/test/mnesia_config_test.erl b/lib/mnesia/test/mnesia_config_test.erl index 204b8fa394..45da909264 100644 --- a/lib/mnesia/test/mnesia_config_test.erl +++ b/lib/mnesia/test/mnesia_config_test.erl @@ -1100,8 +1100,8 @@ dynamic_basic(Config) when is_list(Config) -> ?match(ok, mnesia:dirty_write({tab1, 1, 1})), ?match(ok, mnesia:dirty_write({tab2, 1, 1})), - - ?match(ok, rpc:call(N2, mnesia, start, [[{extra_db_nodes, [N1]}]])), + + ?match(ok, rpc:call(N2, mnesia, start, [[{extra_db_nodes, [N1]}, {schema, ?BACKEND}]])), ?match(ok, rpc:call(N2, mnesia, wait_for_tables, [[tab1,tab2],5000])), io:format("Here ~p ~n",[?LINE]), check_storage(N2, N1, [N3]), @@ -1112,7 +1112,7 @@ dynamic_basic(Config) when is_list(Config) -> ?match(ok, mnesia:delete_schema([N3])), io:format("T1 ~p ~n",[rpc:call(N3,?MODULE,c_nodes,[])]), - ?match(ok, rpc:call(N3, mnesia, start, [])), + ?match(ok, rpc:call(N3, mnesia, start, [[{schema, ?BACKEND}]])), io:format("T2 ~p ~n",[rpc:call(N3,?MODULE,c_nodes,[])]), timer:sleep(2000), io:format("T3 ~p ~n",[rpc:call(N3,?MODULE,c_nodes,[])]), @@ -1127,7 +1127,7 @@ dynamic_basic(Config) when is_list(Config) -> ?match([], mnesia_test_lib:kill_mnesia([N3])), ?match(ok, mnesia:delete_schema([N3])), - ?match(ok, rpc:call(N3, mnesia, start, [])), + ?match(ok, rpc:call(N3, mnesia, start, [[{schema, ?BACKEND}]])), ?match({ok, [N3]}, sort(?rpc_connect(N1, [N3]))), ?match(ok, rpc:call(N3, mnesia, wait_for_tables, [[tab1,tab2],5000])), io:format("Here ~p ~n",[?LINE]), @@ -1143,7 +1143,7 @@ dynamic_basic(Config) when is_list(Config) -> % mnesia should come up now. ?match({atomic, ok}, mnesia:add_table_copy(tab1, N2, ram_copies)), - ?match(ok, rpc:call(N2, mnesia, start, [])), + ?match(ok, rpc:call(N2, mnesia, start, [[{schema, ?BACKEND}]])), ?match({ok, _}, sort(?rpc_connect(N2, [N3]))), ?match(SNs, sort(rpc:call(N1, mnesia, system_info, [running_db_nodes]))), @@ -1162,7 +1162,7 @@ dynamic_basic(Config) when is_list(Config) -> ?match([N3,N1], sort(rpc:call(N1, mnesia, system_info, [running_db_nodes]))), ?match([N3,N1], sort(rpc:call(N3, mnesia, system_info, [running_db_nodes]))), - ?match(ok, rpc:call(N2, mnesia, start, [])), + ?match(ok, rpc:call(N2, mnesia, start, [[{schema, ?BACKEND}]])), ?match({ok, _}, sort(?rpc_connect(N3, [N2]))), ?match(SNs, sort(rpc:call(N1, mnesia, system_info, [running_db_nodes]))), @@ -1192,7 +1192,7 @@ dynamic_ext(Config) when is_list(Config) -> mnesia_test_lib:kill_mnesia([N2]), ?match(ok, mnesia:delete_schema([N2])), - ?match(ok, rpc:call(N2, mnesia, start, [[{extra_db_nodes, [N1]}]])), + ?match(ok, rpc:call(N2, mnesia, start, [[{extra_db_nodes, [N1]}, {schema, ?BACKEND}]])), ?match(SNs, sort(rpc:call(N1, mnesia, system_info, [running_db_nodes]))), ?match(SNs, sort(rpc:call(N2, mnesia, system_info, [running_db_nodes]))), @@ -1213,7 +1213,7 @@ dynamic_ext(Config) when is_list(Config) -> ?match(ok, mnesia:dirty_write({tab3, 42, T})), ?match(stopped, rpc:call(N2, mnesia, stop, [])), - ?match(ok, rpc:call(N2, mnesia, start, [])), + ?match(ok, rpc:call(N2, mnesia, start, [[{schema, ?BACKEND}]])), ?match(SNs, sort(rpc:call(N2, mnesia, system_info, [running_db_nodes]))), ?match(ok, mnesia:wait_for_tables([tab0,tab1,tab2,tab3], 10000)), ?match(ok, rpc:call(N2, mnesia, wait_for_tables, [[tab1,tab2,tab3], 100])), @@ -1226,7 +1226,7 @@ dynamic_ext(Config) when is_list(Config) -> ?match(stopped, rpc:call(N1, mnesia, stop, [])), - ?match(ok, rpc:call(N2, mnesia, start, [[{extra_db_nodes,[N1,N2]}]])), + ?match(ok, rpc:call(N2, mnesia, start, [[{extra_db_nodes,[N1,N2]}, {schema, ?BACKEND}]])), ?match({timeout,[tab0]}, rpc:call(N2, mnesia, wait_for_tables, [[tab0], 500])), ?match(ok, rpc:call(N1, mnesia, start, [[{extra_db_nodes, [N1,N2]}]])), @@ -1238,7 +1238,7 @@ dynamic_ext(Config) when is_list(Config) -> ?match(stopped, rpc:call(N1, mnesia, stop, [])), mnesia_test_lib:kill_mnesia([N2]), ?match(ok, mnesia:delete_schema([N2])), - ?match(ok, rpc:call(N1, mnesia, start, [[{extra_db_nodes, [N1,N2]}]])), + ?match(ok, rpc:call(N1, mnesia, start, [[{extra_db_nodes, [N1,N2]}, {schema, ?BACKEND}]])), ?match({timeout,[tab0]}, rpc:call(N1, mnesia, wait_for_tables, [[tab0], 500])), ?match(ok, rpc:call(N2, mnesia, start, [[{extra_db_nodes,[N1,N2]}]])), diff --git a/lib/mnesia/test/mnesia_dirty_access_test.erl b/lib/mnesia/test/mnesia_dirty_access_test.erl index 88b3a215e1..c9df8ed353 100644 --- a/lib/mnesia/test/mnesia_dirty_access_test.erl +++ b/lib/mnesia/test/mnesia_dirty_access_test.erl @@ -40,43 +40,40 @@ all() -> groups() -> [{dirty_write, [], - [dirty_write_ram, dirty_write_disc, - dirty_write_disc_only]}, + [dirty_write_ram, dirty_write_disc, dirty_write_disc_only, + dirty_write_xets]}, {dirty_read, [], - [dirty_read_ram, dirty_read_disc, - dirty_read_disc_only]}, + [dirty_read_ram, dirty_read_disc, dirty_read_disc_only, dirty_read_xets]}, {dirty_update_counter, [], [dirty_update_counter_ram, dirty_update_counter_disc, - dirty_update_counter_disc_only]}, + dirty_update_counter_disc_only, dirty_update_counter_xets]}, {dirty_delete, [], [dirty_delete_ram, dirty_delete_disc, - dirty_delete_disc_only]}, + dirty_delete_disc_only, dirty_delete_xets]}, {dirty_delete_object, [], [dirty_delete_object_ram, dirty_delete_object_disc, - dirty_delete_object_disc_only]}, + dirty_delete_object_disc_only, dirty_delete_object_xets]}, {dirty_match_object, [], [dirty_match_object_ram, dirty_match_object_disc, - dirty_match_object_disc_only]}, + dirty_match_object_disc_only, dirty_match_object_xets]}, {dirty_index, [], [{group, dirty_index_match_object}, {group, dirty_index_read}, {group, dirty_index_update}]}, {dirty_index_match_object, [], - [dirty_index_match_object_ram, - dirty_index_match_object_disc, - dirty_index_match_object_disc_only]}, + [dirty_index_match_object_ram, dirty_index_match_object_disc, + dirty_index_match_object_disc_only, dirty_index_match_object_xets]}, {dirty_index_read, [], [dirty_index_read_ram, dirty_index_read_disc, - dirty_index_read_disc_only]}, + dirty_index_read_disc_only, dirty_index_read_xets]}, {dirty_index_update, [], - [dirty_index_update_set_ram, - dirty_index_update_set_disc, - dirty_index_update_set_disc_only, + [dirty_index_update_set_ram, dirty_index_update_set_disc, + dirty_index_update_set_disc_only, dirty_index_update_set_xets, dirty_index_update_bag_ram, dirty_index_update_bag_disc, - dirty_index_update_bag_disc_only]}, + dirty_index_update_bag_disc_only, dirty_index_update_bag_xets]}, {dirty_iter, [], - [dirty_iter_ram, dirty_iter_disc, - dirty_iter_disc_only]}, + [dirty_iter_ram, dirty_iter_disc, dirty_iter_disc_only, + dirty_iter_xets]}, {admin_tests, [], [del_table_copy_1, del_table_copy_2, del_table_copy_3, add_table_copy_1, add_table_copy_2, add_table_copy_3, @@ -106,6 +103,9 @@ dirty_write_disc_only(suite) -> []; dirty_write_disc_only(Config) when is_list(Config) -> dirty_write(Config, disc_only_copies). +dirty_write_xets(Config) when is_list(Config) -> + dirty_write(Config, ext_ets). + dirty_write(Config, Storage) -> [Node1] = Nodes = ?acquire_nodes(1, Config), Tab = dirty_write, @@ -137,6 +137,9 @@ dirty_read_disc_only(suite) -> []; dirty_read_disc_only(Config) when is_list(Config) -> dirty_read(Config, disc_only_copies). +dirty_read_xets(Config) when is_list(Config) -> + dirty_read(Config, ext_ets). + dirty_read(Config, Storage) -> [Node1] = Nodes = ?acquire_nodes(1, Config), Tab = dirty_read, @@ -180,6 +183,9 @@ dirty_update_counter_disc_only(suite) -> []; dirty_update_counter_disc_only(Config) when is_list(Config) -> dirty_update_counter(Config, disc_only_copies). +dirty_update_counter_xets(Config) when is_list(Config) -> + dirty_update_counter(Config, ext_ets). + dirty_update_counter(Config, Storage) -> [Node1] = Nodes = ?acquire_nodes(1, Config), Tab = dirty_update_counter, @@ -222,6 +228,9 @@ dirty_delete_disc_only(suite) -> []; dirty_delete_disc_only(Config) when is_list(Config) -> dirty_delete(Config, disc_only_copies). +dirty_delete_xets(Config) when is_list(Config) -> + dirty_delete(Config, ext_ets). + dirty_delete(Config, Storage) -> [Node1] = Nodes = ?acquire_nodes(1, Config), Tab = dirty_delete, @@ -259,6 +268,9 @@ dirty_delete_object_disc_only(suite) -> []; dirty_delete_object_disc_only(Config) when is_list(Config) -> dirty_delete_object(Config, disc_only_copies). +dirty_delete_object_xets(Config) when is_list(Config) -> + dirty_delete_object(Config, ext_ets). + dirty_delete_object(Config, Storage) -> [Node1] = Nodes = ?acquire_nodes(1, Config), Tab = dirty_delete_object, @@ -302,6 +314,9 @@ dirty_match_object_disc_only(suite) -> []; dirty_match_object_disc_only(Config) when is_list(Config) -> dirty_match_object(Config, disc_only_copies). +dirty_match_object_xets(Config) when is_list(Config) -> + dirty_match_object(Config, ext_ets). + dirty_match_object(Config, Storage) -> [Node1] = Nodes = ?acquire_nodes(1, Config), Tab = dirty_match, @@ -326,7 +341,6 @@ dirty_match_object(Config, Storage) -> %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %% Dirty read matching records by using an index - dirty_index_match_object_ram(suite) -> []; dirty_index_match_object_ram(Config) when is_list(Config) -> dirty_index_match_object(Config, ram_copies). @@ -339,6 +353,9 @@ dirty_index_match_object_disc_only(suite) -> []; dirty_index_match_object_disc_only(Config) when is_list(Config) -> dirty_index_match_object(Config, disc_only_copies). +dirty_index_match_object_xets(Config) when is_list(Config) -> + dirty_index_match_object(Config, ext_ets). + dirty_index_match_object(Config, Storage) -> [Node1] = Nodes = ?acquire_nodes(1, Config), Tab = dirty_index_match_object, @@ -376,6 +393,9 @@ dirty_index_read_disc_only(suite) -> []; dirty_index_read_disc_only(Config) when is_list(Config) -> dirty_index_read(Config, disc_only_copies). +dirty_index_read_xets(Config) when is_list(Config) -> + dirty_index_read(Config, ext_ets). + dirty_index_read(Config, Storage) -> [Node1] = Nodes = ?acquire_nodes(1, Config), Tab = dirty_index_read, @@ -437,6 +457,9 @@ dirty_index_update_set_disc_only(suite) -> []; dirty_index_update_set_disc_only(Config) when is_list(Config) -> dirty_index_update_set(Config, disc_only_copies). +dirty_index_update_set_xets(Config) when is_list(Config) -> + dirty_index_update_set(Config, ext_ets). + dirty_index_update_set(Config, Storage) -> [Node1] = Nodes = ?acquire_nodes(1, Config), Tab = index_test, @@ -525,6 +548,9 @@ dirty_index_update_bag_disc_only(suite) -> []; dirty_index_update_bag_disc_only(Config)when is_list(Config) -> dirty_index_update_bag(Config, disc_only_copies). +dirty_index_update_bag_xets(Config) when is_list(Config) -> + dirty_index_update_bag(Config, ext_ets). + dirty_index_update_bag(Config, Storage) -> [Node1] = Nodes = ?acquire_nodes(1, Config), Tab = index_test, @@ -631,7 +657,6 @@ dirty_index_update_bag(Config, Storage) -> %% Dirty iteration %% dirty_slot, dirty_first, dirty_next - dirty_iter_ram(suite) -> []; dirty_iter_ram(Config) when is_list(Config) -> dirty_iter(Config, ram_copies). @@ -644,6 +669,9 @@ dirty_iter_disc_only(suite) -> []; dirty_iter_disc_only(Config) when is_list(Config) -> dirty_iter(Config, disc_only_copies). +dirty_iter_xets(Config) when is_list(Config) -> + dirty_iter(Config, ext_ets). + dirty_iter(Config, Storage) -> [Node1] = Nodes = ?acquire_nodes(1, Config), Tab = dirty_iter, diff --git a/lib/mnesia/test/mnesia_evil_coverage_test.erl b/lib/mnesia/test/mnesia_evil_coverage_test.erl index 2ed62b1538..6e34040bc4 100644 --- a/lib/mnesia/test/mnesia_evil_coverage_test.erl +++ b/lib/mnesia/test/mnesia_evil_coverage_test.erl @@ -72,7 +72,9 @@ groups() -> {record_name_dirty_access, [], [record_name_dirty_access_ram, record_name_dirty_access_disc, - record_name_dirty_access_disc_only]}]. + record_name_dirty_access_disc_only, + record_name_dirty_access_xets + ]}]. init_per_group(_GroupName, Config) -> Config. @@ -112,6 +114,7 @@ system_info(Config) when is_list(Config) -> ?match(I when is_integer(I), mnesia:system_info(transaction_log_writes)), ?match(I when is_integer(I), mnesia:system_info(send_compressed)), ?match(L when is_list(L), mnesia:system_info(all)), + ?match(L when is_list(L), mnesia:system_info(backend_types)), ?match({'EXIT', {aborted, Reason }} when element(1, Reason) == badarg , mnesia:system_info(ali_baba)), ?verify_mnesia(Nodes, []). @@ -132,11 +135,11 @@ table_info(Config) when is_list(Config) -> Schema = case mnesia_test_lib:diskless(Config) of true -> [{type, Type}, {attributes, Attrs}, {index, [ValPos]}, - {ram_copies, Nodes}]; + {ram_copies, [Node1, Node2]}, {ext_ets, [Node3]}]; false -> [{type, Type}, {attributes, Attrs}, {index, [ValPos]}, - {disc_only_copies, [Node1]}, {ram_copies, [Node2]}, - {disc_copies, [Node3]}] + {disc_only_copies, [Node1]}, {ram_copies, [Node2]}, + {ext_ets, [Node3]}] end, ?match({atomic, ok}, mnesia:create_table(Tab, Schema)), @@ -144,28 +147,22 @@ table_info(Config) when is_list(Config) -> Keys = lists:seq(1, Size), Records = [{Tab, A, 7} || A <- Keys], lists:foreach(fun(Rec) -> ?match(ok, mnesia:dirty_write(Rec)) end, Records), - ?match(Mem when is_integer(Mem), mnesia:table_info(Tab, memory)), - ?match(Size, mnesia:table_info(Tab, size)), - ?match(Type, mnesia:table_info(Tab, type)), case mnesia_test_lib:diskless(Config) of true -> ?match(Nodes, mnesia:table_info(Tab, ram_copies)); false -> - ?match([Node3], mnesia:table_info(Tab, mnesia_test_lib:storage_type(disc_copies, Config))), + ?match([Node3], mnesia:table_info(Tab, ext_ets)), ?match([Node2], mnesia:table_info(Tab, ram_copies)), ?match([Node1], mnesia:table_info(Tab, mnesia_test_lib:storage_type(disc_only_copies, Config))) end, Read = [Node1, Node2, Node3], - ?match(true, lists:member(mnesia:table_info(Tab, where_to_read), Read)), Write = ?sort([Node1, Node2, Node3]), - ?match(Write, ?sort(mnesia:table_info(Tab, where_to_write))), - ?match([ValPos], mnesia:table_info(Tab, index)), - ?match(Arity, mnesia:table_info(Tab, arity)), - ?match(Attrs, mnesia:table_info(Tab, attributes)), - ?match({Tab, '_', '_'}, mnesia:table_info(Tab, wild_pattern)), - ?match({atomic, Attrs}, mnesia:transaction(fun() -> - mnesia:table_info(Tab, attributes) end)), + + {[ok,ok,ok], []} = rpc:multicall(Nodes, ?MODULE, info_check, + [Tab, Read, Write, Size, Type, ValPos, Arity, Attrs]), + + ?match({atomic, Attrs}, mnesia:transaction(fun() -> mnesia:table_info(Tab, attributes) end)), ?match(L when is_list(L), mnesia:table_info(Tab, all)), @@ -179,6 +176,17 @@ table_info(Config) when is_list(Config) -> ?match(0, mnesia:table_info(tab_info, size)), ?verify_mnesia([Node1, Node3], [Node2]). +info_check(Tab, Read, Write, Size, Type, ValPos, Arity, Attrs) -> + ?match(true, lists:member(mnesia:table_info(Tab, where_to_read), Read)), + ?match(Write, ?sort(mnesia:table_info(Tab, where_to_write))), + ?match(Mem when is_integer(Mem), mnesia:table_info(Tab, memory)), + ?match(Size, mnesia:table_info(Tab, size)), + ?match(Type, mnesia:table_info(Tab, type)), + ?match([ValPos], mnesia:table_info(Tab, index)), + ?match(Arity, mnesia:table_info(Tab, arity)), + ?match(Attrs, mnesia:table_info(Tab, attributes)), + ?match({Tab, '_', '_'}, mnesia:table_info(Tab, wild_pattern)), + ok. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %% Check the error descriptions @@ -216,11 +224,12 @@ db_node_lifecycle(Config) when is_list(Config) -> [Node1, Node2, Node3] = AllNodes = ?acquire_nodes(3, Config), Tab = db_node_lifecycle, - Who = fun(T) -> + Who = fun(T) -> L1 = mnesia:table_info(T, ram_copies), L2 = mnesia:table_info(T, disc_copies), L3 = mnesia:table_info(T, disc_only_copies), - L1 ++ L2 ++ L3 + L4 = mnesia:table_info(T, ext_ets), + L1 ++ L2 ++ L3 ++ L4 end, SNs = ?sort(AllNodes), @@ -235,6 +244,7 @@ db_node_lifecycle(Config) when is_list(Config) -> ?match({error, _}, mnesia:create_schema([foo@bar])), ?match(ok, mnesia:start()), ?match(false, mnesia:system_info(use_dir)), + ?match([ram_copies, disc_copies, disc_only_copies], mnesia:system_info(backend_types)), ?match({atomic, ok}, mnesia:create_table(Tab, [])), ?match({aborted, {has_no_disc, Node1}}, mnesia:dump_tables([Tab])), ?match({aborted, {has_no_disc, Node1}}, mnesia:change_table_copy_type(Tab, node(), disc_copies)), @@ -242,7 +252,7 @@ db_node_lifecycle(Config) when is_list(Config) -> ?match(stopped, mnesia:stop()), - ?match(ok, mnesia:create_schema(AllNodes)), + ?match(ok, mnesia:create_schema(AllNodes, ?BACKEND)), ?match([], mnesia_test_lib:start_mnesia(AllNodes)), ?match([SNs, SNs, SNs], @@ -271,12 +281,15 @@ db_node_lifecycle(Config) when is_list(Config) -> Tab3 = not_local, Tab4 = local, Tab5 = remote, + Tab6 = ext1, Tabs = [Schema, [{name, Tab2}, {disc_copies, AllNodes}], [{name, Tab3}, {ram_copies, [Node2, Node3]}], [{name, Tab4}, {disc_only_copies, [Node1]}], - [{name, Tab5}, {disc_only_copies, [Node2]}]], + [{name, Tab5}, {disc_only_copies, [Node2]}], + [{name, Tab6}, {ext_ets, [Node1, Node2]}] + ], [?match({atomic, ok}, mnesia:create_table(T)) || T <- Tabs ], @@ -287,31 +300,28 @@ db_node_lifecycle(Config) when is_list(Config) -> ?match({aborted, {node_not_running, Node1}}, mnesia:del_table_copy(schema, Node2)), - ?match([], mnesia_test_lib:start_mnesia([Node1],[Tab2,Tab4])), + ?match([], mnesia_test_lib:start_mnesia([Node1],[Tab2,Tab4,Tab6])), ?match([], mnesia_test_lib:stop_mnesia([Node2])), - ?match({atomic, ok}, - mnesia:del_table_copy(schema, Node2)), + ?match({atomic, ok}, mnesia:del_table_copy(schema, Node2)), - %% Check + %% Check RemNodes = AllNodes -- [Node2], - ?match(RemNodes, mnesia:system_info(db_nodes)), + ?match(RemNodes, mnesia:system_info(db_nodes)), ?match([Node1], Who(Tab)), ?match(RemNodes, Who(Tab2)), ?match([Node3], Who(Tab3)), ?match([Node1], Who(Tab4)), ?match({'EXIT', {aborted, {no_exists, _, _}}}, Who(Tab5)), + ?match([Node1], Who(Tab6)), - ?match({atomic, ok}, - mnesia:change_table_copy_type(Tab2, Node3, ram_copies)), + ?match({atomic, ok}, mnesia:change_table_copy_type(Tab2, Node3, ram_copies)), - ?match({atomic, ok}, - mnesia:change_table_copy_type(schema, Node3, ram_copies)), + ?match({atomic, ok}, mnesia:change_table_copy_type(schema, Node3, ram_copies)), ?match([], mnesia_test_lib:stop_mnesia([Node3])), - ?match({atomic, ok}, - mnesia:del_table_copy(schema, Node3)), - ?match([Node1], mnesia:system_info(db_nodes)), + ?match({atomic, ok}, mnesia:del_table_copy(schema, Node3)), + ?match([Node1], mnesia:system_info(db_nodes)), ?match([Node1], Who(Tab)), ?match([Node1], Who(Tab2)), ?match({'EXIT', {aborted, {no_exists, _, _}}}, Who(Tab3)), @@ -363,7 +373,8 @@ start_and_stop(Config) when is_list(Config) -> checkpoint(suite) -> []; checkpoint(Config) when is_list(Config) -> checkpoint(2, Config), - checkpoint(3, Config). + checkpoint(3, Config), + ok. checkpoint(NodeConfig, Config) -> [Node1 | _] = TabNodes = ?acquire_nodes(NodeConfig, Config), @@ -381,7 +392,7 @@ checkpoint(NodeConfig, Config) -> CreateTab(Type, 3, [lists:last(TabNodes)])] ++ Acc end, - Types = [ram_copies, disc_copies, disc_only_copies], + Types = [ram_copies, disc_copies, disc_only_copies, ext_ets], Tabs = lists:foldl(CreateTabs, [], Types), Recs = ?sort([{T, N, N} || T <- Tabs, N <- lists:seq(1, 10)]), lists:foreach(fun(R) -> ?match(ok, mnesia:dirty_write(R)) end, Recs), @@ -430,25 +441,29 @@ checkpoint(NodeConfig, Config) -> replica_location(suite) -> []; replica_location(Config) when is_list(Config) -> [Node1, Node2, Node3] = Nodes = ?acquire_nodes(3, Config), - Tab = replica_location, %% Create three replicas - Schema = [{name, Tab}, {disc_only_copies, [Node1]}, - {ram_copies, [Node2]}, {disc_copies, [Node3]}], - ?match({atomic, ok}, mnesia:create_table(Schema)), - ?match([], ?vrl(Tab, [Node1], [Node2], [Node3], Nodes)), + Check = fun(Tab, Schema) -> + ?match({atomic, ok}, mnesia:create_table([{name, Tab}|Schema])), + ?match([], ?vrl(Tab, [Node1], [Node2], [Node3], Nodes)), - %% Delete one replica - ?match({atomic, ok}, mnesia:del_table_copy(Tab, Node2)), - ?match([], ?vrl(Tab, [Node1], [], [Node3], Nodes)), + %% Delete one replica + ?match({atomic, ok}, mnesia:del_table_copy(Tab, Node2)), + ?match([], ?vrl(Tab, [Node1], [], [Node3], Nodes)), - %% Move one replica - ?match({atomic, ok}, mnesia:move_table_copy(Tab, Node1, Node2)), - ?match([], ?vrl(Tab, [Node2], [], [Node3], Nodes)), + %% Move one replica + ?match({atomic, ok}, mnesia:move_table_copy(Tab, Node1, Node2)), + ?match([], ?vrl(Tab, [Node2], [], [Node3], Nodes)), + + %% Change replica type + ?match({atomic, ok}, mnesia:change_table_copy_type(Tab, Node2, ram_copies)), + ?match([], ?vrl(Tab, [], [Node2], [Node3], Nodes)) + end, + Check(replica_location, [{disc_only_copies, [Node1]}, + {ram_copies, [Node2]}, {disc_copies, [Node3]}]), - %% Change replica type - ?match({atomic, ok}, mnesia:change_table_copy_type(Tab, Node2, ram_copies)), - ?match([], ?vrl(Tab, [], [Node2], [Node3], Nodes)), + Check(ext_location, [{disc_only_copies, [Node1]}, + {ext_ets, [Node2]}, {disc_copies, [Node3]}]), ?verify_mnesia(Nodes, []). @@ -720,7 +735,7 @@ replica_management(Config) when is_list(Config) -> %% ?match({atomic, ok}, mnesia:create_table([{name, Tab}, {attributes, Attrs}, - {ram_copies, [Node1, Node3]}])), + {ram_copies, [Node1]}, {ext_ets, [Node3]}])), [?match(ok, mnesia:dirty_write({Tab, K, K + 2})) || K <-lists:seq(1, 10)], ?match([], ?vrl(Tab, [], [Node1, Node3], [], Nodes)), %% R - - @@ -757,7 +772,7 @@ replica_management(Config) when is_list(Config) -> ?match([], ?vrl(Tab, [Node2], [], [Node1], Nodes)), ?match([0,10,10], ?SS(rpc:multicall(Nodes, mnesia, table_info, [Tab, size]))), %% D DO - - ?match({atomic, ok}, mnesia:add_table_copy(Tab, Node3, ram_copies)), + ?match({atomic, ok}, mnesia:add_table_copy(Tab, Node3, ext_ets)), ?match([], ?vrl(Tab, [Node2], [Node3], [Node1], Nodes)), ?match([10,10,10], ?SS(rpc:multicall(Nodes, mnesia, table_info, [Tab, size]))), %% D DO R @@ -784,7 +799,7 @@ replica_management(Config) when is_list(Config) -> ?match([10,10,10], ?SS(rpc:multicall(Nodes, mnesia, table_info, [Tab, size]))), %% D DO D0 - ?match({atomic, ok}, mnesia:change_table_copy_type(Tab, Node3, ram_copies)), + ?match({atomic, ok}, mnesia:change_table_copy_type(Tab, Node3, ext_ets)), ?match([], ?vrl(Tab, [Node2], [Node3], [Node1], Nodes)), ?match([10,10,10], ?SS(rpc:multicall(Nodes, mnesia, table_info, [Tab, size]))), %% D DO R @@ -841,18 +856,31 @@ replica_management(Config) when is_list(Config) -> ?match([], ?vrl(Tab, [Node3], [], [Node2], Nodes)), ?match([0,10,10], ?SS(rpc:multicall(Nodes, mnesia, table_info, [Tab, size]))), %% - D DO + ?match({atomic, ok}, mnesia:change_table_copy_type(Tab, Node3, ext_ets)), + ?match([], ?vrl(Tab, [], [Node3], [Node2], Nodes)), + ?match([0,10,10], ?SS(rpc:multicall(Nodes, mnesia, table_info, [Tab, size]))), + %% - D ER + ?match({atomic, ok}, mnesia:move_table_copy(Tab, Node3, Node1)), + ?match([], ?vrl(Tab, [], [Node1], [Node2], Nodes)), + ?match([0,10,10], ?SS(rpc:multicall(Nodes, mnesia, table_info, [Tab, size]))), + %% ER D - + ?match({aborted, _}, mnesia:move_table_copy(Tab, Node1, Node2)), + ?match({aborted, _}, mnesia:move_table_copy(Tab, Node3, Node2)), + ?match({atomic, ok}, mnesia:move_table_copy(Tab, Node1, Node3)), + %% - D ER ?match([], mnesia_test_lib:stop_mnesia([Node3])), ?match({atomic,ok}, mnesia:transaction(fun() -> mnesia:write({Tab, 43, sync_me}) end)), - ?match([], ?vrl(Tab, [Node3], [], [Node2],Nodes -- [Node3])), - %% - D DO + ?match([], ?vrl(Tab, [], [Node3], [Node2],Nodes -- [Node3])), + %% - D ER ?match({aborted,Reason56} when element(1, Reason56) == not_active, mnesia:move_table_copy(Tab, Node3, Node1)), - ?match([], ?vrl(Tab, [Node3], [], [Node2],Nodes -- [Node3])), - %% DO D - + ?match([], ?vrl(Tab, [], [Node3], [Node2],Nodes -- [Node3])), + %% - D ER ?match([], mnesia_test_lib:start_mnesia([Node3])), - ?match([], ?vrl(Tab, [Node3], [], [Node2], Nodes)), - %% DO D - + ?match([], ?vrl(Tab, [], [Node3], [Node2], Nodes)), + %% - D ER + ?match([{Tab,43,sync_me}], mnesia:dirty_read({Tab,43})), %% %% Transformer @@ -990,7 +1018,7 @@ local_content(Config) when is_list(Config) -> ?match([], mnesia_test_lib:stop_mnesia([Node3])), %% Added for OTP-44306 - ?match(ok, rpc:call(Node3, mnesia, start, [])), + ?match(ok, rpc:call(Node3, mnesia, start, [[{schema, ?BACKEND}]])), ?match({ok, _}, mnesia:change_config(extra_db_nodes, [Node3])), mnesia_test_lib:sync_tables([Node3], [Tab1]), @@ -1427,7 +1455,7 @@ unsupp_user_props(Config) when is_list(Config) -> table_info, [silly1, user_properties])), ?match([{prop,propval2}], rpc:call(Node1, mnesia, table_info, [silly2, user_properties])), - ?match([{prop,propval3}], rpc:call(Node1, mnesia, + ?match([_,{prop,propval3}], rpc:call(Node1, mnesia, table_info, [schema, user_properties])), F2 = fun() -> @@ -2262,6 +2290,10 @@ record_name_dirty_access_disc_only(suite) -> record_name_dirty_access_disc_only(Config) when is_list(Config) -> record_name_dirty_access(disc_only_copies, Config). +record_name_dirty_access_xets(Config) when is_list(Config) -> + record_name_dirty_access(ext_ets, Config). + + record_name_dirty_access(Storage, Config) -> [Node1, _Node2] = Nodes = ?acquire_nodes(2, Config), diff --git a/lib/mnesia/test/mnesia_recovery_test.erl b/lib/mnesia/test/mnesia_recovery_test.erl index cd581787fb..2388b595d0 100644 --- a/lib/mnesia/test/mnesia_recovery_test.erl +++ b/lib/mnesia/test/mnesia_recovery_test.erl @@ -576,7 +576,7 @@ delete_during_start(Config) when is_list(Config) -> mnesia_test_lib:kill_mnesia([N2,N3]), %% timer:sleep(500), ?match({[ok,ok],[]}, rpc:multicall([N2,N3], mnesia,start, - [[{extra_db_nodes,[N1]}]])), + [[{extra_db_nodes,[N1]}, {schema, ?BACKEND}]])), [Tab1,Tab2,Tab3|_] = Tabs, ?match({atomic, ok}, mnesia:delete_table(Tab1)), ?match({atomic, ok}, mnesia:delete_table(Tab2)), @@ -1542,7 +1542,7 @@ disc_less(Config) when is_list(Config) -> ?match(ok, rpc:call(Node2, mnesia, start, [])), timer:sleep(500), - ?match(ok, rpc:call(Node3, mnesia, start, [[{extra_db_nodes, [Node1, Node2]}]])), + ?match(ok, rpc:call(Node3, mnesia, start, [[{extra_db_nodes, [Node1, Node2]}, {schema, ?BACKEND}]])), ?match(ok, rpc:call(Node3, mnesia, wait_for_tables, [[Tab1, Tab2, Tab3], 20000])), ?match(ok, rpc:call(Node1, mnesia, wait_for_tables, [[Tab1, Tab2, Tab3], 20000])), diff --git a/lib/mnesia/test/mnesia_test_lib.erl b/lib/mnesia/test/mnesia_test_lib.erl index 616207ed1a..6e84a27ec9 100644 --- a/lib/mnesia/test/mnesia_test_lib.erl +++ b/lib/mnesia/test/mnesia_test_lib.erl @@ -142,6 +142,9 @@ %% included for test server compatibility %% assume that all test cases only takes Config as sole argument init_per_testcase(_Func, Config) -> + Env = application:get_all_env(mnesia), + [application:unset_env(mnesia, Key, [{timeout, infinity}]) || + {Key, _} <- Env, Key /= included_applications], global:register_name(mnesia_global_logger, group_leader()), Config. @@ -668,11 +671,13 @@ do_prepare([delete_schema | Actions], Selected, All, Config, File, Line) -> end, do_prepare(Actions, Selected, All, Config, File, Line); do_prepare([create_schema | Actions], Selected, All, Config, File, Line) -> + Ext = ?BACKEND, case diskless(Config) of true -> + rpc:multicall(Selected, application, set_env, [mnesia, schema, Ext]), skip; _Else -> - case mnesia:create_schema(Selected) of + case mnesia:create_schema(Selected, Ext) of ok -> ignore; BadNodes -> @@ -975,7 +980,6 @@ reload_appls([Appl | Appls], Selected) -> {Ok2temp, Empty} = rpc:multicall(Selected, application, unload, [Appl]), Conv = fun({error,{not_loaded,mnesia}}) -> ok; (Else) -> Else end, Ok2 = {lists:map(Conv, Ok2temp), Empty}, - Ok3 = rpc:multicall(Selected, application, load, [Appl]), if Ok /= Ok2 -> @@ -1040,7 +1044,8 @@ verify_replica_location(Tab, DiscOnly0, Ram0, Disc0, AliveNodes0) -> S1 = ?match(AliveNodes, lists:sort(mnesia:system_info(running_db_nodes))), S2 = ?match(DiscOnly, lists:sort(mnesia:table_info(Tab, disc_only_copies))), - S3 = ?match(Ram, lists:sort(mnesia:table_info(Tab, ram_copies))), + S3 = ?match(Ram, lists:sort(mnesia:table_info(Tab, ram_copies) ++ + mnesia:table_info(Tab, ext_ets))), S4 = ?match(Disc, lists:sort(mnesia:table_info(Tab, disc_copies))), S5 = ?match(Write, lists:sort(mnesia:table_info(Tab, where_to_write))), S6 = case lists:member(This, Read) of diff --git a/lib/mnesia/test/mnesia_test_lib.hrl b/lib/mnesia/test/mnesia_test_lib.hrl index 714ec7a491..ba7eb10ea2 100644 --- a/lib/mnesia/test/mnesia_test_lib.hrl +++ b/lib/mnesia/test/mnesia_test_lib.hrl @@ -150,3 +150,5 @@ -define(verify_mnesia(Ups, Downs), mnesia_test_lib:verify_mnesia(Ups, Downs, ?FILE, ?LINE)). + +-define(BACKEND, [{backend_types, [{ext_ets, ext_test},{ext_dets, ext_test}]}]). diff --git a/lib/mnesia/test/mnesia_trans_access_test.erl b/lib/mnesia/test/mnesia_trans_access_test.erl index 38fb8d6a77..aa50ee4cb1 100644 --- a/lib/mnesia/test/mnesia_trans_access_test.erl +++ b/lib/mnesia/test/mnesia_trans_access_test.erl @@ -931,20 +931,20 @@ index_update_bag(Config)when is_list(Config) -> [IPos] = mnesia_lib:val({Tab,index}), ITab = mnesia_lib:val({index_test,{index, IPos}}), io:format("~n Index ~p @ ~p => ~p ~n~n",[IPos,ITab, ets:tab2list(ITab)]), - ?match([{2,1},{2,2},{12,1}], lists:keysort(1,ets:tab2list(ITab))), + %?match([{2,1},{2,2},{12,1}], lists:keysort(1,ets:tab2list(ITab))), ?match({atomic, ok}, mnesia:transaction(fun() -> mnesia:write(Rec5) end)), {atomic, R60} = mnesia:transaction(fun() -> mnesia:index_read(Tab, 2, ValPos) end), ?match([Rec1,Rec5,Rec2], lists:sort(R60)), - ?match([{2,1},{2,2},{12,1}], lists:keysort(1,ets:tab2list(ITab))), + %?match([{2,1},{2,2},{12,1}], lists:keysort(1,ets:tab2list(ITab))), ?match({atomic, ok}, mnesia:transaction(fun() -> mnesia:delete_object(Rec3) end)), {atomic, R61} = mnesia:transaction(fun() -> mnesia:index_read(Tab, 2, ValPos) end), ?match([Rec1,Rec5,Rec2], lists:sort(R61)), {atomic, R62} = mnesia:transaction(fun() -> mnesia:index_read(Tab,12, ValPos) end), ?match([], lists:sort(R62)), - ?match([{2,1},{2,2}], lists:keysort(1,ets:tab2list(ITab))), + %% ?match([{2,1},{2,2}], lists:keysort(1,ets:tab2list(ITab))), %% reset for rest of testcase ?match({atomic, ok}, mnesia:transaction(fun() -> mnesia:write(Rec3) end)), @@ -1142,8 +1142,9 @@ create_live_table_index(Config, Storage) -> ?match([{atomic,ok}|_], [Create(N) || N <- lists:seq(1,50)]), ?match([], mnesia_test_lib:stop_mnesia([N2,N3])), - ?match(ok, rpc:call(N2, mnesia, start, [[{extra_db_nodes,[N1]}]])), - ?match(ok, rpc:call(N3, mnesia, start, [[{extra_db_nodes,[N1]}]])), + Ext = [{schema, ?BACKEND}], + ?match(ok, rpc:call(N2, mnesia, start, [[{extra_db_nodes,[N1]}|Ext]])), + ?match(ok, rpc:call(N3, mnesia, start, [[{extra_db_nodes,[N1]}|Ext]])), ?match({atomic, ok}, mnesia:add_table_index(Tab, ValPos)), diff --git a/lib/observer/src/observer_alloc_wx.erl b/lib/observer/src/observer_alloc_wx.erl index d37623d1cc..77609b11ce 100644 --- a/lib/observer/src/observer_alloc_wx.erl +++ b/lib/observer/src/observer_alloc_wx.erl @@ -53,25 +53,29 @@ start_link(Notebook, Parent) -> init([Notebook, Parent]) -> try - Panel = wxPanel:new(Notebook), + TopP = wxPanel:new(Notebook), Main = wxBoxSizer:new(?wxVERTICAL), + Panel = wxPanel:new(TopP), + GSzr = wxBoxSizer:new(?wxVERTICAL), BorderFlags = ?wxLEFT bor ?wxRIGHT, - Carrier = make_win(alloc, Panel, Main, BorderFlags bor ?wxTOP), - Utilz = make_win(utilz, Panel, Main, BorderFlags), - - MemWin = {MemPanel,_} = create_mem_info(Panel), - wxSizer:add(Main, MemPanel, [{flag, ?wxEXPAND bor BorderFlags bor ?wxBOTTOM}, - {proportion, 1}, {border, 5}]), - wxWindow:setSizer(Panel, Main), + Carrier = make_win(alloc, Panel, GSzr, BorderFlags bor ?wxTOP), + Utilz = make_win(utilz, Panel, GSzr, BorderFlags), + wxWindow:setSizer(Panel, GSzr), + wxSizer:add(Main, Panel, [{flag, ?wxEXPAND},{proportion,2}]), + + MemWin = create_mem_info(TopP), + wxSizer:add(Main, MemWin, [{flag, ?wxEXPAND bor BorderFlags bor ?wxBOTTOM}, + {proportion, 1}, {border, 5}]), + wxWindow:setSizer(TopP, Main), Windows = [Carrier, Utilz], PaintInfo = setup_graph_drawing(Windows), - {Panel, #state{parent= Parent, - panel = Panel, - wins = Windows, - mem = MemWin, - paint = PaintInfo, - time = setup_time() - } + {TopP, #state{parent= Parent, + panel = Panel, + wins = Windows, + mem = MemWin, + paint = PaintInfo, + time = setup_time() + } } catch _:Err -> io:format("~p crashed ~p: ~p~n",[?MODULE, Err, erlang:get_stacktrace()]), @@ -84,12 +88,14 @@ setup_time() -> %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% handle_event(#wx{id=?ID_REFRESH_INTERVAL, event=#wxCommand{type=command_menu_selected}}, - #state{panel=Panel, appmon=Old, wins=Wins0, time=#ti{fetch=F0} = Ti0} = State) -> + #state{active=Active, panel=Panel, appmon=Old, wins=Wins0, time=#ti{fetch=F0} = Ti0} = State) -> case interval_dialog(Panel, Ti0) of Ti0 -> {noreply, State}; #ti{fetch=F0} = Ti -> %% Same fetch interval force refresh Wins = [W#win{max=undefined} || W <- Wins0], {noreply, precalc(State#state{time=Ti, wins=Wins})}; + Ti when not Active -> + {noreply, State#state{time=Ti}}; Ti -> %% Changed fetch interval, drop all data {noreply, restart_fetcher(Old, State#state{time=Ti})} end; @@ -120,7 +126,7 @@ handle_info({Key, {promise_reply, {badrpc, _}}}, #state{async=Key} = State) -> {noreply, State#state{active=false, appmon=undefined}}; handle_info({Key, {promise_reply, SysInfo}}, - #state{async=Key, panel=Panel, samples=Data, active=Active, wins=Wins0, + #state{async=Key, panel=_Panel, samples=Data, active=Active, wins=Wins0, time=#ti{tick=Tick, disp=Disp0}=Ti} = S0) -> Disp = trunc(Disp0), Next = max(Tick - Disp, 0), @@ -131,7 +137,6 @@ handle_info({Key, {promise_reply, SysInfo}}, if Active -> update_alloc(S0, Info), State = precalc(S1), - catch wxWindow:refresh(Panel), {noreply, State}; true -> {noreply, S1} @@ -193,7 +198,8 @@ precalc(#state{samples=Data0, paint=Paint, time=Ti, wins=Wins0}=State) -> State#state{wins=Wins}. -update_alloc(#state{mem={_, Grid}}, Fields) -> +update_alloc(#state{mem=Grid}, Fields) -> + wxWindow:freeze(Grid), Max = wxListCtrl:getItemCount(Grid), Update = fun({Name, BS, CS}, Row) -> (Row >= Max) andalso wxListCtrl:insertItem(Grid, Row, ""), @@ -203,6 +209,7 @@ update_alloc(#state{mem={_, Grid}}, Fields) -> Row + 1 end, wx:foldl(Update, 0, Fields), + wxWindow:thaw(Grid), Fields. alloc_info(SysInfo) -> @@ -249,10 +256,9 @@ sum_alloc_one_instance([],BS,CS,TotalBS,TotalCS) -> %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% create_mem_info(Parent) -> - Panel = wxPanel:new(Parent), - wxWindow:setBackgroundColour(Panel, {255,255,255}), Style = ?wxLC_REPORT bor ?wxLC_SINGLE_SEL bor ?wxLC_HRULES bor ?wxLC_VRULES, - Grid = wxListCtrl:new(Panel, [{style, Style}]), + Grid = wxListCtrl:new(Parent, [{style, Style}]), + Li = wxListItem:new(), AddListEntry = fun({Name, Align, DefSize}, Col) -> wxListItem:setText(Li, Name), @@ -267,12 +273,7 @@ create_mem_info(Parent) -> lists:foldl(AddListEntry, 0, ListItems), wxListItem:destroy(Li), - Sizer = wxBoxSizer:new(?wxVERTICAL), - wxSizer:add(Sizer, Grid, [{flag, ?wxEXPAND bor ?wxLEFT bor ?wxRIGHT}, - {border, 5}, {proportion, 1}]), - wxWindow:setSizerAndFit(Panel, Sizer), - {Panel, Grid}. - + Grid. create_menus(Parent, _) -> View = {"View", [#create_menu{id = ?ID_REFRESH_INTERVAL, text = "Graph Settings"}]}, diff --git a/lib/observer/src/observer_app_wx.erl b/lib/observer/src/observer_app_wx.erl index 0e01429aa7..cef83037d0 100644 --- a/lib/observer/src/observer_app_wx.erl +++ b/lib/observer/src/observer_app_wx.erl @@ -302,7 +302,9 @@ handle_info({delivery, _Pid, app, _Curr, {[], [], [], []}}, handle_info({delivery, Pid, app, Curr, AppData}, State = #state{panel=Panel, appmon=Pid, current=Curr, usegc=UseGC, app_w=AppWin, paint=#paint{font=Font}}) -> - GC = make_gc(AppWin, UseGC), + GC = if UseGC -> {?wxGC:create(AppWin), false}; + true -> {false, wxWindowDC:new(AppWin)} + end, setFont(GC, Font, {0,0,0}), App = build_tree(AppData, GC), destroy_gc(GC), diff --git a/lib/observer/src/observer_lib.erl b/lib/observer/src/observer_lib.erl index f0b8a004ec..c6a1c73c83 100644 --- a/lib/observer/src/observer_lib.erl +++ b/lib/observer/src/observer_lib.erl @@ -122,7 +122,7 @@ display_yes_no_dialog(Str) -> %% display_info(Parent, [{Title, [{Label, Info}]}]) -> {Panel, Sizer, InfoFieldsToUpdate} display_info(Frame, Info) -> Panel = wxPanel:new(Frame), - wxWindow:setBackgroundColour(Panel, {255,255,255}), + wxWindow:setBackgroundStyle(Panel, ?wxBG_STYLE_SYSTEM), Sizer = wxBoxSizer:new(?wxVERTICAL), wxSizer:addSpacer(Sizer, 5), Add = fun(BoxInfo) -> @@ -201,22 +201,21 @@ update_info2([Scroll = {_, _, _}|Fs], [{_, NewInfo}|Rest]) -> update_scroll_boxes(Scroll, NewInfo), update_info2(Fs, Rest); update_info2([Field|Fs], [{_Str, {click, Value}}|Rest]) -> - wxTextCtrl:setValue(Field, to_str(Value)), + wxStaticText:setLabel(Field, to_str(Value)), update_info2(Fs, Rest); update_info2([Field|Fs], [{_Str, Value}|Rest]) -> - wxTextCtrl:setValue(Field, to_str(Value)), + wxStaticText:setLabel(Field, to_str(Value)), update_info2(Fs, Rest); update_info2([Field|Fs], [undefined|Rest]) -> - wxTextCtrl:setValue(Field, ""), + wxStaticText:setLabel(Field, ""), update_info2(Fs, Rest); update_info2([], []) -> ok. update_scroll_boxes({_, _, 0}, {_, []}) -> ok; update_scroll_boxes({Win, Sizer, _}, {Type, List}) -> [wxSizerItem:deleteWindows(Child) || Child <- wxSizer:getChildren(Sizer)], - BC = wxWindow:getBackgroundColour(Win), Cursor = wxCursor:new(?wxCURSOR_HAND), - add_entries(Type, List, Win, Sizer, BC, Cursor), + add_entries(Type, List, Win, Sizer, Cursor), wxCursor:destroy(Cursor), wxSizer:recalcSizes(Sizer), wxWindow:refresh(Win), @@ -379,25 +378,22 @@ add_box(Panel, OuterBox, Cursor, Title, Proportion, {Format, List}) -> wxScrolledWindow:setScrollbars(Scroll,1,1,0,0), ScrollSizer = wxBoxSizer:new(?wxVERTICAL), wxScrolledWindow:setSizer(Scroll, ScrollSizer), - BC = wxWindow:getBackgroundColour(Panel), - wxWindow:setBackgroundColour(Scroll,BC), - add_entries(Format, List, Scroll, ScrollSizer, BC, Cursor), + wxWindow:setBackgroundStyle(Scroll, ?wxBG_STYLE_SYSTEM), + add_entries(Format, List, Scroll, ScrollSizer, Cursor), wxSizer:add(Box,Scroll,[{proportion,1},{flag,?wxEXPAND}]), wxSizer:add(OuterBox,Box,[{proportion,Proportion},{flag,?wxEXPAND}]), {Scroll,ScrollSizer,length(List)}. -add_entries(click, List, Scroll, ScrollSizer, BC, Cursor) -> +add_entries(click, List, Scroll, ScrollSizer, Cursor) -> Add = fun(Link) -> TC = link_entry(Scroll, Link, Cursor), - wxWindow:setBackgroundColour(TC,BC), - wxSizer:add(ScrollSizer,TC,[{flag,?wxEXPAND}]) + wxWindow:setBackgroundStyle(TC, ?wxBG_STYLE_SYSTEM), + wxSizer:add(ScrollSizer,TC, [{flag,?wxEXPAND}]) end, [Add(Link) || Link <- List]; -add_entries(plain, List, Scroll, ScrollSizer, _, _) -> +add_entries(plain, List, Scroll, ScrollSizer, _) -> Add = fun(String) -> - TC = wxTextCtrl:new(Scroll, ?wxID_ANY, - [{style,?SINGLE_LINE_STYLE}, - {value,String}]), + TC = wxStaticText:new(Scroll, ?wxID_ANY, String), wxSizer:add(ScrollSizer,TC,[{flag,?wxEXPAND}]) end, [Add(String) || String <- List]. @@ -435,51 +431,44 @@ create_box(Panel, {scroll_boxes,Data}) -> wxSizer:layout(OuterBox), {OuterBox, Boxes}; -create_box(Panel, Data) -> - {Title, Align, Info} = get_box_info(Data), - Box = wxStaticBoxSizer:new(?wxVERTICAL, Panel, [{label, Title}]), - LeftSize = get_max_size(Panel,Info), - LeftProportion = [{proportion,0}], - RightProportion = [{proportion,1}, {flag, Align bor ?wxEXPAND}], +create_box(Parent, Data) -> + {Title, _Align, Info} = get_box_info(Data), + Top = wxStaticBoxSizer:new(?wxVERTICAL, Parent, [{label, Title}]), + Panel = wxPanel:new(Parent), + Box = wxBoxSizer:new(?wxVERTICAL), + LeftSize = 30 + get_max_width(Panel,Info), + RightProportion = [{flag, ?wxEXPAND}], AddRow = fun({Desc0, Value0}) -> Desc = Desc0++":", Line = wxBoxSizer:new(?wxHORIZONTAL), - wxSizer:add(Line, - wxTextCtrl:new(Panel, ?wxID_ANY, - [{style,?SINGLE_LINE_STYLE}, - {size,LeftSize}, - {value,Desc}]), - LeftProportion), + Label = wxStaticText:new(Panel, ?wxID_ANY, Desc), + wxSizer:add(Line, 5, 0), + wxSizer:add(Line, Label), + wxSizer:setItemMinSize(Line, Label, LeftSize, -1), Field = case Value0 of {click,"unknown"} -> - wxTextCtrl:new(Panel, ?wxID_ANY, - [{style,?SINGLE_LINE_STYLE}, - {value,"unknown"}]); + wxStaticText:new(Panel, ?wxID_ANY,"unknown"); {click,Value} -> link_entry(Panel,Value); _ -> Value = to_str(Value0), - TCtrl = wxTextCtrl:new(Panel, ?wxID_ANY, - [{style,?SINGLE_LINE_STYLE}, - {value,Value}]), + TCtrl = wxStaticText:new(Panel, ?wxID_ANY,Value), length(Value) > 50 andalso wxWindow:setToolTip(TCtrl,wxToolTip:new(Value)), TCtrl end, wxSizer:add(Line, 10, 0), % space of size 10 horisontally wxSizer:add(Line, Field, RightProportion), - - {_,H,_,_} = wxTextCtrl:getTextExtent(Field,"Wj"), - wxTextCtrl:setMinSize(Field,{0,H}), - - wxSizer:add(Box, Line, [{proportion,0},{flag,?wxEXPAND}]), + wxSizer:add(Box, Line, [{proportion,1},{flag,?wxEXPAND}]), Field; (undefined) -> undefined end, InfoFields = [AddRow(Entry) || Entry <- Info], - {Box, InfoFields}. + wxWindow:setSizer(Panel, Box), + wxSizer:add(Top, Panel, [{proportion,1},{flag,?wxEXPAND}]), + {Top, InfoFields}. link_entry(Panel, Link) -> Cursor = wxCursor:new(?wxCURSOR_HAND), @@ -490,13 +479,12 @@ link_entry(Panel, Link, Cursor) -> link_entry2(Panel, to_link(Link), Cursor). link_entry2(Panel,{Target,Str},Cursor) -> - TC = wxTextCtrl:new(Panel, ?wxID_ANY, [{style, ?SINGLE_LINE_STYLE}]), - wxTextCtrl:setForegroundColour(TC,?wxBLUE), - wxTextCtrl:appendText(TC, Str), + TC = wxStaticText:new(Panel, ?wxID_ANY, Str), + wxWindow:setForegroundColour(TC,?wxBLUE), wxWindow:setCursor(TC, Cursor), - wxTextCtrl:connect(TC, left_down, [{userData,Target}]), - wxTextCtrl:connect(TC, enter_window), - wxTextCtrl:connect(TC, leave_window), + wxWindow:connect(TC, left_down, [{userData,Target}]), + wxWindow:connect(TC, enter_window), + wxWindow:connect(TC, leave_window), ToolTip = wxToolTip:new("Click to see properties for " ++ Str), wxWindow:setToolTip(TC, ToolTip), TC. @@ -521,23 +509,12 @@ html_window(Panel, Html) -> wxHtmlWindow:setPage(Win, Html), Win. -get_max_size(Panel,Info) -> - Txt = wxTextCtrl:new(Panel, ?wxID_ANY, []), - Size = get_max_size(Txt,Info,0,0), - wxTextCtrl:destroy(Txt), - Size. - -get_max_size(Txt,[{Desc,_}|Info],MaxX,MaxY) -> - {X,Y,_,_} = wxTextCtrl:getTextExtent(Txt,Desc++":"), - if X>MaxX -> - get_max_size(Txt,Info,X,Y); - true -> - get_max_size(Txt,Info,MaxX,MaxY) - end; -get_max_size(Txt,[undefined|Info],MaxX,MaxY) -> - get_max_size(Txt,Info,MaxX,MaxY); -get_max_size(_,[],X,_Y) -> - {X+2,-1}. +get_max_width(Parent,Info) -> + lists:foldl(fun({Desc,_}, Max) -> + {W, _, _, _} = wxWindow:getTextExtent(Parent, Desc), + max(W,Max); + (_, Max) -> Max + end, 0, Info). %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% set_listctrl_col_size(LCtrl, Total) -> diff --git a/lib/observer/src/observer_perf_wx.erl b/lib/observer/src/observer_perf_wx.erl index 017f07d2c4..1010a6af4c 100644 --- a/lib/observer/src/observer_perf_wx.erl +++ b/lib/observer/src/observer_perf_wx.erl @@ -100,7 +100,7 @@ setup_graph_drawing(Panels) -> IsWindows = element(1, os:type()) =:= win32, IgnoreCB = {callback, fun(_,_) -> ok end}, Do = fun(#win{panel=Panel}) -> - wxWindow:setBackgroundColour(Panel, ?wxWHITE), + wxWindow:setBackgroundStyle(Panel, ?wxBG_STYLE_SYSTEM), wxPanel:connect(Panel, paint, [callback]), IsWindows andalso wxPanel:connect(Panel, erase_background, [IgnoreCB]) @@ -142,6 +142,8 @@ handle_event(#wx{id=?ID_REFRESH_INTERVAL, event=#wxCommand{type=command_menu_sel #ti{fetch=F0} = Ti -> %% Same fetch interval force refresh Wins = [W#win{max=undefined} || W <- Wins0], {noreply, precalc(State#state{time=Ti, wins=Wins})}; + Ti when Old =:= undefined -> + {noreply, State#state{time=Ti}}; Ti -> %% Changed fetch interval, drop all data {noreply, restart_fetcher(node(Old), State#state{time=Ti})} end; @@ -762,7 +764,10 @@ make_gc(Panel,UseGC) -> destroy_gc({GC, DC}) -> (GC =/= false) andalso ?wxGC:destroy(GC), - wxPaintDC:destroy(DC). + case DC =/= false andalso wx:getObjectType(DC) of + false -> ok; + Type -> Type:destroy(DC) + end. haveGC() -> try diff --git a/lib/observer/src/observer_procinfo.erl b/lib/observer/src/observer_procinfo.erl index 9d6aa84384..cff5fbb474 100644 --- a/lib/observer/src/observer_procinfo.erl +++ b/lib/observer/src/observer_procinfo.erl @@ -125,11 +125,11 @@ handle_event(#wx{event=#wxMouse{type=left_down}, userData=TargetPid}, State) -> {noreply, State}; handle_event(#wx{obj=Obj, event=#wxMouse{type=enter_window}}, State) -> - wxTextCtrl:setForegroundColour(Obj,{0,0,100,255}), + wxStaticText:setForegroundColour(Obj,{0,0,100,255}), {noreply, State}; handle_event(#wx{obj=Obj, event=#wxMouse{type=leave_window}}, State) -> - wxTextCtrl:setForegroundColour(Obj,?wxBLUE), + wxStaticText:setForegroundColour(Obj,?wxBLUE), {noreply, State}; handle_event(#wx{event=#wxHtmlLink{linkInfo=#wxHtmlLinkInfo{href=Href}}}, diff --git a/lib/observer/test/crashdump_viewer_SUITE.erl b/lib/observer/test/crashdump_viewer_SUITE.erl index a795c4fe25..73ed890802 100644 --- a/lib/observer/test/crashdump_viewer_SUITE.erl +++ b/lib/observer/test/crashdump_viewer_SUITE.erl @@ -101,7 +101,7 @@ end_per_group(_GroupName, Config) -> init_per_suite(Config) when is_list(Config) -> delete_saved(Config), DataDir = ?config(data_dir,Config), - Rels = [R || R <- [r16b,'17'], ?t:is_release_available(R)] ++ [current], + Rels = [R || R <- ['17','18'], ?t:is_release_available(R)] ++ [current], io:format("Creating crash dumps for the following releases: ~p", [Rels]), AllDumps = create_dumps(DataDir,Rels), [{dumps,AllDumps}|Config]. @@ -606,21 +606,21 @@ dos_dump(DataDir,Rel,Dump) -> rel_opt(Rel) -> case Rel of - r16b -> [{erl,[{release,"r16b_latest"}]}]; '17' -> [{erl,[{release,"17_latest"}]}]; + '18' -> [{erl,[{release,"18_latest"}]}]; current -> [] end. dump_prefix(Rel) -> case Rel of - r16b -> "r16b_dump."; '17' -> "r17_dump."; - current -> "r18_dump." + '18' -> "r18_dump."; + current -> "r19_dump." end. compat_rel(Rel) -> case Rel of - r16b -> "+R16 "; '17' -> "+R17 "; + '18' -> "+R18 "; current -> "" end. diff --git a/lib/os_mon/c_src/ferrule.c b/lib/os_mon/c_src/ferrule.c index 8c44e52aba..47f8a21270 100644 --- a/lib/os_mon/c_src/ferrule.c +++ b/lib/os_mon/c_src/ferrule.c @@ -18,6 +18,7 @@ * %CopyrightEnd% */ #include <stdio.h> +#include <stdlib.h> #include <string.h> #include <stropts.h> #include <poll.h> diff --git a/lib/os_mon/c_src/mod_syslog.c b/lib/os_mon/c_src/mod_syslog.c index e287ac9090..720b52916e 100644 --- a/lib/os_mon/c_src/mod_syslog.c +++ b/lib/os_mon/c_src/mod_syslog.c @@ -18,6 +18,7 @@ * %CopyrightEnd% */ #include <stdio.h> +#include <stdlib.h> #include <string.h> #include <unistd.h> #include <sys/types.h> diff --git a/lib/runtime_tools/doc/src/LTTng.xml b/lib/runtime_tools/doc/src/LTTng.xml index eab1848e88..4a87133c57 100644 --- a/lib/runtime_tools/doc/src/LTTng.xml +++ b/lib/runtime_tools/doc/src/LTTng.xml @@ -240,6 +240,222 @@ $ make </code> </section> <section> + <title>BEAM Tracepoints</title> + <p>All tracepoints are in the domain of <c>com_ericsson_otp</c></p> + <p>All Erlang types are the string equivalent in LTTng.</p> + + <p><em>scheduler_poll</em></p> + <list type="bulleted"> + <item><c>scheduler : integer</c> :: Scheduler ID. Ex. <c>1</c></item> + <item><c>runnable : integer</c> :: Runnable. Ex. <c>1</c></item> + </list> + <p>Example:</p> + <p><code type="none">scheduler_poll: { cpu_id = 4 }, { scheduler = 1, runnable = 1 }</code></p> + + <p><em>driver_init</em></p> + <list type="bulleted"> + <item><c>driver : string</c> :: Driver name. Ex. <c>"efile"</c></item> + <item><c>major : integer</c> :: Major version. Ex. <c>3</c></item> + <item><c>minor : integer</c> :: Minor version. Ex. <c>1</c></item> + <item><c>flags : integer</c> :: Flags. Ex. <c>1</c></item> + </list> + <p>Example:</p> + <p><code type="none">driver_init: { cpu_id = 2 }, { driver = "caller_drv", major = 3, minor = 3, flags = 1 }</code></p> + + <p><em>driver_start</em></p> + <list type="bulleted"> + <item><c>pid : string</c> :: Process ID. Ex. <c>"<0.131.0>"</c></item> + <item><c>driver : string</c> :: Driver name. Ex. <c>"efile"</c></item> + <item><c>port : string</c> :: Port ID. Ex. <c>"#Port<0.1031>"</c></item> + </list> + <p>Example:</p> + <p><code type="none">driver_start: { cpu_id = 2 }, { pid = "<0.198.0>", driver = "caller_drv", port = "#Port<0.3676>" }</code></p> + + <p><em>driver_output</em></p> + <list type="bulleted"> + <item><c>pid : string</c> :: Process ID. Ex. <c>"<0.131.0>"</c></item> + <item><c>port : string</c> :: Port ID. Ex. <c>"#Port<0.1031>"</c></item> + <item><c>driver : string</c> :: Driver name. Ex. <c>"efile"</c></item> + <item><c>bytes : integer</c> :: Size of data returned. Ex. <c>82</c></item> + </list> + <p>Example:</p> + <p><code type="none">driver_output: { cpu_id = 2 }, { pid = "<0.198.0>", port = "#Port<0.3677>", driver = "/bin/sh -s unix:cmd", bytes = 36 }</code></p> + + <p><em>driver_outputv</em></p> + <list type="bulleted"> + <item><c>pid : string</c> :: Process ID. Ex. <c>"<0.131.0>"</c></item> + <item><c>port : string</c> :: Port ID. Ex. <c>"#Port<0.1031>"</c></item> + <item><c>driver : string</c> :: Driver name. Ex. <c>"efile"</c></item> + <item><c>bytes : integer</c> :: Size of data returned. Ex. <c>82</c></item> + </list> + <p>Example:</p> + <p><code type="none">driver_outputv: { cpu_id = 5 }, { pid = "<0.194.0>", port = "#Port<0.3663>", driver = "tcp_inet", bytes = 3 }</code></p> + + <p><em>driver_ready_input</em></p> + <list type="bulleted"> + <item><c>pid : string</c> :: Process ID. Ex. <c>"<0.131.0>"</c></item> + <item><c>port : string</c> :: Port ID. Ex. <c>"#Port<0.1031>"</c></item> + <item><c>driver : string</c> :: Driver name. Ex. <c>"efile"</c></item> + </list> + <p>Example:</p> + <p><code type="none">driver_ready_input: { cpu_id = 5 }, { pid = "<0.189.0>", port = "#Port<0.3637>", driver = "inet_gethost 4 " }</code></p> + + <p><em>driver_ready_output</em></p> + <list type="bulleted"> + <item><c>pid : string</c> :: Process ID. Ex. <c>"<0.131.0>"</c></item> + <item><c>port : string</c> :: Port ID. Ex. <c>"#Port<0.1031>"</c></item> + <item><c>driver : string</c> :: Driver name. Ex. <c>"efile"</c></item> + </list> + <p>Example:</p> + <p><code type="none">driver_ready_output: { cpu_id = 5 }, { pid = "<0.194.0>", port = "#Port<0.3663>", driver = "tcp_inet" }</code></p> + + <p><em>driver_timeout</em></p> + <list type="bulleted"> + <item><c>pid : string</c> :: Process ID. Ex. <c>"<0.131.0>"</c></item> + <item><c>port : string</c> :: Port ID. Ex. <c>"#Port<0.1031>"</c></item> + <item><c>driver : string</c> :: Driver name. Ex. <c>"efile"</c></item> + </list> + <p>Example:</p> + <p><code type="none">driver_timeout: { cpu_id = 5 }, { pid = "<0.196.0>", port = "#Port<0.3664>", driver = "tcp_inet" }</code></p> + + <p><em>driver_stop_select</em></p> + <list type="bulleted"> + <item><c>driver : string</c> :: Driver name. Ex. <c>"efile"</c></item> + </list> + <p>Example:</p> + <p><code type="none">driver_stop_select: { cpu_id = 5 }, { driver = "unknown" }</code></p> + + <p><em>driver_flush</em></p> + <list type="bulleted"> + <item><c>pid : string</c> :: Process ID. Ex. <c>"<0.131.0>"</c></item> + <item><c>port : string</c> :: Port ID. Ex. <c>"#Port<0.1031>"</c></item> + <item><c>driver : string</c> :: Driver name. Ex. <c>"efile"</c></item> + </list> + <p>Example:</p> + <p><code type="none">driver_flush: { cpu_id = 7 }, { pid = "<0.204.0>", port = "#Port<0.3686>", driver = "tcp_inet" }</code></p> + + <p><em>driver_stop</em></p> + <list type="bulleted"> + <item><c>pid : string</c> :: Process ID. Ex. <c>"<0.131.0>"</c></item> + <item><c>port : string</c> :: Port ID. Ex. <c>"#Port<0.1031>"</c></item> + <item><c>driver : string</c> :: Driver name. Ex. <c>"efile"</c></item> + </list> + <p>Example:</p> + <p><code type="none">driver_stop: { cpu_id = 5 }, { pid = "[]", port = "#Port<0.3673>", driver = "efile" }</code></p> + + <p><em>driver_process_exit</em></p> + <list type="bulleted"> + <item><c>pid : string</c> :: Process ID. Ex. <c>"<0.131.0>"</c></item> + <item><c>port : string</c> :: Port ID. Ex. <c>"#Port<0.1031>"</c></item> + <item><c>driver : string</c> :: Driver name. Ex. <c>"efile"</c></item> + </list> + + <p><em>driver_ready_async</em></p> + <list type="bulleted"> + <item><c>pid : string</c> :: Process ID. Ex. <c>"<0.131.0>"</c></item> + <item><c>port : string</c> :: Port ID. Ex. <c>"#Port<0.1031>"</c></item> + <item><c>driver : string</c> :: Driver name. Ex. <c>"efile"</c></item> + </list> + <p>Example:</p> + <p><code type="none">driver_ready_async: { cpu_id = 3 }, { pid = "<0.181.0>", port = "#Port<0.3622>", driver = "efile" }</code></p> + + <p><em>driver_call</em></p> + <list type="bulleted"> + <item><c>pid : string</c> :: Process ID. Ex. <c>"<0.131.0>"</c></item> + <item><c>port : string</c> :: Port ID. Ex. <c>"#Port<0.1031>"</c></item> + <item><c>driver : string</c> :: Driver name. Ex. <c>"efile"</c></item> + <item><c>command : integer</c> :: Command integer. Ex. <c>1</c></item> + <item><c>bytes : integer</c> :: Size of data returned. Ex. <c>82</c></item> + </list> + <p>Example:</p> + <p><code type="none">driver_call: { cpu_id = 2 }, { pid = "<0.202.0>", port = "#Port<0.3676>", driver = "caller_drv", command = 0, bytes = 2 }</code></p> + + <p><em>driver_control</em></p> + <list type="bulleted"> + <item><c>pid : string</c> :: Process ID. Ex. <c>"<0.131.0>"</c></item> + <item><c>port : string</c> :: Port ID. Ex. <c>"#Port<0.1031>"</c></item> + <item><c>driver : string</c> :: Driver name. Ex. <c>"efile"</c></item> + <item><c>command : integer</c> :: Command integer. Ex. <c>1</c></item> + <item><c>bytes : integer</c> :: Size of data returned. Ex. <c>82</c></item> + </list> + <p>Example:</p> + <p><code type="none">driver_control: { cpu_id = 3 }, { pid = "<0.32767.8191>", port = "#Port<0.0>", driver = "forker", command = 83, bytes = 32 }</code></p> + + <p><em>aio_pool_get</em></p> + <list type="bulleted"> + <item><c>port : string</c> :: Port ID. Ex. <c>"#Port<0.1031>"</c></item> + <item><c>length : integer</c> :: Async queue length. Ex. <c>0</c></item> + </list> + <p>Example:</p> + <p><code type="none">aio_pool_get: { cpu_id = 4 }, { port = "#Port<0.3614>", length = 0 }</code></p> + + <p><em>aio_pool_put</em></p> + <list type="bulleted"> + <item><c>port : string</c> :: Port ID. Ex. <c>"#Port<0.1031>"</c></item> + <item><c>length : integer</c> :: Async queue length. Ex. <c>-1</c></item> + </list> + <p>Async queue length is not defined for <c>put</c> operations.</p> + <p>Example:</p> + <p><code type="none">aio_pool_put: { cpu_id = 3 }, { port = "#Port<0.3614>", length = -1 }</code></p> + + <p><em>carrier_create</em></p> + <list type="bulleted"> + <item><c>type : string</c> :: Carrier type. Ex. <c>"ets_alloc"</c></item> + <item><c>instance : integer</c> :: Allocator instance. Ex. <c>1</c></item> + <item><c>size : integer</c> :: Carrier size. Ex. <c>262144</c></item> + <item><c>mbc_carriers : integer</c> :: Number of multiblock carriers in instance. Ex. <c>3</c></item> + <item><c>mbc_carriers_size : integer</c> :: Total size of multiblock blocks carriers in instance. Ex. <c>1343488</c></item> + <item><c>mbc_blocks : integer</c> :: Number of multiblock blocks in instance. Ex. <c>122</c></item> + <item><c>mbc_blocks_size : integer</c> :: Total size of all multiblock blocks in instance. Ex. <c>285296</c></item> + <item><c>sbc_carriers : integer</c> :: Number of singleblock carriers in instance. Ex. <c>1</c></item> + <item><c>sbc_carriers_size : integer</c> :: Total size of singleblock blocks carriers in instance. Ex. <c>1343488</c></item> + <item><c>sbc_blocks : integer</c> :: Number of singleblocks in instance. Ex. <c>1</c></item> + <item><c>sbc_blocks_size : integer</c> :: Total size of all singleblock blocks in instance. Ex. <c>285296</c></item> + + </list> + <p>Example:</p> + <p><code type="none">carrier_create: { cpu_id = 2 }, { type = "ets_alloc", instance = 7, size = 2097152, mbc_carriers = 4, mbc_carriers_size = 3440640, mbc_blocks = 526, mbc_blocks_size = 1278576, sbc_carriers = 0, sbc_carriers_size = 0, sbc_blocks = 0, sbc_blocks_size = 0 }</code></p> + + <p><em>carrier_destroy</em></p> + <list type="bulleted"> + <item><c>type : string</c> :: Carrier type. Ex. <c>"ets_alloc"</c></item> + <item><c>instance : integer</c> :: Allocator instance. Ex. <c>1</c></item> + <item><c>size : integer</c> :: Carrier size. Ex. <c>262144</c></item> + <item><c>mbc_carriers : integer</c> :: Number of multiblock carriers in instance. Ex. <c>3</c></item> + <item><c>mbc_carriers_size : integer</c> :: Total size of multiblock blocks carriers in instance. Ex. <c>1343488</c></item> + <item><c>mbc_blocks : integer</c> :: Number of multiblock blocks in instance. Ex. <c>122</c></item> + <item><c>mbc_blocks_size : integer</c> :: Total size of all multiblock blocks in instance. Ex. <c>285296</c></item> + <item><c>sbc_carriers : integer</c> :: Number of singleblock carriers in instance. Ex. <c>1</c></item> + <item><c>sbc_carriers_size : integer</c> :: Total size of singleblock blocks carriers in instance. Ex. <c>1343488</c></item> + <item><c>sbc_blocks : integer</c> :: Number of singleblocks in instance. Ex. <c>1</c></item> + <item><c>sbc_blocks_size : integer</c> :: Total size of all singleblock blocks in instance. Ex. <c>285296</c></item> + + </list> + <p>Example:</p> + <p><code type="none">carrier_destroy: { cpu_id = 6 }, { type = "ets_alloc", instance = 7, size = 262144, mbc_carriers = 3, mbc_carriers_size = 3178496, mbc_blocks = 925, mbc_blocks_size = 2305336, sbc_carriers = 0, sbc_carriers_size = 0, sbc_blocks = 0, sbc_blocks_size = 0 }</code></p> + + <p><em>carrier_pool_put</em></p> + <list type="bulleted"> + <item><c>type : string</c> :: Carrier type. Ex. <c>"ets_alloc"</c></item> + <item><c>instance : integer</c> :: Allocator instance. Ex. <c>1</c></item> + <item><c>size : integer</c> :: Carrier size. Ex. <c>262144</c></item> + </list> + <p>Example:</p> + <p><code type="none">carrier_pool_put: { cpu_id = 3 }, { type = "ets_alloc", instance = 5, size = 1048576 }</code></p> + + <p><em>carrier_pool_get</em></p> + <list type="bulleted"> + <item><c>type : string</c> :: Carrier type. Ex. <c>"ets_alloc"</c></item> + <item><c>instance : integer</c> :: Allocator instance. Ex. <c>1</c></item> + <item><c>size : integer</c> :: Carrier size. Ex. <c>262144</c></item> + </list> + <p>Example:</p> + <p><code type="none">carrier_pool_get: { cpu_id = 7 }, { type = "ets_alloc", instance = 4, size = 3208 }</code></p> + + </section> + + + <section> <title>Examples</title> </section> </chapter> diff --git a/lib/runtime_tools/src/runtime_tools.app.src b/lib/runtime_tools/src/runtime_tools.app.src index 4d96996ce0..690c61a4c3 100644 --- a/lib/runtime_tools/src/runtime_tools.app.src +++ b/lib/runtime_tools/src/runtime_tools.app.src @@ -28,7 +28,7 @@ {applications, [kernel, stdlib]}, {env, []}, {mod, {runtime_tools, []}}, - {runtime_dependencies, ["stdlib-2.0","mnesia-4.12","kernel-3.0", - "erts-7.0"]}]}. + {runtime_dependencies, ["stdlib-3.0","mnesia-4.12","kernel-5.0", + "erts-8.0"]}]}. diff --git a/lib/runtime_tools/src/system_information.erl b/lib/runtime_tools/src/system_information.erl index ad7ee7311c..1add01612d 100644 --- a/lib/runtime_tools/src/system_information.erl +++ b/lib/runtime_tools/src/system_information.erl @@ -28,31 +28,25 @@ -behaviour(gen_server). %% API --export([ - report/0, +-export([report/0, from_file/1, - to_file/1 - ]). --export([ - start/0, stop/0, - load_report/0, load_report/2, - applications/0, applications/1, - application/1, application/2, - environment/0, environment/1, - module/1, module/2, - modules/1, - sanity_check/0 - ]). + to_file/1]). +-export([start/0, stop/0, + load_report/0, load_report/2, + applications/0, applications/1, + application/1, application/2, + environment/0, environment/1, + module/1, module/2, + modules/1, + sanity_check/0]). %% gen_server callbacks --export([ - init/1, - handle_call/3, - handle_cast/2, - handle_info/2, - terminate/2, - code_change/3 - ]). +-export([init/1, + handle_call/3, + handle_cast/2, + handle_info/2, + terminate/2, + code_change/3]). -define(SERVER, ?MODULE). @@ -71,13 +65,13 @@ start() -> gen_server:start({local, ?SERVER}, ?MODULE, [], []). stop() -> - gen_server:call(?SERVER, stop). + gen_server:call(?SERVER, stop, infinity). load_report() -> load_report(data, report()). load_report(file, File) -> load_report(data, from_file(File)); load_report(data, Report) -> - start(), gen_server:call(?SERVER, {load_report, Report}). + start(), gen_server:call(?SERVER, {load_report, Report}, infinity). report() -> [ {init_arguments, init:get_arguments()}, @@ -120,22 +114,22 @@ from_file(File) -> applications() -> applications([]). applications(Opts) when is_list(Opts) -> - gen_server:call(?SERVER, {applications, Opts}). + gen_server:call(?SERVER, {applications, Opts}, infinity). application(App) when is_atom(App) -> application(App, []). application(App, Opts) when is_atom(App), is_list(Opts) -> - gen_server:call(?SERVER, {application, App, Opts}). + gen_server:call(?SERVER, {application, App, Opts}, infinity). environment() -> environment([]). environment(Opts) when is_list(Opts) -> - gen_server:call(?SERVER, {environment, Opts}). + gen_server:call(?SERVER, {environment, Opts}, infinity). module(M) when is_atom(M) -> module(M, []). module(M, Opts) when is_atom(M), is_list(Opts) -> - gen_server:call(?SERVER, {module, M, Opts}). + gen_server:call(?SERVER, {module, M, Opts}, infinity). modules(Opt) when is_atom(Opt) -> - gen_server:call(?SERVER, {modules, Opt}). + gen_server:call(?SERVER, {modules, Opt}, infinity). -spec sanity_check() -> ok | {failed, Failures} when diff --git a/lib/runtime_tools/test/dbg_SUITE.erl b/lib/runtime_tools/test/dbg_SUITE.erl index 4b32696aa5..5a3c885571 100644 --- a/lib/runtime_tools/test/dbg_SUITE.erl +++ b/lib/runtime_tools/test/dbg_SUITE.erl @@ -389,8 +389,8 @@ distributed(Config) when is_list(Config) -> {value, {matched, Node, 1}} = lists:keysearch(Node, 2, Z), dbg:cn(Node), dbg:tp(dbg,ln,[]), - ok = rpc:call(Node, dbg, ltp, []), - ok = rpc:call(Node, dbg, ln, []), + ok = rpc:block_call(Node, dbg, ltp, []), + ok = rpc:block_call(Node, dbg, ln, []), ok = dbg:ln(), S = self(), {TraceSend, TraceCall} = @@ -669,12 +669,6 @@ file_port_schedfix1(Config) when is_list(Config) -> %% {ok,[{matched,_,_}]} = dbg:p(all, [clear]), stop(), - % Some debug code to run on all platforms, for finding the fault on genny - % Dont touch please /PaN - io:format("Trace dump by PaN BEGIN~n"), - dbg:trace_client(file,{FName, wrap, ".wraplog"},{fun(end_of_trace,Pid)-> Pid ! done; (Mesg,Pid) -> io:format("~w~n",[Mesg]),Pid end,self()}), - receive done -> ok end, - io:format("Trace dump by PaN END~n"), %% %% Get the trace result %% @@ -695,14 +689,12 @@ file_port_schedfix1(Config) when is_list(Config) -> %% %% Analyze the result %% - {Min, Max} = - lists:foldl( - fun({_Pid, M}, {Mi, Ma}) -> - {if M < Mi -> M; true -> Mi end, - if M > Ma -> M; true -> Ma end} - end, - {void, 0}, - Result), + {Min, Max} = lists:foldl(fun({_Pid, M}, {Mi, Ma}) -> + {if M < Mi -> M; true -> Mi end, + if M > Ma -> M; true -> Ma end} + end, + {void, 0}, + Result), % More PaN debug io:format("Min = ~f, Max = ~f~n",[Min,Max]), %% @@ -1117,6 +1109,10 @@ schedstat_handler(TraceMsg, {Parent, Tag, Data} = State) -> Data end, {Parent, Tag, NewData}; + {trace_ts,_Pid,spawned,_OtherPid,_,_Ts} -> + State; + {trace_ts,_Pid,getting_linked,_OtherPid,_Ts} -> + State; {trace_ts, Pid, exit, normal, {A3, B3, C3}} -> NewData = case lists:keysearch(Pid, 1, Data) of diff --git a/lib/ssh/doc/src/ssh.xml b/lib/ssh/doc/src/ssh.xml index 33aacb8ffe..ff2d6e082a 100644 --- a/lib/ssh/doc/src/ssh.xml +++ b/lib/ssh/doc/src/ssh.xml @@ -360,7 +360,8 @@ </type> <desc> <p>Starts a server listening for SSH connections on the given - port.</p> + port. If the <c>Port</c> is 0, a random free port is selected. See + <seealso marker="#daemon_info/1">daemon_info/1</seealso> about how to find the selected port number.</p> <p>Options:</p> <taglist> <tag><c><![CDATA[{inet, inet | inet6}]]></c></tag> @@ -682,6 +683,18 @@ </func> <func> + <name>daemon_info(Daemon) -> {ok, [{port,Port}]} | {error,Error}</name> + <fsummary>Get info about a daemon</fsummary> + <type> + <v>Port = integer()</v> + <v>Error = bad_daemon_ref</v> + </type> + <desc> + <p>Returns a key-value list with information about the daemon. For now, only the listening port is returned. This is intended for the case the daemon is started with the port set to 0.</p> + </desc> + </func> + + <func> <name>default_algorithms() -> algs_list()</name> <fsummary>Get a list declaring the supported algorithms</fsummary> <desc> diff --git a/lib/ssh/doc/src/ssh_sftp.xml b/lib/ssh/doc/src/ssh_sftp.xml index 1d37933369..071d46ec57 100644 --- a/lib/ssh/doc/src/ssh_sftp.xml +++ b/lib/ssh/doc/src/ssh_sftp.xml @@ -44,24 +44,41 @@ </p> <taglist> + <tag><c>reason()</c></tag> + <item> + <p>= <c>atom()</c> A description of the reason why an operation failed.</p> + <p> + The value is formed from the sftp error codes in the protocol-level responses as defined in + <url href="https://tools.ietf.org/id/draft-ietf-secsh-filexfer-13.txt">draft-ietf-secsh-filexfer-13.txt</url> + section 9.1. + </p> + <p> + The codes are named as <c>SSH_FX_*</c> which are transformed into lowercase of the star-part. + E.g. the error code <c>SSH_FX_NO_SUCH_FILE</c> + will cause the <c>reason()</c> to be <c>no_such_file</c>. + </p> + </item> + <tag><c>ssh_connection_ref() =</c></tag> - <item><p>opaque() - as returned by <c>ssh:connect/3</c></p></item> + <item><p><c>opaque()</c> - as returned by + <seealso marker="ssh#connect-3"><c>ssh:connect/3</c></seealso></p></item> + <tag><c>timeout()</c></tag> - <item><p>= <c>infinity | integer() in milliseconds. Default infinity.</c></p></item> + <item><p>= <c>infinity | integer()</c> in milliseconds. Default infinity.</p></item> </taglist> </section> <section> <title>Time-outs</title> <p>If the request functions for the SFTP channel return <c>{error, timeout}</c>, - it does not guarantee that the request never reached the server and was - not performed. It only means that no answer was received from the - server within the expected time.</p> + no answer was received from the server within the expected time.</p> + <p>The request may have reached the server and may have been performed. + However, no answer was received from the server within the expected time.</p> </section> <funcs> <func> - <name>apread(ChannelPid, Handle, Position, Len) -> {async, N} | {error, Reason}</name> + <name>apread(ChannelPid, Handle, Position, Len) -> {async, N} | {error, reason()}</name> <fsummary>Reads asynchronously from an open file.</fsummary> <type> <v>ChannelPid = pid()</v> @@ -69,16 +86,15 @@ <v>Position = integer()</v> <v>Len = integer()</v> <v>N = term()</v> - <v>Reason = term()</v> </type> - - <desc><p>The <c><![CDATA[apread]]></c> function reads from a specified position, - combining the <c><![CDATA[position]]></c> and <c><![CDATA[aread]]></c> functions.</p> - <p><seealso marker="#apread-4">ssh_sftp:apread/4</seealso></p> </desc> + <desc><p>The <c><![CDATA[apread/4]]></c> function reads from a specified position, + combining the <seealso marker="#position-3"><c>position/3</c></seealso> and + <seealso marker="#aread-3"><c>aread/3</c></seealso> functions.</p> + </desc> </func> <func> - <name>apwrite(ChannelPid, Handle, Position, Data) -> ok | {error, Reason}</name> + <name>apwrite(ChannelPid, Handle, Position, Data) -> {async, N} | {error, reason()}</name> <fsummary>Writes asynchronously to an open file.</fsummary> <type> <v>ChannelPid = pid()</v> @@ -87,16 +103,16 @@ <v>Len = integer()</v> <v>Data = binary()</v> <v>Timeout = timeout()</v> - <v>Reason = term()</v> + <v>N = term()</v> </type> - <desc> - <p><c><![CDATA[apwrite]]></c> writes on a specified position, combining - the <c><![CDATA[position]]></c> and <c><![CDATA[awrite]]></c> operations.</p> - <p><seealso marker="#awrite-3">ssh_sftp:awrite/3</seealso> </p></desc> + <desc><p>The <c><![CDATA[apwrite/4]]></c> function writes to a specified position, + combining the <seealso marker="#position-3"><c>position/3</c></seealso> and + <seealso marker="#awrite-3"><c>awrite/3</c></seealso> functions.</p> + </desc> </func> <func> - <name>aread(ChannelPid, Handle, Len) -> {async, N} | {error, Error}</name> + <name>aread(ChannelPid, Handle, Len) -> {async, N} | {error, reason()}</name> <fsummary>Reads asynchronously from an open file.</fsummary> <type> <v>ChannelPid = pid()</v> @@ -104,7 +120,6 @@ <v>Position = integer()</v> <v>Len = integer()</v> <v>N = term()</v> - <v>Reason = term()</v> </type> <desc> <p>Reads from an open file, without waiting for the result. If the @@ -113,14 +128,12 @@ The actual data is sent as a message to the calling process. This message has the form <c><![CDATA[{async_reply, N, Result}]]></c>, where <c><![CDATA[Result]]></c> is the result from the read, either <c><![CDATA[{ok, Data}]]></c>, - <c><![CDATA[eof]]></c>, or <c><![CDATA[{error, Error}]]></c>.</p> + <c><![CDATA[eof]]></c>, or <c><![CDATA[{error, reason()}]]></c>.</p> </desc> </func> - - <func> - <name>awrite(ChannelPid, Handle, Data) -> ok | {error, Reason}</name> + <name>awrite(ChannelPid, Handle, Data) -> {async, N} | {error, reason()}</name> <fsummary>Writes asynchronously to an open file.</fsummary> <type> <v>ChannelPid = pid()</v> @@ -129,7 +142,6 @@ <v>Len = integer()</v> <v>Data = binary()</v> <v>Timeout = timeout()</v> - <v>Reason = term()</v> </type> <desc> <p>Writes to an open file, without waiting for the result. If the @@ -138,19 +150,18 @@ <c><![CDATA[awrite]]></c>. The result of the <c><![CDATA[write]]></c> operation is sent as a message to the calling process. This message has the form <c><![CDATA[{async_reply, N, Result}]]></c>, where <c><![CDATA[Result]]></c> is the result - from the write, either <c><![CDATA[ok]]></c>, or <c><![CDATA[{error, Error}]]></c>.</p> + from the write, either <c><![CDATA[ok]]></c>, or <c><![CDATA[{error, reason()}]]></c>.</p> </desc> </func> <func> <name>close(ChannelPid, Handle) -></name> - <name>close(ChannelPid, Handle, Timeout) -> ok | {error, Reason}</name> + <name>close(ChannelPid, Handle, Timeout) -> ok | {error, reason()}</name> <fsummary>Closes an open handle.</fsummary> <type> <v>ChannelPid = pid()</v> <v>Handle = term()</v> <v>Timeout = timeout()</v> - <v>Reason = term()</v> </type> <desc> <p>Closes a handle to an open file or directory on the server.</p> @@ -159,29 +170,27 @@ <func> <name>delete(ChannelPid, Name) -></name> - <name>delete(ChannelPid, Name, Timeout) -> ok | {error, Reason}</name> + <name>delete(ChannelPid, Name, Timeout) -> ok | {error, reason()}</name> <fsummary>Deletes a file.</fsummary> <type> <v>ChannelPid = pid()</v> <v>Name = string()</v> <v>Timeout = timeout()</v> - <v>Reason = term()</v> </type> <desc> - <p>Deletes the file specified by <c><![CDATA[Name]]></c>, like - <seealso marker="kernel:file#delete-1">file:delete/1</seealso></p> + <p>Deletes the file specified by <c><![CDATA[Name]]></c>. + </p> </desc> </func> <func> <name>del_dir(ChannelPid, Name) -></name> - <name>del_dir(ChannelPid, Name, Timeout) -> ok | {error, Reason}</name> + <name>del_dir(ChannelPid, Name, Timeout) -> ok | {error, reason()}</name> <fsummary>Deletes an empty directory.</fsummary> <type> <v>ChannelPid = pid()</v> <v>Name = string()</v> <v>Timeout = timeout()</v> - <v>Reason = term()</v> </type> <desc> <p>Deletes a directory specified by <c><![CDATA[Name]]></c>. @@ -192,7 +201,7 @@ <func> <name>list_dir(ChannelPid, Path) -></name> - <name>list_dir(ChannelPid, Path, Timeout) -> {ok, Filenames} | {error, Reason}</name> + <name>list_dir(ChannelPid, Path, Timeout) -> {ok, Filenames} | {error, reason()}</name> <fsummary>Lists the directory.</fsummary> <type> <v>ChannelPid = pid()</v> @@ -200,7 +209,6 @@ <v>Filenames = [Filename]</v> <v>Filename = string()</v> <v>Timeout = timeout()</v> - <v>Reason = term()</v> </type> <desc> <p>Lists the given directory on the server, returning the @@ -210,13 +218,12 @@ <func> <name>make_dir(ChannelPid, Name) -></name> - <name>make_dir(ChannelPid, Name, Timeout) -> ok | {error, Reason}</name> + <name>make_dir(ChannelPid, Name, Timeout) -> ok | {error, reason()}</name> <fsummary>Creates a directory.</fsummary> <type> <v>ChannelPid = pid()</v> <v>Name = string()</v> <v>Timeout = timeout()</v> - <v>Reason = term()</v> </type> <desc> <p>Creates a directory specified by <c><![CDATA[Name]]></c>. <c><![CDATA[Name]]></c> @@ -227,24 +234,23 @@ <func> <name>make_symlink(ChannelPid, Name, Target) -></name> - <name>make_symlink(ChannelPid, Name, Target, Timeout) -> ok | {error, Reason}</name> + <name>make_symlink(ChannelPid, Name, Target, Timeout) -> ok | {error, reason()}</name> <fsummary>Creates a symbolic link.</fsummary> <type> <v>ChannelPid = pid()</v> <v>Name = string()</v> <v>Target = string()</v> - <v>Reason = term()</v> </type> <desc> <p>Creates a symbolic link pointing to <c><![CDATA[Target]]></c> with the - name <c><![CDATA[Name]]></c>, like - <seealso marker="kernel:file#make_symlink-2">file:make_symlink/2</seealso></p> + name <c><![CDATA[Name]]></c>. + </p> </desc> </func> <func> <name>open(ChannelPid, File, Mode) -></name> - <name>open(ChannelPid, File, Mode, Timeout) -> {ok, Handle} | {error, Reason}</name> + <name>open(ChannelPid, File, Mode, Timeout) -> {ok, Handle} | {error, reason()}</name> <fsummary>Opens a file and returns a handle.</fsummary> <type> <v>ChannelPid = pid()</v> @@ -253,7 +259,6 @@ <v>Modeflag = read | write | creat | trunc | append | binary</v> <v>Timeout = timeout()</v> <v>Handle = term()</v> - <v>Reason = term()</v> </type> <desc> <p>Opens a file on the server and returns a handle, which @@ -262,13 +267,12 @@ </func> <func> <name>opendir(ChannelPid, Path) -></name> - <name>opendir(ChannelPid, Path, Timeout) -> {ok, Handle} | {error, Reason}</name> + <name>opendir(ChannelPid, Path, Timeout) -> {ok, Handle} | {error, reason()}</name> <fsummary>Opens a directory and returns a handle.</fsummary> <type> <v>ChannelPid = pid()</v> <v>Path = string()</v> <v>Timeout = timeout()</v> - <v>Reason = term()</v> </type> <desc> <p>Opens a handle to a directory on the server. The handle @@ -278,7 +282,7 @@ <func> <name>open_tar(ChannelPid, Path, Mode) -></name> - <name>open_tar(ChannelPid, Path, Mode, Timeout) -> {ok, Handle} | {error, Reason}</name> + <name>open_tar(ChannelPid, Path, Mode, Timeout) -> {ok, Handle} | {error, reason()}</name> <fsummary>Opens a tar file on the server to which <c>ChannelPid</c> is connected and returns a handle.</fsummary> <type> @@ -298,7 +302,6 @@ <v>DecryptResult = {ok,PlainBin,CryptoState} | {ok,PlainBin,CryptoState,ChunkSize}</v> <v>CloseFun = (fun(PlainBin,CryptoState) -> {ok,EncryptedBin})</v> <v>Timeout = timeout()</v> - <v>Reason = term()</v> </type> <desc> <p>Opens a handle to a tar file on the server, associated with <c>ChannelPid</c>. @@ -333,7 +336,7 @@ <func> <name>position(ChannelPid, Handle, Location) -></name> - <name>position(ChannelPid, Handle, Location, Timeout) -> {ok, NewPosition} | {error, Reason}</name> + <name>position(ChannelPid, Handle, Location, Timeout) -> {ok, NewPosition | {error, reason()}</name> <fsummary>Sets the file position of a file.</fsummary> <type> <v>ChannelPid = pid()</v> @@ -343,12 +346,11 @@ <v>Offset = integer()</v> <v>Timeout = timeout()</v> <v>NewPosition = integer()</v> - <v>Reason = term()</v> </type> <desc> <p>Sets the file position of the file referenced by <c><![CDATA[Handle]]></c>. Returns <c><![CDATA[{ok, NewPosition}]]></c> (as an absolute offset) if - successful, otherwise <c><![CDATA[{error, Reason}]]></c>. <c><![CDATA[Location]]></c> is + successful, otherwise <c><![CDATA[{error, reason()}]]></c>. <c><![CDATA[Location]]></c> is one of the following:</p> <taglist> <tag><c><![CDATA[Offset]]></c></tag> @@ -379,7 +381,7 @@ <func> <name>pread(ChannelPid, Handle, Position, Len) -></name> - <name>pread(ChannelPid, Handle, Position, Len, Timeout) -> {ok, Data} | eof | {error, Error}</name> + <name>pread(ChannelPid, Handle, Position, Len, Timeout) -> {ok, Data} | eof | {error, reason()}</name> <fsummary>Reads from an open file.</fsummary> <type> <v>ChannelPid = pid()</v> @@ -388,18 +390,16 @@ <v>Len = integer()</v> <v>Timeout = timeout()</v> <v>Data = string() | binary()</v> - <v>Reason = term()</v> </type> - <desc> - <p>The <c><![CDATA[pread]]></c> function reads from a specified position, - combining the <c><![CDATA[position]]></c> and <c><![CDATA[read]]></c> functions.</p> - <p><seealso marker="#read-4">ssh_sftp:read/4</seealso></p> - </desc> - </func> + <desc><p>The <c><![CDATA[pread/3,4]]></c> function reads from a specified position, + combining the <seealso marker="#position-3"><c>position/3</c></seealso> and + <seealso marker="#read-3"><c>read/3,4</c></seealso> functions.</p> + </desc> + </func> <func> <name>pwrite(ChannelPid, Handle, Position, Data) -> ok</name> - <name>pwrite(ChannelPid, Handle, Position, Data, Timeout) -> ok | {error, Reason}</name> + <name>pwrite(ChannelPid, Handle, Position, Data, Timeout) -> ok | {error, reason()}</name> <fsummary>Writes to an open file.</fsummary> <type> <v>ChannelPid = pid()</v> @@ -407,19 +407,16 @@ <v>Position = integer()</v> <v>Data = iolist()</v> <v>Timeout = timeout()</v> - <v>Reason = term()</v> </type> - <desc> - <p>The <c><![CDATA[pread]]></c> function writes to a specified position, - combining the <c><![CDATA[position]]></c> and <c><![CDATA[write]]></c> functions.</p> - <p><seealso marker="#write-3">ssh_sftp:write/3</seealso></p> - </desc> + <desc><p>The <c><![CDATA[pwrite/3,4]]></c> function writes to a specified position, + combining the <seealso marker="#position-3"><c>position/3</c></seealso> and + <seealso marker="#write-3"><c>write/3,4</c></seealso> functions.</p> + </desc> </func> - - <func> + <func> <name>read(ChannelPid, Handle, Len) -></name> - <name>read(ChannelPid, Handle, Len, Timeout) -> {ok, Data} | eof | {error, Error}</name> + <name>read(ChannelPid, Handle, Len, Timeout) -> {ok, Data} | eof | {error, reason()}</name> <fsummary>Reads from an open file.</fsummary> <type> <v>ChannelPid = pid()</v> @@ -428,12 +425,11 @@ <v>Len = integer()</v> <v>Timeout = timeout()</v> <v>Data = string() | binary()</v> - <v>Reason = term()</v> </type> <desc> <p>Reads <c><![CDATA[Len]]></c> bytes from the file referenced by <c><![CDATA[Handle]]></c>. Returns <c><![CDATA[{ok, Data}]]></c>, <c><![CDATA[eof]]></c>, or - <c><![CDATA[{error, Reason}]]></c>. If the file is opened with <c><![CDATA[binary]]></c>, + <c><![CDATA[{error, reason()}]]></c>. If the file is opened with <c><![CDATA[binary]]></c>, <c><![CDATA[Data]]></c> is a binary, otherwise it is a string.</p> <p>If the file is read past <c>eof</c>, only the remaining bytes are read and returned. If no bytes are read, <c><![CDATA[eof]]></c> @@ -443,25 +439,22 @@ <func> <name>read_file(ChannelPid, File) -></name> - <name>read_file(ChannelPid, File, Timeout) -> {ok, Data} | {error, Reason}</name> + <name>read_file(ChannelPid, File, Timeout) -> {ok, Data} | {error, reason()}</name> <fsummary>Reads a file.</fsummary> <type> <v>ChannelPid = pid()</v> <v>File = string()</v> <v>Data = binary()</v> <v>Timeout = timeout()</v> - <v>Reason = term()</v> </type> <desc> - <p>Reads a file from the server, and returns the data in a binary, - like - <seealso marker="kernel:file#read_file-1">file:read_file/1</seealso></p> + <p>Reads a file from the server, and returns the data in a binary.</p> </desc> </func> <func> <name>read_file_info(ChannelPid, Name) -></name> - <name>read_file_info(ChannelPid, Name, Timeout) -> {ok, FileInfo} | {error, Reason}</name> + <name>read_file_info(ChannelPid, Name, Timeout) -> {ok, FileInfo} | {error, reason()}</name> <fsummary>Gets information about a file.</fsummary> <type> <v>ChannelPid = pid()</v> @@ -469,35 +462,34 @@ <v>Handle = term()</v> <v>Timeout = timeout()</v> <v>FileInfo = record()</v> - <v>Reason = term()</v> </type> <desc> <p>Returns a <c><![CDATA[file_info]]></c> record from the file specified by - <c><![CDATA[Name]]></c> or <c><![CDATA[Handle]]></c>, - like <seealso marker="kernel:file#read_file_info-2">file:read_file_info/2</seealso></p> + <c><![CDATA[Name]]></c> or <c><![CDATA[Handle]]></c>. See + <seealso marker="kernel:file#read_file_info-2">file:read_file_info/2</seealso> + for information about the record. + </p> </desc> </func> <func> <name>read_link(ChannelPid, Name) -></name> - <name>read_link(ChannelPid, Name, Timeout) -> {ok, Target} | {error, Reason}</name> + <name>read_link(ChannelPid, Name, Timeout) -> {ok, Target} | {error, reason()}</name> <fsummary>Reads symbolic link.</fsummary> <type> <v>ChannelPid = pid()</v> <v>Name = string()</v> <v>Target = string()</v> - <v>Reason = term()</v> </type> <desc> - <p>Reads the link target from the symbolic link specified - by <c><![CDATA[name]]></c>, like - <seealso marker="kernel:file#read_link-1">file:read_link/1</seealso></p> + <p>Reads the link target from the symbolic link specified by <c><![CDATA[name]]></c>. + </p> </desc> </func> <func> - <name>read_link_info(ChannelPid, Name) -> {ok, FileInfo} | {error, Reason}</name> - <name>read_link_info(ChannelPid, Name, Timeout) -> {ok, FileInfo} | {error, Reason}</name> + <name>read_link_info(ChannelPid, Name) -> {ok, FileInfo} | {error, reason()}</name> + <name>read_link_info(ChannelPid, Name, Timeout) -> {ok, FileInfo} | {error, reason()}</name> <fsummary>Gets information about a symbolic link.</fsummary> <type> <v>ChannelPid = pid()</v> @@ -505,30 +497,31 @@ <v>Handle = term()</v> <v>Timeout = timeout()</v> <v>FileInfo = record()</v> - <v>Reason = term()</v> </type> <desc> <p>Returns a <c><![CDATA[file_info]]></c> record from the symbolic - link specified by <c><![CDATA[Name]]></c> or <c><![CDATA[Handle]]></c>, like - <seealso marker="kernel:file#read_link_info-2">file:read_link_info/2</seealso></p> + link specified by <c><![CDATA[Name]]></c> or <c><![CDATA[Handle]]></c>. + See + <seealso marker="kernel:file#read_link_info-2">file:read_link_info/2</seealso> + for information about the record. + </p> </desc> </func> <func> <name>rename(ChannelPid, OldName, NewName) -> </name> - <name>rename(ChannelPid, OldName, NewName, Timeout) -> ok | {error, Reason}</name> + <name>rename(ChannelPid, OldName, NewName, Timeout) -> ok | {error, reason()}</name> <fsummary>Renames a file.</fsummary> <type> <v>ChannelPid = pid()</v> <v>OldName = string()</v> <v>NewName = string()</v> <v>Timeout = timeout()</v> - <v>Reason = term()</v> </type> <desc> <p>Renames a file named <c><![CDATA[OldName]]></c> and gives it the name - <c><![CDATA[NewName]]></c>, like - <seealso marker="kernel:file#rename-2">file:rename/2</seealso></p> + <c><![CDATA[NewName]]></c>. + </p> </desc> </func> @@ -537,14 +530,13 @@ <name>start_channel(ConnectionRef, Options) -></name> <name>start_channel(Host, Options) -></name> <name>start_channel(Host, Port, Options) -> {ok, Pid} | {ok, Pid, ConnectionRef} | - {error, Reason}</name> + {error, reason()|term()}</name> <fsummary>Starts an SFTP client.</fsummary> <type> <v>Host = string()</v> <v>ConnectionRef = ssh_connection_ref()</v> <v>Port = integer()</v> <v>Options = [{Option, Value}]</v> - <v>Reason = term()</v> </type> <desc> <p>If no connection reference is provided, a connection is set @@ -592,7 +584,7 @@ <func> <name>write(ChannelPid, Handle, Data) -></name> - <name>write(ChannelPid, Handle, Data, Timeout) -> ok | {error, Reason}</name> + <name>write(ChannelPid, Handle, Data, Timeout) -> ok | {error, reason()}</name> <fsummary>Writes to an open file.</fsummary> <type> <v>ChannelPid = pid()</v> @@ -600,61 +592,47 @@ <v>Position = integer()</v> <v>Data = iolist()</v> <v>Timeout = timeout()</v> - <v>Reason = term()</v> </type> <desc> <p>Writes <c><![CDATA[data]]></c> to the file referenced by <c><![CDATA[Handle]]></c>. The file is to be opened with <c><![CDATA[write]]></c> or <c><![CDATA[append]]></c> - flag. Returns <c><![CDATA[ok]]></c> if successful or <c><![CDATA[{error, Reason}]]></c> + flag. Returns <c><![CDATA[ok]]></c> if successful or <c><![CDATA[{error, reason()}]]></c> otherwise.</p> - <p>Typical error reasons:</p> - <taglist> - <tag><c><![CDATA[ebadf]]></c></tag> - <item> - <p>File is not opened for writing.</p> - </item> - <tag><c><![CDATA[enospc]]></c></tag> - <item> - <p>No space is left on the device.</p> - </item> - </taglist> </desc> </func> <func> <name>write_file(ChannelPid, File, Iolist) -></name> - <name>write_file(ChannelPid, File, Iolist, Timeout) -> ok | {error, Reason}</name> + <name>write_file(ChannelPid, File, Iolist, Timeout) -> ok | {error, reason()}</name> <fsummary>Writes a file.</fsummary> <type> <v>ChannelPid = pid()</v> <v>File = string()</v> <v>Iolist = iolist()</v> <v>Timeout = timeout()</v> - <v>Reason = term()</v> </type> <desc> - <p>Writes a file to the server, like <seealso - marker="kernel:file#write_file-2">file:write_file/2</seealso> The - file is created if it does not exist. The file is overwritten - if it exists.</p> + <p>Writes a file to the server. The file is created if it does not exist + but overwritten if it exists.</p> </desc> </func> <func> <name>write_file_info(ChannelPid, Name, Info) -></name> - <name>write_file_info(ChannelPid, Name, Info, Timeout) -> ok | {error, Reason}</name> + <name>write_file_info(ChannelPid, Name, Info, Timeout) -> ok | {error, reason()}</name> <fsummary>Writes information for a file.</fsummary> <type> <v>ChannelPid = pid()</v> <v>Name = string()</v> <v>Info = record()</v> <v>Timeout = timeout()</v> - <v>Reason = term()</v> </type> <desc> <p>Writes file information from a <c><![CDATA[file_info]]></c> record to the - file specified by <c><![CDATA[Name]]></c>, like - <seealso marker="kernel:file#write_file_info-2">file:write_file_info/[2,3]</seealso></p> + file specified by <c><![CDATA[Name]]></c>. See + <seealso marker="kernel:file#write_file_info-2">file:write_file_info/[2,3]</seealso> + for information about the record. + </p> </desc> </func> </funcs> diff --git a/lib/ssh/src/ssh.app.src b/lib/ssh/src/ssh.app.src index c67350bf72..3245ba5197 100644 --- a/lib/ssh/src/ssh.app.src +++ b/lib/ssh/src/ssh.app.src @@ -40,7 +40,12 @@ {applications, [kernel, stdlib, crypto, public_key]}, {env, []}, {mod, {ssh_app, []}}, - {runtime_dependencies, ["stdlib-2.3","public_key-0.22","kernel-3.0", - "erts-6.0","crypto-3.3"]}]}. + {runtime_dependencies, [ + "crypto-3.3", + "erts-6.0", + "kernel-3.0", + "public_key-1.1", + "stdlib-3.0" + ]}]}. diff --git a/lib/ssh/src/ssh.erl b/lib/ssh/src/ssh.erl index d0121e73ba..09b07b7a2a 100644 --- a/lib/ssh/src/ssh.erl +++ b/lib/ssh/src/ssh.erl @@ -30,12 +30,18 @@ -export([start/0, start/1, stop/0, connect/3, connect/4, close/1, connection_info/2, channel_info/3, daemon/1, daemon/2, daemon/3, + daemon_info/1, default_algorithms/0, stop_listener/1, stop_listener/2, stop_listener/3, stop_daemon/1, stop_daemon/2, stop_daemon/3, shell/1, shell/2, shell/3 ]). +%%% Type exports +-export_type([connection_ref/0, + channel_id/0 + ]). + %%-------------------------------------------------------------------- -spec start() -> ok | {error, term()}. -spec start(permanent | transient | temporary) -> ok | {error, term()}. @@ -81,7 +87,7 @@ connect(Host, Port, Options, Timeout) -> ConnectionTimeout = proplists:get_value(connect_timeout, Options, infinity), try Transport:connect(Host, Port, [ {active, false} | SocketOptions], ConnectionTimeout) of {ok, Socket} -> - Opts = [{user_pid, self()}, {host, Host} | fix_idle_time(SshOptions)], + Opts = [{user_pid,self()}, {host,Host} | SshOptions], ssh_connection_handler:start_connection(client, Socket, Opts, Timeout); {error, Reason} -> {error, Reason} @@ -153,6 +159,19 @@ daemon(HostAddr, Port, Options0) -> start_daemon(Host, Port, Options, Inet). %%-------------------------------------------------------------------- +daemon_info(Pid) -> + case catch ssh_system_sup:acceptor_supervisor(Pid) of + AsupPid when is_pid(AsupPid) -> + [Port] = + [Prt || {{ssh_acceptor_sup,any,Prt,default}, + _WorkerPid,worker,[ssh_acceptor]} <- supervisor:which_children(AsupPid)], + {ok, [{port,Port}]}; + + _ -> + {error,bad_daemon_ref} + end. + +%%-------------------------------------------------------------------- -spec stop_listener(pid()) -> ok. -spec stop_listener(inet:ip_address(), integer()) -> ok. %% @@ -223,13 +242,6 @@ default_algorithms() -> %%-------------------------------------------------------------------- %%% Internal functions %%-------------------------------------------------------------------- -fix_idle_time(SshOptions) -> - case proplists:get_value(idle_time, SshOptions) of - undefined -> - [{idle_time, infinity}|SshOptions]; - _ -> - SshOptions - end. start_daemon(Host, Port, Options, Inet) -> case handle_options(Options) of {error, _Reason} = Error -> @@ -243,32 +255,52 @@ start_daemon(Host, Port, Options, Inet) -> end end. -do_start_daemon(Host0, Port0, Options, SocketOptions) -> - {Host,Port} = try - case proplists:get_value(fd, SocketOptions) of - undefined -> - {Host0,Port0}; - Fd when Port0==0 -> - find_hostport(Fd); - _ -> - {Host0,Port0} - end - catch - _:_ -> throw(bad_fd) - end, - Profile = proplists:get_value(profile, Options, ?DEFAULT_PROFILE), +do_start_daemon(Host0, Port0, SshOptions, SocketOptions) -> + {Host,Port1} = + try + case proplists:get_value(fd, SocketOptions) of + undefined -> + {Host0,Port0}; + Fd when Port0==0 -> + find_hostport(Fd); + _ -> + {Host0,Port0} + end + catch + _:_ -> throw(bad_fd) + end, + Profile = proplists:get_value(profile, SshOptions, ?DEFAULT_PROFILE), + {Port, WaitRequestControl, Opts} = + case Port1 of + 0 -> %% Allocate the socket here to get the port number... + {_, Callback, _} = + proplists:get_value(transport, SshOptions, {tcp, gen_tcp, tcp_closed}), + {ok,LSock} = ssh_acceptor:callback_listen(Callback, 0, SocketOptions), + {ok,{_,LPort}} = inet:sockname(LSock), + {LPort, + {LSock,Callback}, + [{lsocket,LSock},{lsock_owner,self()}] + }; + _ -> + {Port1, false, []} + end, case ssh_system_sup:system_supervisor(Host, Port, Profile) of undefined -> %% It would proably make more sense to call the %% address option host but that is a too big change at the %% monent. The name is a legacy name! try sshd_sup:start_child([{address, Host}, - {port, Port}, {role, server}, + {port, Port}, + {role, server}, {socket_opts, SocketOptions}, - {ssh_opts, Options}]) of + {ssh_opts, SshOptions} + | Opts]) of {error, {already_started, _}} -> {error, eaddrinuse}; - Result = {Code, _} when (Code == ok) or (Code == error) -> + Result = {ok,_} -> + sync_request_control(WaitRequestControl), + Result; + Result = {error, _} -> Result catch exit:{noproc, _} -> @@ -277,18 +309,31 @@ do_start_daemon(Host0, Port0, Options, SocketOptions) -> Sup -> AccPid = ssh_system_sup:acceptor_supervisor(Sup), case ssh_acceptor_sup:start_child(AccPid, [{address, Host}, - {port, Port}, {role, server}, + {port, Port}, + {role, server}, {socket_opts, SocketOptions}, - {ssh_opts, Options}]) of + {ssh_opts, SshOptions} + | Opts]) of {error, {already_started, _}} -> {error, eaddrinuse}; {ok, _} -> + sync_request_control(WaitRequestControl), {ok, Sup}; Other -> Other end end. +sync_request_control(false) -> + ok; +sync_request_control({LSock,Callback}) -> + receive + {request_control,LSock,ReqPid} -> + ok = Callback:controlling_process(LSock, ReqPid), + ReqPid ! {its_yours,LSock}, + ok + end. + find_hostport(Fd) -> %% Using internal functions inet:open/8 and inet:close/0. %% Don't try this at home unless you know what you are doing! diff --git a/lib/ssh/src/ssh.hrl b/lib/ssh/src/ssh.hrl index 73d6e4d2bc..868f3a9181 100644 --- a/lib/ssh/src/ssh.hrl +++ b/lib/ssh/src/ssh.hrl @@ -70,8 +70,6 @@ -record(ssh, { - %%state, %% what it's waiting for - role, %% client | server peer, %% string version of peer address @@ -135,8 +133,8 @@ user, service, userauth_quiet_mode, % boolean() - userauth_supported_methods, % string() eg "keyboard-interactive,password" userauth_methods, % list( string() ) eg ["keyboard-interactive", "password"] + userauth_supported_methods, % string() eg "keyboard-interactive,password" kb_tries_left = 0, % integer(), num tries left for "keyboard-interactive" userauth_preference, available_host_keys, diff --git a/lib/ssh/src/ssh_acceptor.erl b/lib/ssh/src/ssh_acceptor.erl index d94dedf1bf..90fd951dcd 100644 --- a/lib/ssh/src/ssh_acceptor.erl +++ b/lib/ssh/src/ssh_acceptor.erl @@ -26,7 +26,8 @@ %% Internal application API -export([start_link/5, - number_of_connections/1]). + number_of_connections/1, + callback_listen/3]). %% spawn export -export([acceptor_init/6, acceptor_loop/6]). @@ -46,15 +47,39 @@ start_link(Port, Address, SockOpts, Opts, AcceptTimeout) -> acceptor_init(Parent, Port, Address, SockOpts, Opts, AcceptTimeout) -> {_, Callback, _} = proplists:get_value(transport, Opts, {tcp, gen_tcp, tcp_closed}), - case (catch do_socket_listen(Callback, Port, [{active, false} | SockOpts])) of - {ok, ListenSocket} -> + + SockOwner = proplists:get_value(lsock_owner, Opts), + LSock = proplists:get_value(lsocket, Opts), + UseExistingSocket = + case catch inet:sockname(LSock) of + {ok,{_,Port}} -> is_pid(SockOwner); + _ -> false + end, + + case UseExistingSocket of + true -> proc_lib:init_ack(Parent, {ok, self()}), - acceptor_loop(Callback, - Port, Address, Opts, ListenSocket, AcceptTimeout); - Error -> - proc_lib:init_ack(Parent, Error), - error + request_ownership(LSock, SockOwner), + acceptor_loop(Callback, Port, Address, Opts, LSock, AcceptTimeout); + + false -> + case (catch do_socket_listen(Callback, Port, SockOpts)) of + {ok, ListenSocket} -> + proc_lib:init_ack(Parent, {ok, self()}), + acceptor_loop(Callback, + Port, Address, Opts, ListenSocket, AcceptTimeout); + Error -> + proc_lib:init_ack(Parent, Error), + error + end end. + +request_ownership(LSock, SockOwner) -> + SockOwner ! {request_control,LSock,self()}, + receive + {its_yours,LSock} -> ok + end. + do_socket_listen(Callback, Port0, Opts) -> Port = @@ -62,6 +87,10 @@ do_socket_listen(Callback, Port0, Opts) -> undefined -> Port0; _ -> 0 end, + callback_listen(Callback, Port, Opts). + +callback_listen(Callback, Port, Opts0) -> + Opts = [{active, false}, {reuseaddr,true} | Opts0], case Callback:listen(Port, Opts) of {error, nxdomain} -> Callback:listen(Port, lists:delete(inet6, Opts)); diff --git a/lib/ssh/src/ssh_acceptor_sup.erl b/lib/ssh/src/ssh_acceptor_sup.erl index b2f489a971..4f76dbe6f0 100644 --- a/lib/ssh/src/ssh_acceptor_sup.erl +++ b/lib/ssh/src/ssh_acceptor_sup.erl @@ -85,10 +85,7 @@ child_spec(ServerOpts) -> Profile = proplists:get_value(profile, proplists:get_value(ssh_opts, ServerOpts), ?DEFAULT_PROFILE), Name = id(Address, Port, Profile), SocketOpts = proplists:get_value(socket_opts, ServerOpts), - StartFunc = {ssh_acceptor, start_link, [Port, Address, - [{active, false}, - {reuseaddr, true}] ++ SocketOpts, - ServerOpts, Timeout]}, + StartFunc = {ssh_acceptor, start_link, [Port, Address, SocketOpts, ServerOpts, Timeout]}, Restart = transient, Shutdown = brutal_kill, Modules = [ssh_acceptor], diff --git a/lib/ssh/src/ssh_auth.erl b/lib/ssh/src/ssh_auth.erl index 4b3c21ce3f..49eec8072f 100644 --- a/lib/ssh/src/ssh_auth.erl +++ b/lib/ssh/src/ssh_auth.erl @@ -135,9 +135,9 @@ init_userauth_request_msg(#ssh{opts = Opts} = Ssh) -> service = "ssh-connection"}); {error, no_user} -> ErrStr = "Could not determine the users name", - throw(#ssh_msg_disconnect{code = ?SSH_DISCONNECT_ILLEGAL_USER_NAME, - description = ErrStr, - language = "en"}) + ssh_connection_handler:disconnect( + #ssh_msg_disconnect{code = ?SSH_DISCONNECT_ILLEGAL_USER_NAME, + description = ErrStr}) end. userauth_request_msg(#ssh{userauth_preference = []} = Ssh) -> @@ -355,10 +355,10 @@ handle_userauth_info_response(#ssh_msg_userauth_info_response{num_responses = 1, handle_userauth_info_response(#ssh_msg_userauth_info_response{}, _Auth) -> - throw(#ssh_msg_disconnect{code = ?SSH_DISCONNECT_SERVICE_NOT_AVAILABLE, - description = "Server does not support" - "keyboard-interactive", - language = "en"}). + ssh_connection_handler:disconnect( + #ssh_msg_disconnect{code = ?SSH_DISCONNECT_SERVICE_NOT_AVAILABLE, + description = "Server does not support keyboard-interactive" + }). %%-------------------------------------------------------------------- @@ -420,10 +420,10 @@ check_password(User, Password, Opts, Ssh) -> {false,NewState} -> {false, Ssh#ssh{pwdfun_user_state=NewState}}; disconnect -> - throw(#ssh_msg_disconnect{code = ?SSH_DISCONNECT_SERVICE_NOT_AVAILABLE, - description = - "Unable to connect using the available authentication methods", - language = ""}) + ssh_connection_handler:disconnect( + #ssh_msg_disconnect{code = ?SSH_DISCONNECT_SERVICE_NOT_AVAILABLE, + description = "Unable to connect using the available authentication methods" + }) end end. diff --git a/lib/ssh/src/ssh_channel.erl b/lib/ssh/src/ssh_channel.erl index de6908bb38..a8e6ebde16 100644 --- a/lib/ssh/src/ssh_channel.erl +++ b/lib/ssh/src/ssh_channel.erl @@ -68,7 +68,7 @@ %% Internal application API -export([cache_create/0, cache_lookup/2, cache_update/2, cache_delete/1, cache_delete/2, cache_foldl/3, - cache_find/2, + cache_info/2, cache_find/2, get_print_info/1]). -record(state, { @@ -335,6 +335,9 @@ cache_delete(Cache) -> cache_foldl(Fun, Acc, Cache) -> ets:foldl(Fun, Acc, Cache). +cache_info(num_entries, Cache) -> + proplists:get_value(size, ets:info(Cache)). + cache_find(ChannelPid, Cache) -> case ets:match_object(Cache, #channel{user = ChannelPid}) of [] -> diff --git a/lib/ssh/src/ssh_connect.hrl b/lib/ssh/src/ssh_connect.hrl index 397d51de9d..4fb6bc39f3 100644 --- a/lib/ssh/src/ssh_connect.hrl +++ b/lib/ssh/src/ssh_connect.hrl @@ -22,13 +22,15 @@ %%% Description : SSH connection protocol --type channel_id() :: integer(). +-type role() :: client | server . +-type connection_ref() :: pid(). +-type channel_id() :: pos_integer(). -define(DEFAULT_PACKET_SIZE, 65536). -define(DEFAULT_WINDOW_SIZE, 10*?DEFAULT_PACKET_SIZE). -define(DEFAULT_TIMEOUT, 5000). --define(MAX_PROTO_VERSION, 255). +-define(MAX_PROTO_VERSION, 255). % Max length of the hello string %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %% @@ -241,7 +243,7 @@ -record(channel, { - type, %% "session", "x11", "forwarded-tcpip", "direct-tcpip" + type, %% "session" sys, %% "none", "shell", "exec" "subsystem" user, %% "user" process id (default to cm user) flow_control, diff --git a/lib/ssh/src/ssh_connection.erl b/lib/ssh/src/ssh_connection.erl index a34478732c..d0f2d54c06 100644 --- a/lib/ssh/src/ssh_connection.erl +++ b/lib/ssh/src/ssh_connection.erl @@ -38,8 +38,7 @@ %% Potential API currently unsupported and not tested -export([window_change/4, window_change/6, - direct_tcpip/6, direct_tcpip/8, tcpip_forward/3, - cancel_tcpip_forward/3, signal/3, exit_status/3]). + signal/3, exit_status/3]). %% Internal application API -export([channel_data/5, handle_msg/3, channel_eof_msg/1, @@ -48,7 +47,7 @@ channel_adjust_window_msg/2, channel_data_msg/3, channel_open_msg/5, channel_open_confirmation_msg/4, channel_open_failure_msg/4, channel_request_msg/4, - global_request_msg/3, request_failure_msg/0, + request_failure_msg/0, request_success_msg/1, bind/4, unbind/3, unbind_channel/2, bound_channel/3, encode_ip/1]). @@ -232,52 +231,6 @@ exit_status(ConnectionHandler, Channel, Status) -> ssh_connection_handler:request(ConnectionHandler, Channel, "exit-status", false, [?uint32(Status)], 0). -direct_tcpip(ConnectionHandler, RemoteHost, - RemotePort, OrigIP, OrigPort, Timeout) -> - direct_tcpip(ConnectionHandler, RemoteHost, RemotePort, OrigIP, OrigPort, - ?DEFAULT_WINDOW_SIZE, ?DEFAULT_PACKET_SIZE, Timeout). - -direct_tcpip(ConnectionHandler, RemoteIP, RemotePort, OrigIP, OrigPort, - InitialWindowSize, MaxPacketSize, Timeout) -> - case {encode_ip(RemoteIP), encode_ip(OrigIP)} of - {false, _} -> - {error, einval}; - {_, false} -> - {error, einval}; - {RIP, OIP} -> - ssh_connection_handler:open_channel(ConnectionHandler, - "direct-tcpip", - [?string(RIP), - ?uint32(RemotePort), - ?string(OIP), - ?uint32(OrigPort)], - InitialWindowSize, - MaxPacketSize, - Timeout) - end. - -tcpip_forward(ConnectionHandler, BindIP, BindPort) -> - case encode_ip(BindIP) of - false -> - {error, einval}; - IPStr -> - ssh_connection_handler:global_request(ConnectionHandler, - "tcpip-forward", true, - [?string(IPStr), - ?uint32(BindPort)]) - end. - -cancel_tcpip_forward(ConnectionHandler, BindIP, Port) -> - case encode_ip(BindIP) of - false -> - {error, einval}; - IPStr -> - ssh_connection_handler:global_request(ConnectionHandler, - "cancel-tcpip-forward", true, - [?string(IPStr), - ?uint32(Port)]) - end. - %%-------------------------------------------------------------------- %%% Internal API %%-------------------------------------------------------------------- @@ -300,22 +253,11 @@ l2b([]) -> channel_data(ChannelId, DataType, Data, Connection, From) when is_list(Data)-> - channel_data(ChannelId, DataType, -%% list_to_binary(Data), Connection, From); - l2b(Data), Connection, From); - %% try list_to_binary(Data) - %% of - %% B -> B - %% catch - %% _:_ -> io:format('BAD BINARY: ~p~n',[Data]), - %% unicode:characters_to_binary(Data) - %% end, - %% Connection, From); + channel_data(ChannelId, DataType, l2b(Data), Connection, From); channel_data(ChannelId, DataType, Data, #connection{channel_cache = Cache} = Connection, From) -> - case ssh_channel:cache_lookup(Cache, ChannelId) of #channel{remote_id = Id, sent_close = false} = Channel0 -> {SendList, Channel} = @@ -331,8 +273,7 @@ channel_data(ChannelId, DataType, Data, FlowCtrlMsgs = flow_control(Replies, Channel, Cache), {{replies, Replies ++ FlowCtrlMsgs}, Connection}; _ -> - gen_fsm:reply(From, {error, closed}), - {noreply, Connection} + {{replies,[{channel_request_reply,From,{error,closed}}]}, Connection} end. handle_msg(#ssh_msg_channel_open_confirmation{recipient_channel = ChannelId, @@ -499,7 +440,8 @@ handle_msg(#ssh_msg_channel_open{channel_type = "session" = Type, handle_msg(#ssh_msg_channel_open{channel_type = "session", sender_channel = RemoteId}, - Connection, client) -> + Connection, + client) -> %% Client implementations SHOULD reject any session channel open %% requests to make it more difficult for a corrupt server to attack the %% client. See See RFC 4254 6.1. @@ -509,73 +451,6 @@ handle_msg(#ssh_msg_channel_open{channel_type = "session", {{replies, [{connection_reply, FailMsg}]}, Connection}; -handle_msg(#ssh_msg_channel_open{channel_type = "forwarded-tcpip" = Type, - sender_channel = RemoteId, - initial_window_size = RWindowSz, - maximum_packet_size = RPacketSz, - data = Data}, - #connection{channel_cache = Cache, - options = SSHopts} = Connection0, server) -> - <<?UINT32(ALen), Address:ALen/binary, ?UINT32(Port), - ?UINT32(OLen), Orig:OLen/binary, ?UINT32(OrigPort)>> = Data, - - MinAcceptedPackSz = proplists:get_value(minimal_remote_max_packet_size, SSHopts, 0), - - if - MinAcceptedPackSz =< RPacketSz -> - case bound_channel(Address, Port, Connection0) of - undefined -> - FailMsg = channel_open_failure_msg(RemoteId, - ?SSH_OPEN_CONNECT_FAILED, - "Connection refused", "en"), - {{replies, - [{connection_reply, FailMsg}]}, Connection0}; - ChannelPid -> - {ChannelId, Connection1} = new_channel_id(Connection0), - LWindowSz = ?DEFAULT_WINDOW_SIZE, - LPacketSz = ?DEFAULT_PACKET_SIZE, - Channel = #channel{type = Type, - sys = "none", - user = ChannelPid, - local_id = ChannelId, - recv_window_size = LWindowSz, - recv_packet_size = LPacketSz, - send_window_size = RWindowSz, - send_packet_size = RPacketSz, - send_buf = queue:new() - }, - ssh_channel:cache_update(Cache, Channel), - OpenConfMsg = channel_open_confirmation_msg(RemoteId, ChannelId, - LWindowSz, LPacketSz), - {OpenMsg, Connection} = - reply_msg(Channel, Connection1, - {open, Channel, {forwarded_tcpip, - decode_ip(Address), Port, - decode_ip(Orig), OrigPort}}), - {{replies, [{connection_reply, OpenConfMsg}, - OpenMsg]}, Connection} - end; - - MinAcceptedPackSz > RPacketSz -> - FailMsg = channel_open_failure_msg(RemoteId, - ?SSH_OPEN_ADMINISTRATIVELY_PROHIBITED, - lists:concat(["Maximum packet size below ",MinAcceptedPackSz, - " not supported"]), "en"), - {{replies, [{connection_reply, FailMsg}]}, Connection0} - end; - - -handle_msg(#ssh_msg_channel_open{channel_type = "forwarded-tcpip", - sender_channel = RemoteId}, - Connection, client) -> - %% Client implementations SHOULD reject direct TCP/IP open requests for - %% security reasons. See RFC 4254 7.2. - FailMsg = channel_open_failure_msg(RemoteId, - ?SSH_OPEN_CONNECT_FAILED, - "Connection refused", "en"), - {{replies, [{connection_reply, FailMsg}]}, Connection}; - - handle_msg(#ssh_msg_channel_open{sender_channel = RemoteId}, Connection, _) -> FailMsg = channel_open_failure_msg(RemoteId, ?SSH_OPEN_ADMINISTRATIVELY_PROHIBITED, @@ -786,11 +661,11 @@ handle_msg(#ssh_msg_global_request{name = _Type, handle_msg(#ssh_msg_request_failure{}, #connection{requests = [{_, From} | Rest]} = Connection, _) -> - {{replies, [{channel_requst_reply, From, {failure, <<>>}}]}, + {{replies, [{channel_request_reply, From, {failure, <<>>}}]}, Connection#connection{requests = Rest}}; handle_msg(#ssh_msg_request_success{data = Data}, #connection{requests = [{_, From} | Rest]} = Connection, _) -> - {{replies, [{channel_requst_reply, From, {success, Data}}]}, + {{replies, [{channel_request_reply, From, {success, Data}}]}, Connection#connection{requests = Rest}}; handle_msg(#ssh_msg_disconnect{code = Code, @@ -886,10 +761,6 @@ channel_request_msg(ChannelId, Type, WantReply, Data) -> want_reply = WantReply, data = Data}. -global_request_msg(Type, WantReply, Data) -> - #ssh_msg_global_request{name = Type, - want_reply = WantReply, - data = Data}. request_failure_msg() -> #ssh_msg_request_failure{}. @@ -1059,7 +930,7 @@ request_reply_or_data(#channel{local_id = ChannelId, user = ChannelPid}, Connection, Reply) -> case lists:keysearch(ChannelId, 1, Requests) of {value, {ChannelId, From}} -> - {{channel_requst_reply, From, Reply}, + {{channel_request_reply, From, Reply}, Connection#connection{requests = lists:keydelete(ChannelId, 1, Requests)}}; false when (Reply == success) or (Reply == failure) -> @@ -1351,11 +1222,6 @@ decode_pty_opts2(<<Code, ?UINT32(Value), Tail/binary>>) -> end, [{Op, Value} | decode_pty_opts2(Tail)]. -decode_ip(Addr) when is_binary(Addr) -> - case inet_parse:address(binary_to_list(Addr)) of - {error,_} -> Addr; - {ok,A} -> A - end. backwards_compatible([], Acc) -> Acc; diff --git a/lib/ssh/src/ssh_connection_handler.erl b/lib/ssh/src/ssh_connection_handler.erl index 2bef6a41cd..946adcf384 100644 --- a/lib/ssh/src/ssh_connection_handler.erl +++ b/lib/ssh/src/ssh_connection_handler.erl @@ -28,94 +28,90 @@ -module(ssh_connection_handler). --behaviour(gen_fsm). +-behaviour(gen_statem). -include("ssh.hrl"). -include("ssh_transport.hrl"). -include("ssh_auth.hrl"). -include("ssh_connect.hrl"). --compile(export_all). --export([start_link/3]). -%% Internal application API --export([open_channel/6, reply_request/3, request/6, request/7, - global_request/4, send/5, send_eof/2, info/1, info/2, - connection_info/2, channel_info/3, - adjust_window/3, close/2, stop/1, renegotiate/1, renegotiate_data/1, - start_connection/4, - get_print_info/1]). - -%% gen_fsm callbacks --export([hello/2, kexinit/2, key_exchange/2, - key_exchange_dh_gex_init/2, key_exchange_dh_gex_reply/2, - new_keys/2, - service_request/2, connected/2, - userauth/2, - userauth_keyboard_interactive/2, - userauth_keyboard_interactive_info_response/2, - error/2]). - --export([init/1, handle_event/3, - handle_sync_event/4, handle_info/3, terminate/3, format_status/2, code_change/4]). - --record(state, { - role, - client, - starter, - auth_user, - connection_state, - latest_channel_id = 0, - idle_timer_ref, - transport_protocol, % ex: tcp - transport_cb, - transport_close_tag, - ssh_params, % #ssh{} - from ssh.hrl - socket, % socket() - decoded_data_buffer, % binary() - encoded_data_buffer, % binary() - undecoded_packet_length, % integer() - key_exchange_init_msg, % #ssh_msg_kexinit{} - renegotiate = false, % boolean() - last_size_rekey = 0, - event_queue = [], - connection_queue, - address, - port, - opts, - recbuf - }). - --type state_name() :: hello | kexinit | key_exchange | key_exchange_dh_gex_init | - key_exchange_dh_gex_reply | new_keys | service_request | - userauth | userauth_keyboard_interactive | - userauth_keyboard_interactive_info_response | - connection. - --type gen_fsm_state_return() :: {next_state, state_name(), term()} | - {next_state, state_name(), term(), timeout()} | - {stop, term(), term()}. - --type gen_fsm_sync_return() :: {next_state, state_name(), term()} | - {next_state, state_name(), term(), timeout()} | - {reply, term(), state_name(), term()} | - {stop, term(), term(), term()}. +%%==================================================================== +%%% Exports +%%==================================================================== + +%%% Start and stop +-export([start_link/3, + stop/1 + ]). + +%%% Internal application API +-export([start_connection/4, + open_channel/6, + request/6, request/7, + reply_request/3, + send/5, + send_eof/2, + info/1, info/2, + connection_info/2, + channel_info/3, + adjust_window/3, close/2, + disconnect/1, disconnect/2, + get_print_info/1 + ]). + +%%% Behaviour callbacks +-export([handle_event/4, terminate/3, format_status/2, code_change/4]). + +%%% Exports not intended to be used :). They are used for spawning and tests +-export([init_connection_handler/3, % proc_lib:spawn needs this + init_ssh_record/3, % Export of this internal function + % intended for low-level protocol test suites + renegotiate/1, renegotiate_data/1 % Export intended for test cases + ]). %%==================================================================== -%% Internal application API +%% Start / stop %%==================================================================== +%%-------------------------------------------------------------------- +-spec start_link(role(), + inet:socket(), + proplists:proplist() + ) -> {ok, pid()}. +%% . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . +start_link(Role, Socket, Options) -> + {ok, proc_lib:spawn_link(?MODULE, init_connection_handler, [Role, Socket, Options])}. + %%-------------------------------------------------------------------- --spec start_connection(client| server, port(), proplists:proplist(), - timeout()) -> {ok, pid()} | {error, term()}. +-spec stop(connection_ref() + ) -> ok | {error, term()}. +%% . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . +stop(ConnectionHandler)-> + case call(ConnectionHandler, stop) of + {error, closed} -> + ok; + Other -> + Other + end. + +%%==================================================================== +%% Internal application API +%%==================================================================== + +-define(DefaultTransport, {tcp, gen_tcp, tcp_closed} ). + %%-------------------------------------------------------------------- +-spec start_connection(role(), + inet:socket(), + proplists:proplist(), + timeout() + ) -> {ok, connection_ref()} | {error, term()}. +%% . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . start_connection(client = Role, Socket, Options, Timeout) -> try {ok, Pid} = sshc_sup:start_child([Role, Socket, Options]), - {_, Callback, _} = - proplists:get_value(transport, Options, {tcp, gen_tcp, tcp_closed}), - ok = socket_control(Socket, Pid, Callback), - Ref = erlang:monitor(process, Pid), - handshake(Pid, Ref, Timeout) + ok = socket_control(Socket, Pid, Options), + handshake(Pid, erlang:monitor(process,Pid), Timeout) catch exit:{noproc, _} -> {error, ssh_not_started}; @@ -128,8 +124,8 @@ start_connection(server = Role, Socket, Options, Timeout) -> try case proplists:get_value(parallel_login, SSH_Opts, false) of true -> - HandshakerPid = - spawn_link(fun() -> + HandshakerPid = + spawn_link(fun() -> receive {do_handshake, Pid} -> handshake(Pid, erlang:monitor(process,Pid), Timeout) @@ -148,953 +144,1123 @@ start_connection(server = Role, Socket, Options, Timeout) -> {error, Error} end. -start_the_connection_child(UserPid, Role, Socket, Options) -> - Sups = proplists:get_value(supervisors, Options), - ConnectionSup = proplists:get_value(connection_sup, Sups), - Opts = [{supervisors, Sups}, {user_pid, UserPid} | proplists:get_value(ssh_opts, Options, [])], - {ok, Pid} = ssh_connection_sup:start_child(ConnectionSup, [Role, Socket, Opts]), - {_, Callback, _} = proplists:get_value(transport, Options, {tcp, gen_tcp, tcp_closed}), - socket_control(Socket, Pid, Callback), - Pid. - +%%-------------------------------------------------------------------- +%%% Some other module has decided to disconnect. +-spec disconnect(#ssh_msg_disconnect{}) -> no_return(). +-spec disconnect(#ssh_msg_disconnect{}, iodata()) -> no_return(). +%% . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . +disconnect(Msg = #ssh_msg_disconnect{}) -> + throw({keep_state_and_data, + [{next_event, internal, {disconnect, Msg, Msg#ssh_msg_disconnect.description}}]}). -start_link(Role, Socket, Options) -> - {ok, proc_lib:spawn_link(?MODULE, init, [[Role, Socket, Options]])}. +disconnect(Msg = #ssh_msg_disconnect{}, ExtraInfo) -> + throw({keep_state_and_data, + [{next_event, internal, {disconnect, Msg, {Msg#ssh_msg_disconnect.description,ExtraInfo}}}]}). -init([Role, Socket, SshOpts]) -> - process_flag(trap_exit, true), - {NumVsn, StrVsn} = ssh_transport:versions(Role, SshOpts), - {Protocol, Callback, CloseTag} = - proplists:get_value(transport, SshOpts, {tcp, gen_tcp, tcp_closed}), - Cache = ssh_channel:cache_create(), - State0 = #state{ - role = Role, - connection_state = #connection{channel_cache = Cache, - channel_id_seed = 0, - port_bindings = [], - requests = [], - options = SshOpts}, - socket = Socket, - decoded_data_buffer = <<>>, - encoded_data_buffer = <<>>, - transport_protocol = Protocol, - transport_cb = Callback, - transport_close_tag = CloseTag, - opts = SshOpts - }, - - State = init_role(State0), - - try init_ssh(Role, NumVsn, StrVsn, SshOpts, Socket) of - Ssh -> - gen_fsm:enter_loop(?MODULE, [], hello, - State#state{ssh_params = Ssh}) - catch - _:Error -> - gen_fsm:enter_loop(?MODULE, [], error, {Error, State}) - end. -%% Temporary fix for the Nessus error. SYN-> <-SYNACK ACK-> RST-> ? -error(_Event, {Error,State=#state{}}) -> - case Error of - {badmatch,{error,enotconn}} -> - %% {error,enotconn} probably from inet:peername in - %% init_ssh(server,..)/5 called from init/1 - {stop, {shutdown,"TCP connenction to server was prematurely closed by the client"}, State}; - _ -> - {stop, {shutdown,{init,Error}}, State} - end; -error(Event, State) -> - %% State deliberately not checked beeing #state. This is a panic-clause... - {stop, {shutdown,{init,{spurious_error,Event}}}, State}. - -%%-------------------------------------------------------------------- --spec open_channel(pid(), string(), iodata(), integer(), integer(), - timeout()) -> {open, channel_id()} | {error, term()}. %%-------------------------------------------------------------------- -open_channel(ConnectionHandler, ChannelType, ChannelSpecificData, - InitialWindowSize, - MaxPacketSize, Timeout) -> - sync_send_all_state_event(ConnectionHandler, {open, self(), ChannelType, - InitialWindowSize, MaxPacketSize, - ChannelSpecificData, - Timeout}). -%%-------------------------------------------------------------------- --spec request(pid(), pid(), channel_id(), string(), boolean(), iodata(), - timeout()) -> success | failure | ok | {error, term()}. +-spec open_channel(connection_ref(), + string(), + iodata(), + pos_integer(), + pos_integer(), + timeout() + ) -> {open, channel_id()} | {error, term()}. + +%% . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . +open_channel(ConnectionHandler, + ChannelType, ChannelSpecificData, InitialWindowSize, MaxPacketSize, + Timeout) -> + call(ConnectionHandler, + {open, + self(), + ChannelType, InitialWindowSize, MaxPacketSize, ChannelSpecificData, + Timeout}). + %%-------------------------------------------------------------------- +-spec request(connection_ref(), + pid(), + channel_id(), + string(), + boolean(), + iodata(), + timeout() + ) -> success | failure | ok | {error,timeout}. + +-spec request(connection_ref(), + channel_id(), + string(), + boolean(), + iodata(), + timeout() + ) -> success | failure | ok | {error,timeout}. +%% . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . request(ConnectionHandler, ChannelPid, ChannelId, Type, true, Data, Timeout) -> - sync_send_all_state_event(ConnectionHandler, {request, ChannelPid, ChannelId, Type, Data, - Timeout}); + call(ConnectionHandler, {request, ChannelPid, ChannelId, Type, Data, Timeout}); request(ConnectionHandler, ChannelPid, ChannelId, Type, false, Data, _) -> - send_all_state_event(ConnectionHandler, {request, ChannelPid, ChannelId, Type, Data}). + cast(ConnectionHandler, {request, ChannelPid, ChannelId, Type, Data}). -%%-------------------------------------------------------------------- --spec request(pid(), channel_id(), string(), boolean(), iodata(), - timeout()) -> success | failure | {error, timeout}. -%%-------------------------------------------------------------------- request(ConnectionHandler, ChannelId, Type, true, Data, Timeout) -> - sync_send_all_state_event(ConnectionHandler, {request, ChannelId, Type, Data, Timeout}); + call(ConnectionHandler, {request, ChannelId, Type, Data, Timeout}); request(ConnectionHandler, ChannelId, Type, false, Data, _) -> - send_all_state_event(ConnectionHandler, {request, ChannelId, Type, Data}). + cast(ConnectionHandler, {request, ChannelId, Type, Data}). %%-------------------------------------------------------------------- --spec reply_request(pid(), success | failure, channel_id()) -> ok. -%%-------------------------------------------------------------------- +-spec reply_request(connection_ref(), + success | failure, + channel_id() + ) -> ok. + +%% . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . reply_request(ConnectionHandler, Status, ChannelId) -> - send_all_state_event(ConnectionHandler, {reply_request, Status, ChannelId}). - -%%-------------------------------------------------------------------- --spec global_request(pid(), string(), boolean(), iolist()) -> ok | error. -%%-------------------------------------------------------------------- -global_request(ConnectionHandler, Type, true = Reply, Data) -> - case sync_send_all_state_event(ConnectionHandler, - {global_request, self(), Type, Reply, Data}) of - {ssh_cm, ConnectionHandler, {success, _}} -> - ok; - {ssh_cm, ConnectionHandler, {failure, _}} -> - error - end; -global_request(ConnectionHandler, Type, false = Reply, Data) -> - send_all_state_event(ConnectionHandler, {global_request, self(), Type, Reply, Data}). + cast(ConnectionHandler, {reply_request, Status, ChannelId}). %%-------------------------------------------------------------------- --spec send(pid(), channel_id(), integer(), iodata(), timeout()) -> - ok | {error, timeout} | {error, closed}. -%%-------------------------------------------------------------------- +-spec send(connection_ref(), + channel_id(), + non_neg_integer(), + iodata(), + timeout() + ) -> ok | {error, timeout|closed}. +%% . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . send(ConnectionHandler, ChannelId, Type, Data, Timeout) -> - sync_send_all_state_event(ConnectionHandler, {data, ChannelId, Type, Data, Timeout}). + call(ConnectionHandler, {data, ChannelId, Type, Data, Timeout}). %%-------------------------------------------------------------------- --spec send_eof(pid(), channel_id()) -> ok | {error, closed}. -%%-------------------------------------------------------------------- +-spec send_eof(connection_ref(), + channel_id() + ) -> ok | {error,closed}. +%% . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . send_eof(ConnectionHandler, ChannelId) -> - sync_send_all_state_event(ConnectionHandler, {eof, ChannelId}). + call(ConnectionHandler, {eof, ChannelId}). %%-------------------------------------------------------------------- --spec connection_info(pid(), [atom()]) -> proplists:proplist(). +-spec info(connection_ref() + ) -> {ok, [#channel{}]} . + +-spec info(connection_ref(), + pid() | all + ) -> {ok, [#channel{}]} . +%% . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . +info(ConnectionHandler) -> + info(ConnectionHandler, all). + +info(ConnectionHandler, ChannelProcess) -> + call(ConnectionHandler, {info, ChannelProcess}). + %%-------------------------------------------------------------------- +-type local_sock_info() :: {inet:ip_address(), non_neg_integer()} | string(). +-type peer_sock_info() :: {inet:ip_address(), non_neg_integer()} | string(). +-type state_info() :: iolist(). + +-spec get_print_info(connection_ref() + ) -> {{local_sock_info(), peer_sock_info()}, + state_info() + }. +%% . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . get_print_info(ConnectionHandler) -> - sync_send_all_state_event(ConnectionHandler, get_print_info, 1000). + call(ConnectionHandler, get_print_info, 1000). +%%-------------------------------------------------------------------- +-spec connection_info(connection_ref(), + [atom()] + ) -> proplists:proplist(). +%% . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . connection_info(ConnectionHandler, Options) -> - sync_send_all_state_event(ConnectionHandler, {connection_info, Options}). + call(ConnectionHandler, {connection_info, Options}). %%-------------------------------------------------------------------- --spec channel_info(pid(), channel_id(), [atom()]) -> proplists:proplist(). -%%-------------------------------------------------------------------- +-spec channel_info(connection_ref(), + channel_id(), + [atom()] + ) -> proplists:proplist(). +%% . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . channel_info(ConnectionHandler, ChannelId, Options) -> - sync_send_all_state_event(ConnectionHandler, {channel_info, ChannelId, Options}). + call(ConnectionHandler, {channel_info, ChannelId, Options}). %%-------------------------------------------------------------------- --spec adjust_window(pid(), channel_id(), integer()) -> ok. -%%-------------------------------------------------------------------- +-spec adjust_window(connection_ref(), + channel_id(), + integer() + ) -> ok. +%% . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . adjust_window(ConnectionHandler, Channel, Bytes) -> - send_all_state_event(ConnectionHandler, {adjust_window, Channel, Bytes}). -%%-------------------------------------------------------------------- --spec renegotiate(pid()) -> ok. -%%-------------------------------------------------------------------- -renegotiate(ConnectionHandler) -> - send_all_state_event(ConnectionHandler, renegotiate). - -%%-------------------------------------------------------------------- --spec renegotiate_data(pid()) -> ok. -%%-------------------------------------------------------------------- -renegotiate_data(ConnectionHandler) -> - send_all_state_event(ConnectionHandler, data_size). + cast(ConnectionHandler, {adjust_window, Channel, Bytes}). %%-------------------------------------------------------------------- --spec close(pid(), channel_id()) -> ok. -%%-------------------------------------------------------------------- +-spec close(connection_ref(), + channel_id() + ) -> ok. +%% . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . close(ConnectionHandler, ChannelId) -> - case sync_send_all_state_event(ConnectionHandler, {close, ChannelId}) of + case call(ConnectionHandler, {close, ChannelId}) of ok -> ok; - {error, closed} -> + {error, closed} -> ok - end. - -%%-------------------------------------------------------------------- --spec stop(pid()) -> ok | {error, term()}. -%%-------------------------------------------------------------------- -stop(ConnectionHandler)-> - case sync_send_all_state_event(ConnectionHandler, stop) of - {error, closed} -> - ok; - Other -> - Other end. -info(ConnectionHandler) -> - info(ConnectionHandler, {info, all}). +%%==================================================================== +%% Test support +%%==================================================================== +%%-------------------------------------------------------------------- +-spec renegotiate(connection_ref() + ) -> ok. +%% . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . +renegotiate(ConnectionHandler) -> + cast(ConnectionHandler, renegotiate). -info(ConnectionHandler, ChannelProcess) -> - sync_send_all_state_event(ConnectionHandler, {info, ChannelProcess}). +%%-------------------------------------------------------------------- +-spec renegotiate_data(connection_ref() + ) -> ok. +%% . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . +renegotiate_data(ConnectionHandler) -> + cast(ConnectionHandler, data_size). %%==================================================================== -%% gen_fsm callbacks +%% Internal process state %%==================================================================== +-record(data, { + starter :: pid(), + auth_user :: string() + | undefined, + connection_state :: #connection{}, + latest_channel_id = 0 :: non_neg_integer(), + idle_timer_ref :: undefined + | infinity + | reference(), + idle_timer_value = infinity :: infinity + | pos_integer(), + transport_protocol :: atom(), % ex: tcp + transport_cb :: atom(), % ex: gen_tcp + transport_close_tag :: atom(), % ex: tcp_closed + ssh_params :: #ssh{} + | undefined, + socket :: inet:socket(), + decrypted_data_buffer = <<>> :: binary(), + encrypted_data_buffer = <<>> :: binary(), + undecrypted_packet_length :: undefined | non_neg_integer(), + key_exchange_init_msg :: #ssh_msg_kexinit{} + | undefined, + last_size_rekey = 0 :: non_neg_integer(), + event_queue = [] :: list(), + opts :: proplists:proplist(), + inet_initial_recbuf_size :: pos_integer() + | undefined + }). +%%==================================================================== +%% Intitialisation +%%==================================================================== %%-------------------------------------------------------------------- --spec hello(socket_control | {info_line, list()} | {version_exchange, list()}, - #state{}) -> gen_fsm_state_return(). +-spec init_connection_handler(role(), + inet:socket(), + proplists:proplist() + ) -> no_return(). +%% . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . +init_connection_handler(Role, Socket, Opts) -> + process_flag(trap_exit, true), + S0 = init_process_state(Role, Socket, Opts), + try + {Protocol, Callback, CloseTag} = + proplists:get_value(transport, Opts, ?DefaultTransport), + S0#data{ssh_params = init_ssh_record(Role, Socket, Opts), + transport_protocol = Protocol, + transport_cb = Callback, + transport_close_tag = CloseTag + } + of + S -> + gen_statem:enter_loop(?MODULE, + [], %%[{debug,[trace,log,statistics,debug]} || Role==server], + handle_event_function, + {hello,Role}, + S) + catch + _:Error -> + gen_statem:enter_loop(?MODULE, + [], + handle_event_function, + {init_error,Error}, + S0) + end. + + +init_process_state(Role, Socket, Opts) -> + D = #data{connection_state = + C = #connection{channel_cache = ssh_channel:cache_create(), + channel_id_seed = 0, + port_bindings = [], + requests = [], + options = Opts}, + starter = proplists:get_value(user_pid, Opts), + socket = Socket, + opts = Opts + }, + case Role of + client -> + %% Start the renegotiation timers + timer:apply_after(?REKEY_TIMOUT, gen_statem, cast, [self(), renegotiate]), + timer:apply_after(?REKEY_DATA_TIMOUT, gen_statem, cast, [self(), data_size]), + cache_init_idle_timer(D); + server -> + D#data{connection_state = init_connection(Role, C, Opts)} + end. + + +init_connection(server, C = #connection{}, Opts) -> + Sups = proplists:get_value(supervisors, Opts), + SystemSup = proplists:get_value(system_sup, Sups), + SubSystemSup = proplists:get_value(subsystem_sup, Sups), + ConnectionSup = proplists:get_value(connection_sup, Sups), + Shell = proplists:get_value(shell, Opts), + Exec = proplists:get_value(exec, Opts), + CliSpec = proplists:get_value(ssh_cli, Opts, {ssh_cli, [Shell]}), + C#connection{cli_spec = CliSpec, + exec = Exec, + system_supervisor = SystemSup, + sub_system_supervisor = SubSystemSup, + connection_supervisor = ConnectionSup + }. + + +init_ssh_record(Role, Socket, Opts) -> + {ok, PeerAddr} = inet:peername(Socket), + KeyCb = proplists:get_value(key_cb, Opts, ssh_file), + AuthMethods = proplists:get_value(auth_methods, Opts, ?SUPPORTED_AUTH_METHODS), + S0 = #ssh{role = Role, + key_cb = KeyCb, + opts = Opts, + userauth_supported_methods = AuthMethods, + available_host_keys = supported_host_keys(Role, KeyCb, Opts), + random_length_padding = proplists:get_value(max_random_length_padding, + Opts, + (#ssh{})#ssh.random_length_padding) + }, + + {Vsn, Version} = ssh_transport:versions(Role, Opts), + case Role of + client -> + PeerName = proplists:get_value(host, Opts), + S0#ssh{c_vsn = Vsn, + c_version = Version, + io_cb = case proplists:get_value(user_interaction, Opts, true) of + true -> ssh_io; + false -> ssh_no_io + end, + userauth_quiet_mode = proplists:get_value(quiet_mode, Opts, false), + peer = {PeerName, PeerAddr} + }; + + server -> + S0#ssh{s_vsn = Vsn, + s_version = Version, + io_cb = proplists:get_value(io_cb, Opts, ssh_io), + userauth_methods = string:tokens(AuthMethods, ","), + kb_tries_left = 3, + peer = {undefined, PeerAddr} + } + end. + + + +%%==================================================================== +%% gen_statem callbacks +%%==================================================================== %%-------------------------------------------------------------------- +-type event_content() :: any(). + +-type renegotiate_flag() :: init | renegotiate. + +-type state_name() :: + {init_error,any()} + | {hello, role()} + | {kexinit, role(), renegotiate_flag()} + | {key_exchange, role(), renegotiate_flag()} + | {key_exchange_dh_gex_init, server, renegotiate_flag()} + | {key_exchange_dh_gex_reply, client, renegotiate_flag()} + | {new_keys, role()} + | {service_request, role()} + | {userauth, role()} + | {userauth_keyboard_interactive, role()} + | {connected, role()} + . + +-type handle_event_result() :: gen_statem:handle_event_result(). + +-spec handle_event(gen_statem:event_type(), + event_content(), + state_name(), + #data{} + ) -> handle_event_result(). + +%% . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . + +%%% ######## Error in the initialisation #### + +handle_event(_, _Event, {init_error,Error}, _) -> + case Error of + {badmatch,{error,enotconn}} -> + %% Handles the abnormal sequence: + %% SYN-> + %% <-SYNACK + %% ACK-> + %% RST-> + {stop, {shutdown,"TCP connenction to server was prematurely closed by the client"}}; + + OtherError -> + {stop, {shutdown,{init,OtherError}}} + end; -hello(socket_control, #state{socket = Socket, ssh_params = Ssh} = State) -> - VsnMsg = ssh_transport:hello_version_msg(string_version(Ssh)), - send_msg(VsnMsg, State), - case getopt(recbuf, Socket) of - {ok, Size} -> - inet:setopts(Socket, [{packet, line}, {active, once}, {recbuf, ?MAX_PROTO_VERSION}]), - {next_state, hello, State#state{recbuf = Size}}; - {error, Reason} -> - {stop, {shutdown, Reason}, State} + +%%% ######## {hello, client|server} #### +%% The very first event that is sent when the we are set as controlling process of Socket +handle_event(_, socket_control, {hello,_}, D) -> + VsnMsg = ssh_transport:hello_version_msg(string_version(D#data.ssh_params)), + ok = send_bytes(VsnMsg, D), + case inet:getopts(Socket=D#data.socket, [recbuf]) of + {ok, [{recbuf,Size}]} -> + %% Set the socket to the hello text line handling mode: + inet:setopts(Socket, [{packet, line}, + {active, once}, + % Expecting the version string which might + % be max ?MAX_PROTO_VERSION bytes: + {recbuf, ?MAX_PROTO_VERSION}, + {nodelay,true}]), + {keep_state, D#data{inet_initial_recbuf_size=Size}}; + + Other -> + {stop, {shutdown,{unexpected_getopts_return, Other}}} end; -hello({info_line, _Line},#state{role = client, socket = Socket} = State) -> - %% The server may send info lines before the version_exchange - inet:setopts(Socket, [{active, once}]), - {next_state, hello, State}; - -hello({info_line, _Line},#state{role = server, - socket = Socket, - transport_cb = Transport } = State) -> - %% as openssh - Transport:send(Socket, "Protocol mismatch."), - {stop, {shutdown,"Protocol mismatch in version exchange."}, State}; - -hello({version_exchange, Version}, #state{ssh_params = Ssh0, - socket = Socket, - recbuf = Size} = State) -> +handle_event(_, {info_line,_Line}, {hello,Role}, D) -> + case Role of + client -> + %% The server may send info lines to the client before the version_exchange + inet:setopts(D#data.socket, [{active, once}]), + keep_state_and_data; + server -> + %% But the client may NOT send them to the server. Openssh answers with cleartext, + %% and so do we + ok = send_bytes("Protocol mismatch.", D), + {stop, {shutdown,"Protocol mismatch in version exchange. Client sent info lines."}} + end; + +handle_event(_, {version_exchange,Version}, {hello,Role}, D) -> {NumVsn, StrVsn} = ssh_transport:handle_hello_version(Version), - case handle_version(NumVsn, StrVsn, Ssh0) of + case handle_version(NumVsn, StrVsn, D#data.ssh_params) of {ok, Ssh1} -> - inet:setopts(Socket, [{packet,0}, {mode,binary}, {active, once}, {recbuf, Size}]), + %% Since the hello part is finnished correctly, we set the + %% socket to the packet handling mode (including recbuf size): + inet:setopts(D#data.socket, [{packet,0}, + {mode,binary}, + {active, once}, + {recbuf, D#data.inet_initial_recbuf_size}]), {KeyInitMsg, SshPacket, Ssh} = ssh_transport:key_exchange_init_msg(Ssh1), - send_msg(SshPacket, State), - {next_state, kexinit, next_packet(State#state{ssh_params = Ssh, - key_exchange_init_msg = - KeyInitMsg})}; + ok = send_bytes(SshPacket, D), + {next_state, {kexinit,Role,init}, D#data{ssh_params = Ssh, + key_exchange_init_msg = KeyInitMsg}}; not_supported -> - DisconnectMsg = - #ssh_msg_disconnect{code = - ?SSH_DISCONNECT_PROTOCOL_VERSION_NOT_SUPPORTED, - description = "Protocol version " ++ StrVsn - ++ " not supported", - language = "en"}, - handle_disconnect(DisconnectMsg, State) - end. + disconnect( + #ssh_msg_disconnect{code = ?SSH_DISCONNECT_PROTOCOL_VERSION_NOT_SUPPORTED, + description = ["Protocol version ",StrVsn," not supported"]}, + {next_state, {hello,Role}, D}) + end; -%%-------------------------------------------------------------------- --spec kexinit({#ssh_msg_kexinit{}, binary()}, #state{}) -> gen_fsm_state_return(). -%%-------------------------------------------------------------------- -kexinit({#ssh_msg_kexinit{} = Kex, Payload}, - #state{ssh_params = #ssh{role = Role} = Ssh0, - key_exchange_init_msg = OwnKex} = - State) -> - Ssh1 = ssh_transport:key_init(opposite_role(Role), Ssh0, Payload), - case ssh_transport:handle_kexinit_msg(Kex, OwnKex, Ssh1) of - {ok, NextKexMsg, Ssh} when Role == client -> - send_msg(NextKexMsg, State), - {next_state, key_exchange, - next_packet(State#state{ssh_params = Ssh})}; - {ok, Ssh} when Role == server -> - {next_state, key_exchange, - next_packet(State#state{ssh_params = Ssh})} - end. + +%%% ######## {kexinit, client|server, init|renegotiate} #### -%%-------------------------------------------------------------------- --spec key_exchange(#ssh_msg_kexdh_init{} | #ssh_msg_kexdh_reply{} | - #ssh_msg_kex_dh_gex_group{} | #ssh_msg_kex_dh_gex_request{} | - #ssh_msg_kex_dh_gex_request{} | #ssh_msg_kex_dh_gex_reply{}, #state{}) - -> gen_fsm_state_return(). -%%-------------------------------------------------------------------- +handle_event(_, {#ssh_msg_kexinit{}=Kex, Payload}, {kexinit,Role,ReNeg}, + D = #data{key_exchange_init_msg = OwnKex}) -> + Ssh1 = ssh_transport:key_init(peer_role(Role), D#data.ssh_params, Payload), + Ssh = case ssh_transport:handle_kexinit_msg(Kex, OwnKex, Ssh1) of + {ok, NextKexMsg, Ssh2} when Role==client -> + ok = send_bytes(NextKexMsg, D), + Ssh2; + {ok, Ssh2} when Role==server -> + Ssh2 + end, + {next_state, {key_exchange,Role,ReNeg}, D#data{ssh_params=Ssh}}; -key_exchange(#ssh_msg_kexdh_init{} = Msg, - #state{ssh_params = #ssh{role = server} = Ssh0} = State) -> - case ssh_transport:handle_kexdh_init(Msg, Ssh0) of - {ok, KexdhReply, Ssh1} -> - send_msg(KexdhReply, State), - {ok, NewKeys, Ssh} = ssh_transport:new_keys_message(Ssh1), - send_msg(NewKeys, State), - {next_state, new_keys, next_packet(State#state{ssh_params = Ssh})} - end; -key_exchange(#ssh_msg_kexdh_reply{} = Msg, - #state{ssh_params = #ssh{role = client} = Ssh0} = State) -> - {ok, NewKeys, Ssh} = ssh_transport:handle_kexdh_reply(Msg, Ssh0), - send_msg(NewKeys, State), - {next_state, new_keys, next_packet(State#state{ssh_params = Ssh})}; - -key_exchange(#ssh_msg_kex_dh_gex_request{} = Msg, - #state{ssh_params = #ssh{role = server} = Ssh0} = State) -> - {ok, GexGroup, Ssh} = ssh_transport:handle_kex_dh_gex_request(Msg, Ssh0), - send_msg(GexGroup, State), - {next_state, key_exchange_dh_gex_init, next_packet(State#state{ssh_params = Ssh})}; - -key_exchange(#ssh_msg_kex_dh_gex_request_old{} = Msg, - #state{ssh_params = #ssh{role = server} = Ssh0} = State) -> - {ok, GexGroup, Ssh} = ssh_transport:handle_kex_dh_gex_request(Msg, Ssh0), - send_msg(GexGroup, State), - {next_state, key_exchange_dh_gex_init, next_packet(State#state{ssh_params = Ssh})}; - -key_exchange(#ssh_msg_kex_dh_gex_group{} = Msg, - #state{ssh_params = #ssh{role = client} = Ssh0} = State) -> - {ok, KexGexInit, Ssh} = ssh_transport:handle_kex_dh_gex_group(Msg, Ssh0), - send_msg(KexGexInit, State), - {next_state, key_exchange_dh_gex_reply, next_packet(State#state{ssh_params = Ssh})}; - -key_exchange(#ssh_msg_kex_ecdh_init{} = Msg, - #state{ssh_params = #ssh{role = server} = Ssh0} = State) -> - {ok, KexEcdhReply, Ssh1} = ssh_transport:handle_kex_ecdh_init(Msg, Ssh0), - send_msg(KexEcdhReply, State), +%%% ######## {key_exchange, client|server, init|renegotiate} #### + +%%%---- diffie-hellman +handle_event(_, #ssh_msg_kexdh_init{} = Msg, {key_exchange,server,ReNeg}, D) -> + {ok, KexdhReply, Ssh1} = ssh_transport:handle_kexdh_init(Msg, D#data.ssh_params), + ok = send_bytes(KexdhReply, D), + {ok, NewKeys, Ssh} = ssh_transport:new_keys_message(Ssh1), + ok = send_bytes(NewKeys, D), + {next_state, {new_keys,server,ReNeg}, D#data{ssh_params=Ssh}}; + +handle_event(_, #ssh_msg_kexdh_reply{} = Msg, {key_exchange,client,ReNeg}, D) -> + {ok, NewKeys, Ssh} = ssh_transport:handle_kexdh_reply(Msg, D#data.ssh_params), + ok = send_bytes(NewKeys, D), + {next_state, {new_keys,client,ReNeg}, D#data{ssh_params=Ssh}}; + +%%%---- diffie-hellman group exchange +handle_event(_, #ssh_msg_kex_dh_gex_request{} = Msg, {key_exchange,server,ReNeg}, D) -> + {ok, GexGroup, Ssh} = ssh_transport:handle_kex_dh_gex_request(Msg, D#data.ssh_params), + ok = send_bytes(GexGroup, D), + {next_state, {key_exchange_dh_gex_init,server,ReNeg}, D#data{ssh_params=Ssh}}; + +handle_event(_, #ssh_msg_kex_dh_gex_request_old{} = Msg, {key_exchange,server,ReNeg}, D) -> + {ok, GexGroup, Ssh} = ssh_transport:handle_kex_dh_gex_request(Msg, D#data.ssh_params), + ok = send_bytes(GexGroup, D), + {next_state, {key_exchange_dh_gex_init,server,ReNeg}, D#data{ssh_params=Ssh}}; + +handle_event(_, #ssh_msg_kex_dh_gex_group{} = Msg, {key_exchange,client,ReNeg}, D) -> + {ok, KexGexInit, Ssh} = ssh_transport:handle_kex_dh_gex_group(Msg, D#data.ssh_params), + ok = send_bytes(KexGexInit, D), + {next_state, {key_exchange_dh_gex_reply,client,ReNeg}, D#data{ssh_params=Ssh}}; + +%%%---- elliptic curve diffie-hellman +handle_event(_, #ssh_msg_kex_ecdh_init{} = Msg, {key_exchange,server,ReNeg}, D) -> + {ok, KexEcdhReply, Ssh1} = ssh_transport:handle_kex_ecdh_init(Msg, D#data.ssh_params), + ok = send_bytes(KexEcdhReply, D), {ok, NewKeys, Ssh} = ssh_transport:new_keys_message(Ssh1), - send_msg(NewKeys, State), - {next_state, new_keys, next_packet(State#state{ssh_params = Ssh})}; + ok = send_bytes(NewKeys, D), + {next_state, {new_keys,server,ReNeg}, D#data{ssh_params=Ssh}}; -key_exchange(#ssh_msg_kex_ecdh_reply{} = Msg, - #state{ssh_params = #ssh{role = client} = Ssh0} = State) -> - {ok, NewKeys, Ssh} = ssh_transport:handle_kex_ecdh_reply(Msg, Ssh0), - send_msg(NewKeys, State), - {next_state, new_keys, next_packet(State#state{ssh_params = Ssh})}. +handle_event(_, #ssh_msg_kex_ecdh_reply{} = Msg, {key_exchange,client,ReNeg}, D) -> + {ok, NewKeys, Ssh} = ssh_transport:handle_kex_ecdh_reply(Msg, D#data.ssh_params), + ok = send_bytes(NewKeys, D), + {next_state, {new_keys,client,ReNeg}, D#data{ssh_params=Ssh}}; -%%-------------------------------------------------------------------- --spec key_exchange_dh_gex_init(#ssh_msg_kex_dh_gex_init{}, #state{}) -> gen_fsm_state_return(). -%%-------------------------------------------------------------------- -key_exchange_dh_gex_init(#ssh_msg_kex_dh_gex_init{} = Msg, - #state{ssh_params = #ssh{role = server} = Ssh0} = State) -> - {ok, KexGexReply, Ssh1} = ssh_transport:handle_kex_dh_gex_init(Msg, Ssh0), - send_msg(KexGexReply, State), + +%%% ######## {key_exchange_dh_gex_init, server, init|renegotiate} #### + +handle_event(_, #ssh_msg_kex_dh_gex_init{} = Msg, {key_exchange_dh_gex_init,server,ReNeg}, D) -> + {ok, KexGexReply, Ssh1} = ssh_transport:handle_kex_dh_gex_init(Msg, D#data.ssh_params), + ok = send_bytes(KexGexReply, D), {ok, NewKeys, Ssh} = ssh_transport:new_keys_message(Ssh1), - send_msg(NewKeys, State), - {next_state, new_keys, next_packet(State#state{ssh_params = Ssh})}. + ok = send_bytes(NewKeys, D), + {next_state, {new_keys,server,ReNeg}, D#data{ssh_params=Ssh}}; -%%-------------------------------------------------------------------- --spec key_exchange_dh_gex_reply(#ssh_msg_kex_dh_gex_reply{}, #state{}) -> gen_fsm_state_return(). -%%-------------------------------------------------------------------- -key_exchange_dh_gex_reply(#ssh_msg_kex_dh_gex_reply{} = Msg, - #state{ssh_params = #ssh{role = client} = Ssh0} = State) -> - {ok, NewKeys, Ssh1} = ssh_transport:handle_kex_dh_gex_reply(Msg, Ssh0), - send_msg(NewKeys, State), - {next_state, new_keys, next_packet(State#state{ssh_params = Ssh1})}. -%%-------------------------------------------------------------------- --spec new_keys(#ssh_msg_newkeys{}, #state{}) -> gen_fsm_state_return(). -%%-------------------------------------------------------------------- +%%% ######## {key_exchange_dh_gex_reply, client, init|renegotiate} #### -new_keys(#ssh_msg_newkeys{} = Msg, #state{ssh_params = Ssh0} = State0) -> - {ok, Ssh} = ssh_transport:handle_new_keys(Msg, Ssh0), - after_new_keys(next_packet(State0#state{ssh_params = Ssh})). +handle_event(_, #ssh_msg_kex_dh_gex_reply{} = Msg, {key_exchange_dh_gex_reply,client,ReNeg}, D) -> + {ok, NewKeys, Ssh1} = ssh_transport:handle_kex_dh_gex_reply(Msg, D#data.ssh_params), + ok = send_bytes(NewKeys, D), + {next_state, {new_keys,client,ReNeg}, D#data{ssh_params=Ssh1}}; -%%-------------------------------------------------------------------- --spec service_request(#ssh_msg_service_request{} | #ssh_msg_service_accept{}, - #state{}) -> gen_fsm_state_return(). -%%-------------------------------------------------------------------- -service_request(#ssh_msg_service_request{name = "ssh-userauth"} = Msg, - #state{ssh_params = #ssh{role = server, - session_id = SessionId} = Ssh0} = State) -> - {ok, {Reply, Ssh}} = ssh_auth:handle_userauth_request(Msg, SessionId, Ssh0), - send_msg(Reply, State), - {next_state, userauth, next_packet(State#state{ssh_params = Ssh})}; - -service_request(#ssh_msg_service_accept{name = "ssh-userauth"}, - #state{ssh_params = #ssh{role = client, - service = "ssh-userauth"} = Ssh0} = - State) -> + +%%% ######## {new_keys, client|server} #### + +%% First key exchange round: +handle_event(_, #ssh_msg_newkeys{} = Msg, {new_keys,Role,init}, D) -> + {ok, Ssh1} = ssh_transport:handle_new_keys(Msg, D#data.ssh_params), + Ssh = case Role of + client -> + {MsgReq, Ssh2} = ssh_auth:service_request_msg(Ssh1), + ok = send_bytes(MsgReq, D), + Ssh2; + server -> + Ssh1 + end, + {next_state, {service_request,Role}, D#data{ssh_params=Ssh}}; + +%% Subsequent key exchange rounds (renegotiation): +handle_event(_, #ssh_msg_newkeys{}, {new_keys,Role,renegotiate}, D) -> + {next_state, {connected,Role}, D}; + +%%% ######## {service_request, client|server} + +handle_event(_, Msg = #ssh_msg_service_request{name=ServiceName}, StateName = {service_request,server}, D) -> + case ServiceName of + "ssh-userauth" -> + Ssh0 = #ssh{session_id=SessionId} = D#data.ssh_params, + {ok, {Reply, Ssh}} = ssh_auth:handle_userauth_request(Msg, SessionId, Ssh0), + ok = send_bytes(Reply, D), + {next_state, {userauth,server}, D#data{ssh_params = Ssh}}; + + _ -> + disconnect(#ssh_msg_disconnect{code = ?SSH_DISCONNECT_SERVICE_NOT_AVAILABLE, + description = "Unknown service"}, + StateName, D) + end; + +handle_event(_, #ssh_msg_service_accept{name = "ssh-userauth"}, {service_request,client}, + #data{ssh_params = #ssh{service="ssh-userauth"} = Ssh0} = State) -> {Msg, Ssh} = ssh_auth:init_userauth_request_msg(Ssh0), - send_msg(Msg, State), - {next_state, userauth, next_packet(State#state{auth_user = Ssh#ssh.user, ssh_params = Ssh})}. + ok = send_bytes(Msg, State), + {next_state, {userauth,client}, State#data{auth_user = Ssh#ssh.user, ssh_params = Ssh}}; -%%-------------------------------------------------------------------- --spec userauth(#ssh_msg_userauth_request{} | #ssh_msg_userauth_info_request{} | - #ssh_msg_userauth_info_response{} | #ssh_msg_userauth_success{} | - #ssh_msg_userauth_failure{} | #ssh_msg_userauth_banner{}, - #state{}) -> gen_fsm_state_return(). -%%-------------------------------------------------------------------- -userauth(#ssh_msg_userauth_request{service = "ssh-connection", - method = "none"} = Msg, - #state{ssh_params = #ssh{session_id = SessionId, role = server, - service = "ssh-connection"} = Ssh0 - } = State) -> - {not_authorized, {_User, _Reason}, {Reply, Ssh}} = - ssh_auth:handle_userauth_request(Msg, SessionId, Ssh0), - send_msg(Reply, State), - {next_state, userauth, next_packet(State#state{ssh_params = Ssh})}; - -userauth(#ssh_msg_userauth_request{service = "ssh-connection", - method = Method} = Msg, - #state{ssh_params = #ssh{session_id = SessionId, role = server, - service = "ssh-connection", - peer = {_, Address}} = Ssh0, - opts = Opts, starter = Pid} = State) -> - case lists:member(Method, Ssh0#ssh.userauth_methods) of - true -> - case ssh_auth:handle_userauth_request(Msg, SessionId, Ssh0) of - {authorized, User, {Reply, Ssh}} -> - send_msg(Reply, State), - Pid ! ssh_connected, - connected_fun(User, Address, Method, Opts), - {next_state, connected, - next_packet(State#state{auth_user = User, ssh_params = Ssh#ssh{authenticated = true}})}; - {not_authorized, {User, Reason}, {Reply, Ssh}} when Method == "keyboard-interactive" -> - retry_fun(User, Address, Reason, Opts), - send_msg(Reply, State), - {next_state, userauth_keyboard_interactive, next_packet(State#state{ssh_params = Ssh})}; - {not_authorized, {User, Reason}, {Reply, Ssh}} -> - retry_fun(User, Address, Reason, Opts), - send_msg(Reply, State), - {next_state, userauth, next_packet(State#state{ssh_params = Ssh})} + +%%% ######## {userauth, client|server} #### + +%%---- userauth request to server +handle_event(_, + Msg = #ssh_msg_userauth_request{service = ServiceName, method = Method}, + StateName = {userauth,server}, + D = #data{ssh_params=Ssh0}) -> + + case {ServiceName, Ssh0#ssh.service, Method} of + {"ssh-connection", "ssh-connection", "none"} -> + %% Probably the very first userauth_request but we deny unauthorized login + {not_authorized, _, {Reply,Ssh}} = + ssh_auth:handle_userauth_request(Msg, Ssh0#ssh.session_id, Ssh0), + ok = send_bytes(Reply, D), + {keep_state, D#data{ssh_params = Ssh}}; + + {"ssh-connection", "ssh-connection", Method} -> + %% Userauth request with a method like "password" or so + case lists:member(Method, Ssh0#ssh.userauth_methods) of + true -> + %% Yepp! we support this method + case ssh_auth:handle_userauth_request(Msg, Ssh0#ssh.session_id, Ssh0) of + {authorized, User, {Reply, Ssh}} -> + ok = send_bytes(Reply, D), + D#data.starter ! ssh_connected, + connected_fun(User, Method, D), + {next_state, {connected,server}, + D#data{auth_user = User, + ssh_params = Ssh#ssh{authenticated = true}}}; + {not_authorized, {User, Reason}, {Reply, Ssh}} when Method == "keyboard-interactive" -> + retry_fun(User, Reason, D), + ok = send_bytes(Reply, D), + {next_state, {userauth_keyboard_interactive,server}, D#data{ssh_params = Ssh}}; + {not_authorized, {User, Reason}, {Reply, Ssh}} -> + retry_fun(User, Reason, D), + ok = send_bytes(Reply, D), + {keep_state, D#data{ssh_params = Ssh}} + end; + false -> + %% No we do not support this method (=/= none) + %% At least one non-erlang client does like this. Retry as the next event + {keep_state_and_data, + [{next_event, internal, Msg#ssh_msg_userauth_request{method="none"}}] + } end; - false -> - userauth(Msg#ssh_msg_userauth_request{method="none"}, State) + + %% {"ssh-connection", Expected, Method} when Expected =/= ServiceName -> Do what? + %% {ServiceName, Expected, Method} when Expected =/= ServiceName -> Do what? + + {ServiceName, _, _} when ServiceName =/= "ssh-connection" -> + disconnect(#ssh_msg_disconnect{code = ?SSH_DISCONNECT_SERVICE_NOT_AVAILABLE, + description = "Unknown service"}, + StateName, D) end; -userauth(#ssh_msg_userauth_success{}, #state{ssh_params = #ssh{role = client} = Ssh, - starter = Pid} = State) -> - Pid ! ssh_connected, - {next_state, connected, next_packet(State#state{ssh_params = - Ssh#ssh{authenticated = true}})}; -userauth(#ssh_msg_userauth_failure{}, - #state{ssh_params = #ssh{role = client, - userauth_methods = []}} - = State) -> - Msg = #ssh_msg_disconnect{code = - ?SSH_DISCONNECT_NO_MORE_AUTH_METHODS_AVAILABLE, +%%---- userauth success to client +handle_event(_, #ssh_msg_userauth_success{}, {userauth,client}, D=#data{ssh_params = Ssh}) -> + D#data.starter ! ssh_connected, + {next_state, {connected,client}, D#data{ssh_params=Ssh#ssh{authenticated = true}}}; + + +%%---- userauth failure response to client +handle_event(_, #ssh_msg_userauth_failure{}, {userauth,client}=StateName, + D = #data{ssh_params = #ssh{userauth_methods = []}}) -> + Msg = #ssh_msg_disconnect{code = ?SSH_DISCONNECT_NO_MORE_AUTH_METHODS_AVAILABLE, description = "Unable to connect using the available" - " authentication methods", - language = "en"}, - handle_disconnect(Msg, State); - -%% Server tells us which authentication methods that are allowed -userauth(#ssh_msg_userauth_failure{authentications = Methodes}, - #state{ssh_params = #ssh{role = client, - userauth_methods = none} = Ssh0} = State) -> - AuthMethods = string:tokens(Methodes, ","), - Ssh1 = Ssh0#ssh{userauth_methods = AuthMethods}, + " authentication methods"}, + disconnect(Msg, StateName, D); + +handle_event(_, #ssh_msg_userauth_failure{authentications = Methods}, StateName={userauth,client}, + D = #data{ssh_params = Ssh0}) -> + %% The prefered authentication method failed try next method + Ssh1 = case Ssh0#ssh.userauth_methods of + none -> + %% Server tells us which authentication methods that are allowed + Ssh0#ssh{userauth_methods = string:tokens(Methods, ",")}; + _ -> + %% We already know... + Ssh0 + end, case ssh_auth:userauth_request_msg(Ssh1) of {disconnect, DisconnectMsg, {Msg, Ssh}} -> - send_msg(Msg, State), - handle_disconnect(DisconnectMsg, State#state{ssh_params = Ssh}); + send_bytes(Msg, D), + disconnect(DisconnectMsg, StateName, D#data{ssh_params = Ssh}); {"keyboard-interactive", {Msg, Ssh}} -> - send_msg(Msg, State), - {next_state, userauth_keyboard_interactive, next_packet(State#state{ssh_params = Ssh})}; + send_bytes(Msg, D), + {next_state, {userauth_keyboard_interactive,client}, D#data{ssh_params = Ssh}}; {_Method, {Msg, Ssh}} -> - send_msg(Msg, State), - {next_state, userauth, next_packet(State#state{ssh_params = Ssh})} + send_bytes(Msg, D), + {keep_state, D#data{ssh_params = Ssh}} end; -%% The prefered authentication method failed try next method -userauth(#ssh_msg_userauth_failure{}, - #state{ssh_params = #ssh{role = client} = Ssh0} = State) -> - case ssh_auth:userauth_request_msg(Ssh0) of - {disconnect, DisconnectMsg,{Msg, Ssh}} -> - send_msg(Msg, State), - handle_disconnect(DisconnectMsg, State#state{ssh_params = Ssh}); - {"keyboard-interactive", {Msg, Ssh}} -> - send_msg(Msg, State), - {next_state, userauth_keyboard_interactive, next_packet(State#state{ssh_params = Ssh})}; - {_Method, {Msg, Ssh}} -> - send_msg(Msg, State), - {next_state, userauth, next_packet(State#state{ssh_params = Ssh})} - end; +%%---- banner to client +handle_event(_, #ssh_msg_userauth_banner{message = Msg}, {userauth,client}, D) -> + case D#data.ssh_params#ssh.userauth_quiet_mode of + false -> io:format("~s", [Msg]); + true -> ok + end, + keep_state_and_data; -userauth(#ssh_msg_userauth_banner{}, - #state{ssh_params = #ssh{userauth_quiet_mode = true, - role = client}} = State) -> - {next_state, userauth, next_packet(State)}; -userauth(#ssh_msg_userauth_banner{message = Msg}, - #state{ssh_params = - #ssh{userauth_quiet_mode = false, role = client}} = State) -> - io:format("~s", [Msg]), - {next_state, userauth, next_packet(State)}. - - - -userauth_keyboard_interactive(#ssh_msg_userauth_info_request{} = Msg, - #state{ssh_params = #ssh{role = client, - io_cb = IoCb} = Ssh0} = State) -> - {ok, {Reply, Ssh}} = ssh_auth:handle_userauth_info_request(Msg, IoCb, Ssh0), - send_msg(Reply, State), - {next_state, userauth_keyboard_interactive_info_response, next_packet(State#state{ssh_params = Ssh})}; - -userauth_keyboard_interactive(#ssh_msg_userauth_info_response{} = Msg, - #state{ssh_params = #ssh{role = server, - peer = {_, Address}} = Ssh0, - opts = Opts, starter = Pid} = State) -> - case ssh_auth:handle_userauth_info_response(Msg, Ssh0) of + +%%% ######## {userauth_keyboard_interactive, client|server} + +handle_event(_, #ssh_msg_userauth_info_request{} = Msg, {userauth_keyboard_interactive, client}, + #data{ssh_params = Ssh0} = D) -> + {ok, {Reply, Ssh}} = ssh_auth:handle_userauth_info_request(Msg, Ssh0#ssh.io_cb, Ssh0), + send_bytes(Reply, D), + {next_state, {userauth_keyboard_interactive_info_response,client}, D#data{ssh_params = Ssh}}; + +handle_event(_, #ssh_msg_userauth_info_response{} = Msg, {userauth_keyboard_interactive, server}, D) -> + case ssh_auth:handle_userauth_info_response(Msg, D#data.ssh_params) of {authorized, User, {Reply, Ssh}} -> - send_msg(Reply, State), - Pid ! ssh_connected, - connected_fun(User, Address, "keyboard-interactive", Opts), - {next_state, connected, - next_packet(State#state{auth_user = User, ssh_params = Ssh#ssh{authenticated = true}})}; + send_bytes(Reply, D), + D#data.starter ! ssh_connected, + connected_fun(User, "keyboard-interactive", D), + {next_state, {connected,server}, D#data{auth_user = User, + ssh_params = Ssh#ssh{authenticated = true}}}; {not_authorized, {User, Reason}, {Reply, Ssh}} -> - retry_fun(User, Address, Reason, Opts), - send_msg(Reply, State), - {next_state, userauth, next_packet(State#state{ssh_params = Ssh})} + retry_fun(User, Reason, D), + send_bytes(Reply, D), + {next_state, {userauth,server}, D#data{ssh_params = Ssh}} end; -userauth_keyboard_interactive(Msg = #ssh_msg_userauth_failure{}, - #state{ssh_params = Ssh0 = - #ssh{role = client, - userauth_preference = Prefs0}} - = State) -> - Prefs = [{Method,M,F,A} || {Method,M,F,A} <- Prefs0, + +handle_event(_, Msg = #ssh_msg_userauth_failure{}, {userauth_keyboard_interactive, client}, + #data{ssh_params = Ssh0} = D0) -> + Prefs = [{Method,M,F,A} || {Method,M,F,A} <- Ssh0#ssh.userauth_preference, Method =/= "keyboard-interactive"], - userauth(Msg, State#state{ssh_params = Ssh0#ssh{userauth_preference=Prefs}}). + D = D0#data{ssh_params = Ssh0#ssh{userauth_preference=Prefs}}, + {next_state, {userauth,client}, D, [{next_event, internal, Msg}]}; +handle_event(_, Msg=#ssh_msg_userauth_failure{}, {userauth_keyboard_interactive_info_response, client}, D) -> + {next_state, {userauth,client}, D, [{next_event, internal, Msg}]}; +handle_event(_, Msg=#ssh_msg_userauth_success{}, {userauth_keyboard_interactive_info_response, client}, D) -> + {next_state, {userauth,client}, D, [{next_event, internal, Msg}]}; -userauth_keyboard_interactive_info_response(Msg=#ssh_msg_userauth_failure{}, - #state{ssh_params = #ssh{role = client}} = State) -> - userauth(Msg, State); -userauth_keyboard_interactive_info_response(Msg=#ssh_msg_userauth_success{}, - #state{ssh_params = #ssh{role = client}} = State) -> - userauth(Msg, State); -userauth_keyboard_interactive_info_response(Msg=#ssh_msg_userauth_info_request{}, - #state{ssh_params = #ssh{role = client}} = State) -> - userauth_keyboard_interactive(Msg, State). +handle_event(_, Msg=#ssh_msg_userauth_info_request{}, {userauth_keyboard_interactive_info_response, client}, D) -> + {next_state, {userauth_keyboard_interactive,client}, D, [{next_event, internal, Msg}]}; -%%-------------------------------------------------------------------- --spec connected({#ssh_msg_kexinit{}, binary()}, %%| %% #ssh_msg_kexdh_init{}, - #state{}) -> gen_fsm_state_return(). -%%-------------------------------------------------------------------- -connected({#ssh_msg_kexinit{}, _Payload} = Event, #state{ssh_params = Ssh0} = State0) -> - {KeyInitMsg, SshPacket, Ssh} = ssh_transport:key_exchange_init_msg(Ssh0), - State = State0#state{ssh_params = Ssh, - key_exchange_init_msg = KeyInitMsg, - renegotiate = true}, - send_msg(SshPacket, State), - kexinit(Event, State). -%%-------------------------------------------------------------------- --spec handle_event(#ssh_msg_disconnect{} | #ssh_msg_ignore{} | #ssh_msg_debug{} | - #ssh_msg_unimplemented{} | {adjust_window, integer(), integer()} | - {reply_request, success | failure, integer()} | renegotiate | - data_size | {request, pid(), integer(), integer(), iolist()} | - {request, integer(), integer(), iolist()}, state_name(), - #state{}) -> gen_fsm_state_return(). +%%% ######## {connected, client|server} #### -%%-------------------------------------------------------------------- -handle_event(#ssh_msg_disconnect{description = Desc} = DisconnectMsg, _StateName, #state{} = State) -> - handle_disconnect(peer, DisconnectMsg, State), - {stop, {shutdown, Desc}, State}; - -handle_event(#ssh_msg_ignore{}, StateName, State) -> - {next_state, StateName, next_packet(State)}; - -handle_event(#ssh_msg_debug{always_display = Display, message = DbgMsg, language=Lang}, - StateName, #state{opts = Opts} = State) -> - F = proplists:get_value(ssh_msg_debug_fun, Opts, - fun(_ConnRef, _AlwaysDisplay, _Msg, _Language) -> ok end - ), - catch F(self(), Display, DbgMsg, Lang), - {next_state, StateName, next_packet(State)}; - -handle_event(#ssh_msg_unimplemented{}, StateName, State) -> - {next_state, StateName, next_packet(State)}; - -handle_event(renegotiate, connected, #state{ssh_params = Ssh0} - = State) -> - {KeyInitMsg, SshPacket, Ssh} = ssh_transport:key_exchange_init_msg(Ssh0), - send_msg(SshPacket, State), - timer:apply_after(?REKEY_TIMOUT, gen_fsm, send_all_state_event, [self(), renegotiate]), - {next_state, kexinit, - next_packet(State#state{ssh_params = Ssh, - key_exchange_init_msg = KeyInitMsg, - renegotiate = true})}; - -handle_event(renegotiate, StateName, State) -> +handle_event(_, {#ssh_msg_kexinit{},_} = Event, {connected,Role}, D0) -> + {KeyInitMsg, SshPacket, Ssh} = ssh_transport:key_exchange_init_msg(D0#data.ssh_params), + D = D0#data{ssh_params = Ssh, + key_exchange_init_msg = KeyInitMsg}, + send_bytes(SshPacket, D), + {next_state, {kexinit,Role,renegotiate}, D, [{next_event, internal, Event}]}; + +handle_event(_, #ssh_msg_disconnect{description=Desc} = Msg, StateName, D0) -> + {disconnect, _, {{replies,Replies}, _}} = + ssh_connection:handle_msg(Msg, D0#data.connection_state, role(StateName)), + {Actions,D} = send_replies(Replies, D0), + disconnect_fun(Desc, D), + {stop_and_reply, {shutdown,Desc}, Actions, D}; + +handle_event(_, #ssh_msg_ignore{}, _, _) -> + keep_state_and_data; + +handle_event(_, #ssh_msg_unimplemented{}, _, _) -> + keep_state_and_data; + +handle_event(_, #ssh_msg_debug{} = Msg, _, D) -> + debug_fun(Msg, D), + keep_state_and_data; + +handle_event(internal, Msg=#ssh_msg_global_request{}, StateName, D) -> + handle_connection_msg(Msg, StateName, D); + +handle_event(internal, Msg=#ssh_msg_request_success{}, StateName, D) -> + handle_connection_msg(Msg, StateName, D); + +handle_event(internal, Msg=#ssh_msg_request_failure{}, StateName, D) -> + handle_connection_msg(Msg, StateName, D); + +handle_event(internal, Msg=#ssh_msg_channel_open{}, StateName, D) -> + handle_connection_msg(Msg, StateName, D); + +handle_event(internal, Msg=#ssh_msg_channel_open_confirmation{}, StateName, D) -> + handle_connection_msg(Msg, StateName, D); + +handle_event(internal, Msg=#ssh_msg_channel_open_failure{}, StateName, D) -> + handle_connection_msg(Msg, StateName, D); + +handle_event(internal, Msg=#ssh_msg_channel_window_adjust{}, StateName, D) -> + handle_connection_msg(Msg, StateName, D); + +handle_event(internal, Msg=#ssh_msg_channel_data{}, StateName, D) -> + handle_connection_msg(Msg, StateName, D); + +handle_event(internal, Msg=#ssh_msg_channel_extended_data{}, StateName, D) -> + handle_connection_msg(Msg, StateName, D); + +handle_event(internal, Msg=#ssh_msg_channel_eof{}, StateName, D) -> + handle_connection_msg(Msg, StateName, D); + +handle_event(internal, Msg=#ssh_msg_channel_close{}, StateName, D) -> + handle_connection_msg(Msg, StateName, D); + +handle_event(internal, Msg=#ssh_msg_channel_request{}, StateName, D) -> + handle_connection_msg(Msg, StateName, D); + +handle_event(internal, Msg=#ssh_msg_channel_success{}, StateName, D) -> + handle_connection_msg(Msg, StateName, D); + +handle_event(internal, Msg=#ssh_msg_channel_failure{}, StateName, D) -> + handle_connection_msg(Msg, StateName, D); + + +handle_event(cast, renegotiate, {connected,Role}, D) -> + {KeyInitMsg, SshPacket, Ssh} = ssh_transport:key_exchange_init_msg(D#data.ssh_params), + send_bytes(SshPacket, D), + timer:apply_after(?REKEY_TIMOUT, gen_statem, cast, [self(), renegotiate]), + {next_state, {kexinit,Role,renegotiate}, D#data{ssh_params = Ssh, + key_exchange_init_msg = KeyInitMsg}}; + +handle_event(cast, renegotiate, _, _) -> %% Already in key-exchange so safe to ignore - {next_state, StateName, State}; + timer:apply_after(?REKEY_TIMOUT, gen_statem, cast, [self(), renegotiate]), % FIXME: not here in original + keep_state_and_data; + %% Rekey due to sent data limit reached? -handle_event(data_size, connected, #state{ssh_params = Ssh0} = State) -> - {ok, [{send_oct,Sent0}]} = inet:getstat(State#state.socket, [send_oct]), - Sent = Sent0 - State#state.last_size_rekey, - MaxSent = proplists:get_value(rekey_limit, State#state.opts, 1024000000), - timer:apply_after(?REKEY_DATA_TIMOUT, gen_fsm, send_all_state_event, [self(), data_size]), +handle_event(cast, data_size, {connected,Role}, D) -> + {ok, [{send_oct,Sent0}]} = inet:getstat(D#data.socket, [send_oct]), + Sent = Sent0 - D#data.last_size_rekey, + MaxSent = proplists:get_value(rekey_limit, D#data.opts, 1024000000), + timer:apply_after(?REKEY_DATA_TIMOUT, gen_statem, cast, [self(), data_size]), case Sent >= MaxSent of true -> - {KeyInitMsg, SshPacket, Ssh} = ssh_transport:key_exchange_init_msg(Ssh0), - send_msg(SshPacket, State), - {next_state, kexinit, - next_packet(State#state{ssh_params = Ssh, - key_exchange_init_msg = KeyInitMsg, - renegotiate = true, - last_size_rekey = Sent0})}; + {KeyInitMsg, SshPacket, Ssh} = + ssh_transport:key_exchange_init_msg(D#data.ssh_params), + send_bytes(SshPacket, D), + {next_state, {kexinit,Role,renegotiate}, D#data{ssh_params = Ssh, + key_exchange_init_msg = KeyInitMsg, + last_size_rekey = Sent0}}; _ -> - {next_state, connected, next_packet(State)} + keep_state_and_data end; -handle_event(data_size, StateName, State) -> + +handle_event(cast, data_size, _, _) -> %% Already in key-exchange so safe to ignore - {next_state, StateName, State}; - -handle_event(Event, StateName, State) when StateName /= connected -> - Events = [{event, Event} | State#state.event_queue], - {next_state, StateName, State#state{event_queue = Events}}; - -handle_event({adjust_window, ChannelId, Bytes}, StateName, - #state{connection_state = - #connection{channel_cache = Cache}} = State0) -> - State = - case ssh_channel:cache_lookup(Cache, ChannelId) of - #channel{recv_window_size = WinSize, - recv_window_pending = Pending, - recv_packet_size = PktSize} = Channel - when (WinSize-Bytes) >= 2*PktSize -> - %% The peer can send at least two more *full* packet, no hurry. - ssh_channel:cache_update(Cache, - Channel#channel{recv_window_pending = Pending + Bytes}), - State0; - - #channel{recv_window_size = WinSize, - recv_window_pending = Pending, - remote_id = Id} = Channel -> - %% Now we have to update the window - we can't receive so many more pkts - ssh_channel:cache_update(Cache, - Channel#channel{recv_window_size = - WinSize + Bytes + Pending, - recv_window_pending = 0}), - Msg = ssh_connection:channel_adjust_window_msg(Id, Bytes + Pending), - send_replies([{connection_reply, Msg}], State0); + timer:apply_after(?REKEY_DATA_TIMOUT, gen_statem, cast, [self(), data_size]), % FIXME: not here in original + keep_state_and_data; + + + +handle_event(cast, _, StateName, _) when StateName /= {connected,server}, + StateName /= {connected,client} -> + {keep_state_and_data, [postpone]}; + + +handle_event(cast, {adjust_window,ChannelId,Bytes}, {connected,_}, D) -> + case ssh_channel:cache_lookup(cache(D), ChannelId) of + #channel{recv_window_size = WinSize, + recv_window_pending = Pending, + recv_packet_size = PktSize} = Channel + when (WinSize-Bytes) >= 2*PktSize -> + %% The peer can send at least two more *full* packet, no hurry. + ssh_channel:cache_update(cache(D), + Channel#channel{recv_window_pending = Pending + Bytes}), + keep_state_and_data; + + #channel{recv_window_size = WinSize, + recv_window_pending = Pending, + remote_id = Id} = Channel -> + %% Now we have to update the window - we can't receive so many more pkts + ssh_channel:cache_update(cache(D), + Channel#channel{recv_window_size = + WinSize + Bytes + Pending, + recv_window_pending = 0}), + Msg = ssh_connection:channel_adjust_window_msg(Id, Bytes + Pending), + {keep_state, send_msg(Msg,D)}; - undefined -> - State0 - end, - {next_state, StateName, next_packet(State)}; - -handle_event({reply_request, success, ChannelId}, StateName, - #state{connection_state = - #connection{channel_cache = Cache}} = State0) -> - State = case ssh_channel:cache_lookup(Cache, ChannelId) of - #channel{remote_id = RemoteId} -> - Msg = ssh_connection:channel_success_msg(RemoteId), - send_replies([{connection_reply, Msg}], State0); - undefined -> - State0 - end, - {next_state, StateName, State}; - -handle_event({request, ChannelPid, ChannelId, Type, Data}, StateName, State0) -> - {{replies, Replies}, State1} = handle_request(ChannelPid, ChannelId, - Type, Data, - false, none, State0), - State = send_replies(Replies, State1), - {next_state, StateName, next_packet(State)}; - -handle_event({request, ChannelId, Type, Data}, StateName, State0) -> - {{replies, Replies}, State1} = handle_request(ChannelId, Type, Data, - false, none, State0), - State = send_replies(Replies, State1), - {next_state, StateName, next_packet(State)}; - -handle_event({unknown, Data}, StateName, State) -> + undefined -> + keep_state_and_data + end; + +handle_event(cast, {reply_request,success,ChannelId}, {connected,_}, D) -> + case ssh_channel:cache_lookup(cache(D), ChannelId) of + #channel{remote_id = RemoteId} -> + Msg = ssh_connection:channel_success_msg(RemoteId), + {keep_state, send_msg(Msg,D)}; + + undefined -> + keep_state_and_data + end; + +handle_event(cast, {request,ChannelPid, ChannelId, Type, Data}, {connected,_}, D) -> + {keep_state, handle_request(ChannelPid, ChannelId, Type, Data, false, none, D)}; + +handle_event(cast, {request,ChannelId,Type,Data}, {connected,_}, D) -> + {keep_state, handle_request(ChannelId, Type, Data, false, none, D)}; + +handle_event(cast, {unknown,Data}, {connected,_}, D) -> Msg = #ssh_msg_unimplemented{sequence = Data}, - send_msg(Msg, State), - {next_state, StateName, next_packet(State)}. + {keep_state, send_msg(Msg,D)}; -%%-------------------------------------------------------------------- --spec handle_sync_event({request, pid(), channel_id(), integer(), binary(), timeout()} | - {request, channel_id(), integer(), binary(), timeout()} | - {global_request, pid(), integer(), boolean(), binary()} | {eof, integer()} | - {open, pid(), integer(), channel_id(), integer(), binary(), _} | - {send_window, channel_id()} | {recv_window, channel_id()} | - {connection_info, [client_version | server_version | peer | - sockname]} | {channel_info, channel_id(), [recv_window | - send_window]} | - {close, channel_id()} | stop, term(), state_name(), #state{}) - -> gen_fsm_sync_return(). -%%-------------------------------------------------------------------- -handle_sync_event(get_print_info, _From, StateName, State) -> +%%% Previously handle_sync_event began here +handle_event({call,From}, get_print_info, StateName, D) -> Reply = try - {inet:sockname(State#state.socket), - inet:peername(State#state.socket) + {inet:sockname(D#data.socket), + inet:peername(D#data.socket) } of - {{ok,Local}, {ok,Remote}} -> {{Local,Remote},io_lib:format("statename=~p",[StateName])}; - _ -> {{"-",0},"-"} + {{ok,Local}, {ok,Remote}} -> + {{Local,Remote},io_lib:format("statename=~p",[StateName])}; + _ -> + {{"-",0},"-"} catch - _:_ -> {{"?",0},"?"} + _:_ -> + {{"?",0},"?"} end, - {reply, Reply, StateName, State}; + {keep_state_and_data, [{reply,From,Reply}]}; -handle_sync_event({connection_info, Options}, _From, StateName, State) -> - Info = ssh_info(Options, State, []), - {reply, Info, StateName, State}; +handle_event({call,From}, {connection_info, Options}, _, D) -> + Info = ssh_info(Options, D, []), + {keep_state_and_data, [{reply,From,Info}]}; -handle_sync_event({channel_info, ChannelId, Options}, _From, StateName, - #state{connection_state = #connection{channel_cache = Cache}} = State) -> - case ssh_channel:cache_lookup(Cache, ChannelId) of - #channel{} = Channel -> +handle_event({call,From}, {channel_info,ChannelId,Options}, _, D) -> + case ssh_channel:cache_lookup(cache(D), ChannelId) of + #channel{} = Channel -> Info = ssh_channel_info(Options, Channel, []), - {reply, Info, StateName, State}; + {keep_state_and_data, [{reply,From,Info}]}; undefined -> - {reply, [], StateName, State} + {keep_state_and_data, [{reply,From,[]}]} end; -handle_sync_event({info, ChannelPid}, _From, StateName, - #state{connection_state = - #connection{channel_cache = Cache}} = State) -> + +handle_event({call,From}, {info, all}, _, D) -> + Result = ssh_channel:cache_foldl(fun(Channel, Acc) -> + [Channel | Acc] + end, + [], cache(D)), + {keep_state_and_data, [{reply, From, {ok,Result}}]}; + +handle_event({call,From}, {info, ChannelPid}, _, D) -> Result = ssh_channel:cache_foldl( - fun(Channel, Acc) when ChannelPid == all; - Channel#channel.user == ChannelPid -> + fun(Channel, Acc) when Channel#channel.user == ChannelPid -> [Channel | Acc]; (_, Acc) -> Acc - end, [], Cache), - {reply, {ok, Result}, StateName, State}; + end, [], cache(D)), + {keep_state_and_data, [{reply, From, {ok,Result}}]}; -handle_sync_event(stop, _, _StateName, #state{connection_state = Connection0, - role = Role} = State0) -> +handle_event({call,From}, stop, StateName, D0) -> {disconnect, _Reason, {{replies, Replies}, Connection}} = ssh_connection:handle_msg(#ssh_msg_disconnect{code = ?SSH_DISCONNECT_BY_APPLICATION, - description = "User closed down connection", - language = "en"}, Connection0, Role), - State = send_replies(Replies, State0), - {stop, normal, ok, State#state{connection_state = Connection}}; - - -handle_sync_event(Event, From, StateName, State) when StateName /= connected -> - Events = [{sync, Event, From} | State#state.event_queue], - {next_state, StateName, State#state{event_queue = Events}}; - -handle_sync_event({request, ChannelPid, ChannelId, Type, Data, Timeout}, From, StateName, State0) -> - {{replies, Replies}, State1} = handle_request(ChannelPid, - ChannelId, Type, Data, - true, From, State0), - %% Note reply to channel will happen later when - %% reply is recived from peer on the socket - State = send_replies(Replies, State1), - start_timeout(ChannelId, From, Timeout), - handle_idle_timeout(State), - {next_state, StateName, next_packet(State)}; - -handle_sync_event({request, ChannelId, Type, Data, Timeout}, From, StateName, State0) -> - {{replies, Replies}, State1} = handle_request(ChannelId, Type, Data, - true, From, State0), - %% Note reply to channel will happen later when - %% reply is recived from peer on the socket - State = send_replies(Replies, State1), - start_timeout(ChannelId, From, Timeout), - handle_idle_timeout(State), - {next_state, StateName, next_packet(State)}; - -handle_sync_event({global_request, Pid, _, _, _} = Request, From, StateName, - #state{connection_state = - #connection{channel_cache = Cache}} = State0) -> - State1 = handle_global_request(Request, State0), - Channel = ssh_channel:cache_find(Pid, Cache), - State = add_request(true, Channel#channel.local_id, From, State1), - {next_state, StateName, next_packet(State)}; - -handle_sync_event({data, ChannelId, Type, Data, Timeout}, From, StateName, - #state{connection_state = #connection{channel_cache = _Cache} - = Connection0} = State0) -> - - case ssh_connection:channel_data(ChannelId, Type, Data, Connection0, From) of - {{replies, Replies}, Connection} -> - State = send_replies(Replies, State0#state{connection_state = Connection}), - start_timeout(ChannelId, From, Timeout), - {next_state, StateName, next_packet(State)}; - {noreply, Connection} -> - start_timeout(ChannelId, From, Timeout), - {next_state, StateName, next_packet(State0#state{connection_state = Connection})} - end; - -handle_sync_event({eof, ChannelId}, _From, StateName, - #state{connection_state = - #connection{channel_cache = Cache}} = State0) -> - case ssh_channel:cache_lookup(Cache, ChannelId) of + description = "User closed down connection"}, + D0#data.connection_state, + role(StateName)), + {Repls,D} = send_replies(Replies, D0), + {stop_and_reply, normal, [{reply,From,ok}|Repls], D#data{connection_state=Connection}}; + +handle_event({call,_}, _, StateName, _) when StateName /= {connected,server}, + StateName /= {connected,client} -> + {keep_state_and_data, [postpone]}; + +handle_event({call,From}, {request, ChannelPid, ChannelId, Type, Data, Timeout}, {connected,_}, D0) -> + D = handle_request(ChannelPid, ChannelId, Type, Data, true, From, D0), + %% Note reply to channel will happen later when reply is recived from peer on the socket + start_channel_request_timer(ChannelId, From, Timeout), + {keep_state, cache_request_idle_timer_check(D)}; + +handle_event({call,From}, {request, ChannelId, Type, Data, Timeout}, {connected,_}, D0) -> + D = handle_request(ChannelId, Type, Data, true, From, D0), + %% Note reply to channel will happen later when reply is recived from peer on the socket + start_channel_request_timer(ChannelId, From, Timeout), + {keep_state, cache_request_idle_timer_check(D)}; + +handle_event({call,From}, {data, ChannelId, Type, Data, Timeout}, {connected,_}, D0) -> + {{replies, Replies}, Connection} = + ssh_connection:channel_data(ChannelId, Type, Data, D0#data.connection_state, From), + {Repls,D} = send_replies(Replies, D0#data{connection_state = Connection}), + start_channel_request_timer(ChannelId, From, Timeout), % FIXME: No message exchange so why? + {keep_state, D, Repls}; + +handle_event({call,From}, {eof, ChannelId}, {connected,_}, D0) -> + case ssh_channel:cache_lookup(cache(D0), ChannelId) of #channel{remote_id = Id, sent_close = false} -> - State = send_replies([{connection_reply, - ssh_connection:channel_eof_msg(Id)}], State0), - {reply, ok, StateName, next_packet(State)}; + D = send_msg(ssh_connection:channel_eof_msg(Id), D0), + {keep_state, D, [{reply,From,ok}]}; _ -> - {reply, {error,closed}, StateName, State0} + {keep_state, D0, [{reply,From,{error,closed}}]} end; -handle_sync_event({open, ChannelPid, Type, InitialWindowSize, MaxPacketSize, Data, Timeout}, - From, StateName, #state{connection_state = - #connection{channel_cache = Cache}} = State0) -> +handle_event({call,From}, + {open, ChannelPid, Type, InitialWindowSize, MaxPacketSize, Data, Timeout}, + {connected,_}, + D0) -> erlang:monitor(process, ChannelPid), - {ChannelId, State1} = new_channel_id(State0), - Msg = ssh_connection:channel_open_msg(Type, ChannelId, - InitialWindowSize, - MaxPacketSize, Data), - State2 = send_replies([{connection_reply, Msg}], State1), - Channel = #channel{type = Type, - sys = "none", - user = ChannelPid, - local_id = ChannelId, - recv_window_size = InitialWindowSize, - recv_packet_size = MaxPacketSize, - send_buf = queue:new() - }, - ssh_channel:cache_update(Cache, Channel), - State = add_request(true, ChannelId, From, State2), - start_timeout(ChannelId, From, Timeout), - {next_state, StateName, next_packet(remove_timer_ref(State))}; - -handle_sync_event({send_window, ChannelId}, _From, StateName, - #state{connection_state = - #connection{channel_cache = Cache}} = State) -> - Reply = case ssh_channel:cache_lookup(Cache, ChannelId) of + {ChannelId, D1} = new_channel_id(D0), + D2 = send_msg(ssh_connection:channel_open_msg(Type, ChannelId, + InitialWindowSize, + MaxPacketSize, Data), + D1), + ssh_channel:cache_update(cache(D2), + #channel{type = Type, + sys = "none", + user = ChannelPid, + local_id = ChannelId, + recv_window_size = InitialWindowSize, + recv_packet_size = MaxPacketSize, + send_buf = queue:new() + }), + D = add_request(true, ChannelId, From, D2), + start_channel_request_timer(ChannelId, From, Timeout), + {keep_state, cache_cancel_idle_timer(D)}; + +handle_event({call,From}, {send_window, ChannelId}, {connected,_}, D) -> + Reply = case ssh_channel:cache_lookup(cache(D), ChannelId) of #channel{send_window_size = WinSize, send_packet_size = Packsize} -> {ok, {WinSize, Packsize}}; undefined -> {error, einval} end, - {reply, Reply, StateName, next_packet(State)}; - -handle_sync_event({recv_window, ChannelId}, _From, StateName, - #state{connection_state = #connection{channel_cache = Cache}} - = State) -> + {keep_state_and_data, [{reply,From,Reply}]}; - Reply = case ssh_channel:cache_lookup(Cache, ChannelId) of +handle_event({call,From}, {recv_window, ChannelId}, {connected,_}, D) -> + Reply = case ssh_channel:cache_lookup(cache(D), ChannelId) of #channel{recv_window_size = WinSize, recv_packet_size = Packsize} -> {ok, {WinSize, Packsize}}; undefined -> {error, einval} end, - {reply, Reply, StateName, next_packet(State)}; - -handle_sync_event({close, ChannelId}, _, StateName, - #state{connection_state = - #connection{channel_cache = Cache}} = State0) -> - State = - case ssh_channel:cache_lookup(Cache, ChannelId) of - #channel{remote_id = Id} = Channel -> - State1 = send_replies([{connection_reply, - ssh_connection:channel_close_msg(Id)}], State0), - ssh_channel:cache_update(Cache, Channel#channel{sent_close = true}), - handle_idle_timeout(State1), - State1; - undefined -> - State0 - end, - {reply, ok, StateName, next_packet(State)}. + {keep_state_and_data, [{reply,From,Reply}]}; + +handle_event({call,From}, {close, ChannelId}, {connected,_}, D0) -> + case ssh_channel:cache_lookup(cache(D0), ChannelId) of + #channel{remote_id = Id} = Channel -> + D1 = send_msg(ssh_connection:channel_close_msg(Id), D0), + ssh_channel:cache_update(cache(D1), Channel#channel{sent_close = true}), + {keep_state, cache_request_idle_timer_check(D1), [{reply,From,ok}]}; + undefined -> + {keep_state_and_data, [{reply,From,ok}]} + end; -%%-------------------------------------------------------------------- --spec handle_info({atom(), port(), binary()} | {atom(), port()} | - term (), state_name(), #state{}) -> gen_fsm_state_return(). -%%-------------------------------------------------------------------- -handle_info({Protocol, Socket, "SSH-" ++ _ = Version}, hello, - #state{socket = Socket, - transport_protocol = Protocol} = State ) -> - event({version_exchange, Version}, hello, State); - -handle_info({Protocol, Socket, Info}, hello, - #state{socket = Socket, - transport_protocol = Protocol} = State) -> - event({info_line, Info}, hello, State); - -handle_info({Protocol, Socket, Data}, StateName, - #state{socket = Socket, - transport_protocol = Protocol, - ssh_params = Ssh0, - decoded_data_buffer = DecData0, - encoded_data_buffer = EncData0, - undecoded_packet_length = RemainingSshPacketLen0} = State0) -> - Encoded = <<EncData0/binary, Data/binary>>, - try ssh_transport:handle_packet_part(DecData0, Encoded, RemainingSshPacketLen0, Ssh0) +%%===== Reception of encrypted bytes, decryption and framing +handle_event(info, {Proto, Sock, Info}, {hello,_}, #data{socket = Sock, + transport_protocol = Proto}) -> + case Info of + "SSH-" ++ _ -> + {keep_state_and_data, [{next_event, internal, {version_exchange,Info}}]}; + _ -> + {keep_state_and_data, [{next_event, internal, {info_line,Info}}]} + end; + +handle_event(info, {Proto, Sock, NewData}, StateName, D0 = #data{socket = Sock, + transport_protocol = Proto}) -> + try ssh_transport:handle_packet_part( + D0#data.decrypted_data_buffer, + <<(D0#data.encrypted_data_buffer)/binary, NewData/binary>>, + D0#data.undecrypted_packet_length, + D0#data.ssh_params) of - {get_more, DecBytes, EncDataRest, RemainingSshPacketLen, Ssh1} -> - {next_state, StateName, - next_packet(State0#state{encoded_data_buffer = EncDataRest, - decoded_data_buffer = DecBytes, - undecoded_packet_length = RemainingSshPacketLen, - ssh_params = Ssh1})}; - {decoded, MsgBytes, EncDataRest, Ssh1} -> - generate_event(MsgBytes, StateName, - State0#state{ssh_params = Ssh1, - %% Important to be set for - %% next_packet -%%% FIXME: the following three seem to always be set in generate_event! - decoded_data_buffer = <<>>, - undecoded_packet_length = undefined, - encoded_data_buffer = EncDataRest}, - EncDataRest); + {packet_decrypted, DecryptedBytes, EncryptedDataRest, Ssh1} -> + D = D0#data{ssh_params = + Ssh1#ssh{recv_sequence = ssh_transport:next_seqnum(Ssh1#ssh.recv_sequence)}, + decrypted_data_buffer = <<>>, + undecrypted_packet_length = undefined, + encrypted_data_buffer = EncryptedDataRest}, + try + ssh_message:decode(set_kex_overload_prefix(DecryptedBytes,D)) + of + Msg = #ssh_msg_kexinit{} -> + {keep_state, D, [{next_event, internal, {Msg,DecryptedBytes}}, + {next_event, internal, prepare_next_packet} + ]}; + Msg -> + {keep_state, D, [{next_event, internal, Msg}, + {next_event, internal, prepare_next_packet} + ]} + catch + _C:_E -> + disconnect(#ssh_msg_disconnect{code = ?SSH_DISCONNECT_PROTOCOL_ERROR, + description = "Encountered unexpected input"}, + StateName, D) + end; + + {get_more, DecryptedBytes, EncryptedDataRest, RemainingSshPacketLen, Ssh1} -> + %% Here we know that there are not enough bytes in + %% EncryptedDataRest to use. We must wait for more. + inet:setopts(Sock, [{active, once}]), + {keep_state, D0#data{encrypted_data_buffer = EncryptedDataRest, + decrypted_data_buffer = DecryptedBytes, + undecrypted_packet_length = RemainingSshPacketLen, + ssh_params = Ssh1}}; + {bad_mac, Ssh1} -> - DisconnectMsg = - #ssh_msg_disconnect{code = ?SSH_DISCONNECT_PROTOCOL_ERROR, - description = "Bad mac", - language = ""}, - handle_disconnect(DisconnectMsg, State0#state{ssh_params=Ssh1}); + disconnect(#ssh_msg_disconnect{code = ?SSH_DISCONNECT_PROTOCOL_ERROR, + description = "Bad mac"}, + StateName, D0#data{ssh_params=Ssh1}); {error, {exceeds_max_size,PacketLen}} -> - DisconnectMsg = - #ssh_msg_disconnect{code = ?SSH_DISCONNECT_PROTOCOL_ERROR, - description = "Bad packet length " - ++ integer_to_list(PacketLen), - language = ""}, - handle_disconnect(DisconnectMsg, State0) + disconnect(#ssh_msg_disconnect{code = ?SSH_DISCONNECT_PROTOCOL_ERROR, + description = "Bad packet length " + ++ integer_to_list(PacketLen)}, + StateName, D0) catch - _:_ -> - DisconnectMsg = - #ssh_msg_disconnect{code = ?SSH_DISCONNECT_PROTOCOL_ERROR, - description = "Bad packet", - language = ""}, - handle_disconnect(DisconnectMsg, State0) + _C:_E -> + disconnect(#ssh_msg_disconnect{code = ?SSH_DISCONNECT_PROTOCOL_ERROR, + description = "Bad packet"}, + StateName, D0) end; - -handle_info({CloseTag, _Socket}, _StateName, - #state{transport_close_tag = CloseTag, - ssh_params = #ssh{role = _Role, opts = _Opts}} = State) -> - DisconnectMsg = - #ssh_msg_disconnect{code = ?SSH_DISCONNECT_BY_APPLICATION, - description = "Connection closed", - language = "en"}, - handle_disconnect(DisconnectMsg, State); - -handle_info({timeout, {_, From} = Request}, Statename, - #state{connection_state = #connection{requests = Requests} = Connection} = State) -> + + +%%%==== +handle_event(internal, prepare_next_packet, _, D) -> + Enough = erlang:max(8, D#data.ssh_params#ssh.decrypt_block_size), + case size(D#data.encrypted_data_buffer) of + Sz when Sz >= Enough -> + self() ! {D#data.transport_protocol, D#data.socket, <<>>}; + _ -> + inet:setopts(D#data.socket, [{active, once}]) + end, + keep_state_and_data; + +handle_event(info, {CloseTag,Socket}, StateName, + D = #data{socket = Socket, + transport_close_tag = CloseTag}) -> + disconnect(#ssh_msg_disconnect{code = ?SSH_DISCONNECT_BY_APPLICATION, + description = "Connection closed"}, + StateName, D); + +handle_event(info, {timeout, {_, From} = Request}, _, + #data{connection_state = #connection{requests = Requests} = C0} = D) -> case lists:member(Request, Requests) of true -> - gen_fsm:reply(From, {error, timeout}), - {next_state, Statename, - State#state{connection_state = - Connection#connection{requests = - lists:delete(Request, Requests)}}}; + %% A channel request is not answered in time. Answer {error,timeout} + %% to the caller + C = C0#connection{requests = lists:delete(Request, Requests)}, + {keep_state, D#data{connection_state=C}, [{reply,From,{error,timeout}}]}; false -> - {next_state, Statename, State} + %% The request is answered - just ignore the timeout + keep_state_and_data end; %%% Handle that ssh channels user process goes down -handle_info({'DOWN', _Ref, process, ChannelPid, _Reason}, Statename, State0) -> - {{replies, Replies}, State1} = handle_channel_down(ChannelPid, State0), - State = send_replies(Replies, State1), - {next_state, Statename, next_packet(State)}; +handle_event(info, {'DOWN', _Ref, process, ChannelPid, _Reason}, _, D0) -> + {{replies, Replies}, D1} = handle_channel_down(ChannelPid, D0), + {Repls, D} = send_replies(Replies, D1), + {keep_state, D, Repls}; %%% So that terminate will be run when supervisor is shutdown -handle_info({'EXIT', _Sup, Reason}, _StateName, State) -> - {stop, {shutdown, Reason}, State}; +handle_event(info, {'EXIT', _Sup, Reason}, _, _) -> + {stop, {shutdown, Reason}}; -handle_info({check_cache, _ , _}, - StateName, #state{connection_state = - #connection{channel_cache = Cache}} = State) -> - {next_state, StateName, check_cache(State, Cache)}; +handle_event(info, check_cache, _, D) -> + {keep_state, cache_check_set_idle_timer(D)}; -handle_info(UnexpectedMessage, StateName, #state{opts = Opts, - ssh_params = SshParams} = State) -> - case unexpected_fun(UnexpectedMessage, Opts, SshParams) of +handle_event(info, UnexpectedMessage, StateName, D = #data{ssh_params = Ssh}) -> + case unexpected_fun(UnexpectedMessage, D) of report -> Msg = lists:flatten( io_lib:format( "Unexpected message '~p' received in state '~p'\n" "Role: ~p\n" "Peer: ~p\n" - "Local Address: ~p\n", [UnexpectedMessage, StateName, - SshParams#ssh.role, SshParams#ssh.peer, - proplists:get_value(address, SshParams#ssh.opts)])), - error_logger:info_report(Msg); + "Local Address: ~p\n", [UnexpectedMessage, + StateName, + Ssh#ssh.role, + Ssh#ssh.peer, + proplists:get_value(address, Ssh#ssh.opts)])), + error_logger:info_report(Msg), + keep_state_and_data; skip -> - ok; + keep_state_and_data; Other -> Msg = lists:flatten( @@ -1103,200 +1269,181 @@ handle_info(UnexpectedMessage, StateName, #state{opts = Opts, "Message: ~p\n" "Role: ~p\n" "Peer: ~p\n" - "Local Address: ~p\n", [Other, UnexpectedMessage, - SshParams#ssh.role, - element(2,SshParams#ssh.peer), - proplists:get_value(address, SshParams#ssh.opts)] + "Local Address: ~p\n", [Other, + UnexpectedMessage, + Ssh#ssh.role, + element(2,Ssh#ssh.peer), + proplists:get_value(address, Ssh#ssh.opts)] )), + error_logger:error_report(Msg), + keep_state_and_data + end; + +handle_event(internal, {disconnect,Msg,_Reason}, StateName, D) -> + disconnect(Msg, StateName, D); + +handle_event(Type, Ev, StateName, D) -> + Descr = + case catch atom_to_list(element(1,Ev)) of + "ssh_msg_" ++_ when Type==internal -> + "Message in wrong state"; + _ -> + "Internal error" + end, + disconnect(#ssh_msg_disconnect{code = ?SSH_DISCONNECT_PROTOCOL_ERROR, + description = Descr}, + StateName, D). - error_logger:error_report(Msg) - end, - {next_state, StateName, State}. %%-------------------------------------------------------------------- --spec terminate(Reason::term(), state_name(), #state{}) -> _. -%%-------------------------------------------------------------------- -terminate(normal, _, #state{transport_cb = Transport, - connection_state = Connection, - socket = Socket}) -> - terminate_subsystem(Connection), - (catch Transport:close(Socket)), - ok; +-spec terminate(any(), + state_name(), + #data{} + ) -> finalize_termination_result() . + +%% . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . + +terminate(normal, StateName, State) -> + finalize_termination(StateName, State); terminate({shutdown,{init,Reason}}, StateName, State) -> error_logger:info_report(io_lib:format("Erlang ssh in connection handler init: ~p~n",[Reason])), - terminate(normal, StateName, State); - -%% Terminated by supervisor -terminate(shutdown, StateName, #state{ssh_params = Ssh0} = State) -> - DisconnectMsg = - #ssh_msg_disconnect{code = ?SSH_DISCONNECT_BY_APPLICATION, - description = "Application shutdown", - language = "en"}, - {SshPacket, Ssh} = ssh_transport:ssh_packet(DisconnectMsg, Ssh0), - send_msg(SshPacket, State), - terminate(normal, StateName, State#state{ssh_params = Ssh}); - -terminate({shutdown, #ssh_msg_disconnect{} = Msg}, StateName, - #state{ssh_params = Ssh0} = State) -> - {SshPacket, Ssh} = ssh_transport:ssh_packet(Msg, Ssh0), - send_msg(SshPacket, State), - terminate(normal, StateName, State#state{ssh_params = Ssh}); - -terminate({shutdown, _}, StateName, State) -> - terminate(normal, StateName, State); - -terminate(Reason, StateName, #state{ssh_params = Ssh0, starter = _Pid, - connection_state = Connection} = State) -> - terminate_subsystem(Connection), + finalize_termination(StateName, State); + +terminate(shutdown, StateName, State0) -> + %% Terminated by supervisor + State = send_msg(#ssh_msg_disconnect{code = ?SSH_DISCONNECT_BY_APPLICATION, + description = "Application shutdown"}, + State0), +timer:sleep(400), %% FIXME!!! gen_tcp:shutdown instead + finalize_termination(StateName, State); + +%% terminate({shutdown,Msg}, StateName, State0) when is_record(Msg,ssh_msg_disconnect)-> +%% State = send_msg(Msg, State0), +%% timer:sleep(400), %% FIXME!!! gen_tcp:shutdown instead +%% finalize_termination(StateName, Msg, State); + +terminate({shutdown,_R}, StateName, State) -> + finalize_termination(StateName, State); + +terminate(Reason, StateName, State0) -> + %% Others, e.g undef, {badmatch,_} log_error(Reason), - DisconnectMsg = - #ssh_msg_disconnect{code = ?SSH_DISCONNECT_BY_APPLICATION, - description = "Internal error", - language = "en"}, - {SshPacket, Ssh} = ssh_transport:ssh_packet(DisconnectMsg, Ssh0), - send_msg(SshPacket, State), - terminate(normal, StateName, State#state{ssh_params = Ssh}). - - -terminate_subsystem(#connection{system_supervisor = SysSup, - sub_system_supervisor = SubSysSup}) when is_pid(SubSysSup) -> - ssh_system_sup:stop_subsystem(SysSup, SubSysSup); -terminate_subsystem(_) -> - ok. - -format_status(normal, [_, State]) -> - [{data, [{"StateData", State}]}]; -format_status(terminate, [_, State]) -> - SshParams0 = (State#state.ssh_params), - SshParams = SshParams0#ssh{c_keyinit = "***", - s_keyinit = "***", - send_mac_key = "***", - send_mac_size = "***", - recv_mac_key = "***", - recv_mac_size = "***", - encrypt_keys = "***", - encrypt_ctx = "***", - decrypt_keys = "***", - decrypt_ctx = "***", - compress_ctx = "***", - decompress_ctx = "***", - shared_secret = "***", - exchanged_hash = "***", - session_id = "***", - keyex_key = "***", - keyex_info = "***", - available_host_keys = "***"}, - [{data, [{"StateData", State#state{decoded_data_buffer = "***", - encoded_data_buffer = "***", - key_exchange_init_msg = "***", - opts = "***", - recbuf = "***", - ssh_params = SshParams - }}]}]. + State = send_msg(#ssh_msg_disconnect{code = ?SSH_DISCONNECT_BY_APPLICATION, + description = "Internal error"}, + State0), + finalize_termination(StateName, State). %%-------------------------------------------------------------------- --spec code_change(OldVsn::term(), state_name(), Oldstate::term(), Extra::term()) -> - {ok, state_name(), #state{}}. + +%% . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . + +format_status(normal, [_, _StateName, D]) -> + [{data, [{"State", D}]}]; +format_status(terminate, [_, _StateName, D]) -> + DataPropList0 = fmt_stat_rec(record_info(fields, data), D, + [decrypted_data_buffer, + encrypted_data_buffer, + key_exchange_init_msg, + user_passwords, + opts, + inet_initial_recbuf_size]), + SshPropList = fmt_stat_rec(record_info(fields, ssh), D#data.ssh_params, + [c_keyinit, + s_keyinit, + send_mac_key, + send_mac_size, + recv_mac_key, + recv_mac_size, + encrypt_keys, + encrypt_ctx, + decrypt_keys, + decrypt_ctx, + compress_ctx, + decompress_ctx, + shared_secret, + exchanged_hash, + session_id, + keyex_key, + keyex_info, + available_host_keys]), + DataPropList = lists:keyreplace(ssh_params, 1, DataPropList0, + {ssh_params,SshPropList}), + [{data, [{"State", DataPropList}]}]. + + +fmt_stat_rec(FieldNames, Rec, Exclude) -> + Values = tl(tuple_to_list(Rec)), + [P || {K,_} = P <- lists:zip(FieldNames, Values), + not lists:member(K, Exclude)]. + %%-------------------------------------------------------------------- +-spec code_change(term() | {down,term()}, + state_name(), + #data{}, + term() + ) -> {gen_statem:callback_mode(), state_name(), #data{}}. + +%% . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . + code_change(_OldVsn, StateName, State, _Extra) -> - {ok, StateName, State}. + {handle_event_function, StateName, State}. + + +%%==================================================================== +%% Internal functions +%%==================================================================== %%-------------------------------------------------------------------- -%%% Internal functions -%%-------------------------------------------------------------------- -init_role(#state{role = client, opts = Opts} = State0) -> - Pid = proplists:get_value(user_pid, Opts), - TimerRef = get_idle_time(Opts), - timer:apply_after(?REKEY_TIMOUT, gen_fsm, send_all_state_event, [self(), renegotiate]), - timer:apply_after(?REKEY_DATA_TIMOUT, gen_fsm, send_all_state_event, - [self(), data_size]), - State0#state{starter = Pid, - idle_timer_ref = TimerRef}; -init_role(#state{role = server, opts = Opts, connection_state = Connection} = State) -> - Sups = proplists:get_value(supervisors, Opts), - Pid = proplists:get_value(user_pid, Opts), - SystemSup = proplists:get_value(system_sup, Sups), - SubSystemSup = proplists:get_value(subsystem_sup, Sups), +%% Starting + +start_the_connection_child(UserPid, Role, Socket, Options) -> + Sups = proplists:get_value(supervisors, Options), ConnectionSup = proplists:get_value(connection_sup, Sups), - Shell = proplists:get_value(shell, Opts), - Exec = proplists:get_value(exec, Opts), - CliSpec = proplists:get_value(ssh_cli, Opts, {ssh_cli, [Shell]}), - State#state{starter = Pid, connection_state = Connection#connection{ - cli_spec = CliSpec, - exec = Exec, - system_supervisor = SystemSup, - sub_system_supervisor = SubSystemSup, - connection_supervisor = ConnectionSup - }}. - -get_idle_time(SshOptions) -> - case proplists:get_value(idle_time, SshOptions) of - infinity -> - infinity; - _IdleTime -> %% We dont want to set the timeout on first connect - undefined - end. + Opts = [{supervisors, Sups}, {user_pid, UserPid} | proplists:get_value(ssh_opts, Options, [])], + {ok, Pid} = ssh_connection_sup:start_child(ConnectionSup, [Role, Socket, Opts]), + ok = socket_control(Socket, Pid, Options), + Pid. -init_ssh(client = Role, Vsn, Version, Options, Socket) -> - IOCb = case proplists:get_value(user_interaction, Options, true) of - true -> - ssh_io; - false -> - ssh_no_io - end, +%%-------------------------------------------------------------------- +%% Stopping +-type finalize_termination_result() :: ok . + +finalize_termination(_StateName, #data{transport_cb = Transport, + connection_state = Connection, + socket = Socket}) -> + case Connection of + #connection{system_supervisor = SysSup, + sub_system_supervisor = SubSysSup} when is_pid(SubSysSup) -> + ssh_system_sup:stop_subsystem(SysSup, SubSysSup); + _ -> + do_nothing + end, + (catch Transport:close(Socket)), + ok. - AuthMethods = proplists:get_value(auth_methods, Options, - ?SUPPORTED_AUTH_METHODS), - {ok, PeerAddr} = inet:peername(Socket), - - PeerName = proplists:get_value(host, Options), - KeyCb = proplists:get_value(key_cb, Options, ssh_file), - - #ssh{role = Role, - c_vsn = Vsn, - c_version = Version, - key_cb = KeyCb, - io_cb = IOCb, - userauth_quiet_mode = proplists:get_value(quiet_mode, Options, false), - opts = Options, - userauth_supported_methods = AuthMethods, - peer = {PeerName, PeerAddr}, - available_host_keys = supported_host_keys(Role, KeyCb, Options), - random_length_padding = proplists:get_value(max_random_length_padding, - Options, - (#ssh{})#ssh.random_length_padding) - }; - -init_ssh(server = Role, Vsn, Version, Options, Socket) -> - AuthMethods = proplists:get_value(auth_methods, Options, - ?SUPPORTED_AUTH_METHODS), - AuthMethodsAsList = string:tokens(AuthMethods, ","), - {ok, PeerAddr} = inet:peername(Socket), - KeyCb = proplists:get_value(key_cb, Options, ssh_file), - - #ssh{role = Role, - s_vsn = Vsn, - s_version = Version, - key_cb = KeyCb, - io_cb = proplists:get_value(io_cb, Options, ssh_io), - opts = Options, - userauth_supported_methods = AuthMethods, - userauth_methods = AuthMethodsAsList, - kb_tries_left = 3, - peer = {undefined, PeerAddr}, - available_host_keys = supported_host_keys(Role, KeyCb, Options), - random_length_padding = proplists:get_value(max_random_length_padding, - Options, - (#ssh{})#ssh.random_length_padding) - }. +%%-------------------------------------------------------------------- +%% "Invert" the Role +peer_role(client) -> server; +peer_role(server) -> client. + +%%-------------------------------------------------------------------- +%% StateName to Role +role({_,Role}) -> Role; +role({_,Role,_}) -> Role. +%%-------------------------------------------------------------------- +%% Check the StateName to see if we are in the renegotiation phase +renegotiation({_,_,ReNeg}) -> ReNeg == renegotiation; +renegotiation(_) -> false. + +%%-------------------------------------------------------------------- supported_host_keys(client, _, Options) -> try - case proplists:get_value(public_key, + case proplists:get_value(public_key, proplists:get_value(preferred_algorithms,Options,[]) ) of - undefined -> + undefined -> ssh_transport:default_algorithms(public_key); L -> L -- (L--ssh_transport:default_algorithms(public_key)) @@ -1311,7 +1458,7 @@ supported_host_keys(client, _, Options) -> {stop, {shutdown, Reason}} end; supported_host_keys(server, KeyCb, Options) -> - [atom_to_list(A) || A <- proplists:get_value(public_key, + [atom_to_list(A) || A <- proplists:get_value(public_key, proplists:get_value(preferred_algorithms,Options,[]), ssh_transport:default_algorithms(public_key) ), @@ -1322,10 +1469,16 @@ supported_host_keys(server, KeyCb, Options) -> available_host_key(KeyCb, Alg, Opts) -> element(1, catch KeyCb:host_key(Alg, Opts)) == ok. -send_msg(Msg, #state{socket = Socket, transport_cb = Transport}) -> - Transport:send(Socket, Msg). -handle_version({2, 0} = NumVsn, StrVsn, Ssh0) -> +send_msg(Msg, State=#data{ssh_params=Ssh0}) when is_tuple(Msg) -> + {Bytes, Ssh} = ssh_transport:ssh_packet(Msg, Ssh0), + send_bytes(Bytes, State), + State#data{ssh_params=Ssh}. + +send_bytes(Bytes, #data{socket = Socket, transport_cb = Transport}) -> + Transport:send(Socket, Bytes). + +handle_version({2, 0} = NumVsn, StrVsn, Ssh0) -> Ssh = counterpart_versions(NumVsn, StrVsn, Ssh0), {ok, Ssh}; handle_version(_,_,_) -> @@ -1336,419 +1489,185 @@ string_version(#ssh{role = client, c_version = Vsn}) -> string_version(#ssh{role = server, s_version = Vsn}) -> Vsn. -send_event(FsmPid, Event) -> - gen_fsm:send_event(FsmPid, Event). -send_all_state_event(FsmPid, Event) -> - gen_fsm:send_all_state_event(FsmPid, Event). +cast(FsmPid, Event) -> + gen_statem:cast(FsmPid, Event). -sync_send_all_state_event(FsmPid, Event) -> - sync_send_all_state_event(FsmPid, Event, infinity). +call(FsmPid, Event) -> + call(FsmPid, Event, infinity). -sync_send_all_state_event(FsmPid, Event, Timeout) -> - try gen_fsm:sync_send_all_state_event(FsmPid, Event, Timeout) of - {closed, _Channel} -> +call(FsmPid, Event, Timeout) -> + try gen_statem:call(FsmPid, Event, Timeout) of + {closed, _R} -> + {error, closed}; + {killed, _R} -> {error, closed}; Result -> Result catch - exit:{noproc, _} -> + exit:{noproc, _R} -> {error, closed}; - exit:{normal, _} -> + exit:{normal, _R} -> {error, closed}; - exit:{{shutdown, _},_} -> + exit:{{shutdown, _R},_} -> {error, closed} end. -%% simulate send_all_state_event(self(), Event) -event(#ssh_msg_disconnect{} = Event, StateName, State) -> - handle_event(Event, StateName, State); -event(#ssh_msg_ignore{} = Event, StateName, State) -> - handle_event(Event, StateName, State); -event(#ssh_msg_debug{} = Event, StateName, State) -> - handle_event(Event, StateName, State); -event(#ssh_msg_unimplemented{} = Event, StateName, State) -> - handle_event(Event, StateName, State); -%% simulate send_event(self(), Event) -event(Event, StateName, State) -> - try - ?MODULE:StateName(Event, State) + +handle_connection_msg(Msg, StateName, State0 = + #data{starter = User, + connection_state = Connection0, + event_queue = Qev0}) -> + Renegotiation = renegotiation(StateName), + Role = role(StateName), + try ssh_connection:handle_msg(Msg, Connection0, Role) of + {{replies, Replies}, Connection} -> + case StateName of + {connected,_} -> + {Repls, State} = send_replies(Replies, + State0#data{connection_state=Connection}), + {keep_state, State, Repls}; + _ -> + {ConnReplies, Replies} = + lists:splitwith(fun not_connected_filter/1, Replies), + {Repls, State} = send_replies(Replies, + State0#data{event_queue = Qev0 ++ ConnReplies}), + {keep_state, State, Repls} + end; + + {noreply, Connection} -> + {keep_state, State0#data{connection_state = Connection}}; + + {disconnect, Reason0, {{replies, Replies}, Connection}} -> + {Repls,State} = send_replies(Replies, State0#data{connection_state = Connection}), + case {Reason0,Role} of + {{_, Reason}, client} when ((StateName =/= {connected,client}) and (not Renegotiation)) -> + User ! {self(), not_connected, Reason}; + _ -> + ok + end, + {stop_and_reply, {shutdown,normal}, Repls, State#data{connection_state = Connection}} + catch - throw:#ssh_msg_disconnect{} = DisconnectMsg -> - handle_disconnect(DisconnectMsg, State); - throw:{ErrorToDisplay, #ssh_msg_disconnect{} = DisconnectMsg} -> - handle_disconnect(DisconnectMsg, State, ErrorToDisplay); - _C:_Error -> - handle_disconnect(#ssh_msg_disconnect{code = error_code(StateName), - description = "Invalid state", - language = "en"}, State) + _:Error -> + {disconnect, _Reason, {{replies, Replies}, Connection}} = + ssh_connection:handle_msg( + #ssh_msg_disconnect{code = ?SSH_DISCONNECT_BY_APPLICATION, + description = "Internal error"}, + Connection0, Role), + {Repls,State} = send_replies(Replies, State0#data{connection_state = Connection}), + {stop_and_reply, {shutdown,Error}, Repls, State#data{connection_state = Connection}} end. -error_code(key_exchange) -> - ?SSH_DISCONNECT_KEY_EXCHANGE_FAILED; -error_code(new_keys) -> - ?SSH_DISCONNECT_KEY_EXCHANGE_FAILED; -error_code(_) -> - ?SSH_DISCONNECT_SERVICE_NOT_AVAILABLE. - -generate_event(<<?BYTE(Byte), _/binary>> = Msg, StateName, - #state{ - role = Role, - starter = User, - renegotiate = Renegotiation, - connection_state = Connection0} = State0, EncData) - when Byte == ?SSH_MSG_GLOBAL_REQUEST; - Byte == ?SSH_MSG_REQUEST_SUCCESS; - Byte == ?SSH_MSG_REQUEST_FAILURE; - Byte == ?SSH_MSG_CHANNEL_OPEN; - Byte == ?SSH_MSG_CHANNEL_OPEN_CONFIRMATION; - Byte == ?SSH_MSG_CHANNEL_OPEN_FAILURE; - Byte == ?SSH_MSG_CHANNEL_WINDOW_ADJUST; - Byte == ?SSH_MSG_CHANNEL_DATA; - Byte == ?SSH_MSG_CHANNEL_EXTENDED_DATA; - Byte == ?SSH_MSG_CHANNEL_EOF; - Byte == ?SSH_MSG_CHANNEL_CLOSE; - Byte == ?SSH_MSG_CHANNEL_REQUEST; - Byte == ?SSH_MSG_CHANNEL_SUCCESS; - Byte == ?SSH_MSG_CHANNEL_FAILURE -> - try - ssh_message:decode(Msg) - of - ConnectionMsg -> - State1 = generate_event_new_state(State0, EncData), - try ssh_connection:handle_msg(ConnectionMsg, Connection0, Role) of - {{replies, Replies0}, Connection} -> - if StateName == connected -> - Replies = Replies0, - State2 = State1; - true -> - {ConnReplies, Replies} = - lists:splitwith(fun not_connected_filter/1, Replies0), - Q = State1#state.event_queue ++ ConnReplies, - State2 = State1#state{ event_queue = Q } - end, - State = send_replies(Replies, State2#state{connection_state = Connection}), - {next_state, StateName, next_packet(State)}; - {noreply, Connection} -> - {next_state, StateName, next_packet(State1#state{connection_state = Connection})}; - {disconnect, {_, Reason}, {{replies, Replies}, Connection}} when - Role == client andalso ((StateName =/= connected) and (not Renegotiation)) -> - State = send_replies(Replies, State1#state{connection_state = Connection}), - User ! {self(), not_connected, Reason}, - {stop, {shutdown, normal}, - next_packet(State#state{connection_state = Connection})}; - {disconnect, _Reason, {{replies, Replies}, Connection}} -> - State = send_replies(Replies, State1#state{connection_state = Connection}), - {stop, {shutdown, normal}, State#state{connection_state = Connection}} - catch - _:Error -> - {disconnect, _Reason, {{replies, Replies}, Connection}} = - ssh_connection:handle_msg( - #ssh_msg_disconnect{code = ?SSH_DISCONNECT_BY_APPLICATION, - description = "Internal error", - language = "en"}, Connection0, Role), - State = send_replies(Replies, State1#state{connection_state = Connection}), - {stop, {shutdown, Error}, State#state{connection_state = Connection}} - end - catch - _:_ -> - handle_disconnect( - #ssh_msg_disconnect{code = ?SSH_DISCONNECT_PROTOCOL_ERROR, - description = "Bad packet received", - language = ""}, State0) - end; -generate_event(Msg, StateName, State0, EncData) -> - try - Event = ssh_message:decode(set_prefix_if_trouble(Msg,State0)), - State = generate_event_new_state(State0, EncData), - case Event of - #ssh_msg_kexinit{} -> - %% We need payload for verification later. - event({Event, Msg}, StateName, State); - _ -> - event(Event, StateName, State) - end - catch - _C:_E -> - DisconnectMsg = - #ssh_msg_disconnect{code = ?SSH_DISCONNECT_PROTOCOL_ERROR, - description = "Encountered unexpected input", - language = "en"}, - handle_disconnect(DisconnectMsg, State0) - end. - - -set_prefix_if_trouble(Msg = <<?BYTE(Op),_/binary>>, #state{ssh_params=SshParams}) +set_kex_overload_prefix(Msg = <<?BYTE(Op),_/binary>>, #data{ssh_params=SshParams}) when Op == 30; Op == 31 -> case catch atom_to_list(kex(SshParams)) of - "ecdh-sha2-" ++ _ -> + "ecdh-sha2-" ++ _ -> <<"ecdh",Msg/binary>>; "diffie-hellman-group-exchange-" ++ _ -> <<"dh_gex",Msg/binary>>; "diffie-hellman-group" ++ _ -> <<"dh",Msg/binary>>; - _ -> + _ -> Msg end; -set_prefix_if_trouble(Msg, _) -> +set_kex_overload_prefix(Msg, _) -> Msg. kex(#ssh{algorithms=#alg{kex=Kex}}) -> Kex; kex(_) -> undefined. +cache(#data{connection_state=C}) -> C#connection.channel_cache. + -handle_request(ChannelPid, ChannelId, Type, Data, WantReply, From, - #state{connection_state = - #connection{channel_cache = Cache}} = State0) -> - case ssh_channel:cache_lookup(Cache, ChannelId) of +%%%---------------------------------------------------------------- +handle_request(ChannelPid, ChannelId, Type, Data, WantReply, From, D) -> + case ssh_channel:cache_lookup(cache(D), ChannelId) of #channel{remote_id = Id} = Channel -> - update_sys(Cache, Channel, Type, ChannelPid), - Msg = ssh_connection:channel_request_msg(Id, Type, - WantReply, Data), - Replies = [{connection_reply, Msg}], - State = add_request(WantReply, ChannelId, From, State0), - {{replies, Replies}, State}; + update_sys(cache(D), Channel, Type, ChannelPid), + send_msg(ssh_connection:channel_request_msg(Id, Type, WantReply, Data), + add_request(WantReply, ChannelId, From, D)); undefined -> - {{replies, []}, State0} + D end. -handle_request(ChannelId, Type, Data, WantReply, From, - #state{connection_state = - #connection{channel_cache = Cache}} = State0) -> - case ssh_channel:cache_lookup(Cache, ChannelId) of - #channel{remote_id = Id} -> - Msg = ssh_connection:channel_request_msg(Id, Type, - WantReply, Data), - Replies = [{connection_reply, Msg}], - State = add_request(WantReply, ChannelId, From, State0), - {{replies, Replies}, State}; +handle_request(ChannelId, Type, Data, WantReply, From, D) -> + case ssh_channel:cache_lookup(cache(D), ChannelId) of + #channel{remote_id = Id} -> + send_msg(ssh_connection:channel_request_msg(Id, Type, WantReply, Data), + add_request(WantReply, ChannelId, From, D)); undefined -> - {{replies, []}, State0} - end. - -handle_global_request({global_request, ChannelPid, - "tcpip-forward" = Type, WantReply, - <<?UINT32(IPLen), - IP:IPLen/binary, ?UINT32(Port)>> = Data}, - #state{connection_state = - #connection{channel_cache = Cache} - = Connection0} = State) -> - ssh_channel:cache_update(Cache, #channel{user = ChannelPid, - type = "forwarded-tcpip", - sys = none}), - Connection = ssh_connection:bind(IP, Port, ChannelPid, Connection0), - Msg = ssh_connection:global_request_msg(Type, WantReply, Data), - send_replies([{connection_reply, Msg}], State#state{connection_state = Connection}); - -handle_global_request({global_request, _Pid, "cancel-tcpip-forward" = Type, - WantReply, <<?UINT32(IPLen), - IP:IPLen/binary, ?UINT32(Port)>> = Data}, - #state{connection_state = Connection0} = State) -> - Connection = ssh_connection:unbind(IP, Port, Connection0), - Msg = ssh_connection:global_request_msg(Type, WantReply, Data), - send_replies([{connection_reply, Msg}], State#state{connection_state = Connection}); - -handle_global_request({global_request, _, "cancel-tcpip-forward" = Type, - WantReply, Data}, State) -> - Msg = ssh_connection:global_request_msg(Type, WantReply, Data), - send_replies([{connection_reply, Msg}], State). - -handle_idle_timeout(#state{opts = Opts}) -> - case proplists:get_value(idle_time, Opts, infinity) of - infinity -> - ok; - IdleTime -> - erlang:send_after(IdleTime, self(), {check_cache, [], []}) + D end. -handle_channel_down(ChannelPid, #state{connection_state = - #connection{channel_cache = Cache}} = - State) -> +%%%---------------------------------------------------------------- +handle_channel_down(ChannelPid, D) -> ssh_channel:cache_foldl( fun(Channel, Acc) when Channel#channel.user == ChannelPid -> - ssh_channel:cache_delete(Cache, + ssh_channel:cache_delete(cache(D), Channel#channel.local_id), Acc; (_,Acc) -> Acc - end, [], Cache), - {{replies, []}, check_cache(State, Cache)}. + end, [], cache(D)), + {{replies, []}, cache_check_set_idle_timer(D)}. + update_sys(Cache, Channel, Type, ChannelPid) -> ssh_channel:cache_update(Cache, Channel#channel{sys = Type, user = ChannelPid}). + add_request(false, _ChannelId, _From, State) -> State; -add_request(true, ChannelId, From, #state{connection_state = - #connection{requests = Requests0} = - Connection} = State) -> +add_request(true, ChannelId, From, #data{connection_state = + #connection{requests = Requests0} = + Connection} = State) -> Requests = [{ChannelId, From} | Requests0], - State#state{connection_state = Connection#connection{requests = Requests}}. + State#data{connection_state = Connection#connection{requests = Requests}}. -new_channel_id(#state{connection_state = #connection{channel_id_seed = Id} = - Connection} +new_channel_id(#data{connection_state = #connection{channel_id_seed = Id} = + Connection} = State) -> - {Id, State#state{connection_state = - Connection#connection{channel_id_seed = Id + 1}}}. - -generate_event_new_state(#state{ssh_params = - #ssh{recv_sequence = SeqNum0} - = Ssh} = State, EncData) -> - SeqNum = ssh_transport:next_seqnum(SeqNum0), - State#state{ssh_params = Ssh#ssh{recv_sequence = SeqNum}, - decoded_data_buffer = <<>>, - encoded_data_buffer = EncData, - undecoded_packet_length = undefined}. - -next_packet(#state{decoded_data_buffer = <<>>, - encoded_data_buffer = Buff, - ssh_params = #ssh{decrypt_block_size = BlockSize}, - socket = Socket, - transport_protocol = Protocol} = State) when Buff =/= <<>> -> - case size(Buff) >= erlang:max(8, BlockSize) of - true -> - %% Enough data from the next packet has been received to - %% decode the length indicator, fake a socket-recive - %% message so that the data will be processed - self() ! {Protocol, Socket, <<>>}; - false -> - inet:setopts(Socket, [{active, once}]) - end, - State; - -next_packet(#state{socket = Socket} = State) -> - inet:setopts(Socket, [{active, once}]), - State. - -after_new_keys(#state{renegotiate = true} = State) -> - State1 = State#state{renegotiate = false, event_queue = []}, - lists:foldr(fun after_new_keys_events/2, {next_state, connected, State1}, State#state.event_queue); -after_new_keys(#state{renegotiate = false, - ssh_params = #ssh{role = client} = Ssh0} = State) -> - {Msg, Ssh} = ssh_auth:service_request_msg(Ssh0), - send_msg(Msg, State), - {next_state, service_request, State#state{ssh_params = Ssh}}; -after_new_keys(#state{renegotiate = false, - ssh_params = #ssh{role = server}} = State) -> - {next_state, service_request, State}. - -after_new_keys_events({sync, _Event, From}, {stop, _Reason, _StateData}=Terminator) -> - gen_fsm:reply(From, {error, closed}), - Terminator; -after_new_keys_events(_, {stop, _Reason, _StateData}=Terminator) -> - Terminator; -after_new_keys_events({sync, Event, From}, {next_state, StateName, StateData}) -> - case handle_sync_event(Event, From, StateName, StateData) of - {reply, Reply, NextStateName, NewStateData} -> - gen_fsm:reply(From, Reply), - {next_state, NextStateName, NewStateData}; - {next_state, NextStateName, NewStateData}-> - {next_state, NextStateName, NewStateData}; - {stop, Reason, Reply, NewStateData} -> - gen_fsm:reply(From, Reply), - {stop, Reason, NewStateData} - end; -after_new_keys_events({event, Event}, {next_state, StateName, StateData}) -> - case handle_event(Event, StateName, StateData) of - {next_state, NextStateName, NewStateData}-> - {next_state, NextStateName, NewStateData}; - {stop, Reason, NewStateData} -> - {stop, Reason, NewStateData} - end; -after_new_keys_events({connection_reply, _Data} = Reply, {StateName, State}) -> - NewState = send_replies([Reply], State), - {next_state, StateName, NewState}. - - -handle_disconnect(DisconnectMsg, State) -> - handle_disconnect(own, DisconnectMsg, State). - -handle_disconnect(#ssh_msg_disconnect{} = DisconnectMsg, State, Error) -> - handle_disconnect(own, DisconnectMsg, State, Error); -handle_disconnect(Type, #ssh_msg_disconnect{description = Desc} = Msg, #state{connection_state = Connection0, role = Role} = State0) -> - {disconnect, _, {{replies, Replies}, Connection}} = ssh_connection:handle_msg(Msg, Connection0, Role), - State = send_replies(disconnect_replies(Type, Msg, Replies), State0), - disconnect_fun(Desc, State#state.opts), - {stop, {shutdown, Desc}, State#state{connection_state = Connection}}. - -handle_disconnect(Type, #ssh_msg_disconnect{description = Desc} = Msg, #state{connection_state = Connection0, - role = Role} = State0, ErrorMsg) -> - {disconnect, _, {{replies, Replies}, Connection}} = ssh_connection:handle_msg(Msg, Connection0, Role), - State = send_replies(disconnect_replies(Type, Msg, Replies), State0), - disconnect_fun(Desc, State#state.opts), - {stop, {shutdown, {Desc, ErrorMsg}}, State#state{connection_state = Connection}}. - -disconnect_replies(own, Msg, Replies) -> - [{connection_reply, Msg} | Replies]; -disconnect_replies(peer, _, Replies) -> - Replies. - + {Id, State#data{connection_state = + Connection#connection{channel_id_seed = Id + 1}}}. + +%%%---------------------------------------------------------------- +%% %%% This server/client has decided to disconnect via the state machine: +disconnect(Msg=#ssh_msg_disconnect{description=Description}, _StateName, State0) -> + State = send_msg(Msg, State0), + disconnect_fun(Description, State), +timer:sleep(400), + {stop, {shutdown,Description}, State}. + +%%%---------------------------------------------------------------- counterpart_versions(NumVsn, StrVsn, #ssh{role = server} = Ssh) -> Ssh#ssh{c_vsn = NumVsn , c_version = StrVsn}; counterpart_versions(NumVsn, StrVsn, #ssh{role = client} = Ssh) -> Ssh#ssh{s_vsn = NumVsn , s_version = StrVsn}. -opposite_role(client) -> - server; -opposite_role(server) -> - client. -connected_fun(User, PeerAddr, Method, Opts) -> - case proplists:get_value(connectfun, Opts) of - undefined -> - ok; - Fun -> - catch Fun(User, PeerAddr, Method) - end. - -retry_fun(_, _, undefined, _) -> - ok; - -retry_fun(User, PeerAddr, {error, Reason}, Opts) -> - case proplists:get_value(failfun, Opts) of - undefined -> - ok; - Fun -> - do_retry_fun(Fun, User, PeerAddr, Reason) - end; - -retry_fun(User, PeerAddr, Reason, Opts) -> - case proplists:get_value(infofun, Opts) of - undefined -> - ok; - Fun -> - do_retry_fun(Fun, User, PeerAddr, Reason) - end. - -do_retry_fun(Fun, User, PeerAddr, Reason) -> - case erlang:fun_info(Fun, arity) of - {arity, 2} -> %% Backwards compatible - catch Fun(User, Reason); - {arity, 3} -> - catch Fun(User, PeerAddr, Reason) - end. - ssh_info([], _State, Acc) -> Acc; -ssh_info([client_version | Rest], #state{ssh_params = #ssh{c_vsn = IntVsn, +ssh_info([client_version | Rest], #data{ssh_params = #ssh{c_vsn = IntVsn, c_version = StringVsn}} = State, Acc) -> ssh_info(Rest, State, [{client_version, {IntVsn, StringVsn}} | Acc]); -ssh_info([server_version | Rest], #state{ssh_params =#ssh{s_vsn = IntVsn, +ssh_info([server_version | Rest], #data{ssh_params =#ssh{s_vsn = IntVsn, s_version = StringVsn}} = State, Acc) -> ssh_info(Rest, State, [{server_version, {IntVsn, StringVsn}} | Acc]); -ssh_info([peer | Rest], #state{ssh_params = #ssh{peer = Peer}} = State, Acc) -> +ssh_info([peer | Rest], #data{ssh_params = #ssh{peer = Peer}} = State, Acc) -> ssh_info(Rest, State, [{peer, Peer} | Acc]); -ssh_info([sockname | Rest], #state{socket = Socket} = State, Acc) -> +ssh_info([sockname | Rest], #data{socket = Socket} = State, Acc) -> {ok, SockName} = inet:sockname(Socket), ssh_info(Rest, State, [{sockname, SockName}|Acc]); -ssh_info([user | Rest], #state{auth_user = User} = State, Acc) -> +ssh_info([user | Rest], #data{auth_user = User} = State, Acc) -> ssh_info(Rest, State, [{user, User}|Acc]); ssh_info([ _ | Rest], State, Acc) -> ssh_info(Rest, State, Acc). + ssh_channel_info([], _, Acc) -> Acc; @@ -1765,43 +1684,49 @@ ssh_channel_info([send_window | Rest], #channel{send_window_size = WinSize, ssh_channel_info([ _ | Rest], Channel, Acc) -> ssh_channel_info(Rest, Channel, Acc). + log_error(Reason) -> - Report = io_lib:format("Erlang ssh connection handler failed with reason: " - "~p ~n, Stacktrace: ~p ~n", - [Reason, erlang:get_stacktrace()]), - error_logger:error_report(Report), - "Internal error". - -not_connected_filter({connection_reply, _Data}) -> - true; -not_connected_filter(_) -> - false. - -send_replies([], State) -> - State; -send_replies([{connection_reply, Data} | Rest], #state{ssh_params = Ssh0} = State) -> - {Packet, Ssh} = ssh_transport:ssh_packet(Data, Ssh0), - send_msg(Packet, State), - send_replies(Rest, State#state{ssh_params = Ssh}); -send_replies([Msg | Rest], State) -> - catch send_reply(Msg), - send_replies(Rest, State). - -send_reply({channel_data, Pid, Data}) -> - Pid ! {ssh_cm, self(), Data}; -send_reply({channel_requst_reply, From, Data}) -> - gen_fsm:reply(From, Data); -send_reply({flow_control, Cache, Channel, From, Msg}) -> + Report = io_lib:format("Erlang ssh connection handler failed with reason:~n" + " ~p~n" + "Stacktrace:~n" + " ~p~n", + [Reason, erlang:get_stacktrace()]), + error_logger:error_report(Report). + + +%%%---------------------------------------------------------------- +not_connected_filter({connection_reply, _Data}) -> true; +not_connected_filter(_) -> false. + +%%%---------------------------------------------------------------- +send_replies(Repls, State) -> + lists:foldl(fun get_repl/2, + {[],State}, + Repls). + +get_repl({connection_reply,Msg}, {CallRepls,S}) -> + {CallRepls, send_msg(Msg,S)}; +get_repl({channel_data,undefined,_Data}, Acc) -> + Acc; +get_repl({channel_data,Pid,Data}, Acc) -> + Pid ! {ssh_cm, self(), Data}, + Acc; +get_repl({channel_request_reply,From,Data}, {CallRepls,S}) -> + {[{reply,From,Data}|CallRepls], S}; +get_repl({flow_control,Cache,Channel,From,Msg}, {CallRepls,S}) -> ssh_channel:cache_update(Cache, Channel#channel{flow_control = undefined}), - gen_fsm:reply(From, Msg); -send_reply({flow_control, From, Msg}) -> - gen_fsm:reply(From, Msg). + {[{reply,From,Msg}|CallRepls], S}; +get_repl({flow_control,From,Msg}, {CallRepls,S}) -> + {[{reply,From,Msg}|CallRepls], S}; +get_repl(noreply, Acc) -> + Acc; +get_repl(X, Acc) -> + exit({get_repl,X,Acc}). -disconnect_fun({disconnect,Msg}, Opts) -> - disconnect_fun(Msg, Opts); -disconnect_fun(_, undefined) -> - ok; -disconnect_fun(Reason, Opts) -> +%%%---------------------------------------------------------------- +disconnect_fun({disconnect,Msg}, D) -> + disconnect_fun(Msg, D); +disconnect_fun(Reason, #data{opts=Opts}) -> case proplists:get_value(disconnectfun, Opts) of undefined -> ok; @@ -1809,50 +1734,137 @@ disconnect_fun(Reason, Opts) -> catch Fun(Reason) end. -unexpected_fun(UnexpectedMessage, Opts, #ssh{peer={_,Peer}}) -> +unexpected_fun(UnexpectedMessage, #data{opts = Opts, + ssh_params = #ssh{peer = {_,Peer} } + } ) -> case proplists:get_value(unexpectedfun, Opts) of undefined -> report; Fun -> - catch Fun(UnexpectedMessage, Peer) + catch Fun(UnexpectedMessage, Peer) end. -check_cache(#state{opts = Opts} = State, Cache) -> - %% Check the number of entries in Cache - case proplists:get_value(size, ets:info(Cache)) of - 0 -> - case proplists:get_value(idle_time, Opts, infinity) of - infinity -> - State; - Time -> - handle_idle_timer(Time, State) - end; +debug_fun(#ssh_msg_debug{always_display = Display, + message = DbgMsg, + language = Lang}, + #data{opts = Opts}) -> + case proplists:get_value(ssh_msg_debug_fun, Opts) of + undefined -> + ok; + Fun -> + catch Fun(self(), Display, DbgMsg, Lang) + end. + + +connected_fun(User, Method, #data{ssh_params = #ssh{peer = {_,Peer}}, + opts = Opts}) -> + case proplists:get_value(connectfun, Opts) of + undefined -> + ok; + Fun -> + catch Fun(User, Peer, Method) + end. + +retry_fun(_, undefined, _) -> + ok; +retry_fun(User, Reason, #data{ssh_params = #ssh{opts = Opts, + peer = {_,Peer} + }}) -> + {Tag,Info} = + case Reason of + {error, Error} -> + {failfun, Error}; + _ -> + {infofun, Reason} + end, + Fun = proplists:get_value(Tag, Opts, fun(_,_)-> ok end), + try erlang:fun_info(Fun, arity) + of + {arity, 2} -> %% Backwards compatible + catch Fun(User, Info); + {arity, 3} -> + catch Fun(User, Peer, Info); _ -> - State + ok + catch + _:_ -> + ok + end. + +%%%---------------------------------------------------------------- +%%% Cache idle timer that closes the connection if there are no +%%% channels open for a while. + +cache_init_idle_timer(D) -> + case proplists:get_value(idle_time, D#data.opts, infinity) of + infinity -> + D#data{idle_timer_value = infinity, + idle_timer_ref = infinity % A flag used later... + }; + IdleTime -> + %% We dont want to set the timeout on first connect + D#data{idle_timer_value = IdleTime} end. -handle_idle_timer(Time, #state{idle_timer_ref = undefined} = State) -> - TimerRef = erlang:send_after(Time, self(), {'EXIT', [], "Timeout"}), - State#state{idle_timer_ref=TimerRef}; -handle_idle_timer(_, State) -> - State. - -remove_timer_ref(State) -> - case State#state.idle_timer_ref of - infinity -> %% If the timer is not activated - State; - undefined -> %% If we already has cancelled the timer - State; - TimerRef -> %% Timer is active + +cache_check_set_idle_timer(D = #data{idle_timer_ref = undefined, + idle_timer_value = IdleTime}) -> + %% No timer set - shall we set one? + case ssh_channel:cache_info(num_entries, cache(D)) of + 0 when IdleTime == infinity -> + %% No. Meaningless to set a timer that fires in an infinite time... + D; + 0 -> + %% Yes, we'll set one since the cache is empty and it should not + %% be that for a specified time + D#data{idle_timer_ref = + erlang:send_after(IdleTime, self(), {'EXIT',[],"Timeout"})}; + _ -> + %% No - there are entries in the cache + D + end; +cache_check_set_idle_timer(D) -> + %% There is already a timer set or the timeout time is infinite + D. + + +cache_cancel_idle_timer(D) -> + case D#data.idle_timer_ref of + infinity -> + %% The timer is not activated + D; + undefined -> + %% The timer is already cancelled + D; + TimerRef -> + %% The timer is active erlang:cancel_timer(TimerRef), - State#state{idle_timer_ref = undefined} + D#data{idle_timer_ref = undefined} end. -socket_control(Socket, Pid, Transport) -> - case Transport:controlling_process(Socket, Pid) of + +cache_request_idle_timer_check(D = #data{idle_timer_value = infinity}) -> + D; +cache_request_idle_timer_check(D = #data{idle_timer_value = IdleTime}) -> + erlang:send_after(IdleTime, self(), check_cache), + D. + +%%%---------------------------------------------------------------- +start_channel_request_timer(_,_, infinity) -> + ok; +start_channel_request_timer(Channel, From, Time) -> + erlang:send_after(Time, self(), {timeout, {Channel, From}}). + +%%%---------------------------------------------------------------- +%%% Connection start and initalization helpers + +socket_control(Socket, Pid, Options) -> + {_, TransportCallback, _} = % For example {_,gen_tcp,_} + proplists:get_value(transport, Options, ?DefaultTransport), + case TransportCallback:controlling_process(Socket, Pid) of ok -> - send_event(Pid, socket_control); + gen_statem:cast(Pid, socket_control); {error, Reason} -> {error, Reason} end. @@ -1881,16 +1893,3 @@ handshake(Pid, Ref, Timeout) -> {error, timeout} end. -start_timeout(_,_, infinity) -> - ok; -start_timeout(Channel, From, Time) -> - erlang:send_after(Time, self(), {timeout, {Channel, From}}). - -getopt(Opt, Socket) -> - case inet:getopts(Socket, [Opt]) of - {ok, [{Opt, Value}]} -> - {ok, Value}; - Other -> - {error, {unexpected_getopts_return, Other}} - end. - diff --git a/lib/ssh/src/ssh_info.erl b/lib/ssh/src/ssh_info.erl index 67130d5eac..0c24c09887 100644 --- a/lib/ssh/src/ssh_info.erl +++ b/lib/ssh/src/ssh_info.erl @@ -37,7 +37,7 @@ print() -> io:format("~s", [string()]). print(File) when is_list(File) -> - {ok,D} = file:open(File, write), + {ok,D} = file:open(File, [write]), print(D), file:close(D); print(D) -> diff --git a/lib/ssh/src/ssh_message.erl b/lib/ssh/src/ssh_message.erl index 65754956aa..db80d4c9e3 100644 --- a/lib/ssh/src/ssh_message.erl +++ b/lib/ssh/src/ssh_message.erl @@ -50,13 +50,7 @@ -define(Empint(X), (ssh_bits:mpint(X))/binary ). -define(Ebinary(X), ?STRING(X) ). -%% encode(Msg) -> -%% try encode1(Msg) -%% catch -%% C:E -> -%% io:format('***********************~n~p:~p ~p~n',[C,E,Msg]), -%% error(E) -%% end. +-define(unicode_list(B), unicode:characters_to_list(B)). encode(#ssh_msg_global_request{ name = Name, @@ -176,7 +170,7 @@ encode(#ssh_msg_userauth_pk_ok{ encode(#ssh_msg_userauth_passwd_changereq{prompt = Prompt, languge = Lang })-> - <<?Ebyte(?SSH_MSG_USERAUTH_PASSWD_CHANGEREQ), ?Estring(Prompt), ?Estring(Lang)>>; + <<?Ebyte(?SSH_MSG_USERAUTH_PASSWD_CHANGEREQ), ?Estring_utf8(Prompt), ?Estring(Lang)>>; encode(#ssh_msg_userauth_info_request{ name = Name, @@ -184,14 +178,14 @@ encode(#ssh_msg_userauth_info_request{ language_tag = Lang, num_prompts = NumPromtps, data = Data}) -> - <<?Ebyte(?SSH_MSG_USERAUTH_INFO_REQUEST), ?Estring(Name), ?Estring(Inst), ?Estring(Lang), + <<?Ebyte(?SSH_MSG_USERAUTH_INFO_REQUEST), ?Estring_utf8(Name), ?Estring_utf8(Inst), ?Estring(Lang), ?Euint32(NumPromtps), ?'E...'(Data)>>; encode(#ssh_msg_userauth_info_response{ num_responses = Num, data = Data}) -> lists:foldl(fun %%("", Acc) -> Acc; % commented out since it seem wrong - (Response, Acc) -> <<Acc/binary, ?Estring(Response)>> + (Response, Acc) -> <<Acc/binary, ?Estring_utf8(Response)>> end, <<?Ebyte(?SSH_MSG_USERAUTH_INFO_RESPONSE), ?Euint32(Num)>>, Data); @@ -201,17 +195,17 @@ encode(#ssh_msg_disconnect{ description = Desc, language = Lang }) -> - <<?Ebyte(?SSH_MSG_DISCONNECT), ?Euint32(Code), ?Estring(Desc), ?Estring(Lang)>>; + <<?Ebyte(?SSH_MSG_DISCONNECT), ?Euint32(Code), ?Estring_utf8(Desc), ?Estring(Lang)>>; encode(#ssh_msg_service_request{ name = Service }) -> - <<?Ebyte(?SSH_MSG_SERVICE_REQUEST), ?Estring(Service)>>; + <<?Ebyte(?SSH_MSG_SERVICE_REQUEST), ?Estring_utf8(Service)>>; encode(#ssh_msg_service_accept{ name = Service }) -> - <<?Ebyte(?SSH_MSG_SERVICE_ACCEPT), ?Estring(Service)>>; + <<?Ebyte(?SSH_MSG_SERVICE_ACCEPT), ?Estring_utf8(Service)>>; encode(#ssh_msg_newkeys{}) -> <<?Ebyte(?SSH_MSG_NEWKEYS)>>; @@ -283,7 +277,7 @@ encode(#ssh_msg_kex_ecdh_reply{public_host_key = Key, q_s = Q_s, h_sig = Sign}) <<?Ebyte(?SSH_MSG_KEX_ECDH_REPLY), ?Ebinary(EncKey), ?Empint(Q_s), ?Ebinary(EncSign)>>; encode(#ssh_msg_ignore{data = Data}) -> - <<?Ebyte(?SSH_MSG_IGNORE), ?Estring(Data)>>; + <<?Ebyte(?SSH_MSG_IGNORE), ?Estring_utf8(Data)>>; encode(#ssh_msg_unimplemented{sequence = Seq}) -> <<?Ebyte(?SSH_MSG_UNIMPLEMENTED), ?Euint32(Seq)>>; @@ -291,7 +285,7 @@ encode(#ssh_msg_unimplemented{sequence = Seq}) -> encode(#ssh_msg_debug{always_display = Bool, message = Msg, language = Lang}) -> - <<?Ebyte(?SSH_MSG_DEBUG), ?Eboolean(Bool), ?Estring(Msg), ?Estring(Lang)>>. + <<?Ebyte(?SSH_MSG_DEBUG), ?Eboolean(Bool), ?Estring_utf8(Msg), ?Estring(Lang)>>. %% Connection Messages @@ -330,7 +324,7 @@ decode(<<?BYTE(?SSH_MSG_CHANNEL_OPEN_FAILURE), ?UINT32(Recipient), ?UINT32(Reas #ssh_msg_channel_open_failure{ recipient_channel = Recipient, reason = Reason, - description = unicode:characters_to_list(Desc), + description = ?unicode_list(Desc), lang = Lang }; decode(<<?BYTE(?SSH_MSG_CHANNEL_WINDOW_ADJUST), ?UINT32(Recipient), ?UINT32(Bytes)>>) -> @@ -363,7 +357,7 @@ decode(<<?BYTE(?SSH_MSG_CHANNEL_REQUEST), ?UINT32(Recipient), ?DEC_BIN(RequestType,__0), ?BYTE(Bool), Data/binary>>) -> #ssh_msg_channel_request{ recipient_channel = Recipient, - request_type = unicode:characters_to_list(RequestType), + request_type = ?unicode_list(RequestType), want_reply = erl_boolean(Bool), data = Data }; @@ -381,9 +375,9 @@ decode(<<?BYTE(?SSH_MSG_USERAUTH_REQUEST), ?DEC_BIN(User,__0), ?DEC_BIN(Service,__1), ?DEC_BIN(Method,__2), Data/binary>>) -> #ssh_msg_userauth_request{ - user = unicode:characters_to_list(User), - service = unicode:characters_to_list(Service), - method = unicode:characters_to_list(Method), + user = ?unicode_list(User), + service = ?unicode_list(Service), + method = ?unicode_list(Method), data = Data }; @@ -391,7 +385,7 @@ decode(<<?BYTE(?SSH_MSG_USERAUTH_FAILURE), ?DEC_BIN(Auths,__0), ?BYTE(Bool)>>) -> #ssh_msg_userauth_failure { - authentications = unicode:characters_to_list(Auths), + authentications = ?unicode_list(Auths), partial_success = erl_boolean(Bool) }; @@ -493,18 +487,18 @@ decode(<<"ecdh",?BYTE(?SSH_MSG_KEX_ECDH_REPLY), decode(<<?SSH_MSG_SERVICE_REQUEST, ?DEC_BIN(Service,__0)>>) -> #ssh_msg_service_request{ - name = unicode:characters_to_list(Service) + name = ?unicode_list(Service) }; decode(<<?SSH_MSG_SERVICE_ACCEPT, ?DEC_BIN(Service,__0)>>) -> #ssh_msg_service_accept{ - name = unicode:characters_to_list(Service) + name = ?unicode_list(Service) }; decode(<<?BYTE(?SSH_MSG_DISCONNECT), ?UINT32(Code), ?DEC_BIN(Desc,__0), ?DEC_BIN(Lang,__1)>>) -> #ssh_msg_disconnect{ code = Code, - description = unicode:characters_to_list(Desc), + description = ?unicode_list(Desc), language = Lang }; @@ -512,7 +506,7 @@ decode(<<?BYTE(?SSH_MSG_DISCONNECT), ?UINT32(Code), ?DEC_BIN(Desc,__0), ?DEC_BIN decode(<<?BYTE(?SSH_MSG_DISCONNECT), ?UINT32(Code), ?DEC_BIN(Desc,__0)>>) -> #ssh_msg_disconnect{ code = Code, - description = unicode:characters_to_list(Desc), + description = ?unicode_list(Desc), language = <<"en">> }; @@ -554,7 +548,7 @@ decode_kex_init(<<?BYTE(Bool)>>, Acc, 0) -> X = 0, list_to_tuple(lists:reverse([X, erl_boolean(Bool) | Acc])); decode_kex_init(<<?DEC_BIN(Data,__0), Rest/binary>>, Acc, N) -> - Names = string:tokens(unicode:characters_to_list(Data), ","), + Names = string:tokens(?unicode_list(Data), ","), decode_kex_init(Rest, [Names | Acc], N -1). diff --git a/lib/ssh/src/ssh_no_io.erl b/lib/ssh/src/ssh_no_io.erl index 8144aac66e..1da257ed99 100644 --- a/lib/ssh/src/ssh_no_io.erl +++ b/lib/ssh/src/ssh_no_io.erl @@ -27,27 +27,39 @@ -export([yes_no/2, read_password/2, read_line/2, format/2]). + +-spec yes_no(any(), any()) -> no_return(). + yes_no(_, _) -> - throw({{no_io_allowed, yes_no}, - #ssh_msg_disconnect{code = ?SSH_DISCONNECT_SERVICE_NOT_AVAILABLE, - description = "User interaction is not allowed", - language = "en"}}). + ssh_connection_handler:disconnect( + #ssh_msg_disconnect{code = ?SSH_DISCONNECT_SERVICE_NOT_AVAILABLE, + description = "User interaction is not allowed"}, + {no_io_allowed, yes_no}). + + +-spec read_password(any(), any()) -> no_return(). read_password(_, _) -> - throw({{no_io_allowed, read_password}, - #ssh_msg_disconnect{code = ?SSH_DISCONNECT_SERVICE_NOT_AVAILABLE, - description = "User interaction is not allowed", - language = "en"}}). + ssh_connection_handler:disconnect( + #ssh_msg_disconnect{code = ?SSH_DISCONNECT_SERVICE_NOT_AVAILABLE, + description = "User interaction is not allowed"}, + {no_io_allowed, read_password}). + + +-spec read_line(any(), any()) -> no_return(). read_line(_, _) -> - throw({{no_io_allowed, read_line}, - #ssh_msg_disconnect{code = ?SSH_DISCONNECT_SERVICE_NOT_AVAILABLE, - description = "User interaction is not allowed", - language = "en"}} ). + ssh_connection_handler:disconnect( + #ssh_msg_disconnect{code = ?SSH_DISCONNECT_SERVICE_NOT_AVAILABLE, + description = "User interaction is not allowed"}, + {no_io_allowed, read_line}). + + +-spec format(any(), any()) -> no_return(). format(_, _) -> - throw({{no_io_allowed, format}, - #ssh_msg_disconnect{code = ?SSH_DISCONNECT_SERVICE_NOT_AVAILABLE, - description = "User interaction is not allowed", - language = "en"}}). + ssh_connection_handler:disconnect( + #ssh_msg_disconnect{code = ?SSH_DISCONNECT_SERVICE_NOT_AVAILABLE, + description = "User interaction is not allowed"}, + {no_io_allowed, format}). diff --git a/lib/ssh/src/ssh_system_sup.erl b/lib/ssh/src/ssh_system_sup.erl index 6314671f0d..9a9786a914 100644 --- a/lib/ssh/src/ssh_system_sup.erl +++ b/lib/ssh/src/ssh_system_sup.erl @@ -192,6 +192,9 @@ stop_acceptor(Sup) -> [{Name, AcceptorSup}] = [{SupName, ASup} || {SupName, ASup, _, [ssh_acceptor_sup]} <- supervisor:which_children(Sup)], - supervisor:terminate_child(AcceptorSup, Name). - - + case supervisor:terminate_child(AcceptorSup, Name) of + ok -> + supervisor:delete_child(AcceptorSup, Name); + Error -> + Error + end. diff --git a/lib/ssh/src/ssh_transport.erl b/lib/ssh/src/ssh_transport.erl index c04bd350c7..7cb3b75ac0 100644 --- a/lib/ssh/src/ssh_transport.erl +++ b/lib/ssh/src/ssh_transport.erl @@ -265,7 +265,8 @@ new_keys_message(Ssh0) -> {SshPacket, Ssh} = ssh_packet(#ssh_msg_newkeys{}, Ssh0), {ok, SshPacket, Ssh}. - + + handle_kexinit_msg(#ssh_msg_kexinit{} = CounterPart, #ssh_msg_kexinit{} = Own, #ssh{role = client} = Ssh0) -> {ok, Algoritms} = select_algorithm(client, Own, CounterPart), @@ -275,10 +276,10 @@ handle_kexinit_msg(#ssh_msg_kexinit{} = CounterPart, #ssh_msg_kexinit{} = Own, Ssh0#ssh{algorithms = Algoritms}); _ -> %% TODO: Correct code? - throw(#ssh_msg_disconnect{code = ?SSH_DISCONNECT_KEY_EXCHANGE_FAILED, - description = "Selection of key exchange" - " algorithm failed", - language = ""}) + ssh_connection_handler:disconnect( + #ssh_msg_disconnect{code = ?SSH_DISCONNECT_KEY_EXCHANGE_FAILED, + description = "Selection of key exchange algorithm failed" + }) end; handle_kexinit_msg(#ssh_msg_kexinit{} = CounterPart, #ssh_msg_kexinit{} = Own, @@ -288,10 +289,10 @@ handle_kexinit_msg(#ssh_msg_kexinit{} = CounterPart, #ssh_msg_kexinit{} = Own, true -> {ok, Ssh#ssh{algorithms = Algoritms}}; _ -> - throw(#ssh_msg_disconnect{code = ?SSH_DISCONNECT_KEY_EXCHANGE_FAILED, - description = "Selection of key exchange" - " algorithm failed", - language = ""}) + ssh_connection_handler:disconnect( + #ssh_msg_disconnect{code = ?SSH_DISCONNECT_KEY_EXCHANGE_FAILED, + description = "Selection of key exchange algorithm failed" + }) end. @@ -371,12 +372,12 @@ handle_kexdh_init(#ssh_msg_kexdh_init{e = E}, session_id = sid(Ssh1, H)}}; true -> - throw({{error,bad_e_from_peer}, - #ssh_msg_disconnect{ - code = ?SSH_DISCONNECT_KEY_EXCHANGE_FAILED, - description = "Key exchange failed, 'e' out of bounds", - language = ""} - }) + ssh_connection_handler:disconnect( + #ssh_msg_disconnect{ + code = ?SSH_DISCONNECT_KEY_EXCHANGE_FAILED, + description = "Key exchange failed, 'e' out of bounds"}, + {error,bad_e_from_peer} + ) end. handle_kexdh_reply(#ssh_msg_kexdh_reply{public_host_key = PeerPubHostKey, @@ -396,21 +397,20 @@ handle_kexdh_reply(#ssh_msg_kexdh_reply{public_host_key = PeerPubHostKey, exchanged_hash = H, session_id = sid(Ssh, H)}}; Error -> - throw({Error, - #ssh_msg_disconnect{ - code = ?SSH_DISCONNECT_KEY_EXCHANGE_FAILED, - description = "Key exchange failed", - language = "en"} - }) + ssh_connection_handler:disconnect( + #ssh_msg_disconnect{ + code = ?SSH_DISCONNECT_KEY_EXCHANGE_FAILED, + description = "Key exchange failed"}, + Error) end; true -> - throw({{error,bad_f_from_peer}, - #ssh_msg_disconnect{ - code = ?SSH_DISCONNECT_KEY_EXCHANGE_FAILED, - description = "Key exchange failed, 'f' out of bounds", - language = ""} - }) + ssh_connection_handler:disconnect( + #ssh_msg_disconnect{ + code = ?SSH_DISCONNECT_KEY_EXCHANGE_FAILED, + description = "Key exchange failed, 'f' out of bounds"}, + bad_f_from_peer + ) end. @@ -435,10 +435,11 @@ handle_kex_dh_gex_request(#ssh_msg_kex_dh_gex_request{min = Min0, keyex_info = {Min, Max, NBits} }}; {error,_} -> - throw(#ssh_msg_disconnect{ - code = ?SSH_DISCONNECT_PROTOCOL_ERROR, - description = "No possible diffie-hellman-group-exchange group found", - language = ""}) + ssh_connection_handler:disconnect( + #ssh_msg_disconnect{ + code = ?SSH_DISCONNECT_PROTOCOL_ERROR, + description = "No possible diffie-hellman-group-exchange group found" + }) end; handle_kex_dh_gex_request(#ssh_msg_kex_dh_gex_request_old{n = NBits}, @@ -469,19 +470,19 @@ handle_kex_dh_gex_request(#ssh_msg_kex_dh_gex_request_old{n = NBits}, keyex_info = {-1, -1, NBits} % flag for kex_h hash calc }}; {error,_} -> - throw(#ssh_msg_disconnect{ - code = ?SSH_DISCONNECT_PROTOCOL_ERROR, - description = "No possible diffie-hellman-group-exchange group found", - language = ""}) + ssh_connection_handler:disconnect( + #ssh_msg_disconnect{ + code = ?SSH_DISCONNECT_PROTOCOL_ERROR, + description = "No possible diffie-hellman-group-exchange group found" + }) end; handle_kex_dh_gex_request(_, _) -> - throw({{error,bad_ssh_msg_kex_dh_gex_request}, + ssh_connection_handler:disconnect( #ssh_msg_disconnect{ code = ?SSH_DISCONNECT_KEY_EXCHANGE_FAILED, - description = "Key exchange failed, bad values in ssh_msg_kex_dh_gex_request", - language = ""} - }). + description = "Key exchange failed, bad values in ssh_msg_kex_dh_gex_request"}, + bad_ssh_msg_kex_dh_gex_request). adjust_gex_min_max(Min0, Max0, Opts) -> @@ -495,10 +496,11 @@ adjust_gex_min_max(Min0, Max0, Opts) -> Min2 =< Max2 -> {Min2, Max2}; Max2 < Min2 -> - throw(#ssh_msg_disconnect{ - code = ?SSH_DISCONNECT_PROTOCOL_ERROR, - description = "No possible diffie-hellman-group-exchange group possible", - language = ""}) + ssh_connection_handler:disconnect( + #ssh_msg_disconnect{ + code = ?SSH_DISCONNECT_PROTOCOL_ERROR, + description = "No possible diffie-hellman-group-exchange group possible" + }) end end. @@ -535,20 +537,18 @@ handle_kex_dh_gex_init(#ssh_msg_kex_dh_gex_init{e = E}, session_id = sid(Ssh, H) }}; true -> - throw({{error,bad_K}, - #ssh_msg_disconnect{ - code = ?SSH_DISCONNECT_KEY_EXCHANGE_FAILED, - description = "Key exchange failed, 'K' out of bounds", - language = ""} - }) + ssh_connection_handler:disconnect( + #ssh_msg_disconnect{ + code = ?SSH_DISCONNECT_KEY_EXCHANGE_FAILED, + description = "Key exchange failed, 'K' out of bounds"}, + bad_K) end; true -> - throw({{error,bad_e_from_peer}, - #ssh_msg_disconnect{ - code = ?SSH_DISCONNECT_KEY_EXCHANGE_FAILED, - description = "Key exchange failed, 'e' out of bounds", - language = ""} - }) + ssh_connection_handler:disconnect( + #ssh_msg_disconnect{ + code = ?SSH_DISCONNECT_KEY_EXCHANGE_FAILED, + description = "Key exchange failed, 'e' out of bounds"}, + bad_e_from_peer) end. handle_kex_dh_gex_reply(#ssh_msg_kex_dh_gex_reply{public_host_key = PeerPubHostKey, @@ -572,29 +572,28 @@ handle_kex_dh_gex_reply(#ssh_msg_kex_dh_gex_reply{public_host_key = PeerPubHostK exchanged_hash = H, session_id = sid(Ssh, H)}}; _Error -> - throw(#ssh_msg_disconnect{ - code = ?SSH_DISCONNECT_KEY_EXCHANGE_FAILED, - description = "Key exchange failed", - language = ""} - ) + ssh_connection_handler:disconnect( + #ssh_msg_disconnect{ + code = ?SSH_DISCONNECT_KEY_EXCHANGE_FAILED, + description = "Key exchange failed" + }) end; true -> - throw({{error,bad_K}, - #ssh_msg_disconnect{ - code = ?SSH_DISCONNECT_KEY_EXCHANGE_FAILED, - description = "Key exchange failed, 'K' out of bounds", - language = ""} - }) + ssh_connection_handler:disconnect( + #ssh_msg_disconnect{ + code = ?SSH_DISCONNECT_KEY_EXCHANGE_FAILED, + description = "Key exchange failed, 'K' out of bounds"}, + bad_K) end; true -> - throw({{error,bad_f_from_peer}, - #ssh_msg_disconnect{ - code = ?SSH_DISCONNECT_KEY_EXCHANGE_FAILED, - description = "Key exchange failed, 'f' out of bounds", - language = ""} - }) - end. + ssh_connection_handler:disconnect( + #ssh_msg_disconnect{ + code = ?SSH_DISCONNECT_KEY_EXCHANGE_FAILED, + description = "Key exchange failed, 'f' out of bounds"}, + bad_f_from_peer + ) + end. %%%---------------------------------------------------------------- %%% @@ -624,12 +623,11 @@ handle_kex_ecdh_init(#ssh_msg_kex_ecdh_init{q_c = PeerPublic}, session_id = sid(Ssh1, H)}} catch _:_ -> - throw({{error,invalid_peer_public_key}, - #ssh_msg_disconnect{ - code = ?SSH_DISCONNECT_KEY_EXCHANGE_FAILED, - description = "Peer ECDH public key is invalid", - language = ""} - }) + ssh_connection_handler:disconnect( + #ssh_msg_disconnect{ + code = ?SSH_DISCONNECT_KEY_EXCHANGE_FAILED, + description = "Peer ECDH public key is invalid"}, + invalid_peer_public_key) end. handle_kex_ecdh_reply(#ssh_msg_kex_ecdh_reply{public_host_key = PeerPubHostKey, @@ -650,21 +648,19 @@ handle_kex_ecdh_reply(#ssh_msg_kex_ecdh_reply{public_host_key = PeerPubHostKey, exchanged_hash = H, session_id = sid(Ssh, H)}}; Error -> - throw({Error, - #ssh_msg_disconnect{ - code = ?SSH_DISCONNECT_KEY_EXCHANGE_FAILED, - description = "Key exchange failed", - language = ""} - }) + ssh_connection_handler:disconnect( + #ssh_msg_disconnect{ + code = ?SSH_DISCONNECT_KEY_EXCHANGE_FAILED, + description = "Key exchange failed"}, + Error) end catch _:_ -> - throw({{error,invalid_peer_public_key}, - #ssh_msg_disconnect{ - code = ?SSH_DISCONNECT_KEY_EXCHANGE_FAILED, - description = "Peer ECDH public key is invalid", - language = ""} - }) + ssh_connection_handler:disconnect( + #ssh_msg_disconnect{ + code = ?SSH_DISCONNECT_KEY_EXCHANGE_FAILED, + description = "Peer ECDH public key is invalid"}, + invalid_peer_public_key) end. @@ -675,9 +671,10 @@ handle_new_keys(#ssh_msg_newkeys{}, Ssh0) -> {ok, Ssh} catch _C:_Error -> %% TODO: Throw earlier .... - throw(#ssh_msg_disconnect{code = ?SSH_DISCONNECT_PROTOCOL_ERROR, - description = "Install alg failed", - language = "en"}) + ssh_connection_handler:disconnect( + #ssh_msg_disconnect{code = ?SSH_DISCONNECT_PROTOCOL_ERROR, + description = "Install alg failed" + }) end. %% select session id @@ -929,9 +926,9 @@ select_all(CL, SL) when length(CL) + length(SL) < ?MAX_NUM_ALGORITHMS -> lists:map(fun(ALG) -> list_to_atom(ALG) end, (CL -- A)); select_all(CL, SL) -> Err = lists:concat(["Received too many algorithms (",length(CL),"+",length(SL)," >= ",?MAX_NUM_ALGORITHMS,")."]), - throw(#ssh_msg_disconnect{code = ?SSH_DISCONNECT_PROTOCOL_ERROR, - description = Err, - language = ""}). + ssh_connection_handler:disconnect( + #ssh_msg_disconnect{code = ?SSH_DISCONNECT_PROTOCOL_ERROR, + description = Err}). select([], []) -> @@ -1042,7 +1039,7 @@ handle_packet_part(DecryptedPfx, EncryptedBuffer, TotalNeeded, {bad_mac, Ssh1}; true -> {Ssh, DecompressedPayload} = decompress(Ssh1, payload(DecryptedPacket)), - {decoded, DecompressedPayload, NextPacketBytes, Ssh} + {packet_decrypted, DecompressedPayload, NextPacketBytes, Ssh} end; aead -> PacketLenBin = DecryptedPfx, @@ -1052,7 +1049,7 @@ handle_packet_part(DecryptedPfx, EncryptedBuffer, TotalNeeded, {Ssh1, DecryptedSfx} -> DecryptedPacket = <<DecryptedPfx/binary, DecryptedSfx/binary>>, {Ssh, DecompressedPayload} = decompress(Ssh1, payload(DecryptedPacket)), - {decoded, DecompressedPayload, NextPacketBytes, Ssh} + {packet_decrypted, DecompressedPayload, NextPacketBytes, Ssh} end end. diff --git a/lib/ssh/src/sshc_sup.erl b/lib/ssh/src/sshc_sup.erl index 5667fd2aec..71b5c2c46a 100644 --- a/lib/ssh/src/sshc_sup.erl +++ b/lib/ssh/src/sshc_sup.erl @@ -64,7 +64,7 @@ child_spec(_) -> Name = undefined, % As simple_one_for_one is used. StartFunc = {ssh_connection_handler, start_link, []}, Restart = temporary, - Shutdown = infinity, + Shutdown = 4000, Modules = [ssh_connection_handler], - Type = supervisor, + Type = worker, {Name, StartFunc, Restart, Shutdown, Type, Modules}. diff --git a/lib/ssh/test/Makefile b/lib/ssh/test/Makefile index 4ecc662c13..6ce6d6f537 100644 --- a/lib/ssh/test/Makefile +++ b/lib/ssh/test/Makefile @@ -55,6 +55,7 @@ MODULES= \ ssh_relay HRL_FILES_NEEDED_IN_TEST= \ + $(ERL_TOP)/lib/ssh/test/ssh_test_lib.hrl \ $(ERL_TOP)/lib/ssh/src/ssh.hrl \ $(ERL_TOP)/lib/ssh/src/ssh_xfer.hrl diff --git a/lib/ssh/test/ssh_algorithms_SUITE.erl b/lib/ssh/test/ssh_algorithms_SUITE.erl index bdc980e65c..9910b8f1d7 100644 --- a/lib/ssh/test/ssh_algorithms_SUITE.erl +++ b/lib/ssh/test/ssh_algorithms_SUITE.erl @@ -192,7 +192,7 @@ simple_exec_groups_no_match_too_large(Config) -> %%-------------------------------------------------------------------- %% Testing all default groups -simple_exec_groups() -> [{timetrap,{seconds,180}}]. +simple_exec_groups() -> [{timetrap,{minutes,5}}]. simple_exec_groups(Config) -> Sizes = interpolate( public_key:dh_gex_group_sizes() ), @@ -226,28 +226,13 @@ sshc_simple_exec(Config) -> KnownHosts = filename:join(PrivDir, "known_hosts"), {Host,Port} = ?config(srvr_addr, Config), Cmd = lists:concat(["ssh -p ",Port, - " -C -o UserKnownHostsFile=",KnownHosts, + " -C", + " -o UserKnownHostsFile=",KnownHosts, + " -o StrictHostKeyChecking=no", " ",Host," 1+1."]), ct:log("~p",[Cmd]), - SshPort = open_port({spawn, Cmd}, [binary]), - Expect = <<"2\n">>, - rcv_expected(SshPort, Expect). - - -rcv_expected(SshPort, Expect) -> - receive - {SshPort, {data,Expect}} -> - ct:log("Got expected ~p from ~p",[Expect,SshPort]), - catch port_close(SshPort), - ok; - Other -> - ct:log("Got UNEXPECTED ~p",[Other]), - rcv_expected(SshPort, Expect) - - after ?TIMEOUT -> - catch port_close(SshPort), - ct:fail("Did not receive answer") - end. + OpenSsh = ssh_test_lib:open_port({spawn, Cmd}, [eof,exit_status]), + ssh_test_lib:rcv_expected({data,<<"2\n">>}, OpenSsh, ?TIMEOUT). %%-------------------------------------------------------------------- %% Connect to the ssh server of the OS @@ -361,13 +346,15 @@ get_atoms(L) -> %%% Test case related %%% start_std_daemon(Opts, Config) -> + ct:log("starting std_daemon",[]), {Pid, Host, Port} = ssh_test_lib:std_daemon(Config, Opts), ct:log("started ~p:~p ~p",[Host,Port,Opts]), [{srvr_pid,Pid},{srvr_addr,{Host,Port}} | Config]. -start_pubkey_daemon(Opts, Config) -> +start_pubkey_daemon(Opts0, Config) -> + Opts = [{auth_methods,"publickey"}|Opts0], {Pid, Host, Port} = ssh_test_lib:std_daemon1(Config, Opts), - ct:log("started1 ~p:~p ~p",[Host,Port,Opts]), + ct:log("started pubkey_daemon ~p:~p ~p",[Host,Port,Opts]), [{srvr_pid,Pid},{srvr_addr,{Host,Port}} | Config]. diff --git a/lib/ssh/test/ssh_benchmark_SUITE.erl b/lib/ssh/test/ssh_benchmark_SUITE.erl index 6e1d18cc95..d9be1a32b7 100644 --- a/lib/ssh/test/ssh_benchmark_SUITE.erl +++ b/lib/ssh/test/ssh_benchmark_SUITE.erl @@ -333,52 +333,64 @@ find_time(accept_to_hello, L) -> [T0,T1] = find([fun(C=#call{mfa = {ssh_acceptor,handle_connection,5}}) -> C#call.t_call end, - fun(C=#call{mfa = {ssh_connection_handler,hello,_}, - args = [socket_control|_]}) -> - C#call.t_return - end + ?LINE, + fun(C=#call{mfa = {ssh_connection_handler,handle_event,4}, + args = [_, {version_exchange,_}, {hello,_}, _]}) -> + C#call.t_call + end, + ?LINE ], L, []), {accept_to_hello, now2micro_sec(now_diff(T1,T0)), microsec}; find_time(kex, L) -> - [T0,T1] = find([fun(C=#call{mfa = {ssh_connection_handler,hello,_}, - args = [socket_control|_]}) -> + [T0,T1] = find([fun(C=#call{mfa = {ssh_connection_handler,handle_event,4}, + args = [_, {version_exchange,_}, {hello,_}, _]}) -> C#call.t_call end, - ?send(#ssh_msg_newkeys{}) + ?LINE, + ?send(#ssh_msg_newkeys{}), + ?LINE ], L, []), {kex, now2micro_sec(now_diff(T1,T0)), microsec}; find_time(kex_to_auth, L) -> [T0,T1] = find([?send(#ssh_msg_newkeys{}), - ?recv(#ssh_msg_userauth_request{}) + ?LINE, + ?recv(#ssh_msg_userauth_request{}), + ?LINE ], L, []), {kex_to_auth, now2micro_sec(now_diff(T1,T0)), microsec}; find_time(auth, L) -> [T0,T1] = find([?recv(#ssh_msg_userauth_request{}), - ?send(#ssh_msg_userauth_success{}) + ?LINE, + ?send(#ssh_msg_userauth_success{}), + ?LINE ], L, []), {auth, now2micro_sec(now_diff(T1,T0)), microsec}; find_time(to_prompt, L) -> [T0,T1] = find([fun(C=#call{mfa = {ssh_acceptor,handle_connection,5}}) -> C#call.t_call end, - ?recv(#ssh_msg_channel_request{request_type="env"}) + ?LINE, + ?recv(#ssh_msg_channel_request{request_type="env"}), + ?LINE ], L, []), {to_prompt, now2micro_sec(now_diff(T1,T0)), microsec}; find_time(channel_open_close, L) -> [T0,T1] = find([?recv(#ssh_msg_channel_request{request_type="subsystem"}), - ?send(#ssh_msg_channel_close{}) + ?LINE, + ?send(#ssh_msg_channel_close{}), + ?LINE ], L, []), {channel_open_close, now2micro_sec(now_diff(T1,T0)), microsec}. -find([F|Fs], [C|Cs], Acc) when is_function(F,1) -> +find([F,Id|Fs], [C|Cs], Acc) when is_function(F,1) -> try F(C) of T -> find(Fs, Cs, [T|Acc]) catch - _:_ -> find([F|Fs], Cs, Acc) + _:_ -> find([F,Id|Fs], Cs, Acc) end; find([], _, Acc) -> lists:reverse(Acc). @@ -444,7 +456,7 @@ erlang_trace() -> 0 = erlang:trace(new, true, [call,timestamp,{tracer,TracerPid}]), [init_trace(MFA, tp(MFA)) || MFA <- [{ssh_acceptor,handle_connection,5}, - {ssh_connection_handler,hello,2}, +%% {ssh_connection_handler,hello,2}, {ssh_message,encode,1}, {ssh_message,decode,1}, {ssh_transport,select_algorithm,3}, @@ -454,6 +466,10 @@ erlang_trace() -> {ssh_message,decode,1}, {public_key,dh_gex_group,4} % To find dh_gex group size ]], + init_trace({ssh_connection_handler,handle_event,4}, + [{['_', {version_exchange,'_'}, {hello,'_'}, '_'], + [], + [return_trace]}]), {ok, TracerPid}. tp({_M,_F,Arity}) -> diff --git a/lib/ssh/test/ssh_connection_SUITE.erl b/lib/ssh/test/ssh_connection_SUITE.erl index a5f424f863..0f757a0322 100644 --- a/lib/ssh/test/ssh_connection_SUITE.erl +++ b/lib/ssh/test/ssh_connection_SUITE.erl @@ -23,6 +23,7 @@ -include_lib("common_test/include/ct.hrl"). -include_lib("ssh/src/ssh_connect.hrl"). +-include("ssh_test_lib.hrl"). -compile(export_all). @@ -655,15 +656,21 @@ max_channels_option(Config) when is_list(Config) -> {user_interaction, true}, {user_dir, UserDir}]), + %% Allocate a number of ChannelId:s to play with. (This operation is not + %% counted by the max_channel option). {ok, ChannelId0} = ssh_connection:session_channel(ConnectionRef, infinity), {ok, ChannelId1} = ssh_connection:session_channel(ConnectionRef, infinity), {ok, ChannelId2} = ssh_connection:session_channel(ConnectionRef, infinity), {ok, ChannelId3} = ssh_connection:session_channel(ConnectionRef, infinity), {ok, ChannelId4} = ssh_connection:session_channel(ConnectionRef, infinity), {ok, ChannelId5} = ssh_connection:session_channel(ConnectionRef, infinity), - {ok, _ChannelId6} = ssh_connection:session_channel(ConnectionRef, infinity), + {ok, ChannelId6} = ssh_connection:session_channel(ConnectionRef, infinity), + {ok, _ChannelId7} = ssh_connection:session_channel(ConnectionRef, infinity), - %%%---- shell + %% Now start to open the channels (this is counted my max_channels) to check that + %% it gives a failure at right place + + %%%---- Channel 1(3): shell ok = ssh_connection:shell(ConnectionRef,ChannelId0), receive {ssh_cm,ConnectionRef, {data, ChannelId0, 0, <<"Eshell",_/binary>>}} -> @@ -672,10 +679,10 @@ max_channels_option(Config) when is_list(Config) -> ct:fail("CLI Timeout") end, - %%%---- subsystem "echo_n" + %%%---- Channel 2(3): subsystem "echo_n" success = ssh_connection:subsystem(ConnectionRef, ChannelId1, "echo_n", infinity), - %%%---- exec #1 + %%%---- Channel 3(3): exec. This closes itself. success = ssh_connection:exec(ConnectionRef, ChannelId2, "testing1.\n", infinity), receive {ssh_cm, ConnectionRef, {data, ChannelId2, 0, <<"testing1",_/binary>>}} -> @@ -684,13 +691,13 @@ max_channels_option(Config) when is_list(Config) -> ct:fail("Exec #1 Timeout") end, - %%%---- ptty - success = ssh_connection:ptty_alloc(ConnectionRef, ChannelId3, []), + %%%---- Channel 3(3): subsystem "echo_n" (Note that ChannelId2 should be closed now) + ?wait_match(success, ssh_connection:subsystem(ConnectionRef, ChannelId3, "echo_n", infinity)), - %%%---- exec #2 + %%%---- Channel 4(3) !: exec This should fail failure = ssh_connection:exec(ConnectionRef, ChannelId4, "testing2.\n", infinity), - %%%---- close the shell + %%%---- close the shell (Frees one channel) ok = ssh_connection:send(ConnectionRef, ChannelId0, "exit().\n", 5000), %%%---- wait for the subsystem to terminate @@ -703,14 +710,11 @@ max_channels_option(Config) when is_list(Config) -> ct:fail("exit Timeout",[]) end, - %%%---- exec #3 - success = ssh_connection:exec(ConnectionRef, ChannelId5, "testing3.\n", infinity), - receive - {ssh_cm, ConnectionRef, {data, ChannelId5, 0, <<"testing3",_/binary>>}} -> - ok - after 5000 -> - ct:fail("Exec #3 Timeout") - end, + %%---- Try that we can open one channel instead of the closed one + ?wait_match(success, ssh_connection:subsystem(ConnectionRef, ChannelId5, "echo_n", infinity)), + + %%---- But not a fourth one... + failure = ssh_connection:subsystem(ConnectionRef, ChannelId6, "echo_n", infinity), ssh:close(ConnectionRef), ssh:stop_daemon(Pid). diff --git a/lib/ssh/test/ssh_options_SUITE.erl b/lib/ssh/test/ssh_options_SUITE.erl index 1d14a16065..4ca6a473fa 100644 --- a/lib/ssh/test/ssh_options_SUITE.erl +++ b/lib/ssh/test/ssh_options_SUITE.erl @@ -51,9 +51,7 @@ ssh_connect_arg4_timeout/1, ssh_connect_negtimeout_parallel/1, ssh_connect_negtimeout_sequential/1, - ssh_connect_nonegtimeout_connected_parallel/0, ssh_connect_nonegtimeout_connected_parallel/1, - ssh_connect_nonegtimeout_connected_sequential/0, ssh_connect_nonegtimeout_connected_sequential/1, ssh_connect_timeout/1, connect/4, ssh_daemon_minimal_remote_max_packet_size_option/1, @@ -82,7 +80,7 @@ suite() -> [{ct_hooks,[ts_install_cth]}, - {timetrap,{seconds,40}}]. + {timetrap,{seconds,30}}]. all() -> [connectfun_disconnectfun_server, @@ -493,7 +491,7 @@ ssh_msg_debug_fun_option_client(Config) -> {user_interaction, false}, {ssh_msg_debug_fun,DbgFun}]), %% Beware, implementation knowledge: - gen_fsm:send_all_state_event(ConnectionRef,{ssh_msg_debug,false,<<"Hello">>,<<>>}), + gen_statem:cast(ConnectionRef,{ssh_msg_debug,false,<<"Hello">>,<<>>}), receive {msg_dbg,X={ConnectionRef,false,<<"Hello">>,<<>>}} -> ct:log("Got expected dbg msg ~p",[X]), @@ -606,7 +604,7 @@ ssh_msg_debug_fun_option_server(Config) -> receive {connection_pid,Server} -> %% Beware, implementation knowledge: - gen_fsm:send_all_state_event(Server,{ssh_msg_debug,false,<<"Hello">>,<<>>}), + gen_statem:cast(Server,{ssh_msg_debug,false,<<"Hello">>,<<>>}), receive {msg_dbg,X={_,false,<<"Hello">>,<<>>}} -> ct:log("Got expected dbg msg ~p",[X]), @@ -982,16 +980,10 @@ ssh_connect_negtimeout(Config, Parallel) -> %%-------------------------------------------------------------------- %%% Test that ssh connection does not timeout if the connection is established (parallel) - -ssh_connect_nonegtimeout_connected_parallel() -> [{timetrap,{seconds,90}}]. - ssh_connect_nonegtimeout_connected_parallel(Config) -> ssh_connect_nonegtimeout_connected(Config, true). %%% Test that ssh connection does not timeout if the connection is established (non-parallel) - -ssh_connect_nonegtimeout_connected_sequential() -> [{timetrap,{seconds,90}}]. - ssh_connect_nonegtimeout_connected_sequential(Config) -> ssh_connect_nonegtimeout_connected(Config, false). @@ -1000,7 +992,7 @@ ssh_connect_nonegtimeout_connected(Config, Parallel) -> process_flag(trap_exit, true), SystemDir = filename:join(?config(priv_dir, Config), system), UserDir = ?config(priv_dir, Config), - NegTimeOut = 20000, % ms + NegTimeOut = 2000, % ms ct:log("Parallel: ~p",[Parallel]), {_Pid, _Host, Port} = ssh_test_lib:daemon([{system_dir, SystemDir},{user_dir, UserDir}, @@ -1131,21 +1123,7 @@ max_sessions(Config, ParallelLogin, Connect0) when is_function(Connect0,2) -> %% This is expected %% Now stop one connection and try to open one more ok = ssh:close(hd(Connections)), - receive after 250 -> ok end, % sleep so the supervisor has time to count down. Not nice... - try Connect(Host,Port) - of - _ConnectionRef1 -> - %% Step 3 ok: could set up one more connection after killing one - %% Thats good. - ssh:stop_daemon(Pid), - ok - catch - error:{badmatch,{error,"Connection closed"}} -> - %% Bad indeed. Could not set up one more connection even after killing - %% one existing. Very bad. - ssh:stop_daemon(Pid), - {fail,"Does not decrease # active sessions"} - end + try_to_connect(Connect, Host, Port, Pid) end catch error:{badmatch,{error,"Connection closed"}} -> @@ -1153,6 +1131,35 @@ max_sessions(Config, ParallelLogin, Connect0) when is_function(Connect0,2) -> {fail,"Too few connections accepted"} end. + +try_to_connect(Connect, Host, Port, Pid) -> + {ok,Tref} = timer:send_after(3000, timeout_no_connection), % give the supervisors some time... + try_to_connect(Connect, Host, Port, Pid, Tref, 1). % will take max 3300 ms after 11 tries + +try_to_connect(Connect, Host, Port, Pid, Tref, N) -> + try Connect(Host,Port) + of + _ConnectionRef1 -> + %% Step 3 ok: could set up one more connection after killing one + %% Thats good. + timer:cancel(Tref), + ssh:stop_daemon(Pid), + receive % flush. + timeout_no_connection -> ok + after 0 -> ok + end + catch + error:{badmatch,{error,"Connection closed"}} -> + %% Could not set up one more connection. Try again until timeout. + receive + timeout_no_connection -> + ssh:stop_daemon(Pid), + {fail,"Does not decrease # active sessions"} + after N*50 -> % retry after this time + try_to_connect(Connect, Host, Port, Pid, Tref, N+1) + end + end. + %%-------------------------------------------------------------------- %% Internal functions ------------------------------------------------ %%-------------------------------------------------------------------- diff --git a/lib/ssh/test/ssh_renegotiate_SUITE.erl b/lib/ssh/test/ssh_renegotiate_SUITE.erl index 90132becbd..f1a909cbd0 100644 --- a/lib/ssh/test/ssh_renegotiate_SUITE.erl +++ b/lib/ssh/test/ssh_renegotiate_SUITE.erl @@ -33,7 +33,6 @@ suite() -> [{ct_hooks,[ts_install_cth]}, {timetrap,{seconds,40}}]. - all() -> [{group,default_algs}, {group,aes_gcm} ]. @@ -238,7 +237,7 @@ renegotiate2(Config) -> %% get_kex_init - helper function to get key_exchange_init_msg get_kex_init(Conn) -> %% First, validate the key exchange is complete (StateName == connected) - {connected,S} = sys:get_state(Conn), + {{connected,_},S} = sys:get_state(Conn), %% Next, walk through the elements of the #state record looking %% for the #ssh_msg_kexinit record. This method is robust against %% changes to either record. The KEXINIT message contains a cookie diff --git a/lib/ssh/test/ssh_sftp_SUITE.erl b/lib/ssh/test/ssh_sftp_SUITE.erl index cd6c5f82b9..f6d7be41d6 100644 --- a/lib/ssh/test/ssh_sftp_SUITE.erl +++ b/lib/ssh/test/ssh_sftp_SUITE.erl @@ -38,7 +38,6 @@ suite() -> [{ct_hooks,[ts_install_cth]}, {timetrap,{seconds,40}}]. - all() -> [{group, not_unicode}, {group, unicode} @@ -301,9 +300,9 @@ end_per_testcase(_, Config) -> end_per_testcase(Config) -> {Sftp, Connection} = ?config(sftp, Config), - ssh_sftp:stop_channel(Sftp), + ok = ssh_sftp:stop_channel(Sftp), catch ssh_sftp:stop_channel(?config(channel_pid2, Config)), - ssh:close(Connection). + ok = ssh:close(Connection). %%-------------------------------------------------------------------- %% Test Cases -------------------------------------------------------- @@ -365,7 +364,7 @@ write_file(Config) when is_list(Config) -> {Sftp, _} = ?config(sftp, Config), Data = list_to_binary("Hej hopp!"), - ssh_sftp:write_file(Sftp, FileName, [Data]), + ok = ssh_sftp:write_file(Sftp, FileName, [Data]), {ok, Data} = file:read_file(FileName). %%-------------------------------------------------------------------- @@ -378,7 +377,7 @@ write_file_iolist(Config) when is_list(Config) -> Data = list_to_binary("Hej hopp!"), lists:foreach( fun(D) -> - ssh_sftp:write_file(Sftp, FileName, [D]), + ok = ssh_sftp:write_file(Sftp, FileName, [D]), Expected = if is_binary(D) -> D; is_list(D) -> list_to_binary(D) end, @@ -397,7 +396,7 @@ write_big_file(Config) when is_list(Config) -> {Sftp, _} = ?config(sftp, Config), Data = list_to_binary(lists:duplicate(750000,"a")), - ssh_sftp:write_file(Sftp, FileName, [Data]), + ok = ssh_sftp:write_file(Sftp, FileName, [Data]), {ok, Data} = file:read_file(FileName). %%-------------------------------------------------------------------- @@ -409,7 +408,7 @@ sftp_read_big_file(Config) when is_list(Config) -> Data = list_to_binary(lists:duplicate(750000,"a")), ct:log("Data size to write is ~p bytes",[size(Data)]), - ssh_sftp:write_file(Sftp, FileName, [Data]), + ok = ssh_sftp:write_file(Sftp, FileName, [Data]), {ok, Data} = ssh_sftp:read_file(Sftp, FileName). %%-------------------------------------------------------------------- @@ -425,7 +424,7 @@ remove_file(Config) when is_list(Config) -> ok = ssh_sftp:delete(Sftp, FileName), {ok, NewFiles} = ssh_sftp:list_dir(Sftp, PrivDir), false = lists:member(filename:basename(FileName), NewFiles), - {error, _} = ssh_sftp:delete(Sftp, FileName). + {error, no_such_file} = ssh_sftp:delete(Sftp, FileName). %%-------------------------------------------------------------------- rename_file() -> [{doc, "Test API function rename_file/2"}]. @@ -500,7 +499,7 @@ set_attributes(Config) when is_list(Config) -> io:put_chars(Fd,"foo"), ok = ssh_sftp:write_file_info(Sftp, FileName, #file_info{mode=8#400}), {error, eacces} = file:write_file(FileName, "hello again"), - ssh_sftp:write_file_info(Sftp, FileName, #file_info{mode=8#600}), + ok = ssh_sftp:write_file_info(Sftp, FileName, #file_info{mode=8#600}), ok = file:write_file(FileName, "hello again"). %%-------------------------------------------------------------------- @@ -549,7 +548,7 @@ position(Config) when is_list(Config) -> {Sftp, _} = ?config(sftp, Config), Data = list_to_binary("1234567890"), - ssh_sftp:write_file(Sftp, FileName, [Data]), + ok = ssh_sftp:write_file(Sftp, FileName, [Data]), {ok, Handle} = ssh_sftp:open(Sftp, FileName, [read]), {ok, 3} = ssh_sftp:position(Sftp, Handle, {bof, 3}), @@ -577,7 +576,7 @@ pos_read(Config) when is_list(Config) -> FileName = ?config(testfile, Config), {Sftp, _} = ?config(sftp, Config), Data = list_to_binary("Hej hopp!"), - ssh_sftp:write_file(Sftp, FileName, [Data]), + ok = ssh_sftp:write_file(Sftp, FileName, [Data]), {ok, Handle} = ssh_sftp:open(Sftp, FileName, [read]), {async, Ref} = ssh_sftp:apread(Sftp, Handle, {bof, 5}, 4), @@ -607,7 +606,7 @@ pos_write(Config) when is_list(Config) -> {ok, Handle} = ssh_sftp:open(Sftp, FileName, [write]), Data = list_to_binary("Bye,"), - ssh_sftp:write_file(Sftp, FileName, [Data]), + ok = ssh_sftp:write_file(Sftp, FileName, [Data]), NewData = list_to_binary(" see you tomorrow"), {async, Ref} = ssh_sftp:apwrite(Sftp, Handle, {bof, 4}, NewData), diff --git a/lib/ssh/test/ssh_sftpd_SUITE.erl b/lib/ssh/test/ssh_sftpd_SUITE.erl index fb1a9687af..9385bd127d 100644 --- a/lib/ssh/test/ssh_sftpd_SUITE.erl +++ b/lib/ssh/test/ssh_sftpd_SUITE.erl @@ -105,7 +105,6 @@ init_per_testcase(TestCase, Config) -> ClientUserDir = filename:join(PrivDir, nopubkey), SystemDir = filename:join(?config(priv_dir, Config), system), - Port = ssh_test_lib:inet_port(node()), Options = [{system_dir, SystemDir}, {user_dir, PrivDir}, {user_passwords,[{?USER, ?PASSWD}]}, @@ -113,11 +112,13 @@ init_per_testcase(TestCase, Config) -> {ok, Sftpd} = case TestCase of ver6_basic -> SubSystems = [ssh_sftpd:subsystem_spec([{sftpd_vsn, 6}])], - ssh:daemon(Port, [{subsystems, SubSystems}|Options]); + ssh:daemon(0, [{subsystems, SubSystems}|Options]); _ -> SubSystems = [ssh_sftpd:subsystem_spec([])], - ssh:daemon(Port, [{subsystems, SubSystems}|Options]) + ssh:daemon(0, [{subsystems, SubSystems}|Options]) end, + {ok,Dinf} = ssh:daemon_info(Sftpd), + Port = proplists:get_value(port, Dinf), Cm = ssh_test_lib:connect(Port, [{user_dir, ClientUserDir}, diff --git a/lib/ssh/test/ssh_sftpd_erlclient_SUITE.erl b/lib/ssh/test/ssh_sftpd_erlclient_SUITE.erl index 09bef87148..355ce6a8f5 100644 --- a/lib/ssh/test/ssh_sftpd_erlclient_SUITE.erl +++ b/lib/ssh/test/ssh_sftpd_erlclient_SUITE.erl @@ -39,7 +39,6 @@ suite() -> [{ct_hooks,[ts_install_cth]}, {timetrap,{seconds,40}}]. - all() -> [close_file, quit, diff --git a/lib/ssh/test/ssh_sup_SUITE.erl b/lib/ssh/test/ssh_sup_SUITE.erl index f800ea806d..f8929b30ff 100644 --- a/lib/ssh/test/ssh_sup_SUITE.erl +++ b/lib/ssh/test/ssh_sup_SUITE.erl @@ -22,21 +22,23 @@ -module(ssh_sup_SUITE). -include_lib("common_test/include/ct.hrl"). -include_lib("ssh/src/ssh.hrl"). +-include("ssh_test_lib.hrl"). %% Note: This directive should only be used in test suites. -compile(export_all). --define(WAIT_FOR_SHUTDOWN, 500). -define(USER, "Alladin"). -define(PASSWD, "Sesame"). +-define(WAIT_FOR_SHUTDOWN, 500). + %%-------------------------------------------------------------------- %% Common Test interface functions ----------------------------------- %%-------------------------------------------------------------------- suite() -> [{ct_hooks,[ts_install_cth]}, - {timetrap,{seconds,40}}]. + {timetrap,{seconds,100}}]. all() -> [default_tree, sshc_subtree, sshd_subtree, sshd_subtree_profile]. @@ -92,8 +94,8 @@ default_tree(Config) when is_list(Config) -> lists:keysearch(sshc_sup, 1, TopSupChildren), {value, {sshd_sup, _,supervisor,[sshd_sup]}} = lists:keysearch(sshd_sup, 1, TopSupChildren), - [] = supervisor:which_children(sshc_sup), - [] = supervisor:which_children(sshd_sup). + ?wait_match([], supervisor:which_children(sshc_sup)), + ?wait_match([], supervisor:which_children(sshd_sup)). sshc_subtree() -> [{doc, "Make sure the sshc subtree is correct"}]. @@ -101,24 +103,27 @@ sshc_subtree(Config) when is_list(Config) -> {_Pid, Host, Port} = ?config(server, Config), UserDir = ?config(userdir, Config), - [] = supervisor:which_children(sshc_sup), + ?wait_match([], supervisor:which_children(sshc_sup)), + {ok, Pid1} = ssh:connect(Host, Port, [{silently_accept_hosts, true}, {user_interaction, false}, {user, ?USER}, {password, ?PASSWD},{user_dir, UserDir}]), - [{_, _,supervisor,[ssh_connection_handler]}] = - supervisor:which_children(sshc_sup), + + ?wait_match([{_, _,worker,[ssh_connection_handler]}], + supervisor:which_children(sshc_sup)), + {ok, Pid2} = ssh:connect(Host, Port, [{silently_accept_hosts, true}, {user_interaction, false}, {user, ?USER}, {password, ?PASSWD}, {user_dir, UserDir}]), - [{_,_,supervisor,[ssh_connection_handler]}, - {_,_,supervisor,[ssh_connection_handler]}] = - supervisor:which_children(sshc_sup), + ?wait_match([{_,_,worker,[ssh_connection_handler]}, + {_,_,worker,[ssh_connection_handler]}], + supervisor:which_children(sshc_sup)), + ssh:close(Pid1), - [{_,_,supervisor,[ssh_connection_handler]}] = - supervisor:which_children(sshc_sup), + ?wait_match([{_,_,worker,[ssh_connection_handler]}], + supervisor:which_children(sshc_sup)), ssh:close(Pid2), - ct:sleep(?WAIT_FOR_SHUTDOWN), - [] = supervisor:which_children(sshc_sup). + ?wait_match([], supervisor:which_children(sshc_sup)). sshd_subtree() -> [{doc, "Make sure the sshd subtree is correct"}]. @@ -130,14 +135,16 @@ sshd_subtree(Config) when is_list(Config) -> {failfun, fun ssh_test_lib:failfun/2}, {user_passwords, [{?USER, ?PASSWD}]}]), - [{{server,ssh_system_sup, HostIP, Port, ?DEFAULT_PROFILE}, - Daemon, supervisor, - [ssh_system_sup]}] = - supervisor:which_children(sshd_sup), + + ?wait_match([{{server,ssh_system_sup, HostIP, Port, ?DEFAULT_PROFILE}, + Daemon, supervisor, + [ssh_system_sup]}], + supervisor:which_children(sshd_sup), + Daemon), check_sshd_system_tree(Daemon, Config), ssh:stop_daemon(HostIP, Port), ct:sleep(?WAIT_FOR_SHUTDOWN), - [] = supervisor:which_children(sshd_sup). + ?wait_match([], supervisor:which_children(sshd_sup)). sshd_subtree_profile() -> [{doc, "Make sure the sshd subtree using profile option is correct"}]. @@ -152,14 +159,15 @@ sshd_subtree_profile(Config) when is_list(Config) -> {user_passwords, [{?USER, ?PASSWD}]}, {profile, Profile}]), - [{{server,ssh_system_sup, HostIP,Port,Profile}, - Daemon, supervisor, - [ssh_system_sup]}] = - supervisor:which_children(sshd_sup), + ?wait_match([{{server,ssh_system_sup, HostIP,Port,Profile}, + Daemon, supervisor, + [ssh_system_sup]}], + supervisor:which_children(sshd_sup), + Daemon), check_sshd_system_tree(Daemon, Config), ssh:stop_daemon(HostIP, Port, Profile), ct:sleep(?WAIT_FOR_SHUTDOWN), - [] = supervisor:which_children(sshd_sup). + ?wait_match([], supervisor:which_children(sshd_sup)). check_sshd_system_tree(Daemon, Config) -> @@ -170,28 +178,31 @@ check_sshd_system_tree(Daemon, Config) -> {user_interaction, false}, {user, ?USER}, {password, ?PASSWD},{user_dir, UserDir}]), - [{_,SubSysSup, supervisor,[ssh_subsystem_sup]}, - {{ssh_acceptor_sup,_,_,_}, AccSup, supervisor,[ssh_acceptor_sup]}] - = supervisor:which_children(Daemon), + ?wait_match([{_,SubSysSup, supervisor,[ssh_subsystem_sup]}, + {{ssh_acceptor_sup,_,_,_}, AccSup, supervisor,[ssh_acceptor_sup]}], + supervisor:which_children(Daemon), + [SubSysSup,AccSup]), - [{{server,ssh_connection_sup, _,_}, - ConnectionSup, supervisor, - [ssh_connection_sup]}, - {{server,ssh_channel_sup,_ ,_}, - ChannelSup,supervisor, - [ssh_channel_sup]}] = supervisor:which_children(SubSysSup), + ?wait_match([{{server,ssh_connection_sup, _,_}, + ConnectionSup, supervisor, + [ssh_connection_sup]}, + {{server,ssh_channel_sup,_ ,_}, + ChannelSup,supervisor, + [ssh_channel_sup]}], + supervisor:which_children(SubSysSup), + [ConnectionSup,ChannelSup]), - [{{ssh_acceptor_sup,_,_,_},_,worker,[ssh_acceptor]}] = - supervisor:which_children(AccSup), + ?wait_match([{{ssh_acceptor_sup,_,_,_},_,worker,[ssh_acceptor]}], + supervisor:which_children(AccSup)), - [{_, _, worker,[ssh_connection_handler]}] = - supervisor:which_children(ConnectionSup), + ?wait_match([{_, _, worker,[ssh_connection_handler]}], + supervisor:which_children(ConnectionSup)), - [] = supervisor:which_children(ChannelSup), + ?wait_match([], supervisor:which_children(ChannelSup)), ssh_sftp:start_channel(Client), - [{_, _,worker,[ssh_channel]}] = - supervisor:which_children(ChannelSup), + ?wait_match([{_, _,worker,[ssh_channel]}], + supervisor:which_children(ChannelSup)), ssh:close(Client). diff --git a/lib/ssh/test/ssh_test_cli.erl b/lib/ssh/test/ssh_test_cli.erl index 697ddb730d..f96b9967d2 100644 --- a/lib/ssh/test/ssh_test_cli.erl +++ b/lib/ssh/test/ssh_test_cli.erl @@ -75,10 +75,11 @@ terminate(_Why, _S) -> run_portprog(User, cli, TmpDir) -> Pty_bin = os:find_executable("cat"), - open_port({spawn_executable, Pty_bin}, - [stream, {cd, TmpDir}, {env, [{"USER", User}]}, - {args, []}, binary, - exit_status, use_stdio, stderr_to_stdout]). + ssh_test_lib:open_port({spawn_executable, Pty_bin}, + [stream, + {cd, TmpDir}, + {env, [{"USER", User}]}, + {args, []}]). get_ssh_user(Ref) -> [{user, User}] = ssh:connection_info(Ref, [user]), diff --git a/lib/ssh/test/ssh_test_lib.erl b/lib/ssh/test/ssh_test_lib.erl index 4db7d09ccd..c6541461a1 100644 --- a/lib/ssh/test/ssh_test_lib.erl +++ b/lib/ssh/test/ssh_test_lib.erl @@ -32,15 +32,8 @@ -define(TIMEOUT, 50000). -connect(Options) -> - connect(hostname(), inet_port(), Options). - connect(Port, Options) when is_integer(Port) -> - connect(hostname(), Port, Options); -connect(any, Options) -> - connect(hostname(), inet_port(), Options); -connect(Host, Options) -> - connect(Host, inet_port(), Options). + connect(hostname(), Port, Options). connect(any, Port, Options) -> connect(hostname(), Port, Options); @@ -49,23 +42,33 @@ connect(Host, Port, Options) -> ConnectionRef. daemon(Options) -> - daemon(any, inet_port(), Options). + daemon(any, 0, Options). daemon(Port, Options) when is_integer(Port) -> daemon(any, Port, Options); daemon(Host, Options) -> - daemon(Host, inet_port(), Options). + daemon(Host, 0, Options). + daemon(Host, Port, Options) -> + ct:log("~p:~p Calling ssh:daemon(~p, ~p, ~p)",[?MODULE,?LINE,Host,Port,Options]), case ssh:daemon(Host, Port, Options) of {ok, Pid} when Host == any -> - {Pid, hostname(), Port}; + ct:log("ssh:daemon ok (1)",[]), + {Pid, hostname(), daemon_port(Port,Pid)}; {ok, Pid} -> - {Pid, Host, Port}; + ct:log("ssh:daemon ok (2)",[]), + {Pid, Host, daemon_port(Port,Pid)}; Error -> + ct:log("ssh:daemon error ~p",[Error]), Error end. +daemon_port(0, Pid) -> {ok,Dinf} = ssh:daemon_info(Pid), + proplists:get_value(port, Dinf); +daemon_port(Port, _) -> Port. + + std_daemon(Config, ExtraOpts) -> PrivDir = ?config(priv_dir, Config), @@ -201,6 +204,35 @@ reply(TestCase, Result) -> %%ct:log("reply ~p sending ~p ! ~p",[self(), TestCase, Result]), TestCase ! Result. + + +rcv_expected(Expect, SshPort, Timeout) -> + receive + {SshPort, Expect} -> + ct:log("Got expected ~p from ~p",[Expect,SshPort]), + catch port_close(SshPort), + rcv_lingering(50); + Other -> + ct:log("Got UNEXPECTED ~p~nExpect ~p",[Other, {SshPort,Expect}]), + rcv_expected(Expect, SshPort, Timeout) + + after Timeout -> + catch port_close(SshPort), + ct:fail("Did not receive answer") + end. + +rcv_lingering(Timeout) -> + receive + Msg -> + ct:log("Got LINGERING ~p",[Msg]), + rcv_lingering(Timeout) + + after Timeout -> + ct:log("No more lingering messages",[]), + ok + end. + + receive_exec_result(Msg) -> ct:log("Expect data! ~p", [Msg]), receive @@ -470,8 +502,9 @@ openssh_supports(ClientOrServer, Tag, Alg) when ClientOrServer == sshc ; %% Check if we have a "newer" ssh client that supports these test cases ssh_client_supports_Q() -> - ErlPort = open_port({spawn, "ssh -Q cipher"}, [exit_status, stderr_to_stdout]), - 0 == check_ssh_client_support2(ErlPort). + 0 == check_ssh_client_support2( + ?MODULE:open_port({spawn, "ssh -Q cipher"}) + ). check_ssh_client_support2(P) -> receive @@ -690,3 +723,16 @@ has_inet6_address() -> catch throw:6 -> true end. + +%%%---------------------------------------------------------------- +open_port(Arg1) -> + ?MODULE:open_port(Arg1, []). + +open_port(Arg1, ExtraOpts) -> + erlang:open_port(Arg1, + [binary, + stderr_to_stdout, + exit_status, + use_stdio, + overlapped_io, hide %only affects windows + | ExtraOpts]). diff --git a/lib/ssh/test/ssh_test_lib.hrl b/lib/ssh/test/ssh_test_lib.hrl new file mode 100644 index 0000000000..7cb7edeaa8 --- /dev/null +++ b/lib/ssh/test/ssh_test_lib.hrl @@ -0,0 +1,27 @@ +%%------------------------------------------------------------------------- +%% Help macro +%%------------------------------------------------------------------------- +-define(wait_match(Pattern, FunctionCall, Bind, Timeout, Ntries), + Bind = + (fun() -> + F = fun(N, F1) -> + case FunctionCall of + Pattern -> Bind; + _ when N>0 -> + ct:pal("Must sleep ~p ms at ~p:~p",[Timeout,?MODULE,?LINE]), + timer:sleep(Timeout), + F1(N-1, F1); + Other -> + ct:fail("Unexpected ~p:~p ~p",[?MODULE,?LINE,Other]) + end + end, + F(Ntries, F) + end)() + ). + +-define(wait_match(Pattern, FunctionCall, Timeout, Ntries), ?wait_match(Pattern, FunctionCall, ok, Timeout, Ntries)). + +-define(wait_match(Pattern, FunctionCall, Bind), ?wait_match(Pattern, FunctionCall, Bind, 500, 10) ). + +-define(wait_match(Pattern, FunctionCall), ?wait_match(Pattern, FunctionCall, ok) ). + diff --git a/lib/ssh/test/ssh_to_openssh_SUITE.erl b/lib/ssh/test/ssh_to_openssh_SUITE.erl index 5b65edc32f..2be75fd7f3 100644 --- a/lib/ssh/test/ssh_to_openssh_SUITE.erl +++ b/lib/ssh/test/ssh_to_openssh_SUITE.erl @@ -34,7 +34,7 @@ %%-------------------------------------------------------------------- suite() -> - [{timetrap,{seconds,40}}]. + [{timetrap,{seconds,20}}]. all() -> case os:find_executable("ssh") of @@ -50,13 +50,15 @@ groups() -> [{erlang_client, [], [erlang_shell_client_openssh_server, erlang_client_openssh_server_exec_compressed, erlang_client_openssh_server_setenv, - erlang_client_openssh_server_publickey_rsa, erlang_client_openssh_server_publickey_dsa, + erlang_client_openssh_server_publickey_rsa, erlang_client_openssh_server_password, erlang_client_openssh_server_kexs, erlang_client_openssh_server_nonexistent_subsystem ]}, - {erlang_server, [], [erlang_server_openssh_client_public_key_dsa]} + {erlang_server, [], [erlang_server_openssh_client_public_key_dsa, + erlang_server_openssh_client_public_key_rsa + ]} ]. init_per_suite(Config) -> @@ -74,6 +76,7 @@ init_per_group(erlang_server, Config) -> DataDir = ?config(data_dir, Config), UserDir = ?config(priv_dir, Config), ssh_test_lib:setup_dsa_known_host(DataDir, UserDir), + ssh_test_lib:setup_rsa_known_host(DataDir, UserDir), Config; init_per_group(erlang_client, Config) -> CommonAlgs = ssh_test_lib:algo_intersection( @@ -86,6 +89,7 @@ init_per_group(_, Config) -> end_per_group(erlang_server, Config) -> UserDir = ?config(priv_dir, Config), ssh_test_lib:clean_dsa(UserDir), + ssh_test_lib:clean_rsa(UserDir), Config; end_per_group(_, Config) -> Config. @@ -93,6 +97,8 @@ end_per_group(_, Config) -> init_per_testcase(erlang_server_openssh_client_public_key_dsa, Config) -> chk_key(sshc, 'ssh-dss', ".ssh/id_dsa", Config); +init_per_testcase(erlang_server_openssh_client_public_key_rsa, Config) -> + chk_key(sshc, 'ssh-rsa', ".ssh/id_rsa", Config); init_per_testcase(erlang_client_openssh_server_publickey_dsa, Config) -> chk_key(sshd, 'ssh-dss', ".ssh/id_dsa", Config); init_per_testcase(_TestCase, Config) -> @@ -347,14 +353,24 @@ erlang_client_openssh_server_publickey_dsa(Config) when is_list(Config) -> %%-------------------------------------------------------------------- erlang_server_openssh_client_public_key_dsa() -> - [{doc, "Validate using dsa publickey."}]. + [{timetrap, {seconds,(?TIMEOUT div 1000)+10}}, + {doc, "Validate using dsa publickey."}]. erlang_server_openssh_client_public_key_dsa(Config) when is_list(Config) -> + erlang_server_openssh_client_public_key_X(Config, ssh_dsa). + +erlang_server_openssh_client_public_key_rsa() -> + [{timetrap, {seconds,(?TIMEOUT div 1000)+10}}, + {doc, "Validate using rsa publickey."}]. +erlang_server_openssh_client_public_key_rsa(Config) when is_list(Config) -> + erlang_server_openssh_client_public_key_X(Config, ssh_rsa). + + +erlang_server_openssh_client_public_key_X(Config, PubKeyAlg) -> SystemDir = ?config(data_dir, Config), PrivDir = ?config(priv_dir, Config), KnownHosts = filename:join(PrivDir, "known_hosts"), - {Pid, Host, Port} = ssh_test_lib:daemon([{system_dir, SystemDir}, - {public_key_alg, ssh_dsa}, + {public_key_alg, PubKeyAlg}, {failfun, fun ssh_test_lib:failfun/2}]), ct:sleep(500), @@ -362,18 +378,8 @@ erlang_server_openssh_client_public_key_dsa(Config) when is_list(Config) -> Cmd = "ssh -p " ++ integer_to_list(Port) ++ " -o UserKnownHostsFile=" ++ KnownHosts ++ " " ++ Host ++ " 1+1.", - SshPort = open_port({spawn, Cmd}, [binary, stderr_to_stdout]), - - receive - {SshPort,{data, <<"2\n">>}} -> - ok - after ?TIMEOUT -> - receive - X -> ct:fail("Received: ~p",[X]) - after 0 -> - ct:fail("Did not receive answer") - end - end, + OpenSsh = ssh_test_lib:open_port({spawn, Cmd}), + ssh_test_lib:rcv_expected({data,<<"2\n">>}, OpenSsh, ?TIMEOUT), ssh:stop_daemon(Pid). %%-------------------------------------------------------------------- diff --git a/lib/ssh/test/ssh_to_openssh_SUITE_data/ssh_host_rsa_key b/lib/ssh/test/ssh_to_openssh_SUITE_data/ssh_host_rsa_key new file mode 100644 index 0000000000..79968bdd7d --- /dev/null +++ b/lib/ssh/test/ssh_to_openssh_SUITE_data/ssh_host_rsa_key @@ -0,0 +1,16 @@ +-----BEGIN RSA PRIVATE KEY----- +MIICXQIBAAKBgQDCZX+4FBDwZIh9y/Uxee1VJnEXlowpz2yDKwj8semM4q843337 +zbNfxHmladB1lpz2NqyxI175xMIJuDxogyZdsOxGnFAzAnthR4dqL/RWRWzjaxSB +6IAO9SPYVVlrpZ+1hsjLW79fwXK/yc8VdhRuWTeQiRgYY2ek8+OKbOqz4QIDAQAB +AoGANmvJzJO5hkLuvyDZHKfAnGTtpifcR1wtSa9DjdKUyn8vhKF0mIimnbnYQEmW +NUUb3gXCZLi9PvkpRSVRrASDOZwcjoU/Kvww163vBUVb2cOZfFhyn6o2Sk88Tt++ +udH3hdjpf9i7jTtUkUe+QYPsia+wgvvrmn4QrahLAH86+kECQQDx5gFeXTME3cnW +WMpFz3PPumduzjqgqMMWEccX4FtQkMX/gyGa5UC7OHFyh0N/gSWvPbRHa8A6YgIt +n8DO+fh5AkEAzbqX4DOn8NY6xJIi42q7l/2jIA0RkB6P7YugW5NblhqBZ0XDnpA5 +sMt+rz+K07u9XZtxgh1xi7mNfwY6lEAMqQJBAJBEauCKmRj35Z6OyeQku59SPsnY ++SJEREVvSNw2lH9SOKQQ4wPsYlTGbvKtNVZgAcen91L5MmYfeckYE/fdIZECQQCt +64zxsTnM1I8iFxj/gP/OYlJBikrKt8udWmjaghzvLMEw+T2DExJyb9ZNeT53+UMB +m6O+B/4xzU/djvp+0hbhAkAemIt+rA5kTmYlFndhpvzkSSM8a2EXsO4XIPgGWCTT +tQKS/tTly0ADMjN/TVy11+9d6zcqadNVuHXHGtR4W0GR +-----END RSA PRIVATE KEY----- + diff --git a/lib/ssh/test/ssh_to_openssh_SUITE_data/ssh_host_rsa_key.pub b/lib/ssh/test/ssh_to_openssh_SUITE_data/ssh_host_rsa_key.pub new file mode 100644 index 0000000000..75d2025c71 --- /dev/null +++ b/lib/ssh/test/ssh_to_openssh_SUITE_data/ssh_host_rsa_key.pub @@ -0,0 +1,5 @@ +---- BEGIN SSH2 PUBLIC KEY ---- +AAAAB3NzaC1yc2EAAAADAQABAAAAgQDCZX+4FBDwZIh9y/Uxee1VJnEXlowpz2yDKwj8 +semM4q843337zbNfxHmladB1lpz2NqyxI175xMIJuDxogyZdsOxGnFAzAnthR4dqL/RW +RWzjaxSB6IAO9SPYVVlrpZ+1hsjLW79fwXK/yc8VdhRuWTeQiRgYY2ek8+OKbOqz4Q== +---- END SSH2 PUBLIC KEY ---- diff --git a/lib/ssh/test/ssh_trpt_test_lib.erl b/lib/ssh/test/ssh_trpt_test_lib.erl index 4269529ae8..e34071af99 100644 --- a/lib/ssh/test/ssh_trpt_test_lib.erl +++ b/lib/ssh/test/ssh_trpt_test_lib.erl @@ -294,12 +294,11 @@ instantiate(X, _S) -> %%%================================================================ %%% init_ssh(Role, Socket, Options0) -> - Options = [{user_interaction,false} + Options = [{user_interaction, false}, + {vsn, {2,0}}, + {id_string, "ErlangTestLib"} | Options0], - ssh_connection_handler:init_ssh(Role, - {2,0}, - lists:concat(["SSH-2.0-ErlangTestLib ",Role]), - Options, Socket). + ssh_connection_handler:init_ssh_record(Role, Socket, Options). mangle_opts(Options) -> SysOpts = [{reuseaddr, true}, diff --git a/lib/ssh/test/ssh_upgrade_SUITE.erl b/lib/ssh/test/ssh_upgrade_SUITE.erl index 5c7ec17dac..06bef2455e 100644 --- a/lib/ssh/test/ssh_upgrade_SUITE.erl +++ b/lib/ssh/test/ssh_upgrade_SUITE.erl @@ -146,7 +146,8 @@ setup_server_client(#state{config=Config} = State) -> SFTP = ssh_sftpd:subsystem_spec([{root,FtpRootDir},{cwd,FtpRootDir}]), - {Server,Host,Port} = ssh_test_lib:daemon([{system_dir,DataDir}, + {Server,Host,Port} = ssh_test_lib:daemon(ssh_test_lib:inet_port(), % when lower rel is 18.x + [{system_dir,DataDir}, {user_passwords,[{"hej","hopp"}]}, {subsystems,[SFTP]}]), diff --git a/lib/ssh/vsn.mk b/lib/ssh/vsn.mk index 41b42d454b..b165928877 100644 --- a/lib/ssh/vsn.mk +++ b/lib/ssh/vsn.mk @@ -1,5 +1,5 @@ #-*-makefile-*- ; force emacs to enter makefile-mode -SSH_VSN = 4.2.2 +SSH_VSN = 4.3 APP_VSN = "ssh-$(SSH_VSN)" diff --git a/lib/ssl/doc/src/notes.xml b/lib/ssl/doc/src/notes.xml index 00419b63db..e9b523d9e1 100644 --- a/lib/ssl/doc/src/notes.xml +++ b/lib/ssl/doc/src/notes.xml @@ -28,6 +28,23 @@ <p>This document describes the changes made to the SSL application.</p> +<section><title>SSL 7.3.2</title> + + <section><title>Fixed Bugs and Malfunctions</title> + <list> + <item> + <p> + Correct cipher suites conversion and gaurd expression. + Caused problems with GCM cipher suites and client side + option to set signature_algorithms extention values.</p> + <p> + Own Id: OTP-13525</p> + </item> + </list> + </section> + +</section> + <section><title>SSL 7.3.1</title> <section><title>Fixed Bugs and Malfunctions</title> diff --git a/lib/ssl/src/dtls_connection.erl b/lib/ssl/src/dtls_connection.erl index e490de7eeb..82d6faee42 100644 --- a/lib/ssl/src/dtls_connection.erl +++ b/lib/ssl/src/dtls_connection.erl @@ -21,7 +21,7 @@ %% Internal application API --behaviour(gen_fsm). +-behaviour(gen_statem). -include("dtls_connection.hrl"). -include("dtls_handshake.hrl"). @@ -36,37 +36,38 @@ %% Internal application API %% Setup --export([start_fsm/8]). +-export([start_fsm/8, start_link/7, init/1]). %% State transition handling --export([next_record/1, next_state/4%, - %%next_state_connection/2 - ]). +-export([next_record/1, next_event/3]). %% Handshake handling --export([%%renegotiate/1, +-export([%%renegotiate/2, send_handshake/2, send_change_cipher/2]). + %% Alert and close handling --export([send_alert/2, handle_own_alert/4, %%handle_close_alert/3, - handle_normal_shutdown/3 - %%handle_unexpected_message/3, - %%alert_user/5, alert_user/8 +-export([%%send_alert/2, handle_own_alert/4, handle_close_alert/3, + handle_normal_shutdown/3 %%, close/5 + %%alert_user/6, alert_user/9 ]). %% Data handling -export([%%write_application_data/3, - read_application_data/2%%, -%% passive_receive/2, next_record_if_active/1 + read_application_data/2, + %%passive_receive/2, + next_record_if_active/1 %%, + %%handle_common_event/4 ]). -%% Called by tls_connection_sup --export([start_link/7]). +%% gen_statem state functions +-export([init/3, error/3, downgrade/3, %% Initiation and take down states + hello/3, certify/3, cipher/3, abbreviated/3, %% Handshake states + connection/3]). +%% gen_statem callbacks +-export([terminate/3, code_change/4, format_status/2]). -%% gen_fsm callbacks --export([init/1, hello/2, certify/2, cipher/2, - abbreviated/2, connection/2, handle_event/3, - handle_sync_event/4, handle_info/3, terminate/3, code_change/4]). +-define(GEN_STATEM_CB_MODE, state_functions). %%==================================================================== %% Internal application API @@ -141,75 +142,74 @@ send_change_cipher(Msg, #state{connection_states = ConnectionStates0, start_link(Role, Host, Port, Socket, Options, User, CbInfo) -> {ok, proc_lib:spawn_link(?MODULE, init, [[Role, Host, Port, Socket, Options, User, CbInfo]])}. -init([Role, Host, Port, Socket, {SSLOpts0, _} = Options, User, CbInfo]) -> +init([Role, Host, Port, Socket, Options, User, CbInfo]) -> process_flag(trap_exit, true), State0 = initial_state(Role, Host, Port, Socket, Options, User, CbInfo), - Handshake = ssl_handshake:init_handshake_history(), - TimeStamp = erlang:monotonic_time(), - try ssl_config:init(SSLOpts0, Role) of - {ok, Ref, CertDbHandle, FileRefHandle, CacheHandle, CRLDbInfo, OwnCert, Key, DHParams} -> - Session = State0#state.session, - State = State0#state{ - tls_handshake_history = Handshake, - session = Session#session{own_certificate = OwnCert, - time_stamp = TimeStamp}, - file_ref_db = FileRefHandle, - cert_db_ref = Ref, - cert_db = CertDbHandle, - crl_db = CRLDbInfo, - session_cache = CacheHandle, - private_key = Key, - diffie_hellman_params = DHParams}, - gen_fsm:enter_loop(?MODULE, [], hello, State, get_timeout(State)) + try + State = ssl_connection:ssl_config(State0#state.ssl_options, Role, State0), + gen_statem:enter_loop(?MODULE, [], ?GEN_STATEM_CB_MODE, init, State) catch throw:Error -> - gen_fsm:enter_loop(?MODULE, [], error, {Error,State0}, get_timeout(State0)) + gen_statem:enter_loop(?MODULE, [], ?GEN_STATEM_CB_MODE, error, {Error,State0}) end. %%-------------------------------------------------------------------- -%% Description:There should be one instance of this function for each -%% possible state name. Whenever a gen_fsm receives an event sent -%% using gen_fsm:send_event/2, the instance of this function with the -%% same name as the current state name StateName is called to handle -%% the event. It is also called if a timeout occurs. -%% -hello(start, #state{host = Host, port = Port, role = client, - ssl_options = SslOpts, - session = #session{own_certificate = Cert} = Session0, - session_cache = Cache, session_cache_cb = CacheCb, - transport_cb = Transport, socket = Socket, - connection_states = ConnectionStates0, - renegotiation = {Renegotiation, _}} = State0) -> +%% State functionsconnection/2 +%%-------------------------------------------------------------------- + +init({call, From}, {start, Timeout}, + #state{host = Host, port = Port, role = client, + ssl_options = SslOpts, + session = #session{own_certificate = Cert} = Session0, + transport_cb = Transport, socket = Socket, + connection_states = ConnectionStates0, + renegotiation = {Renegotiation, _}, + session_cache = Cache, + session_cache_cb = CacheCb + } = State0) -> + Timer = ssl_connection:start_or_recv_cancel_timer(Timeout, From), Hello = dtls_handshake:client_hello(Host, Port, ConnectionStates0, SslOpts, - Cache, CacheCb, Renegotiation, Cert), + Cache, CacheCb, Renegotiation, Cert), Version = Hello#client_hello.client_version, + HelloVersion = dtls_record:lowest_protocol_version(SslOpts#ssl_options.versions), Handshake0 = ssl_handshake:init_handshake_history(), {BinMsg, ConnectionStates, Handshake} = - encode_handshake(Hello, Version, ConnectionStates0, Handshake0), + encode_handshake(Hello, HelloVersion, ConnectionStates0, Handshake0), Transport:send(Socket, BinMsg), State1 = State0#state{connection_states = ConnectionStates, negotiated_version = Version, %% Requested version session = Session0#session{session_id = Hello#client_hello.session_id}, - tls_handshake_history = Handshake}, + tls_handshake_history = Handshake, + start_or_recv_from = From, + timer = Timer}, {Record, State} = next_record(State1), - next_state(hello, hello, Record, State); - -hello(Hello = #client_hello{client_version = ClientVersion}, - State = #state{connection_states = ConnectionStates0, - port = Port, session = #session{own_certificate = Cert} = Session0, - renegotiation = {Renegotiation, _}, - session_cache = Cache, - session_cache_cb = CacheCb, - ssl_options = SslOpts}) -> + next_event(hello, Record, State); +init(Type, Event, State) -> + ssl_connection:init(Type, Event, State, ?MODULE). + +error({call, From}, {start, _Timeout}, {Error, State}) -> + {stop_and_reply, normal, {reply, From, {error, Error}}, State}; +error({call, From}, Msg, State) -> + handle_call(Msg, From, error, State); +error(_, _, _) -> + {keep_state_and_data, [postpone]}. + +hello(internal, #client_hello{client_version = ClientVersion} = Hello, + #state{connection_states = ConnectionStates0, + port = Port, session = #session{own_certificate = Cert} = Session0, + renegotiation = {Renegotiation, _}, + session_cache = Cache, + session_cache_cb = CacheCb, + ssl_options = SslOpts} = State) -> case dtls_handshake:hello(Hello, SslOpts, {Port, Session0, Cache, CacheCb, ConnectionStates0, Cert}, Renegotiation) of {Version, {Type, Session}, ConnectionStates, #hello_extensions{ec_point_formats = EcPointFormats, elliptic_curves = EllipticCurves} = ServerHelloExt, HashSign} -> - ssl_connection:hello({common_client_hello, Type, ServerHelloExt, HashSign}, + ssl_connection:hello(internal, {common_client_hello, Type, ServerHelloExt, HashSign}, State#state{connection_states = ConnectionStates, negotiated_version = Version, session = Session, @@ -217,7 +217,7 @@ hello(Hello = #client_hello{client_version = ClientVersion}, #alert{} = Alert -> handle_own_alert(Alert, ClientVersion, hello, State) end; -hello(Hello, +hello(internal, Hello, #state{connection_states = ConnectionStates0, negotiated_version = ReqVersion, role = client, @@ -230,20 +230,30 @@ hello(Hello, ssl_connection:handle_session(Hello, Version, NewId, ConnectionStates, ProtoExt, Protocol, State) end; - -hello(Msg, State) -> - ssl_connection:hello(Msg, State, ?MODULE). - -abbreviated(Msg, State) -> - ssl_connection:abbreviated(Msg, State, ?MODULE). - -certify(Msg, State) -> - ssl_connection:certify(Msg, State, ?MODULE). - -cipher(Msg, State) -> - ssl_connection:cipher(Msg, State, ?MODULE). - -connection(#hello_request{}, #state{host = Host, port = Port, +hello(info, Event, State) -> + handle_info(Event, hello, State); + +hello(Type, Event, State) -> + ssl_connection:hello(Type, Event, State, ?MODULE). + +abbreviated(info, Event, State) -> + handle_info(Event, abbreviated, State); +abbreviated(Type, Event, State) -> + ssl_connection:abbreviated(Type, Event, State, ?MODULE). + +certify(info, Event, State) -> + handle_info(Event, certify, State); +certify(Type, Event, State) -> + ssl_connection:certify(Type, Event, State, ?MODULE). + +cipher(info, Event, State) -> + handle_info(Event, cipher, State); +cipher(Type, Event, State) -> + ssl_connection:cipher(Type, Event, State, ?MODULE). + +connection(info, Event, State) -> + handle_info(Event, connection, State); +connection(internal, #hello_request{}, #state{host = Host, port = Port, session = #session{own_certificate = Cert} = Session0, session_cache = Cache, session_cache_cb = CacheCb, ssl_options = SslOpts, @@ -257,40 +267,30 @@ connection(#hello_request{}, #state{host = Host, port = Port, next_record( State1#state{session = Session0#session{session_id = Hello#client_hello.session_id}}), - next_state(connection, hello, Record, State); + next_event(hello, Record, State); -connection(#client_hello{} = Hello, #state{role = server, allow_renegotiate = true} = State) -> +connection(internal, #client_hello{} = Hello, #state{role = server, allow_renegotiate = true} = State) -> %% Mitigate Computational DoS attack %% http://www.educatedguesswork.org/2011/10/ssltls_and_computational_dos.html %% http://www.thc.org/thc-ssl-dos/ Rather than disabling client %% initiated renegotiation we will disallow many client initiated %% renegotiations immediately after each other. erlang:send_after(?WAIT_TO_ALLOW_RENEGOTIATION, self(), allow_renegotiate), - hello(Hello, State#state{allow_renegotiate = false}); + {next_state, hello, State#state{allow_renegotiate = false}, [{next_event, internal, Hello}]}; + -connection(#client_hello{}, #state{role = server, allow_renegotiate = false} = State0) -> +connection(internal, #client_hello{}, #state{role = server, allow_renegotiate = false} = State0) -> Alert = ?ALERT_REC(?WARNING, ?NO_RENEGOTIATION), - State = send_alert(Alert, State0), - next_state_connection(connection, State); + State1 = send_alert(Alert, State0), + {Record, State} = ssl_connection:prepare_connection(State1, ?MODULE), + next_event(connection, Record, State); -connection(Msg, State) -> - ssl_connection:connection(Msg, State, tls_connection). +connection(Type, Event, State) -> + ssl_connection:connection(Type, Event, State, ?MODULE). -%%-------------------------------------------------------------------- -%% Description: Whenever a gen_fsm receives an event sent using -%% gen_fsm:send_all_state_event/2, this function is called to handle -%% the event. Not currently used! -%%-------------------------------------------------------------------- -handle_event(_Event, StateName, State) -> - {next_state, StateName, State, get_timeout(State)}. +downgrade(Type, Event, State) -> + ssl_connection:downgrade(Type, Event, State, ?MODULE). -%%-------------------------------------------------------------------- -%% Description: Whenever a gen_fsm receives an event sent using -%% gen_fsm:sync_send_all_state_event/2,3, this function is called to handle -%% the event. -%%-------------------------------------------------------------------- -handle_sync_event(Event, From, StateName, State) -> - ssl_connection:handle_sync_event(Event, From, StateName, State). %%-------------------------------------------------------------------- %% Description: This function is called by a gen_fsm when it receives any @@ -301,26 +301,25 @@ handle_sync_event(Event, From, StateName, State) -> %% raw data from socket, unpack records handle_info({Protocol, _, Data}, StateName, #state{data_tag = Protocol} = State0) -> - %% Simplify for now to avoid dialzer warnings before implementation is compleate - %% case next_tls_record(Data, State0) of - %% {Record, State} -> - %% next_state(StateName, StateName, Record, State); - %% #alert{} = Alert -> - %% handle_normal_shutdown(Alert, StateName, State0), - %% {stop, {shutdown, own_alert}, State0} - %% end; - {Record, State} = next_tls_record(Data, State0), - next_state(StateName, StateName, Record, State); - + case next_tls_record(Data, State0) of + {Record, State} -> + next_event(StateName, Record, State); + #alert{} = Alert -> + handle_normal_shutdown(Alert, StateName, State0), + {stop, {shutdown, own_alert}} + end; handle_info({CloseTag, Socket}, StateName, #state{socket = Socket, close_tag = CloseTag, negotiated_version = _Version} = State) -> handle_normal_shutdown(?ALERT_REC(?FATAL, ?CLOSE_NOTIFY), StateName, State), - {stop, {shutdown, transport_closed}, State}; + {stop, {shutdown, transport_closed}}; handle_info(Msg, StateName, State) -> ssl_connection:handle_info(Msg, StateName, State). +handle_call(Event, From, StateName, State) -> + ssl_connection:handle_call(Event, From, StateName, State, ?MODULE). + %%-------------------------------------------------------------------- %% Description:This function is called by a gen_fsm when it is about %% to terminate. It should be the opposite of Module:init/1 and do any @@ -335,7 +334,10 @@ terminate(Reason, StateName, State) -> %% Description: Convert process state when code is changed %%-------------------------------------------------------------------- code_change(_OldVsn, StateName, State, _Extra) -> - {ok, StateName, State}. + {?GEN_STATEM_CB_MODE, StateName, State}. + +format_status(Type, Data) -> + ssl_connection:format_status(Type, Data). %%-------------------------------------------------------------------- %%% Internal functions @@ -372,96 +374,28 @@ next_record(#state{socket = Socket, next_record(State) -> {no_record, State}. -next_state(Current,_, #alert{} = Alert, #state{negotiated_version = Version} = State) -> - handle_own_alert(Alert, Version, Current, State); - -next_state(_,Next, no_record, State) -> - {next_state, Next, State, get_timeout(State)}; - -%% next_state(_,Next, #ssl_tls{type = ?ALERT, fragment = EncAlerts}, State) -> -%% Alerts = decode_alerts(EncAlerts), -%% handle_alerts(Alerts, {next_state, Next, State, get_timeout(State)}); - -next_state(Current, Next, #ssl_tls{type = ?HANDSHAKE, fragment = Data}, - State0 = #state{protocol_buffers = - #protocol_buffers{dtls_handshake_buffer = Buf0} = Buffers, - negotiated_version = Version}) -> - Handle = - fun({#hello_request{} = Packet, _}, {next_state, connection = SName, State}) -> - %% This message should not be included in handshake - %% message hashes. Starts new handshake (renegotiation) - Hs0 = ssl_handshake:init_handshake_history(), - ?MODULE:SName(Packet, State#state{tls_handshake_history=Hs0, - renegotiation = {true, peer}}); - ({#hello_request{} = Packet, _}, {next_state, SName, State}) -> - %% This message should not be included in handshake - %% message hashes. Already in negotiation so it will be ignored! - ?MODULE:SName(Packet, State); - ({#client_hello{} = Packet, Raw}, {next_state, connection = SName, State}) -> - Version = Packet#client_hello.client_version, - Hs0 = ssl_handshake:init_handshake_history(), - Hs1 = ssl_handshake:update_handshake_history(Hs0, Raw), - ?MODULE:SName(Packet, State#state{tls_handshake_history=Hs1, - renegotiation = {true, peer}}); - ({Packet, Raw}, {next_state, SName, State = #state{tls_handshake_history=Hs0}}) -> - Hs1 = ssl_handshake:update_handshake_history(Hs0, Raw), - ?MODULE:SName(Packet, State#state{tls_handshake_history=Hs1}); - (_, StopState) -> StopState - end, - try - {Packets, Buf} = tls_handshake:get_tls_handshake(Version,Data,Buf0), - State = State0#state{protocol_buffers = - Buffers#protocol_buffers{dtls_packets = Packets, - dtls_handshake_buffer = Buf}}, - handle_dtls_handshake(Handle, Next, State) - catch throw:#alert{} = Alert -> - handle_own_alert(Alert, Version, Current, State0) - end; -next_state(_, StateName, #ssl_tls{type = ?APPLICATION_DATA, fragment = Data}, State0) -> - %% Simplify for now to avoid dialzer warnings before implementation is compleate - %% case read_application_data(Data, State0) of - %% Stop = {stop,_,_} -> - %% Stop; - %% {Record, State} -> - %% next_state(StateName, StateName, Record, State) - %% end; - {Record, State} = read_application_data(Data, State0), - next_state(StateName, StateName, Record, State); - -next_state(Current, Next, #ssl_tls{type = ?CHANGE_CIPHER_SPEC, fragment = <<1>>} = - _ChangeCipher, - #state{connection_states = ConnectionStates0} = State0) -> - ConnectionStates1 = - ssl_record:activate_pending_connection_state(ConnectionStates0, read), - {Record, State} = next_record(State0#state{connection_states = ConnectionStates1}), - next_state(Current, Next, Record, State); -next_state(Current, Next, #ssl_tls{type = _Unknown}, State0) -> - %% Ignore unknown type - {Record, State} = next_record(State0), - next_state(Current, Next, Record, State). - -handle_dtls_handshake(Handle, StateName, - #state{protocol_buffers = - #protocol_buffers{dtls_packets = [Packet]} = Buffers} = State) -> - FsmReturn = {next_state, StateName, State#state{protocol_buffers = - Buffers#protocol_buffers{dtls_packets = []}}}, - Handle(Packet, FsmReturn); - -handle_dtls_handshake(Handle, StateName, - #state{protocol_buffers = - #protocol_buffers{dtls_packets = [Packet | Packets]} = Buffers} = - State0) -> - FsmReturn = {next_state, StateName, State0#state{protocol_buffers = - Buffers#protocol_buffers{dtls_packets = - Packets}}}, - case Handle(Packet, FsmReturn) of - {next_state, NextStateName, State, _Timeout} -> - handle_dtls_handshake(Handle, NextStateName, State); - {stop, _,_} = Stop -> - Stop - end. +next_event(StateName, Record, State) -> + next_event(StateName, Record, State, []). +next_event(connection = StateName, no_record, State0, Actions) -> + case next_record_if_active(State0) of + {no_record, State} -> + ssl_connection:hibernate_after(StateName, State, Actions); + {#ssl_tls{} = Record, State} -> + {next_state, StateName, State, [{next_event, internal, {dtls_record, Record}} | Actions]}; + {#alert{} = Alert, State} -> + {next_state, StateName, State, [{next_event, internal, Alert} | Actions]} + end; +next_event(StateName, Record, State, Actions) -> + case Record of + no_record -> + {next_state, StateName, State, Actions}; + #ssl_tls{} = Record -> + {next_state, StateName, State, [{next_event, internal, {dtls_record, Record}} | Actions]}; + #alert{} = Alert -> + {next_state, StateName, State, [{next_event, internal, Alert} | Actions]} + end. send_flight(Fragments, #state{transport_cb = Transport, socket = Socket, protocol_buffers = _PBuffers} = State) -> @@ -514,21 +448,23 @@ initial_state(Role, Host, Port, Socket, {SSLOptions, SocketOptions}, User, renegotiation = {false, first}, allow_renegotiate = SSLOptions#ssl_options.client_renegotiation, start_or_recv_from = undefined, - send_queue = queue:new(), protocol_cb = ?MODULE }. read_application_data(_,State) -> {#ssl_tls{fragment = <<"place holder">>}, State}. - + +next_tls_record(<<>>, _State) -> + #alert{}; %% Place holder next_tls_record(_, State) -> {#ssl_tls{fragment = <<"place holder">>}, State}. -get_timeout(_) -> %% Place holder - infinity. - -next_state_connection(_, State) -> %% Place holder - {next_state, connection, State, get_timeout(State)}. - sequence(_) -> %%TODO real imp 1. +next_record_if_active(State = + #state{socket_options = + #socket_options{active = false}}) -> + {no_record ,State}; + +next_record_if_active(State) -> + next_record(State). diff --git a/lib/ssl/src/dtls_record.erl b/lib/ssl/src/dtls_record.erl index 2530d66052..e79e1cede0 100644 --- a/lib/ssl/src/dtls_record.erl +++ b/lib/ssl/src/dtls_record.erl @@ -39,7 +39,7 @@ -export([encode_plain_text/4, encode_handshake/3, encode_change_cipher_spec/2]). %% Protocol version handling --export([protocol_version/1, lowest_protocol_version/2, +-export([protocol_version/1, lowest_protocol_version/2, lowest_protocol_version/1, highest_protocol_version/1, supported_protocol_versions/0, is_acceptable_version/2]). @@ -254,6 +254,18 @@ lowest_protocol_version(Version = {M,_}, {N, _}) when M > N -> Version; lowest_protocol_version(_,Version) -> Version. + +%%-------------------------------------------------------------------- +-spec lowest_protocol_version([dtls_version()]) -> dtls_version(). +%% +%% Description: Lowest protocol version present in a list +%%-------------------------------------------------------------------- +lowest_protocol_version([]) -> + lowest_protocol_version(); +lowest_protocol_version(Versions) -> + [Ver | Vers] = Versions, + lowest_list_protocol_version(Ver, Vers). + %%-------------------------------------------------------------------- -spec highest_protocol_version([dtls_version()]) -> dtls_version(). %% @@ -302,6 +314,12 @@ supported_protocol_versions([]) -> supported_protocol_versions([_|_] = Vsns) -> Vsns. +%% highest_protocol_version() -> +%% highest_protocol_version(supported_protocol_versions()). + +lowest_protocol_version() -> + lowest_protocol_version(supported_protocol_versions()). + supported_connection_protocol_versions([]) -> ?ALL_DATAGRAM_SUPPORTED_VERSIONS. @@ -421,3 +439,8 @@ mac_hash(Version, MacAlg, MacSecret, SeqNo, Type, Length, Fragment) -> calc_aad(Type, {MajVer, MinVer}, Epoch, SeqNo) -> NewSeq = (Epoch bsl 48) + SeqNo, <<NewSeq:64/integer, ?BYTE(Type), ?BYTE(MajVer), ?BYTE(MinVer)>>. + +lowest_list_protocol_version(Ver, []) -> + Ver; +lowest_list_protocol_version(Ver1, [Ver2 | Rest]) -> + lowest_list_protocol_version(lowest_protocol_version(Ver1, Ver2), Rest). diff --git a/lib/ssl/src/ssl.erl b/lib/ssl/src/ssl.erl index 025e8cea61..dbbb25025c 100644 --- a/lib/ssl/src/ssl.erl +++ b/lib/ssl/src/ssl.erl @@ -696,7 +696,7 @@ handle_options(Opts0, Role) -> default_option_role(server, true, Role), server, Role), renegotiate_at = handle_option(renegotiate_at, Opts, ?DEFAULT_RENEGOTIATE_AT), - hibernate_after = handle_option(hibernate_after, Opts, undefined), + hibernate_after = handle_option(hibernate_after, Opts, infinity), erl_dist = handle_option(erl_dist, Opts, false), alpn_advertised_protocols = handle_option(alpn_advertised_protocols, Opts, undefined), @@ -885,10 +885,13 @@ validate_option(client_renegotiation, Value) when is_boolean(Value) -> validate_option(renegotiate_at, Value) when is_integer(Value) -> erlang:min(Value, ?DEFAULT_RENEGOTIATE_AT); -validate_option(hibernate_after, undefined) -> - undefined; +validate_option(hibernate_after, undefined) -> %% Backwards compatibility + infinity; +validate_option(hibernate_after, infinity) -> + infinity; validate_option(hibernate_after, Value) when is_integer(Value), Value >= 0 -> Value; + validate_option(erl_dist,Value) when is_boolean(Value) -> Value; validate_option(Opt, Value) diff --git a/lib/ssl/src/ssl_cipher.erl b/lib/ssl/src/ssl_cipher.erl index 544d9b41cd..dc0a0c2cc4 100644 --- a/lib/ssl/src/ssl_cipher.erl +++ b/lib/ssl/src/ssl_cipher.erl @@ -992,21 +992,21 @@ suite({ecdh_rsa, aes_256_cbc, sha384, sha384}) -> %% RFC 5288 AES-GCM Cipher Suites suite({rsa, aes_128_gcm, null, sha256}) -> ?TLS_RSA_WITH_AES_128_GCM_SHA256; -suite({rsa, aes_256_gcm, null}) -> +suite({rsa, aes_256_gcm, null, sha384}) -> ?TLS_RSA_WITH_AES_256_GCM_SHA384; -suite({dhe_rsa, aes_128_gcm, null, sha384}) -> +suite({dhe_rsa, aes_128_gcm, null, sha256}) -> ?TLS_DHE_RSA_WITH_AES_128_GCM_SHA256; -suite({dhe_rsa, aes_256_gcm, null, sha256}) -> +suite({dhe_rsa, aes_256_gcm, null, sha384}) -> ?TLS_DHE_RSA_WITH_AES_256_GCM_SHA384; -suite({dh_rsa, aes_128_gcm, null, sha384}) -> +suite({dh_rsa, aes_128_gcm, null, sha256}) -> ?TLS_DH_RSA_WITH_AES_128_GCM_SHA256; -suite({dh_rsa, aes_256_gcm, null, sha256}) -> +suite({dh_rsa, aes_256_gcm, null, sha384}) -> ?TLS_DH_RSA_WITH_AES_256_GCM_SHA384; -suite({dhe_dss, aes_128_gcm, null, sha384}) -> +suite({dhe_dss, aes_128_gcm, null, sha256}) -> ?TLS_DHE_DSS_WITH_AES_128_GCM_SHA256; -suite({dhe_dss, aes_256_gcm, null, sha256}) -> +suite({dhe_dss, aes_256_gcm, null, sha384}) -> ?TLS_DHE_DSS_WITH_AES_256_GCM_SHA384; -suite({dh_dss, aes_128_gcm, null, sha384}) -> +suite({dh_dss, aes_128_gcm, null, sha256}) -> ?TLS_DH_DSS_WITH_AES_128_GCM_SHA256; suite({dh_dss, aes_256_gcm, null, sha384}) -> ?TLS_DH_DSS_WITH_AES_256_GCM_SHA384; diff --git a/lib/ssl/src/ssl_connection.erl b/lib/ssl/src/ssl_connection.erl index 0073e86e26..26c371a8ea 100644 --- a/lib/ssl/src/ssl_connection.erl +++ b/lib/ssl/src/ssl_connection.erl @@ -38,7 +38,7 @@ %% Setup -export([connect/8, ssl_accept/7, handshake/2, handshake/3, - socket_control/4, socket_control/5]). + socket_control/4, socket_control/5, start_or_recv_cancel_timer/2]). %% User Events -export([send/2, recv/3, close/2, shutdown/2, @@ -47,12 +47,16 @@ connection_information/1 ]). --export([handle_session/7]). +%% General gen_statem state functions with extra callback argument +%% to determine if it is an SSL/TLS or DTLS gen_statem machine +-export([init/4, hello/4, abbreviated/4, certify/4, cipher/4, connection/4, downgrade/4]). -%% SSL FSM state functions --export([hello/3, abbreviated/3, certify/3, cipher/3, connection/3]). -%% SSL all state functions --export([handle_sync_event/4, handle_info/3, terminate/3, format_status/2]). +%% gen_statem callbacks +-export([terminate/3, format_status/2]). + +%% +-export([handle_info/3, handle_call/5, handle_session/7, ssl_config/3, + prepare_connection/2, hibernate_after/3]). %%==================================================================== @@ -100,7 +104,7 @@ ssl_accept(Connection, Port, Socket, Opts, User, CbInfo, Timeout) -> %% Description: Starts ssl handshake. %%-------------------------------------------------------------------- handshake(#sslsocket{pid = Pid}, Timeout) -> - case sync_send_all_state_event(Pid, {start, Timeout}) of + case call(Pid, {start, Timeout}) of connected -> ok; Error -> @@ -114,7 +118,7 @@ handshake(#sslsocket{pid = Pid}, Timeout) -> %% Description: Starts ssl handshake with some new options %%-------------------------------------------------------------------- handshake(#sslsocket{pid = Pid}, SslOptions, Timeout) -> - case sync_send_all_state_event(Pid, {start, SslOptions, Timeout}) of + case call(Pid, {start, SslOptions, Timeout}) of connected -> ok; Error -> @@ -148,7 +152,7 @@ socket_control(Connection, Socket, Pid, Transport, ListenTracker) -> %% Description: Sends data over the ssl connection %%-------------------------------------------------------------------- send(Pid, Data) -> - sync_send_all_state_event(Pid, {application_data, + call(Pid, {application_data, %% iolist_to_binary should really %% be called iodata_to_binary() erlang:iolist_to_binary(Data)}). @@ -160,7 +164,7 @@ send(Pid, Data) -> %% Description: Receives data when active = false %%-------------------------------------------------------------------- recv(Pid, Length, Timeout) -> - sync_send_all_state_event(Pid, {recv, Length, Timeout}). + call(Pid, {recv, Length, Timeout}). %%-------------------------------------------------------------------- -spec connection_information(pid()) -> {ok, list()} | {error, reason()}. @@ -168,7 +172,7 @@ recv(Pid, Length, Timeout) -> %% Description: Get the SNI hostname %%-------------------------------------------------------------------- connection_information(Pid) when is_pid(Pid) -> - sync_send_all_state_event(Pid, connection_information). + call(Pid, connection_information). %%-------------------------------------------------------------------- -spec close(pid(), {close, Timeout::integer() | @@ -178,7 +182,7 @@ connection_information(Pid) when is_pid(Pid) -> %% Description: Close an ssl connection %%-------------------------------------------------------------------- close(ConnectionPid, How) -> - case sync_send_all_state_event(ConnectionPid, How) of + case call(ConnectionPid, How) of {error, closed} -> ok; Other -> @@ -190,7 +194,7 @@ close(ConnectionPid, How) -> %% Description: Same as gen_tcp:shutdown/2 %%-------------------------------------------------------------------- shutdown(ConnectionPid, How) -> - sync_send_all_state_event(ConnectionPid, {shutdown, How}). + call(ConnectionPid, {shutdown, How}). %%-------------------------------------------------------------------- -spec new_user(pid(), pid()) -> ok | {error, reason()}. @@ -199,7 +203,7 @@ shutdown(ConnectionPid, How) -> %% or once. %%-------------------------------------------------------------------- new_user(ConnectionPid, User) -> - sync_send_all_state_event(ConnectionPid, {new_user, User}). + call(ConnectionPid, {new_user, User}). %%-------------------------------------------------------------------- -spec negotiated_protocol(pid()) -> {ok, binary()} | {error, reason()}. @@ -207,7 +211,7 @@ new_user(ConnectionPid, User) -> %% Description: Returns the negotiated protocol %%-------------------------------------------------------------------- negotiated_protocol(ConnectionPid) -> - sync_send_all_state_event(ConnectionPid, negotiated_protocol). + call(ConnectionPid, negotiated_protocol). %%-------------------------------------------------------------------- -spec get_opts(pid(), list()) -> {ok, list()} | {error, reason()}. @@ -215,14 +219,14 @@ negotiated_protocol(ConnectionPid) -> %% Description: Same as inet:getopts/2 %%-------------------------------------------------------------------- get_opts(ConnectionPid, OptTags) -> - sync_send_all_state_event(ConnectionPid, {get_opts, OptTags}). + call(ConnectionPid, {get_opts, OptTags}). %%-------------------------------------------------------------------- -spec set_opts(pid(), list()) -> ok | {error, reason()}. %% %% Description: Same as inet:setopts/2 %%-------------------------------------------------------------------- set_opts(ConnectionPid, Options) -> - sync_send_all_state_event(ConnectionPid, {set_opts, Options}). + call(ConnectionPid, {set_opts, Options}). %%-------------------------------------------------------------------- -spec session_info(pid()) -> {ok, list()} | {error, reason()}. @@ -230,7 +234,7 @@ set_opts(ConnectionPid, Options) -> %% Description: Returns info about the ssl session %%-------------------------------------------------------------------- session_info(ConnectionPid) -> - sync_send_all_state_event(ConnectionPid, session_info). + call(ConnectionPid, session_info). %%-------------------------------------------------------------------- -spec peer_certificate(pid()) -> {ok, binary()| undefined} | {error, reason()}. @@ -238,7 +242,7 @@ session_info(ConnectionPid) -> %% Description: Returns the peer cert %%-------------------------------------------------------------------- peer_certificate(ConnectionPid) -> - sync_send_all_state_event(ConnectionPid, peer_certificate). + call(ConnectionPid, peer_certificate). %%-------------------------------------------------------------------- -spec renegotiation(pid()) -> ok | {error, reason()}. @@ -246,7 +250,7 @@ peer_certificate(ConnectionPid) -> %% Description: Starts a renegotiation of the ssl session. %%-------------------------------------------------------------------- renegotiation(ConnectionPid) -> - sync_send_all_state_event(ConnectionPid, renegotiate). + call(ConnectionPid, renegotiate). %%-------------------------------------------------------------------- -spec prf(pid(), binary() | 'master_secret', binary(), @@ -256,9 +260,13 @@ renegotiation(ConnectionPid) -> %% Description: use a ssl sessions TLS PRF to generate key material %%-------------------------------------------------------------------- prf(ConnectionPid, Secret, Label, Seed, WantedLength) -> - sync_send_all_state_event(ConnectionPid, {prf, Secret, Label, Seed, WantedLength}). - + call(ConnectionPid, {prf, Secret, Label, Seed, WantedLength}). +%%-------------------------------------------------------------------- +-spec handle_session(#server_hello{}, ssl_record:ssl_version(), + binary(), #connection_states{}, _,_, #state{}) -> + gen_statem:state_function_result(). +%%-------------------------------------------------------------------- handle_session(#server_hello{cipher_suite = CipherSuite, compression_method = Compression}, Version, NewId, ConnectionStates, ProtoExt, Protocol0, @@ -290,61 +298,104 @@ handle_session(#server_hello{cipher_suite = CipherSuite, handle_resumed_session(NewId, State#state{connection_states = ConnectionStates}) end. - + %%-------------------------------------------------------------------- --spec hello(start | #hello_request{} | #server_hello{} | term(), - #state{}, tls_connection | dtls_connection) -> - gen_fsm_state_return(). +-spec ssl_config(#ssl_options{}, client | server, #state{}) -> #state{}. %%-------------------------------------------------------------------- -hello(start, #state{role = server} = State0, Connection) -> - {Record, State} = Connection:next_record(State0), - Connection:next_state(hello, hello, Record, State); +ssl_config(Opts, Role, State) -> + {ok, Ref, CertDbHandle, FileRefHandle, CacheHandle, CRLDbInfo, + OwnCert, Key, DHParams} = + ssl_config:init(Opts, Role), + Handshake = ssl_handshake:init_handshake_history(), + TimeStamp = erlang:monotonic_time(), + Session = State#state.session, + State#state{tls_handshake_history = Handshake, + session = Session#session{own_certificate = OwnCert, + time_stamp = TimeStamp}, + file_ref_db = FileRefHandle, + cert_db_ref = Ref, + cert_db = CertDbHandle, + crl_db = CRLDbInfo, + session_cache = CacheHandle, + private_key = Key, + diffie_hellman_params = DHParams, + ssl_options = Opts}. -hello(#hello_request{}, #state{role = client} = State0, Connection) -> - {Record, State} = Connection:next_record(State0), - Connection:next_state(hello, hello, Record, State); +%%==================================================================== +%% gen_statem state functions +%%==================================================================== +%%-------------------------------------------------------------------- +-spec init(gen_statem:event_type(), + {start, timeout()} | {start, {list(), list()}, timeout()}| term(), + #state{}, tls_connection | dtls_connection) -> + gen_statem:state_function_result(). +%%-------------------------------------------------------------------- -hello({common_client_hello, Type, ServerHelloExt}, - State, Connection) -> +init({call, From}, {start, Timeout}, State0, Connection) -> + Timer = start_or_recv_cancel_timer(Timeout, From), + {Record, State} = Connection:next_record(State0#state{start_or_recv_from = From, + timer = Timer}), + Connection:next_event(hello, Record, State); +init({call, From}, {start, {Opts, EmOpts}, Timeout}, + #state{role = Role} = State0, Connection) -> + try + State = ssl_config(Opts, Role, State0), + init({call, From}, {start, Timeout}, + State#state{ssl_options = Opts, socket_options = EmOpts}, Connection) + catch throw:Error -> + {stop_and_reply, normal, {reply, From, {error, Error}}} + end; +init({call, From}, Msg, State, Connection) -> + handle_call(Msg, From, init, State, Connection); +init(_Type, _Event, _State, _Connection) -> + {keep_state_and_data, [postpone]}. + +%%-------------------------------------------------------------------- +-spec hello(gen_statem:event_type(), + #hello_request{} | #server_hello{} | term(), + #state{}, tls_connection | dtls_connection) -> + gen_statem:state_function_result(). +%%-------------------------------------------------------------------- +hello({call, From}, Msg, State, Connection) -> + handle_call(Msg, From, hello, State, Connection); +hello(internal, {common_client_hello, Type, ServerHelloExt}, State, Connection) -> do_server_hello(Type, ServerHelloExt, State, Connection); -hello(timeout, State, _) -> - {next_state, hello, State, hibernate}; - -hello(Msg, State, Connection) -> - Connection:handle_unexpected_message(Msg, hello, State). +hello(info, Msg, State, _) -> + handle_info(Msg, hello, State); +hello(Type, Msg, State, Connection) -> + handle_common_event(Type, Msg, hello, State, Connection). %%-------------------------------------------------------------------- --spec abbreviated(#hello_request{} | #finished{} | term(), +-spec abbreviated(gen_statem:event_type(), + #hello_request{} | #finished{} | term(), #state{}, tls_connection | dtls_connection) -> - gen_fsm_state_return(). + gen_statem:state_function_result(). %%-------------------------------------------------------------------- -abbreviated(#hello_request{}, State0, Connection) -> - {Record, State} = Connection:next_record(State0), - Connection:next_state(abbreviated, hello, Record, State); +abbreviated({call, From}, Msg, State, Connection) -> + handle_call(Msg, From, abbreviated, State, Connection); -abbreviated(#finished{verify_data = Data} = Finished, +abbreviated(internal, #finished{verify_data = Data} = Finished, #state{role = server, negotiated_version = Version, expecting_finished = true, tls_handshake_history = Handshake, session = #session{master_secret = MasterSecret}, connection_states = ConnectionStates0} = - State, Connection) -> + State0, Connection) -> case ssl_handshake:verify_connection(Version, Finished, client, get_current_prf(ConnectionStates0, write), MasterSecret, Handshake) of verified -> ConnectionStates = ssl_record:set_client_verify_data(current_both, Data, ConnectionStates0), - Connection:next_state_connection(abbreviated, - ack_connection( - State#state{connection_states = ConnectionStates, - expecting_finished = false})); + {Record, State} = prepare_connection(State0#state{connection_states = ConnectionStates, + expecting_finished = false}, Connection), + Connection:next_event(connection, Record, State); #alert{} = Alert -> - Connection:handle_own_alert(Alert, Version, abbreviated, State) + Connection:handle_own_alert(Alert, Version, abbreviated, State0) end; -abbreviated(#finished{verify_data = Data} = Finished, +abbreviated(internal, #finished{verify_data = Data} = Finished, #state{role = client, tls_handshake_history = Handshake0, session = #session{master_secret = MasterSecret}, negotiated_version = Version, @@ -355,40 +406,49 @@ abbreviated(#finished{verify_data = Data} = Finished, verified -> ConnectionStates1 = ssl_record:set_server_verify_data(current_read, Data, ConnectionStates0), - State = + State1 = finalize_handshake(State0#state{connection_states = ConnectionStates1}, abbreviated, Connection), - Connection:next_state_connection(abbreviated, - ack_connection(State#state{expecting_finished = false})); - #alert{} = Alert -> + {Record, State} = prepare_connection(State1#state{expecting_finished = false}, Connection), + Connection:next_event(connection, Record, State); + #alert{} = Alert -> Connection:handle_own_alert(Alert, Version, abbreviated, State0) end; %% only allowed to send next_protocol message after change cipher spec %% & before finished message and it is not allowed during renegotiation -abbreviated(#next_protocol{selected_protocol = SelectedProtocol}, +abbreviated(internal, #next_protocol{selected_protocol = SelectedProtocol}, #state{role = server, expecting_next_protocol_negotiation = true} = State0, Connection) -> - {Record, State} = Connection:next_record(State0#state{negotiated_protocol = SelectedProtocol}), - Connection:next_state(abbreviated, abbreviated, Record, State#state{expecting_next_protocol_negotiation = false}); - -abbreviated(timeout, State, _) -> - {next_state, abbreviated, State, hibernate }; - -abbreviated(Msg, State, Connection) -> - Connection:handle_unexpected_message(Msg, abbreviated, State). - + {Record, State} = + Connection:next_record(State0#state{negotiated_protocol = SelectedProtocol}), + Connection:next_event(abbreviated, Record, + State#state{expecting_next_protocol_negotiation = false}); +abbreviated(internal, + #change_cipher_spec{type = <<1>>}, #state{connection_states = ConnectionStates0} = + State0, Connection) -> + ConnectionStates1 = + ssl_record:activate_pending_connection_state(ConnectionStates0, read), + {Record, State} = Connection:next_record(State0#state{connection_states = + ConnectionStates1}), + Connection:next_event(abbreviated, Record, State#state{expecting_finished = true}); +abbreviated(info, Msg, State, _) -> + handle_info(Msg, abbreviated, State); +abbreviated(Type, Msg, State, Connection) -> + handle_common_event(Type, Msg, abbreviated, State, Connection). + %%-------------------------------------------------------------------- --spec certify(#hello_request{} | #certificate{} | #server_key_exchange{} | +-spec certify(gen_statem:event_type(), + #hello_request{} | #certificate{} | #server_key_exchange{} | #certificate_request{} | #server_hello_done{} | #client_key_exchange{} | term(), #state{}, tls_connection | dtls_connection) -> - gen_fsm_state_return(). + gen_statem:state_function_result(). %%-------------------------------------------------------------------- -certify(#hello_request{}, State0, Connection) -> - {Record, State} = Connection:next_record(State0), - Connection:next_state(certify, hello, Record, State); - -certify(#certificate{asn1_certificates = []}, +certify({call, From}, Msg, State, Connection) -> + handle_call(Msg, From, certify, State, Connection); +certify(info, Msg, State, _) -> + handle_info(Msg, certify, State); +certify(internal, #certificate{asn1_certificates = []}, #state{role = server, negotiated_version = Version, ssl_options = #ssl_options{verify = verify_peer, fail_if_no_peer_cert = true}} = @@ -396,15 +456,16 @@ certify(#certificate{asn1_certificates = []}, Alert = ?ALERT_REC(?FATAL,?HANDSHAKE_FAILURE), Connection:handle_own_alert(Alert, Version, certify, State); -certify(#certificate{asn1_certificates = []}, +certify(internal, #certificate{asn1_certificates = []}, #state{role = server, ssl_options = #ssl_options{verify = verify_peer, fail_if_no_peer_cert = false}} = State0, Connection) -> - {Record, State} = Connection:next_record(State0#state{client_certificate_requested = false}), - Connection:next_state(certify, certify, Record, State); + {Record, State} = + Connection:next_record(State0#state{client_certificate_requested = false}), + Connection:next_event(certify, Record, State); -certify(#certificate{} = Cert, +certify(internal, #certificate{} = Cert, #state{negotiated_version = Version, role = Role, cert_db = CertDbHandle, @@ -426,7 +487,7 @@ certify(#certificate{} = Cert, Connection:handle_own_alert(Alert, Version, certify, State) end; -certify(#server_key_exchange{exchange_keys = Keys}, +certify(internal, #server_key_exchange{exchange_keys = Keys}, #state{role = client, negotiated_version = Version, key_algorithm = Alg, public_key_info = PubKeyInfo, @@ -438,28 +499,28 @@ certify(#server_key_exchange{exchange_keys = Keys}, Alg == srp_dss; Alg == srp_rsa; Alg == srp_anon -> Params = ssl_handshake:decode_server_key(Keys, Alg, Version), + %% Use negotiated value if TLS-1.2 otherwhise return default HashSign = negotiated_hashsign(Params#server_key_params.hashsign, Alg, PubKeyInfo, Version), + case is_anonymous(Alg) of true -> calculate_secret(Params#server_key_params.params, State#state{hashsign_algorithm = HashSign}, Connection); false -> - case ssl_handshake:verify_server_key(Params, HashSign, ConnectionStates, Version, PubKeyInfo) of + case ssl_handshake:verify_server_key(Params, HashSign, + ConnectionStates, Version, PubKeyInfo) of true -> calculate_secret(Params#server_key_params.params, - State#state{hashsign_algorithm = HashSign}, Connection); + State#state{hashsign_algorithm = HashSign}, + Connection); false -> Connection:handle_own_alert(?ALERT_REC(?FATAL, ?DECRYPT_ERROR), Version, certify, State) end end; -certify(#server_key_exchange{} = Msg, - #state{role = client, key_algorithm = rsa} = State, Connection) -> - Connection:handle_unexpected_message(Msg, certify_server_keyexchange, State); - -certify(#certificate_request{hashsign_algorithms = HashSigns}, +certify(internal, #certificate_request{hashsign_algorithms = HashSigns}, #state{session = #session{own_certificate = Cert}, key_algorithm = KeyExAlg, ssl_options = #ssl_options{signature_algs = SupportedHashSigns}, @@ -470,12 +531,12 @@ certify(#certificate_request{hashsign_algorithms = HashSigns}, Connection:handle_own_alert(Alert, Version, certify, State0); NegotiatedHashSign -> {Record, State} = Connection:next_record(State0#state{client_certificate_requested = true}), - Connection:next_state(certify, certify, Record, + Connection:next_event(certify, Record, State#state{cert_hashsign_algorithm = NegotiatedHashSign}) end; %% PSK and RSA_PSK might bypass the Server-Key-Exchange -certify(#server_hello_done{}, +certify(internal, #server_hello_done{}, #state{session = #session{master_secret = undefined}, negotiated_version = Version, psk_identity = PSKIdentity, @@ -493,10 +554,10 @@ certify(#server_hello_done{}, client_certify_and_key_exchange(State, Connection) end; -certify(#server_hello_done{}, +certify(internal, #server_hello_done{}, #state{session = #session{master_secret = undefined}, ssl_options = #ssl_options{user_lookup_fun = PSKLookup}, - negotiated_version = {Major, Minor}, + negotiated_version = {Major, Minor} = Version, psk_identity = PSKIdentity, premaster_secret = undefined, role = client, @@ -504,16 +565,18 @@ certify(#server_hello_done{}, when Alg == rsa_psk -> Rand = ssl_cipher:random_bytes(?NUM_OF_PREMASTERSECRET_BYTES-2), RSAPremasterSecret = <<?BYTE(Major), ?BYTE(Minor), Rand/binary>>, - case ssl_handshake:premaster_secret({Alg, PSKIdentity}, PSKLookup, RSAPremasterSecret) of + case ssl_handshake:premaster_secret({Alg, PSKIdentity}, PSKLookup, + RSAPremasterSecret) of #alert{} = Alert -> - Alert; + Connection:handle_own_alert(Alert, Version, certify, State0); PremasterSecret -> - State = master_secret(PremasterSecret, State0#state{premaster_secret = RSAPremasterSecret}), + State = master_secret(PremasterSecret, + State0#state{premaster_secret = RSAPremasterSecret}), client_certify_and_key_exchange(State, Connection) end; %% Master secret was determined with help of server-key exchange msg -certify(#server_hello_done{}, +certify(internal, #server_hello_done{}, #state{session = #session{master_secret = MasterSecret} = Session, connection_states = ConnectionStates0, negotiated_version = Version, @@ -529,7 +592,7 @@ certify(#server_hello_done{}, end; %% Master secret is calculated from premaster_secret -certify(#server_hello_done{}, +certify(internal, #server_hello_done{}, #state{session = Session0, connection_states = ConnectionStates0, negotiated_version = Version, @@ -546,14 +609,15 @@ certify(#server_hello_done{}, Connection:handle_own_alert(Alert, Version, certify, State0) end; -certify(#client_key_exchange{} = Msg, +certify(internal = Type, #client_key_exchange{} = Msg, #state{role = server, client_certificate_requested = true, - ssl_options = #ssl_options{fail_if_no_peer_cert = true}} = State, Connection) -> + ssl_options = #ssl_options{fail_if_no_peer_cert = true}} = State, + Connection) -> %% We expect a certificate here - Connection:handle_unexpected_message(Msg, certify_client_key_exchange, State); + handle_common_event(Type, Msg, certify, State, Connection); -certify(#client_key_exchange{exchange_keys = Keys}, +certify(internal, #client_key_exchange{exchange_keys = Keys}, State = #state{key_algorithm = KeyAlg, negotiated_version = Version}, Connection) -> try certify_client_key_exchange(ssl_handshake:decode_client_key(Keys, KeyAlg, Version), @@ -563,22 +627,23 @@ certify(#client_key_exchange{exchange_keys = Keys}, Connection:handle_own_alert(Alert, Version, certify, State) end; -certify(timeout, State, _) -> - {next_state, certify, State, hibernate}; - -certify(Msg, State, Connection) -> - Connection:handle_unexpected_message(Msg, certify, State). - +certify(Type, Msg, State, Connection) -> + handle_common_event(Type, Msg, certify, State, Connection). + %%-------------------------------------------------------------------- --spec cipher(#hello_request{} | #certificate_verify{} | #finished{} | term(), +-spec cipher(gen_statem:event_type(), + #hello_request{} | #certificate_verify{} | #finished{} | term(), #state{}, tls_connection | dtls_connection) -> - gen_fsm_state_return(). + gen_statem:state_function_result(). %%-------------------------------------------------------------------- -cipher(#hello_request{}, State0, Connection) -> - {Record, State} = Connection:next_record(State0), - Connection:next_state(cipher, hello, Record, State); +cipher({call, From}, Msg, State, Connection) -> + handle_call(Msg, From, cipher, State, Connection); -cipher(#certificate_verify{signature = Signature, hashsign_algorithm = CertHashSign}, +cipher(info, Msg, State, _) -> + handle_info(Msg, cipher, State); + +cipher(internal, #certificate_verify{signature = Signature, + hashsign_algorithm = CertHashSign}, #state{role = server, key_algorithm = KexAlg, public_key_info = PublicKeyInfo, @@ -593,19 +658,20 @@ cipher(#certificate_verify{signature = Signature, hashsign_algorithm = CertHashS Version, HashSign, MasterSecret, Handshake) of valid -> {Record, State} = Connection:next_record(State0), - Connection:next_state(cipher, cipher, Record, + Connection:next_event(cipher, Record, State#state{cert_hashsign_algorithm = HashSign}); #alert{} = Alert -> Connection:handle_own_alert(Alert, Version, cipher, State0) end; %% client must send a next protocol message if we are expecting it -cipher(#finished{}, #state{role = server, expecting_next_protocol_negotiation = true, - negotiated_protocol = undefined, negotiated_version = Version} = State0, +cipher(internal, #finished{}, + #state{role = server, expecting_next_protocol_negotiation = true, + negotiated_protocol = undefined, negotiated_version = Version} = State0, Connection) -> Connection:handle_own_alert(?ALERT_REC(?FATAL,?UNEXPECTED_MESSAGE), Version, cipher, State0); -cipher(#finished{verify_data = Data} = Finished, +cipher(internal, #finished{verify_data = Data} = Finished, #state{negotiated_version = Version, host = Host, port = Port, @@ -621,109 +687,154 @@ cipher(#finished{verify_data = Data} = Finished, MasterSecret, Handshake0) of verified -> Session = register_session(Role, Host, Port, Session0), - cipher_role(Role, Data, Session, State#state{expecting_finished = false}, Connection); + cipher_role(Role, Data, Session, + State#state{expecting_finished = false}, Connection); #alert{} = Alert -> Connection:handle_own_alert(Alert, Version, cipher, State) end; %% only allowed to send next_protocol message after change cipher spec %% & before finished message and it is not allowed during renegotiation -cipher(#next_protocol{selected_protocol = SelectedProtocol}, +cipher(internal, #next_protocol{selected_protocol = SelectedProtocol}, #state{role = server, expecting_next_protocol_negotiation = true, expecting_finished = true} = State0, Connection) -> - {Record, State} = Connection:next_record(State0#state{negotiated_protocol = SelectedProtocol}), - Connection:next_state(cipher, cipher, Record, State#state{expecting_next_protocol_negotiation = false}); - -cipher(timeout, State, _) -> - {next_state, cipher, State, hibernate}; - -cipher(Msg, State, Connection) -> - Connection:handle_unexpected_message(Msg, cipher, State). + {Record, State} = + Connection:next_record(State0#state{negotiated_protocol = SelectedProtocol}), + Connection:next_event(cipher, Record, + State#state{expecting_next_protocol_negotiation = false}); +cipher(internal, #change_cipher_spec{type = <<1>>}, #state{connection_states = ConnectionStates0} = + State0, Connection) -> + ConnectionStates1 = + ssl_record:activate_pending_connection_state(ConnectionStates0, read), + {Record, State} = Connection:next_record(State0#state{connection_states = + ConnectionStates1}), + Connection:next_event(cipher, Record, State#state{expecting_finished = true}); +cipher(Type, Msg, State, Connection) -> + handle_common_event(Type, Msg, cipher, State, Connection). %%-------------------------------------------------------------------- --spec connection(term(), #state{}, tls_connection | dtls_connection) -> - gen_fsm_state_return(). +-spec connection(gen_statem:event_type(), term(), + #state{}, tls_connection | dtls_connection) -> + gen_statem:state_function_result(). %%-------------------------------------------------------------------- -connection(timeout, State, _) -> - {next_state, connection, State, hibernate}; +connection({call, From}, {application_data, Data}, + #state{protocol_cb = Connection} = State, Connection) -> + %% We should look into having a worker process to do this to + %% parallize send and receive decoding and not block the receiver + %% if sending is overloading the socket. + try + Connection:write_application_data(Data, From, State) + catch throw:Error -> + hibernate_after(connection, State, [{reply, From, Error}]) + end; +connection({call, RecvFrom}, {recv, N, Timeout}, + #state{protocol_cb = Connection, socket_options = + #socket_options{active = false}} = State0, Connection) -> + Timer = start_or_recv_cancel_timer(Timeout, RecvFrom), + Connection:passive_receive(State0#state{bytes_to_read = N, + start_or_recv_from = RecvFrom, + timer = Timer}, connection); +connection({call, From}, renegotiate, #state{protocol_cb = Connection} = State, + Connection) -> + Connection:renegotiate(State#state{renegotiation = {true, From}}, []); +connection({call, From}, peer_certificate, + #state{session = #session{peer_certificate = Cert}} = State, _) -> + hibernate_after(connection, State, [{reply, From, {ok, Cert}}]); +connection({call, From}, connection_information, State, _) -> + Info = connection_info(State), + hibernate_after(connection, State, [{reply, From, {ok, Info}}]); +connection({call, From}, session_info, #state{session = #session{session_id = Id, + cipher_suite = Suite}} = State, _) -> + SessionInfo = [{session_id, Id}, + {cipher_suite, ssl_cipher:erl_suite_definition(Suite)}], + hibernate_after(connection, State, [{reply, From, SessionInfo}]); +connection({call, From}, negotiated_protocol, + #state{negotiated_protocol = undefined} = State, _) -> + hibernate_after(connection, State, [{reply, From, {error, protocol_not_negotiated}}]); +connection({call, From}, negotiated_protocol, + #state{negotiated_protocol = SelectedProtocol} = State, _) -> + hibernate_after(connection, State, + [{reply, From, {ok, SelectedProtocol}}]); +connection({call, From}, Msg, State, Connection) -> + handle_call(Msg, From, connection, State, Connection); +connection(info, Msg, State, _) -> + handle_info(Msg, connection, State); +connection(internal, {recv, _}, State, Connection) -> + Connection:passive_receive(State, connection); +connection(Type, Msg, State, Connection) -> + handle_common_event(Type, Msg, connection, State, Connection). -connection(Msg, State, Connection) -> - Connection:handle_unexpected_message(Msg, connection, State). +%%-------------------------------------------------------------------- +-spec downgrade(gen_statem:event_type(), term(), + #state{}, tls_connection | dtls_connection) -> + gen_statem:state_function_result(). +%%-------------------------------------------------------------------- +downgrade(internal, #alert{description = ?CLOSE_NOTIFY}, + #state{transport_cb = Transport, socket = Socket, + downgrade = {Pid, From}} = State, _) -> + ssl_socket:setopts(Transport, Socket, [{active, false}, {packet, 0}, {mode, binary}]), + Transport:controlling_process(Socket, Pid), + gen_statem:reply(From, {ok, Socket}), + {stop, normal, State}; +downgrade(timeout, downgrade, #state{downgrade = {_, From}} = State, _) -> + gen_statem:reply(From, {error, timeout}), + {stop, normal, State}; +downgrade(Type, Event, State, Connection) -> + handle_common_event(Type, Event, downgrade, State, Connection). %%-------------------------------------------------------------------- -%% Description: Whenever a gen_fsm receives an event sent using -%% gen_fsm:sync_send_all_state_event/2,3, this function is called to handle -%% the event. +%% Event handling functions called by state functions to handle +%% common or unexpected events for the state. %%-------------------------------------------------------------------- -handle_sync_event({application_data, Data}, From, connection, - #state{protocol_cb = Connection} = State) -> - %% We should look into having a worker process to do this to - %% parallize send and receive decoding and not block the receiver - %% if sending is overloading the socket. - try - Connection:write_application_data(Data, From, State) - catch throw:Error -> - {reply, Error, connection, State, get_timeout(State)} +handle_common_event(internal, {tls_record, TLSRecord}, StateName, State, Connection) -> + Connection:handle_common_event(internal, TLSRecord, StateName, State); +handle_common_event(internal, #hello_request{}, StateName, #state{role = client} = State0, Connection) + when StateName =:= connection -> + {Record, State} = Connection:next_record(State0), + Connection:next_event(StateName, Record, State); +handle_common_event(timeout, hibernate, _, _, _) -> + {keep_state_and_data, [hibernate]}; +handle_common_event(internal, {application_data, Data}, StateName, State0, Connection) -> + case Connection:read_application_data(Data, State0) of + {stop, Reason, State} -> + {stop, Reason, State}; + {Record, State} -> + Connection:next_event(StateName, Record, State) end; -handle_sync_event({application_data, Data}, From, StateName, - #state{send_queue = Queue} = State) -> +handle_common_event(internal, #change_cipher_spec{type = <<1>>}, StateName, + #state{negotiated_version = Version} = State, Connection) -> + Connection:handle_own_alert(?ALERT_REC(?FATAL, ?HANDSHAKE_FAILURE), Version, + StateName, State); +handle_common_event(internal, _, _, _, _) -> + {keep_state_and_data, [postpone]}; +handle_common_event(_Type, Msg, StateName, #state{negotiated_version = Version} = State, + Connection) -> + Alert = ?ALERT_REC(?FATAL,?UNEXPECTED_MESSAGE), + Connection:handle_own_alert(Alert, Version, {StateName, Msg}, State). + +handle_call({application_data, _Data}, _, _, _, _) -> %% In renegotiation priorities handshake, send data when handshake is finished - {next_state, StateName, - State#state{send_queue = queue:in({From, Data}, Queue)}, - get_timeout(State)}; - -handle_sync_event({start, Timeout}, StartFrom, hello, #state{role = Role, - protocol_cb = Connection, - ssl_options = SSLOpts} = State0) -> - try - State = ssl_config(SSLOpts, Role, State0), - Timer = start_or_recv_cancel_timer(Timeout, StartFrom), - Connection:hello(start, State#state{start_or_recv_from = StartFrom, - timer = Timer}) - catch throw:Error -> - {stop, normal, {error, Error}, State0} - end; - -handle_sync_event({start, {Opts, EmOpts}, Timeout}, From, StateName, State) -> - try - handle_sync_event({start, Timeout}, From, StateName, State#state{socket_options = EmOpts, - ssl_options = Opts}) - catch throw:Error -> - {stop, normal, {error, Error}, State} - end; - -%% These two clauses below could happen if a server upgrades a socket in -%% active mode. Note that in this case we are lucky that -%% controlling_process has been evalueated before receiving handshake -%% messages from client. The server should put the socket in passive -%% mode before telling the client that it is willing to upgrade -%% and before calling ssl:ssl_accept/2. These clauses are -%% here to make sure it is the users problem and not owers if -%% they upgrade an active socket. -handle_sync_event({start,_}, _, connection, State) -> - {reply, connected, connection, State, get_timeout(State)}; - -handle_sync_event({start, Timeout}, StartFrom, StateName, #state{role = Role, ssl_options = SslOpts} = State0) -> - try - State = ssl_config(SslOpts, Role, State0), - Timer = start_or_recv_cancel_timer(Timeout, StartFrom), - {next_state, StateName, State#state{start_or_recv_from = StartFrom, - timer = Timer}, get_timeout(State)} - catch throw:Error -> - {stop, normal, {error, Error}, State0} - end; - -handle_sync_event({close, _} = Close, _, StateName, #state{protocol_cb = Connection} = State) -> + {keep_state_and_data, [postpone]}; +handle_call({close, {Pid, Timeout}}, From, StateName, State0, Connection) when is_pid(Pid) -> + %% terminate will send close alert to peer + State = State0#state{downgrade = {Pid, From}}, + Connection:terminate(downgrade, StateName, State), + %% User downgrades connection + %% When downgrading an TLS connection to a transport connection + %% we must recive the close alert from the peer before releasing the + %% transport socket. + {next_state, downgrade, State, [{timeout, Timeout, downgrade}]}; +handle_call({close, _} = Close, From, StateName, State, Connection) -> %% Run terminate before returning so that the reuseaddr - %% inet-option and possible downgrade will work as intended. + %% inet-option Result = Connection:terminate(Close, StateName, State), - {stop, normal, Result, State#state{terminated = true}}; - -handle_sync_event({shutdown, How0}, _, StateName, - #state{transport_cb = Transport, - negotiated_version = Version, - connection_states = ConnectionStates, - socket = Socket} = State) -> + {stop_and_reply, {shutdown, normal}, + {reply, From, Result}, State}; +handle_call({shutdown, How0}, From, _, + #state{transport_cb = Transport, + negotiated_version = Version, + connection_states = ConnectionStates, + socket = Socket}, _) -> case How0 of How when How == write; How == both -> Alert = ?ALERT_REC(?WARNING, ?CLOSE_NOTIFY), @@ -733,95 +844,91 @@ handle_sync_event({shutdown, How0}, _, StateName, _ -> ok end, - + case Transport:shutdown(Socket, How0) of ok -> - {reply, ok, StateName, State, get_timeout(State)}; + {keep_state_and_data, [{reply, From, ok}]}; Error -> - {stop, normal, Error, State} + gen_statem:reply(From, {error, Error}), + {stop, normal} end; -handle_sync_event({recv, _N, _Timeout}, _RecvFrom, StateName, - #state{socket_options = #socket_options{active = Active}} = State) when Active =/= false -> - {reply, {error, einval}, StateName, State, get_timeout(State)}; -handle_sync_event({recv, N, Timeout}, RecvFrom, connection = StateName, - #state{protocol_cb = Connection} = State0) -> - Timer = start_or_recv_cancel_timer(Timeout, RecvFrom), - Connection:passive_receive(State0#state{bytes_to_read = N, - start_or_recv_from = RecvFrom, timer = Timer}, StateName); -%% Doing renegotiate wait with handling request until renegotiate is -%% finished. Will be handled by next_state_is_connection/2. -handle_sync_event({recv, N, Timeout}, RecvFrom, StateName, State) -> +handle_call({recv, _N, _Timeout}, From, _, + #state{socket_options = + #socket_options{active = Active}}, _) when Active =/= false -> + {keep_state_and_data, [{reply, From, {error, einval}}]}; +handle_call({recv, N, Timeout}, RecvFrom, StateName, State, _) -> + %% Doing renegotiate wait with handling request until renegotiate is + %% finished. Timer = start_or_recv_cancel_timer(Timeout, RecvFrom), {next_state, StateName, State#state{bytes_to_read = N, start_or_recv_from = RecvFrom, - timer = Timer}, - get_timeout(State)}; -handle_sync_event({new_user, User}, _From, StateName, - State =#state{user_application = {OldMon, _}}) -> + timer = Timer}, + [{next_event, internal, {recv, RecvFrom}}]}; +handle_call({new_user, User}, From, StateName, + State =#state{user_application = {OldMon, _}}, _) -> NewMon = erlang:monitor(process, User), erlang:demonitor(OldMon, [flush]), - {reply, ok, StateName, State#state{user_application = {NewMon,User}}, - get_timeout(State)}; -handle_sync_event({get_opts, OptTags}, _From, StateName, + {next_state, StateName, State#state{user_application = {NewMon,User}}, + [{reply, From, ok}]}; +handle_call({get_opts, OptTags}, From, _, #state{socket = Socket, transport_cb = Transport, - socket_options = SockOpts} = State) -> + socket_options = SockOpts}, _) -> OptsReply = get_socket_opts(Transport, Socket, OptTags, SockOpts, []), - {reply, OptsReply, StateName, State, get_timeout(State)}; -handle_sync_event(negotiated_protocol, _From, StateName, #state{negotiated_protocol = undefined} = State) -> - {reply, {error, protocol_not_negotiated}, StateName, State, get_timeout(State)}; -handle_sync_event(negotiated_protocol, _From, StateName, #state{negotiated_protocol = SelectedProtocol} = State) -> - {reply, {ok, SelectedProtocol}, StateName, State, get_timeout(State)}; -handle_sync_event({set_opts, Opts0}, _From, StateName0, - #state{socket_options = Opts1, + {keep_state_and_data, [{reply, From, OptsReply}]}; +handle_call({set_opts, Opts0}, From, connection = StateName0, + #state{socket_options = Opts1, protocol_cb = Connection, socket = Socket, transport_cb = Transport, - user_data_buffer = Buffer} = State0) -> + user_data_buffer = Buffer} = State0, _) -> {Reply, Opts} = set_socket_opts(Transport, Socket, Opts0, Opts1, []), State1 = State0#state{socket_options = Opts}, if Opts#socket_options.active =:= false -> - {reply, Reply, StateName0, State1, get_timeout(State1)}; + hibernate_after(StateName0, State1, [{reply, From, Reply}]); Buffer =:= <<>>, Opts1#socket_options.active =:= false -> %% Need data, set active once {Record, State2} = Connection:next_record_if_active(State1), %% Note: Renogotiation may cause StateName0 =/= StateName - case Connection:next_state(StateName0, StateName0, Record, State2) of - {next_state, StateName, State, Timeout} -> - {reply, Reply, StateName, State, Timeout}; + case Connection:next_event(StateName0, Record, State2) of + {next_state, StateName, State} -> + hibernate_after(StateName, State, [{reply, From, Reply}]); + {next_state, StateName, State, Actions} -> + hibernate_after(StateName, State, [{reply, From, Reply} | Actions]); {stop, Reason, State} -> {stop, Reason, State} end; Buffer =:= <<>> -> %% Active once already set - {reply, Reply, StateName0, State1, get_timeout(State1)}; + hibernate_after(StateName0, State1, [{reply, From, Reply}]); true -> case Connection:read_application_data(<<>>, State1) of - Stop = {stop,_,_} -> - Stop; + {stop, Reason, State} -> + {stop, Reason, State}; {Record, State2} -> %% Note: Renogotiation may cause StateName0 =/= StateName - case Connection:next_state(StateName0, StateName0, Record, State2) of - {next_state, StateName, State, Timeout} -> - {reply, Reply, StateName, State, Timeout}; - {stop, Reason, State} -> - {stop, Reason, State} + case Connection:next_event(StateName0, Record, State2) of + {next_state, StateName, State} -> + hibernate_after(StateName, State, [{reply, From, Reply}]); + {next_state, StateName, State, Actions} -> + hibernate_after(StateName, State, [{reply, From, Reply} | Actions]); + {stop, _, _} = Stop -> + Stop end end end; -handle_sync_event(renegotiate, From, connection, #state{protocol_cb = Connection} = State) -> - Connection:renegotiate(State#state{renegotiation = {true, From}}); -handle_sync_event(renegotiate, _, StateName, State) -> - {reply, {error, already_renegotiating}, StateName, State, get_timeout(State)}; -handle_sync_event({prf, Secret, Label, Seed, WantedLength}, _, StateName, - #state{connection_states = ConnectionStates, - negotiated_version = Version} = State) -> +handle_call(renegotiate, From, StateName, _, _) when StateName =/= connection -> + {keep_state_and_data, [{reply, From, {error, already_renegotiating}}]}; +handle_call({prf, Secret, Label, Seed, WantedLength}, From, _, + #state{connection_states = ConnectionStates, + negotiated_version = Version}, _) -> ConnectionState = ssl_record:current_connection_state(ConnectionStates, read), SecParams = ConnectionState#connection_state.security_parameters, #security_parameters{master_secret = MasterSecret, client_random = ClientRandom, - server_random = ServerRandom} = SecParams, + server_random = ServerRandom, + prf_algorithm = PRFAlgorithm} = SecParams, Reply = try SecretToUse = case Secret of _ when is_binary(Secret) -> Secret; @@ -832,32 +939,14 @@ handle_sync_event({prf, Secret, Label, Seed, WantedLength}, _, StateName, (client_random, Acc) -> [ClientRandom|Acc]; (server_random, Acc) -> [ServerRandom|Acc] end, [], Seed)), - ssl_handshake:prf(Version, SecretToUse, Label, SeedToUse, WantedLength) + ssl_handshake:prf(Version, PRFAlgorithm, SecretToUse, Label, SeedToUse, WantedLength) catch exit:_ -> {error, badarg}; error:Reason -> {error, Reason} end, - {reply, Reply, StateName, State, get_timeout(State)}; -handle_sync_event(session_info, _, StateName, - #state{session = #session{session_id = Id, - cipher_suite = Suite}} = State) -> - {reply, [{session_id, Id}, - {cipher_suite, ssl_cipher:erl_suite_definition(Suite)}], - StateName, State, get_timeout(State)}; -handle_sync_event(peer_certificate, _, StateName, - #state{session = #session{peer_certificate = Cert}} - = State) -> - {reply, {ok, Cert}, StateName, State, get_timeout(State)}; -handle_sync_event(connection_information, _, StateName, State) -> - Info = connection_info(State), - {reply, {ok, Info}, StateName, State, get_timeout(State)}. - -connection_info(#state{sni_hostname = SNIHostname, - session = #session{cipher_suite = CipherSuite}, - negotiated_version = Version, ssl_options = Opts}) -> - [{protocol, tls_record:protocol_version(Version)}, - {cipher_suite, ssl_cipher:erl_suite_definition(CipherSuite)}, - {sni_hostname, SNIHostname}] ++ ssl_options_list(Opts). + {keep_state_and_data, [{reply, From, Reply}]}; +handle_call(_,_,_,_,_) -> + {keep_state_and_data, [postpone]}. handle_info({ErrorTag, Socket, econnaborted}, StateName, #state{socket = Socket, transport_cb = Transport, @@ -865,7 +954,8 @@ handle_info({ErrorTag, Socket, econnaborted}, StateName, protocol_cb = Connection, error_tag = ErrorTag, tracker = Tracker} = State) when StateName =/= connection -> - Connection:alert_user(Transport, Tracker,Socket, StartFrom, ?ALERT_REC(?FATAL, ?CLOSE_NOTIFY), Role), + Connection:alert_user(Transport, Tracker,Socket, + StartFrom, ?ALERT_REC(?FATAL, ?CLOSE_NOTIFY), Role), {stop, normal, State}; handle_info({ErrorTag, Socket, Reason}, StateName, #state{socket = Socket, @@ -888,47 +978,46 @@ handle_info({'EXIT', Socket, normal}, _StateName, #state{socket = Socket} = Stat {stop, {shutdown, transport_closed}, State}; handle_info(allow_renegotiate, StateName, State) -> - {next_state, StateName, State#state{allow_renegotiate = true}, get_timeout(State)}; + {next_state, StateName, State#state{allow_renegotiate = true}}; handle_info({cancel_start_or_recv, StartFrom}, StateName, #state{renegotiation = {false, first}} = State) when StateName =/= connection -> - gen_fsm:reply(StartFrom, {error, timeout}), - {stop, {shutdown, user_timeout}, State#state{timer = undefined}}; + {stop_and_reply, {shutdown, user_timeout}, + {reply, StartFrom, {error, timeout}}, State#state{timer = undefined}}; -handle_info({cancel_start_or_recv, RecvFrom}, StateName, #state{start_or_recv_from = RecvFrom} = State) -> - gen_fsm:reply(RecvFrom, {error, timeout}), +handle_info({cancel_start_or_recv, RecvFrom}, StateName, + #state{start_or_recv_from = RecvFrom} = State) when RecvFrom =/= undefined -> {next_state, StateName, State#state{start_or_recv_from = undefined, bytes_to_read = undefined, - timer = undefined}, get_timeout(State)}; + timer = undefined}, [{reply, RecvFrom, {error, timeout}}]}; handle_info({cancel_start_or_recv, _RecvFrom}, StateName, State) -> - {next_state, StateName, State#state{timer = undefined}, get_timeout(State)}; + {next_state, StateName, State#state{timer = undefined}}; handle_info(Msg, StateName, #state{socket = Socket, error_tag = Tag} = State) -> Report = io_lib:format("SSL: Got unexpected info: ~p ~n", [{Msg, Tag, Socket}]), error_logger:info_report(Report), - {next_state, StateName, State, get_timeout(State)}. - + {next_state, StateName, State}. +%%-------------------------------------------------------------------- +%% gen_statem callbacks +%%-------------------------------------------------------------------- terminate(_, _, #state{terminated = true}) -> %% Happens when user closes the connection using ssl:close/1 %% we want to guarantee that Transport:close has been called %% when ssl:close/1 returns. ok; + terminate({shutdown, transport_closed} = Reason, - _StateName, #state{send_queue = SendQueue, protocol_cb = Connection, - socket = Socket, transport_cb = Transport, - renegotiation = Renegotiate} = State) -> + _StateName, #state{protocol_cb = Connection, + socket = Socket, transport_cb = Transport} = State) -> handle_trusted_certs_db(State), - notify_senders(SendQueue), - notify_renegotiater(Renegotiate), Connection:close(Reason, Socket, Transport, undefined, undefined); -terminate({shutdown, own_alert}, _StateName, #state{send_queue = SendQueue, protocol_cb = Connection, - socket = Socket, transport_cb = Transport, - renegotiation = Renegotiate} = State) -> +terminate({shutdown, own_alert}, _StateName, #state{%%send_queue = SendQueue, + protocol_cb = Connection, + socket = Socket, + transport_cb = Transport} = State) -> handle_trusted_certs_db(State), - notify_senders(SendQueue), - notify_renegotiater(Renegotiate), case application:get_env(ssl, alert_timeout) of {ok, Timeout} when is_integer(Timeout) -> Connection:close({timeout, Timeout}, Socket, Transport, undefined, undefined); @@ -939,26 +1028,22 @@ terminate(Reason, connection, #state{negotiated_version = Version, protocol_cb = Connection, connection_states = ConnectionStates0, ssl_options = #ssl_options{padding_check = Check}, - transport_cb = Transport, socket = Socket, - send_queue = SendQueue, renegotiation = Renegotiate} = State) -> + transport_cb = Transport, socket = Socket + } = State) -> handle_trusted_certs_db(State), - notify_senders(SendQueue), - notify_renegotiater(Renegotiate), {BinAlert, ConnectionStates} = terminate_alert(Reason, Version, ConnectionStates0), Transport:send(Socket, BinAlert), Connection:close(Reason, Socket, Transport, ConnectionStates, Check); terminate(Reason, _StateName, #state{transport_cb = Transport, protocol_cb = Connection, - socket = Socket, send_queue = SendQueue, - renegotiation = Renegotiate} = State) -> + socket = Socket + } = State) -> handle_trusted_certs_db(State), - notify_senders(SendQueue), - notify_renegotiater(Renegotiate), Connection:close(Reason, Socket, Transport, undefined, undefined). -format_status(normal, [_, State]) -> - [{data, [{"StateData", State}]}]; -format_status(terminate, [_, State]) -> +format_status(normal, [_, StateName, State]) -> + [{data, [{"State", {StateName, State}}]}]; +format_status(terminate, [_, StateName, State]) -> SslOptions = (State#state.ssl_options), NewOptions = SslOptions#ssl_options{password = ?SECRET_PRINTOUT, cert = ?SECRET_PRINTOUT, @@ -967,39 +1052,29 @@ format_status(terminate, [_, State]) -> dh = ?SECRET_PRINTOUT, psk_identity = ?SECRET_PRINTOUT, srp_identity = ?SECRET_PRINTOUT}, - [{data, [{"StateData", State#state{connection_states = ?SECRET_PRINTOUT, - protocol_buffers = ?SECRET_PRINTOUT, - user_data_buffer = ?SECRET_PRINTOUT, - tls_handshake_history = ?SECRET_PRINTOUT, - session = ?SECRET_PRINTOUT, - private_key = ?SECRET_PRINTOUT, - diffie_hellman_params = ?SECRET_PRINTOUT, - diffie_hellman_keys = ?SECRET_PRINTOUT, - srp_params = ?SECRET_PRINTOUT, - srp_keys = ?SECRET_PRINTOUT, - premaster_secret = ?SECRET_PRINTOUT, - ssl_options = NewOptions - }}]}]. + [{data, [{"State", {StateName, State#state{connection_states = ?SECRET_PRINTOUT, + protocol_buffers = ?SECRET_PRINTOUT, + user_data_buffer = ?SECRET_PRINTOUT, + tls_handshake_history = ?SECRET_PRINTOUT, + session = ?SECRET_PRINTOUT, + private_key = ?SECRET_PRINTOUT, + diffie_hellman_params = ?SECRET_PRINTOUT, + diffie_hellman_keys = ?SECRET_PRINTOUT, + srp_params = ?SECRET_PRINTOUT, + srp_keys = ?SECRET_PRINTOUT, + premaster_secret = ?SECRET_PRINTOUT, + ssl_options = NewOptions} + }}]}]. + %%-------------------------------------------------------------------- %%% Internal functions %%-------------------------------------------------------------------- -ssl_config(Opts, Role, State) -> - {ok, Ref, CertDbHandle, FileRefHandle, CacheHandle, CRLDbInfo, OwnCert, Key, DHParams} = - ssl_config:init(Opts, Role), - Handshake = ssl_handshake:init_handshake_history(), - TimeStamp = erlang:monotonic_time(), - Session = State#state.session, - State#state{tls_handshake_history = Handshake, - session = Session#session{own_certificate = OwnCert, - time_stamp = TimeStamp}, - file_ref_db = FileRefHandle, - cert_db_ref = Ref, - cert_db = CertDbHandle, - crl_db = CRLDbInfo, - session_cache = CacheHandle, - private_key = Key, - diffie_hellman_params = DHParams, - ssl_options = Opts}. +connection_info(#state{sni_hostname = SNIHostname, + session = #session{cipher_suite = CipherSuite}, + negotiated_version = Version, ssl_options = Opts}) -> + [{protocol, tls_record:protocol_version(Version)}, + {cipher_suite, ssl_cipher:erl_suite_definition(CipherSuite)}, + {sni_hostname, SNIHostname}] ++ ssl_options_list(Opts). do_server_hello(Type, #hello_extensions{next_protocol_negotiation = NextProtocols} = ServerHelloExt, @@ -1033,7 +1108,7 @@ new_server_hello(#server_hello{cipher_suite = CipherSuite, cipher_suite = CipherSuite, compression_method = Compression}, {Record, State} = Connection:next_record(State2#state{session = Session}), - Connection:next_state(hello, certify, Record, State) + Connection:next_event(certify, Record, State) catch #alert{} = Alert -> Connection:handle_own_alert(Alert, Version, hello, State0) @@ -1051,7 +1126,7 @@ resumed_server_hello(#state{session = Session, State2 = finalize_handshake(State1, abbreviated, Connection), {Record, State} = Connection:next_record(State2), - Connection:next_state(hello, abbreviated, Record, State); + Connection:next_event(abbreviated, Record, State); #alert{} = Alert -> Connection:handle_own_alert(Alert, Version, hello, State0) end. @@ -1076,7 +1151,7 @@ handle_peer_cert(Role, PeerCert, PublicKeyInfo, State2 = handle_peer_cert_key(Role, PeerCert, PublicKeyInfo, KeyAlg, State1), {Record, State} = Connection:next_record(State2), - Connection:next_state(certify, certify, Record, State). + Connection:next_event(certify, Record, State). handle_peer_cert_key(client, _, {?'id-ecPublicKey', #'ECPoint'{point = _ECPoint} = PublicKey, @@ -1139,7 +1214,7 @@ client_certify_and_key_exchange(#state{negotiated_version = Version} = %% Reinitialize client_certificate_requested = false}, {Record, State} = Connection:next_record(State3), - Connection:next_state(certify, cipher, Record, State) + Connection:next_event(cipher, Record, State) catch throw:#alert{} = Alert -> Connection:handle_own_alert(Alert, Version, certify, State0) @@ -1173,20 +1248,25 @@ certify_client_key_exchange(#client_ec_diffie_hellman_public{dh_public = ClientP calculate_master_secret(PremasterSecret, State, Connection, certify, cipher); certify_client_key_exchange(#client_psk_identity{} = ClientKey, - #state{ssl_options = #ssl_options{user_lookup_fun = PSKLookup}} = State0, Connection) -> + #state{ssl_options = + #ssl_options{user_lookup_fun = PSKLookup}} = State0, + Connection) -> PremasterSecret = ssl_handshake:premaster_secret(ClientKey, PSKLookup), calculate_master_secret(PremasterSecret, State0, Connection, certify, cipher); certify_client_key_exchange(#client_dhe_psk_identity{} = ClientKey, #state{diffie_hellman_params = #'DHParameter'{} = Params, diffie_hellman_keys = {_, ServerDhPrivateKey}, - ssl_options = #ssl_options{user_lookup_fun = PSKLookup}} = State0, + ssl_options = + #ssl_options{user_lookup_fun = PSKLookup}} = State0, Connection) -> - PremasterSecret = ssl_handshake:premaster_secret(ClientKey, ServerDhPrivateKey, Params, PSKLookup), + PremasterSecret = + ssl_handshake:premaster_secret(ClientKey, ServerDhPrivateKey, Params, PSKLookup), calculate_master_secret(PremasterSecret, State0, Connection, certify, cipher); certify_client_key_exchange(#client_rsa_psk_identity{} = ClientKey, #state{private_key = Key, - ssl_options = #ssl_options{user_lookup_fun = PSKLookup}} = State0, + ssl_options = + #ssl_options{user_lookup_fun = PSKLookup}} = State0, Connection) -> PremasterSecret = ssl_handshake:premaster_secret(ClientKey, Key, PSKLookup), calculate_master_secret(PremasterSecret, State0, Connection, certify, cipher); @@ -1198,8 +1278,11 @@ certify_client_key_exchange(#client_srp_public{} = ClientKey, PremasterSecret = ssl_handshake:premaster_secret(ClientKey, Key, Params), calculate_master_secret(PremasterSecret, State0, Connection, certify, cipher). -certify_server(#state{key_algorithm = Algo} = State, _) - when Algo == dh_anon; Algo == ecdh_anon; Algo == psk; Algo == dhe_psk; Algo == srp_anon -> +certify_server(#state{key_algorithm = Algo} = State, _) when Algo == dh_anon; + Algo == ecdh_anon; + Algo == psk; + Algo == dhe_psk; + Algo == srp_anon -> State; certify_server(#state{cert_db = CertDbHandle, @@ -1297,10 +1380,11 @@ key_exchange(#state{role = server, key_algorithm = dhe_psk, SecParams = ConnectionState#connection_state.security_parameters, #security_parameters{client_random = ClientRandom, server_random = ServerRandom} = SecParams, - Msg = ssl_handshake:key_exchange(server, Version, {dhe_psk, PskIdentityHint, DHKeys, Params, - HashSignAlgo, ClientRandom, - ServerRandom, - PrivateKey}), + Msg = ssl_handshake:key_exchange(server, Version, {dhe_psk, + PskIdentityHint, DHKeys, Params, + HashSignAlgo, ClientRandom, + ServerRandom, + PrivateKey}), State = Connection:send_handshake(Msg, State0), State#state{diffie_hellman_keys = DHKeys}; @@ -1389,7 +1473,8 @@ key_exchange(#state{role = client, ssl_options = SslOpts, key_algorithm = psk, negotiated_version = Version} = State0, Connection) -> - Msg = ssl_handshake:key_exchange(client, Version, {psk, SslOpts#ssl_options.psk_identity}), + Msg = ssl_handshake:key_exchange(client, Version, + {psk, SslOpts#ssl_options.psk_identity}), Connection:send_handshake(Msg, State0); key_exchange(#state{role = client, @@ -1398,7 +1483,8 @@ key_exchange(#state{role = client, negotiated_version = Version, diffie_hellman_keys = {DhPubKey, _}} = State0, Connection) -> Msg = ssl_handshake:key_exchange(client, Version, - {dhe_psk, SslOpts#ssl_options.psk_identity, DhPubKey}), + {dhe_psk, + SslOpts#ssl_options.psk_identity, DhPubKey}), Connection:send_handshake(Msg, State0); key_exchange(#state{role = client, ssl_options = SslOpts, @@ -1438,7 +1524,8 @@ rsa_key_exchange(Version, PremasterSecret, PublicKeyInfo = {Algorithm, _, _}) rsa_key_exchange(_, _, _) -> throw (?ALERT_REC(?FATAL,?HANDSHAKE_FAILURE)). -rsa_psk_key_exchange(Version, PskIdentity, PremasterSecret, PublicKeyInfo = {Algorithm, _, _}) +rsa_psk_key_exchange(Version, PskIdentity, PremasterSecret, + PublicKeyInfo = {Algorithm, _, _}) when Algorithm == ?rsaEncryption; Algorithm == ?md2WithRSAEncryption; Algorithm == ?md5WithRSAEncryption; @@ -1473,10 +1560,11 @@ request_client_cert(#state{ssl_options = #ssl_options{verify = verify_none}} = State, _) -> State. -calculate_master_secret(PremasterSecret, #state{negotiated_version = Version, - connection_states = ConnectionStates0, - session = Session0} = State0, Connection, - Current, Next) -> +calculate_master_secret(PremasterSecret, + #state{negotiated_version = Version, + connection_states = ConnectionStates0, + session = Session0} = State0, Connection, + _Current, Next) -> case ssl_handshake:master_secret(record_cb(Connection), Version, PremasterSecret, ConnectionStates0, server) of {MasterSecret, ConnectionStates} -> @@ -1484,7 +1572,7 @@ calculate_master_secret(PremasterSecret, #state{negotiated_version = Version, State1 = State0#state{connection_states = ConnectionStates, session = Session}, {Record, State} = Connection:next_record(State1), - Connection:next_state(Current, Next, Record, State); + Connection:next_event(Next, Record, State); #alert{} = Alert -> Connection:handle_own_alert(Alert, Version, certify, State0) end. @@ -1535,31 +1623,36 @@ save_verify_data(client, #finished{verify_data = Data}, ConnectionStates, abbrev save_verify_data(server, #finished{verify_data = Data}, ConnectionStates, abbreviated) -> ssl_record:set_server_verify_data(current_write, Data, ConnectionStates). -calculate_secret(#server_dh_params{dh_p = Prime, dh_g = Base, dh_y = ServerPublicDhKey} = Params, - State, Connection) -> +calculate_secret(#server_dh_params{dh_p = Prime, dh_g = Base, + dh_y = ServerPublicDhKey} = Params, + State, Connection) -> Keys = {_, PrivateDhKey} = crypto:generate_key(dh, [Prime, Base]), PremasterSecret = ssl_handshake:premaster_secret(ServerPublicDhKey, PrivateDhKey, Params), calculate_master_secret(PremasterSecret, - State#state{diffie_hellman_keys = Keys}, Connection, certify, certify); + State#state{diffie_hellman_keys = Keys}, + Connection, certify, certify); calculate_secret(#server_ecdh_params{curve = ECCurve, public = ECServerPubKey}, State, Connection) -> ECDHKeys = public_key:generate_key(ECCurve), - PremasterSecret = ssl_handshake:premaster_secret(#'ECPoint'{point = ECServerPubKey}, ECDHKeys), + PremasterSecret = + ssl_handshake:premaster_secret(#'ECPoint'{point = ECServerPubKey}, ECDHKeys), calculate_master_secret(PremasterSecret, - State#state{diffie_hellman_keys = ECDHKeys}, Connection, certify, certify); + State#state{diffie_hellman_keys = ECDHKeys}, + Connection, certify, certify); calculate_secret(#server_psk_params{ - hint = IdentityHint}, + hint = IdentityHint}, State0, Connection) -> %% store for later use {Record, State} = Connection:next_record(State0#state{psk_identity = IdentityHint}), - Connection:next_state(certify, certify, Record, State); + Connection:next_event(certify, Record, State); calculate_secret(#server_dhe_psk_params{ dh_params = #server_dh_params{dh_p = Prime, dh_g = Base}} = ServerKey, - #state{ssl_options = #ssl_options{user_lookup_fun = PSKLookup}} = State, Connection) -> + #state{ssl_options = #ssl_options{user_lookup_fun = PSKLookup}} = + State, Connection) -> Keys = {_, PrivateDhKey} = crypto:generate_key(dh, [Prime, Base]), PremasterSecret = ssl_handshake:premaster_secret(ServerKey, PrivateDhKey, PSKLookup), @@ -1567,10 +1660,12 @@ calculate_secret(#server_dhe_psk_params{ Connection, certify, certify); calculate_secret(#server_srp_params{srp_n = Prime, srp_g = Generator} = ServerKey, - #state{ssl_options = #ssl_options{srp_identity = SRPId}} = State, Connection) -> + #state{ssl_options = #ssl_options{srp_identity = SRPId}} = State, + Connection) -> Keys = generate_srp_client_keys(Generator, Prime, 0), PremasterSecret = ssl_handshake:premaster_secret(ServerKey, Keys, SRPId), - calculate_master_secret(PremasterSecret, State#state{srp_keys = Keys}, Connection, certify, certify). + calculate_master_secret(PremasterSecret, State#state{srp_keys = Keys}, Connection, + certify, certify). master_secret(#alert{} = Alert, _) -> Alert; @@ -1626,21 +1721,23 @@ handle_srp_identity(Username, {Fun, UserState}) -> end. -cipher_role(client, Data, Session, #state{connection_states = ConnectionStates0} = State, +cipher_role(client, Data, Session, #state{connection_states = ConnectionStates0} = State0, Connection) -> - ConnectionStates = ssl_record:set_server_verify_data(current_both, Data, ConnectionStates0), - Connection:next_state_connection(cipher, - ack_connection( - State#state{session = Session, - connection_states = ConnectionStates})); - + ConnectionStates = ssl_record:set_server_verify_data(current_both, Data, + ConnectionStates0), + {Record, State} = prepare_connection(State0#state{session = Session, + connection_states = ConnectionStates}, + Connection), + Connection:next_event(connection, Record, State); cipher_role(server, Data, Session, #state{connection_states = ConnectionStates0} = State0, Connection) -> - ConnectionStates1 = ssl_record:set_client_verify_data(current_read, Data, ConnectionStates0), - State = + ConnectionStates1 = ssl_record:set_client_verify_data(current_read, Data, + ConnectionStates0), + State1 = finalize_handshake(State0#state{connection_states = ConnectionStates1, session = Session}, cipher, Connection), - Connection:next_state_connection(cipher, ack_connection(State#state{session = Session})). + {Record, State} = prepare_connection(State1, Connection), + Connection:next_event(connection, Record, State). select_curve(#state{client_ecc = {[Curve|_], _}}) -> {namedCurve, Curve}; @@ -1674,8 +1771,8 @@ record_cb(tls_connection) -> record_cb(dtls_connection) -> dtls_record. -sync_send_all_state_event(FsmPid, Event) -> - try gen_fsm:sync_send_all_state_event(FsmPid, Event, infinity) +call(FsmPid, Event) -> + try gen_statem:call(FsmPid, Event) catch exit:{noproc, _} -> {error, closed}; @@ -1731,38 +1828,42 @@ set_socket_opts(Transport, Socket, [], SockOpts, Other) -> {{error, {options, {socket_options, Other, Error}}}, SockOpts} end; -set_socket_opts(Transport,Socket, [{mode, Mode}| Opts], SockOpts, Other) when Mode == list; Mode == binary -> +set_socket_opts(Transport,Socket, [{mode, Mode}| Opts], SockOpts, Other) + when Mode == list; Mode == binary -> set_socket_opts(Transport, Socket, Opts, SockOpts#socket_options{mode = Mode}, Other); set_socket_opts(_, _, [{mode, _} = Opt| _], SockOpts, _) -> {{error, {options, {socket_options, Opt}}}, SockOpts}; -set_socket_opts(Transport,Socket, [{packet, Packet}| Opts], SockOpts, Other) when Packet == raw; - Packet == 0; - Packet == 1; - Packet == 2; - Packet == 4; - Packet == asn1; - Packet == cdr; - Packet == sunrm; - Packet == fcgi; - Packet == tpkt; - Packet == line; - Packet == http; - Packet == httph; - Packet == http_bin; - Packet == httph_bin -> +set_socket_opts(Transport,Socket, [{packet, Packet}| Opts], SockOpts, Other) + when Packet == raw; + Packet == 0; + Packet == 1; + Packet == 2; + Packet == 4; + Packet == asn1; + Packet == cdr; + Packet == sunrm; + Packet == fcgi; + Packet == tpkt; + Packet == line; + Packet == http; + Packet == httph; + Packet == http_bin; + Packet == httph_bin -> set_socket_opts(Transport, Socket, Opts, SockOpts#socket_options{packet = Packet}, Other); set_socket_opts(_, _, [{packet, _} = Opt| _], SockOpts, _) -> {{error, {options, {socket_options, Opt}}}, SockOpts}; -set_socket_opts(Transport, Socket, [{header, Header}| Opts], SockOpts, Other) when is_integer(Header) -> +set_socket_opts(Transport, Socket, [{header, Header}| Opts], SockOpts, Other) + when is_integer(Header) -> set_socket_opts(Transport, Socket, Opts, SockOpts#socket_options{header = Header}, Other); set_socket_opts(_, _, [{header, _} = Opt| _], SockOpts, _) -> {{error,{options, {socket_options, Opt}}}, SockOpts}; -set_socket_opts(Transport, Socket, [{active, Active}| Opts], SockOpts, Other) when Active == once; - Active == true; - Active == false -> +set_socket_opts(Transport, Socket, [{active, Active}| Opts], SockOpts, Other) + when Active == once; + Active == true; + Active == false -> set_socket_opts(Transport, Socket, Opts, SockOpts#socket_options{active = Active}, Other); set_socket_opts(_, _, [{active, _} = Opt| _], SockOpts, _) -> @@ -1775,11 +1876,10 @@ start_or_recv_cancel_timer(infinity, _RecvFrom) -> start_or_recv_cancel_timer(Timeout, RecvFrom) -> erlang:send_after(Timeout, self(), {cancel_start_or_recv, RecvFrom}). -get_timeout(#state{ssl_options=#ssl_options{hibernate_after = undefined}}) -> - infinity; -get_timeout(#state{ssl_options=#ssl_options{hibernate_after = HibernateAfter}}) -> - HibernateAfter. - +hibernate_after(StateName, #state{ssl_options=#ssl_options{hibernate_after = HibernateAfter}} = State, + Actions) -> + {next_state, StateName, State, [{timeout, HibernateAfter, hibernate} | Actions]}. + terminate_alert(normal, Version, ConnectionStates) -> ssl_alert:encode(?ALERT_REC(?WARNING, ?CLOSE_NOTIFY), Version, ConnectionStates); @@ -1789,10 +1889,12 @@ terminate_alert({Reason, _}, Version, ConnectionStates) when Reason == close; Version, ConnectionStates); terminate_alert(_, Version, ConnectionStates) -> - ssl_alert:encode(?ALERT_REC(?FATAL, ?INTERNAL_ERROR), - Version, ConnectionStates). + {BinAlert, _} = ssl_alert:encode(?ALERT_REC(?FATAL, ?INTERNAL_ERROR), + Version, ConnectionStates), + BinAlert. -handle_trusted_certs_db(#state{ssl_options = #ssl_options{cacertfile = <<>>, cacerts = []}}) -> +handle_trusted_certs_db(#state{ssl_options = + #ssl_options{cacertfile = <<>>, cacerts = []}}) -> %% No trusted certs specified ok; handle_trusted_certs_db(#state{cert_db_ref = Ref, @@ -1802,7 +1904,8 @@ handle_trusted_certs_db(#state{cert_db_ref = Ref, %% with other connections and it is safe to delete them when the connection ends. ssl_pkix_db:remove_trusted_certs(Ref, CertDb); handle_trusted_certs_db(#state{file_ref_db = undefined}) -> - %% Something went wrong early (typically cacertfile does not exist) so there is nothing to handle + %% Something went wrong early (typically cacertfile does not + %% exist) so there is nothing to handle ok; handle_trusted_certs_db(#state{cert_db_ref = Ref, file_ref_db = RefDb, @@ -1814,29 +1917,31 @@ handle_trusted_certs_db(#state{cert_db_ref = Ref, ok end. -notify_senders(SendQueue) -> - lists:foreach(fun({From, _}) -> - gen_fsm:reply(From, {error, closed}) - end, queue:to_list(SendQueue)). - -notify_renegotiater({true, From}) when not is_atom(From) -> - gen_fsm:reply(From, {error, closed}); -notify_renegotiater(_) -> - ok. +prepare_connection(#state{renegotiation = Renegotiate, + start_or_recv_from = RecvFrom} = State0, Connection) + when Renegotiate =/= {false, first}, + RecvFrom =/= undefined -> + State1 = Connection:reinit_handshake_data(State0), + {Record, State} = Connection:next_record(State1), + {Record, ack_connection(State)}; +prepare_connection(State0, Connection) -> + State = Connection:reinit_handshake_data(State0), + {no_record, ack_connection(State)}. ack_connection(#state{renegotiation = {true, Initiater}} = State) when Initiater == internal; Initiater == peer -> State#state{renegotiation = undefined}; ack_connection(#state{renegotiation = {true, From}} = State) -> - gen_fsm:reply(From, ok), + gen_statem:reply(From, ok), State#state{renegotiation = undefined}; ack_connection(#state{renegotiation = {false, first}, start_or_recv_from = StartFrom, timer = Timer} = State) when StartFrom =/= undefined -> - gen_fsm:reply(StartFrom, connected), + gen_statem:reply(StartFrom, connected), cancel_timer(Timer), - State#state{renegotiation = undefined, start_or_recv_from = undefined, timer = undefined}; + State#state{renegotiation = undefined, + start_or_recv_from = undefined, timer = undefined}; ack_connection(State) -> State. @@ -1857,13 +1962,14 @@ register_session(server, _, Port, #session{is_resumable = new} = Session0) -> register_session(_, _, _, Session) -> Session. %% Already registered -handle_new_session(NewId, CipherSuite, Compression, #state{session = Session0, - protocol_cb = Connection} = State0) -> +handle_new_session(NewId, CipherSuite, Compression, + #state{session = Session0, + protocol_cb = Connection} = State0) -> Session = Session0#session{session_id = NewId, cipher_suite = CipherSuite, compression_method = Compression}, {Record, State} = Connection:next_record(State0#state{session = Session}), - Connection:next_state(hello, certify, Record, State). + Connection:next_event(certify, Record, State). handle_resumed_session(SessId, #state{connection_states = ConnectionStates0, negotiated_version = Version, @@ -1879,7 +1985,7 @@ handle_resumed_session(SessId, #state{connection_states = ConnectionStates0, Connection:next_record(State0#state{ connection_states = ConnectionStates, session = Session}), - Connection:next_state(hello, abbreviated, Record, State); + Connection:next_event(abbreviated, Record, State); #alert{} = Alert -> Connection:handle_own_alert(Alert, Version, hello, State0) end. diff --git a/lib/ssl/src/ssl_connection.hrl b/lib/ssl/src/ssl_connection.hrl index bb41ef2b62..7682cb86ea 100644 --- a/lib/ssl/src/ssl_connection.hrl +++ b/lib/ssl/src/ssl_connection.hrl @@ -75,7 +75,7 @@ renegotiation :: undefined | {boolean(), From::term() | internal | peer}, start_or_recv_from :: term(), timer :: undefined | reference(), % start_or_recive_timer - send_queue :: queue:queue(), + %%send_queue :: queue:queue(), terminated = false ::boolean(), allow_renegotiate = true ::boolean(), expecting_next_protocol_negotiation = false ::boolean(), @@ -83,7 +83,8 @@ negotiated_protocol = undefined :: undefined | binary(), client_ecc, % {Curves, PointFmt} tracker :: pid() | 'undefined', %% Tracker process for listen socket - sni_hostname = undefined + sni_hostname = undefined, + downgrade }). -define(DEFAULT_DIFFIE_HELLMAN_PARAMS, diff --git a/lib/ssl/src/ssl_handshake.erl b/lib/ssl/src/ssl_handshake.erl index 2a2a7b7d25..598d4e4112 100644 --- a/lib/ssl/src/ssl_handshake.erl +++ b/lib/ssl/src/ssl_handshake.erl @@ -74,7 +74,7 @@ ]). %% MISC --export([select_version/3, prf/5, select_hashsign/5, +-export([select_version/3, prf/6, select_hashsign/5, select_hashsign_algs/3, premaster_secret/2, premaster_secret/3, premaster_secret/4]). @@ -564,17 +564,15 @@ server_key_exchange_hash(md5sha, Value) -> server_key_exchange_hash(Hash, Value) -> crypto:hash(Hash, Value). %%-------------------------------------------------------------------- --spec prf(ssl_record:ssl_version(), binary(), binary(), [binary()], non_neg_integer()) -> +-spec prf(ssl_record:ssl_version(), non_neg_integer(), binary(), binary(), [binary()], non_neg_integer()) -> {ok, binary()} | {error, undefined}. %% %% Description: use the TLS PRF to generate key material %%-------------------------------------------------------------------- -prf({3,0}, _, _, _, _) -> +prf({3,0}, _, _, _, _, _) -> {error, undefined}; -prf({3,1}, Secret, Label, Seed, WantedLength) -> - {ok, tls_v1:prf(?MD5SHA, Secret, Label, Seed, WantedLength)}; -prf({3,_N}, Secret, Label, Seed, WantedLength) -> - {ok, tls_v1:prf(?SHA256, Secret, Label, Seed, WantedLength)}. +prf({3,_N}, PRFAlgo, Secret, Label, Seed, WantedLength) -> + {ok, tls_v1:prf(PRFAlgo, Secret, Label, Seed, WantedLength)}. %%-------------------------------------------------------------------- diff --git a/lib/ssl/src/ssl_internal.hrl b/lib/ssl/src/ssl_internal.hrl index 9c52f5a315..076e663cd4 100644 --- a/lib/ssl/src/ssl_internal.hrl +++ b/lib/ssl/src/ssl_internal.hrl @@ -118,7 +118,7 @@ %% undefined if not hibernating, or number of ms of %% inactivity after which ssl_connection will go into %% hibernation - hibernate_after :: boolean() | 'undefined', + hibernate_after :: timeout(), %% This option should only be set to true by inet_tls_dist erl_dist = false :: boolean(), alpn_advertised_protocols = undefined :: [binary()] | undefined , diff --git a/lib/ssl/src/ssl_manager.erl b/lib/ssl/src/ssl_manager.erl index 2349158b11..60b4fbe995 100644 --- a/lib/ssl/src/ssl_manager.erl +++ b/lib/ssl/src/ssl_manager.erl @@ -610,8 +610,8 @@ server_register_session(Port, Session, #state{session_cache_server_max = Max, do_register_session(Key, Session, Max, Pid, Cache, CacheCb) -> try CacheCb:size(Cache) of - N when N > Max -> - invalidate_session_cache(Pid, CacheCb, Cache); + Max -> + invalidate_session_cache(Pid, CacheCb, Cache); _ -> CacheCb:update(Cache, Key, Session), Pid diff --git a/lib/ssl/src/tls_connection.erl b/lib/ssl/src/tls_connection.erl index a1d13d1850..208edc644a 100644 --- a/lib/ssl/src/tls_connection.erl +++ b/lib/ssl/src/tls_connection.erl @@ -28,7 +28,7 @@ -module(tls_connection). --behaviour(gen_fsm). +-behaviour(gen_statem). -include("tls_connection.hrl"). -include("tls_handshake.hrl"). @@ -43,31 +43,33 @@ %% Internal application API %% Setup --export([start_fsm/8]). +-export([start_fsm/8, start_link/7, init/1]). %% State transition handling --export([next_record/1, next_state/4, next_state_connection/2]). +-export([next_record/1, next_event/3]). %% Handshake handling --export([renegotiate/1, send_handshake/2, send_change_cipher/2]). +-export([renegotiate/2, send_handshake/2, send_change_cipher/2, + reinit_handshake_data/1]). %% Alert and close handling -export([send_alert/2, handle_own_alert/4, handle_close_alert/3, - handle_normal_shutdown/3, handle_unexpected_message/3, + handle_normal_shutdown/3, close/5, alert_user/6, alert_user/9 ]). %% Data handling -export([write_application_data/3, read_application_data/2, - passive_receive/2, next_record_if_active/1]). + passive_receive/2, next_record_if_active/1, handle_common_event/4]). -%% Called by tls_connection_sup --export([start_link/7]). - -%% gen_fsm callbacks --export([init/1, hello/2, certify/2, cipher/2, - abbreviated/2, connection/2, handle_event/3, - handle_sync_event/4, handle_info/3, terminate/3, code_change/4, format_status/2]). +%% gen_statem state functions +-export([init/3, error/3, downgrade/3, %% Initiation and take down states + hello/3, certify/3, cipher/3, abbreviated/3, %% Handshake states + connection/3]). +%% gen_statem callbacks +-export([terminate/3, code_change/4, format_status/2]). + +-define(GEN_STATEM_CB_MODE, state_functions). %%==================================================================== %% Internal application API @@ -130,6 +132,16 @@ send_change_cipher(Msg, #state{connection_states = ConnectionStates0, Transport:send(Socket, BinChangeCipher), State0#state{connection_states = ConnectionStates}. +reinit_handshake_data(State) -> + %% premaster_secret, public_key_info and tls_handshake_info + %% are only needed during the handshake phase. + %% To reduce memory foot print of a connection reinitialize them. + State#state{ + premaster_secret = undefined, + public_key_info = undefined, + tls_handshake_history = ssl_handshake:init_handshake_history() + }. + %%==================================================================== %% tls_connection_sup API %%==================================================================== @@ -147,23 +159,34 @@ start_link(Role, Host, Port, Socket, Options, User, CbInfo) -> init([Role, Host, Port, Socket, Options, User, CbInfo]) -> process_flag(trap_exit, true), - State = initial_state(Role, Host, Port, Socket, Options, User, CbInfo), - gen_fsm:enter_loop(?MODULE, [], hello, State, get_timeout(State)). + State0 = initial_state(Role, Host, Port, Socket, Options, User, CbInfo), + try + State = ssl_connection:ssl_config(State0#state.ssl_options, Role, State0), + gen_statem:enter_loop(?MODULE, [], ?GEN_STATEM_CB_MODE, init, State) + catch throw:Error -> + gen_statem:enter_loop(?MODULE, [], ?GEN_STATEM_CB_MODE, error, {Error, State0}) + end. %%-------------------------------------------------------------------- -%% Description:There should be one instance of this function for each -%% possible state name. Whenever a gen_fsm receives an event sent -%% using gen_fsm:send_event/2, the instance of this function with the -%% same name as the current state name StateName is called to handle -%% the event. It is also called if a timeout occurs. -%% -hello(start, #state{host = Host, port = Port, role = client, - ssl_options = SslOpts, - session = #session{own_certificate = Cert} = Session0, - session_cache = Cache, session_cache_cb = CacheCb, - transport_cb = Transport, socket = Socket, - connection_states = ConnectionStates0, - renegotiation = {Renegotiation, _}} = State0) -> +%% State functions +%%-------------------------------------------------------------------- +%%-------------------------------------------------------------------- +-spec init(gen_statem:event_type(), + {start, timeout()} | term(), #state{}) -> + gen_statem:state_function_result(). +%%-------------------------------------------------------------------- + +init({call, From}, {start, Timeout}, + #state{host = Host, port = Port, role = client, + ssl_options = SslOpts, + session = #session{own_certificate = Cert} = Session0, + transport_cb = Transport, socket = Socket, + connection_states = ConnectionStates0, + renegotiation = {Renegotiation, _}, + session_cache = Cache, + session_cache_cb = CacheCb + } = State0) -> + Timer = ssl_connection:start_or_recv_cancel_timer(Timeout, From), Hello = tls_handshake:client_hello(Host, Port, ConnectionStates0, SslOpts, Cache, CacheCb, Renegotiation, Cert), @@ -177,13 +200,36 @@ hello(start, #state{host = Host, port = Port, role = client, negotiated_version = Version, %% Requested version session = Session0#session{session_id = Hello#client_hello.session_id}, - tls_handshake_history = Handshake}, + tls_handshake_history = Handshake, + start_or_recv_from = From, + timer = Timer}, {Record, State} = next_record(State1), - next_state(hello, hello, Record, State); + next_event(hello, Record, State); +init(Type, Event, State) -> + ssl_connection:init(Type, Event, State, ?MODULE). + +%%-------------------------------------------------------------------- +-spec error(gen_statem:event_type(), + {start, timeout()} | term(), #state{}) -> + gen_statem:state_function_result(). +%%-------------------------------------------------------------------- -hello(Hello = #client_hello{client_version = ClientVersion, - extensions = #hello_extensions{ec_point_formats = EcPointFormats, - elliptic_curves = EllipticCurves}}, +error({call, From}, {start, _Timeout}, {Error, State}) -> + {stop_and_reply, normal, {reply, From, {error, Error}}, State}; +error({call, From}, Msg, State) -> + handle_call(Msg, From, error, State); +error(_, _, _) -> + {keep_state_and_data, [postpone]}. + +%%-------------------------------------------------------------------- +-spec hello(gen_statem:event_type(), + #hello_request{} | #client_hello{} | #server_hello{} | term(), + #state{}) -> + gen_statem:state_function_result(). +%%-------------------------------------------------------------------- +hello(internal, #client_hello{client_version = ClientVersion, + extensions = #hello_extensions{ec_point_formats = EcPointFormats, + elliptic_curves = EllipticCurves}} = Hello, State = #state{connection_states = ConnectionStates0, port = Port, session = #session{own_certificate = Cert} = Session0, renegotiation = {Renegotiation, _}, @@ -203,7 +249,8 @@ hello(Hello = #client_hello{client_version = ClientVersion, undefined -> CurrentProtocol; _ -> Protocol0 end, - ssl_connection:hello({common_client_hello, Type, ServerHelloExt}, + + ssl_connection:hello(internal, {common_client_hello, Type, ServerHelloExt}, State#state{connection_states = ConnectionStates, negotiated_version = Version, hashsign_algorithm = HashSign, @@ -211,8 +258,7 @@ hello(Hello = #client_hello{client_version = ClientVersion, client_ecc = {EllipticCurves, EcPointFormats}, negotiated_protocol = Protocol}, ?MODULE) end; - -hello(Hello = #server_hello{}, +hello(internal, #server_hello{} = Hello, #state{connection_states = ConnectionStates0, negotiated_version = ReqVersion, role = client, @@ -225,25 +271,52 @@ hello(Hello = #server_hello{}, ssl_connection:handle_session(Hello, Version, NewId, ConnectionStates, ProtoExt, Protocol, State) end; +hello(info, Event, State) -> + handle_info(Event, hello, State); +hello(Type, Event, State) -> + ssl_connection:hello(Type, Event, State, ?MODULE). -hello(Msg, State) -> - ssl_connection:hello(Msg, State, ?MODULE). - -abbreviated(Msg, State) -> - ssl_connection:abbreviated(Msg, State, ?MODULE). +%%-------------------------------------------------------------------- +-spec abbreviated(gen_statem:event_type(), term(), #state{}) -> + gen_statem:state_function_result(). +%%-------------------------------------------------------------------- +abbreviated(info, Event, State) -> + handle_info(Event, abbreviated, State); +abbreviated(Type, Event, State) -> + ssl_connection:abbreviated(Type, Event, State, ?MODULE). -certify(Msg, State) -> - ssl_connection:certify(Msg, State, ?MODULE). +%%-------------------------------------------------------------------- +-spec certify(gen_statem:event_type(), term(), #state{}) -> + gen_statem:state_function_result(). +%%-------------------------------------------------------------------- +certify(info, Event, State) -> + handle_info(Event, certify, State); +certify(Type, Event, State) -> + ssl_connection:certify(Type, Event, State, ?MODULE). -cipher(Msg, State) -> - ssl_connection:cipher(Msg, State, ?MODULE). +%%-------------------------------------------------------------------- +-spec cipher(gen_statem:event_type(), term(), #state{}) -> + gen_statem:state_function_result(). +%%-------------------------------------------------------------------- +cipher(info, Event, State) -> + handle_info(Event, cipher, State); +cipher(Type, Event, State) -> + ssl_connection:cipher(Type, Event, State, ?MODULE). -connection(#hello_request{}, #state{host = Host, port = Port, - session = #session{own_certificate = Cert} = Session0, - session_cache = Cache, session_cache_cb = CacheCb, - ssl_options = SslOpts, - connection_states = ConnectionStates0, - renegotiation = {Renegotiation, _}} = State0) -> +%%-------------------------------------------------------------------- +-spec connection(gen_statem:event_type(), + #hello_request{} | #client_hello{}| term(), #state{}) -> + gen_statem:state_function_result(). +%%-------------------------------------------------------------------- +connection(info, Event, State) -> + handle_info(Event, connection, State); +connection(internal, #hello_request{}, + #state{host = Host, port = Port, + session = #session{own_certificate = Cert} = Session0, + session_cache = Cache, session_cache_cb = CacheCb, + ssl_options = SslOpts, + connection_states = ConnectionStates0, + renegotiation = {Renegotiation, _}} = State0) -> Hello = tls_handshake:client_hello(Host, Port, ConnectionStates0, SslOpts, Cache, CacheCb, Renegotiation, Cert), State1 = send_handshake(Hello, State0), @@ -251,58 +324,49 @@ connection(#hello_request{}, #state{host = Host, port = Port, next_record( State1#state{session = Session0#session{session_id = Hello#client_hello.session_id}}), - next_state(connection, hello, Record, State); - -connection(#client_hello{} = Hello, #state{role = server, allow_renegotiate = true} = State) -> + next_event(hello, Record, State); +connection(internal, #client_hello{} = Hello, + #state{role = server, allow_renegotiate = true} = State) -> %% Mitigate Computational DoS attack %% http://www.educatedguesswork.org/2011/10/ssltls_and_computational_dos.html %% http://www.thc.org/thc-ssl-dos/ Rather than disabling client %% initiated renegotiation we will disallow many client initiated %% renegotiations immediately after each other. erlang:send_after(?WAIT_TO_ALLOW_RENEGOTIATION, self(), allow_renegotiate), - hello(Hello, State#state{allow_renegotiate = false}); - -connection(#client_hello{}, #state{role = server, allow_renegotiate = false} = State0) -> + {next_state, hello, State#state{allow_renegotiate = false}, [{next_event, internal, Hello}]}; +connection(internal, #client_hello{}, + #state{role = server, allow_renegotiate = false} = State0) -> Alert = ?ALERT_REC(?WARNING, ?NO_RENEGOTIATION), - State = send_alert(Alert, State0), - next_state_connection(connection, State); - -connection(Msg, State) -> - ssl_connection:connection(Msg, State, tls_connection). + State1 = send_alert(Alert, State0), + {Record, State} = ssl_connection:prepare_connection(State1, ?MODULE), + next_event(connection, Record, State); +connection(Type, Event, State) -> + ssl_connection:connection(Type, Event, State, ?MODULE). %%-------------------------------------------------------------------- -%% Description: Whenever a gen_fsm receives an event sent using -%% gen_fsm:send_all_state_event/2, this function is called to handle -%% the event. Not currently used! +-spec downgrade(gen_statem:event_type(), term(), #state{}) -> + gen_statem:state_function_result(). %%-------------------------------------------------------------------- -handle_event(_Event, StateName, State) -> - {next_state, StateName, State, get_timeout(State)}. +downgrade(Type, Event, State) -> + ssl_connection:downgrade(Type, Event, State, ?MODULE). %%-------------------------------------------------------------------- -%% Description: Whenever a gen_fsm receives an event sent using -%% gen_fsm:sync_send_all_state_event/2,3, this function is called to handle -%% the event. +%% Event handling functions called by state functions to handle +%% common or unexpected events for the state. %%-------------------------------------------------------------------- -handle_sync_event(Event, From, StateName, State) -> - ssl_connection:handle_sync_event(Event, From, StateName, State). - -%%-------------------------------------------------------------------- -%% Description: This function is called by a gen_fsm when it receives any -%% other message than a synchronous or asynchronous event -%% (or a system message). -%%-------------------------------------------------------------------- - +handle_call(Event, From, StateName, State) -> + ssl_connection:handle_call(Event, From, StateName, State, ?MODULE). + %% raw data from socket, unpack records handle_info({Protocol, _, Data}, StateName, #state{data_tag = Protocol} = State0) -> case next_tls_record(Data, State0) of {Record, State} -> - next_state(StateName, StateName, Record, State); + next_event(StateName, Record, State); #alert{} = Alert -> handle_normal_shutdown(Alert, StateName, State0), - {stop, {shutdown, own_alert}, State0} + {stop, {shutdown, own_alert}} end; - handle_info({CloseTag, Socket}, StateName, #state{socket = Socket, close_tag = CloseTag, negotiated_version = Version} = State) -> @@ -321,32 +385,98 @@ handle_info({CloseTag, Socket}, StateName, ok end, handle_normal_shutdown(?ALERT_REC(?FATAL, ?CLOSE_NOTIFY), StateName, State), - {stop, {shutdown, transport_closed}, State}; - + {stop, {shutdown, transport_closed}}; handle_info(Msg, StateName, State) -> ssl_connection:handle_info(Msg, StateName, State). +handle_common_event(internal, #alert{} = Alert, StateName, + #state{negotiated_version = Version} = State) -> + handle_own_alert(Alert, Version, StateName, State); + +%%% TLS record protocol level handshake messages +handle_common_event(internal, #ssl_tls{type = ?HANDSHAKE, fragment = Data}, + StateName, #state{protocol_buffers = + #protocol_buffers{tls_handshake_buffer = Buf0} = Buffers, + negotiated_version = Version} = State0) -> + + Handle = + fun({#hello_request{} = Packet, _}, {connection, HState}) -> + %% This message should not be included in handshake + %% message hashes. Starts new handshake (renegotiation) + Hs0 = ssl_handshake:init_handshake_history(), + {HState#state{tls_handshake_history = Hs0, + renegotiation = {true, peer}}, + {next_event, internal, Packet}}; + ({#hello_request{}, _}, {next_state, _SName, HState}) -> + %% This message should not be included in handshake + %% message hashes. Already in negotiation so it will be ignored! + {HState, []}; + ({#client_hello{} = Packet, Raw}, {connection, HState0}) -> + HState = handle_sni_extension(Packet, HState0), + Version = Packet#client_hello.client_version, + Hs0 = ssl_handshake:init_handshake_history(), + Hs1 = ssl_handshake:update_handshake_history(Hs0, Raw), + {HState#state{tls_handshake_history = Hs1, + renegotiation = {true, peer}}, + {next_event, internal, Packet}}; + + ({Packet, Raw}, {_SName, HState0 = #state{tls_handshake_history=Hs0}}) -> + HState = handle_sni_extension(Packet, HState0), + Hs1 = ssl_handshake:update_handshake_history(Hs0, Raw), + {HState#state{tls_handshake_history=Hs1}, {next_event, internal, Packet}} + end, + try + {Packets, Buf} = tls_handshake:get_tls_handshake(Version,Data,Buf0), + State1 = State0#state{protocol_buffers = + Buffers#protocol_buffers{tls_packets = Packets, + tls_handshake_buffer = Buf}}, + {State, Events} = tls_handshake_events(Handle, StateName, State1, []), + case StateName of + connection -> + ssl_connection:hibernate_after(StateName, State, Events); + _ -> + {next_state, StateName, State, Events} + end + catch throw:#alert{} = Alert -> + handle_own_alert(Alert, Version, StateName, State0) + end; +%%% TLS record protocol level application data messages +handle_common_event(internal, #ssl_tls{type = ?APPLICATION_DATA, fragment = Data}, StateName, State) -> + {next_state, StateName, State, [{next_event, internal, {application_data, Data}}]}; +%%% TLS record protocol level change cipher messages +handle_common_event(internal, #ssl_tls{type = ?CHANGE_CIPHER_SPEC, fragment = Data}, StateName, State) -> + {next_state, StateName, State, [{next_event, internal, #change_cipher_spec{type = Data}}]}; +%%% TLS record protocol level Alert messages +handle_common_event(internal, #ssl_tls{type = ?ALERT, fragment = EncAlerts}, StateName, + #state{negotiated_version = Version} = State) -> + case decode_alerts(EncAlerts) of + Alerts = [_|_] -> + handle_alerts(Alerts, {next_state, StateName, State}); + #alert{} = Alert -> + handle_own_alert(Alert, Version, StateName, State) + end; +%% Ignore unknown TLS record level protocol messages +handle_common_event(internal, #ssl_tls{type = _Unknown}, StateName, State) -> + {next_state, StateName, State}. + %%-------------------------------------------------------------------- -%% Description:This function is called by a gen_fsm when it is about -%% to terminate. It should be the opposite of Module:init/1 and do any -%% necessary cleaning up. When it returns, the gen_fsm terminates with -%% Reason. The return value is ignored. +%% gen_statem callbacks %%-------------------------------------------------------------------- terminate(Reason, StateName, State) -> catch ssl_connection:terminate(Reason, StateName, State). +format_status(Type, Data) -> + ssl_connection:format_status(Type, Data). + %%-------------------------------------------------------------------- %% code_change(OldVsn, StateName, State, Extra) -> {ok, StateName, NewState} %% Description: Convert process state when code is changed %%-------------------------------------------------------------------- code_change(_OldVsn, StateName, State0, {Direction, From, To}) -> State = convert_state(State0, Direction, From, To), - {ok, StateName, State}; + {?GEN_STATEM_CB_MODE, StateName, State}; code_change(_OldVsn, StateName, State, _) -> - {ok, StateName, State}. - -format_status(Type, Data) -> - ssl_connection:format_status(Type, Data). + {?GEN_STATEM_CB_MODE, StateName, State}. %%-------------------------------------------------------------------- %%% Internal functions @@ -396,7 +526,6 @@ initial_state(Role, Host, Port, Socket, {SSLOptions, SocketOptions, Tracker}, Us renegotiation = {false, first}, allow_renegotiate = SSLOptions#ssl_options.client_renegotiation, start_or_recv_from = undefined, - send_queue = queue:new(), protocol_cb = ?MODULE, tracker = Tracker }. @@ -418,80 +547,6 @@ update_ssl_options_from_sni(OrigSSLOptions, SNIHostname) -> ssl:handle_options(SSLOption, OrigSSLOptions) end. -next_state(Current,_, #alert{} = Alert, #state{negotiated_version = Version} = State) -> - handle_own_alert(Alert, Version, Current, State); - -next_state(_,Next, no_record, State) -> - {next_state, Next, State, get_timeout(State)}; - -next_state(Current, Next, #ssl_tls{type = ?ALERT, fragment = EncAlerts}, #state{negotiated_version = Version} = State) -> - case decode_alerts(EncAlerts) of - Alerts = [_|_] -> - handle_alerts(Alerts, {next_state, Next, State, get_timeout(State)}); - #alert{} = Alert -> - handle_own_alert(Alert, Version, Current, State) - end; -next_state(Current, Next, #ssl_tls{type = ?HANDSHAKE, fragment = Data}, - State0 = #state{protocol_buffers = - #protocol_buffers{tls_handshake_buffer = Buf0} = Buffers, - negotiated_version = Version}) -> - Handle = - fun({#hello_request{} = Packet, _}, {next_state, connection = SName, State}) -> - %% This message should not be included in handshake - %% message hashes. Starts new handshake (renegotiation) - Hs0 = ssl_handshake:init_handshake_history(), - ?MODULE:SName(Packet, State#state{tls_handshake_history=Hs0, - renegotiation = {true, peer}}); - ({#hello_request{} = Packet, _}, {next_state, SName, State}) -> - %% This message should not be included in handshake - %% message hashes. Already in negotiation so it will be ignored! - ?MODULE:SName(Packet, State); - ({#client_hello{} = Packet, Raw}, {next_state, connection = SName, HState0}) -> - HState = handle_sni_extension(Packet, HState0), - Version = Packet#client_hello.client_version, - Hs0 = ssl_handshake:init_handshake_history(), - Hs1 = ssl_handshake:update_handshake_history(Hs0, Raw), - ?MODULE:SName(Packet, HState#state{tls_handshake_history=Hs1, - renegotiation = {true, peer}}); - ({Packet, Raw}, {next_state, SName, HState0 = #state{tls_handshake_history=Hs0}}) -> - HState = handle_sni_extension(Packet, HState0), - Hs1 = ssl_handshake:update_handshake_history(Hs0, Raw), - ?MODULE:SName(Packet, HState#state{tls_handshake_history=Hs1}); - (_, StopState) -> StopState - end, - try - {Packets, Buf} = tls_handshake:get_tls_handshake(Version,Data,Buf0), - State = State0#state{protocol_buffers = - Buffers#protocol_buffers{tls_packets = Packets, - tls_handshake_buffer = Buf}}, - handle_tls_handshake(Handle, Next, State) - catch throw:#alert{} = Alert -> - handle_own_alert(Alert, Version, Current, State0) - end; - -next_state(_, StateName, #ssl_tls{type = ?APPLICATION_DATA, fragment = Data}, State0) -> - case read_application_data(Data, State0) of - Stop = {stop,_,_} -> - Stop; - {Record, State} -> - next_state(StateName, StateName, Record, State) - end; -next_state(Current, Next, #ssl_tls{type = ?CHANGE_CIPHER_SPEC, fragment = <<1>>} = - _ChangeCipher, - #state{connection_states = ConnectionStates0} = State0) - when Next == cipher; Next == abbreviated -> - ConnectionStates1 = - ssl_record:activate_pending_connection_state(ConnectionStates0, read), - {Record, State} = next_record(State0#state{connection_states = ConnectionStates1}), - next_state(Current, Next, Record, State#state{expecting_finished = true}); -next_state(Current, _Next, #ssl_tls{type = ?CHANGE_CIPHER_SPEC, fragment = <<1>>} = - _ChangeCipher, #state{negotiated_version = Version} = State) -> - handle_own_alert(?ALERT_REC(?FATAL, ?HANDSHAKE_FAILURE), Version, Current, State); -next_state(Current, Next, #ssl_tls{type = _Unknown}, State0) -> - %% Ignore unknown type - {Record, State} = next_record(State0), - next_state(Current, Next, Record, State). - next_tls_record(Data, #state{protocol_buffers = #protocol_buffers{tls_record_buffer = Buf0, tls_cipher_texts = CT0} = Buffers} = State0) -> case tls_record:get_tls_records(Data, Buf0) of @@ -504,11 +559,6 @@ next_tls_record(Data, #state{protocol_buffers = #protocol_buffers{tls_record_buf Alert end. -next_record(#state{protocol_buffers = #protocol_buffers{tls_packets = [], tls_cipher_texts = []}, - socket = Socket, - transport_cb = Transport} = State) -> - ssl_socket:setopts(Transport, Socket, [{active,once}]), - {no_record, State}; next_record(#state{protocol_buffers = #protocol_buffers{tls_packets = [], tls_cipher_texts = [CT | Rest]} = Buffers, @@ -522,6 +572,11 @@ next_record(#state{protocol_buffers = #alert{} = Alert -> {Alert, State} end; +next_record(#state{protocol_buffers = #protocol_buffers{tls_packets = [], tls_cipher_texts = []}, + socket = Socket, + transport_cb = Transport} = State) -> + ssl_socket:setopts(Transport, Socket, [{active,once}]), + {no_record, State}; next_record(State) -> {no_record, State}. @@ -533,55 +588,36 @@ next_record_if_active(State = next_record_if_active(State) -> next_record(State). -next_state_connection(StateName, #state{send_queue = Queue0, - negotiated_version = Version, - socket = Socket, - transport_cb = Transport, - connection_states = ConnectionStates0 - } = State) -> - %% Send queued up data that was queued while renegotiating - case queue:out(Queue0) of - {{value, {From, Data}}, Queue} -> - {Msgs, ConnectionStates} = - ssl_record:encode_data(Data, Version, ConnectionStates0), - Result = Transport:send(Socket, Msgs), - gen_fsm:reply(From, Result), - next_state_connection(StateName, - State#state{connection_states = ConnectionStates, - send_queue = Queue}); - {empty, Queue0} -> - next_state_is_connection(StateName, State) - end. - -%% In next_state_is_connection/1: clear tls_handshake, -%% premaster_secret and public_key_info (only needed during handshake) -%% to reduce memory foot print of a connection. -next_state_is_connection(_, State = - #state{start_or_recv_from = RecvFrom, - socket_options = - #socket_options{active = false}}) when RecvFrom =/= undefined -> - passive_receive(State#state{premaster_secret = undefined, - public_key_info = undefined, - tls_handshake_history = ssl_handshake:init_handshake_history()}, connection); - -next_state_is_connection(StateName, State0) -> - {Record, State} = next_record_if_active(State0), - next_state(StateName, connection, Record, State#state{premaster_secret = undefined, - public_key_info = undefined, - tls_handshake_history = ssl_handshake:init_handshake_history()}). - passive_receive(State0 = #state{user_data_buffer = Buffer}, StateName) -> case Buffer of <<>> -> {Record, State} = next_record(State0), - next_state(StateName, StateName, Record, State); + next_event(StateName, Record, State); _ -> - case read_application_data(<<>>, State0) of - Stop = {stop, _, _} -> - Stop; - {Record, State} -> - next_state(StateName, StateName, Record, State) - end + {Record, State} = read_application_data(<<>>, State0), + next_event(StateName, Record, State) + end. + +next_event(StateName, Record, State) -> + next_event(StateName, Record, State, []). + +next_event(connection = StateName, no_record, State0, Actions) -> + case next_record_if_active(State0) of + {no_record, State} -> + ssl_connection:hibernate_after(StateName, State, Actions); + {#ssl_tls{} = Record, State} -> + {next_state, StateName, State, [{next_event, internal, {tls_record, Record}} | Actions]}; + {#alert{} = Alert, State} -> + {next_state, StateName, State, [{next_event, internal, Alert} | Actions]} + end; +next_event(StateName, Record, State, Actions) -> + case Record of + no_record -> + {next_state, StateName, State, Actions}; + #ssl_tls{} = Record -> + {next_state, StateName, State, [{next_event, internal, {tls_record, Record}} | Actions]}; + #alert{} = Alert -> + {next_state, StateName, State, [{next_event, internal, Alert} | Actions]} end. read_application_data(Data, #state{user_application = {_Mon, Pid}, @@ -625,11 +661,6 @@ read_application_data(Data, #state{user_application = {_Mon, Pid}, {stop, normal, State0} end. -get_timeout(#state{ssl_options=#ssl_options{hibernate_after = undefined}}) -> - infinity; -get_timeout(#state{ssl_options=#ssl_options{hibernate_after = HibernateAfter}}) -> - HibernateAfter. - %% Picks ClientData get_data(_, _, <<>>) -> {more, <<>>}; @@ -736,7 +767,7 @@ header(N, Binary) -> [ByteN | header(N-1, NewBinary)]. send_or_reply(false, _Pid, From, Data) when From =/= undefined -> - gen_fsm:reply(From, Data); + gen_statem:reply(From, Data); %% Can happen when handling own alert or tcp error/close and there is %% no outstanding gen_fsm sync events send_or_reply(false, no_pid, _, _) -> @@ -747,51 +778,43 @@ send_or_reply(_, Pid, _From, Data) -> send_user(Pid, Msg) -> Pid ! Msg. -handle_tls_handshake(Handle, StateName, - #state{protocol_buffers = - #protocol_buffers{tls_packets = [Packet]} = Buffers} = State) -> - FsmReturn = {next_state, StateName, State#state{protocol_buffers = - Buffers#protocol_buffers{tls_packets = []}}}, - Handle(Packet, FsmReturn); - -handle_tls_handshake(Handle, StateName, - #state{protocol_buffers = - #protocol_buffers{tls_packets = [Packet | Packets]} = Buffers} = - State0) -> - FsmReturn = {next_state, StateName, State0#state{protocol_buffers = - Buffers#protocol_buffers{tls_packets = - Packets}}}, - case Handle(Packet, FsmReturn) of - {next_state, NextStateName, State, _Timeout} -> - handle_tls_handshake(Handle, NextStateName, State); - {next_state, NextStateName, State} -> - handle_tls_handshake(Handle, NextStateName, State); - {stop, _,_} = Stop -> - Stop - end; - -handle_tls_handshake(_Handle, _StateName, #state{}) -> - throw(?ALERT_REC(?FATAL, ?HANDSHAKE_FAILURE)). +tls_handshake_events(Handle, StateName, + #state{protocol_buffers = + #protocol_buffers{tls_packets = [Packet]} = Buffers} = State0, Acc) -> + {State, Event} = Handle(Packet, {StateName, + State0#state{protocol_buffers = + Buffers#protocol_buffers{tls_packets = []}}}), + {State, lists:reverse([Event |Acc])}; +tls_handshake_events(Handle, StateName, + #state{protocol_buffers = + #protocol_buffers{tls_packets = + [Packet | Packets]} = Buffers} = State0, Acc) -> + {State, Event} = Handle(Packet, {StateName, State0#state{protocol_buffers = + Buffers#protocol_buffers{tls_packets = + Packets}}}), + tls_handshake_events(Handle, StateName, State, [Event | Acc]); + +tls_handshake_events(_Handle, _, #state{}, _) -> + throw(?ALERT_REC(?FATAL, ?HANDSHAKE_FAILURE)). write_application_data(Data0, From, #state{socket = Socket, negotiated_version = Version, transport_cb = Transport, connection_states = ConnectionStates0, - send_queue = SendQueue, socket_options = SockOpts, ssl_options = #ssl_options{renegotiate_at = RenegotiateAt}} = State) -> Data = encode_packet(Data0, SockOpts), case time_to_renegotiate(Data, ConnectionStates0, RenegotiateAt) of true -> - renegotiate(State#state{send_queue = queue:in_r({From, Data}, SendQueue), - renegotiation = {true, internal}}); + renegotiate(State#state{renegotiation = {true, internal}}, + [{next_event, {call, From}, {application_data, Data0}}]); false -> {Msgs, ConnectionStates} = ssl_record:encode_data(Data, Version, ConnectionStates0), Result = Transport:send(Socket, Msgs), - {reply, Result, - connection, State#state{connection_states = ConnectionStates}, get_timeout(State)} + ssl_connection:hibernate_after(connection, State#state{connection_states = ConnectionStates}, + [{reply, From, Result}]) end. encode_packet(Data, #socket_options{packet=Packet}) -> @@ -823,69 +846,73 @@ is_time_to_renegotiate(N, M) when N < M-> false; is_time_to_renegotiate(_,_) -> true. -renegotiate(#state{role = client} = State) -> +renegotiate(#state{role = client} = State, Actions) -> %% Handle same way as if server requested %% the renegotiation Hs0 = ssl_handshake:init_handshake_history(), - connection(#hello_request{}, State#state{tls_handshake_history = Hs0}); + {next_state, connection, State#state{tls_handshake_history = Hs0}, + [{next_event, internal, #hello_request{}} | Actions]}; + renegotiate(#state{role = server, socket = Socket, transport_cb = Transport, negotiated_version = Version, - connection_states = ConnectionStates0} = State0) -> + connection_states = ConnectionStates0} = State0, Actions) -> HelloRequest = ssl_handshake:hello_request(), Frag = tls_handshake:encode_handshake(HelloRequest, Version), Hs0 = ssl_handshake:init_handshake_history(), {BinMsg, ConnectionStates} = ssl_record:encode_handshake(Frag, Version, ConnectionStates0), Transport:send(Socket, BinMsg), - {Record, State} = next_record(State0#state{connection_states = - ConnectionStates, - tls_handshake_history = Hs0}), - next_state(connection, hello, Record, State#state{allow_renegotiate = true}). + State1 = State0#state{connection_states = + ConnectionStates, + tls_handshake_history = Hs0}, + {Record, State} = next_record(State1), + next_event(hello, Record, State, Actions). handle_alerts([], Result) -> Result; -handle_alerts(_, {stop, _, _} = Stop) -> - %% If it is a fatal alert immediately close +handle_alerts(_, {stop,_} = Stop) -> Stop; -handle_alerts([Alert | Alerts], {next_state, StateName, State, _Timeout}) -> - handle_alerts(Alerts, handle_alert(Alert, StateName, State)). - +handle_alerts([Alert | Alerts], {next_state, StateName, State}) -> + handle_alerts(Alerts, handle_alert(Alert, StateName, State)); +handle_alerts([Alert | Alerts], {next_state, StateName, State, _Actions}) -> + handle_alerts(Alerts, handle_alert(Alert, StateName, State)). handle_alert(#alert{level = ?FATAL} = Alert, StateName, #state{socket = Socket, transport_cb = Transport, ssl_options = SslOpts, start_or_recv_from = From, host = Host, port = Port, session = Session, user_application = {_Mon, Pid}, - role = Role, socket_options = Opts, tracker = Tracker} = State) -> + role = Role, socket_options = Opts, tracker = Tracker}) -> invalidate_session(Role, Host, Port, Session), log_alert(SslOpts#ssl_options.log_alert, StateName, Alert), alert_user(Transport, Tracker, Socket, StateName, Opts, Pid, From, Alert, Role), - {stop, normal, State}; + {stop, normal}; handle_alert(#alert{level = ?WARNING, description = ?CLOSE_NOTIFY} = Alert, StateName, State) -> handle_normal_shutdown(Alert, StateName, State), - {stop, {shutdown, peer_close}, State}; + {stop, {shutdown, peer_close}}; handle_alert(#alert{level = ?WARNING, description = ?NO_RENEGOTIATION} = Alert, StateName, #state{ssl_options = SslOpts, renegotiation = {true, internal}} = State) -> log_alert(SslOpts#ssl_options.log_alert, StateName, Alert), handle_normal_shutdown(Alert, StateName, State), - {stop, {shutdown, peer_close}, State}; + {stop, {shutdown, peer_close}}; handle_alert(#alert{level = ?WARNING, description = ?NO_RENEGOTIATION} = Alert, StateName, #state{ssl_options = SslOpts, renegotiation = {true, From}} = State0) -> log_alert(SslOpts#ssl_options.log_alert, StateName, Alert), - gen_fsm:reply(From, {error, renegotiation_rejected}), + gen_statem:reply(From, {error, renegotiation_rejected}), {Record, State} = next_record(State0), - next_state(StateName, connection, Record, State); + %% Go back to connection! + next_event(connection, Record, State); %% Gracefully log and ignore all other warning alerts handle_alert(#alert{level = ?WARNING} = Alert, StateName, #state{ssl_options = SslOpts} = State0) -> log_alert(SslOpts#ssl_options.log_alert, StateName, Alert), {Record, State} = next_record(State0), - next_state(StateName, StateName, Record, State). + next_event(StateName, Record, State). alert_user(Transport, Tracker, Socket, connection, Opts, Pid, From, Alert, Role) -> alert_user(Transport, Tracker, Socket, Opts#socket_options.active, Pid, From, Alert, Role); @@ -937,7 +964,7 @@ handle_own_alert(Alert, Version, StateName, catch _:_ -> ok end, - {stop, {shutdown, own_alert}, State}. + {stop, {shutdown, own_alert}}. handle_normal_shutdown(Alert, _, #state{socket = Socket, transport_cb = Transport, @@ -954,11 +981,6 @@ handle_normal_shutdown(Alert, StateName, #state{socket = Socket, start_or_recv_from = RecvFrom, role = Role}) -> alert_user(Transport, Tracker, Socket, StateName, Opts, Pid, RecvFrom, Alert, Role). -handle_unexpected_message(Msg, Info, #state{negotiated_version = Version} = State) -> - Alert = ?ALERT_REC(?FATAL,?UNEXPECTED_MESSAGE), - handle_own_alert(Alert, Version, {Info, Msg}, State). - - handle_close_alert(Data, StateName, State0) -> case next_tls_record(Data, State0) of {#ssl_tls{type = ?ALERT, fragment = EncAlerts}, State} -> @@ -979,27 +1001,6 @@ invalidate_session(client, Host, Port, Session) -> invalidate_session(server, _, Port, Session) -> ssl_manager:invalidate_session(Port, Session). -%% User downgrades connection -%% When downgrading an TLS connection to a transport connection -%% we must recive the close message before releasing the -%% transport socket. -close({close, {Pid, Timeout}}, Socket, Transport, ConnectionStates, Check) when is_pid(Pid) -> - ssl_socket:setopts(Transport, Socket, [{active, false}, {packet, ssl_tls}]), - case Transport:recv(Socket, 0, Timeout) of - {ok, {ssl_tls, Socket, ?ALERT, Version, Fragment}} -> - case tls_record:decode_cipher_text(#ssl_tls{type = ?ALERT, - version = Version, - fragment = Fragment - }, ConnectionStates, Check) of - {#ssl_tls{fragment = Plain}, _} -> - [Alert| _] = decode_alerts(Plain), - downgrade(Alert, Transport, Socket, Pid) - end; - {error, timeout} -> - {error, timeout}; - _ -> - {error, no_tls_close} - end; %% User closes or recursive call! close({close, Timeout}, Socket, Transport = gen_tcp, _,_) -> ssl_socket:setopts(Transport, Socket, [{active, false}]), @@ -1020,15 +1021,11 @@ close({shutdown, own_alert}, Socket, Transport = gen_tcp, ConnectionStates, Chec %% with the network but we want to maximise the odds that %% peer application gets all data sent on the tcp connection. close({close, ?DEFAULT_TIMEOUT}, Socket, Transport, ConnectionStates, Check); +close(downgrade, _,_,_,_) -> + ok; %% Other close(_, Socket, Transport, _,_) -> Transport:close(Socket). -downgrade(#alert{description = ?CLOSE_NOTIFY}, Transport, Socket, Pid) -> - ssl_socket:setopts(Transport, Socket, [{active, false}, {packet, 0}, {mode, binary}]), - Transport:controlling_process(Socket, Pid), - {ok, Socket}; -downgrade(_, _,_,_) -> - {error, no_tls_close}. convert_state(#state{ssl_options = Options} = State, up, "5.3.5", "5.3.6") -> State#state{ssl_options = convert_options_partial_chain(Options, up)}; @@ -1069,4 +1066,3 @@ handle_sni_extension(#client_hello{extensions = HelloExtensions}, State0) -> end; handle_sni_extension(_, State0) -> State0. - diff --git a/lib/ssl/src/tls_handshake.erl b/lib/ssl/src/tls_handshake.erl index ef718c13df..102dbba198 100644 --- a/lib/ssl/src/tls_handshake.erl +++ b/lib/ssl/src/tls_handshake.erl @@ -278,10 +278,11 @@ handle_server_hello_extensions(Version, SessionId, Random, CipherSuite, {Version, SessionId, ConnectionStates, ProtoExt, Protocol} end. -available_signature_algs(undefined, SupportedHashSigns, _, {Major, Minor}) when (Major < 3) andalso (Minor < 3) -> +available_signature_algs(undefined, SupportedHashSigns, _, {Major, Minor}) when + (Major >= 3) andalso (Minor >= 3) -> SupportedHashSigns; available_signature_algs(#hash_sign_algos{hash_sign_algos = ClientHashSigns}, SupportedHashSigns, - _, {Major, Minor}) when (Major < 3) andalso (Minor < 3) -> + _, {Major, Minor}) when (Major >= 3) andalso (Minor >= 3) -> ordsets:intersection(ClientHashSigns, SupportedHashSigns); available_signature_algs(_, _, _, _) -> undefined. diff --git a/lib/ssl/test/ssl_basic_SUITE.erl b/lib/ssl/test/ssl_basic_SUITE.erl index 0c3c7aa39b..9341d2cae7 100644 --- a/lib/ssl/test/ssl_basic_SUITE.erl +++ b/lib/ssl/test/ssl_basic_SUITE.erl @@ -88,7 +88,8 @@ basic_tests() -> connect_dist, clear_pem_cache, defaults, - fallback + fallback, + cipher_format ]. options_tests() -> @@ -144,7 +145,8 @@ api_tests() -> versions_option, server_name_indication_option, accept_pool, - new_options_in_accept + new_options_in_accept, + prf ]. session_tests() -> @@ -325,6 +327,31 @@ init_per_testcase(rizzo, Config) -> ct:log("TLS/SSL version ~p~n ", [tls_record:supported_protocol_versions()]), ct:timetrap({seconds, 40}), Config; +init_per_testcase(prf, Config) -> + ct:log("TLS/SSL version ~p~n ", [tls_record:supported_protocol_versions()]), + ct:timetrap({seconds, 40}), + case ?config(tc_group_path, Config) of + [] -> Prop = []; + [Prop] -> Prop + end, + case ?config(name, Prop) of + undefined -> TlsVersions = [sslv3, tlsv1, 'tlsv1.1', 'tlsv1.2']; + TlsVersion when is_atom(TlsVersion) -> + TlsVersions = [TlsVersion] + end, + PRFS=[md5, sha, sha256, sha384, sha512], + %All are the result of running tls_v1:prf(PrfAlgo, <<>>, <<>>, <<>>, 16) + %with the specified PRF algorithm + ExpectedPrfResults= + [{md5, <<96,139,180,171,236,210,13,10,28,32,2,23,88,224,235,199>>}, + {sha, <<95,3,183,114,33,169,197,187,231,243,19,242,220,228,70,151>>}, + {sha256, <<166,249,145,171,43,95,158,232,6,60,17,90,183,180,0,155>>}, + {sha384, <<153,182,217,96,186,130,105,85,65,103,123,247,146,91,47,106>>}, + {sha512, <<145,8,98,38,243,96,42,94,163,33,53,49,241,4,127,28>>}, + %TLS 1.0 and 1.1 PRF: + {md5sha, <<63,136,3,217,205,123,200,177,251,211,17,229,132,4,173,80>>}], + TestPlan = prf_create_plan(TlsVersions, PRFS, ExpectedPrfResults), + [{prf_test_plan, TestPlan} | Config]; init_per_testcase(TestCase, Config) when TestCase == ssl_accept_timeout; TestCase == client_closes_socket; @@ -430,6 +457,25 @@ new_options_in_accept(Config) when is_list(Config) -> ssl_test_lib:close(Server), ssl_test_lib:close(Client). %%-------------------------------------------------------------------- +prf() -> + [{doc,"Test that ssl:prf/5 uses the negotiated PRF."}]. +prf(Config) when is_list(Config) -> + TestPlan = ?config(prf_test_plan, Config), + case TestPlan of + [] -> ct:fail({error, empty_prf_test_plan}); + _ -> lists:foreach(fun(Suite) -> + lists:foreach( + fun(Test) -> + V = ?config(tls_ver, Test), + C = ?config(ciphers, Test), + E = ?config(expected, Test), + P = ?config(prf, Test), + prf_run_test(Config, V, C, E, P) + end, Suite) + end, TestPlan) + end. + +%%-------------------------------------------------------------------- connection_info() -> [{doc,"Test the API function ssl:connection_information/1"}]. @@ -719,21 +765,27 @@ clear_pem_cache(Config) when is_list(Config) -> State = ssl_test_lib:state(Prop), [_,FilRefDb |_] = element(6, State), {Server, Client} = basic_verify_test_no_close(Config), - 2 = ets:info(FilRefDb, size), + CountReferencedFiles = fun({_,-1}, Acc) -> + Acc; + ({_, N}, Acc) -> + N + Acc + end, + + 2 = ets:foldl(CountReferencedFiles, 0, FilRefDb), ssl:clear_pem_cache(), _ = sys:get_status(whereis(ssl_manager)), {Server1, Client1} = basic_verify_test_no_close(Config), - 4 = ets:info(FilRefDb, size), + 4 = ets:foldl(CountReferencedFiles, 0, FilRefDb), ssl_test_lib:close(Server), ssl_test_lib:close(Client), - ct:sleep(5000), + ct:sleep(2000), _ = sys:get_status(whereis(ssl_manager)), - 2 = ets:info(FilRefDb, size), + 2 = ets:foldl(CountReferencedFiles, 0, FilRefDb), ssl_test_lib:close(Server1), ssl_test_lib:close(Client1), - ct:sleep(5000), + ct:sleep(2000), _ = sys:get_status(whereis(ssl_manager)), - 0 = ets:info(FilRefDb, size). + 0 = ets:foldl(CountReferencedFiles, 0, FilRefDb). %%-------------------------------------------------------------------- @@ -764,6 +816,14 @@ fallback(Config) when is_list(Config) -> Client, {error,{tls_alert,"inappropriate fallback"}}). %%-------------------------------------------------------------------- +cipher_format() -> + [{doc, "Test that cipher conversion from tuples to binarys works"}]. +cipher_format(Config) when is_list(Config) -> + {ok, Socket} = ssl:listen(0, [{ciphers, ssl:cipher_suites()}]), + ssl:close(Socket). + +%%-------------------------------------------------------------------- + peername() -> [{doc,"Test API function peername/1"}]. @@ -2556,6 +2616,13 @@ der_input(Config) when is_list(Config) -> DataDir = ?config(data_dir, Config), DHParamFile = filename:join(DataDir, "dHParam.pem"), + {status, _, _, StatusInfo} = sys:get_status(whereis(ssl_manager)), + [_, _,_, _, Prop] = StatusInfo, + State = ssl_test_lib:state(Prop), + [CADb | _] = element(6, State), + + Size = ets:info(CADb, size), + SeverVerifyOpts = ?config(server_verification_opts, Config), {ServerCert, ServerKey, ServerCaCerts, DHParams} = der_input_opts([{dhfile, DHParamFile} | SeverVerifyOpts]), @@ -2583,13 +2650,8 @@ der_input(Config) when is_list(Config) -> ssl_test_lib:check_result(Server, ok, Client, ok), ssl_test_lib:close(Server), ssl_test_lib:close(Client), + Size = ets:info(CADb, size). - {status, _, _, StatusInfo} = sys:get_status(whereis(ssl_manager)), - [_, _,_, _, Prop] = StatusInfo, - State = ssl_test_lib:state(Prop), - [CADb | _] = element(6, State), - [] = ets:tab2list(CADb). - %%-------------------------------------------------------------------- der_input_opts(Opts) -> Certfile = proplists:get_value(certfile, Opts), @@ -3051,6 +3113,7 @@ hibernate(Config) -> {current_function, _} = process_info(Pid, current_function), + ssl_test_lib:check_result(Server, ok, Client, ok), timer:sleep(1100), {current_function, {erlang, hibernate, 3}} = @@ -3084,15 +3147,29 @@ hibernate_right_away(Config) -> Server1 = ssl_test_lib:start_server(StartServerOpts), Port1 = ssl_test_lib:inet_port(Server1), - {Client1, #sslsocket{}} = ssl_test_lib:start_client(StartClientOpts ++ + {Client1, #sslsocket{pid = Pid1}} = ssl_test_lib:start_client(StartClientOpts ++ [{port, Port1}, {options, [{hibernate_after, 0}|ClientOpts]}]), + + ssl_test_lib:check_result(Server1, ok, Client1, ok), + + {current_function, {erlang, hibernate, 3}} = + process_info(Pid1, current_function), + ssl_test_lib:close(Server1), ssl_test_lib:close(Client1), Server2 = ssl_test_lib:start_server(StartServerOpts), Port2 = ssl_test_lib:inet_port(Server2), - {Client2, #sslsocket{}} = ssl_test_lib:start_client(StartClientOpts ++ + {Client2, #sslsocket{pid = Pid2}} = ssl_test_lib:start_client(StartClientOpts ++ [{port, Port2}, {options, [{hibernate_after, 1}|ClientOpts]}]), + + ssl_test_lib:check_result(Server2, ok, Client2, ok), + + ct:sleep(100), %% Schedule out + + {current_function, {erlang, hibernate, 3}} = + process_info(Pid2, current_function), + ssl_test_lib:close(Server2), ssl_test_lib:close(Client2). @@ -3677,6 +3754,81 @@ basic_test(Config) -> ssl_test_lib:close(Server), ssl_test_lib:close(Client). +prf_create_plan(TlsVersions, PRFs, Results) -> + lists:foldl(fun(Ver, Acc) -> + A = prf_ciphers_and_expected(Ver, PRFs, Results), + [A|Acc] + end, [], TlsVersions). +prf_ciphers_and_expected(TlsVer, PRFs, Results) -> + case TlsVer of + TlsVer when TlsVer == sslv3 orelse TlsVer == tlsv1 + orelse TlsVer == 'tlsv1.1' -> + Ciphers = ssl:cipher_suites(), + {_, Expected} = lists:keyfind(md5sha, 1, Results), + [[{tls_ver, TlsVer}, {ciphers, Ciphers}, {expected, Expected}, {prf, md5sha}]]; + 'tlsv1.2' -> + lists:foldl( + fun(PRF, Acc) -> + Ciphers = prf_get_ciphers(TlsVer, PRF), + case Ciphers of + [] -> + ct:log("No ciphers for PRF algorithm ~p. Skipping.", [PRF]), + Acc; + Ciphers -> + {_, Expected} = lists:keyfind(PRF, 1, Results), + [[{tls_ver, TlsVer}, {ciphers, Ciphers}, {expected, Expected}, + {prf, PRF}] | Acc] + end + end, [], PRFs) + end. +prf_get_ciphers(TlsVer, PRF) -> + case TlsVer of + 'tlsv1.2' -> + lists:filter( + fun(C) when tuple_size(C) == 4 andalso + element(4, C) == PRF -> + true; + (_) -> false + end, ssl:cipher_suites()) + end. +prf_run_test(_, TlsVer, [], _, Prf) -> + ct:fail({error, cipher_list_empty, TlsVer, Prf}); +prf_run_test(Config, TlsVer, Ciphers, Expected, Prf) -> + {ClientNode, ServerNode, Hostname} = ssl_test_lib:run_where(Config), + BaseOpts = [{active, true}, {versions, [TlsVer]}, {ciphers, Ciphers}], + ServerOpts = BaseOpts ++ ?config(server_opts, Config), + ClientOpts = BaseOpts ++ ?config(client_opts, Config), + Server = ssl_test_lib:start_server( + [{node, ServerNode}, {port, 0}, {from, self()}, + {mfa, {?MODULE, prf_verify_value, [TlsVer, Expected, Prf]}}, + {options, ServerOpts}]), + Port = ssl_test_lib:inet_port(Server), + Client = ssl_test_lib:start_client( + [{node, ClientNode}, {port, Port}, + {host, Hostname}, {from, self()}, + {mfa, {?MODULE, prf_verify_value, [TlsVer, Expected, Prf]}}, + {options, ClientOpts}]), + ssl_test_lib:check_result(Server, ok, Client, ok), + ssl_test_lib:close(Server), + ssl_test_lib:close(Client). +prf_verify_value(Socket, TlsVer, Expected, Algo) -> + Ret = ssl:prf(Socket, <<>>, <<>>, [<<>>], 16), + case TlsVer of + sslv3 -> + case Ret of + {error, undefined} -> ok; + _ -> + {error, {expected, {error, undefined}, + got, Ret, tls_ver, TlsVer, prf_algorithm, Algo}} + end; + _ -> + case Ret of + {ok, Expected} -> ok; + {ok, Val} -> {error, {expected, Expected, got, Val, tls_ver, TlsVer, + prf_algorithm, Algo}} + end + end. + send_recv_result_timeout_client(Socket) -> {error, timeout} = ssl:recv(Socket, 11, 500), ssl:send(Socket, "Hello world"), diff --git a/lib/ssl/test/ssl_certificate_verify_SUITE.erl b/lib/ssl/test/ssl_certificate_verify_SUITE.erl index 66ccbb1da4..49c0b9c5a1 100644 --- a/lib/ssl/test/ssl_certificate_verify_SUITE.erl +++ b/lib/ssl/test/ssl_certificate_verify_SUITE.erl @@ -52,8 +52,8 @@ groups() -> {error_handling, [],error_handling_tests()}]. tests() -> - [server_verify_peer, - server_verify_none, + [verify_peer, + verify_none, server_require_peer_cert_ok, server_require_peer_cert_fail, server_require_peer_cert_partial_chain, @@ -110,6 +110,17 @@ init_per_group(_, Config) -> end_per_group(_GroupName, Config) -> Config. +init_per_testcase(TestCase, Config) when TestCase == cert_expired; + TestCase == invalid_signature_client; + TestCase == invalid_signature_server; + TestCase == extended_key_usage_verify_none; + TestCase == extended_key_usage_verify_peer; + TestCase == critical_extension_verify_none; + TestCase == critical_extension_verify_peer; + TestCase == no_authority_key_identifier; + TestCase == no_authority_key_identifier_and_nonstandard_encoding-> + ssl:clear_pem_cache(), + init_per_testcase(common, Config); init_per_testcase(_TestCase, Config) -> ct:log("TLS/SSL version ~p~n ", [tls_record:supported_protocol_versions()]), ct:timetrap({seconds, 5}), @@ -122,9 +133,9 @@ end_per_testcase(_TestCase, Config) -> %% Test Cases -------------------------------------------------------- %%-------------------------------------------------------------------- -server_verify_peer() -> - [{doc,"Test server option verify_peer"}]. -server_verify_peer(Config) when is_list(Config) -> +verify_peer() -> + [{doc,"Test option verify_peer"}]. +verify_peer(Config) when is_list(Config) -> ClientOpts = ?config(client_verification_opts, Config), ServerOpts = ?config(server_verification_opts, Config), Active = ?config(active, Config), @@ -147,10 +158,10 @@ server_verify_peer(Config) when is_list(Config) -> ssl_test_lib:close(Client). %%-------------------------------------------------------------------- -server_verify_none() -> - [{doc,"Test server option verify_none"}]. +verify_none() -> + [{doc,"Test option verify_none"}]. -server_verify_none(Config) when is_list(Config) -> +verify_none(Config) when is_list(Config) -> ClientOpts = ?config(client_verification_opts, Config), ServerOpts = ?config(server_verification_opts, Config), Active = ?config(active, Config), @@ -220,18 +231,21 @@ server_require_peer_cert_ok(Config) when is_list(Config) -> ServerOpts = [{verify, verify_peer}, {fail_if_no_peer_cert, true} | ?config(server_verification_opts, Config)], ClientOpts = ?config(client_verification_opts, Config), + Active = ?config(active, Config), + ReceiveFunction = ?config(receive_function, Config), {ClientNode, ServerNode, Hostname} = ssl_test_lib:run_where(Config), + Server = ssl_test_lib:start_server([{node, ServerNode}, {port, 0}, {from, self()}, - {mfa, {ssl_test_lib,send_recv_result, []}}, - {options, [{active, false} | ServerOpts]}]), + {mfa, {ssl_test_lib, ReceiveFunction, []}}, + {options, [{active, Active} | ServerOpts]}]), Port = ssl_test_lib:inet_port(Server), Client = ssl_test_lib:start_client([{node, ClientNode}, {port, Port}, {host, Hostname}, {from, self()}, - {mfa, {ssl_test_lib, send_recv_result, []}}, - {options, [{active, false} | ClientOpts]}]), + {mfa, {ssl_test_lib, ReceiveFunction, []}}, + {options, [{active, Active} | ClientOpts]}]), ssl_test_lib:check_result(Server, ok, Client, ok), ssl_test_lib:close(Server), @@ -313,6 +327,8 @@ server_require_peer_cert_allow_partial_chain(Config) when is_list(Config) -> | ?config(server_verification_opts, Config)], ClientOpts = ?config(client_verification_opts, Config), {ClientNode, ServerNode, Hostname} = ssl_test_lib:run_where(Config), + Active = ?config(active, Config), + ReceiveFunction = ?config(receive_function, Config), {ok, ServerCAs} = file:read_file(proplists:get_value(cacertfile, ServerOpts)), [{_,_,_}, {_, IntermidiateCA, _}] = public_key:pem_decode(ServerCAs), @@ -328,16 +344,17 @@ server_require_peer_cert_allow_partial_chain(Config) when is_list(Config) -> Server = ssl_test_lib:start_server([{node, ServerNode}, {port, 0}, {from, self()}, - {mfa, {ssl_test_lib, send_recv_result_active, []}}, - {options, [{cacerts, [IntermidiateCA]}, + {mfa, {ssl_test_lib, ReceiveFunction, []}}, + {options, [{active, Active}, + {cacerts, [IntermidiateCA]}, {partial_chain, PartialChain} | proplists:delete(cacertfile, ServerOpts)]}]), Port = ssl_test_lib:inet_port(Server), Client = ssl_test_lib:start_client([{node, ClientNode}, {port, Port}, {host, Hostname}, {from, self()}, - {mfa, {ssl_test_lib, send_recv_result_active, []}}, - {options, ClientOpts}]), + {mfa, {ssl_test_lib, ReceiveFunction, []}}, + {options, [{active, Active} | ClientOpts]}]), ssl_test_lib:check_result(Server, ok, Client, ok), ssl_test_lib:close(Server), ssl_test_lib:close(Client). @@ -522,32 +539,6 @@ verify_fun_always_run_server(Config) when is_list(Config) -> %%-------------------------------------------------------------------- -client_verify_none_passive() -> - [{doc,"Test client option verify_none"}]. - -client_verify_none_passive(Config) when is_list(Config) -> - ClientOpts = ?config(client_opts, Config), - ServerOpts = ?config(server_opts, Config), - {ClientNode, ServerNode, Hostname} = ssl_test_lib:run_where(Config), - Server = ssl_test_lib:start_server([{node, ServerNode}, {port, 0}, - {from, self()}, - {mfa, {ssl_test_lib, send_recv_result, []}}, - {options, [{active, false} - | ServerOpts]}]), - Port = ssl_test_lib:inet_port(Server), - - Client = ssl_test_lib:start_client([{node, ClientNode}, {port, Port}, - {host, Hostname}, - {from, self()}, - {mfa, {ssl_test_lib, send_recv_result, []}}, - {options, [{active, false}, - {verify, verify_none} - | ClientOpts]}]), - - ssl_test_lib:check_result(Server, ok, Client, ok), - ssl_test_lib:close(Server), - ssl_test_lib:close(Client). -%%-------------------------------------------------------------------- cert_expired() -> [{doc,"Test server with expired certificate"}]. @@ -616,64 +607,6 @@ two_digits_str(N) -> lists:flatten(io_lib:format("~p", [N])). %%-------------------------------------------------------------------- - -client_verify_none_active() -> - [{doc,"Test client option verify_none"}]. - -client_verify_none_active(Config) when is_list(Config) -> - ClientOpts = ?config(client_opts, Config), - ServerOpts = ?config(server_opts, Config), - {ClientNode, ServerNode, Hostname} = ssl_test_lib:run_where(Config), - Server = ssl_test_lib:start_server([{node, ServerNode}, {port, 0}, - {from, self()}, - {mfa, {ssl_test_lib, - send_recv_result_active, []}}, - {options, [{active, true} - | ServerOpts]}]), - Port = ssl_test_lib:inet_port(Server), - Client = ssl_test_lib:start_client([{node, ClientNode}, {port, Port}, - {host, Hostname}, - {from, self()}, - {mfa, {ssl_test_lib, - send_recv_result_active, []}}, - {options, [{active, true}, - {verify, verify_none} - | ClientOpts]}]), - - ssl_test_lib:check_result(Server, ok, Client, ok), - ssl_test_lib:close(Server), - ssl_test_lib:close(Client). - -%%-------------------------------------------------------------------- -client_verify_none_active_once() -> - [{doc,"Test client option verify_none"}]. - -client_verify_none_active_once(Config) when is_list(Config) -> - ClientOpts = ?config(client_opts, Config), - ServerOpts = ?config(server_opts, Config), - - {ClientNode, ServerNode, Hostname} = ssl_test_lib:run_where(Config), - Server = ssl_test_lib:start_server([{node, ServerNode}, {port, 0}, - {from, self()}, - {mfa, {ssl_test_lib, send_recv_result_active, []}}, - {options, [{active, once} | ServerOpts]}]), - Port = ssl_test_lib:inet_port(Server), - - Client = ssl_test_lib:start_client([{node, ClientNode}, {port, Port}, - {host, Hostname}, - {from, self()}, - {mfa, {ssl_test_lib, - send_recv_result_active_once, - []}}, - {options, [{active, once}, - {verify, verify_none} - | ClientOpts]}]), - - ssl_test_lib:check_result(Server, ok, Client, ok), - ssl_test_lib:close(Server), - ssl_test_lib:close(Client). - -%%-------------------------------------------------------------------- extended_key_usage_verify_peer() -> [{doc,"Test cert that has a critical extended_key_usage extension in verify_peer mode"}]. diff --git a/lib/ssl/test/ssl_test_lib.erl b/lib/ssl/test/ssl_test_lib.erl index db9e1c3d38..38cc3532d8 100644 --- a/lib/ssl/test/ssl_test_lib.erl +++ b/lib/ssl/test/ssl_test_lib.erl @@ -1041,10 +1041,13 @@ receive_rizzo_duong_beast() -> end end. -state([{data,[{"State", State}]} | _]) -> - State; -state([{data,[{"StateData", State}]} | _]) -> + +state([{data,[{"State", {_StateName, StateData}}]} | _]) -> %% gen_statem + StateData; +state([{data,[{"State", State}]} | _]) -> %% gen_server State; +state([{data,[{"StateData", State}]} | _]) -> %% gen_fsm + State; state([_ | Rest]) -> state(Rest). diff --git a/lib/ssl/vsn.mk b/lib/ssl/vsn.mk index 8c732002de..3b51fa8c6b 100644 --- a/lib/ssl/vsn.mk +++ b/lib/ssl/vsn.mk @@ -1 +1 @@ -SSL_VSN = 7.3.1 +SSL_VSN = 8.0 diff --git a/lib/stdlib/doc/src/gen_statem.xml b/lib/stdlib/doc/src/gen_statem.xml index ec7f267c64..b1d9799917 100644 --- a/lib/stdlib/doc/src/gen_statem.xml +++ b/lib/stdlib/doc/src/gen_statem.xml @@ -29,39 +29,49 @@ <rev></rev> </header> <module>gen_statem</module> - <modulesummary>Generic State Machine Behaviour</modulesummary> + <modulesummary>Generic state machine behavior.</modulesummary> <description> <p> - A behaviour module for implementing a state machine. Two + This behavior module provides a state machine. Two <seealso marker="#type-callback_mode"><em>callback modes</em></seealso> - are supported. One for finite state machines - (<seealso marker="gen_fsm"><c>gen_fsm</c></seealso> like) - that requires the state to be an atom and uses that state as - the name of the current callback function, - and one without restriction on the state data type - that uses one callback function for all states. - </p> - <p> - This is a new behaviour in OTP-19.0. - It has been thoroughly reviewed, is stable enough - to be used by at least two heavy OTP applications, and is here to stay. - But depending on user feedback, we do not expect - but might find it necessary to make minor - not backwards compatible changes into OTP-20.0, - so its state can be designated as "not quite experimental"... + are supported: </p> + <list type="bulleted"> + <item> + <p>One for finite-state machines + (<seealso marker="gen_fsm"><c>gen_fsm</c></seealso> like), + which requires the state to be an atom and uses that state as + the name of the current callback function + </p> + </item> + <item> + <p>One without restriction on the state data type + that uses one callback function for all states + </p> + </item> + </list> + <note> + <p> + This is a new behavior in Erlang/OTP 19.0. + It has been thoroughly reviewed, is stable enough + to be used by at least two heavy OTP applications, and is here to stay. + Depending on user feedback, we do not expect + but can find it necessary to make minor + not backward compatible changes into Erlang/OTP 20.0. + </p> + </note> <p> - The <c>gen_statem</c> behaviour is intended to replace + The <c>gen_statem</c> behavior is intended to replace <seealso marker="gen_fsm"><c>gen_fsm</c></seealso> for new code. - It has the same features and add some really useful: + It has the same features and adds some really useful: </p> <list type="bulleted"> - <item>State code is gathered</item> - <item>The state can be any term</item> - <item>Events can be postponed</item> - <item>Events can be self generated</item> - <item>A reply can be sent from a later state</item> - <item>There can be multiple sys traceable replies</item> + <item>State code is gathered.</item> + <item>The state can be any term.</item> + <item>Events can be postponed.</item> + <item>Events can be self-generated.</item> + <item>A reply can be sent from a later state.</item> + <item>There can be multiple <c>sys</c> traceable replies.</item> </list> <p> The callback model(s) for <c>gen_statem</c> differs from @@ -71,19 +81,16 @@ </p> <p> A generic state machine process (<c>gen_statem</c>) implemented - using this module will have a standard set of interface functions - and include functionality for tracing and error reporting. - It will also fit into an OTP supervision tree. Refer to - <seealso marker="doc/design_principles:statem"> - OTP Design Principles - </seealso> - for more information. + using this module has a standard set of interface functions + and includes functionality for tracing and error reporting. + It also fits into an OTP supervision tree. For more information, see + <seealso marker="doc/design_principles:statem">OTP Design Principles</seealso>. </p> <p> A <c>gen_statem</c> assumes all specific parts to be located in a - callback module exporting a pre-defined set of functions. - The relationship between the behaviour functions and the callback - functions can be illustrated as follows:</p> + callback module exporting a predefined set of functions. + The relationship between the behavior functions and the callback + functions is as follows:</p> <pre> gen_statem module Callback module ----------------- --------------- @@ -103,59 +110,54 @@ erlang:'!' -----> Module:StateName/3 - -----> Module:code_change/4</pre> <p> Events are of different - <seealso marker="#type-event_type">types</seealso> + <seealso marker="#type-event_type">types</seealso>, so the callback functions can know the origin of an event and how to respond. </p> <p> If a callback function fails or returns a bad value, - the <c>gen_statem</c> will terminate. An exception of class - <seealso marker="erts:erlang#throw/1"><c>throw</c></seealso>, - however, is not regarded as an error but as a valid return. + the <c>gen_statem</c> terminates. However, an exception of class + <seealso marker="erts:erlang#throw/1"><c>throw</c></seealso> + is not regarded as an error but as a valid return. </p> - <marker id="state_function" /> + <marker id="state_function"/> <p> The "<em>state function</em>" for a specific <seealso marker="#type-state">state</seealso> in a <c>gen_statem</c> is the callback function that is called - for all events in this state, and is selected depending on which + for all events in this state. It is selected depending on which <seealso marker="#type-callback_mode"><em>callback mode</em></seealso> - that the implementation specifies when the the server starts. + that the implementation specifies when the server starts. </p> <p> When the <seealso marker="#type-callback_mode"><em>callback mode</em></seealso> - is <c>state_functions</c>, the state has to be an atom and - is used as the state function name. See - <seealso marker="#Module:StateName/3"> - <c>Module:StateName/3</c> - </seealso>. + is <c>state_functions</c>, the state must be an atom and + is used as the state function name; see + <seealso marker="#Module:StateName/3"><c>Module:StateName/3</c></seealso>. This gathers all code for a specific state in one function and hence dispatches on state first. - Note that in this mode the fact that there is - a mandatory callback function - <seealso marker="#Module:terminate/3"> - <c>Module:terminate/3</c> - </seealso> makes the state name <c>terminate</c> unusable. + Notice that in this mode + the mandatory callback function + <seealso marker="#Module:terminate/3"><c>Module:terminate/3</c></seealso> + makes the state name <c>terminate</c> unusable. </p> <p> When the <seealso marker="#type-callback_mode"><em>callback mode</em></seealso> - is <c>handle_event_function</c> the state can be any term + is <c>handle_event_function</c>, the state can be any term and the state function name is - <seealso marker="#Module:handle_event/4"> - <c>Module:handle_event/4</c> - </seealso>. + <seealso marker="#Module:handle_event/4"><c>Module:handle_event/4</c></seealso>. This makes it easy to dispatch on state or on event as you desire. Be careful about which events you handle in which - states so you do not accidentally postpone one event + states so that you do not accidentally postpone an event forever creating an infinite busy loop. </p> <p> The <c>gen_statem</c> enqueues incoming events in order of arrival and presents these to the <seealso marker="#state_function">state function</seealso> - in that order. The state function can postpone an event + in that order. The state function can postpone an event so it is not retried in the current state. After a state change the queue restarts with the postponed events. </p> @@ -163,91 +165,85 @@ erlang:'!' -----> Module:StateName/3 The <c>gen_statem</c> event queue model is sufficient to emulate the normal process message queue with selective receive. Postponing an event corresponds to not matching it - in a receive statement and changing states corresponds + in a receive statement, and changing states corresponds to entering a new receive statement. </p> <p> The <seealso marker="#state_function">state function</seealso> can insert events using the - <seealso marker="#type-action"> - <c>action()</c> <c>next_event</c> - </seealso> + <seealso marker="#type-action"><c>action()</c></seealso> + <c>next_event</c> and such an event is inserted as the next to present - to the state function. That is: as if it is - the oldest incoming event. There is a dedicated - <seealso marker="#type-event_type"> - <c>event_type()</c> - </seealso> - <c>internal</c> that can be used for such events making them impossible + to the state function. That is, as if it is + the oldest incoming event. A dedicated + <seealso marker="#type-event_type"><c>event_type()</c></seealso> + <c>internal</c> can be used for such events making them impossible to mistake for external events. </p> <p> Inserting an event replaces the trick of calling your own state handling functions that you often would have to - resort to in for example <seealso marker="gen_fsm"><c>gen_fsm</c></seealso> + resort to in, for example, + <seealso marker="gen_fsm"><c>gen_fsm</c></seealso> to force processing an inserted event before others. - A warning, though: if you in <c>gen_statem</c> for example - postpone an event in one state and then call some other state function of yours, - you have not changed states and hence the postponed event will not be retried, - which is logical but might be confusing. </p> + <note> + <p>If you in <c>gen_statem</c>, for example, postpone + an event in one state and then call another state function + of yours, you have not changed states and hence the postponed event + is not retried, which is logical but can be confusing. + </p> + </note> <p> - See the type - <seealso marker="#type-transition_option"> - <c>transition_option()</c> - </seealso> - for the details of a state transition. + For the details of a state transition, see type + <seealso marker="#type-transition_option"><c>transition_option()</c></seealso>. </p> <p> - A <c>gen_statem</c> handles system messages as documented in + A <c>gen_statem</c> handles system messages as described in <seealso marker="sys"><c>sys</c></seealso>. - The <c>sys</c>module can be used for debugging a <c>gen_statem</c>. + The <c>sys</c> module can be used for debugging a <c>gen_statem</c>. </p> <p> - Note that a <c>gen_statem</c> does not trap exit signals + Notice that a <c>gen_statem</c> does not trap exit signals automatically, this must be explicitly initiated in the callback module (by calling - <seealso marker="erts:erlang#process_flag/2"> - <c>process_flag(trap_exit, true)</c></seealso>. + <seealso marker="erts:erlang#process_flag/2"><c>process_flag(trap_exit, true)</c></seealso>. </p> <p> Unless otherwise stated, all functions in this module fail if the specified <c>gen_statem</c> does not exist or - if bad arguments are given. + if bad arguments are specified. </p> <p> The <c>gen_statem</c> process can go into hibernation; see - <seealso marker="proc_lib#hibernate/3"> - <c>proc_lib:hibernate/3</c>. - </seealso> + <seealso marker="proc_lib#hibernate/3"><c>proc_lib:hibernate/3</c></seealso>. It is done when a <seealso marker="#state_function">state function</seealso> or <seealso marker="#Module:init/1"><c>Module:init/1</c></seealso> specifies <c>hibernate</c> in the returned <seealso marker="#type-action"><c>Actions</c></seealso> - list. This feature might be useful to reclaim process heap memory + list. This feature can be useful to reclaim process heap memory while the server is expected to be idle for a long time. - However, use this feature with care - since hibernation can be too costly + However, use this feature with care, + as hibernation can be too costly to use after every event; see - <seealso marker="erts:erlang#hibernate/3"> - <c>erlang:hibernate/3</c>. - </seealso> + <seealso marker="erts:erlang#hibernate/3"><c>erlang:hibernate/3</c></seealso>. </p> </description> <section> - <title>EXAMPLE</title> + <title>Example</title> <p> - This example shows a simple pushbutton model + The following example shows a simple pushbutton model for a toggling pushbutton implemented with <seealso marker="#type-callback_mode"><em>callback mode</em></seealso> <c>state_functions</c>. You can push the button and it replies if it went on or off, and you can ask for a count of how many times it has been - pushed to on. + pushed to switch on. </p> - <p>This is the complete callback module file <c>pushbutton.erl</c>:</p> + <p>The following is the complete callback module file + <c>pushbutton.erl</c>:</p> <code type="erl"> -module(pushbutton). -behaviour(gen_statem). @@ -305,7 +301,7 @@ handle_event(_, _, Data) -> %% Ignore all other events {keep_state,Data}. </code> - <p>And this is a shell session when running it:</p> + <p>The following is a shell session when running it:</p> <pre> 1> pushbutton:start(). {ok,<0.36.0>} @@ -326,12 +322,11 @@ ok in function gen:do_for_proc/2 (gen.erl, line 261) in call from gen_statem:call/3 (gen_statem.erl, line 386) </pre> - <p> - And just to compare styles here is the same example using + To compare styles, here follows the same example using <seealso marker="#type-callback_mode"><em>callback mode</em></seealso> - <c>state_functions</c>, or rather here is code to replace - from the <c>init/1</c> function of the <c>pushbutton.erl</c> + <c>state_functions</c>, or rather the code to replace + from function <c>init/1</c> of the <c>pushbutton.erl</c> example file above: </p> <code type="erl"> @@ -364,107 +359,108 @@ handle_event(_, _, State, Data) -> <datatypes> <datatype> - <name name="server_name" /> + <name name="server_name"/> <desc> <p> Name specification to use when starting - a <c>gen_statem</c> server. See - <seealso marker="#start_link/3"> - <c>start_link/3</c> - </seealso> + a <c>gen_statem</c> server. See + <seealso marker="#start_link/3"><c>start_link/3</c></seealso> and - <seealso marker="#type-server_ref"> - <c>server_ref()</c> - </seealso> below. + <seealso marker="#type-server_ref"><c>server_ref()</c></seealso> + below. </p> </desc> </datatype> <datatype> - <name name="server_ref" /> + <name name="server_ref"/> <desc> <p> Server specification to use when addressing a <c>gen_statem</c> server. See <seealso marker="#call/2"><c>call/2</c></seealso> and - <seealso marker="#type-server_name"> - <c>server_name()</c> - </seealso> + <seealso marker="#type-server_name"><c>server_name()</c></seealso> above. </p> <p>It can be:</p> <taglist> - <tag><c>pid()</c><br /> - <c>LocalName</c></tag> - <item>The <c>gen_statem</c> is locally registered.</item> - <tag><c>Name, Node</c></tag> + <tag><c>pid() | LocalName</c></tag> <item> - The <c>gen_statem</c> is locally registered - on another node. + <p> + The <c>gen_statem</c> is locally registered. + </p> + </item> + <tag><c>{Name,Node}</c></tag> + <item> + <p> + The <c>gen_statem</c> is locally registered + on another node. + </p> </item> - <tag><c>GlobalName</c></tag> + <tag><c>{global,GlobalName}</c></tag> <item> - The <c>gen_statem</c> is globally registered - in <seealso marker="kernel:global"><c>global</c></seealso>. + <p> + The <c>gen_statem</c> is globally registered in + <seealso marker="kernel:global"><c>kernel:global</c></seealso>. + </p> </item> - <tag><c>RegMod, ViaName</c></tag> + <tag><c>{via,RegMod,ViaName}</c></tag> <item> - The <c>gen_statem</c> is registered through - an alternative process registry. - The registry callback module <c>RegMod</c> - should export the functions - <c>register_name/2</c>, <c>unregister_name/1</c>, - <c>whereis_name/1</c> and <c>send/2</c>, - which should behave like the corresponding functions - in <seealso marker="kernel:global"><c>global</c></seealso>. - Thus, <c>{via,global,GlobalName}</c> is the same as - <c>{global,GlobalName}</c>. + <p> + The <c>gen_statem</c> is registered in + an alternative process registry. + The registry callback module <c>RegMod</c> + is to export functions + <c>register_name/2</c>, <c>unregister_name/1</c>, + <c>whereis_name/1</c>, and <c>send/2</c>, + which are to behave like the corresponding functions in + <seealso marker="kernel:global"><c>kernel:global</c></seealso>. + Thus, <c>{via,global,GlobalName}</c> is the same as + <c>{global,GlobalName}</c>. + </p> </item> </taglist> </desc> </datatype> <datatype> - <name name="debug_opt" /> + <name name="debug_opt"/> <desc> <p> Debug option that can be used when starting - a <c>gen_statem</c> server through for example + a <c>gen_statem</c> server through, for example, <seealso marker="#enter_loop/5"><c>enter_loop/5</c></seealso>. </p> <p> - For every entry in <c><anno>Dbgs</anno></c> + For every entry in <c><anno>Dbgs</anno></c>, the corresponding function in - <seealso marker="sys"><c>sys</c></seealso> will be called. + <seealso marker="sys"><c>sys</c></seealso> is called. </p> </desc> </datatype> <datatype> - <name name="start_opt" /> + <name name="start_opt"/> <desc> <p> Options that can be used when starting - a <c>gen_statem</c> server through for example + a <c>gen_statem</c> server through, for example, <seealso marker="#start_link/3"><c>start_link/3</c></seealso>. </p> </desc> </datatype> <datatype> - <name name="start_ret" /> + <name name="start_ret"/> <desc> <p> - Return value from the start functions for_example + Return value from the start functions, for example, <seealso marker="#start_link/3"><c>start_link/3</c></seealso>. </p> </desc> </datatype> - <datatype> - <name name="from" /> + <name name="from"/> <desc> <p> - Destination to use when replying through for example the - <seealso marker="#type-action"> - <c>action()</c> - </seealso> + Destination to use when replying through, for example, the + <seealso marker="#type-action"><c>action()</c></seealso> <c>{reply,From,Reply}</c> to a process that has called the <c>gen_statem</c> server using <seealso marker="#call/2"><c>call/2</c></seealso>. @@ -472,231 +468,228 @@ handle_event(_, _, State, Data) -> </desc> </datatype> <datatype> - <name name="state" /> + <name name="state"/> <desc> <p> - After a state change (<c>NextState =/= State</c>) + After a state change (<c>NextState =/= State</c>), all postponed events are retried. </p> </desc> </datatype> <datatype> - <name name="state_name" /> + <name name="state_name"/> <desc> <p> If the <seealso marker="#type-callback_mode"><em>callback mode</em></seealso> is <c>state_functions</c>, - the state has to be of this type. + the state must be of this type. </p> </desc> </datatype> <datatype> - <name name="data" /> + <name name="data"/> <desc> <p> A term in which the state machine implementation - should store any server data it needs. The difference between + is to store any server data it needs. The difference between this and the <seealso marker="#type-state"><c>state()</c></seealso> itself is that a change in this data does not cause - postponed events to be retried. Hence if a change + postponed events to be retried. Hence, if a change in this data would change the set of events that - are handled than that data item should be made + are handled, then that data item is to be made a part of the state. </p> </desc> </datatype> <datatype> - <name name="event_type" /> + <name name="event_type"/> <desc> <p> - External events are of 3 different type: - <c>{call,<anno>From</anno>}</c>, <c>cast</c> or <c>info</c>. + External events are of three types: + <c>{call,<anno>From</anno>}</c>, <c>cast</c>, or <c>info</c>. <seealso marker="#call/2">Calls</seealso> (synchronous) and <seealso marker="#cast/2">casts</seealso> originate from the corresponding API functions. - For calls the event contain whom to reply to. + For calls, the event contains whom to reply to. Type <c>info</c> originates from regular process messages sent - to the <c>gen_statem</c>. It is also possible for the state machine - implementation to generate events of types + to the <c>gen_statem</c>. Also, the state machine + implementation can generate events of types <c>timeout</c> and <c>internal</c> to itself. </p> </desc> </datatype> <datatype> - <name name="callback_mode" /> + <name name="callback_mode"/> <desc> <p> The <em>callback mode</em> is selected when starting the <c>gen_statem</c> using the return value from <seealso marker="#Module:init/1"><c>Module:init/1</c></seealso> or when calling - <seealso marker="#enter_loop/5"><c>enter_loop/5-7</c></seealso>, + <seealso marker="#enter_loop/5"><c>enter_loop/5,6,7</c></seealso>, and with the return value from - <seealso marker="#Module:code_change/4"> - <c>Module:code_change/4</c>. - </seealso> + <seealso marker="#Module:code_change/4"><c>Module:code_change/4</c></seealso>. </p> <taglist> <tag><c>state_functions</c></tag> <item> - The state has to be of type - <seealso marker="#type-state_name"><c>state_name()</c></seealso> - and one callback function per state that is - <seealso marker="#Module:StateName/3"> - <c>Module:StateName/3</c> - </seealso> - is used. + <p> + The state must be of type + <seealso marker="#type-state_name"><c>state_name()</c></seealso> + and one callback function per state, that is, + <seealso marker="#Module:StateName/3"><c>Module:StateName/3</c></seealso>, + is used. + </p> </item> <tag><c>handle_event_function</c></tag> <item> - The state can be any term and the callback function - <seealso marker="#Module:handle_event/4"> - <c>Module:handle_event/4</c> - </seealso> - is used for all states. + <p> + The state can be any term and the callback function + <seealso marker="#Module:handle_event/4"><c>Module:handle_event/4</c></seealso> + is used for all states. + </p> </item> </taglist> </desc> </datatype> <datatype> - <name name="transition_option" /> + <name name="transition_option"/> <desc> <p> - Transition options may be set by + Transition options can be set by <seealso marker="#type-action">actions</seealso> - and they modify some details below in how + and they modify the following in how the state transition is done: </p> <list type="ordered"> <item> - All - <seealso marker="#type-action">actions</seealso> - are processed in order of appearance. + <p> + All + <seealso marker="#type-action">actions</seealso> + are processed in order of appearance. + </p> </item> <item> - If - <seealso marker="#type-postpone"> - <c>postpone()</c> - </seealso> - is <c>true</c> - the current event is postponed. + <p> + If + <seealso marker="#type-postpone"><c>postpone()</c></seealso> + is <c>true</c>, + the current event is postponed. + </p> </item> <item> - If the state changes the queue of incoming events - is reset to start with the oldest postponed. + <p> + If the state changes, the queue of incoming events + is reset to start with the oldest postponed. + </p> </item> <item> - All events stored with - <seealso marker="#type-action"> - <c>action()</c> - </seealso> - <c>next_event</c> - are inserted in the queue to be processed before - all other events. + <p> + All events stored with + <seealso marker="#type-action"><c>action()</c></seealso> + <c>next_event</c> + are inserted in the queue to be processed before + all other events. + </p> </item> <item> - If an - <seealso marker="#type-event_timeout"> - <c>event_timeout()</c> - </seealso> - is set through - <seealso marker="#type-action"> - <c>action()</c> - </seealso> - <c>timeout</c> - an event timer may be started or a timeout zero event - may be enqueued. + <p> + If an + <seealso marker="#type-event_timeout"><c>event_timeout()</c></seealso> + is set through + <seealso marker="#type-action"><c>action()</c></seealso> + <c>timeout</c>, + an event timer can be started or a time-out zero event + can be enqueued. + </p> </item> <item> - The (possibly new) - <seealso marker="#state_function">state function</seealso> - is called with the oldest enqueued event if there is any, - otherwise the <c>gen_statem</c> goes into <c>receive</c> - or hibernation - (if - <seealso marker="#type-hibernate"> - <c>hibernate()</c> - </seealso> - is <c>true</c>) - to wait for the next message. In hibernation the next - non-system event awakens the <c>gen_statem</c>, or rather - the next incoming message awakens the <c>gen_statem</c> - but if it is a system event - it goes right back into hibernation. + <p> + The (possibly new) + <seealso marker="#state_function">state function</seealso> + is called with the oldest enqueued event if there is any, + otherwise the <c>gen_statem</c> goes into <c>receive</c> + or hibernation + (if + <seealso marker="#type-hibernate"><c>hibernate()</c></seealso> + is <c>true</c>) + to wait for the next message. In hibernation the next + non-system event awakens the <c>gen_statem</c>, or rather + the next incoming message awakens the <c>gen_statem</c>, + but if it is a system event + it goes right back into hibernation. + </p> </item> </list> </desc> </datatype> <datatype> - <name name="postpone" /> + <name name="postpone"/> <desc> <p> - If <c>true</c> postpone the current event and retry + If <c>true</c>, postpones the current event and retries it when the state changes (<c>NextState =/= State</c>). </p> </desc> </datatype> <datatype> - <name name="hibernate" /> + <name name="hibernate"/> <desc> <p> - If <c>true</c> hibernate the <c>gen_statem</c> + If <c>true</c>, hibernates the <c>gen_statem</c> by calling - <seealso marker="proc_lib#hibernate/3"> - <c>proc_lib:hibernate/3</c> - </seealso> + <seealso marker="proc_lib#hibernate/3"><c>proc_lib:hibernate/3</c></seealso> before going into <c>receive</c> to wait for a new external event. If there are enqueued events, - to prevent receiving any new event; a - <seealso marker="erts:erlang#garbage_collect/0"> - <c>garbage_collect/0</c> - </seealso> is done instead to simulate + to prevent receiving any new event, an + <seealso marker="erts:erlang#garbage_collect/0"><c>erlang:garbage_collect/0</c></seealso> + is done instead to simulate that the <c>gen_statem</c> entered hibernation and immediately got awakened by the oldest enqueued event. </p> </desc> </datatype> <datatype> - <name name="event_timeout" /> + <name name="event_timeout"/> <desc> <p> - Generate an event of + Generates an event of <seealso marker="#type-event_type"><c>event_type()</c></seealso> <c>timeout</c> - after this time (in milliseconds) unless some other - event arrives in which case this timeout is cancelled. - Note that a retried or inserted event - counts just like a new in this respect. + after this time (in milliseconds) unless another + event arrives in which case this time-out is cancelled. + Notice that a retried or inserted event + counts like a new in this respect. </p> <p> - If the value is <c>infinity</c> no timer is started since - it will never trigger anyway. + If the value is <c>infinity</c>, no timer is started, as + it never triggers anyway. </p> <p> - If the value is <c>0</c> the timeout event is immediately enqueued - unless there already are enqueued events since then the - timeout is immediately cancelled. - This is a feature ensuring that a timeout <c>0</c> event - will be processed before any not yet received external event. + If the value is <c>0</c>, the time-out event is immediately enqueued + unless there already are enqueued events, as the + time-out is then immediately cancelled. + This is a feature ensuring that a time-out <c>0</c> event + is processed before any not yet received external event. </p> <p> - Note that it is not possible nor needed to cancel this timeout - since it is cancelled automatically by any other event. + Notice that it is not possible or needed to cancel this time-out, + as it is cancelled automatically by any other event. </p> </desc> </datatype> <datatype> - <name name="action" /> + <name name="action"/> <desc> <p> - These state transition actions may be invoked by + These state transition actions can be invoked by returning them from the - <seealso marker="#state_function">state function</seealso>, - from <seealso marker="#Module:init/1"><c>Module:init/1</c></seealso> + <seealso marker="#state_function">state function</seealso>, from + <seealso marker="#Module:init/1"><c>Module:init/1</c></seealso> or by giving them to <seealso marker="#enter_loop/6"><c>enter_loop/6,7</c></seealso>. </p> @@ -705,91 +698,81 @@ handle_event(_, _, State, Data) -> </p> <p> Actions that set - <seealso marker="#type-transition_option"> - transition options - </seealso> - overrides any previous of the same type, + <seealso marker="#type-transition_option">transition options</seealso> + override any previous of the same type, so the last in the containing list wins. - For example the last - <seealso marker="#type-event_timeout"> - <c>event_timeout()</c> - </seealso> + For example, the last + <seealso marker="#type-event_timeout"><c>event_timeout()</c></seealso> overrides any other <c>event_timeout()</c> in the list. </p> <taglist> <tag><c>postpone</c></tag> <item> - Set the - <seealso marker="#type-transition_option"> - <c>transition_option()</c> - </seealso> - <seealso marker="#type-postpone"> - <c>postpone()</c> - </seealso> - for this state transition. - This action is ignored when returned from - <seealso marker="#Module:init/1"><c>Module:init/1</c></seealso> - or given to - <seealso marker="#enter_loop/5"><c>enter_loop/5,6</c></seealso> - since there is no event to postpone in those cases. + <p> + Sets the + <seealso marker="#type-transition_option"><c>transition_option()</c></seealso> + <seealso marker="#type-postpone"><c>postpone()</c></seealso> + for this state transition. + This action is ignored when returned from + <seealso marker="#Module:init/1"><c>Module:init/1</c></seealso> + or given to + <seealso marker="#enter_loop/5"><c>enter_loop/5,6</c></seealso>, + as there is no event to postpone in those cases. + </p> </item> <tag><c>hibernate</c></tag> <item> - Set the - <seealso marker="#type-transition_option"> - <c>transition_option()</c> - </seealso> - <seealso marker="#type-hibernate"> - <c>hibernate()</c> - </seealso> - for this state transition. + <p> + Sets the + <seealso marker="#type-transition_option"><c>transition_option()</c></seealso> + <seealso marker="#type-hibernate"><c>hibernate()</c></seealso> + for this state transition. + </p> </item> <tag><c>Timeout</c></tag> <item> - Short for <c>{timeout,Timeout,Timeout}</c> that is - the timeout message is the timeout time. - This form exists to make the - <seealso marker="#state_function">state function</seealso> - return value <c>{next_state,NextState,NewData,Timeout}</c> - allowed like for - <seealso marker="gen_fsm#Module:StateName/2"> - <c>gen_fsm Module:StateName/2</c>. - </seealso> + <p> + Short for <c>{timeout,Timeout,Timeout}</c>, that is, + the time-out message is the time-out time. + This form exists to make the + <seealso marker="#state_function">state function</seealso> + return value <c>{next_state,NextState,NewData,Timeout}</c> + allowed like for <c>gen_fsm</c>'s + <seealso marker="gen_fsm#Module:StateName/2"><c>Module:StateName/2</c></seealso>. + </p> </item> <tag><c>timeout</c></tag> <item> - Set the - <seealso marker="#type-transition_option"> - <c>transition_option()</c> - </seealso> - <seealso marker="#type-event_timeout"> - <c>event_timeout()</c> - </seealso> - to <c><anno>Time</anno></c> with <c><anno>EventContent</anno></c>. + <p> + Sets the + <seealso marker="#type-transition_option"><c>transition_option()</c></seealso> + <seealso marker="#type-event_timeout"><c>event_timeout()</c></seealso> + to <c><anno>Time</anno></c> with <c><anno>EventContent</anno></c>. + </p> </item> <tag><c>reply_action()</c></tag> - <item>Reply to a caller.</item> + <item> + <p> + Replies to a caller. + </p> + </item> <tag><c>next_event</c></tag> <item> - Store the given <c><anno>EventType</anno></c> + <p> + Stores the specified <c><anno>EventType</anno></c> and <c><anno>EventContent</anno></c> for insertion after all actions have been executed. - </item> - <item> + </p> <p> The stored events are inserted in the queue as the next to process - before any already queued events. The order of these stored events - is preserved so the first <c>next_event</c> in the containing list - will become the first to process. + before any already queued events. The order of these stored events + is preserved, so the first <c>next_event</c> in the containing + list becomes the first to process. </p> - </item> - <item> <p> An event of type - <seealso marker="#type-event_type"> - <c>internal</c> - </seealso> - should be used when you want to reliably distinguish + <seealso marker="#type-event_type"><c>internal</c></seealso> + is to be used when you want to reliably distinguish an event inserted this way from any external event. </p> </item> @@ -797,303 +780,126 @@ handle_event(_, _, State, Data) -> </desc> </datatype> <datatype> - <name name="reply_action" /> + <name name="reply_action"/> <desc> <p> - Reply to a caller waiting for a reply in + Replies to a caller waiting for a reply in <seealso marker="#call/2"><c>call/2</c></seealso>. - <c><anno>From</anno></c> must be the term from the - <seealso marker="#type-event_type"> - <c>{call,<anno>From</anno>}</c> - </seealso> - argument to the + <c><anno>From</anno></c> must be the term from argument + <seealso marker="#type-event_type"><c>{call,<anno>From</anno>}</c></seealso> + to the <seealso marker="#state_function">state function</seealso>. </p> </desc> </datatype> <datatype> - <name name="state_function_result" /> + <name name="state_function_result"/> <desc> <taglist> <tag><c>next_state</c></tag> <item> - The <c>gen_statem</c> will do a state transition to - <c><anno>NextStateName</anno></c> - (which may be the same as the current state), - set <c><anno>NewData</anno></c> - and execute all <c><anno>Actions</anno></c> + <p> + The <c>gen_statem</c> does a state transition to + <c><anno>NextStateName</anno></c> + (which can be the same as the current state), + sets <c><anno>NewData</anno></c>, + and executes all <c><anno>Actions</anno></c>. + </p> </item> </taglist> <p> All these terms are tuples or atoms and this property - will hold in any future version of <c>gen_statem</c>, - just in case you need such a promise. + will hold in any future version of <c>gen_statem</c>. </p> </desc> </datatype> <datatype> - <name name="handle_event_result" /> + <name name="handle_event_result"/> <desc> <taglist> <tag><c>next_state</c></tag> <item> - The <c>gen_statem</c> will do a state transition to - <c><anno>NextState</anno></c> - (which may be the same as the current state), - set <c><anno>NewData</anno></c> - and execute all <c><anno>Actions</anno></c> + <p> + The <c>gen_statem</c> does a state transition to + <c><anno>NextState</anno></c> + (which can be the same as the current state), + sets <c><anno>NewData</anno></c>, + and executes all <c><anno>Actions</anno></c>. + </p> </item> </taglist> <p> All these terms are tuples or atoms and this property - will hold in any future version of <c>gen_statem</c>, - just in case you need such a promise. + will hold in any future version of <c>gen_statem</c>. </p> </desc> </datatype> <datatype> - <name name="common_state_callback_result" /> + <name name="common_state_callback_result"/> <desc> <taglist> <tag><c>stop</c></tag> <item> - Terminate the <c>gen_statem</c> by calling - <seealso marker="#Module:terminate/3"> - <c>Module:terminate/3</c> - </seealso> - with <c>Reason</c> and - <c><anno>NewData</anno></c>, if given. + <p> + Terminates the <c>gen_statem</c> by calling + <seealso marker="#Module:terminate/3"><c>Module:terminate/3</c></seealso> + with <c>Reason</c> and + <c><anno>NewData</anno></c>, if specified. + </p> </item> <tag><c>stop_and_reply</c></tag> <item> - Send all <c><anno>Replies</anno></c> - then terminate the <c>gen_statem</c> by calling - <seealso marker="#Module:terminate/3"> - <c>Module:terminate/3</c> - </seealso> - with <c>Reason</c> and - <c><anno>NewData</anno></c>, if given. + <p> + Sends all <c><anno>Replies</anno></c>, + then terminates the <c>gen_statem</c> by calling + <seealso marker="#Module:terminate/3"><c>Module:terminate/3</c></seealso> + with <c>Reason</c> and + <c><anno>NewData</anno></c>, if specified. + </p> </item> <tag><c>keep_state</c></tag> <item> - The <c>gen_statem</c> will keep the current state, or - do a state transition to the current state if you like, - set <c><anno>NewData</anno></c> - and execute all <c><anno>Actions</anno></c>. - This is the same as - <c>{next_state,CurrentState,<anno>NewData</anno>,<anno>Actions</anno>}</c>. + <p> + The <c>gen_statem</c> keeps the current state, or + does a state transition to the current state if you like, + sets <c><anno>NewData</anno></c>, + and executes all <c><anno>Actions</anno></c>. + This is the same as + <c>{next_state,CurrentState,<anno>NewData</anno>,<anno>Actions</anno>}</c>. + </p> </item> <tag><c>keep_state_and_data</c></tag> <item> - The <c>gen_statem</c> will keep the current state or - do a state transition to the current state if you like, - keep the current server data, - and execute all <c><anno>Actions</anno></c>. - This is the same as - <c>{next_state,CurrentState,CurrentData,<anno>Actions</anno>}</c>. + <p> + The <c>gen_statem</c> keeps the current state or + does a state transition to the current state if you like, + keeps the current server data, + and executes all <c><anno>Actions</anno></c>. + This is the same as + <c>{next_state,CurrentState,CurrentData,<anno>Actions</anno>}</c>. + </p> </item> </taglist> <p> All these terms are tuples or atoms and this property - will hold in any future version of <c>gen_statem</c>, - just in case you need such a promise. + will hold in any future version of <c>gen_statem</c>. </p> </desc> </datatype> </datatypes> <funcs> - - <func> - <name name="start_link" arity="3" /> - <name name="start_link" arity="4" /> - <fsummary>Create a linked <c>gen_statem</c> process</fsummary> - <desc> - <p> - Creates a <c>gen_statem</c> process according - to OTP design principles - (using - <seealso marker="proc_lib"><c>proc_lib</c></seealso> - primitives) - that is linked to the calling process. - This is essential when the <c>gen_statem</c> shall be part of - a supervision tree so it gets linked to its supervisor. - </p> - <p> - The <c>gen_statem</c> process calls - <seealso marker="#Module:init/1"><c>Module:init/1</c></seealso> - to initialize the server. To ensure a synchronized start-up - procedure, <c>start_link/3,4</c> does not return until - <seealso marker="#Module:init/1"><c>Module:init/1</c></seealso> - has returned. - </p> - <p> - <c><anno>ServerName</anno></c> specifies the - <seealso marker="#type-server_name"> - <c>server_name()</c> - </seealso> - to register for the <c>gen_statem</c>. - If the <c>gen_statem</c> is started with <c>start_link/3</c> - no <c><anno>ServerName</anno></c> is provided and - the <c>gen_statem</c> is not registered. - </p> - <p><c><anno>Module</anno></c> is the name of the callback module.</p> - <p> - <c><anno>Args</anno></c> is an arbitrary term which is passed as - the argument to - <seealso marker="#Module:init/1"><c>Module:init/1</c></seealso>. - </p> - <p> - If the option <c>{timeout,Time}</c> is present in - <c><anno>Opts</anno></c>, the <c>gen_statem</c> - is allowed to spend <c>Time</c> milliseconds initializing - or it will be terminated and the start function will return - <seealso marker="#type-start_ret"><c>{error,timeout}</c></seealso>. - </p> - <p> - If the option - <seealso marker="#type-debug_opt"><c>{debug,Dbgs}</c></seealso> - is present in <c><anno>Opts</anno></c>, debugging through - <seealso marker="sys"><c>sys</c></seealso> is activated. - </p> - <p> - If the option <c>{spawn_opt,SpawnOpts}</c> is present in - <c><anno>Opts</anno></c>, <c>SpawnOpts</c> will be passed - as option list to - <seealso marker="erts:erlang#spawn_opt/2"><c>spawn_opt/2</c></seealso> - which is used to spawn the <c>gen_statem</c> process. - </p> - <note> - <p> - Using the spawn option <c>monitor</c> is currently not - allowed, but will cause this function to fail with reason - <c>badarg</c>. - </p> - </note> - <p> - If the <c>gen_statem</c> is successfully created - and initialized this function returns - <seealso marker="#type-start_ret"> - <c>{ok,Pid}</c>, - </seealso> - where <c>Pid</c> is the <c>pid()</c> - of the <c>gen_statem</c>. - If there already exists a process with the specified - <c><anno>ServerName</anno></c> this function returns - <seealso marker="#type-start_ret"><c>{error,{already_started,Pid}}</c></seealso>, - where <c>Pid</c> is the <c>pid()</c> of that process. - </p> - <p> - If <c>Module:init/1</c> fails with <c>Reason</c>, - this function returns - <seealso marker="#type-start_ret"><c>{error,Reason}</c></seealso>. - If <c>Module:init/1</c> returns - <seealso marker="#type-start_ret"> - <c>{stop,Reason}</c> - </seealso> - or - <seealso marker="#type-start_ret"><c>ignore</c></seealso>, - the process is terminated and this function - returns - <seealso marker="#type-start_ret"> - <c>{error,Reason}</c> - </seealso> - or - <seealso marker="#type-start_ret"><c>ignore</c></seealso>, - respectively. - </p> - </desc> - </func> - - - <func> - <name name="start" arity="3" /> - <name name="start" arity="4" /> - <fsummary>Create a stand-alone <c>gen_statem</c> process</fsummary> - <desc> - <p> - Creates a stand-alone <c>gen_statem</c> process according to - OTP design principles (using - <seealso marker="proc_lib"><c>proc_lib</c></seealso> - primitives). - Since it does not get linked to the calling process - this start function can not be used by a supervisor - to start a child. - </p> - <p> - See <seealso marker="#start_link/3"><c>start_link/3,4</c></seealso> - for a description of arguments and return values. - </p> - </desc> - </func> - - <func> - <name name="stop" arity="1" /> - <fsummary>Synchronously stop a generic server</fsummary> - <desc> - <p> - The same as - <seealso marker="#stop/3"> - <c>stop(<anno>ServerRef</anno>, normal, infinity)</c>. - </seealso> - </p> - </desc> - </func> - <func> - <name name="stop" arity="3" /> - <fsummary>Synchronously stop a generic server</fsummary> - <desc> - <p> - Orders the <c>gen_statem</c> - <seealso marker="#type-server_ref"> - <c><anno>ServerRef</anno></c> - </seealso> - to exit with the given <c><anno>Reason</anno></c> - and waits for it to terminate. - The <c>gen_statem</c> will call - <seealso marker="#Module:terminate/3"> - <c>Module:terminate/3</c> - </seealso> - before exiting. - </p> - <p> - This function returns <c>ok</c> if the server terminates - with the expected reason. Any other reason than <c>normal</c>, - <c>shutdown</c>, or <c>{shutdown,Term}</c> will cause an - error report to be issued through - <seealso marker="kernel:error_logger#format/2"> - <c>error_logger:format/2</c>. - </seealso> - The default <c><anno>Reason</anno></c> is <c>normal</c>. - </p> - <p> - <c><anno>Timeout</anno></c> is an integer greater than zero - which specifies how many milliseconds to wait for the server to - terminate, or the atom <c>infinity</c> to wait indefinitely. - The default value is <c>infinity</c>. - If the server has not terminated within the specified time, - a <c>timeout</c> exception is raised. - </p> - <p> - If the process does not exist, a <c>noproc</c> exception - is raised. - </p> - </desc> - </func> - <func> - <name name="call" arity="2" /> - <name name="call" arity="3" /> - <fsummary>Make a synchronous call to a <c>gen_statem</c></fsummary> + <name name="call" arity="2"/> + <name name="call" arity="3"/> + <fsummary>Make a synchronous call to a <c>gen_statem</c>.</fsummary> <desc> <p> Makes a synchronous call to the <c>gen_statem</c> - <seealso marker="#type-server_ref"> - <c><anno>ServerRef</anno></c> - </seealso> + <seealso marker="#type-server_ref"><c><anno>ServerRef</anno></c></seealso> by sending a request and waiting until its reply arrives. - The <c>gen_statem</c> will call the + The <c>gen_statem</c> calls the <seealso marker="#state_function">state function</seealso> with <seealso marker="#type-event_type"><c>event_type()</c></seealso> <c>{call,From}</c> and event content @@ -1108,43 +914,41 @@ handle_event(_, _, State, Data) -> and that <c><anno>Reply</anno></c> becomes the return value of this function. </p> - <p> - <c><anno>Timeout</anno></c> is an integer greater than zero + <p> + <c><anno>Timeout</anno></c> is an integer > 0, which specifies how many milliseconds to wait for a reply, or the atom <c>infinity</c> to wait indefinitely, - which is the default. If no reply is received within + which is the default. If no reply is received within the specified time, the function call fails. </p> <note> <p> To avoid getting a late reply in the caller's - inbox this function spawns a proxy process that - does the call. A late reply gets delivered to the - dead proxy process hence gets discarded. This is + inbox, this function spawns a proxy process that + does the call. A late reply gets delivered to the + dead proxy process, hence gets discarded. This is less efficient than using <c><anno>Timeout</anno> =:= infinity</c>. </p> </note> - <p> - The call may fail for example if the <c>gen_statem</c> dies + <p> + The call can fail, for example, if the <c>gen_statem</c> dies before or during this function call. </p> </desc> </func> <func> - <name name="cast" arity="2" /> - <fsummary>Send an asynchronous event to a <c>gen_statem</c></fsummary> + <name name="cast" arity="2"/> + <fsummary>Send an asynchronous event to a <c>gen_statem</c>.</fsummary> <desc> <p> Sends an asynchronous event to the <c>gen_statem</c> - <seealso marker="#type-server_ref"> - <c><anno>ServerRef</anno></c> - </seealso> + <seealso marker="#type-server_ref"><c><anno>ServerRef</anno></c></seealso> and returns <c>ok</c> immediately, ignoring if the destination node or <c>gen_statem</c> does not exist. - The <c>gen_statem</c> will call the + The <c>gen_statem</c> calls the <seealso marker="#state_function">state function</seealso> with <seealso marker="#type-event_type"><c>event_type()</c></seealso> <c>cast</c> and event content @@ -1154,68 +958,29 @@ handle_event(_, _, State, Data) -> </func> <func> - <name name="reply" arity="1" /> - <name name="reply" arity="2" /> - <fsummary>Reply to a caller</fsummary> - <desc> - <p> - This function can be used by a <c>gen_statem</c> - to explicitly send a reply to a process that waits in - <seealso marker="#call/2"><c>call/2</c></seealso> - when the reply cannot be defined in - the return value of a - <seealso marker="#state_function">state function</seealso>. - </p> - <p> - <c><anno>From</anno></c> must be the term from the - <seealso marker="#type-event_type"> - <c>{call,<anno>From</anno>}</c> - </seealso> - argument to the - <seealso marker="#state_function">state function</seealso>. - <c><anno>From</anno></c> and <c><anno>Reply</anno></c> - can also be specified using a - <seealso marker="#type-reply_action"> - <c>reply_action()</c> - </seealso> - and multiple replies with a list of them. - </p> - <note> - <p> - A reply sent with this function will not be visible - in <seealso marker="sys"><c>sys</c></seealso> debug output. - </p> - </note> - </desc> - </func> - - <func> - <name name="enter_loop" arity="5" /> - <fsummary>Enter the <c>gen_statem</c> receive loop</fsummary> + <name name="enter_loop" arity="5"/> + <fsummary>Enter the <c>gen_statem</c> receive loop.</fsummary> <desc> <p> The same as <seealso marker="#enter_loop/7"><c>enter_loop/7</c></seealso> except that no - <seealso marker="#type-server_name"> - <c>server_name()</c> - </seealso> + <seealso marker="#type-server_name"><c>server_name()</c></seealso> must have been registered. </p> </desc> </func> + <func> - <name name="enter_loop" arity="6" /> - <fsummary>Enter the <c>gen_statem</c> receive loop</fsummary> + <name name="enter_loop" arity="6"/> + <fsummary>Enter the <c>gen_statem</c> receive loop.</fsummary> <desc> <p> - If <c><anno>Server_or_Actions</anno></c> is a <c>list()</c> + If <c><anno>Server_or_Actions</anno></c> is a <c>list()</c>, the same as <seealso marker="#enter_loop/7"><c>enter_loop/7</c></seealso> except that no - <seealso marker="#type-server_name"> - <c>server_name()</c> - </seealso> + <seealso marker="#type-server_name"><c>server_name()</c></seealso> must have been registered and <c>Actions = <anno>Server_or_Actions</anno></c>. </p> @@ -1228,73 +993,350 @@ handle_event(_, _, State, Data) -> </p> </desc> </func> + <func> - <name name="enter_loop" arity="7" /> - <fsummary>Enter the <c>gen_statem</c> receive loop</fsummary> + <name name="enter_loop" arity="7"/> + <fsummary>Enter the <c>gen_statem</c> receive loop.</fsummary> <desc> - <p> - Makes an the calling process become a <c>gen_statem</c>. - Does not return, instead the calling process will enter - the <c>gen_statem</c> receive loop and become + <p> + Makes the calling process become a <c>gen_statem</c>. + Does not return, instead the calling process enters + the <c>gen_statem</c> receive loop and becomes a <c>gen_statem</c> server. The process <em>must</em> have been started using one of the start functions in - <seealso marker="proc_lib"><c>proc_lib</c></seealso>. + <seealso marker="proc_lib"><c>proc_lib</c></seealso>. The user is responsible for any initialization of the process, including registering a name for it. </p> - <p> + <p> This function is useful when a more complex initialization - procedure is needed than - the <c>gen_statem</c> behaviour provides. + procedure is needed than + the <c>gen_statem</c> behavior provides. </p> - <p> - <c><anno>Module</anno></c>, <c><anno>Opts</anno></c> and + <p> + <c><anno>Module</anno></c>, <c><anno>Opts</anno></c>, and <c><anno>Server</anno></c> have the same meanings as when calling - <seealso marker="#start_link/3"> - <c>gen_statem:start[_link]/3,4</c>. - </seealso> - However, the - <seealso marker="#type-server_name"> - <c>server_name()</c> - </seealso> + <seealso marker="#start_link/3"><c>start[_link]/3,4</c></seealso>. + However, the + <seealso marker="#type-server_name"><c>server_name()</c></seealso> name must have been registered accordingly <em>before</em> this function is called.</p> <p> <c><anno>CallbackMode</anno></c>, <c><anno>State</anno></c>, - <c><anno>Data</anno></c> and <c><anno>Actions</anno></c> + <c><anno>Data</anno></c>, and <c><anno>Actions</anno></c> have the same meanings as in the return value of - <seealso marker="#Module:init/1"><c>Module:init/1</c></seealso>. - Also, the callback module <c><anno>Module</anno></c> + <seealso marker="#Module:init/1"><c>Module:init/1</c></seealso>. + Also, the callback module <c><anno>Module</anno></c> does not need to export an <c>init/1</c> function. </p> <p> - Failure: If the calling process was not started by a - <seealso marker="proc_lib"><c>proc_lib</c></seealso> + The function fails if the calling process was not started by a + <seealso marker="proc_lib"><c>proc_lib</c></seealso> start function, or if it is not registered - according to + according to <seealso marker="#type-server_name"><c>server_name()</c></seealso>. </p> </desc> </func> - </funcs> + <func> + <name name="reply" arity="1"/> + <name name="reply" arity="2"/> + <fsummary>Reply to a caller.</fsummary> + <desc> + <p> + This function can be used by a <c>gen_statem</c> + to explicitly send a reply to a process that waits in + <seealso marker="#call/2"><c>call/2</c></seealso> + when the reply cannot be defined in + the return value of a + <seealso marker="#state_function">state function</seealso>. + </p> + <p> + <c><anno>From</anno></c> must be the term from argument + <seealso marker="#type-event_type"><c>{call,<anno>From</anno>}</c></seealso> + to the + <seealso marker="#state_function">state function</seealso>. + <c><anno>From</anno></c> and <c><anno>Reply</anno></c> + can also be specified using a + <seealso marker="#type-reply_action"><c>reply_action()</c></seealso> + and multiple replies with a list of them. + </p> + <note> + <p> + A reply sent with this function is not visible + in <seealso marker="sys"><c>sys</c></seealso> debug output. + </p> + </note> + </desc> + </func> + <func> + <name name="start" arity="3"/> + <name name="start" arity="4"/> + <fsummary>Create a standalone <c>gen_statem</c> process.</fsummary> + <desc> + <p> + Creates a standalone <c>gen_statem</c> process according to + OTP design principles (using + <seealso marker="proc_lib"><c>proc_lib</c></seealso> + primitives). + As it does not get linked to the calling process, + this start function cannot be used by a supervisor + to start a child. + </p> + <p> + For a description of arguments and return values, see + <seealso marker="#start_link/3"><c>start_link/3,4</c></seealso>. + </p> + </desc> + </func> + <func> + <name name="start_link" arity="3"/> + <name name="start_link" arity="4"/> + <fsummary>Create a linked <c>gen_statem</c> process.</fsummary> + <desc> + <p> + Creates a <c>gen_statem</c> process according + to OTP design principles + (using + <seealso marker="proc_lib"><c>proc_lib</c></seealso> + primitives) + that is linked to the calling process. + This is essential when the <c>gen_statem</c> must be part of + a supervision tree so it gets linked to its supervisor. + </p> + <p> + The <c>gen_statem</c> process calls + <seealso marker="#Module:init/1"><c>Module:init/1</c></seealso> + to initialize the server. To ensure a synchronized startup + procedure, <c>start_link/3,4</c> does not return until + <seealso marker="#Module:init/1"><c>Module:init/1</c></seealso> + has returned. + </p> + <p> + <c><anno>ServerName</anno></c> specifies the + <seealso marker="#type-server_name"><c>server_name()</c></seealso> + to register for the <c>gen_statem</c>. + If the <c>gen_statem</c> is started with <c>start_link/3</c>, + no <c><anno>ServerName</anno></c> is provided and + the <c>gen_statem</c> is not registered. + </p> + <p><c><anno>Module</anno></c> is the name of the callback module.</p> + <p> + <c><anno>Args</anno></c> is an arbitrary term that is passed as + the argument to + <seealso marker="#Module:init/1"><c>Module:init/1</c></seealso>. + </p> + <list type="bulleted"> + <item> + <p> + If option <c>{timeout,Time}</c> is present in + <c><anno>Opts</anno></c>, the <c>gen_statem</c> + is allowed to spend <c>Time</c> milliseconds initializing + or it terminates and the start function returns + <seealso marker="#type-start_ret"><c>{error,timeout}</c></seealso>. + </p> + </item> + <item> + <p> + If option + <seealso marker="#type-debug_opt"><c>{debug,Dbgs}</c></seealso> + is present in <c><anno>Opts</anno></c>, debugging through + <seealso marker="sys"><c>sys</c></seealso> is activated. + </p> + </item> + <item> + <p> + If option <c>{spawn_opt,SpawnOpts}</c> is present in + <c><anno>Opts</anno></c>, <c>SpawnOpts</c> is passed + as option list to + <seealso marker="erts:erlang#spawn_opt/2"><c>erlang:spawn_opt/2</c></seealso>, + which is used to spawn the <c>gen_statem</c> process. + </p> + </item> + </list> + <note> + <p> + Using spawn option <c>monitor</c> is not + allowed, it causes this function to fail with reason + <c>badarg</c>. + </p> + </note> + <p> + If the <c>gen_statem</c> is successfully created + and initialized, this function returns + <seealso marker="#type-start_ret"><c>{ok,Pid}</c></seealso>, + where <c>Pid</c> is the <c>pid()</c> + of the <c>gen_statem</c>. + If a process with the specified <c><anno>ServerName</anno></c> + exists already, this function returns + <seealso marker="#type-start_ret"><c>{error,{already_started,Pid}}</c></seealso>, + where <c>Pid</c> is the <c>pid()</c> of that process. + </p> + <p> + If <c>Module:init/1</c> fails with <c>Reason</c>, + this function returns + <seealso marker="#type-start_ret"><c>{error,Reason}</c></seealso>. + If <c>Module:init/1</c> returns + <seealso marker="#type-start_ret"><c>{stop,Reason}</c></seealso> + or + <seealso marker="#type-start_ret"><c>ignore</c></seealso>, + the process is terminated and this function + returns + <seealso marker="#type-start_ret"><c>{error,Reason}</c></seealso> + or + <seealso marker="#type-start_ret"><c>ignore</c></seealso>, + respectively. + </p> + </desc> + </func> + + <func> + <name name="stop" arity="1"/> + <fsummary>Synchronously stop a generic server.</fsummary> + <desc> + <p> + The same as + <seealso marker="#stop/3"><c>stop(<anno>ServerRef</anno>, normal, infinity)</c></seealso>. + </p> + </desc> + </func> + + <func> + <name name="stop" arity="3"/> + <fsummary>Synchronously stop a generic server.</fsummary> + <desc> + <p> + Orders the <c>gen_statem</c> + <seealso marker="#type-server_ref"><c><anno>ServerRef</anno></c></seealso> + to exit with the specified <c><anno>Reason</anno></c> + and waits for it to terminate. + The <c>gen_statem</c> calls + <seealso marker="#Module:terminate/3"><c>Module:terminate/3</c></seealso> + before exiting. + </p> + <p> + This function returns <c>ok</c> if the server terminates + with the expected reason. Any other reason than <c>normal</c>, + <c>shutdown</c>, or <c>{shutdown,Term}</c> causes an + error report to be issued through + <seealso marker="kernel:error_logger#format/2"><c>error_logger:format/2</c></seealso>. + The default <c><anno>Reason</anno></c> is <c>normal</c>. + </p> + <p> + <c><anno>Timeout</anno></c> is an integer > 0, + which specifies how many milliseconds to wait for the server to + terminate, or the atom <c>infinity</c> to wait indefinitely. + Defaults to <c>infinity</c>. + If the server does not terminate within the specified time, + a <c>timeout</c> exception is raised. + </p> + <p> + If the process does not exist, a <c>noproc</c> exception + is raised. + </p> + </desc> + </func> + </funcs> <section> - <title>CALLBACK FUNCTIONS</title> + <title>Callback Functions</title> <p> - The following functions should be exported from a + The following functions are to be exported from a <c>gen_statem</c> callback module. </p> </section> + <funcs> + <func> + <name>Module:code_change(OldVsn, OldState, OldData, Extra) -> + Result + </name> + <fsummary>Update the internal state during upgrade/downgrade.</fsummary> + <type> + <v>OldVsn = Vsn | {down,Vsn}</v> + <v> Vsn = term()</v> + <v>OldState = NewState = term()</v> + <v>Extra = term()</v> + <v>Result = {NewCallbackMode,NewState,NewData} | Reason</v> + <v> + NewCallbackMode = + <seealso marker="#type-callback_mode">callback_mode()</seealso> + </v> + <v> + OldState = NewState = + <seealso marker="#type-state">state()</seealso> + </v> + <v> + OldData = NewData = + <seealso marker="#type-data">data()</seealso> + </v> + <v>Reason = term()</v> + </type> + <desc> + <p> + This function is called by a <c>gen_statem</c> when it is to + update its internal state during a release upgrade/downgrade, + that is, when the instruction <c>{update,Module,Change,...}</c>, + where <c>Change={advanced,Extra}</c>, is specified in the + <seealso marker="sasl:appup"><c>appup</c></seealso> + file. For more information, see + <seealso marker="doc/design_principles:release_handling#instr">OTP Design Principles</seealso>. + </p> + <p> + For an upgrade, <c>OldVsn</c> is <c>Vsn</c>, and + for a downgrade, <c>OldVsn</c> is + <c>{down,Vsn}</c>. <c>Vsn</c> is defined by the <c>vsn</c> + attribute(s) of the old version of the callback module + <c>Module</c>. If no such attribute is defined, the version + is the checksum of the Beam file. + </p> + <note> + <p> + If you would dare to change + <seealso marker="#type-callback_mode"><em>callback mode</em></seealso> + during release upgrade/downgrade, the upgrade is no problem, + as the new code surely knows what <em>callback mode</em> + it needs. However, for a downgrade this function must + know from argument <c>Extra</c> that comes from the + <seealso marker="sasl:appup"><c>sasl:appup</c></seealso> + file what <em>callback mode</em> the old code did use. + It can also be possible to figure this out + from argument <c>{down,Vsn}</c>, as <c>Vsn</c> + in effect defines the old callback module version. + </p> + </note> + <p> + <c>OldState</c> and <c>OldData</c> is the internal state + of the <c>gen_statem</c>. + </p> + <p> + <c>Extra</c> is passed "as is" from the <c>{advanced,Extra}</c> + part of the update instruction. + </p> + <p> + If successful, the function must return the updated + internal state in an + <c>{NewCallbackMode,NewState,NewData}</c> tuple. + </p> + <p> + If the function returns <c>Reason</c>, the ongoing + upgrade fails and rolls back to the old release.</p> + <p> + This function can use + <seealso marker="erts:erlang#throw/1"><c>erlang:throw/1</c></seealso> + to return <c>Result</c> or <c>Reason</c>. + </p> + </desc> + </func> <func> <name>Module:init(Args) -> Result</name> - <fsummary>Initialize process and internal state</fsummary> + <fsummary>Initialize process and internal state.</fsummary> <type> <v>Args = term()</v> <v>Result = {CallbackMode,State,Data}</v> @@ -1316,25 +1358,25 @@ handle_event(_, _, State, Data) -> <v>Reason = term()</v> </type> <desc> - <marker id="Module:init-1" /> - <p> + <marker id="Module:init-1"/> + <p> Whenever a <c>gen_statem</c> is started using - <seealso marker="#start_link/3"><c>start_link/3,4</c></seealso> + <seealso marker="#start_link/3"><c>start_link/3,4</c></seealso> or - <seealso marker="#start/3"><c>start/3,4</c></seealso>, - this function is called by the new process to initialize + <seealso marker="#start/3"><c>start/3,4</c></seealso>, + this function is called by the new process to initialize the implementation state and server data. </p> - <p> + <p> <c>Args</c> is the <c>Args</c> argument provided to the start - function. + function. </p> - <p> - If the initialization is successful, the function should - return <c>{CallbackMode,State,Data}</c> or + <p> + If the initialization is successful, the function is to + return <c>{CallbackMode,State,Data}</c> or <c>{CallbackMode,State,Data,Actions}</c>. <c>CallbackMode</c> selects the - <seealso marker="#type-callback_mode"><em>callback mode</em></seealso>. + <seealso marker="#type-callback_mode"><em>callback mode</em></seealso> of the <c>gen_statem</c>. <c>State</c> is the initial <seealso marker="#type-state"><c>state()</c></seealso> @@ -1347,28 +1389,127 @@ handle_event(_, _, State, Data) -> <seealso marker="#type-state">state</seealso> just as for a <seealso marker="#state_function">state function</seealso>. </p> - <p> - If something goes wrong during the initialization - the function should return <c>{stop,Reason}</c> - or <c>ignore</c>. See + <p> + If the initialization fails, + the function is to return <c>{stop,Reason}</c> + or <c>ignore</c>; see <seealso marker="#start_link/3"><c>start_link/3,4</c></seealso>. </p> <p> - This function may use - <seealso marker="erts:erlang#throw/1"><c>throw/1</c></seealso> + This function can use + <seealso marker="erts:erlang#throw/1"><c>erlang:throw/1</c></seealso> to return <c>Result</c>. </p> </desc> </func> <func> + <name>Module:format_status(Opt, [PDict,State,Data]) -> + Status + </name> + <fsummary>Optional function for providing a term describing the + current <c>gen_statem</c> status.</fsummary> + <type> + <v>Opt = normal | terminate</v> + <v>PDict = [{Key, Value}]</v> + <v> + State = + <seealso marker="#type-state">state()</seealso> + </v> + <v> + Data = + <seealso marker="#type-data">data()</seealso> + </v> + <v>Key = term()</v> + <v>Value = term()</v> + <v>Status = term()</v> + </type> + <desc> + <note> + <p> + This callback is optional, so a callback module does not need + to export it. The <c>gen_statem</c> module provides a default + implementation of this function that returns + <c>{State,Data}</c>. If this callback fails, the default + function returns <c>{State,Info}</c>, + where <c>Info</c> informs of the crash but no details, + to hide possibly sensitive data. + </p> + </note> + <p>This function is called by a <c>gen_statem</c> process when + any of the following apply:</p> + <list type="bulleted"> + <item> + One of + <seealso marker="sys#get_status/1"><c>sys:get_status/1,2</c></seealso> + is invoked to get the <c>gen_statem</c> status. <c>Opt</c> is set + to the atom <c>normal</c> for this case. + </item> + <item> + The <c>gen_statem</c> terminates abnormally and logs an error. + <c>Opt</c> is set to the atom <c>terminate</c> for this case. + </item> + </list> + <p> + This function is useful for changing the form and + appearance of the <c>gen_statem</c> status for these cases. A + callback module wishing to change the + <seealso marker="sys#get_status/1"><c>sys:get_status/1,2</c></seealso> + return value and how + its status appears in termination error logs exports an + instance of <c>format_status/2</c>, which returns a term + describing the current status of the <c>gen_statem</c>. + </p> + <p> + <c>PDict</c> is the current value of the process dictionary + of the <c>gen_statem</c>. + </p> + <p> + <seealso marker="#type-state"><c>State</c></seealso> + is the internal state of the <c>gen_statem</c>. + </p> + <p> + <seealso marker="#type-data"><c>Data</c></seealso> + is the internal server data of the <c>gen_statem</c>. + </p> + <p> + The function is to return <c>Status</c>, a term that + changes the details of the current state and status of + the <c>gen_statem</c>. There are no restrictions on the + form <c>Status</c> can take, but for the + <seealso marker="sys#get_status/1"><c>sys:get_status/1,2</c></seealso> + case (when <c>Opt</c> + is <c>normal</c>), the recommended form for + the <c>Status</c> value is <c>[{data, [{"State", + Term}]}]</c>, where <c>Term</c> provides relevant details of + the <c>gen_statem</c> state. Following this recommendation is not + required, but it makes the callback module status + consistent with the rest of the + <seealso marker="sys#get_status/1"><c>sys:get_status/1,2</c></seealso> + return value. + </p> + <p> + One use for this function is to return compact alternative + state representations to avoid having large state terms + printed in log files. Another use is to hide sensitive data from + being written to the error log. + </p> + <p> + This function can use + <seealso marker="erts:erlang#throw/1"><c>erlang:throw/1</c></seealso> + to return <c>Status</c>. + </p> + </desc> + </func> + + <func> <name>Module:StateName(EventType, EventContent, Data) -> - StateFunctionResult + StateFunctionResult </name> <name>Module:handle_event(EventType, EventContent, - State, Data) -> HandleEventResult + State, Data) -> HandleEventResult </name> - <fsummary>Handle an event</fsummary> + <fsummary>Handle an event.</fsummary> <type> <v> EventType = @@ -1385,59 +1526,55 @@ handle_event(_, _, State, Data) -> </v> <v> StateFunctionResult = - <seealso marker="#type-state_function_result"> - state_function_result() - </seealso> + <seealso marker="#type-state_function_result">state_function_result()</seealso> </v> <v> HandleEventResult = - <seealso marker="#type-handle_event_result"> - handle_event_result() - </seealso> + <seealso marker="#type-handle_event_result">handle_event_result()</seealso> </v> </type> <desc> - <p> + <p> Whenever a <c>gen_statem</c> receives an event from - <seealso marker="#call/2"><c>call/2</c></seealso>, - <seealso marker="#cast/2"><c>cast/2</c></seealso> or - as a normal process message one of these functions is called. If + <seealso marker="#call/2"><c>call/2</c></seealso>, + <seealso marker="#cast/2"><c>cast/2</c></seealso>, or + as a normal process message, one of these functions is called. If <seealso marker="#type-callback_mode"><em>callback mode</em></seealso> - is <c>state_functions</c> then <c>Module:StateName/3</c> is called, - and if it is <c>handle_event_function</c> - then <c>Module:handle_event/4</c> is called. + is <c>state_functions</c>, <c>Module:StateName/3</c> is called, + and if it is <c>handle_event_function</c>, + <c>Module:handle_event/4</c> is called. </p> <p> If <c>EventType</c> is - <seealso marker="#type-event_type"><c>{call,From}</c></seealso> - the caller is waiting for a reply. The reply can be sent + <seealso marker="#type-event_type"><c>{call,From}</c></seealso>, + the caller waits for a reply. The reply can be sent from this or from any other <seealso marker="#state_function">state function</seealso> by returning with <c>{reply,From,Reply}</c> in <seealso marker="#type-action"><c>Actions</c></seealso>, in - <seealso marker="#type-reply_action"><c>Replies</c></seealso> + <seealso marker="#type-reply_action"><c>Replies</c></seealso>, or by calling <seealso marker="#reply/2"><c>reply(From, Reply)</c></seealso>. </p> <p> If this function returns with a next state that - does not match equal (<c>=/=</c>) to the current state - all postponed events will be retried in the next state. + does not match equal (<c>=/=</c>) to the current state, + all postponed events are retried in the next state. </p> <p> The only difference between <c>StateFunctionResult</c> and <c>HandleEventResult</c> is that for <c>StateFunctionResult</c> - the next state has to be an atom but for <c>HandleEventResult</c> + the next state must be an atom, but for <c>HandleEventResult</c> there is no restriction on the next state. </p> <p> - See <seealso marker="#type-action"><c>action()</c></seealso> - for options that can be set and actions that can be done - by <c>gen_statem</c> after returning from this function. + For options that can be set and actions that can be done + by <c>gen_statem</c> after returning from this function, + see <seealso marker="#type-action"><c>action()</c></seealso>. </p> <p> - These functions may use - <seealso marker="erts:erlang#throw/1"><c>throw/1</c></seealso>, + These functions can use + <seealso marker="erts:erlang#throw/1"><c>erlang:throw/1</c></seealso>, to return the result. </p> </desc> @@ -1445,7 +1582,7 @@ handle_event(_, _, State, Data) -> <func> <name>Module:terminate(Reason, State, Data) -> Ignored</name> - <fsummary>Clean up before termination</fsummary> + <fsummary>Clean up before termination.</fsummary> <type> <v>Reason = normal | shutdown | {shutdown,term()} | term()</v> <v>State = <seealso marker="#type-state">state()</seealso></v> @@ -1453,272 +1590,82 @@ handle_event(_, _, State, Data) -> <v>Ignored = term()</v> </type> <desc> - <p> + <p> This function is called by a <c>gen_statem</c> - when it is about to terminate. It should be the opposite of + when it is about to terminate. It is to be the opposite of <seealso marker="#Module:init/1"><c>Module:init/1</c></seealso> - and do any necessary cleaning up. When it returns, - the <c>gen_statem</c> terminates with <c>Reason</c>. The return - value is ignored.</p> - <p> + and do any necessary cleaning up. When it returns, + the <c>gen_statem</c> terminates with <c>Reason</c>. The return + value is ignored.</p> + <p> <c>Reason</c> is a term denoting the stop reason and - <seealso marker="#type-state"><c>State</c></seealso> + <seealso marker="#type-state"><c>State</c></seealso> is the internal state of the <c>gen_statem</c>. </p> - <p> + <p> <c>Reason</c> depends on why the <c>gen_statem</c> is terminating. - If it is because another callback function has returned a - stop tuple <c>{stop,Reason}</c> in + If it is because another callback function has returned, a + stop tuple <c>{stop,Reason}</c> in <seealso marker="#type-action"><c>Actions</c></seealso>, - <c>Reason</c> will have the value specified in that tuple. - If it is due to a failure, <c>Reason</c> is the error reason. + <c>Reason</c> has the value specified in that tuple. + If it is because of a failure, <c>Reason</c> is the error reason. </p> <p> If the <c>gen_statem</c> is part of a supervision tree and is - ordered by its supervisor to terminate, this function will be - called with <c>Reason = shutdown</c> if the following + ordered by its supervisor to terminate, this function is + called with <c>Reason = shutdown</c> if both the following conditions apply:</p> <list type="bulleted"> <item> - the <c>gen_statem</c> has been set - to trap exit signals, and + <p> + The <c>gen_statem</c> has been set + to trap exit signals. + </p> </item> <item> - the shutdown strategy as defined in the supervisor's - child specification is an integer timeout value, not - <c>brutal_kill</c>. + <p> + The shutdown strategy as defined in the supervisor's + child specification is an integer time-out value, not + <c>brutal_kill</c>. + </p> </item> </list> <p> Even if the <c>gen_statem</c> is <em>not</em> - part of a supervision tree, this function will be called + part of a supervision tree, this function is called if it receives an <c>'EXIT'</c> message from its parent. - <c>Reason</c> will be the same as + <c>Reason</c> is the same as in the <c>'EXIT'</c> message. </p> <p> - Otherwise, the <c>gen_statem</c> will be immediately terminated. + Otherwise, the <c>gen_statem</c> is immediately terminated. </p> <p> - Note that for any other reason than <c>normal</c>, - <c>shutdown</c>, or <c>{shutdown,Term}</c> - the <c>gen_statem</c> is assumed to terminate due to an error + Notice that for any other reason than <c>normal</c>, + <c>shutdown</c>, or <c>{shutdown,Term}</c>, + the <c>gen_statem</c> is assumed to terminate because of an error and an error report is issued using - <seealso marker="kernel:error_logger#format/2"> - <c>error_logger:format/2</c>. - </seealso> + <seealso marker="kernel:error_logger#format/2"><c>error_logger:format/2</c></seealso>. </p> <p> - This function may use - <seealso marker="erts:erlang#throw/1"><c>throw/1</c></seealso> + This function can use + <seealso marker="erts:erlang#throw/1"><c>erlang:throw/1</c></seealso> to return <c>Ignored</c>, which is ignored anyway. </p> </desc> </func> - - <func> - <name>Module:code_change(OldVsn, OldState, OldData, Extra) -> - Result - </name> - <fsummary>Update the internal state during upgrade/downgrade</fsummary> - <type> - <v>OldVsn = Vsn | {down,Vsn}</v> - <v> Vsn = term()</v> - <v>OldState = NewState = term()</v> - <v>Extra = term()</v> - <v>Result = {NewCallbackMode,NewState,NewData} | Reason</v> - <v> - NewCallbackMode = - <seealso marker="#type-callback_mode">callback_mode()</seealso> - </v> - <v> - OldState = NewState = - <seealso marker="#type-state">state()</seealso> - </v> - <v> - OldData = NewData = - <seealso marker="#type-data">data()</seealso> - </v> - <v>Reason = term()</v> - </type> - <desc> - <p> - This function is called by a <c>gen_statem</c> when it should - update its internal state during a release upgrade/downgrade, - that is when the instruction <c>{update,Module,Change,...}</c> - where <c>Change={advanced,Extra}</c> is given in the - <seealso marker="sasl:appup"><c>appup</c></seealso> - file. See - <seealso marker="doc/design_principles:release_handling#instr"> - OTP Design Principles - </seealso> - for more information. - </p> - <p> - In the case of an upgrade, <c>OldVsn</c> is <c>Vsn</c>, and - in the case of a downgrade, <c>OldVsn</c> is - <c>{down,Vsn}</c>. <c>Vsn</c> is defined by the <c>vsn</c> - attribute(s) of the old version of the callback module - <c>Module</c>. If no such attribute is defined, the version - is the checksum of the BEAM file. - </p> - <note> - <p> - If you would dare to change - <seealso marker="#type-callback_mode"> - <em>callback mode</em> - </seealso> - during release upgrade/downgrade, the upgrade is no problem - since the new code surely knows what <em>callback mode</em> - it needs, but for a downgrade this function will have to - know from the <c>Extra</c> argument that comes from the - <seealso marker="sasl:appup"><c>appup</c></seealso> - file what <em>callback mode</em> the old code did use. - It may also be possible to figure this out - from the <c>{down,Vsn}</c> argument since <c>Vsn</c> - in effect defines the old callback module version. - </p> - </note> - <p> - <c>OldState</c> and <c>OldData</c> is the internal state - of the <c>gen_statem</c>. - </p> - <p> - <c>Extra</c> is passed as-is from the <c>{advanced,Extra}</c> - part of the update instruction. - </p> - <p> - If successful, the function shall return the updated - internal state in an - <c>{NewCallbackMode,NewState,NewData}</c> tuple. - </p> - <p> - If the function returns <c>Reason</c>, the ongoing - upgrade will fail and roll back to the old release.</p> - <p> - This function may use - <seealso marker="erts:erlang#throw/1"><c>throw/1</c></seealso> - to return <c>Result</c> or <c>Reason</c>. - </p> - </desc> - </func> - - <func> - <name>Module:format_status(Opt, [PDict,State,Data]) -> - Status - </name> - <fsummary>Optional function for providing a term describing the - current <c>gen_statem</c> status</fsummary> - <type> - <v>Opt = normal | terminate</v> - <v>PDict = [{Key, Value}]</v> - <v> - State = - <seealso marker="#type-state">state()</seealso> - </v> - <v> - Data = - <seealso marker="#type-data">data()</seealso> - </v> - <v>Key = term()</v> - <v>Value = term()</v> - <v>Status = term()</v> - </type> - <desc> - <note> - <p> - This callback is optional, so a callback module need not - export it. The <c>gen_statem</c> module provides a default - implementation of this function that returns - <c>{State,Data}</c>. If this callback fails the default - function will return <c>{State,Info}</c> - where <c>Info</c> informs of the crash but no details, - to hide possibly sensitive data. - </p> - </note> - <p>This function is called by a <c>gen_statem</c> process when:</p> - <list type="bulleted"> - <item> - One of - <seealso marker="sys#get_status/1"> - <c>sys:get_status/1,2</c> - </seealso> - is invoked to get the <c>gen_statem</c> status. <c>Opt</c> is set - to the atom <c>normal</c> for this case. - </item> - <item> - The <c>gen_statem</c> terminates abnormally and logs an error. - <c>Opt</c> is set to the atom <c>terminate</c> for this case. - </item> - </list> - <p> - This function is useful for customising the form and - appearance of the <c>gen_statem</c> status for these cases. A - callback module wishing to customise the - <seealso marker="sys#get_status/1"> - <c>sys:get_status/1,2</c> - </seealso> - return value as well as how - its status appears in termination error logs exports an - instance of <c>format_status/2</c> that returns a term - describing the current status of the <c>gen_statem</c>. - </p> - <p> - <c>PDict</c> is the current value of the <c>gen_statem</c>'s - process dictionary. - </p> - <p> - <seealso marker="#type-state"><c>State</c></seealso> - is the internal state of the <c>gen_statem</c>. - </p> - <p> - <seealso marker="#type-data"><c>Data</c></seealso> - is the internal server data of the <c>gen_statem</c>. - </p> - <p> - The function should return <c>Status</c>, a term that - customises the details of the current state and status of - the <c>gen_statem</c>. There are no restrictions on the - form <c>Status</c> can take, but for the - <seealso marker="sys#get_status/1"> - <c>sys:get_status/1,2</c> - </seealso> - case (when <c>Opt</c> - is <c>normal</c>), the recommended form for - the <c>Status</c> value is <c>[{data, [{"State", - Term}]}]</c> where <c>Term</c> provides relevant details of - the <c>gen_statem</c> state. Following this recommendation isn't - required, but doing so will make the callback module status - consistent with the rest of the - <seealso marker="sys#get_status/1"> - <c>sys:get_status/1,2</c> - </seealso> - return value. - </p> - <p> - One use for this function is to return compact alternative - state representations to avoid having large state terms - printed in logfiles. Another is to hide sensitive data from - being written to the error log. - </p> - <p> - This function may use - <seealso marker="erts:erlang#throw/1"><c>throw/1</c></seealso> - to return <c>Status</c>. - </p> - </desc> - </func> - </funcs> <section> - <title>SEE ALSO</title> - <p><seealso marker="gen_event"><c>gen_event(3)</c></seealso>, + <title>See Also</title> + <p> + <seealso marker="gen_event"><c>gen_event(3)</c></seealso>, <seealso marker="gen_fsm"><c>gen_fsm(3)</c></seealso>, <seealso marker="gen_server"><c>gen_server(3)</c></seealso>, - <seealso marker="supervisor"><c>supervisor(3)</c></seealso>, <seealso marker="proc_lib"><c>proc_lib(3)</c></seealso>, - <seealso marker="sys"><c>sys(3)</c></seealso></p> + <seealso marker="supervisor"><c>supervisor(3)</c></seealso>, + <seealso marker="sys"><c>sys(3)</c></seealso>. + </p> </section> </erlref> diff --git a/lib/stdlib/src/epp.erl b/lib/stdlib/src/epp.erl index 55a818e87c..73934e0e3c 100644 --- a/lib/stdlib/src/epp.erl +++ b/lib/stdlib/src/epp.erl @@ -53,6 +53,8 @@ | {atom(),non_neg_integer()} | tokens(). +-type warning_info() :: {erl_anno:location(), module(), term()}. + -define(DEFAULT_ENCODING, utf8). %% Epp state record. @@ -158,11 +160,13 @@ scan_erl_form(Epp) -> epp_request(Epp, scan_erl_form). -spec parse_erl_form(Epp) -> - {'ok', AbsForm} | {'eof', Line} | {error, ErrorInfo} when + {'ok', AbsForm} | {error, ErrorInfo} | + {'warning',WarningInfo} | {'eof',Line} when Epp :: epp_handle(), AbsForm :: erl_parse:abstract_form(), Line :: erl_anno:line(), - ErrorInfo :: erl_scan:error_info() | erl_parse:error_info(). + ErrorInfo :: erl_scan:error_info() | erl_parse:error_info(), + WarningInfo :: warning_info(). parse_erl_form(Epp) -> case epp_request(Epp, scan_erl_form) of @@ -219,6 +223,10 @@ format_error({illegal_function_usage,Macro}) -> io_lib:format("?~s must not begin a form", [Macro]); format_error({'NYI',What}) -> io_lib:format("not yet implemented '~s'", [What]); +format_error({error,Term}) -> + io_lib:format("-error(~p).", [Term]); +format_error({warning,Term}) -> + io_lib:format("-warning(~p).", [Term]); format_error(E) -> file:format_error(E). -spec parse_file(FileName, IncludePath, PredefMacros) -> @@ -263,9 +271,11 @@ parse_file(Ifile, Options) -> -spec parse_file(Epp) -> [Form] when Epp :: epp_handle(), - Form :: erl_parse:abstract_form() | {'error', ErrorInfo} | {'eof',Line}, + Form :: erl_parse:abstract_form() | {'error', ErrorInfo} | + {'warning',WarningInfo} | {'eof',Line}, Line :: erl_anno:line(), - ErrorInfo :: erl_scan:error_info() | erl_parse:error_info(). + ErrorInfo :: erl_scan:error_info() | erl_parse:error_info(), + WarningInfo :: warning_info(). parse_file(Epp) -> case parse_erl_form(Epp) of @@ -273,6 +283,8 @@ parse_file(Epp) -> [Form|parse_file(Epp)]; {error,E} -> [{error,E}|parse_file(Epp)]; + {warning,W} -> + [{warning,W}|parse_file(Epp)]; {eof,Location} -> [{eof,erl_anno:new(Location)}] end. @@ -752,6 +764,10 @@ scan_toks([{'-',_Lh},{atom,_Ld,define}=Define|Toks], From, St) -> scan_define(Toks, Define, From, St); scan_toks([{'-',_Lh},{atom,_Ld,undef}=Undef|Toks], From, St) -> scan_undef(Toks, Undef, From, St); +scan_toks([{'-',_Lh},{atom,_Ld,error}=Error|Toks], From, St) -> + scan_err_warn(Toks, Error, From, St); +scan_toks([{'-',_Lh},{atom,_Ld,warning}=Warn|Toks], From, St) -> + scan_err_warn(Toks, Warn, From, St); scan_toks([{'-',_Lh},{atom,_Li,include}=Inc|Toks], From, St) -> scan_include(Toks, Inc, From, St); scan_toks([{'-',_Lh},{atom,_Li,include_lib}=IncLib|Toks], From, St) -> @@ -807,6 +823,24 @@ scan_extends([{atom,Ln,A}=ModAtom,{')',_Lr}|_Ts], Ms0) -> Ms#{'BASE_MODULE_STRING':={none,[{string,Ln,ModString}]}}; scan_extends(_Ts, Ms) -> Ms. +scan_err_warn([{'(',_}|_]=Toks0, {atom,_,Tag}=Token, From, St) -> + try expand_macros(Toks0, St) of + Toks when is_list(Toks) -> + case erl_parse:parse_term(Toks) of + {ok,Term} -> + epp_reply(From, {Tag,{loc(Token),epp,{Tag,Term}}}); + {error,_} -> + epp_reply(From, {error,{loc(Token),epp,{bad,Tag}}}) + end + catch + _:_ -> + epp_reply(From, {error,{loc(Token),epp,{bad,Tag}}}) + end, + wait_req_scan(St); +scan_err_warn(_Toks, {atom,_,Tag}=Token, From, St) -> + epp_reply(From, {error,{loc(Token),epp,{bad,Tag}}}), + wait_req_scan(St). + %% scan_define(Tokens, DefineToken, From, EppState) scan_define([{'(',_Lp},{Type,_Lm,_}=Mac|Toks], Def, From, St) @@ -933,9 +967,15 @@ scan_include(_Toks, Inc, From, St) -> %% normal search path, if not we assume that the first directory name %% is a library name, find its true directory and try with that. -find_lib_dir(NewName) -> - [Lib | Rest] = filename:split(NewName), - {code:lib_dir(list_to_atom(Lib)), Rest}. +expand_lib_dir(Name) -> + try + [App|Path] = filename:split(Name), + LibDir = code:lib_dir(list_to_atom(App)), + {ok,fname_join([LibDir|Path])} + catch + _:_ -> + error + end. scan_include_lib([{'(',_Llp},{string,_Lf,_NewName0},{')',_Lrp},{dot,_Ld}], Inc, From, St) @@ -950,12 +990,11 @@ scan_include_lib([{'(',_Llp},{string,_Lf,NewName0},{')',_Lrp},{dot,_Ld}], {ok,NewF,Pname} -> wait_req_scan(enter_file2(NewF, Pname, From, St, Loc)); {error,_E1} -> - case catch find_lib_dir(NewName) of - {LibDir, Rest} when is_list(LibDir) -> - LibName = fname_join([LibDir | Rest]), - case file:open(LibName, [read]) of + case expand_lib_dir(NewName) of + {ok,Header} -> + case file:open(Header, [read]) of {ok,NewF} -> - wait_req_scan(enter_file2(NewF, LibName, From, + wait_req_scan(enter_file2(NewF, Header, From, St, Loc)); {error,_E2} -> epp_reply(From, @@ -963,7 +1002,7 @@ scan_include_lib([{'(',_Llp},{string,_Lf,NewName0},{')',_Lrp},{dot,_Ld}], {include,lib,NewName}}}), wait_req_scan(St) end; - _Error -> + error -> epp_reply(From, {error,{loc(Inc),epp, {include,lib,NewName}}}), wait_req_scan(St) diff --git a/lib/stdlib/src/erl_lint.erl b/lib/stdlib/src/erl_lint.erl index b14102ac38..2508f96b91 100644 --- a/lib/stdlib/src/erl_lint.erl +++ b/lib/stdlib/src/erl_lint.erl @@ -1502,7 +1502,7 @@ pattern({op,_Line,'++',{string,_Li,_S},R}, Vt, Old, Bvt, St) -> pattern({match,_Line,Pat1,Pat2}, Vt, Old, Bvt, St0) -> {Lvt,Bvt1,St1} = pattern(Pat1, Vt, Old, Bvt, St0), {Rvt,Bvt2,St2} = pattern(Pat2, Vt, Old, Bvt, St1), - St3 = reject_bin_alias(Pat1, Pat2, St2), + St3 = reject_invalid_alias(Pat1, Pat2, Vt, St2), {vtmerge_pat(Lvt, Rvt),vtmerge_pat(Bvt1,Bvt2),St3}; %% Catch legal constant expressions, including unary +,-. pattern(Pat, _Vt, _Old, _Bvt, St) -> @@ -1517,56 +1517,77 @@ pattern_list(Ps, Vt, Old, Bvt0, St) -> {vtmerge_pat(Pvt, Psvt),vtmerge_pat(Bvt,Bvt1),St1} end, {[],[],St}, Ps). -%% reject_bin_alias(Pat, Expr, St) -> St' + + +%% reject_invalid_alias(Pat, Expr, Vt, St) -> St' %% Reject aliases for binary patterns at the top level. +%% Reject aliases for maps patterns at the top level. +%% The variables table (Vt) are for maps checkking. + +reject_invalid_alias_expr({bin,_,_}=P, {match,_,P0,E}, Vt, St0) -> + St = reject_invalid_alias(P, P0, Vt, St0), + reject_invalid_alias_expr(P, E, Vt, St); +reject_invalid_alias_expr({map,_,_}=P, {match,_,P0,E}, Vt, St0) -> + St = reject_invalid_alias(P, P0, Vt, St0), + reject_invalid_alias_expr(P, E, Vt, St); +reject_invalid_alias_expr({match,_,_,_}=P, {match,_,P0,E}, Vt, St0) -> + St = reject_invalid_alias(P, P0, Vt, St0), + reject_invalid_alias_expr(P, E, Vt, St); +reject_invalid_alias_expr(_, _, _, St) -> St. -reject_bin_alias_expr({bin,_,_}=P, {match,_,P0,E}, St0) -> - St = reject_bin_alias(P, P0, St0), - reject_bin_alias_expr(P, E, St); -reject_bin_alias_expr({match,_,_,_}=P, {match,_,P0,E}, St0) -> - St = reject_bin_alias(P, P0, St0), - reject_bin_alias_expr(P, E, St); -reject_bin_alias_expr(_, _, St) -> St. -%% reject_bin_alias(Pat1, Pat2, St) -> St' +%% reject_invalid_alias(Pat1, Pat2, St) -> St' %% Aliases of binary patterns, such as <<A:8>> = <<B:4,C:4>> or even %% <<A:8>> = <<A:8>>, are not allowed. Traverse the patterns in parallel %% and generate an error if any binary aliases are found. %% We generate an error even if is obvious that the overall pattern can't %% possibly match, for instance, {a,<<A:8>>,c}={x,<<A:8>>} WILL generate an %% error. +%% Maps should reject unbound variables here. -reject_bin_alias({bin,Line,_}, {bin,_,_}, St) -> +reject_invalid_alias({bin,Line,_}, {bin,_,_}, _, St) -> add_error(Line, illegal_bin_pattern, St); -reject_bin_alias({cons,_,H1,T1}, {cons,_,H2,T2}, St0) -> - St = reject_bin_alias(H1, H2, St0), - reject_bin_alias(T1, T2, St); -reject_bin_alias({tuple,_,Es1}, {tuple,_,Es2}, St) -> - reject_bin_alias_list(Es1, Es2, St); -reject_bin_alias({record,_,Name1,Pfs1}, {record,_,Name2,Pfs2}, +reject_invalid_alias({map,_Line,Ps1}, {map,_,Ps2}, Vt, St0) -> + Fun = fun ({map_field_exact,L,{var,_,K},_V}, Sti) -> + case is_var_bound(K,Vt) of + true -> + Sti; + false -> + add_error(L, {unbound_var,K}, Sti) + end; + ({map_field_exact,_L,_K,_V}, Sti) -> + Sti + end, + foldl(Fun, foldl(Fun, St0, Ps1), Ps2); +reject_invalid_alias({cons,_,H1,T1}, {cons,_,H2,T2}, Vt, St0) -> + St = reject_invalid_alias(H1, H2, Vt, St0), + reject_invalid_alias(T1, T2, Vt, St); +reject_invalid_alias({tuple,_,Es1}, {tuple,_,Es2}, Vt, St) -> + reject_invalid_alias_list(Es1, Es2, Vt, St); +reject_invalid_alias({record,_,Name1,Pfs1}, {record,_,Name2,Pfs2}, Vt, #lint{records=Recs}=St) -> case {dict:find(Name1, Recs),dict:find(Name2, Recs)} of {{ok,{_Line1,Fields1}},{ok,{_Line2,Fields2}}} -> - reject_bin_alias_rec(Pfs1, Pfs2, Fields1, Fields2, St); + reject_invalid_alias_rec(Pfs1, Pfs2, Fields1, Fields2, Vt, St); {_,_} -> %% One or more non-existing records. (An error messages has %% already been generated, so we are done here.) St end; -reject_bin_alias({match,_,P1,P2}, P, St0) -> - St = reject_bin_alias(P1, P, St0), - reject_bin_alias(P2, P, St); -reject_bin_alias(P, {match,_,_,_}=M, St) -> - reject_bin_alias(M, P, St); -reject_bin_alias(_P1, _P2, St) -> St. - -reject_bin_alias_list([E1|Es1], [E2|Es2], St0) -> - St = reject_bin_alias(E1, E2, St0), - reject_bin_alias_list(Es1, Es2, St); -reject_bin_alias_list(_, _, St) -> St. - -reject_bin_alias_rec(PfsA0, PfsB0, FieldsA0, FieldsB0, St) -> +reject_invalid_alias({match,_,P1,P2}, P, Vt, St0) -> + St = reject_invalid_alias(P1, P, Vt, St0), + reject_invalid_alias(P2, P, Vt, St); +reject_invalid_alias(P, {match,_,_,_}=M, Vt, St) -> + reject_invalid_alias(M, P, Vt, St); +reject_invalid_alias(_P1, _P2, _Vt, St) -> St. + +reject_invalid_alias_list([E1|Es1], [E2|Es2], Vt, St0) -> + St = reject_invalid_alias(E1, E2, Vt, St0), + reject_invalid_alias_list(Es1, Es2, Vt, St); +reject_invalid_alias_list(_, _, _, St) -> St. + +reject_invalid_alias_rec(PfsA0, PfsB0, FieldsA0, FieldsB0, Vt, St) -> %% We treat records as if they have been converted to tuples. PfsA1 = rbia_field_vars(PfsA0), PfsB1 = rbia_field_vars(PfsB0), @@ -1582,7 +1603,7 @@ reject_bin_alias_rec(PfsA0, PfsB0, FieldsA0, FieldsB0, St) -> D = sofs:projection({external,fun({_,_,P1,_,P2}) -> {P1,P2} end}, C), E = sofs:to_external(D), {Ps1,Ps2} = lists:unzip(E), - reject_bin_alias_list(Ps1, Ps2, St). + reject_invalid_alias_list(Ps1, Ps2, Vt, St). rbia_field_vars(Fs) -> [{Name,Pat} || {record_field,_,{atom,_,Name},Pat} <- Fs]. @@ -2284,7 +2305,7 @@ expr({'catch',Line,E}, Vt, St0) -> expr({match,_Line,P,E}, Vt, St0) -> {Evt,St1} = expr(E, Vt, St0), {Pvt,Bvt,St2} = pattern(P, vtupdate(Evt, Vt), St1), - St = reject_bin_alias_expr(P, E, St2), + St = reject_invalid_alias_expr(P, E, Vt, St2), {vtupdate(Bvt, vtmerge(Evt, Pvt)),St}; %% No comparison or boolean operators yet. expr({op,_Line,_Op,A}, Vt, St) -> @@ -2381,7 +2402,7 @@ is_valid_call(Call) -> _ -> true end. -%% is_valid_map_key(K,St) -> true | false +%% is_valid_map_key(K) -> true | false %% variables are allowed for patterns only at the top of the tree is_valid_map_key({var,_,_}) -> true; @@ -3413,6 +3434,14 @@ warn_unused_vars(U, Vt, St0) -> UVt = map(fun ({V,{State,_,Ls}}) -> {V,{State,used,Ls}} end, U), {vtmerge(Vt, UVt), St1}. + +is_var_bound(V, Vt) -> + case orddict:find(V, Vt) of + {ok,{bound,_Usage,_}} -> true; + _ -> false + end. + + %% vtupdate(UpdVarTable, VarTable) -> VarTable. %% Add the variables in the updated vartable to VarTable. The variables %% will be updated with their property in UpdVarTable. The state of diff --git a/lib/stdlib/src/gen_statem.erl b/lib/stdlib/src/gen_statem.erl index f9e2e5f7d2..23bddafeed 100644 --- a/lib/stdlib/src/gen_statem.erl +++ b/lib/stdlib/src/gen_statem.erl @@ -97,7 +97,7 @@ %% * Postponing the current event is performed %% iff 'postpone' is 'true'. %% * A state timer is started iff 'timeout' is set. - %% * Pending events are processed or if there are + %% * Pending events are handled or if there are %% no pending events the server goes into receive %% or hibernate (iff 'hibernate' is 'true') %% @@ -282,16 +282,6 @@ event_type(Type) -> STACKTRACE(), try throw(ok) catch _ -> erlang:get_stacktrace() end). --define( - TERMINATE(Class, Reason, Debug, S, Q), - terminate( - begin Class end, - begin Reason end, - ?STACKTRACE(), - begin Debug end, - begin S end, - begin Q end)). - %%%========================================================================== %%% API @@ -300,11 +290,11 @@ event_type(Type) -> | {'via', RegMod :: module(), Name :: term()} | {'local', atom()}. -type server_ref() :: - {'global', GlobalName :: term()} - | {'via', RegMod :: module(), ViaName :: term()} + pid() | (LocalName :: atom()) | {Name :: atom(), Node :: atom()} - | pid(). + | {'global', GlobalName :: term()} + | {'via', RegMod :: module(), ViaName :: term()}. -type debug_opt() :: {'debug', Dbgs :: @@ -523,12 +513,15 @@ send(Proc, Msg) -> ok end. -%% Here init_it/6 and enter_loop/5,6,7 functions converge +%% Here the init_it/6 and enter_loop/5,6,7 functions converge enter(Module, Opts, CallbackMode, State, Data, Server, Actions, Parent) -> %% The values should already have been type checked Name = gen:get_proc_name(Server), Debug = gen:debug_options(Name, Opts), - PrevState = make_ref(), % Will be discarded by loop_event_actions/9 + P = Events = [], + Event = {internal,initial_state}, + %% We enforce {postpone,false} to ensure that + %% our fake Event gets discarded, thought it might get logged NewActions = if is_list(Actions) -> @@ -540,15 +533,17 @@ enter(Module, Opts, CallbackMode, State, Data, Server, Actions, Parent) -> callback_mode => CallbackMode, module => Module, name => Name, - state => PrevState, + %% All fields below will be replaced according to the arguments to + %% loop_event_actions/10 when it finally loops back to loop/3 + state => State, data => Data, - timer => undefined, - postponed => [], - hibernate => false}, + postponed => P, + hibernate => false, + timer => undefined}, + NewDebug = sys_debug(Debug, S, State, {enter,Event,State}), loop_event_actions( - Parent, Debug, S, [], - {event,undefined}, % Will be discarded thanks to {postpone,false} - PrevState, State, Data, NewActions). + Parent, NewDebug, S, Events, + State, Data, P, Event, State, NewActions). %%%========================================================================== %%% gen callbacks @@ -617,8 +612,12 @@ init_result(Starter, Parent, ServerRef, Module, Result, Opts) -> system_continue(Parent, Debug, S) -> loop(Parent, Debug, S). -system_terminate(Reason, _Parent, Debug, S) -> - ?TERMINATE(exit, Reason, Debug, S, []). +system_terminate( + Reason, _Parent, Debug, + #{state := State, data := Data, postponed := P} = S) -> + terminate( + exit, Reason, ?STACKTRACE(), + Debug, S, [], State, Data, P). system_code_change( #{module := Module, @@ -634,7 +633,10 @@ system_code_change( {NewCallbackMode,NewState,NewData} -> callback_mode(NewCallbackMode) orelse error({callback_mode,NewCallbackMode}), - {ok,S#{state := NewState, data := NewData}}; + {ok, + S#{callback_mode := NewCallbackMode, + state := NewState, + data := NewData}}; {ok,_} = Error -> error({case_clause,Error}); Error -> @@ -654,7 +656,7 @@ system_replace_state( format_status( Opt, [PDict,SysState,Parent,Debug, - #{name := Name, postponed := P} = S]) -> + #{name := Name, postponed := P, state := State, data := Data} = S]) -> Header = gen:format_status_header("Status for state machine", Name), Log = sys:get_debug(log, Debug, []), [{header,Header}, @@ -663,7 +665,7 @@ format_status( {"Parent",Parent}, {"Logged Events",Log}, {"Postponed",P}]} | - case format_status(Opt, PDict, S) of + case format_status(Opt, PDict, S, State, Data) of L when is_list(L) -> L; T -> [T] end]. @@ -673,21 +675,21 @@ format_status( %% them, not as the real erlang messages. Use trace for that. %%--------------------------------------------------------------------------- -print_event(Dev, {in,Event}, #{name := Name}) -> +print_event(Dev, {in,Event}, {Name,_}) -> io:format( Dev, "*DBG* ~p received ~s~n", [Name,event_string(Event)]); -print_event(Dev, {out,Reply,{To,_Tag}}, #{name := Name}) -> +print_event(Dev, {out,Reply,{To,_Tag}}, {Name,_}) -> io:format( Dev, "*DBG* ~p sent ~p to ~p~n", [Name,Reply,To]); -print_event(Dev, {Tag,Event,NewState}, #{name := Name, state := State}) -> +print_event(Dev, {Tag,Event,NextState}, {Name,State}) -> StateString = - case NewState of + case NextState of State -> io_lib:format("~p", [State]); _ -> - io_lib:format("~p => ~p", [State,NewState]) + io_lib:format("~p => ~p", [State,NextState]) end, io:format( Dev, "*DBG* ~p ~w ~s in state ~s~n", @@ -697,16 +699,17 @@ event_string(Event) -> case Event of {{call,{Pid,_Tag}},Request} -> io_lib:format("call ~p from ~w", [Request,Pid]); - {Tag,Content} -> - io_lib:format("~w ~p", [Tag,Content]) + {EventType,EventContent} -> + io_lib:format("~w ~p", [EventType,EventContent]) end. -sys_debug(Debug, S, Entry) -> +sys_debug(Debug, #{name := Name}, State, Entry) -> case Debug of [] -> Debug; _ -> - sys:handle_debug(Debug, fun print_event/3, S, Entry) + sys:handle_debug( + Debug, fun print_event/3, {Name,State}, Entry) end. %%%========================================================================== @@ -720,7 +723,7 @@ wakeup_from_hibernate(Parent, Debug, S) -> %%% State Machine engine implementation of proc_lib/gen server %% Server loop, consists of all loop* functions -%% and some detours through sys and proc_lib +%% and detours through sys:handle_system_message/7 and proc_lib:hibernate/3 %% Entry point for system_continue/3 loop(Parent, Debug, #{hibernate := Hibernate} = S) -> @@ -749,12 +752,16 @@ loop_receive(Parent, Debug, #{timer := Timer} = S) -> sys:handle_system_msg( Req, Pid, Parent, ?MODULE, Debug, S, Hibernate); {'EXIT',Parent,Reason} = EXIT -> + #{state := State, data := Data, postponed := P} = S, %% EXIT is not a 2-tuple and therefore %% not an event and has no event_type(), %% but this will stand out in the crash report... - ?TERMINATE(exit, Reason, Debug, S, [EXIT]); + terminate( + exit, Reason, ?STACKTRACE(), + Debug, S, [EXIT], State, Data, P); {timeout,Timer,Content} when Timer =/= undefined -> - loop_event(Parent, Debug, S, {timeout,Content}); + loop_receive_result( + Parent, Debug, S, {timeout,Content}); _ -> %% Cancel Timer if running case Timer of @@ -782,30 +789,81 @@ loop_receive(Parent, Debug, #{timer := Timer} = S) -> _ -> {info,Msg} end, - loop_event(Parent, Debug, S, Event) + loop_receive_result(Parent, Debug, S, Event) end end. -loop_event(Parent, Debug, S, Event) -> - %% The timer field and the hibernate flag in S - %% are now invalid and ignored until we get back to loop/3 - NewDebug = sys_debug(Debug, S, {in,Event}), - %% Here the queue of not yet processed events is created - loop_events(Parent, NewDebug, S, [Event], false). - -%% Process first the event queue, or if it is empty -%% loop back to receive a new event -loop_events(Parent, Debug, S, [], _Hibernate) -> - loop(Parent, Debug, S); +loop_receive_result( + Parent, Debug, + #{state := State, + data := Data, + postponed := P} = S, + Event) -> + %% The engine state map S is now dismantled + %% and will not be restored until we return to loop/3. + %% + %% The fields 'callback_mode', 'module', and 'name' are still valid. + %% The fields 'state', 'data', and 'postponed' are held in arguments. + %% The fields 'timer' and 'hibernate' will be recalculated. + %% + NewDebug = sys_debug(Debug, S, State, {in,Event}), + %% Here the queue of not yet handled events is created + Events = [], + Hibernate = false, + loop_event( + Parent, NewDebug, S, Events, State, Data, P, Event, Hibernate). + +%% Process the event queue, or if it is empty +%% loop back to loop/3 to receive a new event +loop_events( + Parent, Debug, S, [Event|Events], + State, Data, P, Hibernate, _Timeout) -> + %% + %% If there was a state timer requested we just ignore that + %% since we have events to handle which cancels the timer + loop_event( + Parent, Debug, S, Events, State, Data, P, Event, Hibernate); loop_events( + Parent, Debug, S, [], + State, Data, P, Hibernate, Timeout) -> + case Timeout of + {timeout,0,EventContent} -> + %% Immediate timeout - simulate it + %% so we do not get the timeout message + %% after any received event + loop_event( + Parent, Debug, S, [], + State, Data, P, {timeout,EventContent}, Hibernate); + {timeout,Time,EventContent} -> + %% Actually start a timer + Timer = erlang:start_timer(Time, self(), EventContent), + loop_events_done( + Parent, Debug, S, Timer, State, Data, P, Hibernate); + undefined -> + %% No state timeout has been requested + Timer = undefined, + loop_events_done( + Parent, Debug, S, Timer, State, Data, P, Hibernate) + end. +%% +loop_events_done(Parent, Debug, S, Timer, State, Data, P, Hibernate) -> + NewS = + S#{ + state := State, + data := Data, + postponed := P, + hibernate := Hibernate, + timer := Timer}, + loop(Parent, Debug, NewS). + +loop_event( Parent, Debug, #{callback_mode := CallbackMode, - module := Module, - state := State, - data := Data} = S, - [{Type,Content} = Event|Events] = Q, - Hibernate) -> - %% If the Hibernate flag is true here it can only be + module := Module} = S, + Events, + State, Data, P, {Type,Content} = Event, Hibernate) -> + %% + %% If Hibernate is true here it can only be %% because it was set from an event action %% and we did not go into hibernation since there %% were events in queue, so we do what the user @@ -813,6 +871,7 @@ loop_events( %% would have happened if we actually hibernated %% and immediately was awakened Hibernate andalso garbage_collect(), + %% try case CallbackMode of state_functions -> @@ -822,11 +881,11 @@ loop_events( end of Result -> loop_event_result( - Parent, Debug, S, Events, Event, Result) + Parent, Debug, S, Events, State, Data, P, Event, Result) catch Result -> loop_event_result( - Parent, Debug, S, Events, Event, Result); + Parent, Debug, S, Events, State, Data, P, Event, Result); error:badarg when CallbackMode =:= state_functions -> case erlang:get_stacktrace() of [{erlang,apply,[Module,State,_],_}|Stacktrace] -> @@ -835,9 +894,11 @@ loop_events( error, {undef_state_function,{Module,State,Args}}, Stacktrace, - Debug, S, Q); + Debug, S, [Event|Events], State, Data, P); Stacktrace -> - terminate(error, badarg, Stacktrace, Debug, S, Q) + terminate( + error, badarg, Stacktrace, + Debug, S, [Event|Events], State, Data, P) end; error:undef -> %% Process an undef to check for the simple mistake @@ -852,7 +913,7 @@ loop_events( error, {undef_state_function,{Module,State,Args}}, Stacktrace, - Debug, S, Q); + Debug, S, [Event|Events], State, Data, P); [{Module,handle_event, [Type,Content,State,Data]=Args, _} @@ -860,86 +921,85 @@ loop_events( when CallbackMode =:= handle_event_function -> terminate( error, - {undef_state_function, - {Module,handle_event,Args}}, + {undef_state_function,{Module,handle_event,Args}}, Stacktrace, - Debug, S, Q); + Debug, S, [Event|Events], State, Data, P); Stacktrace -> - terminate(error, undef, Stacktrace, Debug, S, Q) + terminate( + error, undef, Stacktrace, + Debug, S, [Event|Events], State, Data, P) end; Class:Reason -> Stacktrace = erlang:get_stacktrace(), - terminate(Class, Reason, Stacktrace, Debug, S, Q) + terminate( + Class, Reason, Stacktrace, + Debug, S, [Event|Events], State, Data, P) end. %% Interpret all callback return variants loop_event_result( - Parent, Debug, - #{state := State, data := Data} = S, - Events, Event, Result) -> - %% From now until we loop back to the loop_events/4 - %% the state and data fields in S are old + Parent, Debug, S, Events, State, Data, P, Event, Result) -> case Result of stop -> - ?TERMINATE(exit, normal, Debug, S, [Event|Events]); + terminate( + exit, normal, ?STACKTRACE(), + Debug, S, [Event|Events], State, Data, P); {stop,Reason} -> - ?TERMINATE(exit, Reason, Debug, S, [Event|Events]); + terminate( + exit, Reason, ?STACKTRACE(), + Debug, S, [Event|Events], State, Data, P); {stop,Reason,NewData} -> - NewS = S#{data := NewData}, - Q = [Event|Events], - ?TERMINATE(exit, Reason, Debug, NewS, Q); + terminate( + exit, Reason, ?STACKTRACE(), + Debug, S, [Event|Events], State, NewData, P); {stop_and_reply,Reason,Replies} -> Q = [Event|Events], - [Class,NewReason,Stacktrace,NewDebug] = - reply_then_terminate( - exit, Reason, ?STACKTRACE(), Debug, S, Q, Replies), - %% Since we got back here Replies was bad - terminate(Class, NewReason, Stacktrace, NewDebug, S, Q); + reply_then_terminate( + exit, Reason, ?STACKTRACE(), + Debug, S, Q, State, Data, P, Replies); {stop_and_reply,Reason,Replies,NewData} -> - NewS = S#{data := NewData}, Q = [Event|Events], - [Class,NewReason,Stacktrace,NewDebug] = - reply_then_terminate( - exit, Reason, ?STACKTRACE(), Debug, NewS, Q, Replies), - %% Since we got back here Replies was bad - terminate(Class, NewReason, Stacktrace, NewDebug, NewS, Q); + reply_then_terminate( + exit, Reason, ?STACKTRACE(), + Debug, S, Q, State, NewData, P, Replies); {next_state,NextState,NewData} -> loop_event_actions( - Parent, Debug, S, Events, Event, - State, NextState, NewData, []); + Parent, Debug, S, Events, + State, NewData, P, Event, NextState, []); {next_state,NextState,NewData,Actions} -> loop_event_actions( - Parent, Debug, S, Events, Event, - State, NextState, NewData, Actions); + Parent, Debug, S, Events, + State, NewData, P, Event, NextState, Actions); {keep_state,NewData} -> loop_event_actions( - Parent, Debug, S, Events, Event, - State, State, NewData, []); + Parent, Debug, S, Events, + State, NewData, P, Event, State, []); {keep_state,NewData,Actions} -> loop_event_actions( - Parent, Debug, S, Events, Event, - State, State, NewData, Actions); + Parent, Debug, S, Events, + State, NewData, P, Event, State, Actions); keep_state_and_data -> loop_event_actions( - Parent, Debug, S, Events, Event, - State, State, Data, []); + Parent, Debug, S, Events, + State, Data, P, Event, State, []); {keep_state_and_data,Actions} -> loop_event_actions( - Parent, Debug, S, Events, Event, - State, State, Data, Actions); + Parent, Debug, S, Events, + State, Data, P, Event, State, Actions); _ -> - ?TERMINATE( - error, {bad_return_value,Result}, Debug, S, [Event|Events]) + terminate( + error, {bad_return_value,Result}, ?STACKTRACE(), + Debug, S, [Event|Events], State, Data, P) end. loop_event_actions( - Parent, Debug, S, Events, Event, State, NextState, NewData, Actions) -> - Postpone = false, % Shall we postpone this event, true or false + Parent, Debug, S, Events, State, NewData, P, Event, NextState, Actions) -> + Postpone = false, % Shall we postpone this event; boolean() Hibernate = false, Timeout = undefined, NextEvents = [], loop_event_actions( - Parent, Debug, S, Events, Event, State, NextState, NewData, + Parent, Debug, S, Events, State, NewData, P, Event, NextState, if is_list(Actions) -> Actions; @@ -948,97 +1008,103 @@ loop_event_actions( end, Postpone, Hibernate, Timeout, NextEvents). %% -%% Process all action()s +%% Process all actions loop_event_actions( - Parent, Debug, S, Events, Event, - State, NextState, NewData, [Action|Actions], + Parent, Debug, S, Events, + State, NewData, P, Event, NextState, [Action|Actions], Postpone, Hibernate, Timeout, NextEvents) -> case Action of %% Actual actions {reply,From,Reply} -> case from(From) of true -> - NewDebug = do_reply(Debug, S, From, Reply), + NewDebug = do_reply(Debug, S, State, From, Reply), loop_event_actions( - Parent, NewDebug, S, Events, Event, - State, NextState, NewData, Actions, + Parent, NewDebug, S, Events, + State, NewData, P, Event, NextState, Actions, Postpone, Hibernate, Timeout, NextEvents); false -> - ?TERMINATE( - error, {bad_action,Action}, Debug, S, [Event|Events]) + terminate( + error, {bad_action,Action}, ?STACKTRACE(), + Debug, S, [Event|Events], State, NewData, P) end; {next_event,Type,Content} -> case event_type(Type) of true -> loop_event_actions( - Parent, Debug, S, Events, Event, - State, NextState, NewData, Actions, + Parent, Debug, S, Events, + State, NewData, P, Event, NextState, Actions, Postpone, Hibernate, Timeout, [{Type,Content}|NextEvents]); false -> - ?TERMINATE( - error, {bad_action,Action}, Debug, S, [Event|Events]) + terminate( + error, {bad_action,Action}, ?STACKTRACE(), + Debug, S, [Event|Events], State, NewData, P) end; %% Actions that set options {postpone,NewPostpone} when is_boolean(NewPostpone) -> loop_event_actions( - Parent, Debug, S, Events, Event, - State, NextState, NewData, Actions, + Parent, Debug, S, Events, + State, NewData, P, Event, NextState, Actions, NewPostpone, Hibernate, Timeout, NextEvents); {postpone,_} -> - ?TERMINATE( - error, {bad_action,Action}, Debug, S, [Event|Events]); + terminate( + error, {bad_action,Action}, ?STACKTRACE(), + Debug, S, [Event|Events], State, NewData, P); postpone -> loop_event_actions( - Parent, Debug, S, Events, Event, - State, NextState, NewData, Actions, + Parent, Debug, S, Events, + State, NewData, P, Event, NextState, Actions, true, Hibernate, Timeout, NextEvents); {hibernate,NewHibernate} when is_boolean(NewHibernate) -> loop_event_actions( - Parent, Debug, S, Events, Event, - State, NextState, NewData, Actions, + Parent, Debug, S, Events, + State, NewData, P, Event, NextState, Actions, Postpone, NewHibernate, Timeout, NextEvents); {hibernate,_} -> - ?TERMINATE( - error, {bad_action,Action}, Debug, S, [Event|Events]); + terminate( + error, {bad_action,Action}, ?STACKTRACE(), + Debug, S, [Event|Events], State, NewData, P); hibernate -> loop_event_actions( - Parent, Debug, S, Events, Event, - State, NextState, NewData, Actions, + Parent, Debug, S, Events, + State, NewData, P, Event, NextState, Actions, Postpone, true, Timeout, NextEvents); {timeout,infinity,_} -> % Clear timer - it will never trigger loop_event_actions( - Parent, Debug, S, Events, Event, - State, NextState, NewData, Actions, + Parent, Debug, S, Events, + State, NewData, P, Event, NextState, Actions, Postpone, Hibernate, undefined, NextEvents); {timeout,Time,_} = NewTimeout when is_integer(Time), Time >= 0 -> loop_event_actions( - Parent, Debug, S, Events, Event, - State, NextState, NewData, Actions, + Parent, Debug, S, Events, + State, NewData, P, Event, NextState, Actions, Postpone, Hibernate, NewTimeout, NextEvents); {timeout,_,_} -> - ?TERMINATE( - error, {bad_action,Action}, Debug, S, [Event|Events]); + terminate( + error, {bad_action,Action}, ?STACKTRACE(), + Debug, S, [Event|Events], State, NewData, P); infinity -> % Clear timer - it will never trigger loop_event_actions( - Parent, Debug, S, Events, Event, - State, NextState, NewData, Actions, + Parent, Debug, S, Events, + State, NewData, P, Event, NextState, Actions, Postpone, Hibernate, undefined, NextEvents); Time when is_integer(Time), Time >= 0 -> NewTimeout = {timeout,Time,Time}, loop_event_actions( - Parent, Debug, S, Events, Event, - State, NextState, NewData, Actions, + Parent, Debug, S, Events, + State, NewData, P, Event, NextState, Actions, Postpone, Hibernate, NewTimeout, NextEvents); _ -> - ?TERMINATE( - error, {bad_action,Action}, Debug, S, [Event|Events]) + terminate( + error, {bad_action,Action}, ?STACKTRACE(), + Debug, S, [Event|Events], State, NewData, P) end; %% %% End of actions list loop_event_actions( - Parent, Debug, #{postponed := P0} = S, Events, Event, - State, NextState, NewData, [], + Parent, Debug, S, Events, + State, NewData, P0, Event, NextState, [], Postpone, Hibernate, Timeout, NextEvents) -> %% %% All options have been collected and next_events are buffered. @@ -1059,89 +1125,62 @@ loop_event_actions( {lists:reverse(P1, Events),[]} end, %% Place next events first in queue - Q3 = lists:reverse(NextEvents, Q2), + Q = lists:reverse(NextEvents, Q2), %% NewDebug = sys_debug( - Debug, S, + Debug, S, State, case Postpone of true -> {postpone,Event,NextState}; false -> {consume,Event,NextState} end), - %% Have a peek on the event queue so we can avoid starting - %% the state timer unless we have to - {Q,Timer} = - case Timeout of - undefined -> - %% No state timeout has been requested - {Q3,undefined}; - {timeout,Time,EventContent} -> - %% A state timeout has been requested - case Q3 of - [] when Time =:= 0 -> - %% Immediate timeout - simulate it - %% so we do not get the timeout message - %% after any received event - {[{timeout,EventContent}],undefined}; - [] -> - %% Actually start a timer - {Q3,erlang:start_timer(Time, self(), EventContent)}; - _ -> - %% Do not start a timer since any queued - %% event cancels the state timer so we pretend - %% that the timer has been started and cancelled - {Q3,undefined} - end - end, - %% Loop to top of event queue loop; process next event loop_events( - Parent, NewDebug, - S#{ - state := NextState, - data := NewData, - timer := Timer, - postponed := P, - hibernate := Hibernate}, - Q, Hibernate). + Parent, NewDebug, S, Q, NextState, NewData, P, Hibernate, Timeout). %%--------------------------------------------------------------------------- %% Server helpers -reply_then_terminate(Class, Reason, Stacktrace, Debug, S, Q, Replies) -> +reply_then_terminate( + Class, Reason, Stacktrace, + Debug, S, Q, State, Data, P, Replies) -> if is_list(Replies) -> do_reply_then_terminate( - Class, Reason, Stacktrace, Debug, S, Q, Replies); + Class, Reason, Stacktrace, + Debug, S, Q, State, Data, P, Replies); true -> do_reply_then_terminate( - Class, Reason, Stacktrace, Debug, S, Q, [Replies]) + Class, Reason, Stacktrace, + Debug, S, Q, State, Data, P, [Replies]) end. %% -do_reply_then_terminate(Class, Reason, Stacktrace, Debug, S, Q, []) -> - terminate(Class, Reason, Stacktrace, Debug, S, Q); do_reply_then_terminate( - Class, Reason, Stacktrace, Debug, S, Q, [R|Rs]) -> + Class, Reason, Stacktrace, Debug, S, Q, State, Data, P, []) -> + terminate(Class, Reason, Stacktrace, Debug, S, Q, State, Data, P); +do_reply_then_terminate( + Class, Reason, Stacktrace, Debug, S, Q, State, Data, P, [R|Rs]) -> case R of {reply,{_To,_Tag}=From,Reply} -> - NewDebug = do_reply(Debug, S, From, Reply), + NewDebug = do_reply(Debug, S, State, From, Reply), do_reply_then_terminate( - Class, Reason, Stacktrace, NewDebug, S, Q, Rs); + Class, Reason, Stacktrace, + NewDebug, S, Q, State, Data, P, Rs); _ -> - [error,{bad_action,R},?STACKTRACE(),Debug] + terminate( + error, {bad_action,R}, ?STACKTRACE(), + Debug, S, Q, State, Data, P) end. -do_reply(Debug, S, From, Reply) -> +do_reply(Debug, S, State, From, Reply) -> reply(From, Reply), - sys_debug(Debug, S, {out,Reply,From}). + sys_debug(Debug, S, State, {out,Reply,From}). terminate( - Class, Reason, Stacktrace, Debug, - #{module := Module, - state := State, data := Data} = S, - Q) -> + Class, Reason, Stacktrace, + Debug, #{module := Module} = S, Q, State, Data, P) -> try Module:terminate(Reason, State, Data) of _ -> ok catch @@ -1149,8 +1188,8 @@ terminate( C:R -> ST = erlang:get_stacktrace(), error_info( - C, R, ST, Debug, S, Q, - format_status(terminate, get(), S)), + C, R, ST, Debug, S, Q, P, + format_status(terminate, get(), S, State, Data)), erlang:raise(C, R, ST) end, case Reason of @@ -1159,8 +1198,8 @@ terminate( {shutdown,_} -> ok; _ -> error_info( - Class, Reason, Stacktrace, Debug, S, Q, - format_status(terminate, get(), S)) + Class, Reason, Stacktrace, Debug, S, Q, P, + format_status(terminate, get(), S, State, Data)) end, case Stacktrace of [] -> @@ -1171,9 +1210,8 @@ terminate( error_info( Class, Reason, Stacktrace, Debug, - #{name := Name, callback_mode := CallbackMode, - state := State, postponed := P}, - Q, FmtData) -> + #{name := Name, callback_mode := CallbackMode}, + Q, P, FmtData) -> {FixedReason,FixedStacktrace} = case Stacktrace of [{M,F,Args,_}|ST] @@ -1202,46 +1240,49 @@ error_info( error_logger:format( "** State machine ~p terminating~n" ++ case Q of - [] -> - ""; - _ -> - "** Last event = ~p~n" + [] -> ""; + _ -> "** Last event = ~p~n" end ++ - "** When Server state = ~p~n" ++ + "** When server state = ~p~n" ++ "** Reason for termination = ~w:~p~n" ++ - "** State = ~p~n" ++ "** Callback mode = ~p~n" ++ - "** Queued/Postponed = ~w/~w~n" ++ + case Q of + [_,_|_] -> "** Queued = ~p~n"; + _ -> "" + end ++ + case P of + [] -> ""; + _ -> "** Postponed = ~p~n" + end ++ case FixedStacktrace of - [] -> - ""; - _ -> - "** Stacktrace =~n" - "** ~p~n" + [] -> ""; + _ -> "** Stacktrace =~n** ~p~n" end, [Name | case Q of - [] -> - []; - [Event|_] -> - [Event] + [] -> []; + [Event|_] -> [Event] end] ++ [FmtData,Class,FixedReason, - State,CallbackMode,length(Q),length(P)] ++ + CallbackMode] ++ + case Q of + [_|[_|_] = Events] -> [Events]; + _ -> [] + end ++ + case P of + [] -> []; + _ -> [P] + end ++ case FixedStacktrace of - [] -> - []; - _ -> - [FixedStacktrace] + [] -> []; + _ -> [FixedStacktrace] end), sys:print_log(Debug), ok. %% Call Module:format_status/2 or return a default value -format_status( - Opt, PDict, - #{module := Module, state := State, data := Data}) -> +format_status(Opt, PDict, #{module := Module}, State, Data) -> case erlang:function_exported(Module, format_status, 2) of true -> try Module:format_status(Opt, [PDict,State,Data]) diff --git a/lib/stdlib/src/proc_lib.erl b/lib/stdlib/src/proc_lib.erl index 3f79ed0f87..fdc2ae4070 100644 --- a/lib/stdlib/src/proc_lib.erl +++ b/lib/stdlib/src/proc_lib.erl @@ -48,7 +48,9 @@ | {'priority', priority_level()} | {'min_heap_size', non_neg_integer()} | {'min_bin_vheap_size', non_neg_integer()} - | {'fullsweep_after', non_neg_integer()}. + | {'fullsweep_after', non_neg_integer()} + | {'message_queue_data', + 'off_heap' | 'on_heap' | 'mixed' }. -type dict_or_pid() :: pid() | (ProcInfo :: [_]) diff --git a/lib/stdlib/test/epp_SUITE.erl b/lib/stdlib/test/epp_SUITE.erl index ef2c912c57..4078513e38 100644 --- a/lib/stdlib/test/epp_SUITE.erl +++ b/lib/stdlib/test/epp_SUITE.erl @@ -27,7 +27,8 @@ pmod/1, not_circular/1, skip_header/1, otp_6277/1, otp_7702/1, otp_8130/1, overload_mac/1, otp_8388/1, otp_8470/1, otp_8562/1, otp_8665/1, otp_8911/1, otp_10302/1, otp_10820/1, - otp_11728/1, encoding/1, extends/1, function_macro/1]). + otp_11728/1, encoding/1, extends/1, function_macro/1, + test_error/1, test_warning/1]). -export([epp_parse_erl_form/2]). @@ -67,7 +68,7 @@ all() -> not_circular, skip_header, otp_6277, otp_7702, otp_8130, overload_mac, otp_8388, otp_8470, otp_8562, otp_8665, otp_8911, otp_10302, otp_10820, otp_11728, - encoding, extends, function_macro]. + encoding, extends, function_macro, test_error, test_warning]. groups() -> [{upcase_mac, [], [upcase_mac_1, upcase_mac_2]}, @@ -1055,7 +1056,65 @@ ifdef(Config) -> ], [] = run(Config, Ts). +%% OTP-12847: Test the -error directive. +test_error(Config) -> + Cs = [{error_c1, + <<"-error(\"string and macro: \" ?MODULE_STRING).\n" + "-ifdef(NOT_DEFINED).\n" + " -error(\"this one will be skipped\").\n" + "-endif.\n">>, + {errors,[{1,epp,{error,"string and macro: epp_test"}}],[]}}, + + {error_c2, + <<"-ifdef(CONFIG_A).\n" + " t() -> a.\n" + "-else.\n" + "-ifdef(CONFIG_B).\n" + " t() -> b.\n" + "-else.\n" + "-error(\"Neither CONFIG_A nor CONFIG_B are available\").\n" + "-endif.\n" + "-endif.\n">>, + {errors,[{7,epp,{error,"Neither CONFIG_A nor CONFIG_B are available"}}],[]}}, + + {error_c3, + <<"-error(a b c).\n">>, + {errors,[{1,epp,{bad,error}}],[]}} + ], + + [] = compile(Config, Cs), + ok. + +%% OTP-12847: Test the -warning directive. +test_warning(Config) -> + Cs = [{warn_c1, + <<"-warning({a,term,?MODULE}).\n" + "-ifdef(NOT_DEFINED).\n" + "-warning(\"this one will be skipped\").\n" + "-endif.\n">>, + {warnings,[{1,epp,{warning,{a,term,epp_test}}}]}}, + + {warn_c2, + <<"-ifdef(CONFIG_A).\n" + " t() -> a.\n" + "-else.\n" + "-ifdef(CONFIG_B).\n" + " t() -> b.\n" + "-else.\n" + " t() -> c.\n" + "-warning(\"Using fallback\").\n" + "-endif.\n" + "-endif.\n">>, + {warnings,[{8,epp,{warning,"Using fallback"}}]}}, + + {warn_c3, + <<"-warning(a b c).\n">>, + {errors,[{1,epp,{bad,warning}}],[]}} + ], + + [] = compile(Config, Cs), + ok. %% Advanced test on overloading macros. overload_mac(Config) when is_list(Config) -> diff --git a/lib/stdlib/test/erl_lint_SUITE.erl b/lib/stdlib/test/erl_lint_SUITE.erl index 6fea198af3..b0214e5238 100644 --- a/lib/stdlib/test/erl_lint_SUITE.erl +++ b/lib/stdlib/test/erl_lint_SUITE.erl @@ -33,47 +33,38 @@ -define(privdir, proplists:get_value(priv_dir, Conf)). -endif. --export([all/0, suite/0,groups/0,init_per_suite/1, end_per_suite/1, - init_per_group/2,end_per_group/2, - init_per_testcase/2, end_per_testcase/2]). - --export([ - unused_vars_warn_basic/1, - unused_vars_warn_lc/1, - unused_vars_warn_rec/1, - unused_vars_warn_fun/1, - unused_vars_OTP_4858/1, - unused_unsafe_vars_warn/1, - export_vars_warn/1, - shadow_vars/1, - unused_import/1, - unused_function/1, - unsafe_vars/1,unsafe_vars2/1, - unsafe_vars_try/1, - unsized_binary_in_bin_gen_pattern/1, - guard/1, otp_4886/1, otp_4988/1, otp_5091/1, otp_5276/1, otp_5338/1, - otp_5362/1, otp_5371/1, otp_7227/1, otp_5494/1, otp_5644/1, otp_5878/1, - otp_5917/1, otp_6585/1, otp_6885/1, otp_10436/1, otp_11254/1, - otp_11772/1, otp_11771/1, otp_11872/1, - export_all/1, - bif_clash/1, - behaviour_basic/1, behaviour_multiple/1, otp_11861/1, - otp_7550/1, - otp_8051/1, - format_warn/1, - on_load_successful/1, on_load_failing/1, - too_many_arguments/1, - basic_errors/1,bin_syntax_errors/1, - predef/1, - maps/1,maps_type/1,otp_11851/1,otp_11879/1,otp_13230/1, - record_errors/1 - ]). - -init_per_testcase(_Case, Config) -> - Config. - -end_per_testcase(_Case, _Config) -> - ok. +-export([all/0, suite/0, groups/0]). + +-export([unused_vars_warn_basic/1, + unused_vars_warn_lc/1, + unused_vars_warn_rec/1, + unused_vars_warn_fun/1, + unused_vars_OTP_4858/1, + unused_unsafe_vars_warn/1, + export_vars_warn/1, + shadow_vars/1, + unused_import/1, + unused_function/1, + unsafe_vars/1,unsafe_vars2/1, + unsafe_vars_try/1, + unsized_binary_in_bin_gen_pattern/1, + guard/1, otp_4886/1, otp_4988/1, otp_5091/1, otp_5276/1, otp_5338/1, + otp_5362/1, otp_5371/1, otp_7227/1, otp_5494/1, otp_5644/1, otp_5878/1, + otp_5917/1, otp_6585/1, otp_6885/1, otp_10436/1, otp_11254/1, + otp_11772/1, otp_11771/1, otp_11872/1, + export_all/1, + bif_clash/1, + behaviour_basic/1, behaviour_multiple/1, otp_11861/1, + otp_7550/1, + otp_8051/1, + format_warn/1, + on_load_successful/1, on_load_failing/1, + too_many_arguments/1, + basic_errors/1,bin_syntax_errors/1, + predef/1, + maps/1,maps_type/1,maps_parallel_match/1, + otp_11851/1,otp_11879/1,otp_13230/1, + record_errors/1]). suite() -> [{ct_hooks,[ts_install_cth]}, @@ -91,7 +82,8 @@ all() -> bif_clash, behaviour_basic, behaviour_multiple, otp_11861, otp_7550, otp_8051, format_warn, {group, on_load}, too_many_arguments, basic_errors, bin_syntax_errors, predef, - maps, maps_type, otp_11851, otp_11879, otp_13230, + maps, maps_type, maps_parallel_match, + otp_11851, otp_11879, otp_13230, record_errors]. groups() -> @@ -101,19 +93,6 @@ groups() -> unused_vars_OTP_4858, unused_unsafe_vars_warn]}, {on_load, [], [on_load_successful, on_load_failing]}]. -init_per_suite(Config) -> - Config. - -end_per_suite(_Config) -> - ok. - -init_per_group(_GroupName, Config) -> - Config. - -end_per_group(_GroupName, Config) -> - Config. - - %% Warnings for unused variables in some simple cases. unused_vars_warn_basic(Config) when is_list(Config) -> @@ -3583,8 +3562,6 @@ predef(Config) when is_list(Config) -> ok. maps(Config) -> - %% TODO: test key patterns, not done because map patterns are going to be - %% changed a lot. Ts = [{illegal_map_construction, <<"t() -> #{ a := b, @@ -3626,6 +3603,26 @@ maps(Config) -> {errors,[{1,erl_lint,illegal_map_construction}, {1,erl_lint,{unbound_var,'X'}}], []}}, + {legal_map_pattern, + <<" + -record(mapkey, {a=1,b=2}). + t(M,K1) -> + #{ a := 1, + $a := 1, $z := 99, + #{a=>val} := 2, + K1 := 1337, + #mapkey{a = 10} := wat, + #{{a,val}=>val} := 2, + #{ \"hi\" => wazzup, hi => ho } := yep, + ok := 1.0, + [3+3] := nope, + 1.0 := yep, + {3.0+3} := nope, + {yep} := yep + } = M. + ">>, + [], + []}, {legal_map_construction, <<"t(V) -> #{ a => 1, #{a=>V} => 2, @@ -3692,6 +3689,51 @@ maps_type(Config) when is_list(Config) -> [] = run(Config, Ts), ok. +maps_parallel_match(Config) when is_list(Config) -> + Ts = [{parallel_map_patterns_unbound1, + <<" + t(#{} = M) -> + #{K := V} = #{k := K} = M, + V. + ">>, + [], + {errors,[{3,erl_lint,{unbound_var,'K'}}],[]}}, + {parallel_map_patterns_unbound2, + <<" + t(#{} = M) -> + #{K1 := V1} = + #{K2 := V2} = + #{k1 := K1,k2 := K2} = M, + [V1,V2]. + ">>, + [], + {errors,[{3,erl_lint,{unbound_var,'K1'}}, + {3,erl_lint,{unbound_var,'K1'}}, + {4,erl_lint,{unbound_var,'K2'}}, + {4,erl_lint,{unbound_var,'K2'}}],[]}}, + {parallel_map_patterns_bound, + <<" + t(#{} = M,K1,K2) -> + #{K1 := V1} = + #{K2 := V2} = + #{k1 := K1,k2 := K2} = M, + [V1,V2]. + ">>, + [], + []}, + {parallel_map_patterns_literal, + <<" + t(#{} = M) -> + #{k1 := V1} = + #{k2 := V2} = + #{k1 := V1,k2 := V2} = M, + [V1,V2]. + ">>, + [], + []}], + [] = run(Config, Ts), + ok. + %% OTP-11851: More atoms can be used as type names + bug fixes. otp_11851(Config) when is_list(Config) -> Ts = [ diff --git a/lib/stdlib/test/gen_statem_SUITE.erl b/lib/stdlib/test/gen_statem_SUITE.erl index 3deb5fd986..364314f91b 100644 --- a/lib/stdlib/test/gen_statem_SUITE.erl +++ b/lib/stdlib/test/gen_statem_SUITE.erl @@ -634,12 +634,14 @@ sys1(Config) -> stop_it(Pid). code_change(Config) -> + Mode = handle_event_function, {ok,Pid} = gen_statem:start(?MODULE, start_arg(Config, []), []), {idle,data} = sys:get_state(Pid), sys:suspend(Pid), - sys:change_code(Pid, ?MODULE, old_vsn, state_functions), + sys:change_code(Pid, ?MODULE, old_vsn, Mode), sys:resume(Pid), - {idle,{old_vsn,data,state_functions}} = sys:get_state(Pid), + {idle,{old_vsn,data,Mode}} = sys:get_state(Pid), + Mode = gen_statem:call(Pid, get_callback_mode), stop_it(Pid). call_format_status(Config) -> @@ -1478,6 +1480,8 @@ next_events(Type, Content, Data) -> end. +handle_common_events({call,From}, get_callback_mode, _, _) -> + {keep_state_and_data,{reply,From,state_functions}}; handle_common_events({call,From}, get, State, Data) -> {keep_state,Data, [{reply,From,{state,State,Data}}]}; @@ -1501,6 +1505,8 @@ handle_common_events(cast, {'alive?',Pid}, _, Data) -> handle_common_events(_, _, _, _) -> undefined. +handle_event({call,From}, get_callback_mode, _, _) -> + {keep_state_and_data,{reply,From,handle_event_function}}; %% Wrapper state machine that uses a map state machine spec handle_event( Type, Event, State, [Data|Machine]) diff --git a/lib/syntax_tools/src/erl_prettypr.erl b/lib/syntax_tools/src/erl_prettypr.erl index 81272e62de..119d375746 100644 --- a/lib/syntax_tools/src/erl_prettypr.erl +++ b/lib/syntax_tools/src/erl_prettypr.erl @@ -38,7 +38,7 @@ follow/3, empty/0]). -import(erl_parse, [preop_prec/1, inop_prec/1, func_prec/0, - max_prec/0]). + max_prec/0, type_inop_prec/1, type_preop_prec/1]). -define(PADDING, 2). -define(PAPER, 80). @@ -50,7 +50,8 @@ | fun((erl_syntax:syntaxTree(), _, _) -> prettypr:document()). -type clause_t() :: 'case_expr' | 'cond_expr' | 'fun_expr' | 'if_expr' | 'receive_expr' | 'try_expr' - | {'function', prettypr:document()}. + | {'function', prettypr:document()} + | 'spec'. -record(ctxt, {prec = 0 :: integer(), sub_indent = 2 :: non_neg_integer(), @@ -535,9 +536,6 @@ lay_2(Node, Ctxt) -> As = seq(erl_syntax:application_arguments(Node), floating(text(",")), reset_prec(Ctxt), fun lay/2), -%% D1 = beside(D, beside(text("("), -%% beside(par(As), -%% floating(text(")"))))), D1 = beside(D, beside(text("("), beside(par(As), floating(text(")"))))), @@ -651,7 +649,7 @@ lay_2(Node, Ctxt) -> beside(D1, beside(text(":"), D2)); %% - %% The rest is in alphabetical order + %% The rest is in alphabetical order (except map and types) %% arity_qualifier -> @@ -666,18 +664,67 @@ lay_2(Node, Ctxt) -> %% a period. If the arguments is `none', we only output the %% attribute name, without following parentheses. Ctxt1 = reset_prec(Ctxt), - N = erl_syntax:attribute_name(Node), - D = case erl_syntax:attribute_arguments(Node) of - none -> + Args = erl_syntax:attribute_arguments(Node), + N = erl_syntax:attribute_name(Node), + D = case attribute_type(Node) of + spec -> + [SpecTuple] = Args, + [FuncName, FuncTypes] = + erl_syntax:tuple_elements(SpecTuple), + Name = + case erl_syntax:type(FuncName) of + tuple -> + case erl_syntax:tuple_elements(FuncName) of + [F0, _] -> + F0; + [M0, F0, _] -> + erl_syntax:module_qualifier(M0, + F0); + _ -> + FuncName + end; + _ -> + FuncName + end, + Types = dodge_macros(FuncTypes), + D1 = lay_clauses(erl_syntax:concrete(Types), + spec, Ctxt1), + beside(follow(lay(N, Ctxt1), + lay(Name, Ctxt1), + Ctxt1#ctxt.break_indent), + D1); + type -> + [TypeTuple] = Args, + [Name, Type0, Elements] = + erl_syntax:tuple_elements(TypeTuple), + TypeName = dodge_macros(Name), + Type = dodge_macros(Type0), + As0 = dodge_macros(Elements), + As = erl_syntax:concrete(As0), + D1 = lay_type_application(TypeName, As, Ctxt1), + D2 = lay(erl_syntax:concrete(Type), Ctxt1), + beside(follow(lay(N, Ctxt1), + beside(D1, floating(text(" :: "))), + Ctxt1#ctxt.break_indent), + D2); + Tag when Tag =:= export_type; + Tag =:= optional_callbacks -> + [FuncNs] = Args, + FuncNames = erl_syntax:concrete(dodge_macros(FuncNs)), + As = unfold_function_names(FuncNames), + beside(lay(N, Ctxt1), + beside(text("("), + beside(lay(As, Ctxt1), + floating(text(")"))))); + _ when Args =:= none -> lay(N, Ctxt1); - Args -> - As = seq(Args, floating(text(",")), Ctxt1, - fun lay/2), + _ -> + D1 = par(seq(Args, floating(text(",")), Ctxt1, + fun lay/2)), beside(lay(N, Ctxt1), beside(text("("), - beside(par(As), - floating(text(")"))))) - end, + beside(D1, floating(text(")"))))) + end, beside(floating(text("-")), beside(D, floating(text(".")))); binary -> @@ -928,6 +975,16 @@ lay_2(Node, Ctxt) -> text -> text(erl_syntax:text_string(Node)); + typed_record_field -> + {_, Prec, _} = type_inop_prec('::'), + Ctxt1 = reset_prec(Ctxt), + D1 = lay(erl_syntax:typed_record_field_body(Node), Ctxt1), + D2 = lay(erl_syntax:typed_record_field_type(Node), + set_prec(Ctxt, Prec)), + D3 = par([D1, floating(text(" ::")), D2], + Ctxt1#ctxt.break_indent), + maybe_parentheses(D3, Prec, Ctxt); + try_expr -> Ctxt1 = reset_prec(Ctxt), D1 = sep(seq(erl_syntax:try_expr_body(Node), @@ -965,9 +1022,236 @@ lay_2(Node, Ctxt) -> warning_marker -> E = erl_syntax:warning_marker_info(Node), beside(text("%% WARNING: "), - lay_error_info(E, reset_prec(Ctxt))) + lay_error_info(E, reset_prec(Ctxt))); + + %% + %% Types + %% + + annotated_type -> + {_, Prec, _} = type_inop_prec('::'), + D1 = lay(erl_syntax:annotated_type_name(Node), + reset_prec(Ctxt)), + D2 = lay(erl_syntax:annotated_type_body(Node), + set_prec(Ctxt, Prec)), + D3 = follow(beside(D1, floating(text(" ::"))), D2, + Ctxt#ctxt.break_indent), + maybe_parentheses(D3, Prec, Ctxt); + + type_application -> + Name = erl_syntax:type_application_name(Node), + Arguments = erl_syntax:type_application_arguments(Node), + %% Prefer shorthand notation. + case erl_syntax_lib:analyze_type_application(Node) of + {nil, 0} -> + text("[]"); + {list, 1} -> + [A] = Arguments, + D1 = lay(A, reset_prec(Ctxt)), + beside(text("["), beside(D1, text("]"))); + {nonempty_list, 1} -> + [A] = Arguments, + D1 = lay(A, reset_prec(Ctxt)), + beside(text("["), beside(D1, text(", ...]"))); + _ -> + lay_type_application(Name, Arguments, Ctxt) + end; + + bitstring_type -> + Ctxt1 = set_prec(Ctxt, max_prec()), + M = erl_syntax:bitstring_type_m(Node), + N = erl_syntax:bitstring_type_n(Node), + D1 = [beside(text("_:"), lay(M, Ctxt1)) || + (erl_syntax:type(M) =/= integer orelse + erl_syntax:integer_value(M) =/= 0)], + D2 = [beside(text("_:_*"), lay(N, Ctxt1)) || + (erl_syntax:type(N) =/= integer orelse + erl_syntax:integer_value(N) =/= 0)], + F = fun(D, _) -> D end, + D = seq(D1 ++ D2, floating(text(",")), Ctxt1, F), + beside(floating(text("<<")), + beside(par(D), floating(text(">>")))); + + fun_type -> + text("fun()"); + + constrained_function_type -> + Ctxt1 = reset_prec(Ctxt), + D1 = lay(erl_syntax:constrained_function_type_body(Node), + Ctxt1), + D2 = lay(erl_syntax:constrained_function_type_argument(Node), + Ctxt1), + beside(D1, + beside(floating(text(" when ")), D2)); + + function_type -> + {Before, After} = case Ctxt#ctxt.clause of + spec -> + {"", ""}; + _ -> + {"fun(", ")"} + end, + Ctxt1 = reset_prec(Ctxt), + D1 = case erl_syntax:function_type_arguments(Node) of + any_arity -> + text("(...)"); + Arguments -> + As = seq(Arguments, + floating(text(",")), Ctxt1, + fun lay/2), + beside(text("("), + beside(par(As), + floating(text(")")))) + end, + D2 = lay(erl_syntax:function_type_return(Node), Ctxt1), + beside(floating(text(Before)), + beside(D1, + beside(floating(text(" -> ")), + beside(D2, floating(text(After)))))); + + constraint -> + Name = erl_syntax:constraint_argument(Node), + Args = erl_syntax:constraint_body(Node), + case is_subtype(Name, Args) of + true -> + [Var, Type] = Args, + {PrecL, Prec, PrecR} = type_inop_prec('::'), + D1 = lay(Var, set_prec(Ctxt, PrecL)), + D2 = lay(Type, set_prec(Ctxt, PrecR)), + D3 = follow(beside(D1, floating(text(" ::"))), D2, + Ctxt#ctxt.break_indent), + maybe_parentheses(D3, Prec, Ctxt); + false -> + lay_type_application(Name, Args, Ctxt) + end; + + map_type -> + case erl_syntax:map_type_fields(Node) of + any_size -> + text("map()"); + Fs -> + {Prec, _PrecR} = type_preop_prec('#'), + Es = lay_map_fields(Fs, + floating(text(",")), + reset_prec(Ctxt)), + D = beside(floating(text("#{")), + beside(par(Es), + floating(text("}")))), + maybe_parentheses(D, Prec, Ctxt) + end; + + map_type_assoc -> + Name = erl_syntax:map_type_assoc_name(Node), + Value = erl_syntax:map_type_assoc_value(Node), + lay_type_assoc(Name, Value, Ctxt); + + map_type_exact -> + Ctxt1 = reset_prec(Ctxt), + D1 = lay(erl_syntax:map_type_exact_name(Node), Ctxt1), + D2 = lay(erl_syntax:map_type_exact_value(Node), Ctxt1), + par([D1, floating(text(":=")), D2], Ctxt1#ctxt.break_indent); + + integer_range_type -> + {PrecL, Prec, PrecR} = type_inop_prec('..'), + D1 = lay(erl_syntax:integer_range_type_low(Node), + set_prec(Ctxt, PrecL)), + D2 = lay(erl_syntax:integer_range_type_high(Node), + set_prec(Ctxt, PrecR)), + D3 = beside(D1, beside(text(".."), D2)), + maybe_parentheses(D3, Prec, Ctxt); + + record_type -> + {Prec, _PrecR} = type_preop_prec('#'), + D1 = beside(text("#"), + lay(erl_syntax:record_type_name(Node), + reset_prec(Ctxt))), + Es = seq(erl_syntax:record_type_fields(Node), + floating(text(",")), reset_prec(Ctxt), + fun lay/2), + D2 = beside(D1, + beside(text("{"), + beside(par(Es), + floating(text("}"))))), + maybe_parentheses(D2, Prec, Ctxt); + + record_type_field -> + Ctxt1 = reset_prec(Ctxt), + D1 = lay(erl_syntax:record_type_field_name(Node), Ctxt1), + D2 = lay(erl_syntax:record_type_field_type(Node), Ctxt1), + par([D1, floating(text("::")), D2], Ctxt1#ctxt.break_indent); + + tuple_type -> + case erl_syntax:tuple_type_elements(Node) of + any_size -> + text("tuple()"); + Elements -> + Es = seq(Elements, + floating(text(",")), reset_prec(Ctxt), + fun lay/2), + beside(floating(text("{")), + beside(par(Es), floating(text("}")))) + end; + + type_union -> + {_, Prec, PrecR} = type_inop_prec('|'), + Es = par(seq(erl_syntax:type_union_types(Node), + floating(text(" |")), set_prec(Ctxt, PrecR), + fun lay/2)), + maybe_parentheses(Es, Prec, Ctxt); + + user_type_application -> + lay_type_application(erl_syntax:user_type_application_name(Node), + erl_syntax:user_type_application_arguments(Node), + Ctxt) + + end. + +attribute_type(Node) -> + N = erl_syntax:attribute_name(Node), + case catch erl_syntax:concrete(N) of + opaque -> + type; + spec -> + spec; + callback -> + spec; + type -> + type; + export_type -> + export_type; + optional_callbacks -> + optional_callbacks; + _ -> + N end. +is_subtype(Name, [Var, _]) -> + (erl_syntax:is_atom(Name, is_subtype) andalso + erl_syntax:type(Var) =:= variable); +is_subtype(_, _) -> false. + +unfold_function_names(Ns) -> + F = fun ({Atom, Arity}) -> + erl_syntax:arity_qualifier(erl_syntax:atom(Atom), + erl_syntax:integer(Arity)) + end, + erl_syntax:list([F(N) || N <- Ns]). + +%% Macros are not handled well. +dodge_macros(Type) -> + F = fun (T) -> + case erl_syntax:type(T) of + macro -> + Var = erl_syntax:macro_name(T), + VarName0 = erl_syntax:variable_name(Var), + VarName = list_to_atom("?"++atom_to_list(VarName0)), + Atom = erl_syntax:atom(VarName), + Atom; + _ -> T + end + end, + erl_syntax_lib:map(F, Type). + lay_parentheses(D, _Ctxt) -> beside(floating(text("(")), beside(D, floating(text(")")))). @@ -1020,6 +1304,8 @@ split_string_1([], _N, _L, As) -> split_string_2([$^, X | Xs], N, L, As) -> split_string_1(Xs, N - 2, L - 2, [X, $^ | As]); +split_string_2([$x, ${ | Xs], N, L, As) -> + split_string_3(Xs, N - 2, L - 2, [${, $x | As]); split_string_2([X1, X2, X3 | Xs], N, L, As) when X1 >= $0, X1 =< $7, X2 >= $0, X2 =< $7, X3 >= $0, X3 =< $7 -> split_string_1(Xs, N - 3, L - 3, [X3, X2, X1 | As]); @@ -1029,6 +1315,15 @@ split_string_2([X1, X2 | Xs], N, L, As) when split_string_2([X | Xs], N, L, As) -> split_string_1(Xs, N - 1, L - 1, [X | As]). +split_string_3([$} | Xs], N, L, As) -> + split_string_1(Xs, N - 1, L - 1, [$} | As]); +split_string_3([X | Xs], N, L, As) when + X >= $0, X =< $9; X >= $a, X =< $z; X >= $A, X =< $Z -> + split_string_3(Xs, N - 1, L -1, [X | As]); +split_string_3([X | Xs], N, L, As) when + X >= $0, X =< $9 -> + split_string_1(Xs, N - 1, L -1, [X | As]). + %% Note that there is nothing in `lay_clauses' that actually requires %% that the elements have type `clause'; it just sets up the proper %% context and arranges the elements suitably for clauses. @@ -1105,6 +1400,53 @@ lay_error_info(T, Ctxt) -> lay_concrete(T, Ctxt) -> lay(erl_syntax:abstract(T), Ctxt). +lay_map_fields([H | T], Separator, Ctxt) -> + case T of + [] -> + [case erl_syntax:type(H) of + map_type_assoc -> + lay_last_type_assoc(H, Ctxt); + _ -> + lay(H, Ctxt) + end]; + _ -> + [maybe_append(Separator, lay(H, Ctxt)) + | lay_map_fields(T, Separator, Ctxt)] + end; +lay_map_fields([], _, _) -> + [empty()]. + +lay_last_type_assoc(Node, Ctxt) -> + Name = erl_syntax:map_type_assoc_name(Node), + Value = erl_syntax:map_type_assoc_value(Node), + IsAny = fun({type,_,any,[]}) -> true; + %% ({var,_,'_'}) -> true; + (_) -> false + end, + case IsAny(Name) andalso IsAny(Value) of + true -> + text("..."); + false -> + lay_type_assoc(Name, Value, Ctxt) + end. + +lay_type_assoc(Name, Value, Ctxt) -> + Ctxt1 = reset_prec(Ctxt), + D1 = lay(Name, Ctxt1), + D2 = lay(Value, Ctxt1), + par([D1, floating(text("=>")), D2], Ctxt1#ctxt.break_indent). + +lay_type_application(Name, Arguments, Ctxt) -> + {PrecL, Prec} = func_prec(), % + D1 = lay(Name, set_prec(Ctxt, PrecL)), + As = seq(Arguments, + floating(text(",")), reset_prec(Ctxt), + fun lay/2), + D = beside(D1, beside(text("("), + beside(par(As), + floating(text(")"))))), + maybe_parentheses(D, Prec, Ctxt). + seq([H | T], Separator, Ctxt, Fun) -> case T of [] -> diff --git a/lib/syntax_tools/src/erl_syntax.erl b/lib/syntax_tools/src/erl_syntax.erl index 97b5797b06..f4cda814fc 100644 --- a/lib/syntax_tools/src/erl_syntax.erl +++ b/lib/syntax_tools/src/erl_syntax.erl @@ -120,6 +120,9 @@ normalize_list/1, compact_list/1, + annotated_type/2, + annotated_type_name/1, + annotated_type_body/1, application/2, application/3, application_arguments/1, @@ -150,6 +153,9 @@ binary_generator/2, binary_generator_body/1, binary_generator_pattern/1, + bitstring_type/2, + bitstring_type_m/1, + bitstring_type_n/1, block_expr/1, block_expr_body/1, case_expr/2, @@ -175,6 +181,12 @@ cond_expr_clauses/1, conjunction/1, conjunction_body/1, + constrained_function_type/2, + constrained_function_type_body/1, + constrained_function_type_argument/1, + constraint/2, + constraint_argument/1, + constraint_body/1, disjunction/1, disjunction_body/1, eof_marker/0, @@ -188,10 +200,15 @@ fun_expr/1, fun_expr_arity/1, fun_expr_clauses/1, + fun_type/0, function/2, function_arity/1, function_clauses/1, function_name/1, + function_type/1, + function_type/2, + function_type_arguments/1, + function_type_return/1, generator/2, generator_body/1, generator_pattern/1, @@ -209,6 +226,9 @@ is_integer/2, integer_value/1, integer_literal/1, + integer_range_type/2, + integer_range_type_low/1, + integer_range_type_high/1, list/1, list/2, list_comp/2, @@ -230,6 +250,15 @@ map_field_exact/2, map_field_exact_name/1, map_field_exact_value/1, + map_type/0, + map_type/1, + map_type_fields/1, + map_type_assoc/2, + map_type_assoc_name/1, + map_type_assoc_value/1, + map_type_exact/2, + map_type_exact_name/1, + map_type_exact_value/1, match_expr/2, match_expr_body/1, match_expr_pattern/1, @@ -270,6 +299,12 @@ record_index_expr/2, record_index_expr_field/1, record_index_expr_type/1, + record_type/2, + record_type_name/1, + record_type_fields/1, + record_type_field/2, + record_type_field_name/1, + record_type_field_type/1, size_qualifier/2, size_qualifier_argument/1, size_qualifier_body/1, @@ -288,6 +323,18 @@ try_expr_clauses/1, try_expr_handlers/1, try_expr_after/1, + tuple_type/0, + tuple_type/1, + tuple_type_elements/1, + type_application/2, + type_application/3, + type_application_name/1, + type_application_arguments/1, + type_union/1, + type_union_types/1, + typed_record_field/2, + typed_record_field_body/1, + typed_record_field_type/1, class_qualifier/2, class_qualifier_argument/1, class_qualifier_body/1, @@ -295,6 +342,9 @@ tuple_elements/1, tuple_size/1, underscore/0, + user_type_application/2, + user_type_application_name/1, + user_type_application_arguments/1, variable/1, variable_name/1, variable_literal/1, @@ -412,23 +462,28 @@ %% <center><table border="1"> %% <tr> %% <td>application</td> +%% <td>annotated_type</td> %% <td>arity_qualifier</td> %% <td>atom</td> -%% <td>attribute</td> %% </tr><tr> +%% <td>attribute</td> %% <td>binary</td> %% <td>binary_field</td> +%% <td>bitstring_type</td> +%% </tr><tr> %% <td>block_expr</td> %% <td>case_expr</td> -%% </tr><tr> %% <td>catch_expr</td> %% <td>char</td> +%% </tr><tr> %% <td>class_qualifier</td> %% <td>clause</td> -%% </tr><tr> %% <td>comment</td> %% <td>cond_expr</td> +%% </tr><tr> %% <td>conjunction</td> +%% <td>constrained_function_type</td> +%% <td>constraint</td> %% <td>disjunction</td> %% </tr><tr> %% <td>eof_marker</td> @@ -437,43 +492,58 @@ %% <td>form_list</td> %% </tr><tr> %% <td>fun_expr</td> +%% <td>fun_type</td> %% <td>function</td> +%% <td>function_type</td> +%% </tr><tr> %% <td>generator</td> %% <td>if_expr</td> -%% </tr><tr> %% <td>implicit_fun</td> %% <td>infix_expr</td> +%% </tr><tr> %% <td>integer</td> +%% <td>integer_range_type</td> %% <td>list</td> -%% </tr><tr> %% <td>list_comp</td> +%% </tr><tr> %% <td>macro</td> %% <td>map_expr</td> %% <td>map_field_assoc</td> -%% </tr><tr> %% <td>map_field_exact</td> +%% </tr><tr> +%% <td>map_type</td> +%% <td>map_type_assoc</td> +%% <td>map_type_exact</td> %% <td>match_expr</td> %% <td>module_qualifier</td> -%% <td>named_fun_expr</td> %% </tr><tr> +%% <td>named_fun_expr</td> %% <td>nil</td> %% <td>operator</td> %% <td>parentheses</td> -%% <td>prefix_expr</td> %% </tr><tr> +%% <td>prefix_expr</td> %% <td>receive_expr</td> %% <td>record_access</td> %% <td>record_expr</td> -%% <td>record_field</td> %% </tr><tr> +%% <td>record_field</td> %% <td>record_index_expr</td> +%% <td>record_type</td> +%% <td>record_type_field</td> +%% </tr><tr> %% <td>size_qualifier</td> %% <td>string</td> %% <td>text</td> -%% </tr><tr> %% <td>try_expr</td> +%% </tr><tr> %% <td>tuple</td> +%% <td>tuple_type</td> +%% <td>typed_record_field</td> +%% <td>type_application</td> +%% <td>type_union</td> %% <td>underscore</td> +%% <td>user_type_application</td> %% <td>variable</td> %% </tr><tr> %% <td>warning_marker</td> @@ -487,12 +557,14 @@ %% always have the same name as the node type itself. %% %% @see tree/2 +%% @see annotated_type/2 %% @see application/3 %% @see arity_qualifier/2 %% @see atom/1 %% @see attribute/2 %% @see binary/1 %% @see binary_field/2 +%% @see bitstring_type/2 %% @see block_expr/1 %% @see case_expr/2 %% @see catch_expr/1 @@ -502,24 +574,34 @@ %% @see comment/2 %% @see cond_expr/1 %% @see conjunction/1 +%% @see constrained_function_type/2 +%% @see constraint/2 %% @see disjunction/1 %% @see eof_marker/0 %% @see error_marker/1 %% @see float/1 %% @see form_list/1 %% @see fun_expr/1 +%% @see fun_type/0 %% @see function/2 +%% @see function_type/1 +%% @see function_type/2 %% @see generator/2 %% @see if_expr/1 %% @see implicit_fun/2 %% @see infix_expr/3 %% @see integer/1 +%% @see integer_range_type/2 %% @see list/2 %% @see list_comp/2 %% @see macro/2 %% @see map_expr/2 %% @see map_field_assoc/2 %% @see map_field_exact/2 +%% @see map_type/0 +%% @see map_type/1 +%% @see map_type_assoc/2 +%% @see map_type_exact/2 %% @see match_expr/2 %% @see module_qualifier/2 %% @see named_fun_expr/2 @@ -532,12 +614,20 @@ %% @see record_expr/2 %% @see record_field/2 %% @see record_index_expr/2 +%% @see record_type/2 +%% @see record_type_field/2 %% @see size_qualifier/2 %% @see string/1 %% @see text/1 %% @see try_expr/3 %% @see tuple/1 +%% @see tuple_type/0 +%% @see tuple_type/1 +%% @see typed_record_field/2 +%% @see type_application/2 +%% @see type_union/1 %% @see underscore/0 +%% @see user_type_application/2 %% @see variable/1 %% @see warning_marker/1 @@ -602,6 +692,25 @@ type(Node) -> {remote, _, _, _} -> module_qualifier; {'try', _, _, _, _, _} -> try_expr; {tuple, _, _} -> tuple; + + %% Type types + {ann_type, _, _} -> annotated_type; + {remote_type, _, _} -> type_application; + {type, _, binary, [_, _]} -> bitstring_type; + {type, _, bounded_fun, [_, _]} -> constrained_function_type; + {type, _, constraint, [_, _]} -> constraint; + {type, _, 'fun', []} -> fun_type; + {type, _, 'fun', [_, _]} -> function_type; + {type, _, map, _} -> map_type; + {type, _, map_field_assoc, _} -> map_type_assoc; + {type, _, map_field_exact, _} -> map_type_exact; + {type, _, record, _} -> record_type; + {type, _, field_type, _} -> record_type_field; + {type, _, range, _} -> integer_range_type; + {type, _, tuple, _} -> tuple_type; + {type, _, union, _} -> type_union; + {type, _, _, _} -> type_application; + {user_type, _, _, _} -> user_type_application; _ -> erlang:error({badarg, Node}) end. @@ -621,6 +730,7 @@ type(Node) -> %% <td>`error_marker'</td> %% </tr><tr> %% <td>`float'</td> +%% <td>`fun_type'</td> %% <td>`integer'</td> %% <td>`nil'</td> %% <td>`operator'</td> @@ -633,7 +743,13 @@ type(Node) -> %% </tr> %% </table></center> %% +%% A node of type `map_expr' is a leaf node if and only if it has no +%% argument and no fields. +%% A node of type `map_type' is a leaf node if and only if it has no +%% fields (`any_size'). %% A node of type `tuple' is a leaf node if and only if its arity is zero. +%% A node of type `tuple_type' is a leaf node if and only if it has no +%% elements (`any_size'). %% %% Note: not all literals are leaf nodes, and vice versa. E.g., %% tuples with nonzero arity and nonempty lists may be literals, but are @@ -653,6 +769,7 @@ is_leaf(Node) -> eof_marker -> true; error_marker -> true; float -> true; + fun_type -> true; integer -> true; nil -> true; operator -> true; % nonstandard type @@ -661,7 +778,9 @@ is_leaf(Node) -> map_expr -> map_expr_fields(Node) =:= [] andalso map_expr_argument(Node) =:= none; + map_type -> map_type_fields(Node) =:= any_size; tuple -> tuple_elements(Node) =:= []; + tuple_type -> tuple_type_elements(Node) =:= any_size; underscore -> true; variable -> true; warning_marker -> true; @@ -3114,6 +3233,39 @@ attribute(Name) -> %% `Imports' is `{Module, [{A1, N1}, ..., {Ak, Nk}]}', or %% `-import(A1.....An).', if `Imports' is `[A1, ..., An]'. %% +%% {attribute, Pos, export_type, ExportedTypes} +%% +%% ExportedTypes = [{atom(), integer()}] +%% +%% Representing `-export_type([N1/A1, ..., Nk/Ak]).', +%% if `ExportedTypes' is `[{N1, A1}, ..., {Nk, Ak}]'. +%% +%% {attribute, Pos, optional_callbacks, OptionalCallbacks} +%% +%% OptionalCallbacks = [{atom(), integer()}] +%% +%% Representing `-optional_callbacks([A1/N1, ..., Ak/Nk]).', +%% if `OptionalCallbacks' is `[{A1, N1}, ..., {Ak, Nk}]'. +%% +%% {attribute, Pos, SpecTag, {FuncSpec, FuncType}} +%% +%% SpecTag = spec | callback +%% FuncSpec = {module(), atom(), arity()} | {atom(), arity()} +%% FuncType = a (possibly constrained) function type +%% +%% Representing `-SpecTag M:F/A Ft1; ...; Ftk.' or +%% `-SpecTag F/A Ft1; ...; Ftk.', if `FuncTypes' is +%% `[Ft1, ..., Ftk]'. +%% +%% {attribute, Pos, TypeTag, {Name, Type, Parameters}} +%% +%% TypeTag = type | opaque +%% Type = a type +%% Parameters = [Variable] +%% +%% Representing `-TypeTag Name(V1, ..., Vk) :: Type .' +%% if `Parameters' is `[V1, ..., Vk]'. +%% %% {attribute, Pos, file, Position} %% %% Position = {filename(), integer()} @@ -3125,13 +3277,19 @@ attribute(Name) -> %% %% Info = {Name, [Entries]} %% Name = atom() -%% Entries = {record_field, Pos, atom()} -%% | {record_field, Pos, atom(), erl_parse()} %% -%% Representing `-record(Name, {<F1>, ..., <Fn>}).', if `Info' is +%% Entries = UntypedEntries +%% | {typed_record_field, UntypedEntries, Type} +%% UntypedEntries = {record_field, Pos, atom()} +%% | {record_field, Pos, atom(), erl_parse()} +%% +%% Representing `-record(Name, {<F1>, ..., <Fn>}).', if `Info' is %% `{Name, [D1, ..., D1]}', where each `Fi' is either `Ai = <Ei>', %% if the corresponding `Di' is `{record_field, Pos, Ai, Ei}', or -%% otherwise simply `Ai', if `Di' is `{record_field, Pos, Ai}'. +%% otherwise simply `Ai', if `Di' is `{record_field, Pos, Ai}', or +%% `Ai = <Ei> :: <Ti>', if `Di' is `{typed_record_field, +%% {record_field, Pos, Ai, Ei}, Ti}', or `Ai :: <Ti>', if `Di' is +%% `{typed_record_field, {record_field, Pos, Ai}, Ti}'. %% %% {attribute, L, Name, Term} %% @@ -3309,11 +3467,6 @@ attribute_arguments(Node) -> [set_pos( list(unfold_function_names(Data, Pos)), Pos)]; - optional_callbacks -> - D = try list(unfold_function_names(Data, Pos)) - catch _:_ -> abstract(Data) - end, - [set_pos(D, Pos)]; import -> {Module, Imports} = Data, [set_pos(atom(Module), Pos), @@ -4183,7 +4336,8 @@ record_field(Name) -> %% type(Node) = record_field %% data(Node) = #record_field{name :: Name, value :: Value} %% -%% Name = Value = syntaxTree() +%% Name = syntaxTree() +%% Value = none | syntaxTree() -spec record_field(syntaxTree(), 'none' | syntaxTree()) -> syntaxTree(). @@ -4568,7 +4722,7 @@ application(Module, Name, Arguments) -> %% %% `erl_parse' representation: %% -%% {call, Pos, Fun, Args} +%% {call, Pos, Operator, Args} %% %% Operator = erl_parse() %% Arguments = [erl_parse()] @@ -4623,6 +4777,1095 @@ application_arguments(Node) -> (data(Node1))#application.arguments end. +%% ===================================================================== +%% @doc Creates an abstract annotated type expression. The result +%% represents "<code><em>Name</em> :: <em>Type</em></code>". +%% +%% @see annotated_type_name/1 +%% @see annotated_type_body/1 + +-record(annotated_type, {name :: syntaxTree(), body :: syntaxTree()}). + +%% type(Node) = annotated_type +%% data(Node) = #annotated_type{name :: Name, +%% body :: Type} +%% +%% Name = syntaxTree() +%% Type = syntaxTree() +%% +%% `erl_parse' representation: +%% +%% {ann_type, Pos, [Name, Type]} +%% +%% Name = erl_parse() +%% Type = erl_parse() + +-spec annotated_type(syntaxTree(), syntaxTree()) -> syntaxTree(). + +annotated_type(Name, Type) -> + tree(annotated_type, #annotated_type{name = Name, body = Type}). + +revert_annotated_type(Node) -> + Pos = get_pos(Node), + Name = annotated_type_name(Node), + Type = annotated_type_body(Node), + {ann_type, Pos, [Name, Type]}. + + +%% ===================================================================== +%% @doc Returns the name subtree of an `annotated_type' node. +%% +%% @see annotated_type/2 + +-spec annotated_type_name(syntaxTree()) -> syntaxTree(). + +annotated_type_name(Node) -> + case unwrap(Node) of + {ann_type, _, [Name, _]} -> + Name; + Node1 -> + (data(Node1))#annotated_type.name + end. + + +%% ===================================================================== +%% @doc Returns the type subtrees of an `annotated_type' node. +%% +%% @see annotated_type/2 + +-spec annotated_type_body(syntaxTree()) -> syntaxTree(). + +annotated_type_body(Node) -> + case unwrap(Node) of + {ann_type, _, [_, Type]} -> + Type; + Node1 -> + (data(Node1))#annotated_type.body + end. + + +%% ===================================================================== +%% @doc Creates an abstract fun of any type. The result represents +%% "<code>fun()</code>". + +%% type(Node) = fun_type +%% +%% `erl_parse' representation: +%% +%% {type, Pos, 'fun', []} + +-spec fun_type() -> syntaxTree(). + +fun_type() -> + tree(fun_type). + +revert_fun_type(Node) -> + Pos = get_pos(Node), + {type, Pos, 'fun', []}. + + +%% ===================================================================== +%% @doc Creates an abstract type application expression. If +%% `Module' is `none', this is call is equivalent +%% to `type_application(TypeName, Arguments)', otherwise it is +%% equivalent to `type_application(module_qualifier(Module, TypeName), +%% Arguments)'. +%% +%% (This is a utility function.) +%% +%% @see type_application/2 +%% @see module_qualifier/2 + +-spec type_application('none' | syntaxTree(), syntaxTree(), [syntaxTree()]) -> + syntaxTree(). + +type_application(none, TypeName, Arguments) -> + type_application(TypeName, Arguments); +type_application(Module, TypeName, Arguments) -> + type_application(module_qualifier(Module, TypeName), Arguments). + + +%% ===================================================================== +%% @doc Creates an abstract type application expression. If `Arguments' is +%% `[T1, ..., Tn]', the result represents +%% "<code><em>TypeName</em>(<em>T1</em>, ...<em>Tn</em>)</code>". +%% +%% @see user_type_application/2 +%% @see type_application/3 +%% @see type_application_name/1 +%% @see type_application_arguments/1 + +-record(type_application, {type_name :: syntaxTree(), + arguments :: [syntaxTree()]}). + +%% type(Node) = type_application +%% data(Node) = #type_application{type_name :: TypeName, +%% arguments :: Arguments} +%% +%% TypeName = syntaxTree() +%% Arguments = [syntaxTree()] +%% +%% `erl_parse' representation: +%% +%% {remote, Pos, [Module, Name, Arguments]} | +%% {type, Pos, Name, Arguments} +%% +%% Module = erl_parse() +%% Name = atom() +%% Arguments = [erl_parse()] + +-spec type_application(syntaxTree(), [syntaxTree()]) -> syntaxTree(). + +type_application(TypeName, Arguments) -> + tree(type_application, + #type_application{type_name = TypeName, arguments = Arguments}). + +revert_type_application(Node) -> + Pos = get_pos(Node), + TypeName = type_application_name(Node), + Arguments = type_application_arguments(Node), + case type(TypeName) of + module_qualifier -> + Module = module_qualifier_argument(TypeName), + Name = module_qualifier_body(TypeName), + {remote_type, Pos, [Module, Name, Arguments]}; + atom -> + {type, Pos, atom_value(TypeName), Arguments} + end. + + +%% ===================================================================== +%% @doc Returns the type name subtree of a `type_application' node. +%% +%% @see type_application/2 + +-spec type_application_name(syntaxTree()) -> syntaxTree(). + +type_application_name(Node) -> + case unwrap(Node) of + {remote_type, _, [Module, Name, _]} -> + module_qualifier(Module, Name); + {type, Pos, Name, _} -> + set_pos(atom(Name), Pos); + Node1 -> + (data(Node1))#type_application.type_name + end. + + +%% ===================================================================== +%% @doc Returns the arguments subtrees of a `type_application' node. +%% +%% @see type_application/2 + +-spec type_application_arguments(syntaxTree()) -> [syntaxTree()]. + +type_application_arguments(Node) -> + case unwrap(Node) of + {remote_type, _, [_, _, Arguments]} -> + Arguments; + {type, _, _, Arguments} -> + Arguments; + Node1 -> + (data(Node1))#type_application.arguments + end. + + +%% ===================================================================== +%% @doc Creates an abstract bitstring type. The result represents +%% "<code><em><<_:M, _:_*N>></em></code>". +%% +%% @see bitstring_type_m/1 +%% @see bitstring_type_n/1 + +-record(bitstring_type, {m :: syntaxTree(), n :: syntaxTree()}). + +%% type(Node) = bitstring_type +%% data(Node) = #bitstring_type{m :: M, n :: N} +%% +%% M = syntaxTree() +%% N = syntaxTree() +%% + +-spec bitstring_type(syntaxTree(), syntaxTree()) -> syntaxTree(). + +bitstring_type(M, N) -> + tree(bitstring_type, #bitstring_type{m = M, n =N}). + +revert_bitstring_type(Node) -> + Pos = get_pos(Node), + M = bitstring_type_m(Node), + N = bitstring_type_n(Node), + {type, Pos, binary, [M, N]}. + +%% ===================================================================== +%% @doc Returns the number of start bits, `M', of a `bitstring_type' node. +%% +%% @see bitstring_type/2 + +-spec bitstring_type_m(syntaxTree()) -> syntaxTree(). + +bitstring_type_m(Node) -> + case unwrap(Node) of + {type, _, binary, [M, _]} -> + M; + Node1 -> + (data(Node1))#bitstring_type.m + end. + +%% ===================================================================== +%% @doc Returns the segment size, `N', of a `bitstring_type' node. +%% +%% @see bitstring_type/2 + +-spec bitstring_type_n(syntaxTree()) -> syntaxTree(). + +bitstring_type_n(Node) -> + case unwrap(Node) of + {type, _, binary, [_, N]} -> + N; + Node1 -> + (data(Node1))#bitstring_type.n + end. + + +%% ===================================================================== +%% @doc Creates an abstract constrained function type. +%% If `FunctionConstraint' is `[C1, ..., Cn]', the result represents +%% "<code><em>FunctionType</em> when <em>C1</em>, ...<em>Cn</em></code>". +%% +%% @see constrained_function_type_body/1 +%% @see constrained_function_type_argument/1 + +-record(constrained_function_type, {body :: syntaxTree(), + argument :: syntaxTree()}). + +%% type(Node) = constrained_function_type +%% data(Node) = #constrained_function_type{body :: FunctionType, +%% argument :: FunctionConstraint} +%% +%% FunctionType = syntaxTree() +%% FunctionConstraint = syntaxTree() +%% +%% `erl_parse' representation: +%% +%% {type, Pos, bounded_fun, [FunctionType, FunctionConstraint]} +%% +%% FunctionType = erl_parse() +%% FunctionConstraint = [erl_parse()] + +-spec constrained_function_type(syntaxTree(), [syntaxTree()]) -> syntaxTree(). + +constrained_function_type(FunctionType, FunctionConstraint) -> + Conj = conjunction(FunctionConstraint), + tree(constrained_function_type, + #constrained_function_type{body = FunctionType, + argument = Conj}). + +revert_constrained_function_type(Node) -> + Pos = get_pos(Node), + FunctionType = constrained_function_type_body(Node), + FunctionConstraint = + conjunction_body(constrained_function_type_argument(Node)), + {type, Pos, bounded_fun, [FunctionType, FunctionConstraint]}. + + +%% ===================================================================== +%% @doc Returns the function type subtree of a +%% `constrained_function_type' node. +%% +%% @see constrained_function_type/2 + +-spec constrained_function_type_body(syntaxTree()) -> syntaxTree(). + +constrained_function_type_body(Node) -> + case unwrap(Node) of + {type, _, bounded_fun, [FunctionType, _]} -> + FunctionType; + Node1 -> + (data(Node1))#constrained_function_type.body + end. + +%% ===================================================================== +%% @doc Returns the function constraint subtree of a +%% `constrained_function_type' node. +%% +%% @see constrained_function_type/2 + +-spec constrained_function_type_argument(syntaxTree()) -> syntaxTree(). + +constrained_function_type_argument(Node) -> + case unwrap(Node) of + {type, _, bounded_fun, [_, FunctionConstraint]} -> + conjunction(FunctionConstraint); + Node1 -> + (data(Node1))#constrained_function_type.argument + end. + + +%% ===================================================================== +%% @equiv function_type(any_arity, Type) + +function_type(Type) -> + function_type(any_arity, Type). + +%% ===================================================================== +%% @doc Creates an abstract function type. If `Arguments' is +%% `[T1, ..., Tn]', then if it occurs within a function +%% specification, the result represents +%% "<code>(<em>T1</em>, ...<em>Tn</em>) -> <em>Return</em></code>"; otherwise +%% it represents +%% "<code>fun((<em>T1</em>, ...<em>Tn</em>) -> <em>Return</em>)</code>". +%% If `Arguments' is `any_arity', it represents +%% "<code>fun((...) -> <em>Return</em>)</code>". +%% +%% Note that the `erl_parse' representation is identical for +%% "<code><em>FunctionType</em></code>" and +%% "<code>fun(<em>FunctionType</em>)</code>". +%% +%% @see function_type_arguments/1 +%% @see function_type_return/1 + +-record(function_type, {arguments :: any_arity | [syntaxTree()], + return :: syntaxTree()}). + +%% type(Node) = function_type +%% data(Node) = #function_type{arguments :: any | Arguments, +%% return :: Type} +%% +%% Arguments = [syntaxTree()] +%% Type = syntaxTree() +%% +%% `erl_parse' representation: +%% +%% {type, Pos, 'fun', [{type, Pos, product, Arguments}, Type]} +%% {type, Pos, 'fun', [{type, Pos, any}, Type]} +%% +%% Arguments = [erl_parse()] +%% Type = erl_parse() + +-spec function_type('any_arity' | syntaxTree(), syntaxTree()) -> syntaxTree(). + +function_type(Arguments, Return) -> + tree(function_type, + #function_type{arguments = Arguments, return = Return}). + +revert_function_type(Node) -> + Pos = get_pos(Node), + Type = function_type_return(Node), + case function_type_arguments(Node) of + any_arity -> + {type, Pos, 'fun', [{type, Pos, any}, Type]}; + Arguments -> + {type, Pos, 'fun', [{type, Pos, product, Arguments}, Type]} + end. + + +%% ===================================================================== +%% @doc Returns the argument types subtrees of a `function_type' node. +%% If `Node' represents "<code>fun((...) -> <em>Return</em>)</code>", +%% `any_arity' is returned; otherwise, if `Node' represents +%% "<code>(<em>T1</em>, ...<em>Tn</em>) -> <em>Return</em></code>" or +%% "<code>fun((<em>T1</em>, ...<em>Tn</em>) -> <em>Return</em>)</code>", +%% `[T1, ..., Tn]' is returned. + +%% +%% @see function_type/1 +%% @see function_type/2 + +-spec function_type_arguments(syntaxTree()) -> any_arity | [syntaxTree()]. + +function_type_arguments(Node) -> + case unwrap(Node) of + {type, _, 'fun', [{type, _, any}, _]} -> + any_arity; + {type, _, 'fun', [{type, _, product, Arguments}, _]} -> + Arguments; + Node1 -> + (data(Node1))#function_type.arguments + end. + +%% ===================================================================== +%% @doc Returns the return type subtrees of a `function_type' node. +%% +%% @see function_type/1 +%% @see function_type/2 + +-spec function_type_return(syntaxTree()) -> syntaxTree(). + +function_type_return(Node) -> + case unwrap(Node) of + {type, _, 'fun', [_, Type]} -> + Type; + Node1 -> + (data(Node1))#function_type.return + end. + + +%% ===================================================================== +%% @doc Creates an abstract (subtype) constraint. The result represents +%% "<code><em>Name</em> :: <em>Type</em></code>". +%% +%% @see constraint_argument/1 +%% @see constraint_body/1 + +-record(constraint, {name :: syntaxTree(), + types :: [syntaxTree()]}). + +%% type(Node) = constraint +%% data(Node) = #constraint{name :: Name, +%% types :: [Type]} +%% +%% Name = syntaxTree() +%% Type = syntaxTree() +%% +%% `erl_parse' representation: +%% +%% {type, Pos, constraint, [Name, [Var, Type]]} +%% +%% Name = {atom, Pos, is_subtype} +%% Var = erl_parse() +%% Type = erl_parse() + +-spec constraint(syntaxTree(), [syntaxTree()]) -> syntaxTree(). + +constraint(Name, Types) -> + tree(constraint, + #constraint{name = Name, types = Types}). + +revert_constraint(Node) -> + Pos = get_pos(Node), + Name = constraint_argument(Node), + Types = constraint_body(Node), + {type, Pos, constraint, [Name, Types]}. + + +%% ===================================================================== +%% @doc Returns the name subtree of a `constraint' node. +%% +%% @see constraint/2 + +-spec constraint_argument(syntaxTree()) -> syntaxTree(). + +constraint_argument(Node) -> + case unwrap(Node) of + {type, _, constraint, [Name, _]} -> + Name; + Node1 -> + (data(Node1))#constraint.name + end. + +%% ===================================================================== +%% @doc Returns the type subtree of a `constraint' node. +%% +%% @see constraint/2 + +-spec constraint_body(syntaxTree()) -> [syntaxTree()]. + +constraint_body(Node) -> + case unwrap(Node) of + {type, _, constraint, [_, Types]} -> + Types; + Node1 -> + (data(Node1))#constraint.types + end. + + +%% ===================================================================== +%% @doc Creates an abstract map type assoc field. The result represents +%% "<code><em>Name</em> => <em>Value</em></code>". +%% +%% @see map_type_assoc_name/1 +%% @see map_type_assoc_value/1 +%% @see map_type/1 + +-record(map_type_assoc, {name :: syntaxTree(), value :: syntaxTree()}). + +%% `erl_parse' representation: +%% +%% {type, Pos, map_field_assoc, [Name, Value]} + +-spec map_type_assoc(syntaxTree(), syntaxTree()) -> syntaxTree(). + +map_type_assoc(Name, Value) -> + tree(map_type_assoc, #map_type_assoc{name = Name, value = Value}). + +revert_map_type_assoc(Node) -> + Pos = get_pos(Node), + Name = map_type_assoc_name(Node), + Value = map_type_assoc_value(Node), + {type, Pos, map_type_assoc, [Name, Value]}. + + +%% ===================================================================== +%% @doc Returns the name subtree of a `map_type_assoc' node. +%% +%% @see map_type_assoc/2 + +-spec map_type_assoc_name(syntaxTree()) -> syntaxTree(). + +map_type_assoc_name(Node) -> + case Node of + {type, _, map_field_assoc, [Name, _]} -> + Name; + _ -> + (data(Node))#map_type_assoc.name + end. + + +%% ===================================================================== +%% @doc Returns the value subtree of a `map_type_assoc' node. +%% +%% @see map_type_assoc/2 + +-spec map_type_assoc_value(syntaxTree()) -> syntaxTree(). + +map_type_assoc_value(Node) -> + case Node of + {type, _, map_field_assoc, [_, Value]} -> + Value; + _ -> + (data(Node))#map_type_assoc.value + end. + + +%% ===================================================================== +%% @doc Creates an abstract map type exact field. The result represents +%% "<code><em>Name</em> := <em>Value</em></code>". +%% +%% @see map_type_exact_name/1 +%% @see map_type_exact_value/1 +%% @see map_type/1 + +-record(map_type_exact, {name :: syntaxTree(), value :: syntaxTree()}). + +%% `erl_parse' representation: +%% +%% {type, Pos, map_field_exact, [Name, Value]} + +-spec map_type_exact(syntaxTree(), syntaxTree()) -> syntaxTree(). + +map_type_exact(Name, Value) -> + tree(map_type_exact, #map_type_exact{name = Name, value = Value}). + +revert_map_type_exact(Node) -> + Pos = get_pos(Node), + Name = map_type_exact_name(Node), + Value = map_type_exact_value(Node), + {type, Pos, map_type_exact, [Name, Value]}. + + +%% ===================================================================== +%% @doc Returns the name subtree of a `map_type_exact' node. +%% +%% @see map_type_exact/2 + +-spec map_type_exact_name(syntaxTree()) -> syntaxTree(). + +map_type_exact_name(Node) -> + case Node of + {type, _, map_field_exact, [Name, _]} -> + Name; + _ -> + (data(Node))#map_type_exact.name + end. + + +%% ===================================================================== +%% @doc Returns the value subtree of a `map_type_exact' node. +%% +%% @see map_type_exact/2 + +-spec map_type_exact_value(syntaxTree()) -> syntaxTree(). + +map_type_exact_value(Node) -> + case Node of + {type, _, map_field_exact, [_, Value]} -> + Value; + _ -> + (data(Node))#map_type_exact.value + end. + + +%% ===================================================================== +%% @equiv map_type(any_size) + +map_type() -> + map_type(any_size). + +%% ===================================================================== +%% @doc Creates an abstract type map. If `Fields' is +%% `[F1, ..., Fn]', the result represents +%% "<code>#{<em>F1</em>, ..., <em>Fn</em>}</code>"; +%% otherwise, if `Fields' is `any_size', it represents +%% "<code>map()</code>". +%% +%% @see map_type_fields/1 + +%% type(Node) = map_type +%% data(Node) = Fields +%% +%% Fields = any_size | [syntaxTree()] +%% +%% `erl_parse' representation: +%% +%% {type, Pos, map, [Field]} +%% {type, Pos, map, any} +%% +%% Field = erl_parse() + +-spec map_type('any_size' | [syntaxTree()]) -> syntaxTree(). + +map_type(Fields) -> + tree(map_type, Fields). + +revert_map_type(Node) -> + Pos = get_pos(Node), + {type, Pos, map, map_type_fields(Node)}. + + +%% ===================================================================== +%% @doc Returns the list of field subtrees of a `map_type' node. +%% If `Node' represents "<code>map()</code>", `any_size' is returned; +%% otherwise, if `Node' represents +%% "<code>#{<em>F1</em>, ..., <em>Fn</em>}</code>", +%% `[F1, ..., Fn]' is returned. +%% +%% @see map_type/0 +%% @see map_type/1 + +-spec map_type_fields(syntaxTree()) -> 'any_size' | [syntaxTree()]. + +map_type_fields(Node) -> + case unwrap(Node) of + {type, _, map, Fields} when is_list(Fields) -> + Fields; + {type, _, map, any} -> + any_size; + Node1 -> + data(Node1) + end. + + +%% ===================================================================== +%% @doc Creates an abstract range type. The result represents +%% "<code><em>Low</em> .. <em>High</em></code>". +%% +%% @see integer_range_type_low/1 +%% @see integer_range_type_high/1 + +-record(integer_range_type, {low :: syntaxTree(), + high :: syntaxTree()}). + +%% type(Node) = integer_range_type +%% data(Node) = #integer_range_type{low :: Low, high :: High} +%% +%% Low = syntaxTree() +%% High = syntaxTree() +%% +%% `erl_parse' representation: +%% +%% {type, Pos, range, [Low, High]} +%% +%% Low = erl_parse() +%% High = erl_parse() + +-spec integer_range_type(syntaxTree(), syntaxTree()) -> syntaxTree(). + +integer_range_type(Low, High) -> + tree(integer_range_type, #integer_range_type{low = Low, high = High}). + +revert_integer_range_type(Node) -> + Pos = get_pos(Node), + Low = integer_range_type_low(Node), + High = integer_range_type_high(Node), + {type, Pos, range, [Low, High]}. + + +%% ===================================================================== +%% @doc Returns the low limit of an `integer_range_type' node. +%% +%% @see integer_range_type/2 + +-spec integer_range_type_low(syntaxTree()) -> syntaxTree(). + +integer_range_type_low(Node) -> + case unwrap(Node) of + {type, _, range, [Low, _]} -> + Low; + Node1 -> + (data(Node1))#integer_range_type.low + end. + +%% ===================================================================== +%% @doc Returns the high limit of an `integer_range_type' node. +%% +%% @see integer_range_type/2 + +-spec integer_range_type_high(syntaxTree()) -> syntaxTree(). + +integer_range_type_high(Node) -> + case unwrap(Node) of + {type, _, range, [_, High]} -> + High; + Node1 -> + (data(Node1))#integer_range_type.high + end. + + +%% ===================================================================== +%% @doc Creates an abstract record type. If `Fields' is +%% `[F1, ..., Fn]', the result represents +%% "<code>#<em>Name</em>{<em>F1</em>, ..., <em>Fn</em>}</code>". +%% +%% @see record_type_name/1 +%% @see record_type_fields/1 + +-record(record_type, {name :: syntaxTree(), + fields :: [syntaxTree()]}). + +%% type(Node) = record_type +%% data(Node) = #record_type{name = Name, fields = Fields} +%% +%% Name = syntaxTree() +%% Fields = [syntaxTree()] +%% +%% `erl_parse' representation: +%% +%% {type, Pos, record, [Name|Fields]} +%% +%% Name = erl_parse() +%% Fields = [erl_parse()] + +-spec record_type(syntaxTree(), [syntaxTree()]) -> syntaxTree(). + +record_type(Name, Fields) -> + tree(record_type, #record_type{name = Name, fields = Fields}). + +revert_record_type(Node) -> + Pos = get_pos(Node), + Name = record_type_name(Node), + Fields = record_type_fields(Node), + {type, Pos, record, [Name | Fields]}. + + +%% ===================================================================== +%% @doc Returns the name subtree of a `record_type' node. +%% +%% @see record_type/2 + +-spec record_type_name(syntaxTree()) -> syntaxTree(). + +record_type_name(Node) -> + case unwrap(Node) of + {type, _, record, [Name|_]} -> + Name; + Node1 -> + (data(Node1))#record_type.name + end. + +%% ===================================================================== +%% @doc Returns the fields subtree of a `record_type' node. +%% +%% @see record_type/2 + +-spec record_type_fields(syntaxTree()) -> [syntaxTree()]. + +record_type_fields(Node) -> + case unwrap(Node) of + {type, _, record, [_|Fields]} -> + Fields; + Node1 -> + (data(Node1))#record_type.fields + end. + + +%% ===================================================================== +%% @doc Creates an abstract record type field. The result represents +%% "<code><em>Name</em> :: <em>Type</em></code>". +%% +%% @see record_type_field_name/1 +%% @see record_type_field_type/1 + +-record(record_type_field, {name :: syntaxTree(), + type :: syntaxTree()}). + +%% type(Node) = record_type_field +%% data(Node) = #record_type_field{name = Name, type = Type} +%% +%% Name = syntaxTree() +%% Type = syntaxTree() +%% +%% `erl_parse' representation: +%% +%% {type, Pos, field_type, [Name, Type]} +%% +%% Name = erl_parse() +%% Type = erl_parse() + +-spec record_type_field(syntaxTree(), syntaxTree()) -> syntaxTree(). + +record_type_field(Name, Type) -> + tree(record_type_field, #record_type_field{name = Name, type = Type}). + +revert_record_type_field(Node) -> + Pos = get_pos(Node), + Name = record_type_field_name(Node), + Type = record_type_field_type(Node), + {type, Pos, field_type, [Name, Type]}. + + +%% ===================================================================== +%% @doc Returns the name subtree of a `record_type_field' node. +%% +%% @see record_type_field/2 + +-spec record_type_field_name(syntaxTree()) -> syntaxTree(). + +record_type_field_name(Node) -> + case unwrap(Node) of + {type, _, field_type, [Name, _]} -> + Name; + Node1 -> + (data(Node1))#record_type_field.name + end. + +%% ===================================================================== +%% @doc Returns the type subtree of a `record_type_field' node. +%% +%% @see record_type_field/2 + +-spec record_type_field_type(syntaxTree()) -> syntaxTree(). + +record_type_field_type(Node) -> + case unwrap(Node) of + {type, _, field_type, [_, Type]} -> + Type; + Node1 -> + (data(Node1))#record_type_field.type + end. + + +%% ===================================================================== +%% @equiv tuple_type(any_size) + +tuple_type() -> + tuple_type(any_size). + +%% ===================================================================== +%% @doc Creates an abstract type tuple. If `Elements' is +%% `[T1, ..., Tn]', the result represents +%% "<code>{<em>T1</em>, ..., <em>Tn</em>}</code>"; +%% otherwise, if `Elements' is `any_size', it represents +%% "<code>tuple()</code>". +%% +%% @see tuple_type_elements/1 + +%% type(Node) = tuple_type +%% data(Node) = Elements +%% +%% Elements = any_size | [syntaxTree()] +%% +%% `erl_parse' representation: +%% +%% {type, Pos, tuple, [Element]} +%% {type, Pos, tuple, any} +%% +%% Element = erl_parse() + +-spec tuple_type(any_size | [syntaxTree()]) -> syntaxTree(). + +tuple_type(Elements) -> + tree(tuple_type, Elements). + +revert_tuple_type(Node) -> + Pos = get_pos(Node), + {type, Pos, tuple, tuple_type_elements(Node)}. + + +%% ===================================================================== +%% @doc Returns the list of type element subtrees of a `tuple_type' node. +%% If `Node' represents "<code>tuple()</code>", `any_size' is returned; +%% otherwise, if `Node' represents +%% "<code>{<em>T1</em>, ..., <em>Tn</em>}</code>", +%% `[T1, ..., Tn]' is returned. +%% +%% @see tuple_type/0 +%% @see tuple_type/1 + +-spec tuple_type_elements(syntaxTree()) -> 'any_size' | [syntaxTree()]. + +tuple_type_elements(Node) -> + case unwrap(Node) of + {type, _, tuple, Elements} when is_list(Elements) -> + Elements; + {type, _, tuple, any} -> + any_size; + Node1 -> + data(Node1) + end. + + +%% ===================================================================== +%% @doc Creates an abstract type union. If `Types' is +%% `[T1, ..., Tn]', the result represents +%% "<code><em>T1</em> | ... | <em>Tn</em></code>". +%% +%% @see type_union_types/1 + +%% type(Node) = type_union +%% data(Node) = Types +%% +%% Types = [syntaxTree()] +%% +%% `erl_parse' representation: +%% +%% {type, Pos, union, Elements} +%% +%% Elements = [erl_parse()] + +-spec type_union([syntaxTree()]) -> syntaxTree(). + +type_union(Types) -> + tree(type_union, Types). + +revert_type_union(Node) -> + Pos = get_pos(Node), + {type, Pos, union, type_union_types(Node)}. + + +%% ===================================================================== +%% @doc Returns the list of type subtrees of a `type_union' node. +%% +%% @see type_union/1 + +-spec type_union_types(syntaxTree()) -> [syntaxTree()]. + +type_union_types(Node) -> + case unwrap(Node) of + {type, _, union, Types} when is_list(Types) -> + Types; + Node1 -> + data(Node1) + end. + + +%% ===================================================================== +%% @doc Creates an abstract user type. If `Arguments' is +%% `[T1, ..., Tn]', the result represents +%% "<code><em>TypeName</em>(<em>T1</em>, ...<em>Tn</em>)</code>". +%% +%% @see type_application/2 +%% @see user_type_application_name/1 +%% @see user_type_application_arguments/1 + +-record(user_type_application, {type_name :: syntaxTree(), + arguments :: [syntaxTree()]}). + +%% type(Node) = user_type_application +%% data(Node) = #user_type_application{type_name :: TypeName, +%% arguments :: Arguments} +%% +%% TypeName = syntaxTree() +%% Arguments = [syntaxTree()] +%% +%% `erl_parse' representation: +%% +%% {user_type, Pos, Name, Arguments} +%% +%% Name = erl_parse() +%% Arguments = [Type] +%% Type = erl_parse() + +-spec user_type_application(syntaxTree(), [syntaxTree()]) -> syntaxTree(). + +user_type_application(TypeName, Arguments) -> + tree(user_type_application, + #user_type_application{type_name = TypeName, arguments = Arguments}). + +revert_user_type_application(Node) -> + Pos = get_pos(Node), + TypeName = user_type_application_name(Node), + Arguments = user_type_application_arguments(Node), + {user_type, Pos, atom_value(TypeName), Arguments}. + + +%% ===================================================================== +%% @doc Returns the type name subtree of a `user_type_application' node. +%% +%% @see user_type_application/2 + +-spec user_type_application_name(syntaxTree()) -> syntaxTree(). + +user_type_application_name(Node) -> + case unwrap(Node) of + {user_type, Pos, Name, _} -> + set_pos(atom(Name), Pos); + Node1 -> + (data(Node1))#user_type_application.type_name + end. + + +%% ===================================================================== +%% @doc Returns the arguments subtrees of a `user_type_application' node. +%% +%% @see user_type_application/2 + +-spec user_type_application_arguments(syntaxTree()) -> [syntaxTree()]. + +user_type_application_arguments(Node) -> + case unwrap(Node) of + {user_type, _, _, Arguments} -> + Arguments; + Node1 -> + (data(Node1))#user_type_application.arguments + end. + + +%% ===================================================================== +%% @doc Creates an abstract typed record field specification. The +%% result represents "<code><em>Field</em> :: <em>Type</em></code>". +%% +%% @see typed_record_field_body/1 +%% @see typed_record_field_type/1 + +-record(typed_record_field, {body :: syntaxTree(), + type :: syntaxTree()}). + +%% type(Node) = typed_record_field +%% data(Node) = #typed_record_field{body :: Field +%% type = Type} +%% +%% Field = syntaxTree() +%% Type = syntaxTree() + +-spec typed_record_field(syntaxTree(), syntaxTree()) -> syntaxTree(). + +typed_record_field(Field, Type) -> + tree(typed_record_field, + #typed_record_field{body = Field, type = Type}). + + +%% ===================================================================== +%% @doc Returns the field subtree of a `typed_record_field' node. +%% +%% @see typed_record_field/2 + +-spec typed_record_field_body(syntaxTree()) -> syntaxTree(). + +typed_record_field_body(Node) -> + (data(Node))#typed_record_field.body. + + +%% ===================================================================== +%% @doc Returns the type subtree of a `typed_record_field' node. +%% +%% @see typed_record_field/2 + +-spec typed_record_field_type(syntaxTree()) -> syntaxTree(). + +typed_record_field_type(Node) -> + (data(Node))#typed_record_field.type. + %% ===================================================================== %% @doc Creates an abstract list comprehension. If `Body' is @@ -6168,6 +7411,8 @@ revert(Node) -> revert_root(Node) -> case type(Node) of + annotated_type -> + revert_annotated_type(Node); application -> revert_application(Node); atom -> @@ -6182,6 +7427,8 @@ revert_root(Node) -> revert_binary_field(Node); binary_generator -> revert_binary_generator(Node); + bitstring_type -> + revert_bitstring_type(Node); block_expr -> revert_block_expr(Node); case_expr -> @@ -6194,6 +7441,10 @@ revert_root(Node) -> revert_clause(Node); cond_expr -> revert_cond_expr(Node); + constrained_function_type -> + revert_constrained_function_type(Node); + constraint -> + revert_constraint(Node); eof_marker -> revert_eof_marker(Node); error_marker -> @@ -6202,8 +7453,12 @@ revert_root(Node) -> revert_float(Node); fun_expr -> revert_fun_expr(Node); + fun_type -> + revert_fun_type(Node); function -> revert_function(Node); + function_type -> + revert_function_type(Node); generator -> revert_generator(Node); if_expr -> @@ -6214,6 +7469,8 @@ revert_root(Node) -> revert_infix_expr(Node); integer -> revert_integer(Node); + integer_range_type -> + revert_integer_range_type(Node); list -> revert_list(Node); list_comp -> @@ -6224,6 +7481,12 @@ revert_root(Node) -> revert_map_field_assoc(Node); map_field_exact -> revert_map_field_exact(Node); + map_type -> + revert_map_type(Node); + map_type_assoc -> + revert_map_type_assoc(Node); + map_type_exact -> + revert_map_type_exact(Node); match_expr -> revert_match_expr(Node); module_qualifier -> @@ -6244,14 +7507,26 @@ revert_root(Node) -> revert_record_expr(Node); record_index_expr -> revert_record_index_expr(Node); + record_type -> + revert_record_type(Node); + record_type_field -> + revert_record_type_field(Node); + type_application -> + revert_type_application(Node); + type_union -> + revert_type_union(Node); string -> revert_string(Node); try_expr -> revert_try_expr(Node); tuple -> revert_tuple(Node); + tuple_type -> + revert_tuple_type(Node); underscore -> revert_underscore(Node); + user_type_application -> + revert_user_type_application(Node); variable -> revert_variable(Node); warning_marker -> @@ -6379,6 +7654,9 @@ subtrees(T) -> []; false -> case type(T) of + annotated_type -> + [[annotated_type_name(T)], + [annotated_type_body(T)]]; application -> [[application_operator(T)], application_arguments(T)]; @@ -6407,6 +7685,9 @@ subtrees(T) -> binary_generator -> [[binary_generator_pattern(T)], [binary_generator_body(T)]]; + bitstring_type -> + [[bitstring_type_m(T)], + [bitstring_type_n(T)]]; block_expr -> [block_expr_body(T)]; case_expr -> @@ -6429,14 +7710,30 @@ subtrees(T) -> [cond_expr_clauses(T)]; conjunction -> [conjunction_body(T)]; + constrained_function_type -> + C = constrained_function_type_argument(T), + [[constrained_function_type_body(T)], + conjunction_body(C)]; + constraint -> + [[constraint_argument(T)], + constraint_body(T)]; disjunction -> [disjunction_body(T)]; form_list -> [form_list_elements(T)]; fun_expr -> [fun_expr_clauses(T)]; + fun_type -> + []; function -> [[function_name(T)], function_clauses(T)]; + function_type -> + case function_type_arguments(T) of + any_arity -> + [[function_type_return(T)]]; + As -> + [As,[function_type_return(T)]] + end; generator -> [[generator_pattern(T)], [generator_body(T)]]; if_expr -> @@ -6447,6 +7744,9 @@ subtrees(T) -> [[infix_expr_left(T)], [infix_expr_operator(T)], [infix_expr_right(T)]]; + integer_range_type -> + [[integer_range_type_low(T)], + [integer_range_type_high(T)]]; list -> case list_suffix(T) of none -> @@ -6476,6 +7776,14 @@ subtrees(T) -> map_field_exact -> [[map_field_exact_name(T)], [map_field_exact_value(T)]]; + map_type -> + [map_type_fields(T)]; + map_type_assoc -> + [[map_type_assoc_name(T)], + [map_type_assoc_value(T)]]; + map_type_exact -> + [[map_type_exact_name(T)], + [map_type_exact_value(T)]]; match_expr -> [[match_expr_pattern(T)], [match_expr_body(T)]]; @@ -6523,6 +7831,12 @@ subtrees(T) -> record_index_expr -> [[record_index_expr_type(T)], [record_index_expr_field(T)]]; + record_type -> + [[record_type_name(T)], + record_type_fields(T)]; + record_type_field -> + [[record_type_field_name(T)], + [record_type_field_type(T)]]; size_qualifier -> [[size_qualifier_body(T)], [size_qualifier_argument(T)]]; @@ -6532,7 +7846,20 @@ subtrees(T) -> try_expr_handlers(T), try_expr_after(T)]; tuple -> - [tuple_elements(T)] + [tuple_elements(T)]; + tuple_type -> + [tuple_type_elements(T)]; + type_application -> + [[type_application_name(T)], + type_application_arguments(T)]; + type_union -> + [type_union_types(T)]; + typed_record_field -> + [[typed_record_field_body(T)], + [typed_record_field_type(T)]]; + user_type_application -> + [[user_type_application_name(T)], + user_type_application_arguments(T)] end end. @@ -6576,6 +7903,7 @@ update_tree(Node, Groups) -> -spec make_tree(atom(), [[syntaxTree()]]) -> syntaxTree(). +make_tree(annotated_type, [[N], [T]]) -> annotated_type(N, T); make_tree(application, [[F], A]) -> application(F, A); make_tree(arity_qualifier, [[N], [A]]) -> arity_qualifier(N, A); make_tree(attribute, [[N]]) -> attribute(N); @@ -6585,6 +7913,7 @@ make_tree(binary_comp, [[T], B]) -> binary_comp(T, B); make_tree(binary_field, [[B]]) -> binary_field(B); make_tree(binary_field, [[B], Ts]) -> binary_field(B, Ts); make_tree(binary_generator, [[P], [E]]) -> binary_generator(P, E); +make_tree(bitstring_type, [[M], [N]]) -> bitstring_type(M, N); make_tree(block_expr, [B]) -> block_expr(B); make_tree(case_expr, [[A], C]) -> case_expr(A, C); make_tree(catch_expr, [[B]]) -> catch_expr(B); @@ -6593,14 +7922,20 @@ make_tree(clause, [P, B]) -> clause(P, none, B); make_tree(clause, [P, [G], B]) -> clause(P, G, B); make_tree(cond_expr, [C]) -> cond_expr(C); make_tree(conjunction, [E]) -> conjunction(E); +make_tree(constrained_function_type, [[F],C]) -> + constrained_function_type(F, C); +make_tree(constraint, [[N], Ts]) -> constraint(N, Ts); make_tree(disjunction, [E]) -> disjunction(E); make_tree(form_list, [E]) -> form_list(E); make_tree(fun_expr, [C]) -> fun_expr(C); make_tree(function, [[N], C]) -> function(N, C); +make_tree(function_type, [[T]]) -> function_type(T); +make_tree(function_type, [A,[T]]) -> function_type(A, T); make_tree(generator, [[P], [E]]) -> generator(P, E); make_tree(if_expr, [C]) -> if_expr(C); make_tree(implicit_fun, [[N]]) -> implicit_fun(N); make_tree(infix_expr, [[L], [F], [R]]) -> infix_expr(L, F, R); +make_tree(integer_range_type, [[L],[H]]) -> integer_range_type(L, H); make_tree(list, [P]) -> list(P); make_tree(list, [P, [S]]) -> list(P, S); make_tree(list_comp, [[T], B]) -> list_comp(T, B); @@ -6610,6 +7945,9 @@ make_tree(map_expr, [Fs]) -> map_expr(Fs); make_tree(map_expr, [[E], Fs]) -> map_expr(E, Fs); make_tree(map_field_assoc, [[K], [V]]) -> map_field_assoc(K, V); make_tree(map_field_exact, [[K], [V]]) -> map_field_exact(K, V); +make_tree(map_type, [Fs]) -> map_type(Fs); +make_tree(map_type_assoc, [[N],[V]]) -> map_type_assoc(N, V); +make_tree(map_type_exact, [[N],[V]]) -> map_type_exact(N, V); make_tree(match_expr, [[P], [E]]) -> match_expr(P, E); make_tree(named_fun_expr, [[N], C]) -> named_fun_expr(N, C); make_tree(module_qualifier, [[M], [N]]) -> module_qualifier(M, N); @@ -6625,9 +7963,16 @@ make_tree(record_field, [[N]]) -> record_field(N); make_tree(record_field, [[N], [E]]) -> record_field(N, E); make_tree(record_index_expr, [[T], [F]]) -> record_index_expr(T, F); +make_tree(record_type, [[N],Fs]) -> record_type(N, Fs); +make_tree(record_type_field, [[N],[T]]) -> record_type_field(N, T); make_tree(size_qualifier, [[N], [A]]) -> size_qualifier(N, A); make_tree(try_expr, [B, C, H, A]) -> try_expr(B, C, H, A); -make_tree(tuple, [E]) -> tuple(E). +make_tree(tuple, [E]) -> tuple(E); +make_tree(tuple_type, [Es]) -> tuple_type(Es); +make_tree(type_application, [[N], Ts]) -> type_application(N, Ts); +make_tree(type_union, [Es]) -> type_union(Es); +make_tree(typed_record_field, [[F],[T]]) -> typed_record_field(F, T); +make_tree(user_type_application, [[N], Ts]) -> user_type_application(N, Ts). %% ===================================================================== @@ -6954,6 +8299,7 @@ fold_variable_names(Vs) -> unfold_variable_names(Vs, Pos) -> [set_pos(variable(V), Pos) || V <- Vs]. + %% Support functions for transforming lists of record field definitions. %% %% There is no unique representation for field definitions in the @@ -6968,6 +8314,16 @@ fold_record_fields(Fs) -> [fold_record_field(F) || F <- Fs]. fold_record_field(F) -> + case type(F) of + typed_record_field -> + Field = fold_record_field_1(typed_record_field_body(F)), + Type = typed_record_field_type(F), + {typed_record_field, Field, Type}; + record_field -> + fold_record_field_1(F) + end. + +fold_record_field_1(F) -> Pos = get_pos(F), Name = record_field_name(F), case record_field_value(F) of @@ -6980,10 +8336,11 @@ fold_record_field(F) -> unfold_record_fields(Fs) -> [unfold_record_field(F) || F <- Fs]. -unfold_record_field({typed_record_field, Field, _Type}) -> - unfold_record_field_1(Field); +unfold_record_field({typed_record_field, Field, Type}) -> + F = unfold_record_field_1(Field), + set_pos(typed_record_field(F, Type), get_pos(F)); unfold_record_field(Field) -> - unfold_record_field_1(Field). + unfold_record_field_1(Field). unfold_record_field_1({record_field, Pos, Name}) -> set_pos(record_field(Name), Pos); @@ -7010,5 +8367,4 @@ unfold_binary_field_type({Type, Size}, Pos) -> unfold_binary_field_type(Type, Pos) -> set_pos(atom(Type), Pos). - %% ===================================================================== diff --git a/lib/syntax_tools/src/erl_syntax_lib.erl b/lib/syntax_tools/src/erl_syntax_lib.erl index 58c4cc5244..9815559779 100644 --- a/lib/syntax_tools/src/erl_syntax_lib.erl +++ b/lib/syntax_tools/src/erl_syntax_lib.erl @@ -36,6 +36,7 @@ analyze_import_attribute/1, analyze_module_attribute/1, analyze_record_attribute/1, analyze_record_expr/1, analyze_record_field/1, analyze_wild_attribute/1, annotate_bindings/1, + analyze_type_application/1, analyze_type_name/1, annotate_bindings/2, fold/3, fold_subtrees/3, foldl_listlist/3, function_name_expansions/1, is_fail_expr/1, limit/2, limit/3, map/2, map_subtrees/2, mapfold/3, mapfold_subtrees/3, @@ -1029,14 +1030,17 @@ is_fail_expr(E) -> %% <dt>`{records, Records}'</dt> %% <dd><ul> %% <li>`Records = [{atom(), Fields}]'</li> -%% <li>`Fields = [{atom(), Default}]'</li> +%% <li>`Fields = [{atom(), {Default, Type}}]'</li> %% <li>`Default = none | syntaxTree()'</li> +%% <li>`Type = none | syntaxTree()'</li> %% </ul> %% `Records' is a list of pairs representing the names %% and corresponding field declarations of all record declaration %% attributes occurring in `Forms'. For fields declared %% without a default value, the corresponding value for -%% `Default' is the atom `none' (cf. +%% `Default' is the atom `none'. Similarly, for fields declared +%% without a type, the corresponding value for `Type' is the +%% atom `none' (cf. %% `analyze_record_attribute/1'). We do not guarantee %% that each record name occurs at most once in the list. The %% order of listing is not defined.</dd> @@ -1055,9 +1059,9 @@ is_fail_expr(E) -> %% %% @see analyze_wild_attribute/1 %% @see analyze_export_attribute/1 +%% @see analyze_function/1 %% @see analyze_import_attribute/1 %% @see analyze_record_attribute/1 -%% @see analyze_function/1 %% @see erl_syntax:error_marker_info/1 %% @see erl_syntax:warning_marker_info/1 @@ -1102,8 +1106,6 @@ collect_attribute(file, _, Info) -> Info; collect_attribute(record, {R, L}, Info) -> finfo_add_record(R, L, Info); -collect_attribute(spec, _, Info) -> - Info; collect_attribute(_, {N, V}, Info) -> finfo_add_attribute(N, V, Info). @@ -1114,12 +1116,15 @@ collect_attribute(_, {N, V}, Info) -> module_imports = [] :: [atom()], imports = [] :: [{atom(), [{atom(), arity()}]}], attributes = [] :: [{atom(), term()}], - records = [] :: [{atom(), [{atom(), field_default()}]}], + records = [] :: [{atom(), [{atom(), + field_default(), + field_type()}]}], errors = [] :: [term()], warnings = [] :: [term()], functions = [] :: [{atom(), arity()}]}). -type field_default() :: 'none' | erl_syntax:syntaxTree(). +-type field_type() :: 'none' | erl_syntax:syntaxTree(). new_finfo() -> #forms{}. @@ -1326,8 +1331,6 @@ analyze_attribute(file, Node) -> analyze_file_attribute(Node); analyze_attribute(record, Node) -> analyze_record_attribute(Node); -analyze_attribute(spec, _Node) -> - spec; analyze_attribute(_, Node) -> %% A "wild" attribute (such as e.g. a `compile' directive). analyze_wild_attribute(Node). @@ -1523,6 +1526,55 @@ analyze_import_attribute(Node) -> %% ===================================================================== +%% @spec analyze_type_name(Node::syntaxTree()) -> TypeName +%% +%% TypeName = atom() +%% | {atom(), integer()} +%% | {ModuleName, {atom(), integer()}} +%% ModuleName = atom() +%% +%% @doc Returns the type name represented by a syntax tree. If +%% `Node' represents a type name, such as +%% "`foo/1'" or "`bloggs:fred/2'", a uniform +%% representation of that name is returned. +%% +%% The evaluation throws `syntax_error' if +%% `Node' does not represent a well-formed type name. + +-spec analyze_type_name(erl_syntax:syntaxTree()) -> typeName(). + +analyze_type_name(Node) -> + case erl_syntax:type(Node) of + atom -> + erl_syntax:atom_value(Node); + arity_qualifier -> + A = erl_syntax:arity_qualifier_argument(Node), + N = erl_syntax:arity_qualifier_body(Node), + + case ((erl_syntax:type(A) =:= integer) + and (erl_syntax:type(N) =:= atom)) + of + true -> + append_arity(erl_syntax:integer_value(A), + erl_syntax:atom_value(N)); + _ -> + throw(syntax_error) + end; + module_qualifier -> + M = erl_syntax:module_qualifier_argument(Node), + case erl_syntax:type(M) of + atom -> + N = erl_syntax:module_qualifier_body(Node), + N1 = analyze_type_name(N), + {erl_syntax:atom_value(M), N1}; + _ -> + throw(syntax_error) + end; + _ -> + throw(syntax_error) + end. + +%% ===================================================================== %% @spec analyze_wild_attribute(Node::syntaxTree()) -> {atom(), term()} %% %% @doc Returns the name and value of a "wild" attribute. The result is @@ -1547,6 +1599,7 @@ analyze_wild_attribute(Node) -> atom -> case erl_syntax:attribute_arguments(Node) of [V] -> + %% Note: does not work well with macros. case catch {ok, erl_syntax:concrete(V)} of {ok, Val} -> {erl_syntax:atom_value(N), Val}; @@ -1568,17 +1621,22 @@ analyze_wild_attribute(Node) -> %% @spec analyze_record_attribute(Node::syntaxTree()) -> %% {atom(), Fields} %% -%% Fields = [{atom(), none | syntaxTree()}] +%% Fields = [{atom(), {Default, Type}}] +%% Default = none | syntaxTree() +%% Type = none | syntaxTree() %% %% @doc Returns the name and the list of fields of a record declaration %% attribute. The result is a pair `{Name, Fields}', if %% `Node' represents "`-record(Name, {...}).'", %% where `Fields' is a list of pairs `{Label, -%% Default}' for each field "`Label'" or "`Label = -%% <em>Default</em>'" in the declaration, listed in left-to-right +%% {Default, Type}}' for each field "`Label'", "`Label = +%% <em>Default</em>'", "`Label :: <em>Type</em>'", or +%% "`Label = <em>Default</em> :: <em>Type</em>'" in the declaration, +%% listed in left-to-right %% order. If the field has no default-value declaration, the value for -%% `Default' will be the atom `none'. We do not -%% guarantee that each label occurs at most one in the list. +%% `Default' will be the atom `none'. If the field has no type declaration, +%% the value for `Type' will be the atom `none'. We do not +%% guarantee that each label occurs at most once in the list. %% %% The evaluation throws `syntax_error' if %% `Node' does not represent a well-formed record declaration @@ -1587,7 +1645,9 @@ analyze_wild_attribute(Node) -> %% @see analyze_attribute/1 %% @see analyze_record_field/1 --type fields() :: [{atom(), 'none' | erl_syntax:syntaxTree()}]. +-type field() :: {atom(), {field_default(), field_type()}}. + +-type fields() :: [field()]. -spec analyze_record_attribute(erl_syntax:syntaxTree()) -> {atom(), fields()}. @@ -1625,7 +1685,7 @@ analyze_record_attribute_tuple(Node) -> %% {atom(), Info} | atom() %% %% Info = {atom(), [{atom(), Value}]} | {atom(), atom()} | atom() -%% Value = none | syntaxTree() +%% Value = syntaxTree() %% %% @doc Returns the record name and field name/names of a record %% expression. If `Node' has type `record_expr', @@ -1645,9 +1705,9 @@ analyze_record_attribute_tuple(Node) -> %% %% For a `record_expr' node, `Info' represents %% the record name and the list of descriptors for the involved fields, -%% listed in the order they appear. (See -%% `analyze_record_field/1' for details on the field -%% descriptors). For a `record_access' node, +%% listed in the order they appear. A field descriptor is a pair +%% `{Label, Value}', if `Node' represents "`Label = <em>Value</em>'". +%% For a `record_access' node, %% `Info' represents the record name and the field name. For a %% `record_index_expr' node, `Info' represents the %% record name and the name field name. @@ -1659,7 +1719,7 @@ analyze_record_attribute_tuple(Node) -> %% @see analyze_record_attribute/1 %% @see analyze_record_field/1 --type info() :: {atom(), [{atom(), 'none' | erl_syntax:syntaxTree()}]} +-type info() :: {atom(), [{atom(), erl_syntax:syntaxTree()}]} | {atom(), atom()} | atom(). -spec analyze_record_expr(erl_syntax:syntaxTree()) -> {atom(), info()} | atom(). @@ -1670,8 +1730,9 @@ analyze_record_expr(Node) -> A = erl_syntax:record_expr_type(Node), case erl_syntax:type(A) of atom -> - Fs = [analyze_record_field(F) - || F <- erl_syntax:record_expr_fields(Node)], + Fs0 = [analyze_record_field(F) + || F <- erl_syntax:record_expr_fields(Node)], + Fs = [{N, D} || {N, {D, _T}} <- Fs0], {record_expr, {erl_syntax:atom_value(A), Fs}}; _ -> throw(syntax_error) @@ -1713,16 +1774,19 @@ analyze_record_expr(Node) -> end. %% ===================================================================== -%% @spec analyze_record_field(Node::syntaxTree()) -> {atom(), Value} +%% @spec analyze_record_field(Node::syntaxTree()) -> {atom(), {Default, Type}} %% -%% Value = none | syntaxTree() +%% Default = none | syntaxTree() +%% Type = none | syntaxTree() %% -%% @doc Returns the label and value-expression of a record field -%% specifier. The result is a pair `{Label, Value}', if -%% `Node' represents "`Label = <em>Value</em>'" or -%% "`Label'", where in the first case, `Value' is -%% a syntax tree, and in the second case `Value' is -%% `none'. +%% @doc Returns the label, value-expression, and type of a record field +%% specifier. The result is a pair `{Label, {Default, Type}}', if +%% `Node' represents "`Label'", "`Label = <em>Default</em>'", +%% "`Label :: <em>Type</em>'", or +%% "`Label = <em>Default</em> :: <em>Type</em>'". +%% If the field has no value-expression, the value for +%% `Default' will be the atom `none'. If the field has no type, +%% the value for `Type' will be the atom `none'. %% %% The evaluation throws `syntax_error' if %% `Node' does not represent a well-formed record field @@ -1731,8 +1795,7 @@ analyze_record_expr(Node) -> %% @see analyze_record_attribute/1 %% @see analyze_record_expr/1 --spec analyze_record_field(erl_syntax:syntaxTree()) -> - {atom(), 'none' | erl_syntax:syntaxTree()}. +-spec analyze_record_field(erl_syntax:syntaxTree()) -> field(). analyze_record_field(Node) -> case erl_syntax:type(Node) of @@ -1741,10 +1804,15 @@ analyze_record_field(Node) -> case erl_syntax:type(A) of atom -> T = erl_syntax:record_field_value(Node), - {erl_syntax:atom_value(A), T}; + {erl_syntax:atom_value(A), {T, none}}; _ -> throw(syntax_error) end; + typed_record_field -> + F = erl_syntax:typed_record_field_body(Node), + {N, {V, _none}} = analyze_record_field(F), + T = erl_syntax:typed_record_field_type(Node), + {N, {V, T}}; _ -> throw(syntax_error) end. @@ -1887,6 +1955,55 @@ analyze_application(Node) -> %% ===================================================================== +%% @spec analyze_type_application(Node::syntaxTree()) -> typeName() +%% +%% TypeName = {atom(), integer()} +%% | {ModuleName, {atom(), integer()}} +%% ModuleName = atom() +%% +%% @doc Returns the name of a used type. The result is a +%% representation of the name of the used pre-defined or local type `N/A', +%% if `Node' represents a local (user) type application +%% "`<em>N</em>(<em>T_1</em>, ..., <em>T_A</em>)'", or +%% a representation of the name of the used remote type `M:N/A' +%% if `Node' represents a remote user type application +%% "`<em>M</em>:<em>N</em>(<em>T_1</em>, ..., <em>T_A</em>)'". +%% +%% The evaluation throws `syntax_error' if `Node' does not represent a +%% well-formed (user) type application expression. +%% +%% @see analyze_type_name/1 + +-type typeName() :: atom() | {module(), atom(), arity()} | {atom(), arity()}. + +-spec analyze_type_application(erl_syntax:syntaxTree()) -> typeName(). + +analyze_type_application(Node) -> + case erl_syntax:type(Node) of + type_application -> + A = length(erl_syntax:type_application_arguments(Node)), + N = erl_syntax:type_application_name(Node), + case catch {ok, analyze_type_name(N)} of + {ok, TypeName} -> + append_arity(A, TypeName); + _ -> + throw(syntax_error) + end; + user_type_application -> + A = length(erl_syntax:user_type_application_arguments(Node)), + N = erl_syntax:user_type_application_name(Node), + case catch {ok, analyze_type_name(N)} of + {ok, TypeName} -> + append_arity(A, TypeName); + _ -> + throw(syntax_error) + end; + _ -> + throw(syntax_error) + end. + + +%% ===================================================================== %% @spec function_name_expansions(Names::[Name]) -> [{ShortName, Name}] %% %% Name = ShortName | {atom(), Name} diff --git a/lib/syntax_tools/src/igor.erl b/lib/syntax_tools/src/igor.erl index 4557678f9d..1d14bd7c3a 100644 --- a/lib/syntax_tools/src/igor.erl +++ b/lib/syntax_tools/src/igor.erl @@ -2612,6 +2612,19 @@ get_module_info(Forms) -> fold_record_fields(Rs) -> [{N, [fold_record_field(F) || F <- Fs]} || {N, Fs} <- Rs]. +fold_record_field({_Name, {none, _Type}} = None) -> + None; +fold_record_field({Name, {F, Type}}) -> + case erl_syntax:is_literal(F) of + true -> + {Name, {value, erl_syntax:concrete(F)}, Type}; + false -> + %% The default value for the field is not a constant, so we + %% represent it by a hash value instead. (We don't want to + %% do this in the general case.) + {Name, {hash, erlang:phash(F, 16#ffffff)}, Type} + end; +%% The following two clauses handle code before Erlang/OTP 19.0. fold_record_field({_Name, none} = None) -> None; fold_record_field({Name, F}) -> diff --git a/lib/syntax_tools/src/syntax_tools.app.src b/lib/syntax_tools/src/syntax_tools.app.src index dd4ac46055..5c6008a5f0 100644 --- a/lib/syntax_tools/src/syntax_tools.app.src +++ b/lib/syntax_tools/src/syntax_tools.app.src @@ -18,4 +18,4 @@ {applications, [stdlib]}, {env, []}, {runtime_dependencies, - ["compiler-6.0","erts-6.0","kernel-3.0","stdlib-2.5"]}]}. + ["compiler-7.0","erts-8.0","kernel-5.0","stdlib-3.0"]}]}. diff --git a/lib/syntax_tools/test/syntax_tools_SUITE.erl b/lib/syntax_tools/test/syntax_tools_SUITE.erl index eb52cce6af..b935d42bb7 100644 --- a/lib/syntax_tools/test/syntax_tools_SUITE.erl +++ b/lib/syntax_tools/test/syntax_tools_SUITE.erl @@ -61,7 +61,7 @@ appup_test(Config) when is_list(Config) -> smoke_test(Config) when is_list(Config) -> Dog = ?t:timetrap(?t:minutes(12)), Wc = filename:join([code:lib_dir(),"*","src","*.erl"]), - Fs = filelib:wildcard(Wc), + Fs = filelib:wildcard(Wc) ++ test_files(Config), io:format("~p files\n", [length(Fs)]), case p_run(fun smoke_test_file/1, Fs) of 0 -> ok; @@ -93,7 +93,7 @@ print_error_markers(F, File) -> revert(Config) when is_list(Config) -> Dog = ?t:timetrap(?t:minutes(12)), Wc = filename:join([code:lib_dir("stdlib"),"src","*.erl"]), - Fs = filelib:wildcard(Wc), + Fs = filelib:wildcard(Wc) ++ test_files(Config), Path = [filename:join(code:lib_dir(stdlib), "include"), filename:join(code:lib_dir(kernel), "include")], io:format("~p files\n", [length(Fs)]), @@ -203,18 +203,25 @@ t_erl_parse_type(Config) when is_list(Config) -> t_epp_dodger(Config) when is_list(Config) -> DataDir = ?config(data_dir, Config), PrivDir = ?config(priv_dir, Config), - Filenames = ["syntax_tools_SUITE_test_module.erl", - "syntax_tools_test.erl"], + Filenames = test_files(), ok = test_epp_dodger(Filenames,DataDir,PrivDir), ok. t_comment_scan(Config) when is_list(Config) -> DataDir = ?config(data_dir, Config), - Filenames = ["syntax_tools_SUITE_test_module.erl", - "syntax_tools_test.erl"], + Filenames = test_files(), ok = test_comment_scan(Filenames,DataDir), ok. +test_files(Config) -> + DataDir = ?config(data_dir, Config), + [ filename:join(DataDir,Filename) || Filename <- test_files() ]. + +test_files() -> + ["syntax_tools_SUITE_test_module.erl", + "syntax_tools_test.erl", + "type_specs.erl"]. + t_igor(Config) when is_list(Config) -> DataDir = ?config(data_dir, Config), PrivDir = ?config(priv_dir, Config), @@ -222,6 +229,12 @@ t_igor(Config) when is_list(Config) -> FileM2 = filename:join(DataDir,"m2.erl"), ["m.erl",_]=R = igor:merge(m,[FileM1,FileM2],[{outdir,PrivDir}]), io:format("igor:merge/3 = ~p~n", [R]), + + FileTypeSpecs = filename:join(DataDir,"igor_type_specs.erl"), + Empty = filename:join(DataDir,"empty.erl"), + ["n.erl",_]=R2 = igor:merge(n,[FileTypeSpecs,Empty],[{outdir,PrivDir}]), + io:format("igor:merge/3 = ~p~n", [R2]), + ok. test_comment_scan([],_) -> ok; diff --git a/lib/syntax_tools/test/syntax_tools_SUITE_data/empty.erl b/lib/syntax_tools/test/syntax_tools_SUITE_data/empty.erl new file mode 100644 index 0000000000..877ff66013 --- /dev/null +++ b/lib/syntax_tools/test/syntax_tools_SUITE_data/empty.erl @@ -0,0 +1 @@ +-module(empty). diff --git a/lib/syntax_tools/test/syntax_tools_SUITE_data/igor_type_specs.erl b/lib/syntax_tools/test/syntax_tools_SUITE_data/igor_type_specs.erl new file mode 100644 index 0000000000..5a156c7fa3 --- /dev/null +++ b/lib/syntax_tools/test/syntax_tools_SUITE_data/igor_type_specs.erl @@ -0,0 +1,80 @@ +%% Same as ./type_specs.erl, but without macros. +-module(igor_type_specs). + +-include_lib("syntax_tools/include/merl.hrl"). + +-export([f/1, b/0, c/2]). + +-export_type([t/0, ot/2, ff2/0]). + +-type aa() :: _. + +-type t() :: integer(). + +-type ff(A) :: ot(A, A) | tuple() | 1..3 | map() | {}. +-type ff1() :: ff(bin()) | foo:bar(). +-type ff2() :: {list(), [_], list(integer()), + nonempty_list(), nonempty_list(atom()), [ff1(), ...], + nil(), []}. +-type bin() :: <<>> + | <<_:(+4)>> + | <<_:_*8>> + | <<_:12, _:_*16>> + | <<_:16, _:_*(0)>> % same as "<<_:16>>" + | <<_:16, _:_*(+0)>>. + +-callback cb() -> t(). + +-optional_callbacks([cb/0]). + +-opaque ot(A, B) :: {A, B}. + +-type f1() :: fun(). +-type f2() :: fun((...) -> t()). +-type f3() :: fun(() -> t()). +-type f4() :: fun((t(), t()) -> t()). + +-wild(attribute). + +-record(par, {a :: undefined | igor_type_specs}). + +-record(r0, {}). + +-record(r, + {f1 :: integer(), + f2 = a :: atom(), + f3 :: fun(), + f4 = 7}). + +-type r0() :: #r0{} | #r{f1 :: 3} | #r{f1 :: 3, f2 :: 'sju'}. + +-type m1() :: #{}. +-type m2() :: #{a => m1(), b => #{} | fy:m2()}. +-type b1() :: B1 :: binary() | (BitString :: bitstring()). + +-define(PAIR(A, B), {(A), (B)}). + +-spec igor_type_specs:f({r0(), r0()}) -> {t(), t()}. + +f({R, R}) -> + _ = "igor_type_specs" ++ "hej", + _ = <<"foo">>, + _ = R#r.f1, + _ = R#r{f1 = 17, f2 = b}, + {1, 1}. + +-spec igor_type_specs:b() -> integer() | fun(). + +b() -> + case foo:bar() of + #{a := 2} -> 19 + end. + +-spec c(Atom :: atom(), Integer :: integer()) -> {atom(), integer()}; + (X, Y) -> {atom(), float()} when X :: atom(), + is_subtype(Y, float()); + (integer(), atom()) -> {integer(), atom()}. + +c(A, B) -> + _ = integer, + {A, B}. diff --git a/lib/syntax_tools/test/syntax_tools_SUITE_data/type_specs.erl b/lib/syntax_tools/test/syntax_tools_SUITE_data/type_specs.erl new file mode 100644 index 0000000000..5621d3a293 --- /dev/null +++ b/lib/syntax_tools/test/syntax_tools_SUITE_data/type_specs.erl @@ -0,0 +1,84 @@ +-module(type_specs). + +-include_lib("syntax_tools/include/merl.hrl"). + +-export([f/1, b/0, c/2]). + +-export_type([t/0, ot/2, ff2/0]). + +-type aa() :: _. + +-type t() :: integer(). + +-type ff(A) :: ot(A, A) | tuple() | 1..3 | map() | {}. +-type ff1() :: ff(bin()) | foo:bar(). +-type ff2() :: {list(), [_], list(integer()), + nonempty_list(), nonempty_list(atom()), [ff1(), ...], + nil(), []}. +-type bin() :: <<>> + | <<_:(+4)>> + | <<_:_*8>> + | <<_:12, _:_*16>> + | <<_:16, _:_*(0)>> % same as "<<_:16>>" + | <<_:16, _:_*(+0)>>. + +-callback cb() -> t(). + +-optional_callbacks([cb/0]). + +-opaque ot(A, B) :: {A, B}. + +-type f1() :: fun(). +-type f2() :: fun((...) -> t()). +-type f3() :: fun(() -> t()). +-type f4() :: fun((t(), t()) -> t()). + +-wild(attribute). + +-record(par, {a :: undefined | ?MODULE}). + +-record(r0, {}). + +-record(r, + {f1 :: integer(), + f2 = a :: atom(), + f3 :: fun(), + f4 = 7}). + +-type r0() :: #r0{} | #r{f1 :: 3} | #r{f1 :: 3, f2 :: 'sju'}. + +-type m1() :: #{} | map(). +-type m2() :: #{a := m1(), b => #{} | fy:m2()}. +-type m3() :: #{...}. +-type m4() :: #{_ => _, ...}. +-type m5() :: #{any() => any(), ...}. % Currently printed as `#{..., ...}'. +-type b1() :: B1 :: binary() | (BitString :: bitstring()). + +-define(PAIR(A, B), {(A), (B)}). + +-spec ?MODULE:f(?PAIR(r0(), r0())) -> ?PAIR(t(), t()). + +f({R, R}) -> + _ = ?MODULE_STRING ++ "hej", + _ = <<"foo">>, + _ = R#r.f1, + _ = R#r{f1 = 17, f2 = b}, + {1, 1}. + +-spec ?MODULE:b() -> integer() | fun(). + +b() -> + case foo:bar() of + #{a := 2} -> 19 + end. + +-define(I, integer). + +-spec c(Atom :: atom(), Integer :: ?I()) -> {atom(), integer()}; + (X, Y) -> {atom(), float()} when X :: atom(), + is_subtype(Y, float()); + (integer(), atom()) -> {integer(), atom()}. + +c(A, B) -> + _ = ?I, + {A, B}. diff --git a/lib/wx/api_gen/wxapi.conf b/lib/wx/api_gen/wxapi.conf index 4f7223e147..786e536f93 100644 --- a/lib/wx/api_gen/wxapi.conf +++ b/lib/wx/api_gen/wxapi.conf @@ -802,9 +802,9 @@ 'CanRedo','CanUndo','Copy','Cut','GetInsertionPoint','GetLastPosition', 'GetValue','Paste','Redo','Replace','Remove','SetInsertionPoint', 'SetInsertionPointEnd','SetSelection','SetValue','Undo']}. -{class, wxGauge, wxControl, [], - ['wxGauge','~wxGauge','Create','GetBezelFace','GetRange','GetShadowWidth', - 'GetValue','IsVertical','SetBezelFace','SetRange','SetShadowWidth','SetValue', +{class, wxGauge, wxControl, [], + ['wxGauge','~wxGauge','Create','GetRange', + 'GetValue','IsVertical','SetRange','SetValue', 'Pulse']}. {class, wxGenericDirCtrl, wxControl, [], ['wxGenericDirCtrl','~wxGenericDirCtrl','Create','Init','CollapseTree', diff --git a/lib/wx/c_src/gen/wxe_funcs.cpp b/lib/wx/c_src/gen/wxe_funcs.cpp index 283e97f4e2..942baf7c7f 100644 --- a/lib/wx/c_src/gen/wxe_funcs.cpp +++ b/lib/wx/c_src/gen/wxe_funcs.cpp @@ -14630,13 +14630,6 @@ validator = (wxValidator *) getPtr(bp,memenv); bp += 4; rt.addBool(Result); break; } -case wxGauge_GetBezelFace: { // wxGauge::GetBezelFace - wxGauge *This = (wxGauge *) getPtr(bp,memenv); bp += 4; - if(!This) throw wxe_badarg(0); - int Result = This->GetBezelFace(); - rt.addInt(Result); - break; -} case wxGauge_GetRange: { // wxGauge::GetRange wxGauge *This = (wxGauge *) getPtr(bp,memenv); bp += 4; if(!This) throw wxe_badarg(0); @@ -14644,13 +14637,6 @@ case wxGauge_GetRange: { // wxGauge::GetRange rt.addInt(Result); break; } -case wxGauge_GetShadowWidth: { // wxGauge::GetShadowWidth - wxGauge *This = (wxGauge *) getPtr(bp,memenv); bp += 4; - if(!This) throw wxe_badarg(0); - int Result = This->GetShadowWidth(); - rt.addInt(Result); - break; -} case wxGauge_GetValue: { // wxGauge::GetValue wxGauge *This = (wxGauge *) getPtr(bp,memenv); bp += 4; if(!This) throw wxe_badarg(0); @@ -14665,13 +14651,6 @@ case wxGauge_IsVertical: { // wxGauge::IsVertical rt.addBool(Result); break; } -case wxGauge_SetBezelFace: { // wxGauge::SetBezelFace - wxGauge *This = (wxGauge *) getPtr(bp,memenv); bp += 4; - int * w = (int *) bp; bp += 4; - if(!This) throw wxe_badarg(0); - This->SetBezelFace(*w); - break; -} case wxGauge_SetRange: { // wxGauge::SetRange wxGauge *This = (wxGauge *) getPtr(bp,memenv); bp += 4; int * r = (int *) bp; bp += 4; @@ -14679,13 +14658,6 @@ case wxGauge_SetRange: { // wxGauge::SetRange This->SetRange(*r); break; } -case wxGauge_SetShadowWidth: { // wxGauge::SetShadowWidth - wxGauge *This = (wxGauge *) getPtr(bp,memenv); bp += 4; - int * w = (int *) bp; bp += 4; - if(!This) throw wxe_badarg(0); - This->SetShadowWidth(*w); - break; -} case wxGauge_SetValue: { // wxGauge::SetValue wxGauge *This = (wxGauge *) getPtr(bp,memenv); bp += 4; int * pos = (int *) bp; bp += 4; diff --git a/lib/wx/c_src/gen/wxe_macros.h b/lib/wx/c_src/gen/wxe_macros.h index 0d3b79b7f9..82b39b49cd 100644 --- a/lib/wx/c_src/gen/wxe_macros.h +++ b/lib/wx/c_src/gen/wxe_macros.h @@ -1506,1924 +1506,1920 @@ #define wxGauge_new_0 1602 #define wxGauge_new_4 1603 #define wxGauge_Create 1604 -#define wxGauge_GetBezelFace 1605 -#define wxGauge_GetRange 1606 -#define wxGauge_GetShadowWidth 1607 -#define wxGauge_GetValue 1608 -#define wxGauge_IsVertical 1609 -#define wxGauge_SetBezelFace 1610 -#define wxGauge_SetRange 1611 -#define wxGauge_SetShadowWidth 1612 -#define wxGauge_SetValue 1613 -#define wxGauge_Pulse 1614 -#define wxGauge_destroy 1615 -#define wxGenericDirCtrl_new_0 1616 -#define wxGenericDirCtrl_new_2 1617 -#define wxGenericDirCtrl_destruct 1618 -#define wxGenericDirCtrl_Create 1619 -#define wxGenericDirCtrl_Init 1620 -#define wxGenericDirCtrl_CollapseTree 1621 -#define wxGenericDirCtrl_ExpandPath 1622 -#define wxGenericDirCtrl_GetDefaultPath 1623 -#define wxGenericDirCtrl_GetPath 1624 -#define wxGenericDirCtrl_GetFilePath 1625 -#define wxGenericDirCtrl_GetFilter 1626 -#define wxGenericDirCtrl_GetFilterIndex 1627 -#define wxGenericDirCtrl_GetRootId 1628 -#define wxGenericDirCtrl_GetTreeCtrl 1629 -#define wxGenericDirCtrl_ReCreateTree 1630 -#define wxGenericDirCtrl_SetDefaultPath 1631 -#define wxGenericDirCtrl_SetFilter 1632 -#define wxGenericDirCtrl_SetFilterIndex 1633 -#define wxGenericDirCtrl_SetPath 1634 -#define wxStaticBox_new_4 1636 -#define wxStaticBox_new_0 1637 -#define wxStaticBox_Create 1638 -#define wxStaticBox_destroy 1639 -#define wxStaticLine_new_2 1641 -#define wxStaticLine_new_0 1642 -#define wxStaticLine_Create 1643 -#define wxStaticLine_IsVertical 1644 -#define wxStaticLine_GetDefaultSize 1645 -#define wxStaticLine_destroy 1646 -#define wxListBox_new_3 1649 -#define wxListBox_new_0 1650 -#define wxListBox_destruct 1652 -#define wxListBox_Create 1654 -#define wxListBox_Deselect 1655 -#define wxListBox_GetSelections 1656 -#define wxListBox_InsertItems 1657 -#define wxListBox_IsSelected 1658 -#define wxListBox_Set 1659 -#define wxListBox_HitTest 1660 -#define wxListBox_SetFirstItem_1_0 1661 -#define wxListBox_SetFirstItem_1_1 1662 -#define wxListCtrl_new_0 1663 -#define wxListCtrl_new_2 1664 -#define wxListCtrl_Arrange 1665 -#define wxListCtrl_AssignImageList 1666 -#define wxListCtrl_ClearAll 1667 -#define wxListCtrl_Create 1668 -#define wxListCtrl_DeleteAllItems 1669 -#define wxListCtrl_DeleteColumn 1670 -#define wxListCtrl_DeleteItem 1671 -#define wxListCtrl_EditLabel 1672 -#define wxListCtrl_EnsureVisible 1673 -#define wxListCtrl_FindItem_3_0 1674 -#define wxListCtrl_FindItem_3_1 1675 -#define wxListCtrl_GetColumn 1676 -#define wxListCtrl_GetColumnCount 1677 -#define wxListCtrl_GetColumnWidth 1678 -#define wxListCtrl_GetCountPerPage 1679 -#define wxListCtrl_GetEditControl 1680 -#define wxListCtrl_GetImageList 1681 -#define wxListCtrl_GetItem 1682 -#define wxListCtrl_GetItemBackgroundColour 1683 -#define wxListCtrl_GetItemCount 1684 -#define wxListCtrl_GetItemData 1685 -#define wxListCtrl_GetItemFont 1686 -#define wxListCtrl_GetItemPosition 1687 -#define wxListCtrl_GetItemRect 1688 -#define wxListCtrl_GetItemSpacing 1689 -#define wxListCtrl_GetItemState 1690 -#define wxListCtrl_GetItemText 1691 -#define wxListCtrl_GetItemTextColour 1692 -#define wxListCtrl_GetNextItem 1693 -#define wxListCtrl_GetSelectedItemCount 1694 -#define wxListCtrl_GetTextColour 1695 -#define wxListCtrl_GetTopItem 1696 -#define wxListCtrl_GetViewRect 1697 -#define wxListCtrl_HitTest 1698 -#define wxListCtrl_InsertColumn_2 1699 -#define wxListCtrl_InsertColumn_3 1700 -#define wxListCtrl_InsertItem_1 1701 -#define wxListCtrl_InsertItem_2_1 1702 -#define wxListCtrl_InsertItem_2_0 1703 -#define wxListCtrl_InsertItem_3 1704 -#define wxListCtrl_RefreshItem 1705 -#define wxListCtrl_RefreshItems 1706 -#define wxListCtrl_ScrollList 1707 -#define wxListCtrl_SetBackgroundColour 1708 -#define wxListCtrl_SetColumn 1709 -#define wxListCtrl_SetColumnWidth 1710 -#define wxListCtrl_SetImageList 1711 -#define wxListCtrl_SetItem_1 1712 -#define wxListCtrl_SetItem_4 1713 -#define wxListCtrl_SetItemBackgroundColour 1714 -#define wxListCtrl_SetItemCount 1715 -#define wxListCtrl_SetItemData 1716 -#define wxListCtrl_SetItemFont 1717 -#define wxListCtrl_SetItemImage 1718 -#define wxListCtrl_SetItemColumnImage 1719 -#define wxListCtrl_SetItemPosition 1720 -#define wxListCtrl_SetItemState 1721 -#define wxListCtrl_SetItemText 1722 -#define wxListCtrl_SetItemTextColour 1723 -#define wxListCtrl_SetSingleStyle 1724 -#define wxListCtrl_SetTextColour 1725 -#define wxListCtrl_SetWindowStyleFlag 1726 -#define wxListCtrl_SortItems 1727 -#define wxListCtrl_destroy 1728 -#define wxListView_ClearColumnImage 1729 -#define wxListView_Focus 1730 -#define wxListView_GetFirstSelected 1731 -#define wxListView_GetFocusedItem 1732 -#define wxListView_GetNextSelected 1733 -#define wxListView_IsSelected 1734 -#define wxListView_Select 1735 -#define wxListView_SetColumnImage 1736 -#define wxListItem_new_0 1737 -#define wxListItem_new_1 1738 -#define wxListItem_destruct 1739 -#define wxListItem_Clear 1740 -#define wxListItem_GetAlign 1741 -#define wxListItem_GetBackgroundColour 1742 -#define wxListItem_GetColumn 1743 -#define wxListItem_GetFont 1744 -#define wxListItem_GetId 1745 -#define wxListItem_GetImage 1746 -#define wxListItem_GetMask 1747 -#define wxListItem_GetState 1748 -#define wxListItem_GetText 1749 -#define wxListItem_GetTextColour 1750 -#define wxListItem_GetWidth 1751 -#define wxListItem_SetAlign 1752 -#define wxListItem_SetBackgroundColour 1753 -#define wxListItem_SetColumn 1754 -#define wxListItem_SetFont 1755 -#define wxListItem_SetId 1756 -#define wxListItem_SetImage 1757 -#define wxListItem_SetMask 1758 -#define wxListItem_SetState 1759 -#define wxListItem_SetStateMask 1760 -#define wxListItem_SetText 1761 -#define wxListItem_SetTextColour 1762 -#define wxListItem_SetWidth 1763 -#define wxListItemAttr_new_0 1764 -#define wxListItemAttr_new_3 1765 -#define wxListItemAttr_GetBackgroundColour 1766 -#define wxListItemAttr_GetFont 1767 -#define wxListItemAttr_GetTextColour 1768 -#define wxListItemAttr_HasBackgroundColour 1769 -#define wxListItemAttr_HasFont 1770 -#define wxListItemAttr_HasTextColour 1771 -#define wxListItemAttr_SetBackgroundColour 1772 -#define wxListItemAttr_SetFont 1773 -#define wxListItemAttr_SetTextColour 1774 -#define wxListItemAttr_destroy 1775 -#define wxImageList_new_0 1776 -#define wxImageList_new_3 1777 -#define wxImageList_Add_1 1778 -#define wxImageList_Add_2_0 1779 -#define wxImageList_Add_2_1 1780 -#define wxImageList_Create 1781 -#define wxImageList_Draw 1783 -#define wxImageList_GetBitmap 1784 -#define wxImageList_GetIcon 1785 -#define wxImageList_GetImageCount 1786 -#define wxImageList_GetSize 1787 -#define wxImageList_Remove 1788 -#define wxImageList_RemoveAll 1789 -#define wxImageList_Replace_2 1790 -#define wxImageList_Replace_3 1791 -#define wxImageList_destroy 1792 -#define wxTextAttr_new_0 1793 -#define wxTextAttr_new_2 1794 -#define wxTextAttr_GetAlignment 1795 -#define wxTextAttr_GetBackgroundColour 1796 -#define wxTextAttr_GetFont 1797 -#define wxTextAttr_GetLeftIndent 1798 -#define wxTextAttr_GetLeftSubIndent 1799 -#define wxTextAttr_GetRightIndent 1800 -#define wxTextAttr_GetTabs 1801 -#define wxTextAttr_GetTextColour 1802 -#define wxTextAttr_HasBackgroundColour 1803 -#define wxTextAttr_HasFont 1804 -#define wxTextAttr_HasTextColour 1805 -#define wxTextAttr_GetFlags 1806 -#define wxTextAttr_IsDefault 1807 -#define wxTextAttr_SetAlignment 1808 -#define wxTextAttr_SetBackgroundColour 1809 -#define wxTextAttr_SetFlags 1810 -#define wxTextAttr_SetFont 1811 -#define wxTextAttr_SetLeftIndent 1812 -#define wxTextAttr_SetRightIndent 1813 -#define wxTextAttr_SetTabs 1814 -#define wxTextAttr_SetTextColour 1815 -#define wxTextAttr_destroy 1816 -#define wxTextCtrl_new_3 1818 -#define wxTextCtrl_new_0 1819 -#define wxTextCtrl_destruct 1821 -#define wxTextCtrl_AppendText 1822 -#define wxTextCtrl_CanCopy 1823 -#define wxTextCtrl_CanCut 1824 -#define wxTextCtrl_CanPaste 1825 -#define wxTextCtrl_CanRedo 1826 -#define wxTextCtrl_CanUndo 1827 -#define wxTextCtrl_Clear 1828 -#define wxTextCtrl_Copy 1829 -#define wxTextCtrl_Create 1830 -#define wxTextCtrl_Cut 1831 -#define wxTextCtrl_DiscardEdits 1832 -#define wxTextCtrl_ChangeValue 1833 -#define wxTextCtrl_EmulateKeyPress 1834 -#define wxTextCtrl_GetDefaultStyle 1835 -#define wxTextCtrl_GetInsertionPoint 1836 -#define wxTextCtrl_GetLastPosition 1837 -#define wxTextCtrl_GetLineLength 1838 -#define wxTextCtrl_GetLineText 1839 -#define wxTextCtrl_GetNumberOfLines 1840 -#define wxTextCtrl_GetRange 1841 -#define wxTextCtrl_GetSelection 1842 -#define wxTextCtrl_GetStringSelection 1843 -#define wxTextCtrl_GetStyle 1844 -#define wxTextCtrl_GetValue 1845 -#define wxTextCtrl_IsEditable 1846 -#define wxTextCtrl_IsModified 1847 -#define wxTextCtrl_IsMultiLine 1848 -#define wxTextCtrl_IsSingleLine 1849 -#define wxTextCtrl_LoadFile 1850 -#define wxTextCtrl_MarkDirty 1851 -#define wxTextCtrl_Paste 1852 -#define wxTextCtrl_PositionToXY 1853 -#define wxTextCtrl_Redo 1854 -#define wxTextCtrl_Remove 1855 -#define wxTextCtrl_Replace 1856 -#define wxTextCtrl_SaveFile 1857 -#define wxTextCtrl_SetDefaultStyle 1858 -#define wxTextCtrl_SetEditable 1859 -#define wxTextCtrl_SetInsertionPoint 1860 -#define wxTextCtrl_SetInsertionPointEnd 1861 -#define wxTextCtrl_SetMaxLength 1863 -#define wxTextCtrl_SetSelection 1864 -#define wxTextCtrl_SetStyle 1865 -#define wxTextCtrl_SetValue 1866 -#define wxTextCtrl_ShowPosition 1867 -#define wxTextCtrl_Undo 1868 -#define wxTextCtrl_WriteText 1869 -#define wxTextCtrl_XYToPosition 1870 -#define wxNotebook_new_0 1873 -#define wxNotebook_new_3 1874 -#define wxNotebook_destruct 1875 -#define wxNotebook_AddPage 1876 -#define wxNotebook_AdvanceSelection 1877 -#define wxNotebook_AssignImageList 1878 -#define wxNotebook_Create 1879 -#define wxNotebook_DeleteAllPages 1880 -#define wxNotebook_DeletePage 1881 -#define wxNotebook_RemovePage 1882 -#define wxNotebook_GetCurrentPage 1883 -#define wxNotebook_GetImageList 1884 -#define wxNotebook_GetPage 1886 -#define wxNotebook_GetPageCount 1887 -#define wxNotebook_GetPageImage 1888 -#define wxNotebook_GetPageText 1889 -#define wxNotebook_GetRowCount 1890 -#define wxNotebook_GetSelection 1891 -#define wxNotebook_GetThemeBackgroundColour 1892 -#define wxNotebook_HitTest 1894 -#define wxNotebook_InsertPage 1896 -#define wxNotebook_SetImageList 1897 -#define wxNotebook_SetPadding 1898 -#define wxNotebook_SetPageSize 1899 -#define wxNotebook_SetPageImage 1900 -#define wxNotebook_SetPageText 1901 -#define wxNotebook_SetSelection 1902 -#define wxNotebook_ChangeSelection 1903 -#define wxChoicebook_new_0 1904 -#define wxChoicebook_new_3 1905 -#define wxChoicebook_AddPage 1906 -#define wxChoicebook_AdvanceSelection 1907 -#define wxChoicebook_AssignImageList 1908 -#define wxChoicebook_Create 1909 -#define wxChoicebook_DeleteAllPages 1910 -#define wxChoicebook_DeletePage 1911 -#define wxChoicebook_RemovePage 1912 -#define wxChoicebook_GetCurrentPage 1913 -#define wxChoicebook_GetImageList 1914 -#define wxChoicebook_GetPage 1916 -#define wxChoicebook_GetPageCount 1917 -#define wxChoicebook_GetPageImage 1918 -#define wxChoicebook_GetPageText 1919 -#define wxChoicebook_GetSelection 1920 -#define wxChoicebook_HitTest 1921 -#define wxChoicebook_InsertPage 1922 -#define wxChoicebook_SetImageList 1923 -#define wxChoicebook_SetPageSize 1924 -#define wxChoicebook_SetPageImage 1925 -#define wxChoicebook_SetPageText 1926 -#define wxChoicebook_SetSelection 1927 -#define wxChoicebook_ChangeSelection 1928 -#define wxChoicebook_destroy 1929 -#define wxToolbook_new_0 1930 -#define wxToolbook_new_3 1931 -#define wxToolbook_AddPage 1932 -#define wxToolbook_AdvanceSelection 1933 -#define wxToolbook_AssignImageList 1934 -#define wxToolbook_Create 1935 -#define wxToolbook_DeleteAllPages 1936 -#define wxToolbook_DeletePage 1937 -#define wxToolbook_RemovePage 1938 -#define wxToolbook_GetCurrentPage 1939 -#define wxToolbook_GetImageList 1940 -#define wxToolbook_GetPage 1942 -#define wxToolbook_GetPageCount 1943 -#define wxToolbook_GetPageImage 1944 -#define wxToolbook_GetPageText 1945 -#define wxToolbook_GetSelection 1946 -#define wxToolbook_HitTest 1948 -#define wxToolbook_InsertPage 1949 -#define wxToolbook_SetImageList 1950 -#define wxToolbook_SetPageSize 1951 -#define wxToolbook_SetPageImage 1952 -#define wxToolbook_SetPageText 1953 -#define wxToolbook_SetSelection 1954 -#define wxToolbook_ChangeSelection 1955 -#define wxToolbook_destroy 1956 -#define wxListbook_new_0 1957 -#define wxListbook_new_3 1958 -#define wxListbook_AddPage 1959 -#define wxListbook_AdvanceSelection 1960 -#define wxListbook_AssignImageList 1961 -#define wxListbook_Create 1962 -#define wxListbook_DeleteAllPages 1963 -#define wxListbook_DeletePage 1964 -#define wxListbook_RemovePage 1965 -#define wxListbook_GetCurrentPage 1966 -#define wxListbook_GetImageList 1967 -#define wxListbook_GetPage 1969 -#define wxListbook_GetPageCount 1970 -#define wxListbook_GetPageImage 1971 -#define wxListbook_GetPageText 1972 -#define wxListbook_GetSelection 1973 -#define wxListbook_HitTest 1975 -#define wxListbook_InsertPage 1976 -#define wxListbook_SetImageList 1977 -#define wxListbook_SetPageSize 1978 -#define wxListbook_SetPageImage 1979 -#define wxListbook_SetPageText 1980 -#define wxListbook_SetSelection 1981 -#define wxListbook_ChangeSelection 1982 -#define wxListbook_destroy 1983 -#define wxTreebook_new_0 1984 -#define wxTreebook_new_3 1985 -#define wxTreebook_AddPage 1986 -#define wxTreebook_AdvanceSelection 1987 -#define wxTreebook_AssignImageList 1988 -#define wxTreebook_Create 1989 -#define wxTreebook_DeleteAllPages 1990 -#define wxTreebook_DeletePage 1991 -#define wxTreebook_RemovePage 1992 -#define wxTreebook_GetCurrentPage 1993 -#define wxTreebook_GetImageList 1994 -#define wxTreebook_GetPage 1996 -#define wxTreebook_GetPageCount 1997 -#define wxTreebook_GetPageImage 1998 -#define wxTreebook_GetPageText 1999 -#define wxTreebook_GetSelection 2000 -#define wxTreebook_ExpandNode 2001 -#define wxTreebook_IsNodeExpanded 2002 -#define wxTreebook_HitTest 2004 -#define wxTreebook_InsertPage 2005 -#define wxTreebook_InsertSubPage 2006 -#define wxTreebook_SetImageList 2007 -#define wxTreebook_SetPageSize 2008 -#define wxTreebook_SetPageImage 2009 -#define wxTreebook_SetPageText 2010 -#define wxTreebook_SetSelection 2011 -#define wxTreebook_ChangeSelection 2012 -#define wxTreebook_destroy 2013 -#define wxTreeCtrl_new_2 2016 -#define wxTreeCtrl_new_0 2017 -#define wxTreeCtrl_destruct 2019 -#define wxTreeCtrl_AddRoot 2020 -#define wxTreeCtrl_AppendItem 2021 -#define wxTreeCtrl_AssignImageList 2022 -#define wxTreeCtrl_AssignStateImageList 2023 -#define wxTreeCtrl_Collapse 2024 -#define wxTreeCtrl_CollapseAndReset 2025 -#define wxTreeCtrl_Create 2026 -#define wxTreeCtrl_Delete 2027 -#define wxTreeCtrl_DeleteAllItems 2028 -#define wxTreeCtrl_DeleteChildren 2029 -#define wxTreeCtrl_EditLabel 2030 -#define wxTreeCtrl_EnsureVisible 2031 -#define wxTreeCtrl_Expand 2032 -#define wxTreeCtrl_GetBoundingRect 2033 -#define wxTreeCtrl_GetChildrenCount 2035 -#define wxTreeCtrl_GetCount 2036 -#define wxTreeCtrl_GetEditControl 2037 -#define wxTreeCtrl_GetFirstChild 2038 -#define wxTreeCtrl_GetNextChild 2039 -#define wxTreeCtrl_GetFirstVisibleItem 2040 -#define wxTreeCtrl_GetImageList 2041 -#define wxTreeCtrl_GetIndent 2042 -#define wxTreeCtrl_GetItemBackgroundColour 2043 -#define wxTreeCtrl_GetItemData 2044 -#define wxTreeCtrl_GetItemFont 2045 -#define wxTreeCtrl_GetItemImage_1 2046 -#define wxTreeCtrl_GetItemImage_2 2047 -#define wxTreeCtrl_GetItemText 2048 -#define wxTreeCtrl_GetItemTextColour 2049 -#define wxTreeCtrl_GetLastChild 2050 -#define wxTreeCtrl_GetNextSibling 2051 -#define wxTreeCtrl_GetNextVisible 2052 -#define wxTreeCtrl_GetItemParent 2053 -#define wxTreeCtrl_GetPrevSibling 2054 -#define wxTreeCtrl_GetPrevVisible 2055 -#define wxTreeCtrl_GetRootItem 2056 -#define wxTreeCtrl_GetSelection 2057 -#define wxTreeCtrl_GetSelections 2058 -#define wxTreeCtrl_GetStateImageList 2059 -#define wxTreeCtrl_HitTest 2060 -#define wxTreeCtrl_InsertItem 2062 -#define wxTreeCtrl_IsBold 2063 -#define wxTreeCtrl_IsExpanded 2064 -#define wxTreeCtrl_IsSelected 2065 -#define wxTreeCtrl_IsVisible 2066 -#define wxTreeCtrl_ItemHasChildren 2067 -#define wxTreeCtrl_IsTreeItemIdOk 2068 -#define wxTreeCtrl_PrependItem 2069 -#define wxTreeCtrl_ScrollTo 2070 -#define wxTreeCtrl_SelectItem_1 2071 -#define wxTreeCtrl_SelectItem_2 2072 -#define wxTreeCtrl_SetIndent 2073 -#define wxTreeCtrl_SetImageList 2074 -#define wxTreeCtrl_SetItemBackgroundColour 2075 -#define wxTreeCtrl_SetItemBold 2076 -#define wxTreeCtrl_SetItemData 2077 -#define wxTreeCtrl_SetItemDropHighlight 2078 -#define wxTreeCtrl_SetItemFont 2079 -#define wxTreeCtrl_SetItemHasChildren 2080 -#define wxTreeCtrl_SetItemImage_2 2081 -#define wxTreeCtrl_SetItemImage_3 2082 -#define wxTreeCtrl_SetItemText 2083 -#define wxTreeCtrl_SetItemTextColour 2084 -#define wxTreeCtrl_SetStateImageList 2085 -#define wxTreeCtrl_SetWindowStyle 2086 -#define wxTreeCtrl_SortChildren 2087 -#define wxTreeCtrl_Toggle 2088 -#define wxTreeCtrl_ToggleItemSelection 2089 -#define wxTreeCtrl_Unselect 2090 -#define wxTreeCtrl_UnselectAll 2091 -#define wxTreeCtrl_UnselectItem 2092 -#define wxScrollBar_new_0 2093 -#define wxScrollBar_new_3 2094 -#define wxScrollBar_destruct 2095 -#define wxScrollBar_Create 2096 -#define wxScrollBar_GetRange 2097 -#define wxScrollBar_GetPageSize 2098 -#define wxScrollBar_GetThumbPosition 2099 -#define wxScrollBar_GetThumbSize 2100 -#define wxScrollBar_SetThumbPosition 2101 -#define wxScrollBar_SetScrollbar 2102 -#define wxSpinButton_new_2 2104 -#define wxSpinButton_new_0 2105 -#define wxSpinButton_Create 2106 -#define wxSpinButton_GetMax 2107 -#define wxSpinButton_GetMin 2108 -#define wxSpinButton_GetValue 2109 -#define wxSpinButton_SetRange 2110 -#define wxSpinButton_SetValue 2111 -#define wxSpinButton_destroy 2112 -#define wxSpinCtrl_new_0 2113 -#define wxSpinCtrl_new_2 2114 -#define wxSpinCtrl_Create 2116 -#define wxSpinCtrl_SetValue_1_1 2119 -#define wxSpinCtrl_SetValue_1_0 2120 -#define wxSpinCtrl_GetValue 2122 -#define wxSpinCtrl_SetRange 2124 -#define wxSpinCtrl_SetSelection 2125 -#define wxSpinCtrl_GetMin 2127 -#define wxSpinCtrl_GetMax 2129 -#define wxSpinCtrl_destroy 2130 -#define wxStaticText_new_0 2131 -#define wxStaticText_new_4 2132 -#define wxStaticText_Create 2133 -#define wxStaticText_GetLabel 2134 -#define wxStaticText_SetLabel 2135 -#define wxStaticText_Wrap 2136 -#define wxStaticText_destroy 2137 -#define wxStaticBitmap_new_0 2138 -#define wxStaticBitmap_new_4 2139 -#define wxStaticBitmap_Create 2140 -#define wxStaticBitmap_GetBitmap 2141 -#define wxStaticBitmap_SetBitmap 2142 -#define wxStaticBitmap_destroy 2143 -#define wxRadioBox_new 2144 -#define wxRadioBox_destruct 2146 -#define wxRadioBox_Create 2147 -#define wxRadioBox_Enable_2 2148 -#define wxRadioBox_Enable_1 2149 -#define wxRadioBox_GetSelection 2150 -#define wxRadioBox_GetString 2151 -#define wxRadioBox_SetSelection 2152 -#define wxRadioBox_Show_2 2153 -#define wxRadioBox_Show_1 2154 -#define wxRadioBox_GetColumnCount 2155 -#define wxRadioBox_GetItemHelpText 2156 -#define wxRadioBox_GetItemToolTip 2157 -#define wxRadioBox_GetItemFromPoint 2159 -#define wxRadioBox_GetRowCount 2160 -#define wxRadioBox_IsItemEnabled 2161 -#define wxRadioBox_IsItemShown 2162 -#define wxRadioBox_SetItemHelpText 2163 -#define wxRadioBox_SetItemToolTip 2164 -#define wxRadioButton_new_0 2165 -#define wxRadioButton_new_4 2166 -#define wxRadioButton_Create 2167 -#define wxRadioButton_GetValue 2168 -#define wxRadioButton_SetValue 2169 -#define wxRadioButton_destroy 2170 -#define wxSlider_new_6 2172 -#define wxSlider_new_0 2173 -#define wxSlider_Create 2174 -#define wxSlider_GetLineSize 2175 -#define wxSlider_GetMax 2176 -#define wxSlider_GetMin 2177 -#define wxSlider_GetPageSize 2178 -#define wxSlider_GetThumbLength 2179 -#define wxSlider_GetValue 2180 -#define wxSlider_SetLineSize 2181 -#define wxSlider_SetPageSize 2182 -#define wxSlider_SetRange 2183 -#define wxSlider_SetThumbLength 2184 -#define wxSlider_SetValue 2185 -#define wxSlider_destroy 2186 -#define wxDialog_new_4 2188 -#define wxDialog_new_0 2189 -#define wxDialog_destruct 2191 -#define wxDialog_Create 2192 -#define wxDialog_CreateButtonSizer 2193 -#define wxDialog_CreateStdDialogButtonSizer 2194 -#define wxDialog_EndModal 2195 -#define wxDialog_GetAffirmativeId 2196 -#define wxDialog_GetReturnCode 2197 -#define wxDialog_IsModal 2198 -#define wxDialog_SetAffirmativeId 2199 -#define wxDialog_SetReturnCode 2200 -#define wxDialog_Show 2201 -#define wxDialog_ShowModal 2202 -#define wxColourDialog_new_0 2203 -#define wxColourDialog_new_2 2204 -#define wxColourDialog_destruct 2205 -#define wxColourDialog_Create 2206 -#define wxColourDialog_GetColourData 2207 -#define wxColourData_new_0 2208 -#define wxColourData_new_1 2209 -#define wxColourData_destruct 2210 -#define wxColourData_GetChooseFull 2211 -#define wxColourData_GetColour 2212 -#define wxColourData_GetCustomColour 2214 -#define wxColourData_SetChooseFull 2215 -#define wxColourData_SetColour 2216 -#define wxColourData_SetCustomColour 2217 -#define wxPalette_new_0 2218 -#define wxPalette_new_4 2219 -#define wxPalette_destruct 2221 -#define wxPalette_Create 2222 -#define wxPalette_GetColoursCount 2223 -#define wxPalette_GetPixel 2224 -#define wxPalette_GetRGB 2225 -#define wxPalette_IsOk 2226 -#define wxDirDialog_new 2230 -#define wxDirDialog_destruct 2231 -#define wxDirDialog_GetPath 2232 -#define wxDirDialog_GetMessage 2233 -#define wxDirDialog_SetMessage 2234 -#define wxDirDialog_SetPath 2235 -#define wxFileDialog_new 2239 -#define wxFileDialog_destruct 2240 -#define wxFileDialog_GetDirectory 2241 -#define wxFileDialog_GetFilename 2242 -#define wxFileDialog_GetFilenames 2243 -#define wxFileDialog_GetFilterIndex 2244 -#define wxFileDialog_GetMessage 2245 -#define wxFileDialog_GetPath 2246 -#define wxFileDialog_GetPaths 2247 -#define wxFileDialog_GetWildcard 2248 -#define wxFileDialog_SetDirectory 2249 -#define wxFileDialog_SetFilename 2250 -#define wxFileDialog_SetFilterIndex 2251 -#define wxFileDialog_SetMessage 2252 -#define wxFileDialog_SetPath 2253 -#define wxFileDialog_SetWildcard 2254 -#define wxPickerBase_SetInternalMargin 2255 -#define wxPickerBase_GetInternalMargin 2256 -#define wxPickerBase_SetTextCtrlProportion 2257 -#define wxPickerBase_SetPickerCtrlProportion 2258 -#define wxPickerBase_GetTextCtrlProportion 2259 -#define wxPickerBase_GetPickerCtrlProportion 2260 -#define wxPickerBase_HasTextCtrl 2261 -#define wxPickerBase_GetTextCtrl 2262 -#define wxPickerBase_IsTextCtrlGrowable 2263 -#define wxPickerBase_SetPickerCtrlGrowable 2264 -#define wxPickerBase_SetTextCtrlGrowable 2265 -#define wxPickerBase_IsPickerCtrlGrowable 2266 -#define wxFilePickerCtrl_new_0 2267 -#define wxFilePickerCtrl_new_3 2268 -#define wxFilePickerCtrl_Create 2269 -#define wxFilePickerCtrl_GetPath 2270 -#define wxFilePickerCtrl_SetPath 2271 -#define wxFilePickerCtrl_destroy 2272 -#define wxDirPickerCtrl_new_0 2273 -#define wxDirPickerCtrl_new_3 2274 -#define wxDirPickerCtrl_Create 2275 -#define wxDirPickerCtrl_GetPath 2276 -#define wxDirPickerCtrl_SetPath 2277 -#define wxDirPickerCtrl_destroy 2278 -#define wxColourPickerCtrl_new_0 2279 -#define wxColourPickerCtrl_new_3 2280 -#define wxColourPickerCtrl_Create 2281 -#define wxColourPickerCtrl_GetColour 2282 -#define wxColourPickerCtrl_SetColour_1_1 2283 -#define wxColourPickerCtrl_SetColour_1_0 2284 -#define wxColourPickerCtrl_destroy 2285 -#define wxDatePickerCtrl_new_0 2286 -#define wxDatePickerCtrl_new_3 2287 -#define wxDatePickerCtrl_GetRange 2288 -#define wxDatePickerCtrl_GetValue 2289 -#define wxDatePickerCtrl_SetRange 2290 -#define wxDatePickerCtrl_SetValue 2291 -#define wxDatePickerCtrl_destroy 2292 -#define wxFontPickerCtrl_new_0 2293 -#define wxFontPickerCtrl_new_3 2294 -#define wxFontPickerCtrl_Create 2295 -#define wxFontPickerCtrl_GetSelectedFont 2296 -#define wxFontPickerCtrl_SetSelectedFont 2297 -#define wxFontPickerCtrl_GetMaxPointSize 2298 -#define wxFontPickerCtrl_SetMaxPointSize 2299 -#define wxFontPickerCtrl_destroy 2300 -#define wxFindReplaceDialog_new_0 2303 -#define wxFindReplaceDialog_new_4 2304 -#define wxFindReplaceDialog_destruct 2305 -#define wxFindReplaceDialog_Create 2306 -#define wxFindReplaceDialog_GetData 2307 -#define wxFindReplaceData_new_0 2308 -#define wxFindReplaceData_new_1 2309 -#define wxFindReplaceData_GetFindString 2310 -#define wxFindReplaceData_GetReplaceString 2311 -#define wxFindReplaceData_GetFlags 2312 -#define wxFindReplaceData_SetFlags 2313 -#define wxFindReplaceData_SetFindString 2314 -#define wxFindReplaceData_SetReplaceString 2315 -#define wxFindReplaceData_destroy 2316 -#define wxMultiChoiceDialog_new_0 2317 -#define wxMultiChoiceDialog_new_5 2319 -#define wxMultiChoiceDialog_GetSelections 2320 -#define wxMultiChoiceDialog_SetSelections 2321 -#define wxMultiChoiceDialog_destroy 2322 -#define wxSingleChoiceDialog_new_0 2323 -#define wxSingleChoiceDialog_new_5 2325 -#define wxSingleChoiceDialog_GetSelection 2326 -#define wxSingleChoiceDialog_GetStringSelection 2327 -#define wxSingleChoiceDialog_SetSelection 2328 -#define wxSingleChoiceDialog_destroy 2329 -#define wxTextEntryDialog_new 2330 -#define wxTextEntryDialog_GetValue 2331 -#define wxTextEntryDialog_SetValue 2332 -#define wxTextEntryDialog_destroy 2333 -#define wxPasswordEntryDialog_new 2334 -#define wxPasswordEntryDialog_destroy 2335 -#define wxFontData_new_0 2336 -#define wxFontData_new_1 2337 -#define wxFontData_destruct 2338 -#define wxFontData_EnableEffects 2339 -#define wxFontData_GetAllowSymbols 2340 -#define wxFontData_GetColour 2341 -#define wxFontData_GetChosenFont 2342 -#define wxFontData_GetEnableEffects 2343 -#define wxFontData_GetInitialFont 2344 -#define wxFontData_GetShowHelp 2345 -#define wxFontData_SetAllowSymbols 2346 -#define wxFontData_SetChosenFont 2347 -#define wxFontData_SetColour 2348 -#define wxFontData_SetInitialFont 2349 -#define wxFontData_SetRange 2350 -#define wxFontData_SetShowHelp 2351 -#define wxFontDialog_new_0 2355 -#define wxFontDialog_new_2 2357 -#define wxFontDialog_Create 2359 -#define wxFontDialog_GetFontData 2360 -#define wxFontDialog_destroy 2362 -#define wxProgressDialog_new 2363 -#define wxProgressDialog_destruct 2364 -#define wxProgressDialog_Resume 2365 -#define wxProgressDialog_Update_2 2366 -#define wxProgressDialog_Update_0 2367 -#define wxMessageDialog_new 2368 -#define wxMessageDialog_destruct 2369 -#define wxPageSetupDialog_new 2370 -#define wxPageSetupDialog_destruct 2371 -#define wxPageSetupDialog_GetPageSetupData 2372 -#define wxPageSetupDialog_ShowModal 2373 -#define wxPageSetupDialogData_new_0 2374 -#define wxPageSetupDialogData_new_1_0 2375 -#define wxPageSetupDialogData_new_1_1 2376 -#define wxPageSetupDialogData_destruct 2377 -#define wxPageSetupDialogData_EnableHelp 2378 -#define wxPageSetupDialogData_EnableMargins 2379 -#define wxPageSetupDialogData_EnableOrientation 2380 -#define wxPageSetupDialogData_EnablePaper 2381 -#define wxPageSetupDialogData_EnablePrinter 2382 -#define wxPageSetupDialogData_GetDefaultMinMargins 2383 -#define wxPageSetupDialogData_GetEnableMargins 2384 -#define wxPageSetupDialogData_GetEnableOrientation 2385 -#define wxPageSetupDialogData_GetEnablePaper 2386 -#define wxPageSetupDialogData_GetEnablePrinter 2387 -#define wxPageSetupDialogData_GetEnableHelp 2388 -#define wxPageSetupDialogData_GetDefaultInfo 2389 -#define wxPageSetupDialogData_GetMarginTopLeft 2390 -#define wxPageSetupDialogData_GetMarginBottomRight 2391 -#define wxPageSetupDialogData_GetMinMarginTopLeft 2392 -#define wxPageSetupDialogData_GetMinMarginBottomRight 2393 -#define wxPageSetupDialogData_GetPaperId 2394 -#define wxPageSetupDialogData_GetPaperSize 2395 -#define wxPageSetupDialogData_GetPrintData 2397 -#define wxPageSetupDialogData_IsOk 2398 -#define wxPageSetupDialogData_SetDefaultInfo 2399 -#define wxPageSetupDialogData_SetDefaultMinMargins 2400 -#define wxPageSetupDialogData_SetMarginTopLeft 2401 -#define wxPageSetupDialogData_SetMarginBottomRight 2402 -#define wxPageSetupDialogData_SetMinMarginTopLeft 2403 -#define wxPageSetupDialogData_SetMinMarginBottomRight 2404 -#define wxPageSetupDialogData_SetPaperId 2405 -#define wxPageSetupDialogData_SetPaperSize_1_1 2406 -#define wxPageSetupDialogData_SetPaperSize_1_0 2407 -#define wxPageSetupDialogData_SetPrintData 2408 -#define wxPrintDialog_new_2_0 2409 -#define wxPrintDialog_new_2_1 2410 -#define wxPrintDialog_destruct 2411 -#define wxPrintDialog_GetPrintDialogData 2412 -#define wxPrintDialog_GetPrintDC 2413 -#define wxPrintDialogData_new_0 2414 -#define wxPrintDialogData_new_1_1 2415 -#define wxPrintDialogData_new_1_0 2416 -#define wxPrintDialogData_destruct 2417 -#define wxPrintDialogData_EnableHelp 2418 -#define wxPrintDialogData_EnablePageNumbers 2419 -#define wxPrintDialogData_EnablePrintToFile 2420 -#define wxPrintDialogData_EnableSelection 2421 -#define wxPrintDialogData_GetAllPages 2422 -#define wxPrintDialogData_GetCollate 2423 -#define wxPrintDialogData_GetFromPage 2424 -#define wxPrintDialogData_GetMaxPage 2425 -#define wxPrintDialogData_GetMinPage 2426 -#define wxPrintDialogData_GetNoCopies 2427 -#define wxPrintDialogData_GetPrintData 2428 -#define wxPrintDialogData_GetPrintToFile 2429 -#define wxPrintDialogData_GetSelection 2430 -#define wxPrintDialogData_GetToPage 2431 -#define wxPrintDialogData_IsOk 2432 -#define wxPrintDialogData_SetCollate 2433 -#define wxPrintDialogData_SetFromPage 2434 -#define wxPrintDialogData_SetMaxPage 2435 -#define wxPrintDialogData_SetMinPage 2436 -#define wxPrintDialogData_SetNoCopies 2437 -#define wxPrintDialogData_SetPrintData 2438 -#define wxPrintDialogData_SetPrintToFile 2439 -#define wxPrintDialogData_SetSelection 2440 -#define wxPrintDialogData_SetToPage 2441 -#define wxPrintData_new_0 2442 -#define wxPrintData_new_1 2443 -#define wxPrintData_destruct 2444 -#define wxPrintData_GetCollate 2445 -#define wxPrintData_GetBin 2446 -#define wxPrintData_GetColour 2447 -#define wxPrintData_GetDuplex 2448 -#define wxPrintData_GetNoCopies 2449 -#define wxPrintData_GetOrientation 2450 -#define wxPrintData_GetPaperId 2451 -#define wxPrintData_GetPrinterName 2452 -#define wxPrintData_GetQuality 2453 -#define wxPrintData_IsOk 2454 -#define wxPrintData_SetBin 2455 -#define wxPrintData_SetCollate 2456 -#define wxPrintData_SetColour 2457 -#define wxPrintData_SetDuplex 2458 -#define wxPrintData_SetNoCopies 2459 -#define wxPrintData_SetOrientation 2460 -#define wxPrintData_SetPaperId 2461 -#define wxPrintData_SetPrinterName 2462 -#define wxPrintData_SetQuality 2463 -#define wxPrintPreview_new_2 2466 -#define wxPrintPreview_new_3 2467 -#define wxPrintPreview_destruct 2469 -#define wxPrintPreview_GetCanvas 2470 -#define wxPrintPreview_GetCurrentPage 2471 -#define wxPrintPreview_GetFrame 2472 -#define wxPrintPreview_GetMaxPage 2473 -#define wxPrintPreview_GetMinPage 2474 -#define wxPrintPreview_GetPrintout 2475 -#define wxPrintPreview_GetPrintoutForPrinting 2476 -#define wxPrintPreview_IsOk 2477 -#define wxPrintPreview_PaintPage 2478 -#define wxPrintPreview_Print 2479 -#define wxPrintPreview_RenderPage 2480 -#define wxPrintPreview_SetCanvas 2481 -#define wxPrintPreview_SetCurrentPage 2482 -#define wxPrintPreview_SetFrame 2483 -#define wxPrintPreview_SetPrintout 2484 -#define wxPrintPreview_SetZoom 2485 -#define wxPreviewFrame_new 2486 -#define wxPreviewFrame_destruct 2487 -#define wxPreviewFrame_CreateControlBar 2488 -#define wxPreviewFrame_CreateCanvas 2489 -#define wxPreviewFrame_Initialize 2490 -#define wxPreviewFrame_OnCloseWindow 2491 -#define wxPreviewControlBar_new 2492 -#define wxPreviewControlBar_destruct 2493 -#define wxPreviewControlBar_CreateButtons 2494 -#define wxPreviewControlBar_GetPrintPreview 2495 -#define wxPreviewControlBar_GetZoomControl 2496 -#define wxPreviewControlBar_SetZoomControl 2497 -#define wxPrinter_new 2499 -#define wxPrinter_CreateAbortWindow 2500 -#define wxPrinter_GetAbort 2501 -#define wxPrinter_GetLastError 2502 -#define wxPrinter_GetPrintDialogData 2503 -#define wxPrinter_Print 2504 -#define wxPrinter_PrintDialog 2505 -#define wxPrinter_ReportError 2506 -#define wxPrinter_Setup 2507 -#define wxPrinter_destroy 2508 -#define wxXmlResource_new_1 2509 -#define wxXmlResource_new_2 2510 -#define wxXmlResource_destruct 2511 -#define wxXmlResource_AttachUnknownControl 2512 -#define wxXmlResource_ClearHandlers 2513 -#define wxXmlResource_CompareVersion 2514 -#define wxXmlResource_Get 2515 -#define wxXmlResource_GetFlags 2516 -#define wxXmlResource_GetVersion 2517 -#define wxXmlResource_GetXRCID 2518 -#define wxXmlResource_InitAllHandlers 2519 -#define wxXmlResource_Load 2520 -#define wxXmlResource_LoadBitmap 2521 -#define wxXmlResource_LoadDialog_2 2522 -#define wxXmlResource_LoadDialog_3 2523 -#define wxXmlResource_LoadFrame_2 2524 -#define wxXmlResource_LoadFrame_3 2525 -#define wxXmlResource_LoadIcon 2526 -#define wxXmlResource_LoadMenu 2527 -#define wxXmlResource_LoadMenuBar_2 2528 -#define wxXmlResource_LoadMenuBar_1 2529 -#define wxXmlResource_LoadPanel_2 2530 -#define wxXmlResource_LoadPanel_3 2531 -#define wxXmlResource_LoadToolBar 2532 -#define wxXmlResource_Set 2533 -#define wxXmlResource_SetFlags 2534 -#define wxXmlResource_Unload 2535 -#define wxXmlResource_xrcctrl 2536 -#define wxHtmlEasyPrinting_new 2537 -#define wxHtmlEasyPrinting_destruct 2538 -#define wxHtmlEasyPrinting_GetPrintData 2539 -#define wxHtmlEasyPrinting_GetPageSetupData 2540 -#define wxHtmlEasyPrinting_PreviewFile 2541 -#define wxHtmlEasyPrinting_PreviewText 2542 -#define wxHtmlEasyPrinting_PrintFile 2543 -#define wxHtmlEasyPrinting_PrintText 2544 -#define wxHtmlEasyPrinting_PageSetup 2545 -#define wxHtmlEasyPrinting_SetFonts 2546 -#define wxHtmlEasyPrinting_SetHeader 2547 -#define wxHtmlEasyPrinting_SetFooter 2548 -#define wxGLCanvas_new_2 2550 -#define wxGLCanvas_new_3_1 2551 -#define wxGLCanvas_new_3_0 2552 -#define wxGLCanvas_GetContext 2553 -#define wxGLCanvas_SetCurrent 2555 -#define wxGLCanvas_SwapBuffers 2556 -#define wxGLCanvas_destroy 2557 -#define wxAuiManager_new 2558 -#define wxAuiManager_destruct 2559 -#define wxAuiManager_AddPane_2_1 2560 -#define wxAuiManager_AddPane_3 2561 -#define wxAuiManager_AddPane_2_0 2562 -#define wxAuiManager_DetachPane 2563 -#define wxAuiManager_GetAllPanes 2564 -#define wxAuiManager_GetArtProvider 2565 -#define wxAuiManager_GetDockSizeConstraint 2566 -#define wxAuiManager_GetFlags 2567 -#define wxAuiManager_GetManagedWindow 2568 -#define wxAuiManager_GetManager 2569 -#define wxAuiManager_GetPane_1_1 2570 -#define wxAuiManager_GetPane_1_0 2571 -#define wxAuiManager_HideHint 2572 -#define wxAuiManager_InsertPane 2573 -#define wxAuiManager_LoadPaneInfo 2574 -#define wxAuiManager_LoadPerspective 2575 -#define wxAuiManager_SavePaneInfo 2576 -#define wxAuiManager_SavePerspective 2577 -#define wxAuiManager_SetArtProvider 2578 -#define wxAuiManager_SetDockSizeConstraint 2579 -#define wxAuiManager_SetFlags 2580 -#define wxAuiManager_SetManagedWindow 2581 -#define wxAuiManager_ShowHint 2582 -#define wxAuiManager_UnInit 2583 -#define wxAuiManager_Update 2584 -#define wxAuiPaneInfo_new_0 2585 -#define wxAuiPaneInfo_new_1 2586 -#define wxAuiPaneInfo_destruct 2587 -#define wxAuiPaneInfo_BestSize_1 2588 -#define wxAuiPaneInfo_BestSize_2 2589 -#define wxAuiPaneInfo_Bottom 2590 -#define wxAuiPaneInfo_BottomDockable 2591 -#define wxAuiPaneInfo_Caption 2592 -#define wxAuiPaneInfo_CaptionVisible 2593 -#define wxAuiPaneInfo_Centre 2594 -#define wxAuiPaneInfo_CentrePane 2595 -#define wxAuiPaneInfo_CloseButton 2596 -#define wxAuiPaneInfo_DefaultPane 2597 -#define wxAuiPaneInfo_DestroyOnClose 2598 -#define wxAuiPaneInfo_Direction 2599 -#define wxAuiPaneInfo_Dock 2600 -#define wxAuiPaneInfo_Dockable 2601 -#define wxAuiPaneInfo_Fixed 2602 -#define wxAuiPaneInfo_Float 2603 -#define wxAuiPaneInfo_Floatable 2604 -#define wxAuiPaneInfo_FloatingPosition_1 2605 -#define wxAuiPaneInfo_FloatingPosition_2 2606 -#define wxAuiPaneInfo_FloatingSize_1 2607 -#define wxAuiPaneInfo_FloatingSize_2 2608 -#define wxAuiPaneInfo_Gripper 2609 -#define wxAuiPaneInfo_GripperTop 2610 -#define wxAuiPaneInfo_HasBorder 2611 -#define wxAuiPaneInfo_HasCaption 2612 -#define wxAuiPaneInfo_HasCloseButton 2613 -#define wxAuiPaneInfo_HasFlag 2614 -#define wxAuiPaneInfo_HasGripper 2615 -#define wxAuiPaneInfo_HasGripperTop 2616 -#define wxAuiPaneInfo_HasMaximizeButton 2617 -#define wxAuiPaneInfo_HasMinimizeButton 2618 -#define wxAuiPaneInfo_HasPinButton 2619 -#define wxAuiPaneInfo_Hide 2620 -#define wxAuiPaneInfo_IsBottomDockable 2621 -#define wxAuiPaneInfo_IsDocked 2622 -#define wxAuiPaneInfo_IsFixed 2623 -#define wxAuiPaneInfo_IsFloatable 2624 -#define wxAuiPaneInfo_IsFloating 2625 -#define wxAuiPaneInfo_IsLeftDockable 2626 -#define wxAuiPaneInfo_IsMovable 2627 -#define wxAuiPaneInfo_IsOk 2628 -#define wxAuiPaneInfo_IsResizable 2629 -#define wxAuiPaneInfo_IsRightDockable 2630 -#define wxAuiPaneInfo_IsShown 2631 -#define wxAuiPaneInfo_IsToolbar 2632 -#define wxAuiPaneInfo_IsTopDockable 2633 -#define wxAuiPaneInfo_Layer 2634 -#define wxAuiPaneInfo_Left 2635 -#define wxAuiPaneInfo_LeftDockable 2636 -#define wxAuiPaneInfo_MaxSize_1 2637 -#define wxAuiPaneInfo_MaxSize_2 2638 -#define wxAuiPaneInfo_MaximizeButton 2639 -#define wxAuiPaneInfo_MinSize_1 2640 -#define wxAuiPaneInfo_MinSize_2 2641 -#define wxAuiPaneInfo_MinimizeButton 2642 -#define wxAuiPaneInfo_Movable 2643 -#define wxAuiPaneInfo_Name 2644 -#define wxAuiPaneInfo_PaneBorder 2645 -#define wxAuiPaneInfo_PinButton 2646 -#define wxAuiPaneInfo_Position 2647 -#define wxAuiPaneInfo_Resizable 2648 -#define wxAuiPaneInfo_Right 2649 -#define wxAuiPaneInfo_RightDockable 2650 -#define wxAuiPaneInfo_Row 2651 -#define wxAuiPaneInfo_SafeSet 2652 -#define wxAuiPaneInfo_SetFlag 2653 -#define wxAuiPaneInfo_Show 2654 -#define wxAuiPaneInfo_ToolbarPane 2655 -#define wxAuiPaneInfo_Top 2656 -#define wxAuiPaneInfo_TopDockable 2657 -#define wxAuiPaneInfo_Window 2658 -#define wxAuiPaneInfo_GetWindow 2659 -#define wxAuiPaneInfo_GetFrame 2660 -#define wxAuiPaneInfo_GetDirection 2661 -#define wxAuiPaneInfo_GetLayer 2662 -#define wxAuiPaneInfo_GetRow 2663 -#define wxAuiPaneInfo_GetPosition 2664 -#define wxAuiPaneInfo_GetFloatingPosition 2665 -#define wxAuiPaneInfo_GetFloatingSize 2666 -#define wxAuiNotebook_new_0 2667 -#define wxAuiNotebook_new_2 2668 -#define wxAuiNotebook_AddPage 2669 -#define wxAuiNotebook_Create 2670 -#define wxAuiNotebook_DeletePage 2671 -#define wxAuiNotebook_GetArtProvider 2672 -#define wxAuiNotebook_GetPage 2673 -#define wxAuiNotebook_GetPageBitmap 2674 -#define wxAuiNotebook_GetPageCount 2675 -#define wxAuiNotebook_GetPageIndex 2676 -#define wxAuiNotebook_GetPageText 2677 -#define wxAuiNotebook_GetSelection 2678 -#define wxAuiNotebook_InsertPage 2679 -#define wxAuiNotebook_RemovePage 2680 -#define wxAuiNotebook_SetArtProvider 2681 -#define wxAuiNotebook_SetFont 2682 -#define wxAuiNotebook_SetPageBitmap 2683 -#define wxAuiNotebook_SetPageText 2684 -#define wxAuiNotebook_SetSelection 2685 -#define wxAuiNotebook_SetTabCtrlHeight 2686 -#define wxAuiNotebook_SetUniformBitmapSize 2687 -#define wxAuiNotebook_destroy 2688 -#define wxAuiTabArt_SetFlags 2689 -#define wxAuiTabArt_SetMeasuringFont 2690 -#define wxAuiTabArt_SetNormalFont 2691 -#define wxAuiTabArt_SetSelectedFont 2692 -#define wxAuiTabArt_SetColour 2693 -#define wxAuiTabArt_SetActiveColour 2694 -#define wxAuiDockArt_GetColour 2695 -#define wxAuiDockArt_GetFont 2696 -#define wxAuiDockArt_GetMetric 2697 -#define wxAuiDockArt_SetColour 2698 -#define wxAuiDockArt_SetFont 2699 -#define wxAuiDockArt_SetMetric 2700 -#define wxAuiSimpleTabArt_new 2701 -#define wxAuiSimpleTabArt_destroy 2702 -#define wxMDIParentFrame_new_0 2703 -#define wxMDIParentFrame_new_4 2704 -#define wxMDIParentFrame_destruct 2705 -#define wxMDIParentFrame_ActivateNext 2706 -#define wxMDIParentFrame_ActivatePrevious 2707 -#define wxMDIParentFrame_ArrangeIcons 2708 -#define wxMDIParentFrame_Cascade 2709 -#define wxMDIParentFrame_Create 2710 -#define wxMDIParentFrame_GetActiveChild 2711 -#define wxMDIParentFrame_GetClientWindow 2712 -#define wxMDIParentFrame_Tile 2713 -#define wxMDIChildFrame_new_0 2714 -#define wxMDIChildFrame_new_4 2715 -#define wxMDIChildFrame_destruct 2716 -#define wxMDIChildFrame_Activate 2717 -#define wxMDIChildFrame_Create 2718 -#define wxMDIChildFrame_Maximize 2719 -#define wxMDIChildFrame_Restore 2720 -#define wxMDIClientWindow_new_0 2721 -#define wxMDIClientWindow_new_2 2722 -#define wxMDIClientWindow_destruct 2723 -#define wxMDIClientWindow_CreateClient 2724 -#define wxLayoutAlgorithm_new 2725 -#define wxLayoutAlgorithm_LayoutFrame 2726 -#define wxLayoutAlgorithm_LayoutMDIFrame 2727 -#define wxLayoutAlgorithm_LayoutWindow 2728 -#define wxLayoutAlgorithm_destroy 2729 -#define wxEvent_GetId 2730 -#define wxEvent_GetSkipped 2731 -#define wxEvent_GetTimestamp 2732 -#define wxEvent_IsCommandEvent 2733 -#define wxEvent_ResumePropagation 2734 -#define wxEvent_ShouldPropagate 2735 -#define wxEvent_Skip 2736 -#define wxEvent_StopPropagation 2737 -#define wxCommandEvent_getClientData 2738 -#define wxCommandEvent_GetExtraLong 2739 -#define wxCommandEvent_GetInt 2740 -#define wxCommandEvent_GetSelection 2741 -#define wxCommandEvent_GetString 2742 -#define wxCommandEvent_IsChecked 2743 -#define wxCommandEvent_IsSelection 2744 -#define wxCommandEvent_SetInt 2745 -#define wxCommandEvent_SetString 2746 -#define wxScrollEvent_GetOrientation 2747 -#define wxScrollEvent_GetPosition 2748 -#define wxScrollWinEvent_GetOrientation 2749 -#define wxScrollWinEvent_GetPosition 2750 -#define wxMouseEvent_AltDown 2751 -#define wxMouseEvent_Button 2752 -#define wxMouseEvent_ButtonDClick 2753 -#define wxMouseEvent_ButtonDown 2754 -#define wxMouseEvent_ButtonUp 2755 -#define wxMouseEvent_CmdDown 2756 -#define wxMouseEvent_ControlDown 2757 -#define wxMouseEvent_Dragging 2758 -#define wxMouseEvent_Entering 2759 -#define wxMouseEvent_GetButton 2760 -#define wxMouseEvent_GetPosition 2763 -#define wxMouseEvent_GetLogicalPosition 2764 -#define wxMouseEvent_GetLinesPerAction 2765 -#define wxMouseEvent_GetWheelRotation 2766 -#define wxMouseEvent_GetWheelDelta 2767 -#define wxMouseEvent_GetX 2768 -#define wxMouseEvent_GetY 2769 -#define wxMouseEvent_IsButton 2770 -#define wxMouseEvent_IsPageScroll 2771 -#define wxMouseEvent_Leaving 2772 -#define wxMouseEvent_LeftDClick 2773 -#define wxMouseEvent_LeftDown 2774 -#define wxMouseEvent_LeftIsDown 2775 -#define wxMouseEvent_LeftUp 2776 -#define wxMouseEvent_MetaDown 2777 -#define wxMouseEvent_MiddleDClick 2778 -#define wxMouseEvent_MiddleDown 2779 -#define wxMouseEvent_MiddleIsDown 2780 -#define wxMouseEvent_MiddleUp 2781 -#define wxMouseEvent_Moving 2782 -#define wxMouseEvent_RightDClick 2783 -#define wxMouseEvent_RightDown 2784 -#define wxMouseEvent_RightIsDown 2785 -#define wxMouseEvent_RightUp 2786 -#define wxMouseEvent_ShiftDown 2787 -#define wxSetCursorEvent_GetCursor 2788 -#define wxSetCursorEvent_GetX 2789 -#define wxSetCursorEvent_GetY 2790 -#define wxSetCursorEvent_HasCursor 2791 -#define wxSetCursorEvent_SetCursor 2792 -#define wxKeyEvent_AltDown 2793 -#define wxKeyEvent_CmdDown 2794 -#define wxKeyEvent_ControlDown 2795 -#define wxKeyEvent_GetKeyCode 2796 -#define wxKeyEvent_GetModifiers 2797 -#define wxKeyEvent_GetPosition 2800 -#define wxKeyEvent_GetRawKeyCode 2801 -#define wxKeyEvent_GetRawKeyFlags 2802 -#define wxKeyEvent_GetUnicodeKey 2803 -#define wxKeyEvent_GetX 2804 -#define wxKeyEvent_GetY 2805 -#define wxKeyEvent_HasModifiers 2806 -#define wxKeyEvent_MetaDown 2807 -#define wxKeyEvent_ShiftDown 2808 -#define wxSizeEvent_GetSize 2809 -#define wxMoveEvent_GetPosition 2810 -#define wxEraseEvent_GetDC 2811 -#define wxFocusEvent_GetWindow 2812 -#define wxChildFocusEvent_GetWindow 2813 -#define wxMenuEvent_GetMenu 2814 -#define wxMenuEvent_GetMenuId 2815 -#define wxMenuEvent_IsPopup 2816 -#define wxCloseEvent_CanVeto 2817 -#define wxCloseEvent_GetLoggingOff 2818 -#define wxCloseEvent_SetCanVeto 2819 -#define wxCloseEvent_SetLoggingOff 2820 -#define wxCloseEvent_Veto 2821 -#define wxShowEvent_SetShow 2822 -#define wxShowEvent_GetShow 2823 -#define wxIconizeEvent_Iconized 2824 -#define wxJoystickEvent_ButtonDown 2825 -#define wxJoystickEvent_ButtonIsDown 2826 -#define wxJoystickEvent_ButtonUp 2827 -#define wxJoystickEvent_GetButtonChange 2828 -#define wxJoystickEvent_GetButtonState 2829 -#define wxJoystickEvent_GetJoystick 2830 -#define wxJoystickEvent_GetPosition 2831 -#define wxJoystickEvent_GetZPosition 2832 -#define wxJoystickEvent_IsButton 2833 -#define wxJoystickEvent_IsMove 2834 -#define wxJoystickEvent_IsZMove 2835 -#define wxUpdateUIEvent_CanUpdate 2836 -#define wxUpdateUIEvent_Check 2837 -#define wxUpdateUIEvent_Enable 2838 -#define wxUpdateUIEvent_Show 2839 -#define wxUpdateUIEvent_GetChecked 2840 -#define wxUpdateUIEvent_GetEnabled 2841 -#define wxUpdateUIEvent_GetShown 2842 -#define wxUpdateUIEvent_GetSetChecked 2843 -#define wxUpdateUIEvent_GetSetEnabled 2844 -#define wxUpdateUIEvent_GetSetShown 2845 -#define wxUpdateUIEvent_GetSetText 2846 -#define wxUpdateUIEvent_GetText 2847 -#define wxUpdateUIEvent_GetMode 2848 -#define wxUpdateUIEvent_GetUpdateInterval 2849 -#define wxUpdateUIEvent_ResetUpdateTime 2850 -#define wxUpdateUIEvent_SetMode 2851 -#define wxUpdateUIEvent_SetText 2852 -#define wxUpdateUIEvent_SetUpdateInterval 2853 -#define wxMouseCaptureChangedEvent_GetCapturedWindow 2854 -#define wxPaletteChangedEvent_SetChangedWindow 2855 -#define wxPaletteChangedEvent_GetChangedWindow 2856 -#define wxQueryNewPaletteEvent_SetPaletteRealized 2857 -#define wxQueryNewPaletteEvent_GetPaletteRealized 2858 -#define wxNavigationKeyEvent_GetDirection 2859 -#define wxNavigationKeyEvent_SetDirection 2860 -#define wxNavigationKeyEvent_IsWindowChange 2861 -#define wxNavigationKeyEvent_SetWindowChange 2862 -#define wxNavigationKeyEvent_IsFromTab 2863 -#define wxNavigationKeyEvent_SetFromTab 2864 -#define wxNavigationKeyEvent_GetCurrentFocus 2865 -#define wxNavigationKeyEvent_SetCurrentFocus 2866 -#define wxHelpEvent_GetOrigin 2867 -#define wxHelpEvent_GetPosition 2868 -#define wxHelpEvent_SetOrigin 2869 -#define wxHelpEvent_SetPosition 2870 -#define wxContextMenuEvent_GetPosition 2871 -#define wxContextMenuEvent_SetPosition 2872 -#define wxIdleEvent_CanSend 2873 -#define wxIdleEvent_GetMode 2874 -#define wxIdleEvent_RequestMore 2875 -#define wxIdleEvent_MoreRequested 2876 -#define wxIdleEvent_SetMode 2877 -#define wxGridEvent_AltDown 2878 -#define wxGridEvent_ControlDown 2879 -#define wxGridEvent_GetCol 2880 -#define wxGridEvent_GetPosition 2881 -#define wxGridEvent_GetRow 2882 -#define wxGridEvent_MetaDown 2883 -#define wxGridEvent_Selecting 2884 -#define wxGridEvent_ShiftDown 2885 -#define wxNotifyEvent_Allow 2886 -#define wxNotifyEvent_IsAllowed 2887 -#define wxNotifyEvent_Veto 2888 -#define wxSashEvent_GetEdge 2889 -#define wxSashEvent_GetDragRect 2890 -#define wxSashEvent_GetDragStatus 2891 -#define wxListEvent_GetCacheFrom 2892 -#define wxListEvent_GetCacheTo 2893 -#define wxListEvent_GetKeyCode 2894 -#define wxListEvent_GetIndex 2895 -#define wxListEvent_GetColumn 2896 -#define wxListEvent_GetPoint 2897 -#define wxListEvent_GetLabel 2898 -#define wxListEvent_GetText 2899 -#define wxListEvent_GetImage 2900 -#define wxListEvent_GetData 2901 -#define wxListEvent_GetMask 2902 -#define wxListEvent_GetItem 2903 -#define wxListEvent_IsEditCancelled 2904 -#define wxDateEvent_GetDate 2905 -#define wxCalendarEvent_GetWeekDay 2906 -#define wxFileDirPickerEvent_GetPath 2907 -#define wxColourPickerEvent_GetColour 2908 -#define wxFontPickerEvent_GetFont 2909 -#define wxStyledTextEvent_GetPosition 2910 -#define wxStyledTextEvent_GetKey 2911 -#define wxStyledTextEvent_GetModifiers 2912 -#define wxStyledTextEvent_GetModificationType 2913 -#define wxStyledTextEvent_GetText 2914 -#define wxStyledTextEvent_GetLength 2915 -#define wxStyledTextEvent_GetLinesAdded 2916 -#define wxStyledTextEvent_GetLine 2917 -#define wxStyledTextEvent_GetFoldLevelNow 2918 -#define wxStyledTextEvent_GetFoldLevelPrev 2919 -#define wxStyledTextEvent_GetMargin 2920 -#define wxStyledTextEvent_GetMessage 2921 -#define wxStyledTextEvent_GetWParam 2922 -#define wxStyledTextEvent_GetLParam 2923 -#define wxStyledTextEvent_GetListType 2924 -#define wxStyledTextEvent_GetX 2925 -#define wxStyledTextEvent_GetY 2926 -#define wxStyledTextEvent_GetDragText 2927 -#define wxStyledTextEvent_GetDragAllowMove 2928 -#define wxStyledTextEvent_GetDragResult 2929 -#define wxStyledTextEvent_GetShift 2930 -#define wxStyledTextEvent_GetControl 2931 -#define wxStyledTextEvent_GetAlt 2932 -#define utils_wxGetKeyState 2933 -#define utils_wxGetMousePosition 2934 -#define utils_wxGetMouseState 2935 -#define utils_wxSetDetectableAutoRepeat 2936 -#define utils_wxBell 2937 -#define utils_wxFindMenuItemId 2938 -#define utils_wxGenericFindWindowAtPoint 2939 -#define utils_wxFindWindowAtPoint 2940 -#define utils_wxBeginBusyCursor 2941 -#define utils_wxEndBusyCursor 2942 -#define utils_wxIsBusy 2943 -#define utils_wxShutdown 2944 -#define utils_wxShell 2945 -#define utils_wxLaunchDefaultBrowser 2946 -#define utils_wxGetEmailAddress 2947 -#define utils_wxGetUserId 2948 -#define utils_wxGetHomeDir 2949 -#define utils_wxNewId 2950 -#define utils_wxRegisterId 2951 -#define utils_wxGetCurrentId 2952 -#define utils_wxGetOsDescription 2953 -#define utils_wxIsPlatformLittleEndian 2954 -#define utils_wxIsPlatform64Bit 2955 -#define gdicmn_wxDisplaySize 2956 -#define gdicmn_wxSetCursor 2957 -#define wxPrintout_new 2958 -#define wxPrintout_destruct 2959 -#define wxPrintout_GetDC 2960 -#define wxPrintout_GetPageSizeMM 2961 -#define wxPrintout_GetPageSizePixels 2962 -#define wxPrintout_GetPaperRectPixels 2963 -#define wxPrintout_GetPPIPrinter 2964 -#define wxPrintout_GetPPIScreen 2965 -#define wxPrintout_GetTitle 2966 -#define wxPrintout_IsPreview 2967 -#define wxPrintout_FitThisSizeToPaper 2968 -#define wxPrintout_FitThisSizeToPage 2969 -#define wxPrintout_FitThisSizeToPageMargins 2970 -#define wxPrintout_MapScreenSizeToPaper 2971 -#define wxPrintout_MapScreenSizeToPage 2972 -#define wxPrintout_MapScreenSizeToPageMargins 2973 -#define wxPrintout_MapScreenSizeToDevice 2974 -#define wxPrintout_GetLogicalPaperRect 2975 -#define wxPrintout_GetLogicalPageRect 2976 -#define wxPrintout_GetLogicalPageMarginsRect 2977 -#define wxPrintout_SetLogicalOrigin 2978 -#define wxPrintout_OffsetLogicalOrigin 2979 -#define wxStyledTextCtrl_new_2 2980 -#define wxStyledTextCtrl_new_0 2981 -#define wxStyledTextCtrl_destruct 2982 -#define wxStyledTextCtrl_Create 2983 -#define wxStyledTextCtrl_AddText 2984 -#define wxStyledTextCtrl_AddStyledText 2985 -#define wxStyledTextCtrl_InsertText 2986 -#define wxStyledTextCtrl_ClearAll 2987 -#define wxStyledTextCtrl_ClearDocumentStyle 2988 -#define wxStyledTextCtrl_GetLength 2989 -#define wxStyledTextCtrl_GetCharAt 2990 -#define wxStyledTextCtrl_GetCurrentPos 2991 -#define wxStyledTextCtrl_GetAnchor 2992 -#define wxStyledTextCtrl_GetStyleAt 2993 -#define wxStyledTextCtrl_Redo 2994 -#define wxStyledTextCtrl_SetUndoCollection 2995 -#define wxStyledTextCtrl_SelectAll 2996 -#define wxStyledTextCtrl_SetSavePoint 2997 -#define wxStyledTextCtrl_GetStyledText 2998 -#define wxStyledTextCtrl_CanRedo 2999 -#define wxStyledTextCtrl_MarkerLineFromHandle 3000 -#define wxStyledTextCtrl_MarkerDeleteHandle 3001 -#define wxStyledTextCtrl_GetUndoCollection 3002 -#define wxStyledTextCtrl_GetViewWhiteSpace 3003 -#define wxStyledTextCtrl_SetViewWhiteSpace 3004 -#define wxStyledTextCtrl_PositionFromPoint 3005 -#define wxStyledTextCtrl_PositionFromPointClose 3006 -#define wxStyledTextCtrl_GotoLine 3007 -#define wxStyledTextCtrl_GotoPos 3008 -#define wxStyledTextCtrl_SetAnchor 3009 -#define wxStyledTextCtrl_GetCurLine 3010 -#define wxStyledTextCtrl_GetEndStyled 3011 -#define wxStyledTextCtrl_ConvertEOLs 3012 -#define wxStyledTextCtrl_GetEOLMode 3013 -#define wxStyledTextCtrl_SetEOLMode 3014 -#define wxStyledTextCtrl_StartStyling 3015 -#define wxStyledTextCtrl_SetStyling 3016 -#define wxStyledTextCtrl_GetBufferedDraw 3017 -#define wxStyledTextCtrl_SetBufferedDraw 3018 -#define wxStyledTextCtrl_SetTabWidth 3019 -#define wxStyledTextCtrl_GetTabWidth 3020 -#define wxStyledTextCtrl_SetCodePage 3021 -#define wxStyledTextCtrl_MarkerDefine 3022 -#define wxStyledTextCtrl_MarkerSetForeground 3023 -#define wxStyledTextCtrl_MarkerSetBackground 3024 -#define wxStyledTextCtrl_MarkerAdd 3025 -#define wxStyledTextCtrl_MarkerDelete 3026 -#define wxStyledTextCtrl_MarkerDeleteAll 3027 -#define wxStyledTextCtrl_MarkerGet 3028 -#define wxStyledTextCtrl_MarkerNext 3029 -#define wxStyledTextCtrl_MarkerPrevious 3030 -#define wxStyledTextCtrl_MarkerDefineBitmap 3031 -#define wxStyledTextCtrl_MarkerAddSet 3032 -#define wxStyledTextCtrl_MarkerSetAlpha 3033 -#define wxStyledTextCtrl_SetMarginType 3034 -#define wxStyledTextCtrl_GetMarginType 3035 -#define wxStyledTextCtrl_SetMarginWidth 3036 -#define wxStyledTextCtrl_GetMarginWidth 3037 -#define wxStyledTextCtrl_SetMarginMask 3038 -#define wxStyledTextCtrl_GetMarginMask 3039 -#define wxStyledTextCtrl_SetMarginSensitive 3040 -#define wxStyledTextCtrl_GetMarginSensitive 3041 -#define wxStyledTextCtrl_StyleClearAll 3042 -#define wxStyledTextCtrl_StyleSetForeground 3043 -#define wxStyledTextCtrl_StyleSetBackground 3044 -#define wxStyledTextCtrl_StyleSetBold 3045 -#define wxStyledTextCtrl_StyleSetItalic 3046 -#define wxStyledTextCtrl_StyleSetSize 3047 -#define wxStyledTextCtrl_StyleSetFaceName 3048 -#define wxStyledTextCtrl_StyleSetEOLFilled 3049 -#define wxStyledTextCtrl_StyleResetDefault 3050 -#define wxStyledTextCtrl_StyleSetUnderline 3051 -#define wxStyledTextCtrl_StyleSetCase 3052 -#define wxStyledTextCtrl_StyleSetHotSpot 3053 -#define wxStyledTextCtrl_SetSelForeground 3054 -#define wxStyledTextCtrl_SetSelBackground 3055 -#define wxStyledTextCtrl_GetSelAlpha 3056 -#define wxStyledTextCtrl_SetSelAlpha 3057 -#define wxStyledTextCtrl_SetCaretForeground 3058 -#define wxStyledTextCtrl_CmdKeyAssign 3059 -#define wxStyledTextCtrl_CmdKeyClear 3060 -#define wxStyledTextCtrl_CmdKeyClearAll 3061 -#define wxStyledTextCtrl_SetStyleBytes 3062 -#define wxStyledTextCtrl_StyleSetVisible 3063 -#define wxStyledTextCtrl_GetCaretPeriod 3064 -#define wxStyledTextCtrl_SetCaretPeriod 3065 -#define wxStyledTextCtrl_SetWordChars 3066 -#define wxStyledTextCtrl_BeginUndoAction 3067 -#define wxStyledTextCtrl_EndUndoAction 3068 -#define wxStyledTextCtrl_IndicatorSetStyle 3069 -#define wxStyledTextCtrl_IndicatorGetStyle 3070 -#define wxStyledTextCtrl_IndicatorSetForeground 3071 -#define wxStyledTextCtrl_IndicatorGetForeground 3072 -#define wxStyledTextCtrl_SetWhitespaceForeground 3073 -#define wxStyledTextCtrl_SetWhitespaceBackground 3074 -#define wxStyledTextCtrl_GetStyleBits 3075 -#define wxStyledTextCtrl_SetLineState 3076 -#define wxStyledTextCtrl_GetLineState 3077 -#define wxStyledTextCtrl_GetMaxLineState 3078 -#define wxStyledTextCtrl_GetCaretLineVisible 3079 -#define wxStyledTextCtrl_SetCaretLineVisible 3080 -#define wxStyledTextCtrl_GetCaretLineBackground 3081 -#define wxStyledTextCtrl_SetCaretLineBackground 3082 -#define wxStyledTextCtrl_AutoCompShow 3083 -#define wxStyledTextCtrl_AutoCompCancel 3084 -#define wxStyledTextCtrl_AutoCompActive 3085 -#define wxStyledTextCtrl_AutoCompPosStart 3086 -#define wxStyledTextCtrl_AutoCompComplete 3087 -#define wxStyledTextCtrl_AutoCompStops 3088 -#define wxStyledTextCtrl_AutoCompSetSeparator 3089 -#define wxStyledTextCtrl_AutoCompGetSeparator 3090 -#define wxStyledTextCtrl_AutoCompSelect 3091 -#define wxStyledTextCtrl_AutoCompSetCancelAtStart 3092 -#define wxStyledTextCtrl_AutoCompGetCancelAtStart 3093 -#define wxStyledTextCtrl_AutoCompSetFillUps 3094 -#define wxStyledTextCtrl_AutoCompSetChooseSingle 3095 -#define wxStyledTextCtrl_AutoCompGetChooseSingle 3096 -#define wxStyledTextCtrl_AutoCompSetIgnoreCase 3097 -#define wxStyledTextCtrl_AutoCompGetIgnoreCase 3098 -#define wxStyledTextCtrl_UserListShow 3099 -#define wxStyledTextCtrl_AutoCompSetAutoHide 3100 -#define wxStyledTextCtrl_AutoCompGetAutoHide 3101 -#define wxStyledTextCtrl_AutoCompSetDropRestOfWord 3102 -#define wxStyledTextCtrl_AutoCompGetDropRestOfWord 3103 -#define wxStyledTextCtrl_RegisterImage 3104 -#define wxStyledTextCtrl_ClearRegisteredImages 3105 -#define wxStyledTextCtrl_AutoCompGetTypeSeparator 3106 -#define wxStyledTextCtrl_AutoCompSetTypeSeparator 3107 -#define wxStyledTextCtrl_AutoCompSetMaxWidth 3108 -#define wxStyledTextCtrl_AutoCompGetMaxWidth 3109 -#define wxStyledTextCtrl_AutoCompSetMaxHeight 3110 -#define wxStyledTextCtrl_AutoCompGetMaxHeight 3111 -#define wxStyledTextCtrl_SetIndent 3112 -#define wxStyledTextCtrl_GetIndent 3113 -#define wxStyledTextCtrl_SetUseTabs 3114 -#define wxStyledTextCtrl_GetUseTabs 3115 -#define wxStyledTextCtrl_SetLineIndentation 3116 -#define wxStyledTextCtrl_GetLineIndentation 3117 -#define wxStyledTextCtrl_GetLineIndentPosition 3118 -#define wxStyledTextCtrl_GetColumn 3119 -#define wxStyledTextCtrl_SetUseHorizontalScrollBar 3120 -#define wxStyledTextCtrl_GetUseHorizontalScrollBar 3121 -#define wxStyledTextCtrl_SetIndentationGuides 3122 -#define wxStyledTextCtrl_GetIndentationGuides 3123 -#define wxStyledTextCtrl_SetHighlightGuide 3124 -#define wxStyledTextCtrl_GetHighlightGuide 3125 -#define wxStyledTextCtrl_GetLineEndPosition 3126 -#define wxStyledTextCtrl_GetCodePage 3127 -#define wxStyledTextCtrl_GetCaretForeground 3128 -#define wxStyledTextCtrl_GetReadOnly 3129 -#define wxStyledTextCtrl_SetCurrentPos 3130 -#define wxStyledTextCtrl_SetSelectionStart 3131 -#define wxStyledTextCtrl_GetSelectionStart 3132 -#define wxStyledTextCtrl_SetSelectionEnd 3133 -#define wxStyledTextCtrl_GetSelectionEnd 3134 -#define wxStyledTextCtrl_SetPrintMagnification 3135 -#define wxStyledTextCtrl_GetPrintMagnification 3136 -#define wxStyledTextCtrl_SetPrintColourMode 3137 -#define wxStyledTextCtrl_GetPrintColourMode 3138 -#define wxStyledTextCtrl_FindText 3139 -#define wxStyledTextCtrl_FormatRange 3140 -#define wxStyledTextCtrl_GetFirstVisibleLine 3141 -#define wxStyledTextCtrl_GetLine 3142 -#define wxStyledTextCtrl_GetLineCount 3143 -#define wxStyledTextCtrl_SetMarginLeft 3144 -#define wxStyledTextCtrl_GetMarginLeft 3145 -#define wxStyledTextCtrl_SetMarginRight 3146 -#define wxStyledTextCtrl_GetMarginRight 3147 -#define wxStyledTextCtrl_GetModify 3148 -#define wxStyledTextCtrl_SetSelection 3149 -#define wxStyledTextCtrl_GetSelectedText 3150 -#define wxStyledTextCtrl_GetTextRange 3151 -#define wxStyledTextCtrl_HideSelection 3152 -#define wxStyledTextCtrl_LineFromPosition 3153 -#define wxStyledTextCtrl_PositionFromLine 3154 -#define wxStyledTextCtrl_LineScroll 3155 -#define wxStyledTextCtrl_EnsureCaretVisible 3156 -#define wxStyledTextCtrl_ReplaceSelection 3157 -#define wxStyledTextCtrl_SetReadOnly 3158 -#define wxStyledTextCtrl_CanPaste 3159 -#define wxStyledTextCtrl_CanUndo 3160 -#define wxStyledTextCtrl_EmptyUndoBuffer 3161 -#define wxStyledTextCtrl_Undo 3162 -#define wxStyledTextCtrl_Cut 3163 -#define wxStyledTextCtrl_Copy 3164 -#define wxStyledTextCtrl_Paste 3165 -#define wxStyledTextCtrl_Clear 3166 -#define wxStyledTextCtrl_SetText 3167 -#define wxStyledTextCtrl_GetText 3168 -#define wxStyledTextCtrl_GetTextLength 3169 -#define wxStyledTextCtrl_GetOvertype 3170 -#define wxStyledTextCtrl_SetCaretWidth 3171 -#define wxStyledTextCtrl_GetCaretWidth 3172 -#define wxStyledTextCtrl_SetTargetStart 3173 -#define wxStyledTextCtrl_GetTargetStart 3174 -#define wxStyledTextCtrl_SetTargetEnd 3175 -#define wxStyledTextCtrl_GetTargetEnd 3176 -#define wxStyledTextCtrl_ReplaceTarget 3177 -#define wxStyledTextCtrl_SearchInTarget 3178 -#define wxStyledTextCtrl_SetSearchFlags 3179 -#define wxStyledTextCtrl_GetSearchFlags 3180 -#define wxStyledTextCtrl_CallTipShow 3181 -#define wxStyledTextCtrl_CallTipCancel 3182 -#define wxStyledTextCtrl_CallTipActive 3183 -#define wxStyledTextCtrl_CallTipPosAtStart 3184 -#define wxStyledTextCtrl_CallTipSetHighlight 3185 -#define wxStyledTextCtrl_CallTipSetBackground 3186 -#define wxStyledTextCtrl_CallTipSetForeground 3187 -#define wxStyledTextCtrl_CallTipSetForegroundHighlight 3188 -#define wxStyledTextCtrl_CallTipUseStyle 3189 -#define wxStyledTextCtrl_VisibleFromDocLine 3190 -#define wxStyledTextCtrl_DocLineFromVisible 3191 -#define wxStyledTextCtrl_WrapCount 3192 -#define wxStyledTextCtrl_SetFoldLevel 3193 -#define wxStyledTextCtrl_GetFoldLevel 3194 -#define wxStyledTextCtrl_GetLastChild 3195 -#define wxStyledTextCtrl_GetFoldParent 3196 -#define wxStyledTextCtrl_ShowLines 3197 -#define wxStyledTextCtrl_HideLines 3198 -#define wxStyledTextCtrl_GetLineVisible 3199 -#define wxStyledTextCtrl_SetFoldExpanded 3200 -#define wxStyledTextCtrl_GetFoldExpanded 3201 -#define wxStyledTextCtrl_ToggleFold 3202 -#define wxStyledTextCtrl_EnsureVisible 3203 -#define wxStyledTextCtrl_SetFoldFlags 3204 -#define wxStyledTextCtrl_EnsureVisibleEnforcePolicy 3205 -#define wxStyledTextCtrl_SetTabIndents 3206 -#define wxStyledTextCtrl_GetTabIndents 3207 -#define wxStyledTextCtrl_SetBackSpaceUnIndents 3208 -#define wxStyledTextCtrl_GetBackSpaceUnIndents 3209 -#define wxStyledTextCtrl_SetMouseDwellTime 3210 -#define wxStyledTextCtrl_GetMouseDwellTime 3211 -#define wxStyledTextCtrl_WordStartPosition 3212 -#define wxStyledTextCtrl_WordEndPosition 3213 -#define wxStyledTextCtrl_SetWrapMode 3214 -#define wxStyledTextCtrl_GetWrapMode 3215 -#define wxStyledTextCtrl_SetWrapVisualFlags 3216 -#define wxStyledTextCtrl_GetWrapVisualFlags 3217 -#define wxStyledTextCtrl_SetWrapVisualFlagsLocation 3218 -#define wxStyledTextCtrl_GetWrapVisualFlagsLocation 3219 -#define wxStyledTextCtrl_SetWrapStartIndent 3220 -#define wxStyledTextCtrl_GetWrapStartIndent 3221 -#define wxStyledTextCtrl_SetLayoutCache 3222 -#define wxStyledTextCtrl_GetLayoutCache 3223 -#define wxStyledTextCtrl_SetScrollWidth 3224 -#define wxStyledTextCtrl_GetScrollWidth 3225 -#define wxStyledTextCtrl_TextWidth 3226 -#define wxStyledTextCtrl_GetEndAtLastLine 3227 -#define wxStyledTextCtrl_TextHeight 3228 -#define wxStyledTextCtrl_SetUseVerticalScrollBar 3229 -#define wxStyledTextCtrl_GetUseVerticalScrollBar 3230 -#define wxStyledTextCtrl_AppendText 3231 -#define wxStyledTextCtrl_GetTwoPhaseDraw 3232 -#define wxStyledTextCtrl_SetTwoPhaseDraw 3233 -#define wxStyledTextCtrl_TargetFromSelection 3234 -#define wxStyledTextCtrl_LinesJoin 3235 -#define wxStyledTextCtrl_LinesSplit 3236 -#define wxStyledTextCtrl_SetFoldMarginColour 3237 -#define wxStyledTextCtrl_SetFoldMarginHiColour 3238 -#define wxStyledTextCtrl_LineDown 3239 -#define wxStyledTextCtrl_LineDownExtend 3240 -#define wxStyledTextCtrl_LineUp 3241 -#define wxStyledTextCtrl_LineUpExtend 3242 -#define wxStyledTextCtrl_CharLeft 3243 -#define wxStyledTextCtrl_CharLeftExtend 3244 -#define wxStyledTextCtrl_CharRight 3245 -#define wxStyledTextCtrl_CharRightExtend 3246 -#define wxStyledTextCtrl_WordLeft 3247 -#define wxStyledTextCtrl_WordLeftExtend 3248 -#define wxStyledTextCtrl_WordRight 3249 -#define wxStyledTextCtrl_WordRightExtend 3250 -#define wxStyledTextCtrl_Home 3251 -#define wxStyledTextCtrl_HomeExtend 3252 -#define wxStyledTextCtrl_LineEnd 3253 -#define wxStyledTextCtrl_LineEndExtend 3254 -#define wxStyledTextCtrl_DocumentStart 3255 -#define wxStyledTextCtrl_DocumentStartExtend 3256 -#define wxStyledTextCtrl_DocumentEnd 3257 -#define wxStyledTextCtrl_DocumentEndExtend 3258 -#define wxStyledTextCtrl_PageUp 3259 -#define wxStyledTextCtrl_PageUpExtend 3260 -#define wxStyledTextCtrl_PageDown 3261 -#define wxStyledTextCtrl_PageDownExtend 3262 -#define wxStyledTextCtrl_EditToggleOvertype 3263 -#define wxStyledTextCtrl_Cancel 3264 -#define wxStyledTextCtrl_DeleteBack 3265 -#define wxStyledTextCtrl_Tab 3266 -#define wxStyledTextCtrl_BackTab 3267 -#define wxStyledTextCtrl_NewLine 3268 -#define wxStyledTextCtrl_FormFeed 3269 -#define wxStyledTextCtrl_VCHome 3270 -#define wxStyledTextCtrl_VCHomeExtend 3271 -#define wxStyledTextCtrl_ZoomIn 3272 -#define wxStyledTextCtrl_ZoomOut 3273 -#define wxStyledTextCtrl_DelWordLeft 3274 -#define wxStyledTextCtrl_DelWordRight 3275 -#define wxStyledTextCtrl_LineCut 3276 -#define wxStyledTextCtrl_LineDelete 3277 -#define wxStyledTextCtrl_LineTranspose 3278 -#define wxStyledTextCtrl_LineDuplicate 3279 -#define wxStyledTextCtrl_LowerCase 3280 -#define wxStyledTextCtrl_UpperCase 3281 -#define wxStyledTextCtrl_LineScrollDown 3282 -#define wxStyledTextCtrl_LineScrollUp 3283 -#define wxStyledTextCtrl_DeleteBackNotLine 3284 -#define wxStyledTextCtrl_HomeDisplay 3285 -#define wxStyledTextCtrl_HomeDisplayExtend 3286 -#define wxStyledTextCtrl_LineEndDisplay 3287 -#define wxStyledTextCtrl_LineEndDisplayExtend 3288 -#define wxStyledTextCtrl_HomeWrapExtend 3289 -#define wxStyledTextCtrl_LineEndWrap 3290 -#define wxStyledTextCtrl_LineEndWrapExtend 3291 -#define wxStyledTextCtrl_VCHomeWrap 3292 -#define wxStyledTextCtrl_VCHomeWrapExtend 3293 -#define wxStyledTextCtrl_LineCopy 3294 -#define wxStyledTextCtrl_MoveCaretInsideView 3295 -#define wxStyledTextCtrl_LineLength 3296 -#define wxStyledTextCtrl_BraceHighlight 3297 -#define wxStyledTextCtrl_BraceBadLight 3298 -#define wxStyledTextCtrl_BraceMatch 3299 -#define wxStyledTextCtrl_GetViewEOL 3300 -#define wxStyledTextCtrl_SetViewEOL 3301 -#define wxStyledTextCtrl_SetModEventMask 3302 -#define wxStyledTextCtrl_GetEdgeColumn 3303 -#define wxStyledTextCtrl_SetEdgeColumn 3304 -#define wxStyledTextCtrl_SetEdgeMode 3305 -#define wxStyledTextCtrl_GetEdgeMode 3306 -#define wxStyledTextCtrl_GetEdgeColour 3307 -#define wxStyledTextCtrl_SetEdgeColour 3308 -#define wxStyledTextCtrl_SearchAnchor 3309 -#define wxStyledTextCtrl_SearchNext 3310 -#define wxStyledTextCtrl_SearchPrev 3311 -#define wxStyledTextCtrl_LinesOnScreen 3312 -#define wxStyledTextCtrl_UsePopUp 3313 -#define wxStyledTextCtrl_SelectionIsRectangle 3314 -#define wxStyledTextCtrl_SetZoom 3315 -#define wxStyledTextCtrl_GetZoom 3316 -#define wxStyledTextCtrl_GetModEventMask 3317 -#define wxStyledTextCtrl_SetSTCFocus 3318 -#define wxStyledTextCtrl_GetSTCFocus 3319 -#define wxStyledTextCtrl_SetStatus 3320 -#define wxStyledTextCtrl_GetStatus 3321 -#define wxStyledTextCtrl_SetMouseDownCaptures 3322 -#define wxStyledTextCtrl_GetMouseDownCaptures 3323 -#define wxStyledTextCtrl_SetSTCCursor 3324 -#define wxStyledTextCtrl_GetSTCCursor 3325 -#define wxStyledTextCtrl_SetControlCharSymbol 3326 -#define wxStyledTextCtrl_GetControlCharSymbol 3327 -#define wxStyledTextCtrl_WordPartLeft 3328 -#define wxStyledTextCtrl_WordPartLeftExtend 3329 -#define wxStyledTextCtrl_WordPartRight 3330 -#define wxStyledTextCtrl_WordPartRightExtend 3331 -#define wxStyledTextCtrl_SetVisiblePolicy 3332 -#define wxStyledTextCtrl_DelLineLeft 3333 -#define wxStyledTextCtrl_DelLineRight 3334 -#define wxStyledTextCtrl_GetXOffset 3335 -#define wxStyledTextCtrl_ChooseCaretX 3336 -#define wxStyledTextCtrl_SetXCaretPolicy 3337 -#define wxStyledTextCtrl_SetYCaretPolicy 3338 -#define wxStyledTextCtrl_GetPrintWrapMode 3339 -#define wxStyledTextCtrl_SetHotspotActiveForeground 3340 -#define wxStyledTextCtrl_SetHotspotActiveBackground 3341 -#define wxStyledTextCtrl_SetHotspotActiveUnderline 3342 -#define wxStyledTextCtrl_SetHotspotSingleLine 3343 -#define wxStyledTextCtrl_ParaDownExtend 3344 -#define wxStyledTextCtrl_ParaUp 3345 -#define wxStyledTextCtrl_ParaUpExtend 3346 -#define wxStyledTextCtrl_PositionBefore 3347 -#define wxStyledTextCtrl_PositionAfter 3348 -#define wxStyledTextCtrl_CopyRange 3349 -#define wxStyledTextCtrl_CopyText 3350 -#define wxStyledTextCtrl_SetSelectionMode 3351 -#define wxStyledTextCtrl_GetSelectionMode 3352 -#define wxStyledTextCtrl_LineDownRectExtend 3353 -#define wxStyledTextCtrl_LineUpRectExtend 3354 -#define wxStyledTextCtrl_CharLeftRectExtend 3355 -#define wxStyledTextCtrl_CharRightRectExtend 3356 -#define wxStyledTextCtrl_HomeRectExtend 3357 -#define wxStyledTextCtrl_VCHomeRectExtend 3358 -#define wxStyledTextCtrl_LineEndRectExtend 3359 -#define wxStyledTextCtrl_PageUpRectExtend 3360 -#define wxStyledTextCtrl_PageDownRectExtend 3361 -#define wxStyledTextCtrl_StutteredPageUp 3362 -#define wxStyledTextCtrl_StutteredPageUpExtend 3363 -#define wxStyledTextCtrl_StutteredPageDown 3364 -#define wxStyledTextCtrl_StutteredPageDownExtend 3365 -#define wxStyledTextCtrl_WordLeftEnd 3366 -#define wxStyledTextCtrl_WordLeftEndExtend 3367 -#define wxStyledTextCtrl_WordRightEnd 3368 -#define wxStyledTextCtrl_WordRightEndExtend 3369 -#define wxStyledTextCtrl_SetWhitespaceChars 3370 -#define wxStyledTextCtrl_SetCharsDefault 3371 -#define wxStyledTextCtrl_AutoCompGetCurrent 3372 -#define wxStyledTextCtrl_Allocate 3373 -#define wxStyledTextCtrl_FindColumn 3374 -#define wxStyledTextCtrl_GetCaretSticky 3375 -#define wxStyledTextCtrl_SetCaretSticky 3376 -#define wxStyledTextCtrl_ToggleCaretSticky 3377 -#define wxStyledTextCtrl_SetPasteConvertEndings 3378 -#define wxStyledTextCtrl_GetPasteConvertEndings 3379 -#define wxStyledTextCtrl_SelectionDuplicate 3380 -#define wxStyledTextCtrl_SetCaretLineBackAlpha 3381 -#define wxStyledTextCtrl_GetCaretLineBackAlpha 3382 -#define wxStyledTextCtrl_StartRecord 3383 -#define wxStyledTextCtrl_StopRecord 3384 -#define wxStyledTextCtrl_SetLexer 3385 -#define wxStyledTextCtrl_GetLexer 3386 -#define wxStyledTextCtrl_Colourise 3387 -#define wxStyledTextCtrl_SetProperty 3388 -#define wxStyledTextCtrl_SetKeyWords 3389 -#define wxStyledTextCtrl_SetLexerLanguage 3390 -#define wxStyledTextCtrl_GetProperty 3391 -#define wxStyledTextCtrl_GetStyleBitsNeeded 3392 -#define wxStyledTextCtrl_GetCurrentLine 3393 -#define wxStyledTextCtrl_StyleSetSpec 3394 -#define wxStyledTextCtrl_StyleSetFont 3395 -#define wxStyledTextCtrl_StyleSetFontAttr 3396 -#define wxStyledTextCtrl_StyleSetCharacterSet 3397 -#define wxStyledTextCtrl_StyleSetFontEncoding 3398 -#define wxStyledTextCtrl_CmdKeyExecute 3399 -#define wxStyledTextCtrl_SetMargins 3400 -#define wxStyledTextCtrl_GetSelection 3401 -#define wxStyledTextCtrl_PointFromPosition 3402 -#define wxStyledTextCtrl_ScrollToLine 3403 -#define wxStyledTextCtrl_ScrollToColumn 3404 -#define wxStyledTextCtrl_SetVScrollBar 3405 -#define wxStyledTextCtrl_SetHScrollBar 3406 -#define wxStyledTextCtrl_GetLastKeydownProcessed 3407 -#define wxStyledTextCtrl_SetLastKeydownProcessed 3408 -#define wxStyledTextCtrl_SaveFile 3409 -#define wxStyledTextCtrl_LoadFile 3410 -#define wxStyledTextCtrl_DoDragOver 3411 -#define wxStyledTextCtrl_DoDropText 3412 -#define wxStyledTextCtrl_GetUseAntiAliasing 3413 -#define wxStyledTextCtrl_AddTextRaw 3414 -#define wxStyledTextCtrl_InsertTextRaw 3415 -#define wxStyledTextCtrl_GetCurLineRaw 3416 -#define wxStyledTextCtrl_GetLineRaw 3417 -#define wxStyledTextCtrl_GetSelectedTextRaw 3418 -#define wxStyledTextCtrl_GetTextRangeRaw 3419 -#define wxStyledTextCtrl_SetTextRaw 3420 -#define wxStyledTextCtrl_GetTextRaw 3421 -#define wxStyledTextCtrl_AppendTextRaw 3422 -#define wxArtProvider_GetBitmap 3423 -#define wxArtProvider_GetIcon 3424 -#define wxTreeEvent_GetKeyCode 3425 -#define wxTreeEvent_GetItem 3426 -#define wxTreeEvent_GetKeyEvent 3427 -#define wxTreeEvent_GetLabel 3428 -#define wxTreeEvent_GetOldItem 3429 -#define wxTreeEvent_GetPoint 3430 -#define wxTreeEvent_IsEditCancelled 3431 -#define wxTreeEvent_SetToolTip 3432 -#define wxNotebookEvent_GetOldSelection 3433 -#define wxNotebookEvent_GetSelection 3434 -#define wxNotebookEvent_SetOldSelection 3435 -#define wxNotebookEvent_SetSelection 3436 -#define wxFileDataObject_new 3437 -#define wxFileDataObject_AddFile 3438 -#define wxFileDataObject_GetFilenames 3439 -#define wxFileDataObject_destroy 3440 -#define wxTextDataObject_new 3441 -#define wxTextDataObject_GetTextLength 3442 -#define wxTextDataObject_GetText 3443 -#define wxTextDataObject_SetText 3444 -#define wxTextDataObject_destroy 3445 -#define wxBitmapDataObject_new_1_1 3446 -#define wxBitmapDataObject_new_1_0 3447 -#define wxBitmapDataObject_GetBitmap 3448 -#define wxBitmapDataObject_SetBitmap 3449 -#define wxBitmapDataObject_destroy 3450 -#define wxClipboard_new 3452 -#define wxClipboard_destruct 3453 -#define wxClipboard_AddData 3454 -#define wxClipboard_Clear 3455 -#define wxClipboard_Close 3456 -#define wxClipboard_Flush 3457 -#define wxClipboard_GetData 3458 -#define wxClipboard_IsOpened 3459 -#define wxClipboard_Open 3460 -#define wxClipboard_SetData 3461 -#define wxClipboard_UsePrimarySelection 3463 -#define wxClipboard_IsSupported 3464 -#define wxClipboard_Get 3465 -#define wxSpinEvent_GetPosition 3466 -#define wxSpinEvent_SetPosition 3467 -#define wxSplitterWindow_new_0 3468 -#define wxSplitterWindow_new_2 3469 -#define wxSplitterWindow_destruct 3470 -#define wxSplitterWindow_Create 3471 -#define wxSplitterWindow_GetMinimumPaneSize 3472 -#define wxSplitterWindow_GetSashGravity 3473 -#define wxSplitterWindow_GetSashPosition 3474 -#define wxSplitterWindow_GetSplitMode 3475 -#define wxSplitterWindow_GetWindow1 3476 -#define wxSplitterWindow_GetWindow2 3477 -#define wxSplitterWindow_Initialize 3478 -#define wxSplitterWindow_IsSplit 3479 -#define wxSplitterWindow_ReplaceWindow 3480 -#define wxSplitterWindow_SetSashGravity 3481 -#define wxSplitterWindow_SetSashPosition 3482 -#define wxSplitterWindow_SetSashSize 3483 -#define wxSplitterWindow_SetMinimumPaneSize 3484 -#define wxSplitterWindow_SetSplitMode 3485 -#define wxSplitterWindow_SplitHorizontally 3486 -#define wxSplitterWindow_SplitVertically 3487 -#define wxSplitterWindow_Unsplit 3488 -#define wxSplitterWindow_UpdateSize 3489 -#define wxSplitterEvent_GetSashPosition 3490 -#define wxSplitterEvent_GetX 3491 -#define wxSplitterEvent_GetY 3492 -#define wxSplitterEvent_GetWindowBeingRemoved 3493 -#define wxSplitterEvent_SetSashPosition 3494 -#define wxHtmlWindow_new_0 3495 -#define wxHtmlWindow_new_2 3496 -#define wxHtmlWindow_AppendToPage 3497 -#define wxHtmlWindow_GetOpenedAnchor 3498 -#define wxHtmlWindow_GetOpenedPage 3499 -#define wxHtmlWindow_GetOpenedPageTitle 3500 -#define wxHtmlWindow_GetRelatedFrame 3501 -#define wxHtmlWindow_HistoryBack 3502 -#define wxHtmlWindow_HistoryCanBack 3503 -#define wxHtmlWindow_HistoryCanForward 3504 -#define wxHtmlWindow_HistoryClear 3505 -#define wxHtmlWindow_HistoryForward 3506 -#define wxHtmlWindow_LoadFile 3507 -#define wxHtmlWindow_LoadPage 3508 -#define wxHtmlWindow_SelectAll 3509 -#define wxHtmlWindow_SelectionToText 3510 -#define wxHtmlWindow_SelectLine 3511 -#define wxHtmlWindow_SelectWord 3512 -#define wxHtmlWindow_SetBorders 3513 -#define wxHtmlWindow_SetFonts 3514 -#define wxHtmlWindow_SetPage 3515 -#define wxHtmlWindow_SetRelatedFrame 3516 -#define wxHtmlWindow_SetRelatedStatusBar 3517 -#define wxHtmlWindow_ToText 3518 -#define wxHtmlWindow_destroy 3519 -#define wxHtmlLinkEvent_GetLinkInfo 3520 -#define wxSystemSettings_GetColour 3521 -#define wxSystemSettings_GetFont 3522 -#define wxSystemSettings_GetMetric 3523 -#define wxSystemSettings_GetScreenType 3524 -#define wxSystemOptions_GetOption 3525 -#define wxSystemOptions_GetOptionInt 3526 -#define wxSystemOptions_HasOption 3527 -#define wxSystemOptions_IsFalse 3528 -#define wxSystemOptions_SetOption_2_1 3529 -#define wxSystemOptions_SetOption_2_0 3530 -#define wxAuiNotebookEvent_SetSelection 3531 -#define wxAuiNotebookEvent_GetSelection 3532 -#define wxAuiNotebookEvent_SetOldSelection 3533 -#define wxAuiNotebookEvent_GetOldSelection 3534 -#define wxAuiNotebookEvent_SetDragSource 3535 -#define wxAuiNotebookEvent_GetDragSource 3536 -#define wxAuiManagerEvent_SetManager 3537 -#define wxAuiManagerEvent_GetManager 3538 -#define wxAuiManagerEvent_SetPane 3539 -#define wxAuiManagerEvent_GetPane 3540 -#define wxAuiManagerEvent_SetButton 3541 -#define wxAuiManagerEvent_GetButton 3542 -#define wxAuiManagerEvent_SetDC 3543 -#define wxAuiManagerEvent_GetDC 3544 -#define wxAuiManagerEvent_Veto 3545 -#define wxAuiManagerEvent_GetVeto 3546 -#define wxAuiManagerEvent_SetCanVeto 3547 -#define wxAuiManagerEvent_CanVeto 3548 -#define wxLogNull_new 3549 -#define wxLogNull_destroy 3550 -#define wxTaskBarIcon_new 3551 -#define wxTaskBarIcon_destruct 3552 -#define wxTaskBarIcon_PopupMenu 3553 -#define wxTaskBarIcon_RemoveIcon 3554 -#define wxTaskBarIcon_SetIcon 3555 -#define wxLocale_new_0 3556 -#define wxLocale_new_2 3558 -#define wxLocale_destruct 3559 -#define wxLocale_Init 3561 -#define wxLocale_AddCatalog_1 3562 -#define wxLocale_AddCatalog_3 3563 -#define wxLocale_AddCatalogLookupPathPrefix 3564 -#define wxLocale_GetCanonicalName 3565 -#define wxLocale_GetLanguage 3566 -#define wxLocale_GetLanguageName 3567 -#define wxLocale_GetLocale 3568 -#define wxLocale_GetName 3569 -#define wxLocale_GetString_2 3570 -#define wxLocale_GetString_4 3571 -#define wxLocale_GetHeaderValue 3572 -#define wxLocale_GetSysName 3573 -#define wxLocale_GetSystemEncoding 3574 -#define wxLocale_GetSystemEncodingName 3575 -#define wxLocale_GetSystemLanguage 3576 -#define wxLocale_IsLoaded 3577 -#define wxLocale_IsOk 3578 -#define wxActivateEvent_GetActive 3579 -#define wxPopupWindow_new_2 3581 -#define wxPopupWindow_new_0 3582 -#define wxPopupWindow_destruct 3584 -#define wxPopupWindow_Create 3585 -#define wxPopupWindow_Position 3586 -#define wxPopupTransientWindow_new_0 3587 -#define wxPopupTransientWindow_new_2 3588 -#define wxPopupTransientWindow_destruct 3589 -#define wxPopupTransientWindow_Popup 3590 -#define wxPopupTransientWindow_Dismiss 3591 -#define wxOverlay_new 3592 -#define wxOverlay_destruct 3593 -#define wxOverlay_Reset 3594 -#define wxDCOverlay_new_6 3595 -#define wxDCOverlay_new_2 3596 -#define wxDCOverlay_destruct 3597 -#define wxDCOverlay_Clear 3598 +#define wxGauge_GetRange 1605 +#define wxGauge_GetValue 1606 +#define wxGauge_IsVertical 1607 +#define wxGauge_SetRange 1608 +#define wxGauge_SetValue 1609 +#define wxGauge_Pulse 1610 +#define wxGauge_destroy 1611 +#define wxGenericDirCtrl_new_0 1612 +#define wxGenericDirCtrl_new_2 1613 +#define wxGenericDirCtrl_destruct 1614 +#define wxGenericDirCtrl_Create 1615 +#define wxGenericDirCtrl_Init 1616 +#define wxGenericDirCtrl_CollapseTree 1617 +#define wxGenericDirCtrl_ExpandPath 1618 +#define wxGenericDirCtrl_GetDefaultPath 1619 +#define wxGenericDirCtrl_GetPath 1620 +#define wxGenericDirCtrl_GetFilePath 1621 +#define wxGenericDirCtrl_GetFilter 1622 +#define wxGenericDirCtrl_GetFilterIndex 1623 +#define wxGenericDirCtrl_GetRootId 1624 +#define wxGenericDirCtrl_GetTreeCtrl 1625 +#define wxGenericDirCtrl_ReCreateTree 1626 +#define wxGenericDirCtrl_SetDefaultPath 1627 +#define wxGenericDirCtrl_SetFilter 1628 +#define wxGenericDirCtrl_SetFilterIndex 1629 +#define wxGenericDirCtrl_SetPath 1630 +#define wxStaticBox_new_4 1632 +#define wxStaticBox_new_0 1633 +#define wxStaticBox_Create 1634 +#define wxStaticBox_destroy 1635 +#define wxStaticLine_new_2 1637 +#define wxStaticLine_new_0 1638 +#define wxStaticLine_Create 1639 +#define wxStaticLine_IsVertical 1640 +#define wxStaticLine_GetDefaultSize 1641 +#define wxStaticLine_destroy 1642 +#define wxListBox_new_3 1645 +#define wxListBox_new_0 1646 +#define wxListBox_destruct 1648 +#define wxListBox_Create 1650 +#define wxListBox_Deselect 1651 +#define wxListBox_GetSelections 1652 +#define wxListBox_InsertItems 1653 +#define wxListBox_IsSelected 1654 +#define wxListBox_Set 1655 +#define wxListBox_HitTest 1656 +#define wxListBox_SetFirstItem_1_0 1657 +#define wxListBox_SetFirstItem_1_1 1658 +#define wxListCtrl_new_0 1659 +#define wxListCtrl_new_2 1660 +#define wxListCtrl_Arrange 1661 +#define wxListCtrl_AssignImageList 1662 +#define wxListCtrl_ClearAll 1663 +#define wxListCtrl_Create 1664 +#define wxListCtrl_DeleteAllItems 1665 +#define wxListCtrl_DeleteColumn 1666 +#define wxListCtrl_DeleteItem 1667 +#define wxListCtrl_EditLabel 1668 +#define wxListCtrl_EnsureVisible 1669 +#define wxListCtrl_FindItem_3_0 1670 +#define wxListCtrl_FindItem_3_1 1671 +#define wxListCtrl_GetColumn 1672 +#define wxListCtrl_GetColumnCount 1673 +#define wxListCtrl_GetColumnWidth 1674 +#define wxListCtrl_GetCountPerPage 1675 +#define wxListCtrl_GetEditControl 1676 +#define wxListCtrl_GetImageList 1677 +#define wxListCtrl_GetItem 1678 +#define wxListCtrl_GetItemBackgroundColour 1679 +#define wxListCtrl_GetItemCount 1680 +#define wxListCtrl_GetItemData 1681 +#define wxListCtrl_GetItemFont 1682 +#define wxListCtrl_GetItemPosition 1683 +#define wxListCtrl_GetItemRect 1684 +#define wxListCtrl_GetItemSpacing 1685 +#define wxListCtrl_GetItemState 1686 +#define wxListCtrl_GetItemText 1687 +#define wxListCtrl_GetItemTextColour 1688 +#define wxListCtrl_GetNextItem 1689 +#define wxListCtrl_GetSelectedItemCount 1690 +#define wxListCtrl_GetTextColour 1691 +#define wxListCtrl_GetTopItem 1692 +#define wxListCtrl_GetViewRect 1693 +#define wxListCtrl_HitTest 1694 +#define wxListCtrl_InsertColumn_2 1695 +#define wxListCtrl_InsertColumn_3 1696 +#define wxListCtrl_InsertItem_1 1697 +#define wxListCtrl_InsertItem_2_1 1698 +#define wxListCtrl_InsertItem_2_0 1699 +#define wxListCtrl_InsertItem_3 1700 +#define wxListCtrl_RefreshItem 1701 +#define wxListCtrl_RefreshItems 1702 +#define wxListCtrl_ScrollList 1703 +#define wxListCtrl_SetBackgroundColour 1704 +#define wxListCtrl_SetColumn 1705 +#define wxListCtrl_SetColumnWidth 1706 +#define wxListCtrl_SetImageList 1707 +#define wxListCtrl_SetItem_1 1708 +#define wxListCtrl_SetItem_4 1709 +#define wxListCtrl_SetItemBackgroundColour 1710 +#define wxListCtrl_SetItemCount 1711 +#define wxListCtrl_SetItemData 1712 +#define wxListCtrl_SetItemFont 1713 +#define wxListCtrl_SetItemImage 1714 +#define wxListCtrl_SetItemColumnImage 1715 +#define wxListCtrl_SetItemPosition 1716 +#define wxListCtrl_SetItemState 1717 +#define wxListCtrl_SetItemText 1718 +#define wxListCtrl_SetItemTextColour 1719 +#define wxListCtrl_SetSingleStyle 1720 +#define wxListCtrl_SetTextColour 1721 +#define wxListCtrl_SetWindowStyleFlag 1722 +#define wxListCtrl_SortItems 1723 +#define wxListCtrl_destroy 1724 +#define wxListView_ClearColumnImage 1725 +#define wxListView_Focus 1726 +#define wxListView_GetFirstSelected 1727 +#define wxListView_GetFocusedItem 1728 +#define wxListView_GetNextSelected 1729 +#define wxListView_IsSelected 1730 +#define wxListView_Select 1731 +#define wxListView_SetColumnImage 1732 +#define wxListItem_new_0 1733 +#define wxListItem_new_1 1734 +#define wxListItem_destruct 1735 +#define wxListItem_Clear 1736 +#define wxListItem_GetAlign 1737 +#define wxListItem_GetBackgroundColour 1738 +#define wxListItem_GetColumn 1739 +#define wxListItem_GetFont 1740 +#define wxListItem_GetId 1741 +#define wxListItem_GetImage 1742 +#define wxListItem_GetMask 1743 +#define wxListItem_GetState 1744 +#define wxListItem_GetText 1745 +#define wxListItem_GetTextColour 1746 +#define wxListItem_GetWidth 1747 +#define wxListItem_SetAlign 1748 +#define wxListItem_SetBackgroundColour 1749 +#define wxListItem_SetColumn 1750 +#define wxListItem_SetFont 1751 +#define wxListItem_SetId 1752 +#define wxListItem_SetImage 1753 +#define wxListItem_SetMask 1754 +#define wxListItem_SetState 1755 +#define wxListItem_SetStateMask 1756 +#define wxListItem_SetText 1757 +#define wxListItem_SetTextColour 1758 +#define wxListItem_SetWidth 1759 +#define wxListItemAttr_new_0 1760 +#define wxListItemAttr_new_3 1761 +#define wxListItemAttr_GetBackgroundColour 1762 +#define wxListItemAttr_GetFont 1763 +#define wxListItemAttr_GetTextColour 1764 +#define wxListItemAttr_HasBackgroundColour 1765 +#define wxListItemAttr_HasFont 1766 +#define wxListItemAttr_HasTextColour 1767 +#define wxListItemAttr_SetBackgroundColour 1768 +#define wxListItemAttr_SetFont 1769 +#define wxListItemAttr_SetTextColour 1770 +#define wxListItemAttr_destroy 1771 +#define wxImageList_new_0 1772 +#define wxImageList_new_3 1773 +#define wxImageList_Add_1 1774 +#define wxImageList_Add_2_0 1775 +#define wxImageList_Add_2_1 1776 +#define wxImageList_Create 1777 +#define wxImageList_Draw 1779 +#define wxImageList_GetBitmap 1780 +#define wxImageList_GetIcon 1781 +#define wxImageList_GetImageCount 1782 +#define wxImageList_GetSize 1783 +#define wxImageList_Remove 1784 +#define wxImageList_RemoveAll 1785 +#define wxImageList_Replace_2 1786 +#define wxImageList_Replace_3 1787 +#define wxImageList_destroy 1788 +#define wxTextAttr_new_0 1789 +#define wxTextAttr_new_2 1790 +#define wxTextAttr_GetAlignment 1791 +#define wxTextAttr_GetBackgroundColour 1792 +#define wxTextAttr_GetFont 1793 +#define wxTextAttr_GetLeftIndent 1794 +#define wxTextAttr_GetLeftSubIndent 1795 +#define wxTextAttr_GetRightIndent 1796 +#define wxTextAttr_GetTabs 1797 +#define wxTextAttr_GetTextColour 1798 +#define wxTextAttr_HasBackgroundColour 1799 +#define wxTextAttr_HasFont 1800 +#define wxTextAttr_HasTextColour 1801 +#define wxTextAttr_GetFlags 1802 +#define wxTextAttr_IsDefault 1803 +#define wxTextAttr_SetAlignment 1804 +#define wxTextAttr_SetBackgroundColour 1805 +#define wxTextAttr_SetFlags 1806 +#define wxTextAttr_SetFont 1807 +#define wxTextAttr_SetLeftIndent 1808 +#define wxTextAttr_SetRightIndent 1809 +#define wxTextAttr_SetTabs 1810 +#define wxTextAttr_SetTextColour 1811 +#define wxTextAttr_destroy 1812 +#define wxTextCtrl_new_3 1814 +#define wxTextCtrl_new_0 1815 +#define wxTextCtrl_destruct 1817 +#define wxTextCtrl_AppendText 1818 +#define wxTextCtrl_CanCopy 1819 +#define wxTextCtrl_CanCut 1820 +#define wxTextCtrl_CanPaste 1821 +#define wxTextCtrl_CanRedo 1822 +#define wxTextCtrl_CanUndo 1823 +#define wxTextCtrl_Clear 1824 +#define wxTextCtrl_Copy 1825 +#define wxTextCtrl_Create 1826 +#define wxTextCtrl_Cut 1827 +#define wxTextCtrl_DiscardEdits 1828 +#define wxTextCtrl_ChangeValue 1829 +#define wxTextCtrl_EmulateKeyPress 1830 +#define wxTextCtrl_GetDefaultStyle 1831 +#define wxTextCtrl_GetInsertionPoint 1832 +#define wxTextCtrl_GetLastPosition 1833 +#define wxTextCtrl_GetLineLength 1834 +#define wxTextCtrl_GetLineText 1835 +#define wxTextCtrl_GetNumberOfLines 1836 +#define wxTextCtrl_GetRange 1837 +#define wxTextCtrl_GetSelection 1838 +#define wxTextCtrl_GetStringSelection 1839 +#define wxTextCtrl_GetStyle 1840 +#define wxTextCtrl_GetValue 1841 +#define wxTextCtrl_IsEditable 1842 +#define wxTextCtrl_IsModified 1843 +#define wxTextCtrl_IsMultiLine 1844 +#define wxTextCtrl_IsSingleLine 1845 +#define wxTextCtrl_LoadFile 1846 +#define wxTextCtrl_MarkDirty 1847 +#define wxTextCtrl_Paste 1848 +#define wxTextCtrl_PositionToXY 1849 +#define wxTextCtrl_Redo 1850 +#define wxTextCtrl_Remove 1851 +#define wxTextCtrl_Replace 1852 +#define wxTextCtrl_SaveFile 1853 +#define wxTextCtrl_SetDefaultStyle 1854 +#define wxTextCtrl_SetEditable 1855 +#define wxTextCtrl_SetInsertionPoint 1856 +#define wxTextCtrl_SetInsertionPointEnd 1857 +#define wxTextCtrl_SetMaxLength 1859 +#define wxTextCtrl_SetSelection 1860 +#define wxTextCtrl_SetStyle 1861 +#define wxTextCtrl_SetValue 1862 +#define wxTextCtrl_ShowPosition 1863 +#define wxTextCtrl_Undo 1864 +#define wxTextCtrl_WriteText 1865 +#define wxTextCtrl_XYToPosition 1866 +#define wxNotebook_new_0 1869 +#define wxNotebook_new_3 1870 +#define wxNotebook_destruct 1871 +#define wxNotebook_AddPage 1872 +#define wxNotebook_AdvanceSelection 1873 +#define wxNotebook_AssignImageList 1874 +#define wxNotebook_Create 1875 +#define wxNotebook_DeleteAllPages 1876 +#define wxNotebook_DeletePage 1877 +#define wxNotebook_RemovePage 1878 +#define wxNotebook_GetCurrentPage 1879 +#define wxNotebook_GetImageList 1880 +#define wxNotebook_GetPage 1882 +#define wxNotebook_GetPageCount 1883 +#define wxNotebook_GetPageImage 1884 +#define wxNotebook_GetPageText 1885 +#define wxNotebook_GetRowCount 1886 +#define wxNotebook_GetSelection 1887 +#define wxNotebook_GetThemeBackgroundColour 1888 +#define wxNotebook_HitTest 1890 +#define wxNotebook_InsertPage 1892 +#define wxNotebook_SetImageList 1893 +#define wxNotebook_SetPadding 1894 +#define wxNotebook_SetPageSize 1895 +#define wxNotebook_SetPageImage 1896 +#define wxNotebook_SetPageText 1897 +#define wxNotebook_SetSelection 1898 +#define wxNotebook_ChangeSelection 1899 +#define wxChoicebook_new_0 1900 +#define wxChoicebook_new_3 1901 +#define wxChoicebook_AddPage 1902 +#define wxChoicebook_AdvanceSelection 1903 +#define wxChoicebook_AssignImageList 1904 +#define wxChoicebook_Create 1905 +#define wxChoicebook_DeleteAllPages 1906 +#define wxChoicebook_DeletePage 1907 +#define wxChoicebook_RemovePage 1908 +#define wxChoicebook_GetCurrentPage 1909 +#define wxChoicebook_GetImageList 1910 +#define wxChoicebook_GetPage 1912 +#define wxChoicebook_GetPageCount 1913 +#define wxChoicebook_GetPageImage 1914 +#define wxChoicebook_GetPageText 1915 +#define wxChoicebook_GetSelection 1916 +#define wxChoicebook_HitTest 1917 +#define wxChoicebook_InsertPage 1918 +#define wxChoicebook_SetImageList 1919 +#define wxChoicebook_SetPageSize 1920 +#define wxChoicebook_SetPageImage 1921 +#define wxChoicebook_SetPageText 1922 +#define wxChoicebook_SetSelection 1923 +#define wxChoicebook_ChangeSelection 1924 +#define wxChoicebook_destroy 1925 +#define wxToolbook_new_0 1926 +#define wxToolbook_new_3 1927 +#define wxToolbook_AddPage 1928 +#define wxToolbook_AdvanceSelection 1929 +#define wxToolbook_AssignImageList 1930 +#define wxToolbook_Create 1931 +#define wxToolbook_DeleteAllPages 1932 +#define wxToolbook_DeletePage 1933 +#define wxToolbook_RemovePage 1934 +#define wxToolbook_GetCurrentPage 1935 +#define wxToolbook_GetImageList 1936 +#define wxToolbook_GetPage 1938 +#define wxToolbook_GetPageCount 1939 +#define wxToolbook_GetPageImage 1940 +#define wxToolbook_GetPageText 1941 +#define wxToolbook_GetSelection 1942 +#define wxToolbook_HitTest 1944 +#define wxToolbook_InsertPage 1945 +#define wxToolbook_SetImageList 1946 +#define wxToolbook_SetPageSize 1947 +#define wxToolbook_SetPageImage 1948 +#define wxToolbook_SetPageText 1949 +#define wxToolbook_SetSelection 1950 +#define wxToolbook_ChangeSelection 1951 +#define wxToolbook_destroy 1952 +#define wxListbook_new_0 1953 +#define wxListbook_new_3 1954 +#define wxListbook_AddPage 1955 +#define wxListbook_AdvanceSelection 1956 +#define wxListbook_AssignImageList 1957 +#define wxListbook_Create 1958 +#define wxListbook_DeleteAllPages 1959 +#define wxListbook_DeletePage 1960 +#define wxListbook_RemovePage 1961 +#define wxListbook_GetCurrentPage 1962 +#define wxListbook_GetImageList 1963 +#define wxListbook_GetPage 1965 +#define wxListbook_GetPageCount 1966 +#define wxListbook_GetPageImage 1967 +#define wxListbook_GetPageText 1968 +#define wxListbook_GetSelection 1969 +#define wxListbook_HitTest 1971 +#define wxListbook_InsertPage 1972 +#define wxListbook_SetImageList 1973 +#define wxListbook_SetPageSize 1974 +#define wxListbook_SetPageImage 1975 +#define wxListbook_SetPageText 1976 +#define wxListbook_SetSelection 1977 +#define wxListbook_ChangeSelection 1978 +#define wxListbook_destroy 1979 +#define wxTreebook_new_0 1980 +#define wxTreebook_new_3 1981 +#define wxTreebook_AddPage 1982 +#define wxTreebook_AdvanceSelection 1983 +#define wxTreebook_AssignImageList 1984 +#define wxTreebook_Create 1985 +#define wxTreebook_DeleteAllPages 1986 +#define wxTreebook_DeletePage 1987 +#define wxTreebook_RemovePage 1988 +#define wxTreebook_GetCurrentPage 1989 +#define wxTreebook_GetImageList 1990 +#define wxTreebook_GetPage 1992 +#define wxTreebook_GetPageCount 1993 +#define wxTreebook_GetPageImage 1994 +#define wxTreebook_GetPageText 1995 +#define wxTreebook_GetSelection 1996 +#define wxTreebook_ExpandNode 1997 +#define wxTreebook_IsNodeExpanded 1998 +#define wxTreebook_HitTest 2000 +#define wxTreebook_InsertPage 2001 +#define wxTreebook_InsertSubPage 2002 +#define wxTreebook_SetImageList 2003 +#define wxTreebook_SetPageSize 2004 +#define wxTreebook_SetPageImage 2005 +#define wxTreebook_SetPageText 2006 +#define wxTreebook_SetSelection 2007 +#define wxTreebook_ChangeSelection 2008 +#define wxTreebook_destroy 2009 +#define wxTreeCtrl_new_2 2012 +#define wxTreeCtrl_new_0 2013 +#define wxTreeCtrl_destruct 2015 +#define wxTreeCtrl_AddRoot 2016 +#define wxTreeCtrl_AppendItem 2017 +#define wxTreeCtrl_AssignImageList 2018 +#define wxTreeCtrl_AssignStateImageList 2019 +#define wxTreeCtrl_Collapse 2020 +#define wxTreeCtrl_CollapseAndReset 2021 +#define wxTreeCtrl_Create 2022 +#define wxTreeCtrl_Delete 2023 +#define wxTreeCtrl_DeleteAllItems 2024 +#define wxTreeCtrl_DeleteChildren 2025 +#define wxTreeCtrl_EditLabel 2026 +#define wxTreeCtrl_EnsureVisible 2027 +#define wxTreeCtrl_Expand 2028 +#define wxTreeCtrl_GetBoundingRect 2029 +#define wxTreeCtrl_GetChildrenCount 2031 +#define wxTreeCtrl_GetCount 2032 +#define wxTreeCtrl_GetEditControl 2033 +#define wxTreeCtrl_GetFirstChild 2034 +#define wxTreeCtrl_GetNextChild 2035 +#define wxTreeCtrl_GetFirstVisibleItem 2036 +#define wxTreeCtrl_GetImageList 2037 +#define wxTreeCtrl_GetIndent 2038 +#define wxTreeCtrl_GetItemBackgroundColour 2039 +#define wxTreeCtrl_GetItemData 2040 +#define wxTreeCtrl_GetItemFont 2041 +#define wxTreeCtrl_GetItemImage_1 2042 +#define wxTreeCtrl_GetItemImage_2 2043 +#define wxTreeCtrl_GetItemText 2044 +#define wxTreeCtrl_GetItemTextColour 2045 +#define wxTreeCtrl_GetLastChild 2046 +#define wxTreeCtrl_GetNextSibling 2047 +#define wxTreeCtrl_GetNextVisible 2048 +#define wxTreeCtrl_GetItemParent 2049 +#define wxTreeCtrl_GetPrevSibling 2050 +#define wxTreeCtrl_GetPrevVisible 2051 +#define wxTreeCtrl_GetRootItem 2052 +#define wxTreeCtrl_GetSelection 2053 +#define wxTreeCtrl_GetSelections 2054 +#define wxTreeCtrl_GetStateImageList 2055 +#define wxTreeCtrl_HitTest 2056 +#define wxTreeCtrl_InsertItem 2058 +#define wxTreeCtrl_IsBold 2059 +#define wxTreeCtrl_IsExpanded 2060 +#define wxTreeCtrl_IsSelected 2061 +#define wxTreeCtrl_IsVisible 2062 +#define wxTreeCtrl_ItemHasChildren 2063 +#define wxTreeCtrl_IsTreeItemIdOk 2064 +#define wxTreeCtrl_PrependItem 2065 +#define wxTreeCtrl_ScrollTo 2066 +#define wxTreeCtrl_SelectItem_1 2067 +#define wxTreeCtrl_SelectItem_2 2068 +#define wxTreeCtrl_SetIndent 2069 +#define wxTreeCtrl_SetImageList 2070 +#define wxTreeCtrl_SetItemBackgroundColour 2071 +#define wxTreeCtrl_SetItemBold 2072 +#define wxTreeCtrl_SetItemData 2073 +#define wxTreeCtrl_SetItemDropHighlight 2074 +#define wxTreeCtrl_SetItemFont 2075 +#define wxTreeCtrl_SetItemHasChildren 2076 +#define wxTreeCtrl_SetItemImage_2 2077 +#define wxTreeCtrl_SetItemImage_3 2078 +#define wxTreeCtrl_SetItemText 2079 +#define wxTreeCtrl_SetItemTextColour 2080 +#define wxTreeCtrl_SetStateImageList 2081 +#define wxTreeCtrl_SetWindowStyle 2082 +#define wxTreeCtrl_SortChildren 2083 +#define wxTreeCtrl_Toggle 2084 +#define wxTreeCtrl_ToggleItemSelection 2085 +#define wxTreeCtrl_Unselect 2086 +#define wxTreeCtrl_UnselectAll 2087 +#define wxTreeCtrl_UnselectItem 2088 +#define wxScrollBar_new_0 2089 +#define wxScrollBar_new_3 2090 +#define wxScrollBar_destruct 2091 +#define wxScrollBar_Create 2092 +#define wxScrollBar_GetRange 2093 +#define wxScrollBar_GetPageSize 2094 +#define wxScrollBar_GetThumbPosition 2095 +#define wxScrollBar_GetThumbSize 2096 +#define wxScrollBar_SetThumbPosition 2097 +#define wxScrollBar_SetScrollbar 2098 +#define wxSpinButton_new_2 2100 +#define wxSpinButton_new_0 2101 +#define wxSpinButton_Create 2102 +#define wxSpinButton_GetMax 2103 +#define wxSpinButton_GetMin 2104 +#define wxSpinButton_GetValue 2105 +#define wxSpinButton_SetRange 2106 +#define wxSpinButton_SetValue 2107 +#define wxSpinButton_destroy 2108 +#define wxSpinCtrl_new_0 2109 +#define wxSpinCtrl_new_2 2110 +#define wxSpinCtrl_Create 2112 +#define wxSpinCtrl_SetValue_1_1 2115 +#define wxSpinCtrl_SetValue_1_0 2116 +#define wxSpinCtrl_GetValue 2118 +#define wxSpinCtrl_SetRange 2120 +#define wxSpinCtrl_SetSelection 2121 +#define wxSpinCtrl_GetMin 2123 +#define wxSpinCtrl_GetMax 2125 +#define wxSpinCtrl_destroy 2126 +#define wxStaticText_new_0 2127 +#define wxStaticText_new_4 2128 +#define wxStaticText_Create 2129 +#define wxStaticText_GetLabel 2130 +#define wxStaticText_SetLabel 2131 +#define wxStaticText_Wrap 2132 +#define wxStaticText_destroy 2133 +#define wxStaticBitmap_new_0 2134 +#define wxStaticBitmap_new_4 2135 +#define wxStaticBitmap_Create 2136 +#define wxStaticBitmap_GetBitmap 2137 +#define wxStaticBitmap_SetBitmap 2138 +#define wxStaticBitmap_destroy 2139 +#define wxRadioBox_new 2140 +#define wxRadioBox_destruct 2142 +#define wxRadioBox_Create 2143 +#define wxRadioBox_Enable_2 2144 +#define wxRadioBox_Enable_1 2145 +#define wxRadioBox_GetSelection 2146 +#define wxRadioBox_GetString 2147 +#define wxRadioBox_SetSelection 2148 +#define wxRadioBox_Show_2 2149 +#define wxRadioBox_Show_1 2150 +#define wxRadioBox_GetColumnCount 2151 +#define wxRadioBox_GetItemHelpText 2152 +#define wxRadioBox_GetItemToolTip 2153 +#define wxRadioBox_GetItemFromPoint 2155 +#define wxRadioBox_GetRowCount 2156 +#define wxRadioBox_IsItemEnabled 2157 +#define wxRadioBox_IsItemShown 2158 +#define wxRadioBox_SetItemHelpText 2159 +#define wxRadioBox_SetItemToolTip 2160 +#define wxRadioButton_new_0 2161 +#define wxRadioButton_new_4 2162 +#define wxRadioButton_Create 2163 +#define wxRadioButton_GetValue 2164 +#define wxRadioButton_SetValue 2165 +#define wxRadioButton_destroy 2166 +#define wxSlider_new_6 2168 +#define wxSlider_new_0 2169 +#define wxSlider_Create 2170 +#define wxSlider_GetLineSize 2171 +#define wxSlider_GetMax 2172 +#define wxSlider_GetMin 2173 +#define wxSlider_GetPageSize 2174 +#define wxSlider_GetThumbLength 2175 +#define wxSlider_GetValue 2176 +#define wxSlider_SetLineSize 2177 +#define wxSlider_SetPageSize 2178 +#define wxSlider_SetRange 2179 +#define wxSlider_SetThumbLength 2180 +#define wxSlider_SetValue 2181 +#define wxSlider_destroy 2182 +#define wxDialog_new_4 2184 +#define wxDialog_new_0 2185 +#define wxDialog_destruct 2187 +#define wxDialog_Create 2188 +#define wxDialog_CreateButtonSizer 2189 +#define wxDialog_CreateStdDialogButtonSizer 2190 +#define wxDialog_EndModal 2191 +#define wxDialog_GetAffirmativeId 2192 +#define wxDialog_GetReturnCode 2193 +#define wxDialog_IsModal 2194 +#define wxDialog_SetAffirmativeId 2195 +#define wxDialog_SetReturnCode 2196 +#define wxDialog_Show 2197 +#define wxDialog_ShowModal 2198 +#define wxColourDialog_new_0 2199 +#define wxColourDialog_new_2 2200 +#define wxColourDialog_destruct 2201 +#define wxColourDialog_Create 2202 +#define wxColourDialog_GetColourData 2203 +#define wxColourData_new_0 2204 +#define wxColourData_new_1 2205 +#define wxColourData_destruct 2206 +#define wxColourData_GetChooseFull 2207 +#define wxColourData_GetColour 2208 +#define wxColourData_GetCustomColour 2210 +#define wxColourData_SetChooseFull 2211 +#define wxColourData_SetColour 2212 +#define wxColourData_SetCustomColour 2213 +#define wxPalette_new_0 2214 +#define wxPalette_new_4 2215 +#define wxPalette_destruct 2217 +#define wxPalette_Create 2218 +#define wxPalette_GetColoursCount 2219 +#define wxPalette_GetPixel 2220 +#define wxPalette_GetRGB 2221 +#define wxPalette_IsOk 2222 +#define wxDirDialog_new 2226 +#define wxDirDialog_destruct 2227 +#define wxDirDialog_GetPath 2228 +#define wxDirDialog_GetMessage 2229 +#define wxDirDialog_SetMessage 2230 +#define wxDirDialog_SetPath 2231 +#define wxFileDialog_new 2235 +#define wxFileDialog_destruct 2236 +#define wxFileDialog_GetDirectory 2237 +#define wxFileDialog_GetFilename 2238 +#define wxFileDialog_GetFilenames 2239 +#define wxFileDialog_GetFilterIndex 2240 +#define wxFileDialog_GetMessage 2241 +#define wxFileDialog_GetPath 2242 +#define wxFileDialog_GetPaths 2243 +#define wxFileDialog_GetWildcard 2244 +#define wxFileDialog_SetDirectory 2245 +#define wxFileDialog_SetFilename 2246 +#define wxFileDialog_SetFilterIndex 2247 +#define wxFileDialog_SetMessage 2248 +#define wxFileDialog_SetPath 2249 +#define wxFileDialog_SetWildcard 2250 +#define wxPickerBase_SetInternalMargin 2251 +#define wxPickerBase_GetInternalMargin 2252 +#define wxPickerBase_SetTextCtrlProportion 2253 +#define wxPickerBase_SetPickerCtrlProportion 2254 +#define wxPickerBase_GetTextCtrlProportion 2255 +#define wxPickerBase_GetPickerCtrlProportion 2256 +#define wxPickerBase_HasTextCtrl 2257 +#define wxPickerBase_GetTextCtrl 2258 +#define wxPickerBase_IsTextCtrlGrowable 2259 +#define wxPickerBase_SetPickerCtrlGrowable 2260 +#define wxPickerBase_SetTextCtrlGrowable 2261 +#define wxPickerBase_IsPickerCtrlGrowable 2262 +#define wxFilePickerCtrl_new_0 2263 +#define wxFilePickerCtrl_new_3 2264 +#define wxFilePickerCtrl_Create 2265 +#define wxFilePickerCtrl_GetPath 2266 +#define wxFilePickerCtrl_SetPath 2267 +#define wxFilePickerCtrl_destroy 2268 +#define wxDirPickerCtrl_new_0 2269 +#define wxDirPickerCtrl_new_3 2270 +#define wxDirPickerCtrl_Create 2271 +#define wxDirPickerCtrl_GetPath 2272 +#define wxDirPickerCtrl_SetPath 2273 +#define wxDirPickerCtrl_destroy 2274 +#define wxColourPickerCtrl_new_0 2275 +#define wxColourPickerCtrl_new_3 2276 +#define wxColourPickerCtrl_Create 2277 +#define wxColourPickerCtrl_GetColour 2278 +#define wxColourPickerCtrl_SetColour_1_1 2279 +#define wxColourPickerCtrl_SetColour_1_0 2280 +#define wxColourPickerCtrl_destroy 2281 +#define wxDatePickerCtrl_new_0 2282 +#define wxDatePickerCtrl_new_3 2283 +#define wxDatePickerCtrl_GetRange 2284 +#define wxDatePickerCtrl_GetValue 2285 +#define wxDatePickerCtrl_SetRange 2286 +#define wxDatePickerCtrl_SetValue 2287 +#define wxDatePickerCtrl_destroy 2288 +#define wxFontPickerCtrl_new_0 2289 +#define wxFontPickerCtrl_new_3 2290 +#define wxFontPickerCtrl_Create 2291 +#define wxFontPickerCtrl_GetSelectedFont 2292 +#define wxFontPickerCtrl_SetSelectedFont 2293 +#define wxFontPickerCtrl_GetMaxPointSize 2294 +#define wxFontPickerCtrl_SetMaxPointSize 2295 +#define wxFontPickerCtrl_destroy 2296 +#define wxFindReplaceDialog_new_0 2299 +#define wxFindReplaceDialog_new_4 2300 +#define wxFindReplaceDialog_destruct 2301 +#define wxFindReplaceDialog_Create 2302 +#define wxFindReplaceDialog_GetData 2303 +#define wxFindReplaceData_new_0 2304 +#define wxFindReplaceData_new_1 2305 +#define wxFindReplaceData_GetFindString 2306 +#define wxFindReplaceData_GetReplaceString 2307 +#define wxFindReplaceData_GetFlags 2308 +#define wxFindReplaceData_SetFlags 2309 +#define wxFindReplaceData_SetFindString 2310 +#define wxFindReplaceData_SetReplaceString 2311 +#define wxFindReplaceData_destroy 2312 +#define wxMultiChoiceDialog_new_0 2313 +#define wxMultiChoiceDialog_new_5 2315 +#define wxMultiChoiceDialog_GetSelections 2316 +#define wxMultiChoiceDialog_SetSelections 2317 +#define wxMultiChoiceDialog_destroy 2318 +#define wxSingleChoiceDialog_new_0 2319 +#define wxSingleChoiceDialog_new_5 2321 +#define wxSingleChoiceDialog_GetSelection 2322 +#define wxSingleChoiceDialog_GetStringSelection 2323 +#define wxSingleChoiceDialog_SetSelection 2324 +#define wxSingleChoiceDialog_destroy 2325 +#define wxTextEntryDialog_new 2326 +#define wxTextEntryDialog_GetValue 2327 +#define wxTextEntryDialog_SetValue 2328 +#define wxTextEntryDialog_destroy 2329 +#define wxPasswordEntryDialog_new 2330 +#define wxPasswordEntryDialog_destroy 2331 +#define wxFontData_new_0 2332 +#define wxFontData_new_1 2333 +#define wxFontData_destruct 2334 +#define wxFontData_EnableEffects 2335 +#define wxFontData_GetAllowSymbols 2336 +#define wxFontData_GetColour 2337 +#define wxFontData_GetChosenFont 2338 +#define wxFontData_GetEnableEffects 2339 +#define wxFontData_GetInitialFont 2340 +#define wxFontData_GetShowHelp 2341 +#define wxFontData_SetAllowSymbols 2342 +#define wxFontData_SetChosenFont 2343 +#define wxFontData_SetColour 2344 +#define wxFontData_SetInitialFont 2345 +#define wxFontData_SetRange 2346 +#define wxFontData_SetShowHelp 2347 +#define wxFontDialog_new_0 2351 +#define wxFontDialog_new_2 2353 +#define wxFontDialog_Create 2355 +#define wxFontDialog_GetFontData 2356 +#define wxFontDialog_destroy 2358 +#define wxProgressDialog_new 2359 +#define wxProgressDialog_destruct 2360 +#define wxProgressDialog_Resume 2361 +#define wxProgressDialog_Update_2 2362 +#define wxProgressDialog_Update_0 2363 +#define wxMessageDialog_new 2364 +#define wxMessageDialog_destruct 2365 +#define wxPageSetupDialog_new 2366 +#define wxPageSetupDialog_destruct 2367 +#define wxPageSetupDialog_GetPageSetupData 2368 +#define wxPageSetupDialog_ShowModal 2369 +#define wxPageSetupDialogData_new_0 2370 +#define wxPageSetupDialogData_new_1_0 2371 +#define wxPageSetupDialogData_new_1_1 2372 +#define wxPageSetupDialogData_destruct 2373 +#define wxPageSetupDialogData_EnableHelp 2374 +#define wxPageSetupDialogData_EnableMargins 2375 +#define wxPageSetupDialogData_EnableOrientation 2376 +#define wxPageSetupDialogData_EnablePaper 2377 +#define wxPageSetupDialogData_EnablePrinter 2378 +#define wxPageSetupDialogData_GetDefaultMinMargins 2379 +#define wxPageSetupDialogData_GetEnableMargins 2380 +#define wxPageSetupDialogData_GetEnableOrientation 2381 +#define wxPageSetupDialogData_GetEnablePaper 2382 +#define wxPageSetupDialogData_GetEnablePrinter 2383 +#define wxPageSetupDialogData_GetEnableHelp 2384 +#define wxPageSetupDialogData_GetDefaultInfo 2385 +#define wxPageSetupDialogData_GetMarginTopLeft 2386 +#define wxPageSetupDialogData_GetMarginBottomRight 2387 +#define wxPageSetupDialogData_GetMinMarginTopLeft 2388 +#define wxPageSetupDialogData_GetMinMarginBottomRight 2389 +#define wxPageSetupDialogData_GetPaperId 2390 +#define wxPageSetupDialogData_GetPaperSize 2391 +#define wxPageSetupDialogData_GetPrintData 2393 +#define wxPageSetupDialogData_IsOk 2394 +#define wxPageSetupDialogData_SetDefaultInfo 2395 +#define wxPageSetupDialogData_SetDefaultMinMargins 2396 +#define wxPageSetupDialogData_SetMarginTopLeft 2397 +#define wxPageSetupDialogData_SetMarginBottomRight 2398 +#define wxPageSetupDialogData_SetMinMarginTopLeft 2399 +#define wxPageSetupDialogData_SetMinMarginBottomRight 2400 +#define wxPageSetupDialogData_SetPaperId 2401 +#define wxPageSetupDialogData_SetPaperSize_1_1 2402 +#define wxPageSetupDialogData_SetPaperSize_1_0 2403 +#define wxPageSetupDialogData_SetPrintData 2404 +#define wxPrintDialog_new_2_0 2405 +#define wxPrintDialog_new_2_1 2406 +#define wxPrintDialog_destruct 2407 +#define wxPrintDialog_GetPrintDialogData 2408 +#define wxPrintDialog_GetPrintDC 2409 +#define wxPrintDialogData_new_0 2410 +#define wxPrintDialogData_new_1_1 2411 +#define wxPrintDialogData_new_1_0 2412 +#define wxPrintDialogData_destruct 2413 +#define wxPrintDialogData_EnableHelp 2414 +#define wxPrintDialogData_EnablePageNumbers 2415 +#define wxPrintDialogData_EnablePrintToFile 2416 +#define wxPrintDialogData_EnableSelection 2417 +#define wxPrintDialogData_GetAllPages 2418 +#define wxPrintDialogData_GetCollate 2419 +#define wxPrintDialogData_GetFromPage 2420 +#define wxPrintDialogData_GetMaxPage 2421 +#define wxPrintDialogData_GetMinPage 2422 +#define wxPrintDialogData_GetNoCopies 2423 +#define wxPrintDialogData_GetPrintData 2424 +#define wxPrintDialogData_GetPrintToFile 2425 +#define wxPrintDialogData_GetSelection 2426 +#define wxPrintDialogData_GetToPage 2427 +#define wxPrintDialogData_IsOk 2428 +#define wxPrintDialogData_SetCollate 2429 +#define wxPrintDialogData_SetFromPage 2430 +#define wxPrintDialogData_SetMaxPage 2431 +#define wxPrintDialogData_SetMinPage 2432 +#define wxPrintDialogData_SetNoCopies 2433 +#define wxPrintDialogData_SetPrintData 2434 +#define wxPrintDialogData_SetPrintToFile 2435 +#define wxPrintDialogData_SetSelection 2436 +#define wxPrintDialogData_SetToPage 2437 +#define wxPrintData_new_0 2438 +#define wxPrintData_new_1 2439 +#define wxPrintData_destruct 2440 +#define wxPrintData_GetCollate 2441 +#define wxPrintData_GetBin 2442 +#define wxPrintData_GetColour 2443 +#define wxPrintData_GetDuplex 2444 +#define wxPrintData_GetNoCopies 2445 +#define wxPrintData_GetOrientation 2446 +#define wxPrintData_GetPaperId 2447 +#define wxPrintData_GetPrinterName 2448 +#define wxPrintData_GetQuality 2449 +#define wxPrintData_IsOk 2450 +#define wxPrintData_SetBin 2451 +#define wxPrintData_SetCollate 2452 +#define wxPrintData_SetColour 2453 +#define wxPrintData_SetDuplex 2454 +#define wxPrintData_SetNoCopies 2455 +#define wxPrintData_SetOrientation 2456 +#define wxPrintData_SetPaperId 2457 +#define wxPrintData_SetPrinterName 2458 +#define wxPrintData_SetQuality 2459 +#define wxPrintPreview_new_2 2462 +#define wxPrintPreview_new_3 2463 +#define wxPrintPreview_destruct 2465 +#define wxPrintPreview_GetCanvas 2466 +#define wxPrintPreview_GetCurrentPage 2467 +#define wxPrintPreview_GetFrame 2468 +#define wxPrintPreview_GetMaxPage 2469 +#define wxPrintPreview_GetMinPage 2470 +#define wxPrintPreview_GetPrintout 2471 +#define wxPrintPreview_GetPrintoutForPrinting 2472 +#define wxPrintPreview_IsOk 2473 +#define wxPrintPreview_PaintPage 2474 +#define wxPrintPreview_Print 2475 +#define wxPrintPreview_RenderPage 2476 +#define wxPrintPreview_SetCanvas 2477 +#define wxPrintPreview_SetCurrentPage 2478 +#define wxPrintPreview_SetFrame 2479 +#define wxPrintPreview_SetPrintout 2480 +#define wxPrintPreview_SetZoom 2481 +#define wxPreviewFrame_new 2482 +#define wxPreviewFrame_destruct 2483 +#define wxPreviewFrame_CreateControlBar 2484 +#define wxPreviewFrame_CreateCanvas 2485 +#define wxPreviewFrame_Initialize 2486 +#define wxPreviewFrame_OnCloseWindow 2487 +#define wxPreviewControlBar_new 2488 +#define wxPreviewControlBar_destruct 2489 +#define wxPreviewControlBar_CreateButtons 2490 +#define wxPreviewControlBar_GetPrintPreview 2491 +#define wxPreviewControlBar_GetZoomControl 2492 +#define wxPreviewControlBar_SetZoomControl 2493 +#define wxPrinter_new 2495 +#define wxPrinter_CreateAbortWindow 2496 +#define wxPrinter_GetAbort 2497 +#define wxPrinter_GetLastError 2498 +#define wxPrinter_GetPrintDialogData 2499 +#define wxPrinter_Print 2500 +#define wxPrinter_PrintDialog 2501 +#define wxPrinter_ReportError 2502 +#define wxPrinter_Setup 2503 +#define wxPrinter_destroy 2504 +#define wxXmlResource_new_1 2505 +#define wxXmlResource_new_2 2506 +#define wxXmlResource_destruct 2507 +#define wxXmlResource_AttachUnknownControl 2508 +#define wxXmlResource_ClearHandlers 2509 +#define wxXmlResource_CompareVersion 2510 +#define wxXmlResource_Get 2511 +#define wxXmlResource_GetFlags 2512 +#define wxXmlResource_GetVersion 2513 +#define wxXmlResource_GetXRCID 2514 +#define wxXmlResource_InitAllHandlers 2515 +#define wxXmlResource_Load 2516 +#define wxXmlResource_LoadBitmap 2517 +#define wxXmlResource_LoadDialog_2 2518 +#define wxXmlResource_LoadDialog_3 2519 +#define wxXmlResource_LoadFrame_2 2520 +#define wxXmlResource_LoadFrame_3 2521 +#define wxXmlResource_LoadIcon 2522 +#define wxXmlResource_LoadMenu 2523 +#define wxXmlResource_LoadMenuBar_2 2524 +#define wxXmlResource_LoadMenuBar_1 2525 +#define wxXmlResource_LoadPanel_2 2526 +#define wxXmlResource_LoadPanel_3 2527 +#define wxXmlResource_LoadToolBar 2528 +#define wxXmlResource_Set 2529 +#define wxXmlResource_SetFlags 2530 +#define wxXmlResource_Unload 2531 +#define wxXmlResource_xrcctrl 2532 +#define wxHtmlEasyPrinting_new 2533 +#define wxHtmlEasyPrinting_destruct 2534 +#define wxHtmlEasyPrinting_GetPrintData 2535 +#define wxHtmlEasyPrinting_GetPageSetupData 2536 +#define wxHtmlEasyPrinting_PreviewFile 2537 +#define wxHtmlEasyPrinting_PreviewText 2538 +#define wxHtmlEasyPrinting_PrintFile 2539 +#define wxHtmlEasyPrinting_PrintText 2540 +#define wxHtmlEasyPrinting_PageSetup 2541 +#define wxHtmlEasyPrinting_SetFonts 2542 +#define wxHtmlEasyPrinting_SetHeader 2543 +#define wxHtmlEasyPrinting_SetFooter 2544 +#define wxGLCanvas_new_2 2546 +#define wxGLCanvas_new_3_1 2547 +#define wxGLCanvas_new_3_0 2548 +#define wxGLCanvas_GetContext 2549 +#define wxGLCanvas_SetCurrent 2551 +#define wxGLCanvas_SwapBuffers 2552 +#define wxGLCanvas_destroy 2553 +#define wxAuiManager_new 2554 +#define wxAuiManager_destruct 2555 +#define wxAuiManager_AddPane_2_1 2556 +#define wxAuiManager_AddPane_3 2557 +#define wxAuiManager_AddPane_2_0 2558 +#define wxAuiManager_DetachPane 2559 +#define wxAuiManager_GetAllPanes 2560 +#define wxAuiManager_GetArtProvider 2561 +#define wxAuiManager_GetDockSizeConstraint 2562 +#define wxAuiManager_GetFlags 2563 +#define wxAuiManager_GetManagedWindow 2564 +#define wxAuiManager_GetManager 2565 +#define wxAuiManager_GetPane_1_1 2566 +#define wxAuiManager_GetPane_1_0 2567 +#define wxAuiManager_HideHint 2568 +#define wxAuiManager_InsertPane 2569 +#define wxAuiManager_LoadPaneInfo 2570 +#define wxAuiManager_LoadPerspective 2571 +#define wxAuiManager_SavePaneInfo 2572 +#define wxAuiManager_SavePerspective 2573 +#define wxAuiManager_SetArtProvider 2574 +#define wxAuiManager_SetDockSizeConstraint 2575 +#define wxAuiManager_SetFlags 2576 +#define wxAuiManager_SetManagedWindow 2577 +#define wxAuiManager_ShowHint 2578 +#define wxAuiManager_UnInit 2579 +#define wxAuiManager_Update 2580 +#define wxAuiPaneInfo_new_0 2581 +#define wxAuiPaneInfo_new_1 2582 +#define wxAuiPaneInfo_destruct 2583 +#define wxAuiPaneInfo_BestSize_1 2584 +#define wxAuiPaneInfo_BestSize_2 2585 +#define wxAuiPaneInfo_Bottom 2586 +#define wxAuiPaneInfo_BottomDockable 2587 +#define wxAuiPaneInfo_Caption 2588 +#define wxAuiPaneInfo_CaptionVisible 2589 +#define wxAuiPaneInfo_Centre 2590 +#define wxAuiPaneInfo_CentrePane 2591 +#define wxAuiPaneInfo_CloseButton 2592 +#define wxAuiPaneInfo_DefaultPane 2593 +#define wxAuiPaneInfo_DestroyOnClose 2594 +#define wxAuiPaneInfo_Direction 2595 +#define wxAuiPaneInfo_Dock 2596 +#define wxAuiPaneInfo_Dockable 2597 +#define wxAuiPaneInfo_Fixed 2598 +#define wxAuiPaneInfo_Float 2599 +#define wxAuiPaneInfo_Floatable 2600 +#define wxAuiPaneInfo_FloatingPosition_1 2601 +#define wxAuiPaneInfo_FloatingPosition_2 2602 +#define wxAuiPaneInfo_FloatingSize_1 2603 +#define wxAuiPaneInfo_FloatingSize_2 2604 +#define wxAuiPaneInfo_Gripper 2605 +#define wxAuiPaneInfo_GripperTop 2606 +#define wxAuiPaneInfo_HasBorder 2607 +#define wxAuiPaneInfo_HasCaption 2608 +#define wxAuiPaneInfo_HasCloseButton 2609 +#define wxAuiPaneInfo_HasFlag 2610 +#define wxAuiPaneInfo_HasGripper 2611 +#define wxAuiPaneInfo_HasGripperTop 2612 +#define wxAuiPaneInfo_HasMaximizeButton 2613 +#define wxAuiPaneInfo_HasMinimizeButton 2614 +#define wxAuiPaneInfo_HasPinButton 2615 +#define wxAuiPaneInfo_Hide 2616 +#define wxAuiPaneInfo_IsBottomDockable 2617 +#define wxAuiPaneInfo_IsDocked 2618 +#define wxAuiPaneInfo_IsFixed 2619 +#define wxAuiPaneInfo_IsFloatable 2620 +#define wxAuiPaneInfo_IsFloating 2621 +#define wxAuiPaneInfo_IsLeftDockable 2622 +#define wxAuiPaneInfo_IsMovable 2623 +#define wxAuiPaneInfo_IsOk 2624 +#define wxAuiPaneInfo_IsResizable 2625 +#define wxAuiPaneInfo_IsRightDockable 2626 +#define wxAuiPaneInfo_IsShown 2627 +#define wxAuiPaneInfo_IsToolbar 2628 +#define wxAuiPaneInfo_IsTopDockable 2629 +#define wxAuiPaneInfo_Layer 2630 +#define wxAuiPaneInfo_Left 2631 +#define wxAuiPaneInfo_LeftDockable 2632 +#define wxAuiPaneInfo_MaxSize_1 2633 +#define wxAuiPaneInfo_MaxSize_2 2634 +#define wxAuiPaneInfo_MaximizeButton 2635 +#define wxAuiPaneInfo_MinSize_1 2636 +#define wxAuiPaneInfo_MinSize_2 2637 +#define wxAuiPaneInfo_MinimizeButton 2638 +#define wxAuiPaneInfo_Movable 2639 +#define wxAuiPaneInfo_Name 2640 +#define wxAuiPaneInfo_PaneBorder 2641 +#define wxAuiPaneInfo_PinButton 2642 +#define wxAuiPaneInfo_Position 2643 +#define wxAuiPaneInfo_Resizable 2644 +#define wxAuiPaneInfo_Right 2645 +#define wxAuiPaneInfo_RightDockable 2646 +#define wxAuiPaneInfo_Row 2647 +#define wxAuiPaneInfo_SafeSet 2648 +#define wxAuiPaneInfo_SetFlag 2649 +#define wxAuiPaneInfo_Show 2650 +#define wxAuiPaneInfo_ToolbarPane 2651 +#define wxAuiPaneInfo_Top 2652 +#define wxAuiPaneInfo_TopDockable 2653 +#define wxAuiPaneInfo_Window 2654 +#define wxAuiPaneInfo_GetWindow 2655 +#define wxAuiPaneInfo_GetFrame 2656 +#define wxAuiPaneInfo_GetDirection 2657 +#define wxAuiPaneInfo_GetLayer 2658 +#define wxAuiPaneInfo_GetRow 2659 +#define wxAuiPaneInfo_GetPosition 2660 +#define wxAuiPaneInfo_GetFloatingPosition 2661 +#define wxAuiPaneInfo_GetFloatingSize 2662 +#define wxAuiNotebook_new_0 2663 +#define wxAuiNotebook_new_2 2664 +#define wxAuiNotebook_AddPage 2665 +#define wxAuiNotebook_Create 2666 +#define wxAuiNotebook_DeletePage 2667 +#define wxAuiNotebook_GetArtProvider 2668 +#define wxAuiNotebook_GetPage 2669 +#define wxAuiNotebook_GetPageBitmap 2670 +#define wxAuiNotebook_GetPageCount 2671 +#define wxAuiNotebook_GetPageIndex 2672 +#define wxAuiNotebook_GetPageText 2673 +#define wxAuiNotebook_GetSelection 2674 +#define wxAuiNotebook_InsertPage 2675 +#define wxAuiNotebook_RemovePage 2676 +#define wxAuiNotebook_SetArtProvider 2677 +#define wxAuiNotebook_SetFont 2678 +#define wxAuiNotebook_SetPageBitmap 2679 +#define wxAuiNotebook_SetPageText 2680 +#define wxAuiNotebook_SetSelection 2681 +#define wxAuiNotebook_SetTabCtrlHeight 2682 +#define wxAuiNotebook_SetUniformBitmapSize 2683 +#define wxAuiNotebook_destroy 2684 +#define wxAuiTabArt_SetFlags 2685 +#define wxAuiTabArt_SetMeasuringFont 2686 +#define wxAuiTabArt_SetNormalFont 2687 +#define wxAuiTabArt_SetSelectedFont 2688 +#define wxAuiTabArt_SetColour 2689 +#define wxAuiTabArt_SetActiveColour 2690 +#define wxAuiDockArt_GetColour 2691 +#define wxAuiDockArt_GetFont 2692 +#define wxAuiDockArt_GetMetric 2693 +#define wxAuiDockArt_SetColour 2694 +#define wxAuiDockArt_SetFont 2695 +#define wxAuiDockArt_SetMetric 2696 +#define wxAuiSimpleTabArt_new 2697 +#define wxAuiSimpleTabArt_destroy 2698 +#define wxMDIParentFrame_new_0 2699 +#define wxMDIParentFrame_new_4 2700 +#define wxMDIParentFrame_destruct 2701 +#define wxMDIParentFrame_ActivateNext 2702 +#define wxMDIParentFrame_ActivatePrevious 2703 +#define wxMDIParentFrame_ArrangeIcons 2704 +#define wxMDIParentFrame_Cascade 2705 +#define wxMDIParentFrame_Create 2706 +#define wxMDIParentFrame_GetActiveChild 2707 +#define wxMDIParentFrame_GetClientWindow 2708 +#define wxMDIParentFrame_Tile 2709 +#define wxMDIChildFrame_new_0 2710 +#define wxMDIChildFrame_new_4 2711 +#define wxMDIChildFrame_destruct 2712 +#define wxMDIChildFrame_Activate 2713 +#define wxMDIChildFrame_Create 2714 +#define wxMDIChildFrame_Maximize 2715 +#define wxMDIChildFrame_Restore 2716 +#define wxMDIClientWindow_new_0 2717 +#define wxMDIClientWindow_new_2 2718 +#define wxMDIClientWindow_destruct 2719 +#define wxMDIClientWindow_CreateClient 2720 +#define wxLayoutAlgorithm_new 2721 +#define wxLayoutAlgorithm_LayoutFrame 2722 +#define wxLayoutAlgorithm_LayoutMDIFrame 2723 +#define wxLayoutAlgorithm_LayoutWindow 2724 +#define wxLayoutAlgorithm_destroy 2725 +#define wxEvent_GetId 2726 +#define wxEvent_GetSkipped 2727 +#define wxEvent_GetTimestamp 2728 +#define wxEvent_IsCommandEvent 2729 +#define wxEvent_ResumePropagation 2730 +#define wxEvent_ShouldPropagate 2731 +#define wxEvent_Skip 2732 +#define wxEvent_StopPropagation 2733 +#define wxCommandEvent_getClientData 2734 +#define wxCommandEvent_GetExtraLong 2735 +#define wxCommandEvent_GetInt 2736 +#define wxCommandEvent_GetSelection 2737 +#define wxCommandEvent_GetString 2738 +#define wxCommandEvent_IsChecked 2739 +#define wxCommandEvent_IsSelection 2740 +#define wxCommandEvent_SetInt 2741 +#define wxCommandEvent_SetString 2742 +#define wxScrollEvent_GetOrientation 2743 +#define wxScrollEvent_GetPosition 2744 +#define wxScrollWinEvent_GetOrientation 2745 +#define wxScrollWinEvent_GetPosition 2746 +#define wxMouseEvent_AltDown 2747 +#define wxMouseEvent_Button 2748 +#define wxMouseEvent_ButtonDClick 2749 +#define wxMouseEvent_ButtonDown 2750 +#define wxMouseEvent_ButtonUp 2751 +#define wxMouseEvent_CmdDown 2752 +#define wxMouseEvent_ControlDown 2753 +#define wxMouseEvent_Dragging 2754 +#define wxMouseEvent_Entering 2755 +#define wxMouseEvent_GetButton 2756 +#define wxMouseEvent_GetPosition 2759 +#define wxMouseEvent_GetLogicalPosition 2760 +#define wxMouseEvent_GetLinesPerAction 2761 +#define wxMouseEvent_GetWheelRotation 2762 +#define wxMouseEvent_GetWheelDelta 2763 +#define wxMouseEvent_GetX 2764 +#define wxMouseEvent_GetY 2765 +#define wxMouseEvent_IsButton 2766 +#define wxMouseEvent_IsPageScroll 2767 +#define wxMouseEvent_Leaving 2768 +#define wxMouseEvent_LeftDClick 2769 +#define wxMouseEvent_LeftDown 2770 +#define wxMouseEvent_LeftIsDown 2771 +#define wxMouseEvent_LeftUp 2772 +#define wxMouseEvent_MetaDown 2773 +#define wxMouseEvent_MiddleDClick 2774 +#define wxMouseEvent_MiddleDown 2775 +#define wxMouseEvent_MiddleIsDown 2776 +#define wxMouseEvent_MiddleUp 2777 +#define wxMouseEvent_Moving 2778 +#define wxMouseEvent_RightDClick 2779 +#define wxMouseEvent_RightDown 2780 +#define wxMouseEvent_RightIsDown 2781 +#define wxMouseEvent_RightUp 2782 +#define wxMouseEvent_ShiftDown 2783 +#define wxSetCursorEvent_GetCursor 2784 +#define wxSetCursorEvent_GetX 2785 +#define wxSetCursorEvent_GetY 2786 +#define wxSetCursorEvent_HasCursor 2787 +#define wxSetCursorEvent_SetCursor 2788 +#define wxKeyEvent_AltDown 2789 +#define wxKeyEvent_CmdDown 2790 +#define wxKeyEvent_ControlDown 2791 +#define wxKeyEvent_GetKeyCode 2792 +#define wxKeyEvent_GetModifiers 2793 +#define wxKeyEvent_GetPosition 2796 +#define wxKeyEvent_GetRawKeyCode 2797 +#define wxKeyEvent_GetRawKeyFlags 2798 +#define wxKeyEvent_GetUnicodeKey 2799 +#define wxKeyEvent_GetX 2800 +#define wxKeyEvent_GetY 2801 +#define wxKeyEvent_HasModifiers 2802 +#define wxKeyEvent_MetaDown 2803 +#define wxKeyEvent_ShiftDown 2804 +#define wxSizeEvent_GetSize 2805 +#define wxMoveEvent_GetPosition 2806 +#define wxEraseEvent_GetDC 2807 +#define wxFocusEvent_GetWindow 2808 +#define wxChildFocusEvent_GetWindow 2809 +#define wxMenuEvent_GetMenu 2810 +#define wxMenuEvent_GetMenuId 2811 +#define wxMenuEvent_IsPopup 2812 +#define wxCloseEvent_CanVeto 2813 +#define wxCloseEvent_GetLoggingOff 2814 +#define wxCloseEvent_SetCanVeto 2815 +#define wxCloseEvent_SetLoggingOff 2816 +#define wxCloseEvent_Veto 2817 +#define wxShowEvent_SetShow 2818 +#define wxShowEvent_GetShow 2819 +#define wxIconizeEvent_Iconized 2820 +#define wxJoystickEvent_ButtonDown 2821 +#define wxJoystickEvent_ButtonIsDown 2822 +#define wxJoystickEvent_ButtonUp 2823 +#define wxJoystickEvent_GetButtonChange 2824 +#define wxJoystickEvent_GetButtonState 2825 +#define wxJoystickEvent_GetJoystick 2826 +#define wxJoystickEvent_GetPosition 2827 +#define wxJoystickEvent_GetZPosition 2828 +#define wxJoystickEvent_IsButton 2829 +#define wxJoystickEvent_IsMove 2830 +#define wxJoystickEvent_IsZMove 2831 +#define wxUpdateUIEvent_CanUpdate 2832 +#define wxUpdateUIEvent_Check 2833 +#define wxUpdateUIEvent_Enable 2834 +#define wxUpdateUIEvent_Show 2835 +#define wxUpdateUIEvent_GetChecked 2836 +#define wxUpdateUIEvent_GetEnabled 2837 +#define wxUpdateUIEvent_GetShown 2838 +#define wxUpdateUIEvent_GetSetChecked 2839 +#define wxUpdateUIEvent_GetSetEnabled 2840 +#define wxUpdateUIEvent_GetSetShown 2841 +#define wxUpdateUIEvent_GetSetText 2842 +#define wxUpdateUIEvent_GetText 2843 +#define wxUpdateUIEvent_GetMode 2844 +#define wxUpdateUIEvent_GetUpdateInterval 2845 +#define wxUpdateUIEvent_ResetUpdateTime 2846 +#define wxUpdateUIEvent_SetMode 2847 +#define wxUpdateUIEvent_SetText 2848 +#define wxUpdateUIEvent_SetUpdateInterval 2849 +#define wxMouseCaptureChangedEvent_GetCapturedWindow 2850 +#define wxPaletteChangedEvent_SetChangedWindow 2851 +#define wxPaletteChangedEvent_GetChangedWindow 2852 +#define wxQueryNewPaletteEvent_SetPaletteRealized 2853 +#define wxQueryNewPaletteEvent_GetPaletteRealized 2854 +#define wxNavigationKeyEvent_GetDirection 2855 +#define wxNavigationKeyEvent_SetDirection 2856 +#define wxNavigationKeyEvent_IsWindowChange 2857 +#define wxNavigationKeyEvent_SetWindowChange 2858 +#define wxNavigationKeyEvent_IsFromTab 2859 +#define wxNavigationKeyEvent_SetFromTab 2860 +#define wxNavigationKeyEvent_GetCurrentFocus 2861 +#define wxNavigationKeyEvent_SetCurrentFocus 2862 +#define wxHelpEvent_GetOrigin 2863 +#define wxHelpEvent_GetPosition 2864 +#define wxHelpEvent_SetOrigin 2865 +#define wxHelpEvent_SetPosition 2866 +#define wxContextMenuEvent_GetPosition 2867 +#define wxContextMenuEvent_SetPosition 2868 +#define wxIdleEvent_CanSend 2869 +#define wxIdleEvent_GetMode 2870 +#define wxIdleEvent_RequestMore 2871 +#define wxIdleEvent_MoreRequested 2872 +#define wxIdleEvent_SetMode 2873 +#define wxGridEvent_AltDown 2874 +#define wxGridEvent_ControlDown 2875 +#define wxGridEvent_GetCol 2876 +#define wxGridEvent_GetPosition 2877 +#define wxGridEvent_GetRow 2878 +#define wxGridEvent_MetaDown 2879 +#define wxGridEvent_Selecting 2880 +#define wxGridEvent_ShiftDown 2881 +#define wxNotifyEvent_Allow 2882 +#define wxNotifyEvent_IsAllowed 2883 +#define wxNotifyEvent_Veto 2884 +#define wxSashEvent_GetEdge 2885 +#define wxSashEvent_GetDragRect 2886 +#define wxSashEvent_GetDragStatus 2887 +#define wxListEvent_GetCacheFrom 2888 +#define wxListEvent_GetCacheTo 2889 +#define wxListEvent_GetKeyCode 2890 +#define wxListEvent_GetIndex 2891 +#define wxListEvent_GetColumn 2892 +#define wxListEvent_GetPoint 2893 +#define wxListEvent_GetLabel 2894 +#define wxListEvent_GetText 2895 +#define wxListEvent_GetImage 2896 +#define wxListEvent_GetData 2897 +#define wxListEvent_GetMask 2898 +#define wxListEvent_GetItem 2899 +#define wxListEvent_IsEditCancelled 2900 +#define wxDateEvent_GetDate 2901 +#define wxCalendarEvent_GetWeekDay 2902 +#define wxFileDirPickerEvent_GetPath 2903 +#define wxColourPickerEvent_GetColour 2904 +#define wxFontPickerEvent_GetFont 2905 +#define wxStyledTextEvent_GetPosition 2906 +#define wxStyledTextEvent_GetKey 2907 +#define wxStyledTextEvent_GetModifiers 2908 +#define wxStyledTextEvent_GetModificationType 2909 +#define wxStyledTextEvent_GetText 2910 +#define wxStyledTextEvent_GetLength 2911 +#define wxStyledTextEvent_GetLinesAdded 2912 +#define wxStyledTextEvent_GetLine 2913 +#define wxStyledTextEvent_GetFoldLevelNow 2914 +#define wxStyledTextEvent_GetFoldLevelPrev 2915 +#define wxStyledTextEvent_GetMargin 2916 +#define wxStyledTextEvent_GetMessage 2917 +#define wxStyledTextEvent_GetWParam 2918 +#define wxStyledTextEvent_GetLParam 2919 +#define wxStyledTextEvent_GetListType 2920 +#define wxStyledTextEvent_GetX 2921 +#define wxStyledTextEvent_GetY 2922 +#define wxStyledTextEvent_GetDragText 2923 +#define wxStyledTextEvent_GetDragAllowMove 2924 +#define wxStyledTextEvent_GetDragResult 2925 +#define wxStyledTextEvent_GetShift 2926 +#define wxStyledTextEvent_GetControl 2927 +#define wxStyledTextEvent_GetAlt 2928 +#define utils_wxGetKeyState 2929 +#define utils_wxGetMousePosition 2930 +#define utils_wxGetMouseState 2931 +#define utils_wxSetDetectableAutoRepeat 2932 +#define utils_wxBell 2933 +#define utils_wxFindMenuItemId 2934 +#define utils_wxGenericFindWindowAtPoint 2935 +#define utils_wxFindWindowAtPoint 2936 +#define utils_wxBeginBusyCursor 2937 +#define utils_wxEndBusyCursor 2938 +#define utils_wxIsBusy 2939 +#define utils_wxShutdown 2940 +#define utils_wxShell 2941 +#define utils_wxLaunchDefaultBrowser 2942 +#define utils_wxGetEmailAddress 2943 +#define utils_wxGetUserId 2944 +#define utils_wxGetHomeDir 2945 +#define utils_wxNewId 2946 +#define utils_wxRegisterId 2947 +#define utils_wxGetCurrentId 2948 +#define utils_wxGetOsDescription 2949 +#define utils_wxIsPlatformLittleEndian 2950 +#define utils_wxIsPlatform64Bit 2951 +#define gdicmn_wxDisplaySize 2952 +#define gdicmn_wxSetCursor 2953 +#define wxPrintout_new 2954 +#define wxPrintout_destruct 2955 +#define wxPrintout_GetDC 2956 +#define wxPrintout_GetPageSizeMM 2957 +#define wxPrintout_GetPageSizePixels 2958 +#define wxPrintout_GetPaperRectPixels 2959 +#define wxPrintout_GetPPIPrinter 2960 +#define wxPrintout_GetPPIScreen 2961 +#define wxPrintout_GetTitle 2962 +#define wxPrintout_IsPreview 2963 +#define wxPrintout_FitThisSizeToPaper 2964 +#define wxPrintout_FitThisSizeToPage 2965 +#define wxPrintout_FitThisSizeToPageMargins 2966 +#define wxPrintout_MapScreenSizeToPaper 2967 +#define wxPrintout_MapScreenSizeToPage 2968 +#define wxPrintout_MapScreenSizeToPageMargins 2969 +#define wxPrintout_MapScreenSizeToDevice 2970 +#define wxPrintout_GetLogicalPaperRect 2971 +#define wxPrintout_GetLogicalPageRect 2972 +#define wxPrintout_GetLogicalPageMarginsRect 2973 +#define wxPrintout_SetLogicalOrigin 2974 +#define wxPrintout_OffsetLogicalOrigin 2975 +#define wxStyledTextCtrl_new_2 2976 +#define wxStyledTextCtrl_new_0 2977 +#define wxStyledTextCtrl_destruct 2978 +#define wxStyledTextCtrl_Create 2979 +#define wxStyledTextCtrl_AddText 2980 +#define wxStyledTextCtrl_AddStyledText 2981 +#define wxStyledTextCtrl_InsertText 2982 +#define wxStyledTextCtrl_ClearAll 2983 +#define wxStyledTextCtrl_ClearDocumentStyle 2984 +#define wxStyledTextCtrl_GetLength 2985 +#define wxStyledTextCtrl_GetCharAt 2986 +#define wxStyledTextCtrl_GetCurrentPos 2987 +#define wxStyledTextCtrl_GetAnchor 2988 +#define wxStyledTextCtrl_GetStyleAt 2989 +#define wxStyledTextCtrl_Redo 2990 +#define wxStyledTextCtrl_SetUndoCollection 2991 +#define wxStyledTextCtrl_SelectAll 2992 +#define wxStyledTextCtrl_SetSavePoint 2993 +#define wxStyledTextCtrl_GetStyledText 2994 +#define wxStyledTextCtrl_CanRedo 2995 +#define wxStyledTextCtrl_MarkerLineFromHandle 2996 +#define wxStyledTextCtrl_MarkerDeleteHandle 2997 +#define wxStyledTextCtrl_GetUndoCollection 2998 +#define wxStyledTextCtrl_GetViewWhiteSpace 2999 +#define wxStyledTextCtrl_SetViewWhiteSpace 3000 +#define wxStyledTextCtrl_PositionFromPoint 3001 +#define wxStyledTextCtrl_PositionFromPointClose 3002 +#define wxStyledTextCtrl_GotoLine 3003 +#define wxStyledTextCtrl_GotoPos 3004 +#define wxStyledTextCtrl_SetAnchor 3005 +#define wxStyledTextCtrl_GetCurLine 3006 +#define wxStyledTextCtrl_GetEndStyled 3007 +#define wxStyledTextCtrl_ConvertEOLs 3008 +#define wxStyledTextCtrl_GetEOLMode 3009 +#define wxStyledTextCtrl_SetEOLMode 3010 +#define wxStyledTextCtrl_StartStyling 3011 +#define wxStyledTextCtrl_SetStyling 3012 +#define wxStyledTextCtrl_GetBufferedDraw 3013 +#define wxStyledTextCtrl_SetBufferedDraw 3014 +#define wxStyledTextCtrl_SetTabWidth 3015 +#define wxStyledTextCtrl_GetTabWidth 3016 +#define wxStyledTextCtrl_SetCodePage 3017 +#define wxStyledTextCtrl_MarkerDefine 3018 +#define wxStyledTextCtrl_MarkerSetForeground 3019 +#define wxStyledTextCtrl_MarkerSetBackground 3020 +#define wxStyledTextCtrl_MarkerAdd 3021 +#define wxStyledTextCtrl_MarkerDelete 3022 +#define wxStyledTextCtrl_MarkerDeleteAll 3023 +#define wxStyledTextCtrl_MarkerGet 3024 +#define wxStyledTextCtrl_MarkerNext 3025 +#define wxStyledTextCtrl_MarkerPrevious 3026 +#define wxStyledTextCtrl_MarkerDefineBitmap 3027 +#define wxStyledTextCtrl_MarkerAddSet 3028 +#define wxStyledTextCtrl_MarkerSetAlpha 3029 +#define wxStyledTextCtrl_SetMarginType 3030 +#define wxStyledTextCtrl_GetMarginType 3031 +#define wxStyledTextCtrl_SetMarginWidth 3032 +#define wxStyledTextCtrl_GetMarginWidth 3033 +#define wxStyledTextCtrl_SetMarginMask 3034 +#define wxStyledTextCtrl_GetMarginMask 3035 +#define wxStyledTextCtrl_SetMarginSensitive 3036 +#define wxStyledTextCtrl_GetMarginSensitive 3037 +#define wxStyledTextCtrl_StyleClearAll 3038 +#define wxStyledTextCtrl_StyleSetForeground 3039 +#define wxStyledTextCtrl_StyleSetBackground 3040 +#define wxStyledTextCtrl_StyleSetBold 3041 +#define wxStyledTextCtrl_StyleSetItalic 3042 +#define wxStyledTextCtrl_StyleSetSize 3043 +#define wxStyledTextCtrl_StyleSetFaceName 3044 +#define wxStyledTextCtrl_StyleSetEOLFilled 3045 +#define wxStyledTextCtrl_StyleResetDefault 3046 +#define wxStyledTextCtrl_StyleSetUnderline 3047 +#define wxStyledTextCtrl_StyleSetCase 3048 +#define wxStyledTextCtrl_StyleSetHotSpot 3049 +#define wxStyledTextCtrl_SetSelForeground 3050 +#define wxStyledTextCtrl_SetSelBackground 3051 +#define wxStyledTextCtrl_GetSelAlpha 3052 +#define wxStyledTextCtrl_SetSelAlpha 3053 +#define wxStyledTextCtrl_SetCaretForeground 3054 +#define wxStyledTextCtrl_CmdKeyAssign 3055 +#define wxStyledTextCtrl_CmdKeyClear 3056 +#define wxStyledTextCtrl_CmdKeyClearAll 3057 +#define wxStyledTextCtrl_SetStyleBytes 3058 +#define wxStyledTextCtrl_StyleSetVisible 3059 +#define wxStyledTextCtrl_GetCaretPeriod 3060 +#define wxStyledTextCtrl_SetCaretPeriod 3061 +#define wxStyledTextCtrl_SetWordChars 3062 +#define wxStyledTextCtrl_BeginUndoAction 3063 +#define wxStyledTextCtrl_EndUndoAction 3064 +#define wxStyledTextCtrl_IndicatorSetStyle 3065 +#define wxStyledTextCtrl_IndicatorGetStyle 3066 +#define wxStyledTextCtrl_IndicatorSetForeground 3067 +#define wxStyledTextCtrl_IndicatorGetForeground 3068 +#define wxStyledTextCtrl_SetWhitespaceForeground 3069 +#define wxStyledTextCtrl_SetWhitespaceBackground 3070 +#define wxStyledTextCtrl_GetStyleBits 3071 +#define wxStyledTextCtrl_SetLineState 3072 +#define wxStyledTextCtrl_GetLineState 3073 +#define wxStyledTextCtrl_GetMaxLineState 3074 +#define wxStyledTextCtrl_GetCaretLineVisible 3075 +#define wxStyledTextCtrl_SetCaretLineVisible 3076 +#define wxStyledTextCtrl_GetCaretLineBackground 3077 +#define wxStyledTextCtrl_SetCaretLineBackground 3078 +#define wxStyledTextCtrl_AutoCompShow 3079 +#define wxStyledTextCtrl_AutoCompCancel 3080 +#define wxStyledTextCtrl_AutoCompActive 3081 +#define wxStyledTextCtrl_AutoCompPosStart 3082 +#define wxStyledTextCtrl_AutoCompComplete 3083 +#define wxStyledTextCtrl_AutoCompStops 3084 +#define wxStyledTextCtrl_AutoCompSetSeparator 3085 +#define wxStyledTextCtrl_AutoCompGetSeparator 3086 +#define wxStyledTextCtrl_AutoCompSelect 3087 +#define wxStyledTextCtrl_AutoCompSetCancelAtStart 3088 +#define wxStyledTextCtrl_AutoCompGetCancelAtStart 3089 +#define wxStyledTextCtrl_AutoCompSetFillUps 3090 +#define wxStyledTextCtrl_AutoCompSetChooseSingle 3091 +#define wxStyledTextCtrl_AutoCompGetChooseSingle 3092 +#define wxStyledTextCtrl_AutoCompSetIgnoreCase 3093 +#define wxStyledTextCtrl_AutoCompGetIgnoreCase 3094 +#define wxStyledTextCtrl_UserListShow 3095 +#define wxStyledTextCtrl_AutoCompSetAutoHide 3096 +#define wxStyledTextCtrl_AutoCompGetAutoHide 3097 +#define wxStyledTextCtrl_AutoCompSetDropRestOfWord 3098 +#define wxStyledTextCtrl_AutoCompGetDropRestOfWord 3099 +#define wxStyledTextCtrl_RegisterImage 3100 +#define wxStyledTextCtrl_ClearRegisteredImages 3101 +#define wxStyledTextCtrl_AutoCompGetTypeSeparator 3102 +#define wxStyledTextCtrl_AutoCompSetTypeSeparator 3103 +#define wxStyledTextCtrl_AutoCompSetMaxWidth 3104 +#define wxStyledTextCtrl_AutoCompGetMaxWidth 3105 +#define wxStyledTextCtrl_AutoCompSetMaxHeight 3106 +#define wxStyledTextCtrl_AutoCompGetMaxHeight 3107 +#define wxStyledTextCtrl_SetIndent 3108 +#define wxStyledTextCtrl_GetIndent 3109 +#define wxStyledTextCtrl_SetUseTabs 3110 +#define wxStyledTextCtrl_GetUseTabs 3111 +#define wxStyledTextCtrl_SetLineIndentation 3112 +#define wxStyledTextCtrl_GetLineIndentation 3113 +#define wxStyledTextCtrl_GetLineIndentPosition 3114 +#define wxStyledTextCtrl_GetColumn 3115 +#define wxStyledTextCtrl_SetUseHorizontalScrollBar 3116 +#define wxStyledTextCtrl_GetUseHorizontalScrollBar 3117 +#define wxStyledTextCtrl_SetIndentationGuides 3118 +#define wxStyledTextCtrl_GetIndentationGuides 3119 +#define wxStyledTextCtrl_SetHighlightGuide 3120 +#define wxStyledTextCtrl_GetHighlightGuide 3121 +#define wxStyledTextCtrl_GetLineEndPosition 3122 +#define wxStyledTextCtrl_GetCodePage 3123 +#define wxStyledTextCtrl_GetCaretForeground 3124 +#define wxStyledTextCtrl_GetReadOnly 3125 +#define wxStyledTextCtrl_SetCurrentPos 3126 +#define wxStyledTextCtrl_SetSelectionStart 3127 +#define wxStyledTextCtrl_GetSelectionStart 3128 +#define wxStyledTextCtrl_SetSelectionEnd 3129 +#define wxStyledTextCtrl_GetSelectionEnd 3130 +#define wxStyledTextCtrl_SetPrintMagnification 3131 +#define wxStyledTextCtrl_GetPrintMagnification 3132 +#define wxStyledTextCtrl_SetPrintColourMode 3133 +#define wxStyledTextCtrl_GetPrintColourMode 3134 +#define wxStyledTextCtrl_FindText 3135 +#define wxStyledTextCtrl_FormatRange 3136 +#define wxStyledTextCtrl_GetFirstVisibleLine 3137 +#define wxStyledTextCtrl_GetLine 3138 +#define wxStyledTextCtrl_GetLineCount 3139 +#define wxStyledTextCtrl_SetMarginLeft 3140 +#define wxStyledTextCtrl_GetMarginLeft 3141 +#define wxStyledTextCtrl_SetMarginRight 3142 +#define wxStyledTextCtrl_GetMarginRight 3143 +#define wxStyledTextCtrl_GetModify 3144 +#define wxStyledTextCtrl_SetSelection 3145 +#define wxStyledTextCtrl_GetSelectedText 3146 +#define wxStyledTextCtrl_GetTextRange 3147 +#define wxStyledTextCtrl_HideSelection 3148 +#define wxStyledTextCtrl_LineFromPosition 3149 +#define wxStyledTextCtrl_PositionFromLine 3150 +#define wxStyledTextCtrl_LineScroll 3151 +#define wxStyledTextCtrl_EnsureCaretVisible 3152 +#define wxStyledTextCtrl_ReplaceSelection 3153 +#define wxStyledTextCtrl_SetReadOnly 3154 +#define wxStyledTextCtrl_CanPaste 3155 +#define wxStyledTextCtrl_CanUndo 3156 +#define wxStyledTextCtrl_EmptyUndoBuffer 3157 +#define wxStyledTextCtrl_Undo 3158 +#define wxStyledTextCtrl_Cut 3159 +#define wxStyledTextCtrl_Copy 3160 +#define wxStyledTextCtrl_Paste 3161 +#define wxStyledTextCtrl_Clear 3162 +#define wxStyledTextCtrl_SetText 3163 +#define wxStyledTextCtrl_GetText 3164 +#define wxStyledTextCtrl_GetTextLength 3165 +#define wxStyledTextCtrl_GetOvertype 3166 +#define wxStyledTextCtrl_SetCaretWidth 3167 +#define wxStyledTextCtrl_GetCaretWidth 3168 +#define wxStyledTextCtrl_SetTargetStart 3169 +#define wxStyledTextCtrl_GetTargetStart 3170 +#define wxStyledTextCtrl_SetTargetEnd 3171 +#define wxStyledTextCtrl_GetTargetEnd 3172 +#define wxStyledTextCtrl_ReplaceTarget 3173 +#define wxStyledTextCtrl_SearchInTarget 3174 +#define wxStyledTextCtrl_SetSearchFlags 3175 +#define wxStyledTextCtrl_GetSearchFlags 3176 +#define wxStyledTextCtrl_CallTipShow 3177 +#define wxStyledTextCtrl_CallTipCancel 3178 +#define wxStyledTextCtrl_CallTipActive 3179 +#define wxStyledTextCtrl_CallTipPosAtStart 3180 +#define wxStyledTextCtrl_CallTipSetHighlight 3181 +#define wxStyledTextCtrl_CallTipSetBackground 3182 +#define wxStyledTextCtrl_CallTipSetForeground 3183 +#define wxStyledTextCtrl_CallTipSetForegroundHighlight 3184 +#define wxStyledTextCtrl_CallTipUseStyle 3185 +#define wxStyledTextCtrl_VisibleFromDocLine 3186 +#define wxStyledTextCtrl_DocLineFromVisible 3187 +#define wxStyledTextCtrl_WrapCount 3188 +#define wxStyledTextCtrl_SetFoldLevel 3189 +#define wxStyledTextCtrl_GetFoldLevel 3190 +#define wxStyledTextCtrl_GetLastChild 3191 +#define wxStyledTextCtrl_GetFoldParent 3192 +#define wxStyledTextCtrl_ShowLines 3193 +#define wxStyledTextCtrl_HideLines 3194 +#define wxStyledTextCtrl_GetLineVisible 3195 +#define wxStyledTextCtrl_SetFoldExpanded 3196 +#define wxStyledTextCtrl_GetFoldExpanded 3197 +#define wxStyledTextCtrl_ToggleFold 3198 +#define wxStyledTextCtrl_EnsureVisible 3199 +#define wxStyledTextCtrl_SetFoldFlags 3200 +#define wxStyledTextCtrl_EnsureVisibleEnforcePolicy 3201 +#define wxStyledTextCtrl_SetTabIndents 3202 +#define wxStyledTextCtrl_GetTabIndents 3203 +#define wxStyledTextCtrl_SetBackSpaceUnIndents 3204 +#define wxStyledTextCtrl_GetBackSpaceUnIndents 3205 +#define wxStyledTextCtrl_SetMouseDwellTime 3206 +#define wxStyledTextCtrl_GetMouseDwellTime 3207 +#define wxStyledTextCtrl_WordStartPosition 3208 +#define wxStyledTextCtrl_WordEndPosition 3209 +#define wxStyledTextCtrl_SetWrapMode 3210 +#define wxStyledTextCtrl_GetWrapMode 3211 +#define wxStyledTextCtrl_SetWrapVisualFlags 3212 +#define wxStyledTextCtrl_GetWrapVisualFlags 3213 +#define wxStyledTextCtrl_SetWrapVisualFlagsLocation 3214 +#define wxStyledTextCtrl_GetWrapVisualFlagsLocation 3215 +#define wxStyledTextCtrl_SetWrapStartIndent 3216 +#define wxStyledTextCtrl_GetWrapStartIndent 3217 +#define wxStyledTextCtrl_SetLayoutCache 3218 +#define wxStyledTextCtrl_GetLayoutCache 3219 +#define wxStyledTextCtrl_SetScrollWidth 3220 +#define wxStyledTextCtrl_GetScrollWidth 3221 +#define wxStyledTextCtrl_TextWidth 3222 +#define wxStyledTextCtrl_GetEndAtLastLine 3223 +#define wxStyledTextCtrl_TextHeight 3224 +#define wxStyledTextCtrl_SetUseVerticalScrollBar 3225 +#define wxStyledTextCtrl_GetUseVerticalScrollBar 3226 +#define wxStyledTextCtrl_AppendText 3227 +#define wxStyledTextCtrl_GetTwoPhaseDraw 3228 +#define wxStyledTextCtrl_SetTwoPhaseDraw 3229 +#define wxStyledTextCtrl_TargetFromSelection 3230 +#define wxStyledTextCtrl_LinesJoin 3231 +#define wxStyledTextCtrl_LinesSplit 3232 +#define wxStyledTextCtrl_SetFoldMarginColour 3233 +#define wxStyledTextCtrl_SetFoldMarginHiColour 3234 +#define wxStyledTextCtrl_LineDown 3235 +#define wxStyledTextCtrl_LineDownExtend 3236 +#define wxStyledTextCtrl_LineUp 3237 +#define wxStyledTextCtrl_LineUpExtend 3238 +#define wxStyledTextCtrl_CharLeft 3239 +#define wxStyledTextCtrl_CharLeftExtend 3240 +#define wxStyledTextCtrl_CharRight 3241 +#define wxStyledTextCtrl_CharRightExtend 3242 +#define wxStyledTextCtrl_WordLeft 3243 +#define wxStyledTextCtrl_WordLeftExtend 3244 +#define wxStyledTextCtrl_WordRight 3245 +#define wxStyledTextCtrl_WordRightExtend 3246 +#define wxStyledTextCtrl_Home 3247 +#define wxStyledTextCtrl_HomeExtend 3248 +#define wxStyledTextCtrl_LineEnd 3249 +#define wxStyledTextCtrl_LineEndExtend 3250 +#define wxStyledTextCtrl_DocumentStart 3251 +#define wxStyledTextCtrl_DocumentStartExtend 3252 +#define wxStyledTextCtrl_DocumentEnd 3253 +#define wxStyledTextCtrl_DocumentEndExtend 3254 +#define wxStyledTextCtrl_PageUp 3255 +#define wxStyledTextCtrl_PageUpExtend 3256 +#define wxStyledTextCtrl_PageDown 3257 +#define wxStyledTextCtrl_PageDownExtend 3258 +#define wxStyledTextCtrl_EditToggleOvertype 3259 +#define wxStyledTextCtrl_Cancel 3260 +#define wxStyledTextCtrl_DeleteBack 3261 +#define wxStyledTextCtrl_Tab 3262 +#define wxStyledTextCtrl_BackTab 3263 +#define wxStyledTextCtrl_NewLine 3264 +#define wxStyledTextCtrl_FormFeed 3265 +#define wxStyledTextCtrl_VCHome 3266 +#define wxStyledTextCtrl_VCHomeExtend 3267 +#define wxStyledTextCtrl_ZoomIn 3268 +#define wxStyledTextCtrl_ZoomOut 3269 +#define wxStyledTextCtrl_DelWordLeft 3270 +#define wxStyledTextCtrl_DelWordRight 3271 +#define wxStyledTextCtrl_LineCut 3272 +#define wxStyledTextCtrl_LineDelete 3273 +#define wxStyledTextCtrl_LineTranspose 3274 +#define wxStyledTextCtrl_LineDuplicate 3275 +#define wxStyledTextCtrl_LowerCase 3276 +#define wxStyledTextCtrl_UpperCase 3277 +#define wxStyledTextCtrl_LineScrollDown 3278 +#define wxStyledTextCtrl_LineScrollUp 3279 +#define wxStyledTextCtrl_DeleteBackNotLine 3280 +#define wxStyledTextCtrl_HomeDisplay 3281 +#define wxStyledTextCtrl_HomeDisplayExtend 3282 +#define wxStyledTextCtrl_LineEndDisplay 3283 +#define wxStyledTextCtrl_LineEndDisplayExtend 3284 +#define wxStyledTextCtrl_HomeWrapExtend 3285 +#define wxStyledTextCtrl_LineEndWrap 3286 +#define wxStyledTextCtrl_LineEndWrapExtend 3287 +#define wxStyledTextCtrl_VCHomeWrap 3288 +#define wxStyledTextCtrl_VCHomeWrapExtend 3289 +#define wxStyledTextCtrl_LineCopy 3290 +#define wxStyledTextCtrl_MoveCaretInsideView 3291 +#define wxStyledTextCtrl_LineLength 3292 +#define wxStyledTextCtrl_BraceHighlight 3293 +#define wxStyledTextCtrl_BraceBadLight 3294 +#define wxStyledTextCtrl_BraceMatch 3295 +#define wxStyledTextCtrl_GetViewEOL 3296 +#define wxStyledTextCtrl_SetViewEOL 3297 +#define wxStyledTextCtrl_SetModEventMask 3298 +#define wxStyledTextCtrl_GetEdgeColumn 3299 +#define wxStyledTextCtrl_SetEdgeColumn 3300 +#define wxStyledTextCtrl_SetEdgeMode 3301 +#define wxStyledTextCtrl_GetEdgeMode 3302 +#define wxStyledTextCtrl_GetEdgeColour 3303 +#define wxStyledTextCtrl_SetEdgeColour 3304 +#define wxStyledTextCtrl_SearchAnchor 3305 +#define wxStyledTextCtrl_SearchNext 3306 +#define wxStyledTextCtrl_SearchPrev 3307 +#define wxStyledTextCtrl_LinesOnScreen 3308 +#define wxStyledTextCtrl_UsePopUp 3309 +#define wxStyledTextCtrl_SelectionIsRectangle 3310 +#define wxStyledTextCtrl_SetZoom 3311 +#define wxStyledTextCtrl_GetZoom 3312 +#define wxStyledTextCtrl_GetModEventMask 3313 +#define wxStyledTextCtrl_SetSTCFocus 3314 +#define wxStyledTextCtrl_GetSTCFocus 3315 +#define wxStyledTextCtrl_SetStatus 3316 +#define wxStyledTextCtrl_GetStatus 3317 +#define wxStyledTextCtrl_SetMouseDownCaptures 3318 +#define wxStyledTextCtrl_GetMouseDownCaptures 3319 +#define wxStyledTextCtrl_SetSTCCursor 3320 +#define wxStyledTextCtrl_GetSTCCursor 3321 +#define wxStyledTextCtrl_SetControlCharSymbol 3322 +#define wxStyledTextCtrl_GetControlCharSymbol 3323 +#define wxStyledTextCtrl_WordPartLeft 3324 +#define wxStyledTextCtrl_WordPartLeftExtend 3325 +#define wxStyledTextCtrl_WordPartRight 3326 +#define wxStyledTextCtrl_WordPartRightExtend 3327 +#define wxStyledTextCtrl_SetVisiblePolicy 3328 +#define wxStyledTextCtrl_DelLineLeft 3329 +#define wxStyledTextCtrl_DelLineRight 3330 +#define wxStyledTextCtrl_GetXOffset 3331 +#define wxStyledTextCtrl_ChooseCaretX 3332 +#define wxStyledTextCtrl_SetXCaretPolicy 3333 +#define wxStyledTextCtrl_SetYCaretPolicy 3334 +#define wxStyledTextCtrl_GetPrintWrapMode 3335 +#define wxStyledTextCtrl_SetHotspotActiveForeground 3336 +#define wxStyledTextCtrl_SetHotspotActiveBackground 3337 +#define wxStyledTextCtrl_SetHotspotActiveUnderline 3338 +#define wxStyledTextCtrl_SetHotspotSingleLine 3339 +#define wxStyledTextCtrl_ParaDownExtend 3340 +#define wxStyledTextCtrl_ParaUp 3341 +#define wxStyledTextCtrl_ParaUpExtend 3342 +#define wxStyledTextCtrl_PositionBefore 3343 +#define wxStyledTextCtrl_PositionAfter 3344 +#define wxStyledTextCtrl_CopyRange 3345 +#define wxStyledTextCtrl_CopyText 3346 +#define wxStyledTextCtrl_SetSelectionMode 3347 +#define wxStyledTextCtrl_GetSelectionMode 3348 +#define wxStyledTextCtrl_LineDownRectExtend 3349 +#define wxStyledTextCtrl_LineUpRectExtend 3350 +#define wxStyledTextCtrl_CharLeftRectExtend 3351 +#define wxStyledTextCtrl_CharRightRectExtend 3352 +#define wxStyledTextCtrl_HomeRectExtend 3353 +#define wxStyledTextCtrl_VCHomeRectExtend 3354 +#define wxStyledTextCtrl_LineEndRectExtend 3355 +#define wxStyledTextCtrl_PageUpRectExtend 3356 +#define wxStyledTextCtrl_PageDownRectExtend 3357 +#define wxStyledTextCtrl_StutteredPageUp 3358 +#define wxStyledTextCtrl_StutteredPageUpExtend 3359 +#define wxStyledTextCtrl_StutteredPageDown 3360 +#define wxStyledTextCtrl_StutteredPageDownExtend 3361 +#define wxStyledTextCtrl_WordLeftEnd 3362 +#define wxStyledTextCtrl_WordLeftEndExtend 3363 +#define wxStyledTextCtrl_WordRightEnd 3364 +#define wxStyledTextCtrl_WordRightEndExtend 3365 +#define wxStyledTextCtrl_SetWhitespaceChars 3366 +#define wxStyledTextCtrl_SetCharsDefault 3367 +#define wxStyledTextCtrl_AutoCompGetCurrent 3368 +#define wxStyledTextCtrl_Allocate 3369 +#define wxStyledTextCtrl_FindColumn 3370 +#define wxStyledTextCtrl_GetCaretSticky 3371 +#define wxStyledTextCtrl_SetCaretSticky 3372 +#define wxStyledTextCtrl_ToggleCaretSticky 3373 +#define wxStyledTextCtrl_SetPasteConvertEndings 3374 +#define wxStyledTextCtrl_GetPasteConvertEndings 3375 +#define wxStyledTextCtrl_SelectionDuplicate 3376 +#define wxStyledTextCtrl_SetCaretLineBackAlpha 3377 +#define wxStyledTextCtrl_GetCaretLineBackAlpha 3378 +#define wxStyledTextCtrl_StartRecord 3379 +#define wxStyledTextCtrl_StopRecord 3380 +#define wxStyledTextCtrl_SetLexer 3381 +#define wxStyledTextCtrl_GetLexer 3382 +#define wxStyledTextCtrl_Colourise 3383 +#define wxStyledTextCtrl_SetProperty 3384 +#define wxStyledTextCtrl_SetKeyWords 3385 +#define wxStyledTextCtrl_SetLexerLanguage 3386 +#define wxStyledTextCtrl_GetProperty 3387 +#define wxStyledTextCtrl_GetStyleBitsNeeded 3388 +#define wxStyledTextCtrl_GetCurrentLine 3389 +#define wxStyledTextCtrl_StyleSetSpec 3390 +#define wxStyledTextCtrl_StyleSetFont 3391 +#define wxStyledTextCtrl_StyleSetFontAttr 3392 +#define wxStyledTextCtrl_StyleSetCharacterSet 3393 +#define wxStyledTextCtrl_StyleSetFontEncoding 3394 +#define wxStyledTextCtrl_CmdKeyExecute 3395 +#define wxStyledTextCtrl_SetMargins 3396 +#define wxStyledTextCtrl_GetSelection 3397 +#define wxStyledTextCtrl_PointFromPosition 3398 +#define wxStyledTextCtrl_ScrollToLine 3399 +#define wxStyledTextCtrl_ScrollToColumn 3400 +#define wxStyledTextCtrl_SetVScrollBar 3401 +#define wxStyledTextCtrl_SetHScrollBar 3402 +#define wxStyledTextCtrl_GetLastKeydownProcessed 3403 +#define wxStyledTextCtrl_SetLastKeydownProcessed 3404 +#define wxStyledTextCtrl_SaveFile 3405 +#define wxStyledTextCtrl_LoadFile 3406 +#define wxStyledTextCtrl_DoDragOver 3407 +#define wxStyledTextCtrl_DoDropText 3408 +#define wxStyledTextCtrl_GetUseAntiAliasing 3409 +#define wxStyledTextCtrl_AddTextRaw 3410 +#define wxStyledTextCtrl_InsertTextRaw 3411 +#define wxStyledTextCtrl_GetCurLineRaw 3412 +#define wxStyledTextCtrl_GetLineRaw 3413 +#define wxStyledTextCtrl_GetSelectedTextRaw 3414 +#define wxStyledTextCtrl_GetTextRangeRaw 3415 +#define wxStyledTextCtrl_SetTextRaw 3416 +#define wxStyledTextCtrl_GetTextRaw 3417 +#define wxStyledTextCtrl_AppendTextRaw 3418 +#define wxArtProvider_GetBitmap 3419 +#define wxArtProvider_GetIcon 3420 +#define wxTreeEvent_GetKeyCode 3421 +#define wxTreeEvent_GetItem 3422 +#define wxTreeEvent_GetKeyEvent 3423 +#define wxTreeEvent_GetLabel 3424 +#define wxTreeEvent_GetOldItem 3425 +#define wxTreeEvent_GetPoint 3426 +#define wxTreeEvent_IsEditCancelled 3427 +#define wxTreeEvent_SetToolTip 3428 +#define wxNotebookEvent_GetOldSelection 3429 +#define wxNotebookEvent_GetSelection 3430 +#define wxNotebookEvent_SetOldSelection 3431 +#define wxNotebookEvent_SetSelection 3432 +#define wxFileDataObject_new 3433 +#define wxFileDataObject_AddFile 3434 +#define wxFileDataObject_GetFilenames 3435 +#define wxFileDataObject_destroy 3436 +#define wxTextDataObject_new 3437 +#define wxTextDataObject_GetTextLength 3438 +#define wxTextDataObject_GetText 3439 +#define wxTextDataObject_SetText 3440 +#define wxTextDataObject_destroy 3441 +#define wxBitmapDataObject_new_1_1 3442 +#define wxBitmapDataObject_new_1_0 3443 +#define wxBitmapDataObject_GetBitmap 3444 +#define wxBitmapDataObject_SetBitmap 3445 +#define wxBitmapDataObject_destroy 3446 +#define wxClipboard_new 3448 +#define wxClipboard_destruct 3449 +#define wxClipboard_AddData 3450 +#define wxClipboard_Clear 3451 +#define wxClipboard_Close 3452 +#define wxClipboard_Flush 3453 +#define wxClipboard_GetData 3454 +#define wxClipboard_IsOpened 3455 +#define wxClipboard_Open 3456 +#define wxClipboard_SetData 3457 +#define wxClipboard_UsePrimarySelection 3459 +#define wxClipboard_IsSupported 3460 +#define wxClipboard_Get 3461 +#define wxSpinEvent_GetPosition 3462 +#define wxSpinEvent_SetPosition 3463 +#define wxSplitterWindow_new_0 3464 +#define wxSplitterWindow_new_2 3465 +#define wxSplitterWindow_destruct 3466 +#define wxSplitterWindow_Create 3467 +#define wxSplitterWindow_GetMinimumPaneSize 3468 +#define wxSplitterWindow_GetSashGravity 3469 +#define wxSplitterWindow_GetSashPosition 3470 +#define wxSplitterWindow_GetSplitMode 3471 +#define wxSplitterWindow_GetWindow1 3472 +#define wxSplitterWindow_GetWindow2 3473 +#define wxSplitterWindow_Initialize 3474 +#define wxSplitterWindow_IsSplit 3475 +#define wxSplitterWindow_ReplaceWindow 3476 +#define wxSplitterWindow_SetSashGravity 3477 +#define wxSplitterWindow_SetSashPosition 3478 +#define wxSplitterWindow_SetSashSize 3479 +#define wxSplitterWindow_SetMinimumPaneSize 3480 +#define wxSplitterWindow_SetSplitMode 3481 +#define wxSplitterWindow_SplitHorizontally 3482 +#define wxSplitterWindow_SplitVertically 3483 +#define wxSplitterWindow_Unsplit 3484 +#define wxSplitterWindow_UpdateSize 3485 +#define wxSplitterEvent_GetSashPosition 3486 +#define wxSplitterEvent_GetX 3487 +#define wxSplitterEvent_GetY 3488 +#define wxSplitterEvent_GetWindowBeingRemoved 3489 +#define wxSplitterEvent_SetSashPosition 3490 +#define wxHtmlWindow_new_0 3491 +#define wxHtmlWindow_new_2 3492 +#define wxHtmlWindow_AppendToPage 3493 +#define wxHtmlWindow_GetOpenedAnchor 3494 +#define wxHtmlWindow_GetOpenedPage 3495 +#define wxHtmlWindow_GetOpenedPageTitle 3496 +#define wxHtmlWindow_GetRelatedFrame 3497 +#define wxHtmlWindow_HistoryBack 3498 +#define wxHtmlWindow_HistoryCanBack 3499 +#define wxHtmlWindow_HistoryCanForward 3500 +#define wxHtmlWindow_HistoryClear 3501 +#define wxHtmlWindow_HistoryForward 3502 +#define wxHtmlWindow_LoadFile 3503 +#define wxHtmlWindow_LoadPage 3504 +#define wxHtmlWindow_SelectAll 3505 +#define wxHtmlWindow_SelectionToText 3506 +#define wxHtmlWindow_SelectLine 3507 +#define wxHtmlWindow_SelectWord 3508 +#define wxHtmlWindow_SetBorders 3509 +#define wxHtmlWindow_SetFonts 3510 +#define wxHtmlWindow_SetPage 3511 +#define wxHtmlWindow_SetRelatedFrame 3512 +#define wxHtmlWindow_SetRelatedStatusBar 3513 +#define wxHtmlWindow_ToText 3514 +#define wxHtmlWindow_destroy 3515 +#define wxHtmlLinkEvent_GetLinkInfo 3516 +#define wxSystemSettings_GetColour 3517 +#define wxSystemSettings_GetFont 3518 +#define wxSystemSettings_GetMetric 3519 +#define wxSystemSettings_GetScreenType 3520 +#define wxSystemOptions_GetOption 3521 +#define wxSystemOptions_GetOptionInt 3522 +#define wxSystemOptions_HasOption 3523 +#define wxSystemOptions_IsFalse 3524 +#define wxSystemOptions_SetOption_2_1 3525 +#define wxSystemOptions_SetOption_2_0 3526 +#define wxAuiNotebookEvent_SetSelection 3527 +#define wxAuiNotebookEvent_GetSelection 3528 +#define wxAuiNotebookEvent_SetOldSelection 3529 +#define wxAuiNotebookEvent_GetOldSelection 3530 +#define wxAuiNotebookEvent_SetDragSource 3531 +#define wxAuiNotebookEvent_GetDragSource 3532 +#define wxAuiManagerEvent_SetManager 3533 +#define wxAuiManagerEvent_GetManager 3534 +#define wxAuiManagerEvent_SetPane 3535 +#define wxAuiManagerEvent_GetPane 3536 +#define wxAuiManagerEvent_SetButton 3537 +#define wxAuiManagerEvent_GetButton 3538 +#define wxAuiManagerEvent_SetDC 3539 +#define wxAuiManagerEvent_GetDC 3540 +#define wxAuiManagerEvent_Veto 3541 +#define wxAuiManagerEvent_GetVeto 3542 +#define wxAuiManagerEvent_SetCanVeto 3543 +#define wxAuiManagerEvent_CanVeto 3544 +#define wxLogNull_new 3545 +#define wxLogNull_destroy 3546 +#define wxTaskBarIcon_new 3547 +#define wxTaskBarIcon_destruct 3548 +#define wxTaskBarIcon_PopupMenu 3549 +#define wxTaskBarIcon_RemoveIcon 3550 +#define wxTaskBarIcon_SetIcon 3551 +#define wxLocale_new_0 3552 +#define wxLocale_new_2 3554 +#define wxLocale_destruct 3555 +#define wxLocale_Init 3557 +#define wxLocale_AddCatalog_1 3558 +#define wxLocale_AddCatalog_3 3559 +#define wxLocale_AddCatalogLookupPathPrefix 3560 +#define wxLocale_GetCanonicalName 3561 +#define wxLocale_GetLanguage 3562 +#define wxLocale_GetLanguageName 3563 +#define wxLocale_GetLocale 3564 +#define wxLocale_GetName 3565 +#define wxLocale_GetString_2 3566 +#define wxLocale_GetString_4 3567 +#define wxLocale_GetHeaderValue 3568 +#define wxLocale_GetSysName 3569 +#define wxLocale_GetSystemEncoding 3570 +#define wxLocale_GetSystemEncodingName 3571 +#define wxLocale_GetSystemLanguage 3572 +#define wxLocale_IsLoaded 3573 +#define wxLocale_IsOk 3574 +#define wxActivateEvent_GetActive 3575 +#define wxPopupWindow_new_2 3577 +#define wxPopupWindow_new_0 3578 +#define wxPopupWindow_destruct 3580 +#define wxPopupWindow_Create 3581 +#define wxPopupWindow_Position 3582 +#define wxPopupTransientWindow_new_0 3583 +#define wxPopupTransientWindow_new_2 3584 +#define wxPopupTransientWindow_destruct 3585 +#define wxPopupTransientWindow_Popup 3586 +#define wxPopupTransientWindow_Dismiss 3587 +#define wxOverlay_new 3588 +#define wxOverlay_destruct 3589 +#define wxOverlay_Reset 3590 +#define wxDCOverlay_new_6 3591 +#define wxDCOverlay_new_2 3592 +#define wxDCOverlay_destruct 3593 +#define wxDCOverlay_Clear 3594 diff --git a/lib/wx/c_src/wxe_main.cpp b/lib/wx/c_src/wxe_main.cpp index b928eb9567..6fcde42eb5 100644 --- a/lib/wx/c_src/wxe_main.cpp +++ b/lib/wx/c_src/wxe_main.cpp @@ -125,8 +125,8 @@ void *wxe_main_loop(void *vpdl) { int result; int argc = 1; - char * temp = (char *) "Erlang"; - char * argv[] = {temp,NULL}; + const wxChar temp[10] = L"Erlang"; + wxChar * argv[] = {(wxChar *)temp, NULL}; ErlDrvPDL pdl = (ErlDrvPDL) vpdl; driver_pdl_inc_refc(pdl); diff --git a/lib/wx/examples/demo/ex_canvas.erl b/lib/wx/examples/demo/ex_canvas.erl index 2a95ea0777..b00ce81993 100644 --- a/lib/wx/examples/demo/ex_canvas.erl +++ b/lib/wx/examples/demo/ex_canvas.erl @@ -136,11 +136,14 @@ handle_event(#wx{event = #wxCommand{type = command_button_clicked}}, {noreply, State}; handle_event(#wx{event = #wxSize{size={W,H}}}, State = #state{bitmap=Prev, canvas=Canvas}) -> - Bitmap = wxBitmap:new(W,H), - draw(Canvas, Bitmap, fun(DC) -> wxDC:clear(DC) end), - wxBitmap:destroy(Prev), - {noreply, State#state{bitmap = Bitmap}}; - + if W > 0 andalso H > 0 -> + Bitmap = wxBitmap:new(W,H), + draw(Canvas, Bitmap, fun(DC) -> wxDC:clear(DC) end), + wxBitmap:destroy(Prev), + {noreply, State#state{bitmap = Bitmap}}; + true -> + {noreply, State} + end; handle_event(#wx{event = #wxMouse{type=left_down, x=X, y=Y}}, State) -> {noreply, State#state{pos={X,Y}}}; handle_event(#wx{event = #wxMouse{type=motion, x=X1, y=Y1}}, diff --git a/lib/wx/examples/demo/ex_canvas_paint.erl b/lib/wx/examples/demo/ex_canvas_paint.erl index aa510f5342..75eb840b04 100644 --- a/lib/wx/examples/demo/ex_canvas_paint.erl +++ b/lib/wx/examples/demo/ex_canvas_paint.erl @@ -157,10 +157,15 @@ handle_event(#wx{event = #wxMouse{type = motion, x = X, y = Y}}, {noreply, State#state{old_pos = {X,Y}}}; %% Resize event handle_event(#wx{event = #wxSize{size = {W,H}}}, State = #state{bitmap=Prev}) -> - wxBitmap:destroy(Prev), - Bitmap = wxBitmap:new(W,H), - draw(State#state.canvas, Bitmap, fun(DC) -> wxDC:clear(DC) end), - {noreply, State#state{bitmap=Bitmap}}; + case W > 0 andalso H > 0 of + true -> + wxBitmap:destroy(Prev), + Bitmap = wxBitmap:new(W,H), + draw(State#state.canvas, Bitmap, fun(DC) -> wxDC:clear(DC) end), + {noreply, State#state{bitmap=Bitmap}}; + false -> + {noreply, State} + end; handle_event(#wx{event = #wxMouse{type = left_dclick,x = X,y = Y}}, State = #state{}) -> wxPanel:connect(State#state.canvas, motion), {noreply, State#state{old_pos = {X,Y}}}; @@ -235,11 +240,10 @@ draw(Canvas, Bitmap, Fun) -> CDC = wxClientDC:new(Canvas), Fun(MemoryDC), - wxDC:blit(CDC, {0,0}, {wxBitmap:getWidth(Bitmap), wxBitmap:getHeight(Bitmap)}, MemoryDC, {0,0}), - + wxClientDC:destroy(CDC), wxMemoryDC:destroy(MemoryDC). diff --git a/lib/wx/src/gen/wxGauge.erl b/lib/wx/src/gen/wxGauge.erl index 51c35145c4..2745e251b4 100644 --- a/lib/wx/src/gen/wxGauge.erl +++ b/lib/wx/src/gen/wxGauge.erl @@ -30,9 +30,8 @@ -module(wxGauge). -include("wxe.hrl"). --export([create/4,create/5,destroy/1,getBezelFace/1,getRange/1,getShadowWidth/1, - getValue/1,isVertical/1,new/0,new/3,new/4,pulse/1,setBezelFace/2,setRange/2, - setShadowWidth/2,setValue/2]). +-export([create/4,create/5,destroy/1,getRange/1,getValue/1,isVertical/1,new/0, + new/3,new/4,pulse/1,setRange/2,setValue/2]). %% inherited exports -export([cacheBestSize/2,canSetTransparent/1,captureMouse/1,center/1,center/2, @@ -142,14 +141,6 @@ create(#wx_ref{type=ThisT,ref=ThisRef},#wx_ref{type=ParentT,ref=ParentRef},Id,Ra wxe_util:call(?wxGauge_Create, <<ThisRef:32/?UI,ParentRef:32/?UI,Id:32/?UI,Range:32/?UI, BinOpt/binary>>). -%% @doc See <a href="http://www.wxwidgets.org/manuals/2.8.12/wx_wxgauge.html#wxgaugegetbezelface">external documentation</a>. --spec getBezelFace(This) -> integer() when - This::wxGauge(). -getBezelFace(#wx_ref{type=ThisT,ref=ThisRef}) -> - ?CLASS(ThisT,wxGauge), - wxe_util:call(?wxGauge_GetBezelFace, - <<ThisRef:32/?UI>>). - %% @doc See <a href="http://www.wxwidgets.org/manuals/2.8.12/wx_wxgauge.html#wxgaugegetrange">external documentation</a>. -spec getRange(This) -> integer() when This::wxGauge(). @@ -158,14 +149,6 @@ getRange(#wx_ref{type=ThisT,ref=ThisRef}) -> wxe_util:call(?wxGauge_GetRange, <<ThisRef:32/?UI>>). -%% @doc See <a href="http://www.wxwidgets.org/manuals/2.8.12/wx_wxgauge.html#wxgaugegetshadowwidth">external documentation</a>. --spec getShadowWidth(This) -> integer() when - This::wxGauge(). -getShadowWidth(#wx_ref{type=ThisT,ref=ThisRef}) -> - ?CLASS(ThisT,wxGauge), - wxe_util:call(?wxGauge_GetShadowWidth, - <<ThisRef:32/?UI>>). - %% @doc See <a href="http://www.wxwidgets.org/manuals/2.8.12/wx_wxgauge.html#wxgaugegetvalue">external documentation</a>. -spec getValue(This) -> integer() when This::wxGauge(). @@ -182,15 +165,6 @@ isVertical(#wx_ref{type=ThisT,ref=ThisRef}) -> wxe_util:call(?wxGauge_IsVertical, <<ThisRef:32/?UI>>). -%% @doc See <a href="http://www.wxwidgets.org/manuals/2.8.12/wx_wxgauge.html#wxgaugesetbezelface">external documentation</a>. --spec setBezelFace(This, W) -> ok when - This::wxGauge(), W::integer(). -setBezelFace(#wx_ref{type=ThisT,ref=ThisRef},W) - when is_integer(W) -> - ?CLASS(ThisT,wxGauge), - wxe_util:cast(?wxGauge_SetBezelFace, - <<ThisRef:32/?UI,W:32/?UI>>). - %% @doc See <a href="http://www.wxwidgets.org/manuals/2.8.12/wx_wxgauge.html#wxgaugesetrange">external documentation</a>. -spec setRange(This, R) -> ok when This::wxGauge(), R::integer(). @@ -200,15 +174,6 @@ setRange(#wx_ref{type=ThisT,ref=ThisRef},R) wxe_util:cast(?wxGauge_SetRange, <<ThisRef:32/?UI,R:32/?UI>>). -%% @doc See <a href="http://www.wxwidgets.org/manuals/2.8.12/wx_wxgauge.html#wxgaugesetshadowwidth">external documentation</a>. --spec setShadowWidth(This, W) -> ok when - This::wxGauge(), W::integer(). -setShadowWidth(#wx_ref{type=ThisT,ref=ThisRef},W) - when is_integer(W) -> - ?CLASS(ThisT,wxGauge), - wxe_util:cast(?wxGauge_SetShadowWidth, - <<ThisRef:32/?UI,W:32/?UI>>). - %% @doc See <a href="http://www.wxwidgets.org/manuals/2.8.12/wx_wxgauge.html#wxgaugesetvalue">external documentation</a>. -spec setValue(This, Pos) -> ok when This::wxGauge(), Pos::integer(). diff --git a/lib/wx/src/gen/wxe_debug.hrl b/lib/wx/src/gen/wxe_debug.hrl index 2ec485cd52..78c6577439 100644 --- a/lib/wx/src/gen/wxe_debug.hrl +++ b/lib/wx/src/gen/wxe_debug.hrl @@ -1457,1925 +1457,1921 @@ wxdebug_table() -> {1602, {wxGauge, new_0, 0}}, {1603, {wxGauge, new_4, 4}}, {1604, {wxGauge, create, 4}}, - {1605, {wxGauge, getBezelFace, 0}}, - {1606, {wxGauge, getRange, 0}}, - {1607, {wxGauge, getShadowWidth, 0}}, - {1608, {wxGauge, getValue, 0}}, - {1609, {wxGauge, isVertical, 0}}, - {1610, {wxGauge, setBezelFace, 1}}, - {1611, {wxGauge, setRange, 1}}, - {1612, {wxGauge, setShadowWidth, 1}}, - {1613, {wxGauge, setValue, 1}}, - {1614, {wxGauge, pulse, 0}}, - {1615, {wxGauge, 'Destroy', undefined}}, - {1616, {wxGenericDirCtrl, new_0, 0}}, - {1617, {wxGenericDirCtrl, new_2, 2}}, - {1618, {wxGenericDirCtrl, destruct, 0}}, - {1619, {wxGenericDirCtrl, create, 2}}, - {1620, {wxGenericDirCtrl, init, 0}}, - {1621, {wxGenericDirCtrl, collapseTree, 0}}, - {1622, {wxGenericDirCtrl, expandPath, 1}}, - {1623, {wxGenericDirCtrl, getDefaultPath, 0}}, - {1624, {wxGenericDirCtrl, getPath, 0}}, - {1625, {wxGenericDirCtrl, getFilePath, 0}}, - {1626, {wxGenericDirCtrl, getFilter, 0}}, - {1627, {wxGenericDirCtrl, getFilterIndex, 0}}, - {1628, {wxGenericDirCtrl, getRootId, 0}}, - {1629, {wxGenericDirCtrl, getTreeCtrl, 0}}, - {1630, {wxGenericDirCtrl, reCreateTree, 0}}, - {1631, {wxGenericDirCtrl, setDefaultPath, 1}}, - {1632, {wxGenericDirCtrl, setFilter, 1}}, - {1633, {wxGenericDirCtrl, setFilterIndex, 1}}, - {1634, {wxGenericDirCtrl, setPath, 1}}, - {1636, {wxStaticBox, new_4, 4}}, - {1637, {wxStaticBox, new_0, 0}}, - {1638, {wxStaticBox, create, 4}}, - {1639, {wxStaticBox, 'Destroy', undefined}}, - {1641, {wxStaticLine, new_2, 2}}, - {1642, {wxStaticLine, new_0, 0}}, - {1643, {wxStaticLine, create, 2}}, - {1644, {wxStaticLine, isVertical, 0}}, - {1645, {wxStaticLine, getDefaultSize, 0}}, - {1646, {wxStaticLine, 'Destroy', undefined}}, - {1649, {wxListBox, new_3, 3}}, - {1650, {wxListBox, new_0, 0}}, - {1652, {wxListBox, destruct, 0}}, - {1654, {wxListBox, create, 6}}, - {1655, {wxListBox, deselect, 1}}, - {1656, {wxListBox, getSelections, 1}}, - {1657, {wxListBox, insertItems, 2}}, - {1658, {wxListBox, isSelected, 1}}, - {1659, {wxListBox, set, 1}}, - {1660, {wxListBox, hitTest, 1}}, - {1661, {wxListBox, setFirstItem_1_0, 1}}, - {1662, {wxListBox, setFirstItem_1_1, 1}}, - {1663, {wxListCtrl, new_0, 0}}, - {1664, {wxListCtrl, new_2, 2}}, - {1665, {wxListCtrl, arrange, 1}}, - {1666, {wxListCtrl, assignImageList, 2}}, - {1667, {wxListCtrl, clearAll, 0}}, - {1668, {wxListCtrl, create, 2}}, - {1669, {wxListCtrl, deleteAllItems, 0}}, - {1670, {wxListCtrl, deleteColumn, 1}}, - {1671, {wxListCtrl, deleteItem, 1}}, - {1672, {wxListCtrl, editLabel, 1}}, - {1673, {wxListCtrl, ensureVisible, 1}}, - {1674, {wxListCtrl, findItem_3_0, 3}}, - {1675, {wxListCtrl, findItem_3_1, 3}}, - {1676, {wxListCtrl, getColumn, 2}}, - {1677, {wxListCtrl, getColumnCount, 0}}, - {1678, {wxListCtrl, getColumnWidth, 1}}, - {1679, {wxListCtrl, getCountPerPage, 0}}, - {1680, {wxListCtrl, getEditControl, 0}}, - {1681, {wxListCtrl, getImageList, 1}}, - {1682, {wxListCtrl, getItem, 1}}, - {1683, {wxListCtrl, getItemBackgroundColour, 1}}, - {1684, {wxListCtrl, getItemCount, 0}}, - {1685, {wxListCtrl, getItemData, 1}}, - {1686, {wxListCtrl, getItemFont, 1}}, - {1687, {wxListCtrl, getItemPosition, 2}}, - {1688, {wxListCtrl, getItemRect, 3}}, - {1689, {wxListCtrl, getItemSpacing, 0}}, - {1690, {wxListCtrl, getItemState, 2}}, - {1691, {wxListCtrl, getItemText, 1}}, - {1692, {wxListCtrl, getItemTextColour, 1}}, - {1693, {wxListCtrl, getNextItem, 2}}, - {1694, {wxListCtrl, getSelectedItemCount, 0}}, - {1695, {wxListCtrl, getTextColour, 0}}, - {1696, {wxListCtrl, getTopItem, 0}}, - {1697, {wxListCtrl, getViewRect, 0}}, - {1698, {wxListCtrl, hitTest, 3}}, - {1699, {wxListCtrl, insertColumn_2, 2}}, - {1700, {wxListCtrl, insertColumn_3, 3}}, - {1701, {wxListCtrl, insertItem_1, 1}}, - {1702, {wxListCtrl, insertItem_2_1, 2}}, - {1703, {wxListCtrl, insertItem_2_0, 2}}, - {1704, {wxListCtrl, insertItem_3, 3}}, - {1705, {wxListCtrl, refreshItem, 1}}, - {1706, {wxListCtrl, refreshItems, 2}}, - {1707, {wxListCtrl, scrollList, 2}}, - {1708, {wxListCtrl, setBackgroundColour, 1}}, - {1709, {wxListCtrl, setColumn, 2}}, - {1710, {wxListCtrl, setColumnWidth, 2}}, - {1711, {wxListCtrl, setImageList, 2}}, - {1712, {wxListCtrl, setItem_1, 1}}, - {1713, {wxListCtrl, setItem_4, 4}}, - {1714, {wxListCtrl, setItemBackgroundColour, 2}}, - {1715, {wxListCtrl, setItemCount, 1}}, - {1716, {wxListCtrl, setItemData, 2}}, - {1717, {wxListCtrl, setItemFont, 2}}, - {1718, {wxListCtrl, setItemImage, 3}}, - {1719, {wxListCtrl, setItemColumnImage, 3}}, - {1720, {wxListCtrl, setItemPosition, 2}}, - {1721, {wxListCtrl, setItemState, 3}}, - {1722, {wxListCtrl, setItemText, 2}}, - {1723, {wxListCtrl, setItemTextColour, 2}}, - {1724, {wxListCtrl, setSingleStyle, 2}}, - {1725, {wxListCtrl, setTextColour, 1}}, - {1726, {wxListCtrl, setWindowStyleFlag, 1}}, - {1727, {wxListCtrl, sortItems, 2}}, - {1728, {wxListCtrl, 'Destroy', undefined}}, - {1729, {wxListView, clearColumnImage, 1}}, - {1730, {wxListView, focus, 1}}, - {1731, {wxListView, getFirstSelected, 0}}, - {1732, {wxListView, getFocusedItem, 0}}, - {1733, {wxListView, getNextSelected, 1}}, - {1734, {wxListView, isSelected, 1}}, - {1735, {wxListView, select, 2}}, - {1736, {wxListView, setColumnImage, 2}}, - {1737, {wxListItem, new_0, 0}}, - {1738, {wxListItem, new_1, 1}}, - {1739, {wxListItem, destruct, 0}}, - {1740, {wxListItem, clear, 0}}, - {1741, {wxListItem, getAlign, 0}}, - {1742, {wxListItem, getBackgroundColour, 0}}, - {1743, {wxListItem, getColumn, 0}}, - {1744, {wxListItem, getFont, 0}}, - {1745, {wxListItem, getId, 0}}, - {1746, {wxListItem, getImage, 0}}, - {1747, {wxListItem, getMask, 0}}, - {1748, {wxListItem, getState, 0}}, - {1749, {wxListItem, getText, 0}}, - {1750, {wxListItem, getTextColour, 0}}, - {1751, {wxListItem, getWidth, 0}}, - {1752, {wxListItem, setAlign, 1}}, - {1753, {wxListItem, setBackgroundColour, 1}}, - {1754, {wxListItem, setColumn, 1}}, - {1755, {wxListItem, setFont, 1}}, - {1756, {wxListItem, setId, 1}}, - {1757, {wxListItem, setImage, 1}}, - {1758, {wxListItem, setMask, 1}}, - {1759, {wxListItem, setState, 1}}, - {1760, {wxListItem, setStateMask, 1}}, - {1761, {wxListItem, setText, 1}}, - {1762, {wxListItem, setTextColour, 1}}, - {1763, {wxListItem, setWidth, 1}}, - {1764, {wxListItemAttr, new_0, 0}}, - {1765, {wxListItemAttr, new_3, 3}}, - {1766, {wxListItemAttr, getBackgroundColour, 0}}, - {1767, {wxListItemAttr, getFont, 0}}, - {1768, {wxListItemAttr, getTextColour, 0}}, - {1769, {wxListItemAttr, hasBackgroundColour, 0}}, - {1770, {wxListItemAttr, hasFont, 0}}, - {1771, {wxListItemAttr, hasTextColour, 0}}, - {1772, {wxListItemAttr, setBackgroundColour, 1}}, - {1773, {wxListItemAttr, setFont, 1}}, - {1774, {wxListItemAttr, setTextColour, 1}}, - {1775, {wxListItemAttr, 'Destroy', undefined}}, - {1776, {wxImageList, new_0, 0}}, - {1777, {wxImageList, new_3, 3}}, - {1778, {wxImageList, add_1, 1}}, - {1779, {wxImageList, add_2_0, 2}}, - {1780, {wxImageList, add_2_1, 2}}, - {1781, {wxImageList, create, 3}}, - {1783, {wxImageList, draw, 5}}, - {1784, {wxImageList, getBitmap, 1}}, - {1785, {wxImageList, getIcon, 1}}, - {1786, {wxImageList, getImageCount, 0}}, - {1787, {wxImageList, getSize, 3}}, - {1788, {wxImageList, remove, 1}}, - {1789, {wxImageList, removeAll, 0}}, - {1790, {wxImageList, replace_2, 2}}, - {1791, {wxImageList, replace_3, 3}}, - {1792, {wxImageList, 'Destroy', undefined}}, - {1793, {wxTextAttr, new_0, 0}}, - {1794, {wxTextAttr, new_2, 2}}, - {1795, {wxTextAttr, getAlignment, 0}}, - {1796, {wxTextAttr, getBackgroundColour, 0}}, - {1797, {wxTextAttr, getFont, 0}}, - {1798, {wxTextAttr, getLeftIndent, 0}}, - {1799, {wxTextAttr, getLeftSubIndent, 0}}, - {1800, {wxTextAttr, getRightIndent, 0}}, - {1801, {wxTextAttr, getTabs, 0}}, - {1802, {wxTextAttr, getTextColour, 0}}, - {1803, {wxTextAttr, hasBackgroundColour, 0}}, - {1804, {wxTextAttr, hasFont, 0}}, - {1805, {wxTextAttr, hasTextColour, 0}}, - {1806, {wxTextAttr, getFlags, 0}}, - {1807, {wxTextAttr, isDefault, 0}}, - {1808, {wxTextAttr, setAlignment, 1}}, - {1809, {wxTextAttr, setBackgroundColour, 1}}, - {1810, {wxTextAttr, setFlags, 1}}, - {1811, {wxTextAttr, setFont, 2}}, - {1812, {wxTextAttr, setLeftIndent, 2}}, - {1813, {wxTextAttr, setRightIndent, 1}}, - {1814, {wxTextAttr, setTabs, 1}}, - {1815, {wxTextAttr, setTextColour, 1}}, - {1816, {wxTextAttr, 'Destroy', undefined}}, - {1818, {wxTextCtrl, new_3, 3}}, - {1819, {wxTextCtrl, new_0, 0}}, - {1821, {wxTextCtrl, destruct, 0}}, - {1822, {wxTextCtrl, appendText, 1}}, - {1823, {wxTextCtrl, canCopy, 0}}, - {1824, {wxTextCtrl, canCut, 0}}, - {1825, {wxTextCtrl, canPaste, 0}}, - {1826, {wxTextCtrl, canRedo, 0}}, - {1827, {wxTextCtrl, canUndo, 0}}, - {1828, {wxTextCtrl, clear, 0}}, - {1829, {wxTextCtrl, copy, 0}}, - {1830, {wxTextCtrl, create, 3}}, - {1831, {wxTextCtrl, cut, 0}}, - {1832, {wxTextCtrl, discardEdits, 0}}, - {1833, {wxTextCtrl, changeValue, 1}}, - {1834, {wxTextCtrl, emulateKeyPress, 1}}, - {1835, {wxTextCtrl, getDefaultStyle, 0}}, - {1836, {wxTextCtrl, getInsertionPoint, 0}}, - {1837, {wxTextCtrl, getLastPosition, 0}}, - {1838, {wxTextCtrl, getLineLength, 1}}, - {1839, {wxTextCtrl, getLineText, 1}}, - {1840, {wxTextCtrl, getNumberOfLines, 0}}, - {1841, {wxTextCtrl, getRange, 2}}, - {1842, {wxTextCtrl, getSelection, 2}}, - {1843, {wxTextCtrl, getStringSelection, 0}}, - {1844, {wxTextCtrl, getStyle, 2}}, - {1845, {wxTextCtrl, getValue, 0}}, - {1846, {wxTextCtrl, isEditable, 0}}, - {1847, {wxTextCtrl, isModified, 0}}, - {1848, {wxTextCtrl, isMultiLine, 0}}, - {1849, {wxTextCtrl, isSingleLine, 0}}, - {1850, {wxTextCtrl, loadFile, 2}}, - {1851, {wxTextCtrl, markDirty, 0}}, - {1852, {wxTextCtrl, paste, 0}}, - {1853, {wxTextCtrl, positionToXY, 3}}, - {1854, {wxTextCtrl, redo, 0}}, - {1855, {wxTextCtrl, remove, 2}}, - {1856, {wxTextCtrl, replace, 3}}, - {1857, {wxTextCtrl, saveFile, 1}}, - {1858, {wxTextCtrl, setDefaultStyle, 1}}, - {1859, {wxTextCtrl, setEditable, 1}}, - {1860, {wxTextCtrl, setInsertionPoint, 1}}, - {1861, {wxTextCtrl, setInsertionPointEnd, 0}}, - {1863, {wxTextCtrl, setMaxLength, 1}}, - {1864, {wxTextCtrl, setSelection, 2}}, - {1865, {wxTextCtrl, setStyle, 3}}, - {1866, {wxTextCtrl, setValue, 1}}, - {1867, {wxTextCtrl, showPosition, 1}}, - {1868, {wxTextCtrl, undo, 0}}, - {1869, {wxTextCtrl, writeText, 1}}, - {1870, {wxTextCtrl, xYToPosition, 2}}, - {1873, {wxNotebook, new_0, 0}}, - {1874, {wxNotebook, new_3, 3}}, - {1875, {wxNotebook, destruct, 0}}, - {1876, {wxNotebook, addPage, 3}}, - {1877, {wxNotebook, advanceSelection, 1}}, - {1878, {wxNotebook, assignImageList, 1}}, - {1879, {wxNotebook, create, 3}}, - {1880, {wxNotebook, deleteAllPages, 0}}, - {1881, {wxNotebook, deletePage, 1}}, - {1882, {wxNotebook, removePage, 1}}, - {1883, {wxNotebook, getCurrentPage, 0}}, - {1884, {wxNotebook, getImageList, 0}}, - {1886, {wxNotebook, getPage, 1}}, - {1887, {wxNotebook, getPageCount, 0}}, - {1888, {wxNotebook, getPageImage, 1}}, - {1889, {wxNotebook, getPageText, 1}}, - {1890, {wxNotebook, getRowCount, 0}}, - {1891, {wxNotebook, getSelection, 0}}, - {1892, {wxNotebook, getThemeBackgroundColour, 0}}, - {1894, {wxNotebook, hitTest, 2}}, - {1896, {wxNotebook, insertPage, 4}}, - {1897, {wxNotebook, setImageList, 1}}, - {1898, {wxNotebook, setPadding, 1}}, - {1899, {wxNotebook, setPageSize, 1}}, - {1900, {wxNotebook, setPageImage, 2}}, - {1901, {wxNotebook, setPageText, 2}}, - {1902, {wxNotebook, setSelection, 1}}, - {1903, {wxNotebook, changeSelection, 1}}, - {1904, {wxChoicebook, new_0, 0}}, - {1905, {wxChoicebook, new_3, 3}}, - {1906, {wxChoicebook, addPage, 3}}, - {1907, {wxChoicebook, advanceSelection, 1}}, - {1908, {wxChoicebook, assignImageList, 1}}, - {1909, {wxChoicebook, create, 3}}, - {1910, {wxChoicebook, deleteAllPages, 0}}, - {1911, {wxChoicebook, deletePage, 1}}, - {1912, {wxChoicebook, removePage, 1}}, - {1913, {wxChoicebook, getCurrentPage, 0}}, - {1914, {wxChoicebook, getImageList, 0}}, - {1916, {wxChoicebook, getPage, 1}}, - {1917, {wxChoicebook, getPageCount, 0}}, - {1918, {wxChoicebook, getPageImage, 1}}, - {1919, {wxChoicebook, getPageText, 1}}, - {1920, {wxChoicebook, getSelection, 0}}, - {1921, {wxChoicebook, hitTest, 2}}, - {1922, {wxChoicebook, insertPage, 4}}, - {1923, {wxChoicebook, setImageList, 1}}, - {1924, {wxChoicebook, setPageSize, 1}}, - {1925, {wxChoicebook, setPageImage, 2}}, - {1926, {wxChoicebook, setPageText, 2}}, - {1927, {wxChoicebook, setSelection, 1}}, - {1928, {wxChoicebook, changeSelection, 1}}, - {1929, {wxChoicebook, 'Destroy', undefined}}, - {1930, {wxToolbook, new_0, 0}}, - {1931, {wxToolbook, new_3, 3}}, - {1932, {wxToolbook, addPage, 3}}, - {1933, {wxToolbook, advanceSelection, 1}}, - {1934, {wxToolbook, assignImageList, 1}}, - {1935, {wxToolbook, create, 3}}, - {1936, {wxToolbook, deleteAllPages, 0}}, - {1937, {wxToolbook, deletePage, 1}}, - {1938, {wxToolbook, removePage, 1}}, - {1939, {wxToolbook, getCurrentPage, 0}}, - {1940, {wxToolbook, getImageList, 0}}, - {1942, {wxToolbook, getPage, 1}}, - {1943, {wxToolbook, getPageCount, 0}}, - {1944, {wxToolbook, getPageImage, 1}}, - {1945, {wxToolbook, getPageText, 1}}, - {1946, {wxToolbook, getSelection, 0}}, - {1948, {wxToolbook, hitTest, 2}}, - {1949, {wxToolbook, insertPage, 4}}, - {1950, {wxToolbook, setImageList, 1}}, - {1951, {wxToolbook, setPageSize, 1}}, - {1952, {wxToolbook, setPageImage, 2}}, - {1953, {wxToolbook, setPageText, 2}}, - {1954, {wxToolbook, setSelection, 1}}, - {1955, {wxToolbook, changeSelection, 1}}, - {1956, {wxToolbook, 'Destroy', undefined}}, - {1957, {wxListbook, new_0, 0}}, - {1958, {wxListbook, new_3, 3}}, - {1959, {wxListbook, addPage, 3}}, - {1960, {wxListbook, advanceSelection, 1}}, - {1961, {wxListbook, assignImageList, 1}}, - {1962, {wxListbook, create, 3}}, - {1963, {wxListbook, deleteAllPages, 0}}, - {1964, {wxListbook, deletePage, 1}}, - {1965, {wxListbook, removePage, 1}}, - {1966, {wxListbook, getCurrentPage, 0}}, - {1967, {wxListbook, getImageList, 0}}, - {1969, {wxListbook, getPage, 1}}, - {1970, {wxListbook, getPageCount, 0}}, - {1971, {wxListbook, getPageImage, 1}}, - {1972, {wxListbook, getPageText, 1}}, - {1973, {wxListbook, getSelection, 0}}, - {1975, {wxListbook, hitTest, 2}}, - {1976, {wxListbook, insertPage, 4}}, - {1977, {wxListbook, setImageList, 1}}, - {1978, {wxListbook, setPageSize, 1}}, - {1979, {wxListbook, setPageImage, 2}}, - {1980, {wxListbook, setPageText, 2}}, - {1981, {wxListbook, setSelection, 1}}, - {1982, {wxListbook, changeSelection, 1}}, - {1983, {wxListbook, 'Destroy', undefined}}, - {1984, {wxTreebook, new_0, 0}}, - {1985, {wxTreebook, new_3, 3}}, - {1986, {wxTreebook, addPage, 3}}, - {1987, {wxTreebook, advanceSelection, 1}}, - {1988, {wxTreebook, assignImageList, 1}}, - {1989, {wxTreebook, create, 3}}, - {1990, {wxTreebook, deleteAllPages, 0}}, - {1991, {wxTreebook, deletePage, 1}}, - {1992, {wxTreebook, removePage, 1}}, - {1993, {wxTreebook, getCurrentPage, 0}}, - {1994, {wxTreebook, getImageList, 0}}, - {1996, {wxTreebook, getPage, 1}}, - {1997, {wxTreebook, getPageCount, 0}}, - {1998, {wxTreebook, getPageImage, 1}}, - {1999, {wxTreebook, getPageText, 1}}, - {2000, {wxTreebook, getSelection, 0}}, - {2001, {wxTreebook, expandNode, 2}}, - {2002, {wxTreebook, isNodeExpanded, 1}}, - {2004, {wxTreebook, hitTest, 2}}, - {2005, {wxTreebook, insertPage, 4}}, - {2006, {wxTreebook, insertSubPage, 4}}, - {2007, {wxTreebook, setImageList, 1}}, - {2008, {wxTreebook, setPageSize, 1}}, - {2009, {wxTreebook, setPageImage, 2}}, - {2010, {wxTreebook, setPageText, 2}}, - {2011, {wxTreebook, setSelection, 1}}, - {2012, {wxTreebook, changeSelection, 1}}, - {2013, {wxTreebook, 'Destroy', undefined}}, - {2016, {wxTreeCtrl, new_2, 2}}, - {2017, {wxTreeCtrl, new_0, 0}}, - {2019, {wxTreeCtrl, destruct, 0}}, - {2020, {wxTreeCtrl, addRoot, 2}}, - {2021, {wxTreeCtrl, appendItem, 3}}, - {2022, {wxTreeCtrl, assignImageList, 1}}, - {2023, {wxTreeCtrl, assignStateImageList, 1}}, - {2024, {wxTreeCtrl, collapse, 1}}, - {2025, {wxTreeCtrl, collapseAndReset, 1}}, - {2026, {wxTreeCtrl, create, 2}}, - {2027, {wxTreeCtrl, delete, 1}}, - {2028, {wxTreeCtrl, deleteAllItems, 0}}, - {2029, {wxTreeCtrl, deleteChildren, 1}}, - {2030, {wxTreeCtrl, editLabel, 1}}, - {2031, {wxTreeCtrl, ensureVisible, 1}}, - {2032, {wxTreeCtrl, expand, 1}}, - {2033, {wxTreeCtrl, getBoundingRect, 3}}, - {2035, {wxTreeCtrl, getChildrenCount, 2}}, - {2036, {wxTreeCtrl, getCount, 0}}, - {2037, {wxTreeCtrl, getEditControl, 0}}, - {2038, {wxTreeCtrl, getFirstChild, 2}}, - {2039, {wxTreeCtrl, getNextChild, 2}}, - {2040, {wxTreeCtrl, getFirstVisibleItem, 0}}, - {2041, {wxTreeCtrl, getImageList, 0}}, - {2042, {wxTreeCtrl, getIndent, 0}}, - {2043, {wxTreeCtrl, getItemBackgroundColour, 1}}, - {2044, {wxTreeCtrl, getItemData, 1}}, - {2045, {wxTreeCtrl, getItemFont, 1}}, - {2046, {wxTreeCtrl, getItemImage_1, 1}}, - {2047, {wxTreeCtrl, getItemImage_2, 2}}, - {2048, {wxTreeCtrl, getItemText, 1}}, - {2049, {wxTreeCtrl, getItemTextColour, 1}}, - {2050, {wxTreeCtrl, getLastChild, 1}}, - {2051, {wxTreeCtrl, getNextSibling, 1}}, - {2052, {wxTreeCtrl, getNextVisible, 1}}, - {2053, {wxTreeCtrl, getItemParent, 1}}, - {2054, {wxTreeCtrl, getPrevSibling, 1}}, - {2055, {wxTreeCtrl, getPrevVisible, 1}}, - {2056, {wxTreeCtrl, getRootItem, 0}}, - {2057, {wxTreeCtrl, getSelection, 0}}, - {2058, {wxTreeCtrl, getSelections, 1}}, - {2059, {wxTreeCtrl, getStateImageList, 0}}, - {2060, {wxTreeCtrl, hitTest, 2}}, - {2062, {wxTreeCtrl, insertItem, 4}}, - {2063, {wxTreeCtrl, isBold, 1}}, - {2064, {wxTreeCtrl, isExpanded, 1}}, - {2065, {wxTreeCtrl, isSelected, 1}}, - {2066, {wxTreeCtrl, isVisible, 1}}, - {2067, {wxTreeCtrl, itemHasChildren, 1}}, - {2068, {wxTreeCtrl, isTreeItemIdOk, 1}}, - {2069, {wxTreeCtrl, prependItem, 3}}, - {2070, {wxTreeCtrl, scrollTo, 1}}, - {2071, {wxTreeCtrl, selectItem_1, 1}}, - {2072, {wxTreeCtrl, selectItem_2, 2}}, - {2073, {wxTreeCtrl, setIndent, 1}}, - {2074, {wxTreeCtrl, setImageList, 1}}, - {2075, {wxTreeCtrl, setItemBackgroundColour, 2}}, - {2076, {wxTreeCtrl, setItemBold, 2}}, - {2077, {wxTreeCtrl, setItemData, 2}}, - {2078, {wxTreeCtrl, setItemDropHighlight, 2}}, - {2079, {wxTreeCtrl, setItemFont, 2}}, - {2080, {wxTreeCtrl, setItemHasChildren, 2}}, - {2081, {wxTreeCtrl, setItemImage_2, 2}}, - {2082, {wxTreeCtrl, setItemImage_3, 3}}, - {2083, {wxTreeCtrl, setItemText, 2}}, - {2084, {wxTreeCtrl, setItemTextColour, 2}}, - {2085, {wxTreeCtrl, setStateImageList, 1}}, - {2086, {wxTreeCtrl, setWindowStyle, 1}}, - {2087, {wxTreeCtrl, sortChildren, 1}}, - {2088, {wxTreeCtrl, toggle, 1}}, - {2089, {wxTreeCtrl, toggleItemSelection, 1}}, - {2090, {wxTreeCtrl, unselect, 0}}, - {2091, {wxTreeCtrl, unselectAll, 0}}, - {2092, {wxTreeCtrl, unselectItem, 1}}, - {2093, {wxScrollBar, new_0, 0}}, - {2094, {wxScrollBar, new_3, 3}}, - {2095, {wxScrollBar, destruct, 0}}, - {2096, {wxScrollBar, create, 3}}, - {2097, {wxScrollBar, getRange, 0}}, - {2098, {wxScrollBar, getPageSize, 0}}, - {2099, {wxScrollBar, getThumbPosition, 0}}, - {2100, {wxScrollBar, getThumbSize, 0}}, - {2101, {wxScrollBar, setThumbPosition, 1}}, - {2102, {wxScrollBar, setScrollbar, 5}}, - {2104, {wxSpinButton, new_2, 2}}, - {2105, {wxSpinButton, new_0, 0}}, - {2106, {wxSpinButton, create, 2}}, - {2107, {wxSpinButton, getMax, 0}}, - {2108, {wxSpinButton, getMin, 0}}, - {2109, {wxSpinButton, getValue, 0}}, - {2110, {wxSpinButton, setRange, 2}}, - {2111, {wxSpinButton, setValue, 1}}, - {2112, {wxSpinButton, 'Destroy', undefined}}, - {2113, {wxSpinCtrl, new_0, 0}}, - {2114, {wxSpinCtrl, new_2, 2}}, - {2116, {wxSpinCtrl, create, 2}}, - {2119, {wxSpinCtrl, setValue_1_1, 1}}, - {2120, {wxSpinCtrl, setValue_1_0, 1}}, - {2122, {wxSpinCtrl, getValue, 0}}, - {2124, {wxSpinCtrl, setRange, 2}}, - {2125, {wxSpinCtrl, setSelection, 2}}, - {2127, {wxSpinCtrl, getMin, 0}}, - {2129, {wxSpinCtrl, getMax, 0}}, - {2130, {wxSpinCtrl, 'Destroy', undefined}}, - {2131, {wxStaticText, new_0, 0}}, - {2132, {wxStaticText, new_4, 4}}, - {2133, {wxStaticText, create, 4}}, - {2134, {wxStaticText, getLabel, 0}}, - {2135, {wxStaticText, setLabel, 1}}, - {2136, {wxStaticText, wrap, 1}}, - {2137, {wxStaticText, 'Destroy', undefined}}, - {2138, {wxStaticBitmap, new_0, 0}}, - {2139, {wxStaticBitmap, new_4, 4}}, - {2140, {wxStaticBitmap, create, 4}}, - {2141, {wxStaticBitmap, getBitmap, 0}}, - {2142, {wxStaticBitmap, setBitmap, 1}}, - {2143, {wxStaticBitmap, 'Destroy', undefined}}, - {2144, {wxRadioBox, new, 7}}, - {2146, {wxRadioBox, destruct, 0}}, - {2147, {wxRadioBox, create, 7}}, - {2148, {wxRadioBox, enable_2, 2}}, - {2149, {wxRadioBox, enable_1, 1}}, - {2150, {wxRadioBox, getSelection, 0}}, - {2151, {wxRadioBox, getString, 1}}, - {2152, {wxRadioBox, setSelection, 1}}, - {2153, {wxRadioBox, show_2, 2}}, - {2154, {wxRadioBox, show_1, 1}}, - {2155, {wxRadioBox, getColumnCount, 0}}, - {2156, {wxRadioBox, getItemHelpText, 1}}, - {2157, {wxRadioBox, getItemToolTip, 1}}, - {2159, {wxRadioBox, getItemFromPoint, 1}}, - {2160, {wxRadioBox, getRowCount, 0}}, - {2161, {wxRadioBox, isItemEnabled, 1}}, - {2162, {wxRadioBox, isItemShown, 1}}, - {2163, {wxRadioBox, setItemHelpText, 2}}, - {2164, {wxRadioBox, setItemToolTip, 2}}, - {2165, {wxRadioButton, new_0, 0}}, - {2166, {wxRadioButton, new_4, 4}}, - {2167, {wxRadioButton, create, 4}}, - {2168, {wxRadioButton, getValue, 0}}, - {2169, {wxRadioButton, setValue, 1}}, - {2170, {wxRadioButton, 'Destroy', undefined}}, - {2172, {wxSlider, new_6, 6}}, - {2173, {wxSlider, new_0, 0}}, - {2174, {wxSlider, create, 6}}, - {2175, {wxSlider, getLineSize, 0}}, - {2176, {wxSlider, getMax, 0}}, - {2177, {wxSlider, getMin, 0}}, - {2178, {wxSlider, getPageSize, 0}}, - {2179, {wxSlider, getThumbLength, 0}}, - {2180, {wxSlider, getValue, 0}}, - {2181, {wxSlider, setLineSize, 1}}, - {2182, {wxSlider, setPageSize, 1}}, - {2183, {wxSlider, setRange, 2}}, - {2184, {wxSlider, setThumbLength, 1}}, - {2185, {wxSlider, setValue, 1}}, - {2186, {wxSlider, 'Destroy', undefined}}, - {2188, {wxDialog, new_4, 4}}, - {2189, {wxDialog, new_0, 0}}, - {2191, {wxDialog, destruct, 0}}, - {2192, {wxDialog, create, 4}}, - {2193, {wxDialog, createButtonSizer, 1}}, - {2194, {wxDialog, createStdDialogButtonSizer, 1}}, - {2195, {wxDialog, endModal, 1}}, - {2196, {wxDialog, getAffirmativeId, 0}}, - {2197, {wxDialog, getReturnCode, 0}}, - {2198, {wxDialog, isModal, 0}}, - {2199, {wxDialog, setAffirmativeId, 1}}, - {2200, {wxDialog, setReturnCode, 1}}, - {2201, {wxDialog, show, 1}}, - {2202, {wxDialog, showModal, 0}}, - {2203, {wxColourDialog, new_0, 0}}, - {2204, {wxColourDialog, new_2, 2}}, - {2205, {wxColourDialog, destruct, 0}}, - {2206, {wxColourDialog, create, 2}}, - {2207, {wxColourDialog, getColourData, 0}}, - {2208, {wxColourData, new_0, 0}}, - {2209, {wxColourData, new_1, 1}}, - {2210, {wxColourData, destruct, 0}}, - {2211, {wxColourData, getChooseFull, 0}}, - {2212, {wxColourData, getColour, 0}}, - {2214, {wxColourData, getCustomColour, 1}}, - {2215, {wxColourData, setChooseFull, 1}}, - {2216, {wxColourData, setColour, 1}}, - {2217, {wxColourData, setCustomColour, 2}}, - {2218, {wxPalette, new_0, 0}}, - {2219, {wxPalette, new_4, 4}}, - {2221, {wxPalette, destruct, 0}}, - {2222, {wxPalette, create, 4}}, - {2223, {wxPalette, getColoursCount, 0}}, - {2224, {wxPalette, getPixel, 3}}, - {2225, {wxPalette, getRGB, 4}}, - {2226, {wxPalette, isOk, 0}}, - {2230, {wxDirDialog, new, 2}}, - {2231, {wxDirDialog, destruct, 0}}, - {2232, {wxDirDialog, getPath, 0}}, - {2233, {wxDirDialog, getMessage, 0}}, - {2234, {wxDirDialog, setMessage, 1}}, - {2235, {wxDirDialog, setPath, 1}}, - {2239, {wxFileDialog, new, 2}}, - {2240, {wxFileDialog, destruct, 0}}, - {2241, {wxFileDialog, getDirectory, 0}}, - {2242, {wxFileDialog, getFilename, 0}}, - {2243, {wxFileDialog, getFilenames, 1}}, - {2244, {wxFileDialog, getFilterIndex, 0}}, - {2245, {wxFileDialog, getMessage, 0}}, - {2246, {wxFileDialog, getPath, 0}}, - {2247, {wxFileDialog, getPaths, 1}}, - {2248, {wxFileDialog, getWildcard, 0}}, - {2249, {wxFileDialog, setDirectory, 1}}, - {2250, {wxFileDialog, setFilename, 1}}, - {2251, {wxFileDialog, setFilterIndex, 1}}, - {2252, {wxFileDialog, setMessage, 1}}, - {2253, {wxFileDialog, setPath, 1}}, - {2254, {wxFileDialog, setWildcard, 1}}, - {2255, {wxPickerBase, setInternalMargin, 1}}, - {2256, {wxPickerBase, getInternalMargin, 0}}, - {2257, {wxPickerBase, setTextCtrlProportion, 1}}, - {2258, {wxPickerBase, setPickerCtrlProportion, 1}}, - {2259, {wxPickerBase, getTextCtrlProportion, 0}}, - {2260, {wxPickerBase, getPickerCtrlProportion, 0}}, - {2261, {wxPickerBase, hasTextCtrl, 0}}, - {2262, {wxPickerBase, getTextCtrl, 0}}, - {2263, {wxPickerBase, isTextCtrlGrowable, 0}}, - {2264, {wxPickerBase, setPickerCtrlGrowable, 1}}, - {2265, {wxPickerBase, setTextCtrlGrowable, 1}}, - {2266, {wxPickerBase, isPickerCtrlGrowable, 0}}, - {2267, {wxFilePickerCtrl, new_0, 0}}, - {2268, {wxFilePickerCtrl, new_3, 3}}, - {2269, {wxFilePickerCtrl, create, 3}}, - {2270, {wxFilePickerCtrl, getPath, 0}}, - {2271, {wxFilePickerCtrl, setPath, 1}}, - {2272, {wxFilePickerCtrl, 'Destroy', undefined}}, - {2273, {wxDirPickerCtrl, new_0, 0}}, - {2274, {wxDirPickerCtrl, new_3, 3}}, - {2275, {wxDirPickerCtrl, create, 3}}, - {2276, {wxDirPickerCtrl, getPath, 0}}, - {2277, {wxDirPickerCtrl, setPath, 1}}, - {2278, {wxDirPickerCtrl, 'Destroy', undefined}}, - {2279, {wxColourPickerCtrl, new_0, 0}}, - {2280, {wxColourPickerCtrl, new_3, 3}}, - {2281, {wxColourPickerCtrl, create, 3}}, - {2282, {wxColourPickerCtrl, getColour, 0}}, - {2283, {wxColourPickerCtrl, setColour_1_1, 1}}, - {2284, {wxColourPickerCtrl, setColour_1_0, 1}}, - {2285, {wxColourPickerCtrl, 'Destroy', undefined}}, - {2286, {wxDatePickerCtrl, new_0, 0}}, - {2287, {wxDatePickerCtrl, new_3, 3}}, - {2288, {wxDatePickerCtrl, getRange, 2}}, - {2289, {wxDatePickerCtrl, getValue, 0}}, - {2290, {wxDatePickerCtrl, setRange, 2}}, - {2291, {wxDatePickerCtrl, setValue, 1}}, - {2292, {wxDatePickerCtrl, 'Destroy', undefined}}, - {2293, {wxFontPickerCtrl, new_0, 0}}, - {2294, {wxFontPickerCtrl, new_3, 3}}, - {2295, {wxFontPickerCtrl, create, 3}}, - {2296, {wxFontPickerCtrl, getSelectedFont, 0}}, - {2297, {wxFontPickerCtrl, setSelectedFont, 1}}, - {2298, {wxFontPickerCtrl, getMaxPointSize, 0}}, - {2299, {wxFontPickerCtrl, setMaxPointSize, 1}}, - {2300, {wxFontPickerCtrl, 'Destroy', undefined}}, - {2303, {wxFindReplaceDialog, new_0, 0}}, - {2304, {wxFindReplaceDialog, new_4, 4}}, - {2305, {wxFindReplaceDialog, destruct, 0}}, - {2306, {wxFindReplaceDialog, create, 4}}, - {2307, {wxFindReplaceDialog, getData, 0}}, - {2308, {wxFindReplaceData, new_0, 0}}, - {2309, {wxFindReplaceData, new_1, 1}}, - {2310, {wxFindReplaceData, getFindString, 0}}, - {2311, {wxFindReplaceData, getReplaceString, 0}}, - {2312, {wxFindReplaceData, getFlags, 0}}, - {2313, {wxFindReplaceData, setFlags, 1}}, - {2314, {wxFindReplaceData, setFindString, 1}}, - {2315, {wxFindReplaceData, setReplaceString, 1}}, - {2316, {wxFindReplaceData, 'Destroy', undefined}}, - {2317, {wxMultiChoiceDialog, new_0, 0}}, - {2319, {wxMultiChoiceDialog, new_5, 5}}, - {2320, {wxMultiChoiceDialog, getSelections, 0}}, - {2321, {wxMultiChoiceDialog, setSelections, 1}}, - {2322, {wxMultiChoiceDialog, 'Destroy', undefined}}, - {2323, {wxSingleChoiceDialog, new_0, 0}}, - {2325, {wxSingleChoiceDialog, new_5, 5}}, - {2326, {wxSingleChoiceDialog, getSelection, 0}}, - {2327, {wxSingleChoiceDialog, getStringSelection, 0}}, - {2328, {wxSingleChoiceDialog, setSelection, 1}}, - {2329, {wxSingleChoiceDialog, 'Destroy', undefined}}, - {2330, {wxTextEntryDialog, new, 3}}, - {2331, {wxTextEntryDialog, getValue, 0}}, - {2332, {wxTextEntryDialog, setValue, 1}}, - {2333, {wxTextEntryDialog, 'Destroy', undefined}}, - {2334, {wxPasswordEntryDialog, new, 3}}, - {2335, {wxPasswordEntryDialog, 'Destroy', undefined}}, - {2336, {wxFontData, new_0, 0}}, - {2337, {wxFontData, new_1, 1}}, - {2338, {wxFontData, destruct, 0}}, - {2339, {wxFontData, enableEffects, 1}}, - {2340, {wxFontData, getAllowSymbols, 0}}, - {2341, {wxFontData, getColour, 0}}, - {2342, {wxFontData, getChosenFont, 0}}, - {2343, {wxFontData, getEnableEffects, 0}}, - {2344, {wxFontData, getInitialFont, 0}}, - {2345, {wxFontData, getShowHelp, 0}}, - {2346, {wxFontData, setAllowSymbols, 1}}, - {2347, {wxFontData, setChosenFont, 1}}, - {2348, {wxFontData, setColour, 1}}, - {2349, {wxFontData, setInitialFont, 1}}, - {2350, {wxFontData, setRange, 2}}, - {2351, {wxFontData, setShowHelp, 1}}, - {2355, {wxFontDialog, new_0, 0}}, - {2357, {wxFontDialog, new_2, 2}}, - {2359, {wxFontDialog, create, 2}}, - {2360, {wxFontDialog, getFontData, 0}}, - {2362, {wxFontDialog, 'Destroy', undefined}}, - {2363, {wxProgressDialog, new, 3}}, - {2364, {wxProgressDialog, destruct, 0}}, - {2365, {wxProgressDialog, resume, 0}}, - {2366, {wxProgressDialog, update_2, 2}}, - {2367, {wxProgressDialog, update_0, 0}}, - {2368, {wxMessageDialog, new, 3}}, - {2369, {wxMessageDialog, destruct, 0}}, - {2370, {wxPageSetupDialog, new, 2}}, - {2371, {wxPageSetupDialog, destruct, 0}}, - {2372, {wxPageSetupDialog, getPageSetupData, 0}}, - {2373, {wxPageSetupDialog, showModal, 0}}, - {2374, {wxPageSetupDialogData, new_0, 0}}, - {2375, {wxPageSetupDialogData, new_1_0, 1}}, - {2376, {wxPageSetupDialogData, new_1_1, 1}}, - {2377, {wxPageSetupDialogData, destruct, 0}}, - {2378, {wxPageSetupDialogData, enableHelp, 1}}, - {2379, {wxPageSetupDialogData, enableMargins, 1}}, - {2380, {wxPageSetupDialogData, enableOrientation, 1}}, - {2381, {wxPageSetupDialogData, enablePaper, 1}}, - {2382, {wxPageSetupDialogData, enablePrinter, 1}}, - {2383, {wxPageSetupDialogData, getDefaultMinMargins, 0}}, - {2384, {wxPageSetupDialogData, getEnableMargins, 0}}, - {2385, {wxPageSetupDialogData, getEnableOrientation, 0}}, - {2386, {wxPageSetupDialogData, getEnablePaper, 0}}, - {2387, {wxPageSetupDialogData, getEnablePrinter, 0}}, - {2388, {wxPageSetupDialogData, getEnableHelp, 0}}, - {2389, {wxPageSetupDialogData, getDefaultInfo, 0}}, - {2390, {wxPageSetupDialogData, getMarginTopLeft, 0}}, - {2391, {wxPageSetupDialogData, getMarginBottomRight, 0}}, - {2392, {wxPageSetupDialogData, getMinMarginTopLeft, 0}}, - {2393, {wxPageSetupDialogData, getMinMarginBottomRight, 0}}, - {2394, {wxPageSetupDialogData, getPaperId, 0}}, - {2395, {wxPageSetupDialogData, getPaperSize, 0}}, - {2397, {wxPageSetupDialogData, getPrintData, 0}}, - {2398, {wxPageSetupDialogData, isOk, 0}}, - {2399, {wxPageSetupDialogData, setDefaultInfo, 1}}, - {2400, {wxPageSetupDialogData, setDefaultMinMargins, 1}}, - {2401, {wxPageSetupDialogData, setMarginTopLeft, 1}}, - {2402, {wxPageSetupDialogData, setMarginBottomRight, 1}}, - {2403, {wxPageSetupDialogData, setMinMarginTopLeft, 1}}, - {2404, {wxPageSetupDialogData, setMinMarginBottomRight, 1}}, - {2405, {wxPageSetupDialogData, setPaperId, 1}}, - {2406, {wxPageSetupDialogData, setPaperSize_1_1, 1}}, - {2407, {wxPageSetupDialogData, setPaperSize_1_0, 1}}, - {2408, {wxPageSetupDialogData, setPrintData, 1}}, - {2409, {wxPrintDialog, new_2_0, 2}}, - {2410, {wxPrintDialog, new_2_1, 2}}, - {2411, {wxPrintDialog, destruct, 0}}, - {2412, {wxPrintDialog, getPrintDialogData, 0}}, - {2413, {wxPrintDialog, getPrintDC, 0}}, - {2414, {wxPrintDialogData, new_0, 0}}, - {2415, {wxPrintDialogData, new_1_1, 1}}, - {2416, {wxPrintDialogData, new_1_0, 1}}, - {2417, {wxPrintDialogData, destruct, 0}}, - {2418, {wxPrintDialogData, enableHelp, 1}}, - {2419, {wxPrintDialogData, enablePageNumbers, 1}}, - {2420, {wxPrintDialogData, enablePrintToFile, 1}}, - {2421, {wxPrintDialogData, enableSelection, 1}}, - {2422, {wxPrintDialogData, getAllPages, 0}}, - {2423, {wxPrintDialogData, getCollate, 0}}, - {2424, {wxPrintDialogData, getFromPage, 0}}, - {2425, {wxPrintDialogData, getMaxPage, 0}}, - {2426, {wxPrintDialogData, getMinPage, 0}}, - {2427, {wxPrintDialogData, getNoCopies, 0}}, - {2428, {wxPrintDialogData, getPrintData, 0}}, - {2429, {wxPrintDialogData, getPrintToFile, 0}}, - {2430, {wxPrintDialogData, getSelection, 0}}, - {2431, {wxPrintDialogData, getToPage, 0}}, - {2432, {wxPrintDialogData, isOk, 0}}, - {2433, {wxPrintDialogData, setCollate, 1}}, - {2434, {wxPrintDialogData, setFromPage, 1}}, - {2435, {wxPrintDialogData, setMaxPage, 1}}, - {2436, {wxPrintDialogData, setMinPage, 1}}, - {2437, {wxPrintDialogData, setNoCopies, 1}}, - {2438, {wxPrintDialogData, setPrintData, 1}}, - {2439, {wxPrintDialogData, setPrintToFile, 1}}, - {2440, {wxPrintDialogData, setSelection, 1}}, - {2441, {wxPrintDialogData, setToPage, 1}}, - {2442, {wxPrintData, new_0, 0}}, - {2443, {wxPrintData, new_1, 1}}, - {2444, {wxPrintData, destruct, 0}}, - {2445, {wxPrintData, getCollate, 0}}, - {2446, {wxPrintData, getBin, 0}}, - {2447, {wxPrintData, getColour, 0}}, - {2448, {wxPrintData, getDuplex, 0}}, - {2449, {wxPrintData, getNoCopies, 0}}, - {2450, {wxPrintData, getOrientation, 0}}, - {2451, {wxPrintData, getPaperId, 0}}, - {2452, {wxPrintData, getPrinterName, 0}}, - {2453, {wxPrintData, getQuality, 0}}, - {2454, {wxPrintData, isOk, 0}}, - {2455, {wxPrintData, setBin, 1}}, - {2456, {wxPrintData, setCollate, 1}}, - {2457, {wxPrintData, setColour, 1}}, - {2458, {wxPrintData, setDuplex, 1}}, - {2459, {wxPrintData, setNoCopies, 1}}, - {2460, {wxPrintData, setOrientation, 1}}, - {2461, {wxPrintData, setPaperId, 1}}, - {2462, {wxPrintData, setPrinterName, 1}}, - {2463, {wxPrintData, setQuality, 1}}, - {2466, {wxPrintPreview, new_2, 2}}, - {2467, {wxPrintPreview, new_3, 3}}, - {2469, {wxPrintPreview, destruct, 0}}, - {2470, {wxPrintPreview, getCanvas, 0}}, - {2471, {wxPrintPreview, getCurrentPage, 0}}, - {2472, {wxPrintPreview, getFrame, 0}}, - {2473, {wxPrintPreview, getMaxPage, 0}}, - {2474, {wxPrintPreview, getMinPage, 0}}, - {2475, {wxPrintPreview, getPrintout, 0}}, - {2476, {wxPrintPreview, getPrintoutForPrinting, 0}}, - {2477, {wxPrintPreview, isOk, 0}}, - {2478, {wxPrintPreview, paintPage, 2}}, - {2479, {wxPrintPreview, print, 1}}, - {2480, {wxPrintPreview, renderPage, 1}}, - {2481, {wxPrintPreview, setCanvas, 1}}, - {2482, {wxPrintPreview, setCurrentPage, 1}}, - {2483, {wxPrintPreview, setFrame, 1}}, - {2484, {wxPrintPreview, setPrintout, 1}}, - {2485, {wxPrintPreview, setZoom, 1}}, - {2486, {wxPreviewFrame, new, 3}}, - {2487, {wxPreviewFrame, destruct, 0}}, - {2488, {wxPreviewFrame, createControlBar, 0}}, - {2489, {wxPreviewFrame, createCanvas, 0}}, - {2490, {wxPreviewFrame, initialize, 0}}, - {2491, {wxPreviewFrame, onCloseWindow, 1}}, - {2492, {wxPreviewControlBar, new, 4}}, - {2493, {wxPreviewControlBar, destruct, 0}}, - {2494, {wxPreviewControlBar, createButtons, 0}}, - {2495, {wxPreviewControlBar, getPrintPreview, 0}}, - {2496, {wxPreviewControlBar, getZoomControl, 0}}, - {2497, {wxPreviewControlBar, setZoomControl, 1}}, - {2499, {wxPrinter, new, 1}}, - {2500, {wxPrinter, createAbortWindow, 2}}, - {2501, {wxPrinter, getAbort, 0}}, - {2502, {wxPrinter, getLastError, 0}}, - {2503, {wxPrinter, getPrintDialogData, 0}}, - {2504, {wxPrinter, print, 3}}, - {2505, {wxPrinter, printDialog, 1}}, - {2506, {wxPrinter, reportError, 3}}, - {2507, {wxPrinter, setup, 1}}, - {2508, {wxPrinter, 'Destroy', undefined}}, - {2509, {wxXmlResource, new_1, 1}}, - {2510, {wxXmlResource, new_2, 2}}, - {2511, {wxXmlResource, destruct, 0}}, - {2512, {wxXmlResource, attachUnknownControl, 3}}, - {2513, {wxXmlResource, clearHandlers, 0}}, - {2514, {wxXmlResource, compareVersion, 4}}, - {2515, {wxXmlResource, get, 0}}, - {2516, {wxXmlResource, getFlags, 0}}, - {2517, {wxXmlResource, getVersion, 0}}, - {2518, {wxXmlResource, getXRCID, 2}}, - {2519, {wxXmlResource, initAllHandlers, 0}}, - {2520, {wxXmlResource, load, 1}}, - {2521, {wxXmlResource, loadBitmap, 1}}, - {2522, {wxXmlResource, loadDialog_2, 2}}, - {2523, {wxXmlResource, loadDialog_3, 3}}, - {2524, {wxXmlResource, loadFrame_2, 2}}, - {2525, {wxXmlResource, loadFrame_3, 3}}, - {2526, {wxXmlResource, loadIcon, 1}}, - {2527, {wxXmlResource, loadMenu, 1}}, - {2528, {wxXmlResource, loadMenuBar_2, 2}}, - {2529, {wxXmlResource, loadMenuBar_1, 1}}, - {2530, {wxXmlResource, loadPanel_2, 2}}, - {2531, {wxXmlResource, loadPanel_3, 3}}, - {2532, {wxXmlResource, loadToolBar, 2}}, - {2533, {wxXmlResource, set, 1}}, - {2534, {wxXmlResource, setFlags, 1}}, - {2535, {wxXmlResource, unload, 1}}, - {2536, {wxXmlResource, xrcctrl, 3}}, - {2537, {wxHtmlEasyPrinting, new, 1}}, - {2538, {wxHtmlEasyPrinting, destruct, 0}}, - {2539, {wxHtmlEasyPrinting, getPrintData, 0}}, - {2540, {wxHtmlEasyPrinting, getPageSetupData, 0}}, - {2541, {wxHtmlEasyPrinting, previewFile, 1}}, - {2542, {wxHtmlEasyPrinting, previewText, 2}}, - {2543, {wxHtmlEasyPrinting, printFile, 1}}, - {2544, {wxHtmlEasyPrinting, printText, 2}}, - {2545, {wxHtmlEasyPrinting, pageSetup, 0}}, - {2546, {wxHtmlEasyPrinting, setFonts, 3}}, - {2547, {wxHtmlEasyPrinting, setHeader, 2}}, - {2548, {wxHtmlEasyPrinting, setFooter, 2}}, - {2550, {wxGLCanvas, new_2, 2}}, - {2551, {wxGLCanvas, new_3_1, 3}}, - {2552, {wxGLCanvas, new_3_0, 3}}, - {2553, {wxGLCanvas, getContext, 0}}, - {2555, {wxGLCanvas, setCurrent, 0}}, - {2556, {wxGLCanvas, swapBuffers, 0}}, - {2557, {wxGLCanvas, 'Destroy', undefined}}, - {2558, {wxAuiManager, new, 1}}, - {2559, {wxAuiManager, destruct, 0}}, - {2560, {wxAuiManager, addPane_2_1, 2}}, - {2561, {wxAuiManager, addPane_3, 3}}, - {2562, {wxAuiManager, addPane_2_0, 2}}, - {2563, {wxAuiManager, detachPane, 1}}, - {2564, {wxAuiManager, getAllPanes, 0}}, - {2565, {wxAuiManager, getArtProvider, 0}}, - {2566, {wxAuiManager, getDockSizeConstraint, 2}}, - {2567, {wxAuiManager, getFlags, 0}}, - {2568, {wxAuiManager, getManagedWindow, 0}}, - {2569, {wxAuiManager, getManager, 1}}, - {2570, {wxAuiManager, getPane_1_1, 1}}, - {2571, {wxAuiManager, getPane_1_0, 1}}, - {2572, {wxAuiManager, hideHint, 0}}, - {2573, {wxAuiManager, insertPane, 3}}, - {2574, {wxAuiManager, loadPaneInfo, 2}}, - {2575, {wxAuiManager, loadPerspective, 2}}, - {2576, {wxAuiManager, savePaneInfo, 1}}, - {2577, {wxAuiManager, savePerspective, 0}}, - {2578, {wxAuiManager, setArtProvider, 1}}, - {2579, {wxAuiManager, setDockSizeConstraint, 2}}, - {2580, {wxAuiManager, setFlags, 1}}, - {2581, {wxAuiManager, setManagedWindow, 1}}, - {2582, {wxAuiManager, showHint, 1}}, - {2583, {wxAuiManager, unInit, 0}}, - {2584, {wxAuiManager, update, 0}}, - {2585, {wxAuiPaneInfo, new_0, 0}}, - {2586, {wxAuiPaneInfo, new_1, 1}}, - {2587, {wxAuiPaneInfo, destruct, 0}}, - {2588, {wxAuiPaneInfo, bestSize_1, 1}}, - {2589, {wxAuiPaneInfo, bestSize_2, 2}}, - {2590, {wxAuiPaneInfo, bottom, 0}}, - {2591, {wxAuiPaneInfo, bottomDockable, 1}}, - {2592, {wxAuiPaneInfo, caption, 1}}, - {2593, {wxAuiPaneInfo, captionVisible, 1}}, - {2594, {wxAuiPaneInfo, centre, 0}}, - {2595, {wxAuiPaneInfo, centrePane, 0}}, - {2596, {wxAuiPaneInfo, closeButton, 1}}, - {2597, {wxAuiPaneInfo, defaultPane, 0}}, - {2598, {wxAuiPaneInfo, destroyOnClose, 1}}, - {2599, {wxAuiPaneInfo, direction, 1}}, - {2600, {wxAuiPaneInfo, dock, 0}}, - {2601, {wxAuiPaneInfo, dockable, 1}}, - {2602, {wxAuiPaneInfo, fixed, 0}}, - {2603, {wxAuiPaneInfo, float, 0}}, - {2604, {wxAuiPaneInfo, floatable, 1}}, - {2605, {wxAuiPaneInfo, floatingPosition_1, 1}}, - {2606, {wxAuiPaneInfo, floatingPosition_2, 2}}, - {2607, {wxAuiPaneInfo, floatingSize_1, 1}}, - {2608, {wxAuiPaneInfo, floatingSize_2, 2}}, - {2609, {wxAuiPaneInfo, gripper, 1}}, - {2610, {wxAuiPaneInfo, gripperTop, 1}}, - {2611, {wxAuiPaneInfo, hasBorder, 0}}, - {2612, {wxAuiPaneInfo, hasCaption, 0}}, - {2613, {wxAuiPaneInfo, hasCloseButton, 0}}, - {2614, {wxAuiPaneInfo, hasFlag, 1}}, - {2615, {wxAuiPaneInfo, hasGripper, 0}}, - {2616, {wxAuiPaneInfo, hasGripperTop, 0}}, - {2617, {wxAuiPaneInfo, hasMaximizeButton, 0}}, - {2618, {wxAuiPaneInfo, hasMinimizeButton, 0}}, - {2619, {wxAuiPaneInfo, hasPinButton, 0}}, - {2620, {wxAuiPaneInfo, hide, 0}}, - {2621, {wxAuiPaneInfo, isBottomDockable, 0}}, - {2622, {wxAuiPaneInfo, isDocked, 0}}, - {2623, {wxAuiPaneInfo, isFixed, 0}}, - {2624, {wxAuiPaneInfo, isFloatable, 0}}, - {2625, {wxAuiPaneInfo, isFloating, 0}}, - {2626, {wxAuiPaneInfo, isLeftDockable, 0}}, - {2627, {wxAuiPaneInfo, isMovable, 0}}, - {2628, {wxAuiPaneInfo, isOk, 0}}, - {2629, {wxAuiPaneInfo, isResizable, 0}}, - {2630, {wxAuiPaneInfo, isRightDockable, 0}}, - {2631, {wxAuiPaneInfo, isShown, 0}}, - {2632, {wxAuiPaneInfo, isToolbar, 0}}, - {2633, {wxAuiPaneInfo, isTopDockable, 0}}, - {2634, {wxAuiPaneInfo, layer, 1}}, - {2635, {wxAuiPaneInfo, left, 0}}, - {2636, {wxAuiPaneInfo, leftDockable, 1}}, - {2637, {wxAuiPaneInfo, maxSize_1, 1}}, - {2638, {wxAuiPaneInfo, maxSize_2, 2}}, - {2639, {wxAuiPaneInfo, maximizeButton, 1}}, - {2640, {wxAuiPaneInfo, minSize_1, 1}}, - {2641, {wxAuiPaneInfo, minSize_2, 2}}, - {2642, {wxAuiPaneInfo, minimizeButton, 1}}, - {2643, {wxAuiPaneInfo, movable, 1}}, - {2644, {wxAuiPaneInfo, name, 1}}, - {2645, {wxAuiPaneInfo, paneBorder, 1}}, - {2646, {wxAuiPaneInfo, pinButton, 1}}, - {2647, {wxAuiPaneInfo, position, 1}}, - {2648, {wxAuiPaneInfo, resizable, 1}}, - {2649, {wxAuiPaneInfo, right, 0}}, - {2650, {wxAuiPaneInfo, rightDockable, 1}}, - {2651, {wxAuiPaneInfo, row, 1}}, - {2652, {wxAuiPaneInfo, safeSet, 1}}, - {2653, {wxAuiPaneInfo, setFlag, 2}}, - {2654, {wxAuiPaneInfo, show, 1}}, - {2655, {wxAuiPaneInfo, toolbarPane, 0}}, - {2656, {wxAuiPaneInfo, top, 0}}, - {2657, {wxAuiPaneInfo, topDockable, 1}}, - {2658, {wxAuiPaneInfo, window, 1}}, - {2659, {wxAuiPaneInfo, getWindow, 0}}, - {2660, {wxAuiPaneInfo, getFrame, 0}}, - {2661, {wxAuiPaneInfo, getDirection, 0}}, - {2662, {wxAuiPaneInfo, getLayer, 0}}, - {2663, {wxAuiPaneInfo, getRow, 0}}, - {2664, {wxAuiPaneInfo, getPosition, 0}}, - {2665, {wxAuiPaneInfo, getFloatingPosition, 0}}, - {2666, {wxAuiPaneInfo, getFloatingSize, 0}}, - {2667, {wxAuiNotebook, new_0, 0}}, - {2668, {wxAuiNotebook, new_2, 2}}, - {2669, {wxAuiNotebook, addPage, 3}}, - {2670, {wxAuiNotebook, create, 2}}, - {2671, {wxAuiNotebook, deletePage, 1}}, - {2672, {wxAuiNotebook, getArtProvider, 0}}, - {2673, {wxAuiNotebook, getPage, 1}}, - {2674, {wxAuiNotebook, getPageBitmap, 1}}, - {2675, {wxAuiNotebook, getPageCount, 0}}, - {2676, {wxAuiNotebook, getPageIndex, 1}}, - {2677, {wxAuiNotebook, getPageText, 1}}, - {2678, {wxAuiNotebook, getSelection, 0}}, - {2679, {wxAuiNotebook, insertPage, 4}}, - {2680, {wxAuiNotebook, removePage, 1}}, - {2681, {wxAuiNotebook, setArtProvider, 1}}, - {2682, {wxAuiNotebook, setFont, 1}}, - {2683, {wxAuiNotebook, setPageBitmap, 2}}, - {2684, {wxAuiNotebook, setPageText, 2}}, - {2685, {wxAuiNotebook, setSelection, 1}}, - {2686, {wxAuiNotebook, setTabCtrlHeight, 1}}, - {2687, {wxAuiNotebook, setUniformBitmapSize, 1}}, - {2688, {wxAuiNotebook, 'Destroy', undefined}}, - {2689, {wxAuiTabArt, setFlags, 1}}, - {2690, {wxAuiTabArt, setMeasuringFont, 1}}, - {2691, {wxAuiTabArt, setNormalFont, 1}}, - {2692, {wxAuiTabArt, setSelectedFont, 1}}, - {2693, {wxAuiTabArt, setColour, 1}}, - {2694, {wxAuiTabArt, setActiveColour, 1}}, - {2695, {wxAuiDockArt, getColour, 1}}, - {2696, {wxAuiDockArt, getFont, 1}}, - {2697, {wxAuiDockArt, getMetric, 1}}, - {2698, {wxAuiDockArt, setColour, 2}}, - {2699, {wxAuiDockArt, setFont, 2}}, - {2700, {wxAuiDockArt, setMetric, 2}}, - {2701, {wxAuiSimpleTabArt, new, 0}}, - {2702, {wxAuiSimpleTabArt, 'Destroy', undefined}}, - {2703, {wxMDIParentFrame, new_0, 0}}, - {2704, {wxMDIParentFrame, new_4, 4}}, - {2705, {wxMDIParentFrame, destruct, 0}}, - {2706, {wxMDIParentFrame, activateNext, 0}}, - {2707, {wxMDIParentFrame, activatePrevious, 0}}, - {2708, {wxMDIParentFrame, arrangeIcons, 0}}, - {2709, {wxMDIParentFrame, cascade, 0}}, - {2710, {wxMDIParentFrame, create, 4}}, - {2711, {wxMDIParentFrame, getActiveChild, 0}}, - {2712, {wxMDIParentFrame, getClientWindow, 0}}, - {2713, {wxMDIParentFrame, tile, 1}}, - {2714, {wxMDIChildFrame, new_0, 0}}, - {2715, {wxMDIChildFrame, new_4, 4}}, - {2716, {wxMDIChildFrame, destruct, 0}}, - {2717, {wxMDIChildFrame, activate, 0}}, - {2718, {wxMDIChildFrame, create, 4}}, - {2719, {wxMDIChildFrame, maximize, 1}}, - {2720, {wxMDIChildFrame, restore, 0}}, - {2721, {wxMDIClientWindow, new_0, 0}}, - {2722, {wxMDIClientWindow, new_2, 2}}, - {2723, {wxMDIClientWindow, destruct, 0}}, - {2724, {wxMDIClientWindow, createClient, 2}}, - {2725, {wxLayoutAlgorithm, new, 0}}, - {2726, {wxLayoutAlgorithm, layoutFrame, 2}}, - {2727, {wxLayoutAlgorithm, layoutMDIFrame, 2}}, - {2728, {wxLayoutAlgorithm, layoutWindow, 2}}, - {2729, {wxLayoutAlgorithm, 'Destroy', undefined}}, - {2730, {wxEvent, getId, 0}}, - {2731, {wxEvent, getSkipped, 0}}, - {2732, {wxEvent, getTimestamp, 0}}, - {2733, {wxEvent, isCommandEvent, 0}}, - {2734, {wxEvent, resumePropagation, 1}}, - {2735, {wxEvent, shouldPropagate, 0}}, - {2736, {wxEvent, skip, 1}}, - {2737, {wxEvent, stopPropagation, 0}}, - {2738, {wxCommandEvent, getClientData, 0}}, - {2739, {wxCommandEvent, getExtraLong, 0}}, - {2740, {wxCommandEvent, getInt, 0}}, - {2741, {wxCommandEvent, getSelection, 0}}, - {2742, {wxCommandEvent, getString, 0}}, - {2743, {wxCommandEvent, isChecked, 0}}, - {2744, {wxCommandEvent, isSelection, 0}}, - {2745, {wxCommandEvent, setInt, 1}}, - {2746, {wxCommandEvent, setString, 1}}, - {2747, {wxScrollEvent, getOrientation, 0}}, - {2748, {wxScrollEvent, getPosition, 0}}, - {2749, {wxScrollWinEvent, getOrientation, 0}}, - {2750, {wxScrollWinEvent, getPosition, 0}}, - {2751, {wxMouseEvent, altDown, 0}}, - {2752, {wxMouseEvent, button, 1}}, - {2753, {wxMouseEvent, buttonDClick, 1}}, - {2754, {wxMouseEvent, buttonDown, 1}}, - {2755, {wxMouseEvent, buttonUp, 1}}, - {2756, {wxMouseEvent, cmdDown, 0}}, - {2757, {wxMouseEvent, controlDown, 0}}, - {2758, {wxMouseEvent, dragging, 0}}, - {2759, {wxMouseEvent, entering, 0}}, - {2760, {wxMouseEvent, getButton, 0}}, - {2763, {wxMouseEvent, getPosition, 0}}, - {2764, {wxMouseEvent, getLogicalPosition, 1}}, - {2765, {wxMouseEvent, getLinesPerAction, 0}}, - {2766, {wxMouseEvent, getWheelRotation, 0}}, - {2767, {wxMouseEvent, getWheelDelta, 0}}, - {2768, {wxMouseEvent, getX, 0}}, - {2769, {wxMouseEvent, getY, 0}}, - {2770, {wxMouseEvent, isButton, 0}}, - {2771, {wxMouseEvent, isPageScroll, 0}}, - {2772, {wxMouseEvent, leaving, 0}}, - {2773, {wxMouseEvent, leftDClick, 0}}, - {2774, {wxMouseEvent, leftDown, 0}}, - {2775, {wxMouseEvent, leftIsDown, 0}}, - {2776, {wxMouseEvent, leftUp, 0}}, - {2777, {wxMouseEvent, metaDown, 0}}, - {2778, {wxMouseEvent, middleDClick, 0}}, - {2779, {wxMouseEvent, middleDown, 0}}, - {2780, {wxMouseEvent, middleIsDown, 0}}, - {2781, {wxMouseEvent, middleUp, 0}}, - {2782, {wxMouseEvent, moving, 0}}, - {2783, {wxMouseEvent, rightDClick, 0}}, - {2784, {wxMouseEvent, rightDown, 0}}, - {2785, {wxMouseEvent, rightIsDown, 0}}, - {2786, {wxMouseEvent, rightUp, 0}}, - {2787, {wxMouseEvent, shiftDown, 0}}, - {2788, {wxSetCursorEvent, getCursor, 0}}, - {2789, {wxSetCursorEvent, getX, 0}}, - {2790, {wxSetCursorEvent, getY, 0}}, - {2791, {wxSetCursorEvent, hasCursor, 0}}, - {2792, {wxSetCursorEvent, setCursor, 1}}, - {2793, {wxKeyEvent, altDown, 0}}, - {2794, {wxKeyEvent, cmdDown, 0}}, - {2795, {wxKeyEvent, controlDown, 0}}, - {2796, {wxKeyEvent, getKeyCode, 0}}, - {2797, {wxKeyEvent, getModifiers, 0}}, - {2800, {wxKeyEvent, getPosition, 0}}, - {2801, {wxKeyEvent, getRawKeyCode, 0}}, - {2802, {wxKeyEvent, getRawKeyFlags, 0}}, - {2803, {wxKeyEvent, getUnicodeKey, 0}}, - {2804, {wxKeyEvent, getX, 0}}, - {2805, {wxKeyEvent, getY, 0}}, - {2806, {wxKeyEvent, hasModifiers, 0}}, - {2807, {wxKeyEvent, metaDown, 0}}, - {2808, {wxKeyEvent, shiftDown, 0}}, - {2809, {wxSizeEvent, getSize, 0}}, - {2810, {wxMoveEvent, getPosition, 0}}, - {2811, {wxEraseEvent, getDC, 0}}, - {2812, {wxFocusEvent, getWindow, 0}}, - {2813, {wxChildFocusEvent, getWindow, 0}}, - {2814, {wxMenuEvent, getMenu, 0}}, - {2815, {wxMenuEvent, getMenuId, 0}}, - {2816, {wxMenuEvent, isPopup, 0}}, - {2817, {wxCloseEvent, canVeto, 0}}, - {2818, {wxCloseEvent, getLoggingOff, 0}}, - {2819, {wxCloseEvent, setCanVeto, 1}}, - {2820, {wxCloseEvent, setLoggingOff, 1}}, - {2821, {wxCloseEvent, veto, 1}}, - {2822, {wxShowEvent, setShow, 1}}, - {2823, {wxShowEvent, getShow, 0}}, - {2824, {wxIconizeEvent, iconized, 0}}, - {2825, {wxJoystickEvent, buttonDown, 1}}, - {2826, {wxJoystickEvent, buttonIsDown, 1}}, - {2827, {wxJoystickEvent, buttonUp, 1}}, - {2828, {wxJoystickEvent, getButtonChange, 0}}, - {2829, {wxJoystickEvent, getButtonState, 0}}, - {2830, {wxJoystickEvent, getJoystick, 0}}, - {2831, {wxJoystickEvent, getPosition, 0}}, - {2832, {wxJoystickEvent, getZPosition, 0}}, - {2833, {wxJoystickEvent, isButton, 0}}, - {2834, {wxJoystickEvent, isMove, 0}}, - {2835, {wxJoystickEvent, isZMove, 0}}, - {2836, {wxUpdateUIEvent, canUpdate, 1}}, - {2837, {wxUpdateUIEvent, check, 1}}, - {2838, {wxUpdateUIEvent, enable, 1}}, - {2839, {wxUpdateUIEvent, show, 1}}, - {2840, {wxUpdateUIEvent, getChecked, 0}}, - {2841, {wxUpdateUIEvent, getEnabled, 0}}, - {2842, {wxUpdateUIEvent, getShown, 0}}, - {2843, {wxUpdateUIEvent, getSetChecked, 0}}, - {2844, {wxUpdateUIEvent, getSetEnabled, 0}}, - {2845, {wxUpdateUIEvent, getSetShown, 0}}, - {2846, {wxUpdateUIEvent, getSetText, 0}}, - {2847, {wxUpdateUIEvent, getText, 0}}, - {2848, {wxUpdateUIEvent, getMode, 0}}, - {2849, {wxUpdateUIEvent, getUpdateInterval, 0}}, - {2850, {wxUpdateUIEvent, resetUpdateTime, 0}}, - {2851, {wxUpdateUIEvent, setMode, 1}}, - {2852, {wxUpdateUIEvent, setText, 1}}, - {2853, {wxUpdateUIEvent, setUpdateInterval, 1}}, - {2854, {wxMouseCaptureChangedEvent, getCapturedWindow, 0}}, - {2855, {wxPaletteChangedEvent, setChangedWindow, 1}}, - {2856, {wxPaletteChangedEvent, getChangedWindow, 0}}, - {2857, {wxQueryNewPaletteEvent, setPaletteRealized, 1}}, - {2858, {wxQueryNewPaletteEvent, getPaletteRealized, 0}}, - {2859, {wxNavigationKeyEvent, getDirection, 0}}, - {2860, {wxNavigationKeyEvent, setDirection, 1}}, - {2861, {wxNavigationKeyEvent, isWindowChange, 0}}, - {2862, {wxNavigationKeyEvent, setWindowChange, 1}}, - {2863, {wxNavigationKeyEvent, isFromTab, 0}}, - {2864, {wxNavigationKeyEvent, setFromTab, 1}}, - {2865, {wxNavigationKeyEvent, getCurrentFocus, 0}}, - {2866, {wxNavigationKeyEvent, setCurrentFocus, 1}}, - {2867, {wxHelpEvent, getOrigin, 0}}, - {2868, {wxHelpEvent, getPosition, 0}}, - {2869, {wxHelpEvent, setOrigin, 1}}, - {2870, {wxHelpEvent, setPosition, 1}}, - {2871, {wxContextMenuEvent, getPosition, 0}}, - {2872, {wxContextMenuEvent, setPosition, 1}}, - {2873, {wxIdleEvent, canSend, 1}}, - {2874, {wxIdleEvent, getMode, 0}}, - {2875, {wxIdleEvent, requestMore, 1}}, - {2876, {wxIdleEvent, moreRequested, 0}}, - {2877, {wxIdleEvent, setMode, 1}}, - {2878, {wxGridEvent, altDown, 0}}, - {2879, {wxGridEvent, controlDown, 0}}, - {2880, {wxGridEvent, getCol, 0}}, - {2881, {wxGridEvent, getPosition, 0}}, - {2882, {wxGridEvent, getRow, 0}}, - {2883, {wxGridEvent, metaDown, 0}}, - {2884, {wxGridEvent, selecting, 0}}, - {2885, {wxGridEvent, shiftDown, 0}}, - {2886, {wxNotifyEvent, allow, 0}}, - {2887, {wxNotifyEvent, isAllowed, 0}}, - {2888, {wxNotifyEvent, veto, 0}}, - {2889, {wxSashEvent, getEdge, 0}}, - {2890, {wxSashEvent, getDragRect, 0}}, - {2891, {wxSashEvent, getDragStatus, 0}}, - {2892, {wxListEvent, getCacheFrom, 0}}, - {2893, {wxListEvent, getCacheTo, 0}}, - {2894, {wxListEvent, getKeyCode, 0}}, - {2895, {wxListEvent, getIndex, 0}}, - {2896, {wxListEvent, getColumn, 0}}, - {2897, {wxListEvent, getPoint, 0}}, - {2898, {wxListEvent, getLabel, 0}}, - {2899, {wxListEvent, getText, 0}}, - {2900, {wxListEvent, getImage, 0}}, - {2901, {wxListEvent, getData, 0}}, - {2902, {wxListEvent, getMask, 0}}, - {2903, {wxListEvent, getItem, 0}}, - {2904, {wxListEvent, isEditCancelled, 0}}, - {2905, {wxDateEvent, getDate, 0}}, - {2906, {wxCalendarEvent, getWeekDay, 0}}, - {2907, {wxFileDirPickerEvent, getPath, 0}}, - {2908, {wxColourPickerEvent, getColour, 0}}, - {2909, {wxFontPickerEvent, getFont, 0}}, - {2910, {wxStyledTextEvent, getPosition, 0}}, - {2911, {wxStyledTextEvent, getKey, 0}}, - {2912, {wxStyledTextEvent, getModifiers, 0}}, - {2913, {wxStyledTextEvent, getModificationType, 0}}, - {2914, {wxStyledTextEvent, getText, 0}}, - {2915, {wxStyledTextEvent, getLength, 0}}, - {2916, {wxStyledTextEvent, getLinesAdded, 0}}, - {2917, {wxStyledTextEvent, getLine, 0}}, - {2918, {wxStyledTextEvent, getFoldLevelNow, 0}}, - {2919, {wxStyledTextEvent, getFoldLevelPrev, 0}}, - {2920, {wxStyledTextEvent, getMargin, 0}}, - {2921, {wxStyledTextEvent, getMessage, 0}}, - {2922, {wxStyledTextEvent, getWParam, 0}}, - {2923, {wxStyledTextEvent, getLParam, 0}}, - {2924, {wxStyledTextEvent, getListType, 0}}, - {2925, {wxStyledTextEvent, getX, 0}}, - {2926, {wxStyledTextEvent, getY, 0}}, - {2927, {wxStyledTextEvent, getDragText, 0}}, - {2928, {wxStyledTextEvent, getDragAllowMove, 0}}, - {2929, {wxStyledTextEvent, getDragResult, 0}}, - {2930, {wxStyledTextEvent, getShift, 0}}, - {2931, {wxStyledTextEvent, getControl, 0}}, - {2932, {wxStyledTextEvent, getAlt, 0}}, - {2933, {utils, getKeyState, 1}}, - {2934, {utils, getMousePosition, 2}}, - {2935, {utils, getMouseState, 0}}, - {2936, {utils, setDetectableAutoRepeat, 1}}, - {2937, {utils, bell, 0}}, - {2938, {utils, findMenuItemId, 3}}, - {2939, {utils, genericFindWindowAtPoint, 1}}, - {2940, {utils, findWindowAtPoint, 1}}, - {2941, {utils, beginBusyCursor, 1}}, - {2942, {utils, endBusyCursor, 0}}, - {2943, {utils, isBusy, 0}}, - {2944, {utils, shutdown, 1}}, - {2945, {utils, shell, 1}}, - {2946, {utils, launchDefaultBrowser, 2}}, - {2947, {utils, getEmailAddress, 0}}, - {2948, {utils, getUserId, 0}}, - {2949, {utils, getHomeDir, 0}}, - {2950, {utils, newId, 0}}, - {2951, {utils, registerId, 1}}, - {2952, {utils, getCurrentId, 0}}, - {2953, {utils, getOsDescription, 0}}, - {2954, {utils, isPlatformLittleEndian, 0}}, - {2955, {utils, isPlatform64Bit, 0}}, - {2956, {gdicmn, displaySize, 2}}, - {2957, {gdicmn, setCursor, 1}}, - {2958, {wxPrintout, new, 1}}, - {2959, {wxPrintout, destruct, 0}}, - {2960, {wxPrintout, getDC, 0}}, - {2961, {wxPrintout, getPageSizeMM, 2}}, - {2962, {wxPrintout, getPageSizePixels, 2}}, - {2963, {wxPrintout, getPaperRectPixels, 0}}, - {2964, {wxPrintout, getPPIPrinter, 2}}, - {2965, {wxPrintout, getPPIScreen, 2}}, - {2966, {wxPrintout, getTitle, 0}}, - {2967, {wxPrintout, isPreview, 0}}, - {2968, {wxPrintout, fitThisSizeToPaper, 1}}, - {2969, {wxPrintout, fitThisSizeToPage, 1}}, - {2970, {wxPrintout, fitThisSizeToPageMargins, 2}}, - {2971, {wxPrintout, mapScreenSizeToPaper, 0}}, - {2972, {wxPrintout, mapScreenSizeToPage, 0}}, - {2973, {wxPrintout, mapScreenSizeToPageMargins, 1}}, - {2974, {wxPrintout, mapScreenSizeToDevice, 0}}, - {2975, {wxPrintout, getLogicalPaperRect, 0}}, - {2976, {wxPrintout, getLogicalPageRect, 0}}, - {2977, {wxPrintout, getLogicalPageMarginsRect, 1}}, - {2978, {wxPrintout, setLogicalOrigin, 2}}, - {2979, {wxPrintout, offsetLogicalOrigin, 2}}, - {2980, {wxStyledTextCtrl, new_2, 2}}, - {2981, {wxStyledTextCtrl, new_0, 0}}, - {2982, {wxStyledTextCtrl, destruct, 0}}, - {2983, {wxStyledTextCtrl, create, 2}}, - {2984, {wxStyledTextCtrl, addText, 1}}, - {2985, {wxStyledTextCtrl, addStyledText, 1}}, - {2986, {wxStyledTextCtrl, insertText, 2}}, - {2987, {wxStyledTextCtrl, clearAll, 0}}, - {2988, {wxStyledTextCtrl, clearDocumentStyle, 0}}, - {2989, {wxStyledTextCtrl, getLength, 0}}, - {2990, {wxStyledTextCtrl, getCharAt, 1}}, - {2991, {wxStyledTextCtrl, getCurrentPos, 0}}, - {2992, {wxStyledTextCtrl, getAnchor, 0}}, - {2993, {wxStyledTextCtrl, getStyleAt, 1}}, - {2994, {wxStyledTextCtrl, redo, 0}}, - {2995, {wxStyledTextCtrl, setUndoCollection, 1}}, - {2996, {wxStyledTextCtrl, selectAll, 0}}, - {2997, {wxStyledTextCtrl, setSavePoint, 0}}, - {2998, {wxStyledTextCtrl, getStyledText, 2}}, - {2999, {wxStyledTextCtrl, canRedo, 0}}, - {3000, {wxStyledTextCtrl, markerLineFromHandle, 1}}, - {3001, {wxStyledTextCtrl, markerDeleteHandle, 1}}, - {3002, {wxStyledTextCtrl, getUndoCollection, 0}}, - {3003, {wxStyledTextCtrl, getViewWhiteSpace, 0}}, - {3004, {wxStyledTextCtrl, setViewWhiteSpace, 1}}, - {3005, {wxStyledTextCtrl, positionFromPoint, 1}}, - {3006, {wxStyledTextCtrl, positionFromPointClose, 2}}, - {3007, {wxStyledTextCtrl, gotoLine, 1}}, - {3008, {wxStyledTextCtrl, gotoPos, 1}}, - {3009, {wxStyledTextCtrl, setAnchor, 1}}, - {3010, {wxStyledTextCtrl, getCurLine, 1}}, - {3011, {wxStyledTextCtrl, getEndStyled, 0}}, - {3012, {wxStyledTextCtrl, convertEOLs, 1}}, - {3013, {wxStyledTextCtrl, getEOLMode, 0}}, - {3014, {wxStyledTextCtrl, setEOLMode, 1}}, - {3015, {wxStyledTextCtrl, startStyling, 2}}, - {3016, {wxStyledTextCtrl, setStyling, 2}}, - {3017, {wxStyledTextCtrl, getBufferedDraw, 0}}, - {3018, {wxStyledTextCtrl, setBufferedDraw, 1}}, - {3019, {wxStyledTextCtrl, setTabWidth, 1}}, - {3020, {wxStyledTextCtrl, getTabWidth, 0}}, - {3021, {wxStyledTextCtrl, setCodePage, 1}}, - {3022, {wxStyledTextCtrl, markerDefine, 3}}, - {3023, {wxStyledTextCtrl, markerSetForeground, 2}}, - {3024, {wxStyledTextCtrl, markerSetBackground, 2}}, - {3025, {wxStyledTextCtrl, markerAdd, 2}}, - {3026, {wxStyledTextCtrl, markerDelete, 2}}, - {3027, {wxStyledTextCtrl, markerDeleteAll, 1}}, - {3028, {wxStyledTextCtrl, markerGet, 1}}, - {3029, {wxStyledTextCtrl, markerNext, 2}}, - {3030, {wxStyledTextCtrl, markerPrevious, 2}}, - {3031, {wxStyledTextCtrl, markerDefineBitmap, 2}}, - {3032, {wxStyledTextCtrl, markerAddSet, 2}}, - {3033, {wxStyledTextCtrl, markerSetAlpha, 2}}, - {3034, {wxStyledTextCtrl, setMarginType, 2}}, - {3035, {wxStyledTextCtrl, getMarginType, 1}}, - {3036, {wxStyledTextCtrl, setMarginWidth, 2}}, - {3037, {wxStyledTextCtrl, getMarginWidth, 1}}, - {3038, {wxStyledTextCtrl, setMarginMask, 2}}, - {3039, {wxStyledTextCtrl, getMarginMask, 1}}, - {3040, {wxStyledTextCtrl, setMarginSensitive, 2}}, - {3041, {wxStyledTextCtrl, getMarginSensitive, 1}}, - {3042, {wxStyledTextCtrl, styleClearAll, 0}}, - {3043, {wxStyledTextCtrl, styleSetForeground, 2}}, - {3044, {wxStyledTextCtrl, styleSetBackground, 2}}, - {3045, {wxStyledTextCtrl, styleSetBold, 2}}, - {3046, {wxStyledTextCtrl, styleSetItalic, 2}}, - {3047, {wxStyledTextCtrl, styleSetSize, 2}}, - {3048, {wxStyledTextCtrl, styleSetFaceName, 2}}, - {3049, {wxStyledTextCtrl, styleSetEOLFilled, 2}}, - {3050, {wxStyledTextCtrl, styleResetDefault, 0}}, - {3051, {wxStyledTextCtrl, styleSetUnderline, 2}}, - {3052, {wxStyledTextCtrl, styleSetCase, 2}}, - {3053, {wxStyledTextCtrl, styleSetHotSpot, 2}}, - {3054, {wxStyledTextCtrl, setSelForeground, 2}}, - {3055, {wxStyledTextCtrl, setSelBackground, 2}}, - {3056, {wxStyledTextCtrl, getSelAlpha, 0}}, - {3057, {wxStyledTextCtrl, setSelAlpha, 1}}, - {3058, {wxStyledTextCtrl, setCaretForeground, 1}}, - {3059, {wxStyledTextCtrl, cmdKeyAssign, 3}}, - {3060, {wxStyledTextCtrl, cmdKeyClear, 2}}, - {3061, {wxStyledTextCtrl, cmdKeyClearAll, 0}}, - {3062, {wxStyledTextCtrl, setStyleBytes, 2}}, - {3063, {wxStyledTextCtrl, styleSetVisible, 2}}, - {3064, {wxStyledTextCtrl, getCaretPeriod, 0}}, - {3065, {wxStyledTextCtrl, setCaretPeriod, 1}}, - {3066, {wxStyledTextCtrl, setWordChars, 1}}, - {3067, {wxStyledTextCtrl, beginUndoAction, 0}}, - {3068, {wxStyledTextCtrl, endUndoAction, 0}}, - {3069, {wxStyledTextCtrl, indicatorSetStyle, 2}}, - {3070, {wxStyledTextCtrl, indicatorGetStyle, 1}}, - {3071, {wxStyledTextCtrl, indicatorSetForeground, 2}}, - {3072, {wxStyledTextCtrl, indicatorGetForeground, 1}}, - {3073, {wxStyledTextCtrl, setWhitespaceForeground, 2}}, - {3074, {wxStyledTextCtrl, setWhitespaceBackground, 2}}, - {3075, {wxStyledTextCtrl, getStyleBits, 0}}, - {3076, {wxStyledTextCtrl, setLineState, 2}}, - {3077, {wxStyledTextCtrl, getLineState, 1}}, - {3078, {wxStyledTextCtrl, getMaxLineState, 0}}, - {3079, {wxStyledTextCtrl, getCaretLineVisible, 0}}, - {3080, {wxStyledTextCtrl, setCaretLineVisible, 1}}, - {3081, {wxStyledTextCtrl, getCaretLineBackground, 0}}, - {3082, {wxStyledTextCtrl, setCaretLineBackground, 1}}, - {3083, {wxStyledTextCtrl, autoCompShow, 2}}, - {3084, {wxStyledTextCtrl, autoCompCancel, 0}}, - {3085, {wxStyledTextCtrl, autoCompActive, 0}}, - {3086, {wxStyledTextCtrl, autoCompPosStart, 0}}, - {3087, {wxStyledTextCtrl, autoCompComplete, 0}}, - {3088, {wxStyledTextCtrl, autoCompStops, 1}}, - {3089, {wxStyledTextCtrl, autoCompSetSeparator, 1}}, - {3090, {wxStyledTextCtrl, autoCompGetSeparator, 0}}, - {3091, {wxStyledTextCtrl, autoCompSelect, 1}}, - {3092, {wxStyledTextCtrl, autoCompSetCancelAtStart, 1}}, - {3093, {wxStyledTextCtrl, autoCompGetCancelAtStart, 0}}, - {3094, {wxStyledTextCtrl, autoCompSetFillUps, 1}}, - {3095, {wxStyledTextCtrl, autoCompSetChooseSingle, 1}}, - {3096, {wxStyledTextCtrl, autoCompGetChooseSingle, 0}}, - {3097, {wxStyledTextCtrl, autoCompSetIgnoreCase, 1}}, - {3098, {wxStyledTextCtrl, autoCompGetIgnoreCase, 0}}, - {3099, {wxStyledTextCtrl, userListShow, 2}}, - {3100, {wxStyledTextCtrl, autoCompSetAutoHide, 1}}, - {3101, {wxStyledTextCtrl, autoCompGetAutoHide, 0}}, - {3102, {wxStyledTextCtrl, autoCompSetDropRestOfWord, 1}}, - {3103, {wxStyledTextCtrl, autoCompGetDropRestOfWord, 0}}, - {3104, {wxStyledTextCtrl, registerImage, 2}}, - {3105, {wxStyledTextCtrl, clearRegisteredImages, 0}}, - {3106, {wxStyledTextCtrl, autoCompGetTypeSeparator, 0}}, - {3107, {wxStyledTextCtrl, autoCompSetTypeSeparator, 1}}, - {3108, {wxStyledTextCtrl, autoCompSetMaxWidth, 1}}, - {3109, {wxStyledTextCtrl, autoCompGetMaxWidth, 0}}, - {3110, {wxStyledTextCtrl, autoCompSetMaxHeight, 1}}, - {3111, {wxStyledTextCtrl, autoCompGetMaxHeight, 0}}, - {3112, {wxStyledTextCtrl, setIndent, 1}}, - {3113, {wxStyledTextCtrl, getIndent, 0}}, - {3114, {wxStyledTextCtrl, setUseTabs, 1}}, - {3115, {wxStyledTextCtrl, getUseTabs, 0}}, - {3116, {wxStyledTextCtrl, setLineIndentation, 2}}, - {3117, {wxStyledTextCtrl, getLineIndentation, 1}}, - {3118, {wxStyledTextCtrl, getLineIndentPosition, 1}}, - {3119, {wxStyledTextCtrl, getColumn, 1}}, - {3120, {wxStyledTextCtrl, setUseHorizontalScrollBar, 1}}, - {3121, {wxStyledTextCtrl, getUseHorizontalScrollBar, 0}}, - {3122, {wxStyledTextCtrl, setIndentationGuides, 1}}, - {3123, {wxStyledTextCtrl, getIndentationGuides, 0}}, - {3124, {wxStyledTextCtrl, setHighlightGuide, 1}}, - {3125, {wxStyledTextCtrl, getHighlightGuide, 0}}, - {3126, {wxStyledTextCtrl, getLineEndPosition, 1}}, - {3127, {wxStyledTextCtrl, getCodePage, 0}}, - {3128, {wxStyledTextCtrl, getCaretForeground, 0}}, - {3129, {wxStyledTextCtrl, getReadOnly, 0}}, - {3130, {wxStyledTextCtrl, setCurrentPos, 1}}, - {3131, {wxStyledTextCtrl, setSelectionStart, 1}}, - {3132, {wxStyledTextCtrl, getSelectionStart, 0}}, - {3133, {wxStyledTextCtrl, setSelectionEnd, 1}}, - {3134, {wxStyledTextCtrl, getSelectionEnd, 0}}, - {3135, {wxStyledTextCtrl, setPrintMagnification, 1}}, - {3136, {wxStyledTextCtrl, getPrintMagnification, 0}}, - {3137, {wxStyledTextCtrl, setPrintColourMode, 1}}, - {3138, {wxStyledTextCtrl, getPrintColourMode, 0}}, - {3139, {wxStyledTextCtrl, findText, 4}}, - {3140, {wxStyledTextCtrl, formatRange, 7}}, - {3141, {wxStyledTextCtrl, getFirstVisibleLine, 0}}, - {3142, {wxStyledTextCtrl, getLine, 1}}, - {3143, {wxStyledTextCtrl, getLineCount, 0}}, - {3144, {wxStyledTextCtrl, setMarginLeft, 1}}, - {3145, {wxStyledTextCtrl, getMarginLeft, 0}}, - {3146, {wxStyledTextCtrl, setMarginRight, 1}}, - {3147, {wxStyledTextCtrl, getMarginRight, 0}}, - {3148, {wxStyledTextCtrl, getModify, 0}}, - {3149, {wxStyledTextCtrl, setSelection, 2}}, - {3150, {wxStyledTextCtrl, getSelectedText, 0}}, - {3151, {wxStyledTextCtrl, getTextRange, 2}}, - {3152, {wxStyledTextCtrl, hideSelection, 1}}, - {3153, {wxStyledTextCtrl, lineFromPosition, 1}}, - {3154, {wxStyledTextCtrl, positionFromLine, 1}}, - {3155, {wxStyledTextCtrl, lineScroll, 2}}, - {3156, {wxStyledTextCtrl, ensureCaretVisible, 0}}, - {3157, {wxStyledTextCtrl, replaceSelection, 1}}, - {3158, {wxStyledTextCtrl, setReadOnly, 1}}, - {3159, {wxStyledTextCtrl, canPaste, 0}}, - {3160, {wxStyledTextCtrl, canUndo, 0}}, - {3161, {wxStyledTextCtrl, emptyUndoBuffer, 0}}, - {3162, {wxStyledTextCtrl, undo, 0}}, - {3163, {wxStyledTextCtrl, cut, 0}}, - {3164, {wxStyledTextCtrl, copy, 0}}, - {3165, {wxStyledTextCtrl, paste, 0}}, - {3166, {wxStyledTextCtrl, clear, 0}}, - {3167, {wxStyledTextCtrl, setText, 1}}, - {3168, {wxStyledTextCtrl, getText, 0}}, - {3169, {wxStyledTextCtrl, getTextLength, 0}}, - {3170, {wxStyledTextCtrl, getOvertype, 0}}, - {3171, {wxStyledTextCtrl, setCaretWidth, 1}}, - {3172, {wxStyledTextCtrl, getCaretWidth, 0}}, - {3173, {wxStyledTextCtrl, setTargetStart, 1}}, - {3174, {wxStyledTextCtrl, getTargetStart, 0}}, - {3175, {wxStyledTextCtrl, setTargetEnd, 1}}, - {3176, {wxStyledTextCtrl, getTargetEnd, 0}}, - {3177, {wxStyledTextCtrl, replaceTarget, 1}}, - {3178, {wxStyledTextCtrl, searchInTarget, 1}}, - {3179, {wxStyledTextCtrl, setSearchFlags, 1}}, - {3180, {wxStyledTextCtrl, getSearchFlags, 0}}, - {3181, {wxStyledTextCtrl, callTipShow, 2}}, - {3182, {wxStyledTextCtrl, callTipCancel, 0}}, - {3183, {wxStyledTextCtrl, callTipActive, 0}}, - {3184, {wxStyledTextCtrl, callTipPosAtStart, 0}}, - {3185, {wxStyledTextCtrl, callTipSetHighlight, 2}}, - {3186, {wxStyledTextCtrl, callTipSetBackground, 1}}, - {3187, {wxStyledTextCtrl, callTipSetForeground, 1}}, - {3188, {wxStyledTextCtrl, callTipSetForegroundHighlight, 1}}, - {3189, {wxStyledTextCtrl, callTipUseStyle, 1}}, - {3190, {wxStyledTextCtrl, visibleFromDocLine, 1}}, - {3191, {wxStyledTextCtrl, docLineFromVisible, 1}}, - {3192, {wxStyledTextCtrl, wrapCount, 1}}, - {3193, {wxStyledTextCtrl, setFoldLevel, 2}}, - {3194, {wxStyledTextCtrl, getFoldLevel, 1}}, - {3195, {wxStyledTextCtrl, getLastChild, 2}}, - {3196, {wxStyledTextCtrl, getFoldParent, 1}}, - {3197, {wxStyledTextCtrl, showLines, 2}}, - {3198, {wxStyledTextCtrl, hideLines, 2}}, - {3199, {wxStyledTextCtrl, getLineVisible, 1}}, - {3200, {wxStyledTextCtrl, setFoldExpanded, 2}}, - {3201, {wxStyledTextCtrl, getFoldExpanded, 1}}, - {3202, {wxStyledTextCtrl, toggleFold, 1}}, - {3203, {wxStyledTextCtrl, ensureVisible, 1}}, - {3204, {wxStyledTextCtrl, setFoldFlags, 1}}, - {3205, {wxStyledTextCtrl, ensureVisibleEnforcePolicy, 1}}, - {3206, {wxStyledTextCtrl, setTabIndents, 1}}, - {3207, {wxStyledTextCtrl, getTabIndents, 0}}, - {3208, {wxStyledTextCtrl, setBackSpaceUnIndents, 1}}, - {3209, {wxStyledTextCtrl, getBackSpaceUnIndents, 0}}, - {3210, {wxStyledTextCtrl, setMouseDwellTime, 1}}, - {3211, {wxStyledTextCtrl, getMouseDwellTime, 0}}, - {3212, {wxStyledTextCtrl, wordStartPosition, 2}}, - {3213, {wxStyledTextCtrl, wordEndPosition, 2}}, - {3214, {wxStyledTextCtrl, setWrapMode, 1}}, - {3215, {wxStyledTextCtrl, getWrapMode, 0}}, - {3216, {wxStyledTextCtrl, setWrapVisualFlags, 1}}, - {3217, {wxStyledTextCtrl, getWrapVisualFlags, 0}}, - {3218, {wxStyledTextCtrl, setWrapVisualFlagsLocation, 1}}, - {3219, {wxStyledTextCtrl, getWrapVisualFlagsLocation, 0}}, - {3220, {wxStyledTextCtrl, setWrapStartIndent, 1}}, - {3221, {wxStyledTextCtrl, getWrapStartIndent, 0}}, - {3222, {wxStyledTextCtrl, setLayoutCache, 1}}, - {3223, {wxStyledTextCtrl, getLayoutCache, 0}}, - {3224, {wxStyledTextCtrl, setScrollWidth, 1}}, - {3225, {wxStyledTextCtrl, getScrollWidth, 0}}, - {3226, {wxStyledTextCtrl, textWidth, 2}}, - {3227, {wxStyledTextCtrl, getEndAtLastLine, 0}}, - {3228, {wxStyledTextCtrl, textHeight, 1}}, - {3229, {wxStyledTextCtrl, setUseVerticalScrollBar, 1}}, - {3230, {wxStyledTextCtrl, getUseVerticalScrollBar, 0}}, - {3231, {wxStyledTextCtrl, appendText, 1}}, - {3232, {wxStyledTextCtrl, getTwoPhaseDraw, 0}}, - {3233, {wxStyledTextCtrl, setTwoPhaseDraw, 1}}, - {3234, {wxStyledTextCtrl, targetFromSelection, 0}}, - {3235, {wxStyledTextCtrl, linesJoin, 0}}, - {3236, {wxStyledTextCtrl, linesSplit, 1}}, - {3237, {wxStyledTextCtrl, setFoldMarginColour, 2}}, - {3238, {wxStyledTextCtrl, setFoldMarginHiColour, 2}}, - {3239, {wxStyledTextCtrl, lineDown, 0}}, - {3240, {wxStyledTextCtrl, lineDownExtend, 0}}, - {3241, {wxStyledTextCtrl, lineUp, 0}}, - {3242, {wxStyledTextCtrl, lineUpExtend, 0}}, - {3243, {wxStyledTextCtrl, charLeft, 0}}, - {3244, {wxStyledTextCtrl, charLeftExtend, 0}}, - {3245, {wxStyledTextCtrl, charRight, 0}}, - {3246, {wxStyledTextCtrl, charRightExtend, 0}}, - {3247, {wxStyledTextCtrl, wordLeft, 0}}, - {3248, {wxStyledTextCtrl, wordLeftExtend, 0}}, - {3249, {wxStyledTextCtrl, wordRight, 0}}, - {3250, {wxStyledTextCtrl, wordRightExtend, 0}}, - {3251, {wxStyledTextCtrl, home, 0}}, - {3252, {wxStyledTextCtrl, homeExtend, 0}}, - {3253, {wxStyledTextCtrl, lineEnd, 0}}, - {3254, {wxStyledTextCtrl, lineEndExtend, 0}}, - {3255, {wxStyledTextCtrl, documentStart, 0}}, - {3256, {wxStyledTextCtrl, documentStartExtend, 0}}, - {3257, {wxStyledTextCtrl, documentEnd, 0}}, - {3258, {wxStyledTextCtrl, documentEndExtend, 0}}, - {3259, {wxStyledTextCtrl, pageUp, 0}}, - {3260, {wxStyledTextCtrl, pageUpExtend, 0}}, - {3261, {wxStyledTextCtrl, pageDown, 0}}, - {3262, {wxStyledTextCtrl, pageDownExtend, 0}}, - {3263, {wxStyledTextCtrl, editToggleOvertype, 0}}, - {3264, {wxStyledTextCtrl, cancel, 0}}, - {3265, {wxStyledTextCtrl, deleteBack, 0}}, - {3266, {wxStyledTextCtrl, tab, 0}}, - {3267, {wxStyledTextCtrl, backTab, 0}}, - {3268, {wxStyledTextCtrl, newLine, 0}}, - {3269, {wxStyledTextCtrl, formFeed, 0}}, - {3270, {wxStyledTextCtrl, vCHome, 0}}, - {3271, {wxStyledTextCtrl, vCHomeExtend, 0}}, - {3272, {wxStyledTextCtrl, zoomIn, 0}}, - {3273, {wxStyledTextCtrl, zoomOut, 0}}, - {3274, {wxStyledTextCtrl, delWordLeft, 0}}, - {3275, {wxStyledTextCtrl, delWordRight, 0}}, - {3276, {wxStyledTextCtrl, lineCut, 0}}, - {3277, {wxStyledTextCtrl, lineDelete, 0}}, - {3278, {wxStyledTextCtrl, lineTranspose, 0}}, - {3279, {wxStyledTextCtrl, lineDuplicate, 0}}, - {3280, {wxStyledTextCtrl, lowerCase, 0}}, - {3281, {wxStyledTextCtrl, upperCase, 0}}, - {3282, {wxStyledTextCtrl, lineScrollDown, 0}}, - {3283, {wxStyledTextCtrl, lineScrollUp, 0}}, - {3284, {wxStyledTextCtrl, deleteBackNotLine, 0}}, - {3285, {wxStyledTextCtrl, homeDisplay, 0}}, - {3286, {wxStyledTextCtrl, homeDisplayExtend, 0}}, - {3287, {wxStyledTextCtrl, lineEndDisplay, 0}}, - {3288, {wxStyledTextCtrl, lineEndDisplayExtend, 0}}, - {3289, {wxStyledTextCtrl, homeWrapExtend, 0}}, - {3290, {wxStyledTextCtrl, lineEndWrap, 0}}, - {3291, {wxStyledTextCtrl, lineEndWrapExtend, 0}}, - {3292, {wxStyledTextCtrl, vCHomeWrap, 0}}, - {3293, {wxStyledTextCtrl, vCHomeWrapExtend, 0}}, - {3294, {wxStyledTextCtrl, lineCopy, 0}}, - {3295, {wxStyledTextCtrl, moveCaretInsideView, 0}}, - {3296, {wxStyledTextCtrl, lineLength, 1}}, - {3297, {wxStyledTextCtrl, braceHighlight, 2}}, - {3298, {wxStyledTextCtrl, braceBadLight, 1}}, - {3299, {wxStyledTextCtrl, braceMatch, 1}}, - {3300, {wxStyledTextCtrl, getViewEOL, 0}}, - {3301, {wxStyledTextCtrl, setViewEOL, 1}}, - {3302, {wxStyledTextCtrl, setModEventMask, 1}}, - {3303, {wxStyledTextCtrl, getEdgeColumn, 0}}, - {3304, {wxStyledTextCtrl, setEdgeColumn, 1}}, - {3305, {wxStyledTextCtrl, setEdgeMode, 1}}, - {3306, {wxStyledTextCtrl, getEdgeMode, 0}}, - {3307, {wxStyledTextCtrl, getEdgeColour, 0}}, - {3308, {wxStyledTextCtrl, setEdgeColour, 1}}, - {3309, {wxStyledTextCtrl, searchAnchor, 0}}, - {3310, {wxStyledTextCtrl, searchNext, 2}}, - {3311, {wxStyledTextCtrl, searchPrev, 2}}, - {3312, {wxStyledTextCtrl, linesOnScreen, 0}}, - {3313, {wxStyledTextCtrl, usePopUp, 1}}, - {3314, {wxStyledTextCtrl, selectionIsRectangle, 0}}, - {3315, {wxStyledTextCtrl, setZoom, 1}}, - {3316, {wxStyledTextCtrl, getZoom, 0}}, - {3317, {wxStyledTextCtrl, getModEventMask, 0}}, - {3318, {wxStyledTextCtrl, setSTCFocus, 1}}, - {3319, {wxStyledTextCtrl, getSTCFocus, 0}}, - {3320, {wxStyledTextCtrl, setStatus, 1}}, - {3321, {wxStyledTextCtrl, getStatus, 0}}, - {3322, {wxStyledTextCtrl, setMouseDownCaptures, 1}}, - {3323, {wxStyledTextCtrl, getMouseDownCaptures, 0}}, - {3324, {wxStyledTextCtrl, setSTCCursor, 1}}, - {3325, {wxStyledTextCtrl, getSTCCursor, 0}}, - {3326, {wxStyledTextCtrl, setControlCharSymbol, 1}}, - {3327, {wxStyledTextCtrl, getControlCharSymbol, 0}}, - {3328, {wxStyledTextCtrl, wordPartLeft, 0}}, - {3329, {wxStyledTextCtrl, wordPartLeftExtend, 0}}, - {3330, {wxStyledTextCtrl, wordPartRight, 0}}, - {3331, {wxStyledTextCtrl, wordPartRightExtend, 0}}, - {3332, {wxStyledTextCtrl, setVisiblePolicy, 2}}, - {3333, {wxStyledTextCtrl, delLineLeft, 0}}, - {3334, {wxStyledTextCtrl, delLineRight, 0}}, - {3335, {wxStyledTextCtrl, getXOffset, 0}}, - {3336, {wxStyledTextCtrl, chooseCaretX, 0}}, - {3337, {wxStyledTextCtrl, setXCaretPolicy, 2}}, - {3338, {wxStyledTextCtrl, setYCaretPolicy, 2}}, - {3339, {wxStyledTextCtrl, getPrintWrapMode, 0}}, - {3340, {wxStyledTextCtrl, setHotspotActiveForeground, 2}}, - {3341, {wxStyledTextCtrl, setHotspotActiveBackground, 2}}, - {3342, {wxStyledTextCtrl, setHotspotActiveUnderline, 1}}, - {3343, {wxStyledTextCtrl, setHotspotSingleLine, 1}}, - {3344, {wxStyledTextCtrl, paraDownExtend, 0}}, - {3345, {wxStyledTextCtrl, paraUp, 0}}, - {3346, {wxStyledTextCtrl, paraUpExtend, 0}}, - {3347, {wxStyledTextCtrl, positionBefore, 1}}, - {3348, {wxStyledTextCtrl, positionAfter, 1}}, - {3349, {wxStyledTextCtrl, copyRange, 2}}, - {3350, {wxStyledTextCtrl, copyText, 2}}, - {3351, {wxStyledTextCtrl, setSelectionMode, 1}}, - {3352, {wxStyledTextCtrl, getSelectionMode, 0}}, - {3353, {wxStyledTextCtrl, lineDownRectExtend, 0}}, - {3354, {wxStyledTextCtrl, lineUpRectExtend, 0}}, - {3355, {wxStyledTextCtrl, charLeftRectExtend, 0}}, - {3356, {wxStyledTextCtrl, charRightRectExtend, 0}}, - {3357, {wxStyledTextCtrl, homeRectExtend, 0}}, - {3358, {wxStyledTextCtrl, vCHomeRectExtend, 0}}, - {3359, {wxStyledTextCtrl, lineEndRectExtend, 0}}, - {3360, {wxStyledTextCtrl, pageUpRectExtend, 0}}, - {3361, {wxStyledTextCtrl, pageDownRectExtend, 0}}, - {3362, {wxStyledTextCtrl, stutteredPageUp, 0}}, - {3363, {wxStyledTextCtrl, stutteredPageUpExtend, 0}}, - {3364, {wxStyledTextCtrl, stutteredPageDown, 0}}, - {3365, {wxStyledTextCtrl, stutteredPageDownExtend, 0}}, - {3366, {wxStyledTextCtrl, wordLeftEnd, 0}}, - {3367, {wxStyledTextCtrl, wordLeftEndExtend, 0}}, - {3368, {wxStyledTextCtrl, wordRightEnd, 0}}, - {3369, {wxStyledTextCtrl, wordRightEndExtend, 0}}, - {3370, {wxStyledTextCtrl, setWhitespaceChars, 1}}, - {3371, {wxStyledTextCtrl, setCharsDefault, 0}}, - {3372, {wxStyledTextCtrl, autoCompGetCurrent, 0}}, - {3373, {wxStyledTextCtrl, allocate, 1}}, - {3374, {wxStyledTextCtrl, findColumn, 2}}, - {3375, {wxStyledTextCtrl, getCaretSticky, 0}}, - {3376, {wxStyledTextCtrl, setCaretSticky, 1}}, - {3377, {wxStyledTextCtrl, toggleCaretSticky, 0}}, - {3378, {wxStyledTextCtrl, setPasteConvertEndings, 1}}, - {3379, {wxStyledTextCtrl, getPasteConvertEndings, 0}}, - {3380, {wxStyledTextCtrl, selectionDuplicate, 0}}, - {3381, {wxStyledTextCtrl, setCaretLineBackAlpha, 1}}, - {3382, {wxStyledTextCtrl, getCaretLineBackAlpha, 0}}, - {3383, {wxStyledTextCtrl, startRecord, 0}}, - {3384, {wxStyledTextCtrl, stopRecord, 0}}, - {3385, {wxStyledTextCtrl, setLexer, 1}}, - {3386, {wxStyledTextCtrl, getLexer, 0}}, - {3387, {wxStyledTextCtrl, colourise, 2}}, - {3388, {wxStyledTextCtrl, setProperty, 2}}, - {3389, {wxStyledTextCtrl, setKeyWords, 2}}, - {3390, {wxStyledTextCtrl, setLexerLanguage, 1}}, - {3391, {wxStyledTextCtrl, getProperty, 1}}, - {3392, {wxStyledTextCtrl, getStyleBitsNeeded, 0}}, - {3393, {wxStyledTextCtrl, getCurrentLine, 0}}, - {3394, {wxStyledTextCtrl, styleSetSpec, 2}}, - {3395, {wxStyledTextCtrl, styleSetFont, 2}}, - {3396, {wxStyledTextCtrl, styleSetFontAttr, 7}}, - {3397, {wxStyledTextCtrl, styleSetCharacterSet, 2}}, - {3398, {wxStyledTextCtrl, styleSetFontEncoding, 2}}, - {3399, {wxStyledTextCtrl, cmdKeyExecute, 1}}, - {3400, {wxStyledTextCtrl, setMargins, 2}}, - {3401, {wxStyledTextCtrl, getSelection, 2}}, - {3402, {wxStyledTextCtrl, pointFromPosition, 1}}, - {3403, {wxStyledTextCtrl, scrollToLine, 1}}, - {3404, {wxStyledTextCtrl, scrollToColumn, 1}}, - {3405, {wxStyledTextCtrl, setVScrollBar, 1}}, - {3406, {wxStyledTextCtrl, setHScrollBar, 1}}, - {3407, {wxStyledTextCtrl, getLastKeydownProcessed, 0}}, - {3408, {wxStyledTextCtrl, setLastKeydownProcessed, 1}}, - {3409, {wxStyledTextCtrl, saveFile, 1}}, - {3410, {wxStyledTextCtrl, loadFile, 1}}, - {3411, {wxStyledTextCtrl, doDragOver, 3}}, - {3412, {wxStyledTextCtrl, doDropText, 3}}, - {3413, {wxStyledTextCtrl, getUseAntiAliasing, 0}}, - {3414, {wxStyledTextCtrl, addTextRaw, 1}}, - {3415, {wxStyledTextCtrl, insertTextRaw, 2}}, - {3416, {wxStyledTextCtrl, getCurLineRaw, 1}}, - {3417, {wxStyledTextCtrl, getLineRaw, 1}}, - {3418, {wxStyledTextCtrl, getSelectedTextRaw, 0}}, - {3419, {wxStyledTextCtrl, getTextRangeRaw, 2}}, - {3420, {wxStyledTextCtrl, setTextRaw, 1}}, - {3421, {wxStyledTextCtrl, getTextRaw, 0}}, - {3422, {wxStyledTextCtrl, appendTextRaw, 1}}, - {3423, {wxArtProvider, getBitmap, 2}}, - {3424, {wxArtProvider, getIcon, 2}}, - {3425, {wxTreeEvent, getKeyCode, 0}}, - {3426, {wxTreeEvent, getItem, 0}}, - {3427, {wxTreeEvent, getKeyEvent, 0}}, - {3428, {wxTreeEvent, getLabel, 0}}, - {3429, {wxTreeEvent, getOldItem, 0}}, - {3430, {wxTreeEvent, getPoint, 0}}, - {3431, {wxTreeEvent, isEditCancelled, 0}}, - {3432, {wxTreeEvent, setToolTip, 1}}, - {3433, {wxNotebookEvent, getOldSelection, 0}}, - {3434, {wxNotebookEvent, getSelection, 0}}, - {3435, {wxNotebookEvent, setOldSelection, 1}}, - {3436, {wxNotebookEvent, setSelection, 1}}, - {3437, {wxFileDataObject, new, 0}}, - {3438, {wxFileDataObject, addFile, 1}}, - {3439, {wxFileDataObject, getFilenames, 0}}, - {3440, {wxFileDataObject, 'Destroy', undefined}}, - {3441, {wxTextDataObject, new, 1}}, - {3442, {wxTextDataObject, getTextLength, 0}}, - {3443, {wxTextDataObject, getText, 0}}, - {3444, {wxTextDataObject, setText, 1}}, - {3445, {wxTextDataObject, 'Destroy', undefined}}, - {3446, {wxBitmapDataObject, new_1_1, 1}}, - {3447, {wxBitmapDataObject, new_1_0, 1}}, - {3448, {wxBitmapDataObject, getBitmap, 0}}, - {3449, {wxBitmapDataObject, setBitmap, 1}}, - {3450, {wxBitmapDataObject, 'Destroy', undefined}}, - {3452, {wxClipboard, new, 0}}, - {3453, {wxClipboard, destruct, 0}}, - {3454, {wxClipboard, addData, 1}}, - {3455, {wxClipboard, clear, 0}}, - {3456, {wxClipboard, close, 0}}, - {3457, {wxClipboard, flush, 0}}, - {3458, {wxClipboard, getData, 1}}, - {3459, {wxClipboard, isOpened, 0}}, - {3460, {wxClipboard, open, 0}}, - {3461, {wxClipboard, setData, 1}}, - {3463, {wxClipboard, usePrimarySelection, 1}}, - {3464, {wxClipboard, isSupported, 1}}, - {3465, {wxClipboard, get, 0}}, - {3466, {wxSpinEvent, getPosition, 0}}, - {3467, {wxSpinEvent, setPosition, 1}}, - {3468, {wxSplitterWindow, new_0, 0}}, - {3469, {wxSplitterWindow, new_2, 2}}, - {3470, {wxSplitterWindow, destruct, 0}}, - {3471, {wxSplitterWindow, create, 2}}, - {3472, {wxSplitterWindow, getMinimumPaneSize, 0}}, - {3473, {wxSplitterWindow, getSashGravity, 0}}, - {3474, {wxSplitterWindow, getSashPosition, 0}}, - {3475, {wxSplitterWindow, getSplitMode, 0}}, - {3476, {wxSplitterWindow, getWindow1, 0}}, - {3477, {wxSplitterWindow, getWindow2, 0}}, - {3478, {wxSplitterWindow, initialize, 1}}, - {3479, {wxSplitterWindow, isSplit, 0}}, - {3480, {wxSplitterWindow, replaceWindow, 2}}, - {3481, {wxSplitterWindow, setSashGravity, 1}}, - {3482, {wxSplitterWindow, setSashPosition, 2}}, - {3483, {wxSplitterWindow, setSashSize, 1}}, - {3484, {wxSplitterWindow, setMinimumPaneSize, 1}}, - {3485, {wxSplitterWindow, setSplitMode, 1}}, - {3486, {wxSplitterWindow, splitHorizontally, 3}}, - {3487, {wxSplitterWindow, splitVertically, 3}}, - {3488, {wxSplitterWindow, unsplit, 1}}, - {3489, {wxSplitterWindow, updateSize, 0}}, - {3490, {wxSplitterEvent, getSashPosition, 0}}, - {3491, {wxSplitterEvent, getX, 0}}, - {3492, {wxSplitterEvent, getY, 0}}, - {3493, {wxSplitterEvent, getWindowBeingRemoved, 0}}, - {3494, {wxSplitterEvent, setSashPosition, 1}}, - {3495, {wxHtmlWindow, new_0, 0}}, - {3496, {wxHtmlWindow, new_2, 2}}, - {3497, {wxHtmlWindow, appendToPage, 1}}, - {3498, {wxHtmlWindow, getOpenedAnchor, 0}}, - {3499, {wxHtmlWindow, getOpenedPage, 0}}, - {3500, {wxHtmlWindow, getOpenedPageTitle, 0}}, - {3501, {wxHtmlWindow, getRelatedFrame, 0}}, - {3502, {wxHtmlWindow, historyBack, 0}}, - {3503, {wxHtmlWindow, historyCanBack, 0}}, - {3504, {wxHtmlWindow, historyCanForward, 0}}, - {3505, {wxHtmlWindow, historyClear, 0}}, - {3506, {wxHtmlWindow, historyForward, 0}}, - {3507, {wxHtmlWindow, loadFile, 1}}, - {3508, {wxHtmlWindow, loadPage, 1}}, - {3509, {wxHtmlWindow, selectAll, 0}}, - {3510, {wxHtmlWindow, selectionToText, 0}}, - {3511, {wxHtmlWindow, selectLine, 1}}, - {3512, {wxHtmlWindow, selectWord, 1}}, - {3513, {wxHtmlWindow, setBorders, 1}}, - {3514, {wxHtmlWindow, setFonts, 3}}, - {3515, {wxHtmlWindow, setPage, 1}}, - {3516, {wxHtmlWindow, setRelatedFrame, 2}}, - {3517, {wxHtmlWindow, setRelatedStatusBar, 1}}, - {3518, {wxHtmlWindow, toText, 0}}, - {3519, {wxHtmlWindow, 'Destroy', undefined}}, - {3520, {wxHtmlLinkEvent, getLinkInfo, 0}}, - {3521, {wxSystemSettings, getColour, 1}}, - {3522, {wxSystemSettings, getFont, 1}}, - {3523, {wxSystemSettings, getMetric, 2}}, - {3524, {wxSystemSettings, getScreenType, 0}}, - {3525, {wxSystemOptions, getOption, 1}}, - {3526, {wxSystemOptions, getOptionInt, 1}}, - {3527, {wxSystemOptions, hasOption, 1}}, - {3528, {wxSystemOptions, isFalse, 1}}, - {3529, {wxSystemOptions, setOption_2_1, 2}}, - {3530, {wxSystemOptions, setOption_2_0, 2}}, - {3531, {wxAuiNotebookEvent, setSelection, 1}}, - {3532, {wxAuiNotebookEvent, getSelection, 0}}, - {3533, {wxAuiNotebookEvent, setOldSelection, 1}}, - {3534, {wxAuiNotebookEvent, getOldSelection, 0}}, - {3535, {wxAuiNotebookEvent, setDragSource, 1}}, - {3536, {wxAuiNotebookEvent, getDragSource, 0}}, - {3537, {wxAuiManagerEvent, setManager, 1}}, - {3538, {wxAuiManagerEvent, getManager, 0}}, - {3539, {wxAuiManagerEvent, setPane, 1}}, - {3540, {wxAuiManagerEvent, getPane, 0}}, - {3541, {wxAuiManagerEvent, setButton, 1}}, - {3542, {wxAuiManagerEvent, getButton, 0}}, - {3543, {wxAuiManagerEvent, setDC, 1}}, - {3544, {wxAuiManagerEvent, getDC, 0}}, - {3545, {wxAuiManagerEvent, veto, 1}}, - {3546, {wxAuiManagerEvent, getVeto, 0}}, - {3547, {wxAuiManagerEvent, setCanVeto, 1}}, - {3548, {wxAuiManagerEvent, canVeto, 0}}, - {3549, {wxLogNull, new, 0}}, - {3550, {wxLogNull, 'Destroy', undefined}}, - {3551, {wxTaskBarIcon, new, 0}}, - {3552, {wxTaskBarIcon, destruct, 0}}, - {3553, {wxTaskBarIcon, popupMenu, 1}}, - {3554, {wxTaskBarIcon, removeIcon, 0}}, - {3555, {wxTaskBarIcon, setIcon, 2}}, - {3556, {wxLocale, new_0, 0}}, - {3558, {wxLocale, new_2, 2}}, - {3559, {wxLocale, destruct, 0}}, - {3561, {wxLocale, init, 1}}, - {3562, {wxLocale, addCatalog_1, 1}}, - {3563, {wxLocale, addCatalog_3, 3}}, - {3564, {wxLocale, addCatalogLookupPathPrefix, 1}}, - {3565, {wxLocale, getCanonicalName, 0}}, - {3566, {wxLocale, getLanguage, 0}}, - {3567, {wxLocale, getLanguageName, 1}}, - {3568, {wxLocale, getLocale, 0}}, - {3569, {wxLocale, getName, 0}}, - {3570, {wxLocale, getString_2, 2}}, - {3571, {wxLocale, getString_4, 4}}, - {3572, {wxLocale, getHeaderValue, 2}}, - {3573, {wxLocale, getSysName, 0}}, - {3574, {wxLocale, getSystemEncoding, 0}}, - {3575, {wxLocale, getSystemEncodingName, 0}}, - {3576, {wxLocale, getSystemLanguage, 0}}, - {3577, {wxLocale, isLoaded, 1}}, - {3578, {wxLocale, isOk, 0}}, - {3579, {wxActivateEvent, getActive, 0}}, - {3581, {wxPopupWindow, new_2, 2}}, - {3582, {wxPopupWindow, new_0, 0}}, - {3584, {wxPopupWindow, destruct, 0}}, - {3585, {wxPopupWindow, create, 2}}, - {3586, {wxPopupWindow, position, 2}}, - {3587, {wxPopupTransientWindow, new_0, 0}}, - {3588, {wxPopupTransientWindow, new_2, 2}}, - {3589, {wxPopupTransientWindow, destruct, 0}}, - {3590, {wxPopupTransientWindow, popup, 1}}, - {3591, {wxPopupTransientWindow, dismiss, 0}}, - {3592, {wxOverlay, new, 0}}, - {3593, {wxOverlay, destruct, 0}}, - {3594, {wxOverlay, reset, 0}}, - {3595, {wxDCOverlay, new_6, 6}}, - {3596, {wxDCOverlay, new_2, 2}}, - {3597, {wxDCOverlay, destruct, 0}}, - {3598, {wxDCOverlay, clear, 0}}, + {1605, {wxGauge, getRange, 0}}, + {1606, {wxGauge, getValue, 0}}, + {1607, {wxGauge, isVertical, 0}}, + {1608, {wxGauge, setRange, 1}}, + {1609, {wxGauge, setValue, 1}}, + {1610, {wxGauge, pulse, 0}}, + {1611, {wxGauge, 'Destroy', undefined}}, + {1612, {wxGenericDirCtrl, new_0, 0}}, + {1613, {wxGenericDirCtrl, new_2, 2}}, + {1614, {wxGenericDirCtrl, destruct, 0}}, + {1615, {wxGenericDirCtrl, create, 2}}, + {1616, {wxGenericDirCtrl, init, 0}}, + {1617, {wxGenericDirCtrl, collapseTree, 0}}, + {1618, {wxGenericDirCtrl, expandPath, 1}}, + {1619, {wxGenericDirCtrl, getDefaultPath, 0}}, + {1620, {wxGenericDirCtrl, getPath, 0}}, + {1621, {wxGenericDirCtrl, getFilePath, 0}}, + {1622, {wxGenericDirCtrl, getFilter, 0}}, + {1623, {wxGenericDirCtrl, getFilterIndex, 0}}, + {1624, {wxGenericDirCtrl, getRootId, 0}}, + {1625, {wxGenericDirCtrl, getTreeCtrl, 0}}, + {1626, {wxGenericDirCtrl, reCreateTree, 0}}, + {1627, {wxGenericDirCtrl, setDefaultPath, 1}}, + {1628, {wxGenericDirCtrl, setFilter, 1}}, + {1629, {wxGenericDirCtrl, setFilterIndex, 1}}, + {1630, {wxGenericDirCtrl, setPath, 1}}, + {1632, {wxStaticBox, new_4, 4}}, + {1633, {wxStaticBox, new_0, 0}}, + {1634, {wxStaticBox, create, 4}}, + {1635, {wxStaticBox, 'Destroy', undefined}}, + {1637, {wxStaticLine, new_2, 2}}, + {1638, {wxStaticLine, new_0, 0}}, + {1639, {wxStaticLine, create, 2}}, + {1640, {wxStaticLine, isVertical, 0}}, + {1641, {wxStaticLine, getDefaultSize, 0}}, + {1642, {wxStaticLine, 'Destroy', undefined}}, + {1645, {wxListBox, new_3, 3}}, + {1646, {wxListBox, new_0, 0}}, + {1648, {wxListBox, destruct, 0}}, + {1650, {wxListBox, create, 6}}, + {1651, {wxListBox, deselect, 1}}, + {1652, {wxListBox, getSelections, 1}}, + {1653, {wxListBox, insertItems, 2}}, + {1654, {wxListBox, isSelected, 1}}, + {1655, {wxListBox, set, 1}}, + {1656, {wxListBox, hitTest, 1}}, + {1657, {wxListBox, setFirstItem_1_0, 1}}, + {1658, {wxListBox, setFirstItem_1_1, 1}}, + {1659, {wxListCtrl, new_0, 0}}, + {1660, {wxListCtrl, new_2, 2}}, + {1661, {wxListCtrl, arrange, 1}}, + {1662, {wxListCtrl, assignImageList, 2}}, + {1663, {wxListCtrl, clearAll, 0}}, + {1664, {wxListCtrl, create, 2}}, + {1665, {wxListCtrl, deleteAllItems, 0}}, + {1666, {wxListCtrl, deleteColumn, 1}}, + {1667, {wxListCtrl, deleteItem, 1}}, + {1668, {wxListCtrl, editLabel, 1}}, + {1669, {wxListCtrl, ensureVisible, 1}}, + {1670, {wxListCtrl, findItem_3_0, 3}}, + {1671, {wxListCtrl, findItem_3_1, 3}}, + {1672, {wxListCtrl, getColumn, 2}}, + {1673, {wxListCtrl, getColumnCount, 0}}, + {1674, {wxListCtrl, getColumnWidth, 1}}, + {1675, {wxListCtrl, getCountPerPage, 0}}, + {1676, {wxListCtrl, getEditControl, 0}}, + {1677, {wxListCtrl, getImageList, 1}}, + {1678, {wxListCtrl, getItem, 1}}, + {1679, {wxListCtrl, getItemBackgroundColour, 1}}, + {1680, {wxListCtrl, getItemCount, 0}}, + {1681, {wxListCtrl, getItemData, 1}}, + {1682, {wxListCtrl, getItemFont, 1}}, + {1683, {wxListCtrl, getItemPosition, 2}}, + {1684, {wxListCtrl, getItemRect, 3}}, + {1685, {wxListCtrl, getItemSpacing, 0}}, + {1686, {wxListCtrl, getItemState, 2}}, + {1687, {wxListCtrl, getItemText, 1}}, + {1688, {wxListCtrl, getItemTextColour, 1}}, + {1689, {wxListCtrl, getNextItem, 2}}, + {1690, {wxListCtrl, getSelectedItemCount, 0}}, + {1691, {wxListCtrl, getTextColour, 0}}, + {1692, {wxListCtrl, getTopItem, 0}}, + {1693, {wxListCtrl, getViewRect, 0}}, + {1694, {wxListCtrl, hitTest, 3}}, + {1695, {wxListCtrl, insertColumn_2, 2}}, + {1696, {wxListCtrl, insertColumn_3, 3}}, + {1697, {wxListCtrl, insertItem_1, 1}}, + {1698, {wxListCtrl, insertItem_2_1, 2}}, + {1699, {wxListCtrl, insertItem_2_0, 2}}, + {1700, {wxListCtrl, insertItem_3, 3}}, + {1701, {wxListCtrl, refreshItem, 1}}, + {1702, {wxListCtrl, refreshItems, 2}}, + {1703, {wxListCtrl, scrollList, 2}}, + {1704, {wxListCtrl, setBackgroundColour, 1}}, + {1705, {wxListCtrl, setColumn, 2}}, + {1706, {wxListCtrl, setColumnWidth, 2}}, + {1707, {wxListCtrl, setImageList, 2}}, + {1708, {wxListCtrl, setItem_1, 1}}, + {1709, {wxListCtrl, setItem_4, 4}}, + {1710, {wxListCtrl, setItemBackgroundColour, 2}}, + {1711, {wxListCtrl, setItemCount, 1}}, + {1712, {wxListCtrl, setItemData, 2}}, + {1713, {wxListCtrl, setItemFont, 2}}, + {1714, {wxListCtrl, setItemImage, 3}}, + {1715, {wxListCtrl, setItemColumnImage, 3}}, + {1716, {wxListCtrl, setItemPosition, 2}}, + {1717, {wxListCtrl, setItemState, 3}}, + {1718, {wxListCtrl, setItemText, 2}}, + {1719, {wxListCtrl, setItemTextColour, 2}}, + {1720, {wxListCtrl, setSingleStyle, 2}}, + {1721, {wxListCtrl, setTextColour, 1}}, + {1722, {wxListCtrl, setWindowStyleFlag, 1}}, + {1723, {wxListCtrl, sortItems, 2}}, + {1724, {wxListCtrl, 'Destroy', undefined}}, + {1725, {wxListView, clearColumnImage, 1}}, + {1726, {wxListView, focus, 1}}, + {1727, {wxListView, getFirstSelected, 0}}, + {1728, {wxListView, getFocusedItem, 0}}, + {1729, {wxListView, getNextSelected, 1}}, + {1730, {wxListView, isSelected, 1}}, + {1731, {wxListView, select, 2}}, + {1732, {wxListView, setColumnImage, 2}}, + {1733, {wxListItem, new_0, 0}}, + {1734, {wxListItem, new_1, 1}}, + {1735, {wxListItem, destruct, 0}}, + {1736, {wxListItem, clear, 0}}, + {1737, {wxListItem, getAlign, 0}}, + {1738, {wxListItem, getBackgroundColour, 0}}, + {1739, {wxListItem, getColumn, 0}}, + {1740, {wxListItem, getFont, 0}}, + {1741, {wxListItem, getId, 0}}, + {1742, {wxListItem, getImage, 0}}, + {1743, {wxListItem, getMask, 0}}, + {1744, {wxListItem, getState, 0}}, + {1745, {wxListItem, getText, 0}}, + {1746, {wxListItem, getTextColour, 0}}, + {1747, {wxListItem, getWidth, 0}}, + {1748, {wxListItem, setAlign, 1}}, + {1749, {wxListItem, setBackgroundColour, 1}}, + {1750, {wxListItem, setColumn, 1}}, + {1751, {wxListItem, setFont, 1}}, + {1752, {wxListItem, setId, 1}}, + {1753, {wxListItem, setImage, 1}}, + {1754, {wxListItem, setMask, 1}}, + {1755, {wxListItem, setState, 1}}, + {1756, {wxListItem, setStateMask, 1}}, + {1757, {wxListItem, setText, 1}}, + {1758, {wxListItem, setTextColour, 1}}, + {1759, {wxListItem, setWidth, 1}}, + {1760, {wxListItemAttr, new_0, 0}}, + {1761, {wxListItemAttr, new_3, 3}}, + {1762, {wxListItemAttr, getBackgroundColour, 0}}, + {1763, {wxListItemAttr, getFont, 0}}, + {1764, {wxListItemAttr, getTextColour, 0}}, + {1765, {wxListItemAttr, hasBackgroundColour, 0}}, + {1766, {wxListItemAttr, hasFont, 0}}, + {1767, {wxListItemAttr, hasTextColour, 0}}, + {1768, {wxListItemAttr, setBackgroundColour, 1}}, + {1769, {wxListItemAttr, setFont, 1}}, + {1770, {wxListItemAttr, setTextColour, 1}}, + {1771, {wxListItemAttr, 'Destroy', undefined}}, + {1772, {wxImageList, new_0, 0}}, + {1773, {wxImageList, new_3, 3}}, + {1774, {wxImageList, add_1, 1}}, + {1775, {wxImageList, add_2_0, 2}}, + {1776, {wxImageList, add_2_1, 2}}, + {1777, {wxImageList, create, 3}}, + {1779, {wxImageList, draw, 5}}, + {1780, {wxImageList, getBitmap, 1}}, + {1781, {wxImageList, getIcon, 1}}, + {1782, {wxImageList, getImageCount, 0}}, + {1783, {wxImageList, getSize, 3}}, + {1784, {wxImageList, remove, 1}}, + {1785, {wxImageList, removeAll, 0}}, + {1786, {wxImageList, replace_2, 2}}, + {1787, {wxImageList, replace_3, 3}}, + {1788, {wxImageList, 'Destroy', undefined}}, + {1789, {wxTextAttr, new_0, 0}}, + {1790, {wxTextAttr, new_2, 2}}, + {1791, {wxTextAttr, getAlignment, 0}}, + {1792, {wxTextAttr, getBackgroundColour, 0}}, + {1793, {wxTextAttr, getFont, 0}}, + {1794, {wxTextAttr, getLeftIndent, 0}}, + {1795, {wxTextAttr, getLeftSubIndent, 0}}, + {1796, {wxTextAttr, getRightIndent, 0}}, + {1797, {wxTextAttr, getTabs, 0}}, + {1798, {wxTextAttr, getTextColour, 0}}, + {1799, {wxTextAttr, hasBackgroundColour, 0}}, + {1800, {wxTextAttr, hasFont, 0}}, + {1801, {wxTextAttr, hasTextColour, 0}}, + {1802, {wxTextAttr, getFlags, 0}}, + {1803, {wxTextAttr, isDefault, 0}}, + {1804, {wxTextAttr, setAlignment, 1}}, + {1805, {wxTextAttr, setBackgroundColour, 1}}, + {1806, {wxTextAttr, setFlags, 1}}, + {1807, {wxTextAttr, setFont, 2}}, + {1808, {wxTextAttr, setLeftIndent, 2}}, + {1809, {wxTextAttr, setRightIndent, 1}}, + {1810, {wxTextAttr, setTabs, 1}}, + {1811, {wxTextAttr, setTextColour, 1}}, + {1812, {wxTextAttr, 'Destroy', undefined}}, + {1814, {wxTextCtrl, new_3, 3}}, + {1815, {wxTextCtrl, new_0, 0}}, + {1817, {wxTextCtrl, destruct, 0}}, + {1818, {wxTextCtrl, appendText, 1}}, + {1819, {wxTextCtrl, canCopy, 0}}, + {1820, {wxTextCtrl, canCut, 0}}, + {1821, {wxTextCtrl, canPaste, 0}}, + {1822, {wxTextCtrl, canRedo, 0}}, + {1823, {wxTextCtrl, canUndo, 0}}, + {1824, {wxTextCtrl, clear, 0}}, + {1825, {wxTextCtrl, copy, 0}}, + {1826, {wxTextCtrl, create, 3}}, + {1827, {wxTextCtrl, cut, 0}}, + {1828, {wxTextCtrl, discardEdits, 0}}, + {1829, {wxTextCtrl, changeValue, 1}}, + {1830, {wxTextCtrl, emulateKeyPress, 1}}, + {1831, {wxTextCtrl, getDefaultStyle, 0}}, + {1832, {wxTextCtrl, getInsertionPoint, 0}}, + {1833, {wxTextCtrl, getLastPosition, 0}}, + {1834, {wxTextCtrl, getLineLength, 1}}, + {1835, {wxTextCtrl, getLineText, 1}}, + {1836, {wxTextCtrl, getNumberOfLines, 0}}, + {1837, {wxTextCtrl, getRange, 2}}, + {1838, {wxTextCtrl, getSelection, 2}}, + {1839, {wxTextCtrl, getStringSelection, 0}}, + {1840, {wxTextCtrl, getStyle, 2}}, + {1841, {wxTextCtrl, getValue, 0}}, + {1842, {wxTextCtrl, isEditable, 0}}, + {1843, {wxTextCtrl, isModified, 0}}, + {1844, {wxTextCtrl, isMultiLine, 0}}, + {1845, {wxTextCtrl, isSingleLine, 0}}, + {1846, {wxTextCtrl, loadFile, 2}}, + {1847, {wxTextCtrl, markDirty, 0}}, + {1848, {wxTextCtrl, paste, 0}}, + {1849, {wxTextCtrl, positionToXY, 3}}, + {1850, {wxTextCtrl, redo, 0}}, + {1851, {wxTextCtrl, remove, 2}}, + {1852, {wxTextCtrl, replace, 3}}, + {1853, {wxTextCtrl, saveFile, 1}}, + {1854, {wxTextCtrl, setDefaultStyle, 1}}, + {1855, {wxTextCtrl, setEditable, 1}}, + {1856, {wxTextCtrl, setInsertionPoint, 1}}, + {1857, {wxTextCtrl, setInsertionPointEnd, 0}}, + {1859, {wxTextCtrl, setMaxLength, 1}}, + {1860, {wxTextCtrl, setSelection, 2}}, + {1861, {wxTextCtrl, setStyle, 3}}, + {1862, {wxTextCtrl, setValue, 1}}, + {1863, {wxTextCtrl, showPosition, 1}}, + {1864, {wxTextCtrl, undo, 0}}, + {1865, {wxTextCtrl, writeText, 1}}, + {1866, {wxTextCtrl, xYToPosition, 2}}, + {1869, {wxNotebook, new_0, 0}}, + {1870, {wxNotebook, new_3, 3}}, + {1871, {wxNotebook, destruct, 0}}, + {1872, {wxNotebook, addPage, 3}}, + {1873, {wxNotebook, advanceSelection, 1}}, + {1874, {wxNotebook, assignImageList, 1}}, + {1875, {wxNotebook, create, 3}}, + {1876, {wxNotebook, deleteAllPages, 0}}, + {1877, {wxNotebook, deletePage, 1}}, + {1878, {wxNotebook, removePage, 1}}, + {1879, {wxNotebook, getCurrentPage, 0}}, + {1880, {wxNotebook, getImageList, 0}}, + {1882, {wxNotebook, getPage, 1}}, + {1883, {wxNotebook, getPageCount, 0}}, + {1884, {wxNotebook, getPageImage, 1}}, + {1885, {wxNotebook, getPageText, 1}}, + {1886, {wxNotebook, getRowCount, 0}}, + {1887, {wxNotebook, getSelection, 0}}, + {1888, {wxNotebook, getThemeBackgroundColour, 0}}, + {1890, {wxNotebook, hitTest, 2}}, + {1892, {wxNotebook, insertPage, 4}}, + {1893, {wxNotebook, setImageList, 1}}, + {1894, {wxNotebook, setPadding, 1}}, + {1895, {wxNotebook, setPageSize, 1}}, + {1896, {wxNotebook, setPageImage, 2}}, + {1897, {wxNotebook, setPageText, 2}}, + {1898, {wxNotebook, setSelection, 1}}, + {1899, {wxNotebook, changeSelection, 1}}, + {1900, {wxChoicebook, new_0, 0}}, + {1901, {wxChoicebook, new_3, 3}}, + {1902, {wxChoicebook, addPage, 3}}, + {1903, {wxChoicebook, advanceSelection, 1}}, + {1904, {wxChoicebook, assignImageList, 1}}, + {1905, {wxChoicebook, create, 3}}, + {1906, {wxChoicebook, deleteAllPages, 0}}, + {1907, {wxChoicebook, deletePage, 1}}, + {1908, {wxChoicebook, removePage, 1}}, + {1909, {wxChoicebook, getCurrentPage, 0}}, + {1910, {wxChoicebook, getImageList, 0}}, + {1912, {wxChoicebook, getPage, 1}}, + {1913, {wxChoicebook, getPageCount, 0}}, + {1914, {wxChoicebook, getPageImage, 1}}, + {1915, {wxChoicebook, getPageText, 1}}, + {1916, {wxChoicebook, getSelection, 0}}, + {1917, {wxChoicebook, hitTest, 2}}, + {1918, {wxChoicebook, insertPage, 4}}, + {1919, {wxChoicebook, setImageList, 1}}, + {1920, {wxChoicebook, setPageSize, 1}}, + {1921, {wxChoicebook, setPageImage, 2}}, + {1922, {wxChoicebook, setPageText, 2}}, + {1923, {wxChoicebook, setSelection, 1}}, + {1924, {wxChoicebook, changeSelection, 1}}, + {1925, {wxChoicebook, 'Destroy', undefined}}, + {1926, {wxToolbook, new_0, 0}}, + {1927, {wxToolbook, new_3, 3}}, + {1928, {wxToolbook, addPage, 3}}, + {1929, {wxToolbook, advanceSelection, 1}}, + {1930, {wxToolbook, assignImageList, 1}}, + {1931, {wxToolbook, create, 3}}, + {1932, {wxToolbook, deleteAllPages, 0}}, + {1933, {wxToolbook, deletePage, 1}}, + {1934, {wxToolbook, removePage, 1}}, + {1935, {wxToolbook, getCurrentPage, 0}}, + {1936, {wxToolbook, getImageList, 0}}, + {1938, {wxToolbook, getPage, 1}}, + {1939, {wxToolbook, getPageCount, 0}}, + {1940, {wxToolbook, getPageImage, 1}}, + {1941, {wxToolbook, getPageText, 1}}, + {1942, {wxToolbook, getSelection, 0}}, + {1944, {wxToolbook, hitTest, 2}}, + {1945, {wxToolbook, insertPage, 4}}, + {1946, {wxToolbook, setImageList, 1}}, + {1947, {wxToolbook, setPageSize, 1}}, + {1948, {wxToolbook, setPageImage, 2}}, + {1949, {wxToolbook, setPageText, 2}}, + {1950, {wxToolbook, setSelection, 1}}, + {1951, {wxToolbook, changeSelection, 1}}, + {1952, {wxToolbook, 'Destroy', undefined}}, + {1953, {wxListbook, new_0, 0}}, + {1954, {wxListbook, new_3, 3}}, + {1955, {wxListbook, addPage, 3}}, + {1956, {wxListbook, advanceSelection, 1}}, + {1957, {wxListbook, assignImageList, 1}}, + {1958, {wxListbook, create, 3}}, + {1959, {wxListbook, deleteAllPages, 0}}, + {1960, {wxListbook, deletePage, 1}}, + {1961, {wxListbook, removePage, 1}}, + {1962, {wxListbook, getCurrentPage, 0}}, + {1963, {wxListbook, getImageList, 0}}, + {1965, {wxListbook, getPage, 1}}, + {1966, {wxListbook, getPageCount, 0}}, + {1967, {wxListbook, getPageImage, 1}}, + {1968, {wxListbook, getPageText, 1}}, + {1969, {wxListbook, getSelection, 0}}, + {1971, {wxListbook, hitTest, 2}}, + {1972, {wxListbook, insertPage, 4}}, + {1973, {wxListbook, setImageList, 1}}, + {1974, {wxListbook, setPageSize, 1}}, + {1975, {wxListbook, setPageImage, 2}}, + {1976, {wxListbook, setPageText, 2}}, + {1977, {wxListbook, setSelection, 1}}, + {1978, {wxListbook, changeSelection, 1}}, + {1979, {wxListbook, 'Destroy', undefined}}, + {1980, {wxTreebook, new_0, 0}}, + {1981, {wxTreebook, new_3, 3}}, + {1982, {wxTreebook, addPage, 3}}, + {1983, {wxTreebook, advanceSelection, 1}}, + {1984, {wxTreebook, assignImageList, 1}}, + {1985, {wxTreebook, create, 3}}, + {1986, {wxTreebook, deleteAllPages, 0}}, + {1987, {wxTreebook, deletePage, 1}}, + {1988, {wxTreebook, removePage, 1}}, + {1989, {wxTreebook, getCurrentPage, 0}}, + {1990, {wxTreebook, getImageList, 0}}, + {1992, {wxTreebook, getPage, 1}}, + {1993, {wxTreebook, getPageCount, 0}}, + {1994, {wxTreebook, getPageImage, 1}}, + {1995, {wxTreebook, getPageText, 1}}, + {1996, {wxTreebook, getSelection, 0}}, + {1997, {wxTreebook, expandNode, 2}}, + {1998, {wxTreebook, isNodeExpanded, 1}}, + {2000, {wxTreebook, hitTest, 2}}, + {2001, {wxTreebook, insertPage, 4}}, + {2002, {wxTreebook, insertSubPage, 4}}, + {2003, {wxTreebook, setImageList, 1}}, + {2004, {wxTreebook, setPageSize, 1}}, + {2005, {wxTreebook, setPageImage, 2}}, + {2006, {wxTreebook, setPageText, 2}}, + {2007, {wxTreebook, setSelection, 1}}, + {2008, {wxTreebook, changeSelection, 1}}, + {2009, {wxTreebook, 'Destroy', undefined}}, + {2012, {wxTreeCtrl, new_2, 2}}, + {2013, {wxTreeCtrl, new_0, 0}}, + {2015, {wxTreeCtrl, destruct, 0}}, + {2016, {wxTreeCtrl, addRoot, 2}}, + {2017, {wxTreeCtrl, appendItem, 3}}, + {2018, {wxTreeCtrl, assignImageList, 1}}, + {2019, {wxTreeCtrl, assignStateImageList, 1}}, + {2020, {wxTreeCtrl, collapse, 1}}, + {2021, {wxTreeCtrl, collapseAndReset, 1}}, + {2022, {wxTreeCtrl, create, 2}}, + {2023, {wxTreeCtrl, delete, 1}}, + {2024, {wxTreeCtrl, deleteAllItems, 0}}, + {2025, {wxTreeCtrl, deleteChildren, 1}}, + {2026, {wxTreeCtrl, editLabel, 1}}, + {2027, {wxTreeCtrl, ensureVisible, 1}}, + {2028, {wxTreeCtrl, expand, 1}}, + {2029, {wxTreeCtrl, getBoundingRect, 3}}, + {2031, {wxTreeCtrl, getChildrenCount, 2}}, + {2032, {wxTreeCtrl, getCount, 0}}, + {2033, {wxTreeCtrl, getEditControl, 0}}, + {2034, {wxTreeCtrl, getFirstChild, 2}}, + {2035, {wxTreeCtrl, getNextChild, 2}}, + {2036, {wxTreeCtrl, getFirstVisibleItem, 0}}, + {2037, {wxTreeCtrl, getImageList, 0}}, + {2038, {wxTreeCtrl, getIndent, 0}}, + {2039, {wxTreeCtrl, getItemBackgroundColour, 1}}, + {2040, {wxTreeCtrl, getItemData, 1}}, + {2041, {wxTreeCtrl, getItemFont, 1}}, + {2042, {wxTreeCtrl, getItemImage_1, 1}}, + {2043, {wxTreeCtrl, getItemImage_2, 2}}, + {2044, {wxTreeCtrl, getItemText, 1}}, + {2045, {wxTreeCtrl, getItemTextColour, 1}}, + {2046, {wxTreeCtrl, getLastChild, 1}}, + {2047, {wxTreeCtrl, getNextSibling, 1}}, + {2048, {wxTreeCtrl, getNextVisible, 1}}, + {2049, {wxTreeCtrl, getItemParent, 1}}, + {2050, {wxTreeCtrl, getPrevSibling, 1}}, + {2051, {wxTreeCtrl, getPrevVisible, 1}}, + {2052, {wxTreeCtrl, getRootItem, 0}}, + {2053, {wxTreeCtrl, getSelection, 0}}, + {2054, {wxTreeCtrl, getSelections, 1}}, + {2055, {wxTreeCtrl, getStateImageList, 0}}, + {2056, {wxTreeCtrl, hitTest, 2}}, + {2058, {wxTreeCtrl, insertItem, 4}}, + {2059, {wxTreeCtrl, isBold, 1}}, + {2060, {wxTreeCtrl, isExpanded, 1}}, + {2061, {wxTreeCtrl, isSelected, 1}}, + {2062, {wxTreeCtrl, isVisible, 1}}, + {2063, {wxTreeCtrl, itemHasChildren, 1}}, + {2064, {wxTreeCtrl, isTreeItemIdOk, 1}}, + {2065, {wxTreeCtrl, prependItem, 3}}, + {2066, {wxTreeCtrl, scrollTo, 1}}, + {2067, {wxTreeCtrl, selectItem_1, 1}}, + {2068, {wxTreeCtrl, selectItem_2, 2}}, + {2069, {wxTreeCtrl, setIndent, 1}}, + {2070, {wxTreeCtrl, setImageList, 1}}, + {2071, {wxTreeCtrl, setItemBackgroundColour, 2}}, + {2072, {wxTreeCtrl, setItemBold, 2}}, + {2073, {wxTreeCtrl, setItemData, 2}}, + {2074, {wxTreeCtrl, setItemDropHighlight, 2}}, + {2075, {wxTreeCtrl, setItemFont, 2}}, + {2076, {wxTreeCtrl, setItemHasChildren, 2}}, + {2077, {wxTreeCtrl, setItemImage_2, 2}}, + {2078, {wxTreeCtrl, setItemImage_3, 3}}, + {2079, {wxTreeCtrl, setItemText, 2}}, + {2080, {wxTreeCtrl, setItemTextColour, 2}}, + {2081, {wxTreeCtrl, setStateImageList, 1}}, + {2082, {wxTreeCtrl, setWindowStyle, 1}}, + {2083, {wxTreeCtrl, sortChildren, 1}}, + {2084, {wxTreeCtrl, toggle, 1}}, + {2085, {wxTreeCtrl, toggleItemSelection, 1}}, + {2086, {wxTreeCtrl, unselect, 0}}, + {2087, {wxTreeCtrl, unselectAll, 0}}, + {2088, {wxTreeCtrl, unselectItem, 1}}, + {2089, {wxScrollBar, new_0, 0}}, + {2090, {wxScrollBar, new_3, 3}}, + {2091, {wxScrollBar, destruct, 0}}, + {2092, {wxScrollBar, create, 3}}, + {2093, {wxScrollBar, getRange, 0}}, + {2094, {wxScrollBar, getPageSize, 0}}, + {2095, {wxScrollBar, getThumbPosition, 0}}, + {2096, {wxScrollBar, getThumbSize, 0}}, + {2097, {wxScrollBar, setThumbPosition, 1}}, + {2098, {wxScrollBar, setScrollbar, 5}}, + {2100, {wxSpinButton, new_2, 2}}, + {2101, {wxSpinButton, new_0, 0}}, + {2102, {wxSpinButton, create, 2}}, + {2103, {wxSpinButton, getMax, 0}}, + {2104, {wxSpinButton, getMin, 0}}, + {2105, {wxSpinButton, getValue, 0}}, + {2106, {wxSpinButton, setRange, 2}}, + {2107, {wxSpinButton, setValue, 1}}, + {2108, {wxSpinButton, 'Destroy', undefined}}, + {2109, {wxSpinCtrl, new_0, 0}}, + {2110, {wxSpinCtrl, new_2, 2}}, + {2112, {wxSpinCtrl, create, 2}}, + {2115, {wxSpinCtrl, setValue_1_1, 1}}, + {2116, {wxSpinCtrl, setValue_1_0, 1}}, + {2118, {wxSpinCtrl, getValue, 0}}, + {2120, {wxSpinCtrl, setRange, 2}}, + {2121, {wxSpinCtrl, setSelection, 2}}, + {2123, {wxSpinCtrl, getMin, 0}}, + {2125, {wxSpinCtrl, getMax, 0}}, + {2126, {wxSpinCtrl, 'Destroy', undefined}}, + {2127, {wxStaticText, new_0, 0}}, + {2128, {wxStaticText, new_4, 4}}, + {2129, {wxStaticText, create, 4}}, + {2130, {wxStaticText, getLabel, 0}}, + {2131, {wxStaticText, setLabel, 1}}, + {2132, {wxStaticText, wrap, 1}}, + {2133, {wxStaticText, 'Destroy', undefined}}, + {2134, {wxStaticBitmap, new_0, 0}}, + {2135, {wxStaticBitmap, new_4, 4}}, + {2136, {wxStaticBitmap, create, 4}}, + {2137, {wxStaticBitmap, getBitmap, 0}}, + {2138, {wxStaticBitmap, setBitmap, 1}}, + {2139, {wxStaticBitmap, 'Destroy', undefined}}, + {2140, {wxRadioBox, new, 7}}, + {2142, {wxRadioBox, destruct, 0}}, + {2143, {wxRadioBox, create, 7}}, + {2144, {wxRadioBox, enable_2, 2}}, + {2145, {wxRadioBox, enable_1, 1}}, + {2146, {wxRadioBox, getSelection, 0}}, + {2147, {wxRadioBox, getString, 1}}, + {2148, {wxRadioBox, setSelection, 1}}, + {2149, {wxRadioBox, show_2, 2}}, + {2150, {wxRadioBox, show_1, 1}}, + {2151, {wxRadioBox, getColumnCount, 0}}, + {2152, {wxRadioBox, getItemHelpText, 1}}, + {2153, {wxRadioBox, getItemToolTip, 1}}, + {2155, {wxRadioBox, getItemFromPoint, 1}}, + {2156, {wxRadioBox, getRowCount, 0}}, + {2157, {wxRadioBox, isItemEnabled, 1}}, + {2158, {wxRadioBox, isItemShown, 1}}, + {2159, {wxRadioBox, setItemHelpText, 2}}, + {2160, {wxRadioBox, setItemToolTip, 2}}, + {2161, {wxRadioButton, new_0, 0}}, + {2162, {wxRadioButton, new_4, 4}}, + {2163, {wxRadioButton, create, 4}}, + {2164, {wxRadioButton, getValue, 0}}, + {2165, {wxRadioButton, setValue, 1}}, + {2166, {wxRadioButton, 'Destroy', undefined}}, + {2168, {wxSlider, new_6, 6}}, + {2169, {wxSlider, new_0, 0}}, + {2170, {wxSlider, create, 6}}, + {2171, {wxSlider, getLineSize, 0}}, + {2172, {wxSlider, getMax, 0}}, + {2173, {wxSlider, getMin, 0}}, + {2174, {wxSlider, getPageSize, 0}}, + {2175, {wxSlider, getThumbLength, 0}}, + {2176, {wxSlider, getValue, 0}}, + {2177, {wxSlider, setLineSize, 1}}, + {2178, {wxSlider, setPageSize, 1}}, + {2179, {wxSlider, setRange, 2}}, + {2180, {wxSlider, setThumbLength, 1}}, + {2181, {wxSlider, setValue, 1}}, + {2182, {wxSlider, 'Destroy', undefined}}, + {2184, {wxDialog, new_4, 4}}, + {2185, {wxDialog, new_0, 0}}, + {2187, {wxDialog, destruct, 0}}, + {2188, {wxDialog, create, 4}}, + {2189, {wxDialog, createButtonSizer, 1}}, + {2190, {wxDialog, createStdDialogButtonSizer, 1}}, + {2191, {wxDialog, endModal, 1}}, + {2192, {wxDialog, getAffirmativeId, 0}}, + {2193, {wxDialog, getReturnCode, 0}}, + {2194, {wxDialog, isModal, 0}}, + {2195, {wxDialog, setAffirmativeId, 1}}, + {2196, {wxDialog, setReturnCode, 1}}, + {2197, {wxDialog, show, 1}}, + {2198, {wxDialog, showModal, 0}}, + {2199, {wxColourDialog, new_0, 0}}, + {2200, {wxColourDialog, new_2, 2}}, + {2201, {wxColourDialog, destruct, 0}}, + {2202, {wxColourDialog, create, 2}}, + {2203, {wxColourDialog, getColourData, 0}}, + {2204, {wxColourData, new_0, 0}}, + {2205, {wxColourData, new_1, 1}}, + {2206, {wxColourData, destruct, 0}}, + {2207, {wxColourData, getChooseFull, 0}}, + {2208, {wxColourData, getColour, 0}}, + {2210, {wxColourData, getCustomColour, 1}}, + {2211, {wxColourData, setChooseFull, 1}}, + {2212, {wxColourData, setColour, 1}}, + {2213, {wxColourData, setCustomColour, 2}}, + {2214, {wxPalette, new_0, 0}}, + {2215, {wxPalette, new_4, 4}}, + {2217, {wxPalette, destruct, 0}}, + {2218, {wxPalette, create, 4}}, + {2219, {wxPalette, getColoursCount, 0}}, + {2220, {wxPalette, getPixel, 3}}, + {2221, {wxPalette, getRGB, 4}}, + {2222, {wxPalette, isOk, 0}}, + {2226, {wxDirDialog, new, 2}}, + {2227, {wxDirDialog, destruct, 0}}, + {2228, {wxDirDialog, getPath, 0}}, + {2229, {wxDirDialog, getMessage, 0}}, + {2230, {wxDirDialog, setMessage, 1}}, + {2231, {wxDirDialog, setPath, 1}}, + {2235, {wxFileDialog, new, 2}}, + {2236, {wxFileDialog, destruct, 0}}, + {2237, {wxFileDialog, getDirectory, 0}}, + {2238, {wxFileDialog, getFilename, 0}}, + {2239, {wxFileDialog, getFilenames, 1}}, + {2240, {wxFileDialog, getFilterIndex, 0}}, + {2241, {wxFileDialog, getMessage, 0}}, + {2242, {wxFileDialog, getPath, 0}}, + {2243, {wxFileDialog, getPaths, 1}}, + {2244, {wxFileDialog, getWildcard, 0}}, + {2245, {wxFileDialog, setDirectory, 1}}, + {2246, {wxFileDialog, setFilename, 1}}, + {2247, {wxFileDialog, setFilterIndex, 1}}, + {2248, {wxFileDialog, setMessage, 1}}, + {2249, {wxFileDialog, setPath, 1}}, + {2250, {wxFileDialog, setWildcard, 1}}, + {2251, {wxPickerBase, setInternalMargin, 1}}, + {2252, {wxPickerBase, getInternalMargin, 0}}, + {2253, {wxPickerBase, setTextCtrlProportion, 1}}, + {2254, {wxPickerBase, setPickerCtrlProportion, 1}}, + {2255, {wxPickerBase, getTextCtrlProportion, 0}}, + {2256, {wxPickerBase, getPickerCtrlProportion, 0}}, + {2257, {wxPickerBase, hasTextCtrl, 0}}, + {2258, {wxPickerBase, getTextCtrl, 0}}, + {2259, {wxPickerBase, isTextCtrlGrowable, 0}}, + {2260, {wxPickerBase, setPickerCtrlGrowable, 1}}, + {2261, {wxPickerBase, setTextCtrlGrowable, 1}}, + {2262, {wxPickerBase, isPickerCtrlGrowable, 0}}, + {2263, {wxFilePickerCtrl, new_0, 0}}, + {2264, {wxFilePickerCtrl, new_3, 3}}, + {2265, {wxFilePickerCtrl, create, 3}}, + {2266, {wxFilePickerCtrl, getPath, 0}}, + {2267, {wxFilePickerCtrl, setPath, 1}}, + {2268, {wxFilePickerCtrl, 'Destroy', undefined}}, + {2269, {wxDirPickerCtrl, new_0, 0}}, + {2270, {wxDirPickerCtrl, new_3, 3}}, + {2271, {wxDirPickerCtrl, create, 3}}, + {2272, {wxDirPickerCtrl, getPath, 0}}, + {2273, {wxDirPickerCtrl, setPath, 1}}, + {2274, {wxDirPickerCtrl, 'Destroy', undefined}}, + {2275, {wxColourPickerCtrl, new_0, 0}}, + {2276, {wxColourPickerCtrl, new_3, 3}}, + {2277, {wxColourPickerCtrl, create, 3}}, + {2278, {wxColourPickerCtrl, getColour, 0}}, + {2279, {wxColourPickerCtrl, setColour_1_1, 1}}, + {2280, {wxColourPickerCtrl, setColour_1_0, 1}}, + {2281, {wxColourPickerCtrl, 'Destroy', undefined}}, + {2282, {wxDatePickerCtrl, new_0, 0}}, + {2283, {wxDatePickerCtrl, new_3, 3}}, + {2284, {wxDatePickerCtrl, getRange, 2}}, + {2285, {wxDatePickerCtrl, getValue, 0}}, + {2286, {wxDatePickerCtrl, setRange, 2}}, + {2287, {wxDatePickerCtrl, setValue, 1}}, + {2288, {wxDatePickerCtrl, 'Destroy', undefined}}, + {2289, {wxFontPickerCtrl, new_0, 0}}, + {2290, {wxFontPickerCtrl, new_3, 3}}, + {2291, {wxFontPickerCtrl, create, 3}}, + {2292, {wxFontPickerCtrl, getSelectedFont, 0}}, + {2293, {wxFontPickerCtrl, setSelectedFont, 1}}, + {2294, {wxFontPickerCtrl, getMaxPointSize, 0}}, + {2295, {wxFontPickerCtrl, setMaxPointSize, 1}}, + {2296, {wxFontPickerCtrl, 'Destroy', undefined}}, + {2299, {wxFindReplaceDialog, new_0, 0}}, + {2300, {wxFindReplaceDialog, new_4, 4}}, + {2301, {wxFindReplaceDialog, destruct, 0}}, + {2302, {wxFindReplaceDialog, create, 4}}, + {2303, {wxFindReplaceDialog, getData, 0}}, + {2304, {wxFindReplaceData, new_0, 0}}, + {2305, {wxFindReplaceData, new_1, 1}}, + {2306, {wxFindReplaceData, getFindString, 0}}, + {2307, {wxFindReplaceData, getReplaceString, 0}}, + {2308, {wxFindReplaceData, getFlags, 0}}, + {2309, {wxFindReplaceData, setFlags, 1}}, + {2310, {wxFindReplaceData, setFindString, 1}}, + {2311, {wxFindReplaceData, setReplaceString, 1}}, + {2312, {wxFindReplaceData, 'Destroy', undefined}}, + {2313, {wxMultiChoiceDialog, new_0, 0}}, + {2315, {wxMultiChoiceDialog, new_5, 5}}, + {2316, {wxMultiChoiceDialog, getSelections, 0}}, + {2317, {wxMultiChoiceDialog, setSelections, 1}}, + {2318, {wxMultiChoiceDialog, 'Destroy', undefined}}, + {2319, {wxSingleChoiceDialog, new_0, 0}}, + {2321, {wxSingleChoiceDialog, new_5, 5}}, + {2322, {wxSingleChoiceDialog, getSelection, 0}}, + {2323, {wxSingleChoiceDialog, getStringSelection, 0}}, + {2324, {wxSingleChoiceDialog, setSelection, 1}}, + {2325, {wxSingleChoiceDialog, 'Destroy', undefined}}, + {2326, {wxTextEntryDialog, new, 3}}, + {2327, {wxTextEntryDialog, getValue, 0}}, + {2328, {wxTextEntryDialog, setValue, 1}}, + {2329, {wxTextEntryDialog, 'Destroy', undefined}}, + {2330, {wxPasswordEntryDialog, new, 3}}, + {2331, {wxPasswordEntryDialog, 'Destroy', undefined}}, + {2332, {wxFontData, new_0, 0}}, + {2333, {wxFontData, new_1, 1}}, + {2334, {wxFontData, destruct, 0}}, + {2335, {wxFontData, enableEffects, 1}}, + {2336, {wxFontData, getAllowSymbols, 0}}, + {2337, {wxFontData, getColour, 0}}, + {2338, {wxFontData, getChosenFont, 0}}, + {2339, {wxFontData, getEnableEffects, 0}}, + {2340, {wxFontData, getInitialFont, 0}}, + {2341, {wxFontData, getShowHelp, 0}}, + {2342, {wxFontData, setAllowSymbols, 1}}, + {2343, {wxFontData, setChosenFont, 1}}, + {2344, {wxFontData, setColour, 1}}, + {2345, {wxFontData, setInitialFont, 1}}, + {2346, {wxFontData, setRange, 2}}, + {2347, {wxFontData, setShowHelp, 1}}, + {2351, {wxFontDialog, new_0, 0}}, + {2353, {wxFontDialog, new_2, 2}}, + {2355, {wxFontDialog, create, 2}}, + {2356, {wxFontDialog, getFontData, 0}}, + {2358, {wxFontDialog, 'Destroy', undefined}}, + {2359, {wxProgressDialog, new, 3}}, + {2360, {wxProgressDialog, destruct, 0}}, + {2361, {wxProgressDialog, resume, 0}}, + {2362, {wxProgressDialog, update_2, 2}}, + {2363, {wxProgressDialog, update_0, 0}}, + {2364, {wxMessageDialog, new, 3}}, + {2365, {wxMessageDialog, destruct, 0}}, + {2366, {wxPageSetupDialog, new, 2}}, + {2367, {wxPageSetupDialog, destruct, 0}}, + {2368, {wxPageSetupDialog, getPageSetupData, 0}}, + {2369, {wxPageSetupDialog, showModal, 0}}, + {2370, {wxPageSetupDialogData, new_0, 0}}, + {2371, {wxPageSetupDialogData, new_1_0, 1}}, + {2372, {wxPageSetupDialogData, new_1_1, 1}}, + {2373, {wxPageSetupDialogData, destruct, 0}}, + {2374, {wxPageSetupDialogData, enableHelp, 1}}, + {2375, {wxPageSetupDialogData, enableMargins, 1}}, + {2376, {wxPageSetupDialogData, enableOrientation, 1}}, + {2377, {wxPageSetupDialogData, enablePaper, 1}}, + {2378, {wxPageSetupDialogData, enablePrinter, 1}}, + {2379, {wxPageSetupDialogData, getDefaultMinMargins, 0}}, + {2380, {wxPageSetupDialogData, getEnableMargins, 0}}, + {2381, {wxPageSetupDialogData, getEnableOrientation, 0}}, + {2382, {wxPageSetupDialogData, getEnablePaper, 0}}, + {2383, {wxPageSetupDialogData, getEnablePrinter, 0}}, + {2384, {wxPageSetupDialogData, getEnableHelp, 0}}, + {2385, {wxPageSetupDialogData, getDefaultInfo, 0}}, + {2386, {wxPageSetupDialogData, getMarginTopLeft, 0}}, + {2387, {wxPageSetupDialogData, getMarginBottomRight, 0}}, + {2388, {wxPageSetupDialogData, getMinMarginTopLeft, 0}}, + {2389, {wxPageSetupDialogData, getMinMarginBottomRight, 0}}, + {2390, {wxPageSetupDialogData, getPaperId, 0}}, + {2391, {wxPageSetupDialogData, getPaperSize, 0}}, + {2393, {wxPageSetupDialogData, getPrintData, 0}}, + {2394, {wxPageSetupDialogData, isOk, 0}}, + {2395, {wxPageSetupDialogData, setDefaultInfo, 1}}, + {2396, {wxPageSetupDialogData, setDefaultMinMargins, 1}}, + {2397, {wxPageSetupDialogData, setMarginTopLeft, 1}}, + {2398, {wxPageSetupDialogData, setMarginBottomRight, 1}}, + {2399, {wxPageSetupDialogData, setMinMarginTopLeft, 1}}, + {2400, {wxPageSetupDialogData, setMinMarginBottomRight, 1}}, + {2401, {wxPageSetupDialogData, setPaperId, 1}}, + {2402, {wxPageSetupDialogData, setPaperSize_1_1, 1}}, + {2403, {wxPageSetupDialogData, setPaperSize_1_0, 1}}, + {2404, {wxPageSetupDialogData, setPrintData, 1}}, + {2405, {wxPrintDialog, new_2_0, 2}}, + {2406, {wxPrintDialog, new_2_1, 2}}, + {2407, {wxPrintDialog, destruct, 0}}, + {2408, {wxPrintDialog, getPrintDialogData, 0}}, + {2409, {wxPrintDialog, getPrintDC, 0}}, + {2410, {wxPrintDialogData, new_0, 0}}, + {2411, {wxPrintDialogData, new_1_1, 1}}, + {2412, {wxPrintDialogData, new_1_0, 1}}, + {2413, {wxPrintDialogData, destruct, 0}}, + {2414, {wxPrintDialogData, enableHelp, 1}}, + {2415, {wxPrintDialogData, enablePageNumbers, 1}}, + {2416, {wxPrintDialogData, enablePrintToFile, 1}}, + {2417, {wxPrintDialogData, enableSelection, 1}}, + {2418, {wxPrintDialogData, getAllPages, 0}}, + {2419, {wxPrintDialogData, getCollate, 0}}, + {2420, {wxPrintDialogData, getFromPage, 0}}, + {2421, {wxPrintDialogData, getMaxPage, 0}}, + {2422, {wxPrintDialogData, getMinPage, 0}}, + {2423, {wxPrintDialogData, getNoCopies, 0}}, + {2424, {wxPrintDialogData, getPrintData, 0}}, + {2425, {wxPrintDialogData, getPrintToFile, 0}}, + {2426, {wxPrintDialogData, getSelection, 0}}, + {2427, {wxPrintDialogData, getToPage, 0}}, + {2428, {wxPrintDialogData, isOk, 0}}, + {2429, {wxPrintDialogData, setCollate, 1}}, + {2430, {wxPrintDialogData, setFromPage, 1}}, + {2431, {wxPrintDialogData, setMaxPage, 1}}, + {2432, {wxPrintDialogData, setMinPage, 1}}, + {2433, {wxPrintDialogData, setNoCopies, 1}}, + {2434, {wxPrintDialogData, setPrintData, 1}}, + {2435, {wxPrintDialogData, setPrintToFile, 1}}, + {2436, {wxPrintDialogData, setSelection, 1}}, + {2437, {wxPrintDialogData, setToPage, 1}}, + {2438, {wxPrintData, new_0, 0}}, + {2439, {wxPrintData, new_1, 1}}, + {2440, {wxPrintData, destruct, 0}}, + {2441, {wxPrintData, getCollate, 0}}, + {2442, {wxPrintData, getBin, 0}}, + {2443, {wxPrintData, getColour, 0}}, + {2444, {wxPrintData, getDuplex, 0}}, + {2445, {wxPrintData, getNoCopies, 0}}, + {2446, {wxPrintData, getOrientation, 0}}, + {2447, {wxPrintData, getPaperId, 0}}, + {2448, {wxPrintData, getPrinterName, 0}}, + {2449, {wxPrintData, getQuality, 0}}, + {2450, {wxPrintData, isOk, 0}}, + {2451, {wxPrintData, setBin, 1}}, + {2452, {wxPrintData, setCollate, 1}}, + {2453, {wxPrintData, setColour, 1}}, + {2454, {wxPrintData, setDuplex, 1}}, + {2455, {wxPrintData, setNoCopies, 1}}, + {2456, {wxPrintData, setOrientation, 1}}, + {2457, {wxPrintData, setPaperId, 1}}, + {2458, {wxPrintData, setPrinterName, 1}}, + {2459, {wxPrintData, setQuality, 1}}, + {2462, {wxPrintPreview, new_2, 2}}, + {2463, {wxPrintPreview, new_3, 3}}, + {2465, {wxPrintPreview, destruct, 0}}, + {2466, {wxPrintPreview, getCanvas, 0}}, + {2467, {wxPrintPreview, getCurrentPage, 0}}, + {2468, {wxPrintPreview, getFrame, 0}}, + {2469, {wxPrintPreview, getMaxPage, 0}}, + {2470, {wxPrintPreview, getMinPage, 0}}, + {2471, {wxPrintPreview, getPrintout, 0}}, + {2472, {wxPrintPreview, getPrintoutForPrinting, 0}}, + {2473, {wxPrintPreview, isOk, 0}}, + {2474, {wxPrintPreview, paintPage, 2}}, + {2475, {wxPrintPreview, print, 1}}, + {2476, {wxPrintPreview, renderPage, 1}}, + {2477, {wxPrintPreview, setCanvas, 1}}, + {2478, {wxPrintPreview, setCurrentPage, 1}}, + {2479, {wxPrintPreview, setFrame, 1}}, + {2480, {wxPrintPreview, setPrintout, 1}}, + {2481, {wxPrintPreview, setZoom, 1}}, + {2482, {wxPreviewFrame, new, 3}}, + {2483, {wxPreviewFrame, destruct, 0}}, + {2484, {wxPreviewFrame, createControlBar, 0}}, + {2485, {wxPreviewFrame, createCanvas, 0}}, + {2486, {wxPreviewFrame, initialize, 0}}, + {2487, {wxPreviewFrame, onCloseWindow, 1}}, + {2488, {wxPreviewControlBar, new, 4}}, + {2489, {wxPreviewControlBar, destruct, 0}}, + {2490, {wxPreviewControlBar, createButtons, 0}}, + {2491, {wxPreviewControlBar, getPrintPreview, 0}}, + {2492, {wxPreviewControlBar, getZoomControl, 0}}, + {2493, {wxPreviewControlBar, setZoomControl, 1}}, + {2495, {wxPrinter, new, 1}}, + {2496, {wxPrinter, createAbortWindow, 2}}, + {2497, {wxPrinter, getAbort, 0}}, + {2498, {wxPrinter, getLastError, 0}}, + {2499, {wxPrinter, getPrintDialogData, 0}}, + {2500, {wxPrinter, print, 3}}, + {2501, {wxPrinter, printDialog, 1}}, + {2502, {wxPrinter, reportError, 3}}, + {2503, {wxPrinter, setup, 1}}, + {2504, {wxPrinter, 'Destroy', undefined}}, + {2505, {wxXmlResource, new_1, 1}}, + {2506, {wxXmlResource, new_2, 2}}, + {2507, {wxXmlResource, destruct, 0}}, + {2508, {wxXmlResource, attachUnknownControl, 3}}, + {2509, {wxXmlResource, clearHandlers, 0}}, + {2510, {wxXmlResource, compareVersion, 4}}, + {2511, {wxXmlResource, get, 0}}, + {2512, {wxXmlResource, getFlags, 0}}, + {2513, {wxXmlResource, getVersion, 0}}, + {2514, {wxXmlResource, getXRCID, 2}}, + {2515, {wxXmlResource, initAllHandlers, 0}}, + {2516, {wxXmlResource, load, 1}}, + {2517, {wxXmlResource, loadBitmap, 1}}, + {2518, {wxXmlResource, loadDialog_2, 2}}, + {2519, {wxXmlResource, loadDialog_3, 3}}, + {2520, {wxXmlResource, loadFrame_2, 2}}, + {2521, {wxXmlResource, loadFrame_3, 3}}, + {2522, {wxXmlResource, loadIcon, 1}}, + {2523, {wxXmlResource, loadMenu, 1}}, + {2524, {wxXmlResource, loadMenuBar_2, 2}}, + {2525, {wxXmlResource, loadMenuBar_1, 1}}, + {2526, {wxXmlResource, loadPanel_2, 2}}, + {2527, {wxXmlResource, loadPanel_3, 3}}, + {2528, {wxXmlResource, loadToolBar, 2}}, + {2529, {wxXmlResource, set, 1}}, + {2530, {wxXmlResource, setFlags, 1}}, + {2531, {wxXmlResource, unload, 1}}, + {2532, {wxXmlResource, xrcctrl, 3}}, + {2533, {wxHtmlEasyPrinting, new, 1}}, + {2534, {wxHtmlEasyPrinting, destruct, 0}}, + {2535, {wxHtmlEasyPrinting, getPrintData, 0}}, + {2536, {wxHtmlEasyPrinting, getPageSetupData, 0}}, + {2537, {wxHtmlEasyPrinting, previewFile, 1}}, + {2538, {wxHtmlEasyPrinting, previewText, 2}}, + {2539, {wxHtmlEasyPrinting, printFile, 1}}, + {2540, {wxHtmlEasyPrinting, printText, 2}}, + {2541, {wxHtmlEasyPrinting, pageSetup, 0}}, + {2542, {wxHtmlEasyPrinting, setFonts, 3}}, + {2543, {wxHtmlEasyPrinting, setHeader, 2}}, + {2544, {wxHtmlEasyPrinting, setFooter, 2}}, + {2546, {wxGLCanvas, new_2, 2}}, + {2547, {wxGLCanvas, new_3_1, 3}}, + {2548, {wxGLCanvas, new_3_0, 3}}, + {2549, {wxGLCanvas, getContext, 0}}, + {2551, {wxGLCanvas, setCurrent, 0}}, + {2552, {wxGLCanvas, swapBuffers, 0}}, + {2553, {wxGLCanvas, 'Destroy', undefined}}, + {2554, {wxAuiManager, new, 1}}, + {2555, {wxAuiManager, destruct, 0}}, + {2556, {wxAuiManager, addPane_2_1, 2}}, + {2557, {wxAuiManager, addPane_3, 3}}, + {2558, {wxAuiManager, addPane_2_0, 2}}, + {2559, {wxAuiManager, detachPane, 1}}, + {2560, {wxAuiManager, getAllPanes, 0}}, + {2561, {wxAuiManager, getArtProvider, 0}}, + {2562, {wxAuiManager, getDockSizeConstraint, 2}}, + {2563, {wxAuiManager, getFlags, 0}}, + {2564, {wxAuiManager, getManagedWindow, 0}}, + {2565, {wxAuiManager, getManager, 1}}, + {2566, {wxAuiManager, getPane_1_1, 1}}, + {2567, {wxAuiManager, getPane_1_0, 1}}, + {2568, {wxAuiManager, hideHint, 0}}, + {2569, {wxAuiManager, insertPane, 3}}, + {2570, {wxAuiManager, loadPaneInfo, 2}}, + {2571, {wxAuiManager, loadPerspective, 2}}, + {2572, {wxAuiManager, savePaneInfo, 1}}, + {2573, {wxAuiManager, savePerspective, 0}}, + {2574, {wxAuiManager, setArtProvider, 1}}, + {2575, {wxAuiManager, setDockSizeConstraint, 2}}, + {2576, {wxAuiManager, setFlags, 1}}, + {2577, {wxAuiManager, setManagedWindow, 1}}, + {2578, {wxAuiManager, showHint, 1}}, + {2579, {wxAuiManager, unInit, 0}}, + {2580, {wxAuiManager, update, 0}}, + {2581, {wxAuiPaneInfo, new_0, 0}}, + {2582, {wxAuiPaneInfo, new_1, 1}}, + {2583, {wxAuiPaneInfo, destruct, 0}}, + {2584, {wxAuiPaneInfo, bestSize_1, 1}}, + {2585, {wxAuiPaneInfo, bestSize_2, 2}}, + {2586, {wxAuiPaneInfo, bottom, 0}}, + {2587, {wxAuiPaneInfo, bottomDockable, 1}}, + {2588, {wxAuiPaneInfo, caption, 1}}, + {2589, {wxAuiPaneInfo, captionVisible, 1}}, + {2590, {wxAuiPaneInfo, centre, 0}}, + {2591, {wxAuiPaneInfo, centrePane, 0}}, + {2592, {wxAuiPaneInfo, closeButton, 1}}, + {2593, {wxAuiPaneInfo, defaultPane, 0}}, + {2594, {wxAuiPaneInfo, destroyOnClose, 1}}, + {2595, {wxAuiPaneInfo, direction, 1}}, + {2596, {wxAuiPaneInfo, dock, 0}}, + {2597, {wxAuiPaneInfo, dockable, 1}}, + {2598, {wxAuiPaneInfo, fixed, 0}}, + {2599, {wxAuiPaneInfo, float, 0}}, + {2600, {wxAuiPaneInfo, floatable, 1}}, + {2601, {wxAuiPaneInfo, floatingPosition_1, 1}}, + {2602, {wxAuiPaneInfo, floatingPosition_2, 2}}, + {2603, {wxAuiPaneInfo, floatingSize_1, 1}}, + {2604, {wxAuiPaneInfo, floatingSize_2, 2}}, + {2605, {wxAuiPaneInfo, gripper, 1}}, + {2606, {wxAuiPaneInfo, gripperTop, 1}}, + {2607, {wxAuiPaneInfo, hasBorder, 0}}, + {2608, {wxAuiPaneInfo, hasCaption, 0}}, + {2609, {wxAuiPaneInfo, hasCloseButton, 0}}, + {2610, {wxAuiPaneInfo, hasFlag, 1}}, + {2611, {wxAuiPaneInfo, hasGripper, 0}}, + {2612, {wxAuiPaneInfo, hasGripperTop, 0}}, + {2613, {wxAuiPaneInfo, hasMaximizeButton, 0}}, + {2614, {wxAuiPaneInfo, hasMinimizeButton, 0}}, + {2615, {wxAuiPaneInfo, hasPinButton, 0}}, + {2616, {wxAuiPaneInfo, hide, 0}}, + {2617, {wxAuiPaneInfo, isBottomDockable, 0}}, + {2618, {wxAuiPaneInfo, isDocked, 0}}, + {2619, {wxAuiPaneInfo, isFixed, 0}}, + {2620, {wxAuiPaneInfo, isFloatable, 0}}, + {2621, {wxAuiPaneInfo, isFloating, 0}}, + {2622, {wxAuiPaneInfo, isLeftDockable, 0}}, + {2623, {wxAuiPaneInfo, isMovable, 0}}, + {2624, {wxAuiPaneInfo, isOk, 0}}, + {2625, {wxAuiPaneInfo, isResizable, 0}}, + {2626, {wxAuiPaneInfo, isRightDockable, 0}}, + {2627, {wxAuiPaneInfo, isShown, 0}}, + {2628, {wxAuiPaneInfo, isToolbar, 0}}, + {2629, {wxAuiPaneInfo, isTopDockable, 0}}, + {2630, {wxAuiPaneInfo, layer, 1}}, + {2631, {wxAuiPaneInfo, left, 0}}, + {2632, {wxAuiPaneInfo, leftDockable, 1}}, + {2633, {wxAuiPaneInfo, maxSize_1, 1}}, + {2634, {wxAuiPaneInfo, maxSize_2, 2}}, + {2635, {wxAuiPaneInfo, maximizeButton, 1}}, + {2636, {wxAuiPaneInfo, minSize_1, 1}}, + {2637, {wxAuiPaneInfo, minSize_2, 2}}, + {2638, {wxAuiPaneInfo, minimizeButton, 1}}, + {2639, {wxAuiPaneInfo, movable, 1}}, + {2640, {wxAuiPaneInfo, name, 1}}, + {2641, {wxAuiPaneInfo, paneBorder, 1}}, + {2642, {wxAuiPaneInfo, pinButton, 1}}, + {2643, {wxAuiPaneInfo, position, 1}}, + {2644, {wxAuiPaneInfo, resizable, 1}}, + {2645, {wxAuiPaneInfo, right, 0}}, + {2646, {wxAuiPaneInfo, rightDockable, 1}}, + {2647, {wxAuiPaneInfo, row, 1}}, + {2648, {wxAuiPaneInfo, safeSet, 1}}, + {2649, {wxAuiPaneInfo, setFlag, 2}}, + {2650, {wxAuiPaneInfo, show, 1}}, + {2651, {wxAuiPaneInfo, toolbarPane, 0}}, + {2652, {wxAuiPaneInfo, top, 0}}, + {2653, {wxAuiPaneInfo, topDockable, 1}}, + {2654, {wxAuiPaneInfo, window, 1}}, + {2655, {wxAuiPaneInfo, getWindow, 0}}, + {2656, {wxAuiPaneInfo, getFrame, 0}}, + {2657, {wxAuiPaneInfo, getDirection, 0}}, + {2658, {wxAuiPaneInfo, getLayer, 0}}, + {2659, {wxAuiPaneInfo, getRow, 0}}, + {2660, {wxAuiPaneInfo, getPosition, 0}}, + {2661, {wxAuiPaneInfo, getFloatingPosition, 0}}, + {2662, {wxAuiPaneInfo, getFloatingSize, 0}}, + {2663, {wxAuiNotebook, new_0, 0}}, + {2664, {wxAuiNotebook, new_2, 2}}, + {2665, {wxAuiNotebook, addPage, 3}}, + {2666, {wxAuiNotebook, create, 2}}, + {2667, {wxAuiNotebook, deletePage, 1}}, + {2668, {wxAuiNotebook, getArtProvider, 0}}, + {2669, {wxAuiNotebook, getPage, 1}}, + {2670, {wxAuiNotebook, getPageBitmap, 1}}, + {2671, {wxAuiNotebook, getPageCount, 0}}, + {2672, {wxAuiNotebook, getPageIndex, 1}}, + {2673, {wxAuiNotebook, getPageText, 1}}, + {2674, {wxAuiNotebook, getSelection, 0}}, + {2675, {wxAuiNotebook, insertPage, 4}}, + {2676, {wxAuiNotebook, removePage, 1}}, + {2677, {wxAuiNotebook, setArtProvider, 1}}, + {2678, {wxAuiNotebook, setFont, 1}}, + {2679, {wxAuiNotebook, setPageBitmap, 2}}, + {2680, {wxAuiNotebook, setPageText, 2}}, + {2681, {wxAuiNotebook, setSelection, 1}}, + {2682, {wxAuiNotebook, setTabCtrlHeight, 1}}, + {2683, {wxAuiNotebook, setUniformBitmapSize, 1}}, + {2684, {wxAuiNotebook, 'Destroy', undefined}}, + {2685, {wxAuiTabArt, setFlags, 1}}, + {2686, {wxAuiTabArt, setMeasuringFont, 1}}, + {2687, {wxAuiTabArt, setNormalFont, 1}}, + {2688, {wxAuiTabArt, setSelectedFont, 1}}, + {2689, {wxAuiTabArt, setColour, 1}}, + {2690, {wxAuiTabArt, setActiveColour, 1}}, + {2691, {wxAuiDockArt, getColour, 1}}, + {2692, {wxAuiDockArt, getFont, 1}}, + {2693, {wxAuiDockArt, getMetric, 1}}, + {2694, {wxAuiDockArt, setColour, 2}}, + {2695, {wxAuiDockArt, setFont, 2}}, + {2696, {wxAuiDockArt, setMetric, 2}}, + {2697, {wxAuiSimpleTabArt, new, 0}}, + {2698, {wxAuiSimpleTabArt, 'Destroy', undefined}}, + {2699, {wxMDIParentFrame, new_0, 0}}, + {2700, {wxMDIParentFrame, new_4, 4}}, + {2701, {wxMDIParentFrame, destruct, 0}}, + {2702, {wxMDIParentFrame, activateNext, 0}}, + {2703, {wxMDIParentFrame, activatePrevious, 0}}, + {2704, {wxMDIParentFrame, arrangeIcons, 0}}, + {2705, {wxMDIParentFrame, cascade, 0}}, + {2706, {wxMDIParentFrame, create, 4}}, + {2707, {wxMDIParentFrame, getActiveChild, 0}}, + {2708, {wxMDIParentFrame, getClientWindow, 0}}, + {2709, {wxMDIParentFrame, tile, 1}}, + {2710, {wxMDIChildFrame, new_0, 0}}, + {2711, {wxMDIChildFrame, new_4, 4}}, + {2712, {wxMDIChildFrame, destruct, 0}}, + {2713, {wxMDIChildFrame, activate, 0}}, + {2714, {wxMDIChildFrame, create, 4}}, + {2715, {wxMDIChildFrame, maximize, 1}}, + {2716, {wxMDIChildFrame, restore, 0}}, + {2717, {wxMDIClientWindow, new_0, 0}}, + {2718, {wxMDIClientWindow, new_2, 2}}, + {2719, {wxMDIClientWindow, destruct, 0}}, + {2720, {wxMDIClientWindow, createClient, 2}}, + {2721, {wxLayoutAlgorithm, new, 0}}, + {2722, {wxLayoutAlgorithm, layoutFrame, 2}}, + {2723, {wxLayoutAlgorithm, layoutMDIFrame, 2}}, + {2724, {wxLayoutAlgorithm, layoutWindow, 2}}, + {2725, {wxLayoutAlgorithm, 'Destroy', undefined}}, + {2726, {wxEvent, getId, 0}}, + {2727, {wxEvent, getSkipped, 0}}, + {2728, {wxEvent, getTimestamp, 0}}, + {2729, {wxEvent, isCommandEvent, 0}}, + {2730, {wxEvent, resumePropagation, 1}}, + {2731, {wxEvent, shouldPropagate, 0}}, + {2732, {wxEvent, skip, 1}}, + {2733, {wxEvent, stopPropagation, 0}}, + {2734, {wxCommandEvent, getClientData, 0}}, + {2735, {wxCommandEvent, getExtraLong, 0}}, + {2736, {wxCommandEvent, getInt, 0}}, + {2737, {wxCommandEvent, getSelection, 0}}, + {2738, {wxCommandEvent, getString, 0}}, + {2739, {wxCommandEvent, isChecked, 0}}, + {2740, {wxCommandEvent, isSelection, 0}}, + {2741, {wxCommandEvent, setInt, 1}}, + {2742, {wxCommandEvent, setString, 1}}, + {2743, {wxScrollEvent, getOrientation, 0}}, + {2744, {wxScrollEvent, getPosition, 0}}, + {2745, {wxScrollWinEvent, getOrientation, 0}}, + {2746, {wxScrollWinEvent, getPosition, 0}}, + {2747, {wxMouseEvent, altDown, 0}}, + {2748, {wxMouseEvent, button, 1}}, + {2749, {wxMouseEvent, buttonDClick, 1}}, + {2750, {wxMouseEvent, buttonDown, 1}}, + {2751, {wxMouseEvent, buttonUp, 1}}, + {2752, {wxMouseEvent, cmdDown, 0}}, + {2753, {wxMouseEvent, controlDown, 0}}, + {2754, {wxMouseEvent, dragging, 0}}, + {2755, {wxMouseEvent, entering, 0}}, + {2756, {wxMouseEvent, getButton, 0}}, + {2759, {wxMouseEvent, getPosition, 0}}, + {2760, {wxMouseEvent, getLogicalPosition, 1}}, + {2761, {wxMouseEvent, getLinesPerAction, 0}}, + {2762, {wxMouseEvent, getWheelRotation, 0}}, + {2763, {wxMouseEvent, getWheelDelta, 0}}, + {2764, {wxMouseEvent, getX, 0}}, + {2765, {wxMouseEvent, getY, 0}}, + {2766, {wxMouseEvent, isButton, 0}}, + {2767, {wxMouseEvent, isPageScroll, 0}}, + {2768, {wxMouseEvent, leaving, 0}}, + {2769, {wxMouseEvent, leftDClick, 0}}, + {2770, {wxMouseEvent, leftDown, 0}}, + {2771, {wxMouseEvent, leftIsDown, 0}}, + {2772, {wxMouseEvent, leftUp, 0}}, + {2773, {wxMouseEvent, metaDown, 0}}, + {2774, {wxMouseEvent, middleDClick, 0}}, + {2775, {wxMouseEvent, middleDown, 0}}, + {2776, {wxMouseEvent, middleIsDown, 0}}, + {2777, {wxMouseEvent, middleUp, 0}}, + {2778, {wxMouseEvent, moving, 0}}, + {2779, {wxMouseEvent, rightDClick, 0}}, + {2780, {wxMouseEvent, rightDown, 0}}, + {2781, {wxMouseEvent, rightIsDown, 0}}, + {2782, {wxMouseEvent, rightUp, 0}}, + {2783, {wxMouseEvent, shiftDown, 0}}, + {2784, {wxSetCursorEvent, getCursor, 0}}, + {2785, {wxSetCursorEvent, getX, 0}}, + {2786, {wxSetCursorEvent, getY, 0}}, + {2787, {wxSetCursorEvent, hasCursor, 0}}, + {2788, {wxSetCursorEvent, setCursor, 1}}, + {2789, {wxKeyEvent, altDown, 0}}, + {2790, {wxKeyEvent, cmdDown, 0}}, + {2791, {wxKeyEvent, controlDown, 0}}, + {2792, {wxKeyEvent, getKeyCode, 0}}, + {2793, {wxKeyEvent, getModifiers, 0}}, + {2796, {wxKeyEvent, getPosition, 0}}, + {2797, {wxKeyEvent, getRawKeyCode, 0}}, + {2798, {wxKeyEvent, getRawKeyFlags, 0}}, + {2799, {wxKeyEvent, getUnicodeKey, 0}}, + {2800, {wxKeyEvent, getX, 0}}, + {2801, {wxKeyEvent, getY, 0}}, + {2802, {wxKeyEvent, hasModifiers, 0}}, + {2803, {wxKeyEvent, metaDown, 0}}, + {2804, {wxKeyEvent, shiftDown, 0}}, + {2805, {wxSizeEvent, getSize, 0}}, + {2806, {wxMoveEvent, getPosition, 0}}, + {2807, {wxEraseEvent, getDC, 0}}, + {2808, {wxFocusEvent, getWindow, 0}}, + {2809, {wxChildFocusEvent, getWindow, 0}}, + {2810, {wxMenuEvent, getMenu, 0}}, + {2811, {wxMenuEvent, getMenuId, 0}}, + {2812, {wxMenuEvent, isPopup, 0}}, + {2813, {wxCloseEvent, canVeto, 0}}, + {2814, {wxCloseEvent, getLoggingOff, 0}}, + {2815, {wxCloseEvent, setCanVeto, 1}}, + {2816, {wxCloseEvent, setLoggingOff, 1}}, + {2817, {wxCloseEvent, veto, 1}}, + {2818, {wxShowEvent, setShow, 1}}, + {2819, {wxShowEvent, getShow, 0}}, + {2820, {wxIconizeEvent, iconized, 0}}, + {2821, {wxJoystickEvent, buttonDown, 1}}, + {2822, {wxJoystickEvent, buttonIsDown, 1}}, + {2823, {wxJoystickEvent, buttonUp, 1}}, + {2824, {wxJoystickEvent, getButtonChange, 0}}, + {2825, {wxJoystickEvent, getButtonState, 0}}, + {2826, {wxJoystickEvent, getJoystick, 0}}, + {2827, {wxJoystickEvent, getPosition, 0}}, + {2828, {wxJoystickEvent, getZPosition, 0}}, + {2829, {wxJoystickEvent, isButton, 0}}, + {2830, {wxJoystickEvent, isMove, 0}}, + {2831, {wxJoystickEvent, isZMove, 0}}, + {2832, {wxUpdateUIEvent, canUpdate, 1}}, + {2833, {wxUpdateUIEvent, check, 1}}, + {2834, {wxUpdateUIEvent, enable, 1}}, + {2835, {wxUpdateUIEvent, show, 1}}, + {2836, {wxUpdateUIEvent, getChecked, 0}}, + {2837, {wxUpdateUIEvent, getEnabled, 0}}, + {2838, {wxUpdateUIEvent, getShown, 0}}, + {2839, {wxUpdateUIEvent, getSetChecked, 0}}, + {2840, {wxUpdateUIEvent, getSetEnabled, 0}}, + {2841, {wxUpdateUIEvent, getSetShown, 0}}, + {2842, {wxUpdateUIEvent, getSetText, 0}}, + {2843, {wxUpdateUIEvent, getText, 0}}, + {2844, {wxUpdateUIEvent, getMode, 0}}, + {2845, {wxUpdateUIEvent, getUpdateInterval, 0}}, + {2846, {wxUpdateUIEvent, resetUpdateTime, 0}}, + {2847, {wxUpdateUIEvent, setMode, 1}}, + {2848, {wxUpdateUIEvent, setText, 1}}, + {2849, {wxUpdateUIEvent, setUpdateInterval, 1}}, + {2850, {wxMouseCaptureChangedEvent, getCapturedWindow, 0}}, + {2851, {wxPaletteChangedEvent, setChangedWindow, 1}}, + {2852, {wxPaletteChangedEvent, getChangedWindow, 0}}, + {2853, {wxQueryNewPaletteEvent, setPaletteRealized, 1}}, + {2854, {wxQueryNewPaletteEvent, getPaletteRealized, 0}}, + {2855, {wxNavigationKeyEvent, getDirection, 0}}, + {2856, {wxNavigationKeyEvent, setDirection, 1}}, + {2857, {wxNavigationKeyEvent, isWindowChange, 0}}, + {2858, {wxNavigationKeyEvent, setWindowChange, 1}}, + {2859, {wxNavigationKeyEvent, isFromTab, 0}}, + {2860, {wxNavigationKeyEvent, setFromTab, 1}}, + {2861, {wxNavigationKeyEvent, getCurrentFocus, 0}}, + {2862, {wxNavigationKeyEvent, setCurrentFocus, 1}}, + {2863, {wxHelpEvent, getOrigin, 0}}, + {2864, {wxHelpEvent, getPosition, 0}}, + {2865, {wxHelpEvent, setOrigin, 1}}, + {2866, {wxHelpEvent, setPosition, 1}}, + {2867, {wxContextMenuEvent, getPosition, 0}}, + {2868, {wxContextMenuEvent, setPosition, 1}}, + {2869, {wxIdleEvent, canSend, 1}}, + {2870, {wxIdleEvent, getMode, 0}}, + {2871, {wxIdleEvent, requestMore, 1}}, + {2872, {wxIdleEvent, moreRequested, 0}}, + {2873, {wxIdleEvent, setMode, 1}}, + {2874, {wxGridEvent, altDown, 0}}, + {2875, {wxGridEvent, controlDown, 0}}, + {2876, {wxGridEvent, getCol, 0}}, + {2877, {wxGridEvent, getPosition, 0}}, + {2878, {wxGridEvent, getRow, 0}}, + {2879, {wxGridEvent, metaDown, 0}}, + {2880, {wxGridEvent, selecting, 0}}, + {2881, {wxGridEvent, shiftDown, 0}}, + {2882, {wxNotifyEvent, allow, 0}}, + {2883, {wxNotifyEvent, isAllowed, 0}}, + {2884, {wxNotifyEvent, veto, 0}}, + {2885, {wxSashEvent, getEdge, 0}}, + {2886, {wxSashEvent, getDragRect, 0}}, + {2887, {wxSashEvent, getDragStatus, 0}}, + {2888, {wxListEvent, getCacheFrom, 0}}, + {2889, {wxListEvent, getCacheTo, 0}}, + {2890, {wxListEvent, getKeyCode, 0}}, + {2891, {wxListEvent, getIndex, 0}}, + {2892, {wxListEvent, getColumn, 0}}, + {2893, {wxListEvent, getPoint, 0}}, + {2894, {wxListEvent, getLabel, 0}}, + {2895, {wxListEvent, getText, 0}}, + {2896, {wxListEvent, getImage, 0}}, + {2897, {wxListEvent, getData, 0}}, + {2898, {wxListEvent, getMask, 0}}, + {2899, {wxListEvent, getItem, 0}}, + {2900, {wxListEvent, isEditCancelled, 0}}, + {2901, {wxDateEvent, getDate, 0}}, + {2902, {wxCalendarEvent, getWeekDay, 0}}, + {2903, {wxFileDirPickerEvent, getPath, 0}}, + {2904, {wxColourPickerEvent, getColour, 0}}, + {2905, {wxFontPickerEvent, getFont, 0}}, + {2906, {wxStyledTextEvent, getPosition, 0}}, + {2907, {wxStyledTextEvent, getKey, 0}}, + {2908, {wxStyledTextEvent, getModifiers, 0}}, + {2909, {wxStyledTextEvent, getModificationType, 0}}, + {2910, {wxStyledTextEvent, getText, 0}}, + {2911, {wxStyledTextEvent, getLength, 0}}, + {2912, {wxStyledTextEvent, getLinesAdded, 0}}, + {2913, {wxStyledTextEvent, getLine, 0}}, + {2914, {wxStyledTextEvent, getFoldLevelNow, 0}}, + {2915, {wxStyledTextEvent, getFoldLevelPrev, 0}}, + {2916, {wxStyledTextEvent, getMargin, 0}}, + {2917, {wxStyledTextEvent, getMessage, 0}}, + {2918, {wxStyledTextEvent, getWParam, 0}}, + {2919, {wxStyledTextEvent, getLParam, 0}}, + {2920, {wxStyledTextEvent, getListType, 0}}, + {2921, {wxStyledTextEvent, getX, 0}}, + {2922, {wxStyledTextEvent, getY, 0}}, + {2923, {wxStyledTextEvent, getDragText, 0}}, + {2924, {wxStyledTextEvent, getDragAllowMove, 0}}, + {2925, {wxStyledTextEvent, getDragResult, 0}}, + {2926, {wxStyledTextEvent, getShift, 0}}, + {2927, {wxStyledTextEvent, getControl, 0}}, + {2928, {wxStyledTextEvent, getAlt, 0}}, + {2929, {utils, getKeyState, 1}}, + {2930, {utils, getMousePosition, 2}}, + {2931, {utils, getMouseState, 0}}, + {2932, {utils, setDetectableAutoRepeat, 1}}, + {2933, {utils, bell, 0}}, + {2934, {utils, findMenuItemId, 3}}, + {2935, {utils, genericFindWindowAtPoint, 1}}, + {2936, {utils, findWindowAtPoint, 1}}, + {2937, {utils, beginBusyCursor, 1}}, + {2938, {utils, endBusyCursor, 0}}, + {2939, {utils, isBusy, 0}}, + {2940, {utils, shutdown, 1}}, + {2941, {utils, shell, 1}}, + {2942, {utils, launchDefaultBrowser, 2}}, + {2943, {utils, getEmailAddress, 0}}, + {2944, {utils, getUserId, 0}}, + {2945, {utils, getHomeDir, 0}}, + {2946, {utils, newId, 0}}, + {2947, {utils, registerId, 1}}, + {2948, {utils, getCurrentId, 0}}, + {2949, {utils, getOsDescription, 0}}, + {2950, {utils, isPlatformLittleEndian, 0}}, + {2951, {utils, isPlatform64Bit, 0}}, + {2952, {gdicmn, displaySize, 2}}, + {2953, {gdicmn, setCursor, 1}}, + {2954, {wxPrintout, new, 1}}, + {2955, {wxPrintout, destruct, 0}}, + {2956, {wxPrintout, getDC, 0}}, + {2957, {wxPrintout, getPageSizeMM, 2}}, + {2958, {wxPrintout, getPageSizePixels, 2}}, + {2959, {wxPrintout, getPaperRectPixels, 0}}, + {2960, {wxPrintout, getPPIPrinter, 2}}, + {2961, {wxPrintout, getPPIScreen, 2}}, + {2962, {wxPrintout, getTitle, 0}}, + {2963, {wxPrintout, isPreview, 0}}, + {2964, {wxPrintout, fitThisSizeToPaper, 1}}, + {2965, {wxPrintout, fitThisSizeToPage, 1}}, + {2966, {wxPrintout, fitThisSizeToPageMargins, 2}}, + {2967, {wxPrintout, mapScreenSizeToPaper, 0}}, + {2968, {wxPrintout, mapScreenSizeToPage, 0}}, + {2969, {wxPrintout, mapScreenSizeToPageMargins, 1}}, + {2970, {wxPrintout, mapScreenSizeToDevice, 0}}, + {2971, {wxPrintout, getLogicalPaperRect, 0}}, + {2972, {wxPrintout, getLogicalPageRect, 0}}, + {2973, {wxPrintout, getLogicalPageMarginsRect, 1}}, + {2974, {wxPrintout, setLogicalOrigin, 2}}, + {2975, {wxPrintout, offsetLogicalOrigin, 2}}, + {2976, {wxStyledTextCtrl, new_2, 2}}, + {2977, {wxStyledTextCtrl, new_0, 0}}, + {2978, {wxStyledTextCtrl, destruct, 0}}, + {2979, {wxStyledTextCtrl, create, 2}}, + {2980, {wxStyledTextCtrl, addText, 1}}, + {2981, {wxStyledTextCtrl, addStyledText, 1}}, + {2982, {wxStyledTextCtrl, insertText, 2}}, + {2983, {wxStyledTextCtrl, clearAll, 0}}, + {2984, {wxStyledTextCtrl, clearDocumentStyle, 0}}, + {2985, {wxStyledTextCtrl, getLength, 0}}, + {2986, {wxStyledTextCtrl, getCharAt, 1}}, + {2987, {wxStyledTextCtrl, getCurrentPos, 0}}, + {2988, {wxStyledTextCtrl, getAnchor, 0}}, + {2989, {wxStyledTextCtrl, getStyleAt, 1}}, + {2990, {wxStyledTextCtrl, redo, 0}}, + {2991, {wxStyledTextCtrl, setUndoCollection, 1}}, + {2992, {wxStyledTextCtrl, selectAll, 0}}, + {2993, {wxStyledTextCtrl, setSavePoint, 0}}, + {2994, {wxStyledTextCtrl, getStyledText, 2}}, + {2995, {wxStyledTextCtrl, canRedo, 0}}, + {2996, {wxStyledTextCtrl, markerLineFromHandle, 1}}, + {2997, {wxStyledTextCtrl, markerDeleteHandle, 1}}, + {2998, {wxStyledTextCtrl, getUndoCollection, 0}}, + {2999, {wxStyledTextCtrl, getViewWhiteSpace, 0}}, + {3000, {wxStyledTextCtrl, setViewWhiteSpace, 1}}, + {3001, {wxStyledTextCtrl, positionFromPoint, 1}}, + {3002, {wxStyledTextCtrl, positionFromPointClose, 2}}, + {3003, {wxStyledTextCtrl, gotoLine, 1}}, + {3004, {wxStyledTextCtrl, gotoPos, 1}}, + {3005, {wxStyledTextCtrl, setAnchor, 1}}, + {3006, {wxStyledTextCtrl, getCurLine, 1}}, + {3007, {wxStyledTextCtrl, getEndStyled, 0}}, + {3008, {wxStyledTextCtrl, convertEOLs, 1}}, + {3009, {wxStyledTextCtrl, getEOLMode, 0}}, + {3010, {wxStyledTextCtrl, setEOLMode, 1}}, + {3011, {wxStyledTextCtrl, startStyling, 2}}, + {3012, {wxStyledTextCtrl, setStyling, 2}}, + {3013, {wxStyledTextCtrl, getBufferedDraw, 0}}, + {3014, {wxStyledTextCtrl, setBufferedDraw, 1}}, + {3015, {wxStyledTextCtrl, setTabWidth, 1}}, + {3016, {wxStyledTextCtrl, getTabWidth, 0}}, + {3017, {wxStyledTextCtrl, setCodePage, 1}}, + {3018, {wxStyledTextCtrl, markerDefine, 3}}, + {3019, {wxStyledTextCtrl, markerSetForeground, 2}}, + {3020, {wxStyledTextCtrl, markerSetBackground, 2}}, + {3021, {wxStyledTextCtrl, markerAdd, 2}}, + {3022, {wxStyledTextCtrl, markerDelete, 2}}, + {3023, {wxStyledTextCtrl, markerDeleteAll, 1}}, + {3024, {wxStyledTextCtrl, markerGet, 1}}, + {3025, {wxStyledTextCtrl, markerNext, 2}}, + {3026, {wxStyledTextCtrl, markerPrevious, 2}}, + {3027, {wxStyledTextCtrl, markerDefineBitmap, 2}}, + {3028, {wxStyledTextCtrl, markerAddSet, 2}}, + {3029, {wxStyledTextCtrl, markerSetAlpha, 2}}, + {3030, {wxStyledTextCtrl, setMarginType, 2}}, + {3031, {wxStyledTextCtrl, getMarginType, 1}}, + {3032, {wxStyledTextCtrl, setMarginWidth, 2}}, + {3033, {wxStyledTextCtrl, getMarginWidth, 1}}, + {3034, {wxStyledTextCtrl, setMarginMask, 2}}, + {3035, {wxStyledTextCtrl, getMarginMask, 1}}, + {3036, {wxStyledTextCtrl, setMarginSensitive, 2}}, + {3037, {wxStyledTextCtrl, getMarginSensitive, 1}}, + {3038, {wxStyledTextCtrl, styleClearAll, 0}}, + {3039, {wxStyledTextCtrl, styleSetForeground, 2}}, + {3040, {wxStyledTextCtrl, styleSetBackground, 2}}, + {3041, {wxStyledTextCtrl, styleSetBold, 2}}, + {3042, {wxStyledTextCtrl, styleSetItalic, 2}}, + {3043, {wxStyledTextCtrl, styleSetSize, 2}}, + {3044, {wxStyledTextCtrl, styleSetFaceName, 2}}, + {3045, {wxStyledTextCtrl, styleSetEOLFilled, 2}}, + {3046, {wxStyledTextCtrl, styleResetDefault, 0}}, + {3047, {wxStyledTextCtrl, styleSetUnderline, 2}}, + {3048, {wxStyledTextCtrl, styleSetCase, 2}}, + {3049, {wxStyledTextCtrl, styleSetHotSpot, 2}}, + {3050, {wxStyledTextCtrl, setSelForeground, 2}}, + {3051, {wxStyledTextCtrl, setSelBackground, 2}}, + {3052, {wxStyledTextCtrl, getSelAlpha, 0}}, + {3053, {wxStyledTextCtrl, setSelAlpha, 1}}, + {3054, {wxStyledTextCtrl, setCaretForeground, 1}}, + {3055, {wxStyledTextCtrl, cmdKeyAssign, 3}}, + {3056, {wxStyledTextCtrl, cmdKeyClear, 2}}, + {3057, {wxStyledTextCtrl, cmdKeyClearAll, 0}}, + {3058, {wxStyledTextCtrl, setStyleBytes, 2}}, + {3059, {wxStyledTextCtrl, styleSetVisible, 2}}, + {3060, {wxStyledTextCtrl, getCaretPeriod, 0}}, + {3061, {wxStyledTextCtrl, setCaretPeriod, 1}}, + {3062, {wxStyledTextCtrl, setWordChars, 1}}, + {3063, {wxStyledTextCtrl, beginUndoAction, 0}}, + {3064, {wxStyledTextCtrl, endUndoAction, 0}}, + {3065, {wxStyledTextCtrl, indicatorSetStyle, 2}}, + {3066, {wxStyledTextCtrl, indicatorGetStyle, 1}}, + {3067, {wxStyledTextCtrl, indicatorSetForeground, 2}}, + {3068, {wxStyledTextCtrl, indicatorGetForeground, 1}}, + {3069, {wxStyledTextCtrl, setWhitespaceForeground, 2}}, + {3070, {wxStyledTextCtrl, setWhitespaceBackground, 2}}, + {3071, {wxStyledTextCtrl, getStyleBits, 0}}, + {3072, {wxStyledTextCtrl, setLineState, 2}}, + {3073, {wxStyledTextCtrl, getLineState, 1}}, + {3074, {wxStyledTextCtrl, getMaxLineState, 0}}, + {3075, {wxStyledTextCtrl, getCaretLineVisible, 0}}, + {3076, {wxStyledTextCtrl, setCaretLineVisible, 1}}, + {3077, {wxStyledTextCtrl, getCaretLineBackground, 0}}, + {3078, {wxStyledTextCtrl, setCaretLineBackground, 1}}, + {3079, {wxStyledTextCtrl, autoCompShow, 2}}, + {3080, {wxStyledTextCtrl, autoCompCancel, 0}}, + {3081, {wxStyledTextCtrl, autoCompActive, 0}}, + {3082, {wxStyledTextCtrl, autoCompPosStart, 0}}, + {3083, {wxStyledTextCtrl, autoCompComplete, 0}}, + {3084, {wxStyledTextCtrl, autoCompStops, 1}}, + {3085, {wxStyledTextCtrl, autoCompSetSeparator, 1}}, + {3086, {wxStyledTextCtrl, autoCompGetSeparator, 0}}, + {3087, {wxStyledTextCtrl, autoCompSelect, 1}}, + {3088, {wxStyledTextCtrl, autoCompSetCancelAtStart, 1}}, + {3089, {wxStyledTextCtrl, autoCompGetCancelAtStart, 0}}, + {3090, {wxStyledTextCtrl, autoCompSetFillUps, 1}}, + {3091, {wxStyledTextCtrl, autoCompSetChooseSingle, 1}}, + {3092, {wxStyledTextCtrl, autoCompGetChooseSingle, 0}}, + {3093, {wxStyledTextCtrl, autoCompSetIgnoreCase, 1}}, + {3094, {wxStyledTextCtrl, autoCompGetIgnoreCase, 0}}, + {3095, {wxStyledTextCtrl, userListShow, 2}}, + {3096, {wxStyledTextCtrl, autoCompSetAutoHide, 1}}, + {3097, {wxStyledTextCtrl, autoCompGetAutoHide, 0}}, + {3098, {wxStyledTextCtrl, autoCompSetDropRestOfWord, 1}}, + {3099, {wxStyledTextCtrl, autoCompGetDropRestOfWord, 0}}, + {3100, {wxStyledTextCtrl, registerImage, 2}}, + {3101, {wxStyledTextCtrl, clearRegisteredImages, 0}}, + {3102, {wxStyledTextCtrl, autoCompGetTypeSeparator, 0}}, + {3103, {wxStyledTextCtrl, autoCompSetTypeSeparator, 1}}, + {3104, {wxStyledTextCtrl, autoCompSetMaxWidth, 1}}, + {3105, {wxStyledTextCtrl, autoCompGetMaxWidth, 0}}, + {3106, {wxStyledTextCtrl, autoCompSetMaxHeight, 1}}, + {3107, {wxStyledTextCtrl, autoCompGetMaxHeight, 0}}, + {3108, {wxStyledTextCtrl, setIndent, 1}}, + {3109, {wxStyledTextCtrl, getIndent, 0}}, + {3110, {wxStyledTextCtrl, setUseTabs, 1}}, + {3111, {wxStyledTextCtrl, getUseTabs, 0}}, + {3112, {wxStyledTextCtrl, setLineIndentation, 2}}, + {3113, {wxStyledTextCtrl, getLineIndentation, 1}}, + {3114, {wxStyledTextCtrl, getLineIndentPosition, 1}}, + {3115, {wxStyledTextCtrl, getColumn, 1}}, + {3116, {wxStyledTextCtrl, setUseHorizontalScrollBar, 1}}, + {3117, {wxStyledTextCtrl, getUseHorizontalScrollBar, 0}}, + {3118, {wxStyledTextCtrl, setIndentationGuides, 1}}, + {3119, {wxStyledTextCtrl, getIndentationGuides, 0}}, + {3120, {wxStyledTextCtrl, setHighlightGuide, 1}}, + {3121, {wxStyledTextCtrl, getHighlightGuide, 0}}, + {3122, {wxStyledTextCtrl, getLineEndPosition, 1}}, + {3123, {wxStyledTextCtrl, getCodePage, 0}}, + {3124, {wxStyledTextCtrl, getCaretForeground, 0}}, + {3125, {wxStyledTextCtrl, getReadOnly, 0}}, + {3126, {wxStyledTextCtrl, setCurrentPos, 1}}, + {3127, {wxStyledTextCtrl, setSelectionStart, 1}}, + {3128, {wxStyledTextCtrl, getSelectionStart, 0}}, + {3129, {wxStyledTextCtrl, setSelectionEnd, 1}}, + {3130, {wxStyledTextCtrl, getSelectionEnd, 0}}, + {3131, {wxStyledTextCtrl, setPrintMagnification, 1}}, + {3132, {wxStyledTextCtrl, getPrintMagnification, 0}}, + {3133, {wxStyledTextCtrl, setPrintColourMode, 1}}, + {3134, {wxStyledTextCtrl, getPrintColourMode, 0}}, + {3135, {wxStyledTextCtrl, findText, 4}}, + {3136, {wxStyledTextCtrl, formatRange, 7}}, + {3137, {wxStyledTextCtrl, getFirstVisibleLine, 0}}, + {3138, {wxStyledTextCtrl, getLine, 1}}, + {3139, {wxStyledTextCtrl, getLineCount, 0}}, + {3140, {wxStyledTextCtrl, setMarginLeft, 1}}, + {3141, {wxStyledTextCtrl, getMarginLeft, 0}}, + {3142, {wxStyledTextCtrl, setMarginRight, 1}}, + {3143, {wxStyledTextCtrl, getMarginRight, 0}}, + {3144, {wxStyledTextCtrl, getModify, 0}}, + {3145, {wxStyledTextCtrl, setSelection, 2}}, + {3146, {wxStyledTextCtrl, getSelectedText, 0}}, + {3147, {wxStyledTextCtrl, getTextRange, 2}}, + {3148, {wxStyledTextCtrl, hideSelection, 1}}, + {3149, {wxStyledTextCtrl, lineFromPosition, 1}}, + {3150, {wxStyledTextCtrl, positionFromLine, 1}}, + {3151, {wxStyledTextCtrl, lineScroll, 2}}, + {3152, {wxStyledTextCtrl, ensureCaretVisible, 0}}, + {3153, {wxStyledTextCtrl, replaceSelection, 1}}, + {3154, {wxStyledTextCtrl, setReadOnly, 1}}, + {3155, {wxStyledTextCtrl, canPaste, 0}}, + {3156, {wxStyledTextCtrl, canUndo, 0}}, + {3157, {wxStyledTextCtrl, emptyUndoBuffer, 0}}, + {3158, {wxStyledTextCtrl, undo, 0}}, + {3159, {wxStyledTextCtrl, cut, 0}}, + {3160, {wxStyledTextCtrl, copy, 0}}, + {3161, {wxStyledTextCtrl, paste, 0}}, + {3162, {wxStyledTextCtrl, clear, 0}}, + {3163, {wxStyledTextCtrl, setText, 1}}, + {3164, {wxStyledTextCtrl, getText, 0}}, + {3165, {wxStyledTextCtrl, getTextLength, 0}}, + {3166, {wxStyledTextCtrl, getOvertype, 0}}, + {3167, {wxStyledTextCtrl, setCaretWidth, 1}}, + {3168, {wxStyledTextCtrl, getCaretWidth, 0}}, + {3169, {wxStyledTextCtrl, setTargetStart, 1}}, + {3170, {wxStyledTextCtrl, getTargetStart, 0}}, + {3171, {wxStyledTextCtrl, setTargetEnd, 1}}, + {3172, {wxStyledTextCtrl, getTargetEnd, 0}}, + {3173, {wxStyledTextCtrl, replaceTarget, 1}}, + {3174, {wxStyledTextCtrl, searchInTarget, 1}}, + {3175, {wxStyledTextCtrl, setSearchFlags, 1}}, + {3176, {wxStyledTextCtrl, getSearchFlags, 0}}, + {3177, {wxStyledTextCtrl, callTipShow, 2}}, + {3178, {wxStyledTextCtrl, callTipCancel, 0}}, + {3179, {wxStyledTextCtrl, callTipActive, 0}}, + {3180, {wxStyledTextCtrl, callTipPosAtStart, 0}}, + {3181, {wxStyledTextCtrl, callTipSetHighlight, 2}}, + {3182, {wxStyledTextCtrl, callTipSetBackground, 1}}, + {3183, {wxStyledTextCtrl, callTipSetForeground, 1}}, + {3184, {wxStyledTextCtrl, callTipSetForegroundHighlight, 1}}, + {3185, {wxStyledTextCtrl, callTipUseStyle, 1}}, + {3186, {wxStyledTextCtrl, visibleFromDocLine, 1}}, + {3187, {wxStyledTextCtrl, docLineFromVisible, 1}}, + {3188, {wxStyledTextCtrl, wrapCount, 1}}, + {3189, {wxStyledTextCtrl, setFoldLevel, 2}}, + {3190, {wxStyledTextCtrl, getFoldLevel, 1}}, + {3191, {wxStyledTextCtrl, getLastChild, 2}}, + {3192, {wxStyledTextCtrl, getFoldParent, 1}}, + {3193, {wxStyledTextCtrl, showLines, 2}}, + {3194, {wxStyledTextCtrl, hideLines, 2}}, + {3195, {wxStyledTextCtrl, getLineVisible, 1}}, + {3196, {wxStyledTextCtrl, setFoldExpanded, 2}}, + {3197, {wxStyledTextCtrl, getFoldExpanded, 1}}, + {3198, {wxStyledTextCtrl, toggleFold, 1}}, + {3199, {wxStyledTextCtrl, ensureVisible, 1}}, + {3200, {wxStyledTextCtrl, setFoldFlags, 1}}, + {3201, {wxStyledTextCtrl, ensureVisibleEnforcePolicy, 1}}, + {3202, {wxStyledTextCtrl, setTabIndents, 1}}, + {3203, {wxStyledTextCtrl, getTabIndents, 0}}, + {3204, {wxStyledTextCtrl, setBackSpaceUnIndents, 1}}, + {3205, {wxStyledTextCtrl, getBackSpaceUnIndents, 0}}, + {3206, {wxStyledTextCtrl, setMouseDwellTime, 1}}, + {3207, {wxStyledTextCtrl, getMouseDwellTime, 0}}, + {3208, {wxStyledTextCtrl, wordStartPosition, 2}}, + {3209, {wxStyledTextCtrl, wordEndPosition, 2}}, + {3210, {wxStyledTextCtrl, setWrapMode, 1}}, + {3211, {wxStyledTextCtrl, getWrapMode, 0}}, + {3212, {wxStyledTextCtrl, setWrapVisualFlags, 1}}, + {3213, {wxStyledTextCtrl, getWrapVisualFlags, 0}}, + {3214, {wxStyledTextCtrl, setWrapVisualFlagsLocation, 1}}, + {3215, {wxStyledTextCtrl, getWrapVisualFlagsLocation, 0}}, + {3216, {wxStyledTextCtrl, setWrapStartIndent, 1}}, + {3217, {wxStyledTextCtrl, getWrapStartIndent, 0}}, + {3218, {wxStyledTextCtrl, setLayoutCache, 1}}, + {3219, {wxStyledTextCtrl, getLayoutCache, 0}}, + {3220, {wxStyledTextCtrl, setScrollWidth, 1}}, + {3221, {wxStyledTextCtrl, getScrollWidth, 0}}, + {3222, {wxStyledTextCtrl, textWidth, 2}}, + {3223, {wxStyledTextCtrl, getEndAtLastLine, 0}}, + {3224, {wxStyledTextCtrl, textHeight, 1}}, + {3225, {wxStyledTextCtrl, setUseVerticalScrollBar, 1}}, + {3226, {wxStyledTextCtrl, getUseVerticalScrollBar, 0}}, + {3227, {wxStyledTextCtrl, appendText, 1}}, + {3228, {wxStyledTextCtrl, getTwoPhaseDraw, 0}}, + {3229, {wxStyledTextCtrl, setTwoPhaseDraw, 1}}, + {3230, {wxStyledTextCtrl, targetFromSelection, 0}}, + {3231, {wxStyledTextCtrl, linesJoin, 0}}, + {3232, {wxStyledTextCtrl, linesSplit, 1}}, + {3233, {wxStyledTextCtrl, setFoldMarginColour, 2}}, + {3234, {wxStyledTextCtrl, setFoldMarginHiColour, 2}}, + {3235, {wxStyledTextCtrl, lineDown, 0}}, + {3236, {wxStyledTextCtrl, lineDownExtend, 0}}, + {3237, {wxStyledTextCtrl, lineUp, 0}}, + {3238, {wxStyledTextCtrl, lineUpExtend, 0}}, + {3239, {wxStyledTextCtrl, charLeft, 0}}, + {3240, {wxStyledTextCtrl, charLeftExtend, 0}}, + {3241, {wxStyledTextCtrl, charRight, 0}}, + {3242, {wxStyledTextCtrl, charRightExtend, 0}}, + {3243, {wxStyledTextCtrl, wordLeft, 0}}, + {3244, {wxStyledTextCtrl, wordLeftExtend, 0}}, + {3245, {wxStyledTextCtrl, wordRight, 0}}, + {3246, {wxStyledTextCtrl, wordRightExtend, 0}}, + {3247, {wxStyledTextCtrl, home, 0}}, + {3248, {wxStyledTextCtrl, homeExtend, 0}}, + {3249, {wxStyledTextCtrl, lineEnd, 0}}, + {3250, {wxStyledTextCtrl, lineEndExtend, 0}}, + {3251, {wxStyledTextCtrl, documentStart, 0}}, + {3252, {wxStyledTextCtrl, documentStartExtend, 0}}, + {3253, {wxStyledTextCtrl, documentEnd, 0}}, + {3254, {wxStyledTextCtrl, documentEndExtend, 0}}, + {3255, {wxStyledTextCtrl, pageUp, 0}}, + {3256, {wxStyledTextCtrl, pageUpExtend, 0}}, + {3257, {wxStyledTextCtrl, pageDown, 0}}, + {3258, {wxStyledTextCtrl, pageDownExtend, 0}}, + {3259, {wxStyledTextCtrl, editToggleOvertype, 0}}, + {3260, {wxStyledTextCtrl, cancel, 0}}, + {3261, {wxStyledTextCtrl, deleteBack, 0}}, + {3262, {wxStyledTextCtrl, tab, 0}}, + {3263, {wxStyledTextCtrl, backTab, 0}}, + {3264, {wxStyledTextCtrl, newLine, 0}}, + {3265, {wxStyledTextCtrl, formFeed, 0}}, + {3266, {wxStyledTextCtrl, vCHome, 0}}, + {3267, {wxStyledTextCtrl, vCHomeExtend, 0}}, + {3268, {wxStyledTextCtrl, zoomIn, 0}}, + {3269, {wxStyledTextCtrl, zoomOut, 0}}, + {3270, {wxStyledTextCtrl, delWordLeft, 0}}, + {3271, {wxStyledTextCtrl, delWordRight, 0}}, + {3272, {wxStyledTextCtrl, lineCut, 0}}, + {3273, {wxStyledTextCtrl, lineDelete, 0}}, + {3274, {wxStyledTextCtrl, lineTranspose, 0}}, + {3275, {wxStyledTextCtrl, lineDuplicate, 0}}, + {3276, {wxStyledTextCtrl, lowerCase, 0}}, + {3277, {wxStyledTextCtrl, upperCase, 0}}, + {3278, {wxStyledTextCtrl, lineScrollDown, 0}}, + {3279, {wxStyledTextCtrl, lineScrollUp, 0}}, + {3280, {wxStyledTextCtrl, deleteBackNotLine, 0}}, + {3281, {wxStyledTextCtrl, homeDisplay, 0}}, + {3282, {wxStyledTextCtrl, homeDisplayExtend, 0}}, + {3283, {wxStyledTextCtrl, lineEndDisplay, 0}}, + {3284, {wxStyledTextCtrl, lineEndDisplayExtend, 0}}, + {3285, {wxStyledTextCtrl, homeWrapExtend, 0}}, + {3286, {wxStyledTextCtrl, lineEndWrap, 0}}, + {3287, {wxStyledTextCtrl, lineEndWrapExtend, 0}}, + {3288, {wxStyledTextCtrl, vCHomeWrap, 0}}, + {3289, {wxStyledTextCtrl, vCHomeWrapExtend, 0}}, + {3290, {wxStyledTextCtrl, lineCopy, 0}}, + {3291, {wxStyledTextCtrl, moveCaretInsideView, 0}}, + {3292, {wxStyledTextCtrl, lineLength, 1}}, + {3293, {wxStyledTextCtrl, braceHighlight, 2}}, + {3294, {wxStyledTextCtrl, braceBadLight, 1}}, + {3295, {wxStyledTextCtrl, braceMatch, 1}}, + {3296, {wxStyledTextCtrl, getViewEOL, 0}}, + {3297, {wxStyledTextCtrl, setViewEOL, 1}}, + {3298, {wxStyledTextCtrl, setModEventMask, 1}}, + {3299, {wxStyledTextCtrl, getEdgeColumn, 0}}, + {3300, {wxStyledTextCtrl, setEdgeColumn, 1}}, + {3301, {wxStyledTextCtrl, setEdgeMode, 1}}, + {3302, {wxStyledTextCtrl, getEdgeMode, 0}}, + {3303, {wxStyledTextCtrl, getEdgeColour, 0}}, + {3304, {wxStyledTextCtrl, setEdgeColour, 1}}, + {3305, {wxStyledTextCtrl, searchAnchor, 0}}, + {3306, {wxStyledTextCtrl, searchNext, 2}}, + {3307, {wxStyledTextCtrl, searchPrev, 2}}, + {3308, {wxStyledTextCtrl, linesOnScreen, 0}}, + {3309, {wxStyledTextCtrl, usePopUp, 1}}, + {3310, {wxStyledTextCtrl, selectionIsRectangle, 0}}, + {3311, {wxStyledTextCtrl, setZoom, 1}}, + {3312, {wxStyledTextCtrl, getZoom, 0}}, + {3313, {wxStyledTextCtrl, getModEventMask, 0}}, + {3314, {wxStyledTextCtrl, setSTCFocus, 1}}, + {3315, {wxStyledTextCtrl, getSTCFocus, 0}}, + {3316, {wxStyledTextCtrl, setStatus, 1}}, + {3317, {wxStyledTextCtrl, getStatus, 0}}, + {3318, {wxStyledTextCtrl, setMouseDownCaptures, 1}}, + {3319, {wxStyledTextCtrl, getMouseDownCaptures, 0}}, + {3320, {wxStyledTextCtrl, setSTCCursor, 1}}, + {3321, {wxStyledTextCtrl, getSTCCursor, 0}}, + {3322, {wxStyledTextCtrl, setControlCharSymbol, 1}}, + {3323, {wxStyledTextCtrl, getControlCharSymbol, 0}}, + {3324, {wxStyledTextCtrl, wordPartLeft, 0}}, + {3325, {wxStyledTextCtrl, wordPartLeftExtend, 0}}, + {3326, {wxStyledTextCtrl, wordPartRight, 0}}, + {3327, {wxStyledTextCtrl, wordPartRightExtend, 0}}, + {3328, {wxStyledTextCtrl, setVisiblePolicy, 2}}, + {3329, {wxStyledTextCtrl, delLineLeft, 0}}, + {3330, {wxStyledTextCtrl, delLineRight, 0}}, + {3331, {wxStyledTextCtrl, getXOffset, 0}}, + {3332, {wxStyledTextCtrl, chooseCaretX, 0}}, + {3333, {wxStyledTextCtrl, setXCaretPolicy, 2}}, + {3334, {wxStyledTextCtrl, setYCaretPolicy, 2}}, + {3335, {wxStyledTextCtrl, getPrintWrapMode, 0}}, + {3336, {wxStyledTextCtrl, setHotspotActiveForeground, 2}}, + {3337, {wxStyledTextCtrl, setHotspotActiveBackground, 2}}, + {3338, {wxStyledTextCtrl, setHotspotActiveUnderline, 1}}, + {3339, {wxStyledTextCtrl, setHotspotSingleLine, 1}}, + {3340, {wxStyledTextCtrl, paraDownExtend, 0}}, + {3341, {wxStyledTextCtrl, paraUp, 0}}, + {3342, {wxStyledTextCtrl, paraUpExtend, 0}}, + {3343, {wxStyledTextCtrl, positionBefore, 1}}, + {3344, {wxStyledTextCtrl, positionAfter, 1}}, + {3345, {wxStyledTextCtrl, copyRange, 2}}, + {3346, {wxStyledTextCtrl, copyText, 2}}, + {3347, {wxStyledTextCtrl, setSelectionMode, 1}}, + {3348, {wxStyledTextCtrl, getSelectionMode, 0}}, + {3349, {wxStyledTextCtrl, lineDownRectExtend, 0}}, + {3350, {wxStyledTextCtrl, lineUpRectExtend, 0}}, + {3351, {wxStyledTextCtrl, charLeftRectExtend, 0}}, + {3352, {wxStyledTextCtrl, charRightRectExtend, 0}}, + {3353, {wxStyledTextCtrl, homeRectExtend, 0}}, + {3354, {wxStyledTextCtrl, vCHomeRectExtend, 0}}, + {3355, {wxStyledTextCtrl, lineEndRectExtend, 0}}, + {3356, {wxStyledTextCtrl, pageUpRectExtend, 0}}, + {3357, {wxStyledTextCtrl, pageDownRectExtend, 0}}, + {3358, {wxStyledTextCtrl, stutteredPageUp, 0}}, + {3359, {wxStyledTextCtrl, stutteredPageUpExtend, 0}}, + {3360, {wxStyledTextCtrl, stutteredPageDown, 0}}, + {3361, {wxStyledTextCtrl, stutteredPageDownExtend, 0}}, + {3362, {wxStyledTextCtrl, wordLeftEnd, 0}}, + {3363, {wxStyledTextCtrl, wordLeftEndExtend, 0}}, + {3364, {wxStyledTextCtrl, wordRightEnd, 0}}, + {3365, {wxStyledTextCtrl, wordRightEndExtend, 0}}, + {3366, {wxStyledTextCtrl, setWhitespaceChars, 1}}, + {3367, {wxStyledTextCtrl, setCharsDefault, 0}}, + {3368, {wxStyledTextCtrl, autoCompGetCurrent, 0}}, + {3369, {wxStyledTextCtrl, allocate, 1}}, + {3370, {wxStyledTextCtrl, findColumn, 2}}, + {3371, {wxStyledTextCtrl, getCaretSticky, 0}}, + {3372, {wxStyledTextCtrl, setCaretSticky, 1}}, + {3373, {wxStyledTextCtrl, toggleCaretSticky, 0}}, + {3374, {wxStyledTextCtrl, setPasteConvertEndings, 1}}, + {3375, {wxStyledTextCtrl, getPasteConvertEndings, 0}}, + {3376, {wxStyledTextCtrl, selectionDuplicate, 0}}, + {3377, {wxStyledTextCtrl, setCaretLineBackAlpha, 1}}, + {3378, {wxStyledTextCtrl, getCaretLineBackAlpha, 0}}, + {3379, {wxStyledTextCtrl, startRecord, 0}}, + {3380, {wxStyledTextCtrl, stopRecord, 0}}, + {3381, {wxStyledTextCtrl, setLexer, 1}}, + {3382, {wxStyledTextCtrl, getLexer, 0}}, + {3383, {wxStyledTextCtrl, colourise, 2}}, + {3384, {wxStyledTextCtrl, setProperty, 2}}, + {3385, {wxStyledTextCtrl, setKeyWords, 2}}, + {3386, {wxStyledTextCtrl, setLexerLanguage, 1}}, + {3387, {wxStyledTextCtrl, getProperty, 1}}, + {3388, {wxStyledTextCtrl, getStyleBitsNeeded, 0}}, + {3389, {wxStyledTextCtrl, getCurrentLine, 0}}, + {3390, {wxStyledTextCtrl, styleSetSpec, 2}}, + {3391, {wxStyledTextCtrl, styleSetFont, 2}}, + {3392, {wxStyledTextCtrl, styleSetFontAttr, 7}}, + {3393, {wxStyledTextCtrl, styleSetCharacterSet, 2}}, + {3394, {wxStyledTextCtrl, styleSetFontEncoding, 2}}, + {3395, {wxStyledTextCtrl, cmdKeyExecute, 1}}, + {3396, {wxStyledTextCtrl, setMargins, 2}}, + {3397, {wxStyledTextCtrl, getSelection, 2}}, + {3398, {wxStyledTextCtrl, pointFromPosition, 1}}, + {3399, {wxStyledTextCtrl, scrollToLine, 1}}, + {3400, {wxStyledTextCtrl, scrollToColumn, 1}}, + {3401, {wxStyledTextCtrl, setVScrollBar, 1}}, + {3402, {wxStyledTextCtrl, setHScrollBar, 1}}, + {3403, {wxStyledTextCtrl, getLastKeydownProcessed, 0}}, + {3404, {wxStyledTextCtrl, setLastKeydownProcessed, 1}}, + {3405, {wxStyledTextCtrl, saveFile, 1}}, + {3406, {wxStyledTextCtrl, loadFile, 1}}, + {3407, {wxStyledTextCtrl, doDragOver, 3}}, + {3408, {wxStyledTextCtrl, doDropText, 3}}, + {3409, {wxStyledTextCtrl, getUseAntiAliasing, 0}}, + {3410, {wxStyledTextCtrl, addTextRaw, 1}}, + {3411, {wxStyledTextCtrl, insertTextRaw, 2}}, + {3412, {wxStyledTextCtrl, getCurLineRaw, 1}}, + {3413, {wxStyledTextCtrl, getLineRaw, 1}}, + {3414, {wxStyledTextCtrl, getSelectedTextRaw, 0}}, + {3415, {wxStyledTextCtrl, getTextRangeRaw, 2}}, + {3416, {wxStyledTextCtrl, setTextRaw, 1}}, + {3417, {wxStyledTextCtrl, getTextRaw, 0}}, + {3418, {wxStyledTextCtrl, appendTextRaw, 1}}, + {3419, {wxArtProvider, getBitmap, 2}}, + {3420, {wxArtProvider, getIcon, 2}}, + {3421, {wxTreeEvent, getKeyCode, 0}}, + {3422, {wxTreeEvent, getItem, 0}}, + {3423, {wxTreeEvent, getKeyEvent, 0}}, + {3424, {wxTreeEvent, getLabel, 0}}, + {3425, {wxTreeEvent, getOldItem, 0}}, + {3426, {wxTreeEvent, getPoint, 0}}, + {3427, {wxTreeEvent, isEditCancelled, 0}}, + {3428, {wxTreeEvent, setToolTip, 1}}, + {3429, {wxNotebookEvent, getOldSelection, 0}}, + {3430, {wxNotebookEvent, getSelection, 0}}, + {3431, {wxNotebookEvent, setOldSelection, 1}}, + {3432, {wxNotebookEvent, setSelection, 1}}, + {3433, {wxFileDataObject, new, 0}}, + {3434, {wxFileDataObject, addFile, 1}}, + {3435, {wxFileDataObject, getFilenames, 0}}, + {3436, {wxFileDataObject, 'Destroy', undefined}}, + {3437, {wxTextDataObject, new, 1}}, + {3438, {wxTextDataObject, getTextLength, 0}}, + {3439, {wxTextDataObject, getText, 0}}, + {3440, {wxTextDataObject, setText, 1}}, + {3441, {wxTextDataObject, 'Destroy', undefined}}, + {3442, {wxBitmapDataObject, new_1_1, 1}}, + {3443, {wxBitmapDataObject, new_1_0, 1}}, + {3444, {wxBitmapDataObject, getBitmap, 0}}, + {3445, {wxBitmapDataObject, setBitmap, 1}}, + {3446, {wxBitmapDataObject, 'Destroy', undefined}}, + {3448, {wxClipboard, new, 0}}, + {3449, {wxClipboard, destruct, 0}}, + {3450, {wxClipboard, addData, 1}}, + {3451, {wxClipboard, clear, 0}}, + {3452, {wxClipboard, close, 0}}, + {3453, {wxClipboard, flush, 0}}, + {3454, {wxClipboard, getData, 1}}, + {3455, {wxClipboard, isOpened, 0}}, + {3456, {wxClipboard, open, 0}}, + {3457, {wxClipboard, setData, 1}}, + {3459, {wxClipboard, usePrimarySelection, 1}}, + {3460, {wxClipboard, isSupported, 1}}, + {3461, {wxClipboard, get, 0}}, + {3462, {wxSpinEvent, getPosition, 0}}, + {3463, {wxSpinEvent, setPosition, 1}}, + {3464, {wxSplitterWindow, new_0, 0}}, + {3465, {wxSplitterWindow, new_2, 2}}, + {3466, {wxSplitterWindow, destruct, 0}}, + {3467, {wxSplitterWindow, create, 2}}, + {3468, {wxSplitterWindow, getMinimumPaneSize, 0}}, + {3469, {wxSplitterWindow, getSashGravity, 0}}, + {3470, {wxSplitterWindow, getSashPosition, 0}}, + {3471, {wxSplitterWindow, getSplitMode, 0}}, + {3472, {wxSplitterWindow, getWindow1, 0}}, + {3473, {wxSplitterWindow, getWindow2, 0}}, + {3474, {wxSplitterWindow, initialize, 1}}, + {3475, {wxSplitterWindow, isSplit, 0}}, + {3476, {wxSplitterWindow, replaceWindow, 2}}, + {3477, {wxSplitterWindow, setSashGravity, 1}}, + {3478, {wxSplitterWindow, setSashPosition, 2}}, + {3479, {wxSplitterWindow, setSashSize, 1}}, + {3480, {wxSplitterWindow, setMinimumPaneSize, 1}}, + {3481, {wxSplitterWindow, setSplitMode, 1}}, + {3482, {wxSplitterWindow, splitHorizontally, 3}}, + {3483, {wxSplitterWindow, splitVertically, 3}}, + {3484, {wxSplitterWindow, unsplit, 1}}, + {3485, {wxSplitterWindow, updateSize, 0}}, + {3486, {wxSplitterEvent, getSashPosition, 0}}, + {3487, {wxSplitterEvent, getX, 0}}, + {3488, {wxSplitterEvent, getY, 0}}, + {3489, {wxSplitterEvent, getWindowBeingRemoved, 0}}, + {3490, {wxSplitterEvent, setSashPosition, 1}}, + {3491, {wxHtmlWindow, new_0, 0}}, + {3492, {wxHtmlWindow, new_2, 2}}, + {3493, {wxHtmlWindow, appendToPage, 1}}, + {3494, {wxHtmlWindow, getOpenedAnchor, 0}}, + {3495, {wxHtmlWindow, getOpenedPage, 0}}, + {3496, {wxHtmlWindow, getOpenedPageTitle, 0}}, + {3497, {wxHtmlWindow, getRelatedFrame, 0}}, + {3498, {wxHtmlWindow, historyBack, 0}}, + {3499, {wxHtmlWindow, historyCanBack, 0}}, + {3500, {wxHtmlWindow, historyCanForward, 0}}, + {3501, {wxHtmlWindow, historyClear, 0}}, + {3502, {wxHtmlWindow, historyForward, 0}}, + {3503, {wxHtmlWindow, loadFile, 1}}, + {3504, {wxHtmlWindow, loadPage, 1}}, + {3505, {wxHtmlWindow, selectAll, 0}}, + {3506, {wxHtmlWindow, selectionToText, 0}}, + {3507, {wxHtmlWindow, selectLine, 1}}, + {3508, {wxHtmlWindow, selectWord, 1}}, + {3509, {wxHtmlWindow, setBorders, 1}}, + {3510, {wxHtmlWindow, setFonts, 3}}, + {3511, {wxHtmlWindow, setPage, 1}}, + {3512, {wxHtmlWindow, setRelatedFrame, 2}}, + {3513, {wxHtmlWindow, setRelatedStatusBar, 1}}, + {3514, {wxHtmlWindow, toText, 0}}, + {3515, {wxHtmlWindow, 'Destroy', undefined}}, + {3516, {wxHtmlLinkEvent, getLinkInfo, 0}}, + {3517, {wxSystemSettings, getColour, 1}}, + {3518, {wxSystemSettings, getFont, 1}}, + {3519, {wxSystemSettings, getMetric, 2}}, + {3520, {wxSystemSettings, getScreenType, 0}}, + {3521, {wxSystemOptions, getOption, 1}}, + {3522, {wxSystemOptions, getOptionInt, 1}}, + {3523, {wxSystemOptions, hasOption, 1}}, + {3524, {wxSystemOptions, isFalse, 1}}, + {3525, {wxSystemOptions, setOption_2_1, 2}}, + {3526, {wxSystemOptions, setOption_2_0, 2}}, + {3527, {wxAuiNotebookEvent, setSelection, 1}}, + {3528, {wxAuiNotebookEvent, getSelection, 0}}, + {3529, {wxAuiNotebookEvent, setOldSelection, 1}}, + {3530, {wxAuiNotebookEvent, getOldSelection, 0}}, + {3531, {wxAuiNotebookEvent, setDragSource, 1}}, + {3532, {wxAuiNotebookEvent, getDragSource, 0}}, + {3533, {wxAuiManagerEvent, setManager, 1}}, + {3534, {wxAuiManagerEvent, getManager, 0}}, + {3535, {wxAuiManagerEvent, setPane, 1}}, + {3536, {wxAuiManagerEvent, getPane, 0}}, + {3537, {wxAuiManagerEvent, setButton, 1}}, + {3538, {wxAuiManagerEvent, getButton, 0}}, + {3539, {wxAuiManagerEvent, setDC, 1}}, + {3540, {wxAuiManagerEvent, getDC, 0}}, + {3541, {wxAuiManagerEvent, veto, 1}}, + {3542, {wxAuiManagerEvent, getVeto, 0}}, + {3543, {wxAuiManagerEvent, setCanVeto, 1}}, + {3544, {wxAuiManagerEvent, canVeto, 0}}, + {3545, {wxLogNull, new, 0}}, + {3546, {wxLogNull, 'Destroy', undefined}}, + {3547, {wxTaskBarIcon, new, 0}}, + {3548, {wxTaskBarIcon, destruct, 0}}, + {3549, {wxTaskBarIcon, popupMenu, 1}}, + {3550, {wxTaskBarIcon, removeIcon, 0}}, + {3551, {wxTaskBarIcon, setIcon, 2}}, + {3552, {wxLocale, new_0, 0}}, + {3554, {wxLocale, new_2, 2}}, + {3555, {wxLocale, destruct, 0}}, + {3557, {wxLocale, init, 1}}, + {3558, {wxLocale, addCatalog_1, 1}}, + {3559, {wxLocale, addCatalog_3, 3}}, + {3560, {wxLocale, addCatalogLookupPathPrefix, 1}}, + {3561, {wxLocale, getCanonicalName, 0}}, + {3562, {wxLocale, getLanguage, 0}}, + {3563, {wxLocale, getLanguageName, 1}}, + {3564, {wxLocale, getLocale, 0}}, + {3565, {wxLocale, getName, 0}}, + {3566, {wxLocale, getString_2, 2}}, + {3567, {wxLocale, getString_4, 4}}, + {3568, {wxLocale, getHeaderValue, 2}}, + {3569, {wxLocale, getSysName, 0}}, + {3570, {wxLocale, getSystemEncoding, 0}}, + {3571, {wxLocale, getSystemEncodingName, 0}}, + {3572, {wxLocale, getSystemLanguage, 0}}, + {3573, {wxLocale, isLoaded, 1}}, + {3574, {wxLocale, isOk, 0}}, + {3575, {wxActivateEvent, getActive, 0}}, + {3577, {wxPopupWindow, new_2, 2}}, + {3578, {wxPopupWindow, new_0, 0}}, + {3580, {wxPopupWindow, destruct, 0}}, + {3581, {wxPopupWindow, create, 2}}, + {3582, {wxPopupWindow, position, 2}}, + {3583, {wxPopupTransientWindow, new_0, 0}}, + {3584, {wxPopupTransientWindow, new_2, 2}}, + {3585, {wxPopupTransientWindow, destruct, 0}}, + {3586, {wxPopupTransientWindow, popup, 1}}, + {3587, {wxPopupTransientWindow, dismiss, 0}}, + {3588, {wxOverlay, new, 0}}, + {3589, {wxOverlay, destruct, 0}}, + {3590, {wxOverlay, reset, 0}}, + {3591, {wxDCOverlay, new_6, 6}}, + {3592, {wxDCOverlay, new_2, 2}}, + {3593, {wxDCOverlay, destruct, 0}}, + {3594, {wxDCOverlay, clear, 0}}, {-1, {mod, func, -1}} ]. diff --git a/lib/wx/src/gen/wxe_funcs.hrl b/lib/wx/src/gen/wxe_funcs.hrl index f5f839ac67..84fa592aaa 100644 --- a/lib/wx/src/gen/wxe_funcs.hrl +++ b/lib/wx/src/gen/wxe_funcs.hrl @@ -1454,1922 +1454,1918 @@ -define(wxGauge_new_0, 1602). -define(wxGauge_new_4, 1603). -define(wxGauge_Create, 1604). --define(wxGauge_GetBezelFace, 1605). --define(wxGauge_GetRange, 1606). --define(wxGauge_GetShadowWidth, 1607). --define(wxGauge_GetValue, 1608). --define(wxGauge_IsVertical, 1609). --define(wxGauge_SetBezelFace, 1610). --define(wxGauge_SetRange, 1611). --define(wxGauge_SetShadowWidth, 1612). --define(wxGauge_SetValue, 1613). --define(wxGauge_Pulse, 1614). --define(wxGauge_destroy, 1615). --define(wxGenericDirCtrl_new_0, 1616). --define(wxGenericDirCtrl_new_2, 1617). --define(wxGenericDirCtrl_destruct, 1618). --define(wxGenericDirCtrl_Create, 1619). --define(wxGenericDirCtrl_Init, 1620). --define(wxGenericDirCtrl_CollapseTree, 1621). --define(wxGenericDirCtrl_ExpandPath, 1622). --define(wxGenericDirCtrl_GetDefaultPath, 1623). --define(wxGenericDirCtrl_GetPath, 1624). --define(wxGenericDirCtrl_GetFilePath, 1625). --define(wxGenericDirCtrl_GetFilter, 1626). --define(wxGenericDirCtrl_GetFilterIndex, 1627). --define(wxGenericDirCtrl_GetRootId, 1628). --define(wxGenericDirCtrl_GetTreeCtrl, 1629). --define(wxGenericDirCtrl_ReCreateTree, 1630). --define(wxGenericDirCtrl_SetDefaultPath, 1631). --define(wxGenericDirCtrl_SetFilter, 1632). --define(wxGenericDirCtrl_SetFilterIndex, 1633). --define(wxGenericDirCtrl_SetPath, 1634). --define(wxStaticBox_new_4, 1636). --define(wxStaticBox_new_0, 1637). --define(wxStaticBox_Create, 1638). --define(wxStaticBox_destroy, 1639). --define(wxStaticLine_new_2, 1641). --define(wxStaticLine_new_0, 1642). --define(wxStaticLine_Create, 1643). --define(wxStaticLine_IsVertical, 1644). --define(wxStaticLine_GetDefaultSize, 1645). --define(wxStaticLine_destroy, 1646). --define(wxListBox_new_3, 1649). --define(wxListBox_new_0, 1650). --define(wxListBox_destruct, 1652). --define(wxListBox_Create, 1654). --define(wxListBox_Deselect, 1655). --define(wxListBox_GetSelections, 1656). --define(wxListBox_InsertItems, 1657). --define(wxListBox_IsSelected, 1658). --define(wxListBox_Set, 1659). --define(wxListBox_HitTest, 1660). --define(wxListBox_SetFirstItem_1_0, 1661). --define(wxListBox_SetFirstItem_1_1, 1662). --define(wxListCtrl_new_0, 1663). --define(wxListCtrl_new_2, 1664). --define(wxListCtrl_Arrange, 1665). --define(wxListCtrl_AssignImageList, 1666). --define(wxListCtrl_ClearAll, 1667). --define(wxListCtrl_Create, 1668). --define(wxListCtrl_DeleteAllItems, 1669). --define(wxListCtrl_DeleteColumn, 1670). --define(wxListCtrl_DeleteItem, 1671). --define(wxListCtrl_EditLabel, 1672). --define(wxListCtrl_EnsureVisible, 1673). --define(wxListCtrl_FindItem_3_0, 1674). --define(wxListCtrl_FindItem_3_1, 1675). --define(wxListCtrl_GetColumn, 1676). --define(wxListCtrl_GetColumnCount, 1677). --define(wxListCtrl_GetColumnWidth, 1678). --define(wxListCtrl_GetCountPerPage, 1679). --define(wxListCtrl_GetEditControl, 1680). --define(wxListCtrl_GetImageList, 1681). --define(wxListCtrl_GetItem, 1682). --define(wxListCtrl_GetItemBackgroundColour, 1683). --define(wxListCtrl_GetItemCount, 1684). --define(wxListCtrl_GetItemData, 1685). --define(wxListCtrl_GetItemFont, 1686). --define(wxListCtrl_GetItemPosition, 1687). --define(wxListCtrl_GetItemRect, 1688). --define(wxListCtrl_GetItemSpacing, 1689). --define(wxListCtrl_GetItemState, 1690). --define(wxListCtrl_GetItemText, 1691). --define(wxListCtrl_GetItemTextColour, 1692). --define(wxListCtrl_GetNextItem, 1693). --define(wxListCtrl_GetSelectedItemCount, 1694). --define(wxListCtrl_GetTextColour, 1695). --define(wxListCtrl_GetTopItem, 1696). --define(wxListCtrl_GetViewRect, 1697). --define(wxListCtrl_HitTest, 1698). --define(wxListCtrl_InsertColumn_2, 1699). --define(wxListCtrl_InsertColumn_3, 1700). --define(wxListCtrl_InsertItem_1, 1701). --define(wxListCtrl_InsertItem_2_1, 1702). --define(wxListCtrl_InsertItem_2_0, 1703). --define(wxListCtrl_InsertItem_3, 1704). --define(wxListCtrl_RefreshItem, 1705). --define(wxListCtrl_RefreshItems, 1706). --define(wxListCtrl_ScrollList, 1707). --define(wxListCtrl_SetBackgroundColour, 1708). --define(wxListCtrl_SetColumn, 1709). --define(wxListCtrl_SetColumnWidth, 1710). --define(wxListCtrl_SetImageList, 1711). --define(wxListCtrl_SetItem_1, 1712). --define(wxListCtrl_SetItem_4, 1713). --define(wxListCtrl_SetItemBackgroundColour, 1714). --define(wxListCtrl_SetItemCount, 1715). --define(wxListCtrl_SetItemData, 1716). --define(wxListCtrl_SetItemFont, 1717). --define(wxListCtrl_SetItemImage, 1718). --define(wxListCtrl_SetItemColumnImage, 1719). --define(wxListCtrl_SetItemPosition, 1720). --define(wxListCtrl_SetItemState, 1721). --define(wxListCtrl_SetItemText, 1722). --define(wxListCtrl_SetItemTextColour, 1723). --define(wxListCtrl_SetSingleStyle, 1724). --define(wxListCtrl_SetTextColour, 1725). --define(wxListCtrl_SetWindowStyleFlag, 1726). --define(wxListCtrl_SortItems, 1727). --define(wxListCtrl_destroy, 1728). --define(wxListView_ClearColumnImage, 1729). --define(wxListView_Focus, 1730). --define(wxListView_GetFirstSelected, 1731). --define(wxListView_GetFocusedItem, 1732). --define(wxListView_GetNextSelected, 1733). --define(wxListView_IsSelected, 1734). --define(wxListView_Select, 1735). --define(wxListView_SetColumnImage, 1736). --define(wxListItem_new_0, 1737). --define(wxListItem_new_1, 1738). --define(wxListItem_destruct, 1739). --define(wxListItem_Clear, 1740). --define(wxListItem_GetAlign, 1741). --define(wxListItem_GetBackgroundColour, 1742). --define(wxListItem_GetColumn, 1743). --define(wxListItem_GetFont, 1744). --define(wxListItem_GetId, 1745). --define(wxListItem_GetImage, 1746). --define(wxListItem_GetMask, 1747). --define(wxListItem_GetState, 1748). --define(wxListItem_GetText, 1749). --define(wxListItem_GetTextColour, 1750). --define(wxListItem_GetWidth, 1751). --define(wxListItem_SetAlign, 1752). --define(wxListItem_SetBackgroundColour, 1753). --define(wxListItem_SetColumn, 1754). --define(wxListItem_SetFont, 1755). --define(wxListItem_SetId, 1756). --define(wxListItem_SetImage, 1757). --define(wxListItem_SetMask, 1758). --define(wxListItem_SetState, 1759). --define(wxListItem_SetStateMask, 1760). --define(wxListItem_SetText, 1761). --define(wxListItem_SetTextColour, 1762). --define(wxListItem_SetWidth, 1763). --define(wxListItemAttr_new_0, 1764). --define(wxListItemAttr_new_3, 1765). --define(wxListItemAttr_GetBackgroundColour, 1766). --define(wxListItemAttr_GetFont, 1767). --define(wxListItemAttr_GetTextColour, 1768). --define(wxListItemAttr_HasBackgroundColour, 1769). --define(wxListItemAttr_HasFont, 1770). --define(wxListItemAttr_HasTextColour, 1771). --define(wxListItemAttr_SetBackgroundColour, 1772). --define(wxListItemAttr_SetFont, 1773). --define(wxListItemAttr_SetTextColour, 1774). --define(wxListItemAttr_destroy, 1775). --define(wxImageList_new_0, 1776). --define(wxImageList_new_3, 1777). --define(wxImageList_Add_1, 1778). --define(wxImageList_Add_2_0, 1779). --define(wxImageList_Add_2_1, 1780). --define(wxImageList_Create, 1781). --define(wxImageList_Draw, 1783). --define(wxImageList_GetBitmap, 1784). --define(wxImageList_GetIcon, 1785). --define(wxImageList_GetImageCount, 1786). --define(wxImageList_GetSize, 1787). --define(wxImageList_Remove, 1788). --define(wxImageList_RemoveAll, 1789). --define(wxImageList_Replace_2, 1790). --define(wxImageList_Replace_3, 1791). --define(wxImageList_destroy, 1792). --define(wxTextAttr_new_0, 1793). --define(wxTextAttr_new_2, 1794). --define(wxTextAttr_GetAlignment, 1795). --define(wxTextAttr_GetBackgroundColour, 1796). --define(wxTextAttr_GetFont, 1797). --define(wxTextAttr_GetLeftIndent, 1798). --define(wxTextAttr_GetLeftSubIndent, 1799). --define(wxTextAttr_GetRightIndent, 1800). --define(wxTextAttr_GetTabs, 1801). --define(wxTextAttr_GetTextColour, 1802). --define(wxTextAttr_HasBackgroundColour, 1803). --define(wxTextAttr_HasFont, 1804). --define(wxTextAttr_HasTextColour, 1805). --define(wxTextAttr_GetFlags, 1806). --define(wxTextAttr_IsDefault, 1807). --define(wxTextAttr_SetAlignment, 1808). --define(wxTextAttr_SetBackgroundColour, 1809). --define(wxTextAttr_SetFlags, 1810). --define(wxTextAttr_SetFont, 1811). --define(wxTextAttr_SetLeftIndent, 1812). --define(wxTextAttr_SetRightIndent, 1813). --define(wxTextAttr_SetTabs, 1814). --define(wxTextAttr_SetTextColour, 1815). --define(wxTextAttr_destroy, 1816). --define(wxTextCtrl_new_3, 1818). --define(wxTextCtrl_new_0, 1819). --define(wxTextCtrl_destruct, 1821). --define(wxTextCtrl_AppendText, 1822). --define(wxTextCtrl_CanCopy, 1823). --define(wxTextCtrl_CanCut, 1824). --define(wxTextCtrl_CanPaste, 1825). --define(wxTextCtrl_CanRedo, 1826). --define(wxTextCtrl_CanUndo, 1827). --define(wxTextCtrl_Clear, 1828). --define(wxTextCtrl_Copy, 1829). --define(wxTextCtrl_Create, 1830). --define(wxTextCtrl_Cut, 1831). --define(wxTextCtrl_DiscardEdits, 1832). --define(wxTextCtrl_ChangeValue, 1833). --define(wxTextCtrl_EmulateKeyPress, 1834). --define(wxTextCtrl_GetDefaultStyle, 1835). --define(wxTextCtrl_GetInsertionPoint, 1836). --define(wxTextCtrl_GetLastPosition, 1837). --define(wxTextCtrl_GetLineLength, 1838). --define(wxTextCtrl_GetLineText, 1839). --define(wxTextCtrl_GetNumberOfLines, 1840). --define(wxTextCtrl_GetRange, 1841). --define(wxTextCtrl_GetSelection, 1842). --define(wxTextCtrl_GetStringSelection, 1843). --define(wxTextCtrl_GetStyle, 1844). --define(wxTextCtrl_GetValue, 1845). --define(wxTextCtrl_IsEditable, 1846). --define(wxTextCtrl_IsModified, 1847). --define(wxTextCtrl_IsMultiLine, 1848). --define(wxTextCtrl_IsSingleLine, 1849). --define(wxTextCtrl_LoadFile, 1850). --define(wxTextCtrl_MarkDirty, 1851). --define(wxTextCtrl_Paste, 1852). --define(wxTextCtrl_PositionToXY, 1853). --define(wxTextCtrl_Redo, 1854). --define(wxTextCtrl_Remove, 1855). --define(wxTextCtrl_Replace, 1856). --define(wxTextCtrl_SaveFile, 1857). --define(wxTextCtrl_SetDefaultStyle, 1858). --define(wxTextCtrl_SetEditable, 1859). --define(wxTextCtrl_SetInsertionPoint, 1860). --define(wxTextCtrl_SetInsertionPointEnd, 1861). --define(wxTextCtrl_SetMaxLength, 1863). --define(wxTextCtrl_SetSelection, 1864). --define(wxTextCtrl_SetStyle, 1865). --define(wxTextCtrl_SetValue, 1866). --define(wxTextCtrl_ShowPosition, 1867). --define(wxTextCtrl_Undo, 1868). --define(wxTextCtrl_WriteText, 1869). --define(wxTextCtrl_XYToPosition, 1870). --define(wxNotebook_new_0, 1873). --define(wxNotebook_new_3, 1874). --define(wxNotebook_destruct, 1875). --define(wxNotebook_AddPage, 1876). --define(wxNotebook_AdvanceSelection, 1877). --define(wxNotebook_AssignImageList, 1878). --define(wxNotebook_Create, 1879). --define(wxNotebook_DeleteAllPages, 1880). --define(wxNotebook_DeletePage, 1881). --define(wxNotebook_RemovePage, 1882). --define(wxNotebook_GetCurrentPage, 1883). --define(wxNotebook_GetImageList, 1884). --define(wxNotebook_GetPage, 1886). --define(wxNotebook_GetPageCount, 1887). --define(wxNotebook_GetPageImage, 1888). --define(wxNotebook_GetPageText, 1889). --define(wxNotebook_GetRowCount, 1890). --define(wxNotebook_GetSelection, 1891). --define(wxNotebook_GetThemeBackgroundColour, 1892). --define(wxNotebook_HitTest, 1894). --define(wxNotebook_InsertPage, 1896). --define(wxNotebook_SetImageList, 1897). --define(wxNotebook_SetPadding, 1898). --define(wxNotebook_SetPageSize, 1899). --define(wxNotebook_SetPageImage, 1900). --define(wxNotebook_SetPageText, 1901). --define(wxNotebook_SetSelection, 1902). --define(wxNotebook_ChangeSelection, 1903). --define(wxChoicebook_new_0, 1904). --define(wxChoicebook_new_3, 1905). --define(wxChoicebook_AddPage, 1906). --define(wxChoicebook_AdvanceSelection, 1907). --define(wxChoicebook_AssignImageList, 1908). --define(wxChoicebook_Create, 1909). --define(wxChoicebook_DeleteAllPages, 1910). --define(wxChoicebook_DeletePage, 1911). --define(wxChoicebook_RemovePage, 1912). --define(wxChoicebook_GetCurrentPage, 1913). --define(wxChoicebook_GetImageList, 1914). --define(wxChoicebook_GetPage, 1916). --define(wxChoicebook_GetPageCount, 1917). --define(wxChoicebook_GetPageImage, 1918). --define(wxChoicebook_GetPageText, 1919). --define(wxChoicebook_GetSelection, 1920). --define(wxChoicebook_HitTest, 1921). --define(wxChoicebook_InsertPage, 1922). --define(wxChoicebook_SetImageList, 1923). --define(wxChoicebook_SetPageSize, 1924). --define(wxChoicebook_SetPageImage, 1925). --define(wxChoicebook_SetPageText, 1926). --define(wxChoicebook_SetSelection, 1927). --define(wxChoicebook_ChangeSelection, 1928). --define(wxChoicebook_destroy, 1929). --define(wxToolbook_new_0, 1930). --define(wxToolbook_new_3, 1931). --define(wxToolbook_AddPage, 1932). --define(wxToolbook_AdvanceSelection, 1933). --define(wxToolbook_AssignImageList, 1934). --define(wxToolbook_Create, 1935). --define(wxToolbook_DeleteAllPages, 1936). --define(wxToolbook_DeletePage, 1937). --define(wxToolbook_RemovePage, 1938). --define(wxToolbook_GetCurrentPage, 1939). --define(wxToolbook_GetImageList, 1940). --define(wxToolbook_GetPage, 1942). --define(wxToolbook_GetPageCount, 1943). --define(wxToolbook_GetPageImage, 1944). --define(wxToolbook_GetPageText, 1945). --define(wxToolbook_GetSelection, 1946). --define(wxToolbook_HitTest, 1948). --define(wxToolbook_InsertPage, 1949). --define(wxToolbook_SetImageList, 1950). --define(wxToolbook_SetPageSize, 1951). --define(wxToolbook_SetPageImage, 1952). --define(wxToolbook_SetPageText, 1953). --define(wxToolbook_SetSelection, 1954). --define(wxToolbook_ChangeSelection, 1955). --define(wxToolbook_destroy, 1956). --define(wxListbook_new_0, 1957). --define(wxListbook_new_3, 1958). --define(wxListbook_AddPage, 1959). --define(wxListbook_AdvanceSelection, 1960). --define(wxListbook_AssignImageList, 1961). --define(wxListbook_Create, 1962). --define(wxListbook_DeleteAllPages, 1963). --define(wxListbook_DeletePage, 1964). --define(wxListbook_RemovePage, 1965). --define(wxListbook_GetCurrentPage, 1966). --define(wxListbook_GetImageList, 1967). --define(wxListbook_GetPage, 1969). --define(wxListbook_GetPageCount, 1970). --define(wxListbook_GetPageImage, 1971). --define(wxListbook_GetPageText, 1972). --define(wxListbook_GetSelection, 1973). --define(wxListbook_HitTest, 1975). --define(wxListbook_InsertPage, 1976). --define(wxListbook_SetImageList, 1977). --define(wxListbook_SetPageSize, 1978). --define(wxListbook_SetPageImage, 1979). --define(wxListbook_SetPageText, 1980). --define(wxListbook_SetSelection, 1981). --define(wxListbook_ChangeSelection, 1982). --define(wxListbook_destroy, 1983). --define(wxTreebook_new_0, 1984). --define(wxTreebook_new_3, 1985). --define(wxTreebook_AddPage, 1986). --define(wxTreebook_AdvanceSelection, 1987). --define(wxTreebook_AssignImageList, 1988). --define(wxTreebook_Create, 1989). --define(wxTreebook_DeleteAllPages, 1990). --define(wxTreebook_DeletePage, 1991). --define(wxTreebook_RemovePage, 1992). --define(wxTreebook_GetCurrentPage, 1993). --define(wxTreebook_GetImageList, 1994). --define(wxTreebook_GetPage, 1996). --define(wxTreebook_GetPageCount, 1997). --define(wxTreebook_GetPageImage, 1998). --define(wxTreebook_GetPageText, 1999). --define(wxTreebook_GetSelection, 2000). --define(wxTreebook_ExpandNode, 2001). --define(wxTreebook_IsNodeExpanded, 2002). --define(wxTreebook_HitTest, 2004). --define(wxTreebook_InsertPage, 2005). --define(wxTreebook_InsertSubPage, 2006). --define(wxTreebook_SetImageList, 2007). --define(wxTreebook_SetPageSize, 2008). --define(wxTreebook_SetPageImage, 2009). --define(wxTreebook_SetPageText, 2010). --define(wxTreebook_SetSelection, 2011). --define(wxTreebook_ChangeSelection, 2012). --define(wxTreebook_destroy, 2013). --define(wxTreeCtrl_new_2, 2016). --define(wxTreeCtrl_new_0, 2017). --define(wxTreeCtrl_destruct, 2019). --define(wxTreeCtrl_AddRoot, 2020). --define(wxTreeCtrl_AppendItem, 2021). --define(wxTreeCtrl_AssignImageList, 2022). --define(wxTreeCtrl_AssignStateImageList, 2023). --define(wxTreeCtrl_Collapse, 2024). --define(wxTreeCtrl_CollapseAndReset, 2025). --define(wxTreeCtrl_Create, 2026). --define(wxTreeCtrl_Delete, 2027). --define(wxTreeCtrl_DeleteAllItems, 2028). --define(wxTreeCtrl_DeleteChildren, 2029). --define(wxTreeCtrl_EditLabel, 2030). --define(wxTreeCtrl_EnsureVisible, 2031). --define(wxTreeCtrl_Expand, 2032). --define(wxTreeCtrl_GetBoundingRect, 2033). --define(wxTreeCtrl_GetChildrenCount, 2035). --define(wxTreeCtrl_GetCount, 2036). --define(wxTreeCtrl_GetEditControl, 2037). --define(wxTreeCtrl_GetFirstChild, 2038). --define(wxTreeCtrl_GetNextChild, 2039). --define(wxTreeCtrl_GetFirstVisibleItem, 2040). --define(wxTreeCtrl_GetImageList, 2041). --define(wxTreeCtrl_GetIndent, 2042). --define(wxTreeCtrl_GetItemBackgroundColour, 2043). --define(wxTreeCtrl_GetItemData, 2044). --define(wxTreeCtrl_GetItemFont, 2045). --define(wxTreeCtrl_GetItemImage_1, 2046). --define(wxTreeCtrl_GetItemImage_2, 2047). --define(wxTreeCtrl_GetItemText, 2048). --define(wxTreeCtrl_GetItemTextColour, 2049). --define(wxTreeCtrl_GetLastChild, 2050). --define(wxTreeCtrl_GetNextSibling, 2051). --define(wxTreeCtrl_GetNextVisible, 2052). --define(wxTreeCtrl_GetItemParent, 2053). --define(wxTreeCtrl_GetPrevSibling, 2054). --define(wxTreeCtrl_GetPrevVisible, 2055). --define(wxTreeCtrl_GetRootItem, 2056). --define(wxTreeCtrl_GetSelection, 2057). --define(wxTreeCtrl_GetSelections, 2058). --define(wxTreeCtrl_GetStateImageList, 2059). --define(wxTreeCtrl_HitTest, 2060). --define(wxTreeCtrl_InsertItem, 2062). --define(wxTreeCtrl_IsBold, 2063). --define(wxTreeCtrl_IsExpanded, 2064). --define(wxTreeCtrl_IsSelected, 2065). --define(wxTreeCtrl_IsVisible, 2066). --define(wxTreeCtrl_ItemHasChildren, 2067). --define(wxTreeCtrl_IsTreeItemIdOk, 2068). --define(wxTreeCtrl_PrependItem, 2069). --define(wxTreeCtrl_ScrollTo, 2070). --define(wxTreeCtrl_SelectItem_1, 2071). --define(wxTreeCtrl_SelectItem_2, 2072). --define(wxTreeCtrl_SetIndent, 2073). --define(wxTreeCtrl_SetImageList, 2074). --define(wxTreeCtrl_SetItemBackgroundColour, 2075). --define(wxTreeCtrl_SetItemBold, 2076). --define(wxTreeCtrl_SetItemData, 2077). --define(wxTreeCtrl_SetItemDropHighlight, 2078). --define(wxTreeCtrl_SetItemFont, 2079). --define(wxTreeCtrl_SetItemHasChildren, 2080). --define(wxTreeCtrl_SetItemImage_2, 2081). --define(wxTreeCtrl_SetItemImage_3, 2082). --define(wxTreeCtrl_SetItemText, 2083). --define(wxTreeCtrl_SetItemTextColour, 2084). --define(wxTreeCtrl_SetStateImageList, 2085). --define(wxTreeCtrl_SetWindowStyle, 2086). --define(wxTreeCtrl_SortChildren, 2087). --define(wxTreeCtrl_Toggle, 2088). --define(wxTreeCtrl_ToggleItemSelection, 2089). --define(wxTreeCtrl_Unselect, 2090). --define(wxTreeCtrl_UnselectAll, 2091). --define(wxTreeCtrl_UnselectItem, 2092). --define(wxScrollBar_new_0, 2093). --define(wxScrollBar_new_3, 2094). --define(wxScrollBar_destruct, 2095). --define(wxScrollBar_Create, 2096). --define(wxScrollBar_GetRange, 2097). --define(wxScrollBar_GetPageSize, 2098). --define(wxScrollBar_GetThumbPosition, 2099). --define(wxScrollBar_GetThumbSize, 2100). --define(wxScrollBar_SetThumbPosition, 2101). --define(wxScrollBar_SetScrollbar, 2102). --define(wxSpinButton_new_2, 2104). --define(wxSpinButton_new_0, 2105). --define(wxSpinButton_Create, 2106). --define(wxSpinButton_GetMax, 2107). --define(wxSpinButton_GetMin, 2108). --define(wxSpinButton_GetValue, 2109). --define(wxSpinButton_SetRange, 2110). --define(wxSpinButton_SetValue, 2111). --define(wxSpinButton_destroy, 2112). --define(wxSpinCtrl_new_0, 2113). --define(wxSpinCtrl_new_2, 2114). --define(wxSpinCtrl_Create, 2116). --define(wxSpinCtrl_SetValue_1_1, 2119). --define(wxSpinCtrl_SetValue_1_0, 2120). --define(wxSpinCtrl_GetValue, 2122). --define(wxSpinCtrl_SetRange, 2124). --define(wxSpinCtrl_SetSelection, 2125). --define(wxSpinCtrl_GetMin, 2127). --define(wxSpinCtrl_GetMax, 2129). --define(wxSpinCtrl_destroy, 2130). --define(wxStaticText_new_0, 2131). --define(wxStaticText_new_4, 2132). --define(wxStaticText_Create, 2133). --define(wxStaticText_GetLabel, 2134). --define(wxStaticText_SetLabel, 2135). --define(wxStaticText_Wrap, 2136). --define(wxStaticText_destroy, 2137). --define(wxStaticBitmap_new_0, 2138). --define(wxStaticBitmap_new_4, 2139). --define(wxStaticBitmap_Create, 2140). --define(wxStaticBitmap_GetBitmap, 2141). --define(wxStaticBitmap_SetBitmap, 2142). --define(wxStaticBitmap_destroy, 2143). --define(wxRadioBox_new, 2144). --define(wxRadioBox_destruct, 2146). --define(wxRadioBox_Create, 2147). --define(wxRadioBox_Enable_2, 2148). --define(wxRadioBox_Enable_1, 2149). --define(wxRadioBox_GetSelection, 2150). --define(wxRadioBox_GetString, 2151). --define(wxRadioBox_SetSelection, 2152). --define(wxRadioBox_Show_2, 2153). --define(wxRadioBox_Show_1, 2154). --define(wxRadioBox_GetColumnCount, 2155). --define(wxRadioBox_GetItemHelpText, 2156). --define(wxRadioBox_GetItemToolTip, 2157). --define(wxRadioBox_GetItemFromPoint, 2159). --define(wxRadioBox_GetRowCount, 2160). --define(wxRadioBox_IsItemEnabled, 2161). --define(wxRadioBox_IsItemShown, 2162). --define(wxRadioBox_SetItemHelpText, 2163). --define(wxRadioBox_SetItemToolTip, 2164). --define(wxRadioButton_new_0, 2165). --define(wxRadioButton_new_4, 2166). --define(wxRadioButton_Create, 2167). --define(wxRadioButton_GetValue, 2168). --define(wxRadioButton_SetValue, 2169). --define(wxRadioButton_destroy, 2170). --define(wxSlider_new_6, 2172). --define(wxSlider_new_0, 2173). --define(wxSlider_Create, 2174). --define(wxSlider_GetLineSize, 2175). --define(wxSlider_GetMax, 2176). --define(wxSlider_GetMin, 2177). --define(wxSlider_GetPageSize, 2178). --define(wxSlider_GetThumbLength, 2179). --define(wxSlider_GetValue, 2180). --define(wxSlider_SetLineSize, 2181). --define(wxSlider_SetPageSize, 2182). --define(wxSlider_SetRange, 2183). --define(wxSlider_SetThumbLength, 2184). --define(wxSlider_SetValue, 2185). --define(wxSlider_destroy, 2186). --define(wxDialog_new_4, 2188). --define(wxDialog_new_0, 2189). --define(wxDialog_destruct, 2191). --define(wxDialog_Create, 2192). --define(wxDialog_CreateButtonSizer, 2193). --define(wxDialog_CreateStdDialogButtonSizer, 2194). --define(wxDialog_EndModal, 2195). --define(wxDialog_GetAffirmativeId, 2196). --define(wxDialog_GetReturnCode, 2197). --define(wxDialog_IsModal, 2198). --define(wxDialog_SetAffirmativeId, 2199). --define(wxDialog_SetReturnCode, 2200). --define(wxDialog_Show, 2201). --define(wxDialog_ShowModal, 2202). --define(wxColourDialog_new_0, 2203). --define(wxColourDialog_new_2, 2204). --define(wxColourDialog_destruct, 2205). --define(wxColourDialog_Create, 2206). --define(wxColourDialog_GetColourData, 2207). --define(wxColourData_new_0, 2208). --define(wxColourData_new_1, 2209). --define(wxColourData_destruct, 2210). --define(wxColourData_GetChooseFull, 2211). --define(wxColourData_GetColour, 2212). --define(wxColourData_GetCustomColour, 2214). --define(wxColourData_SetChooseFull, 2215). --define(wxColourData_SetColour, 2216). --define(wxColourData_SetCustomColour, 2217). --define(wxPalette_new_0, 2218). --define(wxPalette_new_4, 2219). --define(wxPalette_destruct, 2221). --define(wxPalette_Create, 2222). --define(wxPalette_GetColoursCount, 2223). --define(wxPalette_GetPixel, 2224). --define(wxPalette_GetRGB, 2225). --define(wxPalette_IsOk, 2226). --define(wxDirDialog_new, 2230). --define(wxDirDialog_destruct, 2231). --define(wxDirDialog_GetPath, 2232). --define(wxDirDialog_GetMessage, 2233). --define(wxDirDialog_SetMessage, 2234). --define(wxDirDialog_SetPath, 2235). --define(wxFileDialog_new, 2239). --define(wxFileDialog_destruct, 2240). --define(wxFileDialog_GetDirectory, 2241). --define(wxFileDialog_GetFilename, 2242). --define(wxFileDialog_GetFilenames, 2243). --define(wxFileDialog_GetFilterIndex, 2244). --define(wxFileDialog_GetMessage, 2245). --define(wxFileDialog_GetPath, 2246). --define(wxFileDialog_GetPaths, 2247). --define(wxFileDialog_GetWildcard, 2248). --define(wxFileDialog_SetDirectory, 2249). --define(wxFileDialog_SetFilename, 2250). --define(wxFileDialog_SetFilterIndex, 2251). --define(wxFileDialog_SetMessage, 2252). --define(wxFileDialog_SetPath, 2253). --define(wxFileDialog_SetWildcard, 2254). --define(wxPickerBase_SetInternalMargin, 2255). --define(wxPickerBase_GetInternalMargin, 2256). --define(wxPickerBase_SetTextCtrlProportion, 2257). --define(wxPickerBase_SetPickerCtrlProportion, 2258). --define(wxPickerBase_GetTextCtrlProportion, 2259). --define(wxPickerBase_GetPickerCtrlProportion, 2260). --define(wxPickerBase_HasTextCtrl, 2261). --define(wxPickerBase_GetTextCtrl, 2262). --define(wxPickerBase_IsTextCtrlGrowable, 2263). --define(wxPickerBase_SetPickerCtrlGrowable, 2264). --define(wxPickerBase_SetTextCtrlGrowable, 2265). --define(wxPickerBase_IsPickerCtrlGrowable, 2266). --define(wxFilePickerCtrl_new_0, 2267). --define(wxFilePickerCtrl_new_3, 2268). --define(wxFilePickerCtrl_Create, 2269). --define(wxFilePickerCtrl_GetPath, 2270). --define(wxFilePickerCtrl_SetPath, 2271). --define(wxFilePickerCtrl_destroy, 2272). --define(wxDirPickerCtrl_new_0, 2273). --define(wxDirPickerCtrl_new_3, 2274). --define(wxDirPickerCtrl_Create, 2275). --define(wxDirPickerCtrl_GetPath, 2276). --define(wxDirPickerCtrl_SetPath, 2277). --define(wxDirPickerCtrl_destroy, 2278). --define(wxColourPickerCtrl_new_0, 2279). --define(wxColourPickerCtrl_new_3, 2280). --define(wxColourPickerCtrl_Create, 2281). --define(wxColourPickerCtrl_GetColour, 2282). --define(wxColourPickerCtrl_SetColour_1_1, 2283). --define(wxColourPickerCtrl_SetColour_1_0, 2284). --define(wxColourPickerCtrl_destroy, 2285). --define(wxDatePickerCtrl_new_0, 2286). --define(wxDatePickerCtrl_new_3, 2287). --define(wxDatePickerCtrl_GetRange, 2288). --define(wxDatePickerCtrl_GetValue, 2289). --define(wxDatePickerCtrl_SetRange, 2290). --define(wxDatePickerCtrl_SetValue, 2291). --define(wxDatePickerCtrl_destroy, 2292). --define(wxFontPickerCtrl_new_0, 2293). --define(wxFontPickerCtrl_new_3, 2294). --define(wxFontPickerCtrl_Create, 2295). --define(wxFontPickerCtrl_GetSelectedFont, 2296). --define(wxFontPickerCtrl_SetSelectedFont, 2297). --define(wxFontPickerCtrl_GetMaxPointSize, 2298). --define(wxFontPickerCtrl_SetMaxPointSize, 2299). --define(wxFontPickerCtrl_destroy, 2300). --define(wxFindReplaceDialog_new_0, 2303). --define(wxFindReplaceDialog_new_4, 2304). --define(wxFindReplaceDialog_destruct, 2305). --define(wxFindReplaceDialog_Create, 2306). --define(wxFindReplaceDialog_GetData, 2307). --define(wxFindReplaceData_new_0, 2308). --define(wxFindReplaceData_new_1, 2309). --define(wxFindReplaceData_GetFindString, 2310). --define(wxFindReplaceData_GetReplaceString, 2311). --define(wxFindReplaceData_GetFlags, 2312). --define(wxFindReplaceData_SetFlags, 2313). --define(wxFindReplaceData_SetFindString, 2314). --define(wxFindReplaceData_SetReplaceString, 2315). --define(wxFindReplaceData_destroy, 2316). --define(wxMultiChoiceDialog_new_0, 2317). --define(wxMultiChoiceDialog_new_5, 2319). --define(wxMultiChoiceDialog_GetSelections, 2320). --define(wxMultiChoiceDialog_SetSelections, 2321). --define(wxMultiChoiceDialog_destroy, 2322). --define(wxSingleChoiceDialog_new_0, 2323). --define(wxSingleChoiceDialog_new_5, 2325). --define(wxSingleChoiceDialog_GetSelection, 2326). --define(wxSingleChoiceDialog_GetStringSelection, 2327). --define(wxSingleChoiceDialog_SetSelection, 2328). --define(wxSingleChoiceDialog_destroy, 2329). --define(wxTextEntryDialog_new, 2330). --define(wxTextEntryDialog_GetValue, 2331). --define(wxTextEntryDialog_SetValue, 2332). --define(wxTextEntryDialog_destroy, 2333). --define(wxPasswordEntryDialog_new, 2334). --define(wxPasswordEntryDialog_destroy, 2335). --define(wxFontData_new_0, 2336). --define(wxFontData_new_1, 2337). --define(wxFontData_destruct, 2338). --define(wxFontData_EnableEffects, 2339). --define(wxFontData_GetAllowSymbols, 2340). --define(wxFontData_GetColour, 2341). --define(wxFontData_GetChosenFont, 2342). --define(wxFontData_GetEnableEffects, 2343). --define(wxFontData_GetInitialFont, 2344). --define(wxFontData_GetShowHelp, 2345). --define(wxFontData_SetAllowSymbols, 2346). --define(wxFontData_SetChosenFont, 2347). --define(wxFontData_SetColour, 2348). --define(wxFontData_SetInitialFont, 2349). --define(wxFontData_SetRange, 2350). --define(wxFontData_SetShowHelp, 2351). --define(wxFontDialog_new_0, 2355). --define(wxFontDialog_new_2, 2357). --define(wxFontDialog_Create, 2359). --define(wxFontDialog_GetFontData, 2360). --define(wxFontDialog_destroy, 2362). --define(wxProgressDialog_new, 2363). --define(wxProgressDialog_destruct, 2364). --define(wxProgressDialog_Resume, 2365). --define(wxProgressDialog_Update_2, 2366). --define(wxProgressDialog_Update_0, 2367). --define(wxMessageDialog_new, 2368). --define(wxMessageDialog_destruct, 2369). --define(wxPageSetupDialog_new, 2370). --define(wxPageSetupDialog_destruct, 2371). --define(wxPageSetupDialog_GetPageSetupData, 2372). --define(wxPageSetupDialog_ShowModal, 2373). --define(wxPageSetupDialogData_new_0, 2374). --define(wxPageSetupDialogData_new_1_0, 2375). --define(wxPageSetupDialogData_new_1_1, 2376). --define(wxPageSetupDialogData_destruct, 2377). --define(wxPageSetupDialogData_EnableHelp, 2378). --define(wxPageSetupDialogData_EnableMargins, 2379). --define(wxPageSetupDialogData_EnableOrientation, 2380). --define(wxPageSetupDialogData_EnablePaper, 2381). --define(wxPageSetupDialogData_EnablePrinter, 2382). --define(wxPageSetupDialogData_GetDefaultMinMargins, 2383). --define(wxPageSetupDialogData_GetEnableMargins, 2384). --define(wxPageSetupDialogData_GetEnableOrientation, 2385). --define(wxPageSetupDialogData_GetEnablePaper, 2386). --define(wxPageSetupDialogData_GetEnablePrinter, 2387). --define(wxPageSetupDialogData_GetEnableHelp, 2388). --define(wxPageSetupDialogData_GetDefaultInfo, 2389). --define(wxPageSetupDialogData_GetMarginTopLeft, 2390). --define(wxPageSetupDialogData_GetMarginBottomRight, 2391). --define(wxPageSetupDialogData_GetMinMarginTopLeft, 2392). --define(wxPageSetupDialogData_GetMinMarginBottomRight, 2393). --define(wxPageSetupDialogData_GetPaperId, 2394). --define(wxPageSetupDialogData_GetPaperSize, 2395). --define(wxPageSetupDialogData_GetPrintData, 2397). --define(wxPageSetupDialogData_IsOk, 2398). --define(wxPageSetupDialogData_SetDefaultInfo, 2399). --define(wxPageSetupDialogData_SetDefaultMinMargins, 2400). --define(wxPageSetupDialogData_SetMarginTopLeft, 2401). --define(wxPageSetupDialogData_SetMarginBottomRight, 2402). --define(wxPageSetupDialogData_SetMinMarginTopLeft, 2403). --define(wxPageSetupDialogData_SetMinMarginBottomRight, 2404). --define(wxPageSetupDialogData_SetPaperId, 2405). --define(wxPageSetupDialogData_SetPaperSize_1_1, 2406). --define(wxPageSetupDialogData_SetPaperSize_1_0, 2407). --define(wxPageSetupDialogData_SetPrintData, 2408). --define(wxPrintDialog_new_2_0, 2409). --define(wxPrintDialog_new_2_1, 2410). --define(wxPrintDialog_destruct, 2411). --define(wxPrintDialog_GetPrintDialogData, 2412). --define(wxPrintDialog_GetPrintDC, 2413). --define(wxPrintDialogData_new_0, 2414). --define(wxPrintDialogData_new_1_1, 2415). --define(wxPrintDialogData_new_1_0, 2416). --define(wxPrintDialogData_destruct, 2417). --define(wxPrintDialogData_EnableHelp, 2418). --define(wxPrintDialogData_EnablePageNumbers, 2419). --define(wxPrintDialogData_EnablePrintToFile, 2420). --define(wxPrintDialogData_EnableSelection, 2421). --define(wxPrintDialogData_GetAllPages, 2422). --define(wxPrintDialogData_GetCollate, 2423). --define(wxPrintDialogData_GetFromPage, 2424). --define(wxPrintDialogData_GetMaxPage, 2425). --define(wxPrintDialogData_GetMinPage, 2426). --define(wxPrintDialogData_GetNoCopies, 2427). --define(wxPrintDialogData_GetPrintData, 2428). --define(wxPrintDialogData_GetPrintToFile, 2429). --define(wxPrintDialogData_GetSelection, 2430). --define(wxPrintDialogData_GetToPage, 2431). --define(wxPrintDialogData_IsOk, 2432). --define(wxPrintDialogData_SetCollate, 2433). --define(wxPrintDialogData_SetFromPage, 2434). --define(wxPrintDialogData_SetMaxPage, 2435). --define(wxPrintDialogData_SetMinPage, 2436). --define(wxPrintDialogData_SetNoCopies, 2437). --define(wxPrintDialogData_SetPrintData, 2438). --define(wxPrintDialogData_SetPrintToFile, 2439). --define(wxPrintDialogData_SetSelection, 2440). --define(wxPrintDialogData_SetToPage, 2441). --define(wxPrintData_new_0, 2442). --define(wxPrintData_new_1, 2443). --define(wxPrintData_destruct, 2444). --define(wxPrintData_GetCollate, 2445). --define(wxPrintData_GetBin, 2446). --define(wxPrintData_GetColour, 2447). --define(wxPrintData_GetDuplex, 2448). --define(wxPrintData_GetNoCopies, 2449). --define(wxPrintData_GetOrientation, 2450). --define(wxPrintData_GetPaperId, 2451). --define(wxPrintData_GetPrinterName, 2452). --define(wxPrintData_GetQuality, 2453). --define(wxPrintData_IsOk, 2454). --define(wxPrintData_SetBin, 2455). --define(wxPrintData_SetCollate, 2456). --define(wxPrintData_SetColour, 2457). --define(wxPrintData_SetDuplex, 2458). --define(wxPrintData_SetNoCopies, 2459). --define(wxPrintData_SetOrientation, 2460). --define(wxPrintData_SetPaperId, 2461). --define(wxPrintData_SetPrinterName, 2462). --define(wxPrintData_SetQuality, 2463). --define(wxPrintPreview_new_2, 2466). --define(wxPrintPreview_new_3, 2467). --define(wxPrintPreview_destruct, 2469). --define(wxPrintPreview_GetCanvas, 2470). --define(wxPrintPreview_GetCurrentPage, 2471). --define(wxPrintPreview_GetFrame, 2472). --define(wxPrintPreview_GetMaxPage, 2473). --define(wxPrintPreview_GetMinPage, 2474). --define(wxPrintPreview_GetPrintout, 2475). --define(wxPrintPreview_GetPrintoutForPrinting, 2476). --define(wxPrintPreview_IsOk, 2477). --define(wxPrintPreview_PaintPage, 2478). --define(wxPrintPreview_Print, 2479). --define(wxPrintPreview_RenderPage, 2480). --define(wxPrintPreview_SetCanvas, 2481). --define(wxPrintPreview_SetCurrentPage, 2482). --define(wxPrintPreview_SetFrame, 2483). --define(wxPrintPreview_SetPrintout, 2484). --define(wxPrintPreview_SetZoom, 2485). --define(wxPreviewFrame_new, 2486). --define(wxPreviewFrame_destruct, 2487). --define(wxPreviewFrame_CreateControlBar, 2488). --define(wxPreviewFrame_CreateCanvas, 2489). --define(wxPreviewFrame_Initialize, 2490). --define(wxPreviewFrame_OnCloseWindow, 2491). --define(wxPreviewControlBar_new, 2492). --define(wxPreviewControlBar_destruct, 2493). --define(wxPreviewControlBar_CreateButtons, 2494). --define(wxPreviewControlBar_GetPrintPreview, 2495). --define(wxPreviewControlBar_GetZoomControl, 2496). --define(wxPreviewControlBar_SetZoomControl, 2497). --define(wxPrinter_new, 2499). --define(wxPrinter_CreateAbortWindow, 2500). --define(wxPrinter_GetAbort, 2501). --define(wxPrinter_GetLastError, 2502). --define(wxPrinter_GetPrintDialogData, 2503). --define(wxPrinter_Print, 2504). --define(wxPrinter_PrintDialog, 2505). --define(wxPrinter_ReportError, 2506). --define(wxPrinter_Setup, 2507). --define(wxPrinter_destroy, 2508). --define(wxXmlResource_new_1, 2509). --define(wxXmlResource_new_2, 2510). --define(wxXmlResource_destruct, 2511). --define(wxXmlResource_AttachUnknownControl, 2512). --define(wxXmlResource_ClearHandlers, 2513). --define(wxXmlResource_CompareVersion, 2514). --define(wxXmlResource_Get, 2515). --define(wxXmlResource_GetFlags, 2516). --define(wxXmlResource_GetVersion, 2517). --define(wxXmlResource_GetXRCID, 2518). --define(wxXmlResource_InitAllHandlers, 2519). --define(wxXmlResource_Load, 2520). --define(wxXmlResource_LoadBitmap, 2521). --define(wxXmlResource_LoadDialog_2, 2522). --define(wxXmlResource_LoadDialog_3, 2523). --define(wxXmlResource_LoadFrame_2, 2524). --define(wxXmlResource_LoadFrame_3, 2525). --define(wxXmlResource_LoadIcon, 2526). --define(wxXmlResource_LoadMenu, 2527). --define(wxXmlResource_LoadMenuBar_2, 2528). --define(wxXmlResource_LoadMenuBar_1, 2529). --define(wxXmlResource_LoadPanel_2, 2530). --define(wxXmlResource_LoadPanel_3, 2531). --define(wxXmlResource_LoadToolBar, 2532). --define(wxXmlResource_Set, 2533). --define(wxXmlResource_SetFlags, 2534). --define(wxXmlResource_Unload, 2535). --define(wxXmlResource_xrcctrl, 2536). --define(wxHtmlEasyPrinting_new, 2537). --define(wxHtmlEasyPrinting_destruct, 2538). --define(wxHtmlEasyPrinting_GetPrintData, 2539). --define(wxHtmlEasyPrinting_GetPageSetupData, 2540). --define(wxHtmlEasyPrinting_PreviewFile, 2541). --define(wxHtmlEasyPrinting_PreviewText, 2542). --define(wxHtmlEasyPrinting_PrintFile, 2543). --define(wxHtmlEasyPrinting_PrintText, 2544). --define(wxHtmlEasyPrinting_PageSetup, 2545). --define(wxHtmlEasyPrinting_SetFonts, 2546). --define(wxHtmlEasyPrinting_SetHeader, 2547). --define(wxHtmlEasyPrinting_SetFooter, 2548). --define(wxGLCanvas_new_2, 2550). --define(wxGLCanvas_new_3_1, 2551). --define(wxGLCanvas_new_3_0, 2552). --define(wxGLCanvas_GetContext, 2553). --define(wxGLCanvas_SetCurrent, 2555). --define(wxGLCanvas_SwapBuffers, 2556). --define(wxGLCanvas_destroy, 2557). --define(wxAuiManager_new, 2558). --define(wxAuiManager_destruct, 2559). --define(wxAuiManager_AddPane_2_1, 2560). --define(wxAuiManager_AddPane_3, 2561). --define(wxAuiManager_AddPane_2_0, 2562). --define(wxAuiManager_DetachPane, 2563). --define(wxAuiManager_GetAllPanes, 2564). --define(wxAuiManager_GetArtProvider, 2565). --define(wxAuiManager_GetDockSizeConstraint, 2566). --define(wxAuiManager_GetFlags, 2567). --define(wxAuiManager_GetManagedWindow, 2568). --define(wxAuiManager_GetManager, 2569). --define(wxAuiManager_GetPane_1_1, 2570). --define(wxAuiManager_GetPane_1_0, 2571). --define(wxAuiManager_HideHint, 2572). --define(wxAuiManager_InsertPane, 2573). --define(wxAuiManager_LoadPaneInfo, 2574). --define(wxAuiManager_LoadPerspective, 2575). --define(wxAuiManager_SavePaneInfo, 2576). --define(wxAuiManager_SavePerspective, 2577). --define(wxAuiManager_SetArtProvider, 2578). --define(wxAuiManager_SetDockSizeConstraint, 2579). --define(wxAuiManager_SetFlags, 2580). --define(wxAuiManager_SetManagedWindow, 2581). --define(wxAuiManager_ShowHint, 2582). --define(wxAuiManager_UnInit, 2583). --define(wxAuiManager_Update, 2584). --define(wxAuiPaneInfo_new_0, 2585). --define(wxAuiPaneInfo_new_1, 2586). --define(wxAuiPaneInfo_destruct, 2587). --define(wxAuiPaneInfo_BestSize_1, 2588). --define(wxAuiPaneInfo_BestSize_2, 2589). --define(wxAuiPaneInfo_Bottom, 2590). --define(wxAuiPaneInfo_BottomDockable, 2591). --define(wxAuiPaneInfo_Caption, 2592). --define(wxAuiPaneInfo_CaptionVisible, 2593). --define(wxAuiPaneInfo_Centre, 2594). --define(wxAuiPaneInfo_CentrePane, 2595). --define(wxAuiPaneInfo_CloseButton, 2596). --define(wxAuiPaneInfo_DefaultPane, 2597). --define(wxAuiPaneInfo_DestroyOnClose, 2598). --define(wxAuiPaneInfo_Direction, 2599). --define(wxAuiPaneInfo_Dock, 2600). --define(wxAuiPaneInfo_Dockable, 2601). --define(wxAuiPaneInfo_Fixed, 2602). --define(wxAuiPaneInfo_Float, 2603). --define(wxAuiPaneInfo_Floatable, 2604). --define(wxAuiPaneInfo_FloatingPosition_1, 2605). --define(wxAuiPaneInfo_FloatingPosition_2, 2606). --define(wxAuiPaneInfo_FloatingSize_1, 2607). --define(wxAuiPaneInfo_FloatingSize_2, 2608). --define(wxAuiPaneInfo_Gripper, 2609). --define(wxAuiPaneInfo_GripperTop, 2610). --define(wxAuiPaneInfo_HasBorder, 2611). --define(wxAuiPaneInfo_HasCaption, 2612). --define(wxAuiPaneInfo_HasCloseButton, 2613). --define(wxAuiPaneInfo_HasFlag, 2614). --define(wxAuiPaneInfo_HasGripper, 2615). --define(wxAuiPaneInfo_HasGripperTop, 2616). --define(wxAuiPaneInfo_HasMaximizeButton, 2617). --define(wxAuiPaneInfo_HasMinimizeButton, 2618). --define(wxAuiPaneInfo_HasPinButton, 2619). --define(wxAuiPaneInfo_Hide, 2620). --define(wxAuiPaneInfo_IsBottomDockable, 2621). --define(wxAuiPaneInfo_IsDocked, 2622). --define(wxAuiPaneInfo_IsFixed, 2623). --define(wxAuiPaneInfo_IsFloatable, 2624). --define(wxAuiPaneInfo_IsFloating, 2625). --define(wxAuiPaneInfo_IsLeftDockable, 2626). --define(wxAuiPaneInfo_IsMovable, 2627). --define(wxAuiPaneInfo_IsOk, 2628). --define(wxAuiPaneInfo_IsResizable, 2629). --define(wxAuiPaneInfo_IsRightDockable, 2630). --define(wxAuiPaneInfo_IsShown, 2631). --define(wxAuiPaneInfo_IsToolbar, 2632). --define(wxAuiPaneInfo_IsTopDockable, 2633). --define(wxAuiPaneInfo_Layer, 2634). --define(wxAuiPaneInfo_Left, 2635). --define(wxAuiPaneInfo_LeftDockable, 2636). --define(wxAuiPaneInfo_MaxSize_1, 2637). --define(wxAuiPaneInfo_MaxSize_2, 2638). --define(wxAuiPaneInfo_MaximizeButton, 2639). --define(wxAuiPaneInfo_MinSize_1, 2640). --define(wxAuiPaneInfo_MinSize_2, 2641). --define(wxAuiPaneInfo_MinimizeButton, 2642). --define(wxAuiPaneInfo_Movable, 2643). --define(wxAuiPaneInfo_Name, 2644). --define(wxAuiPaneInfo_PaneBorder, 2645). --define(wxAuiPaneInfo_PinButton, 2646). --define(wxAuiPaneInfo_Position, 2647). --define(wxAuiPaneInfo_Resizable, 2648). --define(wxAuiPaneInfo_Right, 2649). --define(wxAuiPaneInfo_RightDockable, 2650). --define(wxAuiPaneInfo_Row, 2651). --define(wxAuiPaneInfo_SafeSet, 2652). --define(wxAuiPaneInfo_SetFlag, 2653). --define(wxAuiPaneInfo_Show, 2654). --define(wxAuiPaneInfo_ToolbarPane, 2655). --define(wxAuiPaneInfo_Top, 2656). --define(wxAuiPaneInfo_TopDockable, 2657). --define(wxAuiPaneInfo_Window, 2658). --define(wxAuiPaneInfo_GetWindow, 2659). --define(wxAuiPaneInfo_GetFrame, 2660). --define(wxAuiPaneInfo_GetDirection, 2661). --define(wxAuiPaneInfo_GetLayer, 2662). --define(wxAuiPaneInfo_GetRow, 2663). --define(wxAuiPaneInfo_GetPosition, 2664). --define(wxAuiPaneInfo_GetFloatingPosition, 2665). --define(wxAuiPaneInfo_GetFloatingSize, 2666). --define(wxAuiNotebook_new_0, 2667). --define(wxAuiNotebook_new_2, 2668). --define(wxAuiNotebook_AddPage, 2669). --define(wxAuiNotebook_Create, 2670). --define(wxAuiNotebook_DeletePage, 2671). --define(wxAuiNotebook_GetArtProvider, 2672). --define(wxAuiNotebook_GetPage, 2673). --define(wxAuiNotebook_GetPageBitmap, 2674). --define(wxAuiNotebook_GetPageCount, 2675). --define(wxAuiNotebook_GetPageIndex, 2676). --define(wxAuiNotebook_GetPageText, 2677). --define(wxAuiNotebook_GetSelection, 2678). --define(wxAuiNotebook_InsertPage, 2679). --define(wxAuiNotebook_RemovePage, 2680). --define(wxAuiNotebook_SetArtProvider, 2681). --define(wxAuiNotebook_SetFont, 2682). --define(wxAuiNotebook_SetPageBitmap, 2683). --define(wxAuiNotebook_SetPageText, 2684). --define(wxAuiNotebook_SetSelection, 2685). --define(wxAuiNotebook_SetTabCtrlHeight, 2686). --define(wxAuiNotebook_SetUniformBitmapSize, 2687). --define(wxAuiNotebook_destroy, 2688). --define(wxAuiTabArt_SetFlags, 2689). --define(wxAuiTabArt_SetMeasuringFont, 2690). --define(wxAuiTabArt_SetNormalFont, 2691). --define(wxAuiTabArt_SetSelectedFont, 2692). --define(wxAuiTabArt_SetColour, 2693). --define(wxAuiTabArt_SetActiveColour, 2694). --define(wxAuiDockArt_GetColour, 2695). --define(wxAuiDockArt_GetFont, 2696). --define(wxAuiDockArt_GetMetric, 2697). --define(wxAuiDockArt_SetColour, 2698). --define(wxAuiDockArt_SetFont, 2699). --define(wxAuiDockArt_SetMetric, 2700). --define(wxAuiSimpleTabArt_new, 2701). --define(wxAuiSimpleTabArt_destroy, 2702). --define(wxMDIParentFrame_new_0, 2703). --define(wxMDIParentFrame_new_4, 2704). --define(wxMDIParentFrame_destruct, 2705). --define(wxMDIParentFrame_ActivateNext, 2706). --define(wxMDIParentFrame_ActivatePrevious, 2707). --define(wxMDIParentFrame_ArrangeIcons, 2708). --define(wxMDIParentFrame_Cascade, 2709). --define(wxMDIParentFrame_Create, 2710). --define(wxMDIParentFrame_GetActiveChild, 2711). --define(wxMDIParentFrame_GetClientWindow, 2712). --define(wxMDIParentFrame_Tile, 2713). --define(wxMDIChildFrame_new_0, 2714). --define(wxMDIChildFrame_new_4, 2715). --define(wxMDIChildFrame_destruct, 2716). --define(wxMDIChildFrame_Activate, 2717). --define(wxMDIChildFrame_Create, 2718). --define(wxMDIChildFrame_Maximize, 2719). --define(wxMDIChildFrame_Restore, 2720). --define(wxMDIClientWindow_new_0, 2721). --define(wxMDIClientWindow_new_2, 2722). --define(wxMDIClientWindow_destruct, 2723). --define(wxMDIClientWindow_CreateClient, 2724). --define(wxLayoutAlgorithm_new, 2725). --define(wxLayoutAlgorithm_LayoutFrame, 2726). --define(wxLayoutAlgorithm_LayoutMDIFrame, 2727). --define(wxLayoutAlgorithm_LayoutWindow, 2728). --define(wxLayoutAlgorithm_destroy, 2729). --define(wxEvent_GetId, 2730). --define(wxEvent_GetSkipped, 2731). --define(wxEvent_GetTimestamp, 2732). --define(wxEvent_IsCommandEvent, 2733). --define(wxEvent_ResumePropagation, 2734). --define(wxEvent_ShouldPropagate, 2735). --define(wxEvent_Skip, 2736). --define(wxEvent_StopPropagation, 2737). --define(wxCommandEvent_getClientData, 2738). --define(wxCommandEvent_GetExtraLong, 2739). --define(wxCommandEvent_GetInt, 2740). --define(wxCommandEvent_GetSelection, 2741). --define(wxCommandEvent_GetString, 2742). --define(wxCommandEvent_IsChecked, 2743). --define(wxCommandEvent_IsSelection, 2744). --define(wxCommandEvent_SetInt, 2745). --define(wxCommandEvent_SetString, 2746). --define(wxScrollEvent_GetOrientation, 2747). --define(wxScrollEvent_GetPosition, 2748). --define(wxScrollWinEvent_GetOrientation, 2749). --define(wxScrollWinEvent_GetPosition, 2750). --define(wxMouseEvent_AltDown, 2751). --define(wxMouseEvent_Button, 2752). --define(wxMouseEvent_ButtonDClick, 2753). --define(wxMouseEvent_ButtonDown, 2754). --define(wxMouseEvent_ButtonUp, 2755). --define(wxMouseEvent_CmdDown, 2756). --define(wxMouseEvent_ControlDown, 2757). --define(wxMouseEvent_Dragging, 2758). --define(wxMouseEvent_Entering, 2759). --define(wxMouseEvent_GetButton, 2760). --define(wxMouseEvent_GetPosition, 2763). --define(wxMouseEvent_GetLogicalPosition, 2764). --define(wxMouseEvent_GetLinesPerAction, 2765). --define(wxMouseEvent_GetWheelRotation, 2766). --define(wxMouseEvent_GetWheelDelta, 2767). --define(wxMouseEvent_GetX, 2768). --define(wxMouseEvent_GetY, 2769). --define(wxMouseEvent_IsButton, 2770). --define(wxMouseEvent_IsPageScroll, 2771). --define(wxMouseEvent_Leaving, 2772). --define(wxMouseEvent_LeftDClick, 2773). --define(wxMouseEvent_LeftDown, 2774). --define(wxMouseEvent_LeftIsDown, 2775). --define(wxMouseEvent_LeftUp, 2776). --define(wxMouseEvent_MetaDown, 2777). --define(wxMouseEvent_MiddleDClick, 2778). --define(wxMouseEvent_MiddleDown, 2779). --define(wxMouseEvent_MiddleIsDown, 2780). --define(wxMouseEvent_MiddleUp, 2781). --define(wxMouseEvent_Moving, 2782). --define(wxMouseEvent_RightDClick, 2783). --define(wxMouseEvent_RightDown, 2784). --define(wxMouseEvent_RightIsDown, 2785). --define(wxMouseEvent_RightUp, 2786). --define(wxMouseEvent_ShiftDown, 2787). --define(wxSetCursorEvent_GetCursor, 2788). --define(wxSetCursorEvent_GetX, 2789). --define(wxSetCursorEvent_GetY, 2790). --define(wxSetCursorEvent_HasCursor, 2791). --define(wxSetCursorEvent_SetCursor, 2792). --define(wxKeyEvent_AltDown, 2793). --define(wxKeyEvent_CmdDown, 2794). --define(wxKeyEvent_ControlDown, 2795). --define(wxKeyEvent_GetKeyCode, 2796). --define(wxKeyEvent_GetModifiers, 2797). --define(wxKeyEvent_GetPosition, 2800). --define(wxKeyEvent_GetRawKeyCode, 2801). --define(wxKeyEvent_GetRawKeyFlags, 2802). --define(wxKeyEvent_GetUnicodeKey, 2803). --define(wxKeyEvent_GetX, 2804). --define(wxKeyEvent_GetY, 2805). --define(wxKeyEvent_HasModifiers, 2806). --define(wxKeyEvent_MetaDown, 2807). --define(wxKeyEvent_ShiftDown, 2808). --define(wxSizeEvent_GetSize, 2809). --define(wxMoveEvent_GetPosition, 2810). --define(wxEraseEvent_GetDC, 2811). --define(wxFocusEvent_GetWindow, 2812). --define(wxChildFocusEvent_GetWindow, 2813). --define(wxMenuEvent_GetMenu, 2814). --define(wxMenuEvent_GetMenuId, 2815). --define(wxMenuEvent_IsPopup, 2816). --define(wxCloseEvent_CanVeto, 2817). --define(wxCloseEvent_GetLoggingOff, 2818). --define(wxCloseEvent_SetCanVeto, 2819). --define(wxCloseEvent_SetLoggingOff, 2820). --define(wxCloseEvent_Veto, 2821). --define(wxShowEvent_SetShow, 2822). --define(wxShowEvent_GetShow, 2823). --define(wxIconizeEvent_Iconized, 2824). --define(wxJoystickEvent_ButtonDown, 2825). --define(wxJoystickEvent_ButtonIsDown, 2826). --define(wxJoystickEvent_ButtonUp, 2827). --define(wxJoystickEvent_GetButtonChange, 2828). --define(wxJoystickEvent_GetButtonState, 2829). --define(wxJoystickEvent_GetJoystick, 2830). --define(wxJoystickEvent_GetPosition, 2831). --define(wxJoystickEvent_GetZPosition, 2832). --define(wxJoystickEvent_IsButton, 2833). --define(wxJoystickEvent_IsMove, 2834). --define(wxJoystickEvent_IsZMove, 2835). --define(wxUpdateUIEvent_CanUpdate, 2836). --define(wxUpdateUIEvent_Check, 2837). --define(wxUpdateUIEvent_Enable, 2838). --define(wxUpdateUIEvent_Show, 2839). --define(wxUpdateUIEvent_GetChecked, 2840). --define(wxUpdateUIEvent_GetEnabled, 2841). --define(wxUpdateUIEvent_GetShown, 2842). --define(wxUpdateUIEvent_GetSetChecked, 2843). --define(wxUpdateUIEvent_GetSetEnabled, 2844). --define(wxUpdateUIEvent_GetSetShown, 2845). --define(wxUpdateUIEvent_GetSetText, 2846). --define(wxUpdateUIEvent_GetText, 2847). --define(wxUpdateUIEvent_GetMode, 2848). --define(wxUpdateUIEvent_GetUpdateInterval, 2849). --define(wxUpdateUIEvent_ResetUpdateTime, 2850). --define(wxUpdateUIEvent_SetMode, 2851). --define(wxUpdateUIEvent_SetText, 2852). --define(wxUpdateUIEvent_SetUpdateInterval, 2853). --define(wxMouseCaptureChangedEvent_GetCapturedWindow, 2854). --define(wxPaletteChangedEvent_SetChangedWindow, 2855). --define(wxPaletteChangedEvent_GetChangedWindow, 2856). --define(wxQueryNewPaletteEvent_SetPaletteRealized, 2857). --define(wxQueryNewPaletteEvent_GetPaletteRealized, 2858). --define(wxNavigationKeyEvent_GetDirection, 2859). --define(wxNavigationKeyEvent_SetDirection, 2860). --define(wxNavigationKeyEvent_IsWindowChange, 2861). --define(wxNavigationKeyEvent_SetWindowChange, 2862). --define(wxNavigationKeyEvent_IsFromTab, 2863). --define(wxNavigationKeyEvent_SetFromTab, 2864). --define(wxNavigationKeyEvent_GetCurrentFocus, 2865). --define(wxNavigationKeyEvent_SetCurrentFocus, 2866). --define(wxHelpEvent_GetOrigin, 2867). --define(wxHelpEvent_GetPosition, 2868). --define(wxHelpEvent_SetOrigin, 2869). --define(wxHelpEvent_SetPosition, 2870). --define(wxContextMenuEvent_GetPosition, 2871). --define(wxContextMenuEvent_SetPosition, 2872). --define(wxIdleEvent_CanSend, 2873). --define(wxIdleEvent_GetMode, 2874). --define(wxIdleEvent_RequestMore, 2875). --define(wxIdleEvent_MoreRequested, 2876). --define(wxIdleEvent_SetMode, 2877). --define(wxGridEvent_AltDown, 2878). --define(wxGridEvent_ControlDown, 2879). --define(wxGridEvent_GetCol, 2880). --define(wxGridEvent_GetPosition, 2881). --define(wxGridEvent_GetRow, 2882). --define(wxGridEvent_MetaDown, 2883). --define(wxGridEvent_Selecting, 2884). --define(wxGridEvent_ShiftDown, 2885). --define(wxNotifyEvent_Allow, 2886). --define(wxNotifyEvent_IsAllowed, 2887). --define(wxNotifyEvent_Veto, 2888). --define(wxSashEvent_GetEdge, 2889). --define(wxSashEvent_GetDragRect, 2890). --define(wxSashEvent_GetDragStatus, 2891). --define(wxListEvent_GetCacheFrom, 2892). --define(wxListEvent_GetCacheTo, 2893). --define(wxListEvent_GetKeyCode, 2894). --define(wxListEvent_GetIndex, 2895). --define(wxListEvent_GetColumn, 2896). --define(wxListEvent_GetPoint, 2897). --define(wxListEvent_GetLabel, 2898). --define(wxListEvent_GetText, 2899). --define(wxListEvent_GetImage, 2900). --define(wxListEvent_GetData, 2901). --define(wxListEvent_GetMask, 2902). --define(wxListEvent_GetItem, 2903). --define(wxListEvent_IsEditCancelled, 2904). --define(wxDateEvent_GetDate, 2905). --define(wxCalendarEvent_GetWeekDay, 2906). --define(wxFileDirPickerEvent_GetPath, 2907). --define(wxColourPickerEvent_GetColour, 2908). --define(wxFontPickerEvent_GetFont, 2909). --define(wxStyledTextEvent_GetPosition, 2910). --define(wxStyledTextEvent_GetKey, 2911). --define(wxStyledTextEvent_GetModifiers, 2912). --define(wxStyledTextEvent_GetModificationType, 2913). --define(wxStyledTextEvent_GetText, 2914). --define(wxStyledTextEvent_GetLength, 2915). --define(wxStyledTextEvent_GetLinesAdded, 2916). --define(wxStyledTextEvent_GetLine, 2917). --define(wxStyledTextEvent_GetFoldLevelNow, 2918). --define(wxStyledTextEvent_GetFoldLevelPrev, 2919). --define(wxStyledTextEvent_GetMargin, 2920). --define(wxStyledTextEvent_GetMessage, 2921). --define(wxStyledTextEvent_GetWParam, 2922). --define(wxStyledTextEvent_GetLParam, 2923). --define(wxStyledTextEvent_GetListType, 2924). --define(wxStyledTextEvent_GetX, 2925). --define(wxStyledTextEvent_GetY, 2926). --define(wxStyledTextEvent_GetDragText, 2927). --define(wxStyledTextEvent_GetDragAllowMove, 2928). --define(wxStyledTextEvent_GetDragResult, 2929). --define(wxStyledTextEvent_GetShift, 2930). --define(wxStyledTextEvent_GetControl, 2931). --define(wxStyledTextEvent_GetAlt, 2932). --define(utils_wxGetKeyState, 2933). --define(utils_wxGetMousePosition, 2934). --define(utils_wxGetMouseState, 2935). --define(utils_wxSetDetectableAutoRepeat, 2936). --define(utils_wxBell, 2937). --define(utils_wxFindMenuItemId, 2938). --define(utils_wxGenericFindWindowAtPoint, 2939). --define(utils_wxFindWindowAtPoint, 2940). --define(utils_wxBeginBusyCursor, 2941). --define(utils_wxEndBusyCursor, 2942). --define(utils_wxIsBusy, 2943). --define(utils_wxShutdown, 2944). --define(utils_wxShell, 2945). --define(utils_wxLaunchDefaultBrowser, 2946). --define(utils_wxGetEmailAddress, 2947). --define(utils_wxGetUserId, 2948). --define(utils_wxGetHomeDir, 2949). --define(utils_wxNewId, 2950). --define(utils_wxRegisterId, 2951). --define(utils_wxGetCurrentId, 2952). --define(utils_wxGetOsDescription, 2953). --define(utils_wxIsPlatformLittleEndian, 2954). --define(utils_wxIsPlatform64Bit, 2955). --define(gdicmn_wxDisplaySize, 2956). --define(gdicmn_wxSetCursor, 2957). --define(wxPrintout_new, 2958). --define(wxPrintout_destruct, 2959). --define(wxPrintout_GetDC, 2960). --define(wxPrintout_GetPageSizeMM, 2961). --define(wxPrintout_GetPageSizePixels, 2962). --define(wxPrintout_GetPaperRectPixels, 2963). --define(wxPrintout_GetPPIPrinter, 2964). --define(wxPrintout_GetPPIScreen, 2965). --define(wxPrintout_GetTitle, 2966). --define(wxPrintout_IsPreview, 2967). --define(wxPrintout_FitThisSizeToPaper, 2968). --define(wxPrintout_FitThisSizeToPage, 2969). --define(wxPrintout_FitThisSizeToPageMargins, 2970). --define(wxPrintout_MapScreenSizeToPaper, 2971). --define(wxPrintout_MapScreenSizeToPage, 2972). --define(wxPrintout_MapScreenSizeToPageMargins, 2973). --define(wxPrintout_MapScreenSizeToDevice, 2974). --define(wxPrintout_GetLogicalPaperRect, 2975). --define(wxPrintout_GetLogicalPageRect, 2976). --define(wxPrintout_GetLogicalPageMarginsRect, 2977). --define(wxPrintout_SetLogicalOrigin, 2978). --define(wxPrintout_OffsetLogicalOrigin, 2979). --define(wxStyledTextCtrl_new_2, 2980). --define(wxStyledTextCtrl_new_0, 2981). --define(wxStyledTextCtrl_destruct, 2982). --define(wxStyledTextCtrl_Create, 2983). --define(wxStyledTextCtrl_AddText, 2984). --define(wxStyledTextCtrl_AddStyledText, 2985). --define(wxStyledTextCtrl_InsertText, 2986). --define(wxStyledTextCtrl_ClearAll, 2987). --define(wxStyledTextCtrl_ClearDocumentStyle, 2988). --define(wxStyledTextCtrl_GetLength, 2989). --define(wxStyledTextCtrl_GetCharAt, 2990). --define(wxStyledTextCtrl_GetCurrentPos, 2991). --define(wxStyledTextCtrl_GetAnchor, 2992). --define(wxStyledTextCtrl_GetStyleAt, 2993). --define(wxStyledTextCtrl_Redo, 2994). --define(wxStyledTextCtrl_SetUndoCollection, 2995). --define(wxStyledTextCtrl_SelectAll, 2996). --define(wxStyledTextCtrl_SetSavePoint, 2997). --define(wxStyledTextCtrl_GetStyledText, 2998). --define(wxStyledTextCtrl_CanRedo, 2999). --define(wxStyledTextCtrl_MarkerLineFromHandle, 3000). --define(wxStyledTextCtrl_MarkerDeleteHandle, 3001). --define(wxStyledTextCtrl_GetUndoCollection, 3002). --define(wxStyledTextCtrl_GetViewWhiteSpace, 3003). --define(wxStyledTextCtrl_SetViewWhiteSpace, 3004). --define(wxStyledTextCtrl_PositionFromPoint, 3005). --define(wxStyledTextCtrl_PositionFromPointClose, 3006). --define(wxStyledTextCtrl_GotoLine, 3007). --define(wxStyledTextCtrl_GotoPos, 3008). --define(wxStyledTextCtrl_SetAnchor, 3009). --define(wxStyledTextCtrl_GetCurLine, 3010). --define(wxStyledTextCtrl_GetEndStyled, 3011). --define(wxStyledTextCtrl_ConvertEOLs, 3012). --define(wxStyledTextCtrl_GetEOLMode, 3013). --define(wxStyledTextCtrl_SetEOLMode, 3014). --define(wxStyledTextCtrl_StartStyling, 3015). --define(wxStyledTextCtrl_SetStyling, 3016). --define(wxStyledTextCtrl_GetBufferedDraw, 3017). --define(wxStyledTextCtrl_SetBufferedDraw, 3018). --define(wxStyledTextCtrl_SetTabWidth, 3019). --define(wxStyledTextCtrl_GetTabWidth, 3020). --define(wxStyledTextCtrl_SetCodePage, 3021). --define(wxStyledTextCtrl_MarkerDefine, 3022). --define(wxStyledTextCtrl_MarkerSetForeground, 3023). --define(wxStyledTextCtrl_MarkerSetBackground, 3024). --define(wxStyledTextCtrl_MarkerAdd, 3025). --define(wxStyledTextCtrl_MarkerDelete, 3026). --define(wxStyledTextCtrl_MarkerDeleteAll, 3027). --define(wxStyledTextCtrl_MarkerGet, 3028). --define(wxStyledTextCtrl_MarkerNext, 3029). --define(wxStyledTextCtrl_MarkerPrevious, 3030). --define(wxStyledTextCtrl_MarkerDefineBitmap, 3031). --define(wxStyledTextCtrl_MarkerAddSet, 3032). --define(wxStyledTextCtrl_MarkerSetAlpha, 3033). --define(wxStyledTextCtrl_SetMarginType, 3034). --define(wxStyledTextCtrl_GetMarginType, 3035). --define(wxStyledTextCtrl_SetMarginWidth, 3036). --define(wxStyledTextCtrl_GetMarginWidth, 3037). --define(wxStyledTextCtrl_SetMarginMask, 3038). --define(wxStyledTextCtrl_GetMarginMask, 3039). --define(wxStyledTextCtrl_SetMarginSensitive, 3040). --define(wxStyledTextCtrl_GetMarginSensitive, 3041). --define(wxStyledTextCtrl_StyleClearAll, 3042). --define(wxStyledTextCtrl_StyleSetForeground, 3043). --define(wxStyledTextCtrl_StyleSetBackground, 3044). --define(wxStyledTextCtrl_StyleSetBold, 3045). --define(wxStyledTextCtrl_StyleSetItalic, 3046). --define(wxStyledTextCtrl_StyleSetSize, 3047). --define(wxStyledTextCtrl_StyleSetFaceName, 3048). --define(wxStyledTextCtrl_StyleSetEOLFilled, 3049). --define(wxStyledTextCtrl_StyleResetDefault, 3050). --define(wxStyledTextCtrl_StyleSetUnderline, 3051). --define(wxStyledTextCtrl_StyleSetCase, 3052). --define(wxStyledTextCtrl_StyleSetHotSpot, 3053). --define(wxStyledTextCtrl_SetSelForeground, 3054). --define(wxStyledTextCtrl_SetSelBackground, 3055). --define(wxStyledTextCtrl_GetSelAlpha, 3056). --define(wxStyledTextCtrl_SetSelAlpha, 3057). --define(wxStyledTextCtrl_SetCaretForeground, 3058). --define(wxStyledTextCtrl_CmdKeyAssign, 3059). --define(wxStyledTextCtrl_CmdKeyClear, 3060). --define(wxStyledTextCtrl_CmdKeyClearAll, 3061). --define(wxStyledTextCtrl_SetStyleBytes, 3062). --define(wxStyledTextCtrl_StyleSetVisible, 3063). --define(wxStyledTextCtrl_GetCaretPeriod, 3064). --define(wxStyledTextCtrl_SetCaretPeriod, 3065). --define(wxStyledTextCtrl_SetWordChars, 3066). --define(wxStyledTextCtrl_BeginUndoAction, 3067). --define(wxStyledTextCtrl_EndUndoAction, 3068). --define(wxStyledTextCtrl_IndicatorSetStyle, 3069). --define(wxStyledTextCtrl_IndicatorGetStyle, 3070). --define(wxStyledTextCtrl_IndicatorSetForeground, 3071). --define(wxStyledTextCtrl_IndicatorGetForeground, 3072). --define(wxStyledTextCtrl_SetWhitespaceForeground, 3073). --define(wxStyledTextCtrl_SetWhitespaceBackground, 3074). --define(wxStyledTextCtrl_GetStyleBits, 3075). --define(wxStyledTextCtrl_SetLineState, 3076). --define(wxStyledTextCtrl_GetLineState, 3077). --define(wxStyledTextCtrl_GetMaxLineState, 3078). --define(wxStyledTextCtrl_GetCaretLineVisible, 3079). --define(wxStyledTextCtrl_SetCaretLineVisible, 3080). --define(wxStyledTextCtrl_GetCaretLineBackground, 3081). --define(wxStyledTextCtrl_SetCaretLineBackground, 3082). --define(wxStyledTextCtrl_AutoCompShow, 3083). --define(wxStyledTextCtrl_AutoCompCancel, 3084). --define(wxStyledTextCtrl_AutoCompActive, 3085). --define(wxStyledTextCtrl_AutoCompPosStart, 3086). --define(wxStyledTextCtrl_AutoCompComplete, 3087). --define(wxStyledTextCtrl_AutoCompStops, 3088). --define(wxStyledTextCtrl_AutoCompSetSeparator, 3089). --define(wxStyledTextCtrl_AutoCompGetSeparator, 3090). --define(wxStyledTextCtrl_AutoCompSelect, 3091). --define(wxStyledTextCtrl_AutoCompSetCancelAtStart, 3092). --define(wxStyledTextCtrl_AutoCompGetCancelAtStart, 3093). --define(wxStyledTextCtrl_AutoCompSetFillUps, 3094). --define(wxStyledTextCtrl_AutoCompSetChooseSingle, 3095). --define(wxStyledTextCtrl_AutoCompGetChooseSingle, 3096). --define(wxStyledTextCtrl_AutoCompSetIgnoreCase, 3097). --define(wxStyledTextCtrl_AutoCompGetIgnoreCase, 3098). --define(wxStyledTextCtrl_UserListShow, 3099). --define(wxStyledTextCtrl_AutoCompSetAutoHide, 3100). --define(wxStyledTextCtrl_AutoCompGetAutoHide, 3101). --define(wxStyledTextCtrl_AutoCompSetDropRestOfWord, 3102). --define(wxStyledTextCtrl_AutoCompGetDropRestOfWord, 3103). --define(wxStyledTextCtrl_RegisterImage, 3104). --define(wxStyledTextCtrl_ClearRegisteredImages, 3105). --define(wxStyledTextCtrl_AutoCompGetTypeSeparator, 3106). --define(wxStyledTextCtrl_AutoCompSetTypeSeparator, 3107). --define(wxStyledTextCtrl_AutoCompSetMaxWidth, 3108). --define(wxStyledTextCtrl_AutoCompGetMaxWidth, 3109). --define(wxStyledTextCtrl_AutoCompSetMaxHeight, 3110). --define(wxStyledTextCtrl_AutoCompGetMaxHeight, 3111). --define(wxStyledTextCtrl_SetIndent, 3112). --define(wxStyledTextCtrl_GetIndent, 3113). --define(wxStyledTextCtrl_SetUseTabs, 3114). --define(wxStyledTextCtrl_GetUseTabs, 3115). --define(wxStyledTextCtrl_SetLineIndentation, 3116). --define(wxStyledTextCtrl_GetLineIndentation, 3117). --define(wxStyledTextCtrl_GetLineIndentPosition, 3118). --define(wxStyledTextCtrl_GetColumn, 3119). --define(wxStyledTextCtrl_SetUseHorizontalScrollBar, 3120). --define(wxStyledTextCtrl_GetUseHorizontalScrollBar, 3121). --define(wxStyledTextCtrl_SetIndentationGuides, 3122). --define(wxStyledTextCtrl_GetIndentationGuides, 3123). --define(wxStyledTextCtrl_SetHighlightGuide, 3124). --define(wxStyledTextCtrl_GetHighlightGuide, 3125). --define(wxStyledTextCtrl_GetLineEndPosition, 3126). --define(wxStyledTextCtrl_GetCodePage, 3127). --define(wxStyledTextCtrl_GetCaretForeground, 3128). --define(wxStyledTextCtrl_GetReadOnly, 3129). --define(wxStyledTextCtrl_SetCurrentPos, 3130). --define(wxStyledTextCtrl_SetSelectionStart, 3131). --define(wxStyledTextCtrl_GetSelectionStart, 3132). --define(wxStyledTextCtrl_SetSelectionEnd, 3133). --define(wxStyledTextCtrl_GetSelectionEnd, 3134). --define(wxStyledTextCtrl_SetPrintMagnification, 3135). --define(wxStyledTextCtrl_GetPrintMagnification, 3136). --define(wxStyledTextCtrl_SetPrintColourMode, 3137). --define(wxStyledTextCtrl_GetPrintColourMode, 3138). --define(wxStyledTextCtrl_FindText, 3139). --define(wxStyledTextCtrl_FormatRange, 3140). --define(wxStyledTextCtrl_GetFirstVisibleLine, 3141). --define(wxStyledTextCtrl_GetLine, 3142). --define(wxStyledTextCtrl_GetLineCount, 3143). --define(wxStyledTextCtrl_SetMarginLeft, 3144). --define(wxStyledTextCtrl_GetMarginLeft, 3145). --define(wxStyledTextCtrl_SetMarginRight, 3146). --define(wxStyledTextCtrl_GetMarginRight, 3147). --define(wxStyledTextCtrl_GetModify, 3148). --define(wxStyledTextCtrl_SetSelection, 3149). --define(wxStyledTextCtrl_GetSelectedText, 3150). --define(wxStyledTextCtrl_GetTextRange, 3151). --define(wxStyledTextCtrl_HideSelection, 3152). --define(wxStyledTextCtrl_LineFromPosition, 3153). --define(wxStyledTextCtrl_PositionFromLine, 3154). --define(wxStyledTextCtrl_LineScroll, 3155). --define(wxStyledTextCtrl_EnsureCaretVisible, 3156). --define(wxStyledTextCtrl_ReplaceSelection, 3157). --define(wxStyledTextCtrl_SetReadOnly, 3158). --define(wxStyledTextCtrl_CanPaste, 3159). --define(wxStyledTextCtrl_CanUndo, 3160). --define(wxStyledTextCtrl_EmptyUndoBuffer, 3161). --define(wxStyledTextCtrl_Undo, 3162). --define(wxStyledTextCtrl_Cut, 3163). --define(wxStyledTextCtrl_Copy, 3164). --define(wxStyledTextCtrl_Paste, 3165). --define(wxStyledTextCtrl_Clear, 3166). --define(wxStyledTextCtrl_SetText, 3167). --define(wxStyledTextCtrl_GetText, 3168). --define(wxStyledTextCtrl_GetTextLength, 3169). --define(wxStyledTextCtrl_GetOvertype, 3170). --define(wxStyledTextCtrl_SetCaretWidth, 3171). --define(wxStyledTextCtrl_GetCaretWidth, 3172). --define(wxStyledTextCtrl_SetTargetStart, 3173). --define(wxStyledTextCtrl_GetTargetStart, 3174). --define(wxStyledTextCtrl_SetTargetEnd, 3175). --define(wxStyledTextCtrl_GetTargetEnd, 3176). --define(wxStyledTextCtrl_ReplaceTarget, 3177). --define(wxStyledTextCtrl_SearchInTarget, 3178). --define(wxStyledTextCtrl_SetSearchFlags, 3179). --define(wxStyledTextCtrl_GetSearchFlags, 3180). --define(wxStyledTextCtrl_CallTipShow, 3181). --define(wxStyledTextCtrl_CallTipCancel, 3182). --define(wxStyledTextCtrl_CallTipActive, 3183). --define(wxStyledTextCtrl_CallTipPosAtStart, 3184). --define(wxStyledTextCtrl_CallTipSetHighlight, 3185). --define(wxStyledTextCtrl_CallTipSetBackground, 3186). --define(wxStyledTextCtrl_CallTipSetForeground, 3187). --define(wxStyledTextCtrl_CallTipSetForegroundHighlight, 3188). --define(wxStyledTextCtrl_CallTipUseStyle, 3189). --define(wxStyledTextCtrl_VisibleFromDocLine, 3190). --define(wxStyledTextCtrl_DocLineFromVisible, 3191). --define(wxStyledTextCtrl_WrapCount, 3192). --define(wxStyledTextCtrl_SetFoldLevel, 3193). --define(wxStyledTextCtrl_GetFoldLevel, 3194). --define(wxStyledTextCtrl_GetLastChild, 3195). --define(wxStyledTextCtrl_GetFoldParent, 3196). --define(wxStyledTextCtrl_ShowLines, 3197). --define(wxStyledTextCtrl_HideLines, 3198). --define(wxStyledTextCtrl_GetLineVisible, 3199). --define(wxStyledTextCtrl_SetFoldExpanded, 3200). --define(wxStyledTextCtrl_GetFoldExpanded, 3201). --define(wxStyledTextCtrl_ToggleFold, 3202). --define(wxStyledTextCtrl_EnsureVisible, 3203). --define(wxStyledTextCtrl_SetFoldFlags, 3204). --define(wxStyledTextCtrl_EnsureVisibleEnforcePolicy, 3205). --define(wxStyledTextCtrl_SetTabIndents, 3206). --define(wxStyledTextCtrl_GetTabIndents, 3207). --define(wxStyledTextCtrl_SetBackSpaceUnIndents, 3208). --define(wxStyledTextCtrl_GetBackSpaceUnIndents, 3209). --define(wxStyledTextCtrl_SetMouseDwellTime, 3210). --define(wxStyledTextCtrl_GetMouseDwellTime, 3211). --define(wxStyledTextCtrl_WordStartPosition, 3212). --define(wxStyledTextCtrl_WordEndPosition, 3213). --define(wxStyledTextCtrl_SetWrapMode, 3214). --define(wxStyledTextCtrl_GetWrapMode, 3215). --define(wxStyledTextCtrl_SetWrapVisualFlags, 3216). --define(wxStyledTextCtrl_GetWrapVisualFlags, 3217). --define(wxStyledTextCtrl_SetWrapVisualFlagsLocation, 3218). --define(wxStyledTextCtrl_GetWrapVisualFlagsLocation, 3219). --define(wxStyledTextCtrl_SetWrapStartIndent, 3220). --define(wxStyledTextCtrl_GetWrapStartIndent, 3221). --define(wxStyledTextCtrl_SetLayoutCache, 3222). --define(wxStyledTextCtrl_GetLayoutCache, 3223). --define(wxStyledTextCtrl_SetScrollWidth, 3224). --define(wxStyledTextCtrl_GetScrollWidth, 3225). --define(wxStyledTextCtrl_TextWidth, 3226). --define(wxStyledTextCtrl_GetEndAtLastLine, 3227). --define(wxStyledTextCtrl_TextHeight, 3228). --define(wxStyledTextCtrl_SetUseVerticalScrollBar, 3229). --define(wxStyledTextCtrl_GetUseVerticalScrollBar, 3230). --define(wxStyledTextCtrl_AppendText, 3231). --define(wxStyledTextCtrl_GetTwoPhaseDraw, 3232). --define(wxStyledTextCtrl_SetTwoPhaseDraw, 3233). --define(wxStyledTextCtrl_TargetFromSelection, 3234). --define(wxStyledTextCtrl_LinesJoin, 3235). --define(wxStyledTextCtrl_LinesSplit, 3236). --define(wxStyledTextCtrl_SetFoldMarginColour, 3237). --define(wxStyledTextCtrl_SetFoldMarginHiColour, 3238). --define(wxStyledTextCtrl_LineDown, 3239). --define(wxStyledTextCtrl_LineDownExtend, 3240). --define(wxStyledTextCtrl_LineUp, 3241). --define(wxStyledTextCtrl_LineUpExtend, 3242). --define(wxStyledTextCtrl_CharLeft, 3243). --define(wxStyledTextCtrl_CharLeftExtend, 3244). --define(wxStyledTextCtrl_CharRight, 3245). --define(wxStyledTextCtrl_CharRightExtend, 3246). --define(wxStyledTextCtrl_WordLeft, 3247). --define(wxStyledTextCtrl_WordLeftExtend, 3248). --define(wxStyledTextCtrl_WordRight, 3249). --define(wxStyledTextCtrl_WordRightExtend, 3250). --define(wxStyledTextCtrl_Home, 3251). --define(wxStyledTextCtrl_HomeExtend, 3252). --define(wxStyledTextCtrl_LineEnd, 3253). --define(wxStyledTextCtrl_LineEndExtend, 3254). --define(wxStyledTextCtrl_DocumentStart, 3255). --define(wxStyledTextCtrl_DocumentStartExtend, 3256). --define(wxStyledTextCtrl_DocumentEnd, 3257). --define(wxStyledTextCtrl_DocumentEndExtend, 3258). --define(wxStyledTextCtrl_PageUp, 3259). --define(wxStyledTextCtrl_PageUpExtend, 3260). --define(wxStyledTextCtrl_PageDown, 3261). --define(wxStyledTextCtrl_PageDownExtend, 3262). --define(wxStyledTextCtrl_EditToggleOvertype, 3263). --define(wxStyledTextCtrl_Cancel, 3264). --define(wxStyledTextCtrl_DeleteBack, 3265). --define(wxStyledTextCtrl_Tab, 3266). --define(wxStyledTextCtrl_BackTab, 3267). --define(wxStyledTextCtrl_NewLine, 3268). --define(wxStyledTextCtrl_FormFeed, 3269). --define(wxStyledTextCtrl_VCHome, 3270). --define(wxStyledTextCtrl_VCHomeExtend, 3271). --define(wxStyledTextCtrl_ZoomIn, 3272). --define(wxStyledTextCtrl_ZoomOut, 3273). --define(wxStyledTextCtrl_DelWordLeft, 3274). --define(wxStyledTextCtrl_DelWordRight, 3275). --define(wxStyledTextCtrl_LineCut, 3276). --define(wxStyledTextCtrl_LineDelete, 3277). --define(wxStyledTextCtrl_LineTranspose, 3278). --define(wxStyledTextCtrl_LineDuplicate, 3279). --define(wxStyledTextCtrl_LowerCase, 3280). --define(wxStyledTextCtrl_UpperCase, 3281). --define(wxStyledTextCtrl_LineScrollDown, 3282). --define(wxStyledTextCtrl_LineScrollUp, 3283). --define(wxStyledTextCtrl_DeleteBackNotLine, 3284). --define(wxStyledTextCtrl_HomeDisplay, 3285). --define(wxStyledTextCtrl_HomeDisplayExtend, 3286). --define(wxStyledTextCtrl_LineEndDisplay, 3287). --define(wxStyledTextCtrl_LineEndDisplayExtend, 3288). --define(wxStyledTextCtrl_HomeWrapExtend, 3289). --define(wxStyledTextCtrl_LineEndWrap, 3290). --define(wxStyledTextCtrl_LineEndWrapExtend, 3291). --define(wxStyledTextCtrl_VCHomeWrap, 3292). --define(wxStyledTextCtrl_VCHomeWrapExtend, 3293). --define(wxStyledTextCtrl_LineCopy, 3294). --define(wxStyledTextCtrl_MoveCaretInsideView, 3295). --define(wxStyledTextCtrl_LineLength, 3296). --define(wxStyledTextCtrl_BraceHighlight, 3297). --define(wxStyledTextCtrl_BraceBadLight, 3298). --define(wxStyledTextCtrl_BraceMatch, 3299). --define(wxStyledTextCtrl_GetViewEOL, 3300). --define(wxStyledTextCtrl_SetViewEOL, 3301). --define(wxStyledTextCtrl_SetModEventMask, 3302). --define(wxStyledTextCtrl_GetEdgeColumn, 3303). --define(wxStyledTextCtrl_SetEdgeColumn, 3304). --define(wxStyledTextCtrl_SetEdgeMode, 3305). --define(wxStyledTextCtrl_GetEdgeMode, 3306). --define(wxStyledTextCtrl_GetEdgeColour, 3307). --define(wxStyledTextCtrl_SetEdgeColour, 3308). --define(wxStyledTextCtrl_SearchAnchor, 3309). --define(wxStyledTextCtrl_SearchNext, 3310). --define(wxStyledTextCtrl_SearchPrev, 3311). --define(wxStyledTextCtrl_LinesOnScreen, 3312). --define(wxStyledTextCtrl_UsePopUp, 3313). --define(wxStyledTextCtrl_SelectionIsRectangle, 3314). --define(wxStyledTextCtrl_SetZoom, 3315). --define(wxStyledTextCtrl_GetZoom, 3316). --define(wxStyledTextCtrl_GetModEventMask, 3317). --define(wxStyledTextCtrl_SetSTCFocus, 3318). --define(wxStyledTextCtrl_GetSTCFocus, 3319). --define(wxStyledTextCtrl_SetStatus, 3320). --define(wxStyledTextCtrl_GetStatus, 3321). --define(wxStyledTextCtrl_SetMouseDownCaptures, 3322). --define(wxStyledTextCtrl_GetMouseDownCaptures, 3323). --define(wxStyledTextCtrl_SetSTCCursor, 3324). --define(wxStyledTextCtrl_GetSTCCursor, 3325). --define(wxStyledTextCtrl_SetControlCharSymbol, 3326). --define(wxStyledTextCtrl_GetControlCharSymbol, 3327). --define(wxStyledTextCtrl_WordPartLeft, 3328). --define(wxStyledTextCtrl_WordPartLeftExtend, 3329). --define(wxStyledTextCtrl_WordPartRight, 3330). --define(wxStyledTextCtrl_WordPartRightExtend, 3331). --define(wxStyledTextCtrl_SetVisiblePolicy, 3332). --define(wxStyledTextCtrl_DelLineLeft, 3333). --define(wxStyledTextCtrl_DelLineRight, 3334). --define(wxStyledTextCtrl_GetXOffset, 3335). --define(wxStyledTextCtrl_ChooseCaretX, 3336). --define(wxStyledTextCtrl_SetXCaretPolicy, 3337). --define(wxStyledTextCtrl_SetYCaretPolicy, 3338). --define(wxStyledTextCtrl_GetPrintWrapMode, 3339). --define(wxStyledTextCtrl_SetHotspotActiveForeground, 3340). --define(wxStyledTextCtrl_SetHotspotActiveBackground, 3341). --define(wxStyledTextCtrl_SetHotspotActiveUnderline, 3342). --define(wxStyledTextCtrl_SetHotspotSingleLine, 3343). --define(wxStyledTextCtrl_ParaDownExtend, 3344). --define(wxStyledTextCtrl_ParaUp, 3345). --define(wxStyledTextCtrl_ParaUpExtend, 3346). --define(wxStyledTextCtrl_PositionBefore, 3347). --define(wxStyledTextCtrl_PositionAfter, 3348). --define(wxStyledTextCtrl_CopyRange, 3349). --define(wxStyledTextCtrl_CopyText, 3350). --define(wxStyledTextCtrl_SetSelectionMode, 3351). --define(wxStyledTextCtrl_GetSelectionMode, 3352). --define(wxStyledTextCtrl_LineDownRectExtend, 3353). --define(wxStyledTextCtrl_LineUpRectExtend, 3354). --define(wxStyledTextCtrl_CharLeftRectExtend, 3355). --define(wxStyledTextCtrl_CharRightRectExtend, 3356). --define(wxStyledTextCtrl_HomeRectExtend, 3357). --define(wxStyledTextCtrl_VCHomeRectExtend, 3358). --define(wxStyledTextCtrl_LineEndRectExtend, 3359). --define(wxStyledTextCtrl_PageUpRectExtend, 3360). --define(wxStyledTextCtrl_PageDownRectExtend, 3361). --define(wxStyledTextCtrl_StutteredPageUp, 3362). --define(wxStyledTextCtrl_StutteredPageUpExtend, 3363). --define(wxStyledTextCtrl_StutteredPageDown, 3364). --define(wxStyledTextCtrl_StutteredPageDownExtend, 3365). --define(wxStyledTextCtrl_WordLeftEnd, 3366). --define(wxStyledTextCtrl_WordLeftEndExtend, 3367). --define(wxStyledTextCtrl_WordRightEnd, 3368). --define(wxStyledTextCtrl_WordRightEndExtend, 3369). --define(wxStyledTextCtrl_SetWhitespaceChars, 3370). --define(wxStyledTextCtrl_SetCharsDefault, 3371). --define(wxStyledTextCtrl_AutoCompGetCurrent, 3372). --define(wxStyledTextCtrl_Allocate, 3373). --define(wxStyledTextCtrl_FindColumn, 3374). --define(wxStyledTextCtrl_GetCaretSticky, 3375). --define(wxStyledTextCtrl_SetCaretSticky, 3376). --define(wxStyledTextCtrl_ToggleCaretSticky, 3377). --define(wxStyledTextCtrl_SetPasteConvertEndings, 3378). --define(wxStyledTextCtrl_GetPasteConvertEndings, 3379). --define(wxStyledTextCtrl_SelectionDuplicate, 3380). --define(wxStyledTextCtrl_SetCaretLineBackAlpha, 3381). --define(wxStyledTextCtrl_GetCaretLineBackAlpha, 3382). --define(wxStyledTextCtrl_StartRecord, 3383). --define(wxStyledTextCtrl_StopRecord, 3384). --define(wxStyledTextCtrl_SetLexer, 3385). --define(wxStyledTextCtrl_GetLexer, 3386). --define(wxStyledTextCtrl_Colourise, 3387). --define(wxStyledTextCtrl_SetProperty, 3388). --define(wxStyledTextCtrl_SetKeyWords, 3389). --define(wxStyledTextCtrl_SetLexerLanguage, 3390). --define(wxStyledTextCtrl_GetProperty, 3391). --define(wxStyledTextCtrl_GetStyleBitsNeeded, 3392). --define(wxStyledTextCtrl_GetCurrentLine, 3393). --define(wxStyledTextCtrl_StyleSetSpec, 3394). --define(wxStyledTextCtrl_StyleSetFont, 3395). --define(wxStyledTextCtrl_StyleSetFontAttr, 3396). --define(wxStyledTextCtrl_StyleSetCharacterSet, 3397). --define(wxStyledTextCtrl_StyleSetFontEncoding, 3398). --define(wxStyledTextCtrl_CmdKeyExecute, 3399). --define(wxStyledTextCtrl_SetMargins, 3400). --define(wxStyledTextCtrl_GetSelection, 3401). --define(wxStyledTextCtrl_PointFromPosition, 3402). --define(wxStyledTextCtrl_ScrollToLine, 3403). --define(wxStyledTextCtrl_ScrollToColumn, 3404). --define(wxStyledTextCtrl_SetVScrollBar, 3405). --define(wxStyledTextCtrl_SetHScrollBar, 3406). --define(wxStyledTextCtrl_GetLastKeydownProcessed, 3407). --define(wxStyledTextCtrl_SetLastKeydownProcessed, 3408). --define(wxStyledTextCtrl_SaveFile, 3409). --define(wxStyledTextCtrl_LoadFile, 3410). --define(wxStyledTextCtrl_DoDragOver, 3411). --define(wxStyledTextCtrl_DoDropText, 3412). --define(wxStyledTextCtrl_GetUseAntiAliasing, 3413). --define(wxStyledTextCtrl_AddTextRaw, 3414). --define(wxStyledTextCtrl_InsertTextRaw, 3415). --define(wxStyledTextCtrl_GetCurLineRaw, 3416). --define(wxStyledTextCtrl_GetLineRaw, 3417). --define(wxStyledTextCtrl_GetSelectedTextRaw, 3418). --define(wxStyledTextCtrl_GetTextRangeRaw, 3419). --define(wxStyledTextCtrl_SetTextRaw, 3420). --define(wxStyledTextCtrl_GetTextRaw, 3421). --define(wxStyledTextCtrl_AppendTextRaw, 3422). --define(wxArtProvider_GetBitmap, 3423). --define(wxArtProvider_GetIcon, 3424). --define(wxTreeEvent_GetKeyCode, 3425). --define(wxTreeEvent_GetItem, 3426). --define(wxTreeEvent_GetKeyEvent, 3427). --define(wxTreeEvent_GetLabel, 3428). --define(wxTreeEvent_GetOldItem, 3429). --define(wxTreeEvent_GetPoint, 3430). --define(wxTreeEvent_IsEditCancelled, 3431). --define(wxTreeEvent_SetToolTip, 3432). --define(wxNotebookEvent_GetOldSelection, 3433). --define(wxNotebookEvent_GetSelection, 3434). --define(wxNotebookEvent_SetOldSelection, 3435). --define(wxNotebookEvent_SetSelection, 3436). --define(wxFileDataObject_new, 3437). --define(wxFileDataObject_AddFile, 3438). --define(wxFileDataObject_GetFilenames, 3439). --define(wxFileDataObject_destroy, 3440). --define(wxTextDataObject_new, 3441). --define(wxTextDataObject_GetTextLength, 3442). --define(wxTextDataObject_GetText, 3443). --define(wxTextDataObject_SetText, 3444). --define(wxTextDataObject_destroy, 3445). --define(wxBitmapDataObject_new_1_1, 3446). --define(wxBitmapDataObject_new_1_0, 3447). --define(wxBitmapDataObject_GetBitmap, 3448). --define(wxBitmapDataObject_SetBitmap, 3449). --define(wxBitmapDataObject_destroy, 3450). --define(wxClipboard_new, 3452). --define(wxClipboard_destruct, 3453). --define(wxClipboard_AddData, 3454). --define(wxClipboard_Clear, 3455). --define(wxClipboard_Close, 3456). --define(wxClipboard_Flush, 3457). --define(wxClipboard_GetData, 3458). --define(wxClipboard_IsOpened, 3459). --define(wxClipboard_Open, 3460). --define(wxClipboard_SetData, 3461). --define(wxClipboard_UsePrimarySelection, 3463). --define(wxClipboard_IsSupported, 3464). --define(wxClipboard_Get, 3465). --define(wxSpinEvent_GetPosition, 3466). --define(wxSpinEvent_SetPosition, 3467). --define(wxSplitterWindow_new_0, 3468). --define(wxSplitterWindow_new_2, 3469). --define(wxSplitterWindow_destruct, 3470). --define(wxSplitterWindow_Create, 3471). --define(wxSplitterWindow_GetMinimumPaneSize, 3472). --define(wxSplitterWindow_GetSashGravity, 3473). --define(wxSplitterWindow_GetSashPosition, 3474). --define(wxSplitterWindow_GetSplitMode, 3475). --define(wxSplitterWindow_GetWindow1, 3476). --define(wxSplitterWindow_GetWindow2, 3477). --define(wxSplitterWindow_Initialize, 3478). --define(wxSplitterWindow_IsSplit, 3479). --define(wxSplitterWindow_ReplaceWindow, 3480). --define(wxSplitterWindow_SetSashGravity, 3481). --define(wxSplitterWindow_SetSashPosition, 3482). --define(wxSplitterWindow_SetSashSize, 3483). --define(wxSplitterWindow_SetMinimumPaneSize, 3484). --define(wxSplitterWindow_SetSplitMode, 3485). --define(wxSplitterWindow_SplitHorizontally, 3486). --define(wxSplitterWindow_SplitVertically, 3487). --define(wxSplitterWindow_Unsplit, 3488). --define(wxSplitterWindow_UpdateSize, 3489). --define(wxSplitterEvent_GetSashPosition, 3490). --define(wxSplitterEvent_GetX, 3491). --define(wxSplitterEvent_GetY, 3492). --define(wxSplitterEvent_GetWindowBeingRemoved, 3493). --define(wxSplitterEvent_SetSashPosition, 3494). --define(wxHtmlWindow_new_0, 3495). --define(wxHtmlWindow_new_2, 3496). --define(wxHtmlWindow_AppendToPage, 3497). --define(wxHtmlWindow_GetOpenedAnchor, 3498). --define(wxHtmlWindow_GetOpenedPage, 3499). --define(wxHtmlWindow_GetOpenedPageTitle, 3500). --define(wxHtmlWindow_GetRelatedFrame, 3501). --define(wxHtmlWindow_HistoryBack, 3502). --define(wxHtmlWindow_HistoryCanBack, 3503). --define(wxHtmlWindow_HistoryCanForward, 3504). --define(wxHtmlWindow_HistoryClear, 3505). --define(wxHtmlWindow_HistoryForward, 3506). --define(wxHtmlWindow_LoadFile, 3507). --define(wxHtmlWindow_LoadPage, 3508). --define(wxHtmlWindow_SelectAll, 3509). --define(wxHtmlWindow_SelectionToText, 3510). --define(wxHtmlWindow_SelectLine, 3511). --define(wxHtmlWindow_SelectWord, 3512). --define(wxHtmlWindow_SetBorders, 3513). --define(wxHtmlWindow_SetFonts, 3514). --define(wxHtmlWindow_SetPage, 3515). --define(wxHtmlWindow_SetRelatedFrame, 3516). --define(wxHtmlWindow_SetRelatedStatusBar, 3517). --define(wxHtmlWindow_ToText, 3518). --define(wxHtmlWindow_destroy, 3519). --define(wxHtmlLinkEvent_GetLinkInfo, 3520). --define(wxSystemSettings_GetColour, 3521). --define(wxSystemSettings_GetFont, 3522). --define(wxSystemSettings_GetMetric, 3523). --define(wxSystemSettings_GetScreenType, 3524). --define(wxSystemOptions_GetOption, 3525). --define(wxSystemOptions_GetOptionInt, 3526). --define(wxSystemOptions_HasOption, 3527). --define(wxSystemOptions_IsFalse, 3528). --define(wxSystemOptions_SetOption_2_1, 3529). --define(wxSystemOptions_SetOption_2_0, 3530). --define(wxAuiNotebookEvent_SetSelection, 3531). --define(wxAuiNotebookEvent_GetSelection, 3532). --define(wxAuiNotebookEvent_SetOldSelection, 3533). --define(wxAuiNotebookEvent_GetOldSelection, 3534). --define(wxAuiNotebookEvent_SetDragSource, 3535). --define(wxAuiNotebookEvent_GetDragSource, 3536). --define(wxAuiManagerEvent_SetManager, 3537). --define(wxAuiManagerEvent_GetManager, 3538). --define(wxAuiManagerEvent_SetPane, 3539). --define(wxAuiManagerEvent_GetPane, 3540). --define(wxAuiManagerEvent_SetButton, 3541). --define(wxAuiManagerEvent_GetButton, 3542). --define(wxAuiManagerEvent_SetDC, 3543). --define(wxAuiManagerEvent_GetDC, 3544). --define(wxAuiManagerEvent_Veto, 3545). --define(wxAuiManagerEvent_GetVeto, 3546). --define(wxAuiManagerEvent_SetCanVeto, 3547). --define(wxAuiManagerEvent_CanVeto, 3548). --define(wxLogNull_new, 3549). --define(wxLogNull_destroy, 3550). --define(wxTaskBarIcon_new, 3551). --define(wxTaskBarIcon_destruct, 3552). --define(wxTaskBarIcon_PopupMenu, 3553). --define(wxTaskBarIcon_RemoveIcon, 3554). --define(wxTaskBarIcon_SetIcon, 3555). --define(wxLocale_new_0, 3556). --define(wxLocale_new_2, 3558). --define(wxLocale_destruct, 3559). --define(wxLocale_Init, 3561). --define(wxLocale_AddCatalog_1, 3562). --define(wxLocale_AddCatalog_3, 3563). --define(wxLocale_AddCatalogLookupPathPrefix, 3564). --define(wxLocale_GetCanonicalName, 3565). --define(wxLocale_GetLanguage, 3566). --define(wxLocale_GetLanguageName, 3567). --define(wxLocale_GetLocale, 3568). --define(wxLocale_GetName, 3569). --define(wxLocale_GetString_2, 3570). --define(wxLocale_GetString_4, 3571). --define(wxLocale_GetHeaderValue, 3572). --define(wxLocale_GetSysName, 3573). --define(wxLocale_GetSystemEncoding, 3574). --define(wxLocale_GetSystemEncodingName, 3575). --define(wxLocale_GetSystemLanguage, 3576). --define(wxLocale_IsLoaded, 3577). --define(wxLocale_IsOk, 3578). --define(wxActivateEvent_GetActive, 3579). --define(wxPopupWindow_new_2, 3581). --define(wxPopupWindow_new_0, 3582). --define(wxPopupWindow_destruct, 3584). --define(wxPopupWindow_Create, 3585). --define(wxPopupWindow_Position, 3586). --define(wxPopupTransientWindow_new_0, 3587). --define(wxPopupTransientWindow_new_2, 3588). --define(wxPopupTransientWindow_destruct, 3589). --define(wxPopupTransientWindow_Popup, 3590). --define(wxPopupTransientWindow_Dismiss, 3591). --define(wxOverlay_new, 3592). --define(wxOverlay_destruct, 3593). --define(wxOverlay_Reset, 3594). --define(wxDCOverlay_new_6, 3595). --define(wxDCOverlay_new_2, 3596). --define(wxDCOverlay_destruct, 3597). --define(wxDCOverlay_Clear, 3598). +-define(wxGauge_GetRange, 1605). +-define(wxGauge_GetValue, 1606). +-define(wxGauge_IsVertical, 1607). +-define(wxGauge_SetRange, 1608). +-define(wxGauge_SetValue, 1609). +-define(wxGauge_Pulse, 1610). +-define(wxGauge_destroy, 1611). +-define(wxGenericDirCtrl_new_0, 1612). +-define(wxGenericDirCtrl_new_2, 1613). +-define(wxGenericDirCtrl_destruct, 1614). +-define(wxGenericDirCtrl_Create, 1615). +-define(wxGenericDirCtrl_Init, 1616). +-define(wxGenericDirCtrl_CollapseTree, 1617). +-define(wxGenericDirCtrl_ExpandPath, 1618). +-define(wxGenericDirCtrl_GetDefaultPath, 1619). +-define(wxGenericDirCtrl_GetPath, 1620). +-define(wxGenericDirCtrl_GetFilePath, 1621). +-define(wxGenericDirCtrl_GetFilter, 1622). +-define(wxGenericDirCtrl_GetFilterIndex, 1623). +-define(wxGenericDirCtrl_GetRootId, 1624). +-define(wxGenericDirCtrl_GetTreeCtrl, 1625). +-define(wxGenericDirCtrl_ReCreateTree, 1626). +-define(wxGenericDirCtrl_SetDefaultPath, 1627). +-define(wxGenericDirCtrl_SetFilter, 1628). +-define(wxGenericDirCtrl_SetFilterIndex, 1629). +-define(wxGenericDirCtrl_SetPath, 1630). +-define(wxStaticBox_new_4, 1632). +-define(wxStaticBox_new_0, 1633). +-define(wxStaticBox_Create, 1634). +-define(wxStaticBox_destroy, 1635). +-define(wxStaticLine_new_2, 1637). +-define(wxStaticLine_new_0, 1638). +-define(wxStaticLine_Create, 1639). +-define(wxStaticLine_IsVertical, 1640). +-define(wxStaticLine_GetDefaultSize, 1641). +-define(wxStaticLine_destroy, 1642). +-define(wxListBox_new_3, 1645). +-define(wxListBox_new_0, 1646). +-define(wxListBox_destruct, 1648). +-define(wxListBox_Create, 1650). +-define(wxListBox_Deselect, 1651). +-define(wxListBox_GetSelections, 1652). +-define(wxListBox_InsertItems, 1653). +-define(wxListBox_IsSelected, 1654). +-define(wxListBox_Set, 1655). +-define(wxListBox_HitTest, 1656). +-define(wxListBox_SetFirstItem_1_0, 1657). +-define(wxListBox_SetFirstItem_1_1, 1658). +-define(wxListCtrl_new_0, 1659). +-define(wxListCtrl_new_2, 1660). +-define(wxListCtrl_Arrange, 1661). +-define(wxListCtrl_AssignImageList, 1662). +-define(wxListCtrl_ClearAll, 1663). +-define(wxListCtrl_Create, 1664). +-define(wxListCtrl_DeleteAllItems, 1665). +-define(wxListCtrl_DeleteColumn, 1666). +-define(wxListCtrl_DeleteItem, 1667). +-define(wxListCtrl_EditLabel, 1668). +-define(wxListCtrl_EnsureVisible, 1669). +-define(wxListCtrl_FindItem_3_0, 1670). +-define(wxListCtrl_FindItem_3_1, 1671). +-define(wxListCtrl_GetColumn, 1672). +-define(wxListCtrl_GetColumnCount, 1673). +-define(wxListCtrl_GetColumnWidth, 1674). +-define(wxListCtrl_GetCountPerPage, 1675). +-define(wxListCtrl_GetEditControl, 1676). +-define(wxListCtrl_GetImageList, 1677). +-define(wxListCtrl_GetItem, 1678). +-define(wxListCtrl_GetItemBackgroundColour, 1679). +-define(wxListCtrl_GetItemCount, 1680). +-define(wxListCtrl_GetItemData, 1681). +-define(wxListCtrl_GetItemFont, 1682). +-define(wxListCtrl_GetItemPosition, 1683). +-define(wxListCtrl_GetItemRect, 1684). +-define(wxListCtrl_GetItemSpacing, 1685). +-define(wxListCtrl_GetItemState, 1686). +-define(wxListCtrl_GetItemText, 1687). +-define(wxListCtrl_GetItemTextColour, 1688). +-define(wxListCtrl_GetNextItem, 1689). +-define(wxListCtrl_GetSelectedItemCount, 1690). +-define(wxListCtrl_GetTextColour, 1691). +-define(wxListCtrl_GetTopItem, 1692). +-define(wxListCtrl_GetViewRect, 1693). +-define(wxListCtrl_HitTest, 1694). +-define(wxListCtrl_InsertColumn_2, 1695). +-define(wxListCtrl_InsertColumn_3, 1696). +-define(wxListCtrl_InsertItem_1, 1697). +-define(wxListCtrl_InsertItem_2_1, 1698). +-define(wxListCtrl_InsertItem_2_0, 1699). +-define(wxListCtrl_InsertItem_3, 1700). +-define(wxListCtrl_RefreshItem, 1701). +-define(wxListCtrl_RefreshItems, 1702). +-define(wxListCtrl_ScrollList, 1703). +-define(wxListCtrl_SetBackgroundColour, 1704). +-define(wxListCtrl_SetColumn, 1705). +-define(wxListCtrl_SetColumnWidth, 1706). +-define(wxListCtrl_SetImageList, 1707). +-define(wxListCtrl_SetItem_1, 1708). +-define(wxListCtrl_SetItem_4, 1709). +-define(wxListCtrl_SetItemBackgroundColour, 1710). +-define(wxListCtrl_SetItemCount, 1711). +-define(wxListCtrl_SetItemData, 1712). +-define(wxListCtrl_SetItemFont, 1713). +-define(wxListCtrl_SetItemImage, 1714). +-define(wxListCtrl_SetItemColumnImage, 1715). +-define(wxListCtrl_SetItemPosition, 1716). +-define(wxListCtrl_SetItemState, 1717). +-define(wxListCtrl_SetItemText, 1718). +-define(wxListCtrl_SetItemTextColour, 1719). +-define(wxListCtrl_SetSingleStyle, 1720). +-define(wxListCtrl_SetTextColour, 1721). +-define(wxListCtrl_SetWindowStyleFlag, 1722). +-define(wxListCtrl_SortItems, 1723). +-define(wxListCtrl_destroy, 1724). +-define(wxListView_ClearColumnImage, 1725). +-define(wxListView_Focus, 1726). +-define(wxListView_GetFirstSelected, 1727). +-define(wxListView_GetFocusedItem, 1728). +-define(wxListView_GetNextSelected, 1729). +-define(wxListView_IsSelected, 1730). +-define(wxListView_Select, 1731). +-define(wxListView_SetColumnImage, 1732). +-define(wxListItem_new_0, 1733). +-define(wxListItem_new_1, 1734). +-define(wxListItem_destruct, 1735). +-define(wxListItem_Clear, 1736). +-define(wxListItem_GetAlign, 1737). +-define(wxListItem_GetBackgroundColour, 1738). +-define(wxListItem_GetColumn, 1739). +-define(wxListItem_GetFont, 1740). +-define(wxListItem_GetId, 1741). +-define(wxListItem_GetImage, 1742). +-define(wxListItem_GetMask, 1743). +-define(wxListItem_GetState, 1744). +-define(wxListItem_GetText, 1745). +-define(wxListItem_GetTextColour, 1746). +-define(wxListItem_GetWidth, 1747). +-define(wxListItem_SetAlign, 1748). +-define(wxListItem_SetBackgroundColour, 1749). +-define(wxListItem_SetColumn, 1750). +-define(wxListItem_SetFont, 1751). +-define(wxListItem_SetId, 1752). +-define(wxListItem_SetImage, 1753). +-define(wxListItem_SetMask, 1754). +-define(wxListItem_SetState, 1755). +-define(wxListItem_SetStateMask, 1756). +-define(wxListItem_SetText, 1757). +-define(wxListItem_SetTextColour, 1758). +-define(wxListItem_SetWidth, 1759). +-define(wxListItemAttr_new_0, 1760). +-define(wxListItemAttr_new_3, 1761). +-define(wxListItemAttr_GetBackgroundColour, 1762). +-define(wxListItemAttr_GetFont, 1763). +-define(wxListItemAttr_GetTextColour, 1764). +-define(wxListItemAttr_HasBackgroundColour, 1765). +-define(wxListItemAttr_HasFont, 1766). +-define(wxListItemAttr_HasTextColour, 1767). +-define(wxListItemAttr_SetBackgroundColour, 1768). +-define(wxListItemAttr_SetFont, 1769). +-define(wxListItemAttr_SetTextColour, 1770). +-define(wxListItemAttr_destroy, 1771). +-define(wxImageList_new_0, 1772). +-define(wxImageList_new_3, 1773). +-define(wxImageList_Add_1, 1774). +-define(wxImageList_Add_2_0, 1775). +-define(wxImageList_Add_2_1, 1776). +-define(wxImageList_Create, 1777). +-define(wxImageList_Draw, 1779). +-define(wxImageList_GetBitmap, 1780). +-define(wxImageList_GetIcon, 1781). +-define(wxImageList_GetImageCount, 1782). +-define(wxImageList_GetSize, 1783). +-define(wxImageList_Remove, 1784). +-define(wxImageList_RemoveAll, 1785). +-define(wxImageList_Replace_2, 1786). +-define(wxImageList_Replace_3, 1787). +-define(wxImageList_destroy, 1788). +-define(wxTextAttr_new_0, 1789). +-define(wxTextAttr_new_2, 1790). +-define(wxTextAttr_GetAlignment, 1791). +-define(wxTextAttr_GetBackgroundColour, 1792). +-define(wxTextAttr_GetFont, 1793). +-define(wxTextAttr_GetLeftIndent, 1794). +-define(wxTextAttr_GetLeftSubIndent, 1795). +-define(wxTextAttr_GetRightIndent, 1796). +-define(wxTextAttr_GetTabs, 1797). +-define(wxTextAttr_GetTextColour, 1798). +-define(wxTextAttr_HasBackgroundColour, 1799). +-define(wxTextAttr_HasFont, 1800). +-define(wxTextAttr_HasTextColour, 1801). +-define(wxTextAttr_GetFlags, 1802). +-define(wxTextAttr_IsDefault, 1803). +-define(wxTextAttr_SetAlignment, 1804). +-define(wxTextAttr_SetBackgroundColour, 1805). +-define(wxTextAttr_SetFlags, 1806). +-define(wxTextAttr_SetFont, 1807). +-define(wxTextAttr_SetLeftIndent, 1808). +-define(wxTextAttr_SetRightIndent, 1809). +-define(wxTextAttr_SetTabs, 1810). +-define(wxTextAttr_SetTextColour, 1811). +-define(wxTextAttr_destroy, 1812). +-define(wxTextCtrl_new_3, 1814). +-define(wxTextCtrl_new_0, 1815). +-define(wxTextCtrl_destruct, 1817). +-define(wxTextCtrl_AppendText, 1818). +-define(wxTextCtrl_CanCopy, 1819). +-define(wxTextCtrl_CanCut, 1820). +-define(wxTextCtrl_CanPaste, 1821). +-define(wxTextCtrl_CanRedo, 1822). +-define(wxTextCtrl_CanUndo, 1823). +-define(wxTextCtrl_Clear, 1824). +-define(wxTextCtrl_Copy, 1825). +-define(wxTextCtrl_Create, 1826). +-define(wxTextCtrl_Cut, 1827). +-define(wxTextCtrl_DiscardEdits, 1828). +-define(wxTextCtrl_ChangeValue, 1829). +-define(wxTextCtrl_EmulateKeyPress, 1830). +-define(wxTextCtrl_GetDefaultStyle, 1831). +-define(wxTextCtrl_GetInsertionPoint, 1832). +-define(wxTextCtrl_GetLastPosition, 1833). +-define(wxTextCtrl_GetLineLength, 1834). +-define(wxTextCtrl_GetLineText, 1835). +-define(wxTextCtrl_GetNumberOfLines, 1836). +-define(wxTextCtrl_GetRange, 1837). +-define(wxTextCtrl_GetSelection, 1838). +-define(wxTextCtrl_GetStringSelection, 1839). +-define(wxTextCtrl_GetStyle, 1840). +-define(wxTextCtrl_GetValue, 1841). +-define(wxTextCtrl_IsEditable, 1842). +-define(wxTextCtrl_IsModified, 1843). +-define(wxTextCtrl_IsMultiLine, 1844). +-define(wxTextCtrl_IsSingleLine, 1845). +-define(wxTextCtrl_LoadFile, 1846). +-define(wxTextCtrl_MarkDirty, 1847). +-define(wxTextCtrl_Paste, 1848). +-define(wxTextCtrl_PositionToXY, 1849). +-define(wxTextCtrl_Redo, 1850). +-define(wxTextCtrl_Remove, 1851). +-define(wxTextCtrl_Replace, 1852). +-define(wxTextCtrl_SaveFile, 1853). +-define(wxTextCtrl_SetDefaultStyle, 1854). +-define(wxTextCtrl_SetEditable, 1855). +-define(wxTextCtrl_SetInsertionPoint, 1856). +-define(wxTextCtrl_SetInsertionPointEnd, 1857). +-define(wxTextCtrl_SetMaxLength, 1859). +-define(wxTextCtrl_SetSelection, 1860). +-define(wxTextCtrl_SetStyle, 1861). +-define(wxTextCtrl_SetValue, 1862). +-define(wxTextCtrl_ShowPosition, 1863). +-define(wxTextCtrl_Undo, 1864). +-define(wxTextCtrl_WriteText, 1865). +-define(wxTextCtrl_XYToPosition, 1866). +-define(wxNotebook_new_0, 1869). +-define(wxNotebook_new_3, 1870). +-define(wxNotebook_destruct, 1871). +-define(wxNotebook_AddPage, 1872). +-define(wxNotebook_AdvanceSelection, 1873). +-define(wxNotebook_AssignImageList, 1874). +-define(wxNotebook_Create, 1875). +-define(wxNotebook_DeleteAllPages, 1876). +-define(wxNotebook_DeletePage, 1877). +-define(wxNotebook_RemovePage, 1878). +-define(wxNotebook_GetCurrentPage, 1879). +-define(wxNotebook_GetImageList, 1880). +-define(wxNotebook_GetPage, 1882). +-define(wxNotebook_GetPageCount, 1883). +-define(wxNotebook_GetPageImage, 1884). +-define(wxNotebook_GetPageText, 1885). +-define(wxNotebook_GetRowCount, 1886). +-define(wxNotebook_GetSelection, 1887). +-define(wxNotebook_GetThemeBackgroundColour, 1888). +-define(wxNotebook_HitTest, 1890). +-define(wxNotebook_InsertPage, 1892). +-define(wxNotebook_SetImageList, 1893). +-define(wxNotebook_SetPadding, 1894). +-define(wxNotebook_SetPageSize, 1895). +-define(wxNotebook_SetPageImage, 1896). +-define(wxNotebook_SetPageText, 1897). +-define(wxNotebook_SetSelection, 1898). +-define(wxNotebook_ChangeSelection, 1899). +-define(wxChoicebook_new_0, 1900). +-define(wxChoicebook_new_3, 1901). +-define(wxChoicebook_AddPage, 1902). +-define(wxChoicebook_AdvanceSelection, 1903). +-define(wxChoicebook_AssignImageList, 1904). +-define(wxChoicebook_Create, 1905). +-define(wxChoicebook_DeleteAllPages, 1906). +-define(wxChoicebook_DeletePage, 1907). +-define(wxChoicebook_RemovePage, 1908). +-define(wxChoicebook_GetCurrentPage, 1909). +-define(wxChoicebook_GetImageList, 1910). +-define(wxChoicebook_GetPage, 1912). +-define(wxChoicebook_GetPageCount, 1913). +-define(wxChoicebook_GetPageImage, 1914). +-define(wxChoicebook_GetPageText, 1915). +-define(wxChoicebook_GetSelection, 1916). +-define(wxChoicebook_HitTest, 1917). +-define(wxChoicebook_InsertPage, 1918). +-define(wxChoicebook_SetImageList, 1919). +-define(wxChoicebook_SetPageSize, 1920). +-define(wxChoicebook_SetPageImage, 1921). +-define(wxChoicebook_SetPageText, 1922). +-define(wxChoicebook_SetSelection, 1923). +-define(wxChoicebook_ChangeSelection, 1924). +-define(wxChoicebook_destroy, 1925). +-define(wxToolbook_new_0, 1926). +-define(wxToolbook_new_3, 1927). +-define(wxToolbook_AddPage, 1928). +-define(wxToolbook_AdvanceSelection, 1929). +-define(wxToolbook_AssignImageList, 1930). +-define(wxToolbook_Create, 1931). +-define(wxToolbook_DeleteAllPages, 1932). +-define(wxToolbook_DeletePage, 1933). +-define(wxToolbook_RemovePage, 1934). +-define(wxToolbook_GetCurrentPage, 1935). +-define(wxToolbook_GetImageList, 1936). +-define(wxToolbook_GetPage, 1938). +-define(wxToolbook_GetPageCount, 1939). +-define(wxToolbook_GetPageImage, 1940). +-define(wxToolbook_GetPageText, 1941). +-define(wxToolbook_GetSelection, 1942). +-define(wxToolbook_HitTest, 1944). +-define(wxToolbook_InsertPage, 1945). +-define(wxToolbook_SetImageList, 1946). +-define(wxToolbook_SetPageSize, 1947). +-define(wxToolbook_SetPageImage, 1948). +-define(wxToolbook_SetPageText, 1949). +-define(wxToolbook_SetSelection, 1950). +-define(wxToolbook_ChangeSelection, 1951). +-define(wxToolbook_destroy, 1952). +-define(wxListbook_new_0, 1953). +-define(wxListbook_new_3, 1954). +-define(wxListbook_AddPage, 1955). +-define(wxListbook_AdvanceSelection, 1956). +-define(wxListbook_AssignImageList, 1957). +-define(wxListbook_Create, 1958). +-define(wxListbook_DeleteAllPages, 1959). +-define(wxListbook_DeletePage, 1960). +-define(wxListbook_RemovePage, 1961). +-define(wxListbook_GetCurrentPage, 1962). +-define(wxListbook_GetImageList, 1963). +-define(wxListbook_GetPage, 1965). +-define(wxListbook_GetPageCount, 1966). +-define(wxListbook_GetPageImage, 1967). +-define(wxListbook_GetPageText, 1968). +-define(wxListbook_GetSelection, 1969). +-define(wxListbook_HitTest, 1971). +-define(wxListbook_InsertPage, 1972). +-define(wxListbook_SetImageList, 1973). +-define(wxListbook_SetPageSize, 1974). +-define(wxListbook_SetPageImage, 1975). +-define(wxListbook_SetPageText, 1976). +-define(wxListbook_SetSelection, 1977). +-define(wxListbook_ChangeSelection, 1978). +-define(wxListbook_destroy, 1979). +-define(wxTreebook_new_0, 1980). +-define(wxTreebook_new_3, 1981). +-define(wxTreebook_AddPage, 1982). +-define(wxTreebook_AdvanceSelection, 1983). +-define(wxTreebook_AssignImageList, 1984). +-define(wxTreebook_Create, 1985). +-define(wxTreebook_DeleteAllPages, 1986). +-define(wxTreebook_DeletePage, 1987). +-define(wxTreebook_RemovePage, 1988). +-define(wxTreebook_GetCurrentPage, 1989). +-define(wxTreebook_GetImageList, 1990). +-define(wxTreebook_GetPage, 1992). +-define(wxTreebook_GetPageCount, 1993). +-define(wxTreebook_GetPageImage, 1994). +-define(wxTreebook_GetPageText, 1995). +-define(wxTreebook_GetSelection, 1996). +-define(wxTreebook_ExpandNode, 1997). +-define(wxTreebook_IsNodeExpanded, 1998). +-define(wxTreebook_HitTest, 2000). +-define(wxTreebook_InsertPage, 2001). +-define(wxTreebook_InsertSubPage, 2002). +-define(wxTreebook_SetImageList, 2003). +-define(wxTreebook_SetPageSize, 2004). +-define(wxTreebook_SetPageImage, 2005). +-define(wxTreebook_SetPageText, 2006). +-define(wxTreebook_SetSelection, 2007). +-define(wxTreebook_ChangeSelection, 2008). +-define(wxTreebook_destroy, 2009). +-define(wxTreeCtrl_new_2, 2012). +-define(wxTreeCtrl_new_0, 2013). +-define(wxTreeCtrl_destruct, 2015). +-define(wxTreeCtrl_AddRoot, 2016). +-define(wxTreeCtrl_AppendItem, 2017). +-define(wxTreeCtrl_AssignImageList, 2018). +-define(wxTreeCtrl_AssignStateImageList, 2019). +-define(wxTreeCtrl_Collapse, 2020). +-define(wxTreeCtrl_CollapseAndReset, 2021). +-define(wxTreeCtrl_Create, 2022). +-define(wxTreeCtrl_Delete, 2023). +-define(wxTreeCtrl_DeleteAllItems, 2024). +-define(wxTreeCtrl_DeleteChildren, 2025). +-define(wxTreeCtrl_EditLabel, 2026). +-define(wxTreeCtrl_EnsureVisible, 2027). +-define(wxTreeCtrl_Expand, 2028). +-define(wxTreeCtrl_GetBoundingRect, 2029). +-define(wxTreeCtrl_GetChildrenCount, 2031). +-define(wxTreeCtrl_GetCount, 2032). +-define(wxTreeCtrl_GetEditControl, 2033). +-define(wxTreeCtrl_GetFirstChild, 2034). +-define(wxTreeCtrl_GetNextChild, 2035). +-define(wxTreeCtrl_GetFirstVisibleItem, 2036). +-define(wxTreeCtrl_GetImageList, 2037). +-define(wxTreeCtrl_GetIndent, 2038). +-define(wxTreeCtrl_GetItemBackgroundColour, 2039). +-define(wxTreeCtrl_GetItemData, 2040). +-define(wxTreeCtrl_GetItemFont, 2041). +-define(wxTreeCtrl_GetItemImage_1, 2042). +-define(wxTreeCtrl_GetItemImage_2, 2043). +-define(wxTreeCtrl_GetItemText, 2044). +-define(wxTreeCtrl_GetItemTextColour, 2045). +-define(wxTreeCtrl_GetLastChild, 2046). +-define(wxTreeCtrl_GetNextSibling, 2047). +-define(wxTreeCtrl_GetNextVisible, 2048). +-define(wxTreeCtrl_GetItemParent, 2049). +-define(wxTreeCtrl_GetPrevSibling, 2050). +-define(wxTreeCtrl_GetPrevVisible, 2051). +-define(wxTreeCtrl_GetRootItem, 2052). +-define(wxTreeCtrl_GetSelection, 2053). +-define(wxTreeCtrl_GetSelections, 2054). +-define(wxTreeCtrl_GetStateImageList, 2055). +-define(wxTreeCtrl_HitTest, 2056). +-define(wxTreeCtrl_InsertItem, 2058). +-define(wxTreeCtrl_IsBold, 2059). +-define(wxTreeCtrl_IsExpanded, 2060). +-define(wxTreeCtrl_IsSelected, 2061). +-define(wxTreeCtrl_IsVisible, 2062). +-define(wxTreeCtrl_ItemHasChildren, 2063). +-define(wxTreeCtrl_IsTreeItemIdOk, 2064). +-define(wxTreeCtrl_PrependItem, 2065). +-define(wxTreeCtrl_ScrollTo, 2066). +-define(wxTreeCtrl_SelectItem_1, 2067). +-define(wxTreeCtrl_SelectItem_2, 2068). +-define(wxTreeCtrl_SetIndent, 2069). +-define(wxTreeCtrl_SetImageList, 2070). +-define(wxTreeCtrl_SetItemBackgroundColour, 2071). +-define(wxTreeCtrl_SetItemBold, 2072). +-define(wxTreeCtrl_SetItemData, 2073). +-define(wxTreeCtrl_SetItemDropHighlight, 2074). +-define(wxTreeCtrl_SetItemFont, 2075). +-define(wxTreeCtrl_SetItemHasChildren, 2076). +-define(wxTreeCtrl_SetItemImage_2, 2077). +-define(wxTreeCtrl_SetItemImage_3, 2078). +-define(wxTreeCtrl_SetItemText, 2079). +-define(wxTreeCtrl_SetItemTextColour, 2080). +-define(wxTreeCtrl_SetStateImageList, 2081). +-define(wxTreeCtrl_SetWindowStyle, 2082). +-define(wxTreeCtrl_SortChildren, 2083). +-define(wxTreeCtrl_Toggle, 2084). +-define(wxTreeCtrl_ToggleItemSelection, 2085). +-define(wxTreeCtrl_Unselect, 2086). +-define(wxTreeCtrl_UnselectAll, 2087). +-define(wxTreeCtrl_UnselectItem, 2088). +-define(wxScrollBar_new_0, 2089). +-define(wxScrollBar_new_3, 2090). +-define(wxScrollBar_destruct, 2091). +-define(wxScrollBar_Create, 2092). +-define(wxScrollBar_GetRange, 2093). +-define(wxScrollBar_GetPageSize, 2094). +-define(wxScrollBar_GetThumbPosition, 2095). +-define(wxScrollBar_GetThumbSize, 2096). +-define(wxScrollBar_SetThumbPosition, 2097). +-define(wxScrollBar_SetScrollbar, 2098). +-define(wxSpinButton_new_2, 2100). +-define(wxSpinButton_new_0, 2101). +-define(wxSpinButton_Create, 2102). +-define(wxSpinButton_GetMax, 2103). +-define(wxSpinButton_GetMin, 2104). +-define(wxSpinButton_GetValue, 2105). +-define(wxSpinButton_SetRange, 2106). +-define(wxSpinButton_SetValue, 2107). +-define(wxSpinButton_destroy, 2108). +-define(wxSpinCtrl_new_0, 2109). +-define(wxSpinCtrl_new_2, 2110). +-define(wxSpinCtrl_Create, 2112). +-define(wxSpinCtrl_SetValue_1_1, 2115). +-define(wxSpinCtrl_SetValue_1_0, 2116). +-define(wxSpinCtrl_GetValue, 2118). +-define(wxSpinCtrl_SetRange, 2120). +-define(wxSpinCtrl_SetSelection, 2121). +-define(wxSpinCtrl_GetMin, 2123). +-define(wxSpinCtrl_GetMax, 2125). +-define(wxSpinCtrl_destroy, 2126). +-define(wxStaticText_new_0, 2127). +-define(wxStaticText_new_4, 2128). +-define(wxStaticText_Create, 2129). +-define(wxStaticText_GetLabel, 2130). +-define(wxStaticText_SetLabel, 2131). +-define(wxStaticText_Wrap, 2132). +-define(wxStaticText_destroy, 2133). +-define(wxStaticBitmap_new_0, 2134). +-define(wxStaticBitmap_new_4, 2135). +-define(wxStaticBitmap_Create, 2136). +-define(wxStaticBitmap_GetBitmap, 2137). +-define(wxStaticBitmap_SetBitmap, 2138). +-define(wxStaticBitmap_destroy, 2139). +-define(wxRadioBox_new, 2140). +-define(wxRadioBox_destruct, 2142). +-define(wxRadioBox_Create, 2143). +-define(wxRadioBox_Enable_2, 2144). +-define(wxRadioBox_Enable_1, 2145). +-define(wxRadioBox_GetSelection, 2146). +-define(wxRadioBox_GetString, 2147). +-define(wxRadioBox_SetSelection, 2148). +-define(wxRadioBox_Show_2, 2149). +-define(wxRadioBox_Show_1, 2150). +-define(wxRadioBox_GetColumnCount, 2151). +-define(wxRadioBox_GetItemHelpText, 2152). +-define(wxRadioBox_GetItemToolTip, 2153). +-define(wxRadioBox_GetItemFromPoint, 2155). +-define(wxRadioBox_GetRowCount, 2156). +-define(wxRadioBox_IsItemEnabled, 2157). +-define(wxRadioBox_IsItemShown, 2158). +-define(wxRadioBox_SetItemHelpText, 2159). +-define(wxRadioBox_SetItemToolTip, 2160). +-define(wxRadioButton_new_0, 2161). +-define(wxRadioButton_new_4, 2162). +-define(wxRadioButton_Create, 2163). +-define(wxRadioButton_GetValue, 2164). +-define(wxRadioButton_SetValue, 2165). +-define(wxRadioButton_destroy, 2166). +-define(wxSlider_new_6, 2168). +-define(wxSlider_new_0, 2169). +-define(wxSlider_Create, 2170). +-define(wxSlider_GetLineSize, 2171). +-define(wxSlider_GetMax, 2172). +-define(wxSlider_GetMin, 2173). +-define(wxSlider_GetPageSize, 2174). +-define(wxSlider_GetThumbLength, 2175). +-define(wxSlider_GetValue, 2176). +-define(wxSlider_SetLineSize, 2177). +-define(wxSlider_SetPageSize, 2178). +-define(wxSlider_SetRange, 2179). +-define(wxSlider_SetThumbLength, 2180). +-define(wxSlider_SetValue, 2181). +-define(wxSlider_destroy, 2182). +-define(wxDialog_new_4, 2184). +-define(wxDialog_new_0, 2185). +-define(wxDialog_destruct, 2187). +-define(wxDialog_Create, 2188). +-define(wxDialog_CreateButtonSizer, 2189). +-define(wxDialog_CreateStdDialogButtonSizer, 2190). +-define(wxDialog_EndModal, 2191). +-define(wxDialog_GetAffirmativeId, 2192). +-define(wxDialog_GetReturnCode, 2193). +-define(wxDialog_IsModal, 2194). +-define(wxDialog_SetAffirmativeId, 2195). +-define(wxDialog_SetReturnCode, 2196). +-define(wxDialog_Show, 2197). +-define(wxDialog_ShowModal, 2198). +-define(wxColourDialog_new_0, 2199). +-define(wxColourDialog_new_2, 2200). +-define(wxColourDialog_destruct, 2201). +-define(wxColourDialog_Create, 2202). +-define(wxColourDialog_GetColourData, 2203). +-define(wxColourData_new_0, 2204). +-define(wxColourData_new_1, 2205). +-define(wxColourData_destruct, 2206). +-define(wxColourData_GetChooseFull, 2207). +-define(wxColourData_GetColour, 2208). +-define(wxColourData_GetCustomColour, 2210). +-define(wxColourData_SetChooseFull, 2211). +-define(wxColourData_SetColour, 2212). +-define(wxColourData_SetCustomColour, 2213). +-define(wxPalette_new_0, 2214). +-define(wxPalette_new_4, 2215). +-define(wxPalette_destruct, 2217). +-define(wxPalette_Create, 2218). +-define(wxPalette_GetColoursCount, 2219). +-define(wxPalette_GetPixel, 2220). +-define(wxPalette_GetRGB, 2221). +-define(wxPalette_IsOk, 2222). +-define(wxDirDialog_new, 2226). +-define(wxDirDialog_destruct, 2227). +-define(wxDirDialog_GetPath, 2228). +-define(wxDirDialog_GetMessage, 2229). +-define(wxDirDialog_SetMessage, 2230). +-define(wxDirDialog_SetPath, 2231). +-define(wxFileDialog_new, 2235). +-define(wxFileDialog_destruct, 2236). +-define(wxFileDialog_GetDirectory, 2237). +-define(wxFileDialog_GetFilename, 2238). +-define(wxFileDialog_GetFilenames, 2239). +-define(wxFileDialog_GetFilterIndex, 2240). +-define(wxFileDialog_GetMessage, 2241). +-define(wxFileDialog_GetPath, 2242). +-define(wxFileDialog_GetPaths, 2243). +-define(wxFileDialog_GetWildcard, 2244). +-define(wxFileDialog_SetDirectory, 2245). +-define(wxFileDialog_SetFilename, 2246). +-define(wxFileDialog_SetFilterIndex, 2247). +-define(wxFileDialog_SetMessage, 2248). +-define(wxFileDialog_SetPath, 2249). +-define(wxFileDialog_SetWildcard, 2250). +-define(wxPickerBase_SetInternalMargin, 2251). +-define(wxPickerBase_GetInternalMargin, 2252). +-define(wxPickerBase_SetTextCtrlProportion, 2253). +-define(wxPickerBase_SetPickerCtrlProportion, 2254). +-define(wxPickerBase_GetTextCtrlProportion, 2255). +-define(wxPickerBase_GetPickerCtrlProportion, 2256). +-define(wxPickerBase_HasTextCtrl, 2257). +-define(wxPickerBase_GetTextCtrl, 2258). +-define(wxPickerBase_IsTextCtrlGrowable, 2259). +-define(wxPickerBase_SetPickerCtrlGrowable, 2260). +-define(wxPickerBase_SetTextCtrlGrowable, 2261). +-define(wxPickerBase_IsPickerCtrlGrowable, 2262). +-define(wxFilePickerCtrl_new_0, 2263). +-define(wxFilePickerCtrl_new_3, 2264). +-define(wxFilePickerCtrl_Create, 2265). +-define(wxFilePickerCtrl_GetPath, 2266). +-define(wxFilePickerCtrl_SetPath, 2267). +-define(wxFilePickerCtrl_destroy, 2268). +-define(wxDirPickerCtrl_new_0, 2269). +-define(wxDirPickerCtrl_new_3, 2270). +-define(wxDirPickerCtrl_Create, 2271). +-define(wxDirPickerCtrl_GetPath, 2272). +-define(wxDirPickerCtrl_SetPath, 2273). +-define(wxDirPickerCtrl_destroy, 2274). +-define(wxColourPickerCtrl_new_0, 2275). +-define(wxColourPickerCtrl_new_3, 2276). +-define(wxColourPickerCtrl_Create, 2277). +-define(wxColourPickerCtrl_GetColour, 2278). +-define(wxColourPickerCtrl_SetColour_1_1, 2279). +-define(wxColourPickerCtrl_SetColour_1_0, 2280). +-define(wxColourPickerCtrl_destroy, 2281). +-define(wxDatePickerCtrl_new_0, 2282). +-define(wxDatePickerCtrl_new_3, 2283). +-define(wxDatePickerCtrl_GetRange, 2284). +-define(wxDatePickerCtrl_GetValue, 2285). +-define(wxDatePickerCtrl_SetRange, 2286). +-define(wxDatePickerCtrl_SetValue, 2287). +-define(wxDatePickerCtrl_destroy, 2288). +-define(wxFontPickerCtrl_new_0, 2289). +-define(wxFontPickerCtrl_new_3, 2290). +-define(wxFontPickerCtrl_Create, 2291). +-define(wxFontPickerCtrl_GetSelectedFont, 2292). +-define(wxFontPickerCtrl_SetSelectedFont, 2293). +-define(wxFontPickerCtrl_GetMaxPointSize, 2294). +-define(wxFontPickerCtrl_SetMaxPointSize, 2295). +-define(wxFontPickerCtrl_destroy, 2296). +-define(wxFindReplaceDialog_new_0, 2299). +-define(wxFindReplaceDialog_new_4, 2300). +-define(wxFindReplaceDialog_destruct, 2301). +-define(wxFindReplaceDialog_Create, 2302). +-define(wxFindReplaceDialog_GetData, 2303). +-define(wxFindReplaceData_new_0, 2304). +-define(wxFindReplaceData_new_1, 2305). +-define(wxFindReplaceData_GetFindString, 2306). +-define(wxFindReplaceData_GetReplaceString, 2307). +-define(wxFindReplaceData_GetFlags, 2308). +-define(wxFindReplaceData_SetFlags, 2309). +-define(wxFindReplaceData_SetFindString, 2310). +-define(wxFindReplaceData_SetReplaceString, 2311). +-define(wxFindReplaceData_destroy, 2312). +-define(wxMultiChoiceDialog_new_0, 2313). +-define(wxMultiChoiceDialog_new_5, 2315). +-define(wxMultiChoiceDialog_GetSelections, 2316). +-define(wxMultiChoiceDialog_SetSelections, 2317). +-define(wxMultiChoiceDialog_destroy, 2318). +-define(wxSingleChoiceDialog_new_0, 2319). +-define(wxSingleChoiceDialog_new_5, 2321). +-define(wxSingleChoiceDialog_GetSelection, 2322). +-define(wxSingleChoiceDialog_GetStringSelection, 2323). +-define(wxSingleChoiceDialog_SetSelection, 2324). +-define(wxSingleChoiceDialog_destroy, 2325). +-define(wxTextEntryDialog_new, 2326). +-define(wxTextEntryDialog_GetValue, 2327). +-define(wxTextEntryDialog_SetValue, 2328). +-define(wxTextEntryDialog_destroy, 2329). +-define(wxPasswordEntryDialog_new, 2330). +-define(wxPasswordEntryDialog_destroy, 2331). +-define(wxFontData_new_0, 2332). +-define(wxFontData_new_1, 2333). +-define(wxFontData_destruct, 2334). +-define(wxFontData_EnableEffects, 2335). +-define(wxFontData_GetAllowSymbols, 2336). +-define(wxFontData_GetColour, 2337). +-define(wxFontData_GetChosenFont, 2338). +-define(wxFontData_GetEnableEffects, 2339). +-define(wxFontData_GetInitialFont, 2340). +-define(wxFontData_GetShowHelp, 2341). +-define(wxFontData_SetAllowSymbols, 2342). +-define(wxFontData_SetChosenFont, 2343). +-define(wxFontData_SetColour, 2344). +-define(wxFontData_SetInitialFont, 2345). +-define(wxFontData_SetRange, 2346). +-define(wxFontData_SetShowHelp, 2347). +-define(wxFontDialog_new_0, 2351). +-define(wxFontDialog_new_2, 2353). +-define(wxFontDialog_Create, 2355). +-define(wxFontDialog_GetFontData, 2356). +-define(wxFontDialog_destroy, 2358). +-define(wxProgressDialog_new, 2359). +-define(wxProgressDialog_destruct, 2360). +-define(wxProgressDialog_Resume, 2361). +-define(wxProgressDialog_Update_2, 2362). +-define(wxProgressDialog_Update_0, 2363). +-define(wxMessageDialog_new, 2364). +-define(wxMessageDialog_destruct, 2365). +-define(wxPageSetupDialog_new, 2366). +-define(wxPageSetupDialog_destruct, 2367). +-define(wxPageSetupDialog_GetPageSetupData, 2368). +-define(wxPageSetupDialog_ShowModal, 2369). +-define(wxPageSetupDialogData_new_0, 2370). +-define(wxPageSetupDialogData_new_1_0, 2371). +-define(wxPageSetupDialogData_new_1_1, 2372). +-define(wxPageSetupDialogData_destruct, 2373). +-define(wxPageSetupDialogData_EnableHelp, 2374). +-define(wxPageSetupDialogData_EnableMargins, 2375). +-define(wxPageSetupDialogData_EnableOrientation, 2376). +-define(wxPageSetupDialogData_EnablePaper, 2377). +-define(wxPageSetupDialogData_EnablePrinter, 2378). +-define(wxPageSetupDialogData_GetDefaultMinMargins, 2379). +-define(wxPageSetupDialogData_GetEnableMargins, 2380). +-define(wxPageSetupDialogData_GetEnableOrientation, 2381). +-define(wxPageSetupDialogData_GetEnablePaper, 2382). +-define(wxPageSetupDialogData_GetEnablePrinter, 2383). +-define(wxPageSetupDialogData_GetEnableHelp, 2384). +-define(wxPageSetupDialogData_GetDefaultInfo, 2385). +-define(wxPageSetupDialogData_GetMarginTopLeft, 2386). +-define(wxPageSetupDialogData_GetMarginBottomRight, 2387). +-define(wxPageSetupDialogData_GetMinMarginTopLeft, 2388). +-define(wxPageSetupDialogData_GetMinMarginBottomRight, 2389). +-define(wxPageSetupDialogData_GetPaperId, 2390). +-define(wxPageSetupDialogData_GetPaperSize, 2391). +-define(wxPageSetupDialogData_GetPrintData, 2393). +-define(wxPageSetupDialogData_IsOk, 2394). +-define(wxPageSetupDialogData_SetDefaultInfo, 2395). +-define(wxPageSetupDialogData_SetDefaultMinMargins, 2396). +-define(wxPageSetupDialogData_SetMarginTopLeft, 2397). +-define(wxPageSetupDialogData_SetMarginBottomRight, 2398). +-define(wxPageSetupDialogData_SetMinMarginTopLeft, 2399). +-define(wxPageSetupDialogData_SetMinMarginBottomRight, 2400). +-define(wxPageSetupDialogData_SetPaperId, 2401). +-define(wxPageSetupDialogData_SetPaperSize_1_1, 2402). +-define(wxPageSetupDialogData_SetPaperSize_1_0, 2403). +-define(wxPageSetupDialogData_SetPrintData, 2404). +-define(wxPrintDialog_new_2_0, 2405). +-define(wxPrintDialog_new_2_1, 2406). +-define(wxPrintDialog_destruct, 2407). +-define(wxPrintDialog_GetPrintDialogData, 2408). +-define(wxPrintDialog_GetPrintDC, 2409). +-define(wxPrintDialogData_new_0, 2410). +-define(wxPrintDialogData_new_1_1, 2411). +-define(wxPrintDialogData_new_1_0, 2412). +-define(wxPrintDialogData_destruct, 2413). +-define(wxPrintDialogData_EnableHelp, 2414). +-define(wxPrintDialogData_EnablePageNumbers, 2415). +-define(wxPrintDialogData_EnablePrintToFile, 2416). +-define(wxPrintDialogData_EnableSelection, 2417). +-define(wxPrintDialogData_GetAllPages, 2418). +-define(wxPrintDialogData_GetCollate, 2419). +-define(wxPrintDialogData_GetFromPage, 2420). +-define(wxPrintDialogData_GetMaxPage, 2421). +-define(wxPrintDialogData_GetMinPage, 2422). +-define(wxPrintDialogData_GetNoCopies, 2423). +-define(wxPrintDialogData_GetPrintData, 2424). +-define(wxPrintDialogData_GetPrintToFile, 2425). +-define(wxPrintDialogData_GetSelection, 2426). +-define(wxPrintDialogData_GetToPage, 2427). +-define(wxPrintDialogData_IsOk, 2428). +-define(wxPrintDialogData_SetCollate, 2429). +-define(wxPrintDialogData_SetFromPage, 2430). +-define(wxPrintDialogData_SetMaxPage, 2431). +-define(wxPrintDialogData_SetMinPage, 2432). +-define(wxPrintDialogData_SetNoCopies, 2433). +-define(wxPrintDialogData_SetPrintData, 2434). +-define(wxPrintDialogData_SetPrintToFile, 2435). +-define(wxPrintDialogData_SetSelection, 2436). +-define(wxPrintDialogData_SetToPage, 2437). +-define(wxPrintData_new_0, 2438). +-define(wxPrintData_new_1, 2439). +-define(wxPrintData_destruct, 2440). +-define(wxPrintData_GetCollate, 2441). +-define(wxPrintData_GetBin, 2442). +-define(wxPrintData_GetColour, 2443). +-define(wxPrintData_GetDuplex, 2444). +-define(wxPrintData_GetNoCopies, 2445). +-define(wxPrintData_GetOrientation, 2446). +-define(wxPrintData_GetPaperId, 2447). +-define(wxPrintData_GetPrinterName, 2448). +-define(wxPrintData_GetQuality, 2449). +-define(wxPrintData_IsOk, 2450). +-define(wxPrintData_SetBin, 2451). +-define(wxPrintData_SetCollate, 2452). +-define(wxPrintData_SetColour, 2453). +-define(wxPrintData_SetDuplex, 2454). +-define(wxPrintData_SetNoCopies, 2455). +-define(wxPrintData_SetOrientation, 2456). +-define(wxPrintData_SetPaperId, 2457). +-define(wxPrintData_SetPrinterName, 2458). +-define(wxPrintData_SetQuality, 2459). +-define(wxPrintPreview_new_2, 2462). +-define(wxPrintPreview_new_3, 2463). +-define(wxPrintPreview_destruct, 2465). +-define(wxPrintPreview_GetCanvas, 2466). +-define(wxPrintPreview_GetCurrentPage, 2467). +-define(wxPrintPreview_GetFrame, 2468). +-define(wxPrintPreview_GetMaxPage, 2469). +-define(wxPrintPreview_GetMinPage, 2470). +-define(wxPrintPreview_GetPrintout, 2471). +-define(wxPrintPreview_GetPrintoutForPrinting, 2472). +-define(wxPrintPreview_IsOk, 2473). +-define(wxPrintPreview_PaintPage, 2474). +-define(wxPrintPreview_Print, 2475). +-define(wxPrintPreview_RenderPage, 2476). +-define(wxPrintPreview_SetCanvas, 2477). +-define(wxPrintPreview_SetCurrentPage, 2478). +-define(wxPrintPreview_SetFrame, 2479). +-define(wxPrintPreview_SetPrintout, 2480). +-define(wxPrintPreview_SetZoom, 2481). +-define(wxPreviewFrame_new, 2482). +-define(wxPreviewFrame_destruct, 2483). +-define(wxPreviewFrame_CreateControlBar, 2484). +-define(wxPreviewFrame_CreateCanvas, 2485). +-define(wxPreviewFrame_Initialize, 2486). +-define(wxPreviewFrame_OnCloseWindow, 2487). +-define(wxPreviewControlBar_new, 2488). +-define(wxPreviewControlBar_destruct, 2489). +-define(wxPreviewControlBar_CreateButtons, 2490). +-define(wxPreviewControlBar_GetPrintPreview, 2491). +-define(wxPreviewControlBar_GetZoomControl, 2492). +-define(wxPreviewControlBar_SetZoomControl, 2493). +-define(wxPrinter_new, 2495). +-define(wxPrinter_CreateAbortWindow, 2496). +-define(wxPrinter_GetAbort, 2497). +-define(wxPrinter_GetLastError, 2498). +-define(wxPrinter_GetPrintDialogData, 2499). +-define(wxPrinter_Print, 2500). +-define(wxPrinter_PrintDialog, 2501). +-define(wxPrinter_ReportError, 2502). +-define(wxPrinter_Setup, 2503). +-define(wxPrinter_destroy, 2504). +-define(wxXmlResource_new_1, 2505). +-define(wxXmlResource_new_2, 2506). +-define(wxXmlResource_destruct, 2507). +-define(wxXmlResource_AttachUnknownControl, 2508). +-define(wxXmlResource_ClearHandlers, 2509). +-define(wxXmlResource_CompareVersion, 2510). +-define(wxXmlResource_Get, 2511). +-define(wxXmlResource_GetFlags, 2512). +-define(wxXmlResource_GetVersion, 2513). +-define(wxXmlResource_GetXRCID, 2514). +-define(wxXmlResource_InitAllHandlers, 2515). +-define(wxXmlResource_Load, 2516). +-define(wxXmlResource_LoadBitmap, 2517). +-define(wxXmlResource_LoadDialog_2, 2518). +-define(wxXmlResource_LoadDialog_3, 2519). +-define(wxXmlResource_LoadFrame_2, 2520). +-define(wxXmlResource_LoadFrame_3, 2521). +-define(wxXmlResource_LoadIcon, 2522). +-define(wxXmlResource_LoadMenu, 2523). +-define(wxXmlResource_LoadMenuBar_2, 2524). +-define(wxXmlResource_LoadMenuBar_1, 2525). +-define(wxXmlResource_LoadPanel_2, 2526). +-define(wxXmlResource_LoadPanel_3, 2527). +-define(wxXmlResource_LoadToolBar, 2528). +-define(wxXmlResource_Set, 2529). +-define(wxXmlResource_SetFlags, 2530). +-define(wxXmlResource_Unload, 2531). +-define(wxXmlResource_xrcctrl, 2532). +-define(wxHtmlEasyPrinting_new, 2533). +-define(wxHtmlEasyPrinting_destruct, 2534). +-define(wxHtmlEasyPrinting_GetPrintData, 2535). +-define(wxHtmlEasyPrinting_GetPageSetupData, 2536). +-define(wxHtmlEasyPrinting_PreviewFile, 2537). +-define(wxHtmlEasyPrinting_PreviewText, 2538). +-define(wxHtmlEasyPrinting_PrintFile, 2539). +-define(wxHtmlEasyPrinting_PrintText, 2540). +-define(wxHtmlEasyPrinting_PageSetup, 2541). +-define(wxHtmlEasyPrinting_SetFonts, 2542). +-define(wxHtmlEasyPrinting_SetHeader, 2543). +-define(wxHtmlEasyPrinting_SetFooter, 2544). +-define(wxGLCanvas_new_2, 2546). +-define(wxGLCanvas_new_3_1, 2547). +-define(wxGLCanvas_new_3_0, 2548). +-define(wxGLCanvas_GetContext, 2549). +-define(wxGLCanvas_SetCurrent, 2551). +-define(wxGLCanvas_SwapBuffers, 2552). +-define(wxGLCanvas_destroy, 2553). +-define(wxAuiManager_new, 2554). +-define(wxAuiManager_destruct, 2555). +-define(wxAuiManager_AddPane_2_1, 2556). +-define(wxAuiManager_AddPane_3, 2557). +-define(wxAuiManager_AddPane_2_0, 2558). +-define(wxAuiManager_DetachPane, 2559). +-define(wxAuiManager_GetAllPanes, 2560). +-define(wxAuiManager_GetArtProvider, 2561). +-define(wxAuiManager_GetDockSizeConstraint, 2562). +-define(wxAuiManager_GetFlags, 2563). +-define(wxAuiManager_GetManagedWindow, 2564). +-define(wxAuiManager_GetManager, 2565). +-define(wxAuiManager_GetPane_1_1, 2566). +-define(wxAuiManager_GetPane_1_0, 2567). +-define(wxAuiManager_HideHint, 2568). +-define(wxAuiManager_InsertPane, 2569). +-define(wxAuiManager_LoadPaneInfo, 2570). +-define(wxAuiManager_LoadPerspective, 2571). +-define(wxAuiManager_SavePaneInfo, 2572). +-define(wxAuiManager_SavePerspective, 2573). +-define(wxAuiManager_SetArtProvider, 2574). +-define(wxAuiManager_SetDockSizeConstraint, 2575). +-define(wxAuiManager_SetFlags, 2576). +-define(wxAuiManager_SetManagedWindow, 2577). +-define(wxAuiManager_ShowHint, 2578). +-define(wxAuiManager_UnInit, 2579). +-define(wxAuiManager_Update, 2580). +-define(wxAuiPaneInfo_new_0, 2581). +-define(wxAuiPaneInfo_new_1, 2582). +-define(wxAuiPaneInfo_destruct, 2583). +-define(wxAuiPaneInfo_BestSize_1, 2584). +-define(wxAuiPaneInfo_BestSize_2, 2585). +-define(wxAuiPaneInfo_Bottom, 2586). +-define(wxAuiPaneInfo_BottomDockable, 2587). +-define(wxAuiPaneInfo_Caption, 2588). +-define(wxAuiPaneInfo_CaptionVisible, 2589). +-define(wxAuiPaneInfo_Centre, 2590). +-define(wxAuiPaneInfo_CentrePane, 2591). +-define(wxAuiPaneInfo_CloseButton, 2592). +-define(wxAuiPaneInfo_DefaultPane, 2593). +-define(wxAuiPaneInfo_DestroyOnClose, 2594). +-define(wxAuiPaneInfo_Direction, 2595). +-define(wxAuiPaneInfo_Dock, 2596). +-define(wxAuiPaneInfo_Dockable, 2597). +-define(wxAuiPaneInfo_Fixed, 2598). +-define(wxAuiPaneInfo_Float, 2599). +-define(wxAuiPaneInfo_Floatable, 2600). +-define(wxAuiPaneInfo_FloatingPosition_1, 2601). +-define(wxAuiPaneInfo_FloatingPosition_2, 2602). +-define(wxAuiPaneInfo_FloatingSize_1, 2603). +-define(wxAuiPaneInfo_FloatingSize_2, 2604). +-define(wxAuiPaneInfo_Gripper, 2605). +-define(wxAuiPaneInfo_GripperTop, 2606). +-define(wxAuiPaneInfo_HasBorder, 2607). +-define(wxAuiPaneInfo_HasCaption, 2608). +-define(wxAuiPaneInfo_HasCloseButton, 2609). +-define(wxAuiPaneInfo_HasFlag, 2610). +-define(wxAuiPaneInfo_HasGripper, 2611). +-define(wxAuiPaneInfo_HasGripperTop, 2612). +-define(wxAuiPaneInfo_HasMaximizeButton, 2613). +-define(wxAuiPaneInfo_HasMinimizeButton, 2614). +-define(wxAuiPaneInfo_HasPinButton, 2615). +-define(wxAuiPaneInfo_Hide, 2616). +-define(wxAuiPaneInfo_IsBottomDockable, 2617). +-define(wxAuiPaneInfo_IsDocked, 2618). +-define(wxAuiPaneInfo_IsFixed, 2619). +-define(wxAuiPaneInfo_IsFloatable, 2620). +-define(wxAuiPaneInfo_IsFloating, 2621). +-define(wxAuiPaneInfo_IsLeftDockable, 2622). +-define(wxAuiPaneInfo_IsMovable, 2623). +-define(wxAuiPaneInfo_IsOk, 2624). +-define(wxAuiPaneInfo_IsResizable, 2625). +-define(wxAuiPaneInfo_IsRightDockable, 2626). +-define(wxAuiPaneInfo_IsShown, 2627). +-define(wxAuiPaneInfo_IsToolbar, 2628). +-define(wxAuiPaneInfo_IsTopDockable, 2629). +-define(wxAuiPaneInfo_Layer, 2630). +-define(wxAuiPaneInfo_Left, 2631). +-define(wxAuiPaneInfo_LeftDockable, 2632). +-define(wxAuiPaneInfo_MaxSize_1, 2633). +-define(wxAuiPaneInfo_MaxSize_2, 2634). +-define(wxAuiPaneInfo_MaximizeButton, 2635). +-define(wxAuiPaneInfo_MinSize_1, 2636). +-define(wxAuiPaneInfo_MinSize_2, 2637). +-define(wxAuiPaneInfo_MinimizeButton, 2638). +-define(wxAuiPaneInfo_Movable, 2639). +-define(wxAuiPaneInfo_Name, 2640). +-define(wxAuiPaneInfo_PaneBorder, 2641). +-define(wxAuiPaneInfo_PinButton, 2642). +-define(wxAuiPaneInfo_Position, 2643). +-define(wxAuiPaneInfo_Resizable, 2644). +-define(wxAuiPaneInfo_Right, 2645). +-define(wxAuiPaneInfo_RightDockable, 2646). +-define(wxAuiPaneInfo_Row, 2647). +-define(wxAuiPaneInfo_SafeSet, 2648). +-define(wxAuiPaneInfo_SetFlag, 2649). +-define(wxAuiPaneInfo_Show, 2650). +-define(wxAuiPaneInfo_ToolbarPane, 2651). +-define(wxAuiPaneInfo_Top, 2652). +-define(wxAuiPaneInfo_TopDockable, 2653). +-define(wxAuiPaneInfo_Window, 2654). +-define(wxAuiPaneInfo_GetWindow, 2655). +-define(wxAuiPaneInfo_GetFrame, 2656). +-define(wxAuiPaneInfo_GetDirection, 2657). +-define(wxAuiPaneInfo_GetLayer, 2658). +-define(wxAuiPaneInfo_GetRow, 2659). +-define(wxAuiPaneInfo_GetPosition, 2660). +-define(wxAuiPaneInfo_GetFloatingPosition, 2661). +-define(wxAuiPaneInfo_GetFloatingSize, 2662). +-define(wxAuiNotebook_new_0, 2663). +-define(wxAuiNotebook_new_2, 2664). +-define(wxAuiNotebook_AddPage, 2665). +-define(wxAuiNotebook_Create, 2666). +-define(wxAuiNotebook_DeletePage, 2667). +-define(wxAuiNotebook_GetArtProvider, 2668). +-define(wxAuiNotebook_GetPage, 2669). +-define(wxAuiNotebook_GetPageBitmap, 2670). +-define(wxAuiNotebook_GetPageCount, 2671). +-define(wxAuiNotebook_GetPageIndex, 2672). +-define(wxAuiNotebook_GetPageText, 2673). +-define(wxAuiNotebook_GetSelection, 2674). +-define(wxAuiNotebook_InsertPage, 2675). +-define(wxAuiNotebook_RemovePage, 2676). +-define(wxAuiNotebook_SetArtProvider, 2677). +-define(wxAuiNotebook_SetFont, 2678). +-define(wxAuiNotebook_SetPageBitmap, 2679). +-define(wxAuiNotebook_SetPageText, 2680). +-define(wxAuiNotebook_SetSelection, 2681). +-define(wxAuiNotebook_SetTabCtrlHeight, 2682). +-define(wxAuiNotebook_SetUniformBitmapSize, 2683). +-define(wxAuiNotebook_destroy, 2684). +-define(wxAuiTabArt_SetFlags, 2685). +-define(wxAuiTabArt_SetMeasuringFont, 2686). +-define(wxAuiTabArt_SetNormalFont, 2687). +-define(wxAuiTabArt_SetSelectedFont, 2688). +-define(wxAuiTabArt_SetColour, 2689). +-define(wxAuiTabArt_SetActiveColour, 2690). +-define(wxAuiDockArt_GetColour, 2691). +-define(wxAuiDockArt_GetFont, 2692). +-define(wxAuiDockArt_GetMetric, 2693). +-define(wxAuiDockArt_SetColour, 2694). +-define(wxAuiDockArt_SetFont, 2695). +-define(wxAuiDockArt_SetMetric, 2696). +-define(wxAuiSimpleTabArt_new, 2697). +-define(wxAuiSimpleTabArt_destroy, 2698). +-define(wxMDIParentFrame_new_0, 2699). +-define(wxMDIParentFrame_new_4, 2700). +-define(wxMDIParentFrame_destruct, 2701). +-define(wxMDIParentFrame_ActivateNext, 2702). +-define(wxMDIParentFrame_ActivatePrevious, 2703). +-define(wxMDIParentFrame_ArrangeIcons, 2704). +-define(wxMDIParentFrame_Cascade, 2705). +-define(wxMDIParentFrame_Create, 2706). +-define(wxMDIParentFrame_GetActiveChild, 2707). +-define(wxMDIParentFrame_GetClientWindow, 2708). +-define(wxMDIParentFrame_Tile, 2709). +-define(wxMDIChildFrame_new_0, 2710). +-define(wxMDIChildFrame_new_4, 2711). +-define(wxMDIChildFrame_destruct, 2712). +-define(wxMDIChildFrame_Activate, 2713). +-define(wxMDIChildFrame_Create, 2714). +-define(wxMDIChildFrame_Maximize, 2715). +-define(wxMDIChildFrame_Restore, 2716). +-define(wxMDIClientWindow_new_0, 2717). +-define(wxMDIClientWindow_new_2, 2718). +-define(wxMDIClientWindow_destruct, 2719). +-define(wxMDIClientWindow_CreateClient, 2720). +-define(wxLayoutAlgorithm_new, 2721). +-define(wxLayoutAlgorithm_LayoutFrame, 2722). +-define(wxLayoutAlgorithm_LayoutMDIFrame, 2723). +-define(wxLayoutAlgorithm_LayoutWindow, 2724). +-define(wxLayoutAlgorithm_destroy, 2725). +-define(wxEvent_GetId, 2726). +-define(wxEvent_GetSkipped, 2727). +-define(wxEvent_GetTimestamp, 2728). +-define(wxEvent_IsCommandEvent, 2729). +-define(wxEvent_ResumePropagation, 2730). +-define(wxEvent_ShouldPropagate, 2731). +-define(wxEvent_Skip, 2732). +-define(wxEvent_StopPropagation, 2733). +-define(wxCommandEvent_getClientData, 2734). +-define(wxCommandEvent_GetExtraLong, 2735). +-define(wxCommandEvent_GetInt, 2736). +-define(wxCommandEvent_GetSelection, 2737). +-define(wxCommandEvent_GetString, 2738). +-define(wxCommandEvent_IsChecked, 2739). +-define(wxCommandEvent_IsSelection, 2740). +-define(wxCommandEvent_SetInt, 2741). +-define(wxCommandEvent_SetString, 2742). +-define(wxScrollEvent_GetOrientation, 2743). +-define(wxScrollEvent_GetPosition, 2744). +-define(wxScrollWinEvent_GetOrientation, 2745). +-define(wxScrollWinEvent_GetPosition, 2746). +-define(wxMouseEvent_AltDown, 2747). +-define(wxMouseEvent_Button, 2748). +-define(wxMouseEvent_ButtonDClick, 2749). +-define(wxMouseEvent_ButtonDown, 2750). +-define(wxMouseEvent_ButtonUp, 2751). +-define(wxMouseEvent_CmdDown, 2752). +-define(wxMouseEvent_ControlDown, 2753). +-define(wxMouseEvent_Dragging, 2754). +-define(wxMouseEvent_Entering, 2755). +-define(wxMouseEvent_GetButton, 2756). +-define(wxMouseEvent_GetPosition, 2759). +-define(wxMouseEvent_GetLogicalPosition, 2760). +-define(wxMouseEvent_GetLinesPerAction, 2761). +-define(wxMouseEvent_GetWheelRotation, 2762). +-define(wxMouseEvent_GetWheelDelta, 2763). +-define(wxMouseEvent_GetX, 2764). +-define(wxMouseEvent_GetY, 2765). +-define(wxMouseEvent_IsButton, 2766). +-define(wxMouseEvent_IsPageScroll, 2767). +-define(wxMouseEvent_Leaving, 2768). +-define(wxMouseEvent_LeftDClick, 2769). +-define(wxMouseEvent_LeftDown, 2770). +-define(wxMouseEvent_LeftIsDown, 2771). +-define(wxMouseEvent_LeftUp, 2772). +-define(wxMouseEvent_MetaDown, 2773). +-define(wxMouseEvent_MiddleDClick, 2774). +-define(wxMouseEvent_MiddleDown, 2775). +-define(wxMouseEvent_MiddleIsDown, 2776). +-define(wxMouseEvent_MiddleUp, 2777). +-define(wxMouseEvent_Moving, 2778). +-define(wxMouseEvent_RightDClick, 2779). +-define(wxMouseEvent_RightDown, 2780). +-define(wxMouseEvent_RightIsDown, 2781). +-define(wxMouseEvent_RightUp, 2782). +-define(wxMouseEvent_ShiftDown, 2783). +-define(wxSetCursorEvent_GetCursor, 2784). +-define(wxSetCursorEvent_GetX, 2785). +-define(wxSetCursorEvent_GetY, 2786). +-define(wxSetCursorEvent_HasCursor, 2787). +-define(wxSetCursorEvent_SetCursor, 2788). +-define(wxKeyEvent_AltDown, 2789). +-define(wxKeyEvent_CmdDown, 2790). +-define(wxKeyEvent_ControlDown, 2791). +-define(wxKeyEvent_GetKeyCode, 2792). +-define(wxKeyEvent_GetModifiers, 2793). +-define(wxKeyEvent_GetPosition, 2796). +-define(wxKeyEvent_GetRawKeyCode, 2797). +-define(wxKeyEvent_GetRawKeyFlags, 2798). +-define(wxKeyEvent_GetUnicodeKey, 2799). +-define(wxKeyEvent_GetX, 2800). +-define(wxKeyEvent_GetY, 2801). +-define(wxKeyEvent_HasModifiers, 2802). +-define(wxKeyEvent_MetaDown, 2803). +-define(wxKeyEvent_ShiftDown, 2804). +-define(wxSizeEvent_GetSize, 2805). +-define(wxMoveEvent_GetPosition, 2806). +-define(wxEraseEvent_GetDC, 2807). +-define(wxFocusEvent_GetWindow, 2808). +-define(wxChildFocusEvent_GetWindow, 2809). +-define(wxMenuEvent_GetMenu, 2810). +-define(wxMenuEvent_GetMenuId, 2811). +-define(wxMenuEvent_IsPopup, 2812). +-define(wxCloseEvent_CanVeto, 2813). +-define(wxCloseEvent_GetLoggingOff, 2814). +-define(wxCloseEvent_SetCanVeto, 2815). +-define(wxCloseEvent_SetLoggingOff, 2816). +-define(wxCloseEvent_Veto, 2817). +-define(wxShowEvent_SetShow, 2818). +-define(wxShowEvent_GetShow, 2819). +-define(wxIconizeEvent_Iconized, 2820). +-define(wxJoystickEvent_ButtonDown, 2821). +-define(wxJoystickEvent_ButtonIsDown, 2822). +-define(wxJoystickEvent_ButtonUp, 2823). +-define(wxJoystickEvent_GetButtonChange, 2824). +-define(wxJoystickEvent_GetButtonState, 2825). +-define(wxJoystickEvent_GetJoystick, 2826). +-define(wxJoystickEvent_GetPosition, 2827). +-define(wxJoystickEvent_GetZPosition, 2828). +-define(wxJoystickEvent_IsButton, 2829). +-define(wxJoystickEvent_IsMove, 2830). +-define(wxJoystickEvent_IsZMove, 2831). +-define(wxUpdateUIEvent_CanUpdate, 2832). +-define(wxUpdateUIEvent_Check, 2833). +-define(wxUpdateUIEvent_Enable, 2834). +-define(wxUpdateUIEvent_Show, 2835). +-define(wxUpdateUIEvent_GetChecked, 2836). +-define(wxUpdateUIEvent_GetEnabled, 2837). +-define(wxUpdateUIEvent_GetShown, 2838). +-define(wxUpdateUIEvent_GetSetChecked, 2839). +-define(wxUpdateUIEvent_GetSetEnabled, 2840). +-define(wxUpdateUIEvent_GetSetShown, 2841). +-define(wxUpdateUIEvent_GetSetText, 2842). +-define(wxUpdateUIEvent_GetText, 2843). +-define(wxUpdateUIEvent_GetMode, 2844). +-define(wxUpdateUIEvent_GetUpdateInterval, 2845). +-define(wxUpdateUIEvent_ResetUpdateTime, 2846). +-define(wxUpdateUIEvent_SetMode, 2847). +-define(wxUpdateUIEvent_SetText, 2848). +-define(wxUpdateUIEvent_SetUpdateInterval, 2849). +-define(wxMouseCaptureChangedEvent_GetCapturedWindow, 2850). +-define(wxPaletteChangedEvent_SetChangedWindow, 2851). +-define(wxPaletteChangedEvent_GetChangedWindow, 2852). +-define(wxQueryNewPaletteEvent_SetPaletteRealized, 2853). +-define(wxQueryNewPaletteEvent_GetPaletteRealized, 2854). +-define(wxNavigationKeyEvent_GetDirection, 2855). +-define(wxNavigationKeyEvent_SetDirection, 2856). +-define(wxNavigationKeyEvent_IsWindowChange, 2857). +-define(wxNavigationKeyEvent_SetWindowChange, 2858). +-define(wxNavigationKeyEvent_IsFromTab, 2859). +-define(wxNavigationKeyEvent_SetFromTab, 2860). +-define(wxNavigationKeyEvent_GetCurrentFocus, 2861). +-define(wxNavigationKeyEvent_SetCurrentFocus, 2862). +-define(wxHelpEvent_GetOrigin, 2863). +-define(wxHelpEvent_GetPosition, 2864). +-define(wxHelpEvent_SetOrigin, 2865). +-define(wxHelpEvent_SetPosition, 2866). +-define(wxContextMenuEvent_GetPosition, 2867). +-define(wxContextMenuEvent_SetPosition, 2868). +-define(wxIdleEvent_CanSend, 2869). +-define(wxIdleEvent_GetMode, 2870). +-define(wxIdleEvent_RequestMore, 2871). +-define(wxIdleEvent_MoreRequested, 2872). +-define(wxIdleEvent_SetMode, 2873). +-define(wxGridEvent_AltDown, 2874). +-define(wxGridEvent_ControlDown, 2875). +-define(wxGridEvent_GetCol, 2876). +-define(wxGridEvent_GetPosition, 2877). +-define(wxGridEvent_GetRow, 2878). +-define(wxGridEvent_MetaDown, 2879). +-define(wxGridEvent_Selecting, 2880). +-define(wxGridEvent_ShiftDown, 2881). +-define(wxNotifyEvent_Allow, 2882). +-define(wxNotifyEvent_IsAllowed, 2883). +-define(wxNotifyEvent_Veto, 2884). +-define(wxSashEvent_GetEdge, 2885). +-define(wxSashEvent_GetDragRect, 2886). +-define(wxSashEvent_GetDragStatus, 2887). +-define(wxListEvent_GetCacheFrom, 2888). +-define(wxListEvent_GetCacheTo, 2889). +-define(wxListEvent_GetKeyCode, 2890). +-define(wxListEvent_GetIndex, 2891). +-define(wxListEvent_GetColumn, 2892). +-define(wxListEvent_GetPoint, 2893). +-define(wxListEvent_GetLabel, 2894). +-define(wxListEvent_GetText, 2895). +-define(wxListEvent_GetImage, 2896). +-define(wxListEvent_GetData, 2897). +-define(wxListEvent_GetMask, 2898). +-define(wxListEvent_GetItem, 2899). +-define(wxListEvent_IsEditCancelled, 2900). +-define(wxDateEvent_GetDate, 2901). +-define(wxCalendarEvent_GetWeekDay, 2902). +-define(wxFileDirPickerEvent_GetPath, 2903). +-define(wxColourPickerEvent_GetColour, 2904). +-define(wxFontPickerEvent_GetFont, 2905). +-define(wxStyledTextEvent_GetPosition, 2906). +-define(wxStyledTextEvent_GetKey, 2907). +-define(wxStyledTextEvent_GetModifiers, 2908). +-define(wxStyledTextEvent_GetModificationType, 2909). +-define(wxStyledTextEvent_GetText, 2910). +-define(wxStyledTextEvent_GetLength, 2911). +-define(wxStyledTextEvent_GetLinesAdded, 2912). +-define(wxStyledTextEvent_GetLine, 2913). +-define(wxStyledTextEvent_GetFoldLevelNow, 2914). +-define(wxStyledTextEvent_GetFoldLevelPrev, 2915). +-define(wxStyledTextEvent_GetMargin, 2916). +-define(wxStyledTextEvent_GetMessage, 2917). +-define(wxStyledTextEvent_GetWParam, 2918). +-define(wxStyledTextEvent_GetLParam, 2919). +-define(wxStyledTextEvent_GetListType, 2920). +-define(wxStyledTextEvent_GetX, 2921). +-define(wxStyledTextEvent_GetY, 2922). +-define(wxStyledTextEvent_GetDragText, 2923). +-define(wxStyledTextEvent_GetDragAllowMove, 2924). +-define(wxStyledTextEvent_GetDragResult, 2925). +-define(wxStyledTextEvent_GetShift, 2926). +-define(wxStyledTextEvent_GetControl, 2927). +-define(wxStyledTextEvent_GetAlt, 2928). +-define(utils_wxGetKeyState, 2929). +-define(utils_wxGetMousePosition, 2930). +-define(utils_wxGetMouseState, 2931). +-define(utils_wxSetDetectableAutoRepeat, 2932). +-define(utils_wxBell, 2933). +-define(utils_wxFindMenuItemId, 2934). +-define(utils_wxGenericFindWindowAtPoint, 2935). +-define(utils_wxFindWindowAtPoint, 2936). +-define(utils_wxBeginBusyCursor, 2937). +-define(utils_wxEndBusyCursor, 2938). +-define(utils_wxIsBusy, 2939). +-define(utils_wxShutdown, 2940). +-define(utils_wxShell, 2941). +-define(utils_wxLaunchDefaultBrowser, 2942). +-define(utils_wxGetEmailAddress, 2943). +-define(utils_wxGetUserId, 2944). +-define(utils_wxGetHomeDir, 2945). +-define(utils_wxNewId, 2946). +-define(utils_wxRegisterId, 2947). +-define(utils_wxGetCurrentId, 2948). +-define(utils_wxGetOsDescription, 2949). +-define(utils_wxIsPlatformLittleEndian, 2950). +-define(utils_wxIsPlatform64Bit, 2951). +-define(gdicmn_wxDisplaySize, 2952). +-define(gdicmn_wxSetCursor, 2953). +-define(wxPrintout_new, 2954). +-define(wxPrintout_destruct, 2955). +-define(wxPrintout_GetDC, 2956). +-define(wxPrintout_GetPageSizeMM, 2957). +-define(wxPrintout_GetPageSizePixels, 2958). +-define(wxPrintout_GetPaperRectPixels, 2959). +-define(wxPrintout_GetPPIPrinter, 2960). +-define(wxPrintout_GetPPIScreen, 2961). +-define(wxPrintout_GetTitle, 2962). +-define(wxPrintout_IsPreview, 2963). +-define(wxPrintout_FitThisSizeToPaper, 2964). +-define(wxPrintout_FitThisSizeToPage, 2965). +-define(wxPrintout_FitThisSizeToPageMargins, 2966). +-define(wxPrintout_MapScreenSizeToPaper, 2967). +-define(wxPrintout_MapScreenSizeToPage, 2968). +-define(wxPrintout_MapScreenSizeToPageMargins, 2969). +-define(wxPrintout_MapScreenSizeToDevice, 2970). +-define(wxPrintout_GetLogicalPaperRect, 2971). +-define(wxPrintout_GetLogicalPageRect, 2972). +-define(wxPrintout_GetLogicalPageMarginsRect, 2973). +-define(wxPrintout_SetLogicalOrigin, 2974). +-define(wxPrintout_OffsetLogicalOrigin, 2975). +-define(wxStyledTextCtrl_new_2, 2976). +-define(wxStyledTextCtrl_new_0, 2977). +-define(wxStyledTextCtrl_destruct, 2978). +-define(wxStyledTextCtrl_Create, 2979). +-define(wxStyledTextCtrl_AddText, 2980). +-define(wxStyledTextCtrl_AddStyledText, 2981). +-define(wxStyledTextCtrl_InsertText, 2982). +-define(wxStyledTextCtrl_ClearAll, 2983). +-define(wxStyledTextCtrl_ClearDocumentStyle, 2984). +-define(wxStyledTextCtrl_GetLength, 2985). +-define(wxStyledTextCtrl_GetCharAt, 2986). +-define(wxStyledTextCtrl_GetCurrentPos, 2987). +-define(wxStyledTextCtrl_GetAnchor, 2988). +-define(wxStyledTextCtrl_GetStyleAt, 2989). +-define(wxStyledTextCtrl_Redo, 2990). +-define(wxStyledTextCtrl_SetUndoCollection, 2991). +-define(wxStyledTextCtrl_SelectAll, 2992). +-define(wxStyledTextCtrl_SetSavePoint, 2993). +-define(wxStyledTextCtrl_GetStyledText, 2994). +-define(wxStyledTextCtrl_CanRedo, 2995). +-define(wxStyledTextCtrl_MarkerLineFromHandle, 2996). +-define(wxStyledTextCtrl_MarkerDeleteHandle, 2997). +-define(wxStyledTextCtrl_GetUndoCollection, 2998). +-define(wxStyledTextCtrl_GetViewWhiteSpace, 2999). +-define(wxStyledTextCtrl_SetViewWhiteSpace, 3000). +-define(wxStyledTextCtrl_PositionFromPoint, 3001). +-define(wxStyledTextCtrl_PositionFromPointClose, 3002). +-define(wxStyledTextCtrl_GotoLine, 3003). +-define(wxStyledTextCtrl_GotoPos, 3004). +-define(wxStyledTextCtrl_SetAnchor, 3005). +-define(wxStyledTextCtrl_GetCurLine, 3006). +-define(wxStyledTextCtrl_GetEndStyled, 3007). +-define(wxStyledTextCtrl_ConvertEOLs, 3008). +-define(wxStyledTextCtrl_GetEOLMode, 3009). +-define(wxStyledTextCtrl_SetEOLMode, 3010). +-define(wxStyledTextCtrl_StartStyling, 3011). +-define(wxStyledTextCtrl_SetStyling, 3012). +-define(wxStyledTextCtrl_GetBufferedDraw, 3013). +-define(wxStyledTextCtrl_SetBufferedDraw, 3014). +-define(wxStyledTextCtrl_SetTabWidth, 3015). +-define(wxStyledTextCtrl_GetTabWidth, 3016). +-define(wxStyledTextCtrl_SetCodePage, 3017). +-define(wxStyledTextCtrl_MarkerDefine, 3018). +-define(wxStyledTextCtrl_MarkerSetForeground, 3019). +-define(wxStyledTextCtrl_MarkerSetBackground, 3020). +-define(wxStyledTextCtrl_MarkerAdd, 3021). +-define(wxStyledTextCtrl_MarkerDelete, 3022). +-define(wxStyledTextCtrl_MarkerDeleteAll, 3023). +-define(wxStyledTextCtrl_MarkerGet, 3024). +-define(wxStyledTextCtrl_MarkerNext, 3025). +-define(wxStyledTextCtrl_MarkerPrevious, 3026). +-define(wxStyledTextCtrl_MarkerDefineBitmap, 3027). +-define(wxStyledTextCtrl_MarkerAddSet, 3028). +-define(wxStyledTextCtrl_MarkerSetAlpha, 3029). +-define(wxStyledTextCtrl_SetMarginType, 3030). +-define(wxStyledTextCtrl_GetMarginType, 3031). +-define(wxStyledTextCtrl_SetMarginWidth, 3032). +-define(wxStyledTextCtrl_GetMarginWidth, 3033). +-define(wxStyledTextCtrl_SetMarginMask, 3034). +-define(wxStyledTextCtrl_GetMarginMask, 3035). +-define(wxStyledTextCtrl_SetMarginSensitive, 3036). +-define(wxStyledTextCtrl_GetMarginSensitive, 3037). +-define(wxStyledTextCtrl_StyleClearAll, 3038). +-define(wxStyledTextCtrl_StyleSetForeground, 3039). +-define(wxStyledTextCtrl_StyleSetBackground, 3040). +-define(wxStyledTextCtrl_StyleSetBold, 3041). +-define(wxStyledTextCtrl_StyleSetItalic, 3042). +-define(wxStyledTextCtrl_StyleSetSize, 3043). +-define(wxStyledTextCtrl_StyleSetFaceName, 3044). +-define(wxStyledTextCtrl_StyleSetEOLFilled, 3045). +-define(wxStyledTextCtrl_StyleResetDefault, 3046). +-define(wxStyledTextCtrl_StyleSetUnderline, 3047). +-define(wxStyledTextCtrl_StyleSetCase, 3048). +-define(wxStyledTextCtrl_StyleSetHotSpot, 3049). +-define(wxStyledTextCtrl_SetSelForeground, 3050). +-define(wxStyledTextCtrl_SetSelBackground, 3051). +-define(wxStyledTextCtrl_GetSelAlpha, 3052). +-define(wxStyledTextCtrl_SetSelAlpha, 3053). +-define(wxStyledTextCtrl_SetCaretForeground, 3054). +-define(wxStyledTextCtrl_CmdKeyAssign, 3055). +-define(wxStyledTextCtrl_CmdKeyClear, 3056). +-define(wxStyledTextCtrl_CmdKeyClearAll, 3057). +-define(wxStyledTextCtrl_SetStyleBytes, 3058). +-define(wxStyledTextCtrl_StyleSetVisible, 3059). +-define(wxStyledTextCtrl_GetCaretPeriod, 3060). +-define(wxStyledTextCtrl_SetCaretPeriod, 3061). +-define(wxStyledTextCtrl_SetWordChars, 3062). +-define(wxStyledTextCtrl_BeginUndoAction, 3063). +-define(wxStyledTextCtrl_EndUndoAction, 3064). +-define(wxStyledTextCtrl_IndicatorSetStyle, 3065). +-define(wxStyledTextCtrl_IndicatorGetStyle, 3066). +-define(wxStyledTextCtrl_IndicatorSetForeground, 3067). +-define(wxStyledTextCtrl_IndicatorGetForeground, 3068). +-define(wxStyledTextCtrl_SetWhitespaceForeground, 3069). +-define(wxStyledTextCtrl_SetWhitespaceBackground, 3070). +-define(wxStyledTextCtrl_GetStyleBits, 3071). +-define(wxStyledTextCtrl_SetLineState, 3072). +-define(wxStyledTextCtrl_GetLineState, 3073). +-define(wxStyledTextCtrl_GetMaxLineState, 3074). +-define(wxStyledTextCtrl_GetCaretLineVisible, 3075). +-define(wxStyledTextCtrl_SetCaretLineVisible, 3076). +-define(wxStyledTextCtrl_GetCaretLineBackground, 3077). +-define(wxStyledTextCtrl_SetCaretLineBackground, 3078). +-define(wxStyledTextCtrl_AutoCompShow, 3079). +-define(wxStyledTextCtrl_AutoCompCancel, 3080). +-define(wxStyledTextCtrl_AutoCompActive, 3081). +-define(wxStyledTextCtrl_AutoCompPosStart, 3082). +-define(wxStyledTextCtrl_AutoCompComplete, 3083). +-define(wxStyledTextCtrl_AutoCompStops, 3084). +-define(wxStyledTextCtrl_AutoCompSetSeparator, 3085). +-define(wxStyledTextCtrl_AutoCompGetSeparator, 3086). +-define(wxStyledTextCtrl_AutoCompSelect, 3087). +-define(wxStyledTextCtrl_AutoCompSetCancelAtStart, 3088). +-define(wxStyledTextCtrl_AutoCompGetCancelAtStart, 3089). +-define(wxStyledTextCtrl_AutoCompSetFillUps, 3090). +-define(wxStyledTextCtrl_AutoCompSetChooseSingle, 3091). +-define(wxStyledTextCtrl_AutoCompGetChooseSingle, 3092). +-define(wxStyledTextCtrl_AutoCompSetIgnoreCase, 3093). +-define(wxStyledTextCtrl_AutoCompGetIgnoreCase, 3094). +-define(wxStyledTextCtrl_UserListShow, 3095). +-define(wxStyledTextCtrl_AutoCompSetAutoHide, 3096). +-define(wxStyledTextCtrl_AutoCompGetAutoHide, 3097). +-define(wxStyledTextCtrl_AutoCompSetDropRestOfWord, 3098). +-define(wxStyledTextCtrl_AutoCompGetDropRestOfWord, 3099). +-define(wxStyledTextCtrl_RegisterImage, 3100). +-define(wxStyledTextCtrl_ClearRegisteredImages, 3101). +-define(wxStyledTextCtrl_AutoCompGetTypeSeparator, 3102). +-define(wxStyledTextCtrl_AutoCompSetTypeSeparator, 3103). +-define(wxStyledTextCtrl_AutoCompSetMaxWidth, 3104). +-define(wxStyledTextCtrl_AutoCompGetMaxWidth, 3105). +-define(wxStyledTextCtrl_AutoCompSetMaxHeight, 3106). +-define(wxStyledTextCtrl_AutoCompGetMaxHeight, 3107). +-define(wxStyledTextCtrl_SetIndent, 3108). +-define(wxStyledTextCtrl_GetIndent, 3109). +-define(wxStyledTextCtrl_SetUseTabs, 3110). +-define(wxStyledTextCtrl_GetUseTabs, 3111). +-define(wxStyledTextCtrl_SetLineIndentation, 3112). +-define(wxStyledTextCtrl_GetLineIndentation, 3113). +-define(wxStyledTextCtrl_GetLineIndentPosition, 3114). +-define(wxStyledTextCtrl_GetColumn, 3115). +-define(wxStyledTextCtrl_SetUseHorizontalScrollBar, 3116). +-define(wxStyledTextCtrl_GetUseHorizontalScrollBar, 3117). +-define(wxStyledTextCtrl_SetIndentationGuides, 3118). +-define(wxStyledTextCtrl_GetIndentationGuides, 3119). +-define(wxStyledTextCtrl_SetHighlightGuide, 3120). +-define(wxStyledTextCtrl_GetHighlightGuide, 3121). +-define(wxStyledTextCtrl_GetLineEndPosition, 3122). +-define(wxStyledTextCtrl_GetCodePage, 3123). +-define(wxStyledTextCtrl_GetCaretForeground, 3124). +-define(wxStyledTextCtrl_GetReadOnly, 3125). +-define(wxStyledTextCtrl_SetCurrentPos, 3126). +-define(wxStyledTextCtrl_SetSelectionStart, 3127). +-define(wxStyledTextCtrl_GetSelectionStart, 3128). +-define(wxStyledTextCtrl_SetSelectionEnd, 3129). +-define(wxStyledTextCtrl_GetSelectionEnd, 3130). +-define(wxStyledTextCtrl_SetPrintMagnification, 3131). +-define(wxStyledTextCtrl_GetPrintMagnification, 3132). +-define(wxStyledTextCtrl_SetPrintColourMode, 3133). +-define(wxStyledTextCtrl_GetPrintColourMode, 3134). +-define(wxStyledTextCtrl_FindText, 3135). +-define(wxStyledTextCtrl_FormatRange, 3136). +-define(wxStyledTextCtrl_GetFirstVisibleLine, 3137). +-define(wxStyledTextCtrl_GetLine, 3138). +-define(wxStyledTextCtrl_GetLineCount, 3139). +-define(wxStyledTextCtrl_SetMarginLeft, 3140). +-define(wxStyledTextCtrl_GetMarginLeft, 3141). +-define(wxStyledTextCtrl_SetMarginRight, 3142). +-define(wxStyledTextCtrl_GetMarginRight, 3143). +-define(wxStyledTextCtrl_GetModify, 3144). +-define(wxStyledTextCtrl_SetSelection, 3145). +-define(wxStyledTextCtrl_GetSelectedText, 3146). +-define(wxStyledTextCtrl_GetTextRange, 3147). +-define(wxStyledTextCtrl_HideSelection, 3148). +-define(wxStyledTextCtrl_LineFromPosition, 3149). +-define(wxStyledTextCtrl_PositionFromLine, 3150). +-define(wxStyledTextCtrl_LineScroll, 3151). +-define(wxStyledTextCtrl_EnsureCaretVisible, 3152). +-define(wxStyledTextCtrl_ReplaceSelection, 3153). +-define(wxStyledTextCtrl_SetReadOnly, 3154). +-define(wxStyledTextCtrl_CanPaste, 3155). +-define(wxStyledTextCtrl_CanUndo, 3156). +-define(wxStyledTextCtrl_EmptyUndoBuffer, 3157). +-define(wxStyledTextCtrl_Undo, 3158). +-define(wxStyledTextCtrl_Cut, 3159). +-define(wxStyledTextCtrl_Copy, 3160). +-define(wxStyledTextCtrl_Paste, 3161). +-define(wxStyledTextCtrl_Clear, 3162). +-define(wxStyledTextCtrl_SetText, 3163). +-define(wxStyledTextCtrl_GetText, 3164). +-define(wxStyledTextCtrl_GetTextLength, 3165). +-define(wxStyledTextCtrl_GetOvertype, 3166). +-define(wxStyledTextCtrl_SetCaretWidth, 3167). +-define(wxStyledTextCtrl_GetCaretWidth, 3168). +-define(wxStyledTextCtrl_SetTargetStart, 3169). +-define(wxStyledTextCtrl_GetTargetStart, 3170). +-define(wxStyledTextCtrl_SetTargetEnd, 3171). +-define(wxStyledTextCtrl_GetTargetEnd, 3172). +-define(wxStyledTextCtrl_ReplaceTarget, 3173). +-define(wxStyledTextCtrl_SearchInTarget, 3174). +-define(wxStyledTextCtrl_SetSearchFlags, 3175). +-define(wxStyledTextCtrl_GetSearchFlags, 3176). +-define(wxStyledTextCtrl_CallTipShow, 3177). +-define(wxStyledTextCtrl_CallTipCancel, 3178). +-define(wxStyledTextCtrl_CallTipActive, 3179). +-define(wxStyledTextCtrl_CallTipPosAtStart, 3180). +-define(wxStyledTextCtrl_CallTipSetHighlight, 3181). +-define(wxStyledTextCtrl_CallTipSetBackground, 3182). +-define(wxStyledTextCtrl_CallTipSetForeground, 3183). +-define(wxStyledTextCtrl_CallTipSetForegroundHighlight, 3184). +-define(wxStyledTextCtrl_CallTipUseStyle, 3185). +-define(wxStyledTextCtrl_VisibleFromDocLine, 3186). +-define(wxStyledTextCtrl_DocLineFromVisible, 3187). +-define(wxStyledTextCtrl_WrapCount, 3188). +-define(wxStyledTextCtrl_SetFoldLevel, 3189). +-define(wxStyledTextCtrl_GetFoldLevel, 3190). +-define(wxStyledTextCtrl_GetLastChild, 3191). +-define(wxStyledTextCtrl_GetFoldParent, 3192). +-define(wxStyledTextCtrl_ShowLines, 3193). +-define(wxStyledTextCtrl_HideLines, 3194). +-define(wxStyledTextCtrl_GetLineVisible, 3195). +-define(wxStyledTextCtrl_SetFoldExpanded, 3196). +-define(wxStyledTextCtrl_GetFoldExpanded, 3197). +-define(wxStyledTextCtrl_ToggleFold, 3198). +-define(wxStyledTextCtrl_EnsureVisible, 3199). +-define(wxStyledTextCtrl_SetFoldFlags, 3200). +-define(wxStyledTextCtrl_EnsureVisibleEnforcePolicy, 3201). +-define(wxStyledTextCtrl_SetTabIndents, 3202). +-define(wxStyledTextCtrl_GetTabIndents, 3203). +-define(wxStyledTextCtrl_SetBackSpaceUnIndents, 3204). +-define(wxStyledTextCtrl_GetBackSpaceUnIndents, 3205). +-define(wxStyledTextCtrl_SetMouseDwellTime, 3206). +-define(wxStyledTextCtrl_GetMouseDwellTime, 3207). +-define(wxStyledTextCtrl_WordStartPosition, 3208). +-define(wxStyledTextCtrl_WordEndPosition, 3209). +-define(wxStyledTextCtrl_SetWrapMode, 3210). +-define(wxStyledTextCtrl_GetWrapMode, 3211). +-define(wxStyledTextCtrl_SetWrapVisualFlags, 3212). +-define(wxStyledTextCtrl_GetWrapVisualFlags, 3213). +-define(wxStyledTextCtrl_SetWrapVisualFlagsLocation, 3214). +-define(wxStyledTextCtrl_GetWrapVisualFlagsLocation, 3215). +-define(wxStyledTextCtrl_SetWrapStartIndent, 3216). +-define(wxStyledTextCtrl_GetWrapStartIndent, 3217). +-define(wxStyledTextCtrl_SetLayoutCache, 3218). +-define(wxStyledTextCtrl_GetLayoutCache, 3219). +-define(wxStyledTextCtrl_SetScrollWidth, 3220). +-define(wxStyledTextCtrl_GetScrollWidth, 3221). +-define(wxStyledTextCtrl_TextWidth, 3222). +-define(wxStyledTextCtrl_GetEndAtLastLine, 3223). +-define(wxStyledTextCtrl_TextHeight, 3224). +-define(wxStyledTextCtrl_SetUseVerticalScrollBar, 3225). +-define(wxStyledTextCtrl_GetUseVerticalScrollBar, 3226). +-define(wxStyledTextCtrl_AppendText, 3227). +-define(wxStyledTextCtrl_GetTwoPhaseDraw, 3228). +-define(wxStyledTextCtrl_SetTwoPhaseDraw, 3229). +-define(wxStyledTextCtrl_TargetFromSelection, 3230). +-define(wxStyledTextCtrl_LinesJoin, 3231). +-define(wxStyledTextCtrl_LinesSplit, 3232). +-define(wxStyledTextCtrl_SetFoldMarginColour, 3233). +-define(wxStyledTextCtrl_SetFoldMarginHiColour, 3234). +-define(wxStyledTextCtrl_LineDown, 3235). +-define(wxStyledTextCtrl_LineDownExtend, 3236). +-define(wxStyledTextCtrl_LineUp, 3237). +-define(wxStyledTextCtrl_LineUpExtend, 3238). +-define(wxStyledTextCtrl_CharLeft, 3239). +-define(wxStyledTextCtrl_CharLeftExtend, 3240). +-define(wxStyledTextCtrl_CharRight, 3241). +-define(wxStyledTextCtrl_CharRightExtend, 3242). +-define(wxStyledTextCtrl_WordLeft, 3243). +-define(wxStyledTextCtrl_WordLeftExtend, 3244). +-define(wxStyledTextCtrl_WordRight, 3245). +-define(wxStyledTextCtrl_WordRightExtend, 3246). +-define(wxStyledTextCtrl_Home, 3247). +-define(wxStyledTextCtrl_HomeExtend, 3248). +-define(wxStyledTextCtrl_LineEnd, 3249). +-define(wxStyledTextCtrl_LineEndExtend, 3250). +-define(wxStyledTextCtrl_DocumentStart, 3251). +-define(wxStyledTextCtrl_DocumentStartExtend, 3252). +-define(wxStyledTextCtrl_DocumentEnd, 3253). +-define(wxStyledTextCtrl_DocumentEndExtend, 3254). +-define(wxStyledTextCtrl_PageUp, 3255). +-define(wxStyledTextCtrl_PageUpExtend, 3256). +-define(wxStyledTextCtrl_PageDown, 3257). +-define(wxStyledTextCtrl_PageDownExtend, 3258). +-define(wxStyledTextCtrl_EditToggleOvertype, 3259). +-define(wxStyledTextCtrl_Cancel, 3260). +-define(wxStyledTextCtrl_DeleteBack, 3261). +-define(wxStyledTextCtrl_Tab, 3262). +-define(wxStyledTextCtrl_BackTab, 3263). +-define(wxStyledTextCtrl_NewLine, 3264). +-define(wxStyledTextCtrl_FormFeed, 3265). +-define(wxStyledTextCtrl_VCHome, 3266). +-define(wxStyledTextCtrl_VCHomeExtend, 3267). +-define(wxStyledTextCtrl_ZoomIn, 3268). +-define(wxStyledTextCtrl_ZoomOut, 3269). +-define(wxStyledTextCtrl_DelWordLeft, 3270). +-define(wxStyledTextCtrl_DelWordRight, 3271). +-define(wxStyledTextCtrl_LineCut, 3272). +-define(wxStyledTextCtrl_LineDelete, 3273). +-define(wxStyledTextCtrl_LineTranspose, 3274). +-define(wxStyledTextCtrl_LineDuplicate, 3275). +-define(wxStyledTextCtrl_LowerCase, 3276). +-define(wxStyledTextCtrl_UpperCase, 3277). +-define(wxStyledTextCtrl_LineScrollDown, 3278). +-define(wxStyledTextCtrl_LineScrollUp, 3279). +-define(wxStyledTextCtrl_DeleteBackNotLine, 3280). +-define(wxStyledTextCtrl_HomeDisplay, 3281). +-define(wxStyledTextCtrl_HomeDisplayExtend, 3282). +-define(wxStyledTextCtrl_LineEndDisplay, 3283). +-define(wxStyledTextCtrl_LineEndDisplayExtend, 3284). +-define(wxStyledTextCtrl_HomeWrapExtend, 3285). +-define(wxStyledTextCtrl_LineEndWrap, 3286). +-define(wxStyledTextCtrl_LineEndWrapExtend, 3287). +-define(wxStyledTextCtrl_VCHomeWrap, 3288). +-define(wxStyledTextCtrl_VCHomeWrapExtend, 3289). +-define(wxStyledTextCtrl_LineCopy, 3290). +-define(wxStyledTextCtrl_MoveCaretInsideView, 3291). +-define(wxStyledTextCtrl_LineLength, 3292). +-define(wxStyledTextCtrl_BraceHighlight, 3293). +-define(wxStyledTextCtrl_BraceBadLight, 3294). +-define(wxStyledTextCtrl_BraceMatch, 3295). +-define(wxStyledTextCtrl_GetViewEOL, 3296). +-define(wxStyledTextCtrl_SetViewEOL, 3297). +-define(wxStyledTextCtrl_SetModEventMask, 3298). +-define(wxStyledTextCtrl_GetEdgeColumn, 3299). +-define(wxStyledTextCtrl_SetEdgeColumn, 3300). +-define(wxStyledTextCtrl_SetEdgeMode, 3301). +-define(wxStyledTextCtrl_GetEdgeMode, 3302). +-define(wxStyledTextCtrl_GetEdgeColour, 3303). +-define(wxStyledTextCtrl_SetEdgeColour, 3304). +-define(wxStyledTextCtrl_SearchAnchor, 3305). +-define(wxStyledTextCtrl_SearchNext, 3306). +-define(wxStyledTextCtrl_SearchPrev, 3307). +-define(wxStyledTextCtrl_LinesOnScreen, 3308). +-define(wxStyledTextCtrl_UsePopUp, 3309). +-define(wxStyledTextCtrl_SelectionIsRectangle, 3310). +-define(wxStyledTextCtrl_SetZoom, 3311). +-define(wxStyledTextCtrl_GetZoom, 3312). +-define(wxStyledTextCtrl_GetModEventMask, 3313). +-define(wxStyledTextCtrl_SetSTCFocus, 3314). +-define(wxStyledTextCtrl_GetSTCFocus, 3315). +-define(wxStyledTextCtrl_SetStatus, 3316). +-define(wxStyledTextCtrl_GetStatus, 3317). +-define(wxStyledTextCtrl_SetMouseDownCaptures, 3318). +-define(wxStyledTextCtrl_GetMouseDownCaptures, 3319). +-define(wxStyledTextCtrl_SetSTCCursor, 3320). +-define(wxStyledTextCtrl_GetSTCCursor, 3321). +-define(wxStyledTextCtrl_SetControlCharSymbol, 3322). +-define(wxStyledTextCtrl_GetControlCharSymbol, 3323). +-define(wxStyledTextCtrl_WordPartLeft, 3324). +-define(wxStyledTextCtrl_WordPartLeftExtend, 3325). +-define(wxStyledTextCtrl_WordPartRight, 3326). +-define(wxStyledTextCtrl_WordPartRightExtend, 3327). +-define(wxStyledTextCtrl_SetVisiblePolicy, 3328). +-define(wxStyledTextCtrl_DelLineLeft, 3329). +-define(wxStyledTextCtrl_DelLineRight, 3330). +-define(wxStyledTextCtrl_GetXOffset, 3331). +-define(wxStyledTextCtrl_ChooseCaretX, 3332). +-define(wxStyledTextCtrl_SetXCaretPolicy, 3333). +-define(wxStyledTextCtrl_SetYCaretPolicy, 3334). +-define(wxStyledTextCtrl_GetPrintWrapMode, 3335). +-define(wxStyledTextCtrl_SetHotspotActiveForeground, 3336). +-define(wxStyledTextCtrl_SetHotspotActiveBackground, 3337). +-define(wxStyledTextCtrl_SetHotspotActiveUnderline, 3338). +-define(wxStyledTextCtrl_SetHotspotSingleLine, 3339). +-define(wxStyledTextCtrl_ParaDownExtend, 3340). +-define(wxStyledTextCtrl_ParaUp, 3341). +-define(wxStyledTextCtrl_ParaUpExtend, 3342). +-define(wxStyledTextCtrl_PositionBefore, 3343). +-define(wxStyledTextCtrl_PositionAfter, 3344). +-define(wxStyledTextCtrl_CopyRange, 3345). +-define(wxStyledTextCtrl_CopyText, 3346). +-define(wxStyledTextCtrl_SetSelectionMode, 3347). +-define(wxStyledTextCtrl_GetSelectionMode, 3348). +-define(wxStyledTextCtrl_LineDownRectExtend, 3349). +-define(wxStyledTextCtrl_LineUpRectExtend, 3350). +-define(wxStyledTextCtrl_CharLeftRectExtend, 3351). +-define(wxStyledTextCtrl_CharRightRectExtend, 3352). +-define(wxStyledTextCtrl_HomeRectExtend, 3353). +-define(wxStyledTextCtrl_VCHomeRectExtend, 3354). +-define(wxStyledTextCtrl_LineEndRectExtend, 3355). +-define(wxStyledTextCtrl_PageUpRectExtend, 3356). +-define(wxStyledTextCtrl_PageDownRectExtend, 3357). +-define(wxStyledTextCtrl_StutteredPageUp, 3358). +-define(wxStyledTextCtrl_StutteredPageUpExtend, 3359). +-define(wxStyledTextCtrl_StutteredPageDown, 3360). +-define(wxStyledTextCtrl_StutteredPageDownExtend, 3361). +-define(wxStyledTextCtrl_WordLeftEnd, 3362). +-define(wxStyledTextCtrl_WordLeftEndExtend, 3363). +-define(wxStyledTextCtrl_WordRightEnd, 3364). +-define(wxStyledTextCtrl_WordRightEndExtend, 3365). +-define(wxStyledTextCtrl_SetWhitespaceChars, 3366). +-define(wxStyledTextCtrl_SetCharsDefault, 3367). +-define(wxStyledTextCtrl_AutoCompGetCurrent, 3368). +-define(wxStyledTextCtrl_Allocate, 3369). +-define(wxStyledTextCtrl_FindColumn, 3370). +-define(wxStyledTextCtrl_GetCaretSticky, 3371). +-define(wxStyledTextCtrl_SetCaretSticky, 3372). +-define(wxStyledTextCtrl_ToggleCaretSticky, 3373). +-define(wxStyledTextCtrl_SetPasteConvertEndings, 3374). +-define(wxStyledTextCtrl_GetPasteConvertEndings, 3375). +-define(wxStyledTextCtrl_SelectionDuplicate, 3376). +-define(wxStyledTextCtrl_SetCaretLineBackAlpha, 3377). +-define(wxStyledTextCtrl_GetCaretLineBackAlpha, 3378). +-define(wxStyledTextCtrl_StartRecord, 3379). +-define(wxStyledTextCtrl_StopRecord, 3380). +-define(wxStyledTextCtrl_SetLexer, 3381). +-define(wxStyledTextCtrl_GetLexer, 3382). +-define(wxStyledTextCtrl_Colourise, 3383). +-define(wxStyledTextCtrl_SetProperty, 3384). +-define(wxStyledTextCtrl_SetKeyWords, 3385). +-define(wxStyledTextCtrl_SetLexerLanguage, 3386). +-define(wxStyledTextCtrl_GetProperty, 3387). +-define(wxStyledTextCtrl_GetStyleBitsNeeded, 3388). +-define(wxStyledTextCtrl_GetCurrentLine, 3389). +-define(wxStyledTextCtrl_StyleSetSpec, 3390). +-define(wxStyledTextCtrl_StyleSetFont, 3391). +-define(wxStyledTextCtrl_StyleSetFontAttr, 3392). +-define(wxStyledTextCtrl_StyleSetCharacterSet, 3393). +-define(wxStyledTextCtrl_StyleSetFontEncoding, 3394). +-define(wxStyledTextCtrl_CmdKeyExecute, 3395). +-define(wxStyledTextCtrl_SetMargins, 3396). +-define(wxStyledTextCtrl_GetSelection, 3397). +-define(wxStyledTextCtrl_PointFromPosition, 3398). +-define(wxStyledTextCtrl_ScrollToLine, 3399). +-define(wxStyledTextCtrl_ScrollToColumn, 3400). +-define(wxStyledTextCtrl_SetVScrollBar, 3401). +-define(wxStyledTextCtrl_SetHScrollBar, 3402). +-define(wxStyledTextCtrl_GetLastKeydownProcessed, 3403). +-define(wxStyledTextCtrl_SetLastKeydownProcessed, 3404). +-define(wxStyledTextCtrl_SaveFile, 3405). +-define(wxStyledTextCtrl_LoadFile, 3406). +-define(wxStyledTextCtrl_DoDragOver, 3407). +-define(wxStyledTextCtrl_DoDropText, 3408). +-define(wxStyledTextCtrl_GetUseAntiAliasing, 3409). +-define(wxStyledTextCtrl_AddTextRaw, 3410). +-define(wxStyledTextCtrl_InsertTextRaw, 3411). +-define(wxStyledTextCtrl_GetCurLineRaw, 3412). +-define(wxStyledTextCtrl_GetLineRaw, 3413). +-define(wxStyledTextCtrl_GetSelectedTextRaw, 3414). +-define(wxStyledTextCtrl_GetTextRangeRaw, 3415). +-define(wxStyledTextCtrl_SetTextRaw, 3416). +-define(wxStyledTextCtrl_GetTextRaw, 3417). +-define(wxStyledTextCtrl_AppendTextRaw, 3418). +-define(wxArtProvider_GetBitmap, 3419). +-define(wxArtProvider_GetIcon, 3420). +-define(wxTreeEvent_GetKeyCode, 3421). +-define(wxTreeEvent_GetItem, 3422). +-define(wxTreeEvent_GetKeyEvent, 3423). +-define(wxTreeEvent_GetLabel, 3424). +-define(wxTreeEvent_GetOldItem, 3425). +-define(wxTreeEvent_GetPoint, 3426). +-define(wxTreeEvent_IsEditCancelled, 3427). +-define(wxTreeEvent_SetToolTip, 3428). +-define(wxNotebookEvent_GetOldSelection, 3429). +-define(wxNotebookEvent_GetSelection, 3430). +-define(wxNotebookEvent_SetOldSelection, 3431). +-define(wxNotebookEvent_SetSelection, 3432). +-define(wxFileDataObject_new, 3433). +-define(wxFileDataObject_AddFile, 3434). +-define(wxFileDataObject_GetFilenames, 3435). +-define(wxFileDataObject_destroy, 3436). +-define(wxTextDataObject_new, 3437). +-define(wxTextDataObject_GetTextLength, 3438). +-define(wxTextDataObject_GetText, 3439). +-define(wxTextDataObject_SetText, 3440). +-define(wxTextDataObject_destroy, 3441). +-define(wxBitmapDataObject_new_1_1, 3442). +-define(wxBitmapDataObject_new_1_0, 3443). +-define(wxBitmapDataObject_GetBitmap, 3444). +-define(wxBitmapDataObject_SetBitmap, 3445). +-define(wxBitmapDataObject_destroy, 3446). +-define(wxClipboard_new, 3448). +-define(wxClipboard_destruct, 3449). +-define(wxClipboard_AddData, 3450). +-define(wxClipboard_Clear, 3451). +-define(wxClipboard_Close, 3452). +-define(wxClipboard_Flush, 3453). +-define(wxClipboard_GetData, 3454). +-define(wxClipboard_IsOpened, 3455). +-define(wxClipboard_Open, 3456). +-define(wxClipboard_SetData, 3457). +-define(wxClipboard_UsePrimarySelection, 3459). +-define(wxClipboard_IsSupported, 3460). +-define(wxClipboard_Get, 3461). +-define(wxSpinEvent_GetPosition, 3462). +-define(wxSpinEvent_SetPosition, 3463). +-define(wxSplitterWindow_new_0, 3464). +-define(wxSplitterWindow_new_2, 3465). +-define(wxSplitterWindow_destruct, 3466). +-define(wxSplitterWindow_Create, 3467). +-define(wxSplitterWindow_GetMinimumPaneSize, 3468). +-define(wxSplitterWindow_GetSashGravity, 3469). +-define(wxSplitterWindow_GetSashPosition, 3470). +-define(wxSplitterWindow_GetSplitMode, 3471). +-define(wxSplitterWindow_GetWindow1, 3472). +-define(wxSplitterWindow_GetWindow2, 3473). +-define(wxSplitterWindow_Initialize, 3474). +-define(wxSplitterWindow_IsSplit, 3475). +-define(wxSplitterWindow_ReplaceWindow, 3476). +-define(wxSplitterWindow_SetSashGravity, 3477). +-define(wxSplitterWindow_SetSashPosition, 3478). +-define(wxSplitterWindow_SetSashSize, 3479). +-define(wxSplitterWindow_SetMinimumPaneSize, 3480). +-define(wxSplitterWindow_SetSplitMode, 3481). +-define(wxSplitterWindow_SplitHorizontally, 3482). +-define(wxSplitterWindow_SplitVertically, 3483). +-define(wxSplitterWindow_Unsplit, 3484). +-define(wxSplitterWindow_UpdateSize, 3485). +-define(wxSplitterEvent_GetSashPosition, 3486). +-define(wxSplitterEvent_GetX, 3487). +-define(wxSplitterEvent_GetY, 3488). +-define(wxSplitterEvent_GetWindowBeingRemoved, 3489). +-define(wxSplitterEvent_SetSashPosition, 3490). +-define(wxHtmlWindow_new_0, 3491). +-define(wxHtmlWindow_new_2, 3492). +-define(wxHtmlWindow_AppendToPage, 3493). +-define(wxHtmlWindow_GetOpenedAnchor, 3494). +-define(wxHtmlWindow_GetOpenedPage, 3495). +-define(wxHtmlWindow_GetOpenedPageTitle, 3496). +-define(wxHtmlWindow_GetRelatedFrame, 3497). +-define(wxHtmlWindow_HistoryBack, 3498). +-define(wxHtmlWindow_HistoryCanBack, 3499). +-define(wxHtmlWindow_HistoryCanForward, 3500). +-define(wxHtmlWindow_HistoryClear, 3501). +-define(wxHtmlWindow_HistoryForward, 3502). +-define(wxHtmlWindow_LoadFile, 3503). +-define(wxHtmlWindow_LoadPage, 3504). +-define(wxHtmlWindow_SelectAll, 3505). +-define(wxHtmlWindow_SelectionToText, 3506). +-define(wxHtmlWindow_SelectLine, 3507). +-define(wxHtmlWindow_SelectWord, 3508). +-define(wxHtmlWindow_SetBorders, 3509). +-define(wxHtmlWindow_SetFonts, 3510). +-define(wxHtmlWindow_SetPage, 3511). +-define(wxHtmlWindow_SetRelatedFrame, 3512). +-define(wxHtmlWindow_SetRelatedStatusBar, 3513). +-define(wxHtmlWindow_ToText, 3514). +-define(wxHtmlWindow_destroy, 3515). +-define(wxHtmlLinkEvent_GetLinkInfo, 3516). +-define(wxSystemSettings_GetColour, 3517). +-define(wxSystemSettings_GetFont, 3518). +-define(wxSystemSettings_GetMetric, 3519). +-define(wxSystemSettings_GetScreenType, 3520). +-define(wxSystemOptions_GetOption, 3521). +-define(wxSystemOptions_GetOptionInt, 3522). +-define(wxSystemOptions_HasOption, 3523). +-define(wxSystemOptions_IsFalse, 3524). +-define(wxSystemOptions_SetOption_2_1, 3525). +-define(wxSystemOptions_SetOption_2_0, 3526). +-define(wxAuiNotebookEvent_SetSelection, 3527). +-define(wxAuiNotebookEvent_GetSelection, 3528). +-define(wxAuiNotebookEvent_SetOldSelection, 3529). +-define(wxAuiNotebookEvent_GetOldSelection, 3530). +-define(wxAuiNotebookEvent_SetDragSource, 3531). +-define(wxAuiNotebookEvent_GetDragSource, 3532). +-define(wxAuiManagerEvent_SetManager, 3533). +-define(wxAuiManagerEvent_GetManager, 3534). +-define(wxAuiManagerEvent_SetPane, 3535). +-define(wxAuiManagerEvent_GetPane, 3536). +-define(wxAuiManagerEvent_SetButton, 3537). +-define(wxAuiManagerEvent_GetButton, 3538). +-define(wxAuiManagerEvent_SetDC, 3539). +-define(wxAuiManagerEvent_GetDC, 3540). +-define(wxAuiManagerEvent_Veto, 3541). +-define(wxAuiManagerEvent_GetVeto, 3542). +-define(wxAuiManagerEvent_SetCanVeto, 3543). +-define(wxAuiManagerEvent_CanVeto, 3544). +-define(wxLogNull_new, 3545). +-define(wxLogNull_destroy, 3546). +-define(wxTaskBarIcon_new, 3547). +-define(wxTaskBarIcon_destruct, 3548). +-define(wxTaskBarIcon_PopupMenu, 3549). +-define(wxTaskBarIcon_RemoveIcon, 3550). +-define(wxTaskBarIcon_SetIcon, 3551). +-define(wxLocale_new_0, 3552). +-define(wxLocale_new_2, 3554). +-define(wxLocale_destruct, 3555). +-define(wxLocale_Init, 3557). +-define(wxLocale_AddCatalog_1, 3558). +-define(wxLocale_AddCatalog_3, 3559). +-define(wxLocale_AddCatalogLookupPathPrefix, 3560). +-define(wxLocale_GetCanonicalName, 3561). +-define(wxLocale_GetLanguage, 3562). +-define(wxLocale_GetLanguageName, 3563). +-define(wxLocale_GetLocale, 3564). +-define(wxLocale_GetName, 3565). +-define(wxLocale_GetString_2, 3566). +-define(wxLocale_GetString_4, 3567). +-define(wxLocale_GetHeaderValue, 3568). +-define(wxLocale_GetSysName, 3569). +-define(wxLocale_GetSystemEncoding, 3570). +-define(wxLocale_GetSystemEncodingName, 3571). +-define(wxLocale_GetSystemLanguage, 3572). +-define(wxLocale_IsLoaded, 3573). +-define(wxLocale_IsOk, 3574). +-define(wxActivateEvent_GetActive, 3575). +-define(wxPopupWindow_new_2, 3577). +-define(wxPopupWindow_new_0, 3578). +-define(wxPopupWindow_destruct, 3580). +-define(wxPopupWindow_Create, 3581). +-define(wxPopupWindow_Position, 3582). +-define(wxPopupTransientWindow_new_0, 3583). +-define(wxPopupTransientWindow_new_2, 3584). +-define(wxPopupTransientWindow_destruct, 3585). +-define(wxPopupTransientWindow_Popup, 3586). +-define(wxPopupTransientWindow_Dismiss, 3587). +-define(wxOverlay_new, 3588). +-define(wxOverlay_destruct, 3589). +-define(wxOverlay_Reset, 3590). +-define(wxDCOverlay_new_6, 3591). +-define(wxDCOverlay_new_2, 3592). +-define(wxDCOverlay_destruct, 3593). +-define(wxDCOverlay_Clear, 3594). diff --git a/lib/wx/test/wx_class_SUITE.erl b/lib/wx/test/wx_class_SUITE.erl index f88c10f987..6944a78360 100644 --- a/lib/wx/test/wx_class_SUITE.erl +++ b/lib/wx/test/wx_class_SUITE.erl @@ -643,8 +643,11 @@ modal(Config) -> wx:set_env(Env), modal_dialog(Frame, 1, Tester) end), - receive {dialog, M1, 1} -> timer:sleep(200), ets:insert(test_state, {M1, ready}) end, - receive {dialog, M2, 2} -> timer:sleep(200), ets:insert(test_state, {M2, ready}) end, + %% need to sleep so we know that the window is stuck in + %% the ShowModal event loop and not in an earlier event loop + %% wx2.8 invokes the event loop from more calls than wx-3 + receive {dialog, M1, 1} -> timer:sleep(1200), ets:insert(test_state, {M1, ready}) end, + receive {dialog, M2, 2} -> timer:sleep(1200), ets:insert(test_state, {M2, ready}) end, receive done -> ok end, receive {dialog_done, M2, 2} -> M2 end, diff --git a/otp_versions.table b/otp_versions.table index 79e1c14c49..f68986d831 100644 --- a/otp_versions.table +++ b/otp_versions.table @@ -1,3 +1,4 @@ +OTP-18.3.3 : common_test-1.12.1 inets-6.2.3 ssl-7.3.2 # asn1-4.0.2 compiler-6.0.3 cosEvent-2.2 cosEventDomain-1.2 cosFileTransfer-1.2 cosNotification-1.2.1 cosProperty-1.2 cosTime-1.2.1 cosTransactions-1.3.1 crypto-3.6.3 debugger-4.1.2 dialyzer-2.9 diameter-1.11.2 edoc-0.7.18 eldap-1.2.1 erl_docgen-0.4.2 erl_interface-3.8.2 erts-7.3.1 et-1.5.1 eunit-2.2.13 gs-1.6 hipe-3.15 ic-4.4 jinterface-1.6.1 kernel-4.2 megaco-3.18 mnesia-4.13.4 observer-2.1.2 odbc-2.11.1 orber-3.8.1 os_mon-2.4 ose-1.1 otp_mibs-1.1 parsetools-2.1.1 percept-0.8.11 public_key-1.1.1 reltool-0.7 runtime_tools-1.9.3 sasl-2.7 snmp-5.2.2 ssh-4.2.2 stdlib-2.8 syntax_tools-1.7 test_server-3.10 tools-2.8.3 typer-0.9.10 webtool-0.9.1 wx-1.6.1 xmerl-1.3.10 : OTP-18.3.2 : inets-6.2.2 ssl-7.3.1 # asn1-4.0.2 common_test-1.12 compiler-6.0.3 cosEvent-2.2 cosEventDomain-1.2 cosFileTransfer-1.2 cosNotification-1.2.1 cosProperty-1.2 cosTime-1.2.1 cosTransactions-1.3.1 crypto-3.6.3 debugger-4.1.2 dialyzer-2.9 diameter-1.11.2 edoc-0.7.18 eldap-1.2.1 erl_docgen-0.4.2 erl_interface-3.8.2 erts-7.3.1 et-1.5.1 eunit-2.2.13 gs-1.6 hipe-3.15 ic-4.4 jinterface-1.6.1 kernel-4.2 megaco-3.18 mnesia-4.13.4 observer-2.1.2 odbc-2.11.1 orber-3.8.1 os_mon-2.4 ose-1.1 otp_mibs-1.1 parsetools-2.1.1 percept-0.8.11 public_key-1.1.1 reltool-0.7 runtime_tools-1.9.3 sasl-2.7 snmp-5.2.2 ssh-4.2.2 stdlib-2.8 syntax_tools-1.7 test_server-3.10 tools-2.8.3 typer-0.9.10 webtool-0.9.1 wx-1.6.1 xmerl-1.3.10 : OTP-18.3.1 : erts-7.3.1 inets-6.2.1 mnesia-4.13.4 # asn1-4.0.2 common_test-1.12 compiler-6.0.3 cosEvent-2.2 cosEventDomain-1.2 cosFileTransfer-1.2 cosNotification-1.2.1 cosProperty-1.2 cosTime-1.2.1 cosTransactions-1.3.1 crypto-3.6.3 debugger-4.1.2 dialyzer-2.9 diameter-1.11.2 edoc-0.7.18 eldap-1.2.1 erl_docgen-0.4.2 erl_interface-3.8.2 et-1.5.1 eunit-2.2.13 gs-1.6 hipe-3.15 ic-4.4 jinterface-1.6.1 kernel-4.2 megaco-3.18 observer-2.1.2 odbc-2.11.1 orber-3.8.1 os_mon-2.4 ose-1.1 otp_mibs-1.1 parsetools-2.1.1 percept-0.8.11 public_key-1.1.1 reltool-0.7 runtime_tools-1.9.3 sasl-2.7 snmp-5.2.2 ssh-4.2.2 ssl-7.3 stdlib-2.8 syntax_tools-1.7 test_server-3.10 tools-2.8.3 typer-0.9.10 webtool-0.9.1 wx-1.6.1 xmerl-1.3.10 : OTP-18.3 : asn1-4.0.2 common_test-1.12 compiler-6.0.3 cosNotification-1.2.1 cosTime-1.2.1 cosTransactions-1.3.1 crypto-3.6.3 debugger-4.1.2 dialyzer-2.9 diameter-1.11.2 edoc-0.7.18 eldap-1.2.1 erl_docgen-0.4.2 erl_interface-3.8.2 erts-7.3 eunit-2.2.13 hipe-3.15 inets-6.2 kernel-4.2 mnesia-4.13.3 observer-2.1.2 orber-3.8.1 public_key-1.1.1 runtime_tools-1.9.3 sasl-2.7 snmp-5.2.2 ssh-4.2.2 ssl-7.3 stdlib-2.8 test_server-3.10 tools-2.8.3 webtool-0.9.1 wx-1.6.1 xmerl-1.3.10 # cosEvent-2.2 cosEventDomain-1.2 cosFileTransfer-1.2 cosProperty-1.2 et-1.5.1 gs-1.6 ic-4.4 jinterface-1.6.1 megaco-3.18 odbc-2.11.1 os_mon-2.4 ose-1.1 otp_mibs-1.1 parsetools-2.1.1 percept-0.8.11 reltool-0.7 syntax_tools-1.7 typer-0.9.10 : diff --git a/system/doc/design_principles/code_lock.dia b/system/doc/design_principles/code_lock.dia Binary files differindex bed6d8ee86..8e6ff8a898 100644 --- a/system/doc/design_principles/code_lock.dia +++ b/system/doc/design_principles/code_lock.dia diff --git a/system/doc/design_principles/code_lock.png b/system/doc/design_principles/code_lock.png Binary files differindex e40f0320aa..745fd91920 100644 --- a/system/doc/design_principles/code_lock.png +++ b/system/doc/design_principles/code_lock.png diff --git a/system/doc/design_principles/code_lock_2.dia b/system/doc/design_principles/code_lock_2.dia Binary files differindex 4e82a9e1d6..142909a2f5 100644 --- a/system/doc/design_principles/code_lock_2.dia +++ b/system/doc/design_principles/code_lock_2.dia diff --git a/system/doc/design_principles/code_lock_2.png b/system/doc/design_principles/code_lock_2.png Binary files differindex 138fbdef6c..ecf7b0d799 100644 --- a/system/doc/design_principles/code_lock_2.png +++ b/system/doc/design_principles/code_lock_2.png diff --git a/system/doc/design_principles/fsm.xml b/system/doc/design_principles/fsm.xml index 3468f93ae0..4f2b75e6e8 100644 --- a/system/doc/design_principles/fsm.xml +++ b/system/doc/design_principles/fsm.xml @@ -33,7 +33,7 @@ <note> <p> There is a new behaviour - <seealso marker="gen_statem"><c>gen_statem</c></seealso> + <seealso marker="statem"><c>gen_statem</c></seealso> that is intended to replace <c>gen_fsm</c> for new code. It has the same features and add some really useful. This module will not be removed for the foreseeable future diff --git a/system/doc/design_principles/statem.xml b/system/doc/design_principles/statem.xml index ca0fce55e2..585b1a35f5 100644 --- a/system/doc/design_principles/statem.xml +++ b/system/doc/design_principles/statem.xml @@ -5,7 +5,7 @@ <header> <copyright> <year>2016</year> - <holder>Ericsson AB. All Rights Reserved.</holder> + <holder>Ericsson AB. All Rights Reserved.</holder> </copyright> <legalnotice> Licensed under the Apache License, Version 2.0 (the "License"); @@ -22,7 +22,7 @@ </legalnotice> - <title>gen_statem Behaviour</title> + <title>gen_statem Behavior</title> <prepared></prepared> <docno></docno> <date></date> @@ -33,63 +33,61 @@ <p> This section is to be read with the <seealso marker="stdlib:gen_statem"><c>gen_statem(3)</c></seealso> - manual page in STDLIB, where all interface functions and callback + manual page in <c>STDLIB</c>, where all interface functions and callback functions are described in detail. </p> - <p> - This is a new behaviour in OTP-19.0. - It has been thoroughly reviewed, is stable enough - to be used by at least two heavy OTP applications, and is here to stay. - But depending on user feedback, we do not expect - but might find it necessary to make minor - not backwards compatible changes into OTP-20.0, - so its state can be designated as "not quite experimental"... - </p> + <note> + <p> + This is a new behavior in Erlang/OTP 19.0. + It has been thoroughly reviewed, is stable enough + to be used by at least two heavy OTP applications, and is here to stay. + Depending on user feedback, we do not expect + but can find it necessary to make minor + not backward compatible changes into Erlang/OTP 20.0. + </p> + </note> <!-- =================================================================== --> <section> - <title>Event Driven State Machines</title> + <title>Event-Driven State Machines</title> <p> Established Automata theory does not deal much with how a state transition is triggered, - but in general assumes that the output is a function + but assumes that the output is a function of the input (and the state) and that they are some kind of values. </p> <p> - For an Event Driven State Machine the input is an event + For an Event-Driven State Machine, the input is an event that triggers a state transition and the output is actions executed during the state transition. It can analogously to the mathematical model of a - Finite State Machine be described as - a set of relations of the form: + Finite-State Machine be described as + a set of relations of the following form: </p> <pre> State(S) x Event(E) -> Actions(A), State(S')</pre> - <p>These relations are interpreted as meaning:</p> - <p> - If we are in state <c>S</c> and event <c>E</c> occurs, we + <p>These relations are interpreted as follows: + if we are in state <c>S</c> and event <c>E</c> occurs, we are to perform actions <c>A</c> and make a transition to - state <c>S'</c>. - </p> - <p> - Note that <c>S'</c> may be equal to <c>S</c>. + state <c>S'</c>. Notice that <c>S'</c> can be equal to <c>S</c>. </p> <p> - Since <c>A</c> and <c>S'</c> depend only on - <c>S</c> and <c>E</c> the kind of state machine described - here is a Mealy Machine. - (See for example the corresponding Wikipedia article) + As <c>A</c> and <c>S'</c> depend only on + <c>S</c> and <c>E</c>, the kind of state machine described + here is a Mealy Machine + (see, for example, the corresponding Wikipedia article). </p> <p> - Like most <c>gen_</c> behaviours, <c>gen_statem</c> keeps - a server <c>Data</c> besides the state. This and the fact that + Like most <c>gen_</c> behaviors, <c>gen_statem</c> keeps + a server <c>Data</c> besides the state. Because of this, and as there is no restriction on the number of states - (assuming enough virtual machine memory) - or on the number of distinct input events actually makes - a state machine implemented with this behaviour Turing complete. - But it feels mostly like an Event Driven Mealy Machine. + (assuming that there is enough virtual machine memory) + or on the number of distinct input events, + a state machine implemented with this behavior + is in fact Turing complete. + But it feels mostly like an Event-Driven Mealy Machine. </p> </section> @@ -99,38 +97,39 @@ State(S) x Event(E) -> Actions(A), State(S')</pre> <marker id="callback_modes" /> <title>Callback Modes</title> <p> - The <c>gen_statem</c> behaviour supports two different callback modes. - In the mode - <seealso marker="stdlib:gen_statem#type-callback_mode"> - <c>state_functions</c>, - </seealso> - the state transition rules are written as a number of Erlang - functions, which conform to the following convention: + The <c>gen_statem</c> behavior supports two callback modes: </p> - <pre> + <list type="bulleted"> + <item> + <p> + In mode + <seealso marker="stdlib:gen_statem#type-callback_mode"><c>state_functions</c></seealso>, + the state transition rules are written as some Erlang + functions, which conform to the following convention: + </p> + <pre> StateName(EventType, EventContent, Data) -> .. code for actions here ... {next_state, NewStateName, NewData}.</pre> - <p> - In the mode - <seealso marker="stdlib:gen_statem#type-callback_mode"> - <c>handle_event_function</c> - </seealso> - there is only one - Erlang function that implements all state transition rules: - </p> - <pre> + </item> + <item> + <p> + In mode + <seealso marker="stdlib:gen_statem#type-callback_mode"><c>handle_event_function</c></seealso>, + only one Erlang function provides all state transition rules: + </p> + <pre> handle_event(EventType, EventContent, State, Data) -> .. code for actions here ... - {next_state, State', Data'}</pre> - <p> - Both these modes allow other return tuples - that you can find in the - <seealso marker="stdlib:gen_statem#Module:StateName/3"> - reference manual. - </seealso> - These other return tuples can for example stop the machine, - execute state transition actions on the machine engine itself + {next_state, NewState, NewData}</pre> + </item> + </list> + <p> + Both these modes allow other return tuples; see + <seealso marker="stdlib:gen_statem#Module:StateName/3"><c>Module:StateName/3</c></seealso> + in the <c>gen_statem</c> manual page. + These other return tuples can, for example, stop the machine, + execute state transition actions on the machine engine itself, and send replies. </p> @@ -139,54 +138,54 @@ handle_event(EventType, EventContent, State, Data) -> <p> The two <seealso marker="#callback_modes">callback modes</seealso> - gives different possibilities + give different possibilities and restrictions, but one goal remains: you want to handle all possible combinations of events and states. </p> <p> - You can for example do this by focusing on one state at the time - and for every state ensure that all events are handled, - or the other way around focus on one event at the time - and ensure that it is handled in every state, - or mix these strategies. + This can be done, for example, by focusing on one state at the time + and for every state ensure that all events are handled. + Alternatively, you can focus on one event at the time + and ensure that it is handled in every state. + You can also use a mix of these strategies. </p> <p> - With <c>state_functions</c> you are restricted to use - atom only states, and the <c>gen_statem</c> engine dispatches - on state name for you. This encourages the callback module + With <c>state_functions</c>, you are restricted to use + atom-only states, and the <c>gen_statem</c> engine dispatches + on state name for you. This encourages the callback module to gather the implementation of all event actions particular - to one state in the same place in the code + to one state in the same place in the code, hence to focus on one state at the time. </p> <p> - This mode fits well when you have a regular state diagram - like the ones in this chapter that describes all events and actions + This mode fits well when you have a regular state diagram, + like the ones in this chapter, which describes all events and actions belonging to a state visually around that state, and each state has its unique name. </p> <p> - With <c>handle_event_function</c> you are free to mix strategies - as you like because all events and states - are handled in the the same callback function. + With <c>handle_event_function</c>, you are free to mix strategies, + as all events and states are handled in the same callback function. </p> <p> This mode works equally well when you want to focus on - one event at the time or when you want to focus on - one state at the time, but the <c>handle_event/4</c> function + one event at the time or on + one state at the time, but function + <seealso marker="stdlib:gen_statem#Module:handle_event/4"><c>Module:handle_event/4</c></seealso> quickly grows too large to handle without introducing dispatching. </p> <p> - The mode enables the use of non-atom states for example - complex states or even hiearchical states. + The mode enables the use of non-atom states, for example, + complex states or even hierarchical states. If, for example, a state diagram is largely alike - for the client and for the server side of a protocol; - then you can have a state <c>{StateName,server}</c> or - <c>{StateName,client}</c> and since you do the dispatching - yourself you make <c>StateName</c> decide where in the code + for the client side and the server side of a protocol, + you can have a state <c>{StateName,server}</c> or + <c>{StateName,client}</c>. Also, as you do the dispatching + yourself, you make <c>StateName</c> decide where in the code to handle most events in the state. - The second element of the tuple is then used to select - whether to handle special client side or server side events. + The second element of the tuple is then used to select + whether to handle special client-side or server-side events. </p> </section> </section> @@ -196,31 +195,28 @@ handle_event(EventType, EventContent, State, Data) -> <section> <title>Example</title> <p> - This is an example starting off as equivalent to the the example in the - <seealso marker="fsm"><c>gen_fsm</c> behaviour</seealso> - description. In later chapters additions and tweaks are made + This example starts off as equivalent to the example in section + <seealso marker="fsm"><c>gen_fsm</c> Behavior</seealso>. + In later sections, additions and tweaks are made using features in <c>gen_statem</c> that <c>gen_fsm</c> does not have. - At the end of this section you can find the example again + The end of this chapter provides the example again with all the added features. </p> <p> - A door with a code lock can be viewed as a state machine. - Initially, the door is locked. Anytime someone presses a button, - this generates an event. + A door with a code lock can be seen as a state machine. + Initially, the door is locked. When someone presses a button, + an event is generated. Depending on what buttons have been pressed before, the sequence so far can be correct, incomplete, or wrong. - </p> - <p> - If it is correct, the door is unlocked for 10 seconds (10000 ms). - If it is incomplete, we wait for another button to be pressed. If - it is is wrong, we start all over, - waiting for a new button sequence. + If correct, the door is unlocked for 10 seconds (10,000 milliseconds). + If incomplete, we wait for another button to be pressed. If + wrong, we start all over, waiting for a new button sequence. </p> <image file="../design_principles/code_lock.png"> - <icaption>Code lock state diagram</icaption> + <icaption>Code Lock State Diagram</icaption> </image> <p> - We can implement such a code lock state machine using + This code lock state machine can be implemented using <c>gen_statem</c> with the following callback module: </p> <marker id="ex"></marker> @@ -241,7 +237,6 @@ start_link(Code) -> button(Digit) -> gen_statem:cast(?NAME, {button,Digit}). - init(Code) -> do_lock(), Data = #{code => Code, remaining => Code}, @@ -286,7 +281,7 @@ code_change(_Vsn, State, Data, _Extra) -> <section> <title>Starting gen_statem</title> <p> - In the example in the previous section, the <c>gen_statem</c> is + In the example in the previous section, <c>gen_statem</c> is started by calling <c>code_lock:start_link(Code)</c>: </p> <code type="erl"><![CDATA[ @@ -294,80 +289,71 @@ start_link(Code) -> gen_statem:start_link({local,?NAME}, ?MODULE, Code, []). ]]></code> <p> - <c>start_link</c> calls the function - <seealso marker="stdlib:gen_statem#start_link/4"> - <c>gen_statem:start_link/4</c> - </seealso> - which spawns and links to a new process; a <c>gen_statem</c>. + <c>start_link</c> calls function + <seealso marker="stdlib:gen_statem#start_link/4"><c>gen_statem:start_link/4</c></seealso>, + which spawns and links to a new process, a <c>gen_statem</c>. </p> <list type="bulleted"> <item> <p> - The first argument, <c>{local,?NAME}</c>, specifies - the name. In this case, the <c>gen_statem</c> is locally - registered as <c>code_lock</c> through the macro <c>?NAME</c>. - </p> + The first argument, <c>{local,?NAME}</c>, specifies + the name. In this case, the <c>gen_statem</c> is locally + registered as <c>code_lock</c> through the macro <c>?NAME</c>. + </p> <p> - If the name is omitted, the <c>gen_statem</c> is not registered. - Instead its pid must be used. The name can also be given - as <c>{global,Name}</c>, in which case the <c>gen_statem</c> is - registered using - <seealso marker="kernel:global#register_name/2"> - <c>global:register_name/2</c>. - </seealso> - </p> + If the name is omitted, the <c>gen_statem</c> is not registered. + Instead its pid must be used. The name can also be specified + as <c>{global,Name}</c>, then the <c>gen_statem</c> is + registered using + <seealso marker="kernel:global#register_name/2"><c>global:register_name/2</c></seealso> + in <c>Kernel</c>. + </p> </item> <item> <p> - The second argument, <c>?MODULE</c>, is the name of - the callback module, that is; the module where the callback + The second argument, <c>?MODULE</c>, is the name of + the callback module, that is, the module where the callback functions are located, which is this module. - </p> + </p> <p> - The interface functions (<c>start_link/1</c> and <c>button/1</c>) - are located in the same module as the callback functions - (<c>init/1</c>, <c>locked/3</c>, and <c>open/3</c>). - It is normally good programming practice to have the client - side and the server side code contained in one module. - </p> + The interface functions (<c>start_link/1</c> and <c>button/1</c>) + are located in the same module as the callback functions + (<c>init/1</c>, <c>locked/3</c>, and <c>open/3</c>). + It is normally good programming practice to have the client-side + code and the server-side code contained in one module. + </p> </item> <item> <p> - The third argument, <c>Code</c>, is a list of digits that - is the correct unlock code which is passsed - to the callback function <c>init/1</c>. + The third argument, <c>Code</c>, is a list of digits, which + is the correct unlock code that is passed + to callback function <c>init/1</c>. </p> </item> <item> <p> - The fourth argument, <c>[]</c>, is a list of options. See the - <seealso marker="stdlib:gen_statem#start_link/3"> - <c>gen_statem:start_link/3</c> - </seealso> - manual page for available options. + The fourth argument, <c>[]</c>, is a list of options. + For the available options, see + <seealso marker="stdlib:gen_statem#start_link/3"><c>gen_statem:start_link/3</c></seealso>. </p> </item> </list> <p> If name registration succeeds, the new <c>gen_statem</c> process - calls the callback function <c>code_lock:init(Code)</c>. + calls callback function <c>code_lock:init(Code)</c>. This function is expected to return <c>{CallbackMode,State,Data}</c>, where - <seealso marker="#callback_modes"> - <c>CallbackMode</c> - </seealso> + <seealso marker="#callback_modes"><c>CallbackMode</c></seealso> selects callback module state function mode, in this case - <seealso marker="stdlib:gen_statem#type-callback_mode"> - <c>state_functions</c> - </seealso> - through the macro <c>?CALLBACK_MODE</c> that is; each state + <seealso marker="stdlib:gen_statem#type-callback_mode"><c>state_functions</c></seealso> + through macro <c>?CALLBACK_MODE</c>. That is, each state has got its own handler function. <c>State</c> is the initial state of the <c>gen_statem</c>, - in this case <c>locked</c>; assuming the door is locked to begin with. - <c>Data</c> is the internal server data of the <c>gen_statem</c>. + in this case <c>locked</c>; assuming that the door is locked to begin + with. <c>Data</c> is the internal server data of the <c>gen_statem</c>. Here the server data is a <seealso marker="stdlib:maps">map</seealso> - with the key <c>code</c> that stores - the correct button sequence and the key <c>remaining</c> + with key <c>code</c> that stores + the correct button sequence, and key <c>remaining</c> that stores the remaining correct button sequence (the same as the <c>code</c> to begin with). </p> @@ -377,24 +363,19 @@ init(Code) -> Data = #{code => Code, remaining => Code}, {?CALLBACK_MODE,locked,Data}. ]]></code> - <p> - <seealso marker="stdlib:gen_statem#start_link/3"> - <c>gen_statem:start_link</c> - </seealso> - is synchronous. It does not return until the <c>gen_statem</c> - has been initialized and is ready to receive events. + <p>Function + <seealso marker="stdlib:gen_statem#start_link/3"><c>gen_statem:start_link</c></seealso> + is synchronous. It does not return until the <c>gen_statem</c> + is initialized and is ready to receive events. </p> <p> - <seealso marker="stdlib:gen_statem#start_link/3"> - <c>gen_statem:start_link</c> - </seealso> + Function + <seealso marker="stdlib:gen_statem#start_link/3"><c>gen_statem:start_link</c></seealso> must be used if the <c>gen_statem</c> - is part of a supervision tree, that is; started by a supervisor. - There is another function; - <seealso marker="stdlib:gen_statem#start/3"> - <c>gen_statem:start</c> - </seealso> - to start a standalone <c>gen_statem</c>, that is; + is part of a supervision tree, that is, started by a supervisor. + Another function, + <seealso marker="stdlib:gen_statem#start/3"><c>gen_statem:start</c></seealso> + can be used to start a standalone <c>gen_statem</c>, that is, a <c>gen_statem</c> that is not part of a supervision tree. </p> </section> @@ -402,12 +383,10 @@ init(Code) -> <!-- =================================================================== --> <section> - <title>Events and Handling them</title> + <title>Handling Events</title> <p>The function notifying the code lock about a button event is implemented using - <seealso marker="stdlib:gen_statem#cast/2"> - <c>gen_statem:cast/2</c>: - </seealso> + <seealso marker="stdlib:gen_statem#cast/2"><c>gen_statem:cast/2</c></seealso>: </p> <code type="erl"><![CDATA[ button(Digit) -> @@ -415,9 +394,9 @@ button(Digit) -> ]]></code> <p> The first argument is the name of the <c>gen_statem</c> and must - agree with the name used to start it so therefore we use the + agree with the name used to start it. So, we use the same macro <c>?NAME</c> as when starting. - <c>{button,Digit}</c> is the actual event content. + <c>{button,Digit}</c> is the event content. </p> <p> The event is made into a message and sent to the <c>gen_statem</c>. @@ -452,19 +431,19 @@ open(cast, {button,_}, Data) -> ]]></code> <p> If the door is locked and a button is pressed, the pressed - button is compared with the next correct button and, - depending on the result, the door is either unlocked + button is compared with the next correct button. + Depending on the result, the door is either unlocked and the <c>gen_statem</c> goes to state <c>open</c>, or the door remains in state <c>locked</c>. </p> <p> - If the pressed button is incorrect the server data + If the pressed button is incorrect, the server data restarts from the start of the code sequence. </p> <p> - In state <c>open</c> any button locks the door since - any event cancels the event timer so we will not get - a timeout event after a button event. + In state <c>open</c>, any button locks the door, as + any event cancels the event timer, so no + time-out event occurs after a button event. </p> </section> @@ -478,11 +457,11 @@ open(cast, {button,_}, Data) -> {next_state,open,Data#{remaining := Code},10000}; ]]></code> <p> - 10000 is a time-out value in milliseconds. - After this time, that is; 10 seconds, a time-out occurs. + 10,000 is a time-out value in milliseconds. + After this time (10 seconds), a time-out occurs. Then, <c>StateName(timeout, 10000, Data)</c> is called. The time-out occurs when the door has been in state <c>open</c> - for 10 seconds. After that the door is locked again: + for 10 seconds. After that the door is locked again: </p> <code type="erl"><![CDATA[ open(timeout, _, Data) -> @@ -496,16 +475,16 @@ open(timeout, _, Data) -> <section> <title>All State Events</title> <p> - Sometimes an event can arrive in any state of the <c>gen_statem</c>. + Sometimes events can arrive in any state of the <c>gen_statem</c>. It is convenient to handle these in a common state handler function that all state functions call for events not specific to the state. </p> <p> - Let's introduce a <c>code_length/0</c> function that returns + Consider a <c>code_length/0</c> function that returns the length of the correct code - (that should not be sensitive to reveal...). - We'll dispatch all events that are not state specific - to the common function <c>handle_event/3</c>. + (that should not be sensitive to reveal). + We dispatch all events that are not state-specific + to the common function <c>handle_event/3</c>: </p> <code type="erl"><![CDATA[ ... @@ -530,9 +509,7 @@ handle_event({call,From}, code_length, #{code := Code} = Data) -> ]]></code> <p> This example uses - <seealso marker="stdlib:gen_statem#call/2"> - <c>gen_statem:call/2</c> - </seealso> + <seealso marker="stdlib:gen_statem#call/2"><c>gen_statem:call/2</c></seealso>, which waits for a reply from the server. The reply is sent with a <c>{reply,From,Reply}</c> tuple in an action list in the <c>{keep_state,...}</c> tuple @@ -545,14 +522,15 @@ handle_event({call,From}, code_length, #{code := Code} = Data) -> <section> <title>One Event Handler</title> <p> - If you use the mode <c>handle_event_function</c> - all events are handled in <c>handle_event/4</c> and we - may (but do not have to) use an event-centered approach + If mode <c>handle_event_function</c> is used, + all events are handled in + <seealso marker="stdlib:gen_statem#Module:handle_event/4"><c>Module:handle_event/4</c></seealso> + and we can (but do not have to) use an event-centered approach where we dispatch on event first and then state: </p> <code type="erl"><![CDATA[ ... --define(CALLBACK_MODE, state_functions). +-define(CALLBACK_MODE, handle_event_function). ... -export([handle_event/4]). @@ -596,19 +574,14 @@ handle_event(timeout, _, open, Data) -> The <c>gen_statem</c> is automatically terminated by its supervisor. Exactly how this is done is defined by a <seealso marker="sup_princ#shutdown">shutdown strategy</seealso> - set in the supervisor. + set in the supervisor. </p> <p> If it is necessary to clean up before termination, the shutdown - strategy must be a time-out value and the <c>gen_statem</c> must - in the <c>init/1</c> function set itself to trap exit signals + strategy must be a time-out value and the <c>gen_statem</c> must + in function <c>init/1</c> set itself to trap exit signals by calling - <seealso marker="erts:erlang#process_flag/2"> - <c>process_flag(trap_exit, true)</c>. - </seealso> - When ordered to shutdown, the <c>gen_statem</c> then calls - the callback function - <c>terminate(shutdown, State, Data)</c>: + <seealso marker="erts:erlang#process_flag/2"><c>process_flag(trap_exit, true)</c></seealso>: </p> <code type="erl"><![CDATA[ init(Args) -> @@ -617,9 +590,13 @@ init(Args) -> ... ]]></code> <p> - In this example we let the <c>terminate/3</c> function - lock the door if it is open so we do not accidentally leave the door - open when the supervision tree terminates. + When ordered to shut down, the <c>gen_statem</c> then calls + callback function <c>terminate(shutdown, State, Data)</c>. + </p> + <p> + In the following example, function <c>terminate/3</c> + locks the door if it is open, so we do not accidentally leave the door + open when the supervision tree terminates: </p> <code type="erl"><![CDATA[ terminate(_Reason, State, _Data) -> @@ -633,9 +610,7 @@ terminate(_Reason, State, _Data) -> <p> If the <c>gen_statem</c> is not part of a supervision tree, it can be stopped using - <seealso marker="stdlib:gen_statem#stop/1"> - <c>gen_statem:stop</c>, - </seealso> + <seealso marker="stdlib:gen_statem#stop/1"><c>gen_statem:stop</c></seealso>, preferably through an API function: </p> <code type="erl"><![CDATA[ @@ -647,8 +622,8 @@ stop() -> gen_statem:stop(?NAME). ]]></code> <p> - This makes the <c>gen_statem</c> call the <c>terminate/3</c> - callback function just like for a supervised server + This makes the <c>gen_statem</c> call callback function + <c>terminate/3</c> just like for a supervised server and waits for the process to terminate. </p> </section> @@ -659,48 +634,41 @@ stop() -> <section> <title>Actions</title> <p> - In the first chapters we mentioned actions as a part of - the general state machine model, and these actions - are implemented with the code the <c>gen_statem</c> - callback module executes in an event handling + In the first sections actions were mentioned as a part of + the general state machine model. These general actions + are implemented with the code that callback module + <c>gen_statem</c> executes in an event-handling callback function before returning to the <c>gen_statem</c> engine. </p> <p> - There are more specific state transition actions + There are more specific state-transition actions that a callback function can order the <c>gen_statem</c> engine to do after the callback function return. These are ordered by returning a list of - <seealso marker="stdlib:gen_statem#type-action"> - actions - </seealso> + <seealso marker="stdlib:gen_statem#type-action">actions</seealso> in the - <seealso marker="stdlib:gen_statem#type-state_function_result"> - return tuple - </seealso> + <seealso marker="stdlib:gen_statem#type-state_function_result">return tuple</seealso> from the - <seealso marker="stdlib:gen_statem#Module:StateName/3"> - callback function. - </seealso> + <seealso marker="stdlib:gen_statem#Module:StateName/3">callback function</seealso>. These state transition actions affect the <c>gen_statem</c> - engine itself. They can: + engine itself and can do the following: </p> <list type="bulleted"> - <item>Postpone the current event.</item> - <item>Hibernate the <c>gen_statem</c>.</item> - <item>Start an event timeout.</item> - <item>Reply to a caller.</item> - <item>Generate the next event to handle.</item> + <item>Postpone the current event</item> + <item>Hibernate the <c>gen_statem</c></item> + <item>Start an event time-out</item> + <item>Reply to a caller</item> + <item>Generate the next event to handle</item> </list> <p> - We have mentioned the event timeout - and replying to a caller in the example above. - An example of event postponing comes in later in this chapter. - See the - <seealso marker="stdlib:gen_statem#type-action"> - reference manual - </seealso> - for details. You can for example actually reply to several callers + In the example earlier was mentioned the event time-out + and replying to a caller. + An example of event postponing is included later in this chapter. + For details, see the + <seealso marker="stdlib:gen_statem#type-action"><c>gen_statem(3)</c></seealso> + manual page. + You can, for example, reply to many callers and generate multiple next events to handle. </p> </section> @@ -710,38 +678,30 @@ stop() -> <section> <title>Event Types</title> <p> - So far we have mentioned a few - <seealso marker="stdlib:gen_statem#type-event_type"> - event types. - </seealso> + The previous sections mentioned a few + <seealso marker="stdlib:gen_statem#type-event_type">event types</seealso>. Events of all types are handled in the same callback function, for a given state, and the function gets <c>EventType</c> and <c>EventContent</c> as arguments. </p> <p> - Here is the complete list of event types and where + The following is a complete list of event types and where they come from: </p> <taglist> <tag><c>cast</c></tag> <item> Generated by - <seealso marker="stdlib:gen_statem#cast/2"> - <c>gen_statem:cast</c>. - </seealso> + <seealso marker="stdlib:gen_statem#cast/2"><c>gen_statem:cast</c></seealso>. </item> <tag><c>{call,From}</c></tag> <item> Generated by - <seealso marker="stdlib:gen_statem#call/2"> - <c>gen_statem:call</c> - </seealso> + <seealso marker="stdlib:gen_statem#call/2"><c>gen_statem:call</c></seealso>, where <c>From</c> is the reply address to use when replying either through the state transition action <c>{reply,From,Msg}</c> or by calling - <seealso marker="stdlib:gen_statem#reply/1"> - <c>gen_statem:reply</c>. - </seealso> + <seealso marker="stdlib:gen_statem#reply/1"><c>gen_statem:reply</c></seealso>. </item> <tag><c>info</c></tag> <item> @@ -750,15 +710,15 @@ stop() -> </item> <tag><c>timeout</c></tag> <item> - Generated by the state transition action + Generated by state transition action <c>{timeout,Time,EventContent}</c> (or its short form <c>Time</c>) timer timing out. </item> <tag><c>internal</c></tag> <item> - Generated by the state transition action + Generated by state transition action <c>{next_event,internal,EventContent}</c>. - In fact all event types above can be generated using + All event types above can also be generated using <c>{next_event,EventType,EventContent}</c>. </item> </taglist> @@ -767,34 +727,32 @@ stop() -> <!-- =================================================================== --> <section> - <title>State Timeouts</title> + <title>State Time-Outs</title> <p> - The timeout event generated by the state transition action - <c>{timeout,Time,EventContent}</c> is an event timeout, - that is; if an event arrives the timer is cancelled. - You get either an event or a timeout but not both. + The time-out event generated by state transition action + <c>{timeout,Time,EventContent}</c> is an event time-out, + that is, if an event arrives the timer is cancelled. + You get either an event or a time-out, but not both. </p> <p> - Often you want a timer to not be cancelled by any event + Often you want a timer not to be cancelled by any event or you want to start a timer in one state and respond - to the timeout in another. This can be accomplished - with a regular erlang timer: - <seealso marker="erts:erlang#start_timer/4"> - <c>erlang:start_timer</c>. - </seealso> + to the time-out in another. This can be accomplished + with a regular Erlang timer: + <seealso marker="erts:erlang#start_timer/4"><c>erlang:start_timer</c></seealso>. </p> <p> - Looking at the example in this chapter so far; using the + For the example so far in this chapter: using the <c>gen_statem</c> event timer has the consequence that if a button event is generated while in the <c>open</c> state, - the timeout is cancelled and the button event is delivered. - Therefore we chose to lock the door if this happended. + the time-out is cancelled and the button event is delivered. + So, we choose to lock the door if this occurred. </p> <p> - Suppose we do not want a button to lock the door, + Suppose that we do not want a button to lock the door, instead we want to ignore button events in the <c>open</c> state. Then we start a timer when entering the <c>open</c> state - and wait for it to expire while ignoring button events: + and waits for it to expire while ignoring button events: </p> <code type="erl"><![CDATA[ ... @@ -816,17 +774,15 @@ open(cast, {button,_}, Data) -> ... ]]></code> <p> - If you need to cancel a timer due to some other event you can use - <seealso marker="erts:erlang#cancel_timer/2"> - <c>erlang:cancel_timer(Tref)</c>. - </seealso> - Note that a timeout message can not arrive after this, + If you need to cancel a timer because of some other event, you can use + <seealso marker="erts:erlang#cancel_timer/2"><c>erlang:cancel_timer(Tref)</c></seealso>. + Notice that a time-out message cannot arrive after this, unless you have postponed it (see the next section) before, - so make sure you do not accidentally postpone such messages. + so ensure that you do not accidentally postpone such messages. </p> <p> - Another way to cancel a timer is to not cancel it, - but instead to ignore it if it arrives in a state + Another way to cancel a timer is not to cancel it, + but to ignore it if it arrives in a state where it is known to be late. </p> </section> @@ -839,19 +795,17 @@ open(cast, {button,_}, Data) -> If you want to ignore a particular event in the current state and handle it in a future state, you can postpone the event. A postponed event is retried after the state has - changed i.e <c>OldState =/= NewState</c>. + changed, that is, <c>OldState =/= NewState</c>. </p> <p> Postponing is ordered by the state transition - <seealso marker="stdlib:gen_statem#type-action"> - action - </seealso> + <seealso marker="stdlib:gen_statem#type-action">action</seealso> <c>postpone</c>. </p> <p> In this example, instead of ignoring button events - while in the <c>open</c> state we can postpone them - and they will be queued and later handled in the <c>locked</c> state: + while in the <c>open</c> state, we can postpone them + and they are queued and later handled in the <c>locked</c> state: </p> <code type="erl"><![CDATA[ ... @@ -861,16 +815,16 @@ open(cast, {button,_}, Data) -> ]]></code> <p> The fact that a postponed event is only retried after a state change - translates into a requirement on the event and state space: - if you have a choice between storing a state data item - in the <c>State</c> or in the <c>Data</c>; - should a change in the item value affect which events that - are handled, then this item ought to be part of the state. + translates into a requirement on the event and state space. + If you have a choice between storing a state data item + in the <c>State</c> or in the <c>Data</c>: + if a change in the item value affects which events that + are handled, then this item is to be part of the state. </p> <p> - What you want to avoid is that you maybe much later decide - to postpone an event in one state and by misfortune it is never retried - because the code only changes the <c>Data</c> but not the <c>State</c>. + You want to avoid that you maybe much later decide + to postpone an event in one state and by misfortune it is never retried, + as the code only changes the <c>Data</c> but not the <c>State</c>. </p> <section> @@ -883,7 +837,7 @@ open(cast, {button,_}, Data) -> or from the context. </p> <p> - Possible actions may be; ignore as in drop the event + Possible actions: ignore as in drop the event (maybe log it) or deal with the event in some other state as in postpone it. </p> @@ -892,10 +846,10 @@ open(cast, {button,_}, Data) -> <section> <title>Selective Receive</title> <p> - Erlang's selective receive statement is often used to - describe simple state machine examples in straightforward - Erlang code. Here is a possible implementation of - the first example: + Erlang's selective receive statement is often used to + describe simple state machine examples in straightforward + Erlang code. The following is a possible implementation of + the first example: </p> <code type="erl"><![CDATA[ -module(code_lock). @@ -937,33 +891,31 @@ do_unlock() -> io:format("Open~n", []). ]]></code> <p> - The selective receive in this case causes <c>open</c> - to implicitly postpone any events to the <c>locked</c> state. + The selective receive in this case causes implicitly <c>open</c> + to postpone any events to the <c>locked</c> state. </p> <p> - A selective receive can not be used from a <c>gen_statem</c> - behaviour just as for any <c>gen_*</c> behavior - since the receive statement is within the <c>gen_*</c> engine itself. - It has to be there because all + A selective receive cannot be used from a <c>gen_statem</c> + behavior as for any <c>gen_*</c> behavior, + as the receive statement is within the <c>gen_*</c> engine itself. + It must be there because all <seealso marker="stdlib:sys"><c>sys</c></seealso> - compatible behaviours must respond to system messages and therefore + compatible behaviors must respond to system messages and therefore do that in their engine receive loop, passing non-system messages to the callback module. </p> <p> The state transition - <seealso marker="stdlib:gen_statem#type-action"> - action - </seealso> - <c>postpone</c> is designed to be able to model - selective receives. A selective receive implicitly postpones + <seealso marker="stdlib:gen_statem#type-action">action</seealso> + <c>postpone</c> is designed to model + selective receives. A selective receive implicitly postpones any not received events, but the <c>postpone</c> state transition action explicitly postpones one received event. </p> <p> - Other than that both mechanisms have got the same theoretical + Both mechanisms have the same theoretical time and memory complexity, while the selective receive - language construct has got smaller constant factors. + language construct has smaller constant factors. </p> </section> </section> @@ -971,43 +923,39 @@ do_unlock() -> <!-- =================================================================== --> <section> - <title>Self Generated Events</title> + <title>Self-Generated Events</title> <p> - It may be beneficial in some cases to be able to generate events + It can sometimes be beneficial to be able to generate events to your own state machine. This can be done with the state transition - <seealso marker="stdlib:gen_statem#type-action"> - action - </seealso> + <seealso marker="stdlib:gen_statem#type-action">action</seealso> <c>{next_event,EventType,EventContent}</c>. </p> <p> You can generate events of any existing - <seealso marker="stdlib:gen_statem#type-action"> - type, - </seealso> - but the <c>internal</c> type can only be generated through the - <c>next_event</c> action and hence can not come from an external source, + <seealso marker="stdlib:gen_statem#type-action">type</seealso>, + but the <c>internal</c> type can only be generated through action + <c>next_event</c>. Hence, it cannot come from an external source, so you can be certain that an <c>internal</c> event is an event from your state machine to itself. </p> <p> - One example of using self generated events may be when you have + One example of using self-generated events can be when you have a state machine specification that uses state entry actions. - That you could code using a dedicated function - to do the state transition. But if you want that code to be - visible besides the other state logic you can insert + You can code that using a dedicated function + to do the state transition. But if you want that code to be + visible besides the other state logic, you can insert an <c>internal</c> event that does the entry actions. This has the same unfortunate consequence as using - state transition functions that everywhere you go to - the state in question you will have to explicitly + state transition functions: everywhere you go to + the state, you must explicitly insert the <c>internal</c> event - or use state transition function. + or use a state transition function. </p> <p> - Here is an implementation of entry actions + The following is an implementation of entry actions using <c>internal</c> events with content <c>enter</c> - utilizing a helper function <c>enter/3</c> for state entry: + using a helper function <c>enter/3</c> for state entry: </p> <code type="erl"><![CDATA[ ... @@ -1051,20 +999,20 @@ enter(Tag, State, Data) -> <section> <title>Example Revisited</title> <p> - Here is the example after all mentioned modifications - and some more utilizing the entry actions, + This section includes the example after all mentioned modifications + and some more using the entry actions, which deserves a new state diagram: </p> <image file="../design_principles/code_lock_2.png"> - <icaption>Code lock state diagram revisited</icaption> + <icaption>Code Lock State Diagram Revisited</icaption> </image> <p> - Note that this state diagram does not specify how to handle - a button event in the state <c>open</c>, so you will have to - read some other place that is here that unspecified events - shall be ignored as in not consumed but handled in some other state. - Nor does it show that the <c>code_length/0</c> call shall be - handled in every state. + Notice that this state diagram does not specify how to handle + a button event in the state <c>open</c>. So, you need to + read somewhere else that unspecified events + must be ignored as in not consumed but handled in some other state. + Also, the state diagram does not show that the <c>code_length/0</c> + call must be handled in every state. </p> <section> @@ -1147,10 +1095,11 @@ code_change(_Vsn, State, Data, _Extra) -> <section> <title>Callback Mode: handle_event_function</title> <p> - What to change to use one <c>handle_event/4</c> function. - Here a clean first-dispatch-on-event approach - does not work that well due to the generated - entry actions: + This section describes what to change in the example + to use one <c>handle_event/4</c> function. + The previously used clean first-dispatch-on-event approach + does not work that well here because of the generated + entry actions so this example dispatches on state first: </p> <code type="erl"><![CDATA[ ... @@ -1195,7 +1144,7 @@ handle_event({call,From}, code_length, _State, #{code := Code}) -> ]]></code> </section> <p> - Note that postponing buttons from the <c>locked</c> state + Notice that postponing buttons from the <c>locked</c> state to the <c>open</c> state feels like the wrong thing to do for a code lock, but it at least illustrates event postponing. </p> @@ -1206,33 +1155,29 @@ handle_event({call,From}, code_length, _State, #{code := Code}) -> <section> <title>Filter the State</title> <p> - The example servers so far in this chapter will for example - when killed by an exit signal or due to an internal error - print out the full internal state in the error log. + The example servers so far in this chapter + print the full internal state in the error log, for example, + when killed by an exit signal or because of an internal error. This state contains both the code lock code - and which digits that remains to unlock. + and which digits that remain to unlock. </p> <p> This state data can be regarded as sensitive, and maybe not what you want in the error log - because of something unpredictable happening. + because of some unpredictable event. </p> <p> Another reason to filter the state can be - that the state is too big to print out since it fills + that the state is too large to print, as it fills the error log with uninteresting details. </p> <p> - To avoid this you can format the internal state + To avoid this, you can format the internal state that gets in the error log and gets returned from - <seealso marker="stdlib:sys#get_status/1"> - <c>sys:get_status/1,2</c> - </seealso> - by implementing the - <seealso marker="stdlib:gen_statem#Module:format_status/2"> - <c>Module:format_status/2</c> - </seealso> - function, for example like this: + <seealso marker="stdlib:sys#get_status/1"><c>sys:get_status/1,2</c></seealso> + by implementing function + <seealso marker="stdlib:gen_statem#Module:format_status/2"><c>Module:format_status/2</c></seealso>, + for example like this: </p> <code type="erl"><![CDATA[ ... @@ -1257,12 +1202,10 @@ format_status(Opt, [_PDict,State,Data]) -> ]]></code> <p> It is not mandatory to implement a - <seealso marker="stdlib:gen_statem#Module:format_status/2"> - <c>Module:format_status/2</c> - </seealso> - function. If you do not a default implementation is used that + <seealso marker="stdlib:gen_statem#Module:format_status/2"><c>Module:format_status/2</c></seealso> + function. If you do not, a default implementation is used that does the same as this example function without filtering - the <c>Data</c> term that is: <c>StateData = {State,Data}</c>. + the <c>Data</c> term, that is, <c>StateData = {State,Data}</c>. </p> </section> @@ -1272,57 +1215,54 @@ format_status(Opt, [_PDict,State,Data]) -> <title>Complex State</title> <p> The callback mode - <seealso marker="stdlib:gen_statem#type-callback_mode"> - <c>handle_event_function</c> - </seealso> - enables using a non-atom state as described in - <seealso marker="#callback_modes"> - Callback Modes, - </seealso> - for example a complex state term like a tuple. + <seealso marker="stdlib:gen_statem#type-callback_mode"><c>handle_event_function</c></seealso> + enables using a non-atom state as described in section + <seealso marker="#callback_modes">Callback Modes</seealso>, + for example, a complex state term like a tuple. </p> <p> One reason to use this is when you have - a state item that affects the event handling - in particular when combining that with postponing events. - Let us complicate the previous example + a state item that affects the event handling, + in particular in combination with postponing events. + We complicate the previous example by introducing a configurable lock button - (this is the state item in question) - that in the <c>open</c> state immediately locks the door, + (this is the state item in question), + which in the <c>open</c> state immediately locks the door, and an API function <c>set_lock_button/1</c> to set the lock button. </p> <p> Suppose now that we call <c>set_lock_button</c> while the door is open, and have already postponed a button event - that up until now was not the lock button; - the sensible thing might be to say that - the button was pressed too early so it should - not be recognized as the lock button, - but then it might be surprising that a button event + that until now was not the lock button. + The sensible thing can be to say that + the button was pressed too early so it is + not to be recognized as the lock button. + However, then it can be surprising that a button event that now is the lock button event arrives (as retried postponed) immediately after the state transits to <c>locked</c>. </p> <p> - So let us make the <c>button/1</c> function synchronous - by using <c>gen_statem:call</c>, + So we make the <c>button/1</c> function synchronous + by using + <seealso marker="stdlib:gen_statem#call/2"><c>gen_statem:call</c></seealso> and still postpone its events in the <c>open</c> state. Then a call to <c>button/1</c> during the <c>open</c> - state will not return until the state transits to <c>locked</c> - since it is there the event is handled and the reply is sent. + state does not return until the state transits to <c>locked</c>, + as it is there the event is handled and the reply is sent. </p> <p> - If now one process calls <c>set_lock_button/1</c> - to change the lock button while some other process - hangs in <c>button/1</c> with the new lock button - it could be expected that the hanging lock button call + If a process now calls <c>set_lock_button/1</c> + to change the lock button while another process + hangs in <c>button/1</c> with the new lock button, + it can be expected that the hanging lock button call immediately takes effect and locks the lock. - Therefore we make the current lock button a part of the state - so when we change the lock button the state will change - and all postponed events will be retried. + Therefore, we make the current lock button a part of the state, + so that when we change the lock button, the state changes + and all postponed events are retried. </p> <p> - We define the state as <c>{StateName,LockButton}</c> + We define the state as <c>{StateName,LockButton}</c>, where <c>StateName</c> is as before and <c>LockButton</c> is the current lock button: </p> @@ -1441,10 +1381,9 @@ format_status(Opt, [_PDict,State,Data]) -> end. ]]></code> <p> - It may be an ill-fitting model for a physical code lock - that the <c>button/1</c> call might hang until the lock - is locked. But for an API in general it is really not - that strange. + It can be an ill-fitting model for a physical code lock + that the <c>button/1</c> call can hang until the lock + is locked. But for an API in general it is not that strange. </p> </section> @@ -1457,26 +1396,21 @@ format_status(Opt, [_PDict,State,Data]) -> and they have some state(s) in their lifetime in which the servers can be expected to idle for a while, and the amount of heap memory all these servers need - is a problem; then it is possible to minimize - the memory footprint of a server by hibernating it through - <seealso marker="stdlib:proc_lib#hibernate/3"> - <c>proc_lib:hibernate/3</c>. - </seealso> + is a problem, then the memory footprint of a server + can be mimimized by hibernating it through + <seealso marker="stdlib:proc_lib#hibernate/3"><c>proc_lib:hibernate/3</c></seealso>. </p> <note> <p> - To hibernate a process is rather costly. See - <seealso marker="erts:erlang#hibernate/3"> - <c>erlang:hibernate/3</c>. - </seealso> - It is in general not something you want to do - after every event. + It is rather costly to hibernate a process; see + <seealso marker="erts:erlang#hibernate/3"><c>erlang:hibernate/3</c></seealso>. + It is not something you want to do after every event. </p> </note> <p> - We can in this example hibernate in the <c>{open,_}</c> state - since what normally happens in that state is that - the state timeout after a while + We can in this example hibernate in the <c>{open,_}</c> state, + because what normally occurs in that state is that + the state time-out after a while triggers a transition to <c>{locked,_}</c>: </p> <code type="erl"><![CDATA[ @@ -1493,29 +1427,27 @@ handle_event( ]]></code> <p> The - <seealso marker="stdlib:gen_statem#type-hibernate"> - <c>[hibernate]</c> - </seealso> + <seealso marker="stdlib:gen_statem#type-hibernate"><c>[hibernate]</c></seealso> action list on the last line when entering the <c>{open,_}</c> state is the only change. - If any event arrives in the <c>{open,_},</c> state we - do not bother to re-hibernate, so the server stays + If any event arrives in the <c>{open,_},</c> state, we + do not bother to rehibernate, so the server stays awake after any event. </p> <p> To change that we would need to insert - the <c>hibernate</c> action in more places, - for example for the state independent <c>set_lock_button</c> + action <c>hibernate</c> in more places. + For example, for the state-independent <c>set_lock_button</c> and <c>code_length</c> operations that then would have to be aware of using <c>hibernate</c> while in the - <c>{open,_}</c> state which would clutter the code. + <c>{open,_}</c> state, which would clutter the code. </p> <p> - This server probably does not use an amount of + This server probably does not use heap memory worth hibernating for. - To gain anything from hibernation your server would - have to actually produce some garbage during callback execution, - for which this example server may serve as a bad example. + To gain anything from hibernation, your server would + have to produce some garbage during callback execution, + for which this example server can serve as a bad example. </p> </section> diff --git a/system/doc/reference_manual/code_loading.xml b/system/doc/reference_manual/code_loading.xml index e9da40e02f..f6fd2911fa 100644 --- a/system/doc/reference_manual/code_loading.xml +++ b/system/doc/reference_manual/code_loading.xml @@ -130,26 +130,6 @@ loop() -> <marker id="on_load"></marker> <title>Running a Function When a Module is Loaded</title> - <warning> - <p>The <c>on_load</c> feature is to be considered experimental - as there are a number of known weak points in current semantics, - which therefore might change in future Erlang/OTP releases:</p> - <list> - <item><p>Doing external call in <c>on_load</c> to the module itself - leads to deadlock.</p></item> - <item><p>At module upgrade, other processes calling the module - get suspended waiting for <c>on_load</c> to finish. This can be very bad - for applications with demands on realtime characteristics.</p></item> - <item><p>At module upgrade, no rollback is done if the - <c>on_load</c> function fails. - The system is left in a bad limbo state without any working - and reachable instance of the module.</p></item> - </list> - <p>The problems with module upgrade described above can be fixed in future - Erlang/OTP releases by changing the behaviour to not make the module reachable until - after the <c>on_load</c> function has successfully returned.</p> - </warning> - <p>The <c>-on_load()</c> directive names a function that is to be run automatically when a module is loaded.</p> <p>Its syntax is as follows:</p> @@ -159,20 +139,35 @@ loop() -> <p>It is not necessary to export the function. It is called in a freshly spawned process (which terminates as soon as the function - returns). The function must return <c>ok</c> if the module is to - remain loaded and become callable, or any other value if the module - is to be unloaded. Generating an exception also causes the - module to be unloaded. If the return value is not an atom, - a warning error report is sent to the error logger.</p> - - <p>A process that calls any function in a module whose <c>on_load</c> - function has not yet returned, is suspended until the <c>on_load</c> - function has returned.</p> + returns).</p> + + <p>The function must return <c>ok</c> if the module is to + become the new current code for the module and become + callable.</p> + + <p>Returning any other value or generating an exception + causes the new code to be unloaded. If the return value is not an + atom, a warning error report is sent to the error logger.</p> + + <p>If there already is current code for the module, that code will + remain current and can be called until the <c>on_load</c> function + has returned. If the <c>on_load</c> function fails, the current + code (if any) will remain current. If there is no current code for + a module, any process that makes an external call to the module + before the <c>on_load</c> function has finished will be suspended + until the <c>on_load</c> function have finished.</p> + + <note> + <p>Before OTP 19, if the <c>on_load</c> function failed, any + previously current code would become old, essentially leaving + the system without any working and reachable instance of the + module. That problem has been eliminated in OTP 19.</p> + </note> <p>In embedded mode, first all modules are loaded. Then all <c>on_load</c> functions are called. The system is terminated unless all of the <c>on_load</c> functions return - <c>ok</c></p>. + <c>ok</c>.</p> <p><em>Example:</em></p> diff --git a/system/doc/reference_manual/macros.xml b/system/doc/reference_manual/macros.xml index 42ea639b54..350bb1d123 100644 --- a/system/doc/reference_manual/macros.xml +++ b/system/doc/reference_manual/macros.xml @@ -234,6 +234,53 @@ or </section> <section> + <title>-error() and -warning() directives</title> + + <p>The directive <c>-error(Term)</c> causes a compilation error.</p> + + <p><em>Example:</em></p> + <code type="none"> +-module(t). +-export([version/0]). + +-ifdef(VERSION). +version() -> ?VERSION. +-else. +-error("Macro VERSION must be defined."). +version() -> "". +-endif.</code> + + <p>The error message will look like this:</p> + + <pre> +% <input>erlc t.erl</input> +t.erl:7: -error("Macro VERSION must be defined.").</pre> + + <p>The directive <c>-warning(Term)</c> causes a compilation warning.</p> + + <p><em>Example:</em></p> + <code type="none"> +-module(t). +-export([version/0]). + +-ifndef(VERSION). +-warning("Macro VERSION not defined -- using default version."). +-define(VERSION, "0"). +-endif. +version() -> ?VERSION.</code> + + <p>The warning message will look like this:</p> + + <pre> +% <input>erlc t.erl</input> +t.erl:5: Warning: -warning("Macro VERSION not defined -- using default version.").</pre> + + <p>The <c>-error()</c> and <c>-warning()</c> directives were added + in OTP 19.</p> + + </section> + + <section> <title>Stringifying Macro Arguments</title> <p>The construction <c>??Arg</c>, where <c>Arg</c> is a macro argument, is expanded to a string containing the tokens of @@ -253,5 +300,6 @@ io:format("Call ~s: ~w~n",["you : function ( 2 , 1 )",you:function(2,1)]).</code <p>That is, a trace output, with both the function called and the resulting value.</p> </section> + </chapter> |